• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

how to set food limit on a Footmen Frenzy Spawn trigger ?

Status
Not open for further replies.
Level 8
Joined
Aug 8, 2011
Messages
297
how to set food limit on a Footmen Frenzy Spawn trigger ?...

Fx i want a limit on 12 footmen, so if 1 footmen fill up 1 food, then i can spawn 12 footmen at my base. But how to set the limit food on my spawn trigger ?

  • Spawn Footmen
    • Events
      • Time - Every 15.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • -------- Barracks -> Footman --------
          • If (((Region centered at ((Picked player) start location) with size (384.00, 384.00)) contains (Random unit from (Units owned by (Picked player) of type Barracks))) Equal to True) then do (Unit - Create 1 Footman for (Picked player) at ((Picked player) start location) facing Default building facing degrees) else do (Do nothing)
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
I'm not sure on how Frenzy Footmen works, but I guess you have a region around starting area, and you have to build in that area in order to make the buildings have some effect. I'm just guessing, since you need the Barrack to be in a region of 384,384 centered on player start position.

Sadly, your trigger leaks Points, Regions, Unit Groups, etc.

The following trigger allows you to know the amount of valid barracks the player has. If the player builds the barrack within 1000 AoE from his starting position, the Barrack count for that player will increase by 1. If it builds further away it will not count (I can make a Warning advice if the player is building too far if you want). You can modify the available area by just adjusting the distance from 1000 to whatever you want in the trigger condition.

As you can see, it uses a PlayerVar to reduce the amount of (Triggering Player) calls. Also uses 2 Point variables to check the distance between the starting point and the construction point. Both are removed with the custom scripts at the end of the trigger to avoid leaks. It also uses a temporal Integer variable to know the Triggering Player number (Triggering Player stands for Owner of Triggering Unit), and also has the Barracks Integer Array to know the amount of barracks owned by the player.
  • Barrack Set
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Barracks
    • Actions
      • Set PlayerVar = (Triggering player)
      • Set PointVar = (PlayerVar start location)
      • Set PointVar2 = (Position of (Constructed structure))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between PointVar and PointVar2) Less than or equal to 1000.00
        • Then - Actions
          • Set IntegerVar = (Player number of PlayerVar)
          • Set Barracks[IntegerVar] = (Barracks[IntegerVar] + 1)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_PointVar)
      • Custom script: call RemoveLocation(udg_PointVar2)
Now, let's spawn the Footmen: Here, every 15 seconds, we set these variables to work better. If the number of Footmen owned by that player is less than 12, and the amount of Barracks inside the region of the starting area is greater than 1, it creates a footmen and adds that unit to the PlayerFootmen group. This group is to know the amount of alive Footmen each player has. If the player doesn't have a barrack or already has 12 footmen, it will not spawn. Again, the Point is removed at the end of the trigger to avoid leaks. If you want to increase or reduce the number of Footmens each player can have you just modify the "less than or equal to 12" in the trigger condition.

  • FootmenSpawn
    • Events
      • Time - Every 15.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set PlayerVar = (Picked player)
          • Set PointVar = (PlayerVar start location)
          • Set IntegerVar = (Player number of PlayerVar)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in PlayerFootmens[IntegerVar]) Less than 12
              • Barracks[IntegerVar] Greater than 0
            • Then - Actions
              • Unit - Create 1 Footman for PlayerVar at PointVar facing Default building facing degrees
              • Unit Group - Add (Last created unit) to PlayerFootmens[IntegerVar]
            • Else - Actions
          • Custom script: call RemoveLocation(udg_PointVar)
You can also work with the used Food this way; it's easier but has some limitations if you want to make your map bigger and have more features/units etc. in the future. You just have to replace this condition:
  • (Number of units in PlayerFootmens[IntegerVar]) Less than 12
^
| with this one
V
  • If - Conditions
    • (PlayerVar Food used) Less than 12
| and remove the action:
V
  • Unit Group - Add (Last created unit) to PlayerFootmens[IntegerVar]
"Food Used" is a whole number. Food used can never have decimals. So it's an integer and belongs to a "Integer Comparison" under Player - Property comparison is "Food used"
 
Last edited:
Level 8
Joined
Aug 8, 2011
Messages
297
my footmens dont spawn with a trigger.... is there a simple way i can add this limit ? thanks alot for all the help, but i just need a simple trigger to the system i got now. here is my map:
 

Attachments

  • Dota Footmen Frenzy 6.69.w3x
    2 MB · Views: 42
Level 20
Joined
Jul 14, 2011
Messages
3,213
Omg... I've never seen so much leaks before. You have TONS of them. Your triggers seems like a strainer :p

You have too many triggers. How are you creating the footmen right now?

  • Spawn Footmen
    • Events
      • Time - Every 15.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set Player = (Picked player)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player Food used) Less than 12
            • Then - Actions
              • -------- Barracks -> Footman --------
              • If (((Region centered at (Player start location) with size (384.00, 384.00)) contains (Random unit from (Units owned by Player of type Barracks))) Equal to True) then do (Unit - Create 1 Footman for Player at (Player start location) facing Default building facing degrees) else do (Do nothing)
              • Player - Set Player Food used to ((Player Food used) + 1)
            • Else - Actions
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I found the trigger that creates the footmen and showed you the solution in my last post. Using food for this is like using any other Integer value, but less flexible.

The basic of leaks: Wc3 creates a handle for anything you create during triggers. If you don't remove it, it will be stored but will be useless and stack up as lag.

- Whenever you use a Point reference like
· Position of Unit · Random Point in Region · Center of Region... You're creating a point with X and Y coordinates, and you have to clean it after using it. The way to do this is
1- Create a Point type variable.
2- Before using the point you need in the trigger, you declare it into the variable
  • Set Point = Center of YourRegion
3- When you stop using that point in the trigger, you clean it.
  • Custom Script: call RemoveLocation(udg_Point)
4- NOTE: If you're going to use a different location on your trigger, you have to destroy the first one before adding a new value. They don't overwrite. If you need to work with another point without destroying the first one, create another Point variable and destroy it when you don't need it anymore.

As you can see, I used "udg_Point" and not just "Point". It's because GUI interface shows you the variable name, but the variable code/script is followed by "udg_", no matter the variable type.

- Whenever you work with a Player Group like
· Display to (Player group (Pllayer 1)) the text message · Pick ever player in (Players current status is playing)... You need to create a new group to handle that group of players (even if it's only 1). So you have to do the same you did with the point: Create a "Player Group" variable type, and destroy after using it.
1- Create a Player Group type variable.
2- Before using the Player Group you need in the trigger, you declare it into the variable
  • Set PGroup = (Player Group (Player 1))
3- When you stop using that player group in the trigger, you clean it.
  • Custom Script: call DestroyForce(udg_PGroup)
4- The same note for the point applies for this.

- You already know special effect leaks. You have to destroy them inmediatly after creating them. If you add a "wait" action before, you may create another special effect within that "wait" time, and destroying "Last created special effect" may not remove the first one, since it no longer was the last.

See this action:
  • (((Region centered at (Player start location) with size (384.00, 384.00)) contains (Random unit from (Units owned by Player of type Barracks))) Equal to True) then do (Unit - Create 1 Footman for Player at (Player start location) facing Default building facing degrees) else do (Do nothing)
· (Region centered at (Player start location) with size (384.00, 384.00) · The region does not exist, so, the game creates it just for this action, even if the trigger runs again, it will create it again. The same with the point "Player Start Location".
· (Random unit from (Units owned by Player of type Barracks))) · It involves 3 groups: (Random units from (Units owned by Player ( Units of Type Barracks))) · There are 3 leaks every 15 seconds for each player.
· (Unit - Create 1 Footman for Player at (Player start location) · Again, Player Start Location doesn't exist.

For points use: "call RemoveLocation(udg_YourVariableName)"
For player groups use: "call DestroyForce(udg_YourVariableName)"
For Unit Groups use: "call DestroyGroup((udg_YourVariableName)"
For UnitGroups you can also use: "set bj_wantDestroyGroup = true" before the"Pick every unit" action.

There are tons of guides, threats and webs that gives you information about Wc3 leaks and how to fix them. After a while you'll get the hang of it.
 
Status
Not open for further replies.
Top