Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Getting the angle between a npc to player. (https://forums.graalonline.com/forums/showthread.php?t=134257944)

Engine 02-09-2010 06:01 PM

Getting the angle between a npc to player.
 
I'm not the greatest when it comes to math but I was wondering is there a function to get the angle between a player and an npc through gscript?

DustyPorViva 02-09-2010 06:06 PM

First find the delta like so:

temp.dx = ((player.x+1.5) - (npc.x+1.5));
temp.dy = ((player.y+2) - (npc.y+2));

The offset is 1.5x2, which is the center of the player objects. If the NPC is not a player character and has a different body shape, you'll want to adjust that accordingly.

Then use the getangle() function:
getangle(dx,dy);

By the by, Graal uses radials(0-pi*2) and not degrees(0-360).

cbk1994 02-09-2010 06:23 PM

If you're familiar with trigonometry, getangle(dx, dy) is just atan2.

Engine 02-09-2010 06:47 PM

After I graduated in '06 everything in my head went into the 'Recycle Bin'. haha

Soala 02-09-2010 06:49 PM

Quote:

Originally Posted by Engine (Post 1555105)
After I graduated in '06 everything in my head went into the 'Recycle Bin'. haha

How dare you copying me.

Engine 02-09-2010 06:50 PM

Quote:

Originally Posted by alexandralove (Post 1555107)
How dare you copying me.

What?

Soala 02-09-2010 06:57 PM

My 'recycle bin' is full of things I learnt before graduating too :mad:

coreys 02-09-2010 11:25 PM

Quote:

Originally Posted by alexandralove (Post 1555112)
My 'recycle bin' is full of things I learnt before graduating too :mad:

Most peoples are xP

tempandrew 02-09-2010 11:40 PM

I don't even remember what I learned last grade. I can't imagine how much of a ******* I'll be when I graduate in June.

Engine 02-09-2010 11:47 PM

The only thing that my brain registers is video games, beer and food.


All times are GMT +2. The time now is 07:35 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.