} if ($invalid) { echo 'You entered an invalid defender.<br>'; $no = 1; } } } if ($no == 0) { $failed = FALSE; $defreport = ""; $creatures_array = array("Itherian" => $creatures_Itherian); for ($m = 0; $m < count($attackers); $m++) { $attacker = new Creature($attackers[$m]); $defender = new Creature($creatures[$attacker->data["defender"]]); // battle $battleresult = gBattle($attacker, $defender, 1, "challenge", 0, $creatures_array, $defenders, $attackers, 1); $defreport .= $battleresult["defreport"]; if ($battleresult["failed"]) { $failed = TRUE; } // end of battle } if ($failed) { echo 'You failed to kill all your opponents.<br><br>'; echo gParseReport(stripslashes($defreport)); } else { $sql = "INSERT INTO challengelogs (account, challenge) VALUES ('{$acc['id']}', '{$chid}')"; $result = $db->query($sql); echo ' You killed all your opponents!<br> You successfully complete the challenge!<br><br>
$resources += round($attacker->data["skill"] * $gdRaidResourcesStolen); $attackername = $attacker->data["creaturename"]; $attreport .= "<font class=\"alert\"><i>Your {$attackername} was left undefended and could steal a lot of resources.</i></font><br><br>"; $defreport .= "<font class=\"head\"><i>Your opponent\\'s {$attackername} was left undefended and could steal a lot of resources.</i></font><br><br>"; $gotthrough++; $stealmultiplier += $attacker->getStealMultiplier() * $attacker->data[$mult] / 100; // end of raid // fix for xp for < L30 /*if (gCalcLvl($target["xp"], $gdXpVar, $gdStartXp) < 30) { $targetxp += round($gdXpBase * 1.5 * $punishment); $accountxp += round($gdXpBase * 1.5 * $punishment); }*/ } else { $defender = new Creature($creatures[$attacker->data["defender"]]); // battle $battleresult = gBattle($attacker, $defender, $punishment, "battle", $attackers_array, $creatures_array, $defenders, $attackers); $accountxp += $battleresult["attxp"]; $targetxp += $battleresult["defxp"]; $resources += $battleresult["resources"]; $attreport .= $battleresult["attreport"]; $defreport .= $battleresult["defreport"]; if ($battleresult["failed"]) { $gotthrough++; $stealmultiplier += $battleresult["stealmultiplier"] * $attacker->data[$mult] / 100; } // end of battle if ($hidden == 0 && $action == "submitdefend") { $id = $defender->data["id"]; $sql = "INSERT INTO battlelimits (type, battle, summon) VALUES ('0', '{$battle['id']}', '{$id}')"; $result = $db->query($sql); }
$longreport = ""; $failed = 0; for ($m = 0; $m < count($attackers); $m++) { $attacker = new Creature($attackers[$m]); // let through if (is_null($attacker->data["defender"])) { die("NO DEFENDER SELECTED"); } else { $defender = new Creature($defenders[$attackers[$m]["defender"]]); if ($attacker->data["accid"] == 3584) { $attacker->data["accname"] = "Unknown"; } if ($defender->data["accid"] == 3584) { $defender->data["accname"] = "Unknown"; } $battleresult = gBattle($attacker, $defender, 1, "nestbattle", array("id" => $attacker->data["accid"], "name" => $attacker->data["accname"], "Itherian" => $attackers_Itherian), array("id" => $defender->data["accid"], "name" => $defender->data["accname"], "Itherian" => $defenders_Itherian), $defenders, $attackers); $longreport .= $battleresult["defreport"]; $bosskilled = FALSE; // if failed -> update health if ($battleresult["failed"]) { // update health $left = $battleresult["atthealth"]; $sql = "UPDATE summons SET extra = '{$left}' WHERE id = '{$attid}'"; $result = $db->query($sql); } else { // add to counter $left = 0; if ($attacker->data["cid"] == 227) { $acc["pigeon"] += 2; } else { $acc["pigeon"]++;
$result = $db->query($sql); $guardianrow = $db->fetch_array($result); $guardianrow["maxhealth"] = $guardianrow["oldhealth"]; // select attackers $sql = "SELECT {$gdCreatureSelect}, acc.id AS accid, acc.name AS accname, acc.kingdom FROM (summons AS s, creatures AS c, races AS r, accounts AS acc, kingdoms AS k) LEFT JOIN accitems AS ai ON s.item = ai.id LEFT JOIN items AS i ON ai.item = i.id WHERE s.creature = c.id AND c.race = r.id AND s.type = '7' AND s.target = '{$guardian}' AND s.account = acc.id AND acc.kingdom = k.id AND k.faction = '{$faction}' ORDER BY s.extra ASC"; $result = $db->query($sql); unset($attackers); while ($row = $db->fetch_array($result)) { $attackers[count($attackers)] = $row; } $defender = new Creature($guardianrow); for ($m = 0; $m < count($attackers); $m++) { if ($defender->data["maxhealth"] > 0) { $attacker = new creature($attackers[$m]); // battle $battleresult = gBattle($attacker, $defender, 1, "kingdombattle", array("id" => $attacker->data["accid"], "name" => $attacker->data["accname"]), array("id" => 3308, "name" => "Core"), $defenders, $attackers); $report .= $battleresult["shortreport"]; $defender->data["maxhealth"] = $battleresult["defenderhealth"]; if ($defender->data["maxhealth"] < 0) { $defender->data["maxhealth"] = 0; } // end of battle // guardian defeated if ($defender->data["maxhealth"] == 0) { $sql = "SELECT id FROM guardians WHERE dead = '0'"; $result = $db->query($sql); $numrows = $db->num_rows($result); if ($numrows <= 1) { $sql = "SELECT name FROM factions WHERE id = '{$faction}'"; $result = $db->query($sql); $name = addslashes($db->result($result, 0));