• 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.

WC3 squad system reforged

Level 29
Joined
Sep 26, 2009
Messages
2,596
Don't know about the first question, but for the second question: Yes it is. Anything that you can do in GUI you can do in JASS as well (since GUI is converted to jass on map save).
So for example this GUI actions:
  • Unit Group - Order unit_group to Attack-Move To (Center of (Playable map area))
converts to this JASS script:
JASS:
call GroupPointOrderLocBJ( udg_unit_group, "attack", GetRectCenter(GetPlayableMapRect()) )
You can try that yourself by selecting GUI trigger in the editor and then selecting the option Edit -> 'Convert to Custom Text'.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,875
4 unit party like in old dungeon games like The Eye of the Beholder.
I imagine you mean something like Baldur's Gate? I googled The Eye of the Beholder and it's a first-person dungeon crawler where you literally don't see any of your characters nor is it on an RTS engine. Describe it in detail, using the Warcraft 3 engine in mind. There's 100 ways of going about this that all change depending on what you want.
 
I have just normal wc3 map perspective. But i want to hire a squad that would go around the map with my control or by itself (via jass). If i control it then i can not control its members individually. A player can just give a command where it should go. 4 untis staying close to each other melee units forward non-melee backward. if 1 or 2 (randomly) units is killed squad is lost (dispersed / runs away) stops doing a quest.
 
Last edited:
Here's the first version. If any unit of the squad is issued an order, the squad will be given a group order. Unfortunately there is no way AFAIK to make them stay close together no matter what or to have them move in certain formations (or it would be very complicated to do, at least).
Edit: hmmm, smart orders on friendly units don't seem to work for some reason...

The test map creates 4 knights as a squad.

JASS:
function UnitGetSquad takes unit whichUnit returns group
function SquadAddUnit takes group squad, unit whichUnit returns nothing

How do you want selection to work? I can see 2 options:
1) Leave it as it is: the player is free to select 1 or more units in the squad
2) If the player selects more than 1 unit in the squad, automatically unselect all but 1 of them
 

Attachments

  • SquadSystem.w3m
    17.9 KB · Views: 7
Last edited:
Second version. Problem with smart order on friendly units/buildings is fixed. You can set units to be sold as squads (automatically create 3 more of the unit and add to squad). Also added cleanup in case unit dies, and public function:
JASS:
function SquadRemoveUnit takes group squad, unit whichUnit returns nothing
 

Attachments

  • SquadSystem.w3m
    21.3 KB · Views: 4

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,875
@loktar
Are these Waits necessary?
vJASS:
call TriggerSleepAction(0.01)
They create gaps in time that will undoubtedly cause the system to fail. I'm pretty sure you can just delete them.

@kokon
This is the function that runs when an immediate order is issued. These are Orders like Stop, Hold Position, or any ability like War Stomp/Thunderclap:
vJASS:
    // Unit immediate order: order squad
    private function SquadImmediateOrder takes nothing returns nothing
        local trigger trg = GetTriggeringTrigger()
 
        call DisableTrigger(trg) // Prevent infinite loop
        call GroupImmediateOrder(UnitGetSquad(GetOrderedUnit()), OrderId2String(GetIssuedOrderId()))
        call TriggerSleepAction(0.01)
        call EnableTrigger(trg)
 
        set trg = null
    endfunction
Check for the "stop" order here and adjust the groups facing angle.

Do you understand and use Jass yourself or did you just mean that you wanted a system that wasn't Lua mode only?
 
They create gaps in time that will undoubtedly cause the system to fail. I'm pretty sure you can just delete them.
Ah, thanks for the tip. With this, the event fires 4 times (once for each unit), and without it it fires 16 times (4 times for each unit), but I guess it's not such a big deal (I don't notice any performance issues either way).
they should be commanded via banner - a flying invulerable unit in the center of the group. Or there should be some indication that they are in a squad. As there can be two squads of different units nearby to each other
Hmm, I tried adding a banner unit, but it looks kinda silly I think. What do you think? It doesn't stay in the middle and just moves like a normal unit. Not sure how else I can add an indication that they're in a squad.
Note that I haven't added functions yet to remove the banner when the squad dies etc.
 

Attachments

  • SquadSystem.w3m
    21.9 KB · Views: 7
I made it so it automatically deselects all but one unit of a squad, when you select multiple units in the squad. I also added a special effect to squad units, I think it looks pretty good. Let me know what you think.
(I used one of these for the SFX, but you can of course use whatever you want)

edit: now also trained units can be squad, and you can now set the size of trained/hired squads. Also reworked the script to make less use of hashtables.
edit2: now there's a chance the squad will disband each time a unit dies.
edit3: disbanded squads can now flee in a random direction.
edit4: added ability to set unit special effects per squad
edit5: added function to create squad of a unit type
edit6: uploaded it to Spells & Systems section lol: here
 
Last edited:
Top