it not showing the person(you) that attacks but shows the person you attack like outwar lets say you want to attack someone its shows the person that you are attacking and your nameit not showing the person(you) that attacks but shows the person you attack like outwar lets say you want to attack someone its shows the person that you are attacking and your name
<?php $title = "Battle Arena"; include("header.php"); ?>
<?
global $stat;
global $enemy;
global $myarm;
global $mywep;
global $earm;
global $ewep;
?>
<?php
function attack() {
global $stat;
global $enemy;
global $myarm;
global $mywep;
global $earm;
global $ewep;
$repeat = ($stat[agility] / $enemy[agility]);
$attackstr = ceil($repeat);
if ($attackstr <= 0) {
$attackstr = 1;
}
$mypower = ($mywep[power] + $stat[strength]);
$epower = ($enemy[strength] + $earm[power]);
$attackdmg = ($mypower - $epower);
if ($attackdmg <= 0) {
$attackdmg = 1;
}
$round = 1;
while ($round <= $attackstr && $enemy[hp] >= 0) {
$enemy[hp] = ($enemy[hp] - $attackdmg);
print "<b>$stat[name]</b> attacks <b>$enemy[name]</b> for <b>$attackdmg</b> damage! ($enemy[hp] left)<br>";
$round = ($round + 1);
}
if ($enemy[hp] <= 0) {
$enemy[hp] = 0;
print "<br><b>$stat[name]</b> is the winner!<br>";
$expgain = (rand(5,10) * $enemy[level]);
$cashgain = ($enemy[cash] / 10);
print "<b>$stat[name]</b> have gained <b>$expgain</b> EXP and <b>$cashgain</b> cash.<br>";
mysql_query("update crew set hp=$stat[hp] where crewid=$stat[crewid]");
mysql_query("update crew set hp=0 where crewid=$enemy[crewid]");
mysql_query("update crew set exp=exp+$expgain where crewid=$stat[crewid]");
mysql_query("update crew set cash=cash+$cashgain where crewid=$stat[crewid]");
mysql_query("update crew set wins=wins+1 where crewid=$stat[crewid]");
mysql_query("update crew set losses=losses+1 where crewid=$enemy[crewid]");
mysql_query("update crew set lastkilled='$enemy[name]' where crewid=$stat[crewid]");
mysql_query("update crew set lastkilledby='$stat[name]' where crewid=$enemy[crewid]");
$texp = ($stat[exp] + $expgain);
$expn = (($stat[level] * 50) + ($stat[level] * 15));
if ($texp >= $expn) {
print "<b>$stat[name]</b> gained a level! +3 AP and +1 Level.";
mysql_query("update crew set ap=ap+3 where crewid=$stat[crewid]");
mysql_query("update crew set level=level+1 where crewid=$stat[crewid]");
mysql_query("update crew set exp=0 where crewid=$stat[crewid]");
mysql_query("insert into log (owner, log) values($stat[crewid],'During a fight with <b>$enemy[name]</b>, you gained a level.')");
}
mysql_query("insert into log (owner, log) values($stat[crewid],'You have defeated <b>$enemy[name]</b>. Gained <b>$expgain</b> EXP and <b>$cashgain</b> dollars.')");
mysql_query("insert into log (owner, log) values($enemy[crewid],'You were defeated by <b>$stat[name]</b>.')");
include("footer.php");
exit;
} else {
attackback();
}
}
function attackback() {
global $stat;
global $enemy;
global $myarm;
global $mywep;
global $earm;
global $ewep;
$repeat = ($enemy[agility] / $stat[agility]);
$attackstr = ceil($repeat);
if ($attackstr <= 0) {
$attackstr = 1;
}
$mypower = ($mywep[power] + $stat[strength]);
$epower = ($enemy[strength] + $earm[power]);
$attackdmg = ($epower - $mypower);
if ($attackdmg <= 0) {
$attackdmg = 1;
}
$round = 1;
while ($round <= $attackstr && $stat[hp] >= 0) {
$stat[hp] = ($stat[hp] - $attackdmg);
print "<b>$enemy[name]</b> attacks <b>$stat[name]</b> for <b>$attackdmg</b> damage! ($stat[hp] left)<br>";
$round = ($round + 1);
}
if ($stat[hp] <= 0) {
print "<br><b>$enemy[name]</b> is the winner!<br>";
$expgain = (rand(5,10) * $stat[level]);
$cashgain = ($enemy[cash] / 10);
print "<b>$enemy[name]</b> have gained <b>$expgain</b> EXP and <b>$cashgain</b> cash.<br>";
mysql_query("update crew set hp=$enemy[hp] where crewid=$enemy[crewid]");
mysql_query("update crew set hp=0 where crewid=$stat[crewid]");
mysql_query("update crew set exp=exp+$expgain where crewid=$enemy[crewid]");
mysql_query("update crew set cash=cash+$cashgain where crewid=$enemy[crewid]");
mysql_query("update crew set wins=wins+1 where crewid=$enemy[crewid]");
mysql_query("update crew set losses=losses+1 where crewid=$stat[crewid]");
mysql_query("update crew set lastkilled='$stat[name]' where crewid=$enemy[crewid]");
mysql_query("update crew set lastkilledby='$enemy[name]' where crewid=$stat[crewid]");
$texp = ($enemy[exp] + $expgain);
$expn = (($enemy[level] * 50) + ($enemy[level] * 15));
if ($texp >= $expn) {
print "<b>$enemy[name]</b> gained a level! +3 AP and +1 Level.";
mysql_query("update crew set ap=ap+3 where crewid=$enemy[crewid]");
mysql_query("update crew set level=level+1 where crewid=$enemy[crewid]");
mysql_query("update crew set exp=0 where crewid=$enemy[crewid]");
mysql_query("insert into log (owner, log) values($enemy[crewid],'During a fight with <b>$stat[name]</b>, you gained a level.')");
}
mysql_query("insert into log (owner, log) values($enemy[crewid],'You have defeated <b>$stat[name]</b>. Gained <b>$expgain</b> EXP and <b>$cashgain</b> dollars.')");
mysql_query("insert into log (owner, log) values($stat[crewid],'You were defeated by <b>$enemy[name]</b>.')");
include("footer.php");
exit;
} else {
attack();
}
}
?>
<?php
if (!$action && !$battle) {
print "Welcome to the battle arena.<br><br>
- <a href=crewattack.php?action=levellist>List by level</a>.<br>
- <a href=crewattack.php?action=showalive>Show alive players</a>.<br>";
}
if ($action == showalive) {
print "Showing all alive at level $stat[level]...<br><br>";
print "<table><tr><td width=30><b><u>ID</td><td width=100><b><u>Name</td><td width=100><b><u>Rank</td><td width=70><b><u>Options</td></tr>";
$esel = mysql_query("select * from crew where level=$stat[level] and hp>0 limit 50");
while ($elist = mysql_fetch_array($esel)) {
print "<tr><td>$elist[crewid]</td><td><a href=view2.php?view=$elist[crewid]>$elist[name]</a><td>$elist[rank]</td></td><td>- <A href=crewattack.php?battle=$elist[crewid]>Attack</a></td></tr>";
}
print "</table><br>";
print "Or you can always... <a href=crewattack.php>go back</a>.";
}
if ($action == levellist) {
print "<form method=post action=crewattack.php?action=levellist&step=go>";
print "Show me all alive at... <select name=slevel>";
for ($i = 1; $i < 100; ++$i) {
print "<option value=$i>Level $i</option>";
}
print "</select> <input type=submit value=Go></form>";
if ($step == go) {
print "<table><tr><td width=30><b><u>ID</td><td width=100><b><u>Name</td><td width=100><b><u>Rank</td><td width=70><b><u>Options</td></tr>";
$esel = mysql_query("select * from crew where level=$slevel and hp>0 limit 50");
while ($elist = mysql_fetch_array($esel)) {
print "<tr><td>$elist[crewid]</td><td><a href=view2.php?view=$elist[crewid]>$elist[name]</a></td><td>$elist[rank]</td><td>- <A href=crewattack.php?battle=$elist[crewid]>Attack</a></td></tr>";
}
print "</table><br>";
print "Or you can always... <a href=crewattack.php>go back</a>.";
}
}
if ($battle) {
global $stat;
global $enemy;
global $myarm;
global $mywep;
global $earm;
global $ewep;
$enemy = mysql_fetch_array(mysql_query("select * from crew where crewid=$battle"));
$mywep = mysql_fetch_array(mysql_query("select * from crewguns where owner=$stat[crewid] and type='W' and status='S'"));
$myarm = mysql_fetch_array(mysql_query("select * from crewguns where owner=$stat[crewid] and type='A' and status='S'"));
$ewep = mysql_fetch_array(mysql_query("select * from crewguns where owner=$enemy[crewid] and type='W' and status='S'"));
$earm = mysql_fetch_array(mysql_query("select * from crewguns where owner=$enemy[crewid] and type='A' and status='S'"));
if (!$enemy[crewid]) {
print "No such player.";
include("footer.php");
exit;
}
if ($enemy[crewid] == $stat[crewid]) {
print "You cannot attack yourself.";
include("footer.php");
exit;
}
if ($enemy[hp] <= 0) {
print "$enemy[name] is already dead.";
include("footer.php");
exit;
}
if ($stat[energy] < 1) {
print "You do not have enough energy.";
include("footer.php");
exit;
}
if ($stat[hp] <= 0) {
print "You're dead.";
include("footer.php");
exit;
}
print "<b><u>$stat[name] vs. $enemy[name]</b></u><br>";
mysql_query("update crew set energy=energy-1 where crewid=$stat[crewid]");
if ($stat[agility] >= $enemy[agility]) {
attack();
} else {
attackback();
}
}
?>
<?php include("footer.php"); ?>