Difference between revisions of "Rent A Room Tutorial"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Mimada
imported>Vswe
(Rewrote this as it stood in "Things you can do" in the AI Portal)
Line 1: Line 1:
Creating an NPC that will rent a room to you.
How to make a Npc Rent you a bed for the night.


'''Need:'''
===Preparations===
NPC
*Make an inn, both interior and exterior. And link them togheter (see [[Linking Cells and Connecting to the Outside World]]).
*Create a 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: "''(YourInnsname)Rentdoor''" And check the ''Persistent Reference'' box.<br>
Then set the same Ownership to the bed and add a Refrence ID, Example: "''(YourInnsname)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_(Youinnsname)(yourNpcsname)''


Door
Then add the variables;
short rent        ;if you have rent the room or not
short rentday      ;Which day you rent the room
short rentmonth    ;Which month you rent the room
short cleanup      ;For the Reseting
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 rent the room
  if ( setup == 0 )                      ;If this haven't been done before
  set rentday to GameDay                ;Saves the day of the rental
  set rentmonth to GameMonth            ;Saves the month of the rental
  set setup to 1                        ;We don't want this to happened again
  ''(YourDoorRef)''.unlock                  ;Unlock the door
  ''(YourBedRef)''.SetOwnership            ;Makes it legal to sleep in the bed
  else                                  ;If we already have done that
  if ( GameDay != rentday )            ;If it is a new day
    set cleanup to 1                    ;Makes the Reset Ready
  elseif ( GameMonth != rentmonth )    ;Prevent Error at new month
    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 rentmonth 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>
If you want you can add AI so the Npc can sale Beer And Food (see point 4, 4.2 and 5.2 in [[My First Shop]]


'''The Inn:'''
===The Dialogues===
*To 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):'''
This make so you Can't rent a bed outside the inn<br>
*I selected DerveraRomalen in BartholmNewlandsLodge cell and created a copy calling my innkeeper FriedaJones.
If Your Npc Don't move away from the Inn you can Skip the first one.<br><br>
*Give it a unique name (FriedaJonesRef)


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


'''The vendor chest:'''
Add a new Condition:<br>
*Edit the vendor chest and set the ownership to your innkeeper. (I used FriedaJones)
This Condition make so this dialogue only works for our Npc.<br><br>


'''Target:''' No<br>
'''Fuction Name:'''GetIisId<br>
'''Function Info:''' ''(YourInnNpc)''<br>
'''Comp:'''==<br>
'''Value:'''1<br>
AND<br><br>


'''The Rent Bed:'''
Add the last Condition:<br>
*Edit the bed you wish to rent.
He only say this dialogue if you have rent the bed<br><br>
*Change the ownership to your innkeeper. (I used FriedaJones)
*Give your bed a unique name. (I used BHNewlandsLodgeRentBed)


'''Target:''' No<br>
'''Fuction Name:'''GetScripVariable<br>
'''Function Info:''' ''(YourInnNpc)''Rent<br>
'''Comp:'''==<br>
'''Value:'''1<br>
AND<br><br>


'''The Rent Door'''
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 timer but change the Value of the GetSctiptVariable Condition to 0. <br>We want him to say this if you Haven't Rent the bed. <br>Then in The Choices LIst to the right you add: ''BedNo'' and ''BedYes''.<br><br>
*Edit the door to the room you wish to rent. Give it a unique name. (I used BHNewlandsLodgeRentDoor)
*Lock it
*Give it an ownership other than your innkeeper (I used Abhuki)
:(I believe you do this so your innkeeper doesn't use the room.)


The next part is opional, you only 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 Contition as before.<br><br>


'''The Activator & its Script'''
If you Skiped the last part, Countinue here.<br><br>
*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
Select the ''BedYes'' in the left menu.<br> Make a new Response with a 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:


*Open it and create a new form PublicanBartholmNewlandsLodgeTriggerObj
player.removeitem gold001(Priceoftheroom);Remove gold from the player         
set ''(YourNpcRef)''.rent to 1              ;You have now rent the room


*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)
Then add the same GetIsId as allways.<br><br>


*Give it a unique reference name (I use BartholmNewlandsLodgeTriggerRef)
Add this condition:<br>
It makes the npc say this only if you have enough gold.<br><br>


*Open Gameplay > Edit Scripts > Open > PublicanNewlandsLodgeTriggerScript. Select all the text and copy. (Control C)
'''Target:''' Yes<br>
'''Fuction Name:'''GetItemCount<br>
'''Function Info:'''Gold001<br>
'''Comp:'''>=<br>
'''Value:''' ''(Priceoftheroom)''<br>
AND<br><br>


*Select Script > New in the Script Edit window and paste the copied text
Then add a new response with a 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 had but change the Comp in the Getitemcont condition to <. So he say this if you don't have ''(Priceoftheroom)'' gold.<br><br>
 
*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.
 
 
 
'''The Innkeeper (Publican) Script'''
*Open Gameplay > Edit Scripts > Open > PublicanNewlandsLodgeDervera. 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 PublicanNewlandsLodgeFrieda)
 
*Change all references to cellname to your cell. (BartholmNewlandsLodge)
 
*Change all references to your rent door name (BHNewlandsLodgeRentDoor)
 
*Change all references to your rent bed name (BHNewlandsLodgeRentBed)
 
*Change all references to DerveraRomalen to your innkeeper (FriedaJones)
 
*Save the script. Close all windows and save your Mod. (This updates the script files list.)
 
*Edit your new innkeeper and add the new script to it.
 
 
'''The Bed Rent Dialogue:'''
 
*Select Character > Quests to open your quest window.
 
*Select the BedRental topic and the Topics tab.
 
*Select the '''bed''' topic.
 
*Right click on the topmost line ("You've already rented the room.... Not much more to say, is there?.") by VelusHosidius and select "'''New'''". (A new topic named "EMPTY" is added, to which should add some info-text now.)
 
*Repeat the first step to create another new line.
 
*Go down to "But you've already rented a room for the night." by DerveraRomalen, right click on the "''Conditions''" box and select "''Copy All Conditions''"
 
*Go back to your first (topmost) new topic, right-click again on the "''Conditions''"-box and select "''Paste Conditions''".
 
*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
 
*Go down to "I do have a bed available, for 10 gold a night. Would you like to rent it?" by DerveraRomalen, right click on the "''Conditions''" box and select "''Copy All Conditions''"
 
*Go up to your second new topic, right-click again on the "''Conditions''"-box and select "''Paste Conditions''".
 
*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 the topmost line ("You don't seem to have the money for the room. Perhaps you should look elsewhere for accomodations.") by VelusHosidius and select "'''New'''". (A new topic named EMPTY is added...)
 
*Repeat the first step to create another new line.
 
*Go down to "You don't have the money for the room. Perhaps some other time." by DerveraRomalen, right click on the "''Conditions''" box and select "''Copy All Conditions''"
 
*Go up to your first new topic, right-click again on the "''Conditions''"-box and select "''Paste Conditions''".
 
*Select the GetIsID condition and click the Function Parameters button. Select your innkeeper from the dropdown list (Frieda Jones in my case)
 
*Go down to "Walk just up the stairs there, and it's the door on the right. Thank you." by DerveraRomalen, right click on the "''Conditions''" box and select "''Copy All Conditions''"
 
*Go up to your second new topic, right-click again on the "''Conditions''"-box and select "''Paste Conditions''".
 
*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
 
 
 
Thats it. Test your mod. Enjoy!


And now you're done.
[[Category:Tutorials]]
[[Category:Tutorials]]
[[Category:Actor_Tutorials]]
[[Category:Actor_Tutorials]]
[[Category:Miscellaneous_Tutorials]]
[[Category:Miscellaneous_Tutorials]]

Revision as of 05:32, 12 June 2008

How to make a Npc Rent you a bed for the night.

Preparations

Preparing the room

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: "(YourInnsname)Rentdoor" And check the Persistent Reference box.
Then set the same Ownership to the bed and add a Refrence ID, Example: "(YourInnsname)Rentbed". Then check the Persistent Reference box.

The Npc

The Npc Needs a Script To be able to rent you the bed.

Add a Name:

Scriptname Publican_(Youinnsname)(yourNpcsname)

Then add the variables;

short rent         ;if you have rent the room or not
short rentday      ;Which day you rent the room
short rentmonth    ;Which month you rent the room
short cleanup      ;For the Reseting
short setup        ;Check if the first part has been run

Write the rest of the Script:

begin gamemode

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

 else                                   ;If we already have done that
	
  if ( GameDay != rentday )             ;If it is a new day
   set cleanup to 1                     ;Makes the Reset Ready
  elseif ( GameMonth != rentmonth )     ;Prevent Error at new month
   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 rentmonth 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.
If you want you can add AI so the Npc can sale Beer And Food (see point 4, 4.2 and 5.2 in My First Shop

The Dialogues

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:


This make so you Can't rent a bed outside the inn
If Your Npc Don't move away from the Inn you can Skip the first one.

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

Add a new Condition:
This Condition make so this dialogue only works for our Npc.

Target: No
Fuction Name:GetIisId
Function Info: (YourInnNpc)
Comp:==
Value:1
AND

Add the last Condition:
He only say this dialogue if you have rent 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 timer but change the Value of the GetSctiptVariable Condition to 0.
We want him to say this if you Haven't Rent the bed.
Then in The Choices LIst to the right you add: BedNo and BedYes.

The next part is opional, you only 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 Contition as before.

If you Skiped the last part, Countinue here.

Select the BedYes in the left menu.
Make a new Response with a 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 rent the room

Then add the same GetIsId as allways.

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 a 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 had but change the Comp in the Getitemcont condition to <. So he say this if you don't have (Priceoftheroom) gold.

And now you're done.