Timed life for certein units

Status
Not open for further replies.
Level 2
Joined
Mar 2, 2012
Messages
4
I am currently working on a larger map and I would like some help.

Im trying to create a timed life for a milita type unit on the map, That is to say peasent arming them self and after a time dying, not reverting back to peasents but actually dying

any and all help would be appreciated
 
Level 11
Joined
Jun 2, 2004
Messages
849
  • Events
    • Unit - A unit enters (Entire map)
  • Conditions
    • (Unit-type of (Triggering unit)) Equal to Militia
  • Actions
    • Unit - Add a 60.00 second Generic expiration timer to (Triggering unit)
The event is "Unit enters region", near the bottom of events.
The condition is the Unit-type comparison.
The action is "Unit - Add Expiration Timer" action, which you can find in the unit section.
 
That was little bit tricky cause there is no real event for the transformation of the peasent -> militia.

This works according to my testings, if you use the default warcraft 3 human worker mechanic.
If an townhall uses the get to arms skill: add affected workers into a group. I call the group militiaRecruting
Or if an worker uses the militia skill add it to a group.
Frequently enum the group checking, if they became a non worker = success.
Check for beeing dead or changed the order => kick out of group.
GetToArms used from townhall and used from the worker have different orders that's why one has to check for 2 orders inside the loop.

Below you see the triggers which perform this behaviour and a downloadable testmap.
  • To Arms Townhall
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(townbellon))
    • Actions
      • Set Loc = (Position of (Triggering unit))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 2000.00 of Loc) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to (Owner of (Triggering unit))
              • ((Picked unit) is A peon-type unit) Equal to True
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: Found worker
              • Unit Group - Add (Picked unit) to MilitiaRecruting
              • Trigger - Turn on Militia Recruting <gen>
            • Else - Actions
      • Custom script: call RemoveLocation(udg_Loc)
  • To Arms Worker
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(militia))
    • Actions
      • Unit Group - Add (Triggering unit) to MilitiaRecruting
      • Trigger - Turn on Militia Recruting <gen>
  • Militia Recruting
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in MilitiaRecruting and do (Actions)
        • Loop - Actions
          • -------- Worker Transformed? --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A peon-type unit) Equal to False
            • Then - Actions
              • -------- Yes, apply timed life and kick him from recuting group --------
              • Unit Group - Remove (Picked unit) from MilitiaRecruting
              • Unit - Add a 20.00 second Generic expiration timer to (Picked unit)
            • Else - Actions
              • Custom script: set udg_OrderId = GetUnitCurrentOrder(GetEnumUnit())
              • -------- Died / interuppted? --------
              • -------- If the unit is stuned (order = 851973) or still performs the to arms order it is keeped in the group. --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • ((Picked unit) is dead) Equal to True
                      • And - All (Conditions) are true
                        • Conditions
                          • (Current order of (Picked unit)) Not equal to (Order(militia))
                          • (Current order of (Picked unit)) Not equal to (Order(militiaconvert))
                          • OrderId Not equal to 851973
                • Then - Actions
                  • Unit Group - Remove (Picked unit) from MilitiaRecruting
                • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (MilitiaRecruting is empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
 

Attachments

  • To arms.w3x
    18.6 KB · Views: 46
Last edited:
Status
Not open for further replies.
Top