BG :
I have created a spell named "Assasination".
How it works?
Targets a unit, then hero will be invisible and engage target, to be attacked. While engaging, hero receives bonus damage and maximum movespeed for one attack to target. If hero changes target, the buff will lost.
Rawcode Translator :
'e001' = dummy
'A01H' = Invisibility (dummy)
'A01I' = Hero Bonus Damage
'A01G' = Assasination (Hero)
'A01J' = Assasinated Indicator
This spell consists of two triggers. Main Trigger and Target Rechecker.
And the Rechecker :
=====================================
All works properly, no recent bugs. Now, what's the problem? Here, there is...
When I cast this spell, it causes extreme lag (fps drop from 64 to 18-20 or from 45 to 8-12). I have debugged this spell and the problem comes from function Assasination_Act_Ons, but I still not find any "memory" because I did not create units, widgets or massive effects in the function.
Uniquely, the trigger works when target takes damage, but lag happens before it. Even, the lag disappeared when trigger are executed.
Do you have any solution of this?
I have created a spell named "Assasination".
How it works?
Targets a unit, then hero will be invisible and engage target, to be attacked. While engaging, hero receives bonus damage and maximum movespeed for one attack to target. If hero changes target, the buff will lost.
Rawcode Translator :
'e001' = dummy
'A01H' = Invisibility (dummy)
'A01I' = Hero Bonus Damage
'A01G' = Assasination (Hero)
'A01J' = Assasinated Indicator
This spell consists of two triggers. Main Trigger and Target Rechecker.
JASS:
function AssProc takes nothing returns boolean
if (GetEventDamageSource() == udg_AssCaster and GetEventDamage() != 0 and udg_isAttack == true) then
return true
endif
return false
endfunction
function Assasination_Act_Ons takes nothing returns nothing
local unit x = GetEventDamageSource()
local unit y = udg_AssTarget
local integer i = GetRandomInt(1,100)
local location z = GetUnitLoc(y)
//call DisplayTextToForce( GetPlayersAll(), ( "Success damaging target by equal of : " + R2S(GetEventDamage()) ) )
call UnitRemoveAbilityBJ( 'A01I', x )
call SetUnitMoveSpeed( x, GetUnitDefaultMoveSpeed(x) )
if i <= 15 then
call UnitDamageTarget(x,y,1000000000,true,true,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_FIRE,WEAPON_TYPE_WHOKNOWS)
call DestroyEffect(AddSpecialEffectLoc( "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl",z))
endif
call UnitRemoveBuffBJ('B00H',y)
call DisableTrigger(gg_trg_AssasinCheckFX)
set x = null
set y = null
set udg_isAttack = false
call DestroyTrigger ( GetTriggeringTrigger() )
set udg_AssCaster = null
set udg_AssTarget = null
call RemoveLocation(z)
set z = null
endfunction
function Trig_Assasination_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A01G' ) ) then
return false
endif
return true
endfunction
function Trig_Assasination_Func009C takes nothing returns boolean
if ( not ( GetUnitAbilityLevelSwapped('A01G', GetSpellAbilityUnit()) < 3 ) ) then
return false
endif
return true
endfunction
function Trig_Assasination_Actions takes nothing returns nothing
//INIT VARS
local unit LCU
local unit LCU2
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local location casterloc = GetUnitLoc(GetSpellAbilityUnit())
local location targetloc = GetUnitLoc(GetSpellTargetUnit())
local trigger cptrig = CreateTrigger()
//Hashtable Declaration
//call InitHashtableBJ()
//call SaveUnitHandleBJ(caster,StringHash("caster"),StringHash("Assasination"),bj_lastCreatedHashtable)
//call SaveUnitHandleBJ(target,StringHash("target"),StringHash("Assasination"),bj_lastCreatedHashtable)
set udg_AssCaster = caster
set udg_AssTarget = target
//Trigger
call EnableTrigger(gg_trg_AssasinCheckFX)
call CreateNUnitsAtLoc( 1, 'e001', GetOwningPlayer(caster), casterloc, bj_UNIT_FACING )
set LCU = GetLastCreatedUnit()
call UnitAddAbilityBJ( 'A01H', LCU)
call IssueTargetOrderBJ( LCU, "invisibility", caster )
call UnitApplyTimedLifeBJ( 2.00, 'BTLF', LCU )
call SetUnitMoveSpeed( caster, 700.00 )
call UnitAddAbilityBJ( 'A01I', caster )
call SetUnitAbilityLevelSwapped( 'A01I', caster, GetUnitAbilityLevelSwapped('A01G', caster) )
if ( Trig_Assasination_Func009C() ) then
call CreateNUnitsAtLoc( 1, 'e001', GetOwningPlayer(caster), targetloc, bj_UNIT_FACING )
set LCU2 = GetLastCreatedUnit()
call UnitAddAbilityBJ( 'A01J', LCU2 )
call IssueTargetOrderBJ( LCU2, "acidbomb", target)
call UnitApplyTimedLifeBJ( 2.00, 'BTLF', LCU2)
endif
call TriggerRegisterUnitEvent( cptrig, target, EVENT_UNIT_DAMAGED )
call TriggerAddCondition ( cptrig , Condition ( function AssProc ) )
call TriggerAddAction(cptrig, function Assasination_Act_Ons)
call SaveTriggerHandleBJ(cptrig,StringHash("trigger"),StringHash("Assasination"),udg_SkillTable)
call PolledWait(0.43)
call IssueTargetOrderBJ( caster, "attack", target )
set cptrig = null
set caster = null
set target = null
call RemoveLocation(targetloc)
call RemoveLocation(casterloc)
set targetloc = null
set casterloc = null
set LCU = null
set LCU2 = null
endfunction
//===========================================================================
function InitTrig_Assasination takes nothing returns nothing
set gg_trg_Assasination = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Assasination, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Assasination, Condition( function Trig_Assasination_Conditions ) )
call TriggerAddAction( gg_trg_Assasination, function Trig_Assasination_Actions )
endfunction
And the Rechecker :
-
AssasinCheckFX
-
Events
-
Unit - A unit Is attacked
-
-
Conditions
-
(Attacking unit) Equal to AssCaster
-
(AssCaster has buff Assasination ) Equal to False
-
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Attacked unit) Not equal to AssTarget
-
-
Then - Actions
-
Unit - Set AssCaster movement speed to (Default movement speed of AssCaster)
-
Unit - Remove AssasinationDamageBonus from AssCaster
-
Unit - Remove Assasinated buff from AssTarget
-
Custom script: call DestroyTrigger(LoadTriggerHandleBJ(StringHash("trigger"),StringHash("Assasination"),udg_SkillTable))
-
Set AssCaster = No unit
-
Set AssTarget = No unit
-
Set isAttack = False
-
Trigger - Turn off (This trigger)
-
-
Else - Actions
-
Set isAttack = True
-
-
-
-
=====================================
All works properly, no recent bugs. Now, what's the problem? Here, there is...
When I cast this spell, it causes extreme lag (fps drop from 64 to 18-20 or from 45 to 8-12). I have debugged this spell and the problem comes from function Assasination_Act_Ons, but I still not find any "memory" because I did not create units, widgets or massive effects in the function.
Uniquely, the trigger works when target takes damage, but lag happens before it. Even, the lag disappeared when trigger are executed.
Do you have any solution of this?