Unit Battalions

S

Skitz_24

Guest
Well I have somewhat created a Hero Squad.

What you have is a hero, and you can add or remove units from their squad, and when any of the units in the squad move, all the others follow...somewhat.

My problem right now is that not all of the units move with the squad all the time. I can't post the triggers right now because I am at school so you will have to wait maybe 2 hours for me to get home :p

Anyway it wasn't that hard to do, so I will work on making the battalions next.

If everything gets done well I will work on making a System for the Repository so taht people can make use of this :p
 

San-D

New Member
Reaction score
15
Id like to see that system of urs, Ive been wandering about this for the last few days, using GUI I did lots of "interesting" stuff, while trying to create it, including crashing the game
 
S

Skitz_24

Guest
Sorry I have been busy for the past couple of days...

I will post my current codes when I get the chance, I got to go to bed right now XD

Anyway I almost have the thing figured out, my only problem is that is doesn't work properly or it crashes the game :p

Let us hope someone can help fix it XD
 
S

Skitz_24

Guest
Okay, I finally got some time to myself, so I am posting the codes for what I have so far [yes I know this is really over due :p]

Please note I am just experimenting so places where I should have variables...probably don't have variables :p

Now...CODES AWAY!!!!

Code:
Unit Groups
    Events
        Map initialization
    Conditions
    Actions
        Unit Group - Add Commander 0000 <gen> to Unit_Group
        Set UnitsInGroup = (Number of units in Unit_Group)
This is the setup for the unit groups, on a multiplayer map it'll obviously be bigger, but this is all that is needed for now.

Code:
Attatch to Squad
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Attatch to Squad 
    Actions
        Set Cast_Point = (Position of (Triggering unit))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Target unit of ability being cast) Equal to (Random unit from Unit_Group)
                UnitsInGroup Less than 3
            Then - Actions
                Unit Group - Add (Triggering unit) to Unit_Group
                Set UnitsInGroup = (Number of units in Unit_Group)
            Else - Actions
                Floating Text - Create floating text that reads Unit Squad is full at Cast_Point with Z offset 10.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
        Custom script:   call RemoveLocation(udg_Cast_Point)
This trigger makes it so units can attach to my heros squadron. This trigger works fine [I think :p]

Code:
Move
    Events
        Unit - A unit Is issued an order targeting a point
    Conditions
        ((Ordered unit) is in Unit_Group) Equal to True
        Or - Any (Conditions) are true
            Conditions
                (Issued order) Equal to (Order(move))
                (Issued order) Equal to (Order(smart))
    Actions
        Unit Group - Pick every unit in Unit_Group 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 (Ordered unit)
                    Then - Actions
                        Set Moving_Unit = (Picked unit)
                        Trigger - Turn off (This trigger)
                        Unit - Order Moving_Unit to Move To (Target point of issued order)
                        Trigger - Turn on (This trigger)
                    Else - Actions
This is my problem trigger. What it does is one of 2 things:
1. Crash the game T__T
2. Not all units in the squadron move
Now I do not know what my problem is so help would be appreciated

There is my sneak peek at what I have been doing XD

Battalions begin after Squadrons r done :p
 

WolSHaman

knowledgeably ignorant
Reaction score
51
It crashes the map because it creates an infinite loop, because each time a unit in the squad is ordered to move, then the other squad members are ordered to move, so then the first unit is ordered to move, ordering the other members and so on.
 

WolSHaman

knowledgeably ignorant
Reaction score
51
Well, if you want only the hero to be able to order his units to move, then you'd add a condition checking if the ordering unit was a hero. But I'd do the squad system in an entirely different way, using custom values, but that's just me.
 

Ghostwind

o________o
Reaction score
172
Like in Rise of Nations I guess. Well maybe make two locust units that follow the main unit around and make it so when the main unit gets to 66% HP one of them dies, at 33% the other one dies, and then at 0% the main unit dies (of course)
 
S

Skitz_24

Guest
Ya I was considering using Custom Values.

But no I am making nit so that if any unit in the squadron moves, the whole squadron moves with them.
 

Samael88

Evil always finds a way
Reaction score
181
I think you can do it by using custom values.
We can take footman as an example.
You could take one unit with the model of a "circle of power" or something.
That will be the only unit in the squad that is selectable, the others does not need to be.
That selectionunit is the only one wich need to hade customvalue, the other ones can be in a unitgroup and copy its movement.
Then you do like this:
Selectionunit moves
The others attack move to specified locations, like the way San-D wrote.
Set Point[1] = (Position of (Casting unit))
Set Point[2] = (Point[1] offset by (200.00, 0.00))
Set Point[3] = (Point[1] offset by (-200.00, 0.00))
Set Point[4] = (Point[1] offset by (0.00, 200.00))
Set Point[5] = (Point[1] offset by (0.00, -200.00))
Set Point[6] = (Point[1] offset by (200.00, -200.00))
Set Point[7] = (Point[1] offset by (-200.00, -200.00))
Set Point[8] = (Point[1] offset by (200.00, 200.00))
Set Point[9] = (Point[1] offset by (-200.00, 200.00))
Set Place = (Place + 1)

The locations will of course have to be calculated, but i think each unit has a special formation value that you can change. I can't remember the name of it, but it decides the distance between the units in the standard formation.
You know, when you select more than one and move them.
However, that value can be used.

And let's say that you want 20 units in the foramtion, then you can like have 20 life for the selectionunit and make it lose 1hp for each unit in the group that dies.

All you need to do this is atleast to variables, one for each formation, a unit array, and one for the array for the groups.

And also, if you want to have spells on the units like defend for example, then all you need is a dummy spell for the selectionunit, and maybe you can make it easier with some kind of library trigger that uses array spell variables or something like that.

Just a thought that hit me when I read thru this. hope it helps:D
 
S

Skitz_24

Guest
Thanks for the suggestion.

I think I should point out with that my current system I am trying to make it so you can select ANY unit in the squad and give it commands that effect the rest of the squad, this is because each attachable unit has its own special abilities and what not.
 

Samael88

Evil always finds a way
Reaction score
181
Thanks for the suggestion.

I think I should point out with that my current system I am trying to make it so you can select ANY unit in the squad and give it commands that effect the rest of the squad, this is because each attachable unit has its own special abilities and what not.

That is actually not that much of a problem this way either.
You can add abilities to the selection unit when a new unit comes along
and remove when one goes away.
If you want it to be many abilities you can use spellbooks.:thup:
 
S

Skitz_24

Guest
Okay, I have been messing with my triggers all week, and I have made it so that it doesn't crash the game, however it doesn't work properly either.

My current Coding for movement is:
Code:
Move
    Events
        Unit - A unit Is issued an order targeting a point
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Issued order) Equal to (Order(move))
                (Issued order) Equal to (Order(smart))
    Actions
        Unit Group - Pick every unit in Unit_Group and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Ordered unit) is in Unit_Group) Equal to True
                        Or - Any (Conditions) are true
                            Conditions
                                (Issued order) Equal to (Order(move))
                                (Issued order) Equal to (Order(smart))
                        (Picked unit) Not equal to (Ordered unit)
                    Then - Actions
                        Set Moving_Unit = (Picked unit)
                        Trigger - Turn off (This trigger)
                        Unit - Order Moving_Unit to Move To (Target point of issued order)
                        Trigger - Turn on (This trigger)
                    Else - Actions

This is what happens...

I have a Paladin as the original Squad unit, the squad 'hero' I guess. The following is what happens:

1. Attach a footman
2. Attach Rifleman
3. Move Paladin: Footman follows, Rifleman doesn't move
4. Move Footman: Paladin follows, Rifleman doesn't move
5. Move Rifleman: Paladin follows, Footman doesn't move

Anyone know what my problem is?
 
S

Skitz_24

Guest
Yes and I need to get this puzzle figured out to finish the map I am working on =\
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,733
Not to be saying much in any way, but you could add that as a key puzzle to your map, or an easter egg, and let other players try to solve that puzzle out for you in-game.

It's fun and cool, if there's a timer and some actions that endangers the trio.
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,733
Oh well. Try using "Display All Players the text:" action for each of the units, as to debug the actions in the if/then/else action. If one or two shows up, then try re-tracing by asking yourself "Where did that come from?".

Who knows, the answer might be either be unnoticable, or amusingly funny!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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