• 🏆 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!

Need help limiting unit creation

Status
Not open for further replies.
Level 7
Joined
Jul 1, 2008
Messages
1,025
I'm trying to limit the amount of units players can buy but my map uses a slightly different form of unit creation, instead they buy an item and it automaticaly spawns units for them. Heres the trigger, I don't have the WE on this comp so this is from memory, the basic working trigger is there though:

  • Event-Unit uses an item
  • Condition- Item being maipulated equal to -Footmen equal to true
  • Action- Create 3 footmen at (position of (Triggering Unit)) for (owner of (Triggering Unit)).
The problem is he can still get units when his food limit is exceeded, I realy need to sort this out otherwise he could get like thousands of units lagging out the map. I want him to be limited to just 50 food.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
you can set the amount of food consumed by a unit in object editor, so yes different units can take different amounts of food

Hopeless...

Some clearing for you and any other hopeless person that happens to read this thread: "(Owner of (Triggering unit)) Food used) Less than 50" has a little problem
if you have 49 food atm and create a unit with 40 food consumption, you will go over the limit of 50.

As I said hopeless ...
 
Level 13
Joined
Nov 4, 2006
Messages
1,239
lol, then don't use questionmarks, i thought you was asking for that, use an arithmetic, if (food consumed by player + food consumed by footman) is bigger then 50, then do "display message: you cannot summon any more units" else do "create Units"
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Have you heard of a little thing called rethorical questions?
You make it sound so easy.
I can imagine the wall of code that will be the result from this(on account that there a lot of units that can be produced).
 
Level 13
Joined
Nov 4, 2006
Messages
1,239
well according to his trigger he is using a different one for each unit type, so it will be one action to make then copy paste it into every trigger and change the additional food value, don't devalue my suggestion unless you can come up with a better one
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Lol.

  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to (==) Tome of Experience
          • (Player 1 (Red) Food used) Less than (<) 50
        • Then - Actions
          • Do nothing
        • Else - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to (==) Tome of Experience
              • (Player 1 (Red) Food used) Less than (<) 50
            • Then - Actions
              • Do nothing
            • Else - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-type of (Item being manipulated)) Equal to (==) Tome of Experience
                  • (Player 1 (Red) Food used) Less than (<) 50
                • Then - Actions
                  • Do nothing
                • Else - Actions
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Item-type of (Item being manipulated)) Equal to (==) Tome of Experience
                      • (Player 1 (Red) Food used) Less than (<) 50
                    • Then - Actions
                      • Do nothing
                    • Else - Actions
                      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Item-type of (Item being manipulated)) Equal to (==) Tome of Experience
                          • (Player 1 (Red) Food used) Less than (<) 50
                        • Then - Actions
                          • Do nothing
                        • Else - Actions
                          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Item-type of (Item being manipulated)) Equal to (==) Tome of Experience
                              • (Player 1 (Red) Food used) Less than (<) 50
                            • Then - Actions
                              • Do nothing
                            • Else - Actions
                              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Item-type of (Item being manipulated)) Equal to (==) Tome of Experience
                                  • (Player 1 (Red) Food used) Less than (<) 50
                                • Then - Actions
                                  • Do nothing
                                • Else - Actions
                                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • (Item-type of (Item being manipulated)) Equal to (==) Tome of Experience
                                      • (Player 1 (Red) Food used) Less than (<) 50
                                    • Then - Actions
                                      • Do nothing
                                    • Else - Actions
                                      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • (Item-type of (Item being manipulated)) Equal to (==) Tome of Experience
                                          • (Player 1 (Red) Food used) Less than (<) 50
                                        • Then - Actions
                                          • Do nothing
                                        • Else - Actions
                                          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            • If - Conditions
                                              • (Item-type of (Item being manipulated)) Equal to (==) Tome of Experience
                                              • (Player 1 (Red) Food used) Less than (<) 50
                                            • Then - Actions
                                              • Do nothing
                                            • Else - Actions

G, that ain't too long, and it is only for 10 items. What if there are 100?
If you are wrong, why shouldn't I say you are wrong.
Anyway, I have not said you are wrong, I said that you would do something like what is above(or worse) which would be a waste of space.
Create 2(or 3) Arrays.
In first array store the item types of all the items that are going to "summon" units. In the second array, in the corresponding indexes store what type of unit is going to be summoned by the item.
(in the 3-rd you can store how many units are going to be summoned by that item(this would be good only if different items can summon different number of units))
When the trigger fires(item has been sold), you have to check what is the index of the item type in the first array. That can be done with a loop ...
Here is an example:
  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to (==) (ConvertItemType(udg_array1[bj_forLoopAIndex]))
              • ((Owner of (Buying unit)) Food used) Less than or equal to (<=) (50 - (Supply used by (ConvertUnitType(udg_array2[bjforLoopAIndex]))))
            • Then - Actions
              • Unit - Create array3[(Integer A)] (ConvertUnitType(udg_array2[bjforLoopAIndex])) for (Owner of (Buying unit)) at (Center of (Playable map area)) facing Default building facing (270.0) degrees
            • Else - Actions
Disadvantages of this method:
You have to store everything in the arrays
Advantages:
This is shorter than the hidden one(a lot, and this is as long as it gets while the hidden one gets longer and longer per item)
This way you can have as much items as you like.
P.s. Storing can be done in various places, like initialization trigger.
Edit: forgot a little something, added it, also know that I made that trigger in JNGP using the jass options.
 
Level 7
Joined
Jul 1, 2008
Messages
1,025
o0 that looks complicated :confused: I'm not all that great at scripts and variables so I'd prefer to keep it as simple as posible, I can't even find this condition:


  • Conditions
    • ((Owner of (Triggering unit)) Food used) Less than 50

Anyone know what condition type this is under? I cant find it

As the items spawn footmen in groups of 3 the maximum the player can exceed his food limit at 49 is 5 so it won't be game imbalancing if he goes abit over. I'd rather that than making things complicated. I got way more infomation than I expected, thanks!
 
Level 17
Joined
May 6, 2008
Messages
1,598
How about first checking first. then create a footman. then check again, and create a footman, then check again, then create a footman, if it's possible, it should be possible.

Stacking If > then > else.
 
Status
Not open for further replies.
Top