It was not an script problem. I didn’t noticed that the follower’s items were set to “droppable”…
I’ve made a few tweaks to the original:
//::///////////////////////////////////////////////
//:: Henchman Death Script
//::
//:: NW_CH_AC7.nss
//::
//:://////////////////////////////////////////////
#include "nw_i0_generic"
#include "nw_i0_plot"
#include "x3_inc_horse"
#include "x0_i0_henchman"
void raise()
{
// break the loop if became alive outside this script
if(!GetIsDead(OBJECT_SELF))
{
return;
}
// find nearest alive enemy creature
object oEnemy = GetNearestCreature(
CREATURE_TYPE_IS_ALIVE, TRUE, OBJECT_SELF, 1,
CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY
);
// get hench master
object oPC = GetLocalObject (OBJECT_SELF, "NPC master");
// is Enemy Close
int iEnemyClose = FALSE;
if(GetObjectSeen(OBJECT_SELF, oEnemy))
{
iEnemyClose = TRUE;
//FloatingTextStringOnCreature("Seen by an enemy (" + GetName(oEnemy) + ") - staying dead", OBJECT_SELF);
}
// is Master Close
int iMasterClose = FALSE;
if (GetDistanceBetween (OBJECT_SELF, oPC) > 0.0 && GetDistanceBetween (OBJECT_SELF, oPC) < 5.0) {
iMasterClose = TRUE;
}
// is Master Left
int iMasterLeft = FALSE;
if (GetArea(oPC) != GetArea(OBJECT_SELF)) {
iMasterLeft = TRUE;
}
// - If Master Left >> go home
if (iMasterLeft) {
SendMessageToPC (oPC, "You have abandoned a companion.");
//Get Henchman Data
object oHome = GetLocalObject (OBJECT_SELF, "NPC home");
string sHenchmanResRef = GetResRef (OBJECT_SELF);
string sHenchmanTag = GetTag (OBJECT_SELF);
//Clear Item DB
SetCampaignInt ("DB_TDLI_HEN",sHenchmanTag+"_inv_cnt",0);
int iSlot;
string sSlotDB;
for (iSlot = 0; iSlot < 14; iSlot++) {
sSlotDB = sHenchmanTag + "_slot_" + IntToString (iSlot);
SetCampaignString ("DB_TDLI_HEN",sSlotDB, "");
}
//Spawn NPC at Home
object oHenchMan = CreateObject (1,sHenchmanResRef,GetLocation(oHome),FALSE,"");
DestroyObject (OBJECT_SELF, 1.0);
DestroyObject (oHome, 1.0);
} else {
// - If Master in area & Enemy Close >> Wait
if (iEnemyClose) {
DelayCommand(6.0, raise());
} else {
// - If Master in area & Enemy !Close & Master Close >> Raise & Join
if (iMasterClose) {
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(), OBJECT_SELF);
DelayCommand(0.0, AddHenchman(oPC));
} else {
// - If Master in area & Enemy !Close & Master !Close >> Wait
DelayCommand(6.0, raise());
}
}
}
}
void main()
{
// remember current master
object oMaster = GetMaster();
SetLocalObject (OBJECT_SELF, "NPC master", oMaster);
SetLocalString(OBJECT_SELF,"sX3_DEATH_SCRIPT","x2_hen_death");
if (HorseHandleDeath()) return;
DeleteLocalString(OBJECT_SELF,"sX3_DEATH_SCRIPT");
if (GetAssociateType(OBJECT_SELF) == ASSOCIATE_TYPE_HENCHMAN)
{
SetLocalInt(OBJECT_SELF, "X2_L_IJUSTDIED", 10);
SetKilled(GetMaster());
SetDidDie();
object oHench = OBJECT_SELF;
// * Take them out of stealth mode too (Nov 1 - BK)
SetActionMode(oHench, ACTION_MODE_STEALTH, FALSE);
// * Remove invisibility type effects off of henchmen (Nov 7 - BK)
RemoveSpellEffects(SPELL_INVISIBILITY, oHench, oHench);
RemoveSpellEffects(SPELL_IMPROVED_INVISIBILITY, oHench, oHench);
RemoveSpellEffects(SPELL_SANCTUARY, oHench, oHench);
RemoveSpellEffects(SPELL_ETHEREALNESS, oHench, oHench);
}
RemoveHenchman(GetMaster(), OBJECT_SELF);
SetLocalObject (OBJECT_SELF, "NPC master", oMaster);
// begin auto-raise loop with 6-second interval
DelayCommand(6.0, raise());
}