Jump to content

Home

NPC stack problem


GeorgNihilus

Recommended Posts

Hi people, I need help ... again :xp: ... I'm using this long but repetitive script to make a twi'lek walk to 8 consecutives spots at the Unknown world, before standing still. There are no walkpaths in the place it seems.

 

Problem is I want her to stop walking right after I start talking to her. She detects me with an OnNotice script and places perfect in front of the PC, but then she continues walking to the following locations of the walk script and so on until the last point (hPos) while in dialog.

I need to clear those ForceMoveToLocation commands immeditalely started the dialog.

 

This is the walking script for her:

 

//:: k_walkinglin

 

#include "k_inc_debug"

#include "k_inc_utility"

 

void main()

{

 

vector aPos=Vector(12.67,125.92,19.98);

location aWhereToSpawn=Location(aPos,0.0);

 

vector bPos=Vector(21.73,127.42,19.99);

location bWhereToSpawn=Location(bPos,0.0);

 

vector cPos=Vector(39.34,113.02,20.23);

location cWhereToSpawn=Location(cPos,0.0);

 

vector dPos=Vector(29.76,108.19,20.12);

location dWhereToSpawn=Location(dPos,0.0);

 

vector ePos=Vector(57.80,101.38,20.70);

location eWhereToSpawn=Location(ePos,0.0);

 

vector fPos=Vector(61.98,105.75,20.79);

location fWhereToSpawn=Location(fPos,0.0);

 

vector gPos=Vector(27.39,129.43,20.02);

location gWhereToSpawn=Location(gPos,0.0);

 

vector hPos=Vector(66.45,110.17,20.89); // final position for her, closer and facing the Ebon Hawk

location hWhereToSpawn=Location(hPos,0.0);

 

object oNPC = GetObjectByTag("ff_lintarwan");

 

DelayCommand(13.5, AssignCommand (oNPC,ActionForceMoveToLocation(aWhereToSpawn,FALSE))); // (delays ignored??)

ActionDoCommand(SetCommandable(TRUE,oNPC));

DelayCommand(16.5, AssignCommand (oNPC,ActionForceMoveToLocation(bWhereToSpawn,FALSE)));

ActionDoCommand(SetCommandable(TRUE,oNPC));

DelayCommand(19.8, AssignCommand (oNPC,ActionForceMoveToLocation(cWhereToSpawn,FALSE)));

ActionDoCommand(SetCommandable(TRUE,oNPC));

DelayCommand(24.8, AssignCommand (oNPC,ActionForceMoveToLocation(dWhereToSpawn,FALSE)));

ActionDoCommand(SetCommandable(TRUE,oNPC));

DelayCommand(34.8, AssignCommand (oNPC,ActionForceMoveToLocation(eWhereToSpawn,FALSE)));

ActionDoCommand(SetCommandable(TRUE,oNPC));

DelayCommand(39.3, AssignCommand (oNPC,ActionForceMoveToLocation(fWhereToSpawn,FALSE)));

ActionDoCommand(SetCommandable(TRUE,oNPC));

DelayCommand(58.6, AssignCommand (oNPC,ActionForceMoveToLocation(gWhereToSpawn,FALSE)));

ActionDoCommand(SetCommandable(TRUE,oNPC));

DelayCommand(76.9, AssignCommand (oNPC,ActionForceMoveToLocation(hWhereToSpawn,FALSE)));

ActionDoCommand(SetCommandable(TRUE,oNPC));

 

// ActionDoCommand(SetCommandable(FALSE,oNPC));

 

 

And this is the on perception script in my OnNotice field of my .utc:

 

void main() {

 

int bRun;

float fRange;

float fTimeout;

 

// Get object reference to the NPC I just spotted.

object oSeen = GetLastPerceived();

 

// If the character I see is the player character ... (or Juhani, Carth, Mission, Bastila (as Matilda), HK47 or Canderous)

// AND I haven't already done this...

if (GetLastPerceptionSeen() && (oSeen == GetObjectByTag("Carth") || oSeen == GetObjectByTag("Mission") || oSeen == GetFirstPC() || oSeen == GetObjectByTag("Bastila") || oSeen == GetObjectByTag("hk47") || oSeen == GetObjectByTag("juhani") || oSeen == GetObjectByTag("cand")) && !GetLocalBoolean(OBJECT_SELF, 50)) {

 

// Set that I've done this...

SetLocalBoolean(OBJECT_SELF, 50, TRUE);

 

// Stop doing anything I'm currently doing.

ClearAllActions();

 

// Start conversation in ff_lintarwan.dlg with player.

DelayCommand(1.3, ActionStartConversation(oSeen, "ff_lintarwan", FALSE, 0, TRUE));

 

// Move closer to the player so we don't have to shout across the area, running.

ActionForceMoveToObject(oSeen, bRun=TRUE, fRange=2.35f, fTimeout=30.0f);

}

// Not seeing the player, or this has already been done. Do standard AI instead.

else {

ExecuteScript("k_ai_master", OBJECT_SELF, 1002);

}

}

 

So what do you suggest? and by the way, the ClearAllActions() function didn't clear her stack ... it doesn't work on twi'leks right? :(

 

thanks for your time and good modding :)

Link to comment
Share on other sites

I assume the first script is a heartbeat* script? If so, try the GetIsInConversation function (there's also the GetIsConversationActive one which I have never used).

 

 


//:: k_walkinglin

#include "k_inc_debug"
#include "k_inc_utility"

void main()
{

object oNPC = GetObjectByTag("ff_lintarwan");
if(!GetIsInConversation(oNPC))
 {
   vector aPos=Vector(12.67,125.92,19.98);
   location aWhereToSpawn=Location(aPos,0.0);

   vector bPos=Vector(21.73,127.42,19.99);
   location bWhereToSpawn=Location(bPos,0.0);

   vector cPos=Vector(39.34,113.02,20.23);
   location cWhereToSpawn=Location(cPos,0.0);

   vector dPos=Vector(29.76,108.19,20.12);
   location dWhereToSpawn=Location(dPos,0.0);

   vector ePos=Vector(57.80,101.38,20.70);
   location eWhereToSpawn=Location(ePos,0.0);

   vector fPos=Vector(61.98,105.75,20.79);
   location fWhereToSpawn=Location(fPos,0.0);

   vector gPos=Vector(27.39,129.43,20.02);
   location gWhereToSpawn=Location(gPos,0.0);

   vector hPos=Vector(66.45,110.17,20.89);      // final position for her, closer and facing the Ebon Hawk
   location hWhereToSpawn=Location(hPos,0.0);

   DelayCommand(13.5, AssignCommand (oNPC,ActionForceMoveToLocation(aWhereToSpawn,FALSE))); // (delays ignored??)
   ActionDoCommand(SetCommandable(TRUE,oNPC));
   DelayCommand(16.5, AssignCommand (oNPC,ActionForceMoveToLocation(bWhereToSpawn,FALSE)));
   ActionDoCommand(SetCommandable(TRUE,oNPC));
   DelayCommand(19.8, AssignCommand (oNPC,ActionForceMoveToLocation(cWhereToSpawn,FALSE)));
   ActionDoCommand(SetCommandable(TRUE,oNPC));
   DelayCommand(24.8, AssignCommand (oNPC,ActionForceMoveToLocation(dWhereToSpawn,FALSE)));
   ActionDoCommand(SetCommandable(TRUE,oNPC));
   DelayCommand(34.8, AssignCommand (oNPC,ActionForceMoveToLocation(eWhereToSpawn,FALSE)));
   ActionDoCommand(SetCommandable(TRUE,oNPC));
   DelayCommand(39.3, AssignCommand (oNPC,ActionForceMoveToLocation(fWhereToSpawn,FALSE)));
   ActionDoCommand(SetCommandable(TRUE,oNPC));
   DelayCommand(58.6, AssignCommand (oNPC,ActionForceMoveToLocation(gWhereToSpawn,FALSE)));
   ActionDoCommand(SetCommandable(TRUE,oNPC));
   DelayCommand(76.9, AssignCommand (oNPC,ActionForceMoveToLocation(hWhereToSpawn,FALSE)));
   ActionDoCommand(SetCommandable(TRUE,oNPC));

   // ActionDoCommand(SetCommandable(FALSE,oNPC));
}

 

Edit: Doh! forget that...I am so rusty...with all those delay command functions there is no way this would have been a heartbeat script as it runs every 6 seconds :p

Link to comment
Share on other sites

I assume the first script is a heartbeat script?

 

No, it is fired in the previous dialog of my twi'lek dialog. So it is still running when I approach her. Problem is I want her to walk this path only once, not forever if the chat ends :rolleyes: ... that's because later she has to leave the area, fast.

 

The 'GetIsConversation' functions will help me while speaking but not if I want to stop her walking at all. I suppose the heartbeat will do this path forever right?? or wrong? :roleyess:

 

thanks :)

Link to comment
Share on other sites

 

The 'GetIsConversation' functions will help me while speaking but not if I want to stop her walking at all. I suppose the heartbeat will do this path forever right?? or wrong? :roleyess:

Yeah, unless you make a conditional check it will be forever. Heartbeat scripts run every 6 seconds or so. I assumed that you only wanted her to stop during the convo, not forever. Sorry about that. Anyway, it wouldn't work due to your series of delaycommand functions. Also, since your script is run only once, the getisinconversation function is useless here. (I used the ActionRandomWalk() function for that in the past instead...I've always been to lazy to set fixed coordinate points :p ).

 

I can't test anything and I don't know if it will work but maybe try adding those lines to your second script:

SetCommandable(TRUE, oNPC);
AssignCommand(oNPC, ClearAllActions());

 

 

From nwscript.nss:

// 162: Set whether oTarget's action stack can be modified
void SetCommandable(int bCommandable, object oTarget=OBJECT_SELF);

Link to comment
Share on other sites

I used the ActionRandomWalk() function for that in the past instead... I've always been to lazy to set fixed coordinate points :p ).

 

Good idea :D I finally ended with this for the OnSpawn field:

 

//:: k_def_ambient (now lintdialog)

/*

Inteligent Ambient Custom On Spawn In Script

*/

 

#include "k_inc_generic"

#include "k_inc_debug"

 

void main()

{

GN_SetDayNightPresence( AMBIENT_PRESENCE_ALWAYS_PRESENT);

GN_SetListeningPatterns();

GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DIALOGUE_END);

AssignCommand(OBJECT_SELF, ActionRandomWalk());

 

object oNPC=GetObjectByTag("ff_lintarwan");

ActionDoCommand(SetFacingPoint(GetPosition(oNPC)));

}

 

to make her walk randomly before approaching her and it's good enough, a short waypoint walk but it does the job.

 

thanks and good modding :thmbup1:

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...