Author Topic: NPC Surrenders  (Read 526 times)

Legacy_archer4217

  • Full Member
  • ***
  • Posts: 206
  • Karma: +0/-0
NPC Surrenders
« on: April 07, 2011, 12:18:18 am »


               Hi all,

I'm looking for a script that makes a hostile npc surrender when he reaches a certain amt. of damage. Once he surrenders, I need the npc to to behave as if he's been captured and follow the PC to the jail. I tried doing it with the script generator, but no luck. Searched these forums too but found nothing.
I found one thing in the Lexicon, but it doesn't have info on checking for the npc's damage.

Any help is much appreciated. thanks '<img'>
               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
NPC Surrenders
« Reply #1 on: April 07, 2011, 01:59:47 pm »


               You might want to set the NPC to immortal so his HP wont be reduced below 1 by a lucky crit or something.
You could achieve this by with the NPC's OnDamaged script with these functions:

GetCurrentHitPoints
GetMaxHitPoints
AdjustReputation *
ClearAllActions **

* You might have to create a faction just for the NPC... I don't know, im not that experienced with faction functions.

** Apply this to both, the NPC and the PC.
               
               

               


                     Modifié par Xardex, 07 avril 2011 - 01:02 .
                     
                  


            

Legacy_archer4217

  • Full Member
  • ***
  • Posts: 206
  • Karma: +0/-0
NPC Surrenders
« Reply #2 on: April 07, 2011, 04:07:49 pm »


               Awesome sweetie, thank you so much '<img'>
               
               

               
            

Legacy_Bubba McThudd

  • Sr. Member
  • ****
  • Posts: 254
  • Karma: +0/-0
NPC Surrenders
« Reply #3 on: April 07, 2011, 09:34:32 pm »


               Here is a surrender script I used in Agrenost.  It causes the NPC to act out the meditate animation after he surrenders, so it looks like he's pleading for his life.  It also creates a blood pool and a bag of incriminating evidence near the NPC.

------------------
void main()
{
   int nHealth = GetCurrentHitPoints();
   if((nHealth<18))
   {
       SurrenderToEnemies();
       ClearAllActions();
       GiveXPToCreature(GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC), 50 * FloatToInt(GetChallengeRating(OBJECT_SELF)));
       ActionSpeakString ("No more, please!");
       ActionPlayAnimation(ANIMATION_LOOPING_MEDITATE, 1.0f, 900.0f);
       object oPC = GetLastDamager();


object oTarget;
object oSpawn;
location lTarget;
oTarget = oPC;

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "lootbag019", lTarget);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "zep_bloodstain5", lTarget);


   SetLocalInt(GetPCSpeaker(), "nZavog", 1);


   }

}