Delayed House Purchase Script

Post » Fri May 27, 2011 11:00 pm

Ok, here's the scenario. The player is asked to seek revenge for an NPC's slain brother. The NPC stands in front of the house his brother used to live in. When the player completes the quest, the NPC will be thankful and require some time to mourn. About a month later, that same NPC will now be found elsewhere in the town (i'm not sure exactly where yet) and offer to sell his brother's house (now emptied of all valuables) for a fee. The player may either purchase it or not, but the offer will stand until the player DOES purchase the house. My main concern here is a script that gives the NPC a month until he offers to sell the house (keeping the same greeting until then), and if the player DOES decide to buy it, a script which will empty the house of all valuables (leaving the hammock and maybe a few containers behind). This is somewhat similar to the Vodunius Nuccius Extended Quest mod, which extends his quest and allows the player to purchase his house once he leaves, and also empties out all of Vodunius' belongings except a bed, table with benches, and a single candle. After looking at the VNEQ mod, I somewhat understand how to disable and enable the NPC to appear somewhere else, but i'm not exactly sure how to get him to appear there. I also need to know how to allow him to wait a month and offer up the house, and actually empty it once the player decides to buy it. I don't know if these can appear in the same script, or exactly how it all works. Anyone care to help?
User avatar
suniti
 
Posts: 3176
Joined: Mon Sep 25, 2006 4:22 pm

Post » Sat May 28, 2011 11:08 am

It sounds like a quest. I will assume there is a journal associated with it. After the brother is avenged I expect the terminal journal entry has an index of 100. At the same time that entry is added dialog results could start a global script that will keep track of time and move the living brother to his new location. After a month has passed, the script will update the player's journal with something like "It has been a month. I wonder how so-and-so is coping with the death of his brother." This will update the journal to 110 (you could use 'restart quest' if you want to make the quest active again). Another, less obtrusive approach if you do not object to Tribunal dependency would be to simply have the global script SetJournalIndex to 110 (make a dummy entry just to be certain the index is preserved between game sessions). The brother's greetings can be filtered by journal index: 100 and he is still grieving, 110 and he is ready to offer his brother's house for sale. If the player buys the house another journal entry will again close the quest, and filter new greetings. I suppose that you have created a duplicate interior cell for the empty house. The door that leads to the house can be enabled by the script at any time, but perhaps it would be better to have the door locked with a key so the player cannot access it unless he/she purchases the house and gains the key (through dialog). The global script might look like this:

Begin bry_GriefTimer; Self-terminating global script started from dialog with (brother's name) [topic: ]; Moves the brother after his brother's death is avenged, ; enables door to empty house, and; keeps track of time while bother grieves and updated the player's journal when ; one month has passed so the house will be available for sale.short doOnceshort currentDayshort daysElapsedif ( doOnce == 0 )    if ( CellChanged == 1 ) ; moves brother when not observed by player        set doOnce to 1        "brother_ID"->PositionCell x y z zAngle "Cell Name"    endifendifif ( currentDay == 0 )    set currentDay to Dayendifif ( currentDay == Day )    returnelse    set currentDay to Day    set daysElapsed to ) daysElapsed + 1 )endifif ( daysElapsed >= 30 )    SetJournalIndex "bry_AvengeBrother" 110 ; or...;   Journal "bry_AvengeBrother" 110    StopScript "bry_GriefTimer"endifEnd bry_GriefTimer


This code is (obviously) untested.
User avatar
kat no x
 
Posts: 3247
Joined: Mon Apr 16, 2007 5:39 pm

Post » Sat May 28, 2011 9:42 am

Ok, that all sounds pretty self-explanatory. I have an ongoing journal of the dead brother quest up until the time his death is avenged. This quest is part of a mod that requires Tribunal and Bloodmoon to run, so dependency isn't a problem at all. I do have a few questions:

At the same time that entry is added dialog results could start a global script....


I'm not exactly sure how to attach a script to a journal entry. I've actually never attached script to anything but objects or creatures/NPC's as of yet.

(make a dummy entry just to be certain the index is preserved between game sessions)


I'm not sure what you mean by 'dummy' entry. Do you actually mean create an entry for 110 saying something like 'It's been a month...'?

The door that leads to the house can be enabled by the script at any time


The NPC has the house key to the house on him. The door will be locked until the player gets the key. I was thinking about letting the player have a chance to break in when the NPC was out of sight, but I think not doing that would make it a lot easier. I guess the new interior can be enabled anytime after the 'It's been a month.." entry has been given, however, i'm clueless on how to do that.
User avatar
suniti
 
Posts: 3176
Joined: Mon Sep 25, 2006 4:22 pm

Post » Sat May 28, 2011 2:30 am

I expect that there is a quest topic and an entry in which the brother thanks the player for raining vengeance upon his brother's killer. In dialog results you have added the journal update that 'closes' the quest. In the next line write: StartScript "bry_GriefTimer" or whatever name the script will eventually have.

By 'dummy' entry I mean a note of explanation that the index is set but the player's journal is not actually updated. Something like: "Empty - index set by script when one month of grieving as elapsed."

I was thinking the brother would 'lock' the door after thanking the player, but it could be done after one month. The door to the new cell could be enabled from dialog results at the same time the journal is updated and the global script started. In this it does not appear that the house was instantaneously emptied. Something like: "bry_door_brothers_house"->Enable. Even better would be to have the script that initially disables the door check for the journal index of the quest.

Begin bry_BrothersDoorScript; Attached to door bry_ door_brothers_house.; Disables and enables door as appropriate.short doOnceif ( doOnce == 2 )    returnendifif ( doOnce == 1 )    if ( ( GetJournalIndex "bry_AvengeBrother" ) == 100 ) ; or at index = 110        set doOnce to 2        Enable    endifendifif ( doOnce == 0 )    set doOnce to 1    DisableendifEnd bry_BrothersDoorScript

If you want the house accessible by key only, there will need to be additional code in this script to assure that.

Allowing the player to break in is problematic, although some may complain that it is unrealistic there are still many, many buildings that the player can still break into.
User avatar
Penny Courture
 
Posts: 3438
Joined: Sat Dec 23, 2006 11:59 pm

Post » Sat May 28, 2011 5:42 am

Ok. I'm working on typing out the first script. There seems to be a problem with the line having a mismatched parenthesis:

set daysElapsed to ) daysElapsed + 1 )


Should this actually read "set daysElapsed to ( daysElapsed +1 )"?

Edit: I assumed it was and it seemed to save it at least.

One thing I noticed is that the house is empty of valuables as it is. The interior was already created, and I just touched up the quest a bit. Could I just put the above script on that same door as the existing interior? If I understand correctly, that script keeps the door locked until the player purchases the house, then it unlocks it. Does this sound right?

Edit: Hmm. After attaching this script to the existing exterior door, I notice the inside of the house (as seen from the exterior) is missing. Do I have to attach this to the interior door?
User avatar
Danielle Brown
 
Posts: 3380
Joined: Wed Sep 27, 2006 6:03 am

Post » Sat May 28, 2011 10:25 am

I used the script attached to the door in the VNEQ mod and attached it to my exterior door:

if ( GetJournalIndex Journal Name>=8 )
Enable
endif
if ( GetJournalIndex <8 )
Disable
endif
End



The interior door isn't missing at least. I also locked the door in hopes that when journal entry 8 is reached, this script will unlock that door, allowing the player to enter. Journal 8 will be achieved once the player purchases the house. As far as moving the NPC, I avenged his brother and he thanked me. It was in this dialogue entry the script above (bry_grievetimer) was placed. I thought the NPC was supposed to move once I left that cell, but he was still in the same spot. I'm not sure if a month has to pass before he moves, or if something is wrong with the script. I'm still wondering if it's essential to create a new interior or if I can just use the existing one and have the door unlock once the house is bought.
User avatar
Emilie Joseph
 
Posts: 3387
Joined: Thu Mar 15, 2007 6:28 am

Post » Fri May 27, 2011 11:28 pm

Can i suggest that waiting for one month ingame might be a little taxing. A week might be better.

People will either be real keen to get the property, and will then have to wade through waiting ~30 days (ughhhh), or they will just end up forgetting about it.

Well thats my 2c worth ;)
User avatar
Ally Chimienti
 
Posts: 3409
Joined: Fri Jan 19, 2007 6:53 am

Post » Fri May 27, 2011 9:21 pm

I apologize for the typo. I am glad that you figured it out on your own.

No, my current script does not 'lock' the door. There is no code that manages key-only access. I do not recommend the Vodunius Nuccius Extended Quest door script since it enables or disables the door every frame.

I misunderstood your situation before - I though the house was originally completely furnished. If there are just a few items that you would have removed from the brother's house you could put a script on the objects to disable them before the player takes possession. Something like:

Begin bry_BrothersPossessionsScript; Attached to objects in brother's house.; Disables them before the player purchases house.short doOnceif ( doOnce == 1 )    returnendifif ( ( GetJournalIndex "bry_AvengeBrother" ) >= 100 ) ; or at index >= 110    set doOnce to 1    DisableendifEnd bry_BrothersPossessionsScript

For that same reason I agree that a duplicate interior cell (and therefore a new door leading to it) is no longer necessary. All you need is the key requirement. Assuming that the ID of the key is bry_BrothersHouse_key (you can change it to whatever you wish), the following script will prevent access except by key after the quest is completed:

Begin bry_BrothersDoorScript; Attached to door bry_ door_brothers_house.; Requres key to open after player completes quest.short doOnceif ( OnActivate == 1 )    if ( ( GetJournalIndex "bry_AvengeBrother" ) < 100 ) ; or at index < 110        Activate    elseif ( ( player->GetItemCount "bry_BrothersHouse_key ) >= 1 )        Activate    else        messagebox "You require a key to unlock this door."    endifendifEnd bry_BrothersDoorScript

I do not understand why the surviving brother is not being repositioned by the global script unless you have not replaced the place-holding variables with the actual coordinates and cell ID of his destination. Check your changes to be certain that you have a location that actually exists in game - the problem could be caused by a typo.
User avatar
Anthony Santillan
 
Posts: 3461
Joined: Sun Jul 01, 2007 6:42 am

Post » Sat May 28, 2011 3:32 am

I do suppose a week would be much better. Even the thought of testing it was annoying me. The coordinates I have for positioning the NPC are:

-56197, 206826, 918, 90 "Drel Vanor -7, 25"

I noticed you didn't use any commas. Should I have done the same?

Perhaps I didn't enter these correctly? The house actually just contains furniture and containers, and all of this will be included in the purchase of the house, but even still, i'm sure that script will come in very handy for future reference.

As far as the key goes, I assume I would place it in the NPC's inventory, and have him hand it to the player once he/she buys the house?

Another thing regarding that door. Should I set the lock level to 100, or set the key to open it as I normally would on a locked door? Or will that script automatically 'lock' it for me?
User avatar
Mélida Brunet
 
Posts: 3440
Joined: Thu Mar 29, 2007 2:45 am

Post » Sat May 28, 2011 9:10 am

As far as the key goes, I assume I would place it in the NPC's inventory, and have him hand it to the player once he/she buys the house?

Another thing regarding that door. Should I set the lock level to 100, or set the key to open it as I normally would on a locked door? Or will that script automatically 'lock' it for me?

You don't have to have the key in the NPC's inventory, it can just exist in limbo. But in case the NPC dies, or for pickpocketing reasons, you can give it to him if you like.
In the Dialog Results box, use "NPC's ID"->RemoveItem, "your_key" 1 to remove it from his inventory if he has it.
and Player->AddItem "your_key" 1 to add it you.

The door will not appear locked in the traditional way, but it will be "locked" unless you have the key. In other words, the script does it for you.
User avatar
john palmer
 
Posts: 3410
Joined: Fri Jun 22, 2007 8:07 pm

Post » Fri May 27, 2011 9:03 pm

Ahh, ok. I changed the grieving time to just a week. A month did seem a bit much. I'm going to have the NPC give the player the key once he/she purchases it. I'll test all this out when I get the chance.
User avatar
Kathryn Medows
 
Posts: 3547
Joined: Sun Nov 19, 2006 12:10 pm

Post » Sat May 28, 2011 8:21 am

I had not realized that you were moving the brother to another exterior cell. Try this:

"NPC_ID"->Position -56197 206826 918 90

Commas are optional, but consistency is important. I never use commas.

I agree with Pluto. It is not necessary that the NPC have the key in inventory to give it to the player. The only reason to do so is if you want to provide for the possibility of the player stealing from or killing the surviving brother to get the key.
User avatar
Lindsay Dunn
 
Posts: 3247
Joined: Sun Sep 10, 2006 9:34 am

Post » Sat May 28, 2011 9:12 am

Ok. I tested the scripts out. The global script seemed to start, and the NPC was moved. Within about 7 days, he offered me the house. In the meantime, I didn't get a message telling me the door required a key. And when I did get that key, it still didn't open the door. Here is how I copied the script:

if ( OnActivate == 1 )
if ( ( GetJournalIndex "Journal Entry Name" ) < 50 )
Activate
elseif ( ( player->GetItemCount "my_key" ) >= 1 )
Activate
else
MessageBox "A key is required to open this door."
endif
endif


The journal entry 50 is when the player buys the house.

This forum doesn't display the script well if I copy and paste, but all the if's and endif's are in proper order, if that matters.
User avatar
barbara belmonte
 
Posts: 3528
Joined: Fri Apr 06, 2007 6:12 pm

Post » Sat May 28, 2011 7:24 am

The script provides ready access to the house until the house is purchased. After that it requires a key to enter. If you do not want that just delete the journal check (and the accompanying 'Activate'). I tested the door script. It works. Did you attach it to the door? Do not set a lock level on the door.
User avatar
Phoenix Draven
 
Posts: 3443
Joined: Thu Jun 29, 2006 3:50 am

Post » Sat May 28, 2011 2:27 am

Hmm. For some reason, it isn't working. The door doesn't even make a 'clicking' sound when I try to open it. I don't have a lock level set, and it's not reliant on the key. I double checked the journal entry to make sure 50 was the correct one, and it is. I even killed the NPC and took his key and nothing seemed to happen.

I attached a screenshot of the script and the door opened in the CS. Maybe I overlooked something?

http://i56.tinypic.com/28h339c.jpg

You can also see on the left in the Misc Tab that the AV_Norrid_key has actually been created.
User avatar
latrina
 
Posts: 3440
Joined: Mon Aug 20, 2007 4:31 pm


Return to III - Morrowind