/**
* Used for the mini map drawing
*/
function alloc_colors($img)
{
$cols=array();
// 0 1 2 3 4 5 6 7
$strcolors=array("78E317","98664E","6C4837","C7A392","EBC792","000000","F07D0B","0000FF",
// 8 9 10 11 12 13 14 15 16 17
"A0A0A0","009900","999999","996600","FFFFFF","D28080","C8EAF6","0000DD","A13815","DC5300");
foreach($strcolors as $v)
{
$r=hexdec(substr($v,0,2));
$g=hexdec(substr($v,2,2));
$b=hexdec(substr($v,4,2));
$cols[]=imagecolorallocate($img,$r,$g,$b);
}
return $cols;
}
function object_color($type)
{
global $uservals;
if($type >= 11 && $type <= 53) // Houses
return 13;
if($type >= 65 && $type <= 112) // Castle
return 13;
if($type >= 175 && $type <= 186) // Big house
return 13;
if($type >= 212 && $type <= 219) // Tower and house
return 13;
if($type >= 286 && $type <= 291) // House and sign
return 13;
if($type >= 224 && $type <= 227) // Smith
return 13;
if($type >= 229 && $type <= 244) // Fisherman, Token Shop, School
return 13;
if($type >= 343 && $type <= 354) // House
return 13;
if($type >= 323 && $type <= 328) // Waterfall
return 7;
if((($uservals['LOCATION']+0) < 0 || ($_GET["LOCATION"]+0) < 0 ) && $type >= 277 && $type <= 284)
return 6;
switch($type)
{
case 0:
return 0;
case 247: // Something to pick up... normaly.
return 9;
case 115: // Down
case 117:
case 114: // Up
case 118:
return 12;
case 54: // Only while editing
if($_GET["ADMIN"] != 0)
return 9;
return 0;
case 5: // Trees
case 57:
case 58:
case 62:
case 63:
case 329:
case 330:
case 331:
case 332:
case 333:
case 334:
case 335:
case 336:
case 337:
case 338:
case 339:
case 340:
case 341:
case 342:
case 402:
return 9;
case 292: // Shrine
return 13;
default:
return 0;
}
}
function title_color($type)
{
if($type == 42)
return 1;
if($type == 78)
return 2;
if($type == 72 || $type == 458 || $type == 465)
return 12;
if($type == 192)
return 13;
if($type == 92 || $type == 102 || $type == 103)
return 8;
if($type >= 8 && $type <= 22) // roads
return 3;
if($type >= 23 && $type <= 37) // sand
return 4;
if(($type >= 38 && $type != 42 && $type <= 51) || ($type >= 501 && $type <= 508)) // Cave
return 5;
if($type >= 88 && $type != 92 && $type != 102 && $type != 103 && $type <= 105) // Dungeon
return 5;
if($type >= 74 && $type != 78 && $type <= 87) // Magma
return 6;
if(($type >= 52 && $type <= 64) || ($type >= 493 && $type <= 500)) // Water
return 7;
if($type >= 376 && $type <= 388) //Deep water
return 15;
if(($type >= 65 && $type <= 73 && $type != 72) || ($type >= 424 && $type <= 457) || ($type >= 459 && $type <= 464) || ($type >= 468 && $type <= 469))
// Mountain (but not the cave)
return 8;
if($type >= 108 && $type <= 132) // Ice
return 14;
if($type >= 133 && $type <= 142) // Bridge
return 13;
if(($type >= 143 && $type <= 144) || ($type >= 370 && $type <= 375)
|| ($type >= 422 && $type <= 423) || ($type >= 489 && $type <= 492)) // Dock
return 4;
if($type >= 173 && $type <= 187) // Ice road
return 3;
if($type >= 188 && $type <= 201 && $type != 192) // Sky
return 7;
if($type >= 389 && $type <= 421) //Ship
return 16;
if($type >= 470 && $type <= 487) // Carpet
return 17;
if(in_array($type,array(42,78,92,192,206,220,234,248,262,276,290,304,318,332,346,360))) // Dungeon
return 1;
if(($type >= 202 && $type <= 369) || $type == 488) // Dungeon walls
return 5;
return 0; // Grass
}
function draw_map($map,$obj)
{
$strcolors=array("78E317","98664E","6C4837","C7A392","EBC792","000000","F07D0B","0000FF","A0A0A0","009900","999999","996600","FFFFFF","D28080","C8EAF6","0000DD","A13815","DC5300");
foreach($strcolors as $v)
{
$r=hexdec(substr($v,0,2));
$g=hexdec(substr($v,2,2));
$b=hexdec(substr($v,4,2));
$cols[]=imagecolorallocate($im,$r,$g,$b);
}
for($i=0;$i < 99;$i++)
{
for($j=0;$j < 99;$j++)
{
$t=title_color($map[$i][$j]);
$o=object_color($obj[$i][$j]);
if($o != 0)
$t=$o;
imagefilledrectangle($im,$i*2,$j*2,$i*2+1,$j*2+1,$cols[$t]);
}
}
}
?>
Wyszukiwarka
Podobne podstrony:
image map utilimage map utilimage map utilmap utilmap utilmap utilmap utilUtil jsimagefunction pdf execute imageG28 Mirror Imagejava awt image IndexColorModelwięcej podobnych podstron