Jump to content

Calculating max damage with strength VS defence - is this a good way?


slyte33

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.