Announcement

Collapse

Forum Rules

  • No flaming or derogatory remarks, directly or through insinuation.
  • No discussion, sharing or referencing illegal software such as hacks, keygen, cracks and pirated software.
  • No offensive contents, including but not limited to, racism, gore or pornography.
  • No excessive spam/meme, i.e. copious one liners in a short period of time, typing with all caps or posting meme responses (text/image).
  • No trolling, including but not limited to, flame incitation, user provocation or false information distribution.
  • No link spamming or signature advertisements for content not specific to Dota 2.
  • No Dota 2 key requests, sell, trade etc.
  • You may not create multiple accounts for any purpose, including ban evasion, unless expressly permitted by a moderator.

  • Please search before posting. One thread per issue. Do not create another thread if there is an existing one already.
  • Before posting anything, make sure you check out all sticky threads (e.g., this). Do not create new threads about closed ones.
  • It is extremely important that you post in correct forum section.

  • Balance discussion only in Misc.
  • All art related (such as hero model) feedbacks go to Art Feedback Forum.
  • All matchmaking feedback should go here: Matchmaking Feedback
  • All report/low priority issues should go here: Commend/Report/Ban Feedback
  • No specific workshop item feedback. These should go to workshop page of that item.
  • When posting in non-bugs section (such as this), use [Bugs], [Discussion] or [Suggestion] prefix in your thread name.



In case you object some action by a moderator, please contact him directly through PM and explain your concerns politely. If you are still unable to resolve the issue, contact an administrator. Do not drag these issues in public.



All rules are meant to augment common sense, please use them when not conflicted with aforementioned policies.
See more
See less

This is how to interpret the barracks_status and tower_status results from the API

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Maximass
    replied
    How to interpret the building_state from /IDOTA2Match_570/GetTopLiveGame ?
    Code:
    "activate_time":1530222336,
    "deactivate_time":0,
    "server_steam_id":"90115488091499530",
    "lobby_id":"25671396156219670",
    "league_id":0,
    "lobby_type":7,
    "game_time":1921,
    "delay":120,
    "spectators":2338,
    "game_mode":22,
    "average_mmr":6924,
    "sort_score":9762,
    "last_update_time":1530224384,
    "radiant_lead":-6703,
    "radiant_score":42,
    "dire_score":42,
    "players":[...],
    "building_state":5374170

    Leave a comment:


  • scottrick
    replied
    Yeah I have; I based my original implementation on that wiki page, and I noticed the ancient towers were incorrect. To be sure, I found two different matches (one each for dire and radiant) with one ancient tower remaining and verified the tower status by watching the replay in the dota2 client. What I posted is correct, and also matches dotabuff as well.

    I updated the wiki page.
    Last edited by scottrick; 12-22-2015, 07:10 AM.

    Leave a comment:


  • arosian
    replied
    Originally posted by scottrick View Post
    Just looking at this, and this order still isn't *quite* correct. The ancient top/bottom towers are swapped and should be:

    Ancient Bottom
    Ancient Top
    Bottom Tier 3
    Bottom Tier 2
    Bottom Tier 1
    Middle Tier 3
    Middle Tier 2
    Middle Tier 1
    Top Tier 3
    Top Tier 2
    Top Tier 1

    This makes it a little bit more aesthetically pleasing, with bottom always coming before top!
    Have you confirmed this experimentally? I trust you, so if you have, can you update the TF2 wiki here: https://wiki.teamfortress.com/wiki/W...s#Tower_Status. It claims that Top and Bottom are opposite of yours.

    Leave a comment:


  • scottrick
    replied
    Just looking at this, and this order still isn't *quite* correct. The ancient top/bottom towers are swapped and should be:

    Ancient Bottom
    Ancient Top
    Bottom Tier 3
    Bottom Tier 2
    Bottom Tier 1
    Middle Tier 3
    Middle Tier 2
    Middle Tier 1
    Top Tier 3
    Top Tier 2
    Top Tier 1

    This makes it a little bit more aesthetically pleasing, with bottom always coming before top!

    Leave a comment:


  • Razumov
    replied
    Finally got around to implementing this. I'm using tables with images rather than than images on a map. Example: http://www.datdota.com/match.php?q=223010600&p=towers

    Here's the php code (assumes that $towerRadiant is the "radiant_tower_status" from the API etc):
    Code:
     $radTowerBin = sprintf('%011b', $towerRadiant );
            $direTowerBin = sprintf('%011b', $towerDire );
            $radRaxBin = sprintf('%08b', $raxRadiant );
            $direRaxBin = sprintf('%08b', $raxDire );
    
            if( $radWin == 1 ){
                $winnerArray[0] = "<img src=\"images/map/radiant_ancient.png\" alt=\"1\">";
                $winnerArray[1] = "<img src=\"images/map/big_x.png\" alt=\"1\">";
            } else {
                $winnerArray[0] = "<img src=\"images/map/big_x.png\" alt=\"1\">";
                $winnerArray[1] = "<img src=\"images/map/dire_ancient.png\" alt=\"1\">";
            }
            for( $i = 0; $i < 11; $i++ ){
                if( $radTowerBin[$i] == 1 ){
                    $radTowerArray[$i] = "<img src=\"images/map/radiant_tower.png\" alt=\"1\">";  
                } else {
                    $radTowerArray[$i] = "<img src=\"images/map/big_x.png\" alt=\"1\">";
                }
                if( $direTowerBin[$i] == 1 ){
                    $direTowerArray[$i] = "<img src=\"images/map/dire_tower.png\" alt=\"1\">";
                } else {
                    $direTowerArray[$i] = "<img src=\"images/map/big_x.png\" alt=\"1\">";
                }
            }
            for( $i = 2; $i < 8; $i++ ){
                if( $radRaxBin[$i] == 1 ){
                    $radRaxArray[$i-2] = "<img src=\"images/map/radiant_rax.png\" alt=\"1\">";  
                } else {
                    $radRaxArray[$i-2] = "<img src=\"images/map/big_x.png\" alt=\"1\">";
                }
                if( $direRaxBin[$i] == 1 ){
                    $direRaxArray[$i-2] = "<img src=\"images/map/dire_rax.png\" alt=\"1\">";
                } else {
                    $direRaxArray[$i-2] = "<img src=\"images/map/big_x.png\" alt=\"1\">";
                }
            }
            
            //rax, first 2 are not used, not using them in the array
            //bottom ranged, bottom melee, mid ranged, mid melee, top ranged, top melee
            ?>
    <h3>Towers</h3>
    <table class="table table-bordered table-condensed">
        <tr><th>Side</th><th>Tier 1 Top</th><th>Tier 1 Mid</th><th>Tier 1 Bot</th>
            <th>Tier 2 Top</th><th>Tier 2 Mid</th><th>Tier 2 Bot</th>
            <th>Tier 3 Top</th><th>Tier 3 Mid</th><th>Tier 3 Bot</th>
            <th>Tier 4 Top</th><th>Tier 4 Bot</th>
        </tr>
        <tr><td>Radiant</td><td><?php echo $radTowerArray[10]; ?></td><td><?php echo $radTowerArray[7]; ?></td><td><?php echo $radTowerArray[4]; ?></td>
            <td><?php echo $radTowerArray[9]; ?></td><td><?php echo $radTowerArray[6]; ?></td><td><?php echo $radTowerArray[3]; ?></td>
            <td><?php echo $radTowerArray[8]; ?></td><td><?php echo $radTowerArray[5]; ?></td><td><?php echo $radTowerArray[2]; ?></td>
            <td><?php echo $radTowerArray[0]; ?></td><td><?php echo $radTowerArray[1]; ?></td>
        </tr>
        <tr><td>Dire</td><td><?php echo $direTowerArray[10]; ?></td><td><?php echo $direTowerArray[7]; ?></td><td><?php echo $direTowerArray[4]; ?></td>
            <td><?php echo $direTowerArray[9]; ?></td><td><?php echo $direTowerArray[6]; ?></td><td><?php echo $direTowerArray[3]; ?></td>
            <td><?php echo $direTowerArray[8]; ?></td><td><?php echo $direTowerArray[5]; ?></td><td><?php echo $direTowerArray[2]; ?></td>
            <td><?php echo $direTowerArray[0]; ?></td><td><?php echo $direTowerArray[1]; ?></td>
        </tr>
    </table>
    <br>
    <h3>Barracks</h3>
    <table class="table table-bordered table-condensed">
        <tr><th>Side</th><th>Bot Ranged Rax</th><th>Bot Melee Rax</th>
            <th>Mid Ranged Rax</th><th>Mid Melee Rax</th>
            <th>Top Ranged Rax</th><th>Top Melee Rax</th>
        </tr>
        <tr><td>Radiant</td><td><?php echo $radRaxArray[0]; ?></td><td><?php echo $radRaxArray[1]; ?></td>
            <td><?php echo $radRaxArray[2]; ?></td><td><?php echo $radRaxArray[3] ?></td>
            <td><?php echo $radRaxArray[4]; ?></td><td><?php echo $radRaxArray[5]; ?></td>
        </tr>
        <tr><td>Dire</td><td><?php echo $direRaxArray[0]; ?></td><td><?php echo $direRaxArray[1]; ?></td>
            <td><?php echo $direRaxArray[2]; ?></td><td><?php echo $direRaxArray[3] ?></td>
            <td><?php echo $direRaxArray[4]; ?></td><td><?php echo $direRaxArray[5]; ?></td>
        </tr>
    </table>
    <br>
    <h3>Map</h3>
    <table class="table table-bordered table-condensed">
        <tr><td><?php echo $river; ?></td><td></td><td><?php echo $direTowerArray[10]; ?></td>     <td></td><td><?php echo $direTowerArray[9]; ?></td><td></td>     <td><?php echo $direTowerArray[8]; ?></td><td><?php echo $direRaxArray[4]; ?></td><td></td>     <td></td><td></td><td></td></tr>
        <tr><td></td><td><?php echo $river; ?></td><td></td>     <td></td><td></td><td></td>     <td></td><td><?php echo $direRaxArray[5]; ?></td><td></td>     <td><?php echo $direTowerArray[0]; ?></td><td><?php echo $winnerArray[1]; ?></td><td></td></tr>
        <tr><td><?php echo $radTowerArray[10]; ?></td><td></td><td><?php echo $river; ?></td>     <td></td><td></td><td></td>     <td></td><td></td><td><?php echo $direRaxArray[2]; ?></td>     <td></td><td><?php echo $direTowerArray[1]; ?></td><td></td></tr>
        
        <tr><td></td><td></td><td></td>     <td><?php echo $river; ?></td><td></td><td></td>     <td></td><td></td><td><?php echo $direTowerArray[5]; ?></td>     <td><?php echo $direRaxArray[3]; ?></td><td></td><td></td></tr>
        <tr><td><?php echo $radTowerArray[9]; ?></td><td></td><td></td>     <td></td><td><?php echo $river; ?></td><td></td>     <td></td><td><?php echo $direTowerArray[6]; ?></td><td></td>     <td></td><td><?php echo $direRaxArray[0]; ?></td><td><?php echo $direRaxArray[1]; ?></td></tr>
        <tr><td></td><td></td><td></td>     <td></td><td></td><td><?php echo $river; ?></td>     <td><?php echo $direTowerArray[7]; ?></td><td></td><td></td>     <td></td><td></td><td><?php echo $direTowerArray[2]; ?></td></tr>
        
        <tr><td><?php echo $radTowerArray[8]; ?></td><td></td><td></td>     <td></td><td></td><td><?php echo $radTowerArray[7]; ?></td>     <td><?php echo $river; ?></td><td></td><td></td>     <td></td><td></td><td></td></tr>
        <tr><td><?php echo $radRaxArray[4]; ?></td><td><?php echo $radRaxArray[5]; ?></td><td></td>     <td></td><td><?php echo $radTowerArray[6]; ?></td><td></td>     <td></td><td><?php echo $river; ?></td><td></td>     <td></td><td></td><td><?php echo $direTowerArray[3]; ?></td></tr>
        <tr><td></td><td></td><td><?php echo $radRaxArray[2]; ?></td>     <td><?php echo $radTowerArray[5]; ?></td><td></td><td></td>     <td></td><td></td><td><?php echo $river; ?></td>     <td></td><td></td><td></td></tr>
        
        <tr><td></td><td><?php echo $radTowerArray[0]; ?></td><td></td>     <td><?php echo $radRaxArray[3]; ?></td><td></td><td></td>     <td></td><td></td><td></td>     <td><?php echo $river; ?></td><td></td><td><?php echo $direTowerArray[4]; ?></td></tr>
        <tr><td></td><td><?php echo $winnerArray[0]; ?></td><td><?php echo $radTowerArray[1]; ?></td>     <td></td><td><?php echo $radRaxArray[0]; ?></td><td></td>     <td></td><td></td><td></td>     <td></td><td><?php echo $river; ?></td><td></td></tr>
        <tr><td></td><td></td><td></td>     <td></td><td><?php echo $radRaxArray[1]; ?></td><td><?php echo $radTowerArray[2]; ?></td>     <td></td><td><?php echo $radTowerArray[3]; ?></td><td></td>     <td><?php echo $radTowerArray[4]; ?></td><td></td><td><?php echo $river; ?></td></tr>
    </table>

    Leave a comment:


  • MuppetMaster42
    replied
    interesting.. i thought that I got the towers correct when I worked it out all those months ago (9 months ago now)...
    you're the first one to have corrected it! lol

    if it's correct on the wiki, then you are correct on both counts..
    I clearly mixed it up when I did it!

    I have updated my faq sticky with links to the wiki.

    Leave a comment:


  • Razumov
    replied
    Getting conflicting results on the tower_status number too.

    Match ID: 162608771
    tower_status_radiant: 1846
    binary: 11100110110
    Watching replay: All tier 4 and tier 3 remaining. Tier 2 top and mid remaining.

    tower_status_dire: 256
    binary: 00100000000
    Watching replay: Tier 3 bot only one remaining

    This conflicts with the original post in the thread but is the same as what is on the API thread on the teamfortress wiki:

    Ancient Top
    Ancient Bottom
    Bottom Tier 3
    Bottom Tier 2
    Bottom Tier 1
    Middle Tier 3
    Middle Tier 2
    Middle Tier 1
    Top Tier 3
    Top Tier 2
    Top Tier 1

    Leave a comment:


  • MuppetMaster42
    replied
    Originally posted by Razumov View Post
    snip
    back when this was written the barracks_status fields were a broken copy of each other.
    It was hard to tell exactly what was what for what team....

    If I remember rightly - when it was deciphered (all that time ago.. I forget who did the barracks status field..) it was only working for the dire..
    (and deciphering it was made even harder by the fact that 9 times out of 10.. it was either all racks gone or none gone for dire... vary rarely was it certain combinations..)

    When it started working - we assumed that the two teams would work in the same way...
    but from what you're saying - apparently the radiant is reversed.
    i'll have a look when I get home from work and update things as necessary.

    Leave a comment:


  • Razumov
    replied
    I'm having trouble duplicating the same results for barracks as they are described in the original post. Examples:

    Match ID: 162083844
    Radiant Rax api value: 3
    Binary of 3: 000011

    If I'm following the original post, I'm supposed to read that from left to right in this order with 0 indicating destroyed and 1 indicating remaining.

    1 TOP RANGED
    2 TOP MELEE
    3 MID RANGED
    4 MID MELEE
    5 BOT RANGED
    6 BOT MELEE

    So 000011 would indicated the top and mid rax are destroyed while the bottom are remaining. However,
    watching a replay of that game the top rax are remaining and the bottom and mid rax were destroyed.

    Match ID: 161913547
    Radiant Rax API value: 15
    Binary of 15: 001111

    Watching the replay, the Radiant mid and top rax remain while the bottom rax has been destroyed.

    Match ID: 160860759
    Radiant Rax API value: 48
    Binary of 48: 110000

    Watching the replay, the Radiant top and mid rax are destroyed, bottom are left remaining.

    Based on those three replays, it appears the order in the original post is incorrect. http://wiki.teamfortress.com/wiki/We...arracks_Status has the order:

    Bottom Ranged
    Bot Melee
    Mid Ranged
    Mid Melee
    Top Ranged
    Top Melee

    Leave a comment:


  • Razumov
    replied
    Sweet, thanks. I'll try out that code and post some links with the results.

    Leave a comment:


  • MuppetMaster42
    replied
    as requested.
    personally I prefer using back-end php to render the image rather than using front-end javascript like some people have.
    It depends on how much traffic your server gets really.
    But the back-end php is guaranteed to work regardless of the client's browser & settings...

    The images can be found here:
    http://zacher.com.au/dota/images/map/

    the code:
    Code:
    <?php
    
    global $canvas, $canvas_dim, $icon_dim;
    
    $rad_status = sprintf('%011b', 0 );
    $dire_status = sprintf('%011b', 0 );
    if (isset($_GET["r"]) && isset($_GET["d"])) {
        $rad_status = sprintf('%011b', $_GET["r"] );
        $dire_status = sprintf('%011b', $_GET["d"] );
    }
    
    $folder = "images/map/";
    $canvas_dim = 1024;
    $icon_dim = 64;
    $modifier = 1;
    
    // If the thumb parameter is set - make everything thumbnailed
    if (isset($_GET["thumb"])) {
        $folder .= "thumb/";
        $canvas_dim = 512;
        $icon_dim = 32;
        $modifier = 0.5;
    }
    
    // load map
    $canvas = @imagecreatefromjpeg($folder . "dota_map.jpg");
    if ($canvas === false) {
        die("UNABLE TO LOAD IMAGE");
    }
    
    // load tower images
    $tower_dire = load_png($folder . "tower_dire.png");
    $tower_radiant = load_png($folder . "tower_radiant.png");
    
    // Radiant
    $positions = array(
        array(120, 775), // ancient top
        array(150, 800), // ancient bot
        
        array(70, 690),  // t3 top
        array(75, 560),  // t2 top
        array(75, 363),  // t1 top
        
        array(190, 730), // t3 mid
        array(270, 660), // t2 mid
        array(390, 540), // t1 mid
        
        array(230, 850), // t3 bot
        array(420, 870), // t2 bot
        array(800, 850), // t1 bot
    );
    
    for ($i = 0; $i < 11; $i++) {
        if ($rad_status[$i]) {
            draw_icon($tower_radiant, $positions[$i]);
        }
    }
    
    // Dire
    $positions = array(
        array(810, 160), // ancient top
        array(840, 185), // ancient bot
        
        array(710, 120), // t3 top
        array(540, 120), // t2 top
        array(160, 110), // t1 top
        
        array(745, 245), // t3 mid
        array(660, 330), // t2 mid
        array(540, 450), // t1 mid
        
        
        array(875, 290),  // t3 bot
        array(880, 440),  // t2 bot
        array(875, 597),  // t1 bot
    );
    
    for ($i = 0; $i < 11; $i++) {
        if ($dire_status[$i]) {
            draw_icon($tower_dire, $positions[$i]);
        }
    }
    
    // Output the data we send to the client
    header('Content-Type: image/jpg');
    imagejpeg($canvas);
    imagedestroy($canvas); 
    
    
    
    function draw_icon($icon, $coords) {
        global $canvas, $canvas_dim, $icon_dim, $modifier;
        
        // Scale the size as required
        $x = floor($coords[0] * $modifier);
        $y = floor($coords[1] * $modifier);
        
        if (!imagecopyresampled($canvas, $icon, $x, $y, 0, 0, $icon_dim, $icon_dim, $icon_dim, $icon_dim)) {
            die("UNABLE TO DRAW IMAGE");
        }
    }
    
    function load_png($file) {
        $pic = @imagecreatefrompng($file);
        if ($pic === false) {
            die("UNABLE TO LOAD IMAGE");
        }
        
        // make sure the images can be properly drawn together
        imagealphablending($pic, false);
        imagesavealpha($pic, true);
        
        return $pic;
    }
    
    ?>

    Leave a comment:


  • MuppetMaster42
    replied
    Originally posted by Razumov View Post
    snip
    I have some simple code that converts it to a picture!
    example:
    http://zacher.com.au/dota/draw_map.php?r=0&d=1956
    (r & d are the uints with the data)

    I made this based on this post in the olden days epic thread: http://dev.dota2.com/showthread.php?...l=1#post309065
    If you click a bit further through those pages you'll find where someone linked the images I used.

    when I get home from work in a few hours I'll post up my code
    I'd do it from here but the network is poo head and it won't let me access my server to fetch the code....

    Leave a comment:


  • Razumov
    replied
    Has anyone written any code that turns the tower_status fields into a visual representation and wants to share it? I wrote some PHP code that turns the tower_status from the getLiveLeagueGames into a tower score. It's nothing fancy and outputs the score as "(Radiant Towers remaining) -- (Dire Towers Remaining)". The code assumes that the tower_status numbers are in the third position of an array called $bqArray that is of a variable size ($maxSize).

    Code:
     for( $i = 0; $i < $tower_statusSize; $i++ ){
                     $towerBin = decbin($tower_status[$i]);
                     $direBin = substr($towerBin, 1, 11);
                     $radBin = substr($towerBin, 11, 11);   
                     $radScore = 0; $direScore = 0;
                     for( $j = 0; $j < 11; $j++ ){
                         $radScore = $radScore + intval(substr($radBin,$j,1));
                         $direScore = $direScore + intval(substr($direBin,$j,1));
                     }
                     $towerScore = $radScore." -- ".$direScore;
                 }

    Leave a comment:


  • walkingcarpet
    replied
    Yeah... for some reason the <table> tags are disabled on the advanced editor... no idea why. They would solve this scenario completely.

    Leave a comment:


  • Shinkai
    replied
    Code:
    1	ANCIENT TOP
    2	ANCIENT BOTTOM
    3	TOP 3
    4	TOP 2
    5	TOP 1
    6	MIDDLE 3
    7	MIDDLE 2
    8	MIDDLE 1
    9	BOTTOM 3
    10	BOTTOM 2
    11	BOTTOM 1
    Code:
    1	ANCIENT TOP	1	Alive
    2	ANCIENT BOTTOM	0     
    3	TOP 3		1	Alive
    4	TOP 2		0
    5	TOP 1		0
    6	MIDDLE 3	1	Alive
    7	MIDDLE 2	1	Alive
    8	MIDDLE 1	1	Alive
    9	BOTTOM 3	0
    10	BOTTOM 2	0
    11	BOTTOM 1	0
    Code:
    1	TOP RANGED
    2	TOP MELEE
    3	MID RANGED
    4	MID MELEE
    5	BOT RANGED
    6	BOT MELEE
    Use " " which is tab character instead of whitespace. Copy the fixed codes from my post. More info here. Hitting tab in this editor won't give you the desired result, though. Work-around would be just either copying the tab character from notepad or from other posts or just write code section completely in another text editor.
    Last edited by Shinkai; 10-04-2012, 09:37 AM.

    Leave a comment:

Working...
X