• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Mixing Units (into a better one)

Status
Not open for further replies.
Level 4
Joined
Aug 7, 2008
Messages
115
I want to know ,how to make lot of units of the same type enter in a specific region and becomes another unit stronger

example : 3 militia enters in a region and becomes 1 footman
 
Level 8
Joined
May 27, 2007
Messages
170
Reminds me of good ole' commando wars :D

Anyhoo, here's how I would do it basically:

  • Untitled Trigger 001
    • Events
      • Unit - A unit enters (Your Region) <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Militia
    • Actions
      • Unit Group - Add (Triggering unit) to MilitiaUnitGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in MilitiaUnitGroup) Equal to 3
        • Then - Actions
          • Unit Group - Pick every unit in MilitiaUnitGroup and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
              • Unit Group - Remove all units of MilitiaUnitGroup from MilitiaUnitGroup
              • Unit - Create 1 Footman for (Owner of (Triggering unit)) at (Center of Region 000 <gen>) facing Default building facing degrees
        • Else - Actions
          • Do nothing
That should work in the majority of cases. Might get buggered if you have a ridiculous amount of militia pouring into the region at once but it would take me a while to figure out a more effective and reliable way of doing it.

MilitiaUnitGroup is just a simple Unit Group variable.
 
Level 4
Joined
Aug 7, 2008
Messages
115
Hmm nice post, thanks ill try it later if it works i change to solved and i reply! cya

Well i tested and didnt work. =/
Look
mixingunitseb0.jpg


Check it and reply,THANKS !

is my mixunitgroup correct ? it is unit group...maybe the problem is the initial value !
 
Last edited by a moderator:
Level 9
Joined
Jun 26, 2007
Messages
659
example : 3 militia enters in a region and becomes 1 footman

global variable : integer militia_count (default value : 0)

  • Militia enter a region
    • Events
      • Unit - A unit enters a region <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Militia
    • Actions
      • Custom script: local location udg_tmploc
      • Set militia_count = (militia_count + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • militia_count Equal to 3
        • Then - Actions
          • Unit group - Pick every unit in (Units in a region <gen>) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Equal to Militia
                • Then - Actions
                  • Unit - Remove (Picked unit) from the game
          • Set tmploc = (Center of a region <gen>)
          • Unit - Create 1 Footman for (Owner of (Triggering unit)) at tmploc facing 0.00 degrees
          • Custom script: call RemoveLocation(udg_tmploc)
          • Set militia_count = 0
(i've removed the else to make it easier to read)

  • Militia leaves a region
    • Events
      • Unit - A unit leaves a region <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Militia
    • Actions
      • Set militia_count = (militia_count - 1)
 
Level 9
Joined
Jun 26, 2007
Messages
659
<stop the flood !>
using local or global here is EXACTLY the same (except for some insignificant details)
i prefer using local, that's a choice, that's only a choice, that's nothing more than a choice, and that's my choice and just mine, no need to argue about that during hours, thanks
 
Status
Not open for further replies.
Top