Difference between revisions of "Rent A Room Tutorial"
imported>Vswe (Rewrote this as it stood in "Things you can do" in the AI Portal) |
imported>Morerunes (fixed code, grammar) |
||
Line 7: | Line 7: | ||
===Preparing the room=== | ===Preparing the room=== | ||
We Start with the door;<br> First set Ownership to your Npc | 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. | 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=== | ||
The Npc | The Npc needs a script to be able to rent you the bed.<br><br> | ||
Add a Name: | Add a Name: | ||
Line 18: | Line 18: | ||
Then add the variables; | Then add the variables; | ||
short rent ;if you have rent the room or not | short rent ;if you have rent the room or not | ||
short rentday ; | short rentday ;make sure it's the same day | ||
short cleanup ;For the Reseting | short cleanup ;For the Reseting | ||
short setup ;Check if the first part has been run | short setup ;Check if the first part has been run | ||
Line 27: | Line 26: | ||
begin gamemode | begin gamemode | ||
if ( rent == 1 ) ;If you have | if ( rent == 1 ) ;If you have rented the room | ||
if ( setup == 0 ) ;If this | if ( setup == 0 ) ;If this hasn't been done before | ||
set rentday to | set rentday to GameDaysPassed ;Saves the day of the rental | ||
set setup to 1 ;We don't want this to happen again | |||
set setup to 1 ;We don't want this to | |||
''(YourDoorRef)''.unlock ;Unlock the door | ''(YourDoorRef)''.unlock ;Unlock the door | ||
''(YourBedRef)''.SetOwnership ;Makes it legal to sleep in the bed | ''(YourBedRef)''.SetOwnership ;Makes it legal to sleep in the bed | ||
else ;If we already | else ;If we have already done that | ||
if ( | if ( GameDaysPassed != rentday ) ;If it is a new day | ||
set cleanup to 1 ;Makes the | set cleanup to 1 ;Makes the reset ready | ||
endif | endif | ||
endif | endif | ||
if Player.GetinCell ''(YourInnCell)'' == 0 ;If | if Player.GetinCell ''(YourInnCell)'' == 0 ;If the player is outside the inn | ||
if ( Cleanup == 1 ) ;If the | if ( Cleanup == 1 ) ;If the reset Is ready | ||
set Cleanup to 2 ;Start | set Cleanup to 2 ;Start the reset | ||
endif | endif | ||
endif | endif | ||
Line 53: | Line 49: | ||
if ( Cleanup == 2 ) ;If the | if ( Cleanup == 2 ) ;If the reset should start | ||
Line 61: | Line 57: | ||
set setup to 0 | set setup to 0 | ||
set rentday to 0 | set rentday to 0 | ||
set cleanup to 0 | set cleanup to 0 | ||
''(YourDoorRef)''.SetOpenState 0 ;Close | ''(YourDoorRef)''.SetOpenState 0 ;Close the door | ||
''(YourDoorRef)''.lock 30 ;Lock the door | ''(YourDoorRef)''.lock 30 ;Lock the door | ||
''(YourBedRef)''.SetOwnership (NpcID) ;Make it | ''(YourBedRef)''.SetOwnership (NpcID) ;Make it illegal to sleep in the bed | ||
endif | endif | ||
endif | endif | ||
Line 74: | Line 69: | ||
Change The Class to ''MerchPublican''.<br> | Change The Class to ''MerchPublican''.<br> | ||
If you want you can add AI so the | 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=== | ===The Dialogues=== | ||
Now | Now the last thing: The dialogues.<br><br> | ||
Open | Open the quest window, select the ''BedRental'' quest and click on the ''Topics'' tab.<br> | ||
Select the ''Bed'' topic.<br> In the | 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> | <br><br> | ||
'''Target:''' No<br> | '''Target:''' No<br> | ||
Line 92: | Line 83: | ||
'''Value:'''1<br> | '''Value:'''1<br> | ||
AND<br><br> | AND<br><br> | ||
This makes it so you can't rent a bed outside the inn<br> | |||
If your npc Doesn't move away from the inn you can skip the first one.<br><br> | |||
Add a new Condition:<br> | Add a new Condition:<br> | ||
This | This condition makes it so this dialogue only works for our npc.<br><br> | ||
'''Target:''' No<br> | '''Target:''' No<br> | ||
Line 104: | Line 98: | ||
Add the last Condition:<br> | Add the last Condition:<br> | ||
He only | He only says this dialogue if you have rented the bed<br><br> | ||
'''Target:''' No<br> | '''Target:''' No<br> | ||
Line 113: | Line 107: | ||
AND<br><br> | AND<br><br> | ||
Go | 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> | ||
The next part is | 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 | 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> | ||
If you | If you skipped the last part, continue here.<br><br> | ||
Select the ''BedYes'' in the left menu.<br> Make a new | 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 | In the Result Script box you write this: | ||
player.removeitem | player.removeitem Gold001(Priceoftheroom) ;Remove gold from the player | ||
set ''(YourNpcRef)''.rent to 1 ;You have now | set ''(YourNpcRef)''.rent to 1 ;You have now rented the room | ||
Then add the same GetIsId as | Then add the same GetIsId as always.<br><br> | ||
Add this condition:<br> | Add this condition:<br> | ||
Line 138: | Line 132: | ||
AND<br><br> | AND<br><br> | ||
Then add a new response with | 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> | ||
And now you're done. | And now you're done. |
Revision as of 23:33, 7 August 2008
How to make a Npc Rent you a bed for the night.
Preparations
- 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.
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 ;make sure it's the same day 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 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.
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
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 it 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 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.