• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Monster Loot Checker

Colandus

Advanced OT User
Senator
Joined
Jun 6, 2007
Messages
2,434
Solutions
19
Reaction score
219
Location
Sweden
Hello there. I've made this as a request by STiX :)

It will list all monsters from monsters.xml and show their loot (with name of items, not just itemid).

Preview:
acqz6e.jpg


PHP:
<?php 
###### MONSTER LOOT CHECKER ###### 
###### VERSION: 1.5 
###### AUTHOR: Colandus 

$otdir = 'D:/Saker/OT/Rox0r/roxor 8.4'; 

// In percent (highest first). 
$rarity = array( 
    'Not Rare'    => 7, 
    'Semi Rare'    => 2, 
    'Rare'        => 0.5, 
    'Very Rare' => 0 
); 
?> 

<html> 
    <head> 
        <title>Colandus' Monster Loot Checker 1.5</title> 
    </head> 
    <body style="background-color: #434343; color: #C4C4FF"> 
        <script language="javascript"> 
            function toggleVisibility(obj) { 
                var el = document.getElementById('d' + obj.id); 
                var name = obj.innerHTML.substring(4); 
             
                if(el.style.display == 'none') { 
                    obj.innerHTML = '[ -]'; 
                    el.style.display = 'block'; 
                } else { 
                    obj.innerHTML = '[+]'; 
                    el.style.display = 'none'; 
                } 
                obj.innerHTML += ' ' + name; 
            } 
        </script> 
         
        <style type="text/css"> 
            a { 
                color:red; 
                font: bold 13px verdana; 
                text-decoration: none; 
            } 
             
            a:hover { 
                text-decoration: underline; 
            } 
        </style> 

        <?php 
            if(isset($_GET['lootrate'])) 
                $add = '&lootrate'; 
            echo '<a href="' . $_SERVER['PHP_SELF'] . ($add ? '?lootrate' : '') . '">Hide None</a> | '; 
            echo '<a href="?hidefail' . $add . '">Hide Not Found</a> | '; 
            echo '<a href="?hideempty' . $add . '">Hide Monsters Without Loot</a> |'; 
            echo '<a href="?hideempty&hidefail' . $add . '">Hide All</a>'; 
        ?> 
         
        <br /><br /><a href="?lootrate">Use Server Loot Rate</a> 
         
        <br /><br /> 
        <?php 
        $items = simplexml_load_file($otdir . '/data/items/items.xml') or die('<b>Could not load items!</b>'); 
        foreach($items->item as $v) 
            $itemList[(int)$v['id']] = $v['name']; 
             
        if(isset($_GET['lootrate'])) { 
            $config = parse_ini_file($otdir . '/config.lua'); 
            $lootRate = $config['rateLoot']; 
        } 
         
        $monsters = simplexml_load_file($otdir . '/data/monster/monsters.xml') or die('<b>Could not load monsters!</b>'); 
        foreach($monsters->monster as $monster) { 
            $loot = simplexml_load_file($otdir . '/data/monster/' . $monster['file']); 
            if($loot) { 
                if($item = $loot->loot->item) { 
                    echo ' 
                        <a id="' . ++$i . '" style="text-decoration: none; font: bold 14px verdana; color: orange;" href="javascript:void(0);" onclick="toggleVisibility(this)">[+] ' . $monster['name'] . '</a> 
                        <br /><div style="display: none;" id="d' . $i . '"> 
                            <pre>>>> <b><u>' . $otdir . '/' . $monster['file'] . '</u></b><br /><br />'; 
                    addLoot($item); 
                    echo '</pre></div>'; 
                } elseif(!isset($_GET['hideempty'])) 
                    echo '<span style="font: bold 14px verdana; color: red;">[x] ' . $monster['name'] . '</span><br />'; 
            } elseif(!isset($_GET['hidefail'])) 
                echo '<span style="color: white;">Failed to load monster <b>' . $monster[name] . '</b> <i>(' . $monster[file] . ')</i><br />'; 
        } 

        function addLoot($loot, $level=1) { 
            foreach($loot as $test) { 
                $chance = $test['chance']; 
                if(!$chance) 
                    $chance = $test['chance1']; 

                printLoot($level, $test['id'], $test['countmax'], $chance); 
                foreach($test as $k => $v) 
                    addLoot($v->item, $level + 1); 
            } 
        } 
         
        function printLoot($level, $itemid, $count, $chance) { 
            global $itemList, $rarity; 
             
            $chance /= 1000; 
            if(isset($_GET['lootrate'])) { 
                global $lootRate; 
                $chance *= $lootRate; 
            } 
             
            foreach($rarity as $lootRarity => $percent){ 
                if($chance >= $percent) { 
                    echo str_repeat("... ", $level) . '<u>' . ($count ? $count : 1) . '</u> <span style="color: #7878FF; font-weight: bold;">' . $itemList[(int)$itemid] . '</span> ' . $itemid . ' <span style="color: #C45; font-weight: bold;">' . $lootRarity . '</span> (<span style="color: #FF9A9A;">' . $chance . '%</span>)<br />'; 
                    break; 
                } 
            } 
        } 
        ?> 
         
        <br /><p style="font: bold 24px georgia;">By Colandus</p> 
         
    </body> 
</html>

It also loads config.lua and multiply loot with "rateloot".
Enjoy ;) And don't forget to vote it as useful if you use it :D
 
Last edited:
V 1.1 come soon xD


what more?! :S I have no ideas lol... I made in request :D
 
Dude wtf? u know lua right.. you know php.. what else? rofl u big smart ass! :p nah but rlly good job lol as always..


Got any tut for php or smth? xhtml?
 
I am working on it. The % part is done of course, but I will make it say "Rare, Semi Rare" etc :p

Only problem is that I don't know which % is semi rare etc, this is how it is now:
PHP:
// In percent (highest first).
$rarity = array(
	100 	=> 'Always',
	50 		=> 'Often',
	10 		=> 'Rare',
	2 		=> 'Very Rare',
	0.2 	=> 'Semi Rare',
);

But these numbers are not correct :S I don't know which are correct :p

It does work, but numbers are wrong :(
 
Why is very rare before semi rare? :p

It should switch since 'semi' means 'half'.
 
:p
So you learned it too from w3schools? I followed it half way and started scripting then ;)
 
[ -] fire devil

>>> c:\documents and settings\administrador\escritorio\serverr\serverr/demons/fire devil.xml

... 20 gold coin 2148 always (100%)
... 3 meat 2666 semi rare (33.333%)
... 1 necrotic rod 2185 very rare (0.833%)
... 1 torch 2050 semi rare (20%)
... 1 scimitar 2419 semi rare (10%)
... 1 double axe 2387 rare (5%)
... 1 cleaver 2568 semi rare (15%)
... 1 bag 1987 always (100%)
... ... 1 wand of inferno 2187 very rare (1%)
... ... 1 guardian shield 2515 rare (2.857%)
... ... 1 blank rune 2260 rare (6.666%)
... ... 2 brown bread 2691 semi rare (20%)
... ... 2 small amethyst 2150 very rare (1.666%)
... ... 1 wand of dragonbreath 2191 very rare (0.833%)


:eek:ooooo
 
Back
Top