Author Topic: How do I get an npc to destroy himself after a conversation?  (Read 1325 times)

Legacy_Baishi7

  • Newbie
  • *
  • Posts: 43
  • Karma: +0/-0


               How do I get an npc to destroy himself after a conversation? here is the script i tried to make. But its not working.

int nInt;
object oTarget;
/*   Script generated by
Lilac Soul's NWN Script Generator, v. 2.3
For download info, please visit:
http://nwvault.ign.c...&id=4683&id=625    */
//Put this on action taken in the conversation editor
#include "nw_i0_tool"
void main()
{
object oPC = GetPCSpeaker();
if (GetIsSkillSuccessful(oPC, SKILL_TAUNT, 4))
   {
   ActionSpeakString("Okay, Okay, don't hurt me. Take it");
   ActionGiveItem(GetItemPossessedBy(OBJECT_SELF, "Jirovens_Coin"), oPC);
   RewardPartyXP(45, oPC, FALSE);
   oTarget = OBJECT_SELF;
//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead
   nInt = GetObjectType(oTarget);
   if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_BLOOD_CRT_RED), oTarget);
   else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_BLOOD_CRT_RED), GetLocation(oTarget));
   DestroyObject(oTarget, 3.0);
   }
else
   {
   ActionSpeakString("HA, HA, ohh, I'm so scared.");
   }
}
               
               

               


                     Modifié par Baishi7, 21 juillet 2010 - 11:02 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How do I get an npc to destroy himself after a conversation?
« Reply #1 on: July 22, 2010, 12:38:59 am »


               change Object oPC = GetPCSpeaker;



To : object oPC = GetLastPCSpeaker;





If you want the script to just work by clicking on the NPC without starting a conversation window.

place the script in the  OnConversation Event on the NPC.

               
               

               
            

Legacy_Genisys

  • Hero Member
  • *****
  • Posts: 961
  • Karma: +0/-0
How do I get an npc to destroy himself after a conversation?
« Reply #2 on: July 22, 2010, 12:48:07 am »


               SetPlotFlag(oTarget, FALSE);
DestroyObject(oTarget, 3.0f); - NOT THIS >>> DestroyObject(oTarget, 3.0);

God is in the Details...

(by "A famous Architech")
               
               

               


                     Modifié par Genisys, 21 juillet 2010 - 11:49 .
                     
                  


            

Legacy_KooKoo88

  • Jr. Member
  • **
  • Posts: 72
  • Karma: +0/-0
How do I get an npc to destroy himself after a conversation?
« Reply #3 on: July 22, 2010, 01:44:30 am »


               Make him super sad.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How do I get an npc to destroy himself after a conversation?
« Reply #4 on: July 22, 2010, 02:12:45 am »


               

Genisys wrote...

SetPlotFlag(oTarget, FALSE);

The DestroyObject function does not care If the object is set to plot or not. The Plot flag only stops things from dieing from combat.  Now if you stated to  SetIsDestroyable (TRUE);  You could be onto something. 

 
DestroyObject(oTarget, 3.0f); - NOT THIS >>> DestroyObject(oTarget, 3.0);


There is no differance between the two statments above.  They do and are compiled to the exact same thing.

God is in the Details...

(by "A famous Architech")


               
               

               
            

Legacy_Genisys

  • Hero Member
  • *****
  • Posts: 961
  • Karma: +0/-0
How do I get an npc to destroy himself after a conversation?
« Reply #5 on: July 22, 2010, 06:46:50 pm »


               I stand corrected, doh!
               
               

               
            

Legacy_Baishi7

  • Newbie
  • *
  • Posts: 43
  • Karma: +0/-0
How do I get an npc to destroy himself after a conversation?
« Reply #6 on: July 23, 2010, 09:01:42 pm »


               

This line object oPC = GetLastPCSpeaker;

causes



ERROR: VARIABLE DEFINED WITHOUT TYPE
               
               

               
            

Legacy_Baishi7

  • Newbie
  • *
  • Posts: 43
  • Karma: +0/-0
How do I get an npc to destroy himself after a conversation?
« Reply #7 on: July 23, 2010, 09:05:42 pm »


               and  ERROR: PARSING VARIABLE LIST
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
How do I get an npc to destroy himself after a conversation?
« Reply #8 on: July 23, 2010, 09:11:44 pm »


               object oPC = GetLastPCSpeaker();
               
               

               
            

Legacy_Baishi7

  • Newbie
  • *
  • Posts: 43
  • Karma: +0/-0
How do I get an npc to destroy himself after a conversation?
« Reply #9 on: July 23, 2010, 09:39:32 pm »


               ok the variable defined error went away but the  ERROR: PARSING VARIABLE LIST is still there
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
How do I get an npc to destroy himself after a conversation?
« Reply #10 on: July 23, 2010, 09:56:33 pm »


               Ooops. I goofed too. Should be: object oPC = GetLastSpeaker();



               
               

               
            

Legacy_Baishi7

  • Newbie
  • *
  • Posts: 43
  • Karma: +0/-0
How do I get an npc to destroy himself after a conversation?
« Reply #11 on: July 23, 2010, 10:53:47 pm »


               DING DING!!  That's it. Thnaks for the help everyone.