• 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.
  • It's time for the first HD Modeling Contest of 2025. Join the theme discussion for Hive's HD Modeling Contest #7! Click here to post your idea!

Income if unit is alive

Status
Not open for further replies.
Level 9
Joined
May 30, 2008
Messages
430
This Thread don't have Prefix becouse i understood little JASS and i know GUI.
I was about to make a trigger that give to a player x amount of gold if his hero is alive every 30 seconds (when the hero is revived count 30 second and give gold until the hero die). I am about to do it in GUI but it appear there is no stop option for a timers i am wondering if i start the same timer again the time will be again 30 seconds and everything OK. Next problem is that in events i can't loop so i need 12 separete triggers for every player which i don't like, i am sure all this could be done in JASS with no more than 10-15 lines +rep for the first good trigger that i approve:wink:
 
Level 16
Joined
Jul 21, 2008
Messages
1,121
Try this trigger:
  • Income
    • Events
      • Time - Every X seconds of game time
    • Conditions
    • Actions
      • Set TempGroup = (Units in (Playable map area))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to <Your Unit>
            • Then - Actions
              • Player - Add X to (Owner of (Picked unit)) Current gold
              • Player - Add X to (Owner of (Picked unit)) Current lumber
            • Else - Actions
      • Custom script: call DestroyGroup(udg_TempGroup)
 
Well, you need to make an initialization temp player group, where:
  • Trigger1
  • Events
    • Time - Elapsed time is 0.00 seconds (or, if you create the heroes through another trigger, don't add this event, but have an action at that trigger "Trigger - Run Trigger1 <gen> (ignoring conditions)")
  • Conditions
  • Actions
    • Set T_G = (Players matching ((Matching Player) slot Equal to Is playing) and (Matching Player controller) Equal to User)
    • Player Group - Pick up every player in (T_G) and do (Actions)
      • Loop - Actions
        • Set Alive[Player Number of (Picked Player)]= True
  • Trigger2
  • Events
    • Time - Every 30.00 seconds of game-time
  • Conditions
  • Actions
    • Player Group - Pick up every player in (T_G) and do (Actions)
      • Loop - Actions
        • Set UnitGroup = (Units owned by (Picked Player) matching (((Matching unit) is a Hero) Equal to True))
        • Unit Group - Pick up every unit in (UnitGroup) and do (Actions)
          • Loop - Actions
            • If (Conditions)
              • ((Picked unit) is alive) Equal to True
              • Active[Player Number of (Picked Player)] Equal to True
            • Then (Actions)
              • Player - Add 300 to (Picked Player)'s current gold
            • Else (Actions)
          • Custom script: call DestroyGroup (udg_UnitGroup)
  • Trigger3
  • Events
    • Unit - A unit dies
  • Conditions
  • Actions
    • Set Alive[Player Number of (Owner of (Dying unit))] = False
**"Alive" is a boolean variable, with array.
 
Level 9
Joined
May 30, 2008
Messages
430
Both triggers will work but both have the same problem, if the hero is revived when at every 30 seconds left 15 seconds to 0 the players hero have to be alive only 15 seconds to get the gold not 30. The trigger itself have to be with periodic timers not every x seconds.



And there is a question about the timers if some one can help me: is there a command to STOP a periodic timer (after this i have to be able to start it again) becouse in GUI i can see only option "Pause" not "Stop"
 
Status
Not open for further replies.
Top