Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-09-2010, 06:01 PM
Engine Engine is offline
Registered User
Join Date: Jan 2010
Posts: 70
Engine is on a distinguished road
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?
Reply With Quote
  #2  
Old 02-09-2010, 06:06 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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).
Reply With Quote
  #3  
Old 02-09-2010, 06:23 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
If you're familiar with trigonometry, getangle(dx, dy) is just atan2.
__________________
Reply With Quote
  #4  
Old 02-09-2010, 06:47 PM
Engine Engine is offline
Registered User
Join Date: Jan 2010
Posts: 70
Engine is on a distinguished road
After I graduated in '06 everything in my head went into the 'Recycle Bin'. haha
Reply With Quote
  #5  
Old 02-09-2010, 06:49 PM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
Quote:
Originally Posted by Engine View Post
After I graduated in '06 everything in my head went into the 'Recycle Bin'. haha
How dare you copying me.
Reply With Quote
  #6  
Old 02-09-2010, 06:50 PM
Engine Engine is offline
Registered User
Join Date: Jan 2010
Posts: 70
Engine is on a distinguished road
Quote:
Originally Posted by alexandralove View Post
How dare you copying me.
What?
Reply With Quote
  #7  
Old 02-09-2010, 06:57 PM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
My 'recycle bin' is full of things I learnt before graduating too
Reply With Quote
  #8  
Old 02-09-2010, 11:25 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by alexandralove View Post
My 'recycle bin' is full of things I learnt before graduating too
Most peoples are xP
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #9  
Old 02-09-2010, 11:40 PM
tempandrew tempandrew is offline
Registered User
Join Date: May 2005
Posts: 98
tempandrew is on a distinguished road
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.
Reply With Quote
  #10  
Old 02-09-2010, 11:47 PM
Engine Engine is offline
Registered User
Join Date: Jan 2010
Posts: 70
Engine is on a distinguished road
The only thing that my brain registers is video games, beer and food.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:11 AM.


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