library Z requires utils
globals
unit Z_dyingunit = null
unit Z_lastcreatedunit = null
player Z_zombieplayer = null
integer Z_dyingunittype = 0
real Z_dyingunitfacing = 0
integer Z_tmrid = 0
endglobals
public function iszombie takes unit u returns boolean
if GetUnitAbilityLevelSwapped('A034',u)==1 then
return true
endif
return false
endfunction
public function conds takes player kplyr, integer dlvl, integer did, location point,integer kid, timer tmr, boolean disz, boolean kisz returns boolean
if dlvl>=60 or dlvl>5 or dlvl==0 or IsUnitIdType(did, UNIT_TYPE_MAGIC_IMMUNE) or disz then
return false
endif
if IsUnitIdType(did, UNIT_TYPE_UNDEAD) or IsUnitIdType(did, UNIT_TYPE_FLYING) or IsUnitIdType(did, UNIT_TYPE_ANCIENT) then
return false
endif
if IsUnitIdType(did, UNIT_TYPE_GIANT) or IsUnitIdType(did, UNIT_TYPE_SUMMONED) or IsUnitIdType(did, UNIT_TYPE_MECHANICAL) then
return false
endif
if IsUnitIdType(did, UNIT_TYPE_STRUCTURE) or IsUnitIdType(did, UNIT_TYPE_HERO) or IsPlayerEnemy(kplyr,Player(0)) then
return false
endif
if IsPointBlightedBJ(point) or kid=='u006'or kisz then
return true
endif
return false
endfunction
globals
unit Z_turned = null
unit Z_turner = null
endglobals
public function turn takes nothing returns nothing
local unit du = GetDyingUnit()
local unit ku = GetKillingUnitBJ()
local unit d = null
local location dp
local integer did
local real dfacing
local unit k = null
local integer kid
local player kplyr
local timer tmr = null
local integer tmrid
local real tmrlife = 3.5
if du != null then
set d = du
else
set d = Z_turned
call utils_pr("d")
endif
if ku != null then
set k = ku
else
set k = Z_turner
set tmrlife = 0.1
endif
set dp = GetUnitLoc(d)
set did = GetUnitTypeId(d)
set dfacing = GetUnitFacing(d)
set kid = GetUnitTypeId(k)
set kplyr = GetOwningPlayer(k)
if GetUnitAbilityLevelSwapped('Acpf', d)==0 then
if Z_conds(kplyr,GetUnitLevel(d),did,dp,kid,tmr,iszombie(d),iszombie(k)) then
set tmr = CreateTimer()
set tmrid = GetHandleIdBJ(tmr)
call SaveTimerHandleBJ( tmr, 0, did, udg_Z_Timers )
call SaveUnitHandleBJ(d, 0, tmrid, udg_Z_Timers )
if IsUnitIdType(did, UNIT_TYPE_PEON) then
call SaveIntegerBJ( 'n01B', 1, tmrid, udg_Z_Timers )
else
call SaveIntegerBJ( did, 1, tmrid, udg_Z_Timers )
endif
call SaveRealBJ( dfacing, 2, tmrid, udg_Z_Timers )
call SaveLocationHandleBJ( dp, 3, tmrid, udg_Z_Timers )
call TriggerRegisterTimerExpireEventBJ( gg_trg_Zombification, tmr)
call StartTimerBJ( tmr, false, tmrlife)
endif
endif
set tmr = null
set du = null
set ku = null
set d = null
set dp = null
set k = null
set kplyr = null
endfunction
endlibrary
function InitTrig_Unit_Dies_On_Blighted_Land takes nothing returns nothing
set gg_trg_Unit_Dies_On_Blighted_Land = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Unit_Dies_On_Blighted_Land, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction( gg_trg_Unit_Dies_On_Blighted_Land, function Z_turn )
endfunction
function Z_clearupvars takes nothing returns nothing
call FlushChildHashtableBJ(GetUnitTypeId(Z_dyingunit),udg_Z_Timers )
call RemoveLocation(LoadLocationHandleBJ( 3, Z_tmrid, udg_Z_Timers ))
set Z_dyingunit = null
set Z_lastcreatedunit = null
set Z_zombieplayer = null
call FlushChildHashtableBJ(Z_tmrid,udg_Z_Timers )
endfunction
function Z_zombify takes nothing returns nothing
local real lifespan = GetRandomInt(60, 120)
local real r = GetRandomInt(65, 80)
local real g = GetRandomInt(30, 45)
local real b = GetRandomInt(30, 45)
local timer tmr = GetExpiredTimer()
set Z_tmrid = GetHandleIdBJ(tmr)
call DestroyTimer(tmr)
set tmr = null
set Z_dyingunit = LoadUnitHandleBJ(0, Z_tmrid, udg_Z_Timers )
set Z_dyingunittype = LoadIntegerBJ( 1, Z_tmrid, udg_Z_Timers )
set Z_dyingunitfacing = LoadRealBJ( 2, Z_tmrid, udg_Z_Timers )
if GetRandomInt(0,1) == 1 then
set Z_zombieplayer = Player(20)
else
set Z_zombieplayer = Player(21)
endif
//Resurrection
if StringLength(GetUnitName(Z_dyingunit)) == 0 then
call Z_clearupvars()
return
endif
call RemoveUnit(Z_dyingunit)
call utils_createu(Z_dyingunittype, Z_zombieplayer, LoadLocationHandleBJ( 3, Z_tmrid, udg_Z_Timers ),Z_dyingunitfacing)
set Z_lastcreatedunit = created
call SetUnitMoveSpeed( Z_lastcreatedunit, ( GetUnitDefaultMoveSpeed(Z_lastcreatedunit) * GetRandomReal(0.50, 1.5) ) )
//Zombification
if (GetRandomInt(0, 50)==1) then
//leader zombie
if (GetRandomInt(0, 3)==1) then
call UnitAddAbilityBJ( 'A03F', Z_lastcreatedunit )//spreader
call UnitAddAbilityBJ( 'A030', Z_lastcreatedunit )//small green glow
call GroupAddUnitSimple(Z_lastcreatedunit, udg_Group_LightCarriers)
set r = 35
set g = 40
set b = 28
endif
call UnitAddAbilityBJ( 'A03C', Z_lastcreatedunit )//leader zombie
call UnitAddAbilityBJ( 'A035', Z_lastcreatedunit )//carrion swarm
if (GetRandomInt(0, 1)==1) then
call UnitAddAbilityBJ( 'ANb2', Z_lastcreatedunit )//bash
else
call UnitAddAbilityBJ( 'ACcr', Z_lastcreatedunit )//cripple
endif
call SetUnitMoveSpeed( Z_lastcreatedunit, ( GetUnitDefaultMoveSpeed(Z_lastcreatedunit) * 1.5 ) )
//leader zombie
set lifespan = 444
call SetUnitManaPercentBJ( Z_lastcreatedunit, 100 )
call SetUnitScalePercent( Z_lastcreatedunit, GetRandomInt(180, 280),GetRandomInt(180, 280),GetRandomInt(180, 280) )
else
call UnitAddAbilityBJ( 'A034', Z_lastcreatedunit )//normal zombie
if (GetRandomInt(0, 5)==1) then
call UnitAddAbilityBJ( 'A03F', Z_lastcreatedunit )//spreader
set r = 35
set g = 40
set b = 28
endif
endif
call BlzSetUnitName( Z_lastcreatedunit, "Zombie" )
call utils_identify(Z_lastcreatedunit)
call UnitAddTypeBJ( UNIT_TYPE_UNDEAD, Z_lastcreatedunit )
call SetUnitVertexColorBJ( Z_lastcreatedunit, r, g, b, 0 )
call UnitApplyTimedLifeBJ( lifespan, 'Brai', Z_lastcreatedunit )
call utils_se_p(LoadLocationHandleBJ( 3, Z_tmrid, udg_Z_Timers ),1,"Abilities\\Spells\\Undead\\Darksummoning\\DarkSummonTarget.mdl")
//Zombie Self Destruction
call Z_clearupvars()
endfunction
function InitTrig_Zombification takes nothing returns nothing
set gg_trg_Zombification = CreateTrigger( )
call TriggerAddAction( gg_trg_Zombification, function Z_zombify )
endfunction