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

One last issue...

Status
Not open for further replies.
Level 5
Joined
Dec 22, 2007
Messages
103
Recently I got help creating a fire Shield Trigger, and after several helpful threads I created this ability:
  • Fire Shield
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Fire Shield
    • Actions
      • Set Daemon = (Triggering unit)
      • Set FireShieldTarget = (Target unit of ability being cast)
      • Wait 0.50 seconds
      • Unit - Add Fire Shield (Bundle) to FireShieldTarget
      • Unit - Set level of Fire Shield (Effect) for FireShieldTarget to (Level of Fire Shield for Daemon)
      • Unit - Set level of Fire Shield Armor for FireShieldTarget to (Level of Fire Shield for Daemon)
      • Unit - Set mana of FireShieldTarget to TargetMana
      • Unit Group - Add FireShieldTarget to FireShieldTargets
      • Trigger - Turn on Fire Shield Targets <gen>
  • Fire Shield Targets
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in FireShieldTargets and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Fire Shield (Armor)) Equal to False
            • Then - Actions
              • Unit - Remove Fire Shield (Bundle) from FireShieldTarget
              • Unit Group - Remove (Picked unit) from FireShieldTargets
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (FireShieldTargets is empty) Equal to True
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
  • Mana Save
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set TargetMana = (Mana of FireShieldTarget)
The Mana Save trigger is to stop targets from losing all of their mana upon
receiving the Fire Shield ability, which oddly always caused a full mana flush
on the unit it was given to. Now the issue is whenever its cast on another
unit while the buff for the first unit is still active, the variable FireShieldTarget
changes and the first target won't lose the ability after its buff runs out.
The second target also loses the ability after the first target's buff runs out
rather than its own buff.
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240
This could work.

  • Fire Shield
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Fire Shield
    • Actions
      • Custom script: local unit udg_FireShieldTarget = GetSpellTargetUnit()
      • Custom script: local real udg_TargetMana = GetUnitState(udg_FireShieldTarget , UNIT_STATE_MANA )
      • Wait 0.50 seconds
      • Unit - Add Fire Shield (Bundle) to FireShieldTarget
      • Unit - Set level of Fire Shield (Effect) for FireShieldTarget to (Level of Fire Shield for Triggering unit)
      • Unit - Set level of Fire Shield Armor for FireShieldTarget to (Level of Fire Shield for Triggering unit)
      • Unit - Set mana of FireShieldTarget to TargetMana
      • Unit Group - Add FireShieldTarget to FireShieldTargets
      • Trigger - Turn on Fire Shield Targets <gen>
  • Fire Shield Targets
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in FireShieldTargets and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Fire Shield (Armor)) Equal to False
            • Then - Actions
              • Unit - Remove Fire Shield (Bundle) from Picked unit
              • Unit Group - Remove *ability* from Picked unit
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (FireShieldTargets is empty) Equal to True
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions


I edited the first trigger a bit. I also changed this line in the looping trigger: Unit - Remove Fire Shield (Bundle) from Picked unit. You don't need the third trigger with this.
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240
Then use

If triggering unit not equal to FireShieldTarget
then Unit - Set mana of FireShieldTarget to TargetMana
else

I edited the looping trigger a bit, it had one error on the ability removal line.

You could add this as the last line of the first trigger:
Custom script: set udg_FireShieldTarget = null
 
Level 5
Joined
Dec 22, 2007
Messages
103
I did both of Maker's suggestions and at first it didn't work. I removed the 0.5
second wait because it was no longer necessary and it worked great. I have
another ability that adds a passive for the buff's duration, and it does the same
mana dump on its targets. Would I use the same two custom scripts and change
their names around for that trigger? I'm not sure
how JASS works yet.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Maker, I thought Blizzard removed the ability to shadow globals?

So did I once, but it still works. A trigger like this is completely MUI:

  • Untitled Trigger 005
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: local unit udg_u1 = GroupPickRandomUnit(GetUnitsInRectAll(gg_rct_Region_000))
      • Unit - Move u1 instantly to (Center of (Playable map area))
      • Wait 5.00 seconds
      • Unit - Kill u1
mana dump on its targets. Would I use the same two custom scripts and change
their names around for that trigger? I'm not sure
how JASS works yet.

If you're not using a wait then you shouldn't need local variables at all.
 
Status
Not open for further replies.
Top