library BioSupport
private function arcanum takes unit u returns boolean
local integer i = 1
loop
exitwhen i > 6
if GetItemTypeId(UnitItemInSlot(u, i)) == 'I060' then
return true
endif
set i = i +1
endloop
return false
endfunction
private function inviZero takes integer p returns nothing
if invi == 0 then
call UnitAddAbility( udg_Hero_Troll, 'A0DY' )
endif
endfunction
private function slipperyFalse takes integer p, unit dummy returns nothing
set dummy = CreateUnit( Player(PLAYER_NEUTRAL_PASSIVE), 'ndwm', x, y, bj_UNIT_FACING )
call UnitAddAbility( dummy, 'ACcs' )
if udg_ProtectSlip == false then
if udg_Slippery == false then
set udg_Slippery = true
set udg_Crit_power = ( udg_Crit_power - 1 )
endif
else
call SetUnitAbilityLevel( dummy, 'ACcs', 2 )
endif
call IssueTargetOrder( dummy, "curse", udg_Hero_Troll )
call RemoveUnit( dummy) // do not forget this line if u do the game will lag overtime only other option is timed life for unit
set dummy =null
endfunction
public function CheckPlayer takes integer p returns nothing
local unit dummy
local real x = GetUnitX(udg_Hero_Troll)
local real y = GetUnitY(udg_Hero_Troll)
local integer wetbuff = GetUnitAbilityLevel(udg_Hero_Troll, 'BUfa')
local integer heatbuff = GetUnitAbilityLevel(udg_Hero_Troll, 'Bapl')
local integer springbuff = GetUnitAbilityLevel(udg_Hero_Troll, 'BHab')
local integer feverbuff = GetUnitAbilityLevel(udg_Hero_Troll, 'Brej')
local integer shelterbuff = GetUnitAbilityLevel(udg_Hero_Troll, 'B01R')
local integer bear = GetUnitAbilityLevel(udg_Hero_Troll, 'A04F')
local integer pig = GetUnitAbilityLevel(udg_Hero_Troll, 'A04S')
local integer hutt = GetUnitAbilityLevel(udg_Hero_Troll, 'A04L')
local integer saber = GetUnitAbilityLevel(udg_Hero_Troll, 'A04R')
local integer hunter = GetUnitAbilityLevel(udg_Hero_Troll, 'A0HF')
local integer other = GetUnitAbilityLevel(udg_Hero_Troll, 'A0HX')
local integer shaman = GetUnitAbilityLevel(udg_Hero_Troll, 'A0HW')
local integer invi = GetUnitAbilityLevel(udg_Hero_Troll, 'A0DY')
local integer heroheat = GetPlayerState(Player(p-1), PLAYER_STATE_RESOURCE_LUMBER)
local integer herohunger = GetPlayerState(Player(p-1), PLAYER_STATE_RESOURCE_GOLD)
// ===== Water Wet Effect =====
if IsTerrainPathable( x, y, PATHING_TYPE_FLOATABILITY) == false then
if udg_ProtectWater == false then
call slipperyFalse(p, dummy)
elseif wetbuff == 0 and heatbuff == 0 and udg_Rain == true then
call slipperyFalse(p, dummy)
endif
endif
if wetbuff == 0 then
if udg_Slippery == true then
set udg_Slippery = false
set udg_Crit_power = ( udg_Crit_power + 1 )
endif
else
if springbuff == 0 then
set udg_WetEffect = 2
else
set udg_WetEffect = 1
endif
endif
// ===== Frozen by Cold =====
if heroheat <= 0 and udg_Frozen == false then
set udg_MB_Frozen = "Yes"
set udg_Frozen = true
call UnitAddAbility( udg_Hero_Troll, 'A00P' )
endif
if udg_Frozen == true then
if udg_Boat == true then
call UnitAddAbility( udg_BoatLoaded, 'A00P' )
call SetUnitAbilityLevel( udg_BoatLoaded, 'A00P', 2 )
endif
endif
if heroheat <= 0 and GetRandomInt(1, 10) == 1 and feverbuff == 0 then
set x = GetUnitX(udg_Hero_Troll)
set y = GetUnitY(udg_Hero_Troll)
set dummy = CreateUnit( Player(PLAYER_NEUTRAL_PASSIVE), 'ndwm', x, y, bj_UNIT_FACING )
call UnitAddAbility( dummy, 'ACff' )
call IssueTargetOrder( dummy, "faeriefire", udg_Hero_Troll )
call RemoveUnit( dummy) // do not forget this line if u do the game will lag overtime only other option is timed life for unit
set dummy =null
endif
// ===== Unfrozen by Heat =====
if heroheat >= 50 and udg_Frozen == true then
set udg_MB_Frozen = "No"
set udg_Frozen = false
call UnitRemoveAbility( udg_Hero_Troll, 'A00P' )
call UnitRemoveAbility( udg_BoatLoaded, 'A00P' )
endif
// ===== Starving =====
if herohunger <= 0 and udg_Starving == false then
set udg_MB_Starving = "Yes"
call UnitAddAbility( udg_Hero_Troll, 'A00M' )
set udg_Starving = true
else //if udg_Starving == true
set udg_MB_Starving = "No"
call UnitRemoveAbility( udg_Hero_Troll, 'A00M' )
set udg_Starving = false
endif
// ========== SLEEP BONUS ==========
if hutt > 0 or bear > 0 or saber > 0 or pig > 0 or hunter > 0 or shaman > 0 or other > 0 then
call SetPlayerState( Player(p-1), PLAYER_STATE_RESOURCE_GOLD, herohunger + ( 5 - udg_GameDiff ) ))
endif
// ========== INVISIBILITY BONUS ==========
if arcanum(udg_Hero_Troll) and GetRandomInt(1, 4) == 1 then
inviZero(p)
else
call UnitRemoveAbility( udg_Hero_Troll, 'A0DY' )
endif
if shelterbuff > 0 then
inviZero(p)
else
call UnitRemoveAbility( udg_Hero_Troll, 'A0DY' )
endif
// ===== Coma Energy is 0 =====
if udg_Sleeping == false and udg_Coma == false and udg_Eaten == false and GetUnitState( udg_Hero_Troll, UNIT_STATE_MANA) <= 0.00 then
call SetUnitState(udg_Basic_Crafting, UNIT_STATE_MANA, 200.)
set udg_Coma = true
set udg_MB_Coma = "Yes"
call UnitRemoveAbility( udg_Hero_Troll, 'Binv' )
call UnitRemoveAbility( udg_Hero_Troll, 'BOwk' )
set dummy = CreateUnit( Player(PLAYER_NEUTRAL_PASSIVE), 'ndwm', x, y, bj_UNIT_FACING )
call UnitAddAbility( dummy, 'A0MA' )
call TriggerSleepAction( 0.50 )
call IssueTargetOrder( dummy, "creepthunderbolt", udg_Hero_Troll )
call RemoveUnit( dummy) // do not forget this line if u do the game will lag overtime only other option is timed life for unit
set dummy =null
call UnitAddAbility( udg_Hero_Troll, 'A00B' )
set udg_Sleep_Troll = 'A00B'
call SetUnitAnimation( udg_Hero_Troll, "death" )
endif
endfunction
endlibrary