You are here

Battle between NPC and enemy when entering a room

3 posts / 0 new
Last post
andgalf
Battle between NPC and enemy when entering a room

Does anybody know how to do this: When the PC and the companions enter a room I would like that there was a battle going on between some evil creatures and an NPC. You then take your party and help defeat the evil creatures.

I tried with creating the evil creatures hostile in the room and the NPC a commoner, the faction commoner that is, and then I entered the room from outside with the PC and his companions. The thing is that when I entered the NPC was almost dead, or in another case had already killed the evil creatures. I tried making the evil creatures not that difficult to kill but then when I entered the are the NPC had already killed them. And if I made the evil creatures stronger the NPC was almost dead when I entered.

So how would one do this? Is the NPC fighting the creatures even when the PC and his party is not there, or do they start the fighting once you enter?

I tried with an Encounter but then the evil creatures attack the PC and the party and I would like the creatures to fight the NPC at first...

Sorry for my rambling, I hope you understand what I'm trying to do. Is there a script perhaps that does this? I tried with checking the templates but I didn't find anything useful...

  • up
    50%
  • down
    50%
kevL's

you sorta have to follow it through, conceptually, using triggers and events ...

Example. Place (or spawn) the creatures as Commoner faction like the NPC. Place a trigger outside the room and script its OnEnter event to turn the creatures Hostile faction, and give them all a command to attack the NPC.* A better option is perhaps to use the door's OnOpen script, that way you know that PC has direct contact with the situation.

further possibility: Make the creatures stronger than the NPC, and make the NPC either Plot or Immortal, and/or use the latter's OnDamaged script to control the amount of damage he/she takes ...

if (plot) NPC will take no damage
if (immortal) NPC will not die but its hp can go down to 1


note that if you want the NPC to possibly die those flags have to be removed sometime during the fight.

/just ideas, there's probly several ways to do it......


* If using a trigger, a Floating Text could tell the player that there are sounds of battle behind the door.

  • up
    50%
  • down
    50%
andgalf

Thank you for the reply!

I managed to solve the situation to my satisfaction. What I did was make New Generic Trigger upon entering the room and then made the evil creature spawn close to the NPC and made sure the NPC was quite powerful and have enough HP. Since I'm still no good at scripting I used Lilac Souls script generator to make this script:

/*   Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.com/View.php?view=Other.Detail&id=4683&id=625    */

//Put this script OnEnter
void main()
{

object oPC = GetEnteringObject();

if (!GetIsPC(oPC)) return;

object oTarget;
object oSpawn;
location lTarget;
oTarget = GetWaypointByTag("elemental_wp");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "c_elmfirehuge" , lTarget);

}

 

The idea about making the NPC immortal was a really good one. That way you could take a stronger enemy and through at the NPC without having to worry about the NPC dying.

I also like your idea of a floating text above the door. Will try that.

  • up
    50%
  • down
    50%