Scriptname FCMSpectralMaidScript extends Actor  

SPELL PROPERTY pGhostAbilityNew AUTO
SPELL PROPERTY pGhostResistsAbility AUTO

GlobalVariable Property pMaidSpectralFlag Auto
Location Property HomeLocation Auto


Function SetIsSpectral(Bool b)
    if (b)
        pMaidSpectralFlag.SetValue(1)
       AddSpectralAbilities()
    else
        pMaidSpectralFlag.SetValue(0)
        RemoveSpectralAbilities()
    EndIf
EndFunction

Bool Function GetIsSpectral()
    if (pMaidSpectralFlag.getValue() == 1)
        return True
    Else
        Return False
    endIF
EndFunction

Function AddSpectralAbilities()
    addSpell(pGhostAbilityNew)
    addSpell(pGhostResistsAbility)
EndFunction
Function RemoveSpectralAbilities()
    removeSpell(pGhostAbilityNew)
    removeSpell(pGhostResistsAbility)
EndFunction

FUNCTION RestoreSpectralAbilities()
	if (GetIsSpectral())
        AddSpectralAbilities()
    Else
        RemoveSpectralAbilities() 
    Endif
EndFunction


EVENT onLoad()
	RestoreSpectralAbilities()
ENDEVENT

EVENT onLocationChange(Location akOldLoc, Location akNewLoc)
    If(akNewLoc == HomeLocation)
        SetIsSpectral(0)
    EndIf
ENDEVENT