Jump to content

Randomizing Encounters & Data Delivery Help please.


Gheeda

Recommended Posts

I'm currently working on a browser based mmorpg. First things first, here is an example of my battle.php

 

<?php
include_once 'connect.php';
session_start();

include_once 'logo.php';
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<div id="login2" div align="center">


<?php




if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
?>
</div>
<?php
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);

include_once 'statpanel.php';

$pid = $playerinfo3['id'];
$name = $playerinfo3['name'];
$playerhp = $playerinfo3['hpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];

if ($playerhp < 1)
{
  echo "You are dead!" ;
  echo "<br><a href='inn.php>Heal at the lake";
  exit;
}
?>
<div id="table">

<?php

if (isset($_GET['randid']))
{
   $randid=$_GET['randid'];
   $iteminfo="SELECT * from inventory where randid='$randid' AND id ='$pid'";
$iteminfo2=mysql_query($iteminfo) or die("could not get item stats!");
$iteminfo3=mysql_fetch_array($iteminfo2);

if (!$iteminfo3['name'])
{
}
else
{

$iname = $iteminfo3['name'];
$stats = $iteminfo3['stats'];
$statadd = $iteminfo3['statadd'];
$type = $iteminfo3['type'];

if ($type == "healing")
{
   $newhp = $statadd + $playerhp;
   if ($newhp > $playerinfo3['maxhp'])
   {
    $newhp = $playerinfo3['maxhp'];
   }
    $updateplayer="update players set hpoints='$newhp' where id='$pid'";
  mysql_query($updateplayer) or die("Could not update player");

    $updateitem="DELETE from inventory where id='$pid' AND randid='$randid' limit 1";
  mysql_query($updateitem) or die("Could not delete item");
   
   $playerhp = $newhp;

  echo "Used " . $iname . " and recovered " . $statadd . ".<br>";
}

}}





$creature = $playerinfo3['creature'];
if ($creature != 0)
{
$creatureinfo="SELECT * from creatures where id='$creature'";
$creatureinfo2=mysql_query($creatureinfo) or die("could not get the creature you were fighting!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);

}
else
{
  $creatureinfo="SELECT * from creatures order by rand() limit 1";
$creatureinfo2=mysql_query($creatureinfo) or die("could get a creature!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
$cid = $creatureinfo3['id'];
$updateplayer="update players set creature='$cid' where name='$name'";
  mysql_query($updateplayer) or die("Could not update player");
}

$creature = $creatureinfo3['name'];
$creaturehp = $creatureinfo3['hpoints'];
$creatureattack = $creatureinfo3['attack'];
$creaturedefense = $creatureinfo3['defense'];



?>
</div>
<div id="player">
<?php
/////player info
echo "<u> " . $playerinfo3['name'] . "</u><br>";
echo "Hit points = " . $playerhp . "<br>";
echo "Attack = " . $playerattack . "<br>";
echo "Defense = " . $playerdefense . "<br><br><br>";
?>
</div>
<div id="creature">
<img src="images/<?php echo $creatureinfo3['imgurl'];?>" <br>
<?php
///////creature info

echo "<u> " . $creatureinfo3['name'] . "</u><br>";
echo "Hit points = " . $creaturehp . "<br>";
echo "Attack = " . $creatureattack . "<br>";
echo "Defense = " . $creaturedefense . "<br><br><br>";
?>
</div>

<div id="options">
<?php
echo "<a href='attack.php'>Attack</a>";
echo "<br><a href='usemagic.php'>Use Magic</a>";
echo "<br><a href='useitem.php'>Use Item</a>";
echo "<br><a href='index.php'>Exit Arena</a>";


?>
</div>

<div id="logout">
<?php
echo "<br><a href='logout.php'><img src='images/logout.gif'>";
?>
</div>

 

 

Particular functions I'm interested in for zone creation.

 

-Pay to get in & have the initial icon switch to a now usable adventure zone. (done)

 

-When 'adventuring' in this link. Battle php randomizes encounters between 'combat encounters' and 'non-combat' encounters.  (can't get this right, and removed my utter failures from the code above as to not clutter it. Pulls randomly from the Creature DB just fine but when I try to add in the 2nd,non-combat,db..it pulls nothing.)

 

-NonCombat encounters dish our reward. (currently my non combats do not give reward. Unlike a standard creature encounter where a players gold and exper get updated on a victory...I dont know how to immediately trigger the change on encounter & I'm epically unsure how to craft the $updateplayer= to be so broad as to include all possibilities of improvement but only to utilize the one being called upon in the encounter)

 

-I'm also interested in updating my battle.php to include a dropdown list of usable spells/items instead of the current method of Attacking/going back/selecting magic or items/going back/...repeat. It works, sure, but its nasty..Any ideas on how to call on the database for user specific data to fill in a drop down menu?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.