ThyPride Posted July 8, 2023 Share Posted July 8, 2023 Hey there. First, I'm a total noob when it comes to papyrus. I can change some simple things, but that's about it. Now to by problem: I tried to change the 'RentRoomScript' to change the ownership after renting from the player to something that would allow followers to use the bed too. I went for PlayerBedOwnership. On UESP Wiki I found an example:; Set the empire as owning the non-life starNonLifeStarProperty.SetFactionOwner(EmpireFactionProperty)That's for cell ownership, but that won't be too different, right?So, here's what I did... Original code: Scriptname RentRoomScript extends Actor Conditional{script for anyone who rents a room}ObjectReference Property Bed Auto {bed to rent}WIFunctionsScript Property WI Auto{Pointer to WIFunctionsScript attached to WI quest}; rent room or clear rentalfunction RentRoom(DialogueGenericScript pQuestScript) Bed.SetActorOwner(Game.GetPlayer().GetActorBase()) RegisterForSingleUpdateGameTime (pQuestScript.RentHours) Game.GetPlayer().RemoveItem(pQuestScript.Gold, pQuestScript.RoomRentalCost.GetValueInt()) ; used to conditionalize innkeeper dialogue SetActorValue("Variable09", 1.0) WI.ShowPlayerRoom(self, Bed)endFunctionfunction ClearRoom(); debug.trace(self + " ClearRoom called on RentRoomScript - room rental expired") ; clear ownership - either rental expired or I died Bed.SetActorOwner((self as Actor).GetActorBase()) UnregisterForUpdateGameTime() ; used to conditionalize innkeeper dialogue SetActorValue("Variable09", 0.0)endFunction; when this is called, reset the ownership on the bedevent OnUpdateGameTime() ClearRoom()endEvent; if I die, clear the room rental as well, to stop the timerEvent OnDeath(Actor akKiller) ClearRoom()endEvent What I made of it: Scriptname RentRoomScript extends Actor Conditional{script for anyone who rents a room}ObjectReference Property Bed Auto {bed to rent}Faction Property PlayerBedOwnership AutoWIFunctionsScript Property WI Auto{Pointer to WIFunctionsScript attached to WI quest}; rent room or clear rentalfunction RentRoom(DialogueGenericScript pQuestScript) Bed.SetFactionOwner(PlayerBedOwnership) RegisterForSingleUpdateGameTime (pQuestScript.RentHours) Game.GetPlayer().RemoveItem(pQuestScript.Gold, pQuestScript.RoomRentalCost.GetValueInt()) ; used to conditionalize innkeeper dialogue SetActorValue("Variable09", 1.0) WI.ShowPlayerRoom(self, Bed)endFunctionfunction ClearRoom(); debug.trace(self + " ClearRoom called on RentRoomScript - room rental expired") ; clear ownership - either rental expired or I died Bed.SetActorOwner((self as Actor).GetActorBase()) UnregisterForUpdateGameTime() ; used to conditionalize innkeeper dialogue SetActorValue("Variable09", 0.0)endFunction; when this is called, reset the ownership on the bedevent OnUpdateGameTime() ClearRoom()endEvent; if I die, clear the room rental as well, to stop the timerEvent OnDeath(Actor akKiller) ClearRoom()endEvent Now, it somehow works. Followers can use the inn beds. But When using More informative console, the bed shows no ownership at all until rental time expires. Then it goes back to it's original owner. Can anyone explain, what I did wrong? As I said, I'm a total noob, so please explain it for idiots. Thanks. Link to comment Share on other sites More sharing options...
scorrp10 Posted July 9, 2023 Share Posted July 9, 2023 Faction Property PlayerBedOwnership Auto You added this to the script, but have you filled the property in the script? Cause if you did not, your 'PlayerBedOwnership' variable is 'None' (null). I.e. in CK, if you open actor 'Hulda', she has RentRoomScript assigned, and selecting that and clicking Properties, you would see that specifically HER script Bed property is loaded with the specific bed in Bannered Mare.Now, in your case, with the changed script, you will see that RentRoomScript now has 3 properties, and the extra one (PlayerBedOwnership) is unfilled. Your options would be to either:1. use CK to go through every single innkeep in the game, and fill the PlayerBedOwnership in their scripts. 2. Do something like this: Remove PlayerBedOwnership Property, and instead: function RentRoom(DialogueGenericScript pQuestScript) Faction PlayerBedOwnership = Game.GetFormFromFile(0xF2073, "Skyrim.esm") as Faction Bed.SetFactionOwner(PlayerBedOwnership) ... Link to comment Share on other sites More sharing options...
ThyPride Posted July 9, 2023 Author Share Posted July 9, 2023 That did it. (And makes a lot of sense, too :huh:) Thank's mate! Link to comment Share on other sites More sharing options...
scorrp10 Posted July 9, 2023 Share Posted July 9, 2023 Here is a most excellent resource about properties and how to deal with them. Now that solution that I gave you is a bit heavy-handed. That is, Game.GetFormFromFile call is supposedly rather heavy, and it will get invoked any time you rent a room. Which admittedly, is not too often. But having something like that in a script executing every time you swing a weapon.... can be bad.To that extent, you could, for example, do this:Faction PlayerBedOwnership = None function RentRoom(DialogueGenericScript pQuestScript) If(PlayerBedOwnership == None) PlayerBedOwnership = Game.GetFormFromFile(0xF2073, "Skyrim.esm") as Faction EndIf Bed.SetFactionOwner(PlayerBedOwnership) ... Yet another nice way to handle this: as RentRoom gets DialogueGenericScript as a parameter, you could:In Quest section, find DialogueGeneric, and in its script section, in DialogueGenericScript Properties, add the PlayerBedOwnership Faction property, and fill it there. Then, in RentRoom, it is just:Bed.SetFactionOwner(pQuestScript.PlayerBedOwnership) Link to comment Share on other sites More sharing options...
ThyPride Posted July 9, 2023 Author Share Posted July 9, 2023 Thanks for the source, I will check that out. As for the script... As you said, the rent room script does get rarely executed, and as I at least understood, what you did in your first post, I guess I'll stick with that solution for now.Don't like doing stuff without actually understanding what I'm doing. But I'll keep on learning. Thanks again. Link to comment Share on other sites More sharing options...
Recommended Posts