• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Pick all Trees and do X

Status
Not open for further replies.
Level 23
Joined
Oct 12, 2008
Messages
1,783
I am trying to pick every tree on the map and their location for later reference.
- As far as I know, you cannot save destructibles into groups for later referencing.

As such, is it more 'practical' to pick all destructibles as and when I need them, or should I pick once - and save their locations in a vast point array for later use?
 
It's more practical no cache nothing, and to PickAllDestructables just when needed. In general it can make things simple, which is good.
But if it has much less performance, and might be not good if it's a huge map, and/or there are very much destructables placed.
So if it has worse performance, and happens periodically, or just very often in a time frame, then it could become bad for map.

I would cache destructables/trees per se though, not just their locations. One can directly check if destructable is dead, for example.

===

More work, but great performance boost, if needed, would be to use arrays.

Trees = Destroctable[array]
TreesCounter = Integer

Map Start
Code:
PickAllDestructbleOnMap
-- if (Destructable Is A Tree == True)
-- -- TreeCounter = TreeCounter + 1
-- -- Trees[TreeCounter] = Destructable

Then later, you can always loop through Trees:
Code:
For Integer I from 1 To TreeCounter
-- Location = (Position of Trees[I])

When new trees are created you need to adjust the array:
Code:
Destructable - CreateTree(  ... )
TreeCounter = TreeCounter + 1
Trees[TreeCounter] = LastCreatedDestructable()

When trees are dead, you need to adjust the array. Though, it can be done in looo, so just at at next usage. So we adjust the usage loop:
Code:
For Integer I from 1 To TreeCounter
-- If ( Tree[I] Is Dead != True
-- -- Location = (Position of Trees[I])
-- Else
-- -- Set Tree[I] = Tree[TreeCounter]
-- -- Set I = I - 1
^what happens is we moved the last tree in array to current position. And then we decrease loop counter, to try again at same position.

There are systems to get to know if a destructable is a tree, in case you haven't included one, yet. :thumbs_up:
 
Status
Not open for further replies.
Top