Scriptname eXo:Goodneighbor:PokeFeralScript extends ObjectReference

Group Spells
    Spell Property PokeSpell Auto
    Spell Property RadsSpell Auto
    Spell Property BurstSpell Auto
EndGroup

Group Actors
    Actor Property GlowingOne Auto
    Actor Property Ghoul Auto
    Actor Property Feral Auto
    Actor Property Tamer Auto
EndGroup

MiscObject Property Caps001 Auto
Sound Property GhoulSnarlSound Auto
Message Property PokeMessage Auto
ObjectReference Property CageMarker Auto
Faction Property CrimeGoodneighbor Auto Const

Int Property pokeCount = 0 Auto

Event OnLoad()
    pokeCount = 0
    GlowingOne.MoveTo(CageMarker)
EndEvent

Event OnActivate(ObjectReference akActionRef)
    if akActionRef != Game.GetPlayer()
        return
    endif

    int choice = -1

    choice = PokeMessage.Show()
    if choice == 0
        Game.GetPlayer().RemoveItem(Caps001, 2)
        DoPoke()
    endif
EndEvent

Function DoPoke()
    RadsSpell.Cast(Self, Game.GetPlayer())

    if GlowingOne != None
        GhoulSnarlSound.Play(GlowingOne)
        PokeSpell.Cast(Self, GlowingOne)

        CheckForBurstWarnings()
    endif
EndFunction

Function CheckForBurstWarnings()
    pokeCount += 1

    if pokeCount == 4
        Debug.Notification("You swear its glow just pulsed stronger...")
    elseif pokeCount == 5
        Debug.Notification("Its glow pulses unnaturally, like it's building up something.")
    elseif pokeCount == 6
        Debug.Notification("It looks like it's about to burst.")
    elseif pokeCount >= 7
        TriggerRadBurst()
    endif
EndFunction

Function TriggerRadBurst()
    if GlowingOne != None
        BurstSpell.Cast(Self, GlowingOne)
    endif
	
    Ghoul.Disable()
    Feral.Enable()
    Feral.MoveTo(Ghoul)

    Tamer.RemoveFromFaction(CrimeGoodneighbor)
    Utility.Wait(1.5)
    Feral.StartCombat(Tamer)
EndFunction
