Moderator
M
Moderator
Maker, 3rd Aug 2011, Cloud Spiral V2.2
Approved. Could be useful ability in custom maps.
Cloud Spiral - A Spell Template for those new to GUI
Spins cloud around the caster, damaging all units within area of the clouds.
75 Damage,
Each Level adds +1.70 seconds to duration.
Unit Indexer
Events
Map initialization
Conditions
Actions
Custom script: call ExecuteFunc("InitializeUnitIndexer")
Custom script: endfunction
-------- --------
-------- This is the most important function - it provides an index for units as they enter the map --------
-------- --------
Custom script: function IndexUnit takes nothing returns boolean
-------- --------
-------- You can use the boolean UnitIndexerEnabled to protect some of your undesirable units from being indexed --------
-------- Example: --------
-------- Set UnitIndexerEnabled = False --------
-------- Unit - Create 1 Dummy for (Triggering player) at TempLoc facing 0.00 degrees --------
-------- Set UnitIndexerEnabled = True --------
-------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
UnitIndexerEnabled Equal to True
Then - Actions
-------- --------
-------- Generate a unique integer index for this unit --------
-------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
UDexRecycle Equal to 0
Then - Actions
Set UDex = (UDexGen + 1)
Set UDexGen = UDex
Else - Actions
Set UDex = UDexRecycle
Set UDexRecycle = UDexNext[UDex]
-------- --------
-------- Link index to unit, unit to index --------
-------- --------
Set UDexUnits[UDex] = (Matching unit)
Unit - Set the custom value of UDexUnits[UDex] to UDex
-------- --------
-------- Use a doubly-linked list to store all active indexes --------
-------- --------
Set UDexPrev[UDexNext[0]] = UDex
Set UDexNext[UDex] = UDexNext[0]
Set UDexNext[0] = UDex
-------- --------
-------- Fire index event for UDex --------
-------- --------
Set UnitIndexEvent = 1.00
Set UnitIndexEvent = 0.00
Else - Actions
Custom script: return false
Custom script: endfunction
-------- --------
-------- The next function is called each time a unit enters the map --------
-------- --------
Custom script: function IndexNewUnit takes nothing returns boolean
Custom script: local integer pdex
Custom script: local integer ndex
-------- --------
-------- Process to give each unit a custom value for use as array indices --------
-------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
UDexWasted Equal to 15
Then - Actions
-------- --------
-------- Deindex all potentially-removed units for every (15) units created --------
-------- --------
Custom script: set pdex = udg_UDex
Set UDex = UDexNext[0]
Custom script: loop
Custom script: exitwhen udg_UDex == 0
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Custom value of UDexUnits[UDex]) Equal to 0
Then - Actions
-------- --------
-------- Fire deindex event for UDex --------
-------- --------
Set UnitIndexEvent = 2.00
Set UnitIndexEvent = 0.00
-------- --------
-------- Remove index from linked list --------
-------- --------
Custom script: set ndex = udg_UDexNext[udg_UDex]
Custom script: set udg_UDexNext[udg_UDexPrev[udg_UDex]] = ndex
Custom script: set udg_UDexPrev[ndex] = udg_UDexPrev[udg_UDex]
Set UDexPrev[UDex] = 0
-------- --------
-------- Prepare index to be recycled --------
-------- --------
Set UDexUnits[UDex] = No unit
Set UDexNext[UDex] = UDexRecycle
Set UDexRecycle = UDex
Custom script: set udg_UDex = ndex
Else - Actions
Set UDex = UDexNext[UDex]
Custom script: endloop
Custom script: set udg_UDex = pdex
Set UDexWasted = 0
Else - Actions
Set UDexWasted = (UDexWasted + 1)
-------- --------
-------- Handle the entering unit (Matching unit) --------
-------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Custom value of (Matching unit)) Equal to 0
Then - Actions
Custom script: call IndexUnit()
Else - Actions
Custom script: return false
Custom script: endfunction
-------- --------
-------- The next function initializes the core of the system --------
-------- --------
Custom script: function InitializeUnitIndexer takes nothing returns nothing
Custom script: local integer i = 0
Custom script: local region re = CreateRegion()
Custom script: local rect r = GetWorldBounds()
Set UnitIndexerEnabled = True
Custom script: call RegionAddRect(re, r)
Custom script: call TriggerRegisterEnterRegion(CreateTrigger(), re, Filter(function IndexNewUnit))
Custom script: call RemoveRect(r)
Custom script: set re = null
Custom script: set r = null
Custom script: loop
Custom script: call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, Player(i), Filter(function IndexUnit))
Custom script: set i = i + 1
Custom script: exitwhen i == 16
Custom script: endloop
-------- --------
-------- This is the "Unit Indexer Initialized" event --------
-------- --------
Set UnitIndexEvent = 3.00
Set UnitIndexEvent = 0.00
Cloud Spiral Int
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Cloudspiral
Actions
-------- --------
-------- VARIABLE START --------
Set Key = (Custom value of (Triggering unit))
Set SpellIndex = (SpellIndex + 1)
Set Caster[Key] = (Triggering unit)
Set SpellPower[Key] = (Level of Cloudspiral for Caster[Key])
Set Damage[Key] = 75.00
Set TimeInterval[Key] = 0.00
Set TimeCompletion[Key] = ((Real(SpellPower[Key])) x 1.20)
Set SpellRan[Key] = True
Set Distance[Key] = 0.00
Set Angle[Key] = 0.00
Unit Group - Add Caster[Key] to SpellGroup
Trigger - Turn on Cloud Spiral loop <gen>
-------- --------
-------- VARIABLE FINISH --------
Cloud Spiral loop
Events
Time - Every 0.03 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in CS_SpellGroup and do (Actions)
Loop - Actions
Set TempKey = (Custom value of (Picked unit))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(CS_Caster[TempKey] is dead) Equal to True
(CS_Caster[TempKey] has buff Stunned (Pause)) Equal to True
CS_TimeInterval[TempKey] Greater than or equal to CS_TimeCompletion[TempKey]
Then - Actions
Set CS_SpellRan[TempKey] = False
Unit Group - Remove CS_Caster[TempKey] from CS_SpellGroup
Set CS_SpellIndex = (CS_SpellIndex - 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CS_SpellIndex Equal to 0
Then - Actions
Trigger - Turn off (This trigger)
Else - Actions
Else - Actions
-------- --------
Set CS_TimeInterval[TempKey] = (CS_TimeInterval[TempKey] + 0.03)
Set CS_Distance[TempKey] = (CS_Distance[TempKey] + 2.50)
Set CS_Angle[TempKey] = (CS_Angle[TempKey] + 11.25)
Set TempPoint = (Position of CS_Caster[TempKey])
Set TempPoint2 = (TempPoint offset by CS_Distance[TempKey] towards CS_Angle[TempKey] degrees)
-------- --------
Set UnitIndexerEnabled = False
Unit - Create 1 CS_DummyCloud for (Owner of CS_Caster[TempKey]) at TempPoint2 facing Default building facing degrees
Set UnitIndexerEnabled = True
Unit - Add a CS_TimeCompletion[TempKey] second Generic expiration timer to (Last created unit)
Set TempGroup = (Units within 50.00 of TempPoint2 matching (((((Matching unit) is A structure) Not equal to True) and (((Matching unit) is dead) Not equal to True)) and (((Matching unit) belongs to an ally of (Owner of CS_Caster[TempKey])) Not equal to True)))
Unit Group - Pick every unit in TempGroup and do (Actions)
Loop - Actions
Unit - Cause CS_Caster[TempKey] to damage (Picked unit), dealing CS_Damage[TempKey] damage of attack type Spells and damage type Normal
-------- --------
Custom script: call RemoveLocation(udg_TempPoint)
Custom script: call RemoveLocation(udg_TempPoint2)
Custom script: call DestroyGroup(udg_TempGroup)
Preload Spell
Events
Game - UnitIndexEvent becomes Equal to 3.00
Conditions
Actions
Set UnitIndexerEnabled = False
Set TempPoint = (Center of (Playable map area))
Unit - Create 1 CS_DummyCloud for (Owner of CS_Caster[TempKey]) at TempPoint2 facing Default building facing degrees
Set TempUnit = (Last created unit)
-------- --------
-------- To preload abilities and/or buffs, just add them to TempUnit --------
-------- --------
Unit - Add Cloudspiral to TempUnit
-------- --------
-------- The dummy unit's task is now done, it can be removed from the game --------
-------- --------
Unit - Remove TempUnit from the game
Custom script: call RemoveLocation(udg_TempPoint)
Set UnitIndexerEnabled = True
Instructions on how to move into your map :Credits
Credits to Bribe for his Unit Indexer Which allows the use of Indexing for units in GUI; for those just getting use to GUI.
This spell uses a Unit indexing system, (not created by me)
1. Copy Custom Map script, Top part of triggers
2. Copy Unit Indexer (gen)
3. Copy Abilitiy (Cloudspin) and Unit (Cloudspin Dummy)
4. Copy Cloud Spin int and Cloud Spin loop (gen) and Preload Spell <gen>
Minor change to layout of triggers, so that spell shall stop if caster is dead or stunned.
Added Integer, to detect when no spells are running to turn off the trigger.
Changed back to TempPoint and TempPoint2,
Removed CS_CasterPoint. Fixed minor bugs.
Changed the hotkey,
Fixed the same trigger (changed loop order)
Increased Duration of spell to 1.7 with a increase of 1.7.
Changed the hotkey... again
Added new Unit Indexer.
Fixed the Cant Raise Does Not Decay for Dummy
- Made it so the CloudSpin Dummy units do not get a customvalue, this will cut down on the increase of customvalue.
Added new Trigger "Preload Spell"