Had a post typed and lost it... here's the less cool version of it:
I have these lines in my OnSpawn Event for NPCs
if( GetLocalInt(OBJECT_SELF,"ODE") == 1 )
{
SetSpawnInCondition(NW_FLAG_DAMAGED_EVENT);
}
if( GetLocalInt(OBJECT_SELF,"ECRE") == 1 )
{
SetSpawnInCondition(NW_FLAG_END_COMBAT_ROUND_EVENT);
}
If I want a NPC to do something when they are damaged or at the end of a combat roud I set ODE|Int|1 or ECRE|Int|1 in their variables.
Then in the OnUserDefined script under the corresponding event section you can do pretty much anything you want. Some of my NPCs say things at the end of rounds to drive the plot or berate and belittle the player, some get a second wind (i.e. buffs before they die), some call for help spawning other NPCs to aid them, one runs to the nearest cocoon and breaks it open releasing a swarm of little spiders. I have a few NPCs who are possessed and when they die their possessor is exposed leading to a new opponent.
I wrote this up (no testing), but it could work to set your NPC immortal if you put the correct TAGs in the script.
//For example: under the ON_COMBAT_ROUND_EVENT of the OnUserDefined script
//If the NPC running this code has the tag unkillable_dude
if( GetTag(OBJECT_SELF) == "unkillable_dude" )
{
//Let's get the int we stored the first end of round to see how many valid
//placeables there were in our area that make us immortal
int x = GetLocalInt(OBJECT_SELF,"placeable_valid");
//If we found at least one placeable making us immortal then go thru the
//stored objects and see if they are still valid. If so, make sure we're still
//immortal.
if( x >= 1 )
{
int i, bValid = FALSE;
for( i=x; i>0; i-- )
{
if( GetIsObjectValid(GetLocalObject(OBJECT_SELF,"UDP_"+IntToString(i))) )
{
//As soon as we find a valid object exit the for-loop and set us as immortal
bValid = TRUE;
break;
}
}
if( bValid && !GetImmortal(OBJECT_SELF) )
{
SetImmortal(OBJECT_SELF,TRUE);
}
//This is to ensure we don't end up an unkillable NPC somehow
if( !bValid ) SetImmortal(OBJECT_SELF,FALSE);
}
//At the end of the first round it's going to loop thru all objects in the area
//and find those with the tag unkillable_dudes_placeable. We'll set each one
//we find on the NPC so next time we can just check if each of those is valid
//without having to search thru every object in the area each time.
else
{
x = 0;
object oArea = GetArea(OBJECT_SELF);
object o = GetFirstObjectInArea(oArea);
while( GetIsObjectValid(o) )
{
if( GetTag(o) == "unkillable_dudes_placeable" )
{
x++;
SetLocalObject(OBJECT_SELF,"UDP_"+IntToString(x),o);
SetLocalInt(OBJECT_SELF,"placeable_valid",x);
}
o = GetNextObjectInArea(oArea);
}
}
}
VFX (beams) could be added.
The placeables themselves could have multifiring traps set on them and explode when destroyed.
You would likely need a script OnAreaEnter that checks if the placeables are there or not and creates them if they aren't.