Jump to content

npc respawn problem


Warsaw2135

Recommended Posts

hello

 

i added two npcs in one of my houses, IC Shack. i made them wander outside during the day and sleep in the house at night and set both of them to respawn but they are not respawning when they are killed. what am i missing? :mellow:

Link to comment
Share on other sites

Are you waiting three days for the cell to respawn (and are you waiting in a cell well away from the IC)?

 

hello striker, thanks for the reply.

 

yup, i waited in skingrad for about a week.

 

Edit: it looks like the dog they were with respawned but not them.

Edited by Warsaw2135
Link to comment
Share on other sites

Make them essential, that way they won't ever die. Or add a script to a custom door or activator as follows:

 

scn (your tag here)RespawnScript

begin onLoad

if ( Gamehour >= 18 ) || ( Gamehour < 6 )  ;if it is night time
if getdead (person1IDhere) 1
	(person1IDhere).moveto (cellIDhere).
	(person1IDhere).setpos x ;(copy x co-ordinate for the bed here)
	(person1IDhere).setpos y ;(copy y co-ordinate for the bed here)
	(person1IDhere).setpos z ;(copy z co-ordinate for the bed here)
	(person1IDhere).resurrect
	(person1IDhere).enable
	(person1IDhere).evaluatepackage
else
	(person1IDhere).disable
	(person1IDhere).moveto (cellIDhere).
	(person1IDhere).setpos x ;(copy x co-ordinate for the bed here)
	(person1IDhere).setpos y ;(copy y co-ordinate for the bed here)
	(person1IDhere).setpos z ;(copy z co-ordinate for the bed here)
	(person1IDhere).enable
	(person1IDhere).evaluatepackage
endif

if getdead (person2IDhere) 1
	(person2IDhere).moveto (cellIDhere).
	(person2IDhere).setpos x ;(copy x co-ordinate for the bed or xmarker here)
	(person2IDhere).setpos y ;(copy y co-ordinate for the bed or xmarker here)
	(person2IDhere).setpos z ;(copy z co-ordinate for the bed or xmarker here)
	(person2IDhere).resurrect
	(person2IDhere).enable
	(person1IDhere).evaluatepackage
else
	(person2IDhere).disable
	(person2IDhere).moveto (cellIDhere).
	(person2IDhere).setpos x ;(copy x co-ordinate for the bed or xmarker here)
	(person2IDhere).setpos y ;(copy y co-ordinate for the bed or xmarker here)
	(person2IDhere).setpos z ;(copy z co-ordinate for the bed or xmarker here)
	(person2IDhere).enable
	(person1IDhere).evaluatepackage
endif
endif

end

 

This code could get a little odd if the npc is very far away. It would not make sense if you were running faster than the npc and hit the door first. You could curtail this problem by adding a package to the npc which tells it to stick close to the house for the hours of 7 and 17. Just make it a proximity from your door.

 

You can make the script run whenever you want, just change the gamehour part accordingly. You should have no problems with this script other than it will force the actors into the cell every time the player enters it at night. If they are forced by this script inside, then position outside, it could get a little buggy. Fine tune it to your preference and it should be okey dokey.

Edited by theuseless
Link to comment
Share on other sites

-edit-

dont' use the script above. Use the one below please

-edit-

 

 

Add this script to the interior door. You will want to double click on the door. Then click where it says "edit base" to make it unique to your mod. I will use the common door "AnvilDoorMCAnim01" but you can use whatever door you like. So once you have clicked "edit base" it will have a name highlighted in blue. This should be called "ID" in the text before the field. Click anywhere before the name of the door to add your own prefix. I use tUL665 as my prefix. It stands for theUseLess almost evil. So my door would be named "tUL665AnvilDoorMCAnim01" in the mod. Make sure this is the interior door. If you plan on making more mods in the future, you can replace the 01 or add the mod name into the ID somewhere. When you click on "OK" it should ask you if you wish to make a new form. Click "Yes" to make your new door unique. What we did was make a door that will exclusively have the script attatched to it. You don't want the script to run every time that you see an AnvilDoorMCAnim01 door in the game. Now you want to make a script for the door. You simply need to copy the script above and replace the needed fields. Get Notepad++ as it is going to make the work much easier. Get Oblivion Syntax Highlighter for Notepad++ and install it. It really is easy. You don't need it for this but it will save you time in the future.

 

Ok, now you can modify the script. Find your NPC's. Make sure they are new, unique editor ID's. If they aren't, you will need to remake them. Double click on the first character (don't click Edit Base). You should see the top field is called Editor ID. This is where you place the name of your character. This will be the name the scripts call it by, not the name you see in game. Make it have a unique name (like JoeMontanaRef, tUL665ClarkKent) or whatever. Now repeat this process for the second character (I'll call here tUL665LoisLane).

 

When you are making this script, you can edit it in Notepad, the CS editor or MSworks, whatever you like. You will now want to change EVERY instance of (person1IDhere) with tUL665ClarkKent (or whatever you used as the name). Change every instance of (person2IDhere) to tUL665LoisLane (whatever the second name was). I see that I messed up the script above and forgot to change two instances of (person1IDhere) to (person2IDhere). I have the proper script below. We are also going to use the door as the marker to "teleport" the npc's to. It will make it much easier for you. Again, use the script below, not the one above. Change out all instances of (person1IDhere), (person2IDhere) and (doorIDhere) to whatever you have named them. Then go back to the CS, click the pencil. You will now want to click File -> New to make a new script. Copy/Paste your code to this place. Click on save and you have a script.

 

Now double click on the door you named and make it a "Persistent Reference" by checking the box. Click on Edit Base. It should say Script then the field will say None. Change this to your new script name. You can type in the field and it will auto complete for you. Save all the way through and playtest it. It should be fine now.

 

Congrats, you just made a simple teleport script and attatched it to a door. Post back here if you have any trouble.

 

-theuseless

Edited by theuseless
Link to comment
Share on other sites

Ok, I made it so that you only need to replace 4 things in this script to make it work. Replace or modify the script name (scn). Replace the (doorIDhere) with your door's Editor ID. Again, this is the name of the door's Editor ID in the first double click screen, NOT after clicking edit base. Now replace the (person1IDhere) with your first NPC's EditorID name (my example was tUL665ClarkKent). Replace the second with your second Npc's EditorID name (my example was tUL665LoisLane). You are now able to save this as a script. It ran fine on my computer. I set up a couple of temp NPC's and tried it. You will have to tune your AI to make it work well. You might also tune the numbers in the block beginning with

if ( Gamehour >= 18 ) || ( Gamehour < 6 ). Those numbers can be set to match when your characters are supposed to be insid sleeping, cooking or whatever you have them do :dance:

 

The ";" is a special function which says to the game engine "skip anything after this symbol." I personally remove them now, but you don't have to. You will have to remove at least the first one (;<-------Change this). Remember too not to leave the (parenthesis) around your editor ID's. You will want to leave the ones around (Door.getpos z), as these tell the game to do math. Now you don't have to.

 

scn (your tag here)RespawnScript  ;<-------Change this.
;Take out all the (parenthesis) when you replace the names.  Remove all code after
;<----- one of these.  It will clean it up and make it run more smoothly.

ref Door
ref NPC1
ref NPC2

float DPosX
float DPosY
float DPosZ

begin onLoad

set Door to (doorIDhere)     ;<--------------Put your unique door ID here
set DPosX to (Door.getpos x)
set DPosY to (Door.getpos y)
set DPosZ to (Door.getpos z)
set NPC1 to (person1IDhere)  ;<--------------Put NPC ID 1 here
set NPC2 to (person2IDhere)  ;<--------------Put NPC ID 2 here

if ( Gamehour >= 18 ) || ( Gamehour < 6 )
       if getdead NPC1 1
               NPC1.moveto Door
               NPC1.setpos x DPosX
               NPC1.setpos y DPosY
               NPC1.setpos z DPosZ
               NPC1.resurrect
               NPC1.enable
               NPC1.evaluatepackage
       else
               NPC1.disable
               NPC1.moveto Door
               NPC1.setpos x DPosX
               NPC1.setpos y DPosY
               NPC1.setpos z DPosZ
               NPC1.enable
               NPC1.evaluatepackage
       endif

       if getdead NPC2 1
               NPC2.moveto Door
               NPC2.setpos x DPosX
               NPC2.setpos y DPosY
               NPC2.setpos z DPosZ
               NPC2.resurrect
               NPC2.enable
               NPC2.evaluatepackage
       else
               NPC2.disable
               NPC2.moveto Door
               NPC2.setpos x DPosX
               NPC2.setpos y DPosY
               NPC2.setpos z DPosZ
               NPC2.enable
               NPC2.evaluatepackage
       endif
endif

end

 

-edit-

 

Note that you only have to change 4 things. There are some good tutorials on the wiki if you can't get the script onto the door, but I tried to outline only what you will need to do in my post above. Post back here if you have further troubles with this code.

 

An example of how the changes would look for my mod:

scn tUL665RespawnScript

ref Door
ref NPC1
ref NPC2

float DPosX
float DPosY
float DPosZ

begin onLoad

set Door to tUL665AnvilDoorMCAnim01
set DPosX to (Door.getpos x)
set DPosY to (Door.getpos y)
set DPosZ to (Door.getpos z)
set NPC1 to tUL665ClarkKent
set NPC2 to tUL665LoisLane

 

The rest of the code is left untouched in the new one. This should be easy for you to do. Again, come up with a prefix (a suffix won't let you easily search for your changes). Please don't just copy mine. You could go even further and make an Xmarker and place it in front of the door, where the spawn point is (yellow box with pink pyramid). You would only need to name the Xmarker and replace the (doorIDhere) with the name of the Xmarker. Keep both persistent if you do this.

 

theuseless

Edited by theuseless
Link to comment
Share on other sites

Thanks for the code. ill try it out now. :biggrin:

 

Edit: Thanks! it works. :) still a bit buggy and have to adjust the gamehour a bit.

 

btw i just found the reason why they are not respawning normally. it turns out when i edit the npc in the cs, the change is not reflected in game for some reason. i tried setting them to essential but when i run the game, they are not flagged as essential and can still be killed. :confused:

Edited by Warsaw2135
Link to comment
Share on other sites

  • Recently Browsing   0 members

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