- Joined
- Jan 11, 2009
- Messages
- 3,414
Hello guys! I'm working on a custom resource harvesting system which replaces the standard wc3 resources with custom ones, to support more than 2 resources. Naturally, this also requires a custom way to enforce costs when producing units, which i have also managed to do.
Now, my final problem is that repairing and assisting construction (aka. powerbuilding) will also have to use the custom resources. Unfortunately, it appears that the standard repair ability is channeling, and there is no way of tracing when an individual batch of hit points has been added to the unit. I need to find some kind of workaround for this. Here are the ideas i've been throwing around so far:
1. Replacing the repair ability with a custom one, with cooldown instead of channeling. Intercept when a unit starts casting it, and start a timer which will repeatedly order it to cast it until either ordered otherwise, or the unit is complete. For every time that the ability is cast, resoruces are deducted and the construction state/health amount is increased.
Cons: the build animation will not display properly when the constructon state is set manually. Lots of work overall.
2. Start a timer with 1 second repeating interval everytime a unit starts casting the standard repair spell. Deduct the cost every cycle. If the unit starts casting some other ability, the timer is paused. If the player runs out of resources, the unit is ordered to stop.
Cons: it feels kinda wonky to not know how many hit points have actually been added, and just deduct the resources "on faith". If the player runs out of resources, all units engaged in construction will stop and not resume once more resources are gained, unless explicitly ordered to do so.
Which way do you think would be the best? Is there a third, better way? Are there any other problems with these methods?
Now, my final problem is that repairing and assisting construction (aka. powerbuilding) will also have to use the custom resources. Unfortunately, it appears that the standard repair ability is channeling, and there is no way of tracing when an individual batch of hit points has been added to the unit. I need to find some kind of workaround for this. Here are the ideas i've been throwing around so far:
1. Replacing the repair ability with a custom one, with cooldown instead of channeling. Intercept when a unit starts casting it, and start a timer which will repeatedly order it to cast it until either ordered otherwise, or the unit is complete. For every time that the ability is cast, resoruces are deducted and the construction state/health amount is increased.
Cons: the build animation will not display properly when the constructon state is set manually. Lots of work overall.
2. Start a timer with 1 second repeating interval everytime a unit starts casting the standard repair spell. Deduct the cost every cycle. If the unit starts casting some other ability, the timer is paused. If the player runs out of resources, the unit is ordered to stop.
Cons: it feels kinda wonky to not know how many hit points have actually been added, and just deduct the resources "on faith". If the player runs out of resources, all units engaged in construction will stop and not resume once more resources are gained, unless explicitly ordered to do so.
Which way do you think would be the best? Is there a third, better way? Are there any other problems with these methods?