How to keep essential NPC's unconscious?

Post » Mon Aug 01, 2011 7:54 pm

I get tired of my NPC companions waking up after being knocked out and continuing to fight even though they have clearly been bested. What I want to do is make it so they stay knocked out until the Player is no longer in combat, and the player activates them. This will simulate resurrecting a dead companion, or reviving someone who was knocked out etc. I'm actually flexible on the design idea here too... I wouldn't mind it if they just stayed out cold until the player was no longer in combat and then we wake them up.

I created an object and gave it an object script. The idea is to be able to share this with an NPC or CM partner, or any companion really.

My approach was to wait until they are knocked out, modav fatigue 9999 but that only pins them down so they cannot move. Once they wake up from the initial death (where essentials go unconscious) they stand back up but cannot move, but heal themselves. Not the desired effect.

I then tried modav health -9999 but they seem to heal their way out of that one too and wake up shortly. At least companion Vilja did, I could try it on a CM partner but I guess they might do the same.

Here is my script, any ideas are welcome.

scn aaacompanioncontrollerscriptref ownershort CompanionMessage; Begin OnAdd	set owner to getcontainer		if owner !=player && owner.isessential == 0			setessential owner 1		endifendBegin gamemodeIf CompanionMessage == 4 && owner.getknockedstate!=3;negative fatigue knockout	set companionMessage to 0;restarting or resetting everythingendifIf CompanionMessage == 3	addtopic WakeUpTopic	set CompanionMessage to 4endifIf CompanionMessage == 2	owner.modav2 encumbrance 9999	owner.modav2 health -9999	set CompanionMessage to 3endifif CompanionMessage == 1	message "Your companion needs revived."	set CompanionMessage to 2endifif owner.getknockedstate == 1 && CompanionMessage == 0	set CompanionMessage to 1endifEnd

User avatar
BRAD MONTGOMERY
 
Posts: 3354
Joined: Mon Nov 19, 2007 10:43 pm

Post » Mon Aug 01, 2011 8:48 pm

scn CompanionControllerScriptRef rOwnerInt iCompanionMessage;Int iCountBegin OnAdd	Set rOwner to GetContainer;	Set iCount to rOwner.GetItemCount ThisItem	If (rOwner == Player);		Player.RemoveItemNS ThisItem iCount;		Return ; ???	ElseIf rOwner.IsEssential		Set iCount to (iCount -1);		rOwner.RemoveItem ThisItem iCount	Else		SetEssential rOwner 1		Con_SetGameSetting fEssentialDeathTime # ; <------------------ Since you're already using OBSE	EndIfEnd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Begin GameMode	If (iCompanionMessage == 0)		If (rOwner.GetKnockedState == 1)			Set iCompanionMessage to 1		EndIf	ElseIf (iCompanionMessage == 1)		Message "Your companion needs to be revived."		Set iCompanionMessage to 2	ElseIf (iCompanionMessage == 2)		rOwner.ModAV2 Encumbrance 9999		rOwner.ModAV2 Health -9999		Set iCompanionMessage to 3	ElseIf (iCompanionMessage == 3)		AddTopic WakeUpTopic		Set iCompanionMessage to 4	ElseIf (iCompanionMessage == 4)		If (rOwner.GetKnockedState == 3) ; negative fatigue knockout		Else			Set iCompanionMessage to 0 ; restarting or resetting everything		EndIf	EndIfEnd
The commented out stuff is to ensure these tokens don't stockpile in their containers as, I'd imagine, only one is needed per companion and the Player should never have one?
User avatar
daniel royle
 
Posts: 3439
Joined: Thu May 17, 2007 8:44 am

Post » Tue Aug 02, 2011 3:43 am

scn CompanionControllerScriptRef rOwnerInt iCompanionMessage;Int iCountBegin OnAdd	Set rOwner to GetContainer;	Set iCount to rOwner.GetItemCount ThisItem	If (rOwner == Player);		Player.RemoveItemNS ThisItem iCount;		Return ; ???	ElseIf rOwner.IsEssential;		rOwner.RemoveItemNS ThisItem (iCount - 1)	Else		SetEssential rOwner 1		Con_SetGameSetting fEssentialDeathTime # ; <------------------ Since you're already using OBSE	EndIfEnd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Begin GameMode	If (iCompanionMessage == 0)		If (rOwner.GetKnockedState == 1)			Set iCompanionMessage to 1		EndIf	ElseIf (iCompanionMessage == 1)		Message "Your companion needs to be revived."		Set iCompanionMessage to 2	ElseIf (iCompanionMessage == 2)		rOwner.ModAV2 Encumbrance 9999		rOwner.ModAV2 Health -9999		Set iCompanionMessage to 3	ElseIf (iCompanionMessage == 3)		AddTopic WakeUpTopic		Set iCompanionMessage to 4	ElseIf (iCompanionMessage == 4)		If (rOwner.GetKnockedState == 3) ; negative fatigue knockout		Else			Set iCompanionMessage to 0 ; restarting or resetting everything		EndIf	EndIfEnd
The commented out stuff is to ensure these tokens don't stockpile in their containers as, I'd imagine, only one is needed per companion and the Player should never have one?

I don't want to modify ffEssentialDeathTime because then every essential NPC in the game would be knocked out for a very long time. I want to create a item I share with selected NPC's in my party, but people like Martin, etc will not have this item so I wouldn't want to change that setting. If we take that out, I can't see what your doing that would make any difference, the NPC would still wake up on their own through self healing. Is there a command to disable their AI or should I just use modav health every frame to keep them down?
User avatar
Nikki Morse
 
Posts: 3494
Joined: Fri Aug 25, 2006 12:08 pm

Post » Tue Aug 02, 2011 8:40 am

There is http://cs.elderscrolls.com/constwiki/index.php/ToggleActorsAI and http://cs.elderscrolls.com/constwiki/index.php/SetActorsAI, but enemies will still continue targeting the essential actor because technically he/she is still up.
User avatar
Soku Nyorah
 
Posts: 3413
Joined: Tue Oct 17, 2006 1:25 pm

Post » Tue Aug 02, 2011 3:40 am

Seems like using modav health -999 each frame would be the best solution, I'll try that.
User avatar
neil slattery
 
Posts: 3358
Joined: Wed May 16, 2007 4:57 am

Post » Tue Aug 02, 2011 7:39 am

You might also try SetRestrained, it'll let you lock the npc in place (though they'll be "standing" really) if you do that, only other thing I can see is to ToggleActorsAI and modav fatigue -999 repeatedly, they'll be knocked out by means of fatigue and stay that way (they could jiggle a bit).

I'd ToggleActorsAI, at the start, then the tricky part. Add an disease that drains their fatigue (continously). That'll keep them on the ground, you can easily add the disease after or before the ToggleActorsAI, then when they're "revived", remove the disease, ToggleActorsAI again and in a short while they should get back up.
User avatar
TRIsha FEnnesse
 
Posts: 3369
Joined: Sun Feb 04, 2007 5:59 am

Post » Tue Aug 02, 2011 5:59 am

I finally got it working right.

Some issues with the advice.... toggle ai makes it impossible to cast spells on the npc's because it seems to turn off their collision. Also NPC's which have a getknockedstate of 1 will not accept spells, meaning actor.isspelltarget does not return true of any spell you check for, so trying to heal them with my revive spell was not working... so I had to resort to a simple fatigue drain rather than a health and fatigue drain. The only drawback is you can still talk to them and their health recovers... but they are incapacitated so it has the desired effect and is working good so far :)
User avatar
{Richies Mommy}
 
Posts: 3398
Joined: Wed Jun 21, 2006 2:40 pm


Return to IV - Oblivion