* Project name: Battles-Game */ use Battles\Database\DBPDO; use Battles\DressedItems; use Battles\InventoryItem; use Battles\Travel; use Battles\User; require_once 'config.php'; if (empty($_SESSION['uid'])) { header("Location: index.php"); exit; } else { $user = new User($_SESSION['uid']); } if ($user->getId() && $user->getBlock()) { exit('user blocked!'); } /* * Проверки на соответствие скрипта и комнаты, которые были натыканы по всем файлам. */ $fbattleCheckFiles = [ 'c_haos_in.php', 'c_haos.php', 'c_park.php', 'city.php', 'clan_castle.php', 'comission.php', 'enter_cave.php', 'library.php', 'atk.php', 'podzem_dialog.php', 'post.php', 'shop.php', 'tournament.php', 'vxod.php', 'bank.php', 'canalizaciya,php', 'forest.php', 'main.php', 'repair.php', 'towerstamp.php', 'hell.php', 'ul_clans.php', 'labirint.php', 'akadem.php', 'towerin.php', 'user_anketa.php', 'zayavka.php', ]; //Может просто отовсюду? О_о if ($user->getBattle() && in_array(pathinfo(debug_backtrace()[0]['file'])['basename'], $fbattleCheckFiles)) { header('location: fbattle.php'); exit; } $towerinCheckFiles = ['main.php', 'city.php', 'tower.php']; if ($user->getInTower() && in_array(pathinfo(debug_backtrace()[0]['file'])['basename'], $towerinCheckFiles)) { header('location: towerin.php'); exit; } $roomsCheck = [22, 23, 25, 27, 29, 30, 31, 37, 38, 39, 40, 41, 45, 53, 61, 401, 402, 600, 601, 602, 621, 650, 1051, 1052]; // Если я в одной из этих комнат, // [И] Имя файла который инклюдит файл с проверкой не совпадает с именем файла локации в которой я нахожусь // [И] Номер комнаты который я пытаюсь открыть есть в списке проверяемых if (in_array($user->getRoom(), $roomsCheck) && pathinfo(debug_backtrace()[0]['file'])['basename'] != Travel::$roomFileName[$user->getRoom()] && in_array(array_search(pathinfo(debug_backtrace()[0]['file'])['basename'], Travel::$roomFileName), $roomsCheck)) { header('location: main.php'); exit; } $ip = filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP); if (isset($_GET['goto']) && isset($_GET['tStamp']) && isset($_GET['vcode']) && $_GET['vcode'] == md5(sha1($_GET['goto'] . $_GET['tStamp']))) { db::c()->query('UPDATE `users`,`online` SET `users`.`room` = ?i, `online`.`room` = ?i WHERE `online`.`id` = `users`.`id` AND `online`.`id` = ?i', $_GET['goto'], $_GET['goto'], $_SESSION['uid']); $user->setRoom(intval($_GET['goto'])); } function createbot($bot, $login = "") { $rec = db::c()->query('SELECT `id`, `login`, `maxhp` FROM `users` WHERE `id` = "?s" LIMIT 1', $bot)->fetch_assoc(); if (isset($rec['id'])) { if ($login) { $rec['login'] = $login; } $botname = $rec['login']; db::c()->query('INSERT INTO `bots` (`name`, `prototype`, `hp`) VALUES ("?s", "?s", "?s")', $botname, $bot, $rec['maxhp']); $nid = db::c()->getLastInsertId(); return ["id" => $nid, "login" => $botname]; } else { return false; } } $var_map = [ 'cell_1' => 'Березовая роща', 'cell_2' => 'Березовая просека', 'cell_3' => 'Тёмный угол', 'cell_4' => 'Мрачная опушка', 'cell_5' => 'Тёмное урочище', 'cell_6' => 'Бурелом', 'cell_7' => 'Старая ива', 'cell_8' => 'Разнолесье', 'cell_9' => 'Сосновая тропа', 'cell_10' => 'Забытая дорога', 'cell_11' => 'Новая дорога', 'cell_12' => 'Мщаник', 'cell_13' => 'Ясная поляна', 'cell_14' => 'Заросший тракт', 'cell_15' => 'Смутный ельник', 'cell_16' => 'Сосновый бор', 'cell_17' => 'Тихоход', 'cell_18' => 'Сосновый гай', 'cell_19' => 'Смешаный лес', 'cell_20' => 'Темная поляна', 'cell_21' => 'Осенний угол', 'cell_22' => 'Грибное место', 'cell_23' => 'Опушка', 'cell_24' => 'Рыжий лес', 'cell_25' => 'Полесье', ]; function get_out($u) { $pers = db::c()->query('SELECT * FROM users WHERE id = ?i', $u)->fetch_assoc_array(); DressedItems::undressAllItems($pers['id']); db::c()->query('UPDATE inventory SET owner = ?i WHERE owner = ?i', $pers['id'], $pers['id'] + _BOTSEPARATOR_); ### $row = db::c()->query('SELECT * FROM `effects` WHERE `owner` = ?i', $pers['id'] + _BOTSEPARATOR_); $travm = [11, 12, 13, 14]; while ($efs = $row->fetch_assoc()) { if (in_array($efs['type'], $travm)) { $pers['sila'] -= $efs['sila']; $pers['lovk'] -= $efs['lovk']; $pers['inta'] -= $efs['inta']; $pers['vinos'] -= $efs['vinos']; } else { $pers['sila'] += $efs['sila']; $pers['lovk'] += $efs['lovk']; $pers['inta'] += $efs['inta']; $pers['vinos'] += $efs['vinos']; $pers['maxhp'] += $efs['hp']; } $efs['owner'] = $_SESSION['uid']; //mysql_query('UPDATE `effects` SET `owner` = "' . $efs['owner'] . '" WHERE `id` = "' . $efs['id'] . '" LIMIT 1'); //mysql_query('UPDATE `users` SET `sila` = "' . $pers['sila'] . '", `lovk` = "' . $pers['lovk'] . '", `inta` = "' . $pers['inta'] . '", `vinos` = "' . $pers['vinos'] . '", `maxhp` = "' . $pers['maxhp'] . '" WHERE `id` = "' . $pers['id'] . '" LIMIT 1'); } ### } function takeshopitem($item, $table = "shop", $present = '', $onlyonetrip = '', $fields = 0, $uid = 0, $koll = 1, $podzem = 0) { global $user; $flds = []; $goden = ''; if (!$uid) { $uid = $user->getId(); } $r = db::c()->query('SHOW FIELDS FROM ?f', $table); $r2 = db::c()->query('SHOW FIELDS FROM inventory'); while ($rec = $r2->fetch_assoc()) { $flds[$rec['Field']] = 1; } $rec1 = db::c()->query('SELECT * FROM ?f WHERE id = ?i', $table, $item)->fetch_assoc_array(); if ($rec1['koll']) { db::c()->query('UPDATE inventory SET koll = (koll + ?i), massa = (massa + ?i), cost = (cost + ?i) WHERE owner = ?i AND prototype = ?i', $koll, $rec1['massa'] * $koll, $rec1['cost'], $uid, $item); if (db::c()->getAffectedRows() > 0) { return ["img" => $rec1['img'], "name" => $rec1['name']]; } $rec1['koll'] = $koll; $rec1['massa'] *= $koll; } if ($rec1['onlyone']) { $i = db::c()->query('SELECT id FROM inventory WHERE owner = ?i AND prototype = ?i', $uid, $item)->fetch_row(); if ($i) { return ["error" => "У вас слишком много таких вещей."]; } } if ($present) { $rec1['present'] = $present; $rec1['cost'] = 0; $rec1['ecost'] = 0; } $sql = ""; while ($rec = $r->fetch_assoc()) { if (!$flds[$rec['Field']]) { continue; } if ($rec['Field'] == "dategoden") { $goden = $rec1[$rec['Field']]; } if ($rec['Field'] == "goden") { $goden = $rec1[$rec['Field']]; } if ($rec['Field'] == "id" || $rec['Field'] == "prototype" || $rec['Field'] == "dategoden") { continue; } $sql .= ", `$rec[Field]` = '" . $rec1[$rec['Field']] . "' "; } if ($podzem) { $rec1['podzem'] = $podzem; } if ($fields['goden']) { $goden = $fields["goden"]; } mysql_query("INSERT INTO `inventory` SET " . ($present ? "`present` = '$present'," : "") . ($rec1['podzem'] ? "`podzem` = '$rec1[podzem]'," : "") . " `owner` = '$uid', `otdel` = $rec1[razdel] , `prototype` = '$item' " . ($onlyonetrip ? ", `foronetrip` = 1" : "") . ($goden ? ", `dategoden` = '" . ($goden * 60 * 60 * 24 + time()) . "'" : "") . " $sql"); return ["img" => $rec1['img'], "name" => $rec1['name'], "id" => mysql_insert_id()]; } define('_BOTSEPARATOR_', 10000000); function level_up($uid) { $us = db::c()->query('SELECT `id`, `login`, `level`, `money`, `exp`, `nextup`, `stats`, `master`, `ip`, `in_tower` FROM `users` WHERE `id` =?i', $uid)->fetch_assoc(); if (isset($us['id']) && $us['exp'] >= $us['nextup'] && !$us['in_tower']) { if (EXPTABLE[$us['nextup']][4] == 1) { addch("Персонаж {$us['login']} перешел на " . ($us['level'] + 1) . " уровень."); addchp('Внимание! Вы перешли на новый уровень. За это Вы получаете: ' . EXPTABLE[$us['nextup']][3] . ' кр.', '{[]}' . $us['login'] . '{[]}'); } $us['nextup'] = EXPTABLE[$us['nextup']][5]; $us['stats'] += EXPTABLE[$us['nextup']][0]; $us['master'] += EXPTABLE[$us['nextup']][1]; db::c()->query('UPDATE `users` SET `nextup` = ?i, `stats` = ?i, `master` = ?i, `level` = ?i WHERE `id` = ?i', $us['nextup'], $us['stats'], $us['master'], $us['level'], $us['id']); } } /* * Проверка делающая левелап и ограничитель максимального уровня. */ //if (isset($_SESSION['uid'])) { // try { // $userInfo = db::c()->query('SELECT `exp`, `nextup`, `level` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc(); // if ($userInfo && ($userInfo['exp'] >= $userInfo['nextup']) && $userInfo['level'] < 50) { // level_up($_SESSION['uid']); // $levelUpArray = ['nextup' => $nextup, 'stats' =>]; // db::c()->query('UPDATE users SET ?Ai, stats = (stats +2), level = (level +1) WHERE id = ?i', $levelUpArray, $_SESSION['uid']); // } // } catch (\Krugozor\Database\Mysql\Exception $e) { // echo $e->getTraceAsString(); // } //} function savecavedata($cavedata, $caveleader, $floor) { $f1 = fopen("cavedata/$caveleader-$floor.dat", "wb+"); flock($f1, LOCK_EX); fwrite($f1, serialize($cavedata)); flock($f1, LOCK_UN); fclose($f1); } function GiveExp($id, $exp) { db::c()->query('UPDATE users SET exp = exp + ?i WHERE id = ?i', $exp, $id); } function GiveRep($id, $rep) { db::c()->query('UPDATE users SET doblest = (doblest + ?i), rep_laba = (rep_laba + ?i) WHERE `id` = ?i', $rep, $rep, $id); } /** * Генератор прогрессбара. * @param $current - Текущее значение. * @param $maximum - Максимальное значение. * @param string $line_color - Цвет полоски прогрессбара. * @param string $bg_color - Фон прогрессбара. * @return string */ function showProgressBar($current, $maximum, $line_color = 'limegreen', $bg_color = 'silver') { $bar = round($current / $maximum * 100); return <<
$current / $maximum
HTML; } /** * Функция отображает слот для свитков в окне персонажа. * * @param $slot * * @throws \Krugozor\Database\Mysql\Exception */ function echoscroll($slot) { global $user; $all_magic = 0; if ($user->getBattle()) { $script = 'fbattle'; $bat = db::c()->query('SELECT `magic` FROM `battle` WHERE `id` = ?i', $user->getBattle())->fetch_assoc(); $all_magic = unserialize($bat['magic']); } else { $script = 'main'; } $dress = db::c()->query('SELECT `id`, `magic`, `name`, `img`, `duration`, `maxdur` FROM `inventory` WHERE `id` = ?i', $user->$slot)->fetch_assoc(); $need_charge = db::c()->query('SELECT `needcharge` FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc(); if (($user->$slot > 0) && ($all_magic[$user->getId()] < 1 || empty($need_charge['needcharge']))) { $row['id'] = $user->$slot; if ($dress['magic']) { $magic = db::c()->query('SELECT targeted FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc(); echo ""; } echo << ACTIVE_SCROLL; } elseif (($user->$slot > 0) && ($all_magic[$user->getId()] >= 1) && $need_charge['needcharge'] > 0) { echo << INACTIVE_SCROLL; } else { echo << EMPTY_SLOT; } } // ссылка на магию function showhrefmagic($dress) { $user = db::c()->query('SELECT `battle` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc(); $magic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $dress['includemagic'])->fetch_assoc(); $r = ''; $script = 'main'; if ($user['battle']) { $script = 'fbattle'; } $r .= ""; $r .= "На оружии выгравировано '{$dress['text']}'" : "") . "\">
"; return $r; } function timeOut($ttm) { $out = ''; $time_still = $ttm; $tmp = floor($time_still / 2592000); $id = 0; if ($tmp > 0) { $id++; if ($id < 3) { $out .= $tmp . " мес. "; } $time_still = $time_still - $tmp * 2592000; } $tmp = floor($time_still / 86400); if ($tmp > 0) { $id++; if ($id < 3) { $out .= $tmp . " дн. "; } $time_still = $time_still - $tmp * 86400; } $tmp = floor($time_still / 3600); if ($tmp > 0) { $id++; if ($id < 3) { $out .= $tmp . " ч. "; } $time_still = $time_still - $tmp * 3600; } $tmp = floor($time_still / 60); if ($tmp > 0) { $id++; if ($id < 3) { $out .= $tmp . " мин. "; } } if ($out == '') { if ($time_still < 0) { $time_still = 0; } $out = $time_still . ' сек.'; } return $out; } /** * @param $time * @param $vars * @param $vls * @param $uid * * @return bool */ function addActions($time, $vars, $vls, $uid) { db::c()->query('LOCK TABLES `actions` WRITE'); $ins = db::c()->query('INSERT INTO `actions` (`uid`,`time`,`city`,`room`,`vars`,`ip`,`vals`) VALUES (?i, ?i, "?s", ?i, "?s", "?s", "?s")', $uid, $time, "capitalcity", 0, $vars, $_SERVER['REMOTE_ADDR'], $vls); db::c()->query('UNLOCK TABLES'); return $ins; } #15 function ref_drop() { //сможет держать function derj($id) { $user = db::c()->query('SELECT `id`, `align` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc(); $ts = db::c()->query('SELECT `id`, `nalign` FROM `inventory` WHERE `id` = ?i', $id)->fetch_assoc(); $al = '(1 = 1)'; if ($ts['nalign'] == 1.1) { $al = '(1 = 2)'; } $dd = db::c()->query('SELECT `i`.`id` FROM `users` AS `u`, `inventory` AS `i` WHERE `i`.`needident` = 0 AND `i`.`id` = ?i AND `i`.`duration` < `i`.`maxdur` AND `i`.`owner` = ?i AND `u`.`sila` >= `i`.`nsila` AND `u`.`lovk` >= `i`.`nlovk` AND `u`.`inta` >= `i`.`ninta` AND `u`.`vinos` >= `i`.`nvinos` AND `u`.`intel` >= `i`.`nintel` AND `u`.`mudra` >= `i`.`nmudra` AND `u`.`level` >= `i`.`nlevel` AND ("?s" OR (?i = `i`.`nalign`) or (`i`.`nalign` = 0)) AND `u`.`noj` >= `i`.`nnoj` AND `u`.`topor` >= `i`.`ntopor` AND `u`.`dubina` >= `i`.`ndubina` AND `u`.`mec` >= `i`.`nmech` AND `u`.`mfire` >= `i`.`nfire` AND `u`.`mwater` >= `i`.`nwater` AND `u`.`mair` >= `i`.`nair` AND `u`.`mearth` >= `i`.`nearth` AND `u`.`mlight` >= `i`.`nlight` AND `u`.`mgray` >= `i`.`ngray` AND `u`.`mdark` >= `i`.`ndark` AND `i`.`setsale` = 0 AND `u`.`id` = ?i', $id, $user['id'], $al, $user['align'], $user['id']); return $dd->getNumRows() > 0; } $slot = ['sergi', 'kulon', 'weap', 'bron', 'r1', 'r2', 'r3', 'helm', 'perchi', 'shit', 'boots', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm10']; $user = db::c()->query('SELECT `sergi`,`kulon`,`weap`,`bron`,`r1`,`r2`,`r3`,`helm`,`perchi`,`shit`,`boots`,`m1`,`m2`,`m3`,`m4`,`m5`,`m6`,`m7`,`m8`,`m9`,`m10` FROM `users` WHERE id = ?i', $_SESSION['uid'])->fetch_assoc(); for ($i = 0; $i <= 20; $i++) { if ($user[$slot[$i]] && !derj($user[$slot[$i]])) { $item = new DressedItems($_SESSION['uid']); $item->undressItem($i + 1); $user[$slot[$i]] = null; } } } // использовать магию function usemagic($id, $target) { global $user; $row = db::c()->query('SELECT * FROM `inventory` WHERE `owner` = ?i AND id = ?i', $user->getId(), $id)->fetch_assoc_array(); $bat = db::c()->query('SELECT * FROM `battle` WHERE `id` = ?i', $user->getBattle())->fetch_assoc_array(); $all_magic = unserialize($bat['magic']); $charge = 0; $magic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $row['magic'])->fetch_assoc_array(); if ($magic['needcharge'] > 0) { $charge = $magic['needcharge']; } $incmagic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $row['includemagic'])->fetch_assoc_array(); if ($incmagic['needcharge'] > 0) { $charge = $incmagic['needcharge']; } //Переделать под новую базу if (($all_magic[$user->getId()] < 1 || $charge == 0) && ($user['sila'] >= $row['nsila'] && $user['lovk'] >= $row['nlovk'] && $user['inta'] >= $row['ninta'] && $user['vinos'] >= $row['nvinos'] && $user['intel'] >= $row['nintel'] && $user['level'] >= $row['nlevel'] && (($user['align'] > 7 && $user['align'] < 8) || ((int)$user['align'] == (int)$row['nalign']) || ($row['nalign'] == 0)) && $user['noj'] >= $row['nnoj'] && $user['topor'] >= $row['ntopor'] && $user['dubina'] >= $row['ndubina'] && $user['mec'] >= $row['nmech'] && ($row['type'] < 13 || $row['type'] == 50) && ($user['mfire'] >= $row['nfire']) && $user['mwater'] >= $row['nwater'] && $user['mair'] >= $row['nair'] && $user['mearth'] >= $row['nearth'] && $user['mlight'] >= $row['nlight'] && $user['mgray'] >= $row['ngray'] && $user['mdark'] >= $row['ndark'] && $row['needident'] == 0 ) || $row['magic'] == 48 || $row['magic'] == 50) { if (!$row['magic']) { $incmagic['name'] = $row['includemagicname']; $incmagic['cur'] = $row['includemagicdex']; $incmagic['max'] = $row['includemagicmax']; if ($incmagic['cur'] <= 0) { return false; } $magic['targeted'] = $incmagic['targeted']; echo ""; include("magic/" . $incmagic['file']); echo ""; } else { echo ""; include("magic/" . $magic['file']); echo ""; } if ($bat) { if ($row['maxdur'] <= ($row['duration'] + 1)) { InventoryItem::destroyItem($row['id']); } else { if (!$row['magic']) { db::c()->query('UPDATE `inventory` SET `includemagicdex` =`includemagicdex` - ?i WHERE id = ?i', $bat, $row['id']); } else { db::c()->query('UPDATE `inventory` SET duration = duration + ?i WHERE id = ?i', $bat, $row['id']); } } if (!$charge) { $charge = 0; } //ограничение по кол-ву за ход if ($user->getBattle()) { $bat = db::c()->query('SELECT * FROM `battle` WHERE `id` = ?i', $user->getBattle())->fetch_assoc_array(); } if ($bat['magic'] == '') { $all_magic = []; } else { $all_magic = unserialize($bat['magic']); } $all_magic[$user->getId()] += $charge; db::c()->query('UPDATE `battle` SET `magic`= "?s" WHERE id = ?i', serialize($all_magic), $user->getBattle()); } } return false; } function addch($text, $room = 0) { global $user; if ($room == 0) { $room = $user->getRoom(); } if ($fp = @fopen("tmp/chat.txt", "a")) { //открытие flock($fp, LOCK_EX); //БЛОКИРОВКА ФАЙЛА fputs($fp, ":[" . time() . "]:[!sys!!]:[" . ($text) . "]:[" . $room . "]\r\n"); //работа с файлом fflush($fp); //ОЧИЩЕНИЕ ФАЙЛОВОГО БУФЕРА И ЗАПИСЬ В ФАЙЛ flock($fp, LOCK_UN); //СНЯТИЕ БЛОКИРОВКИ fclose($fp); //закрытие } } function addchp($text, $who, $room = 0) { global $user; if ($room == 0) { $room = $user->getRoom(); } $fp = fopen("tmp/chat.txt", "a"); //открытие flock($fp, LOCK_EX); //БЛОКИРОВКА ФАЙЛА fputs($fp, ":[" . time() . "]:[{$who}]:[" . ($text) . "]:[" . $room . "]\r\n"); //работа с файлом fflush($fp); //ОЧИЩЕНИЕ ФАЙЛОВОГО БУФЕРА И ЗАПИСЬ В ФАЙЛ flock($fp, LOCK_UN); //СНЯТИЕ БЛОКИРОВКИ fclose($fp); //закрытие } /** * @param $msg * * @throws \Krugozor\Database\Mysql\Exception * Отправка системного сообщения в чат. */ function AddChatSystem($msg) { if ($msg) { db::c()->query('INSERT INTO `chat` (`cid`,`msg`,`type`) VALUES (?i,"?s","?s")', 1, $msg, 'sys'); } } function err($t) { echo '' . $t . ''; return true; } /** * @param int $userId * @param string $text * */ function telegraph(int $userId, string $text) { $db = DBPDO::INIT(); if ($db->ofetch('SELECT 1 FROM users WHERE id = ?', $userId)) { $db->execute('INSERT INTO chat (user_id,receiver_id,msg,type) VALUES (-1,?,?,?)', [$userId, $text, 'sms']); } unset($db); } function get_meshok() { global $user; $itemsWeight = db::c()->query('SELECT SUM(weight) AS all_weight FROM `inventory` WHERE owner_id = ?i AND on_sale = 0', $_SESSION['uid'])->fetch_assoc(); return ($user->getStrength() * 4 + $itemsWeight['all_weight']); } /** * Надеюсь временная заглушка, которая объединяет get_meshok() и другую выдачу одной строкой. * @return string */ function getItemsMassaInfo(): string { $itemRow = DBPDO::INIT()->ofetch("select sum(weight) as all_weight from inventory where owner_id = ?", $_SESSION['uid']); $userRow = DBPDO::INIT()->ofetch("select strength * 4 as max_weight from users where id = ?", $_SESSION['uid']); $textStyle = ''; if ($itemRow->all_weight > $userRow->max_weight) { $textStyle = " style='color:maroon;'"; } return "$itemRow->all_weight / $userRow->max_weight"; } function addlog($id, $log) { $fp = fopen("backup/logs/battle" . $id . ".txt", "a"); flock($fp, LOCK_EX); fputs($fp, $log); fflush($fp); flock($fp, LOCK_UN); fclose($fp); unset($id, $log); } function SolveExp($at_id, $def_id, $damage) { $mods = ['bloodb' => 1.2, 'btl_1' => 1, 'btl_2' => 0.5, 'btl_3' => 0.05]; $baseexp = ["0" => "2", "1" => "5", "2" => "10", "3" => "15", "4" => "30", "5" => "60", "6" => "90", "7" => "115", "8" => "300", "9" => "400", "10" => "500", "11" => "600", "12" => "700", "13" => "800", "14" => "900", "15" => "1000", "16" => "1100", "17" => "1200", "18" => "1300", "19" => "1400", "20" => "1500", "21" => "1600"]; $expmf = 0; $bot_active = false; $bot_def = false; if ($at_id > _BOTSEPARATOR_) { $bots = db::c()->query('SELECT * FROM bots WHERE id = ?i', $at_id)->fetch_assoc_array(); $at_id = $bots['prototype']; $bot_active = true; } $at = db::c()->query('SELECT `level` FROM `users` WHERE `id` = ?i', $at_id)->fetch_assoc(); $def = db::c()->query('SELECT `level` FROM `users` WHERE `id` = ?i', $def_id)->fetch_assoc(); $at_cost = db::c()->query('SELECT 1+IFNULL((SELECT SUM(`cost`) FROM `inventory` WHERE `owner` = `users`.`id` AND `dressed` = 1), 0), `align` FROM `users` WHERE `id` = ?i', $at_id)->fetch_assoc_array(); $def_cost = db::c()->query('SELECT 1+IFNULL((SELECT SUM(`cost`) FROM `inventory` WHERE `owner` = `users`.`id` AND `dressed` = 1), 0), `align` FROM `users` WHERE `id` = ?i', $def_id)->fetch_assoc_array(); if ($at_id > _BOTSEPARATOR_) { $table_name = 'bots'; } else { $table_name = 'users'; } $bat_raw = db::c()->query('SELECT battle FROM ?f WHERE id = ?i', $table_name, $at_id)->fetch_assoc_array(); $bat = $bat_raw['battle']; $bt = db::c()->query('SELECT `blood`,`type`,`t1`,`t2` FROM `battle` WHERE `id` = ?i', $bat)->fetch_assoc(); if ($def_id > _BOTSEPARATOR_) { $bots = db::c()->query('SELECT * FROM bots WHERE id = ?i', $def_id)->fetch_assoc_array(); $def_id = $bots['prototype']; $bot_def = true; } if ($bt['blood']) { $expmf = $mods['bloodb']; } $filebtl = '/tmp/' . $at_id . '.btl'; if ($bt['type'] == 1 && file_exists($filebtl)) { $btfl = fopen($filebtl, 'r'); $contents = fread($btfl, filesize($filebtl)); fclose($btfl); $cnt = substr_count($contents, $def_id); $exmod = 1; if ($cnt <= 1) { $exmod = $mods['btl_1']; } elseif ($cnt == 2) { $exmod = $mods['btl_2']; } elseif ($cnt > 2) { $exmod = $mods['btl_3']; } $expmf = $expmf * $exmod; } $standart = [ "0" => 1, "1" => 1, "2" => 15, "3" => 111, "4" => 265, "5" => 526, "6" => 882, "7" => 919, "8" => 919, "9" => 919, "10" => 919, "11" => 919, "12" => 919, "13" => 919, "14" => 919, "15" => 919, "16" => 919, "17" => 919, "18" => 919, "19" => 919, "20" => 919, "21" => 919, "22" => 919, "23" => 919, "24" => 919, "25" => 919]; $mfit = ($at_cost[0] / ($standart[$at['level']] / 3)); if ($mfit < 0.8) { $mfit = 0.8; } if ($mfit > 1.5) { $mfit = 1.5; } $pls = count(explode(";", $bt['t1'])) + count(explode(";", $bt['t2'])); if ($pls > 2) { $mfbot = $bot_active ? 0.3 : 1; $mfbot2 = $bot_def ? 0.7 : 1; } else { $mfbot = 1; $mfbot2 = 1; } if ($expmf == 0) { $expmf = 1; } return round((($baseexp[$def['level']]) * ($def_cost[0] / (($at_cost[0] + $def_cost[0]) / 2)) * ($damage / $def['maxhp']) * $expmf * $mfit * $mfbot * $mfbot2) / 3); }