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-30-2007, 10:29 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
More of a math question...

Okay, say I have a number of directions, in this example, 16.
I have a set dir1, 6.
And I also have dir2, 1.

How would I get the 'distance', or in this case, the number of directions dir1 is from dir2?
I know in the example I posted with it, it's 2 directions away, but what would be the formula to do this? The problem arises since, like in the example, dir1 is 15, and dir2 is 1, so abs(dir2-dir1)=14.
If any of this makes sense, any advice?
Attached Images
 
Reply With Quote
  #2  
Old 04-30-2007, 10:46 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 DustyPorViva View Post
Okay, say I have a number of directions, in this example, 16.
I have a set dir1, 6.
And I also have dir2, 1.

How would I get the 'distance', or in this case, the number of directions dir1 is from dir2?
I know in the example I posted with it, it's 2 directions away, but what would be the formula to do this? The problem arises since, like in the example, dir1 is 15, and dir2 is 1, so abs(dir2-dir1)=14.
If any of this makes sense, any advice?
I would suggest just doing something like:

dist = abs(dir2 - dir1);
if (dist > 8) dist = 16 - dist;
__________________
Do it with a DON!
Reply With Quote
  #3  
Old 04-30-2007, 11:19 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Thanks, that worked great.
Though I ended up doing:
dist=abs(dir2-dir1)>8?16-abs(dir2-dir1):abs(dir2-dir1);
Reply With Quote
  #4  
Old 04-30-2007, 11:22 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 DustyPorViva View Post
Thanks, that worked great.
Though I ended up doing:
dist=abs(dir2-dir1)>8?16-abs(dir2-dir1):abs(dir2-dir1);
Hehe.
I just have an OCD think about repeating the same math formula over and over again :P
__________________
Do it with a DON!
Reply With Quote
  #5  
Old 05-01-2007, 12:03 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Oh I know, I thought the same thing at first... but meh, dunno, keeps it to one line so I like it.
Reply With Quote
  #6  
Old 05-01-2007, 12:05 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by zokemon View Post
Hehe.
I just have an OCD think about repeating the same math formula over and over again :P


Then do something like....


PHP Code:
temp.var = abs(dir2 dir1);
dist = (temp.var > 16 temp.var : temp.var); 
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 11:07 AM.


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