• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Universal+stacking lifesteal issues (particularly with illusions)

Status
Not open for further replies.
Hello,

In my map I am trying to make a triggered life steal that works for every units attack type (melee, ranged) and compatible with orb effects. I also want that it stacks.


To do so, I made the trigger that periodically check units every 0.25s for lifesteal-items/lifesteal-abilities/lifesteal-buffs, computes the stacked life steal percentage, and then gives a vampiric potion to the unit that gives the right percentage for 0.5s. Because vampiric potions work with ranged units, orbs, splashs/multi-attacks :)

In WE, I changed all abilities/buffs to 0% life steal (=dummy abilities) and removed abilities from lifesteal items (=dummy items). Also, because "Create item and give it to hero" makes the item visible on the floor for a short time, I set the model of my vampiric potions to dummy.mdx.

It works fine for heroes, and units without inventory (my map doesn't have units with inventory). However it does not work for illusions.


- Vampiric aura from other source displays a buff but have no effect (even in melee).
- Vampiric aura from self displays the effect but have no effect (even in melee).
- Vampiric potion with use when acquired: no effect or cannot be used (I don't know...).
- Adding Item Life Steal (Mask of Death) or Life Steal (Frostmourne) ability: no effect.
- Adding an item with Life Steal Ability: works.


Do you see a good solution to handle life steal on illusions please ? Better than hopping there is a free slow in their inventory, and adding an item that gives life steal...

For dummy lifesteal items, I can replace them by effective lifesteal items when illusions enter the map. What about the other cases (Abilities or buffs that give lifesteal) ???

My code below:
  • UniversalLifeSteal
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) controller) Equal to User
            • Then - Actions
              • Set TempGroup = (Units owned by (Player((Integer A))))
              • 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
                      • ((Picked unit) is A structure) Equal to False
                      • ((Picked unit) is dead) Equal to False
                      • ((Picked unit) is hidden) Equal to False
                      • ((Picked unit) is paused) Equal to False
                      • ((Picked unit) is Stunned) Equal to False
                      • ((Picked unit) is Sleeping) Equal to False
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) is an illusion) Equal to True
                        • Then - Actions
                          • [...] (What can I do ??)
                        • Else - Actions
                          • Set TempReal = 0.00
                          • -------- Check aura effects --------
                          • [...] (Increasing TempReal value depending of dummy lifesteal buffs the unit have)
                          • -------- Check abilities --------
                          • [...] (Increasing TempReal value depending of dummy lifesteal abilities the unit have)
                          • -------- If hero, check items with life steal --------
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • ((Picked unit) is A Hero) Equal to True
                            • Then - Actions
                              • [...] (Increase TempReal according to carried dummy lifesteal items)
                            • Else - Actions
                              • Do nothing
                          • -------- All my lifesteals are multiple of 0.5 (=50%) --------
                          • Set TempNumber = (Integer((TempReal / 0.50)))
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • TempNumber Equal to 0
                            • Then - Actions
                              • Do nothing
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • ((Picked unit) is A Hero) Equal to True
                                • Then - Actions
                                  • Do nothing
                                • Else - Actions
                                  • Unit - Add Stacked Life Steal Unit Inventory (Human) to (Picked unit)
                              • Hero - Create StackedLifeStealLevels[TempNumber] and give it to (Picked unit)
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • ((Picked unit) is A Hero) Equal to True
                                • Then - Actions
                                  • Do nothing
                                • Else - Actions
                                  • Unit - Remove Stacked Life Steal Unit Inventory (Human) from (Picked unit)
                              • -------- Safety check: in cases where the unit could not fetch the item, delete it --------
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • ((Last created item) is owned) Equal to False
                                • Then - Actions
                                  • Item - Remove (Last created item)
                                • Else - Actions
                                  • Do nothing
                    • Else - Actions
                      • Do nothing
              • Custom script: call DestroyGroup(udg_TempGroup)
            • Else - Actions
              • Do nothing
 
Last edited:
Level 41
Joined
Feb 27, 2007
Messages
5,189
This is a needlessly complex way to go about this. If you want triggered lifesteal, just make it work by healing the % with an on-attack-damage trigger from a DDS. Surely you have a DDS already in your map. You can even continue to use the periodically-add-up-lifesteal-buffs method, just save the current lifesteal % in a hashtable or some sort of indexed array and refer to it when damage occurs. Or compute the lifesteal % on each attack-damage instance.
 
This is a needlessly complex way to go about this. If you want triggered lifesteal, just make it work by healing the % with an on-attack-damage trigger from a DDS. Surely you have a DDS already in your map. You can even continue to use the periodically-add-up-lifesteal-buffs method, just save the current lifesteal % in a hashtable or some sort of indexed array and refer to it when damage occurs. Or compute the lifesteal % on each attack-damage instance.

I admit I don't have any DDS nor Unit Indexer for the moment in my map ^^
Damage Detection Systems give you the damage after armor/evade/.. are taken into account ?

GDD doesn't give the damage type (spell, normal, ...) right ?
But Damage Engine does ? Version 5.x for W3 1.31.1, or 3.8 for previous W3 versions.
 
Once you take a little time to get used to a DDS your modding life will change, trust me. Also i recommend you learn JASS, GUI is bad in most cases, specially in those periodic triggers.

I trust you about indexers ^^
About JASS, I learned it but "plain JASS" is a pain to develop with WE no ? Missing auto-completion, syntax check, ...
There also is vJass, this one I never learned.

Are you using a different editor than WE to develop JASS (or vJASS) without pain ?
 
Level 20
Joined
May 16, 2012
Messages
635
I trust you about indexers ^^
About JASS, I learned it but "plain JASS" is a pain to develop with WE no ? Missing auto-completion, syntax check, ...
There also is vJass, this one I never learned.

Are you using a different editor than WE to develop JASS (or vJASS) without pain ?

Yeah right now we dont have a code completion/highlighter but it will come dont worry. I use Sublime Text 3 with the extension for it provided by hive in the tools sections.
 
This is a needlessly complex way to go about this. If you want triggered lifesteal, just make it work by healing the % with an on-attack-damage trigger from a DDS. Surely you have a DDS already in your map. You can even continue to use the periodically-add-up-lifesteal-buffs method, just save the current lifesteal % in a hashtable or some sort of indexed array and refer to it when damage occurs. Or compute the lifesteal % on each attack-damage instance.

Once you take a little time to get used to a DDS your modding life will change, trust me. Also i recommend you learn JASS, GUI is bad in most cases, specially in those periodic triggers.

Global arrays in JASS are fixed in size and do not need to be nullified as their data will eventually be overwritten.

The JASS pointers are not correctly recycled so when using agents (unit, location) local variables should be nulled.

Alternatively, if you use Lua, locals do not need to be nulled.

Thanks everybody, I replaced it all by 3 triggers:

Trigger 1: computing the life steal percentage periodically.
A bit complex because I check for the presence of some items, aura buffs and abilities. And also discard paused/hidden/dead units. To handle auras with 4 levels I couldn't find more simple than do 4 different buffs (one per level).


  • LifeSteal Compute
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) controller) Equal to User
            • Then - Actions
              • Set TempGroup = (Units owned by (Player((Integer A))))
              • Unit Group - Pick every unit in TempGroup and do (Actions)
                • Loop - Actions
                  • Set TempReal = 0.00
                  • -------- Discard dead/hidden/paused units --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is dead) Equal to False
                      • ((Picked unit) is hidden) Equal to False
                      • ((Picked unit) is paused) Equal to False
                    • Then - Actions
                      • -------- Check aura effects --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) has buff Vampiric Aura (Level 1)) Equal to True
                        • Then - Actions
                          • Set TempReal = (TempReal + 0.50)
                        • Else - Actions
                          • Do nothing
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) has buff Vampiric Aura (Level 2)) Equal to True
                        • Then - Actions
                          • Set TempReal = (TempReal + 1.00)
                        • Else - Actions
                          • Do nothing
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) has buff Vampiric Aura (Level 3)) Equal to True
                        • Then - Actions
                          • Set TempReal = (TempReal + 1.50)
                        • Else - Actions
                          • Do nothing
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) has buff Vampiric Aura (Level 4)) Equal to True
                        • Then - Actions
                          • Set TempReal = (TempReal + 2.00)
                        • Else - Actions
                          • Do nothing
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) has buff Muradin's Hammmer (Level 1) Equal to True
                        • Then - Actions
                          • Set TempReal = (TempReal + 0.50)
                        • Else - Actions
                          • Do nothing
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) has buff Muradin's Hammmer (Level 2) Equal to True
                        • Then - Actions
                          • Set TempReal = (TempReal + 1.00)
                        • Else - Actions
                          • Do nothing
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) has buff Muradin's Hammmer (Level 3) Equal to True
                        • Then - Actions
                          • Set TempReal = (TempReal + 1.50)
                        • Else - Actions
                          • Do nothing
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) has buff Muradin's Hammmer (Level 4) Equal to True
                        • Then - Actions
                          • Set TempReal = (TempReal + 2.00)
                        • Else - Actions
                          • Do nothing
                      • -------- Check minions boost --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • BoostLevel Greater than or equal to 7
                        • Then - Actions
                          • Custom script: set udg_TempBoolean = MinionsBoostUnitMatchConditions( GetEnumUnit() )
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • TempBoolean Equal to True
                            • Then - Actions
                              • Set TempReal = (TempReal + 0.50)
                            • Else - Actions
                              • Do nothing
                        • Else - Actions
                          • Do nothing
                      • -------- If hero, check items with life steal --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) is A Hero) Equal to True
                        • Then - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Item carried by (Picked unit) of type Mask of Death) Not equal to No item
                            • Then - Actions
                              • Set TempReal = (TempReal + 0.50)
                            • Else - Actions
                              • Do nothing
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Item carried by (Picked unit) of type ) Not equal to No item
                            • Then - Actions
                              • Set TempReal = (TempReal + 0.50)
                            • Else - Actions
                              • Do nothing
                        • Else - Actions
                          • Do nothing
                    • Else - Actions
                      • Do nothing
                  • Set LifeStealPercentage[(Custom value of (Picked unit))] = TempReal
              • Custom script: call DestroyGroup(udg_TempGroup)
            • Else - Actions
              • Do nothing


Trigger 2: add some quantity to unit life & apply special effect on damage event
  • LifeSteal Execute
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • IsDamageSpell Equal to False
      • LifeStealPercentage[(Custom value of DamageEventSource)] Greater than 0.00
    • Actions
      • Set LifeStealTempReal = (LifeStealPercentage[(Custom value of DamageEventSource)] x DamageEventAmount)
      • Unit - Set life of DamageEventSource to ((Life of DamageEventSource) + LifeStealTempReal)
      • Special Effect - Create a special effect attached to the origin of DamageEventSource using Abilities\Spells\Undead\VampiricAura\VampiricAuraTarget.mdl
      • Special Effect - Destroy (Last created special effect)
Trigger 3: (Optional) Because I am a maniac, I reset my array variables on de-index event
  • LifeSteal Recycle
    • Events
      • Game - UnitIndexEvent becomes Equal to 2.00
    • Conditions
      • LifeStealPercentage[UDex] Not equal to 0.00
    • Actions
      • -------- Clean stored values (optional) --------
      • Set LifeStealPercentage[UDex] = 0.00
 
Last edited:
Status
Not open for further replies.
Top