• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Unit limitation

Status
Not open for further replies.
Level 1
Joined
Dec 29, 2009
Messages
3
Hi Guys!
I try to trigger an Unit limitation to reduce lags but it won't work like I want =/
I use 5 triggers at this moment:
  • Imp500a
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
      • (Unit-type of (Entering unit)) = Soldier
    • Actions
      • Unit Group - Add (Entering unit) to Imp500
  • Imp500b
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
      • (Number of units in Imp500) >= 500
    • Actions
      • Trigger - Turn on Imp500c <gen>
  • Imp500c
    • Events
      • Time - Every 0.15 seconds of game time
    • Conditions
    • Actions
      • Unit - Kill (Random unit from Imp500)
      • Set countImp = (countImp - 1)
      • Unit Group - Remove (Dying unit) from Imp500
  • Imp500d
    • Events
      • Unit - A unit owned by Player 9 (Grey) Stirbt
    • Conditions
      • ((Dying unit) is in Imp500) Gleich True
    • Actions
      • Unit group - Remove (Dying unit) from Imp500
  • Imp500e
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
      • countImp = 0
      • (Imp500c <gen> is on) = True
    • Actions
      • Trigger - Turn off Imp500c <gen>
      • Set countImp = 50
I tried to use the "for each (integer A) from x to y, do (Actions)" but I'm to dumb. >.>
Sorry for my bad english I tried my best =/
 
Level 2
Joined
Aug 18, 2008
Messages
7
Hi Guys!
I try to trigger an Unit limitation to reduce lags but it won't work like I want =/

This should do what you need:
  • CapUnits
  • Events
    • Unit - A unit Finishes training a unit
  • Conditions
    • (Number of living Soldier units owned by (Owner of (Trained unit))) Greater than or equal to (>=) 500
    • (Unit-type of (Trained unit)) Equal to (==) Soldier
  • Actions
  • Unit - Remove (Trained unit) from the game
Of course, it might be better for your gameplay to prevent the unit from being trained at all, perhaps with a message. Using wc3's food system might be better, if you can use that.
 
Level 12
Joined
May 21, 2009
Messages
994
i think it would be stupid to kill one of the units being trained.. what if the unit is important for a kill or something ? you should stop the unit before it gets trained/created.
like when the unit is being created then check if their is over X amount of those units in the game and if their is remove the unit and display a text to a player or something that writes : "you already have too much of this unit-type"
 
Level 9
Joined
Jul 20, 2009
Messages
427
How exactly do you that?Like you mentioned,order training structure to stop/cancel training if x amount of units is of certain amount?Triggers anyone?
 
Level 12
Joined
May 21, 2009
Messages
994
well i think this should work:
  • remove unit
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit_Number[(Player number of (Triggering player))] + 1) Greater than or equal to 3
        • Then - Actions
          • Unit - Remove (Trained unit) from the game
          • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You have too much u...
        • Else - Actions
          • Set Unit_Number[(Player number of (Triggering player))] = (Unit_Number[(Player number of (Triggering player))] + 1)
and this for setting the number down:

  • remove unit from group
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set Unit_Number[(Player number of (Triggering player))] = (Unit_Number[(Player number of (Triggering player))] - 1)
i tested it and it works fine.. However if you want to give the gold and lumber back you need to know easy jass and download the script: GetUnitCostById() i think you can find it in the jass forum.
 
Level 9
Joined
Jul 20, 2009
Messages
427
Yup it works fine,but is there a way to actually cancel the training so that you won't have to remove the trained unit.
 
Level 9
Joined
Jul 20, 2009
Messages
427
I need something that goes A unit begins training a unit>if no. of units in Temp_Group=0,where Temp_Group is equal to number of units player have of type x.
How do I order the training unit to cancel training.
 
Level 5
Joined
Apr 8, 2008
Messages
88
You want this for one specific unit type or all units owned by that player?

If only one unittype:
  • Cancel training
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
      • (Trained unit-type) Equal to Footman
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Number_of_Footmen[(Player number of (Owner of (Triggering unit)))] Less than 500
        • Then - Actions
          • Set Number_of_Footmen[(Player number of (Owner of (Triggering unit)))] = (Number_of_Footmen[(Player number of (Owner of (Triggering unit)))] + 1)
        • Else - Actions
          • Wait 0.01 seconds
          • Selection - Select (Triggering unit) for (Owner of (Triggering unit))
          • Game - Force (Owner of (Triggering unit)) to press Escape/Cancel
          • Game - Display to (Player group((Owner of (Triggering unit)))) for 5.00 seconds the text: You allready have t...
If all units owned by that player:
  • Cancel training
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Number_of_units[(Player number of (Owner of (Triggering unit)))] Less than 500
        • Then - Actions
          • Set Number_of_units[(Player number of (Owner of (Triggering unit)))] = (Number_of_units[(Player number of (Owner of (Triggering unit)))] + 1)
        • Else - Actions
          • Wait 0.01 seconds
          • Selection - Select (Triggering unit) for (Owner of (Triggering unit))
          • Game - Force (Owner of (Triggering unit)) to press Escape/Cancel
          • Game - Display to (Player group((Owner of (Triggering unit)))) for 5.00 seconds the text: You allready have t...
To set it to - when a unit dies (Footman). Else just take away conditions, and rename the variable "number_of_Footmen" to well --> Number_of_Units.
  • Unit dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
    • Actions
      • Set Number_of_Footmen[(Player number of (Owner of (Triggering unit)))] = (Number_of_Footmen[(Player number of (Owner of (Triggering unit)))] - 1)
 
Level 1
Joined
Dec 29, 2009
Messages
3
Thanks for the replies guys!
I recently tried the Integer A thing and I'm suprised that it worked o0
  • UnitCap
  • Events
    • Time - Every 1.00 seconds of game time
  • Conditions
    • (Number of units in Imp500) Greater than or equal 500
  • Actions
    • For each (Integer A) from 1 to 25 do (Actions)
    • Loop - Actions
      • Unit - Kill (Random unit from Imp500)
      • Unit Group - Remove (Dying unit) from Imp500
I don't know if a dying unit is automatic removed from the unit group.
 
Level 13
Joined
Apr 15, 2008
Messages
1,063
Ok, then you'll need to use the food. You can manipulate used/maximum food through Player - set property, so just increase food used when unit is trained and decrease when it dies (to prevent miscalculations, then synchronize Training Player's food usage with Owning Player's (which directly reflects the amount of footman) every time unit trains/dies). It is the clearest solution, since it won't allow you to start training the footman in the first place, instead of cancelling it just as it started)
 
Level 13
Joined
Apr 15, 2008
Messages
1,063
Wow, didn't know about the 300 limit...
It also would be possible to keep player at 0 food used and decrease food max (it would display 300 for anything above 300, which isn't such a problem). (What I mean is setting food cap to 500-(food used by owner player), which would work, since food used can exceed 300)). Also you can't make tooltip say it needs half a unit.
 
Status
Not open for further replies.
Top