Sorry for being slow on this. I was busy.
Anyways, try this out.
Features:
-Completely accurate--When hero reincarnates, there is no delay between having full hp bar and half hp bar (None that a human could tell
).
-Compatible with any reincarnation delay.
-Multi-unit instanceable.
-Configurable revive hp (%).
Drawbacks:
-Hero must actually learn the skill for triggers to work correctly; currently not compatible with it being a unit ability.
-The delay between dying and respawning should be less than the delay between dying and reincarnating.
The above means that if the unit dies (Reincarnation is in CD), the delay of the reincarnation ability must be less than the time it takes to respawn (This shouldn't be a problem...since respawn time is usually 10+ seconds).
The above also means that when a duel starts, there should be a delay before reviving/moving all heros (Longer than the reincarnation delay)
If you want to not have these drawbacks, I can customize the triggers, given the map, as to not have these problems.
//////
System consists of two triggers.
Simply copy the variable in variable editor, the triggers and then configure them and you're ready to go.
Code: Select all
Trigger: Reg on Learn
//Configuration
constant function ReincarnationDelay takes nothing returns real
return 7.00
endfunction
constant function AbilityRawcode takes nothing returns integer
return 'AOre' //The rawcode of the ability
endfunction
constant function PercentRevive takes nothing returns real
return .50 //The %hp of the reincarnation
endfunction
//Endconfiguration
function RegOnDeath takes nothing returns nothing
call TriggerRegisterUnitEvent(gg_trg_Reincarnate_Percent,GetLearningUnit(),EVENT_UNIT_DAMAGED)
endfunction
//===========================================================================
function RegOnDeathCond takes nothing returns boolean
return(GetLearnedSkill()==AbilityRawcode())
endfunction
function InitTrig_Reg_on_Learn takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_HERO_SKILL)
call TriggerAddCondition(t,Condition(function RegOnDeathCond))
call TriggerAddAction(t,function RegOnDeath)
set t=null
endfunction
Code: Select all
Trigger: Reincarnate Percent
//Handle Functions..Leave alone...
function H2I takes handle h returns integer
return h
return 0
endfunction
function GetHandleId takes handle h returns integer
local integer i=H2I(h)
set i=i*2134900736
set i=i/ 524288+4096
return i
endfunction
/////////////////////////////////////
function NerfLife takes nothing returns nothing
local timer t=GetExpiredTimer()
local integer i=GetHandleId(t)
call SetWidgetLife(udg_ReincarnationUnits[i],GetUnitState(udg_ReincarnationUnits[i],UNIT_STATE_MAX_LIFE)*PercentRevive())
call DestroyTimer(t)
set t=null
endfunction
function ReinPercent takes nothing returns nothing
local timer t=CreateTimer()
local integer i=GetHandleId(t)
set udg_ReincarnationUnits[i]=GetTriggerUnit()
call TimerStart(t,0.001+ReincarnationDelay(),false,function NerfLife)
set t=null
endfunction
//===========================================================================
function ReinPCond takes nothing returns boolean
return(GetWidgetLife(GetTriggerUnit())-.405 <= GetEventDamage())
endfunction
function InitTrig_Reincarnate_Percent takes nothing returns nothing
set gg_trg_Reincarnate_Percent=CreateTrigger()
call TriggerAddCondition(gg_trg_Reincarnate_Percent,Condition(function ReinPCond))
call TriggerAddAction(gg_trg_Reincarnate_Percent,function ReinPercent)
endfunction
Refer to
this for an example.