slyte33 Posted March 9, 2010 Share Posted March 9, 2010 Hello, for 5 hours straight now I have been altering my MMORPG game battle formulas(or should I say min/max damage formulas). I have so far, what I think is pretty decent, a formula that calculates how hard the attacker will hit based on his/her strength vs the enemies defence. If anyone knows of a better formula, please do give me advice , else how did I do? if ($defarmor->recordcount() > 0) { $defarm=$defarmor->fetchrow(); $defarmdef = $defarm['damage'] / 100; }else{ $defarmdef = 1; } if ($atkerweapon->recordcount() > 0) { $atkwep=$atkerweapon->fetchrow(); $atkwepatk = $atkwep['damage'] / 100; }else{ $atkwepatk = 1; } $mult=$atker->strength/$def->defence/10; $defender = (($def->defence * .25) + ($def->defence * $defarmdef) + ($def->defence * $mult)); $atkmaxdmg= ((($atker->strength * $atkwepatk) + (($atker->strength) * 1))) - $defender; $atkmindmg= ((($atker->strength * $atkwepatk) + (($atker->strength) * .7))) - $defender; $atker->maxdmg = $atkmaxdmg; $atker->maxdmg = ($atker->maxdmg <= 1)?0:$atker->maxdmg; $atker->maxdmg = ($atker->maxdmg <= 1)?0:$atker->maxdmg; $atker->mindmg = $atkmindmg; $atker->mindmg = ($atker->mindmg <= 1)?0:$atker->mindmg; $atkerdmgg = mt_rand($atker->mindmg, $atker->maxdmg); Link to comment https://forums.phpfreaks.com/topic/194597-calculating-max-damage-with-strength-vs-defence-is-this-a-good-way/ Share on other sites More sharing options...
gizmola Posted March 9, 2010 Share Posted March 9, 2010 Your example uses: $def->defence without any prior reference to where that values comes from or what it is. Your variable $defarmdef isn't explained. You also retrieve one weapon... so does that mean that there's no dual weilding? If you really want any feedback on this, you have to provide some background about the stats and what your intention is. Otherwise, you have some equations ... if they work alright I guess it's ok, but I'm not sure what the algorithm is you're working with or if there's anything I could suggest to you that might be an improvement. Link to comment https://forums.phpfreaks.com/topic/194597-calculating-max-damage-with-strength-vs-defence-is-this-a-good-way/#findComment-1023473 Share on other sites More sharing options...
slyte33 Posted March 9, 2010 Author Share Posted March 9, 2010 Your example uses: $def->defence without any prior reference to where that values comes from or what it is. Your variable $defarmdef isn't explained. You also retrieve one weapon... so does that mean that there's no dual weilding? If you really want any feedback on this, you have to provide some background about the stats and what your intention is. Otherwise, you have some equations ... if they work alright I guess it's ok, but I'm not sure what the algorithm is you're working with or if there's anything I could suggest to you that might be an improvement. Sorry. I am using ADODB, and I left the top part out: $atker = $db->execute("select * from players where id=$player->id"); $attacker = $atker->fetchrow(); foreach($attacker as $key=>$value) { $atker->$key = $value; } $def = $db->execute("select * from players where id=".$_GET['id'].""); $defender = $def->fetchrow(); foreach($defender as $key=>$value) { $def->$key = $value; } $atkerweapon=$db->execute("select * from pweapons where player_id=".$atker->id." and status='eq' and type='weapon'"); $defarmor=$db->execute("select * from pweapons where player_id=".$def->id." and status='eq' and type='armour'"); $defarmdef = Defenders armor / 100 // divide by 100 to get a percent of the defenders armor; i.e 1,000 defence * .75(75) = +750 extra defence As for the algorithm, I will have to try and work that out, but it would take awhile. It works alright so far, i've used plenty of different combinations and all works well. I am just wondering, is there a better way. I've seen this used before: [your strength]/[enemies defence] but thats too simple and would give someone waaay to much strength if the defence is lower than the strength. Did i better explain it? Link to comment https://forums.phpfreaks.com/topic/194597-calculating-max-damage-with-strength-vs-defence-is-this-a-good-way/#findComment-1023475 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.