function war_alli($source_alli, $target_alli) { require_once 'inc/classes/clsAlliance.php'; $objSrcAlli = new clsAlliance($source_alli); if (checkWarBetween($objSrcAlli, $target_alli)) { return 2; } else { return 0; } }
function include_thievery2_text() { global $op, $dplayer, $action, $amount, $amount_sent, $stop; include_once 'inc/functions/ops.php'; include_once 'inc/functions/thievery.php'; $objSrcUser =& $GLOBALS["objSrcUser"]; if ($objSrcUser->get_stat(RACE) == 'Templar') { echo '<div id="textMedium"><p>' . 'Your proud Templar people will not lower themselves to thievery practices.' . '</p></div>'; include_game_down(); exit; } if (!$dplayer) { $objTrgUser = $objSrcUser; } else { $objTrgUser = new clsUser($dplayer); } $arrTrgStats = $objTrgUser->get_stats(); if ($arrTrgStats[KILLED] == 0 && $arrTrgStats[RESET_OPTION] != 'yes' && !$objTrgUser->isPaused()) { set_op_vars(); // Verify attacker's status obj_check_protection($objSrcUser, 'thievery'); $op_level = get_op_level($objSrcUser); if ($op > $op_level) { echo "Please Do Not Edit Forms"; // make something to notifiy the admin if this happens include_game_down(); exit; } make_thievery($objSrcUser, $objTrgUser, $action[$op], $amount_sent, $amount, $stop); //====================================================================== // Report: War effects //====================================================================== require_once 'inc/functions/war.php'; $objSrcAlliance = $objSrcUser->get_alliance(); if (checkWarBetween($objSrcAlliance, $objTrgUser->get_stat(ALLIANCE))) { $objTrgAlliance = $objTrgUser->get_alliance(); if ($arrGains = testWarVictory($objSrcAlliance, $objTrgAlliance)) { // Append war-win message require_once 'inc/pages/war_room2.inc.php'; echo $strReport = '<div id="textMedium">' . '<p><strong class="positive">Your alliance has won the war!</strong></p>' . getVictoryReport($arrGains) . '</div>'; } } } else { echo $strDiv = '<div id="textMedium"><p>' . 'This tribe is either dead or paused.' . '<br /><br />' . '<a href="main.php?cat=game&page=thievery">' . 'Return' . '</a>' . '</p></div>'; } }
function doAttack(&$objSrcUser, &$objTrgUser, $arrSentArmy) { $srcId = $objSrcUser->get_userid(); $trgId = $objTrgUser->get_userid(); $srcKd = $objSrcUser->get_stat(KINGDOM); $trgKd = $objTrgUser->get_stat(KINGDOM); $arrTrgBuilds = $objTrgUser->get_builds(); $iSrcLand = $objSrcUser->get_build(LAND); //========================================================================== // Standard Attack: Acres and Fame //========================================================================== $gains = pow($arrTrgBuilds[LAND] / $iSrcLand, 2) + $arrTrgBuilds[LAND] / ($iSrcLand * 3); $gains = min($gains, 1); $standard_gains = 0.115 * $gains; // Oleg Hai bonus $strSrcRace = $objSrcUser->get_stat(RACE); if ($strSrcRace == "Oleg Hai") { $standard_gains *= 1.3; } if ($standard_gains * $arrTrgBuilds[LAND] > $iSrcLand * 1.3 * $standard_gains) { $standard_gains *= $iSrcLand * 1.3 / $arrTrgBuilds[LAND]; } if ($arrTrgBuilds[LAND] > $iSrcLand * 3) { $standard_gains /= 2; } //========================================================================== // War effects on gains //========================================================================== include_once "inc/functions/war.php"; $modifier = war_alli($srcKd, $trgKd); if ($modifier == 2) { $standard_gains *= 1.2; } $target = war_target($trgKd); if ($target != 0 && $modifier == 0) { $standard_gains *= 0.95; } //========================================================================== // Spell effects on gains //========================================================================== if ($objTrgUser->get_spell(FOREST) > 0) { $standard_gains *= 0.8; } if ($objSrcUser->get_spell(MORTALITY) > 0) { $standard_gains += 0.01; } //========================================================================== // Bottom feed penalty on gains //========================================================================== if ($arrTrgBuilds[LAND] / $iSrcLand < 0.8 && $arrTrgBuilds[LAND] < 1500) { $bottom_feeder_difference = $arrTrgBuilds[LAND] / $iSrcLand; $bottom_feeder_penalty = (0.8 - $bottom_feeder_difference) / 10; $standard_gains -= 5 * $bottom_feeder_penalty; } elseif ($arrTrgBuilds[LAND] / $iSrcLand < 0.8 && $arrTrgBuilds[LAND] > 1499) { $bottom_feeder_difference = $arrTrgBuilds[LAND] / $iSrcLand; $bottom_feeder_penalty = (0.85 - $bottom_feeder_difference) / 10; $standard_gains -= 5 * $bottom_feeder_penalty; } //========================================================================== // Minimum Gains limit //========================================================================== if ($standard_gains < 0.01) { $standard_gains = 0.01; } //========================================================================== // Calculate Acre Gains //========================================================================== include_once 'inc/functions/build.php'; $arrBuildVars = getBuildingVariables($objTrgUser->get_stat(RACE)); $arrBuildVars = $arrBuildVars['variables']; $max_build = $objTrgUser->get_number_build_types(); $total_grab = 0; // Built for ($i = 1; $i <= $max_build; $i++) { $strVar = trim($arrBuildVars[$i]); $acres_won[$strVar] = round($arrTrgBuilds[$strVar] * $standard_gains); $buildings = $objTrgUser->get_build($strVar); $land = $objTrgUser->get_build(LAND); $arrBuilds = array($strVar => $buildings - $acres_won[$strVar], LAND => $land - $acres_won[$strVar]); $objTrgUser->set_builds($arrBuilds); $total_grab += $acres_won[$strVar]; } // 1 hour for ($i = 1; $i <= $max_build; $i++) { $strVar = trim($arrBuildVars[$i]); $strVar = $strVar . "_t1"; $acres_won[$strVar] = round($arrTrgBuilds[$strVar] * $standard_gains); $buildings = $objTrgUser->get_build($strVar); $land = $objTrgUser->get_build(LAND); $arrBuilds = array($strVar => $buildings - $acres_won[$strVar], LAND => $land - $acres_won[$strVar]); $objTrgUser->set_builds($arrBuilds); $total_grab += $acres_won[$strVar]; } // 2 hours for ($i = 1; $i <= $max_build; $i++) { $strVar = trim($arrBuildVars[$i]); $strVar = $strVar . "_t2"; $acres_won[$strVar] = round($arrTrgBuilds[$strVar] * $standard_gains); $buildings = $objTrgUser->get_build($strVar); $land = $objTrgUser->get_build(LAND); $arrBuilds = array($strVar => $buildings - $acres_won[$strVar], LAND => $land - $acres_won[$strVar]); $objTrgUser->set_builds($arrBuilds); $total_grab += $acres_won[$strVar]; } // 3 hours for ($i = 1; $i <= $max_build; $i++) { $strVar = trim($arrBuildVars[$i]); $strVar = $strVar . "_t3"; $acres_won[$strVar] = round($arrTrgBuilds[$strVar] * $standard_gains); $buildings = $objTrgUser->get_build($strVar); $land = $objTrgUser->get_build(LAND); $arrBuilds = array($strVar => $buildings - $acres_won[$strVar], LAND => $land - $acres_won[$strVar]); $objTrgUser->set_builds($arrBuilds); $total_grab += $acres_won[$strVar]; } // 4 hours for ($i = 1; $i <= $max_build; $i++) { $strVar = trim($arrBuildVars[$i]); $strVar = $strVar . "_t4"; $acres_won[$strVar] = round($arrTrgBuilds[$strVar] * $standard_gains); $buildings = $objTrgUser->get_build($strVar); $land = $objTrgUser->get_build(LAND); $arrBuilds = array($strVar => $buildings - $acres_won[$strVar], LAND => $land - $acres_won[$strVar]); $objTrgUser->set_builds($arrBuilds); $total_grab += $acres_won[$strVar]; } // Explored $explore_gains = 0.2; $acres_explored = round($total_grab * $explore_gains); $land = $objSrcUser->get_build(LAND); $objSrcUser->set_build(LAND, $land + $acres_explored); //========================================================================== // Record //========================================================================== $fetch_record = mysql_query("Select * from records where id = 1"); $fetch_record = @mysql_fetch_array($fetch_record); if ($total_grab > $fetch_record['grab']) { $id = $objSrcUser->get_userid(); $update = mysql_query("Update records set grab = {$total_grab}, grab_id = {$id} where id = 1"); } //========================================================================== // Return time //========================================================================== $wait = 4; // 4 hour attack time if ($strSrcRace == "Raven") { $wait = 1; } elseif ($strSrcRace == "Mori Hai" || $strSrcRace == "Dragon") { $wait = 3; } $landtime = 'land_t' . $wait; $objSrcUser->set_user_info(NEXT_ATTACK, $wait); //========================================================================== // Add land to incoming //========================================================================== if ($total_grab > 0) { $old_land = $objSrcUser->get_build($landtime); $objSrcUser->set_build($landtime, $total_grab + $old_land); } //========================================================================== // Calculate Fame Gains //========================================================================== $fame_win = max(0, $total_grab * 2); // War effects include_once 'inc/functions/war.php'; $objSrcAlliance = $objSrcUser->get_alliance(); if (checkWarBetween($objSrcAlliance, $trgKd)) { // Update land counter in new war system March 06, 2008 Martel $iNeeded = $objSrcAlliance->get_war('land_needed'); $objSrcAlliance->set_war('land_needed', max(0, $iNeeded - $total_grab)); // War effects on fame $fame_win *= 1.2; } // Cannot take more fame than what the target has $fame_win = round($fame_win); $target_fame = $objTrgUser->get_stat(FAME); if ($fame_win > $target_fame) { $fame_win = $target_fame; } $fame1 = $objSrcUser->get_stat(FAME) + $fame_win; $fame2 = $target_fame - $fame_win; $objSrcUser->set_stat(FAME, $fame1); $objTrgUser->set_stat(FAME, $fame2); //========================================================================== $arrResults['gained_acres'] = $total_grab; $arrResults['explored_acres'] = $acres_explored; $arrResults['gained_fame'] = $fame_win; return $arrResults; }
function include_invade2_text() { global $ip; $objSrcUser =& $GLOBALS["objSrcUser"]; $arrSrcUser = $objSrcUser->get_user_infos(); $arrSrcStats = $objSrcUser->get_stats(); //========================================================================== // Secure user input from the invasion form //========================================================================== if (isset($_POST['TrgPlayer']) && !empty($_POST['TrgPlayer']) && $_POST['TrgPlayer'] != 'spacer') { // Selected Target $iTrgUserId = abs(intval($_POST['TrgPlayer'])); } else { echo $strDiv = '<div id="textMedium"><p>' . "Your army walk back to their homes, you should give them a " . "target next time!" . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . "Try Again ?" . "</a>" . '</p></div>'; include_game_down(); exit; } $arrWhite = array('1', '2', '3', '4', '5'); $arrWhite2 = array(1 => 'standard', 'raid', 'barren', 'hitnrun', 'bc'); // Selected Target if (isset($_POST['invade_type']) && in_array($_POST['invade_type'], $arrWhite)) { $iAttack = intval($_POST['invade_type']); } else { echo $strDiv = '<div id="textMedium"><p>' . "Your army walk back to their homes, you should give them a " . "target next time!" . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . "Try Again ?" . "</a>" . '</p></div>'; include_game_down(); exit; } // Army Sent $arrUnitVars = getUnitVariables($arrSrcStats[RACE]); $arrUnitOffence = $arrUnitVars['offence']; $arrUnitVar = $arrUnitVars['variables']; if (isset($_POST["arrArmySent"])) { $arrArmySent = $_POST["arrArmySent"]; foreach ($arrUnitOffence as $i => $iUnitOffence) { if ($iUnitOffence > 0) { $arrArmySent[$arrUnitVar[$i]] = max(0, intval($arrArmySent[$arrUnitVar[$i]])); } else { $arrArmySent[$arrUnitVar[$i]] = 0; } } } //========================================================================== // Verify attacker's status //========================================================================== obj_check_protection($objSrcUser, "invade"); $iTotalSentArmy = array_sum($arrArmySent); if ($iTotalSentArmy < 1) { echo $strDiv = '<div id="textMedium"><p>' . 'Sorry, but you did not send any units to battle.<br />' . 'This attack has been aborted.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . "Try Again ?" . "</a>" . '</p></div>'; include_game_down(); exit; } if (verifyArmyAvailable($objSrcUser, $arrArmySent) == 1) { echo $strDiv = '<div id="textMedium"><p>' . 'Sorry, you do not have that many units to send.<br />' . 'This attack has been aborted.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . "Try Again ?" . "</a>" . '</p></div>'; include_game_down(); exit; } if ($arrSrcStats[RACE] == "Oleg Hai" && verifyArmyAvailableOleg($objSrcUser, $arrArmySent) == 1) { $mercsTrainedThisHour = $objSrcUser->get_army_merc(MERC_T3); echo $strDiv = '<div id="textMedium"><p>' . "Sorry, but you did only train {$mercsTrainedThisHour} " . "mercs this update and that's the maximum you may use for an " . "attack.<br />" . "This attack has been aborted." . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . "Try Again ?" . "</a>" . '</p></div>'; include_game_down(); exit; } if ($arrSrcUser[NEXT_ATTACK] > 0) { echo $strDiv = '<div id="textMedium"><p>' . 'Sorry, but you cannot attack for at least ' . $arrSrcUser[NEXT_ATTACK] . ' more updates.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } if ($arrSrcUser[HOURS] < PROTECTION_HOURS) { echo $strDiv = '<div id="textMedium"><p>' . 'You are not allowed to attack while in protection!' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } //========================================================================== // Verify defender's status //========================================================================== include_once 'inc/functions/update.php'; check_to_update($iTrgUserId); $objTrgUser = new clsUser($iTrgUserId); $arrTrgStats = $objTrgUser->get_stats(); if ($arrTrgStats[ALLIANCE] == $objSrcUser->get_stat(ALLIANCE)) { echo $strDiv = '<div id="textMedium"><p>' . 'Sorry, honor before might. Do not attack into your own alliance.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } elseif ($objTrgUser->get_stat(ALLIANCE) < 11) { echo $strDiv = '<div id="textMedium"><p>' . 'I hope you did not think that you would get away with ' . 'attacking into a staff alliance, did you?' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } // Frost: Added a global protection mode include_once 'inc/classes/clsGame.php'; $objGame = new clsGame(); if ($objGame->get_game_switch(GLOBAL_PROTECTION) == 'on') { echo $strDiv = '<div id="textMedium"><p>' . 'Because of a global event all tribes in ORKFiA are under ' . 'protection. Please check the community forum for an announcement.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } $iTrgHours = $objTrgUser->get_user_info(HOURS); if ($iTrgHours < PROTECTION_HOURS) { $iTrgHoursRemaining = PROTECTION_HOURS - $iTrgHours; echo $strDiv = '<div id="textMedium"><p>' . 'It appears that the tribe you wish to target is still ' . 'materializing. Our general estimates that it will ' . 'take another ' . $iTrgHoursRemaining . ' updates for the area ' . 'to become a stable part of reality.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } if ($objTrgUser->get_stat(ALLIANCE) == 0) { echo $strDiv = '<div id="textMedium"><p>' . 'This player has either been deleted or suspended.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } // Frost: added jan -04 // Martel: updated July 08, 2006 if ($objTrgUser->get_stat(KILLED) == 1 || $objTrgUser->get_stat(RESET_OPTION) == 'yes') { echo $strDiv = '<div id="textMedium"><p>' . 'This tribe is dead.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } // Paused account Martel, July 13, 2006 if ($objTrgUser->isPaused()) { echo $strDiv = '<div id="textMedium"><p>' . 'This tribe is paused.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Return' . '</a>' . '</p></div>'; return; } // Blocking system - AI 11/02/2007 if (!clsBlock::isOpAllowed($objSrcUser, $objTrgUser)) { echo '<div id="textMedium"><p>' . 'Someone else from the same IP has already opped this tribe during the last 8 hours.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">Return</a>' . '</p></div>'; clsBlock::reportOp($objSrcUser, $objTrgUser, 'Attack: ' . $arrWhite2[$iAttack], false); return; } $iTrgLand = $objTrgUser->get_build(LAND); $iSrcLand = $objSrcUser->get_build(LAND); $breakoff = round($iSrcLand * 0.7); // Barren attack has 70% bottom feed limit if smaller than 2000 acres if ($iAttack == ATTACK_BARREN && $iTrgLand <= $breakoff && $iTrgLand < 2000) { echo $strDiv = '<div id="textMedium"><p>' . 'Sorry but you can not bash the small ones. Barren grabs are not ' . 'allowed against smaller tribes unless they are within 70% ' . 'of your own size.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Try Again ?' . '</a>' . '</p></div>'; include_game_down(); exit; } if ($iAttack == ATTACK_HNR && $iTrgLand < $iSrcLand) { echo $strDiv = '<div id="textMedium"><p>' . 'What kind of coward are you who try to make a Hit \'n\' Run ' . 'attack against a smaller tribe?' . '</p><p>' . 'Shame on you!' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Return' . '</a>' . '</p></div>'; include_game_down(); exit; } $quick_check = mysql_query("Select * from user where id = 1"); $quick_check = mysql_fetch_array($quick_check); if ($quick_check[STOPGAMETRIGGER] == 99) { echo $strDiv = '<div id="textMedium"><p>' . 'The game has been paused by staff, possibly due to technical ' . 'maintenance. Please look in the announcements ' . 'forum or the admin game message for more information.' . '</p><p>' . '<a href="main.php?cat=game&page=invade">' . 'Return' . '</a>' . '</p></div>'; include_game_down(); exit; } else { //====================================================================== // Do Battle //====================================================================== /* include the code for the attack about to be done */ include_once "inc/attacks/" . $arrWhite2[$iAttack] . ".php"; // Damadm00 19-03-2004, check here the result from the viking check // Martel: Notify thieves about attack only if not viking+25% luck if ($arrSrcStats[RACE] == 'Viking' && getVikingCheck() == 1) { $viking = 1; } else { $viking = 0; getMonitoringCheck($objSrcUser); } include_once 'inc/functions/military.php'; $defence = getArmyDefence($objTrgUser, $iAttack); $defence = $defence['total_home']; $offence = getSentOffence($objSrcUser, $arrArmySent); //Attacking Templars kills mystics, not thieves - AI $thieves = 'thieves'; if ($objTrgUser->get_stat(RACE) == 'Templar') { $thieves = 'mystics'; } // Eagle 30% auto force retreat feature if ($objTrgUser->get_stat(RACE) == "Eagle" && getEagleCheck() == 1) { doRetreat($objSrcUser, $objTrgUser, $arrArmySent, 1, 0); return; } elseif ($offence < $defence && $iAttack != ATTACK_HNR) { doRetreat($objSrcUser, $objTrgUser, $arrArmySent, 0, $viking); return; } elseif ($offence < $defence && $iAttack == ATTACK_HNR) { if ($offence > 0.5 * $defence) { if ($defence == 0) { $defence = 1; } $arrSrcArmyLost = getSrcLosses($objSrcUser, $arrArmySent, $offence / $defence, $arrWhite2[$iAttack]); $arrTrgArmyLost = getTrgLosses($objTrgUser, $objSrcUser, $offence / $defence, $arrWhite2[$iAttack]); $arrReport = doAttack($objSrcUser, $objTrgUser, $arrArmySent); } else { doRetreat($objSrcUser, $objTrgUser, $arrArmySent, 0, $viking); return; } } else { if ($defence == 0) { $defence = 1; } $arrSrcArmyLost = getSrcLosses($objSrcUser, $arrArmySent, $offence / $defence, $arrWhite2[$iAttack]); $arrTrgArmyLost = getTrgLosses($objTrgUser, $objSrcUser, $offence / $defence, $arrWhite2[$iAttack]); $arrReport = doAttack($objSrcUser, $objTrgUser, $arrArmySent); } // Spread Pestilence $arrSpreadPest = checkPestilence($objSrcUser, $objTrgUser); $pestSrc = $arrSpreadPest['attacker']; $pestTrg = $arrSpreadPest['defender']; //====================================================================== // Begin creating the invade report //====================================================================== $strTribe = stripslashes($objTrgUser->get_rankings_personal(TRIBE_NAME)); $iAlliance = $arrTrgStats[ALLIANCE]; $strReport = '<div id="textMedium">' . '<h2>' . "Invade Report" . '</h2>' . '<p>' . 'Your invasion of <strong>' . $strTribe . ' (#' . $iAlliance . ')</strong> was successful, ' . 'below follows a report from your general.' . '</p>'; //====================================================================== // Report: Gains //====================================================================== // Acres if (isset($arrReport['gained_acres']) && $arrReport['gained_acres'] != 0) { $strReport .= '<p>' . "Our army has gained control over " . "<strong>" . $arrReport['gained_acres'] . " acres</strong>. "; // Explored Acres if (isset($arrReport['explored_acres']) && $arrReport['explored_acres'] != 0) { $strReport .= "Also <strong>" . $arrReport['explored_acres'] . " acres</strong> was " . "explored and can be used to build on now."; } $strReport .= '</p>'; } // Citizens Killed (raid or hnr) if (isset($arrReport['killed_citizens']) && $arrReport['killed_citizens'] != 0) { $strReport .= '<p>' . "Our army storm into their lands, killing <strong>" . $arrReport['killed_citizens'] . "</strong> of their citizens." . '</p>'; } // Money (raid) if (isset($arrReport['gained_crowns']) && $arrReport['gained_crowns'] != 0) { $strReport .= '<p>' . "The army report having stolen <strong class=\"indicator\">" . number_format($arrReport['gained_crowns']) . " crowns</strong>." . '</p>'; } // Buildings Razed (blasphemy crusade) if (isset($arrReport['damaged_total']) && $arrReport['damaged_total'] != 0) { $strReport .= '<p>' . "Your loyal army charges into their lands, destroying <strong>" . $arrReport['damaged_total'] . " buildings</strong> of witchcraft " . "and deception. ("; // Academies if (isset($arrReport['damaged_academies']) && $arrReport['damaged_academies'] != 0) { $strReport .= " <strong>" . $arrReport['damaged_academies'] . " academies</strong>"; } // Guilds if (isset($arrReport['damaged_guilds']) && $arrReport['damaged_guilds'] != 0) { $strReport .= " <strong>" . $arrReport['damaged_guilds'] . " guilds</strong>"; } // Hideouts if (isset($arrReport['damaged_hideouts']) && $arrReport['damaged_hideouts'] != 0) { $strReport .= " <strong>" . $arrReport['damaged_hideouts'] . " hideouts</strong>"; } $strReport .= ').</p>'; } // Thieves Killed (blasphemy crusade) if (isset($arrReport['killed_thieves']) && $arrReport['killed_thieves'] != 0) { $strReport .= '<p>' . "Your general reports having killed <strong>" . $arrReport['killed_thieves'] . " {$thieves} of the enemy</strong>." . '</p>'; } // Fame Gained if (isset($arrReport['gained_fame']) && $arrReport['gained_fame'] != 0) { $strReport .= '<p>' . "This invasion gave our tribe <strong class=\"positive\">" . $arrReport['gained_fame'] . " fame</strong>." . '</p>'; } //====================================================================== // Begin enemy defence estimation (report) //====================================================================== if ($offence > $defence * 2) { $strReport .= '<p>' . "Our army is more than double the power of the " . "defending army, causing the enemy to run in fear. (Victory " . "by more than 100%)" . '</p>'; } elseif ($offence > $defence * 1.8) { $strReport .= '<p>' . "Our army is almost double the power of the defending " . "army. (Victory by more than 80%)" . '</p>'; } elseif ($offence > $defence * 1.6) { $strReport .= '<p>' . "Our army has easily broken the enemies defences, " . "overpowering them by more than 3 to 2. (Victory by more " . "than 60%)" . '</p>'; } elseif ($offence > $defence * 1.4) { $strReport .= '<p>' . "Our army has broken the enemies defences, overpowering " . "them by around 3 to 2. (Victory by more than 40%)" . '</p>'; } elseif ($offence > $defence * 1.2) { $strReport .= '<p>' . "Our army has broken through the line of defence, but it was " . "a hard battle. (Victory by more than 20%)" . '</p>'; } elseif ($offence > $defence * 1.1) { $strReport .= '<p>' . "Our army has broken through the line of defence, but it was " . "a very tough battle. (Victory by more than 10%)" . '</p>'; } elseif ($offence >= $defence) { $strReport .= '<p>' . "Our army fought hard, winning only after a lengthy and very " . "difficult battle. (Victory by less than 10%)" . '</p>'; } //====================================================================== // Report: Army Losses //====================================================================== $arrUnitVars = getUnitVariables($objSrcUser->get_stat(RACE)); $arrUnitNames = $arrUnitVars['output']; $strPlural = 's'; $strReport .= '<p>' . "The captains report that we have lost "; if ($arrSrcArmyLost[UNIT1] > 0) { $strReport .= $arrSrcArmyLost[UNIT1] . " " . $arrUnitNames[2] . $strPlural . ", "; } if ($arrSrcArmyLost[UNIT2] > 0) { if ($arrUnitNames[3] == 'Swordmen') { $strPlural = ''; } elseif ($arrUnitNames[3] == 'Pikemen') { $strPlural = ''; } $strReport .= $arrSrcArmyLost[UNIT2] . " " . $arrUnitNames[3] . $strPlural . ", "; } if ($arrSrcArmyLost[UNIT3] > 0) { if ($arrUnitNames[4] == 'Crossbowmen') { $strPlural = ''; } elseif ($arrUnitNames[4] == 'Longbowmen') { $strPlural = ''; } elseif ($arrUnitNames[4] == 'Mummy') { $arrUnitNames[4] = 'Mummie'; } $strReport .= $arrSrcArmyLost[UNIT3] . " " . $arrUnitNames[4] . $strPlural . ", "; } if ($arrSrcArmyLost[UNIT4] > 0) { if ($arrUnitNames[5] == 'Priestess') { $strPlural = ''; } $strReport .= $arrSrcArmyLost[UNIT4] . " " . $arrUnitNames[5] . $strPlural . ", "; } if ($arrSrcArmyLost[UNIT5] > 0) { if ($arrUnitNames[6] == 'Thief') { $arrUnitNames[6] = 'Thieve'; } $strReport .= $arrSrcArmyLost[UNIT5] . " " . $arrUnitNames[6] . $strPlural . ", "; } if (array_sum($arrSrcArmyLost) < 1) { $strReport .= " no military at all, "; } $totalkilled = round(array_sum($arrTrgArmyLost), -2); if ($totalkilled > 0) { $strReport .= " and they estimate the enemy's losses to be {$totalkilled} units"; if ($objSrcUser->get_stat(RACE) == "Undead") { $strReport .= ", who joined our cursed army as soldiers."; } } else { $strReport .= " and they estimate the enemy's losses to be near zero"; } $strReport .= '.</p>'; //====================================================================== // Report: Army available again //====================================================================== $wait = $objSrcUser->get_user_info(NEXT_ATTACK); $strReport .= '<p>' . "Our generals report our army will be able to attack again " . "in " . $wait . " updates. "; if ($wait > 4) { // Assuming that an attack with more than 4 hours is a BC or Hitnrun $wait -= 2; $strReport .= "However, our army will be home to defend our lands after " . $wait . " updates."; } $strReport .= '</p>'; //====================================================================== // Report: Pestilence //====================================================================== if ($pestSrc == "yes") { $strReport .= '<p>' . "<strong class=\"negative\">During your invasion your military " . "got infected with pestilence.</strong>" . '</p>'; } //====================================================================== // frost: added suicide detection | modified for age 18. only one update // loss of 25% citizens //====================================================================== $suicide = getSuicideCheck($objSrcUser, $arrArmySent); if ($arrSrcStats[RACE] != "Raven" && $suicide == 1) { $citz = $objSrcUser->get_pop(CITIZENS); $leavingCitz = floor($citz * 0.25); $strReport .= '<p>' . "<strong class=\"negative\">Your citizens are getting tired of " . "their tax money going to far-away military campaigns " . "instead of defending their homes. " . number_format($leavingCitz) . " citizens have left your lands.</strong>" . '</p>'; $objSrcUser->set_pop(CITIZENS, $citz - $leavingCitz); } //====================================================================== // Report: Viking Stealth Attack //====================================================================== if ($viking == 1) { $strReport .= '<p>' . "<strong class=\"positive\">You got lucky. Your location " . "doesn't end up in the news.</strong>" . '</p>'; } //====================================================================== // Report: War effects //====================================================================== require_once 'inc/functions/war.php'; $objSrcAlliance = $objSrcUser->get_alliance(); if (checkWarBetween($objSrcAlliance, $objTrgUser->get_stat(ALLIANCE))) { $objTrgAlliance = $objTrgUser->get_alliance(); if ($arrGains = testWarVictory($objSrcAlliance, $objTrgAlliance)) { // Append war-win message require_once 'inc/pages/war_room2.inc.php'; $strReport .= '<p><strong class="positive">Your alliance has won the war!</strong></p>' . getVictoryReport($arrGains); } } $strReport .= '<p>' . '<a href="main.php?cat=game&page=tribe">Continue</a>' . '</p>' . '</div>'; echo $strReport; //====================================================================== // Defender tribe news (damage report) //====================================================================== $srcDisplay = $arrSrcStats[TRIBE] . " (#" . $arrSrcStats[ALLIANCE] . ")"; $trgDisplay = $arrTrgStats[TRIBE] . " (#" . $arrTrgStats[ALLIANCE] . ")"; $strStrategy = $arrWhite2[$iAttack]; switch ($strStrategy) { case "standard": if ($viking == 0) { $strTrgTribe = "<span class=\"positive\">{$srcDisplay} has successfully marched into our lands and conquered " . $arrReport['gained_acres'] . " acres</span>"; $strTrgAlliance = "<span class=\"newsattack\">{$srcDisplay} has successfully marched into the lands of {$trgDisplay} and conquered " . $arrReport['gained_acres'] . " acres</span>"; } else { $strTrgTribe = "<span class=\"positive\">An unidentified tribe of vikings has successfully marched into our lands and conquered " . $arrReport['gained_acres'] . " acres</span>"; $strTrgAlliance = "<span class=\"newsattack\">An unidentified tribe of vikings has successfully marched into the lands of {$trgDisplay} and conquered " . $arrReport['gained_acres'] . " acres</span>"; } break; case "raid": if ($viking == 0) { $strTrgTribe = "<span class=\"positive\">{$srcDisplay} has successfully stormed into our lands and conquered " . $arrReport['gained_acres'] . " acres, stolen " . $arrReport['gained_crowns'] . " crowns and slaughtered " . $arrReport['killed_citizens'] . " citizens</span>"; $strTrgAlliance = "<span class=\"newsattack\">{$srcDisplay} has successfully stormed into the lands of {$trgDisplay} and conquered " . $arrReport['gained_acres'] . " acres, stolen " . $arrReport['gained_crowns'] . " crowns and slaughtered " . $arrReport['killed_citizens'] . " citizens</span>"; } else { $strTrgTribe = "<span class=\"positive\">An unidentified tribe of vikings has successfully stormed into our lands and conquered " . $arrReport['gained_acres'] . " acres, stolen " . $arrReport['gained_crowns'] . " crowns and slaughtered " . $arrReport['killed_citizens'] . " citizens</span>"; $strTrgAlliance = "<span class=\"newsattack\">An unidentified tribe of vikings has Successfully stormed into the lands of {$trgDisplay} and conquered " . $arrReport['gained_acres'] . " acres, stolen " . $arrReport['gained_crowns'] . " crowns and slaughtered " . $arrReport['killed_citizens'] . " citizens</span>"; } break; case "barren": if ($viking == 0) { $strTrgTribe = "<span class=\"newsattack\">{$srcDisplay} has successfully sneaked into our lands and claimed " . $arrReport['gained_acres'] . " acres</span>"; $strTrgAlliance = "<span class=\"newsattack\">{$srcDisplay} has successfully sneaked into the lands of {$trgDisplay} and claimed " . $arrReport['gained_acres'] . " acres</span>"; } else { $strTrgTribe = "<span class=\"newsattack\">An unidentified tribe of vikings has successfully sneaked into our lands and claimed " . $arrReport['gained_acres'] . " acres</span>"; $strTrgAlliance = "<span class=\"newsattack\">An unidentified tribe of vikings has successfully sneaked into the lands of {$trgDisplay} and claimed " . $arrReport['gained_acres'] . " acres</span>"; } break; case "bc": if ($viking == 0) { $strTrgTribe = "<span class=\"newsbc\">{$srcDisplay} has successfully charged into our lands and destroyed " . $arrReport['damaged_total'] . " buildings and killed " . $arrReport['killed_thieves'] . " {$thieves}. Our lands will be avaliable for building again after they have been cleared</span>"; $strTrgAlliance = "<span class=\"newsbc\">{$srcDisplay} has successfully charged into the lands of {$trgDisplay} and destroyed " . $arrReport['damaged_total'] . " buildings and slaughtered " . $arrReport['killed_thieves'] . " {$thieves}</span>"; } else { $strTrgTribe = "<span class=\"newsbc\">An unidentified tribe of vikings has successfully charged into our lands and destroyed " . $arrReport['damaged_total'] . " buildings and killed " . $arrReport['killed_thieves'] . " {$thieves}. Our lands will be avaliable for building again after they have been cleared</span>"; $strTrgAlliance = "<span class=\"newsbc\">An unidentified tribe of vikings has successfully charged into the lands of {$trgDisplay} and destroyed " . $arrReport['damaged_total'] . " buildings and killed " . $arrReport['killed_thieves'] . " {$thieves}</span>"; } break; case "hitnrun": $strAdd = ""; if ($offence >= $defence) { $strAdd = " and " . $arrReport['killed_citizens'] . " citizens"; } if ($viking == 0) { $strTrgTribe = "<span class=\"newsattack\">{$srcDisplay} has cowardly ambushed our lands, killing many troops" . $strAdd . "</span>"; $strTrgAlliance = "<span class=\"newsattack\">{$srcDisplay} has cowardly attacked and rained arrows over {$trgDisplay}, killing many troops" . $strAdd . "</span>"; } else { $strTrgTribe = "<span class=\"newsattack\">An unidentified tribe of vikings has cowardly ambushed our lands, killing many troops" . $strAdd . "</span></span>"; $strTrgAlliance = "<span class=\"newsattack\">An unidentified tribe of vikings has cowardly attacked and rained arrows over {$trgDisplay}, killing many troops" . $strAdd . "</span>"; } break; } $trgId = $objTrgUser->get_userid(); $srcId = $objSrcUser->get_userid(); $trgKd = $objTrgUser->get_stat(ALLIANCE); $srcKd = $objSrcUser->get_stat(ALLIANCE); if ($viking == 0) { $result = "INSERT INTO `news` VALUES ('', NOW(), '{$ip}', '{$strStrategy}', '{$trgId}', '{$srcId}', '1', " . quote_smart($strTrgTribe) . ", " . quote_smart($strTrgAlliance) . ",'{$trgKd}','{$srcKd}',1)"; } else { $result = "INSERT INTO `news` VALUES ('', NOW(), '{$ip}', '{$strStrategy}', '{$trgId}', '{$srcId}', '1', " . quote_smart($strTrgTribe) . ", " . quote_smart($strTrgAlliance) . ",'{$trgKd}',0,1)"; } mysql_query($result); $arrUnitVars = getUnitVariables($objTrgUser->get_stat(RACE)); $arrUnitNames = $arrUnitVars['output']; $strPlural = 's'; $strPlural2 = 's'; $strPlural3 = 's'; $strPlural4 = 's'; $strPlural5 = 's'; if ($arrUnitNames[3] == 'Swordmen') { $strPlural2 = ''; } elseif ($arrUnitNames[3] == 'Pikemen') { $strPlural2 = ''; } if ($arrUnitNames[4] == 'Crossbowmen') { $strPlural3 = ''; } elseif ($arrUnitNames[4] == 'Longbowmen') { $strPlural3 = ''; } elseif ($arrUnitNames[4] == 'Mummy') { $arrUnitNames[4] = 'Mummie'; } if ($arrUnitNames[5] == 'Priestess') { $strPlural4 = 'es'; } if ($arrUnitNames[6] == 'Thief') { $arrUnitNames[6] = 'Thieve'; } $strTrgNews = "A report has been collected, our losses are listed as follows: " . "<br />" . $arrUnitNames[2] . $strPlural . " killed: " . "<span class=\"negative\">" . $arrTrgArmyLost[UNIT1] . "</span>," . "<br />" . $arrUnitNames[3] . $strPlural2 . " killed: " . "<span class=\"negative\">" . $arrTrgArmyLost[UNIT2] . "</span>," . "<br />" . $arrUnitNames[4] . $strPlural3 . " killed: " . "<span class=\"negative\">" . $arrTrgArmyLost[UNIT3] . "</span>," . "<br />" . $arrUnitNames[5] . $strPlural4 . " killed: " . "<span class=\"negative\">" . $arrTrgArmyLost[UNIT4] . "</span>."; //Add mystic losses for templars - AI 24/04/2007 if ($arrTrgArmyLost[UNIT5] > 0) { $strTrgNews .= "<br />" . $arrUnitNames[6] . $strPlural5 . " killed: " . "<span class=\"negative\">" . $arrTrgArmyLost[UNIT5] . "</span>."; } if ($pestTrg == "yes") { $strTrgNews .= "<br />" . "<strong class=\"negative\">" . "During this invasion pestilence " . "was spread into our lands for 12 updates" . "</strong>."; } // create tribe news for attack mysql_query("INSERT INTO `news` (`id`, `time`, `ip`, `type`, `duser`, `ouser`, `result`, `text`, `kingdom_text`) VALUES ('', NOW(), '{$ip}', 'invade report', '{$arrTrgStats['id']}', '{$arrSrcStats['id']}', 1, '{$strTrgNews}', '')"); $orkTime = date(TIMESTAMP_FORMAT); $objTrgUser->set_user_info(LAST_NEWS, $orkTime); // Update target rankings include_once 'inc/functions/update_ranking.php'; doUpdateRankings($objTrgUser, 'yes'); // Log the op for blocking system - AI 11/02/2007 clsBlock::logOp($objSrcUser, $objTrgUser, 'Attack: ' . $arrWhite2[$iAttack]); } }
function doAttack(&$objSrcUser, &$objTrgUser, $arrSentArmy) { $srcId = $objSrcUser->get_userid(); $trgId = $objTrgUser->get_userid(); $srcKd = $objSrcUser->get_stat(ALLIANCE); $trgKd = $objTrgUser->get_stat(ALLIANCE); $iSrcLand = $objSrcUser->get_build(LAND); $iTrgLand = $objTrgUser->get_build(LAND); //========================================================================== // Barren Attack: Barren Acres and Fame //========================================================================== $gains = pow($iTrgLand / $iSrcLand, 2) + $iTrgLand / ($iSrcLand * 3); $gains = min($gains, 1); $barren_gains = 0.135 * $gains; // Oleg Hai bonus $strSrcRace = $objSrcUser->get_stat(RACE); if ($strSrcRace == "Oleg Hai") { $barren_gains = $barren_gains * 1.3; } //========================================================================== // Barren Grab Attack //========================================================================== $total_grab = 0; $max_grab = round($iTrgLand * $barren_gains); // Decide how many barren acres to take $intTrgBarren = $objTrgUser->get_barren(); if ($max_grab <= 0) { $total_grab = 0; } elseif ($max_grab < $intTrgBarren) { $total_grab = $max_grab; } else { $total_grab = $intTrgBarren; } // "Bottom feeding" penalties if ($iTrgLand / $iSrcLand < 0.75) { $total_grab = round($total_grab / 2); if ($iTrgLand / $iSrcLand < 0.5) { $total_grab = round($total_grab / 2); } } // "Top feeding" penalties if ($iTrgLand / $iSrcLand > 3) { $total_grab = round($total_grab / 2); if ($iTrgLand / $iSrcLand > 5) { $total_grab = round($total_grab / 2); } } //========================================================================== // Return time //========================================================================== $wait = 4; // 4 hour attack time if ($strSrcRace == "Raven") { $wait = 1; } elseif ($strSrcRace == "Mori Hai" || $strSrcRace == "Dragon") { $wait = 3; } $landtime = 'land_t' . $wait; $objSrcUser->set_user_info(NEXT_ATTACK, $wait); //========================================================================== // Update Target Land //========================================================================== $iNewLand = $iTrgLand - $total_grab; $objTrgUser->set_build(LAND, $iNewLand); //========================================================================== // Add land to incoming //========================================================================== if ($total_grab > 0) { $old_land = $objSrcUser->get_build($landtime); $objSrcUser->set_build($landtime, $total_grab + $old_land); } // Explored $explore_gains = 0.2; $acres_explored = round($total_grab * $explore_gains); $land = $objSrcUser->get_build(LAND); $objSrcUser->set_build(LAND, $land + $acres_explored); //========================================================================== // Calculate Fame Gains //========================================================================== $fame_win = max(0, $total_grab * 2); // War effects include_once 'inc/functions/war.php'; $objSrcAlliance = $objSrcUser->get_alliance(); if (checkWarBetween($objSrcAlliance, $trgKd)) { // Update land counter in new war system March 06, 2008 Martel $iNeeded = $objSrcAlliance->get_war('land_needed'); $objSrcAlliance->set_war('land_needed', max(0, $iNeeded - $total_grab)); // War effects on fame $fame_win *= 1.2; } // Cannot take more fame than what the target has $fame_win = round($fame_win); $target_fame = $objTrgUser->get_stat(FAME); if ($fame_win > $target_fame) { $fame_win = $target_fame; } $fame1 = $objSrcUser->get_stat(FAME) + $fame_win; $fame2 = $target_fame - $fame_win; $objSrcUser->set_stat(FAME, $fame1); $objTrgUser->set_stat(FAME, $fame2); //========================================================================== $arrResults['gained_acres'] = $total_grab; $arrResults['gained_fame'] = $fame_win; return $arrResults; }
function obj_test_for_kill(&$objTrgUser, &$objSrcUser) { global $ip; // Minimize multi-kills - Martel December 30, 2007 // #1 Query DB for kill status (Don't use cached data) #2 Check citz $strSQL = 'SELECT killed FROM stats WHERE id = ' . $objTrgUser->get_userid(); $arrRow = mysql_fetch_row(mysql_query($strSQL)); if ($arrRow[0] == 0 && $objTrgUser->get_pop(CITIZENS) <= 0) { // Separate a reset tribe from a killed (1=age, 2=pk) $objTrgUser->set_stat(KILLED, 2); // Show kill message $arrTrgStats = $objTrgUser->get_stats(); echo $strDiv = '<div id="textMedium">' . '<p>' . "Congratulations! You watch on as the last citizen of " . '<strong class="negative">' . stripslashes($arrTrgStats[TRIBE]) . ' (#' . $arrTrgStats[ALLIANCE] . ")</strong> dies and their empire crumbles in front of you." . '</p>' . '</div>' . '<br />'; // Update SrcUser with +1 Kill $arrSrcStats = $objSrcUser->get_stats(); $iKilled = $arrSrcStats[KILLS] + 1; $objSrcUser->set_stat(KILLS, $iKilled); // Record: Largest Kill require_once 'inc/classes/clsGame.php'; $objGame = new clsGame(); $arrRecords = $objGame->get_game_records(); $arrTrgBuilds = $objTrgUser->get_builds(); if ($arrTrgBuilds[LAND] > $arrRecords[KILLED]) { $arrRecords = array(KILLED => $arrTrgBuilds[LAND], KILLED_ID => $objSrcUser->get_userid()); $objGame->set_game_records($arrRecords); } // War effects require_once "inc/functions/war.php"; $objSrcAlliance = $objSrcUser->get_alliance(); if (checkWarBetween($objSrcAlliance, $arrTrgStats[ALLIANCE])) { $objTrgAlliance = $objTrgUser->get_alliance(); // Update land counter in new war system March 06, 2008 Martel $iNeeded = $objSrcAlliance->get_war('land_needed'); $objSrcAlliance->set_war('land_needed', max(0, $iNeeded - $arrTrgBuilds[LAND])); // Wait with adding this until it is 100% sure no multi kills exist // if (($arrGains = testWarVictory($objSrcAlliance, $objTrgAlliance))) // { // require_once('inc/pages/war_room2.inc.php'); // $strGains = getVictoryReport($arrGains); // // Show war-win message // echo $strDiv = // '<div id="textMedium">' . // '<p><strong class="positive">Your alliance have won the war!</strong></p>' . // $strGains . // '</div>' . // '<br />'; // } // Add war-kill to global news $strGlobalNews = '<strong class="negative">Alliance #' . $arrSrcStats[ALLIANCE] . " has laid the final blow in " . $arrTrgStats[TRIBE] . "\\'s ORKFiA career during their war.</strong>"; mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, " . "result, text, kingdom_text, kingdoma, kingdomb) " . "VALUES ('', NOW(), '---', 'global', 0, 0, 1, '', " . "'{$strGlobalNews}', 0, '')"); // War events if a killed tribe is in the biggest half of the alli $iLand = $arrTrgBuilds[LAND]; $arrRow1 = mysql_fetch_row(mysql_query("SELECT COUNT(id) FROM rankings_personal WHERE land > {$iLand} AND alli_id = " . $arrTrgStats[ALLIANCE])); $arrRow2 = mysql_fetch_row(mysql_query("SELECT COUNT(id) FROM rankings_personal WHERE alli_id = " . $arrTrgStats[ALLIANCE])); if ($arrRow1[0] * 2 < $arrRow2[0]) { require_once "inc/functions/update.php"; //============================================================== // Bonus for the killing alliance: MP+TP gain, army // moved 1 hours closer to home //============================================================== // Since we don't seem to want a max to the mps/tps here, // why not just add obj_mage_power_growth twice, same for // thieves ofc - AI 25/11/2006 //============================================================== $arrUserId = $objSrcAlliance->get_userids(); foreach ($arrUserId as $iUserid) { check_to_update($iUserid); $objTmpUser = new clsUser($iUserid); $build = $objTmpUser->get_builds(); // Bonus to Thievery Credits require_once "inc/functions/ops.php"; $bonus1 = 2 * obj_thief_op_growth($objTmpUser); $iNewCredits = $objTmpUser->get_thievery(CREDITS); $iNewCredits += $bonus1; // Bonus to Spell Power require_once "inc/functions/spells.php"; $bonus2 = 2 * obj_mage_power_growth($objTmpUser); $iNewPower = $objTmpUser->get_spell(POWER); $iNewPower += $bonus2; // Update User $objTmpUser->set_thievery(CREDITS, $iNewCredits); $objTmpUser->set_spell(POWER, $iNewPower); // Update Military Training 1x time (Mori thieves) $arrTmpStats = $objTmpUser->get_stats(); if ($arrTmpStats[RACE] == "Mori Hai") { $arrMercs = $objTmpUser->get_army_mercs(); $arrNewMercs = array(MERC_T0 => $arrMercs[MERC_T1], MERC_T1 => $arrMercs[MERC_T2], MERC_T2 => $arrMercs[MERC_T3], MERC_T3 => 0); $objTmpUser->set_army_mercs($arrNewMercs); } // Update Military Training 1x time (Everybody) $arrRets = $objTmpUser->get_milreturns(); $arrNewRets = array(UNIT1_T1 => $arrRets[UNIT1_T2], UNIT1_T2 => $arrRets[UNIT1_T3], UNIT1_T3 => $arrRets[UNIT1_T4], UNIT1_T4 => 0, UNIT2_T1 => $arrRets[UNIT2_T2], UNIT2_T2 => $arrRets[UNIT2_T3], UNIT2_T3 => $arrRets[UNIT2_T4], UNIT2_T4 => 0, UNIT3_T1 => $arrRets[UNIT3_T2], UNIT3_T2 => $arrRets[UNIT3_T3], UNIT3_T3 => $arrRets[UNIT3_T4], UNIT3_T4 => 0, UNIT4_T1 => $arrRets[UNIT4_T2], UNIT4_T2 => $arrRets[UNIT4_T3], UNIT4_T3 => $arrRets[UNIT4_T4], UNIT4_T4 => 0, UNIT5_T1 => $arrRets[UNIT5_T2], UNIT5_T2 => $arrRets[UNIT5_T3], UNIT5_T3 => $arrRets[UNIT5_T4], UNIT5_T4 => 0, UNIT6_T1 => $arrRets[UNIT6_T2], UNIT6_T2 => $arrRets[UNIT6_T3], UNIT6_T3 => $arrRets[UNIT6_T4], UNIT6_T4 => 0); $objTmpUser->set_milreturns($arrNewRets); // Update Tribe News $strNews = "The death of one of our enemies has given our " . "troops courage! Armies are returning more quickly, " . "thieves are more willing to risk their lives for the " . "tribe and your mage feels extra powerful."; mysql_query("INSERT INTO news (time, ip, type, duser, " . "ouser, result, text, kingdom_text) VALUES " . "(NOW(), '---', 'local_news', {$iUserid}, '', " . "1, '{$strNews}','')"); $objTmpUser->set_user_info(LAST_NEWS, 1); } // Defiance for the losing alliance, gives bonuses to off/tm-dmg $arrUserId = $objTrgAlliance->get_userids(); foreach ($arrUserId as $iUserid) { check_to_update($iUserid); $objTmpUser = new clsUser($iUserid); $objTmpUser->set_spell(DEFIANCE, 4); $strNews = "The death of one of our big tribes has filled the " . "hearts of our people with anger! For 4 more months " . "we will strike hard at our enemies!"; mysql_query("INSERT INTO news (time, ip, type, duser, " . "ouser, result, text, kingdom_text) VALUES " . "(NOW(), '---', 'local_news', {$iUserid}, '', " . "1, '{$strNews}','')"); $objTmpUser->set_user_info(LAST_NEWS, 1); } } //top half } //war // Create News $timestamp = date(TIMESTAMP_FORMAT); $d_news = '<strong class="negative">' . $arrSrcStats[TRIBE] . " (#" . $arrSrcStats[ALLIANCE] . ") has laid the final blow in " . $arrTrgStats[TRIBE] . "\\'s ORKFiA career.</strong>"; $o_news = '<strong class="positive">Our ' . $arrSrcStats[TRIBE] . " has laid the final blow in " . $arrTrgStats[TRIBE] . " (#" . $arrTrgStats[ALLIANCE] . ")\\'s ORKFiA career.</strong>"; $strNews = "I am sorry leader, upon your return to your tribe your alliance " . "has sent this message forth to you." . "<br /><br />" . $d_news . "<br /><br />" . "They have also sent us supplies and some citizens to restart " . "our tribe." . "<br /><br />" . "Below this line is news our previous tribe had recieved:"; $strSQL = "INSERT INTO news (time, ip, type, duser, ouser, result, " . "text, kingdom_text, kingdoma, kingdomb) VALUES ('{$timestamp}', " . "'{$ip}', 'killed', {$arrTrgStats[ID]}, 0, 1, '{$strNews}', " . "'{$d_news}', '{$arrTrgStats[ALLIANCE]}', '')"; mysql_query($strSQL); $strSQL = "INSERT INTO news (time, ip, type, duser, ouser, result, text, " . "kingdom_text, kingdoma, kingdomb) VALUES ('{$timestamp}', '{$ip}', " . "'killed', 0, 0, 1, '', '{$o_news}', '{$arrSrcStats[ALLIANCE]}', '')"; mysql_query($strSQL); //====================================================================== // Kill the tribe //====================================================================== require_once 'inc/staff/delete.inc.php'; doBackupTribe($objTrgUser->get_userid(), 'kill'); obj_kill_user($objTrgUser); } else { return; } }
function do_op(&$objSrcUser,&$objTrgUser,$cnt,$thieves,$mod) { $next_attack = $objTrgUser->get_user_info(NEXT_ATTACK); $maxtime = min($next_attack, 4) * 3600; $userid = $objSrcUser->get_userid(); $targetid = $objTrgUser->get_userid(); $res = mysql_query("SELECT COUNT(*) AS num FROM news WHERE type='invade' AND duser=$userid AND ouser=$targetid AND (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`time`)) < $maxtime AND ambush = 1"); $res = mysql_fetch_array($res); $num = $res["num"]; // Martel: // possibilities of num=0: 1) noone has attacked you 2) you have already ambushed all available tribes if ($num == "0") { $result["text_screen"] = "Your thieves follow your command with pleasure; since no enemy armies are in sight they decide to visit the local taverns instead."; $result["text_news"] = ""; $result["fame"] = 0; return $result; exit; } $build = $objTrgUser->get_builds(); if ($thieves < ($build[LAND]*25)) { $result["text_screen"] = "Your thieves try to follow your command, but are too few in numbers and fail to reclaim any of your acres."; $result["fame"] = 0; $result["text_news"] = ""; return $result; exit; } $mercs_out = 0; $race = $objTrgUser->get_stat(RACE); if ($race == "Mori Hai") { $army_mercs = $objTrgUser->get_army_mercs(); $mercs_out = $army_mercs[MERC_T0] + $army_mercs[MERC_T1] + $army_mercs[MERC_T2] && $army_mercs[MERC_T3]; } $milret = $objTrgUser->get_milreturns(); $total_out = array_sum($milret) + $mercs_out; if ($total_out == 0) { $result["text_screen"] = "Sorry, you are too late. Your target already has your grabbed acres back in."; $result["fame"] = 0; $result["text_news"] = ""; return $result; exit; } if ($num >= 1) { $land1 = floor($build[LAND_T1] / 2); $land2 = floor($build[LAND_T2] / 2); $land3 = floor($build[LAND_T3] / 2); $land4 = floor($build[LAND_T4] / 2); $unit11 = floor($milret[UNIT1_T1] / 40); $unit12 = floor($milret[UNIT1_T2] / 40); $unit13 = floor($milret[UNIT1_T3] / 40); $unit14 = floor($milret[UNIT1_T4] / 40); $unit21 = floor($milret[UNIT2_T1] / 40); $unit22 = floor($milret[UNIT2_T2] / 40); $unit23 = floor($milret[UNIT2_T3] / 40); $unit24 = floor($milret[UNIT2_T4] / 40); $unit31 = floor($milret[UNIT3_T1] / 40); $unit32 = floor($milret[UNIT3_T2] / 40); $unit33 = floor($milret[UNIT3_T3] / 40); $unit34 = floor($milret[UNIT3_T4] / 40); $unit41 = floor($milret[UNIT4_T1] / 40); $unit42 = floor($milret[UNIT4_T2] / 40); $unit43 = floor($milret[UNIT4_T3] / 40); $unit44 = floor($milret[UNIT4_T4] / 40); $unit1 = floor($unit11 + $unit12 + $unit13 + $unit14); $unit2 = floor($unit21 + $unit22 + $unit23 + $unit24); $unit3 = floor($unit31 + $unit32 + $unit33 + $unit34); $unit4 = floor($unit41 + $unit42 + $unit43 + $unit44); $totalUnits = $unit1 + $unit2 + $unit3 + $unit4; if ($race == "Mori Hai") { $unit51 = floor($army_mercs[MERC_T0] / 40); $unit52 = floor($army_mercs[MERC_T1] / 40); $unit53 = floor($army_mercs[MERC_T2] / 40); $unit54 = floor($army_mercs[MERC_T3] / 40); $unit5 = floor($unit51 + $unit52 + $unit53 + $unit54); $totalUnits += $unit5; } $acres = floor($build[LAND_T1] + $build[LAND_T2] + $build[LAND_T3] + $build[LAND_T4] - $land1 - $land2 - $land3 - $land4 ); $famelost = floor($acres * 2); $fame = $objTrgUser->get_stat(FAME) - $famelost; $objTrgUser->set_stat(FAME, $fame); $fame = $objSrcUser->get_stat(FAME) + $famelost; $objSrcUser->set_stat(FAME, $fame); $land = $objSrcUser->get_build(LAND) + $acres; $objSrcUser->set_build(LAND, $land); //Those were set on the source tribe in original code. I assume that was wrong /Gotland $arrBuild = array(LAND_T1 => $land1, LAND_T2 => $land2, LAND_T3 => $land3, LAND_T4 => $land4); $objTrgUser->set_builds($arrBuild); $update = mysql_query("UPDATE news SET ambush=0 WHERE type='invade' AND duser=$o_user[id] AND ouser=$d_user[id] AND (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`time`)) < $maxtime "); $army = $objTrgUser->get_armys(); $arrArmy = array( UNIT1 => $army[UNIT1] - $unit1, UNIT2 => $army[UNIT2] - $unit2, UNIT3 => $army[UNIT3] - $unit3, UNIT4 => $army[UNIT4] - $unit4 ); $arrMilReturn = array( UNIT1_T1 => $milret[UNIT1_T1] - $unit11, UNIT1_T2 => $milret[UNIT1_T2] - $unit12, UNIT1_T3 => $milret[UNIT1_T3] - $unit13, UNIT1_T4 => $milret[UNIT1_T4] - $unit14, UNIT2_T1 => $milret[UNIT2_T1] - $unit21, UNIT2_T2 => $milret[UNIT2_T2] - $unit22, UNIT2_T3 => $milret[UNIT2_T3] - $unit23, UNIT2_T4 => $milret[UNIT2_T4] - $unit24, UNIT3_T1 => $milret[UNIT3_T1] - $unit31, UNIT3_T2 => $milret[UNIT3_T2] - $unit32, UNIT3_T3 => $milret[UNIT3_T3] - $unit33, UNIT3_T4 => $milret[UNIT3_T4] - $unit34, UNIT4_T1 => $milret[UNIT4_T1] - $unit41, UNIT4_T2 => $milret[UNIT4_T2] - $unit42, UNIT4_T3 => $milret[UNIT4_T3] - $unit43, UNIT4_T4 => $milret[UNIT4_T4] - $unit44 ); if ($race == "Mori Hai") { $arrArmy += array (UNIT5 => $army[UNIT5] - $unit5); $arrMilReturn += array( UNIT5_T1 => $milret[UNIT5_T1] - $unit51, UNIT5_T2 => $milret[UNIT5_T2] - $unit52, UNIT5_T3 => $milret[UNIT5_T3] - $unit53, UNIT5_T4 => $milret[UNIT5_T4] - $unit54 ); $arrMercs = array ( MERC_T0 => $army_mercs[MERC_T0] - $unit51, MERC_T1 => $army_mercs[MERC_T1] - $unit52, MERC_T2 => $army_mercs[MERC_T2] - $unit53, MERC_T3 => $army_mercs[MERC_T3] - $unit54 ); $objTrgUser->set_army_mercs($arrMercs); } $objTrgUser->set_milreturns($arrMilReturn); $objTrgUser->set_armys($arrArmy); // War effects include_once('inc/functions/war.php'); $objSrcAlliance = $objSrcUser->get_alliance(); if (checkWarBetween($objSrcAlliance, $objTrgUser->get_stat(ALLIANCE))) { // Update land counter in new war system March 06, 2008 Martel $iNeeded = $objSrcAlliance->get_war('land_needed'); $objSrcAlliance->set_war('land_needed', max(0, $iNeeded - $acres)); } $result["text_news"] = "Our walls have been defaced with crude messages, we have also noted that our target has taken " . number_format($acres) . " of his acres back and killed " . number_format($totalUnits) . " of our military units during this."; $result["text_screen"] ="Our thieves HAPPILY deface the walls of our enemy. Our thieves took back " . number_format($acres) . " of our acres and killed " . number_format($totalUnits) . " military units."; $result["fame"] = $famelost; return $result; } }
function do_op(&$objSrcUser, &$objTrgUser, $cnt, $thieves, $mod) { // require('inc/functions/bonuses.php'); // $alli = $objTrgUser->get_stat(ALLIANCE); // $arrSci = getSciences($alli); // $defsci = $arrSci['def']; $percentage = 0.1; // $percentage *= 1 - ($defsci / 200); //up to 50% land saved by defsci $acres = $objTrgUser->get_build(LAND); $mingain = $acres * 0.005; //.01; changed infinity-age 9 $prefthieves = $acres * 5; //TODO, this is a completely random number $thiefmod = min(1, $thieves / $prefthieves); // the "you didn't send enough thieves" modifier $land_1 = $objTrgUser->get_build(LAND_T1); $land_2 = $objTrgUser->get_build(LAND_T2); $land_3 = $objTrgUser->get_build(LAND_T3); $land_4 = $objTrgUser->get_build(LAND_T4); $incoming = $land_1 + $land_2 + $land_3 + $land_4; $totaltaken = 0; for ($x = 1; $x <= $cnt; $x++) { //calc unmodded amount to take $totake = $incoming * $percentage; if ($mingain > $totake) { $totake = $mingain; } //mod it $taken = floor($totake * $mod * $thiefmod); //make sure we don't take acres that aren't there if ($taken > $incoming) { $taken = $incoming; } //add and subtract and stuff $totaltaken += $taken; $incoming -= $taken; } $toremove = $totaltaken; //keep this var for news purposes and, you know, giving them to the opper /* this is long, ugly code, it can probably be done in 8 lines or so, but I'm tired right now and can't think of how, TODO */ if ($toremove > $land_1) { $toremove -= $land_1; $land_1 = 0; } else { $land_1 -= $toremove; $toremove = 0; } if ($toremove > $land_2) { $toremove -= $land_2; $land_2 = 0; } else { $land_2 -= $toremove; $toremove = 0; } if ($toremove > $land_3) { $toremove -= $land_3; $land_3 = 0; } else { $land_3 -= $toremove; $toremove = 0; } if ($toremove > $land_4) { $toremove -= $land_4; $land_4 = 0; } else { $land_4 -= $toremove; $toremove = 0; } //Now that we've (finally) calced what to do, remove the acres $objTrgUser->set_build(LAND_T1, $land_1); $objTrgUser->set_build(LAND_T2, $land_2); $objTrgUser->set_build(LAND_T3, $land_3); $objTrgUser->set_build(LAND_T4, $land_4); //give the opper his acres $in_in_4 = $objSrcUser->get_build(LAND_T4); $objSrcUser->set_build(LAND_T4, $in_in_4 + $totaltaken); // War effects include_once 'inc/functions/war.php'; $objSrcAlliance = $objSrcUser->get_alliance(); if (checkWarBetween($objSrcAlliance, $objTrgUser->get_stat(ALLIANCE))) { // Update land counter in new war system March 06, 2008 Martel $iNeeded = $objSrcAlliance->get_war('land_needed'); $objSrcAlliance->set_war('land_needed', max(0, $iNeeded - $totaltaken)); } //all the hard stuff should be done now, newsreports here we come... $result["fame"] = $totaltaken * 3; $result["text_screen"] = "Boze has reappropriated <span class=\"negative\">{$totaltaken}</span> incoming acres of the enemy."; $result["text_news"] = "<span class=\"negative\">{$totaltaken}</span> incoming acres have failed to arrive."; return $result; }
function doAttack(&$objSrcUser, &$objTrgUser, $arrSentArmy) { $srcKd = $objSrcUser->get_stat(ALLIANCE); $trgKd = $objTrgUser->get_stat(ALLIANCE); $strSrcRace = $objSrcUser->get_stat(RACE); $iSrcLand = $objSrcUser->get_build(LAND); $arrTrgBuilds = $objTrgUser->get_builds(); $gains = pow($arrTrgBuilds[LAND] / $iSrcLand, 2) + $arrTrgBuilds[LAND] / ($iSrcLand * 3); $gains = min($gains, 1); $quick_gains = 0.01 * $gains; // 1% Land Gain if ($strSrcRace == "Oleg Hai") { $quick_gains = $quick_gains * 1.3; } //========================================================================== // Calculate Acre Gains //========================================================================== include_once 'inc/functions/build.php'; $arrBuildVars = getBuildingVariables($objTrgUser->get_stat(RACE)); $arrBuildVars = $arrBuildVars['variables']; $max_build = $objTrgUser->get_number_build_types(); $total_grab = 0; for ($i = 1; $i <= $max_build; $i++) { $strVar = trim($arrBuildVars[$i]); $acres_won[$strVar] = round($arrTrgBuilds[$strVar] * $quick_gains); $buildings = $objTrgUser->get_build($strVar); $land = $objTrgUser->get_build(LAND); $arrBuilds = array($strVar => $buildings - $acres_won[$strVar], LAND => $land - $acres_won[$strVar]); $objTrgUser->set_builds($arrBuilds); $total_grab = $total_grab + $acres_won[$strVar]; } // Explored $explore_gains = 0.2; $acres_explored = round($total_grab * $explore_gains); $land = $objSrcUser->get_build(LAND); $objSrcUser->set_build(LAND, $land + $acres_explored); //========================================================================== // Calculate Citizens Killed //========================================================================== $trgCits = $objTrgUser->get_pop(CITIZENS); $max_kill = $trgCits * 0.2; $trgRace = $objTrgUser->get_stat(RACE); if ($max_kill < $arrTrgBuilds[LAND] * 3 && $trgRace != "Dragon") { $max_kill = $arrTrgBuilds[LAND] * 3; } elseif ($max_kill < $arrTrgBuilds[LAND] * 2 && $trgRace == "Dragon") { $max_kill = $arrTrgBuilds[LAND] * 2; } // War effects on max kill include_once "inc/functions/war.php"; $modifier = war_alli($srcKd, $trgKd); if ($modifier == 2) { $max_kill = $max_kill * 1.2; } // Martel: small bug fixed, $arrTrgBuilds not $arrTrgBuild $wallsPercent = $arrTrgBuilds[WALLS] * 100 / $arrTrgBuilds[LAND]; if ($wallsPercent > 20) { $wallsPercent = 20; } // frost: age 18, each % walls shelters 2% citizen for ($y = 1; $y <= $wallsPercent; $y++) { $max_kill *= 0.98; } // Max citizens to kill == citizens available $max_kill = round($max_kill); if ($max_kill > $trgCits) { $max_kill = $trgCits; } if ($max_kill > 0) { $intCitizens_alive = $trgCits - $max_kill; $objTrgUser->set_pop(CITIZENS, $intCitizens_alive); } else { $max_kill = 0; } // Let's see if we killed the tribe include_once 'inc/functions/generic.php'; obj_test_for_kill($objTrgUser, $objSrcUser); //========================================================================== // Calculate Cash Gains and Fame //========================================================================== $trgMoney = $objTrgUser->get_good(MONEY); $mod = 1; $stolen_crowns = round($trgMoney * 0.04); if ($arrTrgBuilds[LAND] > $iSrcLand) { $fame_win = round($total_grab * 1.0); } elseif ($arrTrgBuilds[LAND] < $iSrcLand * 0.7) { $fame_win = round(-$total_grab * 1.0); $mod = $arrTrgBuilds[LAND] * 1.3 / $iSrcLand; } else { $fame_win = round($total_grab * 1.2); } if ($mod < 0.7) { $mod = 0.7; } $max_crowns = round($arrTrgBuilds[LAND] * 500); $stolen_crowns = min(round($stolen_crowns * $mod), round($max_crowns)); $objTrgUser->set_good(MONEY, $trgMoney - $stolen_crowns); $money = $objSrcUser->get_good(MONEY); $objSrcUser->set_good(MONEY, $money + $stolen_crowns); //========================================================================== // Return time //========================================================================== $wait = 4; // 4 hour attack time if ($strSrcRace == "Raven") { $wait = 1; } elseif ($strSrcRace == "Mori Hai" || $strSrcRace == "Dragon") { $wait = 3; } $landtime = 'land_t' . $wait; $objSrcUser->set_user_info(NEXT_ATTACK, $wait); //========================================================================== // Add land to incoming //========================================================================== if ($total_grab > 0) { $old_land = $objSrcUser->get_build($landtime); $objSrcUser->set_build($landtime, $total_grab + $old_land); } //========================================================================== // Calculate Fame Gains //========================================================================== // War effects $objSrcAlliance = $objSrcUser->get_alliance(); require_once 'inc/functions/war.php'; if (checkWarBetween($objSrcAlliance, $trgKd)) { // Update land counter in new war system March 06, 2008 Martel $iNeeded = $objSrcAlliance->get_war('land_needed'); $objSrcAlliance->set_war('land_needed', max(0, $iNeeded - $total_grab)); // War effects on fame $fame_win *= 1.2; } // Cannot take more fame than what the target has $fame_win = round($fame_win); $target_fame = $objTrgUser->get_stat(FAME); if ($fame_win > $target_fame) { $fame_win = $target_fame; } $fame1 = $objSrcUser->get_stat(FAME) + $fame_win; $fame2 = $target_fame - $fame_win; $objSrcUser->set_stat(FAME, $fame1); $objTrgUser->set_stat(FAME, $fame2); //========================================================================== $arrResults['gained_acres'] = $total_grab; $arrResults['explored_acres'] = $acres_explored; $arrResults['gained_fame'] = $fame_win; $arrResults['gained_crowns'] = $stolen_crowns; $arrResults['killed_citizens'] = $max_kill; return $arrResults; }