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

[Solved] Spreading a buff to nearby units + hashtables

Status
Not open for further replies.
Level 12
Joined
Feb 5, 2018
Messages
521
Hello hivers. I have made 2 different custom damage over time skills with hashtables.

What I want to do next is a spell that spreads the buffs from the units that have the buff to nearby enemy units, 200 AoE or so. The best option would be if we could add the units to the already existing damage groups.

I have a couple of ideas how to do this, but they seem a bitt off.

The spells cast contains the buffs I want to use, adding them to the target. I managed to add the buffs only to one target by setting the AoE of the skills in the object editor to 0.

Icy touch = Frost Nova
Pestilent Strike = Acid Bomb

  • Icy Touch
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Icy Touch (Text not done)
    • Actions
      • Set VariableSet IT_Damage = ((Real((Level of Icy Touch (Text not done) for (Triggering unit)))) x (125.00 + ((Real((Strength of (Triggering unit) (Include bonuses)))) x 0.45)))
      • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing IT_Damage damage of attack type Spells and damage type Magic
      • -------- --------
      • Set VariableSet IT_Dot = ((Real((Level of Icy Touch (Text not done) for (Triggering unit)))) x 15.00)
      • -------- --------
      • Hashtable - Save IT_Dot as 1 of (Key (Target unit of ability being cast).) in IT_Hashtable.
      • Hashtable - Save ((Real((Level of Icy Touch (Text not done) for (Triggering unit)))) x 4.00) as 0 of (Key (Target unit of ability being cast).) in IT_Hashtable.
      • -------- --------
      • Set VariableSet IT_Caster = (Triggering unit)
      • Hashtable - Save Handle OfIT_Caster as 2 of (Key (Triggering unit).) in IT_Hashtable.
      • -------- --------
      • Unit Group - Add (Target unit of ability being cast) to IT_DamageGroup
      • Unit Group - Add (Triggering unit) to IT_CasterGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Icy Touch Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Icy Touch Loop <gen>
        • Else - Actions

  • Icy Touch Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in IT_CasterGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet IT_Caster = (Load 2 of (Key (Picked unit).) in IT_Hashtable.)
      • Unit Group - Pick every unit in IT_DamageGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet IT_Time = (Load 0 of (Key (Picked unit).) from IT_Hashtable.)
          • Set VariableSet IT_Dot = (Load 1 of (Key (Picked unit).) from IT_Hashtable.)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • IT_Time Greater than 0.00
            • Then - Actions
              • Unit - Cause IT_Caster to damage (Picked unit), dealing IT_Dot damage of attack type Spells and damage type Magic
              • -------- --------
              • Hashtable - Save (IT_Time - 1.00) as 0 of (Key (Picked unit).) in IT_Hashtable.
            • Else - Actions
              • Unit Group - Remove (Picked unit) from IT_DamageGroup.
              • -------- --------
              • Hashtable - Clear all child hashtables of child (Key (Picked unit).) in IT_Hashtable.
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in IT_DamageGroup) Less than or equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Unit Group - Remove all units of IT_CasterGroup from IT_CasterGroup.
        • Else - Actions

The both skills use the exact same method, but i'll post them both here, to see if someone can help me make the skill spreading the buffs.

  • Pestilent Strike
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Pestilent Strike (Text not done)
    • Actions
      • Set VariableSet PS_Damage = ((Real((Level of Pestilent Strike (Text not done) for (Triggering unit)))) x 25.00)
      • Hashtable - Save PS_Damage as 1 of (Key (Target unit of ability being cast).) in PS_Hashtable.
      • -------- --------
      • Hashtable - Save 15.00 as 0 of (Key (Target unit of ability being cast).) in PS_Hashtable.
      • Set VariableSet PS_Caster = (Triggering unit)
      • Hashtable - Save Handle OfPS_Caster as 2 of (Key (Triggering unit).) in PS_Hashtable.
      • -------- --------
      • Unit Group - Add (Target unit of ability being cast) to PS_DamageGroup
      • Unit Group - Add (Triggering unit) to PS_CasterGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Pestilent Strike Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Pestilent Strike Loop <gen>
        • Else - Actions

  • Pestilent Strike Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in PS_CasterGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet PS_Caster = (Load 2 of (Key (Picked unit).) in PS_Hashtable.)
      • Unit Group - Pick every unit in PS_DamageGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet PS_Time = (Load 0 of (Key (Picked unit).) from PS_Hashtable.)
          • Set VariableSet PS_Damage = (Load 1 of (Key (Picked unit).) from PS_Hashtable.)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PS_Time Greater than 0.00
            • Then - Actions
              • Unit - Cause PS_Caster to damage (Picked unit), dealing PS_Damage damage of attack type Spells and damage type Magic
              • -------- --------
              • Hashtable - Save (PS_Time - 1.00) as 0 of (Key (Picked unit).) in PS_Hashtable.
            • Else - Actions
              • Unit Group - Remove (Picked unit) from PS_DamageGroup.
              • -------- --------
              • Hashtable - Clear all child hashtables of child (Key (Picked unit).) in PS_Hashtable.
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in PS_DamageGroup) Less than or equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Unit Group - Remove all units of PS_CasterGroup from PS_CasterGroup.
        • Else - Actions
 
Level 24
Joined
Feb 9, 2009
Messages
1,787
I based the spreading ability on an instant cast spell (berserk in this case)

  • Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Pandemic
    • Actions
      • Set PaDe_Unit[0] = (Triggering unit)
      • Set PaDe_Point[0] = (Position of PaDe_Unit[0])
      • Unit - Create 1 Caster Dummy Unit ReSp for (Triggering player) at PaDe_Point[0] facing Default building facing degrees
      • Set PaDe_Unit[1] = (Last created unit)
      • Unit - Add Pestilence Strike Dummy to PaDe_Unit[1]
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 1500.00 of PaDe_Point[0]) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Acid Bomb) Equal to True
            • Then - Actions
              • Unit Group - Add (Picked unit) to PaDe_ugroup_1
            • Else - Actions
      • Custom script: call RemoveLocation(udg_PaDe_Point[0])
      • Unit Group - Pick every unit in PaDe_ugroup_1 and do (Actions)
        • Loop - Actions
          • Set PaDe_Unit[2] = (Picked unit)
          • Set PaDe_Point[1] = (Position of PaDe_Unit[2])
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within 200.00 of PaDe_Point[1]) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) belongs to an enemy of (Owner of PaDe_Unit[0])) Equal to True
                  • ((Picked unit) belongs to an enemy of (Owner of PaDe_Unit[0])) Equal to True
                • Then - Actions
                  • Unit Group - Add (Picked unit) to PaDe_ugroup_2
                • Else - Actions
          • Custom script: call RemoveLocation(udg_PaDe_Point[1])
      • Unit Group - Remove all units from PaDe_ugroup_1
      • Unit Group - Pick every unit in PaDe_ugroup_2 and do (Actions)
        • Loop - Actions
          • Unit - Order PaDe_Unit[1] to Neutral Alchemist - Acid Bomb (Picked unit)
          • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Undead\DeathCoil\DeathCoilSpecialArt.mdl
          • Special Effect - Destroy (Last created special effect)
      • Unit Group - Remove all units from PaDe_ugroup_2
      • Unit - Add a 0.20 second Generic expiration timer to PaDe_Unit[1]

But i'm not too sure about unit group interactions when cleared on a spell cast basis, so might be best to get a second opinion.
 
Level 12
Joined
Feb 5, 2018
Messages
521
Thanks for this, I already knew how to spread the buff. :) I made something like this:

  • Pestilence
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Pestilence
    • Actions
      • Set VariableSet Pestilence_Caster = (Triggering unit)
      • Set VariableSet Pestilence_Loc1 = (Target point of ability being cast)
      • -------- --------
      • Set VariableSet Pestilence_Aoe = (200.00 + ((Real((Level of Pestilence for Pestilence_Caster))) x 25.00))
      • Set VariableSet Pestilence_UG = (Units within Pestilence_Aoe of Pestilence_Loc1.)
      • Unit Group - Pick every unit in Pestilence_UG and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) belongs to an enemy of (Owner of Pestilence_Caster).) Equal to True
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is Mechanical) Equal to False
              • ((Picked unit) is Magic Immune) Equal to False
              • ((Picked unit) has buff Icy Touch (Custom)) Equal to True
            • Then - Actions
              • Set VariableSet Pestilence_Unit = (Picked unit)
              • Set VariableSet Pestilence_Loc2 = (Position of Pestilence_Unit)
            • Else - Actions
              • -------- This just filters out unwanted units --------
              • Unit Group - Remove (Picked unit) from Pestilence_UG.
      • Custom script: call DestroyGroup (udg_Pestilence_UG)
      • Custom script: call RemoveLocation (udg_Pestilence_Loc1)
      • Set VariableSet Pestilence_UG2 = (Units within Pestilence_Aoe of Pestilence_Loc2.)
      • Unit Group - Pick every unit in Pestilence_UG2 and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Triggering unit) to IT_CasterGroup
          • Unit Group - Add (Picked unit) to IT_DamageGroup
          • -------- --------
          • Set VariableSet IT_Caster = (Triggering unit)
          • Set VariableSet IT_Dot = ((Real((Level of Icy Touch (Text not done) for (Triggering unit)))) x 15.00)
          • -------- --------
          • Hashtable - Save IT_Dot as 1 of (Key (Picked unit).) in IT_Hashtable.
          • Hashtable - Save ((Real((Level of Icy Touch (Text not done) for (Triggering unit)))) x 4.00) as 0 of (Key (Picked unit).) in IT_Hashtable.
          • -------- --------
          • Hashtable - Save Handle OfIT_Caster as 2 of (Key (Triggering unit).) in IT_Hashtable.
          • Set VariableSet Pestilence_Target = (Picked unit)
          • -------- --------
          • Unit - Create 1 DummyUnit for (Owner of Pestilence_Caster) at Pestilence_Loc2 facing Default building facing degrees
          • Set VariableSet Pestilence_Dummy = (Last created unit)
          • -------- --------
          • Unit - Add a 1.00 second Generic expiration timer to Pestilence_Dummy
          • Unit - Add Icy Touch (Dummy) to Pestilence_Dummy
          • Unit - Order Pestilence_Dummy to Undead Lich - Frost Nova Pestilence_Target
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Icy Touch Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Icy Touch Loop <gen>
        • Else - Actions
      • Custom script: call RemoveLocation (udg_Pestilence_Loc2)
      • Custom script: call DestroyGroup (udg_Pestilence_UG2)

EDIT:

  • Pestilence
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Pestilence
    • Actions
      • Set VariableSet Pestilence_Caster = (Triggering unit)
      • Set VariableSet Pestilence_Level = (Level of Icy Touch (Text not done) for Pestilence_Caster)
      • Set VariableSet Pestilence_Level2 = (Level of Pestilent Strike (Text not done) for Pestilence_Caster)
      • Set VariableSet Pestilence_Loc1 = (Target point of ability being cast)
      • -------- --------
      • Set VariableSet Pestilence_Aoe = (200.00 + ((Real((Level of Pestilence for Pestilence_Caster))) x 25.00))
      • Set VariableSet Pestilence_UG = (Units within Pestilence_Aoe of Pestilence_Loc1.)
      • -------- Icy touch buff check --------
      • Unit Group - Pick every unit in Pestilence_UG and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) belongs to an enemy of (Owner of Pestilence_Caster).) Equal to True
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is Mechanical) Equal to False
              • ((Picked unit) is Magic Immune) Equal to False
              • ((Picked unit) has buff Icy Touch (Custom)) Equal to True
            • Then - Actions
              • Set VariableSet Pestilence_Unit = (Picked unit)
              • Set VariableSet Pestilence_Loc2 = (Position of Pestilence_Unit)
            • Else - Actions
              • -------- This just filters out unwanted units --------
              • Unit Group - Remove (Picked unit) from Pestilence_UG.
      • -------- Pestilent Strike buff check --------
      • Set VariableSet Pestilence_UG3 = (Units within Pestilence_Aoe of Pestilence_Loc1.)
      • Unit Group - Pick every unit in Pestilence_UG and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) belongs to an enemy of (Owner of Pestilence_Caster).) Equal to True
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is Mechanical) Equal to False
              • ((Picked unit) is Magic Immune) Equal to False
              • ((Picked unit) has buff Pestilent Strike (Custom)) Equal to True
            • Then - Actions
              • Set VariableSet Pestilence_Unit2 = (Picked unit)
              • Set VariableSet Pesitlence_Loc3 = (Position of Pestilence_Unit2)
            • Else - Actions
              • -------- This just filters out unwanted units --------
              • Unit Group - Remove (Picked unit) from Pestilence_UG3.
      • Custom script: call DestroyGroup (udg_Pestilence_UG)
      • Custom script: call DestroyGroup (udg_Pestilence_UG3)
      • Custom script: call RemoveLocation (udg_Pestilence_Loc1)
      • Set VariableSet Pestilence_UG2 = (Units within Pestilence_Aoe of Pestilence_Loc2.)
      • -------- Icy touch add to damage group --------
      • Unit Group - Pick every unit in Pestilence_UG2 and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Triggering unit) to IT_CasterGroup
          • Unit Group - Add (Picked unit) to IT_DamageGroup
          • -------- --------
          • Set VariableSet IT_Caster = (Triggering unit)
          • Set VariableSet IT_Dot = ((Real((Level of Icy Touch (Text not done) for (Triggering unit)))) x 15.00)
          • -------- --------
          • Hashtable - Save IT_Dot as 1 of (Key (Picked unit).) in IT_Hashtable.
          • Hashtable - Save ((Real((Level of Icy Touch (Text not done) for (Triggering unit)))) x 4.00) as 0 of (Key (Picked unit).) in IT_Hashtable.
          • -------- --------
          • Hashtable - Save Handle OfIT_Caster as 2 of (Key (Triggering unit).) in IT_Hashtable.
          • Set VariableSet Pestilence_Target = (Picked unit)
          • -------- --------
          • Unit - Create 1 DummyUnit for (Owner of Pestilence_Caster) at Pestilence_Loc2 facing Default building facing degrees
          • Set VariableSet Pestilence_Dummy = (Last created unit)
          • -------- --------
          • Unit - Add a 1.00 second Generic expiration timer to Pestilence_Dummy
          • Unit - Add Icy Touch (Dummy) to Pestilence_Dummy
          • Unit - Set level of Icy Touch (Dummy) for Pestilence_Dummy to Pestilence_Level
          • Unit - Order Pestilence_Dummy to Undead Lich - Frost Nova Pestilence_Target
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Icy Touch Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Icy Touch Loop <gen>
        • Else - Actions
      • Custom script: call RemoveLocation (udg_Pestilence_Loc2)
      • Custom script: call DestroyGroup (udg_Pestilence_UG2)
      • Set VariableSet Pestilence_UG4 = (Units within Pestilence_Aoe of Pesitlence_Loc3.)
      • -------- Pestilent Strike add to damage group --------
      • Unit Group - Pick every unit in Pestilence_UG4 and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Triggering unit) to PS_CasterGroup
          • Unit Group - Add (Picked unit) to PS_DamageGroup
          • -------- --------
          • Set VariableSet PS_Caster = (Triggering unit)
          • Set VariableSet PS_Damage = ((Real((Level of Pestilent Strike (Text not done) for (Triggering unit)))) x 25.00)
          • -------- --------
          • Hashtable - Save PS_Damage as 1 of (Key (Picked unit).) in PS_Hashtable.
          • Hashtable - Save 15.00 as 0 of (Key (Picked unit).) in PS_Hashtable.
          • -------- --------
          • Hashtable - Save Handle OfPS_Caster as 2 of (Key (Triggering unit).) in PS_Hashtable.
          • Set VariableSet Pestilence_Target2 = (Picked unit)
          • -------- --------
          • Unit - Create 1 DummyUnit for (Owner of Pestilence_Caster) at Pesitlence_Loc3 facing Default building facing degrees
          • Set VariableSet Pestilence_Dummy2 = (Last created unit)
          • -------- --------
          • Unit - Add a 1.00 second Generic expiration timer to Pestilence_Dummy2
          • Unit - Add Pestilent Strike (Dummy) to Pestilence_Dummy2
          • Unit - Set level of Pestilent Strike (Dummy) for Pestilence_Dummy2 to Pestilence_Level2
          • Unit - Order Pestilence_Dummy2 to Neutral Alchemist - Acid Bomb Pestilence_Target2
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Pestilent Strike Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Pestilent Strike Loop <gen>
        • Else - Actions
      • Custom script: call RemoveLocation (udg_Pesitlence_Loc3)
      • Custom script: call DestroyGroup (udg_Pestilence_UG4)

Unfortunately the final trigger does not work as intented. If the unit only hass Pestilent Strike Buff, it will not spread it at all.

And if the unit has both buffs, the game freezes setting my fps from 200 to 0.1 with reforged graphichs, so it probably has a huge memory leak.

It spreads the icy touch pretty well tho, running really smooth, zero lag.

This was alot harder than expected, because I have to have all damage triggered in my map, due to use of DDS and custom spell critical and physical critical strike system.

As far as i'm concerned, it works really well with only having to spread one buff, but for some reason it stops working when you try to spread both buffs at once.

EDIT EDIT: It was working all along, I just had the DAMAGE INTERVAL of Acid bomb to 0.000. So it crashed the game. Problem was that all along, mistake in OE.
 
Last edited:
Status
Not open for further replies.
Top