Jump to content

How to get NPC rotation?


Zappster

Recommended Posts

This has been partially solved, please scroll down to my next reply for the solution

 

 

So for my script I need to find out which way my NPC is walking. I've checked the API and did some googling to find that: npcs.closest(id).getRotation would work, however it looks like it has been depricated in the API.

 

I can't see anything in the NPCS that would help me find the solution to this.

 

I know I could grab 2 positions of the NPC and work out the direction myself, but my script is heavily reliant on timing and leaves me with not much room to do this calculation.  I could make it work for my script so it's not the end of the world, it's just that I'd like to aviod rewriting functions.

 

So, any clean way to get the rotation of an NPC without having to take 2 positions? Thanks.

Edited by zappa2010
Link to comment
Share on other sites

Hey, I managed to resolve the problem thanks to FrostBug.

 

Dumbass me had the wrong type. Here's my line of code:

Entity npc1 = npcs.closest(id);

The .getRotation belongs to the Character type and needs casting from NPC.

So if you have this problem and need to get the N/E/S/W position of an NPC, you need to change the type to NPC like so:

NPC npc1 = npcs.closest(id);
int rot = npc1.getRotation();

I'm still stuck on what .getRotation returns.

Is this correct?

1-North

2- East

3- South

4- West

 

or is it..

0-North

1-East

2-South

3-West

 

or something I've missed completly?

Link to comment
Share on other sites

Values from .getRotation() when walking into a new tile:
 

North: 1024
Northeast: 1280
East: 1536
Southeast: 1792
South: 0
Southwest: 256
West: 512
Northwest: 768

When interacting with a NPC/Entity, subtract 1 from these values (Ex: North: 1024 if walking; 1023 if interacting).
Edited by Lordsthan
  • 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...