Attacking mob on map
Attacking mob on map
Ok so I made it so that battle arena no longer exist and its mob's on the map instead.. I am trying to figure out is
if the mob is attacked then killed it should be erased and re spawned some where else.. how will I go about doing this in the attack.php page?
if the mob is attacked then killed it should be erased and re spawned some where else.. how will I go about doing this in the attack.php page?
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Attacking mob on map
so you still have the grid based map right?
so when the creatures hp < 0 delete from DB
select creature from creatures table by rand limit 1
$row = rand (1,40) <--- depends on how big your map is
$column = rand(1,40)
then insert into map creature= creature where row=$row and column=$column
so when the creatures hp < 0 delete from DB
select creature from creatures table by rand limit 1
$row = rand (1,40) <--- depends on how big your map is
$column = rand(1,40)
then insert into map creature= creature where row=$row and column=$column
Re: Attacking mob on map
I was thinking this
but im thinking that could possible work so would I have to do a if statement
Code: Select all
$crmaxhp=$creatureinfo3['maxhpoints'];
$updatecreature="UPDATE map SET crhp=0 WHERE mapr='$mapinfo3[mapr]' AND mapc='$mapinfo3[mapc]' limit 1";
mysql_query($updatecreature) or die("Could not update creature");
Code: Select all
if($updatecreature['crhp'] == 0){
then update
}
else
{
echo "....";
}
Re: Attacking mob on map
right but wont that delete the whole row??
I just want to update the crname and crhp to say blank or 0
I just want to update the crname and crhp to say blank or 0
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Attacking mob on map
ah yes then thats fine. I thought you were doing it differently.
Re: Attacking mob on map
Code: Select all
////////////////////////Creature is dead delete then re add to database
$mapcrsql="SELECT * FROM map WHERE mapr='". $_SESSION['mapr'] ."' AND mapc='". $_SESSION['mapc'] ."' LIMIT 1";
$mapcr_result=mysql_query($mapcrsql) or die("<br>Could not get creature information from the map");
$mapcr_row=mysql_fetch_array($mapcr_result);
if($mapcr_row['crhp'] == 0)
{
$mapcrupdate="UPDATE map SET crname='', crhp='' WHERE mapr='". $_SESSION['mapr'] ."' AND mapc='". $_SESSION['mapc'] ."' LIMIT 1";
$mapcrupdate_result=mysql_query($mapcrupdate) or die("<br>ERROR: ". mysql_error() ."");
}

- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Attacking mob on map
these are wrong
should be
might want to add some value here, like none or 0's
Code: Select all
mapr='". $_SESSION['mapr'] ."'
Code: Select all
mapr='$_SESSION['mapr']'
Code: Select all
crname='', crhp=''
Re: Attacking mob on map
well you can use
its the same just highlights the code.
like this awesomely cool sql join from a old game
Code: Select all
echo "". $var=[var] ."";
like this awesomely cool sql join from a old game
Code: Select all
<?php
$sql5="SELECT mitem.sid, mitem.name, mitem.type, muser.username, muser.slot1 FROM mitem inner join muser on mitem.sid = muser.slot1 WHERE muser.username='". $_SESSION['myusername'] ."'";
$result5 = mysql_query($sql5);
while ($rows5 = mysql_fetch_array($result5)){
echo "<a href=use.php?item=". $rows2['sid'] .">". $rows2['name'] ."</a>";
}
?>
Re: Attacking mob on map
this damn thing just wont update....
I also added this into my map.php
Code: Select all
////////////////////////Creature is dead delete then re add to database
$mapcrsql="SELECT * FROM map WHERE mapr='". $_SESSION['mapr'] ."' AND mapc='". $_SESSION['mapc'] ."' LIMIT 1";
$mapcr_result=mysql_query($mapcrsql) or die("<br>Could not get creature information from the map");
$mapcr_row=mysql_fetch_array($mapcr_result);
if($newcreaturehp < 1)
{
$mapcrupdate="UPDATE map SET crname='', crhp='0' WHERE mapr='$_SESSION[mapr]' AND mapc='$_SESSION[mapc]' LIMIT 1";
$mapcrupdate_result=mysql_query($mapcrupdate) or die("<br>ERROR: ". mysql_error() ."");
}
Code: Select all
<?php
if($mapinfo3[crhp] < 1)
{
echo "";
}
if ($mapinfo3[crname] != "")
{
echo "<center><big><big>There is a " . $crinfo3[name] . " in the area. You must kill it before you can harvest here.</big></big></center>";
echo "<center><br><big><big><a href='attack.php?creature=". $mapinfo3[crname] ."'>Attack it</big></big></a><br>";
exit;
}
else
{
}
?>
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Attacking mob on map
Code: Select all
mapr='". $_SESSION['mapr'] ."'