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

Spell Steal v1.2

Due to some popular demands(which i am included too.)created this spell for those who wanted this.
Credits to the IceFrog Team for the idea of the spell.
Note:
This spell replaces the same spell,hence,its just like reseting its cooldown.
[trigger=Init]SS Init
Events
Map initialization
Conditions
Actions
Custom script: set udg_SS_Hash = InitHashtable()
-------- Configuration --------
-------- Determines the unwanted abilities --------
Set SS_IllegalAbilities[1] = Spell Steal
Set SS_IllegalAbilities[2] = Metamorphosis
-------- Determines the color of the stolen spell --------
Set SS_Color = |cff34ff34
-------- Determines how long does the stolen spell last --------
Set SS_Duration[1] = 60.00
Set SS_Duration[2] = 80.00
Set SS_Duration[3] = 100.00
-------- Determines the number when it will starts warning if the stolen spell is about to lose --------
Set SS_Warning = 20.00
-------- SFX when stealing spell --------
Set SS_SFX = Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
[/trigger][trigger=Index]SS Abilities
Events
Map initialization
Conditions
Actions
-------- Abilities --------
-------- Bladestorm --------
Custom script: set udg_SS_OriginalAbility = 'AOww'
-------- Stolen version --------
Custom script: set udg_SS_StolenAbility = 'A005'
-------- Saving --------
Trigger - Run SS Ability Register <gen> (ignoring conditions)
-------- Shockwave --------
Custom script: set udg_SS_OriginalAbility = 'AOsh'
-------- Stolen version --------
Custom script: set udg_SS_StolenAbility = 'A003'
-------- Saving --------
Trigger - Run SS Ability Register <gen> (ignoring conditions)
-------- Mirror Image --------
Custom script: set udg_SS_OriginalAbility = 'AOmi'
-------- Stolen version --------
Custom script: set udg_SS_StolenAbility = 'A004'
-------- Saving --------
Trigger - Run SS Ability Register <gen> (ignoring conditions)
-------- War Stomp --------
Custom script: set udg_SS_OriginalAbility = 'AOws'
-------- Stolen version --------
Custom script: set udg_SS_StolenAbility = 'A002'
-------- Saving --------
Trigger - Run SS Ability Register <gen> (ignoring conditions)
-------- Bladestorm --------
Custom script: set udg_SS_OriginalAbility = 'AOwk'
-------- Stolen version --------
Custom script: set udg_SS_StolenAbility = 'A001'
-------- Saving --------
Trigger - Run SS Ability Register <gen> (ignoring conditions)
[/trigger][trigger=AbilityRegister]SS Ability Register
Events
Conditions
Actions
-------- Saving --------
Custom script: call SaveInteger(udg_SS_Hash,udg_SS_OriginalAbility,1,udg_SS_StolenAbility)
[/trigger][trigger=Register]SS Register
Events
Unit - A unit Starts the effect of an ability
Conditions
And - All (Conditions) are true
Conditions
(Ability being cast) Not equal to SS_IllegalAbilities[1]
(Ability being cast) Not equal to SS_IllegalAbilities[2]
Actions
Set SS_RegisterAbility = (Ability being cast)
Set SS_RegisterLevel = (Level of SS_RegisterAbility for SS_Registered)
Set SS_Registered = (Triggering unit)
Set SS_Casted = True
Custom script: set udg_SS_RegisteredKey = GetHandleId(udg_SS_Registered)
Hashtable - Save SS_Casted as (Key Boolean) of SS_RegisteredKey in SS_Hash
-------- Saving Spell --------
Custom script: call SaveInteger(udg_SS_Hash,udg_SS_RegisteredKey,2,udg_SS_RegisterAbility)
Custom script: call SaveInteger(udg_SS_Hash,udg_SS_RegisteredKey,3,udg_SS_RegisterLevel)
[/trigger][trigger=Cast]SS Cast
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Spell Steal
Actions
-------- Variables --------
Set SS_Caster = (Triggering unit)
Set SS_Target = (Target unit of ability being cast)
Custom script: set udg_SS_Key[1] = GetHandleId(udg_SS_Caster)
Custom script: set udg_SS_Key[2] = GetHandleId(udg_SS_Target)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Load (Key Boolean) of SS_Key[2] from SS_Hash) Equal to True
Then - Actions
-------- Removing Current Spell --------
Custom script: call UnitRemoveAbility(udg_SS_Caster,LoadInteger(udg_SS_Hash,udg_SS_Key[1],4))
Hashtable - Clear all child hashtables of child SS_Key[1] in SS_Hash
Unit Group - Remove SS_Caster from SS_LoopGroup
-------- Adding Ability --------
Custom script: set udg_SS_Ability[1] = LoadInteger(udg_SS_Hash,udg_SS_Key[2],2)
Custom script: set udg_SS_Ability[2] = LoadInteger(udg_SS_Hash,udg_SS_Ability[1],1)
Custom script: call UnitAddAbility(udg_SS_Caster,udg_SS_Ability[2])
-------- Setting Level --------
Set SS_StolenSpellLevel = (Load 3 of SS_Key[2] from SS_Hash)
Unit - Set level of SS_Ability[2] for SS_Caster to SS_StolenSpellLevel
Set SS_Current = 0.00
Set SS_SSLevel = (Level of Spell Steal for SS_Caster)
-------- Saving Variables --------
Custom script: call SaveInteger(udg_SS_Hash,udg_SS_Key[1],4,udg_SS_Ability[2])
Hashtable - Save SS_Current as 5 of SS_Key[1] in SS_Hash
Hashtable - Save SS_SSLevel as 6 of SS_Key[1] in SS_Hash
Hashtable - Save True as (Key On) of SS_Key[1] in SS_Hash
-------- Starting Loop --------
Unit Group - Add SS_Caster to SS_LoopGroup
Trigger - Turn on SS Loop <gen>
-------- Others --------
-------- Floating Text --------
Floating Text - Create floating text that reads (SS_Color + (Name of SS_Ability[1])) above SS_Caster with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Change the fading age of (Last created floating text) to 3.00 seconds
Floating Text - Change the lifespan of (Last created floating text) to 4.00 seconds
Floating Text - Create floating text that reads (SS_Color + (Name of SS_Ability[1])) above SS_Target with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Change the fading age of (Last created floating text) to 3.00 seconds
Floating Text - Change the lifespan of (Last created floating text) to 4.00 seconds
Else - Actions
-------- SFX --------
Special Effect - Create a special effect attached to the chest of SS_Caster using SS_SFX
Special Effect - Destroy (Last created special effect)
Special Effect - Create a special effect attached to the chest of SS_Target using SS_SFX
Special Effect - Destroy (Last created special effect)
[/trigger][trigger=Loop]SS Loop
Events
Time - Every 0.03 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(SS_LoopGroup is empty) Not equal to True
Then - Actions
Unit Group - Pick every unit in SS_LoopGroup and do (Actions)
Loop - Actions
Set SS_Picked = (Picked unit)
Custom script: set udg_SS_Key[3] = GetHandleId(udg_SS_Picked)
-------- Load --------
Set SS_Current = (Load 5 of SS_Key[3] from SS_Hash)
Set SS_SSLevel = (Load 6 of SS_Key[3] from SS_Hash)
-------- Checking --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SS_Current Less than SS_Duration[SS_SSLevel]
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Load (Key On) of SS_Key[3] from SS_Hash) Equal to True
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SS_Current Greater than (SS_Duration[SS_SSLevel] - SS_Warning)
Then - Actions
Set SS_Player = (Player group((Owner of SS_Picked)))
Game - Display to SS_Player the text: (|cffffcc00 + 20 seconds until your stolen spell will be removed)
Custom script: call DestroyForce(udg_SS_Player)
Hashtable - Save False as (Key On) of SS_Key[3] in SS_Hash
Else - Actions
Else - Actions
Hashtable - Save (SS_Current + 0.03) as 5 of SS_Key[3] in SS_Hash
Else - Actions
Custom script: call UnitRemoveAbility(udg_SS_Picked,LoadInteger(udg_SS_Hash,udg_SS_Key[3],4))
Hashtable - Clear all child hashtables of child SS_Key[3] in SS_Hash
Unit Group - Remove SS_Picked from SS_LoopGroup
Else - Actions
Trigger - Turn off (This trigger)
[/trigger]

Changelogs.
v1.1
-Added a new trigger where you can configure the spells,
-Changed name of some variables
v1.2
-Added a register trigger for the abilities

Keywords:
Steal
Contents

Spell Steal v1.2 (Map)

Reviews
05:42, 26th Aug 2012 Magtheridon96: The code's fine, but it would be nice if you were to cache things like (Last created floating text) into variables so that you don't have to repeat the call over and over again.

Moderator

M

Moderator

05:42, 26th Aug 2012
Magtheridon96:

The code's fine, but it would be nice if you were to cache things like (Last created floating text) into variables so that you don't have to repeat the call over and over again.
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
Noooooooooessss replace most arrays with non-arrayed variables. Arrays takes too much space to be worth it.

Why you use customscript for LoadInteger only but not when you save all the other variables into the hashtable? Don't know what their native name is? :)
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
  • Hashtable - Save SS_Casted as (Key Boolean) of SS_RegisteredKey in SS_Hash
  • Hashtable - Save SS_Current as 5 of SS_Key[1] in SS_Hash
  • Hashtable - Save SS_SSLevel as 6 of SS_Key[1] in SS_Hash
  • Hashtable - Save True as (Key On) of SS_Key[1] in SS_Hash
And there's a few more concerning if condition and variables.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
TempAbility -> OriginalAbility
TempAbility2 -> StolenAbility

Users would not understand what the heck is TempAbility1/2.
When they read variable name Original/Stolen - Ability, they would understand it a bit (compared to TempAbility1/2)

Run a trigger, is you do the saving inside another trigger (fires off by running trigger action).
You're making the user of your trigger to be harder to configure your trigger.

Look at some of my system (Signature), it uses this method, saving the values in another trigger (Item Weight (setup save) / Item Durability (setup save) / Frictional Knockback (event save) / etc)

You can learn something from it, apparently it is called as "encapsulation", one of programming-style.
 
Level 1
Joined
Apr 23, 2017
Messages
4
Ok so silly question but how do i import this spell? I get the error(s) that
Line 142: Expected a variable name
set udg_SS_OriginalAbility = 'AOww'
Same for lines 144,148,150,154,156,160,162,166,168
And for Line 184: Expected a name
call SaveInteger(udg_SS_Hash,udg_SS_OriginalAbility,1,udg_SS_StolenAbility

Thx in advance
 
Top