• Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • 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.
  • 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!

[Trigger] Squad System

Status
Not open for further replies.
Level 20
Joined
May 26, 2006
Messages
653
Im trying to make a squad system for my map.

It adds units to a unit_group(number of mana) of the training unit, than adds +1 mana to the training unit. Sets mana of trained unit to number of his unit group. Than when units gets order it picks all units from unit_group(number if mana of ordered unit). For some reason it causes the game to crash. Could anyone help :(?
 

Attachments

  • skad.w3x
    18.3 KB · Views: 99
Level 10
Joined
Jun 26, 2005
Messages
236
Try this:

  • order move
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
    • Actions
      • Set temp_Unit = (Triggering unit)
      • Unit Group - Pick every unit in UnitGroup[(Integer((Mana of (Triggering unit))))] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) Not equal to temp_Unit
            • Then - Actions
              • Unit - Order (Picked unit) to Follow (Triggering unit)
            • Else - Actions
              • Set temp_Unit = No unit
It wasn't working because you were ordering a unit to follow itself.
 
Level 20
Joined
May 26, 2006
Messages
653
Thx! Rep+

Now any idea why this doesnt work?xd

  • order move
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
    • Actions
      • Set OrderPoint = (Target point of issued order)
      • Set temp_Unit = (Triggering unit)
      • Unit Group - Pick every unit in UnitGroup[(Integer((Mana of (Triggering unit))))] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) Not equal to temp_Unit
            • Then - Actions
              • Jednostka - Order (Picked unit) to move to (OrderPoint)
            • Else - Actions
              • Do nothing
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Send a playermessage displaying the amount of units in UnitGroup[Mana of (triggering unit)]. Then you see what's going wrong...

Also, I think something is bugged with the "order picked unit to move to". Instead, use "Unit group - order unit group" rather than "order unit". This means you'd do something like this:
Set TempUnitGroup = Units in UnitGroup[mana]
Unit group - remove triggering unit from TempUnitGroup
Unit group - issue an order targetting a point.

Also, if you're interested, I have made a jassed squad system some time ago. It uses Custom Value rather than mana (though that could be changed, not so easily), and allows you to have veterancy...
 
Level 22
Joined
Feb 26, 2008
Messages
892
> Infinate loops do not crash maps.

I think it depends on the type of loop.
Here, you have a trigger issuing point orders that waits for point orders to be issued.
No op limit will be hit here because it's not the same trigger being fired. The trigger is being called infinitely. New trigger usually means new op limit, I think.
I've had triggers like this crash Warcraft before.

For a solution, try turning the trigger off, issuing the move order, then turning the trigger back on again.
 
Level 9
Joined
May 27, 2006
Messages
498
That's my fast-wrote squad system, hope it'll work... note that im not even 10% sure if whole system works properly in game, i didn't test it (cause i dont have w3 right now...)

Whole system is based on a squad leader, which can add new squad members (up to 9) or remove them.
The most important trigger, the one triggering move, is at the bottom.
  • CreateSquad
    • Events:
      • Unit - A unit uses an ability
    • Conditions:
      • (Ability being cast) Equal to Squad (Create) // A ranged target spell, like Shadow Strike
    • Actions:
      • Set SquadCV = ( (SquadCV) + 1 ) // Default 0
      • Unit - Set custom value of (Triggering unit) to SquadCV
      • Set SquadLeader[custom value of (Triggering unit)] = (Triggering unit)
      • Unit Group - Add (Triggering Unit) to SquadUG[custom value of (Triggering unit)]
      • Unit Group - Add (Target unit of ability being cast) to SquadUG[custom value of (Triggering unit)]
      • Unit - Remove Squad (Create) from (Triggering unit)
      • Unit - Remove Squad (Create) from (Target unit of ability being cast)
      • Unit - Add Squad (AddNew) to (Triggering unit)
      • Unit - Add Squad (Remove) to (Triggering unit)
      • Unit - Add Squad Leader (0 range aura) to (Triggering unit)
      • Unit - Set mana of (Triggering unit) to 2
  • AddSquad
    • Events:
      • Unit - A unit uses an ability
    • Conditions:
      • (Ability being cast) Equal to Squad (AddNew) // Spell base same as Squad (Create)
      • ((Mana of (Triggering unit)) Equal to or less than 10
    • Actions:
      • Unit Group - Add (Target unit of ability being cast) to SquadUG[custom value of (Triggering unit)]
      • Unit - Remove Squad (Create) from (Target unit of ability being cast)
      • Unit - Set mana of (Triggering unit) to ((mana of (Triggering unit)) + 1)
  • RemoveSquad
    • Events:
      • Unit - A unit uses an ability
    • Conditions:
      • (Ability being cast) Equal to Squad (Remove) // Spell base same as Squad (Create)
    • Actions:
      • If Then Else - Multiple Functions:
        • If - Conditions:
          • Mana of (Triggering unit) Greater than or equal to 3
        • Then - Actions:
          • Unit Group - Remove (Target unit of ability being cast) from SquadUG[custom value of (Triggering unit)]
          • Unit - Set mana of (Triggering unit) to ((mana of (Triggering unit)) - 1)
          • Unit - Add Squad (Create) to (Target unit of ability being cast)
        • Else - Actions:
      • If Then Else - Multiple Functions:
        • If - Conditions:
          • ((Mana of (Triggering unit)) Equal to 2
        • Then - Actions:
          • Custom script: call DestroyGroup( udg_SquadUG[get custom value of triggering unit()] ) // anyone here knows how to get custom value of unit in JASS...? :D
          • Unit Group - [alternative for the 'custom script' above] Clear SquadUG[custom value of (Triggering unit)]
          • Unit - Remove Squad (Remove) from (Triggering unit)
          • Unit - Remove Squad (AddNew) from (Triggering unit)
          • Unit - Add Squad (Create) to (Triggering unit)
          • Unit - Add Squad (Create) to (Target unit of ability being cast)
          • Unit - Remove Squad Leader (0 range aura) from (Triggering unit)
          • Unit - Set mana of (Triggering unit) to 1
        • Else - Actions:
  • SquadLeaderDies
    • Events:
      • Unit - A unit dies
    • Conditions:
      • Custom value of (Triggering unit) greater than or equal to 1 // i'm not sure if there is such a condition...
      • Mana of (Triggering unit) greater than or equal to 2 // for this one i'm not sure if it even works...
    • Actions:
      • Unit Group - Remove (Triggering unit) from SquadUG[custom value of (Triggering unit)]
      • Unit Group - Pick random 1 units in SquadUG[custom value of (Triggering unit)] and do (Actions):
        • Unit - Add Squad (AddNew) to (Picked unit)
        • Unit - Add Squad (Remove) to (Picked unit)
        • Unit - Add Squad Leader (0 range aura) to (Picked unit)
        • Unit - Remove Squad (Create) from (Picked unit)
        • Unit - Set custom value of (Picked unit) to (custom value of (Triggering unit))
        • Unit - Set mana of (Picked unit) to (Number of units in SquadUG[custom value of (Triggering unit)
  • MoveSquad
    • Events:
      • Unit - A unit Is issued an order targeting a point
    • Conditions:
      • (Unit-type of (Triggering unit)) Equal to Footman
      • (Triggering unit) has buff Squad Leader Equal to True
    • Actions:
      • Unit Group - Remove (Triggering unit) from SquadUG[custom value of (Triggering unit)]
      • Unit Group - Pick every unit in (units in SquadUG[custom value of (Triggering unit)]) and do Unit - Order (Picked unit) to Folllow (Triggering unit)
      • Unit Group - Add (Triggering unit) to SquadUG[custom value of (Triggering unit)]
EDIT:
Added new trigger that chooses new leader when the old one dies ;P

EDIT2:
Tried to do a trigger which will order units to move in a column... After an hour of writing i resigned - it's impossible to do in my system.

EDIT3:
@down
You tested it? I think you did, anyway, changed to what BB was saying ;p
 
Last edited:
Status
Not open for further replies.
Top