DISQUS

Building Browsergames: Building Browsergames: a simple combat system (PHP)

  • MrLollige · 7 months ago
    This works, but only if you allow people to freely escape from their battles. If you do not want people to be able to flee, will you have to add a row for every instance of a monster, and update their hp every time?

    Right now, if things are going bad, you could navigate away and your HP is back to normal again....
  • Luke · 7 months ago
    I think that you may have misinterpreted the way that the combat system
    works, here - after encounting a monster and clicking attack, the entire
    combat simulation is run and the player's health is updated, before the next
    screen. There isn't really a screen where they can see the battle is going
    badly and run away.
  • MrLollige · 7 months ago
    Oh yes, true, I did not fully read it AND did not fully try to understand that code indeed. I am still a beginner in these things, and expected that smarty (the part I skipped) would enable you to decide every turn what you want to do.
    Thanks for your reply!
  • Xenon · 4 months ago
    I get errors like this:
    "Notice: Use of undefined constant attacker - assumed 'attacker' in /Users/Niels/Sites/bg/smarty/bg/forest.php on line 53"

    Caused by the arrays:
    $combat[$turns] = array(
    attacker => $attacker['name'],
    defender => $defender['name'],
    damage => $damage
    );

    I fixed it this way:
    $combat[$turns] = array(
    'attacker' => $attacker['name'],
    'defender' => $defender['name'],
    'damage' => $damage
    );

    PS: I realy like this tutorial, i was searching a long time for something like this :) .
  • someone · 1 month ago
    I tried modifying the attack of the third monster from 3 to 7, you will end up with a situation where in the loop the attack is always less than defence, and the loop never exists causing a fatal error of memory loss.

    5 player attack value ____ monster defence value 7 > no one will lose any health
    4 monster attack value ____ player defence value 5 > no one will lose any health