Scriptname _00E_NQ03_Functions extends Quest  

;=====================================================================================
;                                       FUNCTIONS                                    
;=====================================================================================

Function EnablePotion()

    NQ03_PotionREF.Enable()

EndFunction

Function SpawnAurathief()

	if !bDone
		Game.RequestAutoSave()
		_00E_MQ11a_MagicAnomalyScreamAM.Play(PlayerREF)
		NQ03_AurathiefREF.Enable()
		NQ03_AurathiefREF.PlaceAtMe(ExplosionIllusionLight01, 1)
		NQ03_AurathiefREF.StartCombat(PlayerREF)
		bDone = True
	endif
    
EndFunction

Function ShowMessageBox()

    SetObjectiveCompleted(5)

    int iButton = _00E_NQ03_PotionMessageBox.Show()

    if iButton == 0
        PlayerREF.AddItem(_00E_NQ03_BottleShards, 1)
        MAGDragonPowerAbsorbManEffect.Play(PlayerREF)
        MAGPowerRacialHitskinM.Play(PlayerREF)
        _00E_HealingIsm.Apply()
        PlayerREF.SetActorValue("Speechcraft", (PlayerREF.GetBaseActorValue("Speechcraft") + __Config_fSpeecCraftBonus))
        PlayerREF.SetActorValue("Health", (PlayerREF.GetBaseActorValue("Health") + __Config_fDrinkPotionHealthBonus))

        _00E_NQ03_sRaisedHealth.Show(__Config_fDrinkPotionHealthBonus)

        _00E_NQ03_sRaisedSpeechcraft.Show(__Config_fSpeecCraftBonus)

        SetCurrentStageID(25)
        if IsObjectiveDisplayed(15)
            SetObjectiveFailed(15)
        endif
        SetObjectiveDisplayed(10)
        MAGDragonPowerAbsorbManEffect.Stop(PlayerREF)
        if PlayerREF.GetItemCount(_00E_NQ03_TarhutiesBottle) > 0
            PlayerREF.RemoveItem(_00E_NQ03_TarhutiesBottle, 1)
        endif
    Else
        SetCurrentStageID(20)
        SetObjectiveDisplayed(15)
        if PlayerREF.GetItemCount(_00E_NQ03_TarhutiesBottle) < 1
            PlayerREF.AddItem(_00E_NQ03_TarhutiesBottle, 1)
        endif
    EndIf
    
    NQ03_PotionREF.Disable()

EndFunction

Function GiveMoneyReward()

    if GetCurrentStageID() == 25
        PlayerREF.AddItem(Gold001, __Config_iMoneyWhenBottleBroken)
        PlayerREF.RemoveItem(_00E_NQ03_BottleShards, 1)
    Elseif GetCurrentStageID() == 20
        PlayerREF.AddItem(Gold001, __Config_iMoneyWhenBottleIntact)
        PlayerREF.RemoveItem(_00E_NQ03_TarhutiesBottle, 1)
    EndIf
    
EndFunction

Function GiveMasterTeacher()

    PlayerREF.AddItem(_00E_MasterTeacher, 1)
    NQ03_MasterSkullSphereREF.Enable()

EndFunction

Function FinishUp()

    _00E_EPHandler.GiveEP(__Config_iRewardEXP)

EndFunction

;=====================================================================================
;                                       PROPETIES                                    
;=====================================================================================

int iState
bool bDone = false

int Property __Config_iRewardEXP = 175 Auto
int Property __Config_iMoneyWhenBottleBroken = 30 Auto
int Property __Config_iMoneyWhenBottleIntact = 130 Auto

float Property __Config_fDrinkPotionHealthBonus = 8.0 Auto
float Property __Config_fSpeecCraftBonus = 3.0 Auto

Message Property _00E_NQ03_sRaisedSpeechcraft Auto
Message Property _00E_NQ03_sRaisedHealth Auto
 
Actor Property PlayerREF Auto
Actor Property NQ03_AurathiefREF Auto

Explosion Property ExplosionIllusionLight01 Auto

VisualEffect Property MAGDragonPowerAbsorbManEffect Auto

ImageSpaceModifier Property _00E_HealingIsm Auto

ObjectReference Property NQ03_PotionREF Auto
ObjectReference Property NQ03_MasterSkullSphereREF Auto

Message Property _00E_NQ03_PotionMessageBox Auto

Sound Property MAGPowerRacialHitskinM Auto
Sound Property _00E_MQ11a_MagicAnomalyScreamAM Auto

MiscObject Property _00E_NQ03_TarhutiesBottle Auto
MiscObject Property _00E_NQ03_BottleShards Auto
MiscObject Property Gold001 Auto
MiscObject Property _00E_MasterTeacher Auto