- Joined
- Oct 9, 2019
- Messages
- 295
This is a follow up on this topic (please read it first): [vJASS] - Solved! Looking for the cause of a freeze with this library
I attempted to re-add the "hero dies bonus" trigger with some code tweaks but it still freezes. See comments in the code for more information.
I attempted to re-add the "hero dies bonus" trigger with some code tweaks but it still freezes. See comments in the code for more information.
JASS:
function CriticalTextForPlayer takes unit whichUnit,string text,real duration,integer red,integer green,integer blue,integer alpha,real text_size,player p returns nothing
local texttag tx= CreateTextTag()
call SetTextTagText(tx, text, text_size)
call SetTextTagPosUnit(tx, whichUnit, 0)
call SetTextTagColor(tx, red, green, blue, alpha)
call SetTextTagLifespan(tx, duration)
call SetTextTagVelocity(tx, 0.0, 0.0355)
call SetTextTagPermanent(tx, false)
if GetLocalPlayer() != p then
call SetTextTagVisibility(tx, false)
endif
set tx=null
endfunction
function Trig_Speedster_Hero_Dies_Bonus_Conditions takes nothing returns boolean
if not UnitAlive(udg_speedster_unit) then
return false
endif
if not IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) then
return false
endif
if ( ( GetKillingUnit() == udg_speedster_unit ) ) then
return true
endif
if DistanceBetweenPointsReal(GetUnitX(udg_speedster_unit) , GetUnitY(udg_speedster_unit) , GetUnitX(GetTriggerUnit()) , GetUnitY(GetTriggerUnit())) <= 2000.0 then
return true
endif
return false
endfunction
function Trig_Speedster_Hero_Dies_Bonus_Timer_Expires takes nothing returns nothing
call CriticalTextForPlayer(udg_speedster_unit , "Death Bonus!" , 1.5 , 0 , 255 , 0 , 255 , 0.019 , GetOwningPlayer(udg_speedster_unit))
call UnitAddCooldownReductionFlat(udg_speedster_unit , udg_lesser_cdr_value)
//call AddUnitBonus(udg_speedster_unit , BONUS_STRENGTH , 5.0)
//call AddUnitBonus(udg_speedster_unit , BONUS_INTELLIGENCE , 5.0)
//call AddUnitBonus(udg_speedster_unit , BONUS_AGILITY , 5.0)
call SetHeroStr(udg_speedster_unit,GetHeroStr(udg_speedster_unit,false)+5,true)
call SetHeroInt(udg_speedster_unit,GetHeroInt(udg_speedster_unit,false)+5,true)
call SetHeroAgi(udg_speedster_unit,GetHeroAgi(udg_speedster_unit,false)+5,true)
call DestroyTimer(GetExpiredTimer()) //[S]Freezes on this line, I see the stats go up just as the recording ends[/S] Actually this is wrong, the hero was leveling up //as it froze. I saw the text from a critical hit from an object editor based Critical Strike skill for the fatal blow but not the "death bonus" text mentioned above.[S][/S]
endfunction
function Trig_Speedster_Hero_Dies_Bonus_Actions takes nothing returns nothing
call TimerStart(CreateTimer(), 0.03, false, function Trig_Speedster_Hero_Dies_Bonus_Timer_Expires) //Using a timer here because for some reason running the same actions without one also freezes
endfunction
//===========================================================================
function InitTrig_Speedster_Hero_Dies_Bonus takes nothing returns nothing
set gg_trg_Speedster_Hero_Dies_Bonus=CreateTrigger()
call DisableTrigger(gg_trg_Speedster_Hero_Dies_Bonus)
call TriggerRegisterAnyUnitEventBJ(gg_trg_Speedster_Hero_Dies_Bonus, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(gg_trg_Speedster_Hero_Dies_Bonus, Condition(function Trig_Speedster_Hero_Dies_Bonus_Conditions))
call TriggerAddAction(gg_trg_Speedster_Hero_Dies_Bonus, function Trig_Speedster_Hero_Dies_Bonus_Actions)
endfunction
Last edited: