Unit Battalions

S

Skitz_24

Guest
LOL alright then, if you want to do work by all means :p

I would like the squadron to work like this...

You start with a unit [preferably a hero] that is the original squad unit, meaning he is what squad attachments, well, attach to.
Now with this unit, if he is in a squad, and is removed from the squad, the whole squad is disassembled [so basically nothing that was in the squad should move or take commands with each other anymore].
Now there will be other units, that will have abilities and what not, and when you add them to this hero's squad, their abilities become active.
Including the hero, you can have a total of 4 units in a squad.

I think that about covers most of it ^_^
Just ask if you got more questions, of and if I use your system in my map I will be sure to credit you ^_^

kirby dance!!!
<(' '<) (>' ')> <(^ ^)>
 

WolSHaman

knowledgeably ignorant
Reaction score
51
Just a few more questions to make sure I understand-- So, each player starts out with a preset number of heroes, and each hero assigns squad members. Now, when a unit is assigned to a squad, can the player still assert direct control over the unit or can the unit only be commanded through the hero? Also, you want each player to be a player, so I can't use the comp player cop-out, right? I think I can do all of this, just wait a bit.
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,706
Please, I hope it is useful for some World War 1, 2 etc. scenario.
 
S

Skitz_24

Guest
Just a few more questions to make sure I understand-- So, each player starts out with a preset number of heroes, and each hero assigns squad members. Now, when a unit is assigned to a squad, can the player still assert direct control over the unit or can the unit only be commanded through the hero? Also, you want each player to be a player, so I can't use the comp player cop-out, right? I think I can do all of this, just wait a bit.

Okay, now each unit should have a 'Add to Squad' ability, which when they are attached to a squad, is exchanged for a 'Remove from Squad' ability.
Now units in the squad can still be controlled themselves, yet the whole squad moves with them. Like so...
A Footman and Rifleman are added to a hero's squad, you can still control both of them instead of the hero, but all 3 units will move in unison.
And I don't understand the last question :p
 

WolSHaman

knowledgeably ignorant
Reaction score
51
Ignore it, if you want to still be able to control each individual unit in the squad at the same time, it doesn't matter.
 

WolSHaman

knowledgeably ignorant
Reaction score
51
mmmk I finished the squad system like you wanted. Here's the triggers w/ some explanations:
first, we need to create the commanders and set their custom values. I'm doing this on map initialization, and you get 4 commanders, and each one has a chance to randomly be one of four random commander types. Here's the stuff for that:
Code:
Melee Initialization
    Events
        Map initialization
    Conditions
    Actions
        Set commandertype[1] = Archmage
        Set commandertype[2] = Paladin
        Set commandertype[3] = Mountain King
        Set commandertype[4] = Blood Mage
        Set pforce = (All players matching (((Matching player) slot status) Equal to Is playing))
        Player Group - Pick every player in pforce and do (Actions)
            Loop - Actions
                For each (Integer A) from 1 to 4, do (Actions)
                    Loop - Actions
                        Set temp_point = (Random point in (Playable map area))
                        Unit - Create 1 commandertype[(Random integer number between 1 and 4)] for (Picked player) at temp_point facing Default building facing degrees
                        Unit - Set the custom value of (Last created unit) to (Integer A)
                        Custom script: call RemoveLocation (udg_temp_point)
        Custom script: call DestroyForce (udg_pforce)

Ok, so the heroes have been created and ID'd as different commanders via custom values. Next, they need the ability to add units to their squad, so we use these triggers:
make sure the unit isn't a structure
Code:
checks
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Add unit (Neutral Hostile)
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Target unit of ability being cast) is A structure) Equal to True
            Then - Actions
                Unit - Order (Triggering unit) to Stop
                Game - Display to (Player group((Owner of (Triggering unit)))) the text: Must target a non-h...
            Else - Actions
now add the unit to the squad if it can fit another unit
Code:
Add unit
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Add unit (Neutral Hostile)
    Actions
        Set temp_group = (Units owned by (Owner of (Triggering unit)) matching ((Custom value of (Matching unit)) Equal to (Custom value of (Triggering unit))))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in temp_group) Less than 5
            Then - Actions
                Unit - Set the custom value of (Target unit of ability being cast) to (Custom value of (Triggering unit))
            Else - Actions
        Custom script: call DestroyGroup (udg_temp_group)

Now we need the triggers for when a unit decides to join a squad, so we use these triggers:
check like before
Code:
checks Copy
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Join a squad (Neutral Hostile)
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Target unit of ability being cast) is A structure) Equal to True
            Then - Actions
                Unit - Order (Triggering unit) to Stop
                Game - Display to (Player group((Owner of (Triggering unit)))) the text: Must target a non-s...
            Else - Actions
now the trigger to add the unit
Code:
Join squad
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Join a squad (Neutral Hostile)
    Actions
        Set temp_group = (Units owned by (Owner of (Triggering unit)) matching ((Custom value of (Matching unit)) Equal to (Custom value of (Target unit of ability being cast))))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in temp_group) Less than 5
                (Custom value of (Target unit of ability being cast)) Greater than 0
            Then - Actions
                Unit - Set the custom value of (Triggering unit) to (Custom value of (Target unit of ability being cast))
            Else - Actions
                Game - Display to (Player group((Owner of (Triggering unit)))) the text: Unable to join that...
        Custom script: call DestroyGroup (udg_temp_group)
this is optional, but it removes a unit from the group if it's in the process of changing squads, making it more convenient
Code:
Remove unit from one squad to join another
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
        (Issued order) Not equal to (Order("fingerofdeath"))
    Actions
        Unit - Set the custom value of (Ordered unit) to 0
Last, we need the order triggers for the group, it's basically the same as the other ones, except you need to ID the selected unit. WARNING: YOU MAY ONLY HAVE 1 SELECTED UNIT AT A TIME AND MOVE IT!
determine the selected unit
Code:
set selected unit
    Events
        Player - Player 1 (Red) Selects a unit
        Player - Player 2 (Blue) Selects a unit
        Player - Player 3 (Teal) Selects a unit
        Player - Player 4 (Purple) Selects a unit
        Player - Player 5 (Yellow) Selects a unit
        Player - Player 6 (Orange) Selects a unit
        Player - Player 7 (Green) Selects a unit
        Player - Player 8 (Pink) Selects a unit
        Player - Player 9 (Gray) Selects a unit
        Player - Player 10 (Light Blue) Selects a unit
        Player - Player 11 (Dark Green) Selects a unit
        Player - Player 12 (Brown) Selects a unit
    Conditions
        (Custom value of (Triggering unit)) Greater than 0
    Actions
        Set selectedunit[(Player number of (Triggering player))] = (Triggering unit)
now the order triggers:
move
Code:
move
    Events
        Unit - A unit Is issued an order targeting a point
    Conditions
        (Ordered unit) Equal to selectedunit[(Player number of (Owner of (Ordered unit)))]
        (Issued order) Not equal to (Order("move"))
        (Issued order) Not equal to (Order("smart"))
    Actions
        Set temp_point = (Target point of issued order)
        Set temp_group = (Units owned by (Owner of (Ordered unit)) matching ((Custom value of (Matching unit)) Equal to (Custom value of selectedunit[(Player number of (Owner of (Triggering unit)))])))
        Unit Group - Remove selectedunit[(Player number of (Owner of (Ordered unit)))] from temp_group
        Unit Group - Pick every unit in temp_group and do (Actions)
            Loop - Actions
                Unit - Order (Picked unit) to Move To temp_point
        Custom script: call RemoveLocation (udg_temp_point)
        Custom script: call DestroyGroup (udg_temp_group)
attack
Code:
attack
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
        (Ordered unit) Equal to selectedunit[(Player number of (Owner of (Ordered unit)))]
        (Issued order) Not equal to (Order("attack"))
        (Issued order) Not equal to (Order("smart"))
    Actions
        Set temp_group = (Units owned by (Owner of (Ordered unit)) matching ((Custom value of (Matching unit)) Equal to (Custom value of selectedunit[(Player number of (Owner of (Triggering unit)))])))
        Unit Group - Remove selectedunit[(Player number of (Owner of (Ordered unit)))] from temp_group
        Unit Group - Pick every unit in temp_group and do (Actions)
            Loop - Actions
                Unit - Order (Picked unit) to Attack (Target unit of issued order)
        Custom script: call DestroyGroup (udg_temp_group)
stop
Code:
stop
    Events
        Unit - A unit Is issued an order with no target
    Conditions
        (Ordered unit) Equal to selectedunit[(Player number of (Owner of (Ordered unit)))]
        (Issued order) Not equal to (Order("stop"))
    Actions
        Set temp_group = (Units owned by (Owner of (Ordered unit)) matching ((Custom value of (Matching unit)) Equal to (Custom value of selectedunit[(Player number of (Owner of (Triggering unit)))])))
        Unit Group - Remove selectedunit[(Player number of (Owner of (Ordered unit)))] from temp_group
        Unit Group - Pick every unit in temp_group and do (Actions)
            Loop - Actions
                Unit - Order (Picked unit) to Stop
        Custom script: call DestroyGroup (udg_temp_group)
That's all for now. Enjoy!
 
S

Skitz_24

Guest
Thank you good sir :D

I will go and test these out now

EDIT: Just to make sure everything I did I am doing right, could you possibly attach a map with the system and what not in it?

kirby dance!!!
<(' '<) (>' ')> <(^ ^)>
 

Oninuva

You can change this now in User CP.
Reaction score
221
You can easily do it with computer player controling the squad units but then again, you want more than 6 players.
 
S

Skitz_24

Guest
*downloads demo map*
*looks at demo map*
*is confused on what to do to see what happens*
 

WolSHaman

knowledgeably ignorant
Reaction score
51
Yes their is, their's a footman who you can attach to squads by the player 1 start location, and the heroes spawn in-game on map initialization. This is where reading the triggers plays a vital role in seeing what the map does.
 
S

Skitz_24

Guest
Must be an invisible Footman, b/c there is only the start location
 

WolSHaman

knowledgeably ignorant
Reaction score
51
Oh found the mistake, the maps file name was Squad SYSTEM, not Squad COMBAT. However, I can't reupload because my comp won't let me, so just practice w/ the triggers.
 
S

Skitz_24

Guest
lol okay [told u there was a problem xD]

Now then, let us try and figure all this out >__>

kirby dance!!!
<(' '<) (>' ')> <(^ ^)>
 

AgentPaper

From the depths, I come.
Reaction score
107
Code:
Create Squad
    Events
        Unit - A unit Finishes training a unit
    Conditions
        ((Triggering unit) is A Hero) Equal to False
    Actions
        Set Squad_Leader[Counter] = (Trained unit)
        Unit - Set the custom value of (Trained unit) to Counter
        Unit - Make (Trained unit) Invulnerable
        Unit - Create SquadSize (Unit-type of (Trained unit)) for (Owner of (Trained unit)) at (Position of (Trained unit)) facing Default building facing degrees
        Set Squad[Counter] = (Last created unit group)
        Unit Group - Pick every unit in (Last created unit group) and do (Actions)
            Loop - Actions
                Unit - Disable supply usage for (Picked unit)
                Unit - Set the custom value of (Picked unit) to Counter
                Unit - Add classification of Summoned to (Picked unit)
        Unit Group - Add Squad_Leader[Counter] to Squad[Counter]
        Trigger - Turn off Move Squad Unit <gen>
        Unit Group - Order Squad[Counter] to Right-Click (Rally-Point of (Triggering unit) as a point)
        Trigger - Turn on Move Squad Unit <gen>
        Set Counter = (Counter + 1)

Code:
Move Squad Unit
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
    Actions
        Trigger - Turn off (This trigger)
        Unit Group - Order Squad[(Custom value of (Ordered unit))] to Right-Click (Target unit of issued order)
        Trigger - Turn on (This trigger)

Code:
Move Squad Point
    Events
        Unit - A unit Is issued an order targeting a point
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Issued order) Equal to (Order(smart))
            Then - Actions
                Trigger - Turn off (This trigger)
                Unit Group - Order Squad[(Custom value of (Ordered unit))] to Right-Click (Target point of issued order)
                Trigger - Turn on (This trigger)
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Issued order) Equal to (Order(attack))
                    Then - Actions
                        Trigger - Turn off (This trigger)
                        Unit Group - Order Squad[(Custom value of (Ordered unit))] to Attack-Move To (Target point of issued order)
                        Trigger - Turn on (This trigger)
                    Else - Actions

Code:
Death
    Events
        Unit - A unit Dies
    Conditions
        ((Triggering unit) is Summoned) Equal to True
    Actions
        Set Num = (Custom value of (Dying unit))
        Unit Group - Remove (Dying unit) from Squad[Num]
        Unit - Set life of Squad_Leader[Num] to (((Real((Number of units in Squad[Num]))) / (Real(SquadSize))) x 100.00)%

Code:
Selection
    Events
        Player - Player 1 (Red) Selects a unit
        Player - Player 2 (Blue) Selects a unit
        Player - Player 3 (Teal) Selects a unit
        Player - Player 4 (Purple) Selects a unit
        Player - Player 5 (Yellow) Selects a unit
        Player - Player 6 (Orange) Selects a unit
        Player - Player 7 (Green) Selects a unit
        Player - Player 8 (Pink) Selects a unit
        Player - Player 9 (Gray) Selects a unit
        Player - Player 10 (Light Blue) Selects a unit
        Player - Player 11 (Dark Green) Selects a unit
        Player - Player 12 (Brown) Selects a unit
    Conditions
    Actions
        Unit Group - Pick every unit in (Units currently selected by (Triggering player)) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Picked unit) is Summoned) Equal to True
                    Then - Actions
                        Selection - Remove (Picked unit) from selection for (Triggering player)
                        Selection - Add Squad_Leader[(Custom value of (Picked unit))] to selection for (Triggering player)
                    Else - Actions

Made a system of my own, I tried doing this before, but I think this system works pretty well. It's quite robust and simple, and doesn't require anything special be done on the units. It could easily be used in a normal melee game, which in fact might be fun to try.

Basically, what it does, is whenever a unit is trained, it makes a number of units of the same type to be that unit's squad. The created unit is then made invulnerable and set to be the "squad leader". Whenever a squad member dies, the squad leader looses life, and he dies when his last squad member does. If you try to select a "squad" unit, the squad leader is selected instead, so you can use drag selects to select different squads without too much trouble.

Whenever you order the squad leader to do something, the rest of the squad will follow the same order. If you try to order any of the squad units (which is possible if you're fast) it makes the whole unit do it anyways, so it's impossible to move single units. This even works for builders. The main unit will start building something, and the rest will automatically start helping him build it, and the same as repairing.


Some things I need to work on:
-Allowing different units to have different squad sizes.
-Allowing units to use spells, or at least activate abilities and auto-casts.
-Allowing heroes to take command of squads temporarily.

Give it a try, I haven't tried it online, but it should work just fine in any situation. As a note, you can change the default squad size in the variables, though a max of 11 is recommended, as unit groups of more than 12 don't work last I checked. (remember the squad has the normal troops as well as a commander, so the actual squad will be the variable's squad size + 1)

In the test map, just make some units to try this out. The units are un-modified, the only change is that they each make 12x as many units as normal. Feel free to take the triggers directly from the map, credit is appreciated, advice is better.


Edit: Check latest post for updated map.
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,706
Advice:

Make a chat message event to spawn creeps at one place, so that it won't run out of units that is needed to test.

There's no melee time of day... How come I can still attack creeps like normal?
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top