I've been working on a system to make peasants and peons drop their gold-sack upon death. It is a little bit flimsy in my opinion as there is no way to detect the moment that the harvest/resumeharvesting order is completed, still I am happy enough with what I have to consider implementing it with the exception of one thing that I am asking for help with.
Here's what I have
As it is the problem is that the worker doesn't receive the harvest order when they can't find their previous mine. My hope was that they would look for the nearest mine if it was close enough no they do not. Can I detect the animation change? I have looked around for something like that (GUI) but have had no luck.
Edit: [trigger][/trigger] tag learning curve. Please excuse my inexperience.
Here's what I have
-
Exit Mine
-
Events
- Unit - A unit Is issued an order targeting an object
-
Conditions
- (Issued order) Equal to (Order(resumeharvesting))
-
Or - Any (Conditions) are true
-
Conditions
- (Unit-type of (Ordered unit)) Equal to Peon
- (Unit-type of (Ordered unit)) Equal to Peasant
-
Conditions
-
Actions
-
Unit Group - Pick every unit in (Units of type Gold Mine) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Distance between (Position of (Ordered unit)) and (Position of (Picked unit))) Less than or equal to 256.00
-
Then - Actions
- Unit - Set the custom value of (Ordered unit) to -1
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Unit Group - Pick every unit in (Units of type Dropped) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Resource quantity contained in (Picked unit)) Equal to 1
- (Distance between (Position of (Ordered unit)) and (Position of (Picked unit))) Less than or equal to 128.00
- (Custom value of (Ordered unit)) Not equal to -1
-
Then - Actions
- Unit - Set the custom value of (Ordered unit) to -1
-
Unit Group - Pick every unit in (Units within 128.00 of (Position of (Picked unit)) matching (((Unit-type of (Matching unit)) Equal to Dropped) and ((Custom value of (Matching unit)) Equal to ((Custom value of (Picked unit)) + 1)))) and do (Actions)
-
Loop - Actions
- Unit - Remove (Picked unit) from the game
-
Loop - Actions
- Unit - Remove (Picked unit) from the game
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Unit Group - Pick every unit in (Units of type Gold Mine) and do (Actions)
-
Events
-
Drop Gold
-
Events
- Unit - A unit Dies
-
Conditions
- (Custom value of (Dying unit)) Equal to -1
-
Or - Any (Conditions) are true
-
Conditions
- (Unit-type of (Dying unit)) Equal to Peon
- (Unit-type of (Dying unit)) Equal to Peasant
-
Conditions
-
Actions
- Unit - Create 1 Dropped for Neutral Passive at (Position of (Dying unit)) facing Default building facing degrees
- Neutral Building - Set (Last created unit) to 11 gold
- Unit - Set the custom value of (Last created unit) to (GoldPair x 2)
- Animation - Change (Last created unit)'s size to (0.01%, 0.01%, 0.01%) of its original size
- Unit - Create 1 Dropped for Neutral Passive at (Position of (Dying unit)) facing Default building facing degrees
- Neutral Building - Set (Last created unit) to 10 gold
- Unit - Set the custom value of (Last created unit) to ((GoldPair x 2) + 1)
- Set GoldPair = (GoldPair + 1)
-
Events
-
Switch Gold
-
Events
- Unit - A unit Is issued an order targeting an object
-
Conditions
- (Unit-type of (Target unit of issued order)) Equal to Dropped
- (Resource quantity contained in (Target unit of issued order)) Equal to 10
-
Or - Any (Conditions) are true
-
Conditions
- (Unit-type of (Ordered unit)) Equal to Peon
- (Unit-type of (Ordered unit)) Equal to Peasant
-
Conditions
-
Actions
-
Unit Group - Pick every unit in (Units within 128.00 of (Position of (Target unit of issued order)) matching (((Unit-type of (Matching unit)) Equal to Dropped) and ((Custom value of (Matching unit)) Equal to ((Custom value of (Target unit of issued order)) - 1)))) and do (Actions)
-
Loop - Actions
- Unit - Order (Ordered unit) to Harvest (Picked unit)
-
Loop - Actions
-
Unit Group - Pick every unit in (Units within 128.00 of (Position of (Target unit of issued order)) matching (((Unit-type of (Matching unit)) Equal to Dropped) and ((Custom value of (Matching unit)) Equal to ((Custom value of (Target unit of issued order)) - 1)))) and do (Actions)
-
Events
-
Reset Harvest
-
Events
- Unit - A unit Is issued an order targeting an object
-
Conditions
-
Or - Any (Conditions) are true
-
Conditions
- (Unit-type of (Target unit of issued order)) Equal to Gold Mine
- (Unit-type of (Target unit of issued order)) Equal to Dropped
-
Conditions
-
Or - Any (Conditions) are true
-
Conditions
- (Issued order) Equal to (Order(harvest))
- (Issued order) Equal to (Order(smart))
-
Conditions
-
Or - Any (Conditions) are true
-
Conditions
- (Unit-type of (Ordered unit)) Equal to Peon
- (Unit-type of (Ordered unit)) Equal to Peasant
-
Conditions
-
Or - Any (Conditions) are true
-
Actions
- Unit - Set the custom value of (Ordered unit) to 0
-
Events
As it is the problem is that the worker doesn't receive the harvest order when they can't find their previous mine. My hope was that they would look for the nearest mine if it was close enough no they do not. Can I detect the animation change? I have looked around for something like that (GUI) but have had no luck.
Edit: [trigger][/trigger] tag learning curve. Please excuse my inexperience.
Last edited: