• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Reinforce System for Squads

Status
Not open for further replies.
Level 22
Joined
Jul 25, 2009
Messages
3,091
Why is this not working? It creates the proper amount of units on the first use on a wounded squad, but it fails to put them in the same squad.

The squads are cached by an integer, each squad has a single custom value for the entire squad, so squad 1's custom values is X, squad 2's is Y.

A triggerer will understand how it's supposed to work, and hopefully why it's not.

Show me what this should look like...

  • Reinforce
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Reinforce
    • Actions
      • Set TempUGroup[1] = (Units within 100.00 of (Target point of ability being cast) matching (((Matching unit) is A structure) Equal to False))
      • Unit Group - Pick every unit in TempUGroup[1] and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 0 to ((Point-value of (Picked unit)) - (Number of units in (Units within 100.00 of (Target point of ability being cast) matching ((Custom value of (Matching unit)) Equal to (Custom value of (Picked unit)))))), do (Actions)
            • Loop - Actions
              • Unit - Create ((Point-value of (Unit-type of (Picked unit))) - (Number of units in (Units in (Playable map area) matching (((Custom value of (Matching unit)) Equal to (Custom value of (Picked unit))) and (((Matching unit) is alive) Equal to True))))) (Unit-type of (Picked unit)) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing 270.00 degrees
              • Unit - Set the custom value of (Last created unit) to (Custom value of (Picked unit))
      • Custom script: call DestroyGroup(udg_TempUGroup[1])
 
I don't really understand what your trigger is supposed to do. It is also leaking a group everytime you count the "number of units in playable map area of type" (that function returns a group). It also feels kinda harsh to count all units in the entire map and comparing their custom values to check whenever a unit is in the same squad.

This is how i would do it instead; you can still let the custom value be the index of the group, starting from 1. Then you use that as the index of a group array where you have a group stored for each squad. Then, you can access it by "GroupArray[Custom Value of(Triggering Unit)] and count the squad members from there.
 
Level 22
Joined
Jul 25, 2009
Messages
3,091
I don't really understand what your trigger is supposed to do. It is also leaking a group everytime you count the "number of units in playable map area of type" (that function returns a group). It also feels kinda harsh to count all units in the entire map and comparing their custom values to check whenever a unit is in the same squad.

This is how i would do it instead; you can still let the custom value be the index of the group, starting from 1. Then you use that as the index of a group array where you have a group stored for each squad. Then, you can access it by "GroupArray[Custom Value of(Triggering Unit)] and count the squad members from there.

Could work, thing is, I don't need to use groups since Custom Values basically equal the groups. Groups would make it easier, but I don't really want to use them.

Also about the leak, yes I'm a lazy ass, that's why I don't want to use groups.

xD
 
Level 22
Joined
Jul 25, 2009
Messages
3,091
Technically you are using groups right now. Only that you are adding every unit on the map into a group to count them.

I was actually working on a DoW-stype squad system a couple of weeks ago just for fun. It supports both reinforcing and attaching commanders to squads. :)

Fundamentally the system looks like it should work? Except for the 0 starting point that was a mistake I didn't notice...

And the leak is ez to fix, like I said I'm just lazy.
 
Level 5
Joined
Jun 16, 2004
Messages
108
Well it is a bit strange trying to put together the logic behind this trigger. Pick units within a radius of the cast point, then for each find the number of units nearby matching conditions, then loop N times creating M more units for each of that loop ... ?

It sounds a bit repetitive anyway.

What probably matters to you is this:
> Unit - Create ((Point-value of (Unit-type of (Picked unit))) - (Number of units in (Units in (Playable map area) matching (((Custom value of (Matching unit)) Equal to (Custom value of (Picked unit))) and (((Matching unit) is alive) Equal to True))))) (Unit-type of (Picked unit)) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing 270.00 degrees

Looks like you are often creating more than one unit with that call, so naturally a call like:
> Unit - Set the custom value of (Last created unit) to (Custom value of (Picked unit))
will not work for more than one at a time.

On another note, the last created unit group is set to all the units you create with the create function, so you can use that. Although I am not sure you mean to create N units each create call when you are also looping through a for loop, running that create call several times.
 
Status
Not open for further replies.
Top