Illusion Editor [vJass + GUI Support] v1.4

User avatar
Enalias
Site Admin
Site Admin
Posts: 200
Joined: Sat Sep 15, 2018 1:57 pm
Reputation: 9
Location: Florida, U.S.A.
Website: http://chaosrealm.co/memberlist.php?mod ... rofile&u=2
Discord: https://discord.gg/BUEZkef
Twitch: https://www.twitch.tv/enalias
Contact:
United States of America

Illusion Editor [vJass + GUI Support] v1.4

#1

Post by Enalias » Fri Nov 02, 2018 9:16 am

Illusion Editor v1.4

This system provides users with helpful utilities with regards to creation of illusions as well as the manipulation of many of their aspects.
With this system, you can now create illusions of any type as easily as creating units. This even allows you to create permanent illusions.
Read the script header for more details.

Please give credits to the following people if you use this resource in your map!

Credits:
- Written by AGD
- Looking_For_Help (PDDS)
- TriggerHappy (UnitDex)
- Bribe (Table)
- Magtheridon96 (RegisterPlayerUnitEvent)
- Vexorian (TimerUtils)
- Rising_Dusk (GroupUtils)
- Alain.Mark (PlayerUtils)
Spoiler
Show
[jass]
library IllusionEditor /*


*/requires /*

*/UnitDex /*
http://www.hiveworkshop.com/threads/sys ... er.248209/

*/DamageEvent /*
https://www.hiveworkshop.com/threads/sy ... on.228456/

*/optional Table /*
https://www.hiveworkshop.com/threads/sn ... le.188084/

*/optional RegisterPlayerUnitEvent /*
https://www.hiveworkshop.com/threads/sn ... nt.203338/

*/optional TimerUtils /*
http://www.wc3c.net/showthread.php?p=1020244

*/optional GroupUtils /*
http://www.wc3c.net/showthread.php?t=104464

*/optional PlayerUtils /*
https://www.hiveworkshop.com/threads/sn ... ls.213620/


*///! novjass

_______________________
| |
| Illusion Editor v1.4 |
| Written by AGD |
|_______________________|

/* This system gives you freedom and ease in creating illusions. With this, you
can now create illusions of any type as easily as creating units or make an
illusion copy from an already existing unit, with the ability to change many
of their aspects (such as duration, damage dealt, damage recieved, deathSFX,
and hero level) dynamically.


Hint:
- Use zero or any negative value for duration to make a permanent illusion
- Setting a hero illusion's level might cause a change to its proper name

To Import:
- Copy all the neccessary Object Editor data or alternatively use the object merger
- Copy this trigger/trigger category together with the requirements
- Configure the configurable object rawcodes
*/
|=======|
| API |
|=======|

function CreateIllusion takes player whichPlayer, integer ID, real dur, real damageDealt, real damageReceived, real x, real y, real angle returns unit/*
- Creates an illusion of type <ID>

*/function CreateIllusionCopy takes player whichPlayer, unit u, real dur, real damageDealt, real damageReceived, real x, real y, real angle returns unit/*
- Creates an illusion copy of a unit which possesses the same abilities and items as the original unit

*/function SetIllusionLevel takes unit u, integer level, boolean showEyeCandy returns boolean/*
- Sets the level of the illusion to a desired value and returns boolean value depending on the success of the operation
(Only works if the illusion is a hero and if it was created using this system)

*/function SetIllusionDuration takes unit u, real time returns boolean/*
- Sets the duration of the illusion and returns a boolean value depending on the success of the operation
(This only works for illusions created by this system)

*/function AddIllusionDuration takes unit u, real extraTime returns boolean/*
- Adds an extra duration to an illusion's timed life and returns a boolean value depending on the success of the operation
(This only works for illusions created by this system)

*/function SetIllusionDamageFactor takes unit u, real factor returns boolean/*
- Sets the damagedealt factor of the illusion and returns a boolean value depending on the success of the operation
(This only works for illusions created by this system)

*/function SetIllusionReceiveFactor takes unit u, real factor returns boolean/*
- Sets the damagereceivefactor of the illusion and returns a boolean value depending on the success of the operation
(This only works for illusions created by this system)

*/function ShowIllusionDeathEffect takes unit u, boolean flag returns boolean/*
- Sets the illusion's death animation ON/OFF and returns a boolean value depending on the success of the operation
(This only works for illusions created by this system)

*/function SetIllusionDeathEffect takes unit u, string model returns boolean/*
- Sets the death animation of the illusion and returns a boolean value depending on the success of the operation
(This only works for illusions created by this system)

*/function GetIllusionElapsedTime takes unit u returns real/*
- Returns the elapsed time of the illusion
(This will return 0 for illusions not created by this system)

*/function GetIllusionRemainingDuration takes unit u returns real/*
- Returns the remaining duration of the illusion
(This will return 0 for illusions not created by this system)

*/function GetIllusionTotalDuration takes unit u returns real/*
- Returns the duration of the illusion
(This will return 0 for illusions not created by this system)

*/function GetIllusionDamageFactor takes unit u returns real/*
- Returns the damagedealt factor of the illusion
(This will return 0 for illusions not created by this system)

*/function GetIllusionReceiveFactor takes unit u returns real/*
- Returns the damagereceive factor of the illusion
(This will return 0 for illusions not created by this system)

*/function GetIllusionBaseUnit takes unit u returns unit/*
- Returns the unit that the illusion is copied from
(Only works for illusion products of CopyUnit())

*/function GetLastIllusion takes nothing returns unit/*
- Returns the last illusion created using this system

*/function GetIllusionFlag takes unit u returns boolean/*
- Checks if the illusion is created by this system or not

*/function IllusionDeathEvent takes code c returns nothing/*
- Adds a code to run when an illusion created from this system dies


*///! endnovjass


globals

///////////////////////////
// Configuration Section //
///////////////////////////

/////////////////////////////////////////////////////
// Rawcode of the item used for creating illusions //
/////////////////////////////////////////////////////
private constant integer ABIL_ID = 'I002'
/////////////////////////////////////////////////////
// Rawcode of the dummy caster //
/////////////////////////////////////////////////////
private constant integer DUMMY_ID = 'i001'
/////////////////////////////////////////////////////
// Illusion timed life check interval //
/////////////////////////////////////////////////////
private constant real LOOP_INTERVAL = 0.03125
/////////////////////////////////////////////////////
// Synchronize this value with the duration of //
// illusions produced by the item in the object //
// editor so that this system will be able to make //
// the neccessary adjustments. //
// It would be better to set this value to 3600 //
// which is the maximum duration you can put in //
// the object editor. But always be reminded that //
// everytime you change this value, change also //
// that of the object editor's! //
/////////////////////////////////////////////////////
private constant real ITEM_DUR_LIMIT = 5.00
/////////////////////////////////////////////////////
// The remaining time of the illusion before it //
// would be replaced with another one in case the //
// desired duration of the illusion is greater //
// than what the item could provide //
/////////////////////////////////////////////////////
private constant real REPLACE_TIME_ALLOWANCE = 0.10
/////////////////////////////////////////////////////
// The default death animation of the illusions //
/////////////////////////////////////////////////////
private constant string DEFAULT_DEATH_SFX = "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl"
/////////////////////////////////////////////////////
// The owning player of the dummy unit //
/////////////////////////////////////////////////////
private constant player DUMMY_OWNER = Player(15)
/////////////////////////////////////////////////////
// The prefix of the operation error message when //
// debug mode is enabled //
/////////////////////////////////////////////////////
private constant string ERROR_PREFIX = "Operation Failed: "

//////////////////////////
// End of Configuration //
//////////////////////////

endglobals


//===== Do not change anything below this line if you're not so sure on what you're doing =====//
native UnitAlive takes unit u returns boolean

private keyword S

globals

private trigger deathEvent = CreateTrigger()
private trigger illuDeathTrig = null
private integer index = 0
private integer tempInt = 0
private integer usedDeathEvent = 0
private real illusionDeathEvent = 0.00
private unit illusion
private unit U
private unit dummyCaster
private player localPlayer
private filterfunc deathHandler
private code durationUpdater

// These variables are used to store unit specific data for each illusion created using this system
private integer array maxTargeterCount
private integer array order
private integer array orderType
private boolean array flag
private boolean array check
private boolean array showDeath
private boolean array dontCatchDeath
private real array targPointX
private real array targPointY
private unit array orderTarget
private unit array baseUnit
private real array totalElapsed
private real array elapsed
private real array totalDuration
private real array duration
private real array damageFactor
private real array receiveFactor
private real array X
private real array Y
private real array facing
private player array owner
private string array deathSFX

endglobals

static if DEBUG_MODE then
private function Debug takes string msg returns nothing
call DisplayTimedTextToPlayer( localPlayer, 0, 0, 30, "|CFFFFCC00[Illusion Editor]|R " + msg )
endfunction
endif


///////////////////////////////////////////////////
// These three functions caches the order of the //
// expiring illusion units to be passed to their //
// replacements. Similarly when the expiring //
// illusion is targeted with an order, the order //
// will be redirected to its replacement as well.//
///////////////////////////////////////////////////
private function CacheTargetOrder takes nothing returns nothing
local unit u = GetOrderedUnit()
local unit t = GetOrderTargetUnit()
local integer i = GetUnitId( u )
local integer tDex = GetUnitId( t )
if check then
set orderType = 1
set orderTarget = t
endif
if check[tDex] then
set order = GetUnitCurrentOrder( u )
if not flag and u != dummyCaster then
loop
set maxTargeterCount[tDex] = maxTargeterCount[tDex] + 1
static if LIBRARY_Table then
if S.hash[tDex].unit[maxTargeterCount[tDex]] == null then
set S.hash[tDex].unit[maxTargeterCount[tDex]] = u
set flag = true
exitwhen true
endif
else
if LoadUnitHandle( S.hash, tDex, maxTargeterCount[tDex] ) == null then
call SaveUnitHandle( S.hash, tDex, maxTargeterCount[tDex], u )
set flag = true
exitwhen true
endif
endif
endloop
endif
endif
set u = null
set t = null
endfunction

private function CachePointOrder takes nothing returns nothing
local integer i = GetUnitId( GetOrderedUnit() )
set flag = false
if check then
set orderType = 2
set targPointX = GetOrderPointX()
set targPointY = GetOrderPointY()
endif
endfunction

private function CacheOrder takes nothing returns nothing
local integer i = GetUnitId( GetOrderedUnit() )
set flag = false
if check then
set orderType = 3
endif
endfunction


///////////////
// On Summon //
///////////////
private function OnSummon takes nothing returns nothing
local timer t
local integer i
local integer uDex
if GetSummoningUnit() == dummyCaster then
set i = GetUnitId( dummyCaster )
set U = GetTriggerUnit()
set uDex = GetUnitId( U )
set check[uDex] = true
set showDeath[uDex] = true
set totalDuration[uDex] = duration
set duration[uDex] = duration
set damageFactor[uDex] = damageFactor
set receiveFactor[uDex] = receiveFactor
set baseUnit[uDex] = baseUnit
set owner[uDex] = owner[i]
set deathSFX[uDex] = DEFAULT_DEATH_SFX
set elapsed[uDex] = 0
set maxTargeterCount[uDex] = 0
static if LIBRARY_TimerUtils then
set t = NewTimer()
else
set t = CreateTimer()
endif
static if LIBRARY_Table then
set S.hash[GetHandleId( t )].unit[0] = U
else
call SaveUnitHandle( S.hash, GetHandleId( t ), 0, U )
endif
call TimerStart( t, LOOP_INTERVAL, true, durationUpdater )
call SetUnitOwner( U, owner[i], true )
call SetUnitFacingTimed( U, facing[i], 0 )
if IsUnitType( U, UNIT_TYPE_STRUCTURE ) then
call SetUnitPosition( U, X[i], Y[i] )
else
call SetUnitX( U, X[i] )
call SetUnitY( U, Y[i] )
endif
call TriggerRegisterUnitStateEvent( deathEvent, U, UNIT_STATE_LIFE, LESS_THAN, UNIT_MIN_LIFE )
set t = null
endif
endfunction


//! textmacro CREATOR takes FUNC, TAKE, X, TARGET, BASEUNIT
private function $FUNC$ takes player whichPlayer, $TAKE$, real dur, real damageDealt, real damageReceived, real x, real y, real angle returns unit
local integer i = GetUnitId( dummyCaster )
$X$local unit tempUnit = CreateUnit( DUMMY_OWNER, ID, x, y, angle )
if dur < 0 then
set dur = 0
endif
if damageDealt < 0 then
set damageDealt = 0
endif
if damageReceived < 0 then
set damageReceived = 0
endif
set X[i] = x
set Y[i] = y
set duration[i] = dur
set damageFactor[i] = damageDealt
set receiveFactor[i] = damageReceived
set facing[i] = angle
set owner[i] = whichPlayer
set baseUnit[i] = $BASEUNIT$
call IssueTargetOrderById( dummyCaster, 852274, $TARGET$ )
$X$call RemoveUnit( tempUnit )
$X$set tempUnit = null
return U
endfunction
//! endtextmacro
//! runtextmacro CREATOR( "Create", "integer ID", "", "tempUnit", "null" )
//! runtextmacro CREATOR( "Copy", "unit u", "//", "u", "u" )


/////////////////////////////////////////////////
// This function controls the duration of the //
// illusions as well as replacing them in case //
// their hardcoded lifetime expires before //
// meeting the duration desired for them //
/////////////////////////////////////////////////
private function AdjustTimedLife takes nothing returns nothing
static if LIBRARY_Table then
local unit u = S.hash[GetHandleId( GetExpiredTimer() )].unit[0]
else
local unit u = LoadUnitHandle( S.hash, GetHandleId( GetExpiredTimer() ), 0 )
endif
local integer i = GetUnitId( u )
local integer lastOrder
local unit new
local real toAdd
if UnitAlive( u ) then
set elapsed[i] = elapsed[i] + LOOP_INTERVAL
set totalElapsed[i] = totalElapsed[i] + LOOP_INTERVAL
if duration[i] < ITEM_DUR_LIMIT and ( ( duration[i] > 0 and elapsed[i] >= duration[i] ) or duration[i] < 0.00 ) then
static if LIBRARY_Table then
call S.hash.remove( GetHandleId( GetExpiredTimer() ) )
else
call FlushChildHashtable( S.hash, GetHandleId( GetExpiredTimer() ) )
endif
call RemoveUnit( u )
static if LIBRARY_TimerUtils then
call ReleaseTimer( GetExpiredTimer() )
else
call DestroyTimer( GetExpiredTimer() )
endif
elseif elapsed[i] >= ITEM_DUR_LIMIT - REPLACE_TIME_ALLOWANCE then
set toAdd = duration[i] - ( ITEM_DUR_LIMIT - REPLACE_TIME_ALLOWANCE )
if toAdd < 0 then
set toAdd = 0
endif
set lastOrder = GetUnitCurrentOrder( u )
set new = Copy( owner[i], u, toAdd, damageFactor[i], receiveFactor[i], GetUnitX( u ), GetUnitY( u ), GetUnitFacing( u ) )
//! textmacro REDIRECTDATA takes KEY, NEWLIFE, NEWMANA
call ShowUnit( u, false )
call SetWidgetLife( new, $NEWLIFE$ )
call SetUnitState( new, UNIT_STATE_MANA, $NEWMANA$ )
set index = 0
loop
set index = index + 1
static if LIBRARY_Table then
set U = S.hash[$KEY$].unit[index]
else
set U = LoadUnitHandle( S.hash, $KEY$, index )
endif
set tempInt = GetUnitId( U )
if flag[tempInt] then
set flag[tempInt] = false
call IssueTargetOrderById( U, order[tempInt], new )
endif
exitwhen index > maxTargeterCount[i]
endloop
if orderType[i] == 1 then
call IssueTargetOrderById( new, lastOrder, orderTarget[i] )
elseif orderType[i] == 2 then
call IssuePointOrderById( new, lastOrder, targPointX[i], targPointY[i] )
elseif orderType[i] == 3 then
call IssueImmediateOrderById( new, lastOrder )
endif
if IsUnitSelected( u, localPlayer ) then
call SelectUnit( new, true )
endif
call RemoveUnit( u )
set maxTargeterCount[i] = 0
set index = GetUnitId( new )
set baseUnit[index] = baseUnit[i]
set totalElapsed[index] = totalElapsed[i]
set totalDuration[index] = totalDuration[i]
set deathSFX[index] = deathSFX[i]
set showDeath[index] = showDeath[i]
set dontCatchDeath[i] = true
set dontCatchDeath[index] = false
set showDeath[i] = false
//! endtextmacro
//! runtextmacro REDIRECTDATA( "i", "GetWidgetLife( u )", "GetUnitState( u, UNIT_STATE_MANA )" )
static if LIBRARY_Table then
call S.hash.remove( GetHandleId( GetExpiredTimer() ) )
else
call FlushChildHashtable( S.hash, GetHandleId( GetExpiredTimer() ) )
endif
static if LIBRARY_TimerUtils then
call ReleaseTimer( GetExpiredTimer() )
else
call DestroyTimer( GetExpiredTimer() )
endif
if u == illusion then
set illusion = new
endif
set new = null
endif
endif
set u = null
endfunction


/////////////////////////////////
// Public APIs //
/////////////////////////////////

function CreateIllusion takes player whichPlayer, integer ID, real dur, real damageDealt, real damageReceived, real x, real y, real angle returns unit
set illusion = Create( whichPlayer, ID, dur, damageDealt, damageReceived, x, y, angle )
return illusion
endfunction

function CreateIllusionCopy takes player whichPlayer, unit u, real dur, real damageDealt, real damageReceived, real x, real y, real angle returns unit
set illusion = Copy( whichPlayer, u, dur, damageDealt, damageReceived, x, y, angle )
return illusion
endfunction

function SetIllusionLevel takes unit u, integer level, boolean showEyeCandy returns boolean
local integer i = GetUnitId( u )
local unit tempUnit
local integer lastOrder
local unit new
local real x
local real y
local boolean success = false
if check[i] then
set x = GetUnitX( u )
set y = GetUnitY( u )
set tempUnit = CreateUnit( DUMMY_OWNER, GetUnitTypeId( u ), x, y, GetUnitFacing( u ) )
if IsUnitType( tempUnit, UNIT_TYPE_HERO ) then
set lastOrder = GetUnitCurrentOrder( u )
call SetHeroLevel( tempUnit, level, false )
set new = Copy( owner[i], tempUnit, duration[i], damageFactor[i], receiveFactor[i], x, y, GetUnitFacing( u ) )
set index = 7
loop
set index = index - 1
call UnitAddItemToSlotById( new, GetItemTypeId( UnitItemInSlot( u, index ) ), index )
exitwhen index == 1
endloop
//! runtextmacro REDIRECTDATA( "GetUnitId( u )", "GetWidgetLife( u )*GetWidgetLife( new )/GetUnitState( u, UNIT_STATE_MAX_LIFE )", "GetUnitState( u, UNIT_STATE_MANA )*GetUnitState( new, UNIT_STATE_MANA )/GetUnitState( u, UNIT_STATE_MAX_MANA )" )
if showEyeCandy then
call DestroyEffect( AddSpecialEffectTarget( "Abilities\\Spells\\Other\\Levelup\\LevelupCaster.mdl", new, "origin" ) )
endif
set success = true
set new = null
debug else
debug call Debug( ERROR_PREFIX + "Specified illusion is not a hero" )
endif
call RemoveUnit( tempUnit )
set tempUnit = null
debug else
debug call Debug( ERROR_PREFIX + "Specified unit is not an illusion created by the system" )
endif
return success
endfunction

//! textmacro DEBUG takes RETURN
if not check[i] then
debug call Debug( ERROR_PREFIX + "Specified unit is not an illusion created by the system" )
$RETURN$
endif
//! endtextmacro

function SetIllusionDuration takes unit u, real time returns boolean
local integer i = GetUnitId( u )
//! runtextmacro DEBUG( "return false" )
set duration[i] = time
set totalDuration[i] = time
return true
endfunction

function AddIllusionDuration takes unit u, real extraTime returns boolean
local integer i = GetUnitId( u )
//! runtextmacro DEBUG( "return false" )
set duration[i] = duration[i] + extraTime
set totalDuration[i] = totalDuration[i] + extraTime
return true
endfunction

function SetIllusionDamageFactor takes unit u, real factor returns boolean
local integer i = GetUnitId( u )
//! runtextmacro DEBUG( "return false" )
set damageFactor[i] = factor
return true
endfunction

function SetIllusionReceiveFactor takes unit u, real factor returns boolean
local integer i = GetUnitId( u )
//! runtextmacro DEBUG( "return false" )
set receiveFactor[i] = factor
return true
endfunction

function ShowIllusionDeathEffect takes unit u, boolean flag returns boolean
local integer i = GetUnitId( u )
//! runtextmacro DEBUG( "return false" )
set showDeath[i] = flag
return true
endfunction

function SetIllusionDeathEffect takes unit u, string model returns boolean
local integer i = GetUnitId( u )
//! runtextmacro DEBUG( "return false" )
set deathSFX[i] = model
return true
endfunction

function GetIllusionElapsedTime takes unit u returns real
local integer i = GetUnitId( u )
//! runtextmacro DEBUG( "" )
return totalElapsed[i]
endfunction

function GetIllusionRemainingDuration takes unit u returns real
local integer i = GetUnitId( u )
local real remaining = totalDuration[i] - totalElapsed[i]
//! runtextmacro DEBUG( "" )
if remaining < 0 then
return 0.00
endif
return remaining
endfunction

function GetIllusionTotalDuration takes unit u returns real
local integer i = GetUnitId( u )
//! runtextmacro DEBUG( "" )
return totalDuration[i]
endfunction

function GetIllusionDamageFactor takes unit u returns real
local integer i = GetUnitId( u )
//! runtextmacro DEBUG( "" )
return damageFactor[i]
endfunction

function GetIllusionReceiveFactor takes unit u returns real
local integer i = GetUnitId( u )
//! runtextmacro DEBUG( "" )
return receiveFactor[i]
endfunction

function GetIllusionBaseUnit takes unit u returns unit
local integer i = GetUnitId( u )
//! runtextmacro DEBUG( "" )
return baseUnit[i]
endfunction

function GetLastIllusion takes nothing returns unit
return illusion
endfunction

function GetIllusionFlag takes unit u returns boolean
return check[GetUnitId( u )]
endfunction

function IllusionDeathEvent takes code c returns nothing
if illuDeathTrig == null then
set illuDeathTrig = CreateTrigger()
call TriggerRegisterVariableEvent( illuDeathTrig, SCOPE_PRIVATE + "illusionDeathEvent", EQUAL, 1 )
endif
call TriggerAddCondition( illuDeathTrig, Filter( c ) )
endfunction


////////////////////////////////////////////////
// This function adjusts the damage dealt and //
// taken by the illusions //
////////////////////////////////////////////////
private function DamageAdjustment takes nothing returns nothing
local integer uDex = GetUnitId( PDDS.source )
local integer tDex = GetUnitId( PDDS.target )
if check[uDex] and check[tDex] then
set PDDS.amount = PDDS.amount*damageFactor[uDex]*receiveFactor[tDex]
elseif check[uDex] then
set PDDS.amount = PDDS.amount*damageFactor[uDex]
elseif check[tDex] then
set PDDS.amount = PDDS.amount*receiveFactor[tDex]
endif
endfunction


////////////////////////////////////////////////
// Registers an illusion death event //
////////////////////////////////////////////////
private function RefreshDeathTrigger takes nothing returns nothing
local unit u
static if LIBRARY_GroupUtils then
call GroupEnumUnitsInRect( ENUM_GROUP, bj_mapInitialPlayableArea, null )
loop
set u = FirstOfGroup( ENUM_GROUP )
exitwhen u == null
call GroupRemoveUnit( ENUM_GROUP, u )
if check[GetUnitId( u )] then
call TriggerRegisterUnitStateEvent( deathEvent, u, UNIT_STATE_LIFE, LESS_THAN, UNIT_MIN_LIFE )
endif
endloop
else
call GroupEnumUnitsInRect( S.tempGroup, bj_mapInitialPlayableArea, null )
loop
set u = FirstOfGroup( S.tempGroup )
exitwhen u == null
call GroupRemoveUnit( S.tempGroup, u )
if check[GetUnitId( u )] then
call TriggerRegisterUnitStateEvent( deathEvent, u, UNIT_STATE_LIFE, LESS_THAN, UNIT_MIN_LIFE )
endif
endloop
endif
endfunction


////////////////////////////////////////////////
// This function is responsible for hiding or //
// showing the illusion's death SFX //
////////////////////////////////////////////////
private function OnDeath takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer i = GetUnitId( u )
call ShowUnit( u, false )
static if LIBRARY_Table then
call S.hash.remove( i )
else
call FlushChildHashtable( S.hash, i )
endif
if not dontCatchDeath[i] then
set illusionDeathEvent = 0
set illusionDeathEvent = 1
set illusionDeathEvent = 0
endif
if showDeath[i] then
call DestroyEffect( AddSpecialEffect( deathSFX[i], GetUnitX( u ), GetUnitY( u ) ) )
endif
set usedDeathEvent = usedDeathEvent + 1
if usedDeathEvent == 30 then
set usedDeathEvent = 0
call DestroyTrigger( deathEvent )
set deathEvent = CreateTrigger()
call TriggerAddCondition( deathEvent, deathHandler )
call RefreshDeathTrigger()
endif
set u = null
endfunction


///////////////////////////////////////////////
// Initialization //
///////////////////////////////////////////////
private module Init
static method onInit takes nothing returns nothing
local code c = function OnDeath
static if LIBRARY_RegisterPlayerUnitEvent then
call RegisterPlayerUnitEventForPlayer( EVENT_PLAYER_UNIT_SUMMON, function OnSummon, DUMMY_OWNER )
call RegisterPlayerUnitEvent( EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, function CacheTargetOrder )
call RegisterPlayerUnitEvent( EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, function CachePointOrder )
call RegisterPlayerUnitEvent( EVENT_PLAYER_UNIT_ISSUED_ORDER, function CacheOrder )
else
local code c1 = function OnSummon
local code c2 = function CacheTargetOrder
local code c3 = function CachePointOrder
local code c4 = function CacheOrder
local trigger t1 = CreateTrigger()
local trigger t2 = CreateTrigger()
local trigger t3 = CreateTrigger()
local trigger t4 = CreateTrigger()
set index = 16
loop
set index = index - 1
static if LIBRARY_PlayerUtils then
call TriggerRegisterPlayerUnitEvent( t2, GetPlayerById(index), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null )
call TriggerRegisterPlayerUnitEvent( t3, GetPlayerById(index), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null )
call TriggerRegisterPlayerUnitEvent( t4, GetPlayerById(index), EVENT_PLAYER_UNIT_ISSUED_ORDER, null )
else
call TriggerRegisterPlayerUnitEvent( t2, Player(index), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null )
call TriggerRegisterPlayerUnitEvent( t3, Player(index), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null )
call TriggerRegisterPlayerUnitEvent( t4, Player(index), EVENT_PLAYER_UNIT_ISSUED_ORDER, null )
endif
exitwhen index == 0
endloop
call TriggerRegisterPlayerUnitEvent( t1, DUMMY_OWNER, EVENT_PLAYER_UNIT_SUMMON, null )
call TriggerAddCondition( t1, Filter( c1 ) )
call TriggerAddCondition( t2, Filter( c2 ) )
call TriggerAddCondition( t3, Filter( c3 ) )
call TriggerAddCondition( t4, Filter( c4 ) )
endif
set deathHandler = Filter( c )
call TriggerAddCondition( deathEvent, deathHandler )
call AddDamageHandler( function DamageAdjustment )
set durationUpdater = function AdjustTimedLife
set localPlayer = GetLocalPlayer()
set dummyCaster = CreateUnit( DUMMY_OWNER, DUMMY_ID, 0, 0, 0 )
call UnitAddAbility( dummyCaster, ABIL_ID )
static if LIBRARY_Table then
set hash = HashTable.create()
endif
endmethod
endmodule

private struct S extends array
static if LIBRARY_Table then
static HashTable hash
else
static hashtable hash = InitHashtable()
endif
static if not LIBRARY_GroupUtils then
static group tempGroup = CreateGroup()
endif
implement Init
endstruct


endlibrary
[/jass]
You do not have the required permissions to view the files attached to this post.

Return to “Systems”

×