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
  #16  
Old 08-31-2007, 01:11 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Stefan View Post
The blocking part of "showcharacters" and players is x=0.5, y=1, width=2, height=2, so the center would be x=1.5 and y=2
:O
__________________
Reply With Quote
  #17  
Old 08-31-2007, 02:25 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
If I want the exact center, and seriously, the exact one, I just do the following:

PHP Code:
temp.cx player.1.5 32;
temp.cy player.32
Well, thats the center of the part normally blocking, the 32*32 pixels at the bottom of the body Dusty pointed out. Why 1 / 32? Thats half a pixel ;P Very nice to remember I guess :]
Reply With Quote
  #18  
Old 08-31-2007, 02:34 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Crow View Post
If I want the exact center, and seriously, the exact one, I just do the following:

PHP Code:
temp.cx player.1.5 32;
temp.cy player.32
Well, thats the center of the part normally blocking, the 32*32 pixels at the bottom of the body Dusty pointed out. Why 1 / 32? Thats half a pixel ;P Very nice to remember I guess :]
or
PHP Code:
temp.cx player.23.5/16;
temp.cy player.31.5/16
which is Loriels' method that he used in his Movement system ;o

But his movement system is compatible with gs1 so I've rewritten his movement system to work with gs2, and to use less cpu (gs1 didn't support temp. variables ) and I added running to it ;o
__________________
Reply With Quote
  #19  
Old 08-31-2007, 10:20 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Chompy View Post
PHP Code:
temp.cx player.1.46875;
temp.cy player.1.96875
uhm?
Thats just going from tiles to pixels.
__________________
Reply With Quote
  #20  
Old 08-31-2007, 10:22 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Inverness View Post
Thats just going from tiles to pixels.
PHP Code:
temp.cx player.23.5/16;
temp.cy player.31.5/16
then
__________________
Reply With Quote
  #21  
Old 08-31-2007, 11:41 PM
Polo Polo is offline
Classic Systems Admin
Join Date: Sep 2002
Location: Vancouver, Canada
Posts: 735
Polo is on a distinguished road
Send a message via AIM to Polo
You should not be subtracting 1/32 (half a pixel), as doing so will give you an innacurate result.

If you're wondering why, it's because a pixel has shape to it: it has both a left and right edge. The easiest way to demonstrate this is to draw 2 adjoining squares on a piece of paper with 0 and 2 written on the outside bottom corners, and 1 written on the touching corner. I'm fairly sure that you'll agree the centre is at 1 and not 0.5.

PHP Code:
  ___ ___
 
|   |   |
 |
___|___|
 
0   1   2 
In light of that, the usual coordinates to use for movement are a 2 by 2 square centred exactly on 1.5, 2 (just as Stefan said).
__________________
Be good little players, or Master Storm will ban you!



Proof that the staff are crazy..
*Ghost Pirate: I'm a little teacup short and stubbe here is my raygun here is my butt
DragonX: Jumping jack rabbits Batman! Our eggo waffles have been stolen! To the batmobile Robin!
X-Mann (RC): I have a head ache
Reply With Quote
  #22  
Old 08-31-2007, 11:50 PM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
So what's the best calculation then Storm?

PHP Code:
temp.cx player.1;
temp.cy player.1
When using that the center is too 'high'. I seem to have started something here... o_o
__________________
Stan.
Reply With Quote
  #23  
Old 09-01-2007, 12:00 AM
Polo Polo is offline
Classic Systems Admin
Join Date: Sep 2002
Location: Vancouver, Canada
Posts: 735
Polo is on a distinguished road
Send a message via AIM to Polo
Quote:
Originally Posted by Kyranki View Post
So what's the best calculation then Storm?
For movement systems, I have always used...
NPC Code:
temp.cx = player.x + 1.5;
temp.cy = player.y + 2;


Which give the center of the players base (thats the area which blocks against walls). Add/subtract 1 from those positions to find the respective edges of this region.
__________________
Be good little players, or Master Storm will ban you!



Proof that the staff are crazy..
*Ghost Pirate: I'm a little teacup short and stubbe here is my raygun here is my butt
DragonX: Jumping jack rabbits Batman! Our eggo waffles have been stolen! To the batmobile Robin!
X-Mann (RC): I have a head ache
Reply With Quote
  #24  
Old 09-01-2007, 02:07 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
Quote:
Originally Posted by Polo View Post
For movement systems, I have always used...
NPC Code:
temp.cx = player.x + 1.5;
temp.cy = player.y + 2;


Which give the center of the players base (thats the area which blocks against walls). Add/subtract 1 from those positions to find the respective edges of this region.
I'm just getting the center of the player to calculate hit detection using the center of the attacker and each possible person to hit.
__________________
Stan.
Reply With Quote
  #25  
Old 09-01-2007, 02:52 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by Kyranki View Post
I'm just getting the center of the player to calculate hit detection using the center of the attacker and each possible person to hit.
So what are you looking for? The center of the player's "image"? player.x + 1 and player.y + 1.5 should do it for you.
__________________
Reply With Quote
  #26  
Old 09-01-2007, 03:05 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Googi View Post
So what are you looking for? The center of the player's "image"? player.x + 1 and player.y + 1.5 should do it for you.
Not quite. Player images are 3x3 tiles.
Quote:
Originally Posted by Stefan
The blocking part of "showcharacters" and players is x=0.5, y=1, width=2, height=2, so the center would be x=1.5 and y=2
Do what Stefan said.
__________________
Reply With Quote
  #27  
Old 09-01-2007, 07:05 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by Inverness View Post
Not quite. Player images are 3x3 tiles.
That might be the programmed size, but the image the player sees is not three tiles across.
__________________
Reply With Quote
  #28  
Old 09-01-2007, 12:13 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Googi View Post
That might be the programmed size, but the image the player sees is not three tiles across.
Since he's trying to check if the player is it, and not anything with the image, he should do what Stefan said which gives you the progammed size (the only area where triggers are checked).
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #29  
Old 09-01-2007, 11:02 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Chompy View Post
PHP Code:
temp.cx player.1.46875;
temp.cy player.1.96875
uhm?
This is true but often you are off-setting it the the pixel down right of your "center" so most just settle with 1.5,2. Unless you are doing like a movement system or something that is checking onwall checks or so, 1.5,2 will work much better for you.
__________________
Do it with a DON!
Reply With Quote
  #30  
Old 09-01-2007, 11:23 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Googi View Post
That might be the programmed size, but the image the player sees is not three tiles across.
The image the player sees is centered in the 3x3 box, meaning player.x+1.5 would be the vertical center of that box and the center of the player image. Stefan said center of player image would be player.x+1.5 and player.y+2
__________________
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 09:04 PM.


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