Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Need some help.. (https://forums.graalonline.com/forums/showthread.php?t=51246)

Kadar 02-21-2004 06:37 PM

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

Termina_Owner 02-21-2004 06:42 PM

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.

Duwul 02-21-2004 08:29 PM

I wish I could find the power..
I've tried all different equations and none of them work.

ZeLpH_MyStiK 02-21-2004 08:33 PM

...
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 =)

WanDaMan 02-21-2004 10:16 PM

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 :]

R0bin 02-21-2004 10:21 PM

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.

Duwul 02-21-2004 11:21 PM

I'll try that and see if it works.

osrs 02-21-2004 11:31 PM

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. :)

WanDaMan 02-21-2004 11:48 PM

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 :)


All times are GMT +2. The time now is 02:01 AM.

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