The included scripts enable henchmen to bleed to -10 when they are 'killed' and also optionally allows looting and carrying of henchman corpses. When they bleed, the henchmen may stabilize and begin to recover, and they can be healed using healing spells (or custom healing kits that cast healing spells - std healing kits don't work because they don't fire a 'OnSpellCastAt' events). If the henchmen reach -10hp, they will die for real, at that point they can either lay there dead waiting for resurrection (default), or can get respawned at a temple. The PC can loot or pick up the dead henchman's corpse. This version should work with patch 1.61 and with HotU/SoU. (although it hasn't been tested without HoTU).
Posted by Hanzo666 at 2011-12-28 13:43:24 Voted 10.00 on 12/28/11
Here is the edited code with name setting on the bleeding and dead corpse of the henchmen (a placeable object).
2 Script need changing:
NW_CH_AC7
hb_unaquireitem
//::///////////////////////////////////////////////
//:: Henchman Death Script
//::
//:: NW_CH_AC7.nss
//::
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
//::
//:://////////////////////////////////////////////
//::
//:: Created By:
//:: Modified by: Brent, April 3 2002
//:: Removed delay in respawning
//:: the henchman - caused bugs
//:: Modified by 69MEH69 21Aug2002 Remove journal entry
//:://////////////////////////////////////////////
//::///////////////////////////////////////////////
//:: Greater Restoration
//:: NW_S0_GrRestore.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Removes all negative effects of a temporary nature
and all permanent effects of a supernatural nature
from the character. Does not remove the effects
relating to Mind-Affecting spells or movement alteration.
Heals target for 5d8 + 1 point per caster level.
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Jan 7, 2002
//:://////////////////////////////////////////////
//:: VFX Pass By: Preston W, On: June 20, 2001
#include "nw_i0_generic"
#include "nw_i0_henchman"
#include "hdeathtokens"
//#include "nw_i0_plot"
int HENCH_BLEED = TRUE; // Set to TRUE to enable henchman bleeding
int HENCH_BLEED_UNDEAD = FALSE; // Set to TRUE to enable bleeding for undead henchmen
int HENCH_STAYDEAD = TRUE; // Set to FALSE to have henchmen respawn at a temple
// when they die (like default OC behavior)
int HENCH_BODY = TRUE; // Set to TRUE to enable Death object upon dying
// Death object allow looting and carrying of the corpse
// * June 1: use RemoveEffects from plot include instead
void RemoveEffects(object oHench)
{
//Declare major variables
object oTarget = oHench;
effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION_GREATER);
void BringBack()
{
SetLocalObject(OBJECT_SELF,"NW_L_FORMERMASTER", GetMaster());
// : REMINDER: The delay is here for a reason
DelayCommand(0.1, RemoveEffects(OBJECT_SELF));
DelayCommand(0.2, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectResurrection(), OBJECT_SELF));
DelayCommand(0.3, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectHeal(GetMaxHitPoints(OBJECT_SELF)), OBJECT_SELF));
DelayCommand(5.1, SetIsDestroyable(TRUE, TRUE, TRUE));
object oWay = GetObjectByTag("NW_DEATH_TEMPLE");
if (GetIsObjectValid(oWay) == TRUE)
{
// * if in Source stone area, respawn at opening to area
if (GetTag(GetArea(OBJECT_SELF)) == "M4Q1D2")
{
DelayCommand(0.2, JumpToObject(GetObjectByTag("M4QD07_ENTER"), FALSE));
}
else
DelayCommand(0.2, JumpToObject(oWay, FALSE));
}
else
DelayCommand(0.3, ActionSpeakString("UT: No place to go"));
}
void JoinHenchman(object oHench, object oPC)
{
AssignCommand(oHench,SetAssociateListenPatterns());
// * Companions, come in, by default with Attack Nearest Enemy && Follow Master modes
SetLocalInt(oHench,"NW_COM_MODE_COMBAT",ASSOCIATE_COMMAND_ATTACKNEAREST);
SetLocalInt(oHench,"NW_COM_MODE_MOVEMENT",ASSOCIATE_COMMAND_FOLLOWMASTER);
object oMaster = oPC;
//SetWorkingForPlayer and SetBeenHired added for ondeath conversation
AssignCommand(oHench,SetWorkingForPlayer(oPC));
SetBeenHired(TRUE,oHench);
//SetLocalObject(oHench, "PCMaster", oSpeaker);
//SetLocalInt(oSpeaker, "nHench", nHench +1);
AddHenchman(oMaster,oHench);
SetAssociateState(NW_ASC_IS_BUSY,FALSE);
}
// Bleeding system for Henchmen (can be adapted to other NPCs as well)
// GetCurrentHitPoints() always returns -11 when the NPC is dead,
// so the hitpoints are tracked in variable "NW_ASC_CUR_HITPOINTS" instead.
// Makes actual hit points consistent with HP tracked in the variable
void AdjustHitPoints(object oTarget, int iCHP)
{
if(GetCurrentHitPoints() < iCHP)
{
effect eHeal = EffectHeal(iCHP - GetCurrentHitPoints());
ApplyEffectToObject(DURATION_TYPE_INSTANT,eHeal,oTarget);
}
}
// HCR Stuff
object oNPC=OBJECT_SELF;
int iCHP=GetLocalInt(OBJECT_SELF,"NW_ASC_CUR_HITPOINTS");
int iLHP=GetLocalInt(OBJECT_SELF,"NW_ASC_LAST_HITPOINTS");;
// if(GetCurrentHitPoints() > iCHP) // Will be true if NPC was healed.
// iCHP = GetCurrentHitPoints();
/* keep executing recursively until character is dead or at +1 hit points */
// SendMessageToPC(GetFirstPC(),GetTag(OBJECT_SELF)+" Bleeding. HP at "+IntToString(iCHP));
// SendMessageToPC(GetFirstPC(),GetTag(OBJECT_SELF)+" Bleeding. Last HP at "+IntToString(iLHP));
// SendMessageToPC(GetFirstPC(),GetTag(OBJECT_SELF)+" Bleeding. Real HP at "+IntToString(GetCurrentHitPoints()));
// SendMessageToPC(GetFirstPC(),GetTag(OBJECT_SELF)+" BleedAmt: "+IntToString(iBleedAmt));
if (GetCurrentHitPoints() 0) /* only check if character has not stablized */
{
if ((d10(1) == 1) || (iCHP >= iLHP))/* 10% chance to stablize */
{
iBleedAmt = -iBleedAmt; /* reverse the bleeding process */
if(GetIsObjectValid(oMaster))
SendMessageToPC(oMaster,GetName(OBJECT_SELF)+"'s wounds have stabilized.");
PlayVoiceChat(VOICE_CHAT_CHEER); /* laugh at death -- this time */
}
else
{
switch (d6())
{
case 1: PlayVoiceChat(VOICE_CHAT_PAIN1); break;
case 2: PlayVoiceChat(VOICE_CHAT_PAIN2); break;
case 3: PlayVoiceChat(VOICE_CHAT_PAIN3); break;
case 4: PlayVoiceChat(VOICE_CHAT_HEALME); break;
case 5: PlayVoiceChat(VOICE_CHAT_NEARDEATH); break;
case 6: PlayVoiceChat(VOICE_CHAT_HELP);
}
}
}
SetLocalInt(OBJECT_SELF,"NW_ASC_CUR_HITPOINTS",iCHP);
SetLocalInt(OBJECT_SELF,"NW_ASC_LAST_HITPOINTS",iCHP);
DelayCommand(6.0,HenchBleed(iBleedAmt)); /* do this again next round */
}
}
void main()
{
// * This is used by the advanced henchmen
// * Let Brent know if it interferes with animal
// * companions et cetera
if (GetIsObjectValid(GetMaster()) && (GetAssociateType(OBJECT_SELF)==ASSOCIATE_TYPE_HENCHMAN))
{
object oMe = OBJECT_SELF; //GetAssociate(ASSOCIATE_TYPE_HENCHMAN, GetMaster());
if (GetIsObjectValid(GetMaster(oMe))
// * this is to prevent 'double hits' from stopping
// * the henchmen from moving to the temple of tyr
// * I.e., henchmen dies 'twice', once after leaving your party
|| GetLocalInt(OBJECT_SELF, "NW_L_HEN_I_DIED") == TRUE)
{
// Mike's code start
int DoBleeding = HENCH_BLEED;
if((GetRacialType(OBJECT_SELF) == RACIAL_TYPE_UNDEAD) && !HENCH_BLEED_UNDEAD)
DoBleeding = FALSE;
if((GetCurrentHitPoints() > -10) && DoBleeding)
{
SendMessageToPC(GetMaster(),GetName(OBJECT_SELF)+" is dying!");
SetLocalInt(OBJECT_SELF,"NPC_BLEEDING",1);
// In case of a "Coup de grace", the henchman can die with positive
// hit points. In that case set his hit points to -1.
if(GetCurrentHitPoints() > 0)
SetLocalInt(OBJECT_SELF,"NW_ASC_CUR_HITPOINTS",-1);
else
SetLocalInt(OBJECT_SELF,"NW_ASC_CUR_HITPOINTS",GetCurrentHitPoints());
int nTokNr = ReserveToken();
string BP = "BO_"+IntToString(nTokNr);
SetCustomToken(nTokNr,GetName(OBJECT_SELF)+"\n");
object oBO = CreateObject(OBJECT_TYPE_PLACEABLE,BP,GetLocation(OBJECT_SELF));
SetName(oBO, "Bleeding " + GetName(OBJECT_SELF));
SetIsDestroyable(FALSE, TRUE, FALSE);
SetLocalObject(oDO,"Corpse",OBJECT_SELF);
}
// Mike's code end
//BringBack(); Commented out by Mike
SetCommandable(FALSE);
}
else
// * I am a familiar, give 1d6 damage to my master
if (GetAssociate(ASSOCIATE_TYPE_FAMILIAR, GetMaster()) == OBJECT_SELF)
{
// April 2002: Made it so that familiar death can never kill the player
// only wound them.
int nDam =d6();
if (nDam >= GetCurrentHitPoints(GetMaster()))
{
nDam = GetCurrentHitPoints(GetMaster()) - 1;
}
effect eDam = EffectDamage(nDam);
FloatingTextStrRefOnCreature(63489, GetMaster(), FALSE);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDam, GetMaster());
}
}
else if(GetAssociateType(OBJECT_SELF)==ASSOCIATE_TYPE_HENCHMAN)
SetIsDestroyable(FALSE,TRUE,TRUE);
}
Posted by Hanzo666 at 2011-12-25 18:40:28 Voted 10.00 on 12/28/11
The system was written a long time ago before the SetName command was added to nwn.
I've easily modified the system to customize the name of the dead corpse to have the name of the dead henchmen.
I'll post all the new code here.
Posted by Hanzo666 at 2011-12-25 13:20:05 Voted 10.00 on 12/28/11
This system is very good. It does what it say its suppose to do.
The instruction are good, I've managed to create custom dead body item for each of my henchmen.
The only problem I have to report is that when a henchmen die, his death corpse does not have his name, instead you read dead
I will take a look into the script and see if I can fix this myself.
Posted by donnykrun ( 24.211.xxx.xxx ) at 2005-11-20 19:14:06
Mishenka,
I was wondering if you could post a script that I could use with a healer so they could rez the henchman instead. I've tried doing this myself I can get the healer to rez the henchman, but the death object is not destroyed and the token isn't released.
Thanks,
Krun
Mishenka,
I tried out your Demo of V4.2 and I'm not sure what is going on with mine. The Priestess is friendly, but all other creatures are hostile. I tried also to build a clean module with no other scripts using the default XP2 henchmen and it doesn't work either. If I try to select the fallen henchman I just get a talk icon and never get the conversation. I really liked using this system with 69HEN69's 1.9b henchman system and would really like to get mine to work with default XP2 hench system. Any ideas would be greatly appreciated.
Thanks,
Krun
The specifics would help, sorry bout that. I am using HoTU1.62 with 69MEH69 kit 1.9b. I am trying to incorporate a bleeding system for PCs and henchmen.
I downloaded your most recent demo from this page and have tested its contents. I think both methods of bleeding are worthwhile, it comes down to a matter of preference.
I don't seem to be getting the vanishing henchman when I use your demo with MEH's scripts.
I pull the lever to apply the critical damage, and the henchman falls. In my module build, if I immediately try to lay on hands, or to heal the fallen companion, the henchman will be healed. BUT, soon after they rejoin, they vanish.
If I allow about 5 seconds to pass before healing the bleeding henchman, they will stand up, rejoin and all is well.
This is happening with the 69_hen_death scripts, not yours. I suppose I will rename the module and try using your files.
I was just wondering if anyone had ever mentioned this problem before. I searched the Bioware.com forums and I didn't see anything mentioned.
Now I want to make sure the PC bleeding system is going to work. I know there is a work around posted at Bioware by a member to allow one's henchmen to use resurrect scrolls on the PC.
I'll post back when I have a chance to test out these scripts.
Are you using only the Henchkit or the Henchkit with my add-on (version 3.0)? If you're not using the add-on, then the bleeding code is a version heavily modified by 69MEH69 and is significantly different than what I have posted here or in version 3.0, so you're better off asking 69MEH69 about them. If you're using my version 3.0 henchman death scripts (which do work with the Henchkit), then I have made some modfications since then. Version 4.0+ works independently of the Henchkit (it's hasn't been tested with it, but it might work with the SoU version of henchkit - no guarantees though) and includes some bug fixes. Although the bug you describe wasn't one of them. If you are in fact using version 3.0 of my scripts, I can take a look and see if I can reproduce the bug. Email me and let me know.
I have the 69MEH69 scripts in my module. Those scripts were last updated on Aug 9, 2003. How many modifications have you made to these scripts since that time?
The reason I ask is because I am having a strange problem with the bleeding. When the henchperson falls, the SendMessageToPC() is fired announcing that the person has fallen, and the 69_hen_death runs through the initial void(). Then it hits the
DelayCommand(6.0, HenchBleed());
If I heal the henchperson before the first 'bleed' SendMessageToPC(), they are announced as having a high int for Hit points and they are healed. They are resurrected for a moment, and then they vanish.
This only occurs if the PC rapidly heals the fallen companion. If I wait 6 seconds, then the henchman heals normally and they do not vanish when resurrected.
Did you ever encounter such a problem?
I am wondering why the object vanishes, presumably it is destroyed or perhaps it jumps to another location/area.
I am going to check out your demo module and will compare the old 69MEH69 scripts myself, but if you have an answer to this issue, that would be great.
Ok, after thinking about it for bit, I realized that there's a potentially serious problem with letting summons leave bodies, since if you keep summoning them and leaving their corpses, you'll eventually run out of death objects (there are only 10 of them).
So I fixed the issue (as described below) and uploaded the new version 4.2. Thanks for catching this issue Fleshmelter.
Yes, I noticed that recently myself. I'm not use if I like it like that or not. It's an easy enough thing to fix, so I'll probably do it in an update sometime soon.
In the meantime you can fix it if you go to script "nw_ch_ac7" and change line 261 from
if (GetIsObjectValid(GetMaster()) == TRUE)
to
if (GetIsObjectValid(GetMaster()) && (GetAssociateType(OBJECT_SELF)==ASSOCIATE_TYPE_HENCHMAN))
New version (v 4.1) has been uploaded that fixes a bug where the bleed/death object tokens were not being released properly. Thanks to Salvatore The Black for identifing the problem.
Danmar,
Thanks a lot for your comments. I added the spellhooks back into the raise and resurrect spells, and the "x0_ch_hen_death" script is now included (I thought it was before as well, not sure what happened) - it's actually identical to my "nw_ch_ac7" script.
I don't think having the raise and res spells work on all placeables is a problem since on normal placeables they won't have any effect, so I left that part alone.
The updated file should appear in a day or two (or whenever the server decides to update it).