Jump to content

I need scripting help.


Clipz

Recommended Posts

Ok, I'm working on a mod that will allow the houses of dead NPC's to be buyable. How I plan to do this is through an Ability spell that continously checks to see whether or not the NPC is alive or not. When they die I'd like it to check for houses that NPC might have owned and removing ownership from it. Then the door's that lead into that building will be set unopenable without a key. A sign will apear infront of the house that when activated will check for the right amount of gold and if you have it take the gold and give you a key. Then once you buy the house the sign will disappear.

 

I don't know how to make it look for buildings(or items for that matter) that belong to the NPC, i don't know if I can check for and lock all doors that lead to the building, and I don't know how to change ownership. For that matter I don't even know if it is possible. Any help on this would be appreciated.

Link to comment
Share on other sites

I'll run you through the functions you'll need. I'm not going to explain dialogue, as it's more complex, and I'm not familiar with it. I'm assuming signs posted on doors. I'd suggest you start with only a few NPCs, for instance MD agents. I'm assuming you know where and how to use If and EndIf.

 

Someone gets killed...

and the next time you visit their town, a master script uses the following:

Begin GameMode

to start the script. Since your script will ultimately be fairly complex, you'll want to use a timer (detailed in the GameMode link) to run it every...10 minutes or so should be good. You can use an OnLoad block to reset the timer to cause it to run a few seconds after the player returns to the city.

 

GetDead

or

GetDeadCount

to check if the owner is dead. Remember, a house may have more than one occupant.

 

Lock

to lock the door. 100 is unpickable.

 

Enable

to make the For Sale sign appear

or

PlaceAtMe

in order to avoid having to place a sign at every door. You'll need to figure out the proper placement for each door style, which can be done in the editor.

 

End

terminates the GameMode block.

 

Now the For Sale sign is on the door. The player activates it...

and a separate script attached to the sign starts.

Begin OnActivate

Self explanatory.

 

GetGold

to check if the player has enough gold.

 

MessageBox

to ask if the player wants to buy the house.

 

GetButtonPressed

to detect their answer.

 

RemoveItem

in order to deduct the appropriate amount of gold (EditorID: Gold001).

 

SetCellOwnership

to give the player ownership of a cell. Remember to repeat for basements and other attached cells.

 

SetCellFullName

if you want to change the name of the house. Again, basements etc.

 

Disable

to remove the For Sale sign.

 

End

terminates the OnActivate block.

 

------

 

You'll end up repeating the stuff inside the GameMode block of the first script for each actor, substituting the relevant references for each.

 

I'm pretty sure you'll end up needing to create a separate script for each house's For Sale sign.

 

Note: I *think* this is everything you'll need. Check the provided links for each command for details on what arguments are needed.

Link to comment
Share on other sites

Thanks a ton. Luckily your assumptions were correct and I have used most of the script commands before. For those that I havent I can look up on the TES wiki (Which I just noticed is where your links take me) so I can understand them more fully. Again thanks I really appreciate it. If I run across any problems I'll post them, unless ofcourse I solve them on my own.
Link to comment
Share on other sites

Ok, well this isn't exactly necessary but I'd like to know how to get to NIF files of oblivion objects. I've never tried accessing them before and I found out that they arent on the disc or the file on the computer.

 

Again this isn't necessary and I'll finish the mod with out it but I'd rather have my for sale signs be a blank sheet of paper than a sign that says Anvil.

Link to comment
Share on other sites

Thanks for that information. I've got the mod working... for the most part. I'm testing the scripts on an NPC named Eugal who belongs to the MD faction and will attack during the main quest. Once I get it working for him I'll search for any other NPCs that own homes that will be killed during a quest and set it up for them.
Link to comment
Share on other sites

Ok, I've tried several things and it won't work. After alot of testing I came up with code that should work. I'll post it below.. For some reason, the sign won't appear when Eugal is killed. I have the sign set on Initially Disabled and have its reference ID as EugalSignb.

 

This is the Ability Script which is set as magic and the ability is on the player.

 

scn aabSellHouse

 

float timer

short init

short dead

 

Begin OnLoad

set init to 0

End

 

Begin GameMode

if init == 0

set timer to 10

else

if timer > 0

set timer to timer - getSecondsPassed

else

set dead to eugalbeletteref.getDead

if dead == 1

eugaldoor.lock 100 1

enable EugalSignb

MessageBox "Eugal's house should now be for sale."

Endif

Endif

Endif

End

 

This is the script on the sign.

 

scn aabEugalSign

 

Short Working

Short Choosing

Short Choice

 

Begin onActivate

Set Choosing to -1

Set Working to 1

end

 

Begin GameMode

If Working

If (Choosing == 0)

Set Working to 0

Elseif (Choosing == -1)

Messagebox "Would you like to buy this house for 5000 gold?" "Yes" "No"

Set Choosing to 1

Set Choice to -1

Elseif (Choosing == 1)

If (Choice == -1)

Set Choice to GetButtonPressed

Elseif (Choice == 0)

player.removeItem 0000000F 5000

setCellOwnership ChorrolEugalBelettesHouse

setCellOwnership ChorrolEugalBelettesBasement

setCellFullName ChorrolEugalBelettesHouse "My House"

setCellFullName ChorrolEugalBelettesBasement "My Basement"

disable EugalSignb

eugalDoor.unlock

Set Choosing to 0

Elseif (Choice == 1) ;Second Option

 

Set Choosing to 0

Endif

Endif

Set Working to 1

Endif

End

 

Any help, again, will be appreciated.

Link to comment
Share on other sites

Good Point. Looking back now I feel kinda stupid.. Oh well. ANd thanks for tipping me in on the box thing, I was wondering how people did it. Ill test again with it setting init to 1 after setting the timer and if all goes well you won't hear from me again until it's done. Thanks!
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...