/* The HitChance has a max of +20(at 100 dex) same with AvoidChance The DamageMod(DMGMod) has a 5times max multiplier at 100 strength The CriticalBonus has a 40 max at 100 dex so a CritChance of 50 or higher(half the time) The CriticalRBonus has at the moment just a 0.05 chance increase(Just Saiyan race is added) */ Public Function CalcATK($Offense, $OType, $Defense, $DType, $Skill){ $OffStats = $this->GetStats($Offense, $OType); //Grab the Offenses Stats $DefStats = $this->Getstats($Defense, $DType); //Grab the Defenses Stats $OffRStats = $this->GetRacialBonus($OffStats->Race); //Grab the Offenses Racial Bonuses $DefRStats = $this->GetRacialBonus($DefStats->Race); //Grab the Defenses Racial Bonuses if($Skill == "None"){ if($OffStats->Powerlevel >= $DefStats->Powerlevel){ //Offense is stronger or Equal to Defense $PLDiff = $OffStats->Powerlevel - $DefStats->Powerlevel; //Find the PL Difference $HitChance = rand(0, ($OffStats->DEX + ($OffStats->DEX * 0.2) + ($PLDiff * 0.001))); //Get a random number between 0 and the OffenseDex + (OffenseDex * 0.14) + (PowerlevelDiff * 0.001) $AvoidChance = rand(0, (($DefStats->DEX + ($DefStats->DEX * 0.2)) - ($PLDiff * 0.001))); //Get a random number between 0 and the DefenseDex + (DefenseDex * 0.14) - (PowerlevelDiff * 0.001) if($HitChance > $AvoidChance){$ChanceToHit = 1;} //If HitChance is greater than AvoidChance then it's a hit if($AvoidChance > $HitChance){$ChanceToHit = 0;} //If AvoidCHance is greater than HitChance then it's a miss } else { //Offense is Weaker than Defense $PLDiff = $DefStats->Powerlevel - $OffStats->Powerlevel; //Find the PL Difference $HitChance = rand(0, (($OffStats->DEX + ($OffStats->DEX * 0.2)) - ($PLDiff * 0.001))); //Get a random number between 0 and the OffenseDex + (OffenseDex * 0.14) - (PowerlevelDiff * 0.001) $AvoidChance = rand(0, ($DefStats->DEX + ($DefStats->DEX * 0.2) + ($PLDiff * 0.001))); //Get a random number between 0 and the DefenseDex + (OffenseDex * 0.14) + (PowerlevelDiff * 0.001) if($HitChance > $AvoidChance){$ChanceToHit = 1;} //If HitChance is greater than AvoidChance then it's a hit if($AvoidChance > $HitChance){$ChanceToHit = 0;} //If AvoidCHance is greater than HitChance then it's a miss } if($ChanceToHit > 0){ //ChanceToHit greater than 0 so its a hit $DMGMod = ($OffStats->STR * 0.1); //Get the Offense Damage Modifier $WeaponDMG = rand(1, 5); //Weapon Damage(Until weapons are added I used 1 to 5) $DMG = round(($WeaponDMG * $DMGMod) + $WeaponDMG); //Get the total damage $CritChance = rand(1, 100); //The Critical chance of 1 to 100 $CritBonus = $OffStats->DEX * 0.4; //The Offense Critical Hit Bonus $CritRBonus = 100 * $OffRStats->CritChance; //Get the Racial Crit Bonus if($CritChance >= (90 - $CritBonus - $CritRBonus)){$DMG = $DMG * 2;$Crit=" - CRIT";} //If CritChance is greter than (90 - CritBonus - CritRBonus), then it's a critical hit. Double DMG return $DMG.$Crit; //Return the DMG to the game } else { //ChanceToHit was 0 so its a miss return "Missed"; //Return Miss to the game } } else { /* Process Skill Data - Still working on Melee will do skills after it's finsihed. */ } }

DBZ Game there is the link to see this in action. Right now each player has 1000pl, 5 dex and 5 strength. I just don't think the way I am doing this is the best way. If anyone has any thoughts or criticism on my code that would be greatly appreciated. I want to make this better.