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.
  • 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
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top