- Joined
- Sep 25, 2013
- Messages
- 717
Hello, i've been working on my own custom resource system with an additional resource. Its been a very complex process and i have mostly got it under control but i am having problem. This trigger is supposed to order workers to continue attacking (harvesting) more of the same resource in the general area after they have used up all the resources (killed) of the resource they are attacking.
The problem is that some of the workers continue on to another resource while others become idle. The range shouldn't be the problem since i make sure there are plenty of resources around and within 300 range. Is there a better way i can do what I'm trying to do? Thank you for your time
Code:
Slaughtered Pig Continue
Events
Unit - A unit Dies
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Triggering unit)) Equal to Slaughtered Pig (Nature)
Then - Actions
Set tempUnitGroup = (Units within 300.00 of (Position of (Triggering unit)) matching (((Matching unit) has buff Worker (All)) Equal to True))
Unit Group - Pick every unit in tempUnitGroup and do (Actions)
Loop - Actions
Set tempUnitGroup2 = (Units within 300.00 of (Position of (Picked unit)) matching ((Unit-type of (Matching unit)) Equal to Slaughtered Pig (Nature)))
Unit - Order (Picked unit) to Attack (Random unit from tempUnitGroup2)
Custom script: call DestroyGroup (udg_tempUnitGroup2)
Custom script: call DestroyGroup (udg_tempUnitGroup)
Unit - Remove (Triggering unit) from the game
Else - Actions
The problem is that some of the workers continue on to another resource while others become idle. The range shouldn't be the problem since i make sure there are plenty of resources around and within 300 range. Is there a better way i can do what I'm trying to do? Thank you for your time