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

[Orb] Percentage Armor Reduce

Status
Not open for further replies.

KPC

KPC

Level 7
Joined
Jun 15, 2018
Messages
178
An orb that reduces armor by 25%. Similar to orb of corruption.

I'm trying to make it using damage engine.

Damage Engine 5.7.1.1

Event is when unit loses hp
Condition Hero manipulating Item - Orb

I'm using Item armor bonus with multiple levels and negative values:
Lvl 1: 0
Lvl 2: - 1
Lvl 3: - 2
etc.

So unit gets armor reduction instantly by having this ability.

Changing its levels changes the value of reduced armor.

I also use Armor Detection System, that makes it possible to get units armor value.
 
Last edited:

KPC

KPC

Level 7
Joined
Jun 15, 2018
Messages
178
I made this so far. But I don't know how to remove effect or keep it properly. I just turn it off after 5 seconds but it also happens when unit is still attacking and still have the effect. It causes it loses effect for a moment with no reason.

  • Events
    • Game - DamageEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (DamageEventSource has an item of type Orb of Reduction) Equal to True
              • IsDamageSpell Equal to False
              • (DamageEventTarget belongs to an enemy of (Owner of DamageEventSource).) Equal to True
              • IsDamageCode Equal to False
              • (Level of Armor Reduction for DamageEventTarget) Less than or equal to 0
        • Then - Actions
          • Custom script: call UnitAddAbility( udg_DamageEventTarget, 'A01X')
          • Wait 0.00 seconds
          • Custom script: call SetUnitAbilityLevel (udg_DamageEventTarget, 'A01X', R2I(GetUnitArmorValue(udg_DamageEventTarget) + 1) )
          • Wait 5.00 seconds
          • Custom script: call UnitRemoveAbility( udg_DamageEventTarget, 'A01X')
        • Else - Actions
 

Attachments

  • Test.w3m
    55.8 KB · Views: 23
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,558
You can't use Waits like that.

DamageEventTarget is a global variable, which means that it can only be set to a single value at a time.

And whenever a unit takes damage, the Damage Engine sets DamageEventTarget to be equal to that damaged unit.

So when you do "Wait 5.00 seconds" and then try to reference DamageEventTarget there's a very high chance that the variable has been set to an entirely different Unit by that time.

Also, the way you're removing the ability is incorrect. You're creating many Waits that will stack up, each Wait removing the ability once finished.

You attack once -> A 5.00 second Wait starts
You attack 1 second later -> Another 5.00 second Wait starts but keep in mind your previous Wait is still running and is now down to 4.00 seconds
You attack 3 seconds later -> Another 5.00 second Wait starts, and now your 1st Wait is down to 1.00 second and your second Wait is down to 2.00 seconds
Etc...

Each time one of these Waits finishes you're going to remove the ability. See the problem?

So how exactly do you want the ability to work?

Do you want it to "refresh" or reset the Wait so that it goes back to 5.00 seconds after every attack. Or do you want each instance of Armor Reduction to wear off after 5.00 seconds (so like after 5.00 seconds the enemy gains 1 Armor back).
 
Last edited:
  • Like
Reactions: KPC

KPC

KPC

Level 7
Joined
Jun 15, 2018
Messages
178
1. I'm not suere but creating local unit might help with damage event overwrites.

2. I wanted it to least 5 secinds from last attack. Idea with gaining 1 armor back per second is very interesting. Seems like the best of those. Just imagine: Orb of Pain reduces the armor by 25% but unit will recover its armor poins coz effect of pain is stopping.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,558
1. I'm not suere but creating local unit might help with damage event overwrites.

2. I wanted it to least 5 secinds from last attack. Idea with gaining 1 armor back per second is very interesting. Seems like the best of those. Just imagine: Orb of Pain reduces the armor by 25% but unit will recover its armor poins coz effect of pain is stopping.
This uses a Unit Indexer, Devotion Aura with -25% Armor, and a local variable (like you mentioned). If you already have a Unit Indexer in your map then make sure not to add another.
  • Armor Reduction
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • IsDamageAttack Equal to True
      • (DamageEventSource has an item of type Mask of Death) Equal to True
    • Actions
      • Custom script: local unit u = udg_DamageEventTarget
      • Set VariableSet CV = (Custom value of DamageEventTarget)
      • Set VariableSet AR_Counter[CV] = (AR_Counter[CV] + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AR_Counter[CV] Equal to 1
        • Then - Actions
          • Unit - Add Armor Reduction to DamageEventTarget
        • Else - Actions
      • Wait 5.00 seconds
      • Custom script: set udg_AR_Unit = u
      • Set VariableSet CV = (Custom value of AR_Unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (AR_Unit is alive) Equal to True
        • Then - Actions
          • Set VariableSet AR_Counter[CV] = (AR_Counter[CV] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AR_Counter[CV] Equal to 0
            • Then - Actions
              • Unit - Remove Armor Reduction from AR_Unit
              • Unit - Remove Armor Reduction buff from AR_Unit
            • Else - Actions
        • Else - Actions
          • Set VariableSet AR_Counter[CV] = 0
      • Custom script: set u = null
It's a fairly simple concept. We keep track of a Counter on our damaged unit, each attack increases the Counter by 1, and 5.00 seconds after that attack the Counter is reduced by 1. If the Counter reaches 0 then we know that the unit hasn't been attacked in the last 5.00 seconds and we can safely remove the Armor Reduction ability from it.

Edit: I forgot to null my local variable. I also forgot to remove the Armor buff. It's fixed now.
 

Attachments

  • Armor Reduction Example 1.w3m
    60.1 KB · Views: 23
Last edited:
Level 24
Joined
Feb 9, 2009
Messages
1,787
@KPC
Please refrain from double post
Follow Grog'nar and use the "Edat Bootan"
edut-bootan-png.316119
 

KPC

KPC

Level 7
Joined
Jun 15, 2018
Messages
178
Armor Reduction

  • joinminus.gif
    events.gif
    Events
    • line.gif
      joinbottom.gif
      game.gif
      Game - DamageEvent becomes Equal to 1.00
  • joinminus.gif
    cond.gif
    Conditions
    • line.gif
      join.gif
      if.gif
      IsDamageAttack Equal to True
    • line.gif
      joinbottom.gif
      if.gif
      (DamageEventSource has an item of type Mask of Death) Equal to True
  • joinbottomminus.gif
    actions.gif
    Actions
    • empty.gif
      join.gif
      page.gif
      Custom script: local unit u = udg_DamageEventTarget
    • empty.gif
      join.gif
      set.gif
      Set VariableSet CV = (Custom value of DamageEventTarget)
    • empty.gif
      join.gif
      set.gif
      Set VariableSet AR_Counter[CV] = (AR_Counter[CV] + 1)
    • empty.gif
      joinminus.gif
      if.gif
      If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • empty.gif
        line.gif
        joinminus.gif
        cond.gif
        If - Conditions
        • empty.gif
          line.gif
          line.gif
          joinbottom.gif
          if.gif
          AR_Counter[CV] Equal to 1
      • empty.gif
        line.gif
        joinminus.gif
        actions.gif
        Then - Actions
        • empty.gif
          line.gif
          line.gif
          joinbottom.gif
          unit.gif
          Unit - Add Armor Reduction to DamageEventTarget
      • empty.gif
        line.gif
        joinbottom.gif
        actions.gif
        Else - Actions
    • empty.gif
      join.gif
      zzz.gif
      Wait 5.00 seconds
    • empty.gif
      join.gif
      page.gif
      Custom script: set udg_AR_Unit = u
    • empty.gif
      join.gif
      set.gif
      Set VariableSet CV = (Custom value of AR_Unit)
    • empty.gif
      joinminus.gif
      if.gif
      If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • empty.gif
        line.gif
        joinminus.gif
        cond.gif
        If - Conditions
        • empty.gif
          line.gif
          line.gif
          joinbottom.gif
          if.gif
          (AR_Unit is alive) Equal to True
      • empty.gif
        line.gif
        joinminus.gif
        actions.gif
        Then - Actions
        • empty.gif
          line.gif
          line.gif
          join.gif
          set.gif
          Set VariableSet AR_Counter[CV] = (AR_Counter[CV] - 1)
        • empty.gif
          line.gif
          line.gif
          joinbottomminus.gif
          if.gif
          If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • empty.gif
            line.gif
            line.gif
            empty.gif
            joinminus.gif
            cond.gif
            If - Conditions
            • empty.gif
              line.gif
              line.gif
              empty.gif
              line.gif
              joinbottom.gif
              if.gif
              AR_Counter[CV] Equal to 0
          • empty.gif
            line.gif
            line.gif
            empty.gif
            joinminus.gif
            actions.gif
            Then - Actions
            • empty.gif
              line.gif
              line.gif
              empty.gif
              line.gif
              join.gif
              unit.gif
              Unit - Remove Armor Reduction from AR_Unit
            • empty.gif
              line.gif
              line.gif
              empty.gif
              line.gif
              joinbottom.gif
              unit.gif
              Unit - Remove Armor Reduction buff from AR_Unit
          • empty.gif
            line.gif
            line.gif
            empty.gif
            joinbottom.gif
            actions.gif
            Else - Actions
      • empty.gif
        line.gif
        joinbottomminus.gif
        actions.gif
        Else - Actions
        • empty.gif
          line.gif
          empty.gif
          joinbottom.gif
          set.gif
          Set VariableSet AR_Counter[CV] = 0
    • empty.gif
      joinbottom.gif
      page.gif
      Custom script: set u = null

Let me ask you about this:

joinminus.gif
cond.gif
If - Conditions
  • empty.gif
    line.gif
    line.gif
    joinbottom.gif
    if.gif
    (AR_Unit is alive) Equal to True
You know, when I test map this causes not removing effect from here when he dies and you revive him.
 
Status
Not open for further replies.
Top