- Joined
- May 12, 2018
- Messages
- 145
I recently learned that if there are many events, even if they have strict conditions, it can burden to the computation. ( [Mapping] - A comprehensive guide to code and trigger optimization #post-361596 )
But I didn't prioritize computational speed and optimization in-game to improve my work speed and map development progress.
My campaign project could easily experience frame-drop during combats due to the presence of many players in a map, their food max are large(200), and also a lot of custom JASS Spell and effects.
I commonly wrote a script like this. (case; work speed first)
The problem with this trigger I guess:
1. Because the trigger for this spell is loaded at the map initialization stage, the computation is overloaded and there is a risk of missing other triggers. Essential variables like global integers and strings must be brought first, and these spell triggers for combat must be loaded later.
2. Therefore, units existing in the map with this type event, the more computation is needed
Is my guess correct?
Here are the another spell made using SpellEffectEvent and RegisterPlayerUnitEvent that written by Bribe and Magtheridon96.
( [Snippet] SpellEffectEvent ) ( [Snippet] RegisterPlayerUnitEvent )
I presume that this is the following.
call RegisterSpellEffectEvent(AID, function thistype.onCast)
generated event like this accurately identifies the AbilityId, so there is a few risk of computational overload than Generic Unit Event.
However, the method's name, "onInit" , is bothering me. Which seems to be that name makes this library is loaded when the map initializes at once. Can I postpone this to a subordinated process?
I'm looking for a way to work with both optimization and speed of work. Maybe the second method approach is closest to this, but I don't know the exact way, so I need help.
But I didn't prioritize computational speed and optimization in-game to improve my work speed and map development progress.
My campaign project could easily experience frame-drop during combats due to the presence of many players in a map, their food max are large(200), and also a lot of custom JASS Spell and effects.
I commonly wrote a script like this. (case; work speed first)
JASS:
scope TransferVitality initializer init
globals
private constant integer SpellId = 'A02A'
private constant real Amount = 10
endglobals
private constant function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SpellId
endfunction
private function Actions takes nothing returns nothing
local unit u = GetSpellAbilityUnit()
call SetWidgetLife(u, GetWidgetLife(u) - Amount )
set u = null
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition( function Conditions ) )
call TriggerAddAction( t, function Actions)
set t = null
endfunction
endscope
The problem with this trigger I guess:
1. Because the trigger for this spell is loaded at the map initialization stage, the computation is overloaded and there is a risk of missing other triggers. Essential variables like global integers and strings must be brought first, and these spell triggers for combat must be loaded later.
2. Therefore, units existing in the map with this type event, the more computation is needed
Is my guess correct?
Here are the another spell made using SpellEffectEvent and RegisterPlayerUnitEvent that written by Bribe and Magtheridon96.
( [Snippet] SpellEffectEvent ) ( [Snippet] RegisterPlayerUnitEvent )
JASS:
library DestLockShadowfury requires RegisterPlayerUnitEvent, SpellEffectEvent, PluginSpellEffect, Utilities, TimerUtils
globals
private constant integer AID = 'A07J'
private constant integer AID_DUMMY = 'A608'
private constant real AOE = 353
private constant string model = "Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl"
private constant string model2 = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl"
private constant real EFFECTHEIGHT = 20
endglobals
private struct Shadowfury
private unit source
private player player
private integer level
static method onCast takes nothing returns nothing
local real x
local real y
local unit locust
local integer i = 0
local integer size = 0
local thistype this = thistype.allocate()
set source = Spell.source.unit
set player = Spell.source.player
set x = Spell.x
set y = Spell.y
set level = Spell.level
set locust = CreateUnit(player, 'u003', x, y, dummylife1)
call UnitApplyTimedLife(locust, 'BTLF', 2)
call UnitAddAbility( locust, AID_DUMMY)
call SetUnitAbilityLevel(locust, AID_DUMMY, level)
call IssuePointOrderById( locust, OrderId_clusterrockets, x, y )
call DestroyEffect(AddSpecialEffectEx(model, x, y, EFFECTHEIGHT, 1 ) )
call DestroyEffect(AddSpecialEffectEx(model2, x, y, EFFECTHEIGHT, 1 ) )
set source = null
set player = null
set locust = null
call this.destroy()
endmethod
private static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(AID, function thistype.onCast)
endmethod
endstruct
endlibrary
call RegisterSpellEffectEvent(AID, function thistype.onCast)
generated event like this accurately identifies the AbilityId, so there is a few risk of computational overload than Generic Unit Event.
However, the method's name, "onInit" , is bothering me. Which seems to be that name makes this library is loaded when the map initializes at once. Can I postpone this to a subordinated process?
I'm looking for a way to work with both optimization and speed of work. Maybe the second method approach is closest to this, but I don't know the exact way, so I need help.
Last edited: