[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 03-01-2008, 10:33 AM   #1 (permalink)
The original NP Emo Kid
 
liam_d's Avatar
 
Join Date: Jan 2005
Location: Plymouth, UK
Posts: 1,648
0.00 NP$ (Donate)

liam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to all


[PHP] making a battle script

Well i have started making a battle script for use in my game but i am really stuck

i have all the values ready to use but i'm not exactly sure how to make the you and them battle?

PHP Code:
function fight($you, $them)
{
    
$get_your_mecha = mysql_query('SELECT * FROM `mecha` WHERE `owner` = "' . (int) $you . '"');
    
$your_mecha = mysql_fetch_array($get_your_mecha);
        
    
$get_enemy_mecha = mysql_query('SELECT * FROM `mecha` WHERE `owner` = "' . (int) $them . '"');
    
$enemy_mecha = mysql_fetch_array($get_your_mecha);
        
        if (
$your_mecha['armour'] <= 0)
        {
            echo
'You need to repair your Mecha before you can battle!';
        }
        
        if (
$your_mecha['armour'] <= 0)
        {
            echo
'You need to repair your Mecha before you can battle!';
        }
        
        
// set your stats here
        
$your_weapon = mysql_fetch_array(mysql_query('SELECT * FROM `weapon` WHERE `mecha_owner` = "' . $your_mecha['id'] . '"'));
        
$your_armour = mysql_fetch_array(mysql_query('SELECT * FROM `armour` WHERE `mecha_owner` = "' . $your_mecha['id'] . '"'));
        
$your_pack = mysql_fetch_array(mysql_query('SELECT * FROM `pack` WHERE `mecha_owner` = "' . $your_mecha['id'] . '"'));
        
        
$your['strength'] = $your_mecha['strength'] + $your_weapon['power'];
        
$your['armour'] = $your_mecha['armour'] + $your_armour['power'];
        
$your['agility'] = $your_mecha['agility'] +  + $your_agility['power'];
        
        
// set enemy stats here
        
$enemy_weapon = mysql_fetch_array(mysql_query('SELECT * FROM `weapon` WHERE `mecha_owner` = "' . $enemy_mecha['id'] . '"'));
        
$enemy_armour = mysql_fetch_array(mysql_query('SELECT * FROM `armour` WHERE `mecha_owner` = "' . $enemy_mecha['id'] . '"'));
        
$enemy_pack = mysql_fetch_array(mysql_query('SELECT * FROM `pack` WHERE `mecha_owner` = "' . $enemy_mecha['id'] . '"'));
        
    
$enemy['strength'] = $enemy_mecha['strength'] + $enemy_weapon['power'];
    
$enemy['armour'] = $enemy_mecha['armour'] + $enemy_armour['power'];
    
$enemy['agility'] = $enemy_mecha['agility'] +  + $enemy_agility['power'];
        
    
// fighting
    /* determine who is first by who has better agility */
    
if ($your['agility'] > $enemy['agility'])
    {
        
    }
        
    else
    {
    }
        

    
// if both alive fight again
}
liam_d is offline  
Old 03-01-2008, 04:06 PM   #2 (permalink)
JFS
NamePros Regular
 
JFS's Avatar
 
Join Date: Oct 2005
Location: Portugal
Posts: 760
56.85 NP$ (Donate)

JFS is just really niceJFS is just really niceJFS is just really niceJFS is just really niceJFS is just really niceJFS is just really nice


here are some thoughts:

Hit chance:

$your['hitchance'] = $your_mecha['agility'] / ( $your['agility'] - $enemy_mecha['agility'] )
$enemy['hitchance']= $enemy_mecha['agility'] / ( $enemy['agility'] - $your_mecha['agility'] )

Combat damage:

$your['maxdamage'] = $your_mecha['strength'] + $your_weapon['power'] - $enemy_mecha['armour']
$your['mindamage'] = $your_mecha['strength'] + $your_weapon['power'] - $enemy_mecha['armour'] + $enemy_armour['power']

( the same for the enemy )
__________________
Joćo Fernandes Silva
Selling :
19P.ORG - ARCADEHITS.ORG - AZIAN.NET - COREFANS.COM - CTUTORIALS.NET - DEDISEEK.COM - HITCHECK.COM - HOST15.COM - HOSTCUSTOMER.COM - LARGETIPS.COM - SCRIPTCANDY.COM - VISUALBOOK.NET - VOXVPS.COM / .NET - WALLPAPERSARENA.COM
JFS is offline  
Old 03-02-2008, 01:18 PM   #3 (permalink)
The original NP Emo Kid
 
liam_d's Avatar
 
Join Date: Jan 2005
Location: Plymouth, UK
Posts: 1,648
0.00 NP$ (Donate)

liam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to all


Thanks for the input, here is what i have now, think all that is left is to actually do the battle, to which i am unsure about how to do?

PHP Code:
<?php

function fight($you, $them)

{

    
$get_your_mecha = mysql_query('SELECT * FROM `mecha` WHERE `owner` = "' . (int) $you . '"');

    
$your_mecha = mysql_fetch_array($get_your_mecha);

        

    
$get_enemy_mecha = mysql_query('SELECT * FROM `mecha` WHERE `owner` = "' . (int) $them . '"');

    
$enemy_mecha = mysql_fetch_array($get_your_mecha);

        

    if (
$your_mecha['armour'] <= 0)

    {

        echo
'You need to repair your Mecha before you can battle!';

    }

        

    if (
$your_mecha['armour'] <= 0)

    {

        echo
'You need to repair your Mecha before you can battle!';

    }

        

    
// set your stats here

    
$your_weapon = mysql_fetch_array(mysql_query('SELECT * FROM `weapon` WHERE `mecha_owner` = "' . $your_mecha['id'] . '"'));

    
$your_armour = mysql_fetch_array(mysql_query('SELECT * FROM `armour` WHERE `mecha_owner` = "' . $your_mecha['id'] . '"'));

    
$your_pack = mysql_fetch_array(mysql_query('SELECT * FROM `pack` WHERE `mecha_owner` = "' . $your_mecha['id'] . '"'));

        

    
$your['strength'] = $your_mecha['strength'] + $your_weapon['power'];

    
$your['armour'] = $your_mecha['armour'] + $your_armour['power'];

    
$your['agility'] = $your_mecha['agility'] +  + $your_agility['power'];

        

    
// set enemy stats here

    
$enemy_weapon = mysql_fetch_array(mysql_query('SELECT * FROM `weapon` WHERE `mecha_owner` = "' . $enemy_mecha['id'] . '"'));

    
$enemy_armour = mysql_fetch_array(mysql_query('SELECT * FROM `armour` WHERE `mecha_owner` = "' . $enemy_mecha['id'] . '"'));

    
$enemy_pack = mysql_fetch_array(mysql_query('SELECT * FROM `pack` WHERE `mecha_owner` = "' . $enemy_mecha['id'] . '"'));

        

    
$enemy['strength'] = $enemy_mecha['strength'] + $enemy_weapon['power'];

    
$enemy['armour'] = $enemy_mecha['armour'] + $enemy_armour['power'];

    
$enemy['agility'] = $enemy_mecha['agility'] +  + $enemy_agility['power'];



    
// chance of hitting first



    
$your['hitchance'] = $your_mecha['agility'] / ( $your['agility'] - $enemy_mecha['agility'] );

    
$enemy['hitchance'] = $enemy_mecha['agility'] / ( $enemy['agility'] - $your_mecha['agility'] );

    

    
//Combat damage:

    

    
$your['maxdamage'] = $your_mecha['strength'] + $your_weapon['power'] - $enemy_mecha['armour'];

    
$your['mindamage'] = $your_mecha['strength'] + $your_weapon['power'] - $enemy_mecha['armour'] + $enemy_armour['power'];

    
//Combat damage:

    

    
$enemy['maxdamage'] = $your_mecha['strength'] + $your_weapon['power'] - $enemy_mecha['armour'];

    
$enemy['mindamage'] = $enemy_mecha['strength'] + $enemy_weapon['power'] - $your_mecha['armour'] + $your_armour['power'];

    

    
// if your go first

    
if ($your['hitchance'] > $enemy['hitchance'])

    {

    }

    

    
// if enemy go first

    
else

    {

    }

}

?>

Last edited by liam_d; 03-06-2008 at 05:06 AM.
liam_d is offline  
Old 03-05-2008, 03:35 PM   #4 (permalink)
The original NP Emo Kid
 
liam_d's Avatar
 
Join Date: Jan 2005
Location: Plymouth, UK
Posts: 1,648
0.00 NP$ (Donate)

liam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to all


friendly bump, any ideas?
liam_d is offline  
Old 03-13-2008, 06:58 PM   #5 (permalink)
Pro Coder & Designer
 
xlusive's Avatar
 
Join Date: Apr 2005
Location: Netherlands
Posts: 964
101.50 NP$ (Donate)

xlusive is just really nicexlusive is just really nicexlusive is just really nicexlusive is just really nicexlusive is just really nice


This is how i would do it :
This is not tested- just written to give you a idea

PHP Code:
<?php
function fight($you, $them) {

$get_your_mecha = mysql_query('
SELECT
user.id,user.strength,user.armour,user.agility,
weapon.power as weapon_power,
armour.power as armour_power,
agility.power as agility_power

FROM mecha as user
LEFT JOIN weapon
ON weapon.mecha_owner = $you
AND
LEFT JOIN armour
ON armour.mecha_owner = $you
AND
LEFT JOIN pack
ON pack.mecha_owner = $you

WHERE user.owner = "'
. (int) $you . '"');
$you = mysql_fetch_array($get_your_mecha);

$get_enemy_mecha = mysql_query('
SELECT
user.id,user.strength,user.armour,user.agility,
weapon.power as weapon_power,
armour.power as armour_power,
agility.power as agility_power

FROM mecha as user
LEFT JOIN weapon
ON weapon.mecha_owner = $them
AND
LEFT JOIN armour
ON armor.mecha_owner = $them
AND
LEFT JOIN pack
ON pack.mecha_owner = $them

WHERE user.owner = "'
. (int) $them . '"');
);
$enemy = mysql_fetch_array($get_enemy_mecha);

if (
$you['armour_power'] <= 0)  {
echo
'You need to repair your Mecha before you can battle!';
}
    
/*$your_weapon = mysql_fetch_array(mysql_query('SELECT * FROM `weapon` WHERE `mecha_owner` = "' . $your_mecha['id'] . '"'));
    $your_armour = mysql_fetch_array(mysql_query('SELECT * FROM `armour` WHERE `mecha_owner` = "' . $your_mecha['id'] . '"'));
    $your_pack = mysql_fetch_array(mysql_query('SELECT * FROM `pack` WHERE `mecha_owner` = "' . $your_mecha['id'] . '"'));
    */
         

    
$you['strength'] = $you['strength'] + $you['weapon_power'];
    
$you['armour'] = $you['armour'] + $you['armour_power'];
    
$you['agility'] = $you['agility'] + $you['agility_power'];
    
// set enemy stats here
    /*
    $your['strength'] = $your_mecha['strength'] + $your_weapon['power'];

    $your['armour'] = $your_mecha['armour'] + $your_armour['power'];

    $your['agility'] = $your_mecha['agility'] +  + $your_agility['power'];
    

    $enemy_weapon = mysql_fetch_array(mysql_query('SELECT * FROM `weapon` WHERE `mecha_owner` = "' . $enemy_mecha['id'] . '"'));
    $enemy_armour = mysql_fetch_array(mysql_query('SELECT * FROM `armour` WHERE `mecha_owner` = "' . $enemy_mecha['id'] . '"'));
    $enemy_pack = mysql_fetch_array(mysql_query('SELECT * FROM `pack` WHERE `mecha_owner` = "' . $enemy_mecha['id'] . '"'));
    $enemy['strength'] = $enemy_mecha['strength'] + $enemy_weapon['power'];
    $enemy['armour'] = $enemy_mecha['armour'] + $enemy_armour['power'];
    $enemy['agility'] = $enemy_mecha['agility'] +  + $enemy_agility['power'];
*/
    
    
$enemy['strength'] = $enemy['strength'] + $enemy['weapon_power'];
    
$enemy['armour'] = $enemy['armour'] + $enemy['armour_power'];
    
$enemy['agility'] = $enemy['agility'] + $enemy['agility_power'];


    
$your['hitchance'] = $you['agility'] / ( $you['agility'] - $enemy['agility'] );
    
$enemy['hitchance'] = $enemy['agility'] / ( $enemy['agility'] - $you['agility'] );
   
    
$your['maxdamage'] = $you['strength'] + $you['weapon_power'] - $enemy['armour_power'];
    
$your['mindamage'] = $you['strength'] + $you['weapon_power'] - $enemy['armour_power'] + $enemy['armour_power'];

    
//Combat damage:
    
$enemy['maxdamage'] = $you['strength'] + $your['weapon_power'] - $enemy['weapon_armour'];
    
$enemy['mindamage'] = $enemy['strength'] + $enemy['weapon_power'] - $you['armour'] + $your['weapon_power'];

    
// if your go first

    
if ($your['hitchance'] > $enemy['hitchance']) {
    } else {

    }

}
?>
__________________
Online Dragonball Game
xlusive is offline  
Old 03-14-2008, 05:26 AM   #6 (permalink)
The original NP Emo Kid
 
liam_d's Avatar
 
Join Date: Jan 2005
Location: Plymouth, UK
Posts: 1,648
0.00 NP$ (Donate)

liam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to all


Thanks for the post this will help quite a lot i think and will definitely make it faster since using less queries .

What i need now is to do the actual battle, which i have no idea how to do properly

Thanks!
liam_d is offline  
Old 03-14-2008, 07:51 AM   #7 (permalink)
Pro Coder & Designer
 
xlusive's Avatar
 
Join Date: Apr 2005
Location: Netherlands
Posts: 964
101.50 NP$ (Donate)

xlusive is just really nicexlusive is just really nicexlusive is just really nicexlusive is just really nicexlusive is just really nice


basically - you can do like the above - you have to add certain health (which is i guess armour) to be deducted from the total amount untill one of them drops to zero
might be handy if they can choose what attack - since i assume every attack has their own strength?
__________________
Online Dragonball Game
xlusive is offline  
Old 03-18-2008, 11:59 PM   #8 (permalink)
New Member
 
Join Date: Mar 2008
Posts: 5
0.00 NP$ (Donate)

jessemiller is an unknown quantity at this point


I wrote this up in this post when i saw your post, so i definately didnt test it, but its a very good start to the direction your heading in

Code:
<?
session_start();

// lets tell the script that if the user is not logged in they cannot access
// the game, when the user is logging in, some variable should be
// set that they are logged in, a basic easy one is
// $_SESSION['loggedin']=1;
// and when they logout destroy the session, google is your friend.

if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }

$userid=$_SESSION['userid']; //assuming you have sessions set
$id=$_GET['userid']; // assuming the url uses a GET function

$z=mysql_query("SELECT * FROM users WHERE userid='$userid'");
$x=mysql_fetch_array($z);

// Protect the admin, you.

if($_GET['userid'] == '1') {
print "You cannot attack the admin, i am all powerful"; die;
}

// Lets make sure they are not attacking themselves

if($_GET['userid'] == '$userid') {
print "You cannot attack yourself"; die;
}

if(isset($_GET['userid'])) {
$q=mysql_query("SELECT * FROM users WHERE userid='$id'");
$r=mysql_fetch_array($q);

// Set some variables

$offender=$x['name'];
$defender=$r['name'];
$offhealth=$x['health'];
$defhealth=$r['health'];
$offstat1=$x['stat1'];
$defstat1=$r['stat1'];
$offstat2=$x['stat2'];
$defstat2=$r['stat2'];

// Lets make sure the user isn't trying to kill a dead user
// Or trying to kill people even though they are dead

if($offhealth<1) {
print "You are dead, you cannot attack while dead, jerk."; die;
}

if($defhealth<1) {
print "This Player Is Dead"; die;
}

// Set a random factor so the most powerful is not always the winner

$offrand=rand(0,100);
$defrand=rand(0,100);
$rand=rand(100,999);

// Do some math

$offpower=($offstat1+$offstat2+$offrand);
$defpower=($defstat1+$defstat2+$defrand);

$offdamage=($defpower-$defrand/*3);
$defdamage=($offpower-$offrand/*3);

// This is where you let the user know what is going on
// Send them to a link
// attack.php?userid=$id&math=$rand
// Print the names and health of each user

if($offpower>$defpower){

// print the action that took place, defense lost health

mysql_query("UPDATE users SET health=health-'$defdamamge' WHERE userid='$id'"); }

if($offpower<$defpower){

// print the action that took place, offense lost health

mysql_query("UPDATE users SET health=health-'$offdamamge' WHERE userid='$userid'"); }

// when a player reaches 1 health or lower it will state the player is dead
// this script will need editing if stats are involved
// but this is a good start to get you on your way
}
?>
I hope this helps you bud.

Last edited by jessemiller; 03-19-2008 at 12:04 AM.
jessemiller is offline  
Old 04-06-2008, 02:55 PM   #9 (permalink)
The original NP Emo Kid
 
liam_d's Avatar
 
Join Date: Jan 2005
Location: Plymouth, UK
Posts: 1,648
0.00 NP$ (Donate)

liam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to all


Quote:
Originally Posted by JFS
here are some thoughts:

Hit chance:

$your['hitchance'] = $your_mecha['agility'] / ( $your['agility'] - $enemy_mecha['agility'] )
$enemy['hitchance']= $enemy_mecha['agility'] / ( $enemy['agility'] - $your_mecha['agility'] )

Combat damage:

$your['maxdamage'] = $your_mecha['strength'] + $your_weapon['power'] - $enemy_mecha['armour']
$your['mindamage'] = $your_mecha['strength'] + $your_weapon['power'] - $enemy_mecha['armour'] + $enemy_armour['power']

( the same for the enemy )
Just a question about the hitchance here, why is the hitchance for myself for example be my agility divided by my agility take the enemys agility?
Is that the best way?
liam_d is offline  
Old 04-07-2008, 06:45 AM   #10 (permalink)
The original NP Emo Kid
 
liam_d's Avatar
 
Join Date: Jan 2005
Location: Plymouth, UK
Posts: 1,648
0.00 NP$ (Donate)

liam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to all


Okay i have gotten it working for all but one thing, the attack_back function and the hitchance dont seem to work properly, for one thing i seem to always attack first even if the enemy hitchance is bigger and i always attack_back not the enemy?

PHP Code:
<?php
class attacking
{
    var
$your;
    var
$enemy;
    var
$your_mecha;
    var
$enemy_mecha;
    
    function
fight($you, $them)
    {
        
$get_your_mecha = mysql_query('SELECT * FROM `mecha` WHERE `owner` = "' . (int) $you . '"');
        
$this->your_mecha = mysql_fetch_array($get_your_mecha);
            
        
$get_enemy_mecha = mysql_query('SELECT * FROM `mecha` WHERE `owner` = "' . (int) $them . '"');
        
$this->enemy_mecha = mysql_fetch_array($get_enemy_mecha);
        
        if (
$this->your_mecha['armour'] <= 0)
        {
            echo
'You need to repair your Mecha before you can battle!';
        }
            
        else if (
$this->enemy_mecha['armour'] <= 0)
        {
            echo
'The enemy has already been disabled!!';
        }
        
        else
        {
            
            
// set your stats here
            
$your_weapon = mysql_fetch_array(mysql_query('SELECT * FROM `weapon` WHERE `mecha_owner` = "' . $your_mecha['id'] . '"'));
            
$your_armour = mysql_fetch_array(mysql_query('SELECT * FROM `armour` WHERE `mecha_owner` = "' . $your_mecha['id'] . '"'));
            
$your_pack = mysql_fetch_array(mysql_query('SELECT * FROM `pack` WHERE `mecha_owner` = "' . $your_mecha['id'] . '"'));
                
            
$this->your['strength'] = $this->your_mecha['strength'] + $your_weapon['power'];
            
$this->your['armour'] = $this->your_mecha['armour'] + $your_armour['power'];
            
$this->your['agility'] = $this->your_mecha['agility'] +  + $your_agility['power'];
                
            
// set enemy stats here
            
$enemy_weapon = mysql_fetch_array(mysql_query('SELECT * FROM `weapon` WHERE `mecha_owner` = "' . $enemy_mecha['id'] . '"'));
            
$enemy_armour = mysql_fetch_array(mysql_query('SELECT * FROM `armour` WHERE `mecha_owner` = "' . $enemy_mecha['id'] . '"'));
            
$enemy_pack = mysql_fetch_array(mysql_query('SELECT * FROM `pack` WHERE `mecha_owner` = "' . $enemy_mecha['id'] . '"'));
                
            
$this->enemy['strength'] = $this->enemy_mecha['strength'] + $enemy_weapon['power'];
            
$this->enemy['armour'] = $this->enemy_mecha['armour'] + $enemy_armour['power'];
            
$this->enemy['agility'] = $this->enemy_mecha['agility'] +  + $enemy_agility['power'];
        
            
// chance of hitting first
        
            
$this->your['hitchance'] = $this->your_mecha['agility'] - $this->enemy_mecha['agility'];
            
$this->enemy['hitchance'] = $this->enemy_mecha['agility'] - $this->your_mecha['agility'];
            
            
//Combat damage:
            
            
$this->your['maxdamage'] = $this->your_mecha['strength'] + $your_weapon['power'];
            
$this->your['mindamage'] = $this->your_mecha['strength'] + $your_weapon['power'] / 3;
        
            
//Combat damage:
            
            
$this->enemy['maxdamage'] = $this->enemy_mecha['strength'] + $enemy_weapon['power'];
            
$this->enemy['mindamage'] = $this->enemy_mecha['strength'] + $enemy_weapon['power'] / 3;
            
            
// if your go first
            
if ($this->your['hitchance'] > $this->enemy['hitchance'])
            {
                
$this->attack(1);
            }
            
            
// if enemy go first
            
else
            {
                
$this->attack(2);
            }
        }
    }
    
    
// for first attack
    
function attack ($first)
    {
        if (
$first = 1)
        {
            
// Get power of attack as a random number between min and max damage you can cause
            
$power = rand($this->your['mindamage'], $this->your['maxdamage']);
            
            
// take that power away from enemy armour
            
$this->enemy['armour'] = $this->enemy['armour'] - $power;
            
            echo
"You attack the enemy and cause {$power} damage. Enemy armour is now at {$this->enemy['armour']}<br />";
            
            if (
$this->enemy['armour'] <= 0)
            {
                
mysql_query("UPDATE `mecha` SET `armour` = '0' WHERE `id` = '{$this->enemy_mecha['id']}'");
                echo
'You have disabled the enemy, you have won the battle!<br />';
            }
                
            else
            {
                
$this->attack_back(2);
            }
        }
        
        else if (
$first = 2)
        {
            
// Get power of attack as a random number between min and max damage you can cause
            
$power = rand($this->enemy['mindamage'], $this->enemy['maxdamage']);
            
            
// take that power away from enemy armour
            
$this->your['armour'] = $this->your['armour'] - $power;
            
            echo
"The enemy attacks and causes {$power} damage. Your armour is now at {$this->your['armour']}<br />";
            
            if (
$this->your['armour'] <= 0)
            {
                
mysql_query("UPDATE `mecha` SET `armour` = '0' WHERE `id` = '{$this->your_mecha['id']}'");
                echo
'You have disabled the enemy, you have won the battle!<br />';
            }
                
            else
            {
                
$this->attack_back(1);
            }
        }
    }
    
    
// for all other attacking
    
function attack_back ($who)
    {
        if (
$who = 1)
        {
            
// Get power of attack as a random number between min and max damage you can cause
            
$power = rand($this->your['mindamage'], $this->your['maxdamage']);
            
            
// take that power away from enemy armour
            
$this->enemy['armour'] = $this->enemy['armour'] - $power;
            
            echo
"You attack the enemy again and cause {$power} damage. Enemy armour is now at {$this->enemy['armour']}<br />";
            
            if (
$this->enemy['armour'] <= 0)
            {
                
mysql_query("UPDATE `mecha` SET `armour` = '0' WHERE `id` = '{$this->enemy_mecha['id']}'");
                echo
'You have disabled the enemy, you have won the battle!<br />';
            }
                
            else
            {
                
$this->attack_back(2);
            }
        }
        
        else if (
$who = 2)
        {
            
// Get power of attack as a random number between min and max damage you can cause
            
$power = rand($this->enemy['mindamage'], $this->enemy['maxdamage']);
            
            
// take that power away from enemy armour
            
$this->your['armour'] = $this->your['armour'] - $power;
            
            echo
"The enemy attacks again and causes {$power} damage. Your armour is now at {$this->your['armour']}<br />";
            
            if (
$this->your['armour'] <= 0)
            {
                
mysql_query("UPDATE `mecha` SET `armour` = '0' WHERE `id` = '{$this->your_mecha['id']}'");
                echo
'You have disabled the enemy, you have won the battle!<br />';
            }
                
            else
            {
                
$this->attack_back(1);
            }
        }
    }
}
?>
liam_d is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 03:14 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85