Pls help me with my php fighting script

Discussion in 'Game programming' started by Kuya, Feb 23, 2011.

  1. Kuya

    Kuya New Member

    Joined:
    Feb 23, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello everybody. Im new with this php codes. I am trying to make my own RPG game at home. Im stuck with this fighting script. what I have now is this:
    Code:
    <html>
    <body>
    $attacker['health']=30
    $attacker['dodge']=3
    $attacker['accuracy']=3
    $attacker['weapondamage']=5-7
    $defender['health']=30
    $defender['dodge']=4
    $defender['accuracy']=2
    $defender['weapondamage']=5-7
    
    <?php
    if ( $attacker['accuracy']>= $defender['dodge']) // first attack is successful
    echo "Attacker hit the defender with" $attacker['weapondamage'] . ;
    elseif (( $attacker['accuracy']< $defender['dodge'])) // first attack is miss
    echo "Defender dodge the Attacker";
    ?>
    </body>
    </html>
    
    I want this to loop until one player is dead. I don't know how to do this. And also I want the echo to be continuous like this:


    Attacker miss the Defender.
    Defender miss the Attacker!
    Attacker miss the Defender.
    Defender hit the Attacker with 10 damage!
    Attacker hit the Defender with 40 damage!
    Defender hit the Attacker with 30 damage and died!

    Defender wins!

    Now my question are:
    What are the things I need to place in my current script to have those above results?
    Is there a way to materialize my fighting script?

    Help pls...
     
    Last edited by a moderator: Feb 23, 2011
  2. ManzZup

    ManzZup New Member

    Joined:
    May 9, 2009
    Messages:
    278
    Likes Received:
    43
    Trophy Points:
    0
    Occupation:
    Production Manager:Software @ ZONTEK
    Location:
    Sri Lanka
    Home Page:
    http://zontek.zzl.org
    on which logic you make the accuracy and dodge things
    i mean you should randomize all these
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice