//TESH.scrollpos=0
//TESH.alwaysfold=0
Name | Type | is_array | initial_value |
TempInteger | integer | No | |
TempString | string | No |
//TESH.scrollpos=60
//TESH.alwaysfold=0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Wietlol's Advanced Event Management System 1.2 24/04/2015
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Description:
// This system is made to create events and add triggers aka event responses to an event.
// The reason is that you can remove event responses from an event, create subevents to increase performance by ignoring checks
// and to control priority of event responses.
// This system is written in JASS and requires JASSHelper to copmile.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// How to install:
// 1. Copy the Advanced Event Management System (AEM) category and paste it in your map.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// How to create event responses for GUI triggers:
// 1. Find out how the trigger is called...
// Trigger names are "gg_trg_" + the name of the trigger in the list at the left of the screen
// where spaces are replaced by underscores.
// Trigger "AEM System" is called "gg_trg_AEM_System"
// 2. Go to any JASS trigger and find the InitTrig_<triggerName> function. (Ussually found at the bottom.)
// You can go to the AEM_Normal_Events_Implementation trigger.
// 3. Write "call AEM_FunctionRegisterEvent(<eventName>, <triggerName>, udg_AEM_EXECUTION_TYPE_CONDITIONAL, 0, true, true)"
// <eventName> is the name of the event.
// <triggerName> is the name of the trigger which we have made in step 1.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Feature list:
// This system:
// - allows you to create custom events.
// - allows you to remove triggers from events.
// - allows you to control priority of event responses.
// - allows you to automatically remove an event response after the first call.
// - allows you to create an event with a (integer)parameter to separate speficif event responses into the proper events.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Variable explaination:
//////////////////////////
// General:
// - AEM_EXECUTION_TYPE_CONDITIONAL - integer
// This is the execution type for regular execution.
// It is recommended for GUI triggers.
//
// - AEM_EXECUTION_TYPE_EVALUATE - integer
// This is the execution type for conditions only.
// It is recommended for JASS triggers.
//
// - AEM_EXECUTION_TYPE_EXECUTE - integer
// This is the execution type for actions only.
// It is recommended for ... well... nothing.
//
// - AEM_Hashtable - hashtable
// The AEM System uses 3 hashtables.
// In the first hashtable are the events saved together with all their event responses.
// In the second hashtable are event ids saved of events that have a subtype.
// These subtypes can be used to increase performance of event responses
// by only running the triggers that very probably have actions on that event.
// The third hashtable allows a second subtype making events even more specific.
//
// - udg_AEM_NextIndex - integer
// This is the index of the latest event.
// When creating an event response to an unknown event, a unique number is created that will represent that event.
// For NextIndex3, the next index is for the
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Changelog:
// 1.2 - 24/04/2015 -
// - Added other spell events in the Normal Event Implementation trigger.
// - Added spell examples.
// - Added the possibility to stop all other actions to the current event.
// - Added the possibility to start an event from a certain priority.
//
// 1.1 - 20/04/2015 - Second Subtype.
// - Now has a second subtype for even more specific events.
// - Renamed register functions so the name is more logic.
// - Made the creation event have "bj_lastCreatedUnit" as the created unit.
//
// 1.0 - 17/04/2015 - First official release on the Hive.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Known bugs:
// - You can add an event response to an event multiple times but you only remove one.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
library aemSystem
globals
integer udg_AEM_EXECUTION_TYPE_CONDITIONAL = 0
integer udg_AEM_EXECUTION_TYPE_EVALUATE = 1
integer udg_AEM_EXECUTION_TYPE_EXECUTE = 2
hashtable udg_AEM_Hashtable1 = InitHashtable()
hashtable udg_AEM_Hashtable2 = InitHashtable()
hashtable udg_AEM_Hashtable3 = InitHashtable()
integer udg_AEM_NextIndex2 = 9999
integer udg_AEM_NextIndex3 = 9999
integer udg_AEM_StopRemainingEventResponses = 1
//////////////////////////////////////////////////////////////////////////////////////
//
// Event List:
// Make sure that all events have a unique id between 1 and 9,999.
// Events with 0 or lower are illegal events.
// Events above 9,999 are dynamic events, created by the second hashtable.
// You can increase that amount in the global variable above but you won't have much problems with 9,999 events.
//
// |----|-|----| |----------------------------------------------------------------|
// |0001|-|0017| |AEM_Normal_Events_Implementation |
// |----|-|----| |----------------------------------------------------------------|
//////////////////////////////////////////////////////////////////////////////////////
endglobals
//////////////////////////////////////////////////////////////////////////////////////
//These functions remove an event response from an event.
// whichEvent is the event id where the response is linked to.
// whichTrigger is the trigger that must be removed.
function AEM_FunctionRemoveEvent takes integer whichEvent, trigger whichTrigger returns nothing
local integer i = 0
local trigger t
loop
//The end of the responses is reached.
exitwhen not(HaveSavedHandle(udg_AEM_Hashtable1, whichEvent, i))
//The trigger has been found.
set t = LoadTriggerHandle(udg_AEM_Hashtable1, whichEvent, i)
if t == whichTrigger then
loop
exitwhen not HaveSavedHandle(udg_AEM_Hashtable1, whichEvent, i+4)
//Replace all event responses after the found trigger by the ones that follow it afterwards.
call SaveTriggerHandle(udg_AEM_Hashtable1, whichEvent, i, LoadTriggerHandle(udg_AEM_Hashtable1, whichEvent, i+4))
call SaveInteger(udg_AEM_Hashtable1, whichEvent, i+1, LoadInteger(udg_AEM_Hashtable1, whichEvent, i+5))
call SaveBoolean(udg_AEM_Hashtable1, whichEvent, i+2, LoadBoolean(udg_AEM_Hashtable1, whichEvent, i+6))
call SaveInteger(udg_AEM_Hashtable1, whichEvent, i+3, LoadInteger(udg_AEM_Hashtable1, whichEvent, i+7))
set i = i + 3
endloop
//Remove the last event response from the event.
call RemoveSavedHandle(udg_AEM_Hashtable1, whichEvent, i)
call RemoveSavedInteger(udg_AEM_Hashtable1, whichEvent, i+1)
call RemoveSavedBoolean(udg_AEM_Hashtable1, whichEvent, i+2)
call RemoveSavedInteger(udg_AEM_Hashtable1, whichEvent, i+3)
return
endif
set i = i + 3
endloop
endfunction
//Same as above.
// whichParameter is the subtype of the event response.
function AEM_FunctionRemoveEvent2 takes integer whichEvent, integer whichParameter2, trigger whichTrigger returns nothing
local integer index = LoadInteger(udg_AEM_Hashtable2, whichEvent, whichParameter2)
if index == 0 then
return
endif
call AEM_FunctionRemoveEvent(index, whichTrigger)
endfunction
//Same as above.
// whichParameter is the subtype of the event response.
function AEM_FunctionRemoveEvent3 takes integer whichEvent, integer whichParameter2, integer whichParameter3, trigger whichTrigger returns nothing
local integer index = LoadInteger(udg_AEM_Hashtable3, whichEvent, whichParameter2)
if index == 0 then
return
endif
call AEM_FunctionRemoveEvent2(index, whichParameter3, whichTrigger)
endfunction
//////////////////////////////////////////////////////////////////////////////////////
//These functions call the events made in this system.
// whichEvent is the event id that is fired.
function AEM_CallEventWithPriority takes integer whichEvent, integer startingPriority returns nothing
local trigger array triggers
local integer index
local integer i
local integer array executionType
local integer oldStopRemainingEventResponses
//Check if the event is a valid event.
if whichEvent <= 0 then
return
endif
//Save all event responses locally.
set i = startingPriority
set index = 0
loop
exitwhen not(HaveSavedHandle(udg_AEM_Hashtable1, whichEvent, i))
set triggers[index] = LoadTriggerHandle(udg_AEM_Hashtable1, whichEvent, i)
set executionType[index] = LoadInteger(udg_AEM_Hashtable1, whichEvent, i+3)
if not(LoadBoolean(udg_AEM_Hashtable1, whichEvent, i+2)) then
//Remove the event response because it is not repeating.
call AEM_FunctionRemoveEvent(whichEvent, triggers[index])
set i = i - 4
endif
set index = index + 1
set i = i + 4
endloop
//Call all locally saved triggers.
set oldStopRemainingEventResponses = udg_AEM_StopRemainingEventResponses
set udg_AEM_StopRemainingEventResponses = 1
set i = 0
loop
exitwhen udg_AEM_StopRemainingEventResponses <= 0
exitwhen i >= index
if executionType[i] == udg_AEM_EXECUTION_TYPE_CONDITIONAL then
if TriggerEvaluate(triggers[i]) then
call TriggerExecute(triggers[i])
endif
elseif executionType[i] == udg_AEM_EXECUTION_TYPE_EVALUATE then
call TriggerEvaluate(triggers[i])
elseif executionType[i] == udg_AEM_EXECUTION_TYPE_EXECUTE then
call TriggerExecute(triggers[i])
endif
set triggers[i] = null
set i = i + 1
endloop
set udg_AEM_StopRemainingEventResponses = oldStopRemainingEventResponses
endfunction
function AEM_CallEvent takes integer whichEvent returns nothing
call AEM_CallEventWithPriority(whichEvent, 0)
endfunction
//Same as above.
// whichParameter2 is the subtype of the event response.
function AEM_CallEvent2WithPriority takes integer whichEvent, integer whichParameter2, integer startingPriority returns nothing
call AEM_CallEventWithPriority(LoadInteger(udg_AEM_Hashtable2, whichEvent, whichParameter2), startingPriority)
endfunction
function AEM_CallEvent2 takes integer whichEvent, integer whichParameter2 returns nothing
call AEM_CallEvent2WithPriority(whichEvent, whichParameter2, 0)
endfunction
//Same as above.
// whichParameter3 is the sub-subtype of the event response.
function AEM_CallEvent3WithPriority takes integer whichEvent, integer whichParameter2, integer whichParameter3, integer startingPriority returns nothing
call AEM_CallEvent2WithPriority(LoadInteger(udg_AEM_Hashtable3, whichEvent, whichParameter2), whichParameter3, startingPriority)
endfunction
function AEM_CallEvent3 takes integer whichEvent, integer whichParameter2, integer whichParameter3 returns nothing
call AEM_CallEvent3WithPriority(whichEvent, whichParameter2, whichParameter3, 0)
endfunction
//////////////////////////////////////////////////////////////////////////////////////
//These functions register a trigger to an event.
// whichEvent is the event id that is used.
// whichTrigger is the trigger that is executed when the event fires.
// executionType is the type of how the trigger is executed (only conditions, only actions, both (if conditions allow to)).
// priority is the order in which the triggers are executed. Low priority is called first. High priority is called last.
// priorize is if this trigger must be before the other trigger in the same priority. Be aware that registrations after this one can override that priority.
// repeating is if the trigger must remain on the event. When this is put to false, the trigger gets removed from the event on the next call.
function AEM_RegisterTrigger takes integer whichEvent, trigger whichTrigger, integer executionType, integer priority, boolean priorize, boolean repeating returns nothing
local integer i = 0
local integer i2
local boolean shiftRemaining = false
//Find the proper place for the event response.
loop
exitwhen not(HaveSavedHandle(udg_AEM_Hashtable1, whichEvent, i))
set shiftRemaining = true
if priorize then
exitwhen LoadInteger(udg_AEM_Hashtable1, whichEvent, i+1) >= priority
else
exitwhen LoadInteger(udg_AEM_Hashtable1, whichEvent, i+1) > priority
endif
set shiftRemaining = false
set i = i + 4
endloop
//Check if the event response is placed between other event responses or placed at the end.
if shiftRemaining then
set i2 = i + 4
loop
exitwhen not(HaveSavedHandle(udg_AEM_Hashtable1, whichEvent, i2))
set i2 = i2 + 4
endloop
loop
exitwhen i2 == i
call SaveTriggerHandle(udg_AEM_Hashtable1, whichEvent, i2, LoadTriggerHandle(udg_AEM_Hashtable1, whichEvent, i2-4))
call SaveInteger(udg_AEM_Hashtable1, whichEvent, i2+1, LoadInteger(udg_AEM_Hashtable1, whichEvent, i2-3))
call SaveBoolean(udg_AEM_Hashtable1, whichEvent, i2+2, LoadBoolean(udg_AEM_Hashtable1, whichEvent, i2-2))
call SaveInteger(udg_AEM_Hashtable1, whichEvent, i+3, LoadInteger(udg_AEM_Hashtable1, whichEvent, i2-1))
set i2 = i2 - 4
endloop
endif
//Save the event response to the event.
call SaveTriggerHandle(udg_AEM_Hashtable1, whichEvent, i, whichTrigger)
call SaveInteger(udg_AEM_Hashtable1, whichEvent, i+1, priority)
call SaveBoolean(udg_AEM_Hashtable1, whichEvent, i+2, repeating)
call SaveInteger(udg_AEM_Hashtable1, whichEvent, i+3, executionType)
endfunction
//Same as above.
// whichParameter2 is the subtype of the event.
function AEM_RegisterTrigger2 takes integer whichEvent, integer whichParameter2, trigger whichTrigger, integer executionType, integer priority, boolean priorize, boolean repeating returns nothing
//If the event doesn't exist yet, create an event with the NextIndex2.
local integer index = LoadInteger(udg_AEM_Hashtable2, whichEvent, whichParameter2)
if index == 0 then
set udg_AEM_NextIndex2 = udg_AEM_NextIndex2 + 1
set index = udg_AEM_NextIndex2
call SaveInteger(udg_AEM_Hashtable2, whichEvent, whichParameter2, index)
endif
//Add the trigger to the event response.
call AEM_RegisterTrigger(index, whichTrigger, executionType, priority, priorize, repeating)
endfunction
//Same as above.
// whichParameter3 is the sub-subtype of the event.
function AEM_RegisterTrigger3 takes integer whichEvent, integer whichParameter2, integer whichParameter3, trigger whichTrigger, integer executionType, integer priority, boolean priorize, boolean repeating returns nothing
//If the event doesn't exist yet, create an event with the NextIndex3.
local integer index = LoadInteger(udg_AEM_Hashtable3, whichEvent, whichParameter2)
if index == 0 then
set udg_AEM_NextIndex3 = udg_AEM_NextIndex3 + 1
set index = udg_AEM_NextIndex3
call SaveInteger(udg_AEM_Hashtable3, whichEvent, whichParameter2, index)
endif
//Add the trigger to the event response.
call AEM_RegisterTrigger2(index, whichParameter3, whichTrigger, executionType, priority, priorize, repeating)
endfunction
endlibrary
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// AEM System end
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TESH.scrollpos=248
//TESH.alwaysfold=0
globals
integer udg_AEM_Event_Player_Chat_Message = 1
integer udg_AEM_Event_Player_Esc_Button = 2
integer udg_AEM_Event_Player_Leave = 3
integer udg_AEM_Event_Unit_Pickup_Item = 4
integer udg_AEM_Event_Unit_Drop_Item = 5
integer udg_AEM_Event_Unit_Attacked = 6
integer udg_AEM_Event_Unit_Spell_Channel = 7
integer udg_AEM_Event_Unit_Spell_Cast = 8
integer udg_AEM_Event_Unit_Spell_Effect = 9
integer udg_AEM_Event_Unit_Spell_Finish = 10
integer udg_AEM_Event_Unit_Spell_Cancel = 11
integer udg_AEM_Event_Unit_Levelup = 12
integer udg_AEM_Event_Unit_Die = 13
integer udg_AEM_Event_Unit_Order_Target = 14
integer udg_AEM_Event_Unit_Order_Point = 15
integer udg_AEM_Event_Unit_Order_Instant = 16
integer udg_AEM_Event_Unit_Created = 17
endglobals
function AEM_Event_Player_Chat_Message takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Player_Chat_Message)
return false
endfunction
function AEM_Event_Player_Esc_Button takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Player_Esc_Button)
return false
endfunction
function AEM_Event_Player_Leave takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Player_Leave)
return false
endfunction
function AEM_Event_Unit_Pickup_Item takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Unit_Pickup_Item)
call AEM_CallEvent2(udg_AEM_Event_Unit_Pickup_Item, GetItemTypeId(GetManipulatedItem()))
return false
endfunction
function AEM_Event_Unit_Drop_Item takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Unit_Drop_Item)
call AEM_CallEvent2(udg_AEM_Event_Unit_Drop_Item, GetItemTypeId(GetManipulatedItem()))
return false
endfunction
function AEM_Event_Unit_Attacked takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Unit_Attacked)
return false
endfunction
function AEM_Event_Unit_Spell_Cast takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Unit_Spell_Cast)
call AEM_CallEvent2(udg_AEM_Event_Unit_Spell_Cast, GetSpellAbilityId())
return false
endfunction
function AEM_Event_Unit_Spell_Channel takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Unit_Spell_Channel)
call AEM_CallEvent2(udg_AEM_Event_Unit_Spell_Channel, GetSpellAbilityId())
return false
endfunction
function AEM_Event_Unit_Spell_Effect takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Unit_Spell_Effect)
call AEM_CallEvent2(udg_AEM_Event_Unit_Spell_Effect, GetSpellAbilityId())
return false
endfunction
function AEM_Event_Unit_Spell_Finish takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Unit_Spell_Finish)
call AEM_CallEvent2(udg_AEM_Event_Unit_Spell_Finish, GetSpellAbilityId())
return false
endfunction
function AEM_Event_Unit_Spell_Cancel takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Unit_Spell_Cancel)
call AEM_CallEvent2(udg_AEM_Event_Unit_Spell_Cancel, GetSpellAbilityId())
return false
endfunction
function AEM_Event_Unit_Levelup takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Unit_Levelup)
return false
endfunction
function AEM_Event_Unit_Die takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Unit_Die)
return false
endfunction
function AEM_Event_Unit_Order_Target takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Unit_Order_Target)
call AEM_CallEvent2(udg_AEM_Event_Unit_Order_Target, GetIssuedOrderId())
return false
endfunction
function AEM_Event_Unit_Order_Point takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Unit_Order_Point)
call AEM_CallEvent2(udg_AEM_Event_Unit_Order_Point, GetIssuedOrderId())
return false
endfunction
function AEM_Event_Unit_Order_Instant takes nothing returns boolean
call AEM_CallEvent(udg_AEM_Event_Unit_Order_Instant)
call AEM_CallEvent2(udg_AEM_Event_Unit_Order_Instant, GetIssuedOrderId())
return false
endfunction
function UnitCreation_Event takes nothing returns boolean
set bj_lastCreatedUnit = GetFilterUnit()
call AEM_CallEvent(udg_AEM_Event_Unit_Created)
return false
endfunction
function UnitCreation_Start takes nothing returns nothing
local group g = CreateGroup()
local trigger t = CreateTrigger()
local region rectRegion = CreateRegion()
call DestroyTimer(GetExpiredTimer())
call RegionAddRect(rectRegion, GetWorldBounds())
call TriggerRegisterEnterRegion(t, rectRegion, Filter(function UnitCreation_Event))
call GroupEnumUnitsInRect(g, GetWorldBounds(), Filter(function UnitCreation_Event))
call DestroyGroup(g)
set g = null
endfunction
//===========================================================================
function InitTrig_AEM_Normal_Events_Implementation takes nothing returns nothing
local trigger t
local integer i
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerChatEvent(t, Player(i), "", false)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Player_Chat_Message))
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_END_CINEMATIC)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Player_Esc_Button))
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_LEAVE)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Player_Leave))
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_PICKUP_ITEM, null)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Unit_Pickup_Item))
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_DROP_ITEM, null)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Unit_Drop_Item))
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_ATTACKED, null)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Unit_Attacked))
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_CHANNEL, null)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Unit_Spell_Channel))
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_CAST, null)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Unit_Spell_Cast))
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Unit_Spell_Effect))
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_FINISH, null)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Unit_Spell_Finish))
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_ENDCAST, null)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Unit_Spell_Cancel))
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_HERO_LEVEL, null)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Unit_Levelup))
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_DEATH, null)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Unit_Die))
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Unit_Order_Target))
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Unit_Order_Point))
set t = CreateTrigger()
set i = 0
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
set i = i + 1
endloop
call TriggerAddCondition(t, Filter(function AEM_Event_Unit_Order_Instant))
call TimerStart(CreateTimer(), 0.05, false, function UnitCreation_Start)
set t = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function AEM_Example_Action takes nothing returns boolean
call BJDebugMsg("Example1 Called")
return false
endfunction
function AEM_Example_Action2 takes nothing returns boolean
call BJDebugMsg("Example2 Called")
return false
endfunction
//===========================================================================
function InitTrig_AEM_Example takes nothing returns nothing
local trigger t = CreateTrigger()
call AEM_RegisterTrigger(udg_AEM_Event_Player_Esc_Button, t, udg_AEM_EXECUTION_TYPE_EVALUATE, 0, true, true)
call TriggerAddCondition(t, Filter(function AEM_Example_Action))
set t = CreateTrigger()
call AEM_RegisterTrigger(udg_AEM_Event_Player_Esc_Button, t, udg_AEM_EXECUTION_TYPE_EVALUATE, 0, true, true)
call TriggerAddCondition(t, Filter(function AEM_Example_Action2))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Old_Way_Actions takes nothing returns boolean
local integer abilityId = GetSpellAbilityId()
//Ofcourse this is also very optimal compared to what people use. (separate triggers in one)
if abilityId == 'AHav' then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Avatar has being cast.")
endif
if abilityId == 'AHbn' then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Banish has being cast.")
endif
if abilityId == 'AHbz' then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Blizzard has being cast.")
endif
if abilityId == 'AHds' then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Divine Shield has being cast.")
endif
if abilityId == 'AHfs' then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Flame Strike has being cast.")
endif
if abilityId == 'AHhb' then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Holy Light has being cast.")
endif
if abilityId == 'AHmt' then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Mass Teleport has being cast.")
endif
if abilityId == 'AHpx' then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Phoenix has being cast.")
endif
if abilityId == 'AHre' then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Resurrection has being cast.")
endif
if abilityId == 'AHdr' then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Siphon Mana has being cast.")
endif
if abilityId == 'AHtb' then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Storm Bolt has being cast.")
endif
if abilityId == 'AHwe' then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Summon Water Elemental has being cast.")
endif
if abilityId == 'AHtc' then
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Thunder Clap has being cast.")
endif
return false
endfunction
//===========================================================================
function InitTrig_Old_Way takes nothing returns nothing
set gg_trg_Old_Way = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Old_Way, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_Old_Way, Filter(function Trig_Old_Way_Actions))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Ability_Effect_Avatar takes nothing returns boolean
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Avatar has being cast.")
return false
endfunction
//===========================================================================
function InitTrig_Avatar takes nothing returns nothing
local trigger t = CreateTrigger()
call AEM_RegisterTrigger2(udg_AEM_Event_Unit_Spell_Effect, 'AHav', t, udg_AEM_EXECUTION_TYPE_EVALUATE, 0, true, true)
call TriggerAddCondition(t, Filter(function Ability_Effect_Avatar))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Ability_Effect_Banish takes nothing returns boolean
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Banish has being cast.")
return false
endfunction
//===========================================================================
function InitTrig_Banish takes nothing returns nothing
local trigger t = CreateTrigger()
call AEM_RegisterTrigger2(udg_AEM_Event_Unit_Spell_Effect, 'AHbn', t, udg_AEM_EXECUTION_TYPE_EVALUATE, 0, true, true)
call TriggerAddCondition(t, Filter(function Ability_Effect_Banish))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Ability_Effect_Blizzard takes nothing returns boolean
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Blizzard has being cast.")
return false
endfunction
//===========================================================================
function InitTrig_Blizzard takes nothing returns nothing
local trigger t = CreateTrigger()
call AEM_RegisterTrigger2(udg_AEM_Event_Unit_Spell_Effect, 'AHbz', t, udg_AEM_EXECUTION_TYPE_EVALUATE, 0, true, true)
call TriggerAddCondition(t, Filter(function Ability_Effect_Blizzard))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Ability_Effect_DivineShield takes nothing returns boolean
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Divine Shield has being cast.")
return false
endfunction
//===========================================================================
function InitTrig_Divine_Shield takes nothing returns nothing
local trigger t = CreateTrigger()
call AEM_RegisterTrigger2(udg_AEM_Event_Unit_Spell_Effect, 'AHds', t, udg_AEM_EXECUTION_TYPE_EVALUATE, 0, true, true)
call TriggerAddCondition(t, Filter(function Ability_Effect_DivineShield))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Ability_Effect_FlameStrike takes nothing returns boolean
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Flame Strike has being cast.")
return false
endfunction
//===========================================================================
function InitTrig_Flame_Strike takes nothing returns nothing
local trigger t = CreateTrigger()
call AEM_RegisterTrigger2(udg_AEM_Event_Unit_Spell_Effect, 'AHfs', t, udg_AEM_EXECUTION_TYPE_EVALUATE, 0, true, true)
call TriggerAddCondition(t, Filter(function Ability_Effect_FlameStrike))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Ability_Effect_HolyLight takes nothing returns boolean
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Holy Bolt has being cast.")
return false
endfunction
//===========================================================================
function InitTrig_Holy_Light takes nothing returns nothing
local trigger t = CreateTrigger()
call AEM_RegisterTrigger2(udg_AEM_Event_Unit_Spell_Effect, 'AHhb', t, udg_AEM_EXECUTION_TYPE_EVALUATE, 0, true, true)
call TriggerAddCondition(t, Filter(function Ability_Effect_HolyLight))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Ability_Effect_MassTeleport takes nothing returns boolean
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Mass Teleport has being cast.")
return false
endfunction
//===========================================================================
function InitTrig_Mass_Teleport takes nothing returns nothing
local trigger t = CreateTrigger()
call AEM_RegisterTrigger2(udg_AEM_Event_Unit_Spell_Effect, 'AHmt', t, udg_AEM_EXECUTION_TYPE_EVALUATE, 0, true, true)
call TriggerAddCondition(t, Filter(function Ability_Effect_MassTeleport))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Ability_Effect_Phoenix takes nothing returns boolean
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Phoenix has being cast.")
return false
endfunction
//===========================================================================
function InitTrig_Phoenix takes nothing returns nothing
local trigger t = CreateTrigger()
call AEM_RegisterTrigger2(udg_AEM_Event_Unit_Spell_Effect, 'AHpx', t, udg_AEM_EXECUTION_TYPE_EVALUATE, 0, true, true)
call TriggerAddCondition(t, Filter(function Ability_Effect_Phoenix))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Ability_Effect_Resurrection takes nothing returns boolean
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Resurrection has being cast.")
return false
endfunction
//===========================================================================
function InitTrig_Resurrection takes nothing returns nothing
local trigger t = CreateTrigger()
call AEM_RegisterTrigger2(udg_AEM_Event_Unit_Spell_Effect, 'AHre', t, udg_AEM_EXECUTION_TYPE_EVALUATE, 0, true, true)
call TriggerAddCondition(t, Filter(function Ability_Effect_Resurrection))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Ability_Effect_SiphonMana takes nothing returns boolean
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Siphon Mana has being cast.")
return false
endfunction
//===========================================================================
function InitTrig_Siphon_Mana takes nothing returns nothing
local trigger t = CreateTrigger()
call AEM_RegisterTrigger2(udg_AEM_Event_Unit_Spell_Effect, 'AHdr', t, udg_AEM_EXECUTION_TYPE_EVALUATE, 0, true, true)
call TriggerAddCondition(t, Filter(function Ability_Effect_SiphonMana))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Ability_Effect_StormBolt takes nothing returns boolean
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Storm Bolt has being cast.")
return false
endfunction
//===========================================================================
function InitTrig_Storm_Bolt takes nothing returns nothing
local trigger t = CreateTrigger()
call AEM_RegisterTrigger2(udg_AEM_Event_Unit_Spell_Effect, 'AHtb', t, udg_AEM_EXECUTION_TYPE_EVALUATE, 0, true, true)
call TriggerAddCondition(t, Filter(function Ability_Effect_StormBolt))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Ability_Effect_SummonWaterElemental takes nothing returns boolean
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Summon Water Elemental has being cast.")
return false
endfunction
//===========================================================================
function InitTrig_Summon_Water_Elemental takes nothing returns nothing
local trigger t = CreateTrigger()
call AEM_RegisterTrigger2(udg_AEM_Event_Unit_Spell_Effect, 'AHwe', t, udg_AEM_EXECUTION_TYPE_EVALUATE, 0, true, true)
call TriggerAddCondition(t, Filter(function Ability_Effect_SummonWaterElemental))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Ability_Effect_ThunderClap takes nothing returns boolean
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Thunder Clap has being cast.")
return false
endfunction
//===========================================================================
function InitTrig_Thunder_Clap takes nothing returns nothing
local trigger t = CreateTrigger()
call AEM_RegisterTrigger2(udg_AEM_Event_Unit_Spell_Effect, 'AHtc', t, udg_AEM_EXECUTION_TYPE_EVALUATE, 0, true, true)
call TriggerAddCondition(t, Filter(function Ability_Effect_ThunderClap))
endfunction