System Squad System

AdamGriffith

You can change this now in User CP.
Reaction score
69
Just a suggestion.
Recycle the arrays.
Because (I know it is unlikely) you might have a long game where they're has been over 8192 squads in play. And obviously not all of them will still be alive so there will be empty arrays.
You could develop a way of recycling the arrays and this would be even better. (Y)
 

Kiwi_Jesus

New Member
Reaction score
1
Ah, Sorry im having trouble with some of the actions in one of your triggers, could you support me with this?


Create Squad
Events
Unit - A unit Finishes training a unit
Conditions
((Trained unit) is A Hero) Equal to False
((Trained unit) is A peon-type unit) Equal to False
Actions
-------- It starts at 1, as any unit with a custom value of 0 is recognized as not being in a squad. --------
Set Squad_Leader[Counter] = (Trained unit)
-------- Makes the trained unit the squad leader --------
Unit - Set the custom value of (Trained unit) to Counter
-------- Sets the squad leader's custom value to that of what the squad will be. --------
Unit - Make (Trained unit) Invulnerable
-------- Makes the squad leader immune to all attacks. His health will represent the health of the squad, so he isn't actually invincible. --------
Unit - Create SquadSize (Unit-type of (Trained unit)) for (Owner of (Trained unit)) at (Position of (Trained unit)) facing Default building facing degrees -------- Creates the rest of the squad. The squad will be the same type of unit as the leader. --------
Set Squad[Counter] = (Last created unit group) -------- Sets the created units to the Squad variable, using the Counter as the index. --------
Unit Group - Pick every unit in (Last created unit group) and do (Actions)
Loop - Actions
Unit - Disable supply usage for (Picked unit)
-------- Makes it so the sub-units in the squad do not use food. This can be disabled, but then the unit will use much more food. --------
Unit - Set the custom value of (Picked unit) to Counter
-------- Sets the custom value of each of the sub-units, to keep track of what units are in what squads. --------
Unit - Add classification of Summoned to (Picked unit)
-------- All sub-units are classified as "Summoned" to seperate them from the squad leaders and non-squad units. --------
Unit Group - Add Squad_Leader[Counter] to Squad[Counter] -------- Makes the squad leader to be part of the unit he leads. --------
Trigger - Turn off Order Squad Point <gen>
Trigger - Turn off Order Squad Object <gen>
-------- This is to ensure there can be no infinite loop. --------
Unit Group - Order Squad[Counter] to Right-Click (Rally-Point of (Triggering unit) as a point)
-------- Makes the squad move to the rally point of the building the unit was trained in. --------
Trigger - Turn on Order Squad Point <gen>
Trigger - Turn on Order Squad Object <gen>
-------- Turns the movement triggers back on. --------
Set Counter = (Counter + 1)
-------- Increases the counter, so the next unit made will not override this one. --------Code:
 

UndeadDragon

Super Moderator
Reaction score
447
Try putting your trigger into CODE tags to make it more readable.

And, what is it that you actually need help with?
 

Kiwi_Jesus

New Member
Reaction score
1
Try putting your trigger into CODE tags to make it more readable.

And, what is it that you actually need help with?



The stuff thats in red is what i dont understand, i need some help verrifiing what it means.

or the actual trigger that i need to make for that part of the script.
 

Kiwi_Jesus

New Member
Reaction score
1
Need Help Please. When I'm playing in game. I've tried this with 3 different computers, it happens on all of them, when im ingame it doesnt lag, but it delays the units actions badly.

I don't know why, i've got all the triggers EXACTLY the same as AgentPapers code except for the counter number mines 4 instead of 12 and i dont know whats wrong. Can anyone help?
 

AgentPaper

From the depths, I come.
Reaction score
107
New update on the first post. Lots of new features this update, but unfortunately there seems to be a bad case of memory leak that I can't find. If someone could take a look at the triggers or open up the map to give it a look, that'd be great.

Also if this could be dug out of the graveyard, if you please. ;)
 
Reaction score
456
1. Order Squad Point:
Trigger:
  • Custom script: call GroupPointOrderLoc( udg_Squad[udg_Num], udg_Order, GetOrderPointLoc() )

GetOrderPointLoc() leaks.

2. Hero Leave Squad:
Trigger:
  • Unit - Create 1 (Unit-type of (Random unit from Squad[Num])) for (Owner of Hero) at (Position of (Random unit from Squad[Num])) facing Default building facing degrees

You're actually storing the point into a variable, but you're not using it for some reason :p ...

3. Create Squad:
Trigger:
  • Unit Group - Order Squad[Num] to Attack-Move To (Rally-Point of (Triggering unit) as a point)
    • Unit Group - Order Squad[Num] to Right-Click (Rally-Point of (Triggering unit) as a unit)

Those rally-points leak. LOOOCATIONS.

Other than leaks:
You have pasted Hero Leave Squad twice.

In Hero Join Squad you're storing point to a variable and you remove it, but it's never used.

And I wonder where those selection events belong.
 

AgentPaper

From the depths, I come.
Reaction score
107
Perfect. I can fix the other two, the first one is the one I need to know how to fix, since it's already in custom script. Do I just have to use custom script to destroy the "Order" variable?

Those order triggers run A LOT, so I'd love to keep them as short and leak-free as possible. As in, as short as mathmatically possible and without a single leak. They're running nigh-constantly throughout the game.
 
Reaction score
456
In the first one the problem is not in the Order variable, but in the GetOrderPointLoc().

You need to use some point variable there:
Trigger:
  • Custom script: set udg_somePoint = GetOrderPointLoc()
    • Custom script: call GroupPointOrderLoc( udg_Squad[udg_Num], udg_Order, udg_somePoint )
    • Custom script: call RemoveLocation(udg_somePoint)
 

AgentPaper

From the depths, I come.
Reaction score
107
Trigger:
  • Order Squad Point
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Custom value of (Ordered unit)) Not equal to 0
    • Actions
      • Set Num = (Custom value of (Ordered unit))
      • -------- Num is an integer, set to the value of the squad we are dealing with. --------
      • Set Order = (String((Issued order)))
      • -------- Order is a string, used to hold the order we will give to the squad later. --------
      • Trigger - Turn off (This trigger)
      • -------- This is to ensure there can be no infinite loop. --------
      • Custom script: set udg_Point = GetOrderPointLoc()
      • Custom script: call GroupPointOrderLoc( udg_Squad[udg_Num], udg_Order, udg_Point )
      • Custom script: call RemoveLocation(udg_Point)
      • -------- This custom text orders the squad to do the order specified earlier at the same point as the ordered unit. --------
      • Trigger - Turn on (This trigger)
      • -------- Turns the movement triggers back on. --------
      • Set Order = &lt;Empty String&gt;
      • Set Num = 0
      • -------- Resets the variables used to prevent errors. --------

That look leak-free? I'm pretty sure this was causing the slowdown I was experiencing. If there's no leaks left after this change, as well as fixing the other two you pointed out, (which I have done already) I'll upload the fixed version as 1.1b.
 

AgentPaper

From the depths, I come.
Reaction score
107
Thanks for the help, gave you credit in the map. Uploaded the revised 1.1b map to the first post.

Now I'm getting an issue where the selection system doesn't work for Siege Engines. Specifically, everything about them works except that the trigger that's supposed to deselect all but the main unit automatically, doesn't. Works for everything else, though, which has me stumped.
 
Reaction score
456
What's the trigger for the selection system? I can see only bunch of selection events, but no actions. :)
 

SerraAvenger

Cuz I can
Reaction score
234
Code:
# Custom script: set udg_Point = GetOrderPointLoc()
# Custom script: call GroupPointOrderLoc( udg_Squad[udg_Num], udg_Order, udg_Point )
# Custom script: call RemoveLocation(udg_Point)

can be
Code:
# Custom script: call GroupPointOrder( udg_Squad[udg_Num], udg_Order, GetOrderPointX(), GetOrderPointY()  )

Too bad you're using Custom values for this, makes it impossible to use with most other systems : /
 

AgentPaper

From the depths, I come.
Reaction score
107
Code:
# Custom script: set udg_Point = GetOrderPointLoc()
# Custom script: call GroupPointOrderLoc( udg_Squad[udg_Num], udg_Order, udg_Point )
# Custom script: call RemoveLocation(udg_Point)

can be
Code:
# Custom script: call GroupPointOrder( udg_Squad[udg_Num], udg_Order, GetOrderPointX(), GetOrderPointY()  )

Too bad you're using Custom values for this, makes it impossible to use with most other systems : /

And that also won't leak?

And yea, custom values really help a lot, though I might try and change it later to not require them anymore. I'll put it on my plate for 1.2 or 1.3, once any other major issues are resolved.

And yeah, it seems I only copied the events for the selection trigger. Fixed that. :p
 

SerraAvenger

Cuz I can
Reaction score
234
Yupp, won't leak.
I have a map with a similiar system, but there you have up to five squads that are all controlled by your hero : )
Code:
#
# Game - Display to (All players) the text: Initializing Units
that shouldn't happen!

I also don't like the game being paused : /
 

AgentPaper

From the depths, I come.
Reaction score
107
Look at the trigger, it's a loop that will run for every unit pre-placed on the map, and has to wait .1 seconds for each one. It would never be there for more than a few seconds, unless someone went crazy with the units, but I figured it was better to prevent any issues that might happen while the squads were being made. And nobody likes the game paused without knowing why, hence the message.

And thanks for the shorter bit of code, should help with lag, though I have yet to test this over B.net yet, since I can't host. I'll use it for 1.2.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top