Power Shield

TzalDadok

New Member
Reaction score
2
This is a triggered spell I made, is called Power Shield. I know it has been done but im the kind of guy who learns by doing and correcting.

The thing with this spell is that, when I use it, the target heals each time is hit. Kind of Lord of Avernus ultimate.

What I want to achieve is a shield that just absorbs damage.

Thanks for your help :D

Trigger:
  • Power Shield 1
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Power Shield
    • Actions
      • Set PowerShield_SkillLevel = (PowerShield_SkillLevel + 1)


Trigger:
  • Power Shield 2
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Power Shield
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PowerShield_SkillLevel Equal to 1
        • Then - Actions
          • Set PowerShield_Caster = (Casting unit)
          • Set PowerShield_Target = (Target unit of ability being cast)
          • Set PowerShield_ShieldLife = 200.00
          • Set PowerShield_Activate = True
          • Countdown Timer - Start PowerShield_Timer as a One-shot timer that will expire in 15.00 seconds
          • Trigger - Add to Power Shield DeActivate 1 <gen> the event (Game - PowerShield_ShieldLife becomes Less than or equal to 0.00)
          • Trigger - Add to Power Shield Activate <gen> the event (Unit - PowerShield_Target Takes damage)
          • Unit - Create 1 Dummy for Player 1 (Red) at (Position of PowerShield_Target) facing Default building facing degrees
          • Unit - Order (Last created unit) to Neutral Pit Lord - Howl Of Terror
          • Unit - Remove (Last created unit) from the game
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PowerShield_SkillLevel Equal to 2
            • Then - Actions
              • Set PowerShield_Caster = (Casting unit)
              • Set PowerShield_Target = (Target unit of ability being cast)
              • Set PowerShield_ShieldLife = 300.00
              • Set PowerShield_Activate = True
              • Countdown Timer - Start PowerShield_Timer as a One-shot timer that will expire in 20.00 seconds
              • Trigger - Add to Power Shield DeActivate 1 <gen> the event (Game - PowerShield_ShieldLife becomes Less than or equal to 0.00)
              • Trigger - Add to Power Shield Activate <gen> the event (Unit - PowerShield_Target Takes damage)
              • Unit - Create 1 Dummy for Player 1 (Red) at (Position of PowerShield_Target) facing Default building facing degrees
              • Unit - Order (Last created unit) to Neutral Pit Lord - Howl Of Terror
              • Unit - Remove (Last created unit) from the game
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • PowerShield_SkillLevel Equal to 3
                • Then - Actions
                  • Set PowerShield_Caster = (Casting unit)
                  • Set PowerShield_Target = (Target unit of ability being cast)
                  • Set PowerShield_ShieldLife = 400.00
                  • Set PowerShield_Activate = True
                  • Countdown Timer - Start PowerShield_Timer as a One-shot timer that will expire in 25.00 seconds
                  • Trigger - Add to Power Shield DeActivate 1 <gen> the event (Game - PowerShield_ShieldLife becomes Less than or equal to 0.00)
                  • Trigger - Add to Power Shield Activate <gen> the event (Unit - PowerShield_Target Takes damage)
                  • Unit - Create 1 Dummy for Player 1 (Red) at (Position of PowerShield_Target) facing Default building facing degrees
                  • Unit - Order (Last created unit) to Neutral Pit Lord - Howl Of Terror
                  • Unit - Remove (Last created unit) from the game
                • Else - Actions
                  • Set PowerShield_Caster = (Casting unit)
                  • Set PowerShield_Target = (Target unit of ability being cast)
                  • Set PowerShield_ShieldLife = 500.00
                  • Set PowerShield_Activate = True
                  • Countdown Timer - Start PowerShield_Timer as a One-shot timer that will expire in 30.00 seconds
                  • Trigger - Add to Power Shield DeActivate 1 <gen> the event (Game - PowerShield_ShieldLife becomes Less than or equal to 0.00)
                  • Trigger - Add to Power Shield Activate <gen> the event (Unit - PowerShield_Target Takes damage)
                  • Unit - Create 1 Dummy for Player 1 (Red) at (Position of PowerShield_Target) facing Default building facing degrees
                  • Unit - Order (Last created unit) to Neutral Pit Lord - Howl Of Terror
                  • Unit - Remove (Last created unit) from the game


Trigger:
  • Power Shield Activate
    • Events
    • Conditions
      • PowerShield_Activate Equal to True
    • Actions
      • Unit - Set life of PowerShield_Target to ((Life of PowerShield_Target) + (Damage taken))
      • Set PowerShield_ShieldLife = (PowerShield_ShieldLife - (Damage taken))


Trigger:
  • Power Shield DeActivate 1
    • Events
    • Conditions
    • Actions
      • Unit - Remove Power Shield buff from PowerShield_Target
      • Set PowerShield_Activate = False


Trigger:
  • Power Shield DeActivate 2
    • Events
      • Time - PowerShield_Timer expires
    • Conditions
      • PowerShield_Activate Equal to True
    • Actions
      • Unit - Remove Power Shield buff from PowerShield_Target
      • Set PowerShield_Activate = False
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
you add the events every time the unit casts the ability, so on the second time it begins triggering twice every time the unit takes damage

in order to remove events you need to trigger it in jass, and in order to not add it multiple times you need to have a boolean check where if this is true it adds it if not then it doesnt, but you need that for every unit
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
every trigger can have fire off any event in the trigger
even if that event has multiple copies of itself...
and you create the event: Casting Unit takes damage; multiple times in one trigger, so it fires a bunch off of 1 time being damaged, resulting in a heal, you need to only add the event once or destroy the event after its finished
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
What GFreak means is that, every time you cast the ability, an instance of the same event is added to the Activate trigger. Thus, on the Xth time you cast the ability, there will be X of the same events in the trigger, so the actions take place X times.

Do you need this for multiple units, or only one? I feel like trying to make it.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
create a hashtable at map initialization and do this instead of the add event:
Trigger:
  • if then else
    • If
      • (Hashtable - load boolean (key triggering unit) of 1 in last created hashtable) is not equal to true (boolean comparison)
    • Then
      • Add your event
      • Hashtable - Save boolean true as (key Triggering Unit) of 1 in last created hashtable)
    • Else
 

Dirac

22710180
Reaction score
147
Instead of encouraging users to use hashtables, link them to a good GUI unit indexing system and have them use the unit's custom value
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
usually i do, but when triggering in gui i prefer to use hashtables, you can use only 1 to store all the information you need and you can use unit handles as the keys, thats good enough for me, and its pretty simple, when i was a noob and i got directed to AIDS i got confused as shit
 

Dirac

22710180
Reaction score
147
Using hashtables for everything is just a bad idea, i know that handling variables in GUI is a huge pain, but that's what you get for coding in GUI.
Create array variables for each ability and use custom value of units as their index.
 

BloodySkullz

Active Member
Reaction score
10
yea, i tink that array variables and custom value are easier to understand than hashtables. though each has its own pros n cons.

But the user do not need the spell to be MUI, so just normal variables will do.
 

TzalDadok

New Member
Reaction score
2
LOL, I really dont understand any of the things above :p

I'll start reading tutorials.

¿Isn't any action available that can remove event?
 

TzalDadok

New Member
Reaction score
2
Now I modified some stuff and the trigger stopped working and I don't know why xD

Can someone help me please. This is what i have now:

Trigger:
  • Power Shield 1
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Power Shield
    • Actions
      • Set PowerShield_SkillLevel = (PowerShield_SkillLevel + 1)


Trigger:
  • Power Shield 2
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Power Shield
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PowerShield_SkillLevel Equal to 1
        • Then - Actions
          • Set PowerShield_Caster = (Casting unit)
          • Set PowerShield_Target = (Target unit of ability being cast)
          • Set PowerShield_ShieldLife = 200.00
          • Countdown Timer - Start PowerShield_Timer as a One-shot timer that will expire in 15.00 seconds
          • Trigger - Add to Power Shield DeActivate 1 <gen> the event (Game - PowerShield_ShieldLife becomes Less than or equal to 0.00)
          • Unit - Create 1 Dummy for Player 1 (Red) at (Position of PowerShield_Target) facing Default building facing degrees
          • Unit - Order (Last created unit) to Neutral Pit Lord - Howl Of Terror
          • Unit - Remove (Last created unit) from the game
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PowerShield_SkillLevel Equal to 2
            • Then - Actions
              • Set PowerShield_Caster = (Casting unit)
              • Set PowerShield_Target = (Target unit of ability being cast)
              • Set PowerShield_ShieldLife = 300.00
              • Countdown Timer - Start PowerShield_Timer as a One-shot timer that will expire in 20.00 seconds
              • Trigger - Add to Power Shield DeActivate 1 <gen> the event (Game - PowerShield_ShieldLife becomes Less than or equal to 0.00)
              • Unit - Create 1 Dummy for Player 1 (Red) at (Position of PowerShield_Target) facing Default building facing degrees
              • Unit - Order (Last created unit) to Neutral Pit Lord - Howl Of Terror
              • Unit - Remove (Last created unit) from the game
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • PowerShield_SkillLevel Equal to 3
                • Then - Actions
                  • Set PowerShield_Caster = (Casting unit)
                  • Set PowerShield_Target = (Target unit of ability being cast)
                  • Set PowerShield_ShieldLife = 400.00
                  • Countdown Timer - Start PowerShield_Timer as a One-shot timer that will expire in 25.00 seconds
                  • Trigger - Add to Power Shield DeActivate 1 <gen> the event (Game - PowerShield_ShieldLife becomes Less than or equal to 0.00)
                  • Unit - Create 1 Dummy for Player 1 (Red) at (Position of PowerShield_Target) facing Default building facing degrees
                  • Unit - Order (Last created unit) to Neutral Pit Lord - Howl Of Terror
                  • Unit - Remove (Last created unit) from the game
                • Else - Actions
                  • Set PowerShield_Caster = (Casting unit)
                  • Set PowerShield_Target = (Target unit of ability being cast)
                  • Set PowerShield_ShieldLife = 500.00
                  • Countdown Timer - Start PowerShield_Timer as a One-shot timer that will expire in 30.00 seconds
                  • Trigger - Add to Power Shield DeActivate 1 <gen> the event (Game - PowerShield_ShieldLife becomes Less than or equal to 0.00)
                  • Unit - Create 1 Dummy for Player 1 (Red) at (Position of PowerShield_Target) facing Default building facing degrees
                  • Unit - Order (Last created unit) to Neutral Pit Lord - Howl Of Terror
                  • Unit - Remove (Last created unit) from the game


Trigger:
  • Power Shield Activate
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacked unit) has buff Power Shield ) Equal to True
    • Actions
      • Unit - Set life of PowerShield_Target to ((Life of PowerShield_Target) + (Damage taken))
      • Set PowerShield_ShieldLife = (PowerShield_ShieldLife - (Damage taken))


Trigger:
  • Power Shield DeActivate 1
    • Events
    • Conditions
    • Actions
      • Unit - Remove Power Shield buff from PowerShield_Target


Trigger:
  • Power Shield DeActivate 2
    • Events
      • Time - PowerShield_Timer expires
    • Conditions
    • Actions
      • Unit - Remove Power Shield buff from PowerShield_Target
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
because being attacked isnt the part of the attack the deals damage, there is no damage done yet, its when the unit begins to swing or fire it's projectile, just do this, whenever a unit learns the ability for the first time then add the damage event to that trigger, and change the actions to set the values to the greater value between what they are setting to now and 0
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
1). Since there's only one unit, you don't need a variable to track the level of Power Shield. Just use [Level of Power Shield for YourUnit].
2). Don't use multiple Ifs. First, bring all the actions that happen regardless of level OUT of the If block into the main trigger. Then use simple formulae to find the values that depend on level, i.e. (10 + (5 x Level)) for the number of seconds on the timer and (100 + (100 x Level)) for PowerShield_ShieldLife.
3). Don't add the event each time. Just make a single trigger with ONE event - [PowerShield_ShieldLife becomes Less than or equal to 0.00]. Otherwise the trigger runs once every time the event is added.
4). Give the "Howl of Terror" effect to the main ability instead of making a dummy to cast it.
5). Check the leak guide and remove all your leaks.
6). Make just ONE trigger with the event [YourUnit takes damage] instead of A unit is attacked. GFreak's post above explains why.
7). There's hardly any point in having a timer in the first place. Make the ability place a buff on the unit, and check for the presence of THAT buff instead.
8). Try adding this If block for the damage negation:
Trigger:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Life of (Triggering unit)) Equal to (Max life of (Triggering unit))
    • Then - Actions
      • Wait 0.00 seconds
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))
    • Else - Actions
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))

and make sure it goes at the end of the damage negation trigger. The Wait avoids adding HP before the damage is taken, which seems to happen last.
 

TzalDadok

New Member
Reaction score
2
Ok, taking everything I could understand from your answers i got this:

Trigger:
  • Power Shield
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Power Shield
    • Actions
      • Set PowerShield_Caster = (Casting unit)
      • Set PowerShield_Target = (Target unit of ability being cast)
      • Unit - Create 1 Dummy for Player 1 (Red) at (Position of PowerShield_Target) facing Default building facing degrees
      • Unit - Order (Last created unit) to Neutral Pit Lord - Howl Of Terror
      • Unit - Remove (Last created unit) from the game
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Power Shield for PowerShield_Caster) Equal to 1
        • Then - Actions
          • Set PowerShield_ShieldLife = 200.00
          • Countdown Timer - Start PowerShield_Timer as a One-shot timer that will expire in 15.00 seconds
          • Trigger - Add to Power Shield Activate <gen> the event (Unit - PowerShield_Target Takes damage)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Power Shield for PowerShield_Caster) Equal to 2
            • Then - Actions
              • Set PowerShield_ShieldLife = 300.00
              • Countdown Timer - Start PowerShield_Timer as a One-shot timer that will expire in 20.00 seconds
              • Trigger - Add to Power Shield Activate <gen> the event (Unit - PowerShield_Target Takes damage)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Power Shield for PowerShield_Caster) Equal to 3
                • Then - Actions
                  • Set PowerShield_ShieldLife = 400.00
                  • Countdown Timer - Start PowerShield_Timer as a One-shot timer that will expire in 25.00 seconds
                  • Trigger - Add to Power Shield Activate <gen> the event (Unit - PowerShield_Target Takes damage)
                • Else - Actions
                  • Set PowerShield_ShieldLife = 500.00
                  • Countdown Timer - Start PowerShield_Timer as a One-shot timer that will expire in 30.00 seconds
                  • Trigger - Add to Power Shield Activate <gen> the event (Unit - PowerShield_Target Takes damage)


Trigger:
  • Power Shield Activate
    • Events
    • Conditions
      • (PowerShield_Target has buff Power Shield ) Equal to True
    • Actions
      • Unit - Set life of PowerShield_Target to ((Life of PowerShield_Target) + (Damage taken))
      • Set PowerShield_ShieldLife = (PowerShield_ShieldLife - (Damage taken))


Trigger:
  • Power Shield DeActivate 1
    • Events
      • Game - PowerShield_ShieldLife becomes Less than or equal to 0.00
    • Conditions
    • Actions
      • Unit - Remove Power Shield buff from PowerShield_Target


Trigger:
  • Power Shield DeActivate 2
    • Events
      • Time - PowerShield_Timer expires
    • Conditions
    • Actions
      • Unit - Remove Power Shield buff from PowerShield_Target


I still have the unit takes damage event stacking problem. I didn't understand what's the solution for this. Thanks to all you are being really helpful.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
do you know what if then else functions are?
Trigger:
  • If (all conditions are true), Then (do actions), Else (do actions)
    • If (all conditions are true)
      • Some Condition <----- if this is true it does the then actions, if not it does the else actions but you dont need any actions in either section
    • Then (do actions)
      • Do some actions
    • Else (do actions)
      • Do some actions


you use this to add a condition to adding the damage event, you can do this by creating a variable named Damage_Event_Added (boolean variable with a default value of false) then do this:

Trigger:
  • If (all conditions are true), Then (do actions), Else (do actions)
    • If (all conditions are true)
      • Damage_Event_Added is equal to False (boolean condition)
    • Then (do actions)
      • Trigger - Add to Power Shield Activate <gen> the event (Unit - PowerShield_Target Takes damage)
      • Set Damage_Event_Added = True
    • Else (do actions)
      • Do some actions


replace the damage event actions with this
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
There's only ONE unit that has this skill, right? Then just put the event
Trigger:
  • Unit - PowerShield_Target Takes damage

into the trigger. If you keep adding events into the trigger, it will definitely fail.

Also, use formulas for your timer and Shield_Life values, with Level of Ability being the constant.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top