-
Are you planning to upload your awesome spell or system to Hive? Please review the rules here.Dismiss Notice
-
Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.Dismiss Notice
-
A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!Dismiss Notice
-
Check out the Staff job openings thread.Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.
Spell Effect Indexer v1.5
Submitted by
Almia
- Tags:
- System, Template, GUI / Triggers
- Filesize:
- 25.68 KB
- Rating:
-
(1 vote)
- Downloads:
- 301
- Uploaded:
- Dec 21, 2012
- Updated:
- May 5, 2016
- Resources:
- 1
- Author(s):
- Almia
- State:
- Approved

This bundle is marked as approved. It works and satisfies the submission rules.
- Introduction
- Are you tired of rewriting a spell indexer all over again?
- Do you want a much easier spell indexer?
- Then here it is, the Spell Indexer!
- This helps users who uses a dynamic indexing and linked list for their spells.
- Features
- Spell Effect Event with corresponding Event variables for better retrieving
- Easy registering spells
- Auto registers looping timer event for every trigger with looping
- Requires:
- Code
Code (vJASS):
//************************************************************************************
//*
//*
//* SPELL EFFECT INDEXER
//*
//* BY : ALMIA
//*
//*
//************************************************************************************
//*
//* Indexes every instance created by a casted spell/ ability
//*
//************************************************************************************
//*
//* Requires:
//*
//* Linked List Table = http://www.hiveworkshop.com/forums/spells-569/linked-list-table-v1-2-a-230076/
//*
//************************************************************************************
//*
//* Code API
//*
//* constant function SpellDefaultTimeout takes nothing returns real
//* - System default timeout for looping spells
//*
//* function TriggerRegisterSpellEffect takes integer spell, trigger onEffect, trigger onLoop returns nothing
//*
//* - Registers the spell to the system
//* - Also, it registers the triggers being evaluated and looped
//* - Creates linked lists for every spell registered
//*
//* function RegisterSpellEffect takes integer spell, code onEffect ,code onLoop returns nothing
//* - Same goes to TriggerRegisterSpellEffect, though uses code
//*
//* function OnSpellEffect takes nothing returns boolean
//*
//* - System trigger condition
//* - Evaluates the triggers for every spell casted
//* - Creates new indexed instance for multi instancability
//*
//* function RecycleSpellIndex takes integer spell, integer index returns nothing
//*
//* - Recycles the spell's current index
//* - Used when the spell's effect ends in the loop
//*
//* function GetSpellNewIndex takes integer spell returns integer
//*
//* - Wrapper for SpellEffectEventIndex
//* - Created in case the SpellEffectEventIndex is overwritten
//*
//* function SpellGetFirst takes integer a returns integer
//*
//* - Gets the starting index of the spell's linked list
//*
//* function SpellGetNext takes integer a, integer index returns integer
//*
//* - Gets the next index of the given index from a spell's linked list
//*
//*
//************************************************************************************
//*
//* ITERATION MODULE
//*
//* All variables in between "$" will be replaced by your own variables
//* Must be CnPed
//*
//* Variables required:
//*
//* $SPELL$ = your Spell
//* $INDEX$ = Your Index variable
//*
//* =====================================================================
//*
//* set $INDEX$ = SpellGetFirst($SPELL$)
//*
//* loop
//*
//* exitwhen 0 == $INDEX$
//*
//* ( YOUR CODE HERE )
//*
//* ( IF YOUR SPELL'S EFFECT HAS ENDED )
//* ( MAKE SURE TO USE "call RecycleSpellIndex($SPELL$, $INDEX$)
//*
//* set $INDEX$ = SpellGetNext($SPELL$, $INDEX$)
//*
//* endloop
//*
//* =====================================================================
//*
//************************************************************************************
//*
//* NOTES:
//*
//* - Registers spells only in map initialization triggers.
//* - Do not register any events in your trigger which will have the spell's effect
//* - Do not register any events in your spell effect loop trigger
//* - Iteration module must be followed when iterating instances
//* - You can uses either GetSpellNewIndex or SpellEffectEventIndex to get
//* the spell being casted
//* - Use SpellEffectEventAbility to retrieve the casted spell
//*
//************************************************************************************
//*
//* Variables :
//*
//* SpellEffectEventIndex = Integer
//* SEI_Table = Hashtable
//*
//************************************************************************************
constant function SpellDefaultTimeout takes nothing returns real
return 0.031250000
endfunction
//************************************************************************************
function OnSpellEffect takes nothing returns boolean
// Locals
local integer spell = GetSpellAbilityId()
local integer count
local trigger t
if HaveSavedBoolean(udg_SEI_Table, spell, 0) then
set t = LoadTriggerHandle(udg_SEI_Table, spell, 1)
//Evaluating trigger with event-related variables
set udg_SpellEffectEventIndex = GetNewIndexFromLinkedList(LoadInteger(udg_SEI_Table, spell, 0))
//In case EventIndex is overwritten, save variable
call SaveInteger(udg_SEI_Table, spell, 4, udg_SpellEffectEventIndex)
//Start evaluating
if TriggerEvaluate(t) then
call TriggerExecute(t)
endif
set t = null
//Count instances
set count = LoadInteger(udg_SEI_Table, spell, 3) + 1
call SaveInteger(udg_SEI_Table, spell, 3, count)
//If instances counted is equal to 1
//then turn on the looping trigger
if 1 == count then
call EnableTrigger(LoadTriggerHandle(udg_SEI_Table, spell, 2))
endif
endif
return false
endfunction
//************************************************************************************
function InitSpellIndexer takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Filter(function OnSpellEffect))
set udg_SEI_Table = InitHashtable()
set t = null
endfunction
//************************************************************************************
function TriggerRegisterSpellEffect takes integer spell, trigger onEffect, trigger onLoop returns nothing
if null == udg_SEI_Table then
call InitSpellIndexer()
endif
call SaveBoolean(udg_SEI_Table, spell, 0, true)
// Creating new linked list for the registered ability
call SaveInteger(udg_SEI_Table, spell, 0, CreateLinkedList())
// Saving trigger related to spell
call SaveTriggerHandle(udg_SEI_Table, spell, 1, onEffect)
call SaveTriggerHandle(udg_SEI_Table, spell, 2, onLoop)
// registering looping event
call TriggerRegisterTimerEvent(onLoop, SpellDefaultTimeout(), true)
endfunction
//************************************************************************************
function RegisterSpellEffect takes integer spell, code onEffect ,code onLoop returns nothing
local trigger t = CreateTrigger()
local trigger t2 = CreateTrigger()
call TriggerAddCondition(t, Condition(onEffect))
call TriggerAddCondition(t, Condition(onLoop))
call TriggerRegisterSpellEffect(spell, t, t2)
set t = null
set t2 = null
endfunction
//************************************************************************************
function RecycleSpellIndex takes integer spell, integer index returns nothing
// Recycling Instance
local integer count = LoadInteger(udg_SEI_Table, spell, 3) - 1
call RecycleIndexFromLinkedList(LoadInteger(udg_SEI_Table, spell, 0), index)
call SaveInteger(udg_SEI_Table, spell, 3, count)
// If number of instance counted is equal to 0
// Disable trigger
if 0 == count then
call DisableTrigger(LoadTriggerHandle(udg_SEI_Table, spell, 2))
endif
endfunction
//************************************************************************************
//*
//* EXTRA FUNCTIONS or UTILS
//*
//************************************************************************************
// SPELL EFFECT EVENT RELATED
function GetSpellNewIndex takes integer spell returns integer
return LoadInteger(udg_SEI_Table, spell, 4)
endfunction
// ITERATION RELATED
function SpellGetFirst takes integer a returns integer
return GetFirstIndexFromLinkedList(LoadInteger(udg_SEI_Table, a, 0))
endfunction
function SpellGetNext takes integer a, integer index returns integer
return GetNextIndexFromLinkedList(LoadInteger(udg_SEI_Table, a, 0), index)
endfunction
//************************************************************************************
- Demo
-
-
TC Start
-
Events
-
Map initialization
-
-
Conditions
-
Actions
-
Custom script: call RegisterSpellEffect('AHtc', gg_trg_TC_Cast , gg_trg_TC_Loop)
-
-
-
-
-
TC Cast
-
Events
-
Conditions
-
Actions
-
Set TC_Index = SpellEffectEventIndex
-
Set TC_U[TC_Index] = (Triggering unit)
-
Set TC_Time[TC_Index] = 0.00
-
Set TC_Duration[TC_Index] = 10.00
-
-
-
-
-
TC Loop
-
Events
-
Conditions
-
Actions
-
Custom script: set udg_TC_Index = SpellGetFirst('AHtc')
-
Custom script: loop
-
Custom script: exitwhen 0 == udg_TC_Index
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
TC_Time[TC_Index] Less than TC_Duration[TC_Index]
-
-
Then - Actions
-
Custom script: set udg_TC_Time[udg_TC_Index] = udg_TC_Time[udg_TC_Index] + SpellDefaultTimeout()
-
Set TC_Loc = (Position of TC_U[TC_Index])
-
Special Effect - Create a special effect at TC_Loc using Abilities\Spells\Orc\MirrorImage\MirrorImageCaster.mdl
-
Special Effect - Destroy (Last created special effect)
-
Custom script: call RemoveLocation(udg_TC_Loc)
-
-
Else - Actions
-
Custom script: call RecycleSpellIndex('AHtc', udg_TC_Index)
-
Set TC_U[TC_Index] = No unit
-
Set TC_Duration[TC_Index] = 0.00
-
Set TC_Time[TC_Index] = 0.00
-
-
-
Custom script: set udg_TC_Index = SpellGetNext('AHtc',udg_TC_Index)
-
Custom script: endloop
-
-
-
-
- Installing
- Install Linked List Table
- Copy the Spell Effect Indexer trigger.
- Create variables listed in the code
- Changelogs
- Updated system due to Linked List Table's update.
- Updated due to Linked List Table's update
- Code simplified
- - New Update -
- Now supports codes
- Updated to get rid of Wacraft III Header compiler's bug
Contents
Page 1 of 2