• 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.

Static Bomb v4

Im Bored,created a new spell,the first spell with lightning SFX ahaha
Target point to summon a Static Bomb.Static Bomb strikes the units with a bolt dealing 15/30/45 damage and stuns it for 0.25 seconds who come near it within 500 radius.Every time it strikes a unit,the orb collects 10/15/20 damage and adds it to the strike damage and collects 10/15/20 AoE radius and adds it to its base radius.Once the orb dies,all units within 500 + the collected radius will receive the number of damage collected by the orb.Orbs last for 5/7.5/10 seconds.
[trigger=Config]SB Config
Events
Map initialization
Conditions
Actions
Custom script: set udg_SB_Hash = InitHashtable()
-------- CONFIGURATION --------
-------- Determines the base radius --------
Set SB_BaseRadius = 500.00
-------- Determines the base damage --------
Set SB_BaseDamage[1] = 15.00
Set SB_BaseDamage[2] = 30.00
Set SB_BaseDamage[3] = 45.00
-------- Determines the radius collected --------
Set SB_RadiusPlus[1] = 10.00
Set SB_RadiusPlus[2] = 15.00
Set SB_RadiusPlus[3] = 20.00
-------- Determines the damage collected --------
Set SB_DamagePlus[1] = 10.00
Set SB_DamagePlus[2] = 15.00
Set SB_DamagePlus[3] = 20.00
-------- Determines how the orbs last --------
Set SB_Duration[1] = 5.00
Set SB_Duration[2] = 7.50
Set SB_Duration[3] = 10.00
-------- Determines the lightning used --------
Set SB_LightningModel = CLPB
-------- Determines the SFX when a lightning strikes a unit --------
Set SB_SFX[1] = Abilities\Weapons\Bolt\BoltImpact.mdl
-------- Determines the SFX when the orb dies --------
Set SB_SFX[2] = Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
-------- Determines the Size of the orb --------
Set SB_OrbSize[1] = 300.00
Set SB_OrbSize[2] = 400.00
Set SB_OrbSize[3] = 500.00
-------- Determines the lightning height --------
Set SB_Height = 75.00
[/trigger][trigger=Cast]SB Cast
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Static Bomb
Actions
-------- VARIABLES --------
Set SB_Caster = (Triggering unit)
Set SB_TargetLoc = (Target point of ability being cast)
-------- Creating Orb --------
Unit - Create 1 SB Orb Dummy for (Owner of SB_Caster) at SB_TargetLoc facing Default building facing degrees
Set SB_Orb = (Last created unit)
Custom script: set udg_SB_OrbKey = GetHandleId(udg_SB_Orb)
-------- Determines the level of the ability --------
Set SB_Levels = (Level of Static Bomb for SB_Caster)
-------- Determines the number of damage collected --------
Set SB_CollectedDamage = 0.00
-------- Determines the number of radius collected --------
Set SB_CollectedRadius = 0.00
-------- Changing its size --------
Animation - Change SB_Orb's size to (SB_OrbSize[SB_Levels]%, SB_OrbSize[SB_Levels]%, SB_OrbSize[SB_Levels]%) of its original size
-------- Adding Duration --------
Unit - Add a SB_Duration[SB_Levels] second Generic expiration timer to SB_Orb
-------- Saving Variables --------
Hashtable - Save SB_Levels as 0 of SB_OrbKey in SB_Hash
Hashtable - Save SB_CollectedDamage as 1 of SB_OrbKey in SB_Hash
Hashtable - Save SB_CollectedRadius as 2 of SB_OrbKey in SB_Hash
-------- Starting Loop --------
Unit Group - Add SB_Orb to SB_LoopGroup
Trigger - Turn on SB Loop <gen>
-------- Clean Leak --------
Custom script: call RemoveLocation(udg_SB_TargetLoc)
[/trigger][trigger=Loop]SB Loop
Events
Time - Every 0.25 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in SB_LoopGroup and do (Actions)
Loop - Actions
Set SB_Looper = (Picked unit)
Custom script: set udg_SB_LooperKey = GetHandleId(udg_SB_Looper)
-------- Loading --------
Set SB_Levels = (Load 0 of SB_LooperKey from SB_Hash)
Set SB_CollectedDamage = (Load 1 of SB_LooperKey from SB_Hash)
Set SB_CollectedRadius = (Load 2 of SB_LooperKey from SB_Hash)
-------- Checking --------
Set SB_LooperLoc = (Position of SB_Looper)
-------- Determines the current radius --------
Set SB_CurrentRadius = (SB_BaseRadius + SB_CollectedRadius)
-------- Determines the current radius --------
Set SB_CurrentDamage = (SB_BaseDamage[SB_Levels] + SB_CollectedDamage)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(SB_Looper is alive) Equal to True
Then - Actions
-------- Starting Damage Loop --------
Set SB_DamageGroup[1] = (Units within SB_CurrentRadius of SB_LooperLoc matching (((((Matching unit) is A structure) Not equal to True) and (((Matching unit) is Magic Immune) Not equal to True)) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy
Set SB_DamageGroup[2] = (Random 1 units from SB_DamageGroup[1])
-------- Destroying the current lightning effect --------
Lightning - Destroy (Load (Key Lightning) of SB_LooperKey in SB_Hash)
-------- Checking --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in SB_DamageGroup[1]) Greater than 0
Then - Actions
-------- Picking --------
Unit Group - Pick every unit in SB_DamageGroup[2] and do (Actions)
Loop - Actions
Set SB_Picked = (Picked unit)
Set SB_PickedLoc = (Position of SB_Picked)
-------- Variables for Lightning --------
-------- For the Orb --------
Custom script: set udg_SB_LooperX = GetUnitX(udg_SB_Looper)
Custom script: set udg_SB_LooperY = GetUnitY(udg_SB_Looper)
Custom script: set udg_SB_LooperZ = GetUnitFlyHeight(udg_SB_Looper)
-------- For the Picked Unit --------
Custom script: set udg_SB_PickedX = GetUnitX(udg_SB_Picked)
Custom script: set udg_SB_PickedY = GetUnitY(udg_SB_Picked)
Custom script: set udg_SB_PickedZ = GetUnitFlyHeight(udg_SB_Picked) + udg_SB_Height
-------- Creating Lightning --------
Custom script: set udg_SB_Lightning = AddLightningEx(udg_SB_LightningModel,true,udg_SB_LooperX,udg_SB_LooperY,udg_SB_LooperZ,udg_SB_PickedX,udg_SB_PickedY,udg_SB_PickedZ)
-------- Adding Color --------
Lightning - Change color of (Last created lightning effect) to (0.00 0.00 1.00) with 1.00 alpha
-------- Saving --------
Hashtable - Save Handle OfSB_Lightning as (Key Lightning) of SB_LooperKey in SB_Hash
-------- Damaging Unit --------
Unit - Cause SB_Looper to damage SB_Picked, dealing SB_CurrentDamage damage of attack type Spells and damage type Magic
-------- Stunning Unit --------
Unit - Create 1 SB Dummy for (Owner of SB_Looper) at SB_PickedLoc facing Default building facing degrees
Unit - Add SB Stun to (Last created unit)
Unit - Set level of SB Stun for (Last created unit) to SB_Levels
Unit - Order (Last created unit) to Human Mountain King - Storm Bolt SB_Picked
Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
-------- SFX --------
Special Effect - Create a special effect attached to the chest of SB_Picked using SB_SFX[1]
Special Effect - Destroy (Last created special effect)
-------- Floating Text to Determine the collected damage --------
Floating Text - Create floating text that reads (+ + (String((Integer(SB_DamagePlus[SB_Levels]))))) above SB_Picked with Z offset 0.00, using font size 10.00, color (0.00%, 0.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 lifespan of (Last created floating text) to 5.00 seconds
Floating Text - Change the fading age of (Last created floating text) to 4.00 seconds
-------- Saving Variables --------
Hashtable - Save (SB_CollectedRadius + SB_RadiusPlus[SB_Levels]) as 1 of SB_LooperKey in SB_Hash
Hashtable - Save (SB_CollectedDamage + SB_DamagePlus[SB_Levels]) as 2 of SB_LooperKey in SB_Hash
-------- Cleaning Leak --------
Custom script: call RemoveLocation(udg_SB_PickedLoc)
Else - Actions
-------- Floating Text to Determine the collected radius --------
Floating Text - Destroy (Load (Key Float) of SB_LooperKey in SB_HashIf the label is not found, this function returns NULL.)
Floating Text - Create floating text that reads (String((Integer(SB_CurrentRadius)))) above SB_Looper with Z offset 0.00, using font size 10.00, color (0.00%, 0.00%, 100.00%), and 0.00% transparency
Hashtable - Save Handle Of(Last created floating text) as (Key Float) of SB_LooperKey in SB_Hash
-------- Cleaning Leaks --------
Custom script: call DestroyGroup(udg_SB_DamageGroup[1])
Custom script: call DestroyGroup(udg_SB_DamageGroup[2])
Else - Actions
-------- Damaging Units --------
Set SB_DamageGroup[3] = (Units within SB_CurrentRadius of SB_LooperLoc)
Unit Group - Pick every unit in SB_DamageGroup[3] and do (Actions)
Loop - Actions
Set SB_Victim = (Picked unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
(SB_Victim is A structure) Not equal to True
(SB_Victim is Magic Immune) Not equal to True
(SB_Victim is alive) Equal to True
(SB_Victim belongs to an enemy of (Owner of SB_Looper)) Equal to True
Then - Actions
-------- Damaging Unit --------
Unit - Cause SB_Looper to damage SB_Victim, dealing SB_CollectedDamage damage of attack type Spells and damage type Magic
-------- SFX --------
Special Effect - Create a special effect attached to the chest of SB_Victim using SB_SFX[1]
Special Effect - Destroy (Last created special effect)
Else - Actions
-------- Floating Text for the damage --------
Floating Text - Create floating text that reads ((String((Integer(SB_CollectedDamage)))) + !) above SB_Looper with Z offset 0.00, using font size 15.00, color (0.00%, 0.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 lifespan of (Last created floating text) to 5.00 seconds
Floating Text - Change the fading age of (Last created floating text) to 4.00 seconds
-------- SFX --------
Special Effect - Create a special effect at SB_LooperLoc using SB_SFX[2]
Special Effect - Destroy (Last created special effect)
-------- Destroying the current lightning effect --------
Lightning - Destroy (Load (Key Lightning) of SB_LooperKey in SB_Hash)
Floating Text - Destroy (Load (Key Float) of SB_LooperKey in SB_HashIf the label is not found, this function returns NULL.)
-------- Clean Up --------
Custom script: call DestroyGroup(udg_SB_DamageGroup[3])
Hashtable - Clear all child hashtables of child SB_LooperKey in SB_Hash
Unit Group - Remove SB_Looper from SB_LoopGroup
-------- Checking --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(SB_LoopGroup is empty) Equal to True
Then - Actions
Trigger - Turn off (This trigger)
Else - Actions
Custom script: call RemoveLocation(udg_SB_LooperLoc)
[/trigger]
Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb Static Bomb

Changelogs:
Version 2
-Cleaned Leaks
Version 3
-Removed A variable
-Creates floating text to indicate the touch radius of the orb
-moved some variables
-Added new variable(SB_Height)
-changed lightning effect attachment
-Due to some sort of bug in lightnings,it remains unfixed
Version 4
-as of what Mag said,i moved the damagegroup 2 to then actions


Keywords:
static,orb,lightning,electric,sphere,thunder,bomb,explosion,storm
Contents

Static Bomb v4 (Map)

Reviews
06:55, 24th Jul 2012 Magtheridon96: Approved. 3.2/5.

Moderator

M

Moderator

06:55, 24th Jul 2012
Magtheridon96: Approved.
3.2/5.
 
When you scale a unit, the last 2 values don't matter.
They might as well be 0.

Don't repeat function calls over and over again.
For example, when you create the floating text, you can store the last
created floating text into a variable rather than repeating the call over and over again.
This can be applied to /everything/. (Last created unit) is another example.


Instead of repeating this line twice:
Custom script: call RemoveLocation(udg_SB_LooperLoc)

(Once in the Else actions and another in the Then actions),
you can use it just once outside of the entire if block.

Leaks should be destroyed in the same scope level that they were created in.
(Unless you're aborting a function, in which case, destroy all of them)

Actually, over here, you're overwriting the location.
Just delete this line:
Set SB_LooperLoc = (Position of SB_Looper)
From inside the Else actions, and it'll be fixed. (Because it currently leaks)

You also have a group leak in there.
SB_DamageGroup[2] will leak if the Then actions of the if block don't execute.


Why not set it to the random unit INSIDE the Then actions?
You only need it inside the Then actions anyway.
Group enumerations are expensive you know.


edit
The ones in green are solved.
The ones in red are the most important.
The ones in yellow are only minor suggestions for performance.
 
Last edited:
Level 5
Joined
Jan 5, 2012
Messages
116
Hey guys I have a problem. I did everything alright but when I saved map a message showed up saying that it expected a variable name in these lines:
set udg_SB_LooperX = GetUnitX(udg_SB_Looper)
set udg_SB_LooperY = GetUnitY(udg_SB_Looper)
set udg_SB_LooperZ = GetUnitFlyHeight(udg_SB_Looper)
// For the Picked Unit
set udg_SB_PickedX = GetUnitX(udg_SB_Picked)
set udg_SB_PickedY = GetUnitY(udg_SB_Picked)
set udg_SB_PickedZ = GetUnitFlyHeight(udg_SB_Picked) + udg_SB_Height
// Creating Lightning
set udg_SB_Lightning = AddLightningEx(udg_SB_LightningModel,true,udg_SB_LooperX,udg_SB_LooperY,udg_SB_LooperZ,udg_SB_PickedX,udg_SB_PickedY,udg_SB_PickedZ)

Can anyone help me please?
 
Top