Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-21-2004, 06:37 PM
Kadar Kadar is offline
Registered User
Join Date: Jan 2002
Posts: 636
Kadar is on a distinguished road
Unhappy Need some help..

Im not so good at math so i cant figure this one out, here goes.

I am trying to make a npc that shoots a projectile towards the mousex and mousey, but i cant figure out how to get the angle to work.

Im trying to get the angle of mousex and mousey so the projectile will shoot towards the mouse position, i can figure out how to use power but i cant figure out the angle part, any help would be appreciated..

Thanks
__________________
Reply With Quote
  #2  
Old 02-21-2004, 06:42 PM
Termina_Owner Termina_Owner is offline
Registered User
Join Date: Oct 2003
Posts: 175
Termina_Owner is on a distinguished road
getangle( dx,dy ) - the angle of vector (dx,dy) to the x coordinate (0...2*3.14)

Just subtract the player position with the mouse position.
__________________
- Rance Vicious
Reply With Quote
  #3  
Old 02-21-2004, 08:29 PM
Duwul Duwul is offline
Registered User
Join Date: Nov 2003
Posts: 105
Duwul is on a distinguished road
I wish I could find the power..
I've tried all different equations and none of them work.
__________________
-Ajira
Liek, omigosh.
<3 DoomsDay.
Reply With Quote
  #4  
Old 02-21-2004, 08:33 PM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
...
dx=mousex-playerx;
dy=mousey-playery;
angle=getangle(dx,dy);
btw u might want to change dx and dy so its from the center of the mouse and player but that's the concept =)
__________________
Reply With Quote
  #5  
Old 02-21-2004, 10:16 PM
WanDaMan WanDaMan is offline
Master Tux
WanDaMan's Avatar
Join Date: Aug 2002
Location: England, United Kingdom
Posts: 5,571
WanDaMan is a jewel in the roughWanDaMan is a jewel in the rough
Send a message via MSN to WanDaMan
Quote:
Originally posted by ZeLpH_MyStiK
...
dx=mousex-playerx;
dy=mousey-playery;
angle=getangle(dx,dy);
btw u might want to change dx and dy so its from the center of the mouse and player but that's the concept =)
What I was going to say, what you did on Zion :]
__________________
V$:CONFL16T
Reply With Quote
  #6  
Old 02-21-2004, 10:21 PM
R0bin R0bin is offline
Banned
R0bin's Avatar
Join Date: Oct 2002
Location: Wales, UK
Posts: 828
R0bin is on a distinguished road
Send a message via AIM to R0bin
and you could use the basic distance calculation to make the projectile land where you click

(((playerx-mousex)^2)+((playery-mousey)^2))^0.5

I think.
Reply With Quote
  #7  
Old 02-21-2004, 11:21 PM
Duwul Duwul is offline
Registered User
Join Date: Nov 2003
Posts: 105
Duwul is on a distinguished road
I'll try that and see if it works.
__________________
-Ajira
Liek, omigosh.
<3 DoomsDay.
Reply With Quote
  #8  
Old 02-21-2004, 11:31 PM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
NPC Code:

if(created || timeout){
distx = playerx - mousex;
disty = playery - mousey;
ang = getangle(distx,disty);
showpoly 200,{playerx+1.5,playery+1.5,mousex,mousey;}
message #v(ang);
timeout = 0.05;
}



I'm phat.
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #9  
Old 02-21-2004, 11:48 PM
WanDaMan WanDaMan is offline
Master Tux
WanDaMan's Avatar
Join Date: Aug 2002
Location: England, United Kingdom
Posts: 5,571
WanDaMan is a jewel in the roughWanDaMan is a jewel in the rough
Send a message via MSN to WanDaMan
Quote:
Originally posted by osrs
NPC Code:

if(created || timeout){
distx = playerx - mousex;
disty = playery - mousey;
ang = getangle(distx,disty);
showpoly 200,{playerx+1.5,playery+1.5,mousex,mousey;}
message #v(ang);
timeout = 0.05;
}



I'm phat.
*Cough-showoff-Cough*
Looks nice
__________________
V$:CONFL16T
Reply With Quote
Reply


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:23 AM.


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