0 Members and 1 Guest are viewing this topic.
is it waypointed?
It was designed for DM.
<? error_reporting ( E_ALL ); $poly_types = array ( "POLY_NORMAL", "POLY_ONLY_BULLET_COLLIDES", "POLY_ONLY_PLAYER_COLLIDES", "POLY_DOES_NOT_COLLIDE", "POLY_ICE", "POLY_DEADLY", "POLY_BLOODY_DEADLY", "POLY_HURTS", "POLY_REGENERATES", "POLY_LAVA" ); $spawn_types = array ( "SP_PLAYER", "SP_ALPHA", "SP_BRAVO", "SP_CHARLIE", "SP_DELTA", "SP_RED_FLAG", "SP_BLUE_FLAG", "SP_NADEPACK", "SP_MEDIKIT", "SP_CLUSTERS", "SP_VEST", "SP_FLAMEGOD", "SP_BERSERKER", "SP_PREDATOR", "SP_YELLOW_FLAG", "SP_RAMBO_BOW", "SP_STATIONARY_GUN" ); for ( $i = 0; $i < count ( $poly_types ); $i ++ ) define ( $poly_types [ $i ], $i ); for ( $i = 0; $i < count ( $spawn_types ); $i ++ ) define ( $spawn_types [ $i ], $i ); class vertex { var $r; var $g; var $b; var $x; var $y; function vertex ( $_x, $_y, $_r = 0, $_g = 0 , $_b = 0 ) { $this -> r = $_r; $this -> g = $_g; $this -> b = $_b; $this -> x = $_x; $this -> y = $_y; } } class poly { var $vertex; var $transparent; var $type; function poly ( $v1, $v2, $v3, $t ) { $this -> vertex [ 0 ] = $v1; $this -> vertex [ 1 ] = $v2; $this -> vertex [ 2 ] = $v3; $this -> type = $t; } } class spawn { var $x; var $y; var $type; function spawn ( $_x, $_y, $_t ) { $this -> x = $_x; $this -> y = $_y; $this -> type = $_t; } } $polycount = 0; $spawncount = 0; function fputc ( $char, $file ) { fwrite ( $file, chr ( $char ), 1 ); } function writevertex ( $file, $vertex, $transparent ) { fwrite ( $file, pack ( 'f', $vertex -> x ), 4 ); fwrite ( $file, pack ( 'f', $vertex -> y ), 4 ); if ( $transparent ) { fwrite ( $file, pack ( 'f', 1.0 ), 4 ); fwrite ( $file, pack ( 'f', 6.861987458251e-7 ), 4 ); } else { fwrite ( $file, pack ( 'f', 0 ), 4 ); fwrite ( $file, pack ( 'f', 1 ), 4 ); } fputc ( $vertex -> b, $file ); fputc ( $vertex -> g, $file ); fputc ( $vertex -> r, $file ); fputc ( 0xff, $file ); fwrite ( $file, pack ( 'f', 1.0 ), 4 ); fwrite ( $file, pack ( 'f', - 1.0 ), 4 ); } function writepoly ( $file, $poly ) { writevertex ( $file, $poly -> vertex [ 0 ], $poly -> transparent ); writevertex ( $file, $poly -> vertex [ 1 ], $poly -> transparent ); writevertex ( $file, $poly -> vertex [ 2 ], $poly -> transparent ); for ( $i = 0; $i < 36; $i ++ ) fputc ( 0, $file ); fputc ( $poly -> type, $file ); } function makepoly ( $v1, $v2, $v3, $t = POLY_NORMAL ) { global $polycount; global $polys; $polys [ $polycount ++ ] = new poly ( $v1, $v2, $v3, $t ); } function writespawn ( $file, $spawn ) { fwrite ( $file, pack ( 'i', 0 ), 4 ); fwrite ( $file, pack ( 'i', $spawn -> x ), 4 ); fwrite ( $file, pack ( 'i', $spawn -> y ), 4 ); fwrite ( $file, pack ( 'i', $spawn -> type ), 4 ); } function makespawn ( $x, $y, $t ) { global $spawncount; global $spawns; $spawns [ $spawncount ++ ] = new spawn ( $x, $y, $t ); } /* MAKE POLYGONS, MAP SETTINGS */ $filename = "map.PMS"; $mapname = "by rr-"; $texturename = "alpha.png"; $bkcolor1 = array ( 16, 24, 32 ); $bkcolor2 = array ( 128, 196, 255 ); $nades = 2; $medikits = 2; $weather = 0; $steps = 0; $mapid = mt_rand ( ) % 1000000; $jets = 32766; $write = true; $image = true; $ca = 5.0; $xw = 2000.0; $xh = 2000.0; $bh = $xw / 25.0; $s = $xw / 2.0 - ( 2.0 * $bh ); $x1 = $s; $y1 = 0; $ch = $cw = 0.2; //shouldnt be modified $cx = $cw * 5; $cy = $ch * 5; for ( $cx = $cw; $cx <= $cw * 5; $cx += $cw ) for ( $a = - 180.0; $a <= 180.0; $a += $ca ) { $l = ( 1.0 - $cx ) * 255 * 2.0 * ( 1.0 - ( abs ( $y1 ) / abs ( $s * sin ( 0.5 * M_PI ) ) ) ); $d = $l * 0.6; $t = $cx == $cw * 5 ? POLY_LAVA : POLY_DOES_NOT_COLLIDE; $x2 = $x1; $y2 = $y1; $x3 = ( $s + $bh ) * cos ( $a / 180.0 * M_PI ); $y3 = ( $s + $bh ) * sin ( $a / 180.0 * M_PI ); $x1 = $s * cos ( $a / 180.0 * M_PI ); $y1 = $s * sin ( $a / 180.0 * M_PI ); makepoly ( new vertex ( $cx * $x1, $cy * $y1, $l, $l, $l ), new vertex ( $cx * $x2, $cy * $y2, $l, $l, $l ), new vertex ( $cx * $x3, $cy * $y3, $d, $d, $d ), $t ); $sx2 = $s * cos ( $a / 180.0 * M_PI ); $sy2 = $s * sin ( $a / 180.0 * M_PI ); $sx3 = ( $s + $bh ) * cos ( $a / 180.0 * M_PI ); $sy3 = ( $s + $bh ) * sin ( $a / 180.0 * M_PI ); $sx1 = ( $s + $bh ) * cos ( ( $a - $ca ) / 180.0 * M_PI ); $sy1 = ( $s + $bh ) * sin ( ( $a - $ca ) / 180.0 * M_PI ); makepoly ( new vertex ( $cx * $sx1, $cy * $sy1, $d, $d, $d ), new vertex ( $cx * $sx2, $cy * $sy2, $d, $d, $d ), new vertex ( $cx * $sx3, $cy * $sy3, $d, $d, $d ), $t ); $sx2 = ( $s + $bh ) * cos ( $a / 180.0 * M_PI ); $sy2 = ( $s + $bh ) * sin ( $a / 180.0 * M_PI ); $sx3 = ( $s + $bh ) * cos ( ( $a - $ca ) / 180.0 * M_PI ); $sy3 = ( $s + $bh ) * sin ( ( $a - $ca ) / 180.0 * M_PI ); if ( $cx >= $cw * 5 && $a >= - 180 && $a <= - 90 ) makepoly ( new vertex ( - $xw / 2.0, - $xh / 2.0 ), new vertex ( $cx * $sx2, $cy * $sy2 ), new vertex ( $cx * $sx3, $cy * $sy3 ), $t ); if ( $cx >= $cw * 5 && $a >= - 90 && $a <= - 0 ) makepoly ( new vertex ( $xw / 2.0, - $xh / 2.0 ), new vertex ( $cx * $sx2, $cy * $sy2 ), new vertex ( $cx * $sx3, $cy * $sy3 ), $t ); if ( $cx >= $cw * 5 && $a >= 0 && $a <= 90 ) makepoly ( new vertex ( $xw / 2.0, $xh / 2.0 ), new vertex ( $cx * $sx2, $cy * $sy2 ), new vertex ( $cx * $sx3, $cy * $sy3 ), $t ); if ( $cx >= $cw * 5 && $a >= 90 && $a <= 180 ) makepoly ( new vertex ( - $xw / 2.0, $xh / 2.0 ), new vertex ( $cx * $sx2, $cy * $sy2 ), new vertex ( $cx * $sx3, $cy * $sy3 ), $t ); } $cx = $cw * 5; $cy = $ch * 5; for ( $cy = $ch; $cy < $ch * 5; $cy += $ch ) for ( $a = - 180.0; $a <= 180.0; $a += $ca ) { $l = ( 1.0 - $cy ) * 255 * 2.0 * ( 1.0 - ( abs ( $x1 ) / abs ( $s * cos ( M_PI ) ) ) ); $d = $l * 0.6; $x2 = $x1; $y2 = $y1; $x3 = ( $s + $bh ) * cos ( $a / 180.0 * M_PI ); $y3 = ( $s + $bh ) * sin ( $a / 180.0 * M_PI ); $x1 = $s * cos ( $a / 180.0 * M_PI ); $y1 = $s * sin ( $a / 180.0 * M_PI ); makepoly ( new vertex ( $cx * $x1, $cy * $y1, $l, $l, $l ), new vertex ( $cx * $x2, $cy * $y2, $l, $l, $l ), new vertex ( $cx * $x3, $cy * $y3, $d, $d, $d ), POLY_DOES_NOT_COLLIDE ); $sx2 = $s * cos ( $a / 180.0 * M_PI ); $sy2 = $s * sin ( $a / 180.0 * M_PI ); $sx3 = ( $s + $bh ) * cos ( $a / 180.0 * M_PI ); $sy3 = ( $s + $bh ) * sin ( $a / 180.0 * M_PI ); $sx1 = ( $s + $bh ) * cos ( ( $a - $ca ) / 180.0 * M_PI ); $sy1 = ( $s + $bh ) * sin ( ( $a - $ca ) / 180.0 * M_PI ); makepoly ( new vertex ( $cx * $sx1, $cy * $sy1, $d, $d, $d ), new vertex ( $cx * $sx2, $cy * $sy2, $d, $d, $d ), new vertex ( $cx * $sx3, $cy * $sy3, $d, $d, $d ), POLY_DOES_NOT_COLLIDE ); } makepoly ( new vertex ( - $xw / 2.0, - $xh / 2.0 ), new vertex ( - $xw / 2.0, $xh / 2.0 ), new vertex ( ( $s + $bh ) * cos ( - M_PI ), 0 ) ); makepoly ( new vertex ( $xw / 2.0, - $xh / 2.0 ), new vertex ( - $xw / 2.0, - $xh / 2.0 ), new vertex ( 0, ( $s + $bh ) * sin ( - 0.5 * M_PI ) ) ); makepoly ( new vertex ( $xw / 2.0, $xh / 2.0 ), new vertex ( - $xw / 2.0, $xh / 2.0 ), new vertex ( 0, ( $s + $bh ) * sin ( 0.5 * M_PI ) ) ); makepoly ( new vertex ( $xw / 2.0, $xh / 2.0 ), new vertex ( $xw / 2.0, - $xh / 2.0 ), new vertex ( ( $s + $bh ) * cos ( 2 * M_PI ), 0 ) ); /* OUTPUT POLYGONS */ if ( $image ) { $w = 1000.0; $h = 1000.0; $img = imagecreatetruecolor ( $w, $h ); $color = imagecolorallocate ( $img, 255, 255, 255 ); imagefilledrectangle ( $img, 0, 0, $w - 1, $h - 1, $color ); $color = imagecolorallocate ( $img, 255, 196, 128 ); for ( $i = 0; $i < $polycount; $i ++ ) { $points = array ( ); $points [ ] = $w / 2 + $polys [ $i ] -> vertex [ 0 ] -> x * $w / $xw; $points [ ] = $h / 2 + $polys [ $i ] -> vertex [ 0 ] -> y * $h / $xh; $points [ ] = $w / 2 + $polys [ $i ] -> vertex [ 1 ] -> x * $w / $xw; $points [ ] = $h / 2 + $polys [ $i ] -> vertex [ 1 ] -> y * $h / $xh; $points [ ] = $w / 2 + $polys [ $i ] -> vertex [ 2 ] -> x * $w / $xw; $points [ ] = $h / 2 + $polys [ $i ] -> vertex [ 2 ] -> y * $h / $xh; imagepolygon ( $img, $points, 3, $color ); } $color = imagecolorallocate ( $img, 0, 0, 0 ); imagestring ( $img, 5, 2, 2, "polys: " . $polycount . ", spawns: " . $spawncount, $color ); header ( "content-type: image/png" ); imagepng ( $img ); imagedestroy ( $img ); } else echo "polys: " . $polycount . "<br>spawns: " . $spawncount; /* WRITE POLYGONS */ if ( ! $write ) return; $file = fopen ( $filename, "wb" ); fwrite ( $file, pack ( 'i', 11 ), 4 ); fputc ( strlen ( $mapname ), $file ); for ( $i = 0; $i < 38; $i ++ ) if ( $i >= strlen ( $mapname ) ) fputc ( 0, $file ); else fputc ( ord ( $mapname [ $i ] ), $file ); fputc ( strlen ( $texturename ), $file ); for ( $i = 0; $i < 24; $i ++ ) if ( $i >= strlen ( $texturename ) ) fputc ( 0, $file ); else fputc ( ord ( $texturename [ $i ] ), $file ); fputc ( $bkcolor1 [ 2 ], $file ); fputc ( $bkcolor1 [ 1 ], $file ); fputc ( $bkcolor1 [ 0 ], $file ); fputc ( 0xff, $file ); fputc ( $bkcolor2 [ 2 ], $file ); fputc ( $bkcolor2 [ 1 ], $file ); fputc ( $bkcolor2 [ 0 ], $file ); fputc ( 0xff, $file ); fwrite ( $file, pack ( 'i', $jets ), 4 ); fputc ( $nades, $file ); fputc ( $medikits, $file ); fputc ( $weather, $file ); fputc ( $steps, $file ); fwrite ( $file, pack ( 'i', $mapid ), 4 ); fwrite ( $file, pack ( 'i', $polycount ), 4 ); for ( $i = 0; $i < $polycount; $i ++ ) writepoly ( $file, $polys [ $i ] ); fputc ( 25, $file ); for ( $i = 0; $i < 5221; $i ++ ) fputc ( 0, $file ); fwrite ( $file, pack ( 'i', $spawncount ), 4 ); for ( $i = 0; $i < $spawncount; $i ++ ) writespawn ( $file, $spawns [ $i ] ); for ( $i = 0; $i < 8; $i ++ ) fputc ( 0, $file ); fclose ( $file ); ?>