<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Building Browsergames: a simple combat system (PHP)</title>
	<atom:link href="http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/feed/" rel="self" type="application/rss+xml" />
	<link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/</link>
	<description>Ever wanted to build a browsergame?</description>
	<lastBuildDate>Wed, 30 Nov 2011 19:42:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: MeeeeeePa</title>
		<link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/comment-page-1/#comment-781</link>
		<dc:creator>MeeeeeePa</dc:creator>
		<pubDate>Mon, 17 May 2010 00:03:41 +0000</pubDate>
		<guid isPermaLink="false">http://buildingbrowsergames.com/?p=61#comment-781</guid>
		<description>I decided to not use Smarty. but I can&#039;t understand how to &quot;translate&quot; the Smarty Template into PHP. Help?</description>
		<content:encoded><![CDATA[<p>I decided to not use Smarty. but I can&#39;t understand how to &#8220;translate&#8221; the Smarty Template into PHP. Help?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nirkun</title>
		<link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/comment-page-1/#comment-764</link>
		<dc:creator>Nirkun</dc:creator>
		<pubDate>Sat, 27 Mar 2010 23:48:02 +0000</pubDate>
		<guid isPermaLink="false">http://buildingbrowsergames.com/?p=61#comment-764</guid>
		<description>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&#039;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!</description>
		<content:encoded><![CDATA[<p>hey, your tutorial is great! It really helps me with my understanding of php.<br />I would love to insert a random number in that battlesystem. But when i do so in every fight the number doesn&#39;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&#8230;<br />Would be nice to know were you would do that<br />Again thanks for this tutorial!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BUnzaga</title>
		<link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/comment-page-1/#comment-682</link>
		<dc:creator>BUnzaga</dc:creator>
		<pubDate>Wed, 06 Jan 2010 04:32:02 +0000</pubDate>
		<guid isPermaLink="false">http://buildingbrowsergames.com/?p=61#comment-682</guid>
		<description>Perhaps do what they did in diablo 2 (and other games I am sure) put a minimum acceptable value.  Something like &lt;br&gt;&lt;br&gt;damage = (attack-defense) &#124;&#124; 1;&lt;br&gt;&lt;br&gt;So no matter what they will at least do 1 damage.  Or if put in a different formula&lt;br&gt;&lt;br&gt;damage = (attack-defense &gt; 0) ? attack-defense : (Math.rand() &gt; .5) ? 1 : 0;&lt;br&gt;&lt;br&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;br&gt;&lt;br&gt;Doing something like this will get rid of those never ending battles.  Or perhaps put in a situational check at the start:&lt;br&gt;&lt;br&gt;if (($player[&#039;attack&#039;] - $monster[&#039;defense&#039;] &lt; 1) &amp;&amp; ($monster[&#039;attack&#039;] - $player[&#039;defense&#039;] &lt; 1){&lt;br&gt;  // end in draw.&lt;br&gt;}&lt;br&gt;&lt;br&gt;Anyway, there are a few different ideas to work around this.</description>
		<content:encoded><![CDATA[<p>Perhaps do what they did in diablo 2 (and other games I am sure) put a minimum acceptable value.  Something like </p>
<p>damage = (attack-defense) || 1;</p>
<p>So no matter what they will at least do 1 damage.  Or if put in a different formula</p>
<p>damage = (attack-defense &gt; 0) ? attack-defense : (Math.rand() &gt; .5) ? 1 : 0;</p>
<p>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.</p>
<p>Doing something like this will get rid of those never ending battles.  Or perhaps put in a situational check at the start:</p>
<p>if (($player[&#39;attack&#39;] &#8211; $monster[&#39;defense&#39;] &lt; 1) &#038;&#038; ($monster[&#39;attack&#39;] &#8211; $player[&#39;defense&#39;] &lt; 1){<br />  // end in draw.<br />}</p>
<p>Anyway, there are a few different ideas to work around this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: someone</title>
		<link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/comment-page-1/#comment-618</link>
		<dc:creator>someone</dc:creator>
		<pubDate>Wed, 16 Sep 2009 01:56:10 +0000</pubDate>
		<guid isPermaLink="false">http://buildingbrowsergames.com/?p=61#comment-618</guid>
		<description>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;br&gt;&lt;br&gt;5 player attack value ____  monster defence value 7 &gt; no one will lose any health&lt;br&gt;4 monster attack value ____  player defence value 5 &gt; no one will lose any health</description>
		<content:encoded><![CDATA[<p>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.</p>
<p>5 player attack value ____  monster defence value 7 &gt; no one will lose any health<br />4 monster attack value ____  player defence value 5 &gt; no one will lose any health</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: someone</title>
		<link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/comment-page-1/#comment-460</link>
		<dc:creator>someone</dc:creator>
		<pubDate>Tue, 15 Sep 2009 20:56:10 +0000</pubDate>
		<guid isPermaLink="false">http://buildingbrowsergames.com/?p=61#comment-460</guid>
		<description>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;br&gt;&lt;br&gt;5 player attack value ____  monster defence value 7 &gt; no one will lose any health&lt;br&gt;4 monster attack value ____  player defence value 5 &gt; no one will lose any health</description>
		<content:encoded><![CDATA[<p>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.</p>
<p>5 player attack value ____  monster defence value 7 &gt; no one will lose any health<br />4 monster attack value ____  player defence value 5 &gt; no one will lose any health</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xenon</title>
		<link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/comment-page-1/#comment-429</link>
		<dc:creator>Xenon</dc:creator>
		<pubDate>Wed, 01 Jul 2009 19:20:25 +0000</pubDate>
		<guid isPermaLink="false">http://buildingbrowsergames.com/?p=61#comment-429</guid>
		<description>I get errors like this: &lt;br&gt;&quot;Notice: Use of undefined constant attacker - assumed &#039;attacker&#039; in /Users/Niels/Sites/bg/smarty/bg/forest.php on line 53&quot;&lt;br&gt;&lt;br&gt;Caused by the arrays:&lt;br&gt;$combat[$turns] = array(&lt;br&gt;				attacker	=&gt;	$attacker[&#039;name&#039;],&lt;br&gt;				defender	=&gt;	$defender[&#039;name&#039;],&lt;br&gt;				damage		=&gt;	$damage&lt;br&gt;			);&lt;br&gt;&lt;br&gt;I fixed it this way:&lt;br&gt;$combat[$turns] = array(&lt;br&gt;				&#039;attacker&#039;	=&gt;	$attacker[&#039;name&#039;],&lt;br&gt;				&#039;defender&#039;	=&gt;	$defender[&#039;name&#039;],&lt;br&gt;				&#039;damage&#039;		=&gt;	$damage&lt;br&gt;			);&lt;br&gt;&lt;br&gt;PS: I realy like this tutorial, i was searching a long time for something like this :) .</description>
		<content:encoded><![CDATA[<p>I get errors like this: <br />&#8220;Notice: Use of undefined constant attacker &#8211; assumed &#39;attacker&#39; in /Users/Niels/Sites/bg/smarty/bg/forest.php on line 53&#8243;</p>
<p>Caused by the arrays:<br />$combat[$turns] = array(<br />				attacker	=&gt;	$attacker[&#39;name&#39;],<br />				defender	=&gt;	$defender[&#39;name&#39;],<br />				damage		=&gt;	$damage<br />			);</p>
<p>I fixed it this way:<br />$combat[$turns] = array(<br />				&#39;attacker&#39;	=&gt;	$attacker[&#39;name&#39;],<br />				&#39;defender&#39;	=&gt;	$defender[&#39;name&#39;],<br />				&#39;damage&#39;		=&gt;	$damage<br />			);</p>
<p>PS: I realy like this tutorial, i was searching a long time for something like this <img src='http://buildingbrowsergames.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MrLollige</title>
		<link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/comment-page-1/#comment-366</link>
		<dc:creator>MrLollige</dc:creator>
		<pubDate>Sat, 14 Mar 2009 18:00:54 +0000</pubDate>
		<guid isPermaLink="false">http://buildingbrowsergames.com/?p=61#comment-366</guid>
		<description>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!</description>
		<content:encoded><![CDATA[<p>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.<br />Thanks for your reply!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luke</title>
		<link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/comment-page-1/#comment-365</link>
		<dc:creator>Luke</dc:creator>
		<pubDate>Sat, 14 Mar 2009 17:01:16 +0000</pubDate>
		<guid isPermaLink="false">http://buildingbrowsergames.com/?p=61#comment-365</guid>
		<description>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&#039;s health is updated, before the next&lt;br&gt;screen. There isn&#039;t really a screen where they can see the battle is going&lt;br&gt;badly and run away.</description>
		<content:encoded><![CDATA[<p>I think that you may have misinterpreted the way that the combat system<br />works, here &#8211; after encounting a monster and clicking attack, the entire<br />combat simulation is run and the player&#39;s health is updated, before the next<br />screen. There isn&#39;t really a screen where they can see the battle is going<br />badly and run away.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MrLollige</title>
		<link>http://buildingbrowsergames.com/2008/06/11/building-browsergames-a-simple-combat-system/comment-page-1/#comment-355</link>
		<dc:creator>MrLollige</dc:creator>
		<pubDate>Sat, 14 Mar 2009 09:12:05 +0000</pubDate>
		<guid isPermaLink="false">http://buildingbrowsergames.com/?p=61#comment-355</guid>
		<description>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;br&gt;&lt;br&gt;Right now, if things are going bad, you could navigate away and your HP is back to normal again....</description>
		<content:encoded><![CDATA[<p>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?</p>
<p>Right now, if things are going bad, you could navigate away and your HP is back to normal again&#8230;.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

