Jump to content

PVP Battle Arena


Ads

Recommended Posts

Sorry xD

 

I am making a PVP battle Arena, And I have already made my own But it Sucks bad, I have googled it a bit and come up with nothing of Much Help. So i was wondering if anyone where had any advice for when(if) i build another one. Or if there are any Good Tutorials out there.

Link to comment
https://forums.phpfreaks.com/topic/93668-pvp-battle-arena/#findComment-479892
Share on other sites

Well that's great.

 

However in order for use to improve your battle arena programming we need to see what it's doing (i.e the code).

What you want it to do.

And also, what your database structure is.

 

If google doesn't turn much up I doubt there's a whole lot out there for "programming player versus player situations".

 

Thus, use your intuition, write out what you want it to do, and analyse what is currently available.

Link to comment
https://forums.phpfreaks.com/topic/93668-pvp-battle-arena/#findComment-479897
Share on other sites

Perhaps just write out what you're doing in a summary.

i.e.

1) Person 1 enters arena and chooses character

2) Person 2 enters arena and chooses character (both require DB calls)

3) Each person chooses weapons (DB call, info held in Session)

4) Round 1 begins

5) Process x,y,z happens during battle

6) Round 2,3,4...

 

That at least will give us an overview of what you're doing.

 

Nothing wrong with posting a couple of hundred lines of code.

Maybe take out the unimportant bits. (i.e. function getStrength() {return 5;})

Give us the juicy bits, like your database calls, your recursive functions, information pertaining to your storage method, large arrays, etc.

Maybe just put a timer and the top and bottom of your script and output the time took to process the script, as perhaps it's running well but the server isn't sending the page back quickly enough?

Link to comment
https://forums.phpfreaks.com/topic/93668-pvp-battle-arena/#findComment-479906
Share on other sites

What I tried to get to do is. Player 1 Clicks on a Link which Enter a Simple Text based Arena with player 2. And then it call all there stats(Health, Str,spd,agl,acc)[just Examples] and Passes them through some Algorithms To bring out a Result. Critcal and Counter inculded.

Link to comment
https://forums.phpfreaks.com/topic/93668-pvp-battle-arena/#findComment-479910
Share on other sites

<?php
include "include/db.php";
$ID=$_GET['ID'];
$oppstats3=mysql_fetch_array($oppplayerstats=mysql_query("SELECT * FROM players WHERE id='$ID'"));
$oppstats1=mysql_query("SELECT * from mechs where playersid='$ID'");
$oppstats=mysql_fetch_array($oppstats1);
//Oppenetns mech Stats
$oppmechname=$oppstats['mechname'];
$oppcharge=$oppstats['charge'];
$oppdex=$oppstats['dexterity'];
$opppow=$oppstats['power'];
$oppdef=$oppstats['defence'];
$oppweaponpow=$oppstats['weaponpower'];
//Oppenets Player stats
$oppref=$oppstats3['reflex'];
$opptac=$oppstats3['tactics'];
$oppluck=$oppstats3['luck'];
//Your mech stats
$mechname=$MECH['mechname'];
$charge=$MECH['charge'];
$dex=$MECH['dexterity'];
$pow=$MECH['power'];
$def=$MECH['defence'];
$weaponpow=$MECH['weaponpower'];
//Your Player stats
$ref=$row['reflex'];
$tac=$row['tactics'];
$luck=$row['luck'];
//******************************BATTLE CODE ******************************
while($oppcharge>0 && $charge>0){ //while Mechs are still alive
if($oppdex>=$dex) //Openets Speed is Greater than or Equal to Your speed
{
	if($oppcharge>0)
	{
		$randmultiplier = rand(0,10);
		$attackturns = 1000;

		while($attackturns>=10)
		{
			$oppdodge = ($oppref*rand(1,5))-$dex;
			$dodge = ($ref*rand(1,5))-$oppdex;
			$attackturns = $attackturns -$oppdex-$dex;
			if($dodge>$oppdodge) //Dodgeing
			{
				echo "<font color='blue'>".$mechname. " dodged " .$oppmechname. "</font><br>";
			}
			else
			{
				// Amount of Damage
				$attackdamage = round((($oppweaponpow + $opppower)*($opptac/2))-$def*$randmultiplier); 
				$criticaldamage = 0;
				$criticalchance = (($oppluck*6)/10);
				$criticalnumerator = rand(0,40);
					if($criticalnumerator<$criticalchance) // Critcal
					{
					echo "<font color='yellow'><b> ".$oppmechname. " hit " .$mechname. " for Critical Damage ";
					$criticaldamage = ($luck*$attackdamage)*30	;
					$charge=$charge-$attackdamage-$criticaldamage;
					echo $criticaldamage.  " - ".$charge." Health left <br></font></b>";

					}
					else // Normal Damage
					{
						$oppcharge=$oppcharge-$attackdamage;
						echo"<font color='purple'>". $oppmechname . " hit " . $mechname . " for " . $attackdamage ."-".$oppcharge." Health left</font> <br>";
					}

				if($oppcharge<=0)
				{
				$oppcharege==0;
				echo $oppmechname." wins<br>";
				exit();
				}
			}
		}	
	}
}
else
{
	if($charge>0)
	{
		echo  $mechname. " retaliated <br>";
		$oppdodge = (($oppref*rand(0,5))-$dex);
		$dodge = (($ref*rand(0,5))-$oppdex);

		if($dodge>$oppdodge)
		{
			echo  $mechname ." dodged " .$oppmechname."<br>";
		}
		else
		{
		$attackdamage = round((($weaponpow . $pow) * ($tac/2))-($oppdef*$randmultiplier));
		echo  $mechname." retaliated for ".$attackdamage." - ".$charge." Health left <br>";
				if($charge<=0)
				{
				$charege==0;
				echo $mechname." wins<br>";
				exit();
				}
		}
	}
}



if($oppdex>=$dex)
{
	if($charge>0)
	{	
		$randmultiplier = rand(0,2);
		$attackturns = 1000;		
		while($attackturns>=10)
		{
			$oppdodge = (($oppref*rand(0,5))-$dex);
			$dodge = (($ref*rand(0,5))-$oppdex);
			$attackturns = $attackturns-($dex-$oppdex);

			if($dodge>$oppdodge)
			{
				echo  $oppmechname." dodged ".$mechname."<br>";
			}
			else
			{
				$attackdamage = round((($weaponpow + $opppow)* ($tac/2))-($oppdef*$randmultiplier));
				$criticaldamage = 0;
				$criticalchance = (($luck*6)/10);
				$criticalnumerator = rand(0,10);
				if($criticalnumerator<$criticalchance)
				{
					echo "<font color='green'><b> ".$mechname. " hit " .$oppmechname. " for Critical Damage ";
					$criticaldamage = ($luck*$attackdamage)/2;
					$charge=$charge-$attackdamage-$criticaldamage;
					echo $criticaldamage.  "  ".$charge." Health left <br></font></b>";

				}
				else
				{
					$charge=$charge-$attackdamage-$criticaldamage;
					echo  $mechname." hit ".$oppmechname." for" . $attackdamage . " - ".$charge." Health left <br>";
				}
				if($charge<=0)
				{
				$charege==0;
				echo $mechname." wins<br>";
				exit();
				}
			}
		}
	}
}
else
{

	if($oppcharge>0)
	{
		echo  $oppmechname ." retaliated<br>";
		$oppdodge = (($oppref*rand(0,5))-$dex);
		$dodge = (($ref*rand(0,5))-$oppdex);

		if($oppdodge<$dodge)
		{
			echo  $oppmechname ." dodged " .$mechname."<br>";
		}
		else
		{
			$attackdamage = round((($oppweaponpow + $opppow)*($opptec/2))-$def*$randmultiplier);
			echo  $oppmechname. " retaliated for ".$attackdamage."-".$oppcharge." Health left <br>";
		}
		if($oppcharge<=0)
		{
			$oppcharege==0;
			echo $oppmechname." wins<br>";
			exit();
		}
	}
}
}
?>
<html>
<head>
<link href=style.css rel='stylesheet' type='css/text'>

 

 

THere ya go :)

Link to comment
https://forums.phpfreaks.com/topic/93668-pvp-battle-arena/#findComment-480434
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.