diff --git a/scripts/_00e_questfunctions.pex b/scripts/_00e_questfunctions.pex index 649f7479..b1b1366d 100644 Binary files a/scripts/_00e_questfunctions.pex and b/scripts/_00e_questfunctions.pex differ diff --git a/scripts/source/_00e_gaboff_grammophonesc.psc b/scripts/source/_00e_gaboff_grammophonesc.psc deleted file mode 100644 index beb7f698..00000000 --- a/scripts/source/_00e_gaboff_grammophonesc.psc +++ /dev/null @@ -1,132 +0,0 @@ -Scriptname _00E_Gaboff_GrammophoneSC extends ObjectReference - -Message Property _00E_Gaboff_GrammophoneMSG Auto -Message Property _00E_PlayerhousingKoppophonVolume Auto -Sound Property _00E_MUS_Special_OceansWidowM Auto -MiscObject Property Gold001 Auto -Actor Property PlayerREF Auto - -Int iSoundID = -1 -Float fVolume = 0.5 -Bool bMusicLocked = False - -Float Property MUSIC_LENGTH = 212.3 AutoReadOnly - - -;===================================================================================== -; FUNCTIONS -;===================================================================================== - -Function PlayMusic(Sound musicSound, Float fMusicLength) - If fVolume <= 0.0 || fVolume > 1.0 - fVolume = 0.5 - EndIf - RegisterForModEvent("BardsLoadGame", "OnBardsLoadGame") - iSoundID = musicSound.Play(Self) - Sound.SetInstanceVolume(iSoundID, fVolume) - RegisterForSingleUpdate(_00E_QuestFunctions.AdjustTimePeriodByEngineTimerError(fMusicLength)) - GoToState("") - _00E_PlayerhousingKoppophonVolume.Show(fVolume * 100.0) -EndFunction - -Function ChangeMusicVolume() - If fVolume >= 0.0 && fVolume < 1.0 - fVolume += 0.25 - Else ; fVolume >= 1.0 or something is wrong with fVolume - fVolume = 0.0 - EndIf - Sound.SetInstanceVolume(iSoundID, fVolume) - _00E_PlayerhousingKoppophonVolume.Show(fVolume * 100.0) -EndFunction - -Function StopMusic() - bMusicLocked = True - - GoToState("DoneCleanup") - UnregisterForModEvent("BardsLoadGame") - UnregisterForUpdate() - - If iSoundID != -1 - Sound.StopInstance(iSoundID) - iSoundID = -1 - EndIf - - bMusicLocked = False -EndFunction - -Function TryStopMusic() - If bMusicLocked == False - StopMusic() - Else - RegisterForSingleUpdate(0.5) - EndIf -EndFunction - - -;===================================================================================== -; EVENTS -;===================================================================================== - -Event OnInit() - GoToState("DoneCleanup") -EndEvent - -Event OnActivate(ObjectReference akActionRef) - If akActionRef == PlayerREF && bMusicLocked == False - bMusicLocked = True - - If iSoundID == -1 - If _00E_Gaboff_GrammophoneMSG.Show() == 0 - PlayerREF.RemoveItem(Gold001, 5) - PlayMusic(_00E_MUS_Special_OceansWidowM, MUSIC_LENGTH) - EndIf - Else - ChangeMusicVolume() - EndIf - - bMusicLocked = False - EndIf -EndEvent - -Event OnUpdate() - TryStopMusic() -EndEvent - -Event OnBardsLoadGame(string eventName, string strArg, float numArg, Form sender) - ; Player just loaded a save with the gramophone playing. The sound is dead by now. - TryStopMusic() -EndEvent - -Event OnCellAttach() - TryStopMusic() -EndEvent - -Event OnLoad() - TryStopMusic() -EndEvent - -Event OnCellDetach() - TryStopMusic() -EndEvent - -Event OnUnload() - TryStopMusic() -EndEvent - -State DoneCleanup - Event OnCellAttach() - ; Do nothing - EndEvent - - Event OnLoad() - ; Do nothing - EndEvent - - Event OnCellDetach() - ; Do nothing - EndEvent - - Event OnUnload() - ; Do nothing - EndEvent -EndState diff --git a/scripts/source/_00e_game_playerhouse_boardsc.psc b/scripts/source/_00e_game_playerhouse_boardsc.psc deleted file mode 100644 index 5297a5c8..00000000 --- a/scripts/source/_00e_game_playerhouse_boardsc.psc +++ /dev/null @@ -1,186 +0,0 @@ -scriptName _00E_Game_Playerhouse_BoardSC extends ObjectReference conditional - -;===================================================================================== -; FUNCTIONS -;===================================================================================== - -function EnableFurniture(Int iLevel) - - FadeToBlackIMOD.Apply(1.00000) - utility.Wait(2 as Float) - FadeToBlackHoldIMOD.ApplyCrossFade(1 as Float) - if iLevel == 1 - _00E_Game_Playerhouse_ArkMarket_Level01Linker.Enable() - elseIf iLevel == 2 - _00E_Game_Playerhouse_ArkMarket_Level02Linker.Enable() - elseIf iLevel == 3 - _00E_Game_Playerhouse_ArkMarket_Level03Linker.Enable() - endIf - FadeToBlackBackIMOD.ApplyCrossFade(1 as Float) - -endFunction - -function DisableFurniture() - - FadeToBlackIMOD.Apply(1.00000) - utility.Wait(2 as Float) - FadeToBlackHoldIMOD.ApplyCrossFade(1 as Float) - _00E_Game_Playerhouse_ArkMarket_Level01Linker.Disable(false) - _00E_Game_Playerhouse_ArkMarket_Level02Linker.Disable(false) - _00E_Game_Playerhouse_ArkMarket_Level03Linker.Disable(false) - FadeToBlackBackIMOD.ApplyCrossFade(1 as Float) - -endFunction - - -function OnActivate(ObjectReference akActionRef) - - ;backwards compatibility for saves prior patch 1.2.3.0 - If (_00E_Game_Playerhouse_ArkMarket_Level01Linker.IsEnabled()) - _00E_FurniturePurchased.SetValue(1) - EndIf - ;backwards compatibility for saves prior patch 1.2.3.0 - - Int iButton = _00E_Game_PlayerHouse_ArkMarket_Board.Show(0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000) - if iButton == 7 - return - elseIf iButton == 0 - - If PlayerREF.GetParentCell() == CapitalCityPlayerhouse - PlayerREF.RemoveItem(Gold001, 300) - Else - PlayerREF.RemoveItem(Gold001, 1250) - EndIf - - _00E_FurniturePurchased.SetValue(1) - self.EnableFurniture(1) - - elseIf iButton == 1 - - If PlayerREF.GetParentCell() == CapitalCityPlayerhouse - PlayerREF.RemoveItem(Gold001, 500) - Else - PlayerREF.RemoveItem(Gold001, 1500) - EndIf - - _00E_FurniturePurchased.SetValue(2) - self.EnableFurniture(2) - - elseIf iButton == 2 - - If PlayerREF.GetParentCell() == CapitalCityPlayerhouse - PlayerREF.RemoveItem(Gold001, 700) - Else - PlayerREF.RemoveItem(Gold001, 1750) - EndIf - - _00E_FurniturePurchased.SetValue(3) - self.EnableFurniture(3) - - elseif iButton == 4 - - int iButton02 = _00E_Game_PlayerHouse_RemoveFurniture.Show() - - if iButton02 == 0 - - ReturnAndRefund() - - Else - - Activate(PlayerREF) - - EndIf - - elseif iButton == 5 - - Cell cCurrentCell = Self.GetParentCell() - String sHouseName = NQ24.ChooseHouseName() - cCurrentCell.SetName(sHouseName) - - If cCurrentCell == CapitalCityPlayerhouse - Player.sHouseMarketQuarterName = sHouseName - ElseIf cCurrentCell == CapitalCityPlayerHouseUpper - Player.sHouseNobleQuarterName = sHouseName - EndIf - - elseif iButton == 6 - - _00E_PlayerhousingMaster.GetMaster().ShowExpansionBoardTutorial() - - endIf - -endFunction - -;===================================================================================== -; FUNCTIONS -;===================================================================================== - -Function ReturnAndRefund() - - DisableFurniture() - - If PlayerREF.GetParentCell() == CapitalCityPlayerhouse - - If _00E_FurniturePurchased.GetValue() == 1 - PlayerREF.AddItem(Gold001, 150) - _00E_FurniturePurchased.SetValue(0) - ElseIf _00E_FurniturePurchased.GetValue() == 2 - PlayerREF.AddItem(Gold001, 250) - _00E_FurniturePurchased.SetValue(0) - ElseIf _00E_FurniturePurchased.GetValue() == 3 - PlayerREF.AddItem(Gold001, 350) - _00E_FurniturePurchased.SetValue(0) - EndIf - - ElseIf PlayerREF.GetParentCell() == CapitalCityPlayerhouseUpper - - If _00E_FurniturePurchased.GetValue() == 1 - PlayerREF.AddItem(Gold001, 625) - _00E_FurniturePurchased.SetValue(0) - ElseIf _00E_FurniturePurchased.GetValue() == 2 - PlayerREF.AddItem(Gold001, 750) - _00E_FurniturePurchased.SetValue(0) - ElseIf _00E_FurniturePurchased.GetValue() == 3 - PlayerREF.AddItem(Gold001, 875) - _00E_FurniturePurchased.SetValue(0) - EndIf - - EndIf - -EndFunction - -;===================================================================================== -; PROPERTIES -;===================================================================================== - -Actor Property PlayerREF Auto - -Cell Property CapitalCityPlayerhouse Auto -Cell Property CapitalCityPlayerHouseUpper Auto - -GlobalVariable Property _00E_FurniturePurchased Auto - -bool Property bLevel01FurniturePurchased Auto Conditional Hidden -bool Property bLevel02FurniturePurchased Auto Conditional Hidden -bool Property bLevel03FurniturePurchased Auto Conditional Hidden - -imagespacemodifier property FadeToBlackBackIMOD auto -ObjectReference property _00E_Game_Playerhouse_ArkMarket_Level01Linker auto -message property _00E_Game_PlayerHouse_ArkMarket_Board auto -imagespacemodifier property FadeToBlackIMOD auto -Bool property __Config_bHouseHasLevel02 auto conditional -{Check this if this house has level 02 furniture designed.} -ObjectReference property _00E_Game_Playerhouse_ArkMarket_Level02Linker auto -imagespacemodifier property FadeToBlackHoldIMOD auto -Bool property __Config_bHouseHasLevel01 auto conditional -{Check this if this house has level 01 furniture designed.} -ObjectReference property _00E_Game_Playerhouse_ArkMarket_Level03Linker auto -Bool property __Config_bHouseHasLevel03 auto conditional -{Check this if this house has level 03 furniture designed.} - -MiscObject Property Gold001 Auto - -Message Property _00E_Game_PlayerHouse_RemoveFurniture Auto - -_00E_NQ24_Playerhousing_Functions Property NQ24 Auto -_00E_PlayerHousing_CellNameSC Property Player Auto diff --git a/scripts/source/_00e_placeablegrammophonplay.psc b/scripts/source/_00e_placeablegrammophonplay.psc deleted file mode 100644 index 4a428c87..00000000 --- a/scripts/source/_00e_placeablegrammophonplay.psc +++ /dev/null @@ -1,161 +0,0 @@ -Scriptname _00E_PlaceableGrammophonPlay extends ObjectReference - -Sound Property _00E_MUS_Placeable_Koppophon Auto -MusicType Property _00E_SilenceTransitionHighPriority Auto ; OBSOLETE. Left for version update on older saves. -MusicType Property _00E_SilenceKoppophon Auto -GlobalVariable Property _00E_AchievementsEnabled Auto -Message Property _00E_PlayerhousingKoppophonVolume Auto -Actor Property PlayerREF Auto - -Int playbackId = -1 -Float volume = 0.5 -Bool bDone ; Unlocked END_KOPPOPHON_01 achievement -Bool bMusicLocked = False -Bool bOldSilenceUpdated = False - -Float Property MUSIC_LENGTH = 87.2 AutoReadOnly - - -;===================================================================================== -; FUNCTIONS -;===================================================================================== - -Function StopMusic() - bMusicLocked = True - - UnregisterForModEvent("BardsLoadGame") - UnregisterForUpdate() - - If bOldSilenceUpdated == False - bOldSilenceUpdated = True - If playbackId != -1 - _00E_SilenceTransitionHighPriority.Remove() - EndIf - EndIf - - If playbackId != -1 - Sound.StopInstance(playbackId) - playbackId = -1 - EndIf - - _00E_SilenceKoppophon.Remove() - - bMusicLocked = False -EndFunction - -Function TryStopMusic() - If bMusicLocked == False - StopMusic() - Else - RegisterForSingleUpdate(0.5) - EndIf -EndFunction - -Function Cleanup() - GoToState("DoneCleanup") - TryStopMusic() -EndFunction - - -;===================================================================================== -; EVENTS -;===================================================================================== - -Event OnInit() - GoToState("DoneCleanup") -EndEvent - -Event OnActivate(ObjectReference triggerRef) - If triggerRef == PlayerREF && _00E_PlayerhousingMaster.ReferenceCanBeActivated(Self) && bMusicLocked == False - bMusicLocked = True - - If playbackId == -1 ; Start playing - bOldSilenceUpdated = True - RegisterForModEvent("BardsLoadGame", "OnBardsLoadGame") - - _00E_SilenceKoppophon.Add() - - playbackId = _00E_MUS_Placeable_Koppophon.Play(Self) - If volume <= 0.0 || volume > 1.0 - volume = 0.5 - EndIf - Sound.SetInstanceVolume(playbackId, volume) - RegisterForSingleUpdate(_00E_QuestFunctions.AdjustTimePeriodByEngineTimerError(MUSIC_LENGTH)) - - GoToState("") - - _00E_PlayerhousingKoppophonVolume.Show(volume * 100.0) - - If _00E_AchievementsEnabled.GetValueInt() == 1 && (bDone == False) - bDone = True - Game.UnlockAchievement("END_KOPPOPHON_01") - EndIf - - ElseIf bOldSilenceUpdated == False - ; Player just loaded an older save with the Koppophon playing. The sound is dead by now. - StopMusic() - - Else ; Volume control - Float fNewVolume = volume + 0.25 - If fNewVolume > 1.0 - fNewVolume = 0.0 - EndIf - - Sound.SetInstanceVolume(playbackId, fNewVolume) - If fNewVolume == 0.0 ; On mute - _00E_SilenceKoppophon.Remove() - ElseIf volume == 0.0 ; On unmute - _00E_SilenceKoppophon.Add() - EndIf - volume = fNewVolume - - _00E_PlayerhousingKoppophonVolume.Show(volume * 100.0) - - EndIf - - bMusicLocked = False - EndIf -EndEvent - -Event OnUpdate() - TryStopMusic() -EndEvent - -Event OnBardsLoadGame(string eventName, string strArg, float numArg, Form sender) - ; Player just loaded a save with the Koppophon playing. The sound is dead by now. - TryStopMusic() -EndEvent - -Event OnCellAttach() - Cleanup() -EndEvent - -Event OnLoad() - Cleanup() -EndEvent - -Event OnCellDetach() - Cleanup() -EndEvent - -Event OnUnload() - Cleanup() -EndEvent - -State DoneCleanup - Event OnCellAttach() - ; Do nothing - EndEvent - - Event OnLoad() - ; Do nothing - EndEvent - - Event OnCellDetach() - ; Do nothing - EndEvent - - Event OnUnload() - ; Do nothing - EndEvent -EndState diff --git a/scripts/source/_00e_playerhousing_furniture.psc b/scripts/source/_00e_playerhousing_furniture.psc deleted file mode 100644 index f5717f8f..00000000 --- a/scripts/source/_00e_playerhousing_furniture.psc +++ /dev/null @@ -1,48 +0,0 @@ -scriptname _00E_Playerhousing_Furniture extends ObjectReference -{A manipulatable housing object while being in the world} - -Float Property CustomDistance Auto -{ Custom distance from the player in the placemenet Move Mode } -Float Property OffsetAngleZ Auto -{ Custom offset Z rotation in the placemenet Move Mode } -Float Property OffsetPositionZ Auto -{ Custom offset Z position in the placemenet Move Mode } -Bool Property IsSetPositionIncompatible Auto -{ If the .nif of the object has a bhkCollisionObject with SET_LOCAL flag, SetPosition() or MoveTo() can easily mess this object up in the placement mode. } - -Form Property InventoryItem Auto Hidden - -_00E_Playerhousing_FurnitureItem Property furnitureItem Auto Hidden -{ OBSOLETE. Left for compatibility with older saves. } - -Form Function GetInventoryItem() - If furnitureItem ; Update from the old way of storing the base inventory item - If InventoryItem == None - InventoryItem = furnitureItem.GetBaseObject() - EndIf - furnitureItem = None - EndIf - - Return InventoryItem -EndFunction - -Function finishPlacement() - ; This function is called when the furniture object is at the right position and being placed. - - SetMotionType(Motion_Dynamic, True) - - ; in case we place a mannequin, we need to store its position - ObjectReference myObjRef = self as ObjectReference - If myObjRef as _00E_Playerhousing_MannequinControl - (myObjRef as _00E_Playerhousing_MannequinControl).FinishPlacement() - Else - BlockActivation(true) - Disable() - Utility.Wait(0.1) - Enable() - - If myObjRef as _00E_Phasmalist_Workbench - (myObjRef as _00E_Phasmalist_Workbench).FinishPlacement() - EndIf - EndIf -EndFunction diff --git a/scripts/source/_00e_playerhousing_furnitureitem.psc b/scripts/source/_00e_playerhousing_furnitureitem.psc deleted file mode 100644 index 30ea0540..00000000 --- a/scripts/source/_00e_playerhousing_furnitureitem.psc +++ /dev/null @@ -1,43 +0,0 @@ -scriptname _00E_Playerhousing_FurnitureItem extends ObjectReference -{A manipulatable housing object while being in the players inventory} - -ActorBase Property _MANNEQUIN_toCreate auto -Furniture Property _FURNITURE_toCreate auto -Container Property _CONTAINER_toCreate auto -Light Property _LIGHT_toCreate auto -MiscObject Property _MISC_toCreate Auto -Activator Property _ACTIVATOR_toCreate Auto - -_00E_PlayerhousingMaster Property master Auto - -Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) - If akNewContainer == None - If master == None - master = _00E_PlayerhousingMaster.GetMaster() - EndIf - master.playerItemDropped(Self) - EndIf -EndEvent - -_00E_Playerhousing_Furniture Function placeFurnitureAtMe() - _00E_Playerhousing_Furniture result = None - If _MANNEQUIN_toCreate - result = PlaceAtMe(_MANNEQUIN_toCreate, abForcePersist = True, abInitiallyDisabled = True) as _00E_Playerhousing_Furniture - ElseIf _FURNITURE_toCreate - result = PlaceAtMe(_FURNITURE_toCreate, abInitiallyDisabled = True) as _00E_Playerhousing_Furniture - ElseIf _CONTAINER_toCreate - result = PlaceAtMe(_CONTAINER_toCreate, abInitiallyDisabled = True) as _00E_Playerhousing_Furniture - ElseIf _LIGHT_toCreate - result = PlaceAtMe(_LIGHT_toCreate, abInitiallyDisabled = True) as _00E_Playerhousing_Furniture - ElseIf _ACTIVATOR_toCreate - result = PlaceAtMe(_ACTIVATOR_toCreate, abInitiallyDisabled = True) as _00E_Playerhousing_Furniture - ElseIf _MISC_toCreate - result = PlaceAtMe(_MISC_toCreate, abInitiallyDisabled = True) as _00E_Playerhousing_Furniture - EndIf - - If result == None - Debug.MessageBox("ERROR: *_toCreate property in playerhousingfurnitureitem is no furnitureitem, please write a bugticket") - EndIf - - Return result -EndFunction \ No newline at end of file diff --git a/scripts/source/_00e_playerhousing_lightfurniture.psc b/scripts/source/_00e_playerhousing_lightfurniture.psc deleted file mode 100644 index e61375f6..00000000 --- a/scripts/source/_00e_playerhousing_lightfurniture.psc +++ /dev/null @@ -1,23 +0,0 @@ -Scriptname _00E_Playerhousing_LightFurniture extends _00E_Playerhousing_Furniture - -Light Property LIGHT_toCreate auto -{not used due to graphic bugs} -; ObjectReference createdLight - -function finishPlacement() -{this function is called when the furniture object is at the right position and being placed; use e.g. for light} - parent.finishPlacement() - ;real light cannot be placed since it causes graphic bugs - - ;createdLight = placeAtMe(LIGHT_toCreate) - ;createdLight.setScale(0.99) -Endfunction - -;/ -Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) - if akOldContainer== None - createdLight.disable() - createdLight.delete() - Endif -Endevent -/; \ No newline at end of file diff --git a/scripts/source/_00e_playerhousing_mannequincontrol.psc b/scripts/source/_00e_playerhousing_mannequincontrol.psc deleted file mode 100644 index 8b70a7b1..00000000 --- a/scripts/source/_00e_playerhousing_mannequincontrol.psc +++ /dev/null @@ -1,231 +0,0 @@ -Scriptname _00E_Playerhousing_MannequinControl extends Actor - -import utility - -Actor Property PlayerREF Auto - -Bool bIsInPlacementMode = False -Bool bActivationBlocked = False - - -;===================================================================================== -; EVENTS -;===================================================================================== - -Event OnCellLoad() - If bIsInPlacementMode == False - ResetOnLoad() - EndIf -EndEvent - -Event OnLoad() - If bIsInPlacementMode - ResetOnLoad() - EndIf -EndEvent - -Event OnActivate(ObjectReference TriggerRef) - If TriggerRef == PlayerREF && _00E_PlayerhousingMaster.ReferenceCanBeActivated(self) && bActivationBlocked == False - bActivationBlocked = True - - ConvertArmorSlots() ; Version update - - OpenInventory(True) - ResetPosition() - Wait(0.1) - EnableAI(False) - - bActivationBlocked = False - EndIf -EndEvent - -Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) - If (akBaseItem as Armor) - If TryRegisterAddedArmor(akBaseItem) - EquipItem(akBaseItem) - Else - ;Turn it back if the mannequin has one of these already, or if all the slots are full. - RemoveItem(akBaseItem, aiItemCount, True, PlayerREF) - EndIf - Else - RemoveItem(akBaseItem, aiItemCount, True, PlayerREF) - EndIf -EndEvent - -Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) - If (akBaseObject as Armor) - UnregisterRemovedArmor(akBaseObject) - EndIf -EndEvent - - -;===================================================================================== -; 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 - - ; 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 - - -;===================================================================================== -; FUNCTIONS -;===================================================================================== - -Float forceX -Float forceY -Float forceZ -Float forceAngleX -Float forceAngleY -Float forceAngleZ - -Bool bPosisionValidated = False - -Function ResetPosition() - If bPosisionValidated == False - bPosisionValidated = True - - If forceX == 0 && forceY == 0 && forceZ == 0 - Float fAngleZ = PlayerREF.GetAngleZ() - Float fDistanceFromPlayer = 100.0 - - forceX = PlayerREF.GetPositionX() + fDistanceFromPlayer * Math.sin(fAngleZ) - forceY = PlayerREF.GetPositionY() + fDistanceFromPlayer * Math.cos(fAngleZ) - forceZ = PlayerREF.GetPositionZ() - EndIf - EndIf - - SetPosition(forceX, forceY, forceZ) - SetAngle(forceAngleX, forceAngleY, forceAngleZ) -EndFunction - -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 diff --git a/scripts/source/_00e_playerhousingcurrentomanipulate.psc b/scripts/source/_00e_playerhousingcurrentomanipulate.psc deleted file mode 100644 index ff095ced..00000000 --- a/scripts/source/_00e_playerhousingcurrentomanipulate.psc +++ /dev/null @@ -1,336 +0,0 @@ -Scriptname _00E_PlayerhousingCurrentOManipulate extends ReferenceAlias - -EffectShader Property _00E_PlayerHousingManipulationShader Auto -Sound Property UIMenuPrevNext Auto -Actor Property PlayerRef Auto - -String Property CONTROL_TURN_LEFT = "Strafe Left" AutoReadOnly -String Property CONTROL_TURN_RIGHT = "Strafe Right" AutoReadOnly -String Property CONTROL_MOVE_UP = "Forward" AutoReadOnly -String Property CONTROL_MOVE_DOWN = "Back" AutoReadOnly - -Int Property TRANSLATION_TURN_LEFT = 0 AutoReadOnly -Int Property TRANSLATION_TURN_RIGHT = 1 AutoReadOnly -Int Property TRANSLATION_MOVE_UP = 2 AutoReadOnly -Int Property TRANSLATION_MOVE_DOWN = 3 AutoReadOnly - -Int Property STATE_IDLE = 0 AutoReadOnly -Int Property STATE_UPDATING = 1 AutoReadOnly -Int Property STATE_WORKING = 2 AutoReadOnly - -Float Property ROTATION_SPEED_START = 15.0 AutoReadOnly -Float Property ROTATION_SPEED_FALLBACK = 20.0 AutoReadOnly -Float Property ROTATION_SPEED_MAX = 180.0 AutoReadOnly -Float Property ROTATION_SPEED_CHANGE_MOD = 0.25 AutoReadOnly -Float Property ROTATION_MAX = 90.0 AutoReadOnly - -Float Property MOVEMENT_SPEED_START = 10.0 AutoReadOnly -Float Property MOVEMENT_SPEED_FALLBACK = 20.0 AutoReadOnly -Float Property MOVEMENT_SPEED_MAX = 200.0 AutoReadOnly -Float Property MOVEMENT_SPEED_CHANGE_MOD = 0.25 AutoReadOnly -Float Property MOVEMENT_MAX = 100.0 AutoReadOnly - -Float Property FAST_TRANSLATION_SPEED = 1000000.0 AutoReadOnly - -Float fObjectPosX -Float fObjectPosY -Float fObjectPosZ -Float fObjectAngleX -Float fObjectAngleY -Float fObjectAngleZ -Float fPlayerPosZ -Float fTablePosZ - -Float fTranslationSpeed -Float fTranslationSpeedIncrease - -Int iWorkingState -Int iCurrentTranslation -Bool bGamepadMode -Int iWatchedKeyCode -Int iTurnLeftKey -Int iTurnRightKey -Int iMoveUpKey -Int iMoveDownKey - -Function Setup(ObjectReference curObjectRef) - ForceRefTo(curObjectRef) - - iWorkingState = STATE_IDLE - - bGamepadMode = Game.UsingGamepad() - If bGamepadMode == False - iTurnLeftKey = Input.GetMappedKey(CONTROL_TURN_LEFT, 0) - iTurnRightKey = Input.GetMappedKey(CONTROL_TURN_RIGHT, 0) - iMoveUpKey = Input.GetMappedKey(CONTROL_MOVE_UP, 0) - iMoveDownKey = Input.GetMappedKey(CONTROL_MOVE_DOWN, 0) - Else - iTurnLeftKey = 274 - iTurnRightKey = 275 - iMoveUpKey = 280 - iMoveDownKey = 281 - EndIf - - If PlayerRef == None ; Just in case - PlayerRef = Game.GetPlayer() - EndIf - - fPlayerPosZ = PlayerRef.GetPositionZ() - fTablePosZ = fPlayerPosZ + 64.0 - - GoToState("Working") - - TryRegisterForKey(iTurnLeftKey, CONTROL_TURN_LEFT) - TryRegisterForKey(iTurnRightKey, CONTROL_TURN_RIGHT) - TryRegisterForKey(iMoveUpKey, CONTROL_MOVE_UP) - TryRegisterForKey(iMoveDownKey, CONTROL_MOVE_DOWN) - - _00E_PlayerHousingManipulationShader.Play(curObjectRef) -EndFunction - -Function TryRegisterForKey(Int iKeyCode, String control) - If iKeyCode > 0 - RegisterForKey(iKeyCode) - Else - RegisterForControl(control) - EndIf -EndFunction - -Function Shutdown(Bool bRegisterNewOffsets) - GoToState("") - UnregisterForAllKeys() - UnregisterForAllControls() - UnregisterForUpdate() - - ObjectReference myRef = GetRef() - If myRef != None - _00E_PlayerHousingManipulationShader.Stop(myRef) - - While iWorkingState != STATE_IDLE && iWorkingState != STATE_WORKING - Utility.WaitMenuMode(0.05) - EndWhile - If iWorkingState == STATE_WORKING - myRef.StopTranslation() - EndIf - - If bRegisterNewOffsets - Float fNewOffsetAngleZ = myRef.GetAngleZ() - PlayerRef.GetAngleZ() - Float fNewOffsetPosZ = myRef.GetPositionZ() - PlayerRef.GetPositionZ() - (GetOwningQuest() as _00E_PlayerhousingMaster).RegisterNewHousingObjectOffsets(fNewOffsetAngleZ, fNewOffsetPosZ) - EndIf - - Clear() - EndIf -EndFunction - -State Working - Event OnKeyDown(Int iKeyCode) - TryStartTranslation(KeyCodeToTranslationMode(iKeyCode), iKeyCode) - EndEvent - - Event OnKeyUp(Int iKeyCode, Float fHoldTime) - TryStopTranslation(KeyCodeToTranslationMode(iKeyCode)) - EndEvent - - Event OnControlDown(String control) - TryStartTranslation(ControlToTranslationMode(control), 0) - EndEvent - - Event OnControlUp(String control, Float fHoldTime) - TryStopTranslation(ControlToTranslationMode(control)) - EndEvent - - Event OnUpdate() - ; OnControlUp is not always properly triggered. Maybe OnKeyUp too. The code below is a workaround for that. - ; For gamepads this failsafe is useless because Input.IsKeyPressed always returns False for controller buttons. - If iWatchedKeyCode > 0 && iWorkingState == STATE_WORKING - If Input.IsKeyPressed(iWatchedKeyCode) - RegisterForSingleUpdate(0.05) - Else - TryStopTranslation(iCurrentTranslation) - EndIf - EndIf - EndEvent - - Event OnTranslationComplete() - ; The previously started translation reached its end point - - If iWorkingState != STATE_WORKING - Return - EndIf - iWorkingState = STATE_UPDATING - - ObjectReference myRef = GetRef() - - If iWatchedKeyCode <= 0 || fTranslationSpeedIncrease < 0.0 - ; Do nothing - ElseIf iCurrentTranslation == TRANSLATION_TURN_LEFT || iCurrentTranslation == TRANSLATION_TURN_RIGHT - Float fRotationAngle = GetNextTranslationStep(ROTATION_SPEED_MAX, ROTATION_SPEED_CHANGE_MOD, ROTATION_MAX) - fObjectAngleZ = myRef.GetAngleZ() - TurnTranslate(myRef, fRotationAngle) - - iWorkingState = STATE_WORKING - Return - ElseIf iCurrentTranslation == TRANSLATION_MOVE_UP || iCurrentTranslation == TRANSLATION_MOVE_DOWN - Float fMoveZ = GetNextTranslationStep(MOVEMENT_SPEED_MAX, MOVEMENT_SPEED_CHANGE_MOD, MOVEMENT_MAX) - fObjectPosZ = myRef.GetPositionZ() - MoveTranslate(myRef, fMoveZ) - - iWorkingState = STATE_WORKING - Return - EndIf - - ; Fallback - FinalizeTranslation(myRef) - UIMenuPrevNext.Play(PlayerRef) - - iWorkingState = STATE_IDLE - EndEvent -EndState - -Int Function KeyCodeToTranslationMode(Int iKeyCode) - If iKeyCode > 0 - If iKeyCode == iTurnLeftKey - Return TRANSLATION_TURN_LEFT - ElseIf iKeyCode == iTurnRightKey - Return TRANSLATION_TURN_RIGHT - ElseIf iKeyCode == iMoveUpKey - Return TRANSLATION_MOVE_UP - ElseIf iKeyCode == iMoveDownKey - Return TRANSLATION_MOVE_DOWN - EndIf - EndIf - - Return -1 -EndFunction - -Int Function ControlToTranslationMode(String control) - If control == CONTROL_TURN_LEFT - Return TRANSLATION_TURN_LEFT - ElseIf control == CONTROL_TURN_RIGHT - Return TRANSLATION_TURN_RIGHT - ElseIf control == CONTROL_MOVE_UP - Return TRANSLATION_MOVE_UP - ElseIf control == CONTROL_MOVE_DOWN - Return TRANSLATION_MOVE_DOWN - EndIf - - Return -1 -EndFunction - -Function TryStartTranslation(Int iTranslationMode, Int iTriggerKeyCode) - If iTranslationMode < 0 || iWorkingState != STATE_IDLE - Return - EndIf - - iWorkingState = STATE_UPDATING - iCurrentTranslation = iTranslationMode - iWatchedKeyCode = iTriggerKeyCode - - ObjectReference myRef = GetRef() - - fObjectPosX = myRef.GetPositionX() - fObjectPosY = myRef.GetPositionY() - fObjectPosZ = myRef.GetPositionZ() - - fObjectAngleX = myRef.GetAngleX() - fObjectAngleY = myRef.GetAngleY() - fObjectAngleZ = myRef.GetAngleZ() - - fTranslationSpeedIncrease = 0.0 - - If iCurrentTranslation == TRANSLATION_TURN_LEFT || iCurrentTranslation == TRANSLATION_TURN_RIGHT - If iWatchedKeyCode > 0 - fTranslationSpeed = ROTATION_SPEED_START - TurnTranslate(myRef, fTranslationSpeed * ROTATION_SPEED_CHANGE_MOD) - Else - fTranslationSpeed = ROTATION_SPEED_FALLBACK - TurnTranslate(myRef, ROTATION_MAX) - EndIf - ElseIf iCurrentTranslation == TRANSLATION_MOVE_UP || iCurrentTranslation == TRANSLATION_MOVE_DOWN - If iWatchedKeyCode > 0 - fTranslationSpeed = MOVEMENT_SPEED_START - MoveTranslate(myRef, fTranslationSpeed * MOVEMENT_SPEED_CHANGE_MOD) - Else - fTranslationSpeed = MOVEMENT_SPEED_FALLBACK - MoveTranslate(myRef, MOVEMENT_MAX) - EndIf - EndIf - - If iWatchedKeyCode > 0 && bGamepadMode == False - RegisterForSingleUpdate(0.05) - EndIf - - iWorkingState = STATE_WORKING -EndFunction - -Function TryStopTranslation(Int iTranslationMode) - If iCurrentTranslation != iTranslationMode || iWorkingState != STATE_WORKING - Return - EndIf - - iWorkingState = STATE_UPDATING - - ObjectReference myRef = GetRef() - myRef.StopTranslation() - UnregisterForUpdate() - FinalizeTranslation(myRef) - - iWorkingState = STATE_IDLE -EndFunction - -Function TurnTranslate(ObjectReference myRef, Float fRotationAngle) - If iCurrentTranslation == TRANSLATION_TURN_LEFT - fObjectAngleZ -= fRotationAngle - Else - fObjectAngleZ += fRotationAngle - EndIf - myRef.TranslateTo(fObjectPosX, fObjectPosY, fObjectPosZ, fObjectAngleX, fObjectAngleY, fObjectAngleZ, FAST_TRANSLATION_SPEED, fTranslationSpeed) -EndFunction - -Function MoveTranslate(ObjectReference myRef, Float fMoveZ) - If iCurrentTranslation == TRANSLATION_MOVE_DOWN - Float fNewZ = fObjectPosZ - fMoveZ - If fObjectPosZ > fTablePosZ && fNewZ < fTablePosZ - ; A primitive "drop on the table" - fNewZ = fTablePosZ - fTranslationSpeedIncrease = -1.0 ; Stop on reaching fPlayerPosZ. - ElseIf fObjectPosZ > fPlayerPosZ && fNewZ < fPlayerPosZ - ; A primitive "drop on the floor" - fNewZ = fPlayerPosZ - fTranslationSpeedIncrease = -1.0 ; Stop on reaching fPlayerPosZ. - EndIf - fObjectPosZ = fNewZ - Else - fObjectPosZ += fMoveZ - EndIf - myRef.TranslateTo(fObjectPosX, fObjectPosY, fObjectPosZ, fObjectAngleX, fObjectAngleY, fObjectAngleZ, fTranslationSpeed, FAST_TRANSLATION_SPEED) -EndFunction - -Float Function GetNextTranslationStep(Float fSpeedMax, Float fSpeedChangeMod, Float fChangeMax) - If fTranslationSpeed < fSpeedMax - If fTranslationSpeedIncrease < 20.0 - fTranslationSpeedIncrease += 5.0 - EndIf - fTranslationSpeed += fTranslationSpeedIncrease - If fTranslationSpeed > fSpeedMax - fTranslationSpeed = fSpeedMax - EndIf - EndIf - Float fResult = fTranslationSpeed * fSpeedChangeMod - If fTranslationSpeed >= fSpeedMax || fResult > fChangeMax - Return fChangeMax - Else - Return fResult - EndIf -EndFunction - -Function FinalizeTranslation(ObjectReference myRef) - ; TranslateTo below prevents the object from twitching and becoming blurry when a translation ends - If iCurrentTranslation == TRANSLATION_TURN_LEFT || iCurrentTranslation == TRANSLATION_TURN_RIGHT - fObjectAngleZ = myRef.GetAngleZ() - ElseIf iCurrentTranslation == TRANSLATION_MOVE_UP || iCurrentTranslation == TRANSLATION_MOVE_DOWN - fObjectPosZ = myRef.GetPositionZ() - EndIf - myRef.TranslateTo(fObjectPosX, fObjectPosY, fObjectPosZ, fObjectAngleX, fObjectAngleY, fObjectAngleZ, FAST_TRANSLATION_SPEED, FAST_TRANSLATION_SPEED) -EndFunction diff --git a/scripts/source/_00e_playerhousingcurrentotranslation.psc b/scripts/source/_00e_playerhousingcurrentotranslation.psc deleted file mode 100644 index 45bac641..00000000 --- a/scripts/source/_00e_playerhousingcurrentotranslation.psc +++ /dev/null @@ -1,117 +0,0 @@ -Scriptname _00E_PlayerhousingCurrentOTranslation extends ReferenceAlias - -EffectShader Property _00E_PlayerHousingTranslationShader Auto -Actor Property PlayerRef Auto - -Bool bIsWorking = False -Bool bIsWarmingUp = False - -Float fDistance -Float fOffsetAngleZ -Float fOffsetPosZ - -Float Property ORBIT_ANGULAR_SPEED_CAP = 30.0 AutoReadOnly -Float Property FAST_TRANSLATION_SPEED = 1000000.0 AutoReadOnly - - -Function Setup(_00E_Playerhousing_Furniture furnitureRef, Bool bEnteringPlacement, Float fStoredOffsetAngleZ, Float fStoredOffsetPositionZ) - bIsWarmingUp = True - furnitureRef.Disable() - - If PlayerRef == None - PlayerRef = Game.GetPlayer() - EndIf - - fDistance = furnitureRef.CustomDistance - If fDistance <= 0.0 - fDistance = 100.0 - EndIf - - If bEnteringPlacement - fOffsetAngleZ = furnitureRef.OffsetAngleZ - fOffsetPosZ = furnitureRef.OffsetPositionZ - - If furnitureRef.IsSetPositionIncompatible == False - Float x = PlayerRef.GetPositionX() - Float y = PlayerRef.GetPositionY() - Float z = PlayerRef.GetPositionZ() - Float fAngleZ = PlayerRef.GetAngleZ() - - furnitureRef.SetPosition(x + fDistance * Math.sin(fAngleZ), y + fDistance * Math.cos(fAngleZ), z + fOffsetPosZ) - furnitureRef.SetAngle(0, 0, fAngleZ + fOffsetAngleZ) - EndIf - - ObjectReference myRef = furnitureRef as ObjectReference - If (myRef as _00E_Playerhousing_MannequinControl) - (myRef as _00E_Playerhousing_MannequinControl).StartPlacement() - ElseIf (myRef as _00E_Phasmalist_Workbench) - (myRef as _00E_Phasmalist_Workbench).StartPlacement() - EndIf - Else - fOffsetAngleZ = fStoredOffsetAngleZ - fOffsetPosZ = fStoredOffsetPositionZ - EndIf - - ForceRefTo(furnitureRef) - bIsWorking = True - furnitureRef.Enable() -EndFunction - -Function Shutdown() - bIsWorking = False - - ObjectReference myRef = GetRef() - If myRef - While bIsWarmingUp && (PlayerRef.GetParentCell() == myRef.GetParentCell()) - Utility.WaitMenuMode(0.05) - EndWhile - myRef.StopTranslation() - _00E_PlayerHousingTranslationShader.Stop(myRef) - Clear() - EndIf -EndFunction - -Event OnLoad() - ; Loop needs to be extracted from the rest of the code due to performance reasons (don't know why exactly, but defining new functions slows this down dramatically) - ObjectReference myRef = GetRef() - Float fPrevAngleZ = -1.0 - - myRef.SetMotionType(4) ; Set motion type to Motion_Keyframed. This would fix "collision phantoms" of the object while the player is moving around "dragging" it. - _00E_PlayerHousingTranslationShader.Play(myRef) - - bIsWarmingUp = False - - While bIsWorking - Float x = PlayerRef.GetPositionX() - Float y = PlayerRef.GetPositionY() - Float z = PlayerRef.GetPositionZ() - Float fAngleZ = PlayerRef.GetAngleZ() - - ; Cap the angular speed of the object's orbiting around the player at ORBIT_ANGULAR_SPEED_CAP. - ; This fixes some objects pushing the player (because they pass THROUGH the player?) on sharp camera turns. - If fPrevAngleZ >= 0.0 - Float fDelta = fAngleZ - fPrevAngleZ - If fDelta < -180.0 - fDelta += 360.0 - ElseIf fDelta > 180.0 - fDelta -= 360.0 - EndIf - If fDelta < -ORBIT_ANGULAR_SPEED_CAP - fAngleZ = fPrevAngleZ - ORBIT_ANGULAR_SPEED_CAP - If fAngleZ < 0.0 - fAngleZ += 360.0 - EndIf - ElseIf fDelta > ORBIT_ANGULAR_SPEED_CAP - fAngleZ = fPrevAngleZ + ORBIT_ANGULAR_SPEED_CAP - If fAngleZ >= 360.0 - fAngleZ -= 360.0 - EndIf - EndIf - EndIf - - If bIsWorking - myRef.TranslateTo(x + fDistance * Math.sin(fAngleZ), y + fDistance * Math.cos(fAngleZ), z + fOffsetPosZ, 0, 0, fAngleZ + fOffsetAngleZ, FAST_TRANSLATION_SPEED, FAST_TRANSLATION_SPEED) - EndIf - fPrevAngleZ = fAngleZ - EndWhile -EndEvent diff --git a/scripts/source/_00e_playerhousingmaster.psc b/scripts/source/_00e_playerhousingmaster.psc deleted file mode 100644 index bff27002..00000000 --- a/scripts/source/_00e_playerhousingmaster.psc +++ /dev/null @@ -1,554 +0,0 @@ -scriptname _00E_PlayerhousingMaster extends Quest - -Actor Property player Auto -ReferenceAlias Property currentHousingObjectInTranslation Auto -ReferenceAlias Property currentHousingObjectInManipulation Auto -Message Property _00E_Playerhousing_CannotPlaceObjectsHere Auto -Message Property _00E_Playerhousing_ContainerContentMove Auto -Message Property _00E_Playerhousing_StartTutorial Auto -Message Property _00E_Playerhousing_ExpansionBoardTutorial Auto -Message Property _00E_Playerhousing_TranslationMode Auto -Message Property _00E_Playerhousing_TranslationModeTutorial Auto -Message Property _00E_Playerhousing_TranslationModeTutorial_Gamepad Auto -Message Property _00E_Playerhousing_ManipulationMode Auto -Message Property _00E_Playerhousing_ManipulationModeTutorial Auto -Message Property _00E_Playerhousing_ManipulationModeTutorial_Gamepad Auto -Sound Property UIMenuActive Auto -GlobalVariable Property _00E_Meditate_Allowed Auto -GlobalVariable Property _00E_Phasmalist_TankMode Auto -GlobalVariable Property _00E_DisableCraftingTutorials Auto - -_00E_Playerhousing_Furniture currentHousingObject - -Bool bIsInPlacementMode = False -Bool bDisableNormalActivation = False -Bool bGamepadMode = False -Bool bDroppedFromInventory = False -Int iPickupKey - -Float fStoredOffsetAngleZ -Float fStoredOffsetPositionZ - -String Property CONTROL_ACTIVATE = "Activate" AutoReadOnly -String Property CONTROL_SHEATH = "Ready Weapon" AutoReadOnly - - -;===================================================================================== -; GLOBAL FUNCTIONS -;===================================================================================== - -_00E_PlayerhousingMaster Function GetMaster() Global - Return Game.GetFormFromFile(0x00043270, "Skyrim.esm") as _00E_PlayerhousingMaster -EndFunction - -Bool Function ReferenceCanBeActivated(ObjectReference ref) Global - If (ref as _00E_Playerhousing_Furniture) - _00E_PlayerhousingMaster master = GetMaster() - If master - Return master.IsNormalActivationEnabled() - EndIf - EndIf - - Return True -EndFunction - - -;===================================================================================== -; TUTORIALS -;===================================================================================== - -Bool bStartTutorialShown = False - -Bool bHideTranslationTutorial = False -Bool bHideTranslationTutorial_Gamepad = False -Bool bHideManipulationTutorial = False -Bool bHideManipulationTutorial_Gamepad = False - -Function ShowStartBuildModeTutorial() - If _00E_DisableCraftingTutorials.GetValueInt() == 0 && bStartTutorialShown == False - bStartTutorialShown = True - _00E_Playerhousing_StartTutorial.Show() - EndIf -EndFunction - -Function ShowExpansionBoardTutorial() - ; Called from _00E_Game_Playerhouse_BoardSC - If _00E_Playerhousing_ExpansionBoardTutorial.Show() == 1 - bHideTranslationTutorial = False - bHideTranslationTutorial_Gamepad = False - bHideManipulationTutorial = False - bHideManipulationTutorial_Gamepad = False - EndIf -EndFunction - -Bool Function _ShowPlacementModeTutorial(Message msgTutorial, Bool bHideFlag) - If bHideFlag == False - Return (msgTutorial.Show() == 1) - Else - Return bHideFlag - EndIf -EndFunction - -Function ShowTranslationModeTutorial() - If bGamepadMode - bHideTranslationTutorial_Gamepad = _ShowPlacementModeTutorial(_00E_Playerhousing_TranslationModeTutorial_Gamepad, bHideTranslationTutorial_Gamepad) - Else - bHideTranslationTutorial = _ShowPlacementModeTutorial(_00E_Playerhousing_TranslationModeTutorial, bHideTranslationTutorial) - EndIf -EndFunction - -Function ShowManipulationModeTutorial() - If bGamepadMode - bHideManipulationTutorial_Gamepad = _ShowPlacementModeTutorial(_00E_Playerhousing_ManipulationModeTutorial_Gamepad, bHideManipulationTutorial_Gamepad) - Else - bHideManipulationTutorial = _ShowPlacementModeTutorial(_00E_Playerhousing_ManipulationModeTutorial, bHideManipulationTutorial) - EndIf -EndFunction - - -;===================================================================================== -; SERVICE FUNCTIONS -;===================================================================================== - -Bool Function CanEnterPlacementMode() - Return (_00E_Meditate_Allowed.GetValue() != 0.0 && _00E_Phasmalist_TankMode.GetValue() == 0.0) -EndFunction - -Float fPlacementModeCarryWeightMod = 0.0 - -Function EnterPlacementMode() - If bIsInPlacementMode == False - bIsInPlacementMode = True - _00E_Meditate_Allowed.SetValueInt(0) - Game.SetInChargen(true, true, false) ; Forbid saving the game while placing stuff - - ; Make the player over encumbered to prevent them from the default running and in general to slow them down - fPlacementModeCarryWeightMod = Player.GetAV("CarryWeight") * 2.0 - If fPlacementModeCarryWeightMod < 1000.0 - fPlacementModeCarryWeightMod = 1000.0 - EndIf - Player.ModAV("CarryWeight", -fPlacementModeCarryWeightMod) - - bGamepadMode = Game.UsingGamepad() - If bGamepadMode == False - iPickupKey = Input.GetMappedKey(CONTROL_SHEATH, 0) - Else - iPickupKey = 277 - EndIf - EndIf -EndFunction - -Function ExitPlacementMode() - If bIsInPlacementMode - bIsInPlacementMode = False - If fPlacementModeCarryWeightMod != 0.0 - Player.ModAV("CarryWeight", fPlacementModeCarryWeightMod) - fPlacementModeCarryWeightMod = 0.0 - EndIf - Game.SetInChargen(false, true, false) ; Re-allow saving - _00E_Meditate_Allowed.SetValueInt(1) - EndIf - - currentHousingObject = None ; Prevent persistence -EndFunction - -Function PickUpHousingObject() - ; Clear currentHousingObject ASAP because of possible race conditions - _00E_Playerhousing_Furniture furnitureRef = (currentHousingObject as _00E_Playerhousing_Furniture) - currentHousingObject = None - - Form furnBaseObject = furnitureRef.GetBaseObject() - If (furnBaseObject as ActorBase) || (furnBaseObject as Container) - If furnitureRef.GetNumItems() > 0 - furnitureRef.RemoveAllItems(Player) - _00E_Playerhousing_ContainerContentMove.Show() - Else - ; Whatever... - furnitureRef.RemoveAllItems(Player) - EndIf - EndIf - Player.AddItem(furnitureRef.GetInventoryItem(), 1, False) - furnitureRef.Disable() - _00E_Phasmalist_Workbench worbenchRef = (furnitureRef as ObjectReference) as _00E_Phasmalist_Workbench - If worbenchRef - worbenchRef.OnPickUp() - EndIf - furnitureRef.Delete() -EndFunction - -Function FinishPlacingHousingObject() - ; Clear currentHousingObject ASAP because of possible race conditions - _00E_Playerhousing_Furniture furnitureRef = (currentHousingObject as _00E_Playerhousing_Furniture) - currentHousingObject = None - - Utility.Wait(0.05) ; Wait for the shaders to stop for sure - furnitureRef.finishPlacement() - PlaySwitchSound() -EndFunction - -Function PlaySwitchSound() - UIMenuActive.Play(player) -EndFunction - -Function RegisterNewHousingObjectOffsets(Float fNewOffsetAngleZ, Float fNewOffsetPositionZ) - fStoredOffsetAngleZ = fNewOffsetAngleZ - fStoredOffsetPositionZ = fNewOffsetPositionZ -EndFunction - -Function Update_209() - bStartTutorialShown = ((Self as Quest) as _00E_PlayerhousingTutorial).StartTutorialIsShown() -EndFunction - - -;===================================================================================== -; CONTROLS -;===================================================================================== - -Bool bLockActions = False -Bool bActiveActivate = False - -Function LockActions() - bLockActions = True - InterruptActivate() -EndFunction - -Function UnlockActions() - bLockActions = False - InterruptActivate() -EndFunction - -Function InterruptActivate() - If bActiveActivate - bActiveActivate = False - UnregisterForUpdate() - EndIf -EndFunction - -Function EnableBuildmodeControls() - RegisterForControl(CONTROL_ACTIVATE) - If bIsInPlacementMode && iPickupKey > 0 - RegisterForKey(iPickupKey) - EndIf - - UnlockActions() -EndFunction - -Function DisableBuildmodeControls() - LockActions() - - UnregisterForAllControls() - UnregisterForAllKeys() - UnregisterForUpdate() -EndFunction - -Event OnControlDown(String control) - If control == CONTROL_ACTIVATE - If bActiveActivate - bActiveActivate = False - bDisableNormalActivation = True - UnregisterForUpdate() - ElseIf bLockActions == False - bActiveActivate = True - bDisableNormalActivation = False - RegisterForSingleUpdate(1.1) - EndIf - EndIf -EndEvent - -Event OnControlUp(String control, Float holdTime) - If control == CONTROL_ACTIVATE - If bActiveActivate - bActiveActivate = False - UnregisterForUpdate() - If bLockActions == False - activateShortPressed() - EndIf - EndIf - EndIf -EndEvent - -Event OnUpdate() - If bActiveActivate - bActiveActivate = False - bDisableNormalActivation = True - If bLockActions == False - activateLongPressed() - EndIf - EndIf -EndEvent - -Event OnKeyDown(Int iKeyCode) - If iKeyCode == iPickupKey - If bLockActions == False - pickUpPressed() - EndIf - EndIf -EndEvent - - -;===================================================================================== -; DEFAULT STATE -;===================================================================================== - -Event OnBeginState() - ExitPlacementMode() -EndEvent - -Function playerItemDropped(_00E_Playerhousing_FurnitureItem akItemReference) - ; Called from _00E_Playerhousing_FurnitureItem on a placeable dropped from the inventory - Player.AddItem(akItemReference, 1, False) - _00E_Playerhousing_CannotPlaceObjectsHere.Show() -EndFunction - -Function activateShortPressed() - ; Process short activate press -EndFunction - -Function activateLongPressed() - ; Process long activate press -EndFunction - -Function pickUpPressed() - ; Process pick up key press -EndFunction - -Function enableBuildmode() - ; Enter the build mode when the player enters their house - ShowStartBuildModeTutorial() - GoToState("Buildmode") -EndFunction - -Function disableBuildmode() - ; Exit a build mode when the player leaves their house -EndFunction - -Bool Function IsNormalActivationEnabled() - ; The player can activate a placeable furniture normally - Return True -EndFunction - - -;===================================================================================== -; STATE Buildmode -;===================================================================================== - -STATE Buildmode - ; The player can enter the manipulation or translation mode by choosing a housing object or dropping a housing item - - Event OnBeginState() - ExitPlacementMode() - bDisableNormalActivation = True - EnableBuildmodeControls() - EndEvent - - Event OnEndState() - DisableBuildmodeControls() - EndEvent - - Function playerItemDropped(_00E_Playerhousing_FurnitureItem akItemReference) - If CanEnterPlacementMode() == False || bLockActions ; Locked by something else - Player.AddItem(akItemReference, 1, False) - Return - EndIf - LockActions() - - currentHousingObject = akItemReference.placeFurnitureAtMe() - If currentHousingObject == None - ; Some error happened - Player.AddItem(akItemReference, 1, False) - UnlockActions() - Return - EndIf - - DisableBuildmodeControls() - akItemReference.Disable() - currentHousingObject.InventoryItem = akItemReference.GetBaseObject() - akItemReference.Delete() - bDroppedFromInventory = True - GoToState("Translation") - EndFunction - - Function activateLongPressed() - LockActions() - - _00E_Playerhousing_Furniture targetRef = Game.GetCurrentCrosshairRef() as _00E_Playerhousing_Furniture - If targetRef && targetRef.IsFurnitureInUse() == False && Utility.IsInMenuMode() == False && CanEnterPlacementMode() - currentHousingObject = targetRef - GoToState("Translation") - Else - UnlockActions() - EndIf - EndFunction - - Function activateShortPressed() - ObjectReference targetRef = Game.GetCurrentCrosshairRef() - If (targetRef as _00E_Playerhousing_Furniture) && (bLockActions == False) - If (targetRef as _00E_Playerhousing_FurnitureItem) - ; Activate() would mean "Take" for this misc. object, so do nothing - ElseIf (targetRef as _00E_Theriantrophist_BlockCraftingSC) || (targetRef as _00E_Playerhousing_MannequinControl) || (targetRef as _00E_BedScript) || (targetRef as _00E_Phasmalist_Workbench) || (targetRef as _00E_PlaceableGrammophonPlay) - ; These objects do activation themselves in OnActivate event - Else - targetRef.Activate(player, true) - EndIf - EndIf - EndFunction - - Function enableBuildmode() - ; Do nothing - EndFunction - - Function disableBuildmode() - GoToState("") - EndFunction - - Bool Function IsNormalActivationEnabled() - Return ((bDisableNormalActivation == False) && (bLockActions == False)) - EndFunction - -ENDSTATE - - -;===================================================================================== -; STATE Translation -;===================================================================================== - -STATE Translation - ; The selected housing object is moved with the player - - Event OnBeginState() - Bool bEnteringPlacement = (bIsInPlacementMode == False) - - Game.DisablePlayerControls(abMovement = false, abFighting = true, abCamSwitch = false, abLooking = false, abSneaking = false, abMenu = true, abActivate = true) - EnterPlacementMode() - - If bEnteringPlacement && bDroppedFromInventory == False - ObjectReference housingObjRef = currentHousingObject as ObjectReference - If (housingObjRef as _00E_PlaceableGrammophonPlay) - (housingObjRef as _00E_PlaceableGrammophonPlay).StopMusic() - EndIf - EndIf - - If bDroppedFromInventory == False - PlaySwitchSound() - Else - bDroppedFromInventory = False - EndIf - - _00E_Playerhousing_TranslationMode.Show() - - (currentHousingObjectInTranslation as _00E_PlayerhousingCurrentOTranslation).Setup(currentHousingObject, bEnteringPlacement, fStoredOffsetAngleZ, fStoredOffsetPositionZ) - - ShowTranslationModeTutorial() - - EnableBuildmodeControls() - EndEvent - - Event OnEndState() - Game.EnablePlayerControls(abMovement = true, abFighting = true, abCamSwitch = true, abLooking = true, abSneaking = true, abMenu = true, abActivate = true) - EndEvent - - Function activateShortPressed() - DisableBuildmodeControls() - (currentHousingObjectInTranslation as _00E_PlayerhousingCurrentOTranslation).Shutdown() - GoToState("Manipulation") - EndFunction - - Function activateLongPressed() - DisableBuildmodeControls() - (currentHousingObjectInTranslation as _00E_PlayerhousingCurrentOTranslation).Shutdown() - FinishPlacingHousingObject() - GoToState("Buildmode") - EndFunction - - Function pickUpPressed() - DisableBuildmodeControls() - (currentHousingObjectInTranslation as _00E_PlayerhousingCurrentOTranslation).Shutdown() - PickUpHousingObject() - GoToState("Buildmode") - EndFunction - - Function enableBuildmode() - ; Do nothing - EndFunction - - Function disableBuildmode() - DisableBuildmodeControls() - (currentHousingObjectInTranslation as _00E_PlayerhousingCurrentOTranslation).Shutdown() - If currentHousingObject - PickUpHousingObject() - EndIf - GoToState("") - EndFunction - - Bool Function IsNormalActivationEnabled() - Return False - EndFunction - -ENDSTATE - - -;===================================================================================== -; STATE Manipulation -;===================================================================================== - -STATE Manipulation - ; The player can change orientation or altitude of the selected housing object by using the keys - - Event OnBeginState() - Game.DisablePlayerControls(abMovement = false, abFighting = true, abCamSwitch = false, abLooking = false, abSneaking = false, abMenu = true, abActivate = true) - Game.SetPlayerAIDriven(True) - - PlaySwitchSound() - - _00E_Playerhousing_ManipulationMode.Show() - - (currentHousingObjectInManipulation as _00E_PlayerhousingCurrentOManipulate).Setup(currentHousingObject) - - ShowManipulationModeTutorial() - - EnableBuildmodeControls() - EndEvent - - Event OnEndState() - Game.SetPlayerAIDriven(False) - Game.EnablePlayerControls(abMovement = true, abFighting = true, abCamSwitch = true, abLooking = true, abSneaking = true, abMenu = true, abActivate = true) - EndEvent - - Function activateShortPressed() - DisableBuildmodeControls() - (currentHousingObjectInManipulation as _00E_PlayerhousingCurrentOManipulate).Shutdown(True) - GoToState("Translation") - EndFunction - - Function activateLongPressed() - DisableBuildmodeControls() - (currentHousingObjectInManipulation as _00E_PlayerhousingCurrentOManipulate).Shutdown(False) - FinishPlacingHousingObject() - GoToState("Buildmode") - EndFunction - - Function pickUpPressed() - DisableBuildmodeControls() - (currentHousingObjectInManipulation as _00E_PlayerhousingCurrentOManipulate).Shutdown(False) - PickUpHousingObject() - GoToState("Buildmode") - EndFunction - - Function enableBuildmode() - ; Do nothing - EndFunction - - Function disableBuildmode() - DisableBuildmodeControls() - (currentHousingObjectInManipulation as _00E_PlayerhousingCurrentOManipulate).Shutdown(False) - If currentHousingObject - PickUpHousingObject() - EndIf - GoToState("") - EndFunction - - Bool Function IsNormalActivationEnabled() - Return False - EndFunction - -ENDSTATE diff --git a/scripts/source/_00e_playerhousingtutorial.psc b/scripts/source/_00e_playerhousingtutorial.psc deleted file mode 100644 index 308e38f8..00000000 --- a/scripts/source/_00e_playerhousingtutorial.psc +++ /dev/null @@ -1,14 +0,0 @@ -Scriptname _00E_PlayerhousingTutorial extends Quest -{ OBSOLETE. Left for version update. } - -Bool Function StartTutorialIsShown() - Return False -EndFunction - -STATE NoTutorial - - Bool Function StartTutorialIsShown() - Return True - EndFunction - -Endstate diff --git a/scripts/source/_00e_playersetupscript.psc b/scripts/source/_00e_playersetupscript.psc deleted file mode 100644 index 65452046..00000000 --- a/scripts/source/_00e_playersetupscript.psc +++ /dev/null @@ -1,663 +0,0 @@ -Scriptname _00E_PlayerSetUpScript extends ObjectReference -{Initializes all the necessary Quests, maintains the player, contains various OnPlayerLoadGame() failsafes} - -Float Property CURRENT_PATCH_VERSION = 2.09 AutoReadOnly - - -;===================================================================================== -; EVENTS -;===================================================================================== - -Event OnInit() - - ; needs the IsInMenuMode() check to prevent stuck messages when FS is not loaded - While Utility.IsInMenuMode() - Utility.WaitMenuMode(0.1) - EndWhile - - CheckIfForgottenStoriesIsLoaded() - - If self == (PlayerREF as ObjectReference) - - If fPatchVersion == 0.00 - fPatchVersion = CURRENT_PATCH_VERSION - EndIf - - GoToState("RealPlayer") - PlayerREF.SetActorValue("speedMult", 95) - PlayerREF.SetActorValue("Healrate", 0) - - SetAmountAutosaves() - - EnableDisableKillmove() - - AddPerks() - - DisableRegularWaiting() - StartQuests(QuestsToStart) - - EndIf - -EndEvent - -Event OnPlayerLoadGame() - If self == (PlayerREF as ObjectReference) ; A check just in case. Most likely this condition is always True - CheckIfForgottenStoriesIsLoaded() - Maintenance() - If GetState() != "RealPlayer" ; Post-1.2.5.0 version update - GoToState("RealPlayer") - EndIf - EndIf -EndEvent - -State RealPlayer - - ;/ Event OnBeginState() - Debug.Trace(self + ": OnBeginState RealPlayer") - EndEvent /; - -EndState - - -;===================================================================================== -; FUNCTIONS -;===================================================================================== - -Function CheckIfForgottenStoriesIsLoaded() - - ; function that quits back to the main menu when the Enderal - Forgotten Stories.esm is not not being added to the plugins.txt - ; and hence not being loaded in-game. Unknown reason, probably write protection issues - - If Game.GetModByName("Enderal - Forgotten Stories.esm") == 255 - bFSWasNotLoadedBefore = true - _00E_Game_ForgottenStoriesNotLoaded.Show() - Game.QuitToMainMenu() - Else - If bFSWasNotLoadedBefore == true - AddPerks() - If FSQuestsToStartFailsafePatch1560 == None - FSQuestsToStartFailsafePatch1560 = Game.GetFormFromFile(0x0102F4B0, "Enderal - Forgotten Stories.esm") as FormList - EndIf - StartQuests(FSQuestsToStartFailsafePatch1560) - bFSWasNotLoadedBefore = false - EndIf - EndIf - -EndFunction - -;===================================================================================== -; 1.5.6.0 -;===================================================================================== - -Function ResetFSNQR05Temple() - - ; resets the cells which is needed due to the fixes on enemies and ambushes in patch 1.5.6.0 - Quest FS_NQR05 = Game.GetFormFromFile(0x000438D2,"Skyrim.esm") as Quest - Cell FS_NQR05_Temple_02_New = Game.GetFormFromFile(0x00045101,"Skyrim.esm") as Cell - If FS_NQR05.GetStage() < 165 - FS_NQR05_Temple_02_New.Reset() - EndIf - -EndFunction - -;===================================================================================== -; 1.5.7.0 -;===================================================================================== - -Function CleanMQ12bGhostFlags() - - ; cleans old ghost flags on certain NPCs after the siege when patch 1.5.7.0 is applied - ; only needed once, since it won't happen anymore for everyone with a save before the siege - _00E_MQ12b_Functions MQ12bFunctions = Game.GetFormFromFile(0x0002EBAD,"Skyrim.esm") as _00E_MQ12b_Functions - MQ12bFunctions.OldRemoveGhostFlag() - -EndFunction - -;===================================================================================== -; 1.5.8.0 -;===================================================================================== - -Function ResetAuroraOnLoad() - ; resets Aurora if she was stuck during the ritual scene due to the gamehour change while she was in the smoking animation - _00E_FS_NQ07_Functions FS_NQ07Functions = Game.GetFormFromFile(0x0101CA09,"Enderal - Forgotten Stories.esm") as _00E_FS_NQ07_Functions - FS_NQ07Functions.ResetAurora() -EndFunction - -Function DisableMQ12bPanicTriggerbox() - ; disables MQ12b_SC3_PanicTriggerboxREF when patch 1.5.8.0 is applied - _00E_MQ12b_Functions MQ12bFunctions = Game.GetFormFromFile(0x0002EBAD,"Skyrim.esm") as _00E_MQ12b_Functions - If MQ12bFunctions.IsCompleted() - MQ12bFunctions.DisablePanicTriggerbox() - EndIf -EndFunction - -Function ReAddDarkKeeperAffinity() - - ; Dark Keeper Affinity Update - Spell _00E_Affinity_AbDarkKeeper = Game.GetFormFromFile(0x00143340,"Skyrim.esm") as Spell - If PlayerREF.HasSpell(_00E_Affinity_AbDarkKeeper) - PlayerREF.RemoveSpell(_00E_Affinity_AbDarkKeeper) - Utility.Wait(1) - PlayerREF.AddSpell(_00E_Affinity_AbDarkKeeper, false) - EndIf - -EndFunction - -Function ReAddFuryDrivenPerk() - - ; Fury Driven ability update - Spell abFuryDriven = Game.GetFormFromFile(0x000855CE, "Skyrim.esm") as Spell - If PlayerREF.HasSpell(abFuryDriven) - PlayerREF.RemoveSpell(abFuryDriven) - Utility.Wait(1) - PlayerREF.AddSpell(abFuryDriven, False) - EndIf - -EndFunction - -Function UpdateLivingTempleTrigger() - - ; Living Temple's ambush trigger update - ObjectReference triggerRef = Game.GetFormFromFile(0x000C6766, "Skyrim.esm") as ObjectReference - (triggerRef as defaultActivateSelf).playerAndAlliesOnly = True - -EndFunction - -Function UpdateMQ11a() - - ; MQ11a update - ObjectReference portcullisRef = Game.GetFormFromFile(0x000E1D1F, "Skyrim.esm") as ObjectReference - Quest MQ11a = Game.GetFormFromFile(0x0002EBA9, "Skyrim.esm") as Quest - If (MQ11a.GetStage() <= 125) && (portcullisRef.Is3DLoaded() == False) - (portcullisRef as _00E_DUNGate01Script).isOpen = False - EndIf - - If MQ11a.IsRunning() && (MQ11a.IsCompleted() == False) - (MQ11a as _00E_MQ11a_Functions).UpdateCaliaAliasScriptState() - EndIf - - ObjectReference NQ34_EnableMarkerREF = Game.GetFormFromFile(0x000480E8, "Skyrim.esm") as ObjectReference - If MQ11a.GetStage() >= 45 - NQ34_EnableMarkerREF.Enable() - EndIf - - Actor NQ34_WildMageREF = Game.GetFormFromFile(0x00141F00, "Skyrim.esm") as Actor - Quest NQ34 = Game.GetFormFromFile(0x00020A12, "Skyrim.esm") as Quest - If NQ34.GetStage() == 15 || NQ34.GetStage() == 20 - NQ34_WildMageREF.Enable() - EndIf - - If NQ34_WildMageREF.IsDead() && NQ34.GetStage() == 15 - NQ34.SetStage(20) - EndIf - -EndFunction - -Function AddPerks() - - ; adds the new Balancing perks for alchemy potions to the player, this is needed because of the changes with the Lycantroph - PlayerREF.AddPerk(_00E_FS_Alchemy_BalancingPerk) - PlayerREF.AddPerk(_00E_FS_Alchemy_BalancingPerk_RestorePotions) - -EndFunction - -Function DisableRegularWaiting() -{Disables regular waiting by adding the no-wait ability} - - PlayerREF.AddSpell(_00E_AbBlockWaiting, False) - -EndFunction - -Function StartQuests(Formlist QuestList) - - ; starts all quests that are in the formlist - Int iIndex = QuestList.GetSize() - While iIndex - iIndex -= 1 - Quest kQuest = QuestList.GetAt(iIndex) as Quest - kQuest.Start() - endwhile - -EndFunction - -;===================================================================================== -; 1.6.0.0 -;===================================================================================== - -Function UpdatePhasmalistContainer() - - ObjectReference Phasmalist_ApparationInventory_Bandit_Tier4 = Game.GetFormFromFile(0x0101E99B, "Enderal - Forgotten Stories.esm") as ObjectReference - ObjectReference Phasmalist_ApparationInventory_Archer_Tier5 = Game.GetFormFromFile(0x0101E9CA, "Enderal - Forgotten Stories.esm") as ObjectReference - Armor _00E_Phasmalist_Trinket_Bandit_Tier4 = Game.GetFormFromFile(0x0101E9A6, "Enderal - Forgotten Stories.esm") as Armor - Armor _00E_Phasmalist_Trinket_Archer_Tier5 = Game.GetFormFromFile(0x0101E9D4, "Enderal - Forgotten Stories.esm") as Armor - - _00E_Phasmalist_ApparationSC _36E_Phasmalist_Apparation_Hybrid_Tier4 = Game.GetFormFromFile(0x01025309, "Enderal - Forgotten Stories.esm") as _00E_Phasmalist_ApparationSC - _36E_Phasmalist_Apparation_Hybrid_Tier4.inventoryContainer = Phasmalist_ApparationInventory_Bandit_Tier4 - - If (PlayerREF.GetItemCount(_00E_Phasmalist_Trinket_Bandit_Tier4) > 0 && PlayerREF.GetItemCount(_00E_Phasmalist_Trinket_Archer_Tier5) == 0) - Phasmalist_ApparationInventory_Archer_Tier5.RemoveAllItems(Phasmalist_ApparationInventory_Bandit_Tier4, false, true) - EndIf - -EndFunction - -Function UpdatePassengerBookAtShipwreck() - - _00E_FS_NQ02_Functions FS_NQ02_Functions = (Game.GetFormFromFile(0x000438AC, "Skyrim.esm") as Quest) as _00E_FS_NQ02_Functions - FS_NQ02_Functions.UpdatePassengerBook() - -EndFunction - -Function ResetMQ02Riddle() - - GlobalVariable _00E_MQ02Riddle = Game.GetFormFromFile(0x00074B07, "Skyrim.esm") as GlobalVariable - - If _00E_MQ02Riddle.GetValueInt() > 0 - _00E_MQ02_Functions MQ02Functions = Game.GetFormFromFile(0x0002EBA1, "Skyrim.esm") as _00E_MQ02_Functions - MQ02Functions.ResetRiddle() - EndIf - -EndFunction - - -;===================================================================================== -; 1.6.1.0 -;===================================================================================== - - -Function UpdateMQ02() - _00E_MQ02_Functions MQ02Functions = Game.GetFormFromFile(0x0002EBA1, "Skyrim.esm") as _00E_MQ02_Functions - Int mq02stage = MQ02Functions.GetStage() - If mq02stage >= 138 && mq02stage < 170 - MQ02Functions.MQ02_TripToArkEnableMarker.EnableNoWait() - EndIf -EndFunction - - -;===================================================================================== -; 1.6.2.0 -;===================================================================================== - - -Function UpdateItemHandler() - - Cell ClassMenue = Game.GetFormFromFile(0x000A7FBC, "Skyrim.esm") as Cell - - If PlayerREF.GetParentCell() == ClassMenue - Quest ClassMenuItemHandler = Game.GetFormFromFile(0x00048442, "Skyrim.esm") as Quest - ReferenceAlias Player = ClassMenuItemHandler.GetAliasByName("Player") as ReferenceAlias - Player.ForceRefTo(PlayerREF) - EndIf - -EndFunction - - -;===================================================================================== -; 2.0.6 -;===================================================================================== - -Function UpdateMQ12b_206() - _00E_MQ12b_Functions MQ12bFunctions = Game.GetFormFromFile(0x0002EBAD, "Skyrim.esm") as _00E_MQ12b_Functions - Quest MQ15 = Game.GetFormFromFile(0x0002EBB0, "Skyrim.esm") as Quest - If MQ12bFunctions.GetStage() >= 135 && MQ15.GetStage() < 5 - MQ12bFunctions.OldReenableDisabledNPC() - EndIf -EndFunction - - -;===================================================================================== -; 2.0.8 -;===================================================================================== - -Function Update_208() - ; Obsolete abilities cleanup - _00E_FS_NQ07_Functions FS_NQ07_Quest = Game.GetFormFromFile(0x0001CA09, "Enderal - Forgotten Stories.esm") as _00E_FS_NQ07_Functions - Int iFS_NQ07Stage = FS_NQ07_Quest.GetStage() - If iFS_NQ07Stage >= 5 && iFS_NQ07Stage < 410 - FS_NQ07_Quest.UpdateAarosCarryTraySpell() - Else - RemoveObsoleteSpell(0x0009A893, "Skyrim.esm", 0x000F649A, "Skyrim.esm") - EndIf - - RemoveObsoleteSpell(0x0010D339, "Skyrim.esm", 0x000F649A, "Skyrim.esm") - RemoveObsoleteSpell(0x0006FFAF, "Skyrim.esm", 0x000F6498, "Skyrim.esm") - RemoveObsoleteSpell(0x000F64A0, "Skyrim.esm", 0x000F6498, "Skyrim.esm") - - ; Refill _00E_AnimTest_SC package arrays where needed - FillAnimTestPackages(0x00137889, "Skyrim.esm", 0x00070657, "Skyrim.esm") - FillAnimTestPackages(0x0013788A, "Skyrim.esm", 0x00070657, "Skyrim.esm") - FillAnimTestPackages(0x0013789F, "Skyrim.esm", 0x00070657, "Skyrim.esm") - FillAnimTestPackages(0x001378A2, "Skyrim.esm", 0x00070657, "Skyrim.esm") - FillAnimTestPackages(0x001378AA, "Skyrim.esm", 0x00070657, "Skyrim.esm") - FillAnimTestPackages(0x001378AB, "Skyrim.esm", 0x00070657, "Skyrim.esm") - FillAnimTestPackages(0x00147E12, "Skyrim.esm", 0x00070657, "Skyrim.esm") - FillAnimTestPackages(0x00147E14, "Skyrim.esm", 0x00070657, "Skyrim.esm") - - FillAnimTestPackages(0x0010D336, "Skyrim.esm", 0x00070645, "Skyrim.esm") - FillAnimTestPackages(0x0010D33B, "Skyrim.esm", 0x00070645, "Skyrim.esm") - FillAnimTestPackages(0x00147DEA, "Skyrim.esm", 0x00070645, "Skyrim.esm") - FillAnimTestPackages(0x00147E37, "Skyrim.esm", 0x00070645, "Skyrim.esm") - - ; "Gypsy minstrels" update - Keyword performSpotKwd = Game.GetFormFromFile(0x000FB905, "Skyrim.esm") as Keyword - (Game.GetFormFromFile(0x00044EBC, "Skyrim.esm") as _00E_BardPlayInstrumentScript).LinkedPlayMarkerKeyword = performSpotKwd - - (Game.GetFormFromFile(0x00046D79, "Skyrim.esm") as _00E_GypsyMinstrelsControlScript).UpdateWaypoint() -EndFunction - -Function RemoveObsoleteSpell(Int idNPC, String esmNPC, Int idSpell, String esmSpell) - Spell obsoleteSpell = Game.GetFormFromFile(idSpell, esmSpell) as Spell - (Game.GetFormFromFile(idNPC, esmNPC) as Actor).RemoveSpell(obsoleteSpell) -EndFunction - -Function FillAnimTestPackages(Int idNPC, String esmNPC, Int idPackage, String esmPackage) - Package newPackage = Game.GetFormFromFile(idPackage, esmPackage) as Package - (Game.GetFormFromFile(idNPC, esmNPC) as _00E_AnimTest_SC).UpdateFillPackages(newPackage) -EndFunction - - -;===================================================================================== -; 2.0.9 -;===================================================================================== - -Function Update_209() - Spell abSoulcaller = Game.GetFormFromFile(0x002F0EA, "Enderal - Forgotten Stories.esm") as Spell - If PlayerREF.HasSpell(abSoulcaller) - PlayerREF.RemoveSpell(abSoulcaller) - Utility.Wait(1) - PlayerREF.AddSpell(abSoulcaller, False) - EndIf - - Perk perkBloodlust = Game.GetFormFromFile(0x00069D38, "Skyrim.esm") as Perk - _ResetPerk(perkBloodlust) - - _00E_PlayerhousingMaster.GetMaster().Update_209() -EndFunction - - -;===================================================================================== -; ALL UPDATES -;===================================================================================== - -Function EnableDisableKillmove() - - ; it seems like that this ini setting does not do stuff by itself (or it is bugged) - ; therefore we need to read it from the file and change the global with which the killmoves are conditioned - If (Utility.GetINIBool("bVATSDisable:VATS") == 1) - KillMove.SetValueInt(0) - ElseIf (Utility.GetINIBool("bVATSDisable:VATS") == 0) - KillMove.SetValueInt(1) - EndIf - -EndFunction - -Function SetAmountAutosaves() - - ; increases amount of autosaves created from 3 to 5 without editing the ini files - ; new default ini files already have set the int to 5 - If Utility.GetINIInt("iAutoSaveCount:SaveGame") == 3 - Utility.SetINIInt("iAutoSaveCount:SaveGame", 5) - EndIf - -EndFunction - -Function SetAutoSaveInterval() - - ; updates the autosave interval - _00E_AutoSaveSystem_Functions AutoSaveSystem_Functions = Game.GetFormFromFile(0x00048141, "Skyrim.esm") as _00E_AutoSaveSystem_Functions - AutoSaveSystem_Functions.UpdateAutoSaveInterval() - -EndFunction - -Function FailsafeMQ05PrologueAliases() - - ; failsafe for issue 1536, fills empty aliases - If MQ05PrologueFunctions == None - MQ05PrologueFunctions = Game.GetFormFromFile(0x00033A5B, "Skyrim.esm") as _00E_MQ05Prologue_Functions - EndIf - MQ05PrologueFunctions.FillEmptyAliasesFailsafe() - -EndFunction - -Function RefreshMountNamesOnLoad() - - _00E_NQ06_Functions NQ06Functions = Game.GetFormFromFile(0x000725BA,"Skyrim.esm") as _00E_NQ06_Functions - NQ06Functions.RefreshNamesOnSaveLoad() - -EndFunction - -Function _ResetPerk(Perk p) - If PlayerREF.HasPerk(p) - PlayerREF.RemovePerk(p) - PlayerREF.AddPerk(p) - EndIf -EndFunction - -Function ResetArmorWeightPerks() - - ; Perks modifying armor weights need some push on each game load to work. - ; The push is needed only if the player is over-encumbered on game load. - ; If the player is not over-encumbered, the push is not needed because checking the inventory, picking up items, sheathing/drawing a weapon will reset the perks anyway. - If PlayerREF.IsOverEncumbered() - _ResetPerk(_00E_Class_Keeper_P05_C_Conditioning) - _ResetPerk(_00E_Class_Vagrant_P05_B_Lightweight) - EndIf - -EndFunction - -Function FixMoreAffinitiesMod() -{Fixes "More Affinites" mod missing properties in the Levelsystem scripts} - - _00E_QuestFunctions QuestFunctionsScript = (Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") as Quest) as _00E_QuestFunctions - If QuestFunctionsScript._00E_RemoveAllItems_TrashContainer == NONE - - Debug.Messagebox("Found broken scripts caused by mod >>More Affinities<<. Press OK to fix scripts.") - _00E_ConfigMenu ConfigMenuScript = (Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") as Quest) as _00E_ConfigMenu - ConfigMenuScript.controlQuest = (Game.GetFormFromFile(0x0101EC71, "Enderal - Forgotten Stories.esm") as Quest) as _FS_Phasmalist_ControlQuest - ConfigMenuScript._00E_ConfigMenu_DisableCraftingTutorials = Game.GetFormFromFile(0x00046D8E, "Skyrim.esm") as Message - ConfigMenuScript._00E_ConfigMenu_DisableMenuTutorials = Game.GetFormFromFile(0x00046D8A, "Skyrim.esm") as Message - ConfigMenuScript._00E_ConfigMenu_DisableOtherTutorials = Game.GetFormFromFile(0x00046D8F, "Skyrim.esm") as Message - ConfigMenuScript._00E_ConfigMenu_DisableQuestTutorials = Game.GetFormFromFile(0x00046D8C, "Skyrim.esm") as Message - ConfigMenuScript._00E_ConfigMenu_DisableReadAloudBooks = Game.GetFormFromFile(0x0102E982, "Enderal - Forgotten Stories.esm") as Message - ConfigMenuScript._00E_ConfigMenu_DisableSkillTutorials = Game.GetFormFromFile(0x00046D8D, "Skyrim.esm") as Message - ConfigMenuScript._00E_ConfigMenu_GameplayOptions = Game.GetFormFromFile(0x0102F1BC, "Enderal - Forgotten Stories.esm") as Message - ConfigMenuScript._00E_ConfigMenu_Meditate = Game.GetFormFromFile(0x00046D98, "Skyrim.esm") as Message - ConfigMenuScript._00E_ConfigMenu_OtherOptions = Game.GetFormFromFile(0x00046D89, "Skyrim.esm") as Message - ConfigMenuScript._00E_ConfigMenu_VideoSkip = Game.GetFormFromFile(0x0102E983, "Enderal - Forgotten Stories.esm") as Message - ConfigMenuScript._00E_DisableCraftingTutorials = Game.GetFormFromFile(0x00046D90, "Skyrim.esm") as GlobalVariable - ConfigMenuScript._00E_DisableMenuTutorials = Game.GetFormFromFile(0x00046D8B, "Skyrim.esm") as GlobalVariable - ConfigMenuScript._00E_DisableOtherTutorials = Game.GetFormFromFile(0x00046D93, "Skyrim.esm") as GlobalVariable - ConfigMenuScript._00E_DisableQuestTutorials = Game.GetFormFromFile(0x00046D92, "Skyrim.esm") as GlobalVariable - ConfigMenuScript._00E_DisableReadAloudBooks = Game.GetFormFromFile(0x0102E984, "Enderal - Forgotten Stories.esm") as GlobalVariable - ConfigMenuScript._00E_DisableSkillTutorials = Game.GetFormFromFile(0x00046D91, "Skyrim.esm") as GlobalVariable - ConfigMenuScript._00E_FS_ConfigMenu_Mount_Teleport = Game.GetFormFromFile(0x0102F1B9, "Enderal - Forgotten Stories.esm") as Message - ConfigMenuScript._00E_FS_ConfigMenu_Phasmalist_Teleport = Game.GetFormFromFile(0x0101F2B6, "Enderal - Forgotten Stories.esm") as Message - ConfigMenuScript._00E_FS_IsForgottenStoriesActivated = Game.GetFormFromFile(0x0004320E, "Skyrim.esm") as GlobalVariable - ConfigMenuScript._00E_HorseFlute_New = ((Game.GetFormFromFile(0x000725BA, "Skyrim.esm") as Quest).GetAliasByName("HorseFlute")) as _00E_Horseflute_SC - ConfigMenuScript._00E_VideoSkip = Game.GetFormFromFile(0x0102E985, "Enderal - Forgotten Stories.esm") as GlobalVariable - - - QuestFunctionsScript.BastionPerks = Game.GetFormFromFile(0x0006686B, "Skyrim.esm") as Formlist - QuestFunctionsScript.DerwishPerks = Game.GetFormFromFile(0x0006686D, "Skyrim.esm") as Formlist - QuestFunctionsScript.ElementalismPerks = Game.GetFormFromFile(0x00066875, "Skyrim.esm") as Formlist - QuestFunctionsScript.EspionagePerks = Game.GetFormFromFile(0x00066889, "Skyrim.esm") as Formlist - QuestFunctionsScript.GameHour = Game.GetFormFromFile(0x00000038, "Skyrim.esm") as GlobalVariable - QuestFunctionsScript.Gold001 = Game.GetFormFromFile(0x0000000f, "Skyrim.esm") as MiscObject - QuestFunctionsScript.LifeAndDeathPerks = Game.GetFormFromFile(0x00066873, "Skyrim.esm") as Formlist - QuestFunctionsScript.MAGIllusionCharm = Game.GetFormFromFile(0x00075805, "Skyrim.esm") as Sound - QuestFunctionsScript.ManipulationPerks = Game.GetFormFromFile(0x0006686A, "Skyrim.esm") as Formlist - QuestFunctionsScript.PlayerSkillMenu = ((Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") as Quest).GetAliasByName("Player") as Alias) as _00E_Game_SkillmenuSC - QuestFunctionsScript.RagePerks = Game.GetFormFromFile(0x00066887, "Skyrim.esm") as Formlist - QuestFunctionsScript.SympathyEsme = Game.GetFormFromFile(0x0102A498, "Enderal - Forgotten Stories.esm") as GlobalVariable - QuestFunctionsScript.TrickeryPerks = Game.GetFormFromFile(0x0006687F, "Skyrim.esm") as Formlist - QuestFunctionsScript.VagabondPerks = Game.GetFormFromFile(0x00066877, "Skyrim.esm") as Formlist - QuestFunctionsScript._00E_AchievementsEnabled = Game.GetFormFromFile(0x00046F83, "Skyrim.esm") as GlobalVariable - QuestFunctionsScript._00E_AllAmmos = Game.GetFormFromFile(0x000456C0, "Skyrim.esm") as Formlist - QuestFunctionsScript._00E_ArmorSetScript_sSetBonusRemoved = Game.GetFormFromFile(0x00036F96, "Skyrim.esm") as Message - QuestFunctionsScript._00E_DisableQuestTutorials = Game.GetFormFromFile(0x00046D92, "Skyrim.esm") as GlobalVariable - QuestFunctionsScript._00E_DisableSkillTutorials = Game.GetFormFromFile(0x00046D91, "Skyrim.esm") as GlobalVariable - QuestFunctionsScript._00E_FS_A3_AlreadyKnowThisLevel = Game.GetFormFromFile(0x0102F533, "Enderal - Forgotten Stories.esm") as Message - QuestFunctionsScript._00E_FS_A3_NeedToLearnOtherLevels = Game.GetFormFromFile(0x0101EC7D, "Enderal - Forgotten Stories.esm") as Message - QuestFunctionsScript._00E_FS_A3_sIn = Game.GetFormFromFile(0x00043BE0, "Skyrim.esm") as Message - QuestFunctionsScript._00E_FS_A3_sMageClassName = Game.GetFormFromFile(0x00043BE4, "Skyrim.esm") as Message - QuestFunctionsScript._00E_FS_A3_sRogueClassName = Game.GetFormFromFile(0x00043BE3, "Skyrim.esm") as Message - QuestFunctionsScript._00E_FS_A3_sToUnlockThisClass = Game.GetFormFromFile(0x00043BE1, "Skyrim.esm") as Message - QuestFunctionsScript._00E_FS_A3_sWarriorClassName = Game.GetFormFromFile(0x00043BE2, "Skyrim.esm") as Message - QuestFunctionsScript._00E_FS_A3_sYouNeedSkillpoints = Game.GetFormFromFile(0x00043BDF, "Skyrim.esm") as Message - QuestFunctionsScript._00E_FS_NQ02_Esme = Game.GetFormFromFile(0x0101F0D0, "Enderal - Forgotten Stories.esm") as ActorBase - QuestFunctionsScript._00E_FS_NQR05_SlowMotionSP = Game.GetFormFromFile(0x0102E2BD, "Enderal - Forgotten Stories.esm") as Spell - QuestFunctionsScript._00E_FS_NQR05_SlowMotion_IntroM = Game.GetFormFromFile(0x0102E2BF, "Enderal - Forgotten Stories.esm") as Sound - QuestFunctionsScript._00E_FS_NQR05_SlowMotion_OutroM = Game.GetFormFromFile(0x0102E2C1, "Enderal - Forgotten Stories.esm") as Sound - QuestFunctionsScript._00E_Levelsystem_sAbilityStanceQyrai = Game.GetFormFromFile(0x00046D9B, "Skyrim.esm") as Message - QuestFunctionsScript._00E_Levelsystem_sAbilityStanceSkaragg = Game.GetFormFromFile(0x00046D9C, "Skyrim.esm") as Message - QuestFunctionsScript._00E_PleaseRemoveMoney = Game.GetFormFromFile(0x000480DA, "Skyrim.esm") as Message - QuestFunctionsScript._00E_RemoveAllItems_TrashContainer = Game.GetFormFromFile(0x000469E7, "Skyrim.esm") as ObjectReference - QuestFunctionsScript._00E_SkillbookWarning = Game.GetFormFromFile(0x00031ACF, "Skyrim.esm") as Message - - - _00E_Game_SkillmenuSC SkillMenuScript = ((Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") as Quest).GetAliasByName("Player") as Alias) as _00E_Game_SkillmenuSC - SkillMenuScript._00E_FS_Game_Affinity_Spectralist = Game.GetFormFromFile(0x01029A35, "Skyrim.esm") as Message - - - _00E_PlayerHousing_CellNameSC CellNameScript = ((Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") as Quest).GetAliasByName("Player") as Alias) as _00E_PlayerHousing_CellNameSC - CellNameScript.FS_NQR03 = Game.GetFormFromFile(0x0014CEA2, "Skyrim.esm") as Quest - CellNameScript.FS_NQR03_RhalataTemple = Game.GetFormFromFile(0x0010D1C2, "Skyrim.esm") as Cell - CellNameScript._00E_sPlayerHouseMarketQuarterName = Game.GetFormFromFile(0x00047CA5, "Skyrim.esm") as Message - CellNameScript._00E_sPlayerHouseNobleQuarterName = Game.GetFormFromFile(0x00047CA6, "Skyrim.esm") as Message - CellNameScript._00E_sRhalataTempleName = Game.GetFormFromFile(0x00047C29, "Skyrim.esm") as Message - - - _00E_WeatherControlScriptSC WeatherControlScript = ((Game.GetFormFromFile(0x00010AA2, "Skyrim.esm") as Quest).GetAliasByName("Player") as Alias) as _00E_WeatherControlScriptSC - WeatherControlScript.CapitalCityCastleWorld = Game.GetFormFromFile(0x00070729, "Skyrim.esm") as WorldSpace - WeatherControlScript.CapitalCityLocation = Game.GetFormFromFile(0x000A1A12, "Skyrim.esm") as Location - WeatherControlScript.MQ09 = Game.GetFormFromFile(0x0007FA91, "Skyrim.esm") as Quest - WeatherControlScript.MQ12b = Game.GetFormFromFile(0x0002EBAD, "Skyrim.esm") as Quest - WeatherControlScript.MQ17 = Game.GetFormFromFile(0x0007FA93, "Skyrim.esm") as Quest - WeatherControlScript.SkyrimOvercastRain = Game.GetFormFromFile(0x000C821F, "Skyrim.esm") as Weather - WeatherControlScript.Vyn = Game.GetFormFromFile(0x00001D3C, "Skyrim.esm") as WorldSpace - WeatherControlScript._00E_EnderalOvercast = Game.GetFormFromFile(0x00072785, "Skyrim.esm") as Weather - WeatherControlScript._00E_MQ11c_SilberhainDeadWeather = Game.GetFormFromFile(0x00096807, "Skyrim.esm") as GlobalVariable - WeatherControlScript._00E_SuntempleLocations = Game.GetFormFromFile(0x0003BB5B, "Skyrim.esm") as FormList - - Utility.Wait(1) - Debug.Messagebox("Scripts fixed. Make sure to save the game. Restart the client and reload the save that you just created.\n If you have set items equipped, unequip them all and re-equip them for potential set bonuses to apply.") - EndIf - -EndFunction - -;===================================================================================== -; MAINTENANCE -;===================================================================================== - -Function Maintenance() - - If fPatchVersion <= 1.25 && !bdoOnce - int iButton01 = _00E_Game_OldSaves_01.Show() - If iButton01 == 0 - Game.QuitToMainMenu() - ElseIf iButton01 == 1 - int iButton02 = _00E_Game_OldSaves_02.Show() - If iButton02 == 0 - Game.QuitToMainMenu() - ElseIf iButton02 == 1 - bdoOnce = true - EndIf - EndIf - ElseIf fPatchVersion >= 1.5 && fPatchVersion < CURRENT_PATCH_VERSION - - ; only do this once when update 1.5.6.0 is applied - If fPatchVersion < 1.56 - ResetFSNQR05Temple() - EndIf - ; only do this once when update 1.5.7.0 is applied - If fPatchVersion < 1.57 - CleanMQ12bGhostFlags() - EndIf - ; only do this once when update 1.5.8.0 is applied - If fPatchVersion < 1.58 - ResetAuroraOnLoad() - DisableMQ12bPanicTriggerbox() - ReAddDarkKeeperAffinity() - ReAddFuryDrivenPerk() - UpdateLivingTempleTrigger() - UpdateMQ11a() - EndIf - ; only do this once when update 1.6.0.0 is applied - If fPatchVersion < 1.60 - UpdatePhasmalistContainer() - UpdatePassengerBookAtShipwreck() - ResetMQ02Riddle() - EndIf - ; only do this once when update 1.6.1.0 is applied - If fPatchVersion < 1.61 - UpdateMQ02() - EndIf - ; only do this once when update 1.6.2.0 is applied - If fPatchVersion < 1.62 - UpdateItemHandler() - EndIf - ; only do this once when update 2.0.6 (SE) is applied - If fPatchVersion < 2.06 - UpdateMQ12b_206() - EndIf - ; only do this once when update 2.0.8 (SE) is applied - If fPatchVersion < 2.08 - Update_208() - EndIf - ; only do this once when update 2.0.9 (SE) is applied - If fPatchVersion < 2.09 - Update_209() - EndIf - fPatchVersion = CURRENT_PATCH_VERSION - EndIf - - ; changes to the actor value healrate will not persist in consecutive saves - ; every time a save gets loaded the healrate needs to be set to 0, otherwise it will go back again to default at 0.7 - ; this is called before active magic effects of potions or spells are applied to the player which could also alter the value - PlayerREF.SetActorValue("Healrate", 0) - - EnableDisableKillmove() - - ResetArmorWeightPerks() - - SetAmountAutosaves() - - SetAutoSaveInterval() - - FailsafeMQ05PrologueAliases() - - RefreshMountNamesOnLoad() - - ; fixes properties that were accidentally set to NONE by the "More Affinities" mod - If Game.GetModByName("Enderal_FS_More_Affinities.esp") != 255 - FixMoreAffinitiesMod() - EndIf - -EndFunction - -;===================================================================================== -; PROPERTIES -;===================================================================================== - -float fPatchVersion -bool bdoOnce = false -bool bFSWasNotLoadedBefore = false - -_00E_MQ05Prologue_Functions Property MQ05PrologueFunctions Auto - -Perk Property _00E_FS_Alchemy_BalancingPerk Auto -Perk Property _00E_FS_Alchemy_BalancingPerk_RestorePotions Auto - -Spell Property _00E_AbBlockWaiting Auto -Actor Property PlayerREF Auto - -FormList Property QuestsToStart Auto -FormList Property FSQuestsToStartFailsafePatch1560 Auto - -Message Property _00E_Game_OldSaves_01 Auto -Message Property _00E_Game_OldSaves_02 Auto -Message Property _00E_Game_ForgottenStoriesNotLoaded Auto - -GlobalVariable Property KillMove Auto - -Perk Property _00E_Class_Keeper_P05_C_Conditioning Auto -Perk Property _00E_Class_Vagrant_P05_B_Lightweight Auto diff --git a/scripts/source/_00e_questfunctions.psc b/scripts/source/_00e_questfunctions.psc deleted file mode 100644 index c3e906c3..00000000 --- a/scripts/source/_00e_questfunctions.psc +++ /dev/null @@ -1,1420 +0,0 @@ -Scriptname _00E_QuestFunctions extends Quest Conditional -{This script is meant to be attached to any quests and serves as a Function library. Simply import it to call Global functions, and create a script property to access non-global functions} - -Import math -Import Utility - -;===================================================================================== -; EXP -;===================================================================================== - -Function GiveEP(int ToGive) - - If (PlayerREF as _00E_EPUpdateFunctions).receiveEP(ToGive) - ; Player receives EP - EndIf - -EndFunction - -;===================================================================================== -; SYMPATHY -;===================================================================================== - -Function ModSympathyNG(Actor akSympathyActor, int iSympathyMod, bool bIsFlirt = False, bool bStringOverride = False, String sOverride = "") - - Levelsystem_SympathyActor.ForceRefTo(akSympathyActor) - - ActorBase sympathyBase = akSympathyActor.GetActorBase() - - If sympathyBase == _00E_MC_Jespar - SympathyJespar.Mod(iSympathyMod) - ElseIf sympathyBase == _00E_MC_Calia - SympathyCalia.Mod(iSympathyMod) - ElseIf sympathyBase == _00E_CapitalCityMaelGroschenfrst - SympathyMaelGroschenfuerst.Mod(iSympathyMod) - ElseIf sympathyBase == _00E_SC_Dijaam - SympathyDijaam.Mod(iSympathyMod) - ElseIf sympathyBase == _00E_SC_Tharael - SympathyTharael.Mod(iSympathyMod) - ElseIf sympathyBase == _00E_MQ11c_Ryneus - SympathyRyneus.Mod(iSympathyMod) - ElseIf sympathyBase == _00E_MC_Yuslan - SympathyYuslan.Mod(iSympathyMod) - ElseIf sympathyBase == _00E_FS_NQ02_Esme - SympathyEsme.Mod(iSympathyMod) - EndIf - - If bIsFlirt - If sympathyBase == _00E_MC_Jespar - JesparFlirtCounter.SetValueInt(JesparFlirtCounter.GetValueInt() + 1) - ElseIf sympathyBase == _00E_MC_Calia - CaliaFlirtCounter.SetValueInt(CaliaFlirtCounter.GetValueInt() + 1) - ElseIf sympathyBase == _00E_SC_Dijaam - DijaamFlirtCounter.SetValueInt(DijaamFlirtCounter.GetValueInt() + 1) - ElseIf sympathyBase == _00E_SC_Tharael - TharaelFlirtCounter.SetValueInt(TharaelFlirtCounter.GetValueInt() + 1) - EndIf - EndIf - - String sActorName = sympathyBase.GetName() - - If !bStringOverride - If (iSympathyMod > 0) && (iSympathyMod <= 5) - _00E_Levelsystem_sApproves.Show() - ; Debug.Notification(sActorName + sLevelsystemAppreciate + ".") - ElseIf (iSympathyMod > 5) && (iSympathyMod <= 10) - _00E_Levelsystem_sAppreciates.Show() - ; Debug.Notification(sActorName + sLevelsystemAppreciateALot + ".") - ElseIf (iSympathyMod > 10) && (iSympathyMod <= 20) - _00E_Levelsystem_sAppreciatesALot.Show() - ; Debug.Notification(sActorName + sLevelsystemApproves + ".") - ElseIf (iSympathyMod < 0) && (iSympathyMod >= -5) - _00E_Levelsystem_sDislikes.Show() - ; Debug.Notification(sActorName + sLevelsystemDislikes + ".") - ElseIf (iSympathyMod < -5) && (iSympathyMod >= -10) - _00E_Levelsystem_sHurt.Show() - ; Debug.Notification(sActorName + sLevelsystemOffended + ".") - ElseIf (iSympathyMod < -10) && (iSympathyMod >= -20) - _00E_Levelsystem_sVeryHurt.Show() - ; Debug.Notification(sActorName + sLevelsystemVeryOffended + ".") - EndIf - Else - Debug.Notification(sActorName + sOverride) - EndIf - -EndFunction - -;===================================================================================== -; CAMERA -;===================================================================================== - -Function LockCamera() - - fCameraMaxDistance = Utility.GetINIFloat("fVanityModeMaxDist:Camera") - Utility.SetINIFloat("fVanityModeMaxDist:Camera", Utility.GetIniFloat("fVanityModeMinDist:Camera")) - -EndFunction - -Function UnlockCamera() - - Utility.SetINIFloat("fVanityModeMaxDist:Camera", fCameraMaxDistance) - -EndFunction - -;===================================================================================== -; GLOBAL FUNCTIONS -;===================================================================================== - -Function Brawl(Actor pTarget, Actor pTargetFriend = None) - - BrawlKeyword.SendStoryEvent(None, pTarget, pTargetFriend) - -EndFunction - -function PlayerAIWalkStop() Global - - Game.ShowFirstPersonGeometry(True) - Game.SetPlayerAIDriven(False) - Game.EnablePlayerControls() - -endFunction - -function PlayerAIWalk(bool abLockedSight = True) Global - - Game.ShowFirstPersonGeometry(False) - Game.SetPlayerAIDriven(True) - If abLockedSight == True - Game.DisablePlayerControls(true, true, true, true, true, true, true, true) - ElseIf abLockedSight == False - Game.DisablePlayerControls(true, true, true, False, true, true, true, true) - EndIf - -endFunction - -Function DisableDialogueQuitting() Global -{Disables the TAB Key during dialogue. Resets automatically upon dialogue exit via Goodbye.} - - UI.InvokeBool("Dialogue Menu", "_root.DialogueMenu_mc.SetVariable", False) - -EndFunction - -Function EnableDialogueQuitting() Global -{Disables the TAB Key during dialogue. Resets automatically upon dialogue exit via Goodbye.} - - UI.InvokeBool("Dialogue Menu", "_root.DialogueMenu_mc.SetVariable", True) - -EndFunction - -Function RefreshFace() Global - - String facegen = "bUseFaceGenPreprocessedHeads:General" - Utility.SetINIBool(facegen, False) - Game.GetPlayer().QueueNiNodeUpdate() - Utility.SetINIBool(facegen, True) - -EndFunction - -Function ShowHelpMessage(Message msg, Float fDuration = 5.0, String sEvent = "Empty") Global - - Message.ResetHelpMessage(sEvent) - msg.ShowAsHelpMessage(sEvent, fDuration, 1.0, 1) - -EndFunction - -Function SafeMoveTo(ObjectReference refToMove, ObjectReference targetRef, Bool bFadeIn = False) Global - - ; A safer way to move an object reference to another ref than just MoveTo. - ; Mostly for actors to take their intended positions. - ; It's better for the actor to be already running a package that moves them to targetRef at the moment this function is called. - - refToMove.Disable() - refToMove.MoveTo(targetRef) - refToMove.Enable(bFadeIn) - -EndFunction - -Function SafeMoveTo_NoWait(ObjectReference refToMove, ObjectReference targetRef, Bool bFadeIn = False) Global - - ; A safer way to move an object reference to another ref than just MoveTo (without waiting for it to be fully enabled). - ; Mostly for actors to take their intended positions. - ; It's better for the actor to be already running a package that moves them to targetRef at the moment this function is called. - - refToMove.Disable() - refToMove.MoveTo(targetRef) - refToMove.EnableNoWait(bFadeIn) - -EndFunction - -Bool Function DistanceFailsafeMoveTo(ObjectReference refToMove, ObjectReference targetRef, Float fTooFarDistance) Global - - ; Moves refToMove to targetRef if refToMove is not within fTooFarDistance from targetRef. - ; Mostly for character travel failsafes in scenes. - - ; Debug.Trace("FailsafeMoveTo: refToMove = " + refToMove + "; d = " + refToMove.GetDistance(targetRef)) - If refToMove.GetDistance(targetRef) >= fTooFarDistance - refToMove.MoveTo(targetRef) - ; Debug.Trace("FailsafeMoveTo: refToMove = " + refToMove + " force-moved to marker") - Return True - Else - Return False - EndIf - -EndFunction - -Function WaitForReferenceToLoad(ObjectReference ref) Global - - Int maxIterationsToWait = 180 - While ref.Is3DLoaded() == False && maxIterationsToWait > 0 - ; Utility.Wait(0.02) - maxIterationsToWait -= 1 - EndWhile - -EndFunction - -Float Function NormalizeHour(Float fHour) Global - - If fHour >= 24.0 - Return (fHour - 24.0) - ElseIf fHour < 0.0 - Return (fHour + 24.0) - Else - Return fHour - EndIf - -EndFunction - -Bool Function HourIsInRange(Float fHour, Float fHourStart, Float fHourEnd) Global - - ; "Smart" test for fHour being withing a range. - ; Works both with "day" ranges (e.g., 06:00- 20:00) and with "night" ranges (e.g., 21:00-06:00) - - fHour = NormalizeHour(fHour) - fHourStart = NormalizeHour(fHourStart) - fHourEnd = NormalizeHour(fHourEnd) - - If fHourStart <= fHourEnd ; Something like 06:00 - 20:00 - Return (fHour >= fHourStart && fHour < fHourEnd) - Else ; Something like 20:00 - 06:00 - Return (fHour >= fHourStart || fHour < fHourEnd) - EndIf - -EndFunction - -Function EnableReferenceFormList(FormList referenceList) Global - - Int nItems = referenceList.GetSize() - Int i = 0 - - If nItems < 128 && nItems > 1 - Form[] refArray = referenceList.ToArray() - While i < nItems - (refArray[i] as ObjectReference).EnableNoWait() - i += 1 - EndWhile - Else - While i < nItems - (referenceList.GetAt(i) as ObjectReference).EnableNoWait() - i += 1 - EndWhile - EndIf - -EndFunction - -Function DisableReferenceFormList(FormList referenceList) Global - - Int nItems = referenceList.GetSize() - Int i = 0 - - If nItems < 128 && nItems > 1 - Form[] refArray = referenceList.ToArray() - While i < nItems - (refArray[i] as ObjectReference).DisableNoWait() - i += 1 - EndWhile - Else - While i < nItems - (referenceList.GetAt(i) as ObjectReference).DisableNoWait() - i += 1 - EndWhile - EndIf - -EndFunction - -Float Function SetActorScale(Actor akActor, Float fNewScale) Global - - ; Sets the scale of akActor to fNewScale and returns the old scale. - ; This is a workaround for GetScale() returning the cumulative scale of Race.Height * Actor.Scale for actors. - ; So it results in a messed up scale if the value returned by GetScale() is used to revert the scale change for an actor whose race has a non-1.00 height (for example, HighElfRace) - - Float fOriginalScale = akActor.GetScale() - akActor.SetScale(fNewScale) - ; Now use the known fNewScale and the return of GetScale() to get the race height coeff, and apply that coeff to fOriginalScale to calculate the true actor's reference scale. - Return fOriginalScale * fNewScale / akActor.GetScale() - -EndFunction - -Float Function AdjustTimePeriodByEngineTimerError(Float fUnadjustedPeriod) Global - - ; In SE, the game time runs slower than the real time by about 2.5/60 second - - Return fUnadjustedPeriod - (2.5 * Math.Floor(fUnadjustedPeriod) / 60.0) - -EndFunction - -Function PrintDebugMessage(String msg) Global - ; Dummy to fix error messages in Papyrus.log about missing function -EndFunction - -Function PDB(String msg) Global - ; Dummy to fix error messages in Papyrus.log about missing function -EndFunction - - - -;===================================================================================== -; GENERAL NON-GLOBAL FUNCTIONS -;===================================================================================== - -Function RemoveSilence() - - _00E_SilenceTransitionLowPriority02.Remove() - _00E_Music_Special_MQ12b_Samael.Remove() - _00E_SilenceLongTransitionHighPriority.Remove() - _00E_SilenceTransitionLowPriority.Remove() - _00E_SilenceTransitionHighPriority.Remove() - _00E_SilenceAbruptHighPriority.Remove() - _00E_Music_Special_TavernSilence.Remove() - AudioCategoryAMB.UnMute() - AudioCategoryAMBr.UnMute() - AudioCategorySFX.UnMute() - -EndFunction - -Function RemoveCombatSoundtracks() - - int iIndex = _00E_MUS_AllCombatSoundtracks.GetSize() - - while iIndex > 0 - iIndex -= 1 - MusicType musicToRemove = _00E_MUS_AllCombatSoundtracks.GetAt(iIndex) as MusicType - musicToRemove.Remove() - endwhile - -EndFunction - -Function ShowFailedMessage(String companionName = "Jespar") - - if companionName == "Jespar" && _00E_DisableQuestTutorials.GetValueInt() == 0 - _00E_Tutorial_Companions02_Jespar.Show() - ElseIf _00E_DisableQuestTutorials.GetValueInt() == 0 - _00E_Tutorial_Companions02_Calia.Show() - EndIf - -EndFunction - -Function ShowBrawlTutorial() - - If _00E_DisableSkillTutorials.GetValueInt() == 0 - Message.ResetHelpMessage("Brawl") - _00E_Tutorial_Brawl.ShowAsHelpMessage("Brawl", 3, 3, 1) - EndIf - -EndFunction - -Function PriestHeal() -{Called in dialoges with priests} - - PlayerREF.RestoreActorValue("Health", PlayerREF.GetAV("Health")) - _00E_PriestCureDiseases.Cast(PlayerREF, PlayerREF) - -EndFunction - -Function TeleportNPC(Actor NPCToTeleport, ObjectReference TeleportTarget) -{Teleport an NPC, with animations and FX} - - Weapon weap01 = NPCToTeleport.GetEquippedWeapon(0) - Weapon weap02 = NPCToTeleport.GetEquippedWeapon(1) - - If weap01 != None - NPCToTeleport.UnEquipItem(weap01) - EndIf - If weap02 != None - NPCToTeleport.UnEquipItem(weap02) - EndIf - NPCToTeleport.PlayIdle(IdleMagic_01) - _00E_TeleportCastSound.Play(NPCToTeleport) - Wait(3) - - if NPCToTeleport.GetActorBase().GetSex() == 0 - NPCToTeleport.PlayIdle(IdleT02AscendMale) - Else - NPCToTeleport.PlayIdle(IdleT02AscendFemale) - EndIf - - _00E_MagicProtectionSpellM.Play(NPCToTeleport) - Wait(4) - TimeFadeOut01FXS.Play(NPCToTeleport) - Wait(2) - _00E_A2_Ghostwalk_TeleportDoneSound.Play(NPCToTeleport) - - ObjectReference TeleportFXMarker = NPCToTeleport.PlaceAtMe(XMarkerHeading, 1) - TeleportFXMarker.MoveTo(NPCToTeleport, 0.0, 0.0, 100.0) - ObjectReference FXExplosion = TeleportFXMarker.PlaceAtMe(_00E_TeleportExplosion, 1) - _00E_NPCTeleportExplosionIMOD.Apply() - Game.ShakeCamera(afStrength = 0.2) - NPCToTeleport.MoveTo(TeleportTarget) - Debug.sendAnimationEvent(NPCToTeleport, "IdleWebEnterInstant") - NPCToTeleport.setActorValue("Variable03", 5) - TimeFadeOut01FXS.Stop(NPCToTeleport) - If NPCToTeleport.Is3DLoaded() - TimeFadeIn01FXS.Play(NPCToTeleport) - EndIf - Wait(0.5) - NPCToTeleport.playidle(WebIdleExit) - Wait(1) - TimeFadeIn01FXS.Stop(NPCToTeleport) - NPCToTeleport.setActorValue("Variable03", 0) - If weap01 != None - NPCToTeleport.EquipItem(weap01) - EndIf - If weap02 != None - NPCToTeleport.EquipItem(weap02) - EndIf - - Return - -EndFunction - -Function SetAllowIdleChatter(bool bAllow = False) - - if !bAllow - bAllowIdleChatter = False - SendModEvent("IdleChatterOff") - Elseif bAllow - bAllowIdleChatter = True - EndIf - -EndFunction - -Function ShowSynergyMessage() - - _00E_Levelsystem_sSynergyDiscovered.Show() - GiveEP(150) - - If _00E_AchievementsEnabled.GetValueInt() == 1 && !bUnlockedSynergyAchievement - Game.UnlockAchievement("END_SYNERGY_01") - bUnlockedSynergyAchievement = true - EndIf - -EndFunction - -Function SkipTimeToHour(Float fNewHourOfDay, Float fMinHoursToSkip = 0.0) - - ; Progresses the current in-game time to the desired hour (and optionally, by no less than fMinHoursToSkip hours), moving to the next day if needed - - Float fCurHour = GameHour.GetValue() - If fNewHourOfDay <= fCurHour - fNewHourOfDay += 24.0 ; Go to the next day - EndIf - If (fNewHourOfDay - fCurHour) < fMinHoursToSkip - fNewHourOfDay += 24.0 ; Go to the next day - EndIf - GameHour.SetValue(fNewHourOfDay) - SendModEvent("TimeSkip") - -EndFunction - -Function SkipHours(Float fHoursToSkip) - - ; Progresses the current in-game time by fHoursToSkip hours - - GameHour.SetValue(GameHour.GetValue() + fHoursToSkip) - SendModEvent("TimeSkip") - -EndFunction - - -;===================================================================================== -; Player Teleport -;===================================================================================== - -Event OnUpdate() - Game.EnablePlayerControls() -EndEvent - -Function TeleportPlayer(ObjectReference TeleportTarget) - - Game.DisablePlayerControls(abCamSwitch = true) - Wait(3) - If PlayerREF.IsWeaponDrawn() - PlayerREF.SheatheWeapon() - EndIf - Wait(2) - TeleportIn() - PlayerREF.MoveTo(TeleportTarget) - TeleportOut() - RefreshFace() - -EndFunction - -Function TeleportIn() - - Game.ForceThirdPerson() - - if Player.GetSex() == 0 - PlayerREF.PlayIdle(IdleT02AscendMale) - Else - PlayerREF.PlayIdle(IdleT02AscendFemale) - EndIf - - _00E_MagicProtectionSpellM.Play(PlayerREF) - Wait(2.7) - TimeFadeOut01FXS.Play(PlayerREF) - Wait(1.3) - _00E_TeleportImod.Apply() - Wait(2) - -EndFunction - -Function TeleportOut() - - _00E_A2_Ghostwalk_TeleportDoneSound.Play(playerREF) - PlayerREF.PlaceAtMe(_00E_NPCOorbayaTeleportExplosionBlue, 1) - Debug.sendAnimationEvent(playerREF, "IdleWebEnterInstant") - PlayerREF.setActorValue("Variable03", 5) - TimeFadeOut01FXS.Stop(PlayerREF) - TimeFadeIn01FXS.Play(PlayerREF) - Wait(0.5) - PlayerREF.playidle(WebIdleExit) - TimeFadeIn01FXS.Stop(PlayerREF) - PlayerREF.setActorValue("Variable03", 0) - PlayerREF.DrawWeapon() - Wait(3) - Debug.SendAnimationEvent(PlayerREF, "IdleForceDefaultState") - PlayerREF.PlayIdle(IdleForceDefaultState) - PlayerREF.setActorValue("Variable03", 0) - Game.EnablePlayerControls() - _FS_Phasmalist_ControlQuest.MoveApparitionToPlayer() - RegisterForSingleUpdate(2) - -EndFunction - -;===================================================================================== -; FADE TO BLACK -;===================================================================================== - -Function FadeToBlackAndBack() - - FadeToBlackIMOD.Apply() - Wait(2.8) - FadeToBlackIMOD.PopTo(FadeToBlackHoldIMOD) - Wait(1.9) - FadeToBlackHoldIMOD.PopTo(FadeToBlackBackIMOD) - -EndFunction - -Function FadeToBlack() - - FadeToBlackIMOD.Apply() - Wait(2.8) - FadeToBlackIMOD.PopTo(FadeToBlackHoldImod) - -EndFunction - -Function FadeToBlackBack() - - FadeToBlackHoldImod.PopTo(FadeToBlackBackImod) - -EndFunction - -;===================================================================================== -; FAKEHEADTRACK (unused?) -;===================================================================================== - -function FakeHeadtrackStart() - - _00E_HeadtrackGlobal.SetValueInt(1) - game.SetPlayerAIDriven(true) - game.DisablePlayerControls(true, true, true, true, true, true, true, false, 0) - PlayerREF.AddPerk(_00E_VisionPerk) - UpdateSpeed(PlayerREF) - Wait(0.500000) - PlayerREF.RemoveSpell(_00E_Vision_UpdateAb) - -endFunction - -function FakeHeadtrackEnd() - - _00E_HeadtrackGlobal.SetValueInt(0) - game.EnablePlayerControls(true, true, true, true, true, true, true, true, 0) - game.SetPlayerAIDriven(false) - PlayerREF.RemovePerk(_00E_VisionPerk) - UpdateSpeed(PlayerREF) - Wait(0.500000) - -endFunction - -;===================================================================================== -; VISION -;===================================================================================== - -function EndVision(bool ScenePlaying, Scene RunningScene = None) - - If PlayerREF.HasSpell(_00E_Vision_TimeSpell) - PlayerREF.RemoveSpell(_00E_Vision_TimeSpell) - ElseIf PlayerREF.HasSpell(_00E_Vision_NoTimeSpell) - PlayerREF.RemoveSpell(_00E_Vision_NoTimeSpell) - ElseIf PlayerREF.HasSpell(_00E_Vision_NoTimeSubtleSpell) - PlayerREF.RemoveSpell(_00E_Vision_NoTimeSubtleSpell) - EndIf - VisionLight.Delete() - If ScenePlaying == True && RunningScene.IsPlaying() - RunningScene.Stop() - EndIf - PlayerREF.MoveTo(PlayerVisionStartMarker) - -endFunction - -Function VisionEffectTimestop(bool bSilent = False, bool bCustomImod = False, bool bCustomMusic = False) - - If bCustomImod == False - _00E_VisionStartTimestopIMOD.Apply() - _00E_VisionImod.ApplyCrossFade(0.25) - EndIf - - PlayerREF.AddSpell(_00E_Vision_TimeSpell, False) - - if !bCustomMusic - _00E_SilenceAbruptHighPriority.Add() - EndIf - - MagRacialBattlecryFire.Play(PlayerREF) - fPlayerSpeedBeforeVision = PlayerREF.GetActorValue("SpeedMult") - PlayerREF.SetActorValue("SpeedMult", 35) - UpdateSpeed(PlayerREF) - - If !bSilent - VisionSound = _00E_VisionLPM.Play(PlayerREF) - EndIf - - _00E_VisionShaderParticles.Apply(0.5) - AudioCategoryFST.Mute() - - PlayerREF.SetGhost(True) - - PlayerVisionStartMarker = PlayerREF.PlaceAtMe(XMarker as form, 1, false, false) - PlayerVisionFailsaveMarker.MoveTo(PlayerREF) - Game.DisablePlayerControls(false, true, true, false, true, false, true, false) - Game.ForceFirstPerson() - Game.ShowFirstPersonGeometry(False) - Wait(0.100000) - -EndFunction - -Function VisionEffectTimestopStop(bool bMovementHasBeenLocked = False) - - float fSpeedMultBefore = PlayerREF.GetAV("speedMult") - - PlayerREF.SetGhost(False) - Game.DisablePlayerControls() - PlayerREF.SetActorValue("SpeedMult", PlayerSpeed) - PlayerREF.SetGhost(False) - AudioCategoryFST.UnMute() - UpdateSpeed(PlayerREF) - Game.ShowFirstPersonGeometry(True) - - If !bMovementHasBeenLocked - If PlayerVisionFailsaveMarker.GetDistance(PlayerREF) <= 1000 - PlayerREF.MoveTo(PlayerVisionStartMarker) - Elseif PlayerVisionFailsaveMarker.GetDistance(PlayerREF) >= 1000 - PlayerREF.MoveTo(PlayerVisionFailsaveMarker) - EndIf - EndIf - - PlayerREF.SetGhost(False) - Sound.StopInstance(VisionSound) - MAGConjurePortalClose.Play(PlayerREF) - _00E_SilenceAbruptHighPriority.Remove() - PlayerREF.RemoveSpell(_00E_Vision_TimeSpell) - _00E_VisionShaderParticles.Remove(0.5) - _00E_VisionEndImod.ApplyCrossFade(1) - Wait(0.5) - PlayerREF.SetAV("speedMult", fPlayerSpeedBeforeVision) - - If PlayerREF.GetAV("speedMult") < 50 - PlayerREF.SetAV("speedMult", 100) - EndIf - - UpdateSpeed(PlayerREF) - Game.EnablePlayerControls() - Game.SetPlayerAIDriven(0) - Game.ShowFirstPersonGeometry(True) - _00E_SilenceAbruptHighPriority.Remove() - -EndFunction - -Function VisionEffectNoTimestop(Formlist RefsInvolved, Formlist ActorsToFreeze, bool bCustomMusic = False) - - Game.ShowFirstPersonGeometry(False) - PlayerREF.SetAlpha(0.1) - PlayerREF.AddPerk(_00E_VisionPerk) - UpdateSpeed(PlayerREF) - MagRacialBattlecryFire.Play(PlayerREF) - - if !bCustomMusic - _00E_SilenceAbruptHighPriority.Add() - EndIf - - AudioCategoryFST.Mute() - PlayerVisionStartMarker = PlayerREF.PlaceAtMe(XMarker as form, 1, false, false) - PlayerVisionFailsaveMarker.MoveTo(PlayerREF) - PlayerREF.SetGhost(True) - VisionSound = _00E_VisionLPM.Play(PlayerREF) - _00E_VisionStartImod.Apply() - - If PlayerREF.IsInInterior() - _00E_VisionShaderParticles.Apply(0.5) - EndIf - - if RefsInvolved != None - int iIndex = RefsInvolved.GetSize() - - while iIndex > 0 - iIndex -= 1 - Actor VisionREF = RefsInvolved.GetAt(iIndex) as Actor - if VisionREF.IsDisabled() - VisionREF.EnableNoWait() - EndIf - VisionRef.SetAlpha(0.5) - MS04MemoryFXBody01VFX.Play(VisionREF) - EndWhile - endif - - if ActorsToFreeze != None - int iIndex02 = ActorsToFreeze.GetSize() - - while iIndex02 > 0 - iIndex02 -= 1 - Actor FreezeREF = ActorsToFreeze.GetAt(iIndex02) as Actor - FreezeREF.EnableAI(False) - EndWhile - endif - - _00E_MQ16_VisionIMOD.Remove() - _00E_VisionImod.ApplyCrossFade(1) - -EndFunction - -Function VisionEffectNoTimestopStop(Formlist RefsInvolved, Formlist ActorsToFreeze, bool bHasBeenRestrained = False) - - PlayerREF.SetAlpha(1.0) - Game.ShowFirstPersonGeometry(True) - - If !bHasBeenRestrained - If PlayerVisionFailsaveMarker.GetDistance(PlayerREF) <= 1000 - PlayerREF.MoveTo(PlayerVisionStartMarker) - Elseif PlayerVisionFailsaveMarker.GetDistance(PlayerREF) >= 1000 - PlayerREF.MoveTo(PlayerVisionFailsaveMarker) - EndIf - EndIf - - _00E_VisionEndImod.ApplyCrossFade(1) - If PlayerREF.IsInInterior() - _00E_VisionShaderParticles.Remove(0.5) - EndIf - - if RefsInvolved != None - int iIndex = RefsInvolved.GetSize() - - while iIndex > 0 - iIndex -= 1 - Actor VisionREF = RefsInvolved.GetAt(iIndex) as Actor - MS04MemoryFXBody01VFX.Stop(VisionREF) - VisionRef.SetAlpha(1) - EndWhile - endif - - if ActorsToFreeze != None - int iIndex02 = ActorsToFreeze.GetSize() - - while iIndex02 > 0 - iIndex02 -= 1 - Actor FreezeREF = ActorsToFreeze.GetAt(iIndex02) as Actor - FreezeREF.EnableAI(True) - EndWhile - endif - - AudioCategoryFST.UnMute() - PlayerREF.SetGhost(False) - Sound.StopInstance(VisionSound) - MAGConjurePortalClose.Play(PlayerREF) - _00E_SilenceAbruptHighPriority.Remove() - PlayerREF.RemovePerk(_00E_VisionPerk) - - If PlayerREF.GetAV("speedMult") < 50 - PlayerREF.SetAV("speedMult", 100) - EndIf - - UpdateSpeed(PlayerREF) - _00E_MQ16_VisionIMOD.Remove() - _00E_VisionImod.Remove() - -EndFunction - -Function UpdateSpeed(Actor SpeedUpdateActor) - - If SpeedUpdateActor.HasSpell(_00E_Vision_UpdateAb) - SpeedUpdateActor.RemoveSpell(_00E_Vision_UpdateAb) - EndIf - - SpeedUpdateActor.AddSpell(_00E_Vision_UpdateAb, False) - Wait(0.1) - SpeedUpdateActor.RemoveSpell(_00E_Vision_UpdateAb) - -EndFunction - -;===================================================================================== -; AREMOVE ITEMS SAFE -;===================================================================================== - -Function RemoveAllItemsSafeVersion(ObjectReference TransferToLoc = NONE) - If Gold001 == NONE || _00E_AllAmmos == NONE - Return - EndIf - - RemoveItemsIncrementally(Gold001, TransferToLoc) - Form[] arrows = _00E_AllAmmos.ToArray() - Int i = 0 - While i < arrows.Length - RemoveItemsIncrementally(arrows[i], TransferToLoc) - i += 1 - EndWhile - - If TransferToLoc == NONE - PlayerREF.removeAllItems(_00E_RemoveAllItems_TrashContainer, abRemoveQuestItems = false) - _00E_RemoveAllItems_TrashContainer.removeAllItems() - Else - PlayerREF.RemoveAllItems(akTransferTo = TransferToLoc, abRemoveQuestItems = true) - EndIf -EndFunction - -Function RemoveItemsIncrementally(Form akItem, ObjectReference TransferToLoc) - Int nCount = PlayerREF.GetItemCount(akItem) - If nCount > 3000000 && akItem == Gold001 - _00E_PleaseRemoveMoney.Show() - EndIf - While nCount > 0 - PlayerREF.RemoveItem(akItem, 10000, true, TransferToLoc) - nCount -= 10000 - EndWhile -EndFunction - -;===================================================================================== -; ADDED IN FORGOTTEN STORIES -;===================================================================================== - -Function SlowMotion(float fDuration = 5.0, bool bSound = true) - - PlayerREF.AddSpell(_00E_FS_NQR05_SlowMotionSP, False) - - if bSound - _00E_FS_NQR05_SlowMotion_IntroM.Play(PlayerREF) - endif - - Wait(fDuration) - - if bSound - _00E_FS_NQR05_SlowMotion_OutroM.Play(PlayerREF) - endif - - PlayerREF.RemoveSpell(_00E_FS_NQR05_SlowMotionSP) - -EndFunction - -Function UnsummonApparitionIfExists() Global - - _FS_Phasmalist_ControlQuest.UnsummonApparitionIfExists() - -EndFunction - -Function EndWerewolfModeWhenTransformed() Global - - ; This function ends the werewolf mode if the player is currently transformed, with no penalties. - _FS_TheriantrophistControlQuest.TransformBackIfTransformed() - ; Links to Theriantrophist script. - -EndFunction - -Function SetNPCAsCompanion(Actor akActor, bool bCompanion = True, int iCompanionHealth = 100, int iCompanionStamina = 100, int iCompanionMagicka = 100) Global -;Sets an NPC as companion, showing his health bar, making him friendly, unflagging him as ghost. Does the opposite when bCompanion is set to false. -;Additionally sets the AVs Health, Stamina, Magicka for the NPC companion - - _00E_FS_ForgottenStories_Functions ForgottenStoriesMiscDialogue = Game.GetFormFromFile(0x01016E89, "Enderal - Forgotten Stories.esm") as _00E_FS_ForgottenStories_Functions - - If bCompanion - - akActor.SetRelationshipRank(Game.GetPlayer(), 3) - akActor.SetGhost(False) - akActor.getActorbase().SetEssential(true) ; just in case, had trouble with FS_NQR05 - akActor.SetPlayerTeammate(True) - akActor.IgnoreFriendlyHits() - akActor.SetAV("Health", iCompanionHealth) - akActor.SetAV("Stamina", iCompanionStamina) - akActor.SetAV("Magicka", iCompanionMagicka) - ForgottenStoriesMiscDialogue.showActorHealthBars(akActor) - - Else - - akActor.SetGhost(True) - akActor.getActorbase().SetEssential(true) ; just in case, had trouble with FS_NQR05 - akActor.ResetHealthAndLimbs() - akActor.SetPlayerTeammate(False) - akActor.IgnoreFriendlyHits(False) - ForgottenStoriesMiscDialogue.hideActorHealthBars(akActor) - - EndIf - -EndFunction - -Function StartVoicedLetter(MusicType MTVoicedLetter) - - MTToRemove = MTVoicedLetter - RegisterForMenu("Book Menu") - MTVoicedLetter.Add() - -EndFunction - -Event OnMenuClose(String MenuName) - - If MenuName == "Book Menu" - MTToRemove.Remove() - UnregisterForMenu("Book Menu") - EndIf - -EndEvent - - -; SKILL BOOKS - -Message Property _00E_SkillbookWarning Auto - -Bool _SkillBookReadLocked = False - -Function _ReadSkillBook(String skillName, Int skillTopLimit, Form bookItem, Message msgSkillIncrease, GlobalVariable availablePoints, Message msgNoPoints) - Message failMsg = None - - While _SkillBookReadLocked - WaitMenuMode(0.1) - EndWhile - _SkillBookReadLocked = True - - ; DO NOT FORGET TO FALSE _SkillBookReadLocked ON RETURN - - If availablePoints.GetValue() >= 1 - Int curSkill = PlayerREF.GetBaseActorValue(skillName) as Int - - If curSkill >= skillTopLimit - failMsg = _00E_Levelsystem_sSkillTooWellDeveloped - ElseIf curSkill >= (skillTopLimit - 25) || (_00E_SkillbookWarning.Show() == 0) ; If cur. skill is within the book's limit or the player says "Yes" - ; Do skill increase - curSkill += 1 - PlayerREF.SetActorValue(skillName, curSkill) - availablePoints.Mod(-1) - _SkillBookReadLocked = False - msgSkillIncrease.Show(1, curSkill) - Return - EndIf - Else ; availablePoints < 1 - failMsg = msgNoPoints - EndIf - - ; Processing failed read - _SkillBookReadLocked = False - - If failMsg != None - failMsg.Show() - EndIf - - PlayerREF.AddItem(bookItem, 1, True) -EndFunction - -Function ReadPrimarySkillBook(String skillName, Int skillTopLimit, Form bookItem, Message msgSkillIncrease) - _ReadSkillBook(skillName, skillTopLimit, bookItem, msgSkillIncrease, Lernpunkte, _00E_Levelsystem_sNoMoreLearningPoints) -EndFunction - -Function ReadCraftingSkillBook(String skillName, Int skillTopLimit, Form bookItem, Message msgSkillIncrease) - _ReadSkillBook(skillName, skillTopLimit, bookItem, msgSkillIncrease, Handwerkspunkte, _00E_Levelsystem_sNoMoreCraftingPoints) -EndFunction - -Function ReadMemorySkillBook(String sClass, Int iTier, Message talentMessage, float fRecoveryTime02, float fRecoveryTime03, Potion PotionItem, Shout TaughtTalent, WordOfPower Word01, WordOfPower Word02, WordOfPower Word03, Perk Perk01, Perk Perk02, Perk Perk03) - While _MemoryBookReadLocked - WaitMenuMode(0.1) - EndWhile - _MemoryBookReadLocked = True - - int iButton = talentMessage.Show() - - if iButton == 0 - - if iTier == 1 - iRequiredPoints = iPointRequirementTier01 - Elseif iTier == 2 - iRequiredPoints = iPointRequirementTier02 - Else - iRequiredPoints = iPointRequirementTier03 - EndIf - - if RequirementsMetMemoryBook(iTier, Perk01, Perk02, Perk03, sClass) - TeachTalent(iTier, TaughtTalent, Perk01, Perk02, Perk03, Word01, Word02, Word03, fRecoveryTime02, fRecoveryTime03) - Else - - if bValidSkilllevel - - Message messageToShow = _00E_FS_A3_sMageClassName - - if sClass == "Rogue" - messageToShow = _00E_FS_A3_sRogueClassName - Elseif sClass == "Warrior" - messageToShow = _00E_FS_A3_sWarriorClassName - EndIf - Debug.Notification(_00E_FS_A3_sYouNeedSkillpoints.GetName() + " " + iRequiredPoints + _00E_FS_A3_sIn.GetName() + messageToShow.GetName() + _00E_FS_A3_sToUnlockThisClass.GetName()) - - EndIf - - PlayerREF.AddItem(PotionItem, 1, true) - - EndIf - _MemoryBookReadLocked = False - - Else - - PlayerREF.AddItem(PotionItem, 1, true) - _MemoryBookReadLocked = False - Return - - EndIf -EndFunction - -bool Function RequirementsMetMemoryBook(int iTier, Perk Perk01, Perk Perk02, Perk Perk03, string sClass) - - Formlist ClassFormList01 - Formlist ClassFormList02 - Formlist ClassFormList03 - - if (iTier == 3 && !PlayerREF.HasPerk(Perk02)) || (iTier == 2 && !PlayerREF.HasPerk(Perk01)) - - _00E_FS_A3_NeedToLearnOtherLevels.Show() - bValidSkilllevel = False - Return False - - Elseif (iTier == 1 && PlayerREF.HasPerk(Perk01)) || (iTier == 2 && PlayerREF.HasPerk(Perk02)) || (iTier == 3 && PlayerREF.HasPerk(Perk03)) - - _00E_FS_A3_AlreadyKnowThisLevel.Show() - bValidSkilllevel = False - Return False - - Else - - bValidSkilllevel = True - - if sClass == "Rogue" - ClassFormList01 = EspionagePerks - ClassFormList02 = TrickeryPerks - ClassFormList03 = VagabondPerks - - Elseif sClass == "Warrior" - ClassFormList01 = BastionPerks - ClassFormList02 = DerwishPerks - ClassFormList03 = RagePerks - - Elseif sClass == "Mage" - ClassFormList01 = ElementalismPerks - ClassFormList02 = LifeAndDeathPerks - ClassFormList03 = ManipulationPerks - EndIf - - int iTotalPointsInRequiredClass = (PlayerSkillMenu.GetPointsInClass(ClassFormList01) + PlayerSkillMenu.GetPointsInClass(ClassFormList02) + PlayerSkillMenu.GetPointsInClass(ClassFormList03)) - if iTotalPointsInRequiredClass >= iRequiredPoints - Return True - Else - Return False - EndIf - - EndIf - -EndFunction - -Function TeachTalent(int iLevel, Shout TaughtTalent, Perk Perk01, Perk Perk02, Perk Perk03, WordOfPower Word01, WordOfPower Word02, WordOfPower Word03, float fRecoveryTime02, float fRecoveryTime03) - - if iLevel == 1 - - PlayerREF.AddPerk(Perk01) - PlayerREF.AddShout(TaughtTalent) - Game.UnlockWord(Word01) - Game.TeachWord(Word01) - - Elseif iLevel == 2 - - PlayerREF.AddPerk(Perk02) - Game.UnlockWord(Word02) - Game.TeachWord(Word02) - SetRecoveryTimeMemoryBook(2, TaughtTalent, fRecoveryTime02, fRecoveryTime03) - - Else - - PlayerREF.AddPerk(Perk03) - Game.UnlockWord(Word03) - Game.TeachWord(Word03) - SetRecoveryTimeMemoryBook(3, TaughtTalent, fRecoveryTime02, fRecoveryTime03) - - EndIf - - TalentPoints.Mod(-1) - - If _00E_AchievementsEnabled.GetValueInt() == 1 - Game.UnlockAchievement("END_TALENT_BOOK_01") - EndIf - -EndFunction - -Function SetRecoveryTimeMemoryBook(int iWord, Shout TaughtTalent, float fRecoveryTime02, float fRecoveryTime03) -{This function handles the issue of cooldowns not depending on the value in the CK but on the duration the player presses the [Shout] key on his keyboard.} - - If iWord == 2 - TaughtTalent.SetNthRecoveryTime(0, fRecoveryTime02) - TaughtTalent.SetNthRecoveryTime(1, fRecoveryTime02) - Else - TaughtTalent.SetNthRecoveryTime(0, fRecoveryTime03) - TaughtTalent.SetNthRecoveryTime(1, fRecoveryTime03) - TaughtTalent.SetNthRecoveryTime(2, fRecoveryTime03) - EndIf - -EndFunction - - -; EQUIPPING SETS - -Function OnArmorSetBonusAdded(Bool bFullSet) - Sound.SetInstanceVolume(MAGIllusionCharm.Play(PlayerREF), 0.4) ; Play MAGIllusionCharm at lower volume - - If bFullSet && bSetAchievementUnlocked == False && _00E_AchievementsEnabled.GetValueInt() == 1 - Game.UnlockAchievement("END_SET_01") - bSetAchievementUnlocked = True - EndIf -EndFunction - -Function OnArmorSetBonusRemoved() - _00E_ArmorSetScript_sSetBonusRemoved.Show() -EndFunction - - - -Float fDefaultHeadTrackTimerOldValue = 0.0 -Float fStayHeadTrackTimerOldValue = 0.0 - -Function StopRandomHeadTracking() - ; Raise "change headtrack target" timers a lot so the NPCs would stare at what the scene tells them, without randomly switching to the player or other NPCs - If fDefaultHeadTrackTimerOldValue == 0.0 - fDefaultHeadTrackTimerOldValue = Game.GetGameSettingFloat("fAIHoldDefaultHeadTrackTimer") - Game.SetGameSettingFloat("fAIHoldDefaultHeadTrackTimer", 1000.0) - EndIf - If fStayHeadTrackTimerOldValue == 0.0 - fStayHeadTrackTimerOldValue = Game.GetGameSettingFloat("fAIStayonScriptHeadtrack") - Game.SetGameSettingFloat("fAIStayonScriptHeadtrack", 1000.0) - EndIf -EndFunction - -Function ResumeRandomHeadTracking() - If fDefaultHeadTrackTimerOldValue > 0.0 - Game.SetGameSettingFloat("fAIHoldDefaultHeadTrackTimer", fDefaultHeadTrackTimerOldValue) - fDefaultHeadTrackTimerOldValue = 0.0 - EndIf - If fStayHeadTrackTimerOldValue > 0.0 - Game.SetGameSettingFloat("fAIStayonScriptHeadtrack", fStayHeadTrackTimerOldValue) - fStayHeadTrackTimerOldValue = 0.0 - EndIf -EndFunction - - -;===================================================================================== -; PROPERTIES -;===================================================================================== - -int Property iMajorClassIndex Auto Conditional Hidden -int Property iMinorClassIndex Auto Conditional Hidden - -bool Property bAllowIdleChatter = True Auto Conditional Hidden ; Set this to true when NPCs shouldn't Idle around - -float Property fPlayerSpeedBeforeVision Auto Hidden -float Property fCameraMaxDistance Auto Hidden -float Property fBaseGravity Auto Hidden - -;Actor akPlayerCopy - -Sound Property _00E_FS_NQR05_SlowMotion_IntroM Auto -Sound Property _00E_FS_NQR05_SlowMotion_OutroM Auto - -ActorBase Property _00E_MC_Jespar Auto -ActorBase Property _00E_MC_Calia Auto -ActorBase Property _00E_SC_Tharael Auto -ActorBase Property _00E_SC_Dijaam Auto -ActorBase Property _00E_MQ11c_Ryneus Auto -ActorBase Property _00E_CapitalCityMaelGroschenfrst Auto -ActorBase Property _00E_MC_Yuslan Auto -ActorBase Property _00E_FS_NQ02_Esme Auto - -GlobalVariable Property SympathyTharael Auto -GlobalVariable Property SympathyJespar Auto -GlobalVariable Property SympathyDijaam Auto -GlobalVariable Property SympathyMaelGroschenfuerst Auto -GlobalVariable Property SympathyCalia Auto -GlobalVariable Property SympathyYuslan Auto -GlobalVariable Property SympathyEsme Auto - -GlobalVariable Property CaliaFlirtCounter Auto -GlobalVariable Property DijaamFlirtCounter Auto -GlobalVariable Property JesparFlirtCounter Auto -GlobalVariable Property TharaelFlirtCounter Auto - -GlobalVariable Property _00E_AchievementsEnabled Auto - -ReferenceAlias Property Levelsystem_SympathyActor Auto - -Formlist Property _00E_AllAmmos Auto - -MiscObject Property Gold001 Auto - -Message Property _00E_PleaseRemoveMoney Auto - -GlobalVariable Property GameHour Auto - -;--------------------------------------VISION-----------------------------------; - -float PlayerSpeed -int VisionSound - -Perk Property _00E_VisionPerk Auto - -SoundCategory Property AudioCategoryFST Auto - -VisualEffect Property MS04MemoryFXBody01VFX Auto -ImageSpaceModifier Property _00E_VisionStartImod Auto -ImageSpaceModifier Property _00E_VisionIMOD Auto -ImageSpaceModifier Property _00E_VisionEndImod Auto -Sound Property _00E_VisionLPM Auto -Sound Property MagRacialBattlecryFire Auto -Sound Property MAGConjurePortalClose Auto - -Spell Property _00E_Vision_UpdateAb Auto - -MusicType Property _00E_SilenceTransitionLowPriority02 Auto -MusicType Property _00E_Music_Special_MQ12b_Samael Auto -MusicType Property _00E_SilenceLongTransitionHighPriority Auto -MusicType Property _00E_SilenceTransitionLowPriority Auto -MusicType Property _00E_SilenceTransitionHighPriority Auto -MusicType Property _00E_SilenceAbruptHighPriority Auto -MusicType Property _00E_Music_Special_TavernSilence Auto - -Formlist Property _00E_MUS_AllCombatSoundtracks Auto - -;--------------------------------------LEVELSYSTEM----------------------------------- - -GlobalVariable Property Handwerkspunkte auto -GlobalVariable Property SympathyRyneus auto -GlobalVariable Property Lernpunkte auto -GlobalVariable Property TalentPoints auto -GlobalVariable Property _00E_DisableQuestTutorials Auto -GlobalVariable Property _00E_DisableSkillTutorials Auto -Keyword Property BrawlKeyword Auto - -Message Property _00E_FS_A3_sYouNeedSkillpoints Auto -Message Property _00E_FS_A3_sIn Auto -Message Property _00E_FS_A3_sToUnlockThisClass Auto -Message Property _00E_FS_A3_sWarriorClassName Auto -Message Property _00E_FS_A3_sRogueClassName Auto -Message Property _00E_FS_A3_sMageClassName Auto -Message Property _00E_FS_A3_NeedToLearnOtherLevels Auto -Message Property _00E_FS_A3_AlreadyKnowThisLevel Auto - -int iPointRequirementTier01 = 5 -int iPointRequirementTier02 = 10 -int iPointRequirementTier03 = 15 - -int iRequiredPoints - -bool bValidSkilllevel - -Formlist Property EspionagePerks Auto -Formlist Property TrickeryPerks Auto -Formlist Property VagabondPerks Auto -Formlist Property BastionPerks Auto -Formlist Property DerwishPerks Auto -Formlist Property RagePerks Auto -Formlist Property ElementalismPerks Auto -Formlist Property LifeAndDeathPerks Auto -Formlist Property ManipulationPerks Auto - -_00E_Game_SkillmenuSC Property PlayerSkillMenu Auto - -Bool _MemoryBookReadLocked = False - -;-------------------------------------TELEPORT SCRIPT----------------------------------- - -VisualEffect Property MGTeleportInEffect Auto -Actor Property PlayerREF Auto -ActorBase Property Player Auto -EffectShader Property TimeFadeOut01FXS Auto -EffectShader Property TimeFadeIn01FXS Auto -Explosion Property _00E_TeleportExplosion Auto -Explosion Property _00E_NPCOorbayaTeleportExplosionBlue Auto - -Idle Property WebIdleExit Auto -Idle Property IdleT02AscendMale Auto -Idle Property IdleT02AscendFemale Auto -Idle Property IdleForceDefaultState Auto - -Static Property XMarkerHeading Auto - -Sound Property _00E_MagicProtectionSpellM Auto -Sound Property _00E_A2_Ghostwalk_TeleportDoneSound Auto -Sound Property _00E_TeleportCastSound Auto - -Message Property _00E_Tutorial_Brawl Auto -Message Property _00E_Tutorial_Companions02_Jespar Auto -Message Property _00E_Tutorial_Companions02_Calia Auto - -Message Property _00E_Levelsystem_sApproves Auto -Message Property _00E_Levelsystem_sAppreciates Auto -Message Property _00E_Levelsystem_sAppreciatesALot Auto -Message Property _00E_Levelsystem_sDislikes Auto -Message Property _00E_Levelsystem_sHurt Auto -Message Property _00E_Levelsystem_sVeryHurt Auto -Message Property _00E_Levelsystem_sDoesNotTrust Auto -Message Property _00E_Levelsystem_sExtremelyHurt Auto -Message Property _00E_Levelsystem_sIsHurt Auto - -Message Property _00E_Levelsystem_sSynergyDiscovered Auto -Message Property _00E_Levelsystem_sNoMoreCraftingPoints Auto -Message Property _00E_Levelsystem_sNoMoreLearningPoints Auto -Message Property _00E_Levelsystem_sSkillTooWellDeveloped Auto -Message Property _00E_Levelsystem_sSkillBy Auto -Message Property _00E_Levelsystem_sSkillTo Auto -Message Property _00E_Levelsystem_sSkillFrom Auto -Message Property _00E_Levelsystem_sSkillIncreased Auto -Message Property _00E_Levelsystem_sAbilityEnemyLevelTooHigh Auto -Message Property _00E_Levelsystem_sAbilityEnemyHasToBeAlive Auto -Message Property _00E_Levelsystem_sEnemyHasToBeDead Auto -Message Property _00E_Levelsystem_sAbilityEnemyTooFarAway Auto -Message Property _00E_Levelsystem_sAbilityTargetImmune Auto -Message Property _00E_Levelsystem_sAbilityMarkingRemoved Auto -Message Property _00E_Levelsystem_sEnemyMarked Auto -Message Property _00E_Levelsystem_sAbilityStanceStarted Auto -Message Property _00E_Levelsystem_sAbilityStanceEnded Auto -Message Property _00E_Levelsystem_sAbilityStanceQyrai Auto -Message Property _00E_Levelsystem_sAbilityStanceSkaragg Auto -Message Property _00E_Levelsystem_sEnemyAlreadyMarked Auto -Message Property _00E_Levelsystem_sEldritchBloodVictimMarked Auto -Message Property _00E_Levelsystem_sEldritchBloodAttackTargetMarked Auto -Message Property _00E_Levelsystem_sEldritchBloodAttackVictimMarkingRemoved Auto -Message Property _00E_Levelsystem_sEldritchBloodVictimMarkingRemoved Auto -Message Property _00E_Levelsystem_sGhostwalkEnemyTooCloseToWall Auto - -ObjectReference Property PlayerVisionStartMarker Auto Hidden -ObjectReference Property PlayerVisionFailsaveMarker Auto Hidden -ObjectReference Property VisionLight Auto Hidden - -ObjectReference Property _00E_RemoveAllItems_TrashContainer Auto - -Idle Property IdleMagic_01 Auto - -Spell Property _00E_Vision_NoTimeSpell Auto -Spell Property _00E_Vision_NoTimeSubtleSpell Auto -Spell Property _00E_Vision_TimeSpell Auto -Spell Property _00E_PriestCureDiseases Auto -Spell Property _00E_FS_NQR05_SlowMotionSP Auto - -GlobalVariable Property _00E_HeadtrackGlobal Auto - -ImageSpaceModifier Property FadeToBlackIMOD Auto -ImageSpaceModifier Property FadeToBlackHoldIMOD Auto -ImageSpaceModifier Property FadeToBlackBackIMOD Auto -ImageSpaceModifier Property _00E_NPCTeleportExplosionIMOD Auto -ImageSpaceModifier Property _00E_TeleportImod Auto -ImageSpaceModifier Property _00E_VisionStartTimestopIMOD Auto -ImageSpaceModifier Property _00E_MQ16_VisionIMOD Auto - -ShaderParticleGeometry Property _00E_VisionShaderParticles Auto - -SoundCategory Property AudioCategoryAMB Auto -SoundCategory Property AudioCategoryAMBr Auto -SoundCategory Property AudioCategorySFX Auto - -Static Property XMarker Auto - -int doOnce -int done -float SpeedBefore - -bool bUnlockedSynergyAchievement - -;for re-equipping the player after the bathouse scene -Armor PlayerHelmet -Armor PlayerCuirass -Armor PlayerGauntlets -Armor PlayerBoots -Armor PlayerRing01 -Armor PlayerRing02 -Armor PlayerNecklace -Weapon RightHandWeapon -Weapon LeftHandWeapon -Spell RightHandSpell -Spell LeftHandSpell -Armor Shield - -;for VoiceLetters -MusicType MTToRemove - -;for sets -Sound Property MAGIllusionCharm Auto -Message Property _00E_ArmorSetScript_sSetBonusRemoved Auto -bool bSetAchievementUnlocked = false diff --git a/source/scripts/_00e_gaboff_grammophonesc.psc b/source/scripts/_00e_gaboff_grammophonesc.psc index c394488e..beb7f698 100644 --- a/source/scripts/_00e_gaboff_grammophonesc.psc +++ b/source/scripts/_00e_gaboff_grammophonesc.psc @@ -1,40 +1,132 @@ Scriptname _00E_Gaboff_GrammophoneSC extends ObjectReference -Event OnUpdate() +Message Property _00E_Gaboff_GrammophoneMSG Auto +Message Property _00E_PlayerhousingKoppophonVolume Auto +Sound Property _00E_MUS_Special_OceansWidowM Auto +MiscObject Property Gold001 Auto +Actor Property PlayerREF Auto + +Int iSoundID = -1 +Float fVolume = 0.5 +Bool bMusicLocked = False + +Float Property MUSIC_LENGTH = 212.3 AutoReadOnly + + +;===================================================================================== +; FUNCTIONS +;===================================================================================== + +Function PlayMusic(Sound musicSound, Float fMusicLength) + If fVolume <= 0.0 || fVolume > 1.0 + fVolume = 0.5 + EndIf + RegisterForModEvent("BardsLoadGame", "OnBardsLoadGame") + iSoundID = musicSound.Play(Self) + Sound.SetInstanceVolume(iSoundID, fVolume) + RegisterForSingleUpdate(_00E_QuestFunctions.AdjustTimePeriodByEngineTimerError(fMusicLength)) + GoToState("") + _00E_PlayerhousingKoppophonVolume.Show(fVolume * 100.0) +EndFunction + +Function ChangeMusicVolume() + If fVolume >= 0.0 && fVolume < 1.0 + fVolume += 0.25 + Else ; fVolume >= 1.0 or something is wrong with fVolume + fVolume = 0.0 + EndIf + Sound.SetInstanceVolume(iSoundID, fVolume) + _00E_PlayerhousingKoppophonVolume.Show(fVolume * 100.0) +EndFunction + +Function StopMusic() + bMusicLocked = True + + GoToState("DoneCleanup") + UnregisterForModEvent("BardsLoadGame") + UnregisterForUpdate() + + If iSoundID != -1 + Sound.StopInstance(iSoundID) + iSoundID = -1 + EndIf + + bMusicLocked = False +EndFunction + +Function TryStopMusic() + If bMusicLocked == False + StopMusic() + Else + RegisterForSingleUpdate(0.5) + EndIf +EndFunction - bIsPlaying = False +;===================================================================================== +; EVENTS +;===================================================================================== + +Event OnInit() + GoToState("DoneCleanup") EndEvent Event OnActivate(ObjectReference akActionRef) + If akActionRef == PlayerREF && bMusicLocked == False + bMusicLocked = True - If !bIsPlaying - - int iButton = _00E_Gaboff_GrammophoneMSG.Show() - - if iButton == 0 - - bIsPlaying = True - PlayerREF.RemoveItem(Gold001, 5) - _00E_MUS_Special_OceansWidowM.Play(Self) - RegisterForSingleUpdate(160) - + If iSoundID == -1 + If _00E_Gaboff_GrammophoneMSG.Show() == 0 + PlayerREF.RemoveItem(Gold001, 5) + PlayMusic(_00E_MUS_Special_OceansWidowM, MUSIC_LENGTH) + EndIf Else - - Return - + ChangeMusicVolume() EndIf - + + bMusicLocked = False EndIf - EndEvent -bool bIsPlaying +Event OnUpdate() + TryStopMusic() +EndEvent -Actor Property PlayerREF Auto +Event OnBardsLoadGame(string eventName, string strArg, float numArg, Form sender) + ; Player just loaded a save with the gramophone playing. The sound is dead by now. + TryStopMusic() +EndEvent -MiscObject Property Gold001 Auto +Event OnCellAttach() + TryStopMusic() +EndEvent -Message Property _00E_Gaboff_GrammophoneMSG Auto +Event OnLoad() + TryStopMusic() +EndEvent + +Event OnCellDetach() + TryStopMusic() +EndEvent + +Event OnUnload() + TryStopMusic() +EndEvent + +State DoneCleanup + Event OnCellAttach() + ; Do nothing + EndEvent + + Event OnLoad() + ; Do nothing + EndEvent + + Event OnCellDetach() + ; Do nothing + EndEvent -Sound Property _00E_MUS_Special_OceansWidowM Auto \ No newline at end of file + Event OnUnload() + ; Do nothing + EndEvent +EndState diff --git a/source/scripts/_00e_game_playerhouse_boardsc.psc b/source/scripts/_00e_game_playerhouse_boardsc.psc index 733ade9e..5297a5c8 100644 --- a/source/scripts/_00e_game_playerhouse_boardsc.psc +++ b/source/scripts/_00e_game_playerhouse_boardsc.psc @@ -104,8 +104,8 @@ function OnActivate(ObjectReference akActionRef) EndIf elseif iButton == 6 - - PlayerhousingMaster.ShowTutorial() + + _00E_PlayerhousingMaster.GetMaster().ShowExpansionBoardTutorial() endIf @@ -184,4 +184,3 @@ Message Property _00E_Game_PlayerHouse_RemoveFurniture Auto _00E_NQ24_Playerhousing_Functions Property NQ24 Auto _00E_PlayerHousing_CellNameSC Property Player Auto -_00E_PlayerhousingTutorial Property PlayerhousingMaster Auto \ No newline at end of file diff --git a/source/scripts/_00e_placeablegrammophonplay.psc b/source/scripts/_00e_placeablegrammophonplay.psc index c28ab841..4a428c87 100644 --- a/source/scripts/_00e_placeablegrammophonplay.psc +++ b/source/scripts/_00e_placeablegrammophonplay.psc @@ -1,63 +1,161 @@ Scriptname _00E_PlaceableGrammophonPlay extends ObjectReference -Sound Property soundToPlay Auto -MusicType Property _00E_SilenceTransitionHighPriority Auto +Sound Property _00E_MUS_Placeable_Koppophon Auto +MusicType Property _00E_SilenceTransitionHighPriority Auto ; OBSOLETE. Left for version update on older saves. +MusicType Property _00E_SilenceKoppophon Auto GlobalVariable Property _00E_AchievementsEnabled Auto Message Property _00E_PlayerhousingKoppophonVolume Auto -bool bDone -float Property soundLengthInSeconds Auto +Actor Property PlayerREF Auto -int playbackId = -1 -float volume = 0.5 -bool bmuted = true +Int playbackId = -1 +Float volume = 0.5 +Bool bDone ; Unlocked END_KOPPOPHON_01 achievement +Bool bMusicLocked = False +Bool bOldSilenceUpdated = False -Event OnCellAttach() - playbackId = -1 - bmuted = true -Endevent +Float Property MUSIC_LENGTH = 87.2 AutoReadOnly -Event OnLoad() - playbackId = -1 - bmuted = true -Endevent -Event OnCellDetach() - _00E_SilenceTransitionHighPriority.Remove() - Sound.StopInstance(playbackId) - playbackId = -1 +;===================================================================================== +; FUNCTIONS +;===================================================================================== + +Function StopMusic() + bMusicLocked = True + + UnregisterForModEvent("BardsLoadGame") UnregisterForUpdate() -Endevent + + If bOldSilenceUpdated == False + bOldSilenceUpdated = True + If playbackId != -1 + _00E_SilenceTransitionHighPriority.Remove() + EndIf + EndIf + + If playbackId != -1 + Sound.StopInstance(playbackId) + playbackId = -1 + EndIf + + _00E_SilenceKoppophon.Remove() + + bMusicLocked = False +EndFunction + +Function TryStopMusic() + If bMusicLocked == False + StopMusic() + Else + RegisterForSingleUpdate(0.5) + EndIf +EndFunction + +Function Cleanup() + GoToState("DoneCleanup") + TryStopMusic() +EndFunction + + +;===================================================================================== +; EVENTS +;===================================================================================== + +Event OnInit() + GoToState("DoneCleanup") +EndEvent Event OnActivate(ObjectReference triggerRef) - if playbackId == -1 - playbackId = soundToPlay.Play(Self) - RegisterForSingleUpdate(soundLengthInSeconds) - If volume == 0 - volume = 0.5 - endif - Sound.setInstanceVolume(playbackId, volume) - _00E_SilenceTransitionHighPriority.Add() - If _00E_AchievementsEnabled.GetValueInt() == 1 && !bDone - bDone = true - Game.UnlockAchievement("END_KOPPOPHON_01") + If triggerRef == PlayerREF && _00E_PlayerhousingMaster.ReferenceCanBeActivated(Self) && bMusicLocked == False + bMusicLocked = True + + If playbackId == -1 ; Start playing + bOldSilenceUpdated = True + RegisterForModEvent("BardsLoadGame", "OnBardsLoadGame") + + _00E_SilenceKoppophon.Add() + + playbackId = _00E_MUS_Placeable_Koppophon.Play(Self) + If volume <= 0.0 || volume > 1.0 + volume = 0.5 + EndIf + Sound.SetInstanceVolume(playbackId, volume) + RegisterForSingleUpdate(_00E_QuestFunctions.AdjustTimePeriodByEngineTimerError(MUSIC_LENGTH)) + + GoToState("") + + _00E_PlayerhousingKoppophonVolume.Show(volume * 100.0) + + If _00E_AchievementsEnabled.GetValueInt() == 1 && (bDone == False) + bDone = True + Game.UnlockAchievement("END_KOPPOPHON_01") + EndIf + + ElseIf bOldSilenceUpdated == False + ; Player just loaded an older save with the Koppophon playing. The sound is dead by now. + StopMusic() + + Else ; Volume control + Float fNewVolume = volume + 0.25 + If fNewVolume > 1.0 + fNewVolume = 0.0 + EndIf + + Sound.SetInstanceVolume(playbackId, fNewVolume) + If fNewVolume == 0.0 ; On mute + _00E_SilenceKoppophon.Remove() + ElseIf volume == 0.0 ; On unmute + _00E_SilenceKoppophon.Add() + EndIf + volume = fNewVolume + + _00E_PlayerhousingKoppophonVolume.Show(volume * 100.0) + EndIf - else - volume = volume + 0.25 - if volume > 1 - volume = 0 - bmuted = false - _00E_SilenceTransitionHighPriority.Remove() - elseif bmuted == false - bmuted = true - _00E_SilenceTransitionHighPriority.Add() - Endif - Sound.SetInstanceVolume(playbackId, volume) - Endif - _00E_PlayerhousingKoppophonVolume.Show(volume*100) -Endevent + + bMusicLocked = False + EndIf +EndEvent Event OnUpdate() - _00E_SilenceTransitionHighPriority.Remove() - Sound.StopInstance(playbackId) - playbackId = -1 -Endevent \ No newline at end of file + TryStopMusic() +EndEvent + +Event OnBardsLoadGame(string eventName, string strArg, float numArg, Form sender) + ; Player just loaded a save with the Koppophon playing. The sound is dead by now. + TryStopMusic() +EndEvent + +Event OnCellAttach() + Cleanup() +EndEvent + +Event OnLoad() + Cleanup() +EndEvent + +Event OnCellDetach() + Cleanup() +EndEvent + +Event OnUnload() + Cleanup() +EndEvent + +State DoneCleanup + Event OnCellAttach() + ; Do nothing + EndEvent + + Event OnLoad() + ; Do nothing + EndEvent + + Event OnCellDetach() + ; Do nothing + EndEvent + + Event OnUnload() + ; Do nothing + EndEvent +EndState diff --git a/source/scripts/_00e_playerhousing_furniture.psc b/source/scripts/_00e_playerhousing_furniture.psc index caa89086..f5717f8f 100644 --- a/source/scripts/_00e_playerhousing_furniture.psc +++ b/source/scripts/_00e_playerhousing_furniture.psc @@ -1,25 +1,48 @@ scriptname _00E_Playerhousing_Furniture extends ObjectReference {A manipulatable housing object while being in the world} -_00E_Playerhousing_FurnitureItem Property furnitureItem auto hidden -{Set by Playerhousing_FurnitureItem when placing this Furniture} - -_00E_Playerhousing_FurnitureItem function getFurnitureItem() - return furnitureItem -Endfunction - -bool function shouldActivateBePossible() - return !((self as ObjectReference) as _00E_Playerhousing_FurnitureItem) ; if the _00E_Playerhousing_FurnitureItem script is on this object, activating means taking -Endfunction - -function finishPlacement() -{this function is called when the furniture object is at the right position and being placed; use e.g. for light} - blockActivation(true) - disable() - enable() +Float Property CustomDistance Auto +{ Custom distance from the player in the placemenet Move Mode } +Float Property OffsetAngleZ Auto +{ Custom offset Z rotation in the placemenet Move Mode } +Float Property OffsetPositionZ Auto +{ Custom offset Z position in the placemenet Move Mode } +Bool Property IsSetPositionIncompatible Auto +{ If the .nif of the object has a bhkCollisionObject with SET_LOCAL flag, SetPosition() or MoveTo() can easily mess this object up in the placement mode. } + +Form Property InventoryItem Auto Hidden + +_00E_Playerhousing_FurnitureItem Property furnitureItem Auto Hidden +{ OBSOLETE. Left for compatibility with older saves. } + +Form Function GetInventoryItem() + If furnitureItem ; Update from the old way of storing the base inventory item + If InventoryItem == None + InventoryItem = furnitureItem.GetBaseObject() + EndIf + furnitureItem = None + EndIf + + Return InventoryItem +EndFunction + +Function finishPlacement() + ; This function is called when the furniture object is at the right position and being placed. + + SetMotionType(Motion_Dynamic, True) + ; in case we place a mannequin, we need to store its position - If self.GetBaseObject() == Game.GetFormFromFile(0x00141028, "Skyrim.esm") - ObjectReference akNPC = self as ObjectReference - (akNPC as _00E_Playerhousing_MannequinControl).setForcePosition(akNPC.GetPositionX(), akNPC.GetPositionY(), akNPC.GetPositionZ(), akNPC.GetAngleX(), akNPC.GetAngleY(), akNPC.GetAngleZ()) + ObjectReference myObjRef = self as ObjectReference + If myObjRef as _00E_Playerhousing_MannequinControl + (myObjRef as _00E_Playerhousing_MannequinControl).FinishPlacement() + Else + BlockActivation(true) + Disable() + Utility.Wait(0.1) + Enable() + + If myObjRef as _00E_Phasmalist_Workbench + (myObjRef as _00E_Phasmalist_Workbench).FinishPlacement() + EndIf EndIf -Endfunction +EndFunction diff --git a/source/scripts/_00e_playerhousing_furnitureitem.psc b/source/scripts/_00e_playerhousing_furnitureitem.psc index 8d5d00af..30ea0540 100644 --- a/source/scripts/_00e_playerhousing_furnitureitem.psc +++ b/source/scripts/_00e_playerhousing_furnitureitem.psc @@ -1,8 +1,8 @@ scriptname _00E_Playerhousing_FurnitureItem extends ObjectReference {A manipulatable housing object while being in the players inventory} -Actorbase Property _MANNEQUIN_toCreate auto -furniture Property _FURNITURE_toCreate auto +ActorBase Property _MANNEQUIN_toCreate auto +Furniture Property _FURNITURE_toCreate auto Container Property _CONTAINER_toCreate auto Light Property _LIGHT_toCreate auto MiscObject Property _MISC_toCreate Auto @@ -11,42 +11,33 @@ Activator Property _ACTIVATOR_toCreate Auto _00E_PlayerhousingMaster Property master Auto Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) - if akNewContainer == none - if master == none - Debug.messagebox("ERROR: PlayerhousingMaster property in Playerhousingfurnitureitem is missing, please write a bugticket") - return - endif - - if master.canPlaceItem() - master.playerItemDropped(Self) - else - master.cannotPlaceObjectHere.show() - Game.getplayer().additem((self ), 1, true) - endif - endif -ENDevent + If akNewContainer == None + If master == None + master = _00E_PlayerhousingMaster.GetMaster() + EndIf + master.playerItemDropped(Self) + EndIf +EndEvent -_00E_Playerhousing_Furniture function placeFurnitureAtMe() +_00E_Playerhousing_Furniture Function placeFurnitureAtMe() _00E_Playerhousing_Furniture result = None - if _MANNEQUIN_toCreate - result = placeAtMe(_MANNEQUIN_toCreate, abForcePersist = true) as _00E_Playerhousing_Furniture - elseif _FURNITURE_toCreate - result = placeAtMe(_FURNITURE_toCreate) as _00E_Playerhousing_Furniture - elseif _CONTAINER_toCreate - result = placeAtMe(_CONTAINER_toCreate) as _00E_Playerhousing_Furniture - elseif _LIGHT_toCreate - result = placeAtMe(_LIGHT_toCreate) as _00E_Playerhousing_Furniture - elseif _ACTIVATOR_toCreate - result = placeAtMe(_ACTIVATOR_toCreate) as _00E_Playerhousing_Furniture - elseif _MISC_toCreate - result = placeAtMe(_MISC_toCreate) as _00E_Playerhousing_Furniture - else - Debug.MessageBox("ERROR: *_toCreate property in playerhousingfurnitureitem is missing, please write a bugticket") - return None - ENDif - if result == None + If _MANNEQUIN_toCreate + result = PlaceAtMe(_MANNEQUIN_toCreate, abForcePersist = True, abInitiallyDisabled = True) as _00E_Playerhousing_Furniture + ElseIf _FURNITURE_toCreate + result = PlaceAtMe(_FURNITURE_toCreate, abInitiallyDisabled = True) as _00E_Playerhousing_Furniture + ElseIf _CONTAINER_toCreate + result = PlaceAtMe(_CONTAINER_toCreate, abInitiallyDisabled = True) as _00E_Playerhousing_Furniture + ElseIf _LIGHT_toCreate + result = PlaceAtMe(_LIGHT_toCreate, abInitiallyDisabled = True) as _00E_Playerhousing_Furniture + ElseIf _ACTIVATOR_toCreate + result = PlaceAtMe(_ACTIVATOR_toCreate, abInitiallyDisabled = True) as _00E_Playerhousing_Furniture + ElseIf _MISC_toCreate + result = PlaceAtMe(_MISC_toCreate, abInitiallyDisabled = True) as _00E_Playerhousing_Furniture + EndIf + + If result == None Debug.MessageBox("ERROR: *_toCreate property in playerhousingfurnitureitem is no furnitureitem, please write a bugticket") - Endif - result.furnitureItem = Self - return result -ENDfunction + EndIf + + Return result +EndFunction \ No newline at end of file diff --git a/source/scripts/_00e_playerhousing_lightfurniture.psc b/source/scripts/_00e_playerhousing_lightfurniture.psc index 09d7ed98..e61375f6 100644 --- a/source/scripts/_00e_playerhousing_lightfurniture.psc +++ b/source/scripts/_00e_playerhousing_lightfurniture.psc @@ -2,7 +2,7 @@ Scriptname _00E_Playerhousing_LightFurniture extends _00E_Playerhousing_Furnitur Light Property LIGHT_toCreate auto {not used due to graphic bugs} -ObjectReference createdLight +; ObjectReference createdLight function finishPlacement() {this function is called when the furniture object is at the right position and being placed; use e.g. for light} @@ -13,9 +13,11 @@ function finishPlacement() ;createdLight.setScale(0.99) Endfunction +;/ Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) if akOldContainer== None createdLight.disable() createdLight.delete() Endif Endevent +/; \ No newline at end of file diff --git a/source/scripts/_00e_playerhousing_mannequincontrol.psc b/source/scripts/_00e_playerhousing_mannequincontrol.psc index f9c4fa7b..8b70a7b1 100644 --- a/source/scripts/_00e_playerhousing_mannequincontrol.psc +++ b/source/scripts/_00e_playerhousing_mannequincontrol.psc @@ -2,292 +2,230 @@ Scriptname _00E_Playerhousing_MannequinControl extends Actor import utility -Form Property ArmorSlot01 auto hidden -Form Property ArmorSlot02 auto hidden -Form Property ArmorSlot03 auto hidden -Form Property ArmorSlot04 auto hidden -Form Property ArmorSlot05 auto hidden -Form Property ArmorSlot06 auto hidden -Form Property ArmorSlot07 auto hidden -Form Property ArmorSlot08 auto hidden -Form Property ArmorSlot09 auto hidden -Form Property ArmorSlot10 auto hidden - -Armor Property ArmorRefresh auto - Actor Property PlayerREF Auto -Form Property EmptySlot auto hidden +Bool bIsInPlacementMode = False +Bool bActivationBlocked = False -MiscObject Property _00E_Placeable_Mannequin Auto -Message Property _00E_MannequinInteractMSG Auto +;===================================================================================== +; EVENTS +;===================================================================================== -;int Property CurrentPose = 1 Auto -{The pose the Mannequin starts in, and is currently in. DEFAULT = 1} +Event OnCellLoad() + If bIsInPlacementMode == False + ResetOnLoad() + EndIf +EndEvent -float forceX -float forceY -float forceZ -float forceAngleX -float forceAngleY -float forceAngleZ +Event OnLoad() + If bIsInPlacementMode + ResetOnLoad() + EndIf +EndEvent -;===================================================================================== -; EVENTS -;===================================================================================== +Event OnActivate(ObjectReference TriggerRef) + If TriggerRef == PlayerREF && _00E_PlayerhousingMaster.ReferenceCanBeActivated(self) && bActivationBlocked == False + bActivationBlocked = True -EVENT OnInit() - - self.BlockActivation() - PrepareForcePosition() - -EndEVENT + ConvertArmorSlots() ; Version update -EVENT OnCellLoad() - - If !(self.IsActivationBlocked()) - self.BlockActivation() + OpenInventory(True) + ResetPosition() + Wait(0.1) + EnableAI(False) + + bActivationBlocked = False EndIf - - PrepareForcePosition() - -EndEVENT +EndEvent -EVENT OnActivate(ObjectReference TriggerRef) - - If self.IsActivationBlocked() - int iButton = _00E_MannequinInteractMSG.Show() - - If iButton == 0 - self.OpenInventory(true) - wait(0.1) - self.EnableAI(false) +Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) + If (akBaseItem as Armor) + If TryRegisterAddedArmor(akBaseItem) + EquipItem(akBaseItem) Else - self.RemoveAllItems(PlayerREF) - Wait(0.5) - PlayerREF.addItem(_00E_Placeable_Mannequin, 1, true) - PlayerREF.DropObject(_00E_Placeable_Mannequin, 1) - self.disable() - self.delete() + ;Turn it back if the mannequin has one of these already, or if all the slots are full. + RemoveItem(akBaseItem, aiItemCount, True, PlayerREF) EndIf + Else + RemoveItem(akBaseItem, aiItemCount, True, PlayerREF) + EndIf +EndEvent + +Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) + If (akBaseObject as Armor) + UnregisterRemovedArmor(akBaseObject) EndIf +EndEvent -EndEVENT -EVENT OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) - - if (akBaseItem as Armor) - if akBaseItem != ArmorRefresh - AddToArmorSlot(akBaseItem) - self.EquipItem(akBaseItem) - endif - else - self.RemoveItem(akBaseItem, aiItemCount, true, PlayerREF) - endif +;===================================================================================== +; 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 -endEVENT + ; 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 -EVENT OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) - if (akBaseObject as Armor) - RemoveFromArmorSlot(akBaseObject) - endif -endEVENT ;===================================================================================== -; FUNCTIONS +; FUNCTIONS ;===================================================================================== -function PrepareForcePosition() +Float forceX +Float forceY +Float forceZ +Float forceAngleX +Float forceAngleY +Float forceAngleZ - wait(0.25) - self.BlockActivation(true) - ForcePosition() +Bool bPosisionValidated = False -Endfunction +Function ResetPosition() + If bPosisionValidated == False + bPosisionValidated = True -function ForcePosition() + If forceX == 0 && forceY == 0 && forceZ == 0 + Float fAngleZ = PlayerREF.GetAngleZ() + Float fDistanceFromPlayer = 100.0 - self.Enable() - self.EnableAI(false) - - If forceX == 0 && forceY == 0 && forceZ == 0 - forceX = PlayerREF.GetPositionX() - forceY = PlayerREF.GetPositionY() - forceZ = PlayerREF.GetPositionZ() + forceX = PlayerREF.GetPositionX() + fDistanceFromPlayer * Math.sin(fAngleZ) + forceY = PlayerREF.GetPositionY() + fDistanceFromPlayer * Math.cos(fAngleZ) + forceZ = PlayerREF.GetPositionZ() + EndIf EndIf - - wait(0.1) - self.setPosition(forceX, forceY, forceZ) - self.setAngle(forceAngleX,forceAngleY,forceAngleZ) - - self.additem(ArmorRefresh, 1) - self.removeitem(ArmorRefresh, 1) - - EquipCurrentArmor() - -ENDfunction - -function setForcePosition(float x, float y, float z, float angleX, float angleY, float angleZ) - forceX = x - forceY = y - forceZ = z - forceAngleX = angleX - forceAngleY = angleY - forceAngleZ = angleZ -Endfunction - -Function EquipCurrentArmor() - if (ArmorSlot01 != EmptySlot) - self.EquipItem(ArmorSlot01) - endif - if (ArmorSlot02 != EmptySlot) - self.EquipItem(ArmorSlot02) - endif - if (ArmorSlot03 != EmptySlot) - self.EquipItem(ArmorSlot03) - endif - if (ArmorSlot04 != EmptySlot) - self.EquipItem(ArmorSlot04) - endif - if (ArmorSlot05 != EmptySlot) - self.EquipItem(ArmorSlot05) - endif - if (ArmorSlot06 != EmptySlot) - self.EquipItem(ArmorSlot06) - endif - if (ArmorSlot07 != EmptySlot) - self.EquipItem(ArmorSlot07) - endif - if (ArmorSlot08 != EmptySlot) - self.EquipItem(ArmorSlot08) - endif - if (ArmorSlot09 != EmptySlot) - self.EquipItem(ArmorSlot09) - endif - if (ArmorSlot10 != EmptySlot) - self.EquipItem(ArmorSlot10) - endif -endFunction - -Function AddToArmorSlot(Form akBaseItem) - bool FoundEmptySlot = FALSE - - if (ArmorSlot01 == EmptySlot) && (FoundEmptySlot == FALSE) - ArmorSlot01 = akBaseItem - FoundEmptySlot = TRUE - endif - - if (ArmorSlot02 == EmptySlot) && (FoundEmptySlot == FALSE) - ArmorSlot02 = akBaseItem - FoundEmptySlot = TRUE - endif - - if (ArmorSlot03 == EmptySlot) && (FoundEmptySlot == FALSE) - ArmorSlot03 = akBaseItem - FoundEmptySlot = TRUE - endif - - if (ArmorSlot04 == EmptySlot) && (FoundEmptySlot == FALSE) - ArmorSlot04 = akBaseItem - FoundEmptySlot = TRUE - endif - - if (ArmorSlot05 == EmptySlot) && (FoundEmptySlot == FALSE) - ArmorSlot05 = akBaseItem - FoundEmptySlot = TRUE - endif - - if (ArmorSlot06 == EmptySlot) && (FoundEmptySlot == FALSE) - ArmorSlot06 = akBaseItem - FoundEmptySlot = TRUE - endif - - if (ArmorSlot07 == EmptySlot) && (FoundEmptySlot == FALSE) - ArmorSlot07 = akBaseItem - FoundEmptySlot = TRUE - endif - - if (ArmorSlot08 == EmptySlot) && (FoundEmptySlot == FALSE) - ArmorSlot08 = akBaseItem - FoundEmptySlot = TRUE - endif - - if (ArmorSlot09 == EmptySlot) && (FoundEmptySlot == FALSE) - ArmorSlot09 = akBaseItem - FoundEmptySlot = TRUE - endif - - if (ArmorSlot10 == EmptySlot) && (FoundEmptySlot == FALSE) - ArmorSlot10 = akBaseItem - FoundEmptySlot = TRUE - endif - FoundEmptySlot = FALSE -endFunction -Function RemoveFromArmorSlot(Form akBaseItem) - ;Trace("DARYL - " + self + " Running the RemoveFromArmorSlot Function") + SetPosition(forceX, forceY, forceZ) + SetAngle(forceAngleX, forceAngleY, forceAngleZ) +EndFunction - bool FoundMatchingSlot = FALSE - - if (ArmorSlot01 == akBaseItem) && (FoundMatchingSlot == FALSE) - ;Trace("DARYL - " + self + " Match Found, Removing " + akBaseItem + " from armor slot 01") - ArmorSlot01 = EmptySlot - FoundMatchingSlot = TRUE - endif - - if (ArmorSlot02 == akBaseItem) && (FoundMatchingSlot == FALSE) - ;Trace("DARYL - " + self + " Match Found, Removing " + akBaseItem + " from armor slot 02") - ArmorSlot02 = EmptySlot - FoundMatchingSlot = TRUE - endif - - if (ArmorSlot03 == akBaseItem) && (FoundMatchingSlot == FALSE) - ;Trace("DARYL - " + self + " Match Found, Removing " + akBaseItem + " from armor slot 03") - ArmorSlot03 = EmptySlot - FoundMatchingSlot = TRUE - endif - - if (ArmorSlot04 == akBaseItem) && (FoundMatchingSlot == FALSE) - ;Trace("DARYL - " + self + " Match Found, Removing " + akBaseItem + " from armor slot 04") - ArmorSlot04 = EmptySlot - FoundMatchingSlot = TRUE - endif - - if (ArmorSlot05 == akBaseItem) && (FoundMatchingSlot == FALSE) - ;Trace("DARYL - " + self + " Match Found, Removing " + akBaseItem + " from armor slot 05") - ArmorSlot05 = EmptySlot - FoundMatchingSlot = TRUE - endif - - if (ArmorSlot06 == akBaseItem) && (FoundMatchingSlot == FALSE) - ;Trace("DARYL - " + self + " Match Found, Removing " + akBaseItem + " from armor slot 06") - ArmorSlot06 = EmptySlot - FoundMatchingSlot = TRUE - endif - - if (ArmorSlot07 == akBaseItem) && (FoundMatchingSlot == FALSE) - ;Trace("DARYL - " + self + " Match Found, Removing " + akBaseItem + " from armor slot 07") - ArmorSlot07 = EmptySlot - FoundMatchingSlot = TRUE - endif - - if (ArmorSlot08 == akBaseItem) && (FoundMatchingSlot == FALSE) - ;Trace("DARYL - " + self + " Match Found, Removing " + akBaseItem + " from armor slot 08") - ArmorSlot08 = EmptySlot - FoundMatchingSlot = TRUE - endif - - if (ArmorSlot09 == akBaseItem) && (FoundMatchingSlot == FALSE) - ;Trace("DARYL - " + self + " Match Found, Removing " + akBaseItem + " from armor slot 09") - ArmorSlot09 = EmptySlot - FoundMatchingSlot = TRUE - endif - - if (ArmorSlot10 == akBaseItem) && (FoundMatchingSlot == FALSE) - ;Trace("DARYL - " + self + " Match Found, Removing " + akBaseItem + " from armor slot 10") - ArmorSlot10 = EmptySlot - FoundMatchingSlot = TRUE - endif - -endFunction +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 diff --git a/source/scripts/_00e_playerhousingcurrentomanipulate.psc b/source/scripts/_00e_playerhousingcurrentomanipulate.psc index 49572393..ff095ced 100644 --- a/source/scripts/_00e_playerhousingcurrentomanipulate.psc +++ b/source/scripts/_00e_playerhousingcurrentomanipulate.psc @@ -1,31 +1,336 @@ Scriptname _00E_PlayerhousingCurrentOManipulate extends ReferenceAlias -float deltaTranslationZ = 0.0 -float deltaRotation = 0.0 - -;translations needs to be extracted from the rest of the code due to performance reasons (don't know why exactely, but defining new functions slows this down dramatically) -;the registerForControl / unregisterForControl are called in _00E_PlayerhousingMaster - -Event onControlDown(String control) - getRef().stopTranslation() - if control == "Forward" - deltaTranslationZ = 100 - elseif control == "Back" - deltaTranslationZ = -100 - elseif control == "strafe left" - deltaRotation = 100 - elseif control == "strafe right" - deltaRotation = -100 - Endif - getRef().translateTo(getRef().getPositionX(), getRef().getPositionY(), getRef().getPositionZ() + deltaTranslationZ, getRef().getAngleX(), getRef().getAngleY(), getRef().getAngleZ() + deltaRotation, 100, 100) -Endevent - -Event onControlUp(String control, float holdTime) - getRef().stopTranslation() - if control == "Forward" || control == "Back" - deltaTranslationZ = 0 - elseif control == "strafe left" || control == "strafe right" - deltaRotation = 0 - Endif - getRef().translateTo(getRef().getPositionX(), getRef().getPositionY(), getRef().getPositionZ() + deltaTranslationZ, getRef().getAngleX(), getRef().getAngleY(), getRef().getAngleZ() + deltaRotation, 100, 100) -Endevent +EffectShader Property _00E_PlayerHousingManipulationShader Auto +Sound Property UIMenuPrevNext Auto +Actor Property PlayerRef Auto + +String Property CONTROL_TURN_LEFT = "Strafe Left" AutoReadOnly +String Property CONTROL_TURN_RIGHT = "Strafe Right" AutoReadOnly +String Property CONTROL_MOVE_UP = "Forward" AutoReadOnly +String Property CONTROL_MOVE_DOWN = "Back" AutoReadOnly + +Int Property TRANSLATION_TURN_LEFT = 0 AutoReadOnly +Int Property TRANSLATION_TURN_RIGHT = 1 AutoReadOnly +Int Property TRANSLATION_MOVE_UP = 2 AutoReadOnly +Int Property TRANSLATION_MOVE_DOWN = 3 AutoReadOnly + +Int Property STATE_IDLE = 0 AutoReadOnly +Int Property STATE_UPDATING = 1 AutoReadOnly +Int Property STATE_WORKING = 2 AutoReadOnly + +Float Property ROTATION_SPEED_START = 15.0 AutoReadOnly +Float Property ROTATION_SPEED_FALLBACK = 20.0 AutoReadOnly +Float Property ROTATION_SPEED_MAX = 180.0 AutoReadOnly +Float Property ROTATION_SPEED_CHANGE_MOD = 0.25 AutoReadOnly +Float Property ROTATION_MAX = 90.0 AutoReadOnly + +Float Property MOVEMENT_SPEED_START = 10.0 AutoReadOnly +Float Property MOVEMENT_SPEED_FALLBACK = 20.0 AutoReadOnly +Float Property MOVEMENT_SPEED_MAX = 200.0 AutoReadOnly +Float Property MOVEMENT_SPEED_CHANGE_MOD = 0.25 AutoReadOnly +Float Property MOVEMENT_MAX = 100.0 AutoReadOnly + +Float Property FAST_TRANSLATION_SPEED = 1000000.0 AutoReadOnly + +Float fObjectPosX +Float fObjectPosY +Float fObjectPosZ +Float fObjectAngleX +Float fObjectAngleY +Float fObjectAngleZ +Float fPlayerPosZ +Float fTablePosZ + +Float fTranslationSpeed +Float fTranslationSpeedIncrease + +Int iWorkingState +Int iCurrentTranslation +Bool bGamepadMode +Int iWatchedKeyCode +Int iTurnLeftKey +Int iTurnRightKey +Int iMoveUpKey +Int iMoveDownKey + +Function Setup(ObjectReference curObjectRef) + ForceRefTo(curObjectRef) + + iWorkingState = STATE_IDLE + + bGamepadMode = Game.UsingGamepad() + If bGamepadMode == False + iTurnLeftKey = Input.GetMappedKey(CONTROL_TURN_LEFT, 0) + iTurnRightKey = Input.GetMappedKey(CONTROL_TURN_RIGHT, 0) + iMoveUpKey = Input.GetMappedKey(CONTROL_MOVE_UP, 0) + iMoveDownKey = Input.GetMappedKey(CONTROL_MOVE_DOWN, 0) + Else + iTurnLeftKey = 274 + iTurnRightKey = 275 + iMoveUpKey = 280 + iMoveDownKey = 281 + EndIf + + If PlayerRef == None ; Just in case + PlayerRef = Game.GetPlayer() + EndIf + + fPlayerPosZ = PlayerRef.GetPositionZ() + fTablePosZ = fPlayerPosZ + 64.0 + + GoToState("Working") + + TryRegisterForKey(iTurnLeftKey, CONTROL_TURN_LEFT) + TryRegisterForKey(iTurnRightKey, CONTROL_TURN_RIGHT) + TryRegisterForKey(iMoveUpKey, CONTROL_MOVE_UP) + TryRegisterForKey(iMoveDownKey, CONTROL_MOVE_DOWN) + + _00E_PlayerHousingManipulationShader.Play(curObjectRef) +EndFunction + +Function TryRegisterForKey(Int iKeyCode, String control) + If iKeyCode > 0 + RegisterForKey(iKeyCode) + Else + RegisterForControl(control) + EndIf +EndFunction + +Function Shutdown(Bool bRegisterNewOffsets) + GoToState("") + UnregisterForAllKeys() + UnregisterForAllControls() + UnregisterForUpdate() + + ObjectReference myRef = GetRef() + If myRef != None + _00E_PlayerHousingManipulationShader.Stop(myRef) + + While iWorkingState != STATE_IDLE && iWorkingState != STATE_WORKING + Utility.WaitMenuMode(0.05) + EndWhile + If iWorkingState == STATE_WORKING + myRef.StopTranslation() + EndIf + + If bRegisterNewOffsets + Float fNewOffsetAngleZ = myRef.GetAngleZ() - PlayerRef.GetAngleZ() + Float fNewOffsetPosZ = myRef.GetPositionZ() - PlayerRef.GetPositionZ() + (GetOwningQuest() as _00E_PlayerhousingMaster).RegisterNewHousingObjectOffsets(fNewOffsetAngleZ, fNewOffsetPosZ) + EndIf + + Clear() + EndIf +EndFunction + +State Working + Event OnKeyDown(Int iKeyCode) + TryStartTranslation(KeyCodeToTranslationMode(iKeyCode), iKeyCode) + EndEvent + + Event OnKeyUp(Int iKeyCode, Float fHoldTime) + TryStopTranslation(KeyCodeToTranslationMode(iKeyCode)) + EndEvent + + Event OnControlDown(String control) + TryStartTranslation(ControlToTranslationMode(control), 0) + EndEvent + + Event OnControlUp(String control, Float fHoldTime) + TryStopTranslation(ControlToTranslationMode(control)) + EndEvent + + Event OnUpdate() + ; OnControlUp is not always properly triggered. Maybe OnKeyUp too. The code below is a workaround for that. + ; For gamepads this failsafe is useless because Input.IsKeyPressed always returns False for controller buttons. + If iWatchedKeyCode > 0 && iWorkingState == STATE_WORKING + If Input.IsKeyPressed(iWatchedKeyCode) + RegisterForSingleUpdate(0.05) + Else + TryStopTranslation(iCurrentTranslation) + EndIf + EndIf + EndEvent + + Event OnTranslationComplete() + ; The previously started translation reached its end point + + If iWorkingState != STATE_WORKING + Return + EndIf + iWorkingState = STATE_UPDATING + + ObjectReference myRef = GetRef() + + If iWatchedKeyCode <= 0 || fTranslationSpeedIncrease < 0.0 + ; Do nothing + ElseIf iCurrentTranslation == TRANSLATION_TURN_LEFT || iCurrentTranslation == TRANSLATION_TURN_RIGHT + Float fRotationAngle = GetNextTranslationStep(ROTATION_SPEED_MAX, ROTATION_SPEED_CHANGE_MOD, ROTATION_MAX) + fObjectAngleZ = myRef.GetAngleZ() + TurnTranslate(myRef, fRotationAngle) + + iWorkingState = STATE_WORKING + Return + ElseIf iCurrentTranslation == TRANSLATION_MOVE_UP || iCurrentTranslation == TRANSLATION_MOVE_DOWN + Float fMoveZ = GetNextTranslationStep(MOVEMENT_SPEED_MAX, MOVEMENT_SPEED_CHANGE_MOD, MOVEMENT_MAX) + fObjectPosZ = myRef.GetPositionZ() + MoveTranslate(myRef, fMoveZ) + + iWorkingState = STATE_WORKING + Return + EndIf + + ; Fallback + FinalizeTranslation(myRef) + UIMenuPrevNext.Play(PlayerRef) + + iWorkingState = STATE_IDLE + EndEvent +EndState + +Int Function KeyCodeToTranslationMode(Int iKeyCode) + If iKeyCode > 0 + If iKeyCode == iTurnLeftKey + Return TRANSLATION_TURN_LEFT + ElseIf iKeyCode == iTurnRightKey + Return TRANSLATION_TURN_RIGHT + ElseIf iKeyCode == iMoveUpKey + Return TRANSLATION_MOVE_UP + ElseIf iKeyCode == iMoveDownKey + Return TRANSLATION_MOVE_DOWN + EndIf + EndIf + + Return -1 +EndFunction + +Int Function ControlToTranslationMode(String control) + If control == CONTROL_TURN_LEFT + Return TRANSLATION_TURN_LEFT + ElseIf control == CONTROL_TURN_RIGHT + Return TRANSLATION_TURN_RIGHT + ElseIf control == CONTROL_MOVE_UP + Return TRANSLATION_MOVE_UP + ElseIf control == CONTROL_MOVE_DOWN + Return TRANSLATION_MOVE_DOWN + EndIf + + Return -1 +EndFunction + +Function TryStartTranslation(Int iTranslationMode, Int iTriggerKeyCode) + If iTranslationMode < 0 || iWorkingState != STATE_IDLE + Return + EndIf + + iWorkingState = STATE_UPDATING + iCurrentTranslation = iTranslationMode + iWatchedKeyCode = iTriggerKeyCode + + ObjectReference myRef = GetRef() + + fObjectPosX = myRef.GetPositionX() + fObjectPosY = myRef.GetPositionY() + fObjectPosZ = myRef.GetPositionZ() + + fObjectAngleX = myRef.GetAngleX() + fObjectAngleY = myRef.GetAngleY() + fObjectAngleZ = myRef.GetAngleZ() + + fTranslationSpeedIncrease = 0.0 + + If iCurrentTranslation == TRANSLATION_TURN_LEFT || iCurrentTranslation == TRANSLATION_TURN_RIGHT + If iWatchedKeyCode > 0 + fTranslationSpeed = ROTATION_SPEED_START + TurnTranslate(myRef, fTranslationSpeed * ROTATION_SPEED_CHANGE_MOD) + Else + fTranslationSpeed = ROTATION_SPEED_FALLBACK + TurnTranslate(myRef, ROTATION_MAX) + EndIf + ElseIf iCurrentTranslation == TRANSLATION_MOVE_UP || iCurrentTranslation == TRANSLATION_MOVE_DOWN + If iWatchedKeyCode > 0 + fTranslationSpeed = MOVEMENT_SPEED_START + MoveTranslate(myRef, fTranslationSpeed * MOVEMENT_SPEED_CHANGE_MOD) + Else + fTranslationSpeed = MOVEMENT_SPEED_FALLBACK + MoveTranslate(myRef, MOVEMENT_MAX) + EndIf + EndIf + + If iWatchedKeyCode > 0 && bGamepadMode == False + RegisterForSingleUpdate(0.05) + EndIf + + iWorkingState = STATE_WORKING +EndFunction + +Function TryStopTranslation(Int iTranslationMode) + If iCurrentTranslation != iTranslationMode || iWorkingState != STATE_WORKING + Return + EndIf + + iWorkingState = STATE_UPDATING + + ObjectReference myRef = GetRef() + myRef.StopTranslation() + UnregisterForUpdate() + FinalizeTranslation(myRef) + + iWorkingState = STATE_IDLE +EndFunction + +Function TurnTranslate(ObjectReference myRef, Float fRotationAngle) + If iCurrentTranslation == TRANSLATION_TURN_LEFT + fObjectAngleZ -= fRotationAngle + Else + fObjectAngleZ += fRotationAngle + EndIf + myRef.TranslateTo(fObjectPosX, fObjectPosY, fObjectPosZ, fObjectAngleX, fObjectAngleY, fObjectAngleZ, FAST_TRANSLATION_SPEED, fTranslationSpeed) +EndFunction + +Function MoveTranslate(ObjectReference myRef, Float fMoveZ) + If iCurrentTranslation == TRANSLATION_MOVE_DOWN + Float fNewZ = fObjectPosZ - fMoveZ + If fObjectPosZ > fTablePosZ && fNewZ < fTablePosZ + ; A primitive "drop on the table" + fNewZ = fTablePosZ + fTranslationSpeedIncrease = -1.0 ; Stop on reaching fPlayerPosZ. + ElseIf fObjectPosZ > fPlayerPosZ && fNewZ < fPlayerPosZ + ; A primitive "drop on the floor" + fNewZ = fPlayerPosZ + fTranslationSpeedIncrease = -1.0 ; Stop on reaching fPlayerPosZ. + EndIf + fObjectPosZ = fNewZ + Else + fObjectPosZ += fMoveZ + EndIf + myRef.TranslateTo(fObjectPosX, fObjectPosY, fObjectPosZ, fObjectAngleX, fObjectAngleY, fObjectAngleZ, fTranslationSpeed, FAST_TRANSLATION_SPEED) +EndFunction + +Float Function GetNextTranslationStep(Float fSpeedMax, Float fSpeedChangeMod, Float fChangeMax) + If fTranslationSpeed < fSpeedMax + If fTranslationSpeedIncrease < 20.0 + fTranslationSpeedIncrease += 5.0 + EndIf + fTranslationSpeed += fTranslationSpeedIncrease + If fTranslationSpeed > fSpeedMax + fTranslationSpeed = fSpeedMax + EndIf + EndIf + Float fResult = fTranslationSpeed * fSpeedChangeMod + If fTranslationSpeed >= fSpeedMax || fResult > fChangeMax + Return fChangeMax + Else + Return fResult + EndIf +EndFunction + +Function FinalizeTranslation(ObjectReference myRef) + ; TranslateTo below prevents the object from twitching and becoming blurry when a translation ends + If iCurrentTranslation == TRANSLATION_TURN_LEFT || iCurrentTranslation == TRANSLATION_TURN_RIGHT + fObjectAngleZ = myRef.GetAngleZ() + ElseIf iCurrentTranslation == TRANSLATION_MOVE_UP || iCurrentTranslation == TRANSLATION_MOVE_DOWN + fObjectPosZ = myRef.GetPositionZ() + EndIf + myRef.TranslateTo(fObjectPosX, fObjectPosY, fObjectPosZ, fObjectAngleX, fObjectAngleY, fObjectAngleZ, FAST_TRANSLATION_SPEED, FAST_TRANSLATION_SPEED) +EndFunction diff --git a/source/scripts/_00e_playerhousingcurrentotranslation.psc b/source/scripts/_00e_playerhousingcurrentotranslation.psc index ef0e1554..45bac641 100644 --- a/source/scripts/_00e_playerhousingcurrentotranslation.psc +++ b/source/scripts/_00e_playerhousingcurrentotranslation.psc @@ -1,12 +1,117 @@ Scriptname _00E_PlayerhousingCurrentOTranslation extends ReferenceAlias -GlobalVariable Property continueTranslateToPlayerLoop Auto +EffectShader Property _00E_PlayerHousingTranslationShader Auto +Actor Property PlayerRef Auto -Event onLoad() - ;loop needs to be extracted from the rest of the code due to performance reasons (don't know why exactely, but defining new functions slows this down dramatically) - Actor player = Game.getPlayer() - while continueTranslateToPlayerLoop.getValue() - getRef().TranslateTo(player.getPositionX() + 100 * Math.sin(player.getAngleZ()), player.getPositionY() + 100 * Math.cos(player.getAngleZ()), player.getPositionZ(), 0, 0, player.getAngleZ(), 5000) - Endwhile -Endevent +Bool bIsWorking = False +Bool bIsWarmingUp = False +Float fDistance +Float fOffsetAngleZ +Float fOffsetPosZ + +Float Property ORBIT_ANGULAR_SPEED_CAP = 30.0 AutoReadOnly +Float Property FAST_TRANSLATION_SPEED = 1000000.0 AutoReadOnly + + +Function Setup(_00E_Playerhousing_Furniture furnitureRef, Bool bEnteringPlacement, Float fStoredOffsetAngleZ, Float fStoredOffsetPositionZ) + bIsWarmingUp = True + furnitureRef.Disable() + + If PlayerRef == None + PlayerRef = Game.GetPlayer() + EndIf + + fDistance = furnitureRef.CustomDistance + If fDistance <= 0.0 + fDistance = 100.0 + EndIf + + If bEnteringPlacement + fOffsetAngleZ = furnitureRef.OffsetAngleZ + fOffsetPosZ = furnitureRef.OffsetPositionZ + + If furnitureRef.IsSetPositionIncompatible == False + Float x = PlayerRef.GetPositionX() + Float y = PlayerRef.GetPositionY() + Float z = PlayerRef.GetPositionZ() + Float fAngleZ = PlayerRef.GetAngleZ() + + furnitureRef.SetPosition(x + fDistance * Math.sin(fAngleZ), y + fDistance * Math.cos(fAngleZ), z + fOffsetPosZ) + furnitureRef.SetAngle(0, 0, fAngleZ + fOffsetAngleZ) + EndIf + + ObjectReference myRef = furnitureRef as ObjectReference + If (myRef as _00E_Playerhousing_MannequinControl) + (myRef as _00E_Playerhousing_MannequinControl).StartPlacement() + ElseIf (myRef as _00E_Phasmalist_Workbench) + (myRef as _00E_Phasmalist_Workbench).StartPlacement() + EndIf + Else + fOffsetAngleZ = fStoredOffsetAngleZ + fOffsetPosZ = fStoredOffsetPositionZ + EndIf + + ForceRefTo(furnitureRef) + bIsWorking = True + furnitureRef.Enable() +EndFunction + +Function Shutdown() + bIsWorking = False + + ObjectReference myRef = GetRef() + If myRef + While bIsWarmingUp && (PlayerRef.GetParentCell() == myRef.GetParentCell()) + Utility.WaitMenuMode(0.05) + EndWhile + myRef.StopTranslation() + _00E_PlayerHousingTranslationShader.Stop(myRef) + Clear() + EndIf +EndFunction + +Event OnLoad() + ; Loop needs to be extracted from the rest of the code due to performance reasons (don't know why exactly, but defining new functions slows this down dramatically) + ObjectReference myRef = GetRef() + Float fPrevAngleZ = -1.0 + + myRef.SetMotionType(4) ; Set motion type to Motion_Keyframed. This would fix "collision phantoms" of the object while the player is moving around "dragging" it. + _00E_PlayerHousingTranslationShader.Play(myRef) + + bIsWarmingUp = False + + While bIsWorking + Float x = PlayerRef.GetPositionX() + Float y = PlayerRef.GetPositionY() + Float z = PlayerRef.GetPositionZ() + Float fAngleZ = PlayerRef.GetAngleZ() + + ; Cap the angular speed of the object's orbiting around the player at ORBIT_ANGULAR_SPEED_CAP. + ; This fixes some objects pushing the player (because they pass THROUGH the player?) on sharp camera turns. + If fPrevAngleZ >= 0.0 + Float fDelta = fAngleZ - fPrevAngleZ + If fDelta < -180.0 + fDelta += 360.0 + ElseIf fDelta > 180.0 + fDelta -= 360.0 + EndIf + If fDelta < -ORBIT_ANGULAR_SPEED_CAP + fAngleZ = fPrevAngleZ - ORBIT_ANGULAR_SPEED_CAP + If fAngleZ < 0.0 + fAngleZ += 360.0 + EndIf + ElseIf fDelta > ORBIT_ANGULAR_SPEED_CAP + fAngleZ = fPrevAngleZ + ORBIT_ANGULAR_SPEED_CAP + If fAngleZ >= 360.0 + fAngleZ -= 360.0 + EndIf + EndIf + EndIf + + If bIsWorking + myRef.TranslateTo(x + fDistance * Math.sin(fAngleZ), y + fDistance * Math.cos(fAngleZ), z + fOffsetPosZ, 0, 0, fAngleZ + fOffsetAngleZ, FAST_TRANSLATION_SPEED, FAST_TRANSLATION_SPEED) + EndIf + fPrevAngleZ = fAngleZ + EndWhile +EndEvent diff --git a/source/scripts/_00e_playerhousingmaster.psc b/source/scripts/_00e_playerhousingmaster.psc index f4869efa..bff27002 100644 --- a/source/scripts/_00e_playerhousingmaster.psc +++ b/source/scripts/_00e_playerhousingmaster.psc @@ -1,246 +1,554 @@ scriptname _00E_PlayerhousingMaster extends Quest -EffectShader Property shaderActive Auto -{Shader that is applied while the object is being manipulated} Actor Property player Auto -GlobalVariable Property continueTranslateToPlayerLoop Auto -{Controls the translateTo player loop while being in Translation mode. This variable is used to communicate with _00E_PlayerhousingCurrentOTranslation} ReferenceAlias Property currentHousingObjectInTranslation Auto ReferenceAlias Property currentHousingObjectInManipulation Auto -Message Property cannotPlaceObjectHere auto +Message Property _00E_Playerhousing_CannotPlaceObjectsHere Auto +Message Property _00E_Playerhousing_ContainerContentMove Auto +Message Property _00E_Playerhousing_StartTutorial Auto +Message Property _00E_Playerhousing_ExpansionBoardTutorial Auto +Message Property _00E_Playerhousing_TranslationMode Auto +Message Property _00E_Playerhousing_TranslationModeTutorial Auto +Message Property _00E_Playerhousing_TranslationModeTutorial_Gamepad Auto +Message Property _00E_Playerhousing_ManipulationMode Auto +Message Property _00E_Playerhousing_ManipulationModeTutorial Auto +Message Property _00E_Playerhousing_ManipulationModeTutorial_Gamepad Auto +Sound Property UIMenuActive Auto +GlobalVariable Property _00E_Meditate_Allowed Auto +GlobalVariable Property _00E_Phasmalist_TankMode Auto +GlobalVariable Property _00E_DisableCraftingTutorials Auto _00E_Playerhousing_Furniture currentHousingObject -float timeToHoldActivateToFinish = 2.0 -Event onBeginState() - currentHousingObject = None ; prevent persistence +Bool bIsInPlacementMode = False +Bool bDisableNormalActivation = False +Bool bGamepadMode = False +Bool bDroppedFromInventory = False +Int iPickupKey + +Float fStoredOffsetAngleZ +Float fStoredOffsetPositionZ + +String Property CONTROL_ACTIVATE = "Activate" AutoReadOnly +String Property CONTROL_SHEATH = "Ready Weapon" AutoReadOnly + + +;===================================================================================== +; GLOBAL FUNCTIONS +;===================================================================================== + +_00E_PlayerhousingMaster Function GetMaster() Global + Return Game.GetFormFromFile(0x00043270, "Skyrim.esm") as _00E_PlayerhousingMaster +EndFunction + +Bool Function ReferenceCanBeActivated(ObjectReference ref) Global + If (ref as _00E_Playerhousing_Furniture) + _00E_PlayerhousingMaster master = GetMaster() + If master + Return master.IsNormalActivationEnabled() + EndIf + EndIf + + Return True +EndFunction + + +;===================================================================================== +; TUTORIALS +;===================================================================================== + +Bool bStartTutorialShown = False + +Bool bHideTranslationTutorial = False +Bool bHideTranslationTutorial_Gamepad = False +Bool bHideManipulationTutorial = False +Bool bHideManipulationTutorial_Gamepad = False + +Function ShowStartBuildModeTutorial() + If _00E_DisableCraftingTutorials.GetValueInt() == 0 && bStartTutorialShown == False + bStartTutorialShown = True + _00E_Playerhousing_StartTutorial.Show() + EndIf +EndFunction + +Function ShowExpansionBoardTutorial() + ; Called from _00E_Game_Playerhouse_BoardSC + If _00E_Playerhousing_ExpansionBoardTutorial.Show() == 1 + bHideTranslationTutorial = False + bHideTranslationTutorial_Gamepad = False + bHideManipulationTutorial = False + bHideManipulationTutorial_Gamepad = False + EndIf +EndFunction + +Bool Function _ShowPlacementModeTutorial(Message msgTutorial, Bool bHideFlag) + If bHideFlag == False + Return (msgTutorial.Show() == 1) + Else + Return bHideFlag + EndIf +EndFunction + +Function ShowTranslationModeTutorial() + If bGamepadMode + bHideTranslationTutorial_Gamepad = _ShowPlacementModeTutorial(_00E_Playerhousing_TranslationModeTutorial_Gamepad, bHideTranslationTutorial_Gamepad) + Else + bHideTranslationTutorial = _ShowPlacementModeTutorial(_00E_Playerhousing_TranslationModeTutorial, bHideTranslationTutorial) + EndIf +EndFunction + +Function ShowManipulationModeTutorial() + If bGamepadMode + bHideManipulationTutorial_Gamepad = _ShowPlacementModeTutorial(_00E_Playerhousing_ManipulationModeTutorial_Gamepad, bHideManipulationTutorial_Gamepad) + Else + bHideManipulationTutorial = _ShowPlacementModeTutorial(_00E_Playerhousing_ManipulationModeTutorial, bHideManipulationTutorial) + EndIf +EndFunction + + +;===================================================================================== +; SERVICE FUNCTIONS +;===================================================================================== + +Bool Function CanEnterPlacementMode() + Return (_00E_Meditate_Allowed.GetValue() != 0.0 && _00E_Phasmalist_TankMode.GetValue() == 0.0) +EndFunction + +Float fPlacementModeCarryWeightMod = 0.0 + +Function EnterPlacementMode() + If bIsInPlacementMode == False + bIsInPlacementMode = True + _00E_Meditate_Allowed.SetValueInt(0) + Game.SetInChargen(true, true, false) ; Forbid saving the game while placing stuff + + ; Make the player over encumbered to prevent them from the default running and in general to slow them down + fPlacementModeCarryWeightMod = Player.GetAV("CarryWeight") * 2.0 + If fPlacementModeCarryWeightMod < 1000.0 + fPlacementModeCarryWeightMod = 1000.0 + EndIf + Player.ModAV("CarryWeight", -fPlacementModeCarryWeightMod) + + bGamepadMode = Game.UsingGamepad() + If bGamepadMode == False + iPickupKey = Input.GetMappedKey(CONTROL_SHEATH, 0) + Else + iPickupKey = 277 + EndIf + EndIf +EndFunction + +Function ExitPlacementMode() + If bIsInPlacementMode + bIsInPlacementMode = False + If fPlacementModeCarryWeightMod != 0.0 + Player.ModAV("CarryWeight", fPlacementModeCarryWeightMod) + fPlacementModeCarryWeightMod = 0.0 + EndIf + Game.SetInChargen(false, true, false) ; Re-allow saving + _00E_Meditate_Allowed.SetValueInt(1) + EndIf + + currentHousingObject = None ; Prevent persistence +EndFunction + +Function PickUpHousingObject() + ; Clear currentHousingObject ASAP because of possible race conditions + _00E_Playerhousing_Furniture furnitureRef = (currentHousingObject as _00E_Playerhousing_Furniture) + currentHousingObject = None + + Form furnBaseObject = furnitureRef.GetBaseObject() + If (furnBaseObject as ActorBase) || (furnBaseObject as Container) + If furnitureRef.GetNumItems() > 0 + furnitureRef.RemoveAllItems(Player) + _00E_Playerhousing_ContainerContentMove.Show() + Else + ; Whatever... + furnitureRef.RemoveAllItems(Player) + EndIf + EndIf + Player.AddItem(furnitureRef.GetInventoryItem(), 1, False) + furnitureRef.Disable() + _00E_Phasmalist_Workbench worbenchRef = (furnitureRef as ObjectReference) as _00E_Phasmalist_Workbench + If worbenchRef + worbenchRef.OnPickUp() + EndIf + furnitureRef.Delete() +EndFunction + +Function FinishPlacingHousingObject() + ; Clear currentHousingObject ASAP because of possible race conditions + _00E_Playerhousing_Furniture furnitureRef = (currentHousingObject as _00E_Playerhousing_Furniture) + currentHousingObject = None + + Utility.Wait(0.05) ; Wait for the shaders to stop for sure + furnitureRef.finishPlacement() + PlaySwitchSound() +EndFunction + +Function PlaySwitchSound() + UIMenuActive.Play(player) +EndFunction + +Function RegisterNewHousingObjectOffsets(Float fNewOffsetAngleZ, Float fNewOffsetPositionZ) + fStoredOffsetAngleZ = fNewOffsetAngleZ + fStoredOffsetPositionZ = fNewOffsetPositionZ +EndFunction + +Function Update_209() + bStartTutorialShown = ((Self as Quest) as _00E_PlayerhousingTutorial).StartTutorialIsShown() +EndFunction + + +;===================================================================================== +; CONTROLS +;===================================================================================== + +Bool bLockActions = False +Bool bActiveActivate = False + +Function LockActions() + bLockActions = True + InterruptActivate() +EndFunction + +Function UnlockActions() + bLockActions = False + InterruptActivate() +EndFunction + +Function InterruptActivate() + If bActiveActivate + bActiveActivate = False + UnregisterForUpdate() + EndIf +EndFunction + +Function EnableBuildmodeControls() + RegisterForControl(CONTROL_ACTIVATE) + If bIsInPlacementMode && iPickupKey > 0 + RegisterForKey(iPickupKey) + EndIf + + UnlockActions() +EndFunction + +Function DisableBuildmodeControls() + LockActions() + + UnregisterForAllControls() + UnregisterForAllKeys() + UnregisterForUpdate() +EndFunction + +Event OnControlDown(String control) + If control == CONTROL_ACTIVATE + If bActiveActivate + bActiveActivate = False + bDisableNormalActivation = True + UnregisterForUpdate() + ElseIf bLockActions == False + bActiveActivate = True + bDisableNormalActivation = False + RegisterForSingleUpdate(1.1) + EndIf + EndIf EndEvent -bool function canPlaceItem() - return false -Endfunction +Event OnControlUp(String control, Float holdTime) + If control == CONTROL_ACTIVATE + If bActiveActivate + bActiveActivate = False + UnregisterForUpdate() + If bLockActions == False + activateShortPressed() + EndIf + EndIf + EndIf +EndEvent -Event onControlUp(String control, float holdTime) - if holdTime > timeToHoldActivateToFinish - activateLongPressed() - else - activatePressed() - Endif +Event OnUpdate() + If bActiveActivate + bActiveActivate = False + bDisableNormalActivation = True + If bLockActions == False + activateLongPressed() + EndIf + EndIf EndEvent -function enableBuildmode() -{Enables the player to choose housing objects for manipulation or translation; should be called when the player enters one of his houses} - ((Self as Quest) as _00E_PlayerhousingTutorial).onStartBuildmode() - GoToState("Buildmode") -ENDfunction +Event OnKeyDown(Int iKeyCode) + If iKeyCode == iPickupKey + If bLockActions == False + pickUpPressed() + EndIf + EndIf +EndEvent + + +;===================================================================================== +; DEFAULT STATE +;===================================================================================== -function playerItemDropped(_00E_Playerhousing_FurnitureItem akItemReference) -{Tests if this item drop by the player triggers an entering into buildmode and performs this change if necessary} -ENDfunction +Event OnBeginState() + ExitPlacementMode() +EndEvent + +Function playerItemDropped(_00E_Playerhousing_FurnitureItem akItemReference) + ; Called from _00E_Playerhousing_FurnitureItem on a placeable dropped from the inventory + Player.AddItem(akItemReference, 1, False) + _00E_Playerhousing_CannotPlaceObjectsHere.Show() +EndFunction -function enterBuildmode() -{Enables the player to translate the current housing object and change to manipulation mode} - GoToState("Translation") -ENDfunction +Function activateShortPressed() + ; Process short activate press +EndFunction -function toggleMode() -{Switches between tranlation and manipulation buildmode} -ENDfunction +Function activateLongPressed() + ; Process long activate press +EndFunction -function leaveBuildmode() -{Disables the player to translate or manipulate a housing object; the player can still enter buildmode again} -ENDfunction +Function pickUpPressed() + ; Process pick up key press +EndFunction -function disableBuildmode() -{Disables the player to enter buildmode} -ENDfunction +Function enableBuildmode() + ; Enter the build mode when the player enters their house + ShowStartBuildModeTutorial() + GoToState("Buildmode") +EndFunction -function activatePressed() -{updates the buildmode as necessary when the activation control has been pressed} -Endfunction +Function disableBuildmode() + ; Exit a build mode when the player leaves their house +EndFunction -function activateLongPressed() -{updates the buildmode as necessary when the activation control has been pressed long} -Endfunction +Bool Function IsNormalActivationEnabled() + ; The player can activate a placeable furniture normally + Return True +EndFunction -function translateCurrentHousingObjectLoop() -{translates the current housing object before the player in a recursive loop} -ENDfunction -function pickUp() -{deletes the current housing object and adds the appropriate item to the player's inventory} - Player.addItem(currentHousingObject.getFurnitureItem().getBaseObject(), 1) - currentHousingObject.disable() - currentHousingObject.delete() -Endfunction +;===================================================================================== +; STATE Buildmode +;===================================================================================== -;==================================================================== STATE Buildmode =================================================================================================== STATE Buildmode -;the player can enter the manipulation or translation mode by choosing a housing object or dropping a housing item + ; The player can enter the manipulation or translation mode by choosing a housing object or dropping a housing item - Event onBeginState() - currentHousingObject = None ; prevent persistence - RegisterForControl("activate") + Event OnBeginState() + ExitPlacementMode() + bDisableNormalActivation = True + EnableBuildmodeControls() EndEvent - bool function canPlaceItem() - return True - Endfunction - - Event onEndState() - unRegisterForControl("activate") + Event OnEndState() + DisableBuildmodeControls() EndEvent - - function playerItemDropped(_00E_Playerhousing_FurnitureItem akItemReference) - {Tests if this item drop by the player triggers an entering into buildmode and performs this change if necessary} + + Function playerItemDropped(_00E_Playerhousing_FurnitureItem akItemReference) + If CanEnterPlacementMode() == False || bLockActions ; Locked by something else + Player.AddItem(akItemReference, 1, False) + Return + EndIf + LockActions() + currentHousingObject = akItemReference.placeFurnitureAtMe() - akItemReference.delete() + If currentHousingObject == None + ; Some error happened + Player.AddItem(akItemReference, 1, False) + UnlockActions() + Return + EndIf + + DisableBuildmodeControls() + akItemReference.Disable() + currentHousingObject.InventoryItem = akItemReference.GetBaseObject() + akItemReference.Delete() + bDroppedFromInventory = True GoToState("Translation") - ENDfunction + EndFunction - function activateLongPressed() - {updates the buildmode as necessary when the activation control has been pressed long} - ObjectReference targetRef = Game.GetCurrentCrosshairRef() - if targetRef as _00E_Playerhousing_Furniture - currentHousingObject = targetRef as _00E_Playerhousing_Furniture + Function activateLongPressed() + LockActions() + + _00E_Playerhousing_Furniture targetRef = Game.GetCurrentCrosshairRef() as _00E_Playerhousing_Furniture + If targetRef && targetRef.IsFurnitureInUse() == False && Utility.IsInMenuMode() == False && CanEnterPlacementMode() + currentHousingObject = targetRef GoToState("Translation") - Endif - Endfunction + Else + UnlockActions() + EndIf + EndFunction - function activatePressed() - {updates the buildmode as necessary when the activation control has been pressed} + Function activateShortPressed() ObjectReference targetRef = Game.GetCurrentCrosshairRef() - if !(targetRef as _00E_Phasmalist_Workbench) && (targetRef as _00E_Playerhousing_Furniture) && (targetRef as _00E_Playerhousing_Furniture).shouldActivateBePossible() - targetRef.activate(player, true) - Endif - Endfunction - - function disableBuildmode() - {Disables the player to enter buildmode} - GoToState("null") - ENDfunction + If (targetRef as _00E_Playerhousing_Furniture) && (bLockActions == False) + If (targetRef as _00E_Playerhousing_FurnitureItem) + ; Activate() would mean "Take" for this misc. object, so do nothing + ElseIf (targetRef as _00E_Theriantrophist_BlockCraftingSC) || (targetRef as _00E_Playerhousing_MannequinControl) || (targetRef as _00E_BedScript) || (targetRef as _00E_Phasmalist_Workbench) || (targetRef as _00E_PlaceableGrammophonPlay) + ; These objects do activation themselves in OnActivate event + Else + targetRef.Activate(player, true) + EndIf + EndIf + EndFunction + + Function enableBuildmode() + ; Do nothing + EndFunction + Function disableBuildmode() + GoToState("") + EndFunction + + Bool Function IsNormalActivationEnabled() + Return ((bDisableNormalActivation == False) && (bLockActions == False)) + EndFunction + ENDSTATE -;==================================================================== STATE Translation =================================================================================================== + +;===================================================================================== +; STATE Translation +;===================================================================================== + STATE Translation -;the selected housing object is moved with the player + ; The selected housing object is moved with the player - Event onBeginState() - Game.DisablePlayerControls(abMovement = false, abFighting = true, abCamSwitch = false, abLooking = false, abSneaking = false, abMenu = false, abActivate = true) - - ((Self as Quest) as _00E_PlayerhousingTutorial).onTranslationMode() + Event OnBeginState() + Bool bEnteringPlacement = (bIsInPlacementMode == False) - continueTranslateToPlayerLoop.setValue(1) - currentHousingObjectInTranslation.forceRefTo(currentHousingObject) - currentHousingObject.disable() - currentHousingObject.enable() ;disable - enable reloads the 3d so onLoad of the object is invoked; this will start the translateToPlayer-loop - - RegisterForControl("activate") - while !currentHousingObject.is3DLoaded() - Utility.wait(0.1) - Endwhile - shaderActive.Play(currentHousingObject) + Game.DisablePlayerControls(abMovement = false, abFighting = true, abCamSwitch = false, abLooking = false, abSneaking = false, abMenu = true, abActivate = true) + EnterPlacementMode() + + If bEnteringPlacement && bDroppedFromInventory == False + ObjectReference housingObjRef = currentHousingObject as ObjectReference + If (housingObjRef as _00E_PlaceableGrammophonPlay) + (housingObjRef as _00E_PlaceableGrammophonPlay).StopMusic() + EndIf + EndIf + + If bDroppedFromInventory == False + PlaySwitchSound() + Else + bDroppedFromInventory = False + EndIf + + _00E_Playerhousing_TranslationMode.Show() + + (currentHousingObjectInTranslation as _00E_PlayerhousingCurrentOTranslation).Setup(currentHousingObject, bEnteringPlacement, fStoredOffsetAngleZ, fStoredOffsetPositionZ) + + ShowTranslationModeTutorial() + + EnableBuildmodeControls() EndEvent - Event onEndState() - shaderActive.Stop(currentHousingObject) - continueTranslateToPlayerLoop.setValue(0) - - currentHousingObjectInTranslation.clear() - unRegisterForControl("activate") - + Event OnEndState() Game.EnablePlayerControls(abMovement = true, abFighting = true, abCamSwitch = true, abLooking = true, abSneaking = true, abMenu = true, abActivate = true) EndEvent - function activatePressed() - {updates the buildmode as necessary when the activation control has been pressed} - toggleMode() - Endfunction - - function activateLongPressed() - {updates the buildmode as necessary when the activation control has been pressed long} - pickUp() - leaveBuildmode() - Endfunction - - function toggleMode() - {Switches between tranlation and manipulation buildmode} + Function activateShortPressed() + DisableBuildmodeControls() + (currentHousingObjectInTranslation as _00E_PlayerhousingCurrentOTranslation).Shutdown() GoToState("Manipulation") - ENDfunction - - function disableBuildmode() - {Disables the player to enter buildmode} - GoToState("null") - ENDfunction + EndFunction - function leaveBuildmode() - {Disables the player to translate or manipulate a housing object; the player can still enter buildmode again} + Function activateLongPressed() + DisableBuildmodeControls() + (currentHousingObjectInTranslation as _00E_PlayerhousingCurrentOTranslation).Shutdown() + FinishPlacingHousingObject() + GoToState("Buildmode") + EndFunction + + Function pickUpPressed() + DisableBuildmodeControls() + (currentHousingObjectInTranslation as _00E_PlayerhousingCurrentOTranslation).Shutdown() + PickUpHousingObject() GoToState("Buildmode") - ENDfunction + EndFunction + + Function enableBuildmode() + ; Do nothing + EndFunction + + Function disableBuildmode() + DisableBuildmodeControls() + (currentHousingObjectInTranslation as _00E_PlayerhousingCurrentOTranslation).Shutdown() + If currentHousingObject + PickUpHousingObject() + EndIf + GoToState("") + EndFunction + + Bool Function IsNormalActivationEnabled() + Return False + EndFunction ENDSTATE -;==================================================================== STATE Manipulation =================================================================================================== + +;===================================================================================== +; STATE Manipulation +;===================================================================================== + STATE Manipulation -;the player can change orientation or height of the selected housing object by using the keys + ; The player can change orientation or altitude of the selected housing object by using the keys - Event onBeginState() - Game.DisablePlayerControls(abMovement = false, abFighting = true, abCamSwitch = false, abLooking = false, abSneaking = false, abMenu = false, abActivate = true) + Event OnBeginState() + Game.DisablePlayerControls(abMovement = false, abFighting = true, abCamSwitch = false, abLooking = false, abSneaking = false, abMenu = true, abActivate = true) Game.SetPlayerAIDriven(True) - ((Self as Quest) as _00E_PlayerhousingTutorial).onManipulationMode() - - currentHousingObjectInManipulation.forceRefTo(currentHousingObject) - currentHousingObjectInManipulation.RegisterForControl("forward") - currentHousingObjectInManipulation.RegisterForControl("back") - currentHousingObjectInManipulation.RegisterForControl("strafe left") - currentHousingObjectInManipulation.RegisterForControl("strafe right") - - RegisterForControl("activate") - - ;we do not have to wait until the 3d is loaded since the manipulation mode is only entered from the translation mode - shaderActive.Play(currentHousingObject) - EndEvent + PlaySwitchSound() - Event onEndState() - shaderActive.Stop(currentHousingObject) - unRegisterForControl("activate") + _00E_Playerhousing_ManipulationMode.Show() - currentHousingObjectInManipulation.unRegisterForControl("forward") - currentHousingObjectInManipulation.unRegisterForControl("back") - currentHousingObjectInManipulation.unRegisterForControl("strafe left") - currentHousingObjectInManipulation.unRegisterForControl("strafe right") - currentHousingObjectInManipulation.clear() + (currentHousingObjectInManipulation as _00E_PlayerhousingCurrentOManipulate).Setup(currentHousingObject) + + ShowManipulationModeTutorial() + + EnableBuildmodeControls() + EndEvent + Event OnEndState() Game.SetPlayerAIDriven(False) Game.EnablePlayerControls(abMovement = true, abFighting = true, abCamSwitch = true, abLooking = true, abSneaking = true, abMenu = true, abActivate = true) EndEvent - function activatePressed() - {updates the buildmode as necessary when the activation control has been pressed} - toggleMode() - Endfunction + Function activateShortPressed() + DisableBuildmodeControls() + (currentHousingObjectInManipulation as _00E_PlayerhousingCurrentOManipulate).Shutdown(True) + GoToState("Translation") + EndFunction - function activateLongPressed() - {updates the buildmode as necessary when the activation control has been pressed long} - currentHousingObject.finishPlacement() - leaveBuildmode() - Endfunction + Function activateLongPressed() + DisableBuildmodeControls() + (currentHousingObjectInManipulation as _00E_PlayerhousingCurrentOManipulate).Shutdown(False) + FinishPlacingHousingObject() + GoToState("Buildmode") + EndFunction - function toggleMode() - {Switches between tranlation and manipulation buildmode} - GoToState("Translation") - ENDfunction + Function pickUpPressed() + DisableBuildmodeControls() + (currentHousingObjectInManipulation as _00E_PlayerhousingCurrentOManipulate).Shutdown(False) + PickUpHousingObject() + GoToState("Buildmode") + EndFunction - function disableBuildmode() - {Disables the player to enter buildmode} - GoToState("null") - ENDfunction + Function enableBuildmode() + ; Do nothing + EndFunction - function leaveBuildmode() - {Disables the player to translate or manipulate a housing object; the player can still enter buildmode again} - GoToState("Buildmode") - ENDfunction + Function disableBuildmode() + DisableBuildmodeControls() + (currentHousingObjectInManipulation as _00E_PlayerhousingCurrentOManipulate).Shutdown(False) + If currentHousingObject + PickUpHousingObject() + EndIf + GoToState("") + EndFunction + + Bool Function IsNormalActivationEnabled() + Return False + EndFunction ENDSTATE diff --git a/source/scripts/_00e_playerhousingtutorial.psc b/source/scripts/_00e_playerhousingtutorial.psc index e1f2a013..308e38f8 100644 --- a/source/scripts/_00e_playerhousingtutorial.psc +++ b/source/scripts/_00e_playerhousingtutorial.psc @@ -1,48 +1,14 @@ Scriptname _00E_PlayerhousingTutorial extends Quest +{ OBSOLETE. Left for version update. } -Message Property buildmodeTutorial auto -Message Property translationModeTutorial auto -Message Property manipulationModeTutorial auto - -GlobalVariable Property _00E_DisableCraftingTutorials Auto - -function ShowTutorial() - int button = buildmodeTutorial.show() - if button == 0 - GotoState("") - else - GotoState("NoTutorial") - Endif -Endfunction - -function onStartBuildmode() - If _00E_DisableCraftingTutorials.GetValueInt() == 0 - ShowTutorial() - EndIf -Endfunction - -function onTranslationMode() - Debug.Notification(translationModeTutorial.getName()) - translationModeTutorial.show() -Endfunction - -function onManipulationMode() - Debug.Notification(manipulationModeTutorial.getName()) - manipulationModeTutorial.show() -Endfunction +Bool Function StartTutorialIsShown() + Return False +EndFunction STATE NoTutorial - function onStartBuildmode() - - Endfunction - - function onTranslationMode() - Debug.Notification(translationModeTutorial.getName()) - Endfunction - - function onManipulationMode() - Debug.Notification(manipulationModeTutorial.getName()) - Endfunction + Bool Function StartTutorialIsShown() + Return True + EndFunction Endstate diff --git a/source/scripts/_00e_playersetupscript.psc b/source/scripts/_00e_playersetupscript.psc index 037303cf..65452046 100644 --- a/source/scripts/_00e_playersetupscript.psc +++ b/source/scripts/_00e_playersetupscript.psc @@ -1,7 +1,7 @@ Scriptname _00E_PlayerSetUpScript extends ObjectReference {Initializes all the necessary Quests, maintains the player, contains various OnPlayerLoadGame() failsafes} -Float Property CURRENT_PATCH_VERSION = 2.08 AutoReadOnly +Float Property CURRENT_PATCH_VERSION = 2.09 AutoReadOnly ;===================================================================================== @@ -355,6 +355,25 @@ Function FillAnimTestPackages(Int idNPC, String esmNPC, Int idPackage, String es EndFunction +;===================================================================================== +; 2.0.9 +;===================================================================================== + +Function Update_209() + Spell abSoulcaller = Game.GetFormFromFile(0x002F0EA, "Enderal - Forgotten Stories.esm") as Spell + If PlayerREF.HasSpell(abSoulcaller) + PlayerREF.RemoveSpell(abSoulcaller) + Utility.Wait(1) + PlayerREF.AddSpell(abSoulcaller, False) + EndIf + + Perk perkBloodlust = Game.GetFormFromFile(0x00069D38, "Skyrim.esm") as Perk + _ResetPerk(perkBloodlust) + + _00E_PlayerhousingMaster.GetMaster().Update_209() +EndFunction + + ;===================================================================================== ; ALL UPDATES ;===================================================================================== @@ -406,10 +425,10 @@ Function RefreshMountNamesOnLoad() EndFunction -Function _ResetArmorWeightPerk(Perk weightPerk) - If PlayerREF.HasPerk(weightPerk) - PlayerREF.RemovePerk(weightPerk) - PlayerREF.AddPerk(weightPerk) +Function _ResetPerk(Perk p) + If PlayerREF.HasPerk(p) + PlayerREF.RemovePerk(p) + PlayerREF.AddPerk(p) EndIf EndFunction @@ -419,8 +438,8 @@ Function ResetArmorWeightPerks() ; The push is needed only if the player is over-encumbered on game load. ; If the player is not over-encumbered, the push is not needed because checking the inventory, picking up items, sheathing/drawing a weapon will reset the perks anyway. If PlayerREF.IsOverEncumbered() - _ResetArmorWeightPerk(_00E_Class_Keeper_P05_C_Conditioning) - _ResetArmorWeightPerk(_00E_Class_Vagrant_P05_B_Lightweight) + _ResetPerk(_00E_Class_Keeper_P05_C_Conditioning) + _ResetPerk(_00E_Class_Vagrant_P05_B_Lightweight) EndIf EndFunction @@ -543,7 +562,7 @@ Function Maintenance() bdoOnce = true EndIf EndIf - ElseIf fPatchVersion >= 1.5 + ElseIf fPatchVersion >= 1.5 && fPatchVersion < CURRENT_PATCH_VERSION ; only do this once when update 1.5.6.0 is applied If fPatchVersion < 1.56 @@ -584,6 +603,10 @@ Function Maintenance() If fPatchVersion < 2.08 Update_208() EndIf + ; only do this once when update 2.0.9 (SE) is applied + If fPatchVersion < 2.09 + Update_209() + EndIf fPatchVersion = CURRENT_PATCH_VERSION EndIf diff --git a/source/scripts/_00e_questfunctions.psc b/source/scripts/_00e_questfunctions.psc index f4edeab1..c3e906c3 100644 --- a/source/scripts/_00e_questfunctions.psc +++ b/source/scripts/_00e_questfunctions.psc @@ -134,14 +134,6 @@ endFunction Function DisableDialogueQuitting() Global {Disables the TAB Key during dialogue. Resets automatically upon dialogue exit via Goodbye.} - if UI.GetBool("Dialogue Menu", "_root.DialogueMenu_mc.bEnableTab") != true - ; Suspected non-Enderal dialoguemenu.swf replacer, rechecking value in order to be sure. - UI.InvokeBool("Dialogue Menu", "_root.DialogueMenu_mc.SetVariable", True) - if UI.GetBool("Dialogue Menu", "_root.DialogueMenu_mc.bEnableTab") != true - Debug.Notification("Detected incompatible dialoguemenu.swf!") - endif - endif - UI.InvokeBool("Dialogue Menu", "_root.DialogueMenu_mc.SetVariable", False) EndFunction @@ -288,6 +280,27 @@ Function DisableReferenceFormList(FormList referenceList) Global EndFunction +Float Function SetActorScale(Actor akActor, Float fNewScale) Global + + ; Sets the scale of akActor to fNewScale and returns the old scale. + ; This is a workaround for GetScale() returning the cumulative scale of Race.Height * Actor.Scale for actors. + ; So it results in a messed up scale if the value returned by GetScale() is used to revert the scale change for an actor whose race has a non-1.00 height (for example, HighElfRace) + + Float fOriginalScale = akActor.GetScale() + akActor.SetScale(fNewScale) + ; Now use the known fNewScale and the return of GetScale() to get the race height coeff, and apply that coeff to fOriginalScale to calculate the true actor's reference scale. + Return fOriginalScale * fNewScale / akActor.GetScale() + +EndFunction + +Float Function AdjustTimePeriodByEngineTimerError(Float fUnadjustedPeriod) Global + + ; In SE, the game time runs slower than the real time by about 2.5/60 second + + Return fUnadjustedPeriod - (2.5 * Math.Floor(fUnadjustedPeriod) / 60.0) + +EndFunction + Function PrintDebugMessage(String msg) Global ; Dummy to fix error messages in Papyrus.log about missing function EndFunction @@ -1215,7 +1228,7 @@ Message Property _00E_PleaseRemoveMoney Auto GlobalVariable Property GameHour Auto -;--------------------------------------VISION----------------------------------- +;--------------------------------------VISION-----------------------------------; float PlayerSpeed int VisionSound