• 🏆 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!

GetOrderTargetDestructalbe problems

Status
Not open for further replies.
Hello everyone,

I have been trying for some time to make a custom resource system. The greatest issue so far has been the part where you intercept the order to target the resource.

Since spells cannot be made to target trees unless they were made to do so (ex. sentinel, eat tree), and the spells that can have great drawbacks (kills the destructable or can only be used once per destructable), i decided to use normal destructables for the resources. Whenever a unit is ordered to attack them, the order is changed to either "move" (if the unit is not a harvester) or to a custom harvest ability (if the unit is a harvester). Harvesters need to be able to attack destructables for players to use right-click orders. So far it works quite well.

The problem occurs when a unit is ordered to attack a destructable which is outside the players vision, using a right click "smart" order. Somehow, i cannot retrieve a target destructable from this order. With some experimentation, i found that this counts as a "point" order rather than a "target" order.

My solution was to use a small rect, which i move to the location of the smart order, and then simply enum all destructables in this rect and set the first of them as the target of the order. This works sometimes, and only for some destructables. It also doesn't work at the start of the game, but rather after a minute or two, and i have no idea how this comes.

I thought the issue might be related to the pathing of the destructable. I tried tampering with them to no result.

Does anyone have suggestions as to how to solve this? Any reliable solutions to retrieving the target destructable of a smart order are welcome. My system is great apart from this flaw and can support an arbitrary amount of resource types, supports intuitive features to make a unit drop a resource on death (can be used for harvestable animals, stone rubble resource for destroyed buildings, etc.), a large set of trigger events to add your own functionality, and much more. Thanks in advance.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I can only think of a workaround now.

1)If order is a smart order,
2)if ordering unit is a harvester,
3)if order point is in fog of war to harvester player

Pick destructables with 32 aoe (this number needs to be 32 or higher, 32 is good.) around target point.If there is a valid destructable picked, it is your target tree.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I tested before I posted that message and it was working I guess, maybe your resource destructables have different collision sizes?
 

Attachments

  • fog smart tree.w3x
    20 KB · Views: 40
Level 12
Joined
Feb 22, 2010
Messages
1,115
Yeah sorry, I meant pathing.I will test with destructables with different pathing too, it would be good if someone else look into issue.
 
Status
Not open for further replies.
Top