function calcUnitStr(&$objUser, $unit_off, $unit_def) { require_once 'inc/functions/bonuses.php'; $arrSci = getSciences($objUser->get_stat(ALLIANCE)); // possibly + spells + war, but I dont think that part of the mod off is // intresting here (same with def) $X = $unit_off * (1 + $arrSci['war']); $Y = $unit_def * (1 + $arrSci['def']); // a fifteenth of a str pt for each off pt beyond half of def, if that is // positive. $def_str = $Y / 4 + max($X - $Y / 2, 0) / 15; // 5% more str on the unit for having turtle at all, then 1/20:th of a str // pt for each def pt. $off_str = $X / 4 * (1 + min($Y, 0.05)) + $Y / 20; // taking the highest of the two above $unit_str = max($off_str, $def_str); return $unit_str; }
function getArmyDefence(&$objUser, $attack_type = '') { $arrUnitInfo = getUnitVariables($objUser->get_stat(RACE)); $arrUnitDefence = $arrUnitInfo['defence']; // Raw deffence $arrArmy = $objUser->get_armys(); $raw_defence = $arrArmy[UNIT1] * $arrUnitDefence[2] + $arrArmy[UNIT2] * $arrUnitDefence[3] + $arrArmy[UNIT3] * $arrUnitDefence[4] + $arrArmy[UNIT4] * $arrUnitDefence[5] + $arrArmy[UNIT5] * $arrUnitDefence[6]; // Bonus From Walls $arrBuildBonus = getBuildBonuses($objUser); $wall_bonus = floor($raw_defence * $arrBuildBonus['defence']); // Bonus From Science $arrSci = getSciences($objUser->get_stat(ALLIANCE)); $research_bonus = floor($raw_defence * $arrSci['def']); // Bonus From Spells $arrSpellBonus = getSpellBonuses($objUser); $spell_bonus = floor($raw_defence * $arrSpellBonus['defence']); // Total $total = $raw_defence + $wall_bonus + $research_bonus + $spell_bonus; // Total Home $arrArmyHome = $objUser->get_armys_home(); $raw_defence_home = $arrArmyHome[UNIT1] * $arrUnitDefence[2] + $arrArmyHome[UNIT2] * $arrUnitDefence[3] + $arrArmyHome[UNIT3] * $arrUnitDefence[4] + $arrArmyHome[UNIT4] * $arrUnitDefence[5] + $arrArmyHome[UNIT5] * $arrUnitDefence[6]; // this'll add 15% to raw, fixed now - AI 16/11/06 //if ($attack_type == ATTACK_RAID) // $raw_defence_home *= 1.15; $home_raid = 0; if ($attack_type == ATTACK_RAID) { $home_raid = floor($raw_defence_home * 0.15); } $home_spell = floor($raw_defence_home * $arrSpellBonus['defence']); $home_research = floor($raw_defence_home * $arrSci['def']); $home_walls = floor($raw_defence_home * $arrBuildBonus['defence']); $total_home = $raw_defence_home + $home_spell + $home_research + $home_walls + $home_raid; $defence['raw'] = $raw_defence; $defence['building_bonus'] = $wall_bonus; $defence['research_bonus'] = $research_bonus; $defence['spell_bonus'] = $spell_bonus; $defence['total'] = $total; $defence['total_home'] = $total_home; return $defence; }
function getSentOffence(&$objUser, $arrArmySent) { $arrUnitInfo = getUnitVariables($objUser->get_stat(RACE)); $arrUnitOffence = $arrUnitInfo['offence']; // Raw offence $raw_offence = $arrArmySent[UNIT1] * $arrUnitOffence[2] + $arrArmySent[UNIT2] * $arrUnitOffence[3] + $arrArmySent[UNIT3] * $arrUnitOffence[4] + $arrArmySent[UNIT4] * $arrUnitOffence[5] + $arrArmySent[UNIT5] * $arrUnitOffence[6]; // Bonus From Weaponries $arrBuildBonus = getBuildBonuses($objUser); $weapon_bonus = floor($raw_offence * $arrBuildBonus['offence']); // Bonus From Science $arrSci = getSciences($objUser->get_stat(ALLIANCE)); $research_bonus = floor($raw_offence * $arrSci['war']); // Bonus From Spells $arrSpellBonus = getSpellBonuses($objUser); $spell_bonus = floor($raw_offence * $arrSpellBonus['offence']); // Bonus From Fame Martel, September 25, 2007 $arrFameBonus = getFameBonuses($objUser); $fame_bonus = floor($raw_offence * $arrFameBonus['offence']); // Total $total = $raw_offence + $weapon_bonus + $research_bonus + $spell_bonus + $fame_bonus; return $total; }