• 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] While Loop

Status
Not open for further replies.
Level 3
Joined
Feb 14, 2009
Messages
30
hello Hive.

I've got an issue with a trigger for a spell...

The spell is like water shield from World of Warcraft, if you know about it;

It gives mana regen per 5 seconds (mp5) for aslong as the shield lasts.
Now this wouldn't be an issue for me if it was permanent, but i'm not the best when it comes to triggers so i need help with it.

so while the buff of the water shield is on the target (it can only target self) it should increase the value of the int variable "Mana_Per_5" by 12 which is easy but when the buff runs out those 12 mp5 needs to disappear.

in short: while water shield buff is up increase "mana_per_5" by 12. when the buff fades decrease "mana_per_5" by 12.


could also use some help with the actual mana give trigger which currently looks like:
  • give mp5
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Set mana of Player_Character[1] to ((Mana of Player_Character[1]) + (Real(mana_Per_5[1])))
      • Unit - Set mana of Player_Character[2] to ((Mana of Player_Character[2]) + (Real(mana_Per_5[2])))
      • Unit - Set mana of Player_Character[3] to ((Mana of Player_Character[3]) + (Real(mana_Per_5[3])))
      • Unit - Set mana of Player_Character[4] to ((Mana of Player_Character[4]) + (Real(mana_Per_5[4])))
      • Unit - Set mana of Player_Character[5] to ((Mana of Player_Character[5]) + (Real(mana_Per_5[5])))
      • Unit - Set mana of Player_Character[6] to ((Mana of Player_Character[6]) + (Real(mana_Per_5[6])))
      • Unit - Set mana of Player_Character[7] to ((Mana of Player_Character[7]) + (Real(mana_Per_5[7])))
      • Unit - Set mana of Player_Character[8] to ((Mana of Player_Character[8]) + (Real(mana_Per_5[8])))
It could use some optimization

and the mana_per_5 variable is changed with either:
  • Set mana_Per_5[(Player number of (Owner of (Hero manipulating item)))] = (mana_Per_5[(Player number of (Owner of (Hero manipulating item)))] + X)
or:
  • Set mana_Per_5[(Player number of (Owner of (Learning Hero)))] = (mana_Per_5[(Player number of (Owner of (Learning Hero)))] + X)
Depending on if it's when you get an item with mp5 or when you learn a skill that gives mp5
 
Last edited by a moderator:
First, declare a new integer variable. (Let's assume it's called Index)

And viola:

  • give mp5
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • For each Index from 1 to 8, do (Actions)
        • Loop - Actions
          • Unit - Set mana of Player_Character[Index] to ((Mana of Player_Character[Index]) + (Real(mana_Per_5[Index])))
There we go, much better.

edit
Now as for the variation you want, I'll get to that in a moment.

edit

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • ((YouUnit) has buff YourBuff) Equal to True
    • Then - Actions
      • give the unit mana_per_5 + 12
    • Else - Actions
      • give the unit mana_per_5
That should do it.

edit
Your final trigger should probably look like this:

  • Give Mana
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • For each Index from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Player_Character[Index] Not Equal to No unit
              • (Player_Character[Index] is Alive) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Player_Character[Index] has buff Water Shield) Equal to True
                • Then - Actions
                  • Unit - Set mana of Player_Character[Index] to ((Mana of Player_Character[Index]) + (Real(mana_Per_5[Index])) + 12.00)
                • Else - Actions
                  • Unit - Set mana of Player_Character[Index] to ((Mana of Player_Character[Index]) + (Real(mana_Per_5[Index])))
            • Else - Actions
 
Level 3
Joined
Feb 14, 2009
Messages
30
cheers magtheridon! that worked perfectly between all players :D +rep

also i don't use rejuvenation ability because is is gonna be used by the druid so i don't want the buffs to override eachother.
 
Status
Not open for further replies.
Top