Player Location

Everything todo with programming goes HERE.
Post Reply
User avatar
Light
Reverse Outside Corner Grinder
Posts: 1667
Joined: Thu Oct 20, 2011 2:11 pm

Player Location

Post by Light »

Is there a way to get an accurate player location? I know I could divide the grid position by the arena's size, but then it needs to be hardcoded, unless you know of a way to get the REAL_ARENA_SIZE_FACTOR from within a script.
User avatar
AI-team
Shutout Match Winner
Posts: 1020
Joined: Tue Jun 23, 2009 6:17 pm
Location: Germany/Munich
Contact:

Re: Player Location

Post by AI-team »

http://www.crazy-tronners.com/wiki/inde ... ER_GRIDPOS

edit: nevermind, seems like this is ct+sty only
  
 
"95% of people believe in every quote you post on the internet" ~ Abraham Lincoln
 
 
User avatar
Light
Reverse Outside Corner Grinder
Posts: 1667
Joined: Thu Oct 20, 2011 2:11 pm

Re: Player Location

Post by Light »

AI-team wrote:http://www.crazy-tronners.com/wiki/inde ... ER_GRIDPOS

edit: nevermind, seems like this is ct+sty only
That's what I currently use, but it's not actually accurate for anything unless you divide it by the real arena size factor.
Wik
Average Program
Posts: 72
Joined: Tue Aug 10, 2010 1:32 pm

Re: Player Location

Post by Wik »

If you already have size_factor:

real_arena_size_factor = sqrt(2)^size_factor

Are you looking for this?
User avatar
AI-team
Shutout Match Winner
Posts: 1020
Joined: Tue Jun 23, 2009 6:17 pm
Location: Germany/Munich
Contact:

Re: Player Location

Post by AI-team »

Light wrote:That's what I currently use, but it's not actually accurate for anything unless you divide it by the real arena size factor.
Ah seems that I didn't read trough your post carefully enough
  
 
"95% of people believe in every quote you post on the internet" ~ Abraham Lincoln
 
 
XzL.Smart
Round Winner
Posts: 216
Joined: Sun Apr 30, 2006 4:21 am
Location: Arizona

Re: Player Location

Post by XzL.Smart »

You can put a readout in the cockpit file, if you're on 0.3.0+.
http://wiki.armagetronad.org/index.php/Cockpit_Tutorial
current_pos_x | The position of the player in grid units, x- coordinate
current_pos_y | The position of the player in grid units, y- coordinate
Image
User avatar
kyle
Reverse Outside Corner Grinder
Posts: 1876
Joined: Thu Jun 08, 2006 3:33 pm
Location: Indiana, USA, Earth, Milky Way Galaxy, Universe, Multiverse
Contact:

Re: Player Location

Post by kyle »

you want map based location, not the one based on real size factor? That is actually a todo of mine to update PLAYER_GRIDPOS based on map instead of arena, as SPAWN_ZONE now takes in map based points, allows scaling without changing the zones.

I'll try to move that up in my priority queue
Image
User avatar
Light
Reverse Outside Corner Grinder
Posts: 1667
Joined: Thu Oct 20, 2011 2:11 pm

Re: Player Location

Post by Light »

kyle wrote:you want map based location, not the one based on real size factor? That is actually a todo of mine to update PLAYER_GRIDPOS based on map instead of arena, as SPAWN_ZONE now takes in map based points, allows scaling without changing the zones.

I'll try to move that up in my priority queue
Would be cool, but not a huge deal. I was just curious if there was already a better way than hardcoding the arena size value and dividing to get the actual grid position.
User avatar
kyle
Reverse Outside Corner Grinder
Posts: 1876
Joined: Thu Jun 08, 2006 3:33 pm
Location: Indiana, USA, Earth, Milky Way Galaxy, Universe, Multiverse
Contact:

Re: Player Location

Post by kyle »

what you get is the actual grid position, what you want is the grid position relitive to the map.
Image
User avatar
LOVER$BOY
Match Winner
Posts: 731
Joined: Thu Jan 24, 2008 12:46 pm

Re: Player Location

Post by LOVER$BOY »

Code: Select all

$sizeMultiplier = '0.5f';   //  map size multiplier
$size_factor    = 0;       //  size factor of the map

//  set sizeMultiplier (got straight off arma game code)
$sizeMultiplier = exponent($size_factor);

function exponent($i)
{
    $abs = $i;
    if ( $abs < 0 )
        $abs = -$abs;

    $ret = 1;
    $fac = sqrt(2);

    while ($abs > 0)
    {
        if ( 1 == ($abs & 1) )
            $ret *= $fac;

        $fac *= $fac;
        $abs >>= 1;
    }

    if ($i < 0)
        $ret = 1/$ret;

    return $ret;
}
Image
User avatar
delinquent
Match Winner
Posts: 760
Joined: Sat Jul 07, 2012 3:07 am

Re: Player Location

Post by delinquent »

Code: Select all

 if ( 1 == ($abs & 1) )
            $ret *= $fac;

        $fac *= $fac;
        $abs >>= 1;
I'm confused, isn't this just the same thing twice?
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Re: Player Location

Post by Jonathan »

No, delinquent. Look again: different variables. It's exponentiation by squaring.

Oh, and pow(2,$x/2) will be just fine. If you want it to be bit-exact, you must emulate single-precision floating point as well.
ˌɑrməˈɡɛˌtrɑn
User avatar
Light
Reverse Outside Corner Grinder
Posts: 1667
Joined: Thu Oct 20, 2011 2:11 pm

Re: Player Location

Post by Light »

Jonathan wrote:pow(2,$x/2)
That's what I use. See no real reason to do extra work. :P

That still needs the hardcoded arena size though. :/
Post Reply