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

Creating and Removing unit loop trigger with food counter

Status
Not open for further replies.
Level 3
Joined
Jul 19, 2014
Messages
38
Hi there! I will explain the situation; Food : 0/1 . Hero food occupied : 1. So, I wanted to remove a unit when you pick a hero from a tavern and create a unit when the food cap. becomes greater, as you can realize, this is a loop system, where a unit will be removed when you pick a hero and a unit will be created when you augment your food capacity. I can´t get it by myself, so please, someone can help me with that??? If you want more information of what I really want to do I can give you. Thanks for read!!
 
Level 5
Joined
Jan 5, 2012
Messages
116
Can you explain it better? You want to remove a unit somewhere when the player picks a hero and create one when the food becomes greater than 1?
If I understand correctly, you want something like this but with your own regions and units.
To remove unit when hero is picked :
  • Remove Unit
    • Events
      • Unit - A unit enters Tavern Region <gen>
    • Conditions
      • ((Entering unit) is A Hero) Equal to True
      • (Owner of (Entering unit)) Equal to Player 1 (Red)
    • Actions
      • Unit - Remove Footman 0000 <gen> from the game
To create unit when food becomes greater than 1 :
  • Create unit
    • Events
      • Player - Player 1 (Red)'s Food cap becomes Greater than 1.00
    • Conditions
    • Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
 
Level 3
Joined
Jul 19, 2014
Messages
38
Okey. You understood it very well, but this event has to happen everytime it becomes greater, not just when its greater than 1 (I believe if I do it like that, it will happen just 1 time because then, it's going to be always greater than 1). Your first trigger may be a good solution, I didn't think about the Hero that is picked, it was a good way !! But, What about the second trigger that creates the unit?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
You must do "Player - Player 1 (Red)'s Food cap becomes Greater than PlayerMaxFood[1]"
"Player - Player 2 (Blue)'s Food cap becomes Greater than PlayerMaxFood[2]"
etc etc etc.
As an action, you set the PlayerMaxFood[Number of player] to the new food cap.

GUI doesnt support variables inside that event but JASSHelper doesn't give an error.
I suppose that it would work but am not 100% sure.
Ofcourse you must make the event in JASS.
JASS:
call TriggerRegisterPlayerStateEvent(gg_trg_Your_Trigger_Name, Player(0), PLAYER_STATE_RESOURCE_FOOD_CAP, GREATER_THAN, udg_PlayerMaxFood[0])
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
You can't use variables in that event, (doesn't matter you use JASS or not, technically you can use variables but it won't change the result.You can't change value in event after it is written)You need to detect when the food increases.
 
Status
Not open for further replies.
Top