Jump to content

Home

[K1] PC within a certain range of NPC script.


Stream

Recommended Posts

First I apologise for the dodgy title, I couldn't think of what to call this.

 

What I'm wondering is - Is there anyway of having a conditional in a script that checks to see if the PC is within a certain range of an NPC? I have this script so far which works fine but I'd like it to only work if the PC is within say 5 meters of the NPC;

 

void main() {

object oNPC = GetObjectByTag("kas25_secura");

if ((GetPartyMemberByIndex(1) == OBJECT_INVALID) && (GetPartyMemberByIndex(2) == OBJECT_INVALID) && (GetGlobalBoolean("test_test")==0))
   {
AssignCommand(oNPC, ActionStartConversation(GetFirstPC(), "", 0, 0, 0, "", "", "", "", "", "", 0, 0xFFFFFFFF, 0xFFFFFFFF, 0));
SetGlobalBoolean("test_test",1);
   }
else {

if ((GetGlobalBoolean("test_test")==0))
ExecuteScript("Deadly_Exit_1", OBJECT_SELF, 1002);    
   }
}

I'm not sure if this is possible or not, I hope it is do I'll have to rethink how to implement the script.

 

Kind Regards

--Strean

Link to comment
Share on other sites

Try this:

void main() {

object oNPC = GetObjectByTag("kas25_secura");

if ((GetPartyMemberByIndex(1) == OBJECT_INVALID) && (GetPartyMemberByIndex(2) == OBJECT_INVALID) && (GetGlobalBoolean("test_test")==0)) [color=Yellow]&& (GetDistanceBetween(oNPC, OBJECT_SELF) <= 5.0)[/color]
   {
AssignCommand(oNPC, ActionStartConversation(GetFirstPC(), "", 0, 0, 0, "", "", "", "", "", "", 0, 0xFFFFFFFF, 0xFFFFFFFF, 0));
SetGlobalBoolean("test_test",1);
   }
else {

if ((GetGlobalBoolean("test_test")==0))
ExecuteScript("Deadly_Exit_1", OBJECT_SELF, 1002);    
   }
}

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...