Resurrection Script for Followers

Post » Sat Oct 26, 2013 10:40 am

Hi Everyone,

After some work here is a Script I wrote for Resurrecting your Follower.

You need to create an Amulet with "Amulet_Of_Resurrection" ID.

After your Follower has fallen, open up his inventory and drop the Amulet of Resurrection on him.

The Follower will be Resurrected and the Amulet will be brought back to you.

You do need to get the Equipment you want him to maintain from him before you drop the amulet on him, and once back to health give it back to him.

Add this following script to your follower:

begin followerrespawn
if ( GetHealth == 0 )
if ( GetItemCount, "Amulet_Of_Resurrection" > 0 )
Resurrect
AIFollow player, 0,0,0,0
PlaySound, "Restoration Hit"
Removeitem "Amulet_Of_Resurrection", 1
Player->additem "Amulet_Of_Resurrection", 1
MenuTest
endif
endif
end followerrespawn
User avatar
Project
 
Posts: 3490
Joined: Fri May 04, 2007 7:58 am

Post » Sat Oct 26, 2013 12:00 pm

Should've called the amulet a Phoenix Down. ;)

Thanks for the nifty script. In many circumstances, I think the resurrect function isn't too good to use. But it may not be an issue here so long as there are no dialogue or journal entries linked to their death.

User avatar
Siobhan Thompson
 
Posts: 3443
Joined: Sun Nov 12, 2006 10:40 am

Post » Sat Oct 26, 2013 2:39 pm

Nifty little script indeed. You did mention one issue that I never considered when I was doing my NPC Flee script....the fact that the NPC could lose items you had given it later (things you had given it in game)...hmmm...maybe I will have to revisit that.

User avatar
x a million...
 
Posts: 3464
Joined: Tue Jun 13, 2006 2:59 pm

Post » Sat Oct 26, 2013 12:16 pm

Thanks guys, I'm happy you like it... :twirl:

And yes, this is for Followers you added in your realm as long term companions who simply fight by your side with no link to anything else.

User avatar
ANaIs GRelot
 
Posts: 3401
Joined: Tue Dec 12, 2006 6:19 pm

Post » Sat Oct 26, 2013 11:14 pm

I see a problem with using ( GetItemCount, "Amulet_Of_Resurrection" > 0 ) in the same block as the resurrect function, again because the NPC loses all items in their inventory -- the amulet will disappear and the script may fail to execute all the way if you're unlucky enough to have a frame change during the process. Though it may work fine in your tests, it's likely to randomly fail as written.

The way to stabilize this is to use ( GetItemCount, "Amulet_Of_Resurrection" > 0 ) to set a short variable and have another if-block checking for that variable set to one to continue the process. Removing the amulet from the NPC's inventory should be unnecessary because the resurrection will do that for you. Once your script is done all it needs to do, set the variable back to 0 to ready it for the next time.

User avatar
Austin England
 
Posts: 3528
Joined: Thu Oct 11, 2007 7:16 pm

Post » Sat Oct 26, 2013 7:34 pm

Thanks for the help Stuporstar, I'll work on integrating that in the Code :icecream:

In the mean time, I also added the following code to the script to enable companion sharing

Short Companion

Set Companion to 1

User avatar
Nikki Hype
 
Posts: 3429
Joined: Mon Jan 01, 2007 12:38 pm

Post » Sat Oct 26, 2013 7:19 pm


Considering that the resurrect cannot happen until the NPC has the amulet, the resurrect getting rid of the amulet would actually cause an encumbrance bug I believe, where the NPC is having something removed it no longer has. So the line "Removeitem "Amulet_Of_Resurrection", 1" could be removed from the script and the script should function just fine. *scratches head* I do wonder what could interrupt a frame like you are mentioning though.

I do agree that this will work as well.
Something I have seen done in other companion scripts, it might be a good idea to disable and enable the NPC right after the resurrect to make sure it is 'cleared'. Need more data on this though to be sure.
User avatar
Sabrina Schwarz
 
Posts: 3538
Joined: Fri Jul 14, 2006 10:02 am

Post » Sat Oct 26, 2013 10:56 pm

It's not so much a matter of interrupting the frame, it's load order and if it can complete execution within the frame due to CPU timing. I have encountered a lot of bugs that all boil down to a script not completing within one frame due to CPU timing, and the more Cydriic adds to his companion scripts, the more this will become an issue. Call it voodoo-proofing, but it's always better safe than sorry. Adding a short state variable will make it more stable.

Absolutely correct on the encumberance bug. Since the resurrection cleans out the NPC's inventory, that script will remove the weight of the amulet even though there's no amulet to remove.

There's two ways to make sure a companion is debugged: one is starting and stopping combat, the other is disable/enabling them. This is usually only done in things like warp scripts though. It's not necessary for this. I have a self-resurrecting daedric companion and I've found her AI doesn't need debugging after a resurrection.

User avatar
Quick draw II
 
Posts: 3301
Joined: Thu Nov 08, 2007 4:11 pm


Return to III - Morrowind