- Joined
- Nov 13, 2006
- Messages
- 1,814
once happened with me similiar with level up trigger or what, there if i moved everything to action function then worked well, else in cindition function it was ran multiple times
now the respawn, reiving trigger do same but the action part and i dont know why
now the respawn, reiving trigger do same but the action part and i dont know why
JASS:
function Revive_and_Respawn takes nothing returns nothing
local unit du = GetDyingUnit()
local unit ku = GetKillingUnit()
local integer dutype = GetUnitTypeId(du)
local integer dLv
local real x = GetUnitX(du)
local real y = GetUnitY(du)
local real ang = GetUnitFacing(du)
local player pd = GetOwningPlayer(du)
local player pk = GetOwningPlayer(ku)
local integer pld = GetPlayerId(pd) + 1
local integer plk = GetPlayerId(pk) + 1
local integer cvd = GetUnitUserData(du)
local integer cvk = GetUnitUserData(ku)
local integer exp
local integer boss = 0
local timer t
set udg_CombatTimer[cvd] = 1
if GetPlayerController(pd) == MAP_CONTROL_USER then
call DisplayTextToPlayer(Player(0), 0, 0, "debug 1."+GetUnitName(du)+R2S(GetWidgetLife(du)))
if IsUnitType(du, UNIT_TYPE_HERO) then
//if udg_Inv_Unit[pld] == cvd then
// if udg_Camera_Lock[pld] > 0 then
// call WindowTransition (pld, udg_Camera_Lock[pld], 0)
// endif
//endif
set t = CreateTimer()
call SaveUnitHandle(udg_Stat_Table, 8991, GetHandleId(t), du)
call TimerStart(t,5, false, function Revive_Hero) //here was wait, i changed to timer coz i thought that the problem but no
set t = null
endif
else
//get the dying unit lv
if not IsUnitType(du, UNIT_TYPE_HERO) then
set dLv = GetUnitLevel(du)
else
set dLv = GetHeroLevel(du)
set boss = 1
endif
//add exp
if ku == udg_Hero[plk] then
set exp = R2I((udg_Global_Exp[cvd] * ((100.00 + udg_Stat_Exp[cvk]) / 100.00)))
call SuspendHeroXP(ku, false)
call AddHeroXP(ku, exp, true)
call SuspendHeroXP(ku, true)
call FT_Ex (pk, pk, "+" + I2S(exp) + " exp", 2, du, 13, 0, 0, 255, 255, 90)
if udg_Global_Hp4Kill[cvk] > 0 then
call SetWidgetLife(ku, GetWidgetLife(ku) + udg_Global_Hp4Kill[cvk])
endif
if udg_Global_Mp4Kill[cvk] > 0 then
call SetUnitState(ku, UNIT_STATE_MANA, GetUnitState(ku, UNIT_STATE_MANA) + udg_Global_Mp4Kill[cvk])
endif
endif
if not IsUnitType(du, UNIT_TYPE_SUMMONED) then
call CreateDrop(du, ku)
call TriggerSleepAction(10)
if boss == 0 then
call RemoveUnit(du)
call CreateUnit(pd, dutype, LoadReal(udg_Stat_Table, 9999, cvd), LoadReal(udg_Stat_Table, 9998, cvd), bj_RADTODEG * LoadReal(udg_Stat_Table, 9997, cvd))
else
call ReviveHero(du, LoadReal(udg_Stat_Table, 9999, cvd), LoadReal(udg_Stat_Table, 9998, cvd), false)
call SetHeroLevel(du, LoadInteger(udg_Stat_Table, 9996, cvd), true)
endif
endif
endif
call TriggerSleepAction(1) //if this 1 second then debug msg appear every sec, if this wait removed then every second appear the msg even unit already revived
//sometimes revive faster than needed and on old position
set du = null
set ku = null
set pd = null
set pk = null
endfunction
//===========================================================================
function InitTrig_Revive_Respawn_Drop takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_DEATH, null)
call TriggerAddAction( t, function Revive_and_Respawn )
set i = i + 1
exitwhen i == 15
endloop
set t = null
endfunction