Jump to content

Storing NPC I attack for luring to safespot


Criboo

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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