Attacking mob on map

Location of the Videos
GrInd3r
Posts: 66
Joined: Mon Jul 13, 2009 10:34 pm

Attacking mob on map

Post 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?
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Attacking mob on map

Post 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
GrInd3r
Posts: 66
Joined: Mon Jul 13, 2009 10:34 pm

Re: Attacking mob on map

Post 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 "....";
}
GrInd3r
Posts: 66
Joined: Mon Jul 13, 2009 10:34 pm

Re: Attacking mob on map

Post by GrInd3r »

right but wont that delete the whole row??

I just want to update the crname and crhp to say blank or 0
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Attacking mob on map

Post by hallsofvallhalla »

ah yes then thats fine. I thought you were doing it differently.
GrInd3r
Posts: 66
Joined: Mon Jul 13, 2009 10:34 pm

Re: Attacking mob on map

Post 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. :(
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Attacking mob on map

Post 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=''
GrInd3r
Posts: 66
Joined: Mon Jul 13, 2009 10:34 pm

Re: Attacking mob on map

Post 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>";
		}
		?>
GrInd3r
Posts: 66
Joined: Mon Jul 13, 2009 10:34 pm

Re: Attacking mob on map

Post 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
    {
	 
    }
    ?>
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Attacking mob on map

Post 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.
Post Reply

Return to “Older Browser MMO Videos”