enderalse/scripts/source/_00e_visionhomesc.psc

114 lines
2.6 KiB
Plaintext

Scriptname _00E_VisionHomeSC extends ObjectReference
Event OnTriggerEnter(ObjectReference akActionRef)
if akActionRef == PlayerREF
bPlayerIsInside = True
If bLockedDoor == False || IsBattleRunning() == False
SetWeather(_00E_MQ07aVisionWeatherNoRain)
EndIf
ElseIf (akActionRef as _00E_MQ07a_SoldierSC)
nEnemiesInside += 1
EndIf
EndEvent
Event OnTriggerLeave(ObjectReference akActionRef)
If akActionRef == PlayerREF
bPlayerIsInside = False
TryCloseDoor()
SetWeather(_00E_MQ07aVisionWeatherRain)
ElseIf (akActionRef as _00E_MQ07a_SoldierSC)
nEnemiesInside -= 1
TryCloseDoor()
EndIf
EndEvent
Event OnUpdate()
bWeaponTransitionAllowed = True
If PendindWeather
UpdatePendingWeather()
EndIf
EndEvent
;=====================================================================================
; Inside/outside weather control
;=====================================================================================
Function SetWeather(Weather newWeather)
If newWeather == CurrentWeather
PendindWeather = None
Return
EndIf
PendindWeather = newWeather
If bWeaponTransitionAllowed
UpdatePendingWeather()
EndIf
EndFunction
Function UpdatePendingWeather()
bWeaponTransitionAllowed = False
CurrentWeather = PendindWeather
PendindWeather = None
If MQ07a.GetStage() < 170
CurrentWeather.ForceActive(True)
If CurrentWeather == _00E_MQ07aVisionWeatherNoRain
MQ07a_SC6_Rainparent.Enable()
Else
MQ07a_SC6_Rainparent.Disable()
EndIf
RegisterForSingleUpdate(1.5)
EndIf
EndFunction
;=====================================================================================
; Hut's door control
;=====================================================================================
Function ResetEnemiesInside()
nEnemiesInside = 0
TryCloseDoor()
EndFunction
Function TryCloseDoor()
If IsBattleRunning() && bLockedDoor == False && bPlayerIsInside == False && nEnemiesInside <= 0
bLockedDoor = True
MQ07a_SC8_HouseDoor.SetOpen(False)
MQ07a_SC8_HouseDoor.Lock()
MQ07a_SC8_HouseDoor.SetLockLevel(255)
MQ07a_SC8_HouseDoor.BlockActivation(True)
EndIf
EndFunction
Bool Function IsBattleRunning()
Return (MQ07a.GetStage() == 145)
EndFunction
ObjectReference Property MQ07a_SC6_Rainparent Auto
ObjectReference Property MQ07a_SC8_HouseDoor Auto
Weather Property _00E_MQ07aVisionWeatherNoRain Auto
Weather Property _00E_MQ07aVisionWeatherRain Auto
Actor Property PlayerREF Auto
Quest Property MQ07a Auto
Weather CurrentWeather = None
Weather PendindWeather = None
Bool bWeaponTransitionAllowed = True
Int nEnemiesInside = 10
Bool bPlayerIsInside = True
Bool bLockedDoor = False