2021-10-05 22:15:58 +00:00
|
|
|
Scriptname _00E_Playerhousing_MannequinControl extends Actor
|
|
|
|
|
|
|
|
import utility
|
|
|
|
|
|
|
|
Actor Property PlayerREF Auto
|
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
Bool bIsInPlacementMode = False
|
|
|
|
Bool bActivationBlocked = False
|
2021-10-05 22:15:58 +00:00
|
|
|
|
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
;=====================================================================================
|
|
|
|
; EVENTS
|
|
|
|
;=====================================================================================
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
Event OnCellLoad()
|
|
|
|
If bIsInPlacementMode == False
|
|
|
|
ResetOnLoad()
|
|
|
|
EndIf
|
|
|
|
EndEvent
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
Event OnLoad()
|
|
|
|
If bIsInPlacementMode
|
|
|
|
ResetOnLoad()
|
|
|
|
EndIf
|
|
|
|
EndEvent
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
Event OnActivate(ObjectReference TriggerRef)
|
|
|
|
If TriggerRef == PlayerREF && _00E_PlayerhousingMaster.ReferenceCanBeActivated(self) && bActivationBlocked == False
|
|
|
|
bActivationBlocked = True
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
ConvertArmorSlots() ; Version update
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
OpenInventory(True)
|
|
|
|
ResetPosition()
|
|
|
|
Wait(0.1)
|
|
|
|
EnableAI(False)
|
|
|
|
|
|
|
|
bActivationBlocked = False
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
2021-10-11 18:39:58 +00:00
|
|
|
EndEvent
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
|
|
|
|
If (akBaseItem as Armor)
|
|
|
|
If TryRegisterAddedArmor(akBaseItem)
|
|
|
|
EquipItem(akBaseItem)
|
2021-10-05 22:15:58 +00:00
|
|
|
Else
|
2021-10-11 18:39:58 +00:00
|
|
|
;Turn it back if the mannequin has one of these already, or if all the slots are full.
|
|
|
|
RemoveItem(akBaseItem, aiItemCount, True, PlayerREF)
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
2021-10-11 18:39:58 +00:00
|
|
|
Else
|
|
|
|
RemoveItem(akBaseItem, aiItemCount, True, PlayerREF)
|
|
|
|
EndIf
|
|
|
|
EndEvent
|
|
|
|
|
|
|
|
Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
|
|
|
|
If (akBaseObject as Armor)
|
|
|
|
UnregisterRemovedArmor(akBaseObject)
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
2021-10-11 18:39:58 +00:00
|
|
|
EndEvent
|
2021-10-05 22:15:58 +00:00
|
|
|
|
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
;=====================================================================================
|
|
|
|
; ARMOR SLOTS TRACKING
|
|
|
|
;=====================================================================================
|
|
|
|
|
|
|
|
Form Property ArmorSlot01 Auto Hidden ; Obsolete. Left for version updates on older saves.
|
|
|
|
Form Property ArmorSlot02 Auto Hidden ; Obsolete. Left for version updates on older saves.
|
|
|
|
Form Property ArmorSlot03 Auto Hidden ; Obsolete. Left for version updates on older saves.
|
|
|
|
Form Property ArmorSlot04 Auto Hidden ; Obsolete. Left for version updates on older saves.
|
|
|
|
Form Property ArmorSlot05 Auto Hidden ; Obsolete. Left for version updates on older saves.
|
|
|
|
Form Property ArmorSlot06 Auto Hidden ; Obsolete. Left for version updates on older saves.
|
|
|
|
Form Property ArmorSlot07 Auto Hidden ; Obsolete. Left for version updates on older saves.
|
|
|
|
Form Property ArmorSlot08 Auto Hidden ; Obsolete. Left for version updates on older saves.
|
|
|
|
Form Property ArmorSlot09 Auto Hidden ; Obsolete. Left for version updates on older saves.
|
|
|
|
Form Property ArmorSlot10 Auto Hidden ; Obsolete. Left for version updates on older saves.
|
|
|
|
|
|
|
|
Form[] ArmorSlots
|
|
|
|
Bool bConvertedArmorSlots = False
|
|
|
|
|
|
|
|
Function ConvertArmorSlots()
|
|
|
|
If bConvertedArmorSlots
|
|
|
|
Return
|
|
|
|
EndIf
|
|
|
|
bConvertedArmorSlots = True
|
|
|
|
|
|
|
|
ArmorSlots = New Form[10]
|
|
|
|
|
|
|
|
Int index = _ConvertArmorSlot(0, ArmorSlot01)
|
|
|
|
index = _ConvertArmorSlot(index, ArmorSlot02)
|
|
|
|
index = _ConvertArmorSlot(index, ArmorSlot03)
|
|
|
|
index = _ConvertArmorSlot(index, ArmorSlot04)
|
|
|
|
index = _ConvertArmorSlot(index, ArmorSlot05)
|
|
|
|
index = _ConvertArmorSlot(index, ArmorSlot06)
|
|
|
|
index = _ConvertArmorSlot(index, ArmorSlot07)
|
|
|
|
index = _ConvertArmorSlot(index, ArmorSlot08)
|
|
|
|
index = _ConvertArmorSlot(index, ArmorSlot09)
|
|
|
|
index = _ConvertArmorSlot(index, ArmorSlot10)
|
|
|
|
|
|
|
|
ArmorSlot01 = None
|
|
|
|
ArmorSlot02 = None
|
|
|
|
ArmorSlot03 = None
|
|
|
|
ArmorSlot04 = None
|
|
|
|
ArmorSlot05 = None
|
|
|
|
ArmorSlot06 = None
|
|
|
|
ArmorSlot07 = None
|
|
|
|
ArmorSlot08 = None
|
|
|
|
ArmorSlot09 = None
|
|
|
|
ArmorSlot10 = None
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Int Function _ConvertArmorSlot(Int index, Form armorItem)
|
|
|
|
If armorItem && ArmorSlots.Find(armorItem) < 0
|
|
|
|
ArmorSlots[index] = armorItem
|
|
|
|
index += 1
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
Return index
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Bool Function TryRegisterAddedArmor(Form armorItem)
|
|
|
|
; First check to see if this is already in a slot
|
|
|
|
If ArmorSlots.Find(armorItem) >= 0
|
|
|
|
Return False
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
; Now find an emtpy slot to put it in, if there is one.
|
|
|
|
Int i = 0
|
|
|
|
While i < ArmorSlots.Length
|
|
|
|
If ArmorSlots[i] == None
|
|
|
|
ArmorSlots[i] = armorItem
|
|
|
|
Return True
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
i += 1
|
|
|
|
EndWhile
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
; Nope. No room left.
|
|
|
|
Return False
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function UnregisterRemovedArmor(Form armorItem)
|
|
|
|
;This loop will also clear duplicates that might have been generated.
|
|
|
|
Int i = 0
|
|
|
|
While i < ArmorSlots.Length
|
|
|
|
If ArmorSlots[i] == armorItem
|
|
|
|
ArmorSlots[i] = None
|
|
|
|
EndIf
|
|
|
|
i += 1
|
|
|
|
EndWhile
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function ReequipAllArmor()
|
|
|
|
UnequipAll()
|
|
|
|
|
|
|
|
Int i = 0
|
|
|
|
While i < ArmorSlots.Length
|
|
|
|
If ArmorSlots[i]
|
|
|
|
EquipItem(ArmorSlots[i])
|
|
|
|
EndIf
|
|
|
|
i += 1
|
|
|
|
EndWhile
|
|
|
|
EndFunction
|
2021-10-05 22:15:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
;=====================================================================================
|
2021-10-11 18:39:58 +00:00
|
|
|
; FUNCTIONS
|
2021-10-05 22:15:58 +00:00
|
|
|
;=====================================================================================
|
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
Float forceX
|
|
|
|
Float forceY
|
|
|
|
Float forceZ
|
|
|
|
Float forceAngleX
|
|
|
|
Float forceAngleY
|
|
|
|
Float forceAngleZ
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
Bool bPosisionValidated = False
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
Function ResetPosition()
|
|
|
|
If bPosisionValidated == False
|
|
|
|
bPosisionValidated = True
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
If forceX == 0 && forceY == 0 && forceZ == 0
|
|
|
|
Float fAngleZ = PlayerREF.GetAngleZ()
|
|
|
|
Float fDistanceFromPlayer = 100.0
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
forceX = PlayerREF.GetPositionX() + fDistanceFromPlayer * Math.sin(fAngleZ)
|
|
|
|
forceY = PlayerREF.GetPositionY() + fDistanceFromPlayer * Math.cos(fAngleZ)
|
|
|
|
forceZ = PlayerREF.GetPositionZ()
|
|
|
|
EndIf
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
SetPosition(forceX, forceY, forceZ)
|
|
|
|
SetAngle(forceAngleX, forceAngleY, forceAngleZ)
|
|
|
|
EndFunction
|
2021-10-05 22:15:58 +00:00
|
|
|
|
2021-10-11 18:39:58 +00:00
|
|
|
Function ResetOnLoad()
|
|
|
|
ConvertArmorSlots() ; Version update
|
|
|
|
|
|
|
|
BlockActivation()
|
|
|
|
|
|
|
|
EnableAI(True)
|
|
|
|
If bIsInPlacementMode == False
|
|
|
|
ResetPosition()
|
|
|
|
EndIf
|
|
|
|
ReequipAllArmor()
|
|
|
|
EnableAI(False)
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function StartPlacement()
|
|
|
|
bIsInPlacementMode = True
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function FinishPlacement()
|
|
|
|
bIsInPlacementMode = False
|
|
|
|
|
|
|
|
Disable()
|
|
|
|
|
|
|
|
forceX = GetPositionX()
|
|
|
|
forceY = GetPositionY()
|
|
|
|
forceZ = GetPositionZ()
|
|
|
|
forceAngleX = GetAngleX()
|
|
|
|
forceAngleY = GetAngleY()
|
|
|
|
forceAngleZ = GetAngleZ()
|
|
|
|
|
|
|
|
bPosisionValidated = True
|
|
|
|
|
|
|
|
Enable()
|
|
|
|
|
|
|
|
_00E_QuestFunctions.WaitForReferenceToLoad(self)
|
|
|
|
ResetOnLoad()
|
|
|
|
EndFunction
|