Jump to content

Storing NPC I attack for luring to safespot


Recommended Posts

Posted

Hi all

I'm writing a script which requires the player to attack an NPC and lure it to a safespot.  Doing so involves my player leaving the safespot to find the monster, attacking it, running to a certain place then running to the safespot.

There are several of this NPC in my general fight area, and I am trying to ensure that once I attack it it becomes my NPC (rather than just a NPC) which I lure and attack.  This is to avoid attacking an NPC, running to my first spot then attempting to fight another one.

Is there a way I can segregate an NPC which I attack, but am then subsequently not fighting (or necessarily being attacked by as I run away) so that my script keeps focus on that NPC? 

Thanks in advance

Chris

Posted
4 hours ago, Criboo said:

Hi all

I'm writing a script which requires the player to attack an NPC and lure it to a safespot.  Doing so involves my player leaving the safespot to find the monster, attacking it, running to a certain place then running to the safespot.

There are several of this NPC in my general fight area, and I am trying to ensure that once I attack it it becomes my NPC (rather than just a NPC) which I lure and attack.  This is to avoid attacking an NPC, running to my first spot then attempting to fight another one.

Is there a way I can segregate an NPC which I attack, but am then subsequently not fighting (or necessarily being attacked by as I run away) so that my script keeps focus on that NPC? 

Thanks in advance

Chris


Just store the NPC as a global variable so you can access it later.

  • Like 1
Posted (edited)
18 hours ago, billyboy420 said:

When you select your npc just save it in a variable like Explv said then interact with it after you move to the safe spot

 


NPC npcToSafeSpot = getNpcs().closest("NPC NAME");
getWalking().webWalk(SafeSpot);
npcToSafeSpot.interact("Attack");

It would need to be a global variable.

So something like this:

private NPC npc;

npc = getNpcs().closest("NPC");

if (safespot does not contain our player) {
	if (getWalking().webWalk(safespot)
	// sleep until whatever
} else {
	if (npc != null) {
		// attack npc
	}
}

 

Edited by HeyImJamie
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...