• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Trouble destroying a special effect using hashtables

Status
Not open for further replies.
Level 5
Joined
May 20, 2008
Messages
138
I am making a MUI spell called flame shock. Flame shock is a damage over time effect that sets the target on fire and deals damage every 3 seconds for 18 seconds. Each player hero can cast flame shock on any enemy target, and have it up on several targets at a time, if two players cast on the same target, the effect stacks.

The problem I am having is with the special effect that sets the target on fire. I create a special effect in the first trigger and save it to a hashtable, "HSHAMAN_flameshockeffect_table".

  • Special Effect - Create a special effect attached to the origin of (Target unit of ability being cast) using Environment\LargeBuildingFire\LargeBuildingFire2.mdl
  • Hashtable - Save (Key (Last created special effect)) as (Player number of (Owner of (Casting unit))) of (Key (Target unit of ability being cast)) in HSHAMAN_flameshockeffect_table
In the second trigger I try to load and destroy it once the Flame Shock duration has finished. However, the effect persists even after Flame Shock is done, so obviously something about my coding is wrong. Maybe you can't save and load special effects in the same way you can save load integers? Does anybody know?

  • Set HSHAMAN_flameshockeffect = (Load (Integer A) of (Key (Picked unit)) in HSHAMAN_flameshockeffect_table)
  • Special Effect - Destroy HSHAMAN_flameshockeffect
You should look at the entire triggers to understand how Integer A and (Key (Picked unit)) are used to load the special effect. Please note that I use the same technique to load other values and it seems to be working, it's only the special effect that I can't seem to load and destroy


Here is the casting trigger, I have emphasized the part where the special effect gets created and saved, since that is the important part:

  • Shaman Flame Shock
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (Shaman) Flame Shock
    • Actions
      • -------- deal initial damage --------
      • Unit - Cause (Casting unit) to damage (Target unit of ability being cast), dealing 100.00 damage of attack type Spells and damage type Fire
      • -------- save the caster --------
      • Set HSHAMAN_flameshockcaster[(Player number of (Owner of (Casting unit)))] = (Casting unit)
      • -------- refresh the flame shock duration and ticks --------
      • Hashtable - Save 18 as (Player number of (Owner of (Triggering unit))) of (Key (Target unit of ability being cast)) in HSHAMAN_flameshocktime_table
      • Hashtable - Save 1 as (Player number of (Owner of (Triggering unit))) of (Key (Target unit of ability being cast)) in HSHAMAN_flameshocktick_table
      • -------- create a special effect and save that the unit has a buff of flame shock on it --------
      • -------- create a special effect and save that the unit has a buff of flame shock on it --------
      • -------- create a special effect and save that the unit has a buff of flame shock on it --------
      • -------- create a special effect and save that the unit has a buff of flame shock on it --------
      • Special Effect - Create a special effect attached to the origin of (Target unit of ability being cast) using Environment\LargeBuildingFire\LargeBuildingFire2.mdl
      • Hashtable - Save (Key (Last created special effect)) as (Player number of (Owner of (Casting unit))) of (Key (Target unit of ability being cast)) in HSHAMAN_flameshockeffect_table
      • -------- create a special effect and save that the unit has a buff of flame shock on it --------
      • -------- create a special effect and save that the unit has a buff of flame shock on it --------
      • -------- create a special effect and save that the unit has a buff of flame shock on it --------
      • -------- create a special effect and save that the unit has a buff of flame shock on it --------
      • -------- create a special effect and save that the unit has a buff of flame shock on it --------
      • -------- save the fact that the unit has a flame shock belonging to the owner of the casting unit on it for finishing the time trigger and the lava burst trigger --------
      • Hashtable - Save 1 as (Player number of (Owner of (Casting unit))) of (Key (Target unit of ability being cast)) in HSHAMAN_flameshockstacks_table
      • -------- save the target for the damage dealing and duration trigger --------
      • Unit Group - Add (Target unit of ability being cast) to HSHAMAN_flameshocktargets
      • -------- create text --------
      • Floating Text - Create floating text that reads Flameshock above (Target unit of ability being cast) with Z offset 0.00, using font size 10.00, color (100.00%, 75.00%, 0.00%), and 0.00% transparency
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
      • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
      • Floating Text - Change the lifespan of (Last created floating text) to 4.00 seconds
      • Floating Text - Hide (Last created floating text) for (All players)
      • Floating Text - Show (Last created floating text) for (All players matching ((Owner of (Casting unit)) Equal to (Matching player)))
Here is the periodic damage and duration trigger, I have emphasized the part where the special effect SHOULD get loaded and destroyed, however this doesn't work (it's in the final else of the trigger). I have verified that the trigger at least gets to and executes this and the other parts via ingame text messages:

  • Shaman Flame Shock time
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • -------- pick every unit that has been saved as a flame shock target --------
      • Unit Group - Pick every unit in HSHAMAN_flameshocktargets and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 1 to 10, do (Actions)
            • Loop - Actions
              • -------- each players flameshock duration has been saved with the players number--------
              • -------- , and it goes through all players with Integer A from 1 to 10,--------
              • -------- this goes trhough all the units and checks if the flameshock duration on them is greater than 0--------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Load (Integer A) of (Key (Picked unit)) from HSHAMAN_flameshocktime_table) Greater than 0
                • Then - Actions
                  • -------- reduce duration for each player --------
                  • Set HSHAMAN_flameshocktime = (Load (Integer A) of (Key (Picked unit)) from HSHAMAN_flameshocktime_table)
                  • Set HSHAMAN_flameshocktime = (HSHAMAN_flameshocktime - 1)
                  • Hashtable - Save HSHAMAN_flameshocktime as (Integer A) of (Key (Picked unit)) in HSHAMAN_flameshocktime_table
                  • -------- do ticks --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Load (Integer A) of (Key (Picked unit)) from HSHAMAN_flameshocktick_table) Less than 3
                    • Then - Actions
                      • Set HSHAMAN_flameshockticks = (Load (Integer A) of (Key (Picked unit)) from HSHAMAN_flameshocktick_table)
                      • Set HSHAMAN_flameshockticks = (HSHAMAN_flameshockticks + 1)
                      • Hashtable - Save HSHAMAN_flameshockticks as (Integer A) of (Key (Picked unit)) in HSHAMAN_flameshocktick_table
                    • Else - Actions
                      • -------- at 3 ticks deal damage --------
                      • Hashtable - Save 1 as (Integer A) of (Key (Picked unit)) in HSHAMAN_flameshocktick_table
                      • Unit - Cause HSHAMAN_flameshockcaster[(Integer A)] to damage (Picked unit), dealing 20.00 damage of attack type Spells and damage type Fire
                • Else - Actions
                  • -------- when the duration of the flameshock has finished, set stacks to 0 so lava burst wont do double damage, and destroy special effect --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Load (Integer A) of (Key (Picked unit)) from HSHAMAN_flameshockstacks_table) Equal to 1
                    • Then - Actions
                      • Hashtable - Save 0 as (Integer A) of (Key (Picked unit)) in HSHAMAN_flameshockstacks_table
                      • -------- destroy special effect OBS! THIS DOESNT WORK! --------
                      • -------- destroy special effect OBS! THIS DOESNT WORK! --------
                      • -------- destroy special effect OBS! THIS DOESNT WORK! --------
                      • Set HSHAMAN_flameshockeffect = (Load (Integer A) of (Key (Picked unit)) in HSHAMAN_flameshockeffect_table)
                      • Special Effect - Destroy HSHAMAN_flameshockeffect
                      • -------- destroy special effect OBS! THIS DOESNT WORK! --------
                      • -------- destroy special effect OBS! THIS DOESNT WORK! --------
                      • -------- destroy special effect OBS! THIS DOESNT WORK! --------
                      • -------- dispaly (floating and ingame) text to verify that this part of the trigger is executed --------
                      • Game - Display to (All players) the text: else, destroy speci...
                      • Floating Text - Create floating text that reads Flameshock fades above (Picked unit) with Z offset -50.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
                      • Floating Text - Change (Last created floating text): Disable permanence
                      • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
                      • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
                      • Floating Text - Change the lifespan of (Last created floating text) to 4.00 seconds
                      • Floating Text - Hide (Last created floating text) for (All players)
                      • Floating Text - Show (Last created floating text) for (All players matching ((Player number of (Matching player)) Equal to (Integer A)))
                    • Else - Actions
 
Last edited:
Level 9
Joined
May 27, 2006
Messages
498
Honestly, i've no idea why it doesn't remove it. It should be working, as far as i can tell.
Tho it could be a very stupid mistake, like not creating the proper hashtable.

Anyway, i'd recommend using an ability-based effect instead of trigger. Ie. go to Object Editor - Abilities - Special - Items, and select any Claws of Attack ability. Copy it, modify it so that it doesn't boost damage, will be considered as unit ability and give it a special effect you desire. Then simply add it to unit through your trigger and remove the ability when the effect wears off.
 
Level 5
Joined
May 20, 2008
Messages
138
thanks for all your replies guys! I really appreciate it that you take time and look through such big triggers

raft_pl is correct, the spell even uses 4 different hashtables but I could probably reduce it to two or 3, I copy pasted this off of another, similar spell I made earlier (and yes, I have made new variables/tables for everything in this spell, so no conflicts there :p) and added some additional mechanics, like the hashtable for the special effect.

I have verified that all hashtables are created and saved to a variable at the map initialization, and everything works just fine except the special effect.

I simply might have to try the item spell solution unless somebody figures this out :)

@Maker I'll try to make a test map
 
Level 9
Joined
Apr 25, 2009
Messages
468
Dude why would you destroy it anyway?
Just disable the permanence and set a lifespan to it, done.
 
Level 5
Joined
May 20, 2008
Messages
138
Dude why would you destroy it anyway?
Just disable the permanence and set a lifespan to it, done.

Aren't you talking about Floating Texts now? I can only find functions for Creating a special effect at a point, Creating a special effect on a unit, and Destroying a special effect in the trigger editor.
 
Level 9
Joined
Apr 25, 2009
Messages
468
Yes im talking about floating texts.
Here's a trigger:
  • Your trigger
    • Actions
      • Floating Text - Create floating text that reads....
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
 
Level 9
Joined
Apr 25, 2009
Messages
468
Why do people always want to make it more complicated than it really is?
There's no need for any hashtables or such, just follow the code I did 2 posts ago.
 
Level 5
Joined
May 20, 2008
Messages
138
Why do people always want to make it more complicated than it really is?
There's no need for any hashtables or such, just follow the code I did 2 posts ago.

I am trying to destroy a special effect, not a floating text. By special effect I mean stuff like a fire attached to a unit via a trigger.

Key (Last created special effect) returns an integer
but you want to destroy a special effect
that won't work

you will have to use "Hashtable - Save Effect Handle[...]"

I will try that, thanks!
 
Level 5
Joined
May 20, 2008
Messages
138
Key (Last created special effect) returns an integer
but you want to destroy a special effect
that won't work

you will have to use "Hashtable - Save Effect Handle[...]"

D4RK_G4ND4LF's solution worked! Thanks everybody, muchos +repos to you all :)

EDIT: Except that I need to spread around some more before giving to some of you guys again... damn :p
 
Status
Not open for further replies.
Top