moprpg/actions.php

238 lines
5.0 KiB
PHP
Raw Normal View History

2017-10-22 18:15:11 -07:00
<?php
include("gui.php");
include("config.php");
include("walkable.php");
include("battlezones.php");
$update=false;
$credsYo=$_COOKIE['mrpg-ethbnd'];
$credsYo=explode("@seperator@", $credsYo);
$u=strtolower($credsYo[0]);
$p=strtolower($credsYo[1]);
2017-10-22 20:39:20 -07:00
if($u=="") {
header("Location: index.php?login");
2017-10-22 18:15:11 -07:00
}
$result = mysql_query("SELECT * FROM mrpg_users WHERE name='$u'");
2017-10-22 20:39:20 -07:00
while($row = mysql_fetch_array($result)) {
if($row['password']!=$p) {
header("Location: index.php");
exit;
2017-10-22 18:15:11 -07:00
}
}
$sql="UPDATE mrpg_users SET lastact='" . date("U") . "' WHERE name='$u'";
$result = mysql_query($sql);
$sql="SELECT * FROM mrpg_users WHERE name='$u'";
$result = mysql_query($sql);
2017-10-22 20:39:20 -07:00
while($row = mysql_fetch_array($result)) {
$char['id']=$row['id'];
$char['x']=$row['x'];
$char['y']=$row['y'];
$char['mode']=$row['mode'];
2017-10-22 18:15:11 -07:00
}
if($char['mode']=="battle") {
2017-10-22 20:39:20 -07:00
if($_SERVER['QUERY_STRING']=="stats") {
header("Location: stat.php?x=" . $u . "&y=" . md5($p));
exit;
}
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
header("Location: battle.php");
exit;
2017-10-22 18:15:11 -07:00
} else if($char['mode']=="lvlup") {
2017-10-22 20:39:20 -07:00
header("Location: lvlup.php");
exit;
2017-10-22 18:15:11 -07:00
} else if($char['mode']=="confirm") {
2017-10-22 20:39:20 -07:00
header("Location: confirm.php");
exit;
2017-10-22 18:15:11 -07:00
} else if($char['mode']=="message") {
2017-10-22 20:39:20 -07:00
header("Location: message.php");
exit;
2017-10-22 18:15:11 -07:00
}
if($_SERVER['QUERY_STRING']!="") {
$update=true;
switch($_SERVER['QUERY_STRING']) {
2017-10-22 20:39:20 -07:00
2017-10-22 18:15:11 -07:00
case "up":
$char['x']=$char['x'];
$char['y']=$char['y']-1;
$sql="UPDATE mrpg_users SET dir='1' WHERE name='$u'";
$result = mysql_query($sql);
break;
case "down":
$char['x']=$char['x'];
$char['y']=$char['y']+1;
$sql="UPDATE mrpg_users SET dir='4' WHERE name='$u'";
$result = mysql_query($sql);
break;
case "right":
$char['x']=$char['x']+1;
$char['y']=$char['y'];
$sql="UPDATE mrpg_users SET dir='3' WHERE name='$u'";
$result = mysql_query($sql);
break;
case "left":
$char['x']=$char['x']-1;
$char['y']=$char['y'];
$sql="UPDATE mrpg_users SET dir='2' WHERE name='$u'";
$result = mysql_query($sql);
break;
2017-10-22 20:39:20 -07:00
case "stats":
2017-10-22 18:15:11 -07:00
header("Location: stat.php?x=" . $u . "&y=" . md5($p));
exit;
break;
}
}
if($_GET['que']!="") {
$update=true;
$que=$_GET['que'];
$que=explode(",", $que);
if($que[10]!="") {
fallback();
}
2017-10-22 20:39:20 -07:00
foreach($que as $value) {
walkByNumArray($value);
if(!(walkable($char['x'], $char['y']))) {
fallback();
}
}
2017-10-22 18:15:11 -07:00
}
/* TELES */
2017-10-22 20:39:20 -07:00
if($char['x']==19 && $char['y']==7) {
$char['x']=10; $char['y']=60;
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
//Lol heal
mysql_query("UPDATE mrpg_stat SET hp=maxhp WHERE id=" . $char['id'] . ";");
2017-10-22 18:15:11 -07:00
} //Tele into tut area
2017-10-22 20:39:20 -07:00
else if($char['x']==11 && $char['y']==59) {
$char['x']=19; $char['y']=8;
} //Tele out of tut area, to noobland
else if($char['x']==56 && $char['y']==10) {
$char['x']=6; $char['y']=58;
mysql_query("UPDATE mrpg_stat SET hp=maxhp WHERE id=" . $char['id'] . ";");
} //Out of canyon. + heal.
2017-10-22 18:15:11 -07:00
/* Misc stuff, like confirmations & messages */
if($char['x']==6 && $char['y']==56) {
2017-10-22 20:39:20 -07:00
$char['x']=6;
$char['y']=57;
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
mysql_query("UPDATE mrpg_users SET mode='confirm' WHERE id=" . $char['id'] . ";");
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
mysql_query("UPDATE mrpg_confirm SET q='The area you are about to enter is very dangerous for low-levels, and also leads to the first City. Level 10+ Reccommended. Once you exit it, you will never be able to return here. Do you want to continue?', yesx=56, yesy=11, nox=6, noy=57 WHERE id=" . $char['id'] . ";");
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
header("Location: confirm.php");
exit;
2017-10-22 18:15:11 -07:00
} else if($char['x']==97 && $char['y']==13) {
2017-10-22 20:39:20 -07:00
mysql_query("UPDATE mrpg_users SET mode='message' WHERE id=" . $char['id'] . ";");
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
mysql_query("UPDATE mrpg_message SET q='<h4>Chapter I:<br><br>Coming soon! :)<h4>', x=96, y=13 WHERE id=" . $char['id'] . ";");
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
header("Location: message.php");
exit;
2017-10-22 18:15:11 -07:00
}
if($update==true && walkable($char['x'], $char['y'])) {
2017-10-22 20:39:20 -07:00
$tx=$char['x'];
$ty=$char['y'];
$sql="UPDATE mrpg_users SET x='$tx', y='$ty' WHERE name='$u'";
$result = mysql_query($sql);
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
///////////BATTLE CHECK////////////
$bzone=checkbzone($tx, $ty, 0);
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
$battle=$bzone[rand(0,(count($bzone)-1))];
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
if($battle!=0) {
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
$sql="UPDATE mrpg_users SET mode='battle' WHERE name='$u'";
$result = mysql_query($sql);
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
$result = mysql_query("SELECT * FROM mrpg_monsters WHERE id='$battle'");
while($row = mysql_fetch_array($result))
{
$battlehp=$row['hp'];
}
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
$sql="UPDATE `mrpg_battles` SET `use` = '1', `enemy` = '$battle', `enemyhp` = '$battlehp' WHERE `id` =" . $char['id'] . ";";
$result = mysql_query($sql);
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
//echo "<font color='white'>BATTLE! <br> $sql";
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
header("Location: battle.php?appear=yes");
exit;
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
}
//////////END BATTLE CHECK//////////
2017-10-22 18:15:11 -07:00
2017-10-22 20:39:20 -07:00
fallback();
2017-10-22 18:15:11 -07:00
}
function walkByNumArray($num) {
2017-10-22 20:39:20 -07:00
global $char;
if($num==1) {
$char['x']=$char['x'];
$char['y'] =$char['y']-1;
} else if($num==2) {
$char['x']=$char['x']-1;
$char['y'] =$char['y'];
} else if($num==3) {
$char['x']=$char['x']+1;
$char['y'] =$char['y'];
} else if($num==4) {
$char['x']=$char['x'];
$char['y'] =$char['y']+1;
}
2017-10-22 18:15:11 -07:00
}
function fallback() {
2017-10-22 20:39:20 -07:00
global $u, $p;
header('Location: showim.php?x=' . $u . '&y=' . md5($p));
exit;
2017-10-22 18:15:11 -07:00
}
fallback();
2017-10-22 20:39:20 -07:00
?>