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 04-11-2010, 10:23 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Box Checks

Is there any way to check if a number that is between a set of two numbers is inside of a point between two numbers? Mostly for checking if any point of a player's body is inside of an area, similar to findareanpcs().
I think my picture will explain it better than i could in words.
Note that there's no definite location of where the number(s) could be (as it could be hit in various spaces), so I can't check for only one point/general location.
Attached Thumbnails
Click image for larger version

Name:	asdfghjkl.png
Views:	331
Size:	3.5 KB
ID:	50879  
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.

Last edited by Switch; 04-11-2010 at 10:34 AM..
Reply With Quote
  #2  
Old 04-11-2010, 10:38 AM
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
Just use a point to tell if it's inside. Alternatively, use radiuses.
Attached Images
 
__________________
Reply With Quote
  #3  
Old 04-11-2010, 10:51 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by Switch View Post
Note that there's no definite location of where the number(s) could be (as it could be hit in various spaces), so I can't check for only one point/general location.
Quote:
Originally Posted by cbk1994 View Post
Just use a point to tell if it's inside. Alternatively, use radiuses.
And I can't use radii because that can cut off corners.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #4  
Old 04-11-2010, 10:58 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
You want to do this..?

PHP Code:
if (player.x in |this.6this.6| && player.y in |this.6this.6|) {
  
// In Box

Use that and you could..

1. Check the center
2. Check the corners
__________________
Quote:
Reply With Quote
  #5  
Old 04-11-2010, 11:09 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by fowlplay4 View Post
You want to do this..?

PHP Code:
if (player.x in |this.6this.6| && player.y in |this.6this.6|) {
  
// In Box

Use that and you could..

1. Check the center
2. Check the corners
Can't really because it's a largish area.

More along the lines of this (though not possible)
PHP Code:
if (|player.xplayer.x+3in |this.xthis.x+this.movementx| && |player.yplayer.y+3in |this.ythis.y+this.movementy|) {
  
//overlapping points

__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #6  
Old 04-11-2010, 11:18 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Then use a for loop?

PHP Code:
for (temp.player.xtemp.< (player.3); temp.i++) {
  for (
temp.player.ytemp.< (player.3); temp.j++) {
    if (
temp.i in |this.6this.6| && temp.j in |this.6this.6|) { 
      
// In Box 
    

  }

__________________
Quote:
Reply With Quote
  #7  
Old 04-11-2010, 11:26 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by fowlplay4 View Post
Then use a for loop?

PHP Code:
for (temp.player.xtemp.< (player.3); temp.i++) {
  for (
temp.player.ytemp.< (player.3); temp.j++) {
    if (
temp.i in |this.6this.6| && temp.j in |this.6this.6|) { 
      
// In Box 
    

  }

I was seeing if there was a way to do it without loops.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #8  
Old 04-11-2010, 11:35 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Check out the separating axis theorem.
Reply With Quote
  #9  
Old 04-12-2010, 10:44 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by WhiteDragon View Post
Check out the separating axis theorem.
Although not as simple as this, it gave me a good idea on how to go about this, and works perfect! Thanks for the springboard.
Checked if either of the image's edges are inside another one, so there are 4 checks each for horizontal and vertical.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #10  
Old 05-16-2010, 11:13 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Forgot to post this, but if anyone is wondering what I've done for this, I've posted it below.

PHP Code:
function checkCollision(firstxfirstyfirstwfirsthsecondxsecondysecondwsecondh) {
  if ((
firstx <= secondx && firstx+firstw >= secondx+secondw) || (firstx >= secondx && firstx+firstw <= secondx+secondw) || (firstx <= secondx && firstx+firstw >= secondx) || (firstx <= secondx+secondw && firstx+firstw >= secondx+secondw)) {
    if ((
firsty <= secondy && firsty+firsth >= secondy+secondh) || (firsty >= secondy && firsty+firsth <= secondy+secondh) || (firsty <= secondy && firsty+firsth >= secondy) || (firsty <= secondy+secondh && firsty+firsth >= secondy+secondh)) {
      return 
true;
    }
  }

__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
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 10:15 PM.


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