Difference between revisions of "Rent A Room Tutorial"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Jsera
imported>Ketoleperouch
m (Minor changes to the script, like GetIisID -> GetIsID)
 
(10 intermediate revisions by 7 users not shown)
Line 1: Line 1:
Creating an NPC that will rent a room to you.
How to make an NPC Rent you a bed for the night.


'''Need:'''
===Preparations===
NPC
*Make an inn, both interior and exterior, and link them together (see [[Linking Cells and Connecting to the Outside World]]).
*Create an NPC.
*Add a door and a bed to the rentable room.


NPC PublicanScript
===Preparing the room===
We Start with the door;<br> First set Ownership to your NPC's BaseID. <br>Then Lock it. Not with a key, just choose hard or something.<br> Add a Reference ID, Example: "''(YourInnName)Rentdoor''" And check the ''Persistent Reference'' box.<br>
Then set the same Ownership to the bed and add a Refrence ID, Example: "''(YourInnName)Rentbed''". Then check the ''Persistent Reference'' box.


Activator
===The NPC===
The NPC needs a script to be able to rent you the bed.<br><br>


ActivatorScript
Add a Name:
Scriptname ''Publican_(YourInnName)(YourNPCName)''


Door
Then add the variables;
short rent        ;if you have rent the room or not
short rentday      ;make sure it's the same day
short cleanup      ;For the Resetting
short setup        ;Check if the first part has been run


Bed
Write the rest of the Script:


BedRent Topic changes
begin gamemode
if ( rent == 1 )                        ;If you have rented the room
  if ( setup == 0 )                      ;If this hasn't been done before
  set rentday to GameDaysPassed        ;Saves the day of the rental
  set setup to 1                        ;We don't want this to happen again
  ''(YourDoorRef)''.unlock                  ;Unlock the door
  ''(YourBedRef)''.SetOwnership            ;Makes it legal to sleep in the bed
  else                                  ;If we have already done that
  if ( GameDaysPassed != rentday )            ;If it is a new day
    set cleanup to 1                    ;Makes the reset ready
  endif
  endif
  if Player.GetinCell ''(YourInnCell)'' == 0 ;If the player is outside the inn
  if ( Cleanup == 1 )                  ;If the reset Is ready
    set Cleanup to 2                    ;Start the reset
  endif
  endif
  if ( Cleanup == 2 )                    ;If the reset should start
;Resets The Variables
  set rent to 0                       
  set setup to 0                       
  set rentday to 0
  set cleanup to 0
  ''(YourDoorRef)''.SetOpenState 0        ;Close the door
  ''(YourDoorRef)''.lock 30                ;Lock the door
  ''(YourBedRef)''.SetOwnership (NpcID)    ;Make it illegal to sleep in the bed
  endif
endif
End


Change The Class to ''MerchPublican''.<br>
Be sure to save the script as an Object, not a Quest.<br>
If you want you can add AI so the npc can sell beer And food (see point 4, 4.2 and 5.2 in [[My First Shop]]


'''The Inn:'''
===The Dialogues===
-Too create my Inn I made a copy of CheydinallyNewlandsLodge and linked it to my town. I called mine BartholmNewlandsLodge
Now the last thing: The dialogues.<br><br>
Open the quest window, select the ''BedRental'' quest and click on the ''Topics'' tab.<br>
Select the ''Bed'' topic.<br> In the response list you add a new response with a text like: "''Hope it suits you''".<br> Then add the audio, if you don't want to record your own voice you can unpack some voices from oblivion.<br><br> Then add conditions; First add one with:
<br><br>


'''The Innkeeper (Publican):'''
'''Target:''' No<br>
-I selected DerveraRomalen in BartholmNewlandsLodge cell and created a copy calling my innkeeper FriedaJones.
'''Fuction Name:'''GetInCell<br>
-Give it a unique name (FriedaJonesRef)
'''Function Info:''' ''(YourInnCell)''<br>
'''Comp:'''==<br>
'''Value:'''1<br>
AND<br><br>


'''The vendor chest:'''
This makes it so you can't rent a bed outside the inn<br>
-Edit the vendor chest and set the ownership to your innkeeper. (I used FriedaJones)
If your NPC doesn't move away from the inn you can skip the first one.<br><br>


'''The Rent Bed:'''
Add a new Condition:<br>
-Edit the bed you wish to rent.
This condition makes sure this dialogue only works for our NPC.<br><br>
-Change the ownership to your innkeeper. (I used FriedaJones)
-Give your bed a unique name. (I used BHNewlandsLodgeRentBed)


'''The Rent Door'''
'''Target:''' No<br>
-Edit the door to the room you wish to rent. Give it a unique name. (I used BHNewlandsLodgeRentDoor)
'''Fuction Name:'''GetIsId<br>
-Lock it
'''Function Info:''' ''(YourInnNPC)''<br>
-Give it an ownership other than your innkeeper (I used Abhuki)
'''Comp:'''==<br>
(I believe you do this so your innkeeper doesn't use the room.)
'''Value:'''1<br>
AND<br><br>


Add the last Condition:<br>
He only says this dialogue if you have rented the bed<br><br>


'''The Innkeeper (Publican) Script'''
'''Target:''' No<br>
-Open Gameplay > Edit Scripts > Open > PublicanNewlandsLodgeDervera. Select all the text and copy. (Control C)
'''Fuction Name:'''GetScripVariable<br>
'''Function Info:''' ''(YourInnNPC)''Rent<br>
'''Comp:'''==<br>
'''Value:'''1<br>
AND<br><br>


-Select Script > New in the Script Edit window and paste the copied text
Go back to the Response list and add a new response.<br> Write something like this: "''I've got a room, and a cheap one at that. You looking for one?''".<br>Add audio. <br>Add the same Condition as last time, but change the value of the GetSctiptVariable condition to 0. <br>We want him to say this if you haven't rented the bed. <br>Then in the Choices list to the right, you add: ''BedNo'' and ''BedYes''.<br><br>


-Change the scriptname (I used PublicanNewlandsLodgeFrieda)
The next part is optional, you only need to do this if you want to make a special response if you choose no.<br><br>
Select ''BedNo'' in the list to the left.<br> Add a new response with a text like this: "''Then stop wasting my time.''".<br> Add audio. <br>Add a Conditon; The same GetIsId Condition as before.<br><br>


-Change all references to cellname to your cell. (BartholmNewlandsLodge)
If you skipped the last part, continue here.<br><br>


-Change all references to your rent door name (BHNewlandsLodgeRentDoor)
Select the ''BedYes'' in the left menu.<br> Make a new response with text like this: "''Right then. Head up the stairs, and it's the first door on your right. Remember, I didn't say it was clean. I said it was cheap.''".<br> Add audio.<br><br>
In the Result Script box you write this:


-Change all references to your rent bed name (BHNewlandsLodgeRentBed)
player.removeitem Gold001(Priceoftheroom) ;Remove gold from the player         
set ''(YourNPCRef)''.rent to 1              ;You have now rented the room


-Change all references to DerveraRomalen to your innkeeper (FriedaJones)
Then add the same GetIsId as always.<br><br>


-Save the script. Close all windows and save your Mod. (This updates the script files list.)
Add this condition:<br>
It makes the NPC say this only if you have enough gold.<br><br>


-Edit your new innkeeper and add the new script to it.
'''Target:''' Yes<br>
'''Fuction Name:'''GetItemCount<br>
'''Function Info:'''Gold001<br>
'''Comp:'''>=<br>
'''Value:''' ''(Priceoftheroom)''<br>
AND<br><br>


Then add a new response with text like this: "''Not even ''(Priceoftheroom)'' gold to your name? And here I thought I had it bad. Sorry, but I need you to pay before I can let you stay here.''". <br>Add Audio.<br>Add the same conditions as the last one, but change the Comp in the Getitemcont condition to <. So he says this if you don't have ''(Priceoftheroom)'' gold.<br><br>


'''The BedRent Topic:'''
And now you're done.
 
-Select Character > Quests to open your quest window.
 
-Select the BedRental topic and the Topics tab.
 
-Select the bed topic.
 
-Right click on "But you've already rented a room for the night." by DerveraRomalen and select copy. (A new topic is added with the same info)
 
-Select the GetIsID condition and click the Function Parameters button. Select your innkeeper from the dropdown list (Frieda Jones in my case)
 
-Select the GetScriptVariable condition and click the Function Parameters button. Select rent from the list of variables
 
-Right click on "I do have a bed available, for 10 gold a night. Would you like to rent it?" by DerveraRomalen and select copy. (A new topic is added with the same info)
 
-Select the GetIsID condition and click the Function Parameters button. Select your innkeeper from the dropdown list (Frieda Jones in my case)
 
-Select the GetScriptVariable condition and click the Function Parameters button. Select rent from the list of variables
 
-Select the BedYes topic.
 
-Right click on "You don't have the money for the room. Perhaps some other time." by DerveraRomalen and select copy. (A new topic is added with the same info)
 
-Select the GetIsID condition and click the Function Parameters button. Select your innkeeper from the dropdown list (Frieda Jones in my case)
 
-Right click on "Walk just up the stairs there, and it's the door on the right. Thank you." by DerveraRomalen and select copy. (A new topic is added with the same info)
 
-Select the GetIsID condition and click the Function Parameters button. Select your innkeeper from the dropdown list (Frieda Jones in my case)
 
-In the Result Script section change "set DerveraRomalenRef.rent to 1" to "set FriedaJonesRef.rent to 1
 
-Click OK to close the quest window
 
 
'''The Activator & its Script'''
-Load the exterior cell that connects to your inn (ie the outside of the building)
 
-In the Object Window > World Objects > Activator > Dungeons select PublicanNewlandsLodgeTriggerObj
 
-Open it and create a new form PublicanBartholmNewlandsLodgeTriggerObj
 
-Drag it into your exterior cell and set it near the entrance to your inn. (Mine is hidden in the steps up to the door)
 
-Give it a unique reference name (I use BartholmNewlandsLodgeTriggerRef)
 
-Open Gameplay > Edit Scripts > Open > PublicanNewlandsLodgeTriggerScript. Select all the text and copy. (Control C)
 
-Select Script > New in the Script Edit window and paste the copied text
 
-Change the scriptname (I used PublicanBartholmNewlandsLodgeTriggerScript)
 
-Change all references to DerveraRomalenRef to your innkeepers unique name (I used FriedaJonesRef)
 
-Save the script. Close all windows and save your Mod. (This updates the script files list.)
 
-Edit your new activator and add the new script to it.
 
 
Thats it. Test your mod. Enjoy!
 
[[Category:Tutorials]]
[[Category:Tutorials]]
[[Category:Actor_Tutorials]]
[[Category:Miscellaneous_Tutorials]]

Latest revision as of 04:20, 19 July 2015

How to make an NPC Rent you a bed for the night.

Preparations[edit | edit source]

Preparing the room[edit | edit source]

We Start with the door;
First set Ownership to your NPC's BaseID.
Then Lock it. Not with a key, just choose hard or something.
Add a Reference ID, Example: "(YourInnName)Rentdoor" And check the Persistent Reference box.
Then set the same Ownership to the bed and add a Refrence ID, Example: "(YourInnName)Rentbed". Then check the Persistent Reference box.

The NPC[edit | edit source]

The NPC needs a script to be able to rent you the bed.

Add a Name:

Scriptname Publican_(YourInnName)(YourNPCName)

Then add the variables;

short rent         ;if you have rent the room or not
short rentday      ;make sure it's the same day
short cleanup      ;For the Resetting
short setup        ;Check if the first part has been run

Write the rest of the Script:

begin gamemode

if ( rent == 1 )                        ;If you have rented the room
	
 if ( setup == 0 )                      ;If this hasn't been done before
  set rentday to GameDaysPassed         ;Saves the day of the rental 
  set setup to 1                        ;We don't want this to happen again
  (YourDoorRef).unlock                  ;Unlock the door
  (YourBedRef).SetOwnership             ;Makes it legal to sleep in the bed

 else                                   ;If we have already done that
	
  if ( GameDaysPassed != rentday )             ;If it is a new day
   set cleanup to 1                     ;Makes the reset ready
  endif
 endif

 if Player.GetinCell (YourInnCell) == 0 ;If the player is outside the inn
  if ( Cleanup == 1 )                   ;If the reset Is ready
   set Cleanup to 2                     ;Start the reset
  endif
 endif



 if ( Cleanup == 2 )                    ;If the reset should start


;Resets The Variables
	
  set rent to 0                         
  set setup to 0                        
  set rentday to 0
  set cleanup to 0


  (YourDoorRef).SetOpenState 0         ;Close the door
  (YourDoorRef).lock 30                ;Lock the door
  (YourBedRef).SetOwnership (NpcID)    ;Make it illegal to sleep in the bed
 endif
endif

End

Change The Class to MerchPublican.
Be sure to save the script as an Object, not a Quest.
If you want you can add AI so the npc can sell beer And food (see point 4, 4.2 and 5.2 in My First Shop

The Dialogues[edit | edit source]

Now the last thing: The dialogues.

Open the quest window, select the BedRental quest and click on the Topics tab.
Select the Bed topic.
In the response list you add a new response with a text like: "Hope it suits you".
Then add the audio, if you don't want to record your own voice you can unpack some voices from oblivion.

Then add conditions; First add one with:

Target: No
Fuction Name:GetInCell
Function Info: (YourInnCell)
Comp:==
Value:1
AND

This makes it so you can't rent a bed outside the inn
If your NPC doesn't move away from the inn you can skip the first one.

Add a new Condition:
This condition makes sure this dialogue only works for our NPC.

Target: No
Fuction Name:GetIsId
Function Info: (YourInnNPC)
Comp:==
Value:1
AND

Add the last Condition:
He only says this dialogue if you have rented the bed

Target: No
Fuction Name:GetScripVariable
Function Info: (YourInnNPC)Rent
Comp:==
Value:1
AND

Go back to the Response list and add a new response.
Write something like this: "I've got a room, and a cheap one at that. You looking for one?".
Add audio.
Add the same Condition as last time, but change the value of the GetSctiptVariable condition to 0.
We want him to say this if you haven't rented the bed.
Then in the Choices list to the right, you add: BedNo and BedYes.

The next part is optional, you only need to do this if you want to make a special response if you choose no.

Select BedNo in the list to the left.
Add a new response with a text like this: "Then stop wasting my time.".
Add audio.
Add a Conditon; The same GetIsId Condition as before.

If you skipped the last part, continue here.

Select the BedYes in the left menu.
Make a new response with text like this: "Right then. Head up the stairs, and it's the first door on your right. Remember, I didn't say it was clean. I said it was cheap.".
Add audio.

In the Result Script box you write this:

player.removeitem Gold001(Priceoftheroom) ;Remove gold from the player           
set (YourNPCRef).rent to 1               ;You have now rented the room

Then add the same GetIsId as always.

Add this condition:
It makes the NPC say this only if you have enough gold.

Target: Yes
Fuction Name:GetItemCount
Function Info:Gold001
Comp:>=
Value: (Priceoftheroom)
AND

Then add a new response with text like this: "Not even (Priceoftheroom) gold to your name? And here I thought I had it bad. Sorry, but I need you to pay before I can let you stay here.".
Add Audio.
Add the same conditions as the last one, but change the Comp in the Getitemcont condition to <. So he says this if you don't have (Priceoftheroom) gold.

And now you're done.