Jump to content

Home

Making NPC start conversation **Spoilers**


Patriarch

Recommended Posts

Hey

my question is how to make a npc start a conversation after all enemies are dead in the area, I tried doing so with a heartbeat script in my npc.utc that looks like this:

 

#include "k_inc_debug"
#include "k_inc_utility"


void main()
{


location location1 = GetLocation(OBJECT_SELF);
object oShapeObject = GetFirstObjectInShape(2, 20.0, location1, 0, 1, [0.0,0.0,0.0]);
if (GetIsObjectValid(oShapeObject) && (FindSubString(GetTag(oShapeObject), "mercenary") == TRUE)) {
ExecuteScript("k_def_heartbt01", OBJECT_SELF);
   }


else  (GetIsObjectValid(oShapeObject) && (FindSubString(GetTag(oShapeObject), "mercenary") == FALSE) {
ExecuteScript("pa_conv_start", OBJECT_SELF);
}
}

 

No matter what it starts the conversation...I suspect the the TRUE and False is what is causing the problem...

 

I want the conversation to happen after i azkull spawns outside the crystal cave.

 

Any suggestions?

Link to comment
Share on other sites

I use this as the OnDeath script (fires when last creature with a certain tag is dead):

 

#include "k_inc_switch"


void main()
{
   string sTag = GetTag(OBJECT_SELF);
   int nCount = 0;
   int i = 0;

   object oNpc1 = GetObjectByTag(sTag, i);
   object oJed1 = GetObjectByTag("npc_to_talk_tag");
   object oPC=GetFirstPC();

   while (GetIsObjectValid(oNpc1)) {
       if ((oNpc1 != OBJECT_SELF) && !GetIsDead(oNpc1)) {
           nCount++;
           break;
       }

       oNpc1 = GetObjectByTag(sTag, ++i);
   }

   if (nCount == 0)  {
   AssignCommand(oJed1, ActionStartConversation ( oPC, "my_dlg", FALSE, CONVERSATION_TYPE_CINEMATIC, TRUE ));


}

Link to comment
Share on other sites

Hey Darth333

 

I been trying all day to do this, with no success... but your solution works....SIMPLY WORKS.....Though i did have to add execute "your script to in the default k_merc_ondeath_event" as it seems to trigger something else.... But thanks....scripting is always oh so obvious when you know the solution......

Link to comment
Share on other sites

Hey

my question is how to make a npc start a conversation after all enemies are dead in the area, I tried doing so with a heartbeat script in my npc.utc that looks like this:

(code snipped)

No matter what it starts the conversation...I suspect the the TRUE and False is what is causing the problem...

 

I want the conversation to happen after i azkull spawns outside the crystal cave.

 

A few problems with the script I noticed at a quick glance:

  • You are missing an if between else and the following conditionals.
     
     
  • You are missing a closing paranthesis after the else conditionals.
     
     
  • FindSubString() does not return TRUE or FALSE, but the position within the target string where the substring was located (character count). Thus, FindSubString(GetTag(oShapeObject), "mercenary") == FALSE translates to FindSubString(GetTag(oShapeObject), "mercenary") == 0, which would evaluate to TRUE for all creatures whose Tag starts (character position 0) with mercenary.
     
     
  • You are not using a loop to check through all creatures in the area. You always check only the first creature in the area with GetFirstObjectInShape(), which isn't necessarily one of your enemies (it could be the main character or a party member for example). You'd need to use a loop where you call GetNextObjectInShape() as well for each iteration until you've looped through all creatures (or found the one you are looking for).

 

Further, while not an error, if you want to check for enemies in the whole area (like your post suggests) and not just those within 20 meters of the one running the script, it's probably better to use Get[First|Next]ObjectInArea() rather than Get[First|Next]ObjectInShape(). Also, you don't need to specify the default parameters to GetFirstObjectInShape() if you don't change their value.

Link to comment
Share on other sites

Thanks Stoffe

 

I'm a novice at scripting, my background is not programming in c, but I'm willing to learn...I got my inspiration from the c_laigreik_check in 610DAN and what you say is true...the loop is needed...

 

btw er du fra sverige?

 

Thanks for the input, i got what i wanted...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...