<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Building Browsergames - Latest Comments in Building Browsergames: a simple combat system (PHP)</title><link>http://bbgames.disqus.com/</link><description></description><atom:link href="https://bbgames.disqus.com/building_browsergames_a_simple_combat_system_php/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Sun, 16 May 2010 15:03:41 -0000</lastBuildDate><item><title>Re: Building Browsergames: a simple combat system (PHP)</title><link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/#comment-50618993</link><description>&lt;p&gt;I decided to not use Smarty. but I can't understand how to "translate" the Smarty Template into PHP. Help?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">MeeeeeePa</dc:creator><pubDate>Sun, 16 May 2010 15:03:41 -0000</pubDate></item><item><title>Re: Building Browsergames: a simple combat system (PHP)</title><link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/#comment-41911365</link><description>&lt;p&gt;hey, your tutorial is great! It really helps me with my understanding of php.&lt;br&gt;I would love to insert a random number in that battlesystem. But when i do so in every fight the number doesn't change throughout the turns. Were is the best place to add the rand so i have a different damage in every turn? Or am I just unlucky and it always takes the same random number...&lt;br&gt;Would be nice to know were you would do that&lt;br&gt;Again thanks for this tutorial!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nirkun</dc:creator><pubDate>Sat, 27 Mar 2010 14:48:02 -0000</pubDate></item><item><title>Re: Building Browsergames: a simple combat system (PHP)</title><link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/#comment-28598624</link><description>&lt;p&gt;Perhaps do what they did in diablo 2 (and other games I am sure) put a minimum acceptable value.  Something like&lt;/p&gt;&lt;p&gt;damage = (attack-defense) || 1;&lt;/p&gt;&lt;p&gt;So no matter what they will at least do 1 damage.  Or if put in a different formula&lt;/p&gt;&lt;p&gt;damage = (attack-defense &amp;gt; 0) ? attack-defense : (Math.rand() &amp;gt; .5) ? 1 : 0;&lt;/p&gt;&lt;p&gt;By tweaking a system like this, if the attack is greater than 0, it will do the attack.  If not, it will get a random value between 0 and 1.  If it is greater than .5 then it will take off 1 damage.  If it is less than .5, it will take off 0 damage.&lt;/p&gt;&lt;p&gt;Doing something like this will get rid of those never ending battles.  Or perhaps put in a situational check at the start:&lt;/p&gt;&lt;p&gt;if (($player['attack'] - $monster['defense'] &amp;lt; 1) &amp;amp;&amp;amp; ($monster['attack'] - $player['defense'] &amp;lt; 1){&lt;br&gt;  // end in draw.&lt;br&gt;}&lt;/p&gt;&lt;p&gt;Anyway, there are a few different ideas to work around this.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">BUnzaga</dc:creator><pubDate>Tue, 05 Jan 2010 18:32:02 -0000</pubDate></item><item><title>Re: Building Browsergames: a simple combat system (PHP)</title><link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/#comment-16661012</link><description>&lt;p&gt;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.&lt;/p&gt;&lt;p&gt;5 player attack value ____  monster defence value 7 &amp;gt; no one will lose any health&lt;br&gt;4 monster attack value ____  player defence value 5 &amp;gt; no one will lose any health&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">someone</dc:creator><pubDate>Tue, 15 Sep 2009 16:56:10 -0000</pubDate></item><item><title>Re: Building Browsergames: a simple combat system (PHP)</title><link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/#comment-11992082</link><description>&lt;p&gt;I get errors like this: &lt;br&gt;"Notice: Use of undefined constant attacker - assumed 'attacker' in /Users/Niels/Sites/bg/smarty/bg/forest.php on line 53"&lt;/p&gt;&lt;p&gt;Caused by the arrays:&lt;br&gt;$combat[$turns] = array(&lt;br&gt;				attacker	=&amp;gt;	$attacker['name'],&lt;br&gt;				defender	=&amp;gt;	$defender['name'],&lt;br&gt;				damage		=&amp;gt;	$damage&lt;br&gt;			);&lt;/p&gt;&lt;p&gt;I fixed it this way:&lt;br&gt;$combat[$turns] = array(&lt;br&gt;				'attacker'	=&amp;gt;	$attacker['name'],&lt;br&gt;				'defender'	=&amp;gt;	$defender['name'],&lt;br&gt;				'damage'		=&amp;gt;	$damage&lt;br&gt;			);&lt;/p&gt;&lt;p&gt;PS: I realy like this tutorial, i was searching a long time for something like this :) .&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Xenon</dc:creator><pubDate>Wed, 01 Jul 2009 15:20:25 -0000</pubDate></item><item><title>Re: Building Browsergames: a simple combat system (PHP)</title><link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/#comment-7216361</link><description>&lt;p&gt;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.&lt;br&gt;Thanks for your reply!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">MrLollige</dc:creator><pubDate>Sat, 14 Mar 2009 14:00:54 -0000</pubDate></item><item><title>Re: Building Browsergames: a simple combat system (PHP)</title><link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/#comment-7215374</link><description>&lt;p&gt;I think that you may have misinterpreted the way that the combat system&lt;br&gt;works, here - after encounting a monster and clicking attack, the entire&lt;br&gt;combat simulation is run and the player's health is updated, before the next&lt;br&gt;screen. There isn't really a screen where they can see the battle is going&lt;br&gt;badly and run away.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Luke</dc:creator><pubDate>Sat, 14 Mar 2009 13:01:16 -0000</pubDate></item><item><title>Re: Building Browsergames: a simple combat system (PHP)</title><link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/#comment-7209993</link><description>&lt;p&gt;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?&lt;/p&gt;&lt;p&gt;Right now, if things are going bad, you could navigate away and your HP is back to normal again....&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">MrLollige</dc:creator><pubDate>Sat, 14 Mar 2009 05:12:05 -0000</pubDate></item></channel></rss>