- Joined
- Jan 11, 2009
- Messages
- 3,414
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.
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.