scope IronBane initializer init
globals
private constant string EventStart = "Units\\Human\\Rifleman\\RiflemanPissed1.wav"
private constant string EventWipe = "Units\\Human\\Rifleman\\RiflemanPissed5.wav"
private constant string EventKill = "Units\\Human\\Rifleman\\RiflemanPissed8.wav"
private constant string EventSnipeShot = "Units\\Human\\Rifleman\\RiflemanYesAttack1.wav"
private unit IronBane
private player IronBaneP
private rect IronBaneR
private real IronBaneX
private real IronBaneY
private real HBX // HiddenBomb
private real HBY // HiddenBomb
private boolexpr Bool
private unit tempu
private integer SnipeShots = 0
private integer Fighters = 0
private integer HiddenBombs = 0
private group G = CreateGroup()
private group HBG = CreateGroup() // Nature Blast
private group SSG = CreateGroup() // Snipeshot MaxRange
private timer HiddenBombT = CreateTimer() // HiddenBomb
private timer SnipeShotT = CreateTimer() // Snipeshot
private trigger Phase1T = CreateTrigger()
private trigger Phase2T = CreateTrigger()
private trigger Phase3T = CreateTrigger()
public trigger StartTrig = CreateTrigger()
public trigger EndTrig = CreateTrigger()
public trigger EndTrig2 = CreateTrigger()
private region IronBaneReg
private region IronBaneAReg
endglobals
//===============================================================================================
// HiddenBomb
//===============================================================================================
private function HiddenBombExe takes nothing returns nothing
call GroupEnumUnitsInRange(HBG,HBX,HBY,200.,Bool)
loop
set tempu = FirstOfGroup(HBG)
exitwhen tempu == null
call GroupRemoveUnit(HBG,tempu)
call UnitDamageTargetEx(IronBane, tempu,GetRandomReal(100.,140.), ATTACK_TYPE_MAGIC, DAMAGE_TYPE_SPELLNATURE, false)
call DestroyEffect(AddSpecialEffect("Abilities\\Weapons\\FragDriller\\FragDriller.md",HBX,HBY))
endloop
endfunction
private function HiddenBomb takes unit target returns nothing
set HBX = GetUnitX(target)
set HBY = GetUnitY(target)
call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl",HBX,HBY))
set HiddenBombs = HiddenBombs + 1
call TimerStart(HiddenBombT,2.5,false,function HiddenBombExe)
endfunction
//===============================================================================================
// Snipe Shot
//===============================================================================================
private function SnipeShotExe takes nothing returns nothing
call GroupEnumUnitsInRange(SSG,GetUnitX(IronBane),GetUnitY(IronBane),2000.,Bool)
call PauseUnit(IronBane, false)
call SetUnitTimeScale(IronBane, 1.)
loop
set tempu = FirstOfGroup(SSG)
exitwhen tempu == null
call GroupRemoveUnit(SSG,tempu)
if IsUnitInRange(tempu,Ironbane,225.) != true and GetUnitAbilityLevel(tempu,'B00O') > 0 then
call UnitDamageTargetEx(IronBane, tempu,GetRandomReal(350.,750.), ATTACK_TYPE_ATTACK, DAMAGE_TYPE_ATTACK, false)
endif
endloop
endfunction
private function SnipeShot takes unit target returns nothing
local sound S = CreateSound(EventSnipeShot,false,true,true,10,10,"DefaultEAXON")
local real a
local integer i = 0
local string msg
local unit dummy = CreateUnit(IronBaneP,'h00J',GetUnitX(IronBane),GetUnitY(IronBane),0.)
call UnitAddAbility(dummy,'A0FJ')
call UnitApplyTimedLife(dummy,'BTLF',1)
call IssueTargetOrder(dummy,"faeriefire",target)
call PlaySoundOnUnitBJ(S,100.,IronBane)
set S = null
set msg = "Fire!"
loop
exitwhen i > GetPlayers()
call DisplayTimedTextToPlayer(Player(i),0,0,5,msg)
set i = i + 1
endloop
set SnipeShots = SnipeShots + 1
call PauseUnit(IronBane, true)
call SetUnitAnimation(IronBane,"attack, slam")
call SetUnitTimeScale(IronBane, 0,33)
set a = ABU(IronBane,target) * bj_RADTODEG
call SetUnitFacing(IronBane,a)
call TimerStart(SnipeShotT,4.,false,function SnipeShotExe)
endfunction
//===============================================================================================
// PHASE 1
//===============================================================================================
private function Phase1 takes nothing returns nothing
local real chance = GetRandomReal(0.,100.)
call GroupClear(G)
call GroupEnumUnitsInRect(G,IronBaneR,Bool)
if chance <= 50. then
call HiddenBomb(GroupPickRandomUnit(G))
endif
endfunction
private function PhaseTrans1 takes nothing returns nothing
local string msg
local integer i = 0
call DisableTrigger(Phase1T)
call EnableTrigger(Phase2T)
set msg = "Let's make this a littlebit tougher."
loop
exitwhen i > GetPlayers()
call DisplayTimedTextToPlayer(Player(i),0,0,5,msg)
set i = i + 1
endloop
endfunction
//===============================================================================================
// PHASE 2
//===============================================================================================
private function Phase2 takes nothing returns nothing
local real chance = GetRandomReal(0.,100.)
call GroupClear(G)
call GroupEnumUnitsInRect(G,IronBaneR,Bool)
if chance <= 75. then
call HiddenBomb(GroupPickRandomUnit(G))
endif
if ModuloInteger(SnipeShots,6) == 0 then
call SnipeShot(GroupPickRandomUnit(G))
else
set SnipeShots = Snipeshots + 1
endif
endfunction
private function PhaseTrans2 takes nothing returns nothing
local string msg
local integer i = 0
call DisableTrigger(Phase2T)
call EnableTrigger(Phase3T)
set msg = "Now you're making me really angry!"
loop
exitwhen i > GetPlayers()
call DisplayTimedTextToPlayer(Player(i),0,0,5,msg)
set i = i + 1
endloop
endfunction
//===============================================================================================
// PHASE 3
//===============================================================================================
private function Phase3 takes nothing returns nothing
call GroupClear(G)
call GroupEnumUnitsInRect(G,IronBaneR,Bool)
call HiddenBomb(GroupPickRandomUnit(G))
if ModuloInteger(SnipeShots,6) == 0 then
call SnipeShot(GroupPickRandomUnit(G))
else
set SnipeShots = Snipeshots + 1
endif
endfunction
//===============================================================================================
// Start of Fight
//===============================================================================================
private function EncounterStart takes nothing returns nothing
local string msg
local integer i = 0
local sound S = CreateSound(EventStart,false,true,true,10,10,"DefaultEAXON")
if IsUnitType(GetEnteringUnit(),UNIT_TYPE_HERO) and GetUnitTypeId(GetEnteringUnit()) != GetUnitTypeId(IronBane) then
if Fighters == 0 then
call GroupClear(G)
call GroupEnumUnitsInRect(G,IronBaneR,Bool)
call ShowUnit(IronBane,true)
call PauseUnit(IronBane,false)
call IssueTargetOrder(IronBane,"attack",GroupPickRandomUnit(G))
call EnableTrigger(Phase1T)
set msg = "This is my... BOOMSTICK!!!''
call PlaySoundOnUnitBJ(S,100.,IronBane)
loop
exitwhen i > GetPlayers()
call DisplayTimedTextToPlayer(Player(i),0,0,5,msg)
set i = i + 1
endloop
endif
set Fighters = Fighters + 1
endif
set S = null
endfunction
//===============================================================================================
// End of Fight
//===============================================================================================
private function EncounterFinish takes nothing returns nothing
local string msg
local integer i = 0
call DisableTrigger(Phase3T)
call DisableTrigger(StartTrig)
call DisableTrigger(EndTrig)
call DisableTrigger(EndTrig2)
set msg = "You'll take my blunderbuss when you pry it from my cold dead hands!"
loop
exitwhen i > GetPlayers()
call DisplayTimedTextToPlayer(Player(i),0,0,5,msg)
set i = i + 1
endloop
endfunction
public function EncounterStop takes nothing returns nothing
local integer i = 0
local string msg
set Fighters = 0
if IsTriggerEnabled(Phase1T) then
call DisableTrigger(Phase1T)
endif
if IsTriggerEnabled(Phase2T) then
call DisableTrigger(Phase2T)
endif
if IsTriggerEnabled(Phase3T) then
call DisableTrigger(Phase3T)
endif
call SetWidgetLife(IronBane,1000000.)
call SetUnitPosition(IronBane,IronBaneX,IronBaneY)
call PauseUnit(IronBane,true)
call ShowUnit(IronBane,false)
///call ResetUnitAggro(IronBane)
set msg = "Timeout Phrase!"
loop
exitwhen i > GetPlayers()
call DisplayTimedTextToPlayer(Player(i),0,0,5,msg)
set i = i + 1
endloop
endfunction
private function EncounterEnd takes nothing returns nothing
local string msg
local integer i = 0
local sound S = CreateSound(EventWipe,false,true,true,10,10,"DefaultEAXON")
if IsUnitType(GetLeavingUnit(),UNIT_TYPE_HERO) and GetUnitTypeId(GetLeavingUnit()) != GetUnitTypeId(IronBane) then
set Fighters = Fighters - 1
if Fighters == 0 then
call PlaySoundOnUnitBJ(S,100.,IronBane)
if IsTriggerEnabled(Phase1T) then
call DisableTrigger(Phase1T)
endif
if IsTriggerEnabled(Phase2T) then
call DisableTrigger(Phase2T)
endif
if IsTriggerEnabled(Phase3T) then
call DisableTrigger(Phase3T)
endif
call SetWidgetLife(IronBane,1000000.)
call SetUnitPosition(IronBane,IronBaneX,IronBaneY)
call PauseUnit(IronBane,true)
call ShowUnit(IronBane,false)
///call ResetUnitAggro(IronBane)
set msg = "Guns don't kill people... I DO!!!"
loop
exitwhen i > GetPlayers()
call DisplayTimedTextToPlayer(Player(i),0,0,5,msg)
set i = i + 1
endloop
endif
endif
set S = null
endfunction
private function EncounterEndDeath takes nothing returns nothing
local string msg
local integer i = 0
local sound S = CreateSound(EventWipe,false,true,true,10,10,"DefaultEAXON")
local sound S2 = CreateSound(EventKill,false,true,true,10,10,"DefaultEAXON")
if IsUnitType(GetDyingUnit(),UNIT_TYPE_HERO) and IsUnitInRegion(IronBaneReg,GetDyingUnit()) and GetUnitTypeId(GetDyingUnit()) != GetUnitTypeId(IronBane) then
set Fighters = Fighters - 1
if Fighters == 0 then
call PlaySoundOnUnitBJ(S,100.,IronBane)
if IsTriggerEnabled(Phase1T) then
call DisableTrigger(Phase1T)
endif
if IsTriggerEnabled(Phase2T) then
call DisableTrigger(Phase2T)
endif
if IsTriggerEnabled(Phase3T) then
call DisableTrigger(Phase3T)
endif
call SetWidgetLife(IronBane,1000000.)
call SetUnitPosition(IronBane,IronBaneX,IronBaneY)
call PauseUnit(IronBane,true)
call ShowUnit(IronBane,false)
///call ResetUnitAggro(IronBane)
set msg = "Guns don't kill people... I DO!!!"
loop
exitwhen i > GetPlayers()
call DisplayTimedTextToPlayer(Player(i),0,0,5,msg)
set i = i + 1
endloop
else
call PlaySoundOnUnitBJ(S2,100.,IronBane)
endif
endif
set S = null
set S2 = null
endfunction
//===============================================================================================
// Init
//===============================================================================================
private function ValidEnemy takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(),IronBaneP) and GetUnitTypeId(GetFilterUnit()) != 'h00J' and GetUnitTypeId(GetFilterUnit()) != 'dumm' and GetFilterUnit():Life > .405
endfunction
private function init takes nothing returns nothing
local trigger trig = CreateTrigger()
set IronBaneR = gg_rct_Boss_IronBane_Region
set IronBaneReg = CreateRegion()
call RegionAddRect(IronBaneReg,IronBaneR)
set IronBaneAR = gg_rct_Boss_IronBaneAggro_Region
set IronBaneAReg = CreateRegion()
call RegionAddRect(IronBaneAReg,IronBaneAR)
set IronBane = gg_unit_H01O_0070
set IronBaneP = GetOwningPlayer(IronBane)
set IronBaneX = GetUnitX(IronBane)
set IronBaneY = GetUnitY(IronBane)
call ShowUnit(IronBane,false)
call PauseUnit(IronBane,true)
///call GroupAddUnit(OOCExceptions,IronBane)
set Bool = Condition(function ValidEnemy)
call TriggerRegisterUnitEvent(trig,IronBane,EVENT_UNIT_DEATH)
call TriggerAddAction(trig,function EncounterFinish)
call TriggerRegisterEnterRegion(StartTrig,IronBaneAReg,null)
call TriggerAddAction(StartTrig,function EncounterStart)
call DisableTrigger(StartTrig)
call TriggerRegisterLeaveRegion(EndTrig,IronBaneReg,null)
call TriggerAddAction(EndTrig,function EncounterEnd)
call DisableTrigger(EndTrig)
call TriggerRegisterAnyUnitEventBJ(EndTrig2,EVENT_PLAYER_UNIT_DEATH)
call TriggerAddAction(EndTrig2,function EncounterEndDeath)
call DisableTrigger(EndTrig2)
//PHASES TRANSITIONS
set trig = CreateTrigger()
call TriggerRegisterUnitStateEvent(trig,IronBane,UNIT_STATE_LifE,LESS_THAN,GetUnitState(IronBane,UNIT_STATE_MAX_LifE)*0.65)
call TriggerAddAction(trig,function PhaseTrans1)
set trig = CreateTrigger()
call TriggerRegisterUnitStateEvent(trig,IronBane,UNIT_STATE_LifE,LESS_THAN,GetUnitState(IronBane,UNIT_STATE_MAX_LifE)*0.25)
call TriggerAddAction(trig,function PhaseTrans2)
//PHASES
call TriggerRegisterTimerEvent(Phase1T,6.,true)
call TriggerAddAction(Phase1T,function Phase1)
call DisableTrigger(Phase1T)
call TriggerRegisterTimerEvent(Phase2T,6.,true)
call TriggerAddAction(Phase2T,function Phase2)
call DisableTrigger(Phase2T)
call TriggerRegisterTimerEvent(Phase3T,6.,true)
call TriggerAddAction(Phase3T,function Phase3)
call DisableTrigger(Phase3T)
set trig = null
endfunction
endscope