generic map





PHPXRef 0.7 : NEABExplorer : /locations_modules/2dmap/generic_map.php source









[ Index ]


PHP Cross Reference of NEABExplorer














if (gwGetCookie('xrefnav')=='off')
document.write('[ Show Explorer ]');
else
document.write('[ Hide Explorer ]');



[ Show Explorer ]
[ Hide Navbar ]





titleBody[close]
/locations_modules/2dmap/ -> generic_map.php (source)

[Summary view]
[Print]
[Text view]


1 <?PHP
2 /**
3 * This code takes care of showing a 2D map where the player can walk/interract with and start fights.
4 * It uses the map_script.js and via AJAX the action_on_map.php.
5 */
6
7 if($_GET["CMD"] == "STYLESHEET")
8 {
9 header("Expires: ".gmstrftime("%a, %d %e %b %Y %H:%M:%S GMT",time()+30*24*3600));
10 header("Pragma: public");
11 header("Last-Modified: Wed, 15 Sep 2004 12:00:00 GMT");
12 header("Cache-Control: post-check=90000,pre-check=360000,min-fresh=90000,max-age=360000");
13 header("Content-type: text/css");
14
15 if($_GET["ZOOM"] == 2)
16 {
17 echo ".SPR {width: 128; height: 128; border: 0; src: store_cache.php?OBJ=objects/0.gif}\n";
18 echo ".HELP {position: absolute; visibility: visible; top: 5; left: 190; height: 100; width: 207; background-color: #E0E0E0; border: 1px solid #000000; padding:3px;font-size: 10px; filter: alpha(opacity=50); opacity: 0.5; -moz-opacity: 0.5;}\n";
19 echo ".MESSAGES {position: absolute; visibility: visible; top: 500; left: 865; height: 115; width: 207; background-color: #FFA0A0; border: 1px solid #000000; padding:3px;font-size: 10px; filter: alpha(opacity=50); opacity: 0.5; -moz-opacity: 0.5;}\n";
20 echo ".MINIMAP {position: absolute; visibility: visible; top: 0; left: 881; border: 1px solid #000000; filter: alpha(opacity=70); opacity: 0.7; -moz-opacity: 0.7; }\n";
21 echo ".MINIMONSTERS {position: absolute; visibility: visible; top: 1; left: 882; height: 200; width: 200;}\n";
22 }
23 else
24 {
25 echo ".SPR {width: 64; height: 64; border: 0; src: store_cache.php?OBJ=objects/0.gif}\n";
26 echo ".HELP {position: absolute; visibility: visible; top: 80; left: 640; height: 100; width: 207; background-color: #E0E0E0; border: 1px solid #000000; padding:3px;font-size: 10px;}\n";
27 echo ".MESSAGES {position: absolute; visibility: visible; top: 193; left: 640; height: 115; width: 207; background-color: #FFA0A0; border: 1px solid #000000; padding:3px;font-size: 10px;}\n";
28 echo ".MINIMAP {position: absolute; visibility: visible; top: 320; left: 640; height: 200; width: 200; background-color: #E0E0E0; border: 1px solid #000000; padding:3px;font-size: 10px;}\n";
29 echo ".MINIMONSTERS {position: absolute; visibility: visible; top: 320; left: 640; height: 200; width: 200;}\n";
30 }
31 echo ".MINIMAPPOS {position: absolute; visibility: visible; top: 320; left: 640; height: 2; width: 2; background-color: #FF0000;}\n";
32 echo ".MINIMAPPOSNONE {position: absolute; visibility: visible; top: 320; left: 640;}\n";
33 if($_GET["ZOOM"] == 2) for($y=0;$y < 7;$y++)
34 for($x=0;$x < 7;$x++)
35 echo "#OVER_OBJ_".$x."_".$y." {position: absolute; visibility: hidden; top: ".($y*128)."; left: ".($x*128)."}\n";
36 else for($y=0;$y < 7;$y++)
37 for($x=0;$x < 7;$x++)
38 echo "#OVER_OBJ_".$x."_".$y." {position: absolute; visibility: hidden; top: ".($y*64+80)."; left: ".($x*64+185)."}\n";
39 exit;
40 }
41
42 include "$basedir/libs/map_util.php";
43 if(file_exists("$basedir/libs/walkable.php"))
44 include_once "$basedir/libs/walkable.php";
45 else
46 {
47 $objwalk=str_pad("",600,"Y");
48 $bgwalk=str_pad("",600,"Y");
49 }
50
51
52 if($_POST["COMBAT"] <> "")
53 {
54 $_GET=$_POST;
55 $db->Execute("UPDATE PLAYER SET MAPX=".($_GET["X"]+0).", MAPY=".($_GET["Y"]+0).", INVISIBILITY=".($_GET["INVISIBILITY"]+0)." WHERE ID = $userid AND LOCATION = ".$uservals["LOCATION"]);
56 include_once "$basedir/combat/combats_util.php";
57 start_combat($_GET["COMBAT"]+0);
58 return;
59 }
60 else if($_POST["ACTION"] <> "" || $_GET["ACTION"] <> "")
61 {
62 if($_POST["ACTION"] <> "")
63 $_GET=$_POST;
64 include "$basedir/locations_modules/2dmap/action_on_map.php";
65 return;
66 }
67
68 retreive_loc();
69
70 $mapheader=true;
71 $mapparams="ID=".$uservals["LOCATION"];
72 $_GET["ID"]=$uservals["LOCATION"];
73
74 include "$basedir/locations_modules/2dmap/loadmap.php";
75 $bodydef="<BODY BGCOLOR=#FFFFFF onUnload='store_pos()' leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'";
76 $bodydef.=">\n";
77
78 $header.="<link href=locations_modules/2dmap/generic_map.php?CMD=STYLESHEET&VER=18&ZOOM=1 rel=stylesheet type=text/css>\n";
79
80 //$didyouknow=3;
81 if(strftime("%d/%m") == "06/06" && $uservals["LEVEL"]+0 > 3 && ($uservals['LOCATION'] == 8 || $uservals['LOCATION'] == 9))
82 $sql="SELECT ID,IFCODE,PROBABILITY FROM MONSTERS WHERE ID >= 11742 && ID <= 11743 ORDER BY ABS(LEVEL-".$uservals["LEVEL"].") LIMIT 0,2";
83 else if($userid == $locinfo["MANAGER"])
84 $sql="";
85 else if(($uservals['LOCATION']+0) < 0)
86 {
87 $sql="SELECT CONTAINERSVALUE,OWNEDBY FROM PLAYER_MAP WHERE USERID=$userid AND LEVEL = ".(-$uservals['LOCATION']);
88 $r=$db->Execute($sql);
89 $levelvalue=$r->fields[0];
90 if($r->fields[1] == $userid)
91 {
92 //echo "//Player owned...\n";
93 $sql="";
94 }
95 else
96 $sql="SELECT ID,IFCODE,PROBABILITY FROM MONSTERS WHERE MAXGOLD <= $levelvalue AND DEFLOCATION = 0 AND MANAGER = 0 AND WATER = 'N' ORDER BY MAXGOLD DESC LIMIT 0,18";
97 //$sql="SELECT ID,IFCODE,PROBABILITY FROM MONSTERS WHERE MAXGOLD <= $levelvalue AND DEFLOCATION = 0 AND ID < 1000 ORDER BY MAXGOLD DESC LIMIT 0,8";
98 $r->Close();
99 }
100 else
101 {
102 $r=$db->Execute("SELECT COUNT(MONSTERID) FROM MAP_MONSTERS WHERE MAPID = ".$uservals["LOCATION"]);
103 $nb=$r->fields[0]+0;
104 $r->Close();
105 if($nb > 0)
106 $sql="SELECT MONSTERID,IFCODE,PROBABILITY FROM MAP_MONSTERS,MONSTERS WHERE MONSTERS.ID = MAP_MONSTERS.MONSTERID AND MAPID = ".$uservals["LOCATION"];
107 else
108 $sql="SELECT ID,IFCODE,PROBABILITY FROM MONSTERS WHERE USERLEVELMIN <= {$uservals['LEVEL']} AND (DEFLOCATION = 0 OR DEFLOCATION = ".$uservals["LOCATION"].") AND MANAGER = 0 AND WATER = 'N' ORDER BY DEFLOCATION DESC, LEVEL DESC LIMIT 0,18";
109 //$sql="SELECT ID,IFCODE,PROBABILITY FROM MONSTERS WHERE USERLEVELMIN <= {$uservals['LEVEL']} AND (DEFLOCATION = 0 OR DEFLOCATION = ".$uservals["LOCATION"].") AND ID < 1000 ORDER BY DEFLOCATION DESC, LEVEL DESC LIMIT 0,8";
110 }
111
112 $nbmonsters=0;
113 $monsters=array();
114 if($sql != "")
115 {
116 $r=$db->Execute($sql);
117
118 if($r !== false) while(!$r->EOF)
119 {
120 if(($r->fields[0]+0) == 0)
121 {
122 $r->MoveNext();
123 continue;
124 }
125 $p=mt_rand(0,100);
126 if(($r->fields[2]+0) != 100 && $p < ($r->fields[2]+0))
127 {
128 $r->MoveNext();
129 continue;
130 }
131 if($r->fields[1] != "")
132 {
133 $res=false;
134 $code='if ('.$r->fields[1].') $res=true;';
135 eval($code);
136 if($res == false)
137 {
138 $r->MoveNext();
139 continue;
140 }
141 }
142 $monsters[]=$r->fields[0];
143 $nbmonsters++;
144 $r->MoveNext();
145 }
146 if($r !== false) $r->Close();
147 }
148
149 echo "<FORM METHOD=POST NAME=COMM ACTION=game.php>\n";
150 echo "<INPUT TYPE=HIDDEN NAME=ACTION>\n";
151 echo "<INPUT TYPE=HIDDEN NAME=X VALUE=$sx>\n";
152 echo "<INPUT TYPE=HIDDEN NAME=Y VALUE=$sy>\n";
153 echo "<INPUT TYPE=HIDDEN NAME=DX>\n";
154 echo "<INPUT TYPE=HIDDEN NAME=DY>\n";
155 echo "<INPUT TYPE=HIDDEN NAME=COMBAT>\n";
156 echo "<INPUT TYPE=HIDDEN NAME=LOC VALUE=".$uservals["LOCATION"].">\n";
157 echo "<INPUT TYPE=HIDDEN NAME=LEVEL VALUE=1>\n";
158 if(($uservals["RING1"]+0) == 8013 || ($uservals["RING2"]+0) == 8013)
159 echo "<INPUT TYPE=HIDDEN NAME=INVISIBILITY VALUE=-100>\n";
160 else
161 echo "<INPUT TYPE=HIDDEN NAME=INVISIBILITY VALUE=".$uservals["INVISIBILITY"].">\n";
162 echo "<INPUT TYPE=HIDDEN NAME=OWNER>\n";
163
164 if(($uservals["LOCATION"]+0) < 0)
165 $sql="SELECT ISMAPPABLE FROM PLAYER_MAP WHERE USERID=$userid AND LEVEL = ".(-$uservals["LOCATION"]);
166 else
167 $sql="SELECT ISMAPPABLE FROM MAPS WHERE ID = ".$uservals["LOCATION"];
168 $r=$db->Execute($sql);
169 $ismappable=$r->fields[0];
170 $r->Close();
171
172 // Div used to display the wait loading message
173 echo "<DIV id=WAIT_LOADING STYLE='position: absolute; visibility: visible; top: 80; left: 185; width:448; height:448' ALIGN=CENTER>";
174 echo "<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 BGCOLOR=#000000>";
175 echo "<TR><TH><B><FONT COLOR=#FFFFFF>Loading</FONT></B></TH></TR>\n";
176 echo "<TR><TD BGCOLOR=#E0E0E0 ALIGN=CENTER>";
177 echo "Please wait while we are loading the map...<BR>\n";
178 echo "<IMG SRC=images/progress_bar.gif WIDTH=194 HEIGHT=10><BR>\n";
179 echo "<DIV id=LOAD_INFO></DIV></TD></TR></TABLE>\n";
180 echo "</DIV>\n";
181
182 // Div used to show the background tiles
183 echo "<DIV id=BG_TILES STYLE='position: absolute; visibility: hidden; top: 80; left: 185; width:448; height:448'>";
184 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=448 HEIGHT=448>\n";
185 for($y=0;$y < 7;$y++)
186 {
187 echo "<TR HEIGHT=64>";
188 for($x=0;$x < 7;$x++)
189 echo "<TD WIDTH=64><IMG NAME=IMG_".$x."_".$y." class=SPR></TD>";
190 echo "</TR>";
191 }
192 echo "</TABLE></DIV>\n";
193
194 // Div used to display the objects
195 for($y=0;$y < 7;$y++)
196 for($x=0;$x < 7;$x++)
197 echo "<DIV id=OVER_OBJ_".$x."_".$y."><IMG NAME=OBJ_".$x."_".$y." class=SPR></DIV>";
198 echo "<DIV ID=DIALOG_DIV STYLE='position:absolute; left:0; top:0; width: 150; visibility: hidden; background-color: #FFFF99; border: 1px solid #FF9900; padding:3px;font-size: 10px;'></DIV>\n";
199
200 echo "<DIV STYLE='position: absolute; visibility: visible; top: 500; left: 200;'>";
201 echo "<A HREF=# OnClick='return link_to(\"QUICK1\");'><IMG SRC=images/quick_1.gif WIDTH=20 HEIGHT=20 BORDER=0></A>\n";
202 echo "<A HREF=# OnClick='return link_to(\"QUICK2\");'><IMG SRC=images/quick_2.gif WIDTH=20 HEIGHT=20 BORDER=0></A>\n";
203 echo "<A HREF=# OnClick='return link_to(\"QUICK3\");'><IMG SRC=images/quick_3.gif WIDTH=20 HEIGHT=20 BORDER=0></A>\n";
204 echo "<A HREF=# OnClick='return link_to(\"QUICK4\");'><IMG SRC=images/quick_4.gif WIDTH=20 HEIGHT=20 BORDER=0></A>\n";
205 echo "</DIV>\n";
206
207 echo "<DIV id=HELP class=help>";
208 if(($uservals["IMAGEQUALITY"]+0) >= 2 && $java == false)
209 echo "Temporary using Javascript<BR>\n";
210 if(($uservals["IMAGEQUALITY"]+0) >= 2 && $java == true)
211 echo "In order to navigate in the 2D map click on the map and use the following keys:<BR>";
212 else
213 echo "In order to nagivate in the 2D map use the following keys:<BR>";
214 echo "Up: (Key Up), (8), (w), (z)<BR>\n";
215 echo "Left: (Key Left), (4), (a), (q)<BR>\n";
216 echo "Right: (Key Right), (6), (d)<BR>\n";
217 echo "Down: (Key Down), (2), (x)<BR>\n";
218 if(($uservals["IMAGEQUALITY"]+0) >= 2 && $java == true)
219 echo "You may also use the mouse and the arrows on the bottom right of the map.";
220 else
221 echo "Or use the mouse and<BR>the small arrows on the right.";
222 echo "</DIV>\n";
223 // Add the small arrows
224 if(!(($uservals["IMAGEQUALITY"]+0) >= 2 && $java == true))
225 {
226 echo "<DIV ID=smallarrows STYLE='position: absolute; top:110; left: 773'>";
227 echo "<IMG SRC=images/small_arrows.gif width=73 height=69 border=0 usemap='#SMLARR'\n>";
228 echo "</DIV>\n";
229 echo "<map name='SMLARR'>\n";
230 echo " <area shape='rect' coords='24,0,47,30' href='Javascript:execKey(\"8\");'>\n";
231 echo " <area shape='rect' coords='23,40,47,69' href='Javascript:execKey(\"2\");'>\n";
232 echo " <area shape='rect' coords='0,21,24,47' href='Javascript:execKey(\"4\");'>\n";
233 echo " <area shape='rect' coords='46,21,73,47' href='Javascript:execKey(\"6\");'>\n";
234 echo "</map>\n";
235 }
236 echo "<DIV id=MESSAGES class=MESSAGES>";
237 echo "<B>Message window:</B><BR><BR>Wait... loading...<BR><BR>\n";
238 if(($uservals["IMAGEQUALITY"]+0) >= 2 && $java == true)
239 {
240 echo "If the Java engine does not show up, change to another image quality:<BR>\n";
241 echo "<A HREF=game.php?ACTION=ACCOUNT>Change quality</A>\n";
242 }
243 echo "</DIV>\n";
244
245 if($uservals["RING1"] == 8006 || $uservals["RING2"] == 8006 || $uservals["RING1"] == 8020 || $uservals["RING2"] == 8020)
246 {
247 echo "<DIV id=MINIMAP CLASS=MINIMAP>";
248 echo "<IMG SRC=locations_modules/2dmap/minimap.php?RAND=".time()." WIDTH=198 HEIGHT=198>";
249 echo "</DIV>\n";
250 if(($ismappable == 'N' || $ismappable == 'P') && $userid != 1)
251 echo "<DIV id=MINIMAPPOS CLASS=MINIMAPPOSNONE></DIV>\n";
252 else
253 echo "<DIV id=MINIMAPPOS CLASS=MINIMAPPOS><IMAGE SRC=images/spacer.gif WIDTH=2 HEIGHT=2></DIV>\n";
254 $showminimap="true";
255 }
256 else
257 $showminimap="false";
258 if($uservals["RING1"] == 8014 || $uservals["RING2"] == 8014 || $uservals["RING1"] == 8020 || $uservals["RING2"] == 8020)
259 {
260 echo "<DIV id=MINIMONSTERS CLASS=MINIMONSTERS></DIV>";
261 $showminimonsters="true";
262 }
263 else
264 $showminimonsters="false";
265
266 $s=stat("$basedir/locations_modules/2dmap/map_script.js");
267 echo "<SCRIPT SRC=store_cache.php?OBJ=locations_modules/2dmap/map_script.js&v=".$s["mtime"]."></SCRIPT>\n";
268
269 if($uservals["SUBLOC"]+0 > 0)
270 {
271 echo "<IFRAME ID=NPCDIALOG NAME=NPCDIALOG FRAMEBORDER=NO SRC=game.php?INMAP=TRUE&TALK=".urlencode(stripslashes($_GET["TALK"]))."&DIALOG=".$_GET["DIALOG"]." STYLE='position: absolute; visibility: visible; width: 400; height: 200; left: 0; top: 0;background-color: #E0E0E0; border: 1px solid #000000; padding:3px;font-size: 10px;'></IFRAME>";
272 echo "<SCRIPT>\n";
273 echo "document.getElementById('NPCDIALOG').style.top=339;\n";
274 echo "document.getElementById('NPCDIALOG').style.left=211;\n";
275 echo "inmapdialog=true;\n";
276 echo "</SCRIPT>\n";
277 }
278 else
279 echo "<IFRAME ID=NPCDIALOG NAME=NPCDIALOG FRAMEBORDER=NO SRC=empty.html STYLE='position: absolute; visibility: hidden; width: 400; height: 200; left: 0; top: 0;background-color: #E0E0E0; border: 1px solid #000000; padding:3px;font-size: 10px;'></IFRAME>";
280
281 echo "<SCRIPT>\n";
282 if($uservals["LOCATION"] > 0)
283 {
284 $r=$db->Execute("SELECT X,Y,DIALOG FROM MAP_DIALOG WHERE MAPID=".$uservals["LOCATION"]);
285 while(!$r->EOF)
286 {
287 echo "add_map_dialog(".$r->fields[0].",".$r->fields[1].",unescape('".rawurlencode($r->fields[2])."'));\n";
288 $r->MoveNext();
289 }
290 $r->Close();
291 }
292
293 echo "var hour='".str_pad(floor($hour), 2, "0", STR_PAD_LEFT).":".str_pad(floor(fmod($hour,1)*60), 2, "0", STR_PAD_LEFT)."';\n";
294 if(($uservals["LOCATION"]+0) == 39) // In jail ?
295 echo "var injail=true;\n";
296 else
297 echo "var injail=false;\n";
298
299 echo "// Initial values for the needed variables. Used later on by the Javascript map utilities.\n";
300 echo "var x=$sx;\n";
301 echo "var y=$sy;\n";
302 echo "var zoom=false;\n";
303 echo "var showminimap=$showminimap;\n";
304 echo "var showminimonsters=$showminimonsters;\n";
305 echo "var playerdir='s';\n";
306 echo "var loc='".$uservals["LOCATION"]."';\n";
307 if(($uservals['LOCATION']+0) < 0)
308 echo "var randommap=true;\n";
309 else
310 echo "var randommap=false;\n";
311
312 echo "var monsterid = new Array();\n";
313
314 for($i=0;$i < $nbmonsters;$i++)
315 echo "monsterid[$i]=".$monsters[$i].";\n";
316 echo "var nbmonsters=$nbmonsters;\n";
317
318 echo "var weapon=".$uservals["WEAPON"].";\n";
319 echo "var hp=".$uservals['HP'].";\n";
320 echo "var sickness=".$uservals['SICKNESS'].";\n";
321 echo "var nbsteps=0;\n";
322 echo "var userid=$userid;\n";
323 echo "var maxhp=".($uservals["HPMOD"]+$uservals['MAXHP']).";\n";
324 echo "var monsterstarted=false;\n";
325 echo "var disablemove=false;\n";
326 echo "var needtostore=true;\n";
327 echo "var needtostoremonsters=true;\n";
328 echo "var objwalk='$objwalk';\n";
329 echo "var bgwalk='$bgwalk';\n";
330 if(($uservals["RING1"]+0) == 8013 || ($uservals["RING2"]+0) == 8013)
331 echo "var invisible=-100;\n";
332 else
333 echo "var invisible=".$uservals["INVISIBILITY"].";\n";
334 if(inventory_check(4051) > 0 || inventory_check(4055) > 0)
335 echo "var boat=true;\n";
336 else
337 echo "var boat=false;\n";
338 if(inventory_check(4055) > 0)
339 echo "var boattype='i';\n";
340 else
341 echo "var boattype='';\n";
342 if(($uservals["RING1"]+0) == 8005 || ($uservals["RING2"]+0) == 8005)
343 echo "var repulse=true;\n";
344 else
345 echo "var repulse=false;\n";
346 echo "var timeID=0;\n";
347 echo "preload_images();\n";
348 echo "</SCRIPT>\n";
349 echo "</DIV>\n";
350 ?>



FUNC_DATA={
'execkey': ['execkey', '', [['locations_modules/2dmap','map_script.js',989]], 5],
'add_map_dialog': ['add_map_dialog', '', [['locations_modules/2dmap','map_script.js',23]], 1],
'start_combat': ['start_combat', '', [['combat','combats_util.php',721]], 3],
'movenext': ['movenext', '', [['libs','db_conn_5.php',89],['libs','db_conn_4.php',89]], 104],
'store_pos': ['store_pos', '', [['locations_modules/2dmap','map_script.js',1094]], 1],
'close': ['close', '', [['libs','db_conn_5.php',35],['libs','db_conn_5.php',87],['libs','db_conn_4.php',35],['libs','db_conn_4.php',87]], 380],
'retreive_loc': ['retreive_loc', 'retreives the current player location and returns it in the global variables sx,sy; ', [['libs','map_util.php',190]], 2],
'inventory_check': ['inventory_check', 'Checks if the player have this item. ', [['libs','objects_util.php',425]], 44],
'execute': ['execute', '', [['libs','db_conn_5.php',37],['libs','db_conn_4.php',37]], 652],
'preload_images': ['preload_images', '', [['locations_modules/2dmap','loadmap.php',412]], 2],
'link_to': ['link_to', '', [['locations_modules/2dmap','map_script.js',1246]], 4],
'urlencode': ['urlencode', '', [], 34],
'stripslashes': ['stripslashes', '', [], 67],
'floor': ['floor', '', [], 45],
'mt_rand': ['mt_rand', '', [], 102],
'fmod': ['fmod', '', [], 1],
'strftime': ['strftime', '', [], 5],
'count': ['count', '', [], 113],
'rawurlencode': ['rawurlencode', '', [], 14],
'abs': ['abs', '', [], 17],
'time': ['time', '', [], 16],
'file_exists': ['file_exists', '', [], 48],
'str_pad': ['str_pad', '', [], 11],
'gmstrftime': ['gmstrftime', '', [], 3],
'header': ['header', '', [], 59]};
CLASS_DATA={
};
CONST_DATA={
};

titleDescriptionBody
titleDescriptionBody
titleDescriptionBody
titleBody



Generated: Sun Jul 8 18:11:25 2007
Cross-referenced by PHPXref 0.7





Wyszukiwarka