Page 1 of 2

Attacking mob on map

Posted: Tue Dec 22, 2009 8:10 pm
by GrInd3r
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?

Re: Attacking mob on map

Posted: Tue Dec 22, 2009 8:16 pm
by hallsofvallhalla
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

Re: Attacking mob on map

Posted: Tue Dec 22, 2009 8:18 pm
by GrInd3r
I was thinking this

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");
but im thinking that could possible work so would I have to do a if statement

Code: Select all

if($updatecreature['crhp'] == 0){
then update
}
else
{
echo "....";
}

Re: Attacking mob on map

Posted: Tue Dec 22, 2009 8:29 pm
by GrInd3r
right but wont that delete the whole row??

I just want to update the crname and crhp to say blank or 0

Re: Attacking mob on map

Posted: Tue Dec 22, 2009 8:46 pm
by hallsofvallhalla
ah yes then thats fine. I thought you were doing it differently.

Re: Attacking mob on map

Posted: Tue Dec 22, 2009 11:54 pm
by GrInd3r

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() ."");
}
I set the session in the auth page for the mapr & mapc. but it dosnt seem to work and dosnt want to update that the creature info in the map database crname and crhp. :(

Re: Attacking mob on map

Posted: Wed Dec 23, 2009 12:14 am
by hallsofvallhalla
these are wrong

Code: Select all

mapr='". $_SESSION['mapr'] ."'
should be

Code: Select all

mapr='$_SESSION['mapr']'
might want to add some value here, like none or 0's

Code: Select all

crname='', crhp=''

Re: Attacking mob on map

Posted: Wed Dec 23, 2009 1:37 am
by GrInd3r
well you can use

Code: Select all

echo "". $var=[var] ."";
its the same just highlights the code.

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

Posted: Wed Dec 23, 2009 3:32 am
by GrInd3r
this damn thing just wont update....

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() ."");
}
I also added this into my map.php

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
    {
	 
    }
    ?>

Re: Attacking mob on map

Posted: Wed Dec 23, 2009 2:31 pm
by hallsofvallhalla

Code: Select all

mapr='". $_SESSION['mapr'] ."'
it doesn't make any sense why you would do it that way, its more confusion and more typing and your quotes cannot be right, you may need to escape the single quote out. This may not be your error but I just don't see the use behind it.