- Joined
- May 16, 2012
- Messages
- 652
Hello Hive,
i've been wondering if there is an optimal way to create/handle events that have potencial to fire thousands of times in a game, like EVENT_PLAYER_UNIT_DAMAGED or EVENT_PLAYER_UNIT_DEATH. Right now i'm using RegisterPlayerUnitEvent library to avoid creating one trigger for every spell/effect that i want to code. Is it the best way possible? I have about 80 triggers like the one below in my map at the moment, and the game is performing just fine, but i'm afraid that as my development continue and that number goes up, the performance impact will degrade the player experience.
Thanks.
i've been wondering if there is an optimal way to create/handle events that have potencial to fire thousands of times in a game, like EVENT_PLAYER_UNIT_DAMAGED or EVENT_PLAYER_UNIT_DEATH. Right now i'm using RegisterPlayerUnitEvent library to avoid creating one trigger for every spell/effect that i want to code. Is it the best way possible? I have about 80 triggers like the one below in my map at the moment, and the game is performing just fine, but i'm afraid that as my development continue and that number goes up, the performance impact will degrade the player experience.
JASS:
scope LightningSpear initializer Init
private function Conditions takes nothing returns nothing
local unit source = GetEventDamageSource()
local unit target = BlzGetEventDamageTarget()
if (UnitHasItemOfType(source, 'I03V') > 0 and BlzGetEventDamageType() == DAMAGE_TYPE_NORMAL and GetRandomInt(1,100) <= 25 and IsUnitEnemy(target, GetOwningPlayer(source)) and not IsUnitType(target, UNIT_TYPE_STRUCTURE)) then
call CreateChainLightning(source, target, 250.0, 0, 4, 500.0, 0.2, 0.1, "BLNL", "Shock2HD.mdx", "origin")
endif
set source = null
set target = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_DAMAGED, function Conditions)
endfunction
endscope
Thanks.

