Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Hitting in an area (https://forums.graalonline.com/forums/showthread.php?t=134259421)

Jiroxys7 06-06-2010 03:55 AM

Hitting in an area
 
I'm trying to make a custom bomb script that hits in an area. but i'm not totally sure on what all of the math functions we can use. anyone care to fill me in on some of the ones i should be using? also would i be entering this into a triggeraction, or something else?

cbk1994 06-06-2010 04:38 AM

Are you familiar with the distance formula?

https://www.google.com/chart?cht=tx&...-%20y1)%5E2%7D

If not Google it and familiarize yourself with it, it's quite useful.

You don't really need to understand it in your case though.

PHP Code:

function hit(x, y, radius) {
  for (
temp.pl : findNearestPlayers(x, y)) {
    if (
dist(x, y, pl.x, pl.y) <= radius) {
      
pl.trigger("hit");
    }
  }
}

function 
dist(x1, y1, x2, y2) {
  return (((
x2 - x1) ^ 2) + ((y2 - y1) ^ 2))) ^ 0.5;
} 



All times are GMT +2. The time now is 10:58 PM.

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