function heal($healer, $patient, $cost) { //$healer = preg_replace ('/[^a-z0-9_\.]/i', '', $healer); //$patient = preg_replace ('/[^a-z0-9_]/i', '', $patient); $cost = preg_replace('/[^0-9]/', '', $cost); $id = is_player($patient); $nid = is_npc($healer); $q = do_mysql("SELECT location, money, life, status1 FROM players WHERE id_player = '" . $id . "';"); $p = mysql_fetch_assoc($q); $q = do_mysql("SELECT location FROM npc WHERE id_npc = '" . $nid . "';"); $loc = mysql_result($q, 0); if ($p['location'] != $loc) { return 0; } $p['life'] = explode('|', $p['life']); if ($p['life'][0] == $p['life'][1]) { exit_msg('целительство', 'вы итак полностью здоровы!'); } $price = ceil(($p['life'][1] - $p['life'][0]) / 100) * $cost; if ($p['money'] < $price) { exit_msg('целительство', 'у вас нехватает денег, надо ' . $price . ' серебра!'); } $p['money'] -= $price; $nlife = $p['life'][1] . '|' . $p['life'][1]; $p['status1'][2] = 0; $p['status1'][3] = 0; $p['status1'][4] = 0; do_mysql("UPDATE players SET money = '" . $p['money'] . "', life = '" . $nlife . "', status1 = '" . $p['status1'] . "' WHERE id_player = '" . $id . "';"); exit_msg('целительство', 'вы выздоровили! цена: ' . $price . ' серебра.'); }
function healer_stop_b($healer, $patient, $cost) { //$healer = preg_replace ('/[^a-z0-9_\.]/i', '', $healer); //$patient = preg_replace ('/[^a-z0-9_]/i', '', $patient); $cost = preg_replace('/[^0-9]/', '', $cost); $id = is_player($patient); $nid = is_npc($healer); $q = do_mysql("SELECT location, money, status1 FROM players WHERE id_player = '" . $id . "';"); $p = mysql_fetch_assoc($q); $q = do_mysql("SELECT location FROM npc WHERE id_npc = '" . $nid . "';"); $loc = mysql_result($q, 0); if ($p['location'] != $loc) { return 0; } if (!$p['status1'][2] && !$p['status1'][3] && !$p['status1'][4]) { exit_msg('целительство', 'вы итак полностью здоровы!'); } $price = $cost; if ($p['money'] < $price) { exit_msg('целительство', 'у вас нехватает денег, надо ' . $price . ' серебра!'); } $p['money'] -= $price; $p['status1'][2] = 0; $p['status1'][3] = 0; $p['status1'][4] = 0; do_mysql("UPDATE players SET money = '" . $p['money'] . "', status1 = '" . $p['status1'] . "' WHERE id_player = '" . $id . "';"); exit_msg('целительство', 'вaши раны залечены! цена: ' . $price . ' серебра.'); }
function is_inloc($login, $who) { //$login = mysql_real_escape_string ($login); //$who = mysql_real_escape_string ($who); // lokacija igroka $id = is_player($login); if ($id) { $q = do_mysql("SELECT location FROM players WHERE id_player = '" . $id . "';"); } else { $q = do_mysql("SELECT location FROM npc WHERE id_npc = '" . is_npc($login) . "';"); } if (!mysql_num_rows($q)) { return 0; } $loc = mysql_result($q, 0); $id = is_player($who); if ($id) { $q = do_mysql("SELECT location FROM players WHERE id_player = '" . $id . "';"); } else { $q = do_mysql("SELECT location FROM npc WHERE id_npc = '" . is_npc($who) . "';"); } if (!mysql_num_rows($q)) { return 0; } $loc2 = mysql_result($q, 0); if ($loc == $loc2) { return 1; } return 0; }
function get_affected($name) { //$name = preg_replace ('/[^a-z\._0-9]/i', '', $name); // pokachto tolqko chelam: $id = is_player($name); if ($id) { $q = do_mysql("SELECT affected FROM players WHERE id_player = '" . $id . "';"); $a = mysql_result($q, 0); } else { $id = is_npc($name); if (!$id) { return 0; } $q = do_mysql("SELECT affected FROM npc WHERE id_npc = '" . $id . "';"); if (!mysql_num_rows($q)) { return 0; } $a = mysql_result($q, 0); } if (!$a) { return 0; } $a = explode('|', $a); $c = count($a); for ($i = 0; $i < $c; $i++) { $a[$i] = explode(':', $a[$i]); $arr[] = $a[$i][0]; } return $arr; }
function teach_magic_from_sc($scroll, $npc, $login) { //$scroll = preg_replace ('/[^a-z0-9_\.]/i', '', $scroll); //$npc = preg_replace ('/[^a-z0-9_\.]/i', '', $npc); //$login = preg_replace ('/[^a-z0-9_]/i', '', $login); $nid = is_npc($npc); $id = is_player($login); // v odnoj li lokacii $q = do_mysql("SELECT location FROM npc WHERE id_npc = '" . $nid . "';"); if (!mysql_num_rows($q)) { return 0; } $loc1 = mysql_result($q, 0); $q = do_mysql("SELECT location FROM players WHERE id_player = '" . $id . "';"); if (!mysql_num_rows($q)) { return 0; } $loc2 = mysql_result($q, 0); if ($loc1 != $loc2) { return 0; } include_once 'modules/f_has_item.php'; if (!has_item($scroll, $login)) { put_g_error('у вас нету свитка!'); } $q = do_mysql("SELECT on_take, price FROM items WHERE fullname = '" . $scroll . "' AND type = 's';"); if (!mysql_num_rows($q)) { return 0; } $spell = mysql_fetch_assoc($q); // neumeet li on uzhe include_once 'modules/f_has_magic.php'; if (has_magic($spell['on_take'], $login)) { put_g_error('вы уже умеете это заклинание!'); } // cenu vyschitaem: $q = do_mysql("SELECT money FROM players WHERE id_player = '" . $id . "';"); $money = mysql_result($q, 0); $cost = $spell['price'] * 10; if ($money < $cost) { put_g_error('нехватает серебра, нужно ' . $cost . ' серебреных!'); } $money -= $cost; // dobavljaem zakl: $q = do_mysql("SELECT magic FROM players WHERE id_player = '" . $id . "';"); $magic = mysql_result($q, 0); if (!$magic) { $magic = $spell['on_take']; } else { $magic .= '|' . $spell['on_take']; } // obnovim dannye: do_mysql("UPDATE players SET magic = '" . $magic . "', money = '" . $money . "' WHERE id_player = '" . $id . "';"); // udaljaem svitok include_once 'modules/f_delete_item.php'; delete_item($scroll); $q = do_mysql("SELECT name FROM magic WHERE fullname = '" . $spell['on_take'] . "';"); $name = mysql_result($q, 0); exit_msg('магия', 'вы выучили заклинание ' . $name . ' за ' . $cost . ' серебреных!'); }
function has_npc_quest($npc) { $id = is_npc($npc); $q = do_mysql("SELECT quest FROM npc WHERE id_npc = '" . $id . "';"); $quest = mysql_result($q, 0); if ($quest) { return 1; } else { return 0; } }
function end_battle($who) { $id = is_player($who); if ($id) { do_mysql("UPDATE players SET in_battle = '0' WHERE id_player = '" . $id . "';"); } else { $id = is_npc($who); do_mysql("UPDATE npc SET in_battle = '0' WHERE id_npc = '" . $id . "';"); } return 1; }
function block($to) { $id = is_player($to); if ($id) { $q = do_mysql("SELECT name, location FROM players WHERE id_player = '" . $id . "';"); $p = mysql_fetch_assoc($q); add_journal($p['name'] . ' блокировал!', 'l.' . $p['location']); } else { $id = is_npc($to); $q = do_mysql("SELECT name, location FROM npc WHERE id_npc = '" . $id . "';"); $n = mysql_fetch_assoc($q); add_journal($n['name'] . ' блокировал!', 'l.' . $n['location']); } return 1; }
function add_to_loc($loc, $who) { // proverka dannyh //$who = preg_replace ('/[^a-z\._0-9]/i', '', $who); //$loc = preg_replace ('/[^a-z0-9\|]/i', '', $loc); if (is_npc($who)) { // vpishem npc $map = substr($loc, 0, 4); do_mysql("UPDATE npc SET location = '" . $loc . "', map = '" . $map . "' WHERE fullname = '" . $who . "';"); } else { $log = substr($who, 0, 2); // vpishem igroka do_mysql("UPDATE players SET location = '" . $loc . "' WHERE login = '******';"); } return 1; }
function get_npc_battle_har($npc) { //$npc = preg_replace ('/[^a-z\._0-9]/i', '', $npc); $id = is_npc($npc); $q = do_mysql("SELECT chanse FROM npc WHERE id_npc = '" . $id . "';"); if (!mysql_num_rows($q)) { include 'modules/s_main.php'; } $c = mysql_result($q, 0); $c = explode('~', $c); include_once 'modules/f_get_affected.php'; $aff = get_affected($npc); if (is_in('osleplen', $aff)) { for ($i = 0; $i < 10; $i++) { $с[$i] = round($с[$i] / 2); } } return $c; }
function upd_last_attack($pl) { //$pl = preg_replace ('/[^a-z0-9_\.]/i', '', $pl); $now = time(); $id = is_player($pl); if (!$id) { $id = is_npc($pl); // npc do_mysql("UPDATE npc SET lastattack = '" . $now . "' WHERE id_npc = '" . $id . "';"); return 1; } $q = do_mysql("SELECT last FROM players WHERE id_player = '" . $id . "';"); $last = mysql_result($q, 0); $last = explode('|', $last); $last[1] = $now; $nlast = $last[0] . '|' . $last[1] . '|' . $last[2] . '|' . $last[3] . '|' . $last[4] . '|' . $last[5] . '|' . $last[6] . '|' . $last[7] . '|' . $last[8]; do_mysql("UPDATE players SET last = '" . $nlast . "' WHERE id_player = '" . $id . "';"); return 1; }
function upd_affected($name, $end = 0) { //$name = preg_replace ('/[^a-z0-9_\.]/i', '', $name); $id = is_player($name); $n = 0; if ($id) { $q = do_mysql("SELECT affected FROM players WHERE id_player = '" . $id . "';"); } else { $id = is_npc($name); $n = 1; $q = do_mysql("SELECT affected FROM npc WHERE id_npc = '" . $id . "';"); } $aff = mysql_result($q, 0); if (!$aff) { return 1; } $aff = explode('|', $aff); $c = count($aff); for ($i = 0; $i < $c; $i++) { $aff[$i] = explode(':', $aff[$i]); //echo $aff[$i][0].' '.$aff[$i][1].' '.(time()).'<br/>'; if ($aff[$i][1] <= time() || $end) { // dalee, esi estq takoj fail, spec izmenenija effekta ustanovim if (file_exists('modules/effects/e_end_' . $aff[$i][0] . '.php')) { include 'modules/effects/e_end_' . $aff[$i][0] . '.php'; } unset($aff[$i]); } if (isset($aff[$i])) { $aff[$i] = implode(':', $aff[$i]); } } $aff = implode('|', $aff); if ($aff == '|') { $aff = ''; } if (!$n) { do_mysql("UPDATE players SET affected = '" . $aff . "' WHERE id_player = '" . $id . "';"); } else { do_mysql("UPDATE npc SET affected = '" . $aff . "' WHERE id_npc = '" . $id . "';"); } return 1; }
function mag_summon($spell, $login) { //$spell = preg_replace ('/[^a-z0-9_]/i', '', $spell); //$login = preg_replace ('/[^a-z0-9_]/i', '', $login); $id = is_player($login); $q = do_mysql("SELECT cname FROM magic WHERE fullname = '" . $spell . "';"); if (!mysql_num_rows($q)) { return 0; } $fullname = mysql_result($q, 0); if (!$fullname) { return 0; } // zapros na lokaciju igroka i kolichestvo priruchennyh zhivotnyh $q = do_mysql("SELECT location FROM players WHERE id_player = '" . $id . "';"); if (!mysql_num_rows($q)) { return 0; } $loc = mysql_result($q, 0); $q = do_mysql("SELECT COUNT(*) FROM npc WHERE belongs = '" . $login . "';"); $c = mysql_result($q, 0); if ($c > 0) { put_g_error('у вас уже есть нпц, принадлежащие вам'); } // sozdaem npc: include_once 'modules/f_create_npc.php'; $npc = create_npc($fullname, substr($loc, 0, 4), $loc); $nid = is_npc($npc); // izmenim imja: $q = do_mysql("SELECT name FROM npc WHERE id_npc = '" . $nid . "';"); $name = mysql_result($q, 0); $nname = 'призванный ' . $name; $fullname = $npc . '.' . $login; // ataka: $q = do_mysql("SELECT in_battle FROM players WHERE id_player = '" . $id . "';"); $inb = mysql_result($q, 0); do_mysql("UPDATE npc SET fullname = '" . $fullname . "', name = '" . $nname . "', belongs = '" . $login . "', move = '30', in_battle = '" . $inb . "', type = 'a' WHERE id_npc = '" . $nid . "';"); $q = do_mysql("SELECT name FROM players WHERE id_player = '" . $id . "';"); $pn = mysql_result($q, 0); add_journal($pn . ': призвал ' . $name . '!', 'l.' . $loc); return 1; }
function get_npc_info($npc, $what) { //$npc = preg_replace ('/[^a-z\._0-9]/i', '', $npc); //$what = preg_replace ('/[^a-z]/i', '', $what); // sbnachalo proverim chto za what // what == 'name' - imja // $what == 'all' - vse, razdroblenno otdatq // $what == 'location' - lokaciju // $what == 'is_alive' - zhiv li // $what == 'life' - zhiznq $id = is_npc($npc); if ($what == 'name') { $alo = do_mysql("SELECT name FROM npc WHERE id_npc = '" . $id . "';"); $name = mysql_result($alo, 0); return $name; } if ($what == 'all') { $q = do_mysql("SELECT * FROM npc WHERE id_npc = '" . $id . "';"); $all = mysql_fetch_assoc($q); $all['life'] = explode('|', $all['life']); return $all; } if ($what == 'location') { $alo = do_mysql("SELECT location FROM npc WHERE id_npc = '" . $id . "';"); $loc = mysql_result($alo, 0); return $loc; } if ($what == 'is_alive') { $q = do_mysql("SELECT life FROM npc WHERE id_npc = '" . $id . "';"); $al = mysql_result($q, 0); if (substr($al, 0, 1) == 0) { return 0; } else { return 1; } } if ($what == 'life') { $q = do_mysql("SELECT life FROM npc WHERE id_npc = '" . $id . "';"); $al = mysql_result($q, 0); return $al; } }
function check_dead($who) { //$who = preg_replace ('/[^a-z\._0-9]/i', '', $who); $id = is_player($who); if ($id) { $q = do_mysql("SELECT life FROM players WHERE id_player = '" . $id . "';"); } else { $q = do_mysql("SELECT life FROM npc WHERE id_npc = '" . is_npc($who) . "';"); } if (!mysql_num_rows($q)) { return 0; } $life = mysql_result($q, 0); $life = explode('|', $life); if (!$life[0]) { return 1; } else { return 0; } }
function end_fire($name) { //$name = preg_replace ('/[^a-z0-9_\.]/i', '', $name); $id = is_player($name); if ($id) { $q = do_mysql("SELECT status1 FROM players WHERE id_player = '" . $id . "';"); $st = mysql_result($q, 0); $st[4] = 0; do_mysql("UPDATE players SET status1 = '" . $st . "' WHERE id_player = '" . $id . "';"); return 1; } $id = is_npc($name); $q = do_mysql("SELECT affected FROM npc WHERE id_npc = '" . $id . "';"); $aff = mysql_result($q, 0); if (!$aff) { return 1; } $aff = explode('|', $aff); $c = count($aff); for ($i = 0; $i < $c; $i++) { $aff[$i] = explode(':', $aff[$i]); //echo $aff[$i][0].' '.$aff[$i][1].' '.(time()).'<br/>'; if ($aff[$i][0] == 'gorit') { unset($aff[$i]); } if (isset($aff[$i])) { $aff[$i] = implode(':', $aff[$i]); } } if (isset($aff)) { $aff = implode('|', $aff); } else { $aff = ''; } if ($aff == '|') { $aff = ''; } do_mysql("UPDATE npc SET affected = '" . $aff . "' WHERE id_npc = '" . $id . "';"); return 1; }
function teach_kombo($teacher, $student, $kombo, $price) { //$teacher = preg_replace ('/[^a-z0-9_\.]/i', '', $teacher); //$student = preg_replace ('/[^a-z0-9_]/i', '', $student); //$kombo = preg_replace ('/[^a-z0-9_]/i', '', $kombo); $price = preg_replace('/[^0-9]/', '', $price); $id = is_player($student); $nid = is_npc($teacher); $q = do_mysql("SELECT location, money, kombo FROM players WHERE id_player = '" . $id . "';"); $p = mysql_fetch_assoc($q); $q = do_mysql("SELECT location FROM npc WHERE id_npc = '" . $nid . "';"); $loc = mysql_result($q, 0); if ($p['location'] != $loc) { return 0; } if ($p['money'] < $price) { exit_msg('комбо', 'у вас нехватает денег, надо ' . $price . ' серебра!'); } $kb = explode('|', $p['kombo']); $c = count($kb); $has = 0; for ($i = 0; $i < $c; $i++) { $kb[$i] = explode(':', $kb[$i]); if ($kb[$i][0] == $kombo) { $has = 1; } } if ($has) { exit_msg('комбо', 'вы уже yмеете этот прием!'); } $p['money'] -= $price; if (!$p['kombo']) { $p['kombo'] = $kombo . ':1:0'; } else { $p['kombo'] .= '|' . $kombo . ':1:0'; } do_mysql("UPDATE players SET money = '" . $p['money'] . "', kombo = '" . $p['kombo'] . "' WHERE id_player = '" . $id . "';"); exit_msg('комбо', 'вы выучили новый прием!'); }
function mag_decl_attack($who, $to) { // po idee magiej npc napadatq nebudut, no na vsjakij pozharnyj i tak puwu: //$who = preg_replace ('/[^a-z0-9_\.]/i', '', $who); //$to = preg_replace ('/[^a-z0-9_\.]/i', '', $to); if ($to == $who) { put_g_error('на себя напасть нелзя!'); } $id = is_player($who); $n = 0; if ($id) { $q = do_mysql("SELECT in_battle, status1, location, last FROM players WHERE id_player = '" . $id . "';"); } else { $id = is_npc($who); $n = 1; $q = do_mysql("SELECT in_battle, location FROM npc WHERE id_npc = '" . $id . "';"); } $w_inf = mysql_fetch_assoc($q); $tid = is_player($to); $tn = 0; if ($tid) { $q = do_mysql("SELECT in_battle, status1, location FROM players WHERE id_player = '" . $tid . "';"); } else { $tid = is_npc($to); $tn = 1; $q = do_mysql("SELECT in_battle, location FROM npc WHERE id_npc = '" . $tid . "';"); } $t_inf = mysql_fetch_assoc($q); if ($w_inf['location'] != $t_inf['location']) { return 0; } // celq nedostezhima include_once 'modules/f_attack.php'; attack($who, $to); return 1; }
<?php // $name=login $id = is_player($name); if ($id) { // esli igrok $q = do_mysql("SELECT skills FROM players WHERE id_player = '" . $id . "';"); $s = mysql_result($q, 0); $s = explode('|', $s); $s[1] += 5; // dex +5 $s = implode('|', $s); do_mysql("UPDATE players SET skills = '" . $s . "' WHERE id_player = '" . $id . "';"); } else { // esli npc $id = is_npc($name); do_mysql("UPDATE npc SET dex = dex + 5 WHERE id_npc = '" . $id . "';"); }
function check_npc_exp($npc2) { $id = is_npc($npc2); if (!$id) { return 0; } $q = do_mysql("SELECT * FROM npc WHERE id_npc = '" . $id . "';"); $n = mysql_fetch_assoc($q); $exphas = round((600 * $n['lvl'] * $n['lvl'] + 1000 * $n['lvl']) / 7); $expto = 600 * $n['lvl'] * $n['lvl'] + 1000 * $n['lvl']; // exphas - do novogo ochka, expto, do novogo urovnja. if ($exphas <= $n['exphas']) { $n['exphas'] -= $exphas; $s = array('str', 'dex', 'int', 'rea', 'other'); $num = array_rand($s); $n[$s[$num]]++; add_journal($n['name'] . ' получил очко опыта! ' . $s[$num] . '++!', 'l.' . $n['location']); $file_name = str_replace('.', '_', $n['realname']); $dir = substr($n['realname'], 2, 1); if (!file_exists('modules/npc/' . $dir . '/' . $file_name . '.php')) { put_error('файл нпц не найден ' . $fullname); } include 'modules/npc/' . $dir . '/' . $file_name . '.php'; $p['skills'][0] = $n['str']; $p['skills'][1] = $n['dex']; $p['skills'][2] = $n['int']; $p['skills'][3] = $n['rea']; $p['skills'][4] = $n['other']; $t[0] = $p['skills'][1] * 10 + $p['skills'][4] * 10 + $p['skills'][3] * 2; # udar $t[1] = $p['skills'][1] * 10 + $p['skills'][4] * 10 + $p['skills'][3] * 5; # blok $t[2] = $p['skills'][1] * 5 + $p['skills'][4] * 5 + $p['skills'][3] * 5; # uklon $t[3] = $p['skills'][1] * 10 + $p['skills'][4] * 10 + $p['skills'][3] * 2; # parirovanie $t[4] = $p['skills'][2] * 8 + $p['skills'][4] * 3; // pri primenenii dobavitq magija na 9 # uron magija $t[5] = $p['skills'][2] * 4 + $p['skills'][4] * 2 + $p['skills'][4] * 6; // pri primenenii dobavitq magija na 3 # ochki blok magija $t[6] = $p['skills'][2] * 8 + $p['skills'][4] * 2 + $p['skills'][4] * 8; // pri primenenii dobavitq magija na 3 # soprotivlenie magii $t[7] = $p['skills'][2] * 5 + $p['skills'][4] * 5 + $p['skills'][4] + $p['skills'][4] * 3; // pri ispolqzovanii dobavitq magija na 3; # uklon ot magii $t[8] = $p['skills'][1] * 3 + $p['skills'][4] * 3 + $p['skills'][4] * 3; # uklon ot strelqby $t[9] = $p['skills'][1] * 5 + $p['skills'][3] * 5 + $p['skills'][4] * 5; $life = $p['skills'][0] * 71 + $p['skills'][1] * 32; $n['life'] = $life . '|' . $life; $n['chanse'] = $t[0] . '~' . $t[1] . '~' . $t[2] . '~' . $t[3] . '~' . $t[4] . '~' . $t[5] . '~' . $t[6] . '~' . $t[7] . '~' . $t[8] . '~' . $t[9]; $n['exp'] = $n['lvl'] * 20 + $n['str'] * 5; $dmgmin = $n['lvl'] * 21 + $p['skills'][0] * 4 + $p['skills'][4] * 5 + $p['skills'][1] * 3; $dmgmax = $n['lvl'] * 22 + $p['skills'][0] * 8 + $p['skills'][4] * 7 + $p['skills'][1] * 4; // $n['dmg'] = str_replace ('1-1', $dmgmin.'-'.$dmgmax, $n['dmg']); $primea = round(($dmgmin + $dmgmax) / 3); $seconda = round(($dmgmin + $dmgmax) / 5); // $dmgmin = round ($dmgmin * 0.7); // $dmgmax = round ($dmgmax * 0.7); // $n['dmg'] = str_replace ('2-2', $dmgmin.'-'.$dmgmax, $n['dmg']); $n['dmg'] = explode('~', $npc['dmg']); for ($i = 0; $i < 5; $i++) { if ($n['dmg'][$i] == '1-1') { $n['dmg'][$i] = $dmgmin . '-' . $dmgmax; } if ($n['dmg'][$i] == '2-2') { $n['dmg'][$i] = round($dmgmin * 0.7) . '-' . round($dmgmax * 0.7); } } $n['dmg'] = implode('~', $n['dmg']); $n['armor'] = explode('~', $npc['armor']); for ($i = 0; $i < 5; $i++) { if ($n['armor'][$i] == 1) { $n['armor'][$i] = $primea; } if ($n['armor'][$i] == 2) { $n['armor'][$i] = $seconda; } } $n['armor'] = implode('~', $n['armor']); //echo '<pre>'; //print_r ($n); //print_r ($npc); do_mysql("UPDATE npc SET exphas = '" . $n['exphas'] . "', str = '" . $n['str'] . "', dex = '" . $n['dex'] . "', `int` = '" . $n['int'] . "', rea = '" . $n['rea'] . "', other = '" . $n['other'] . "', sp = sp + 1, dmg = '" . $n['dmg'] . "', armor = '" . $n['armor'] . "', life = '" . $n['life'] . "', chanse = '" . $n['chanse'] . "', exp = '" . $n['exp'] . "' WHERE id_npc = '" . $id . "';"); unset($npc); } if ($expto <= $n['expto']) { $n['expto'] -= $expto; $n['lvl'] += 1; $n['str'] += 1; $n['dex'] += 1; $n['other'] += 1; $n['sp'] += 3; add_journal($n['name'] . ' получил новый уровень! ', 'l.' . $n['location']); $file_name = str_replace('.', '_', $n['realname']); $dir = substr($n['realname'], 2, 1); if (!file_exists('modules/npc/' . $dir . '/' . $file_name . '.php')) { put_error('файл нпц не найден ' . $fullname); } include 'modules/npc/' . $dir . '/' . $file_name . '.php'; $p['skills'][0] = $n['str']; $p['skills'][1] = $n['dex']; $p['skills'][2] = $n['int']; $p['skills'][3] = $n['rea']; $p['skills'][4] = $n['other']; $t[0] = $p['skills'][1] * 10 + $p['skills'][4] * 10 + $p['skills'][3] * 2; # udar $t[1] = $p['skills'][1] * 10 + $p['skills'][4] * 10 + $p['skills'][3] * 5; # blok $t[2] = $p['skills'][1] * 5 + $p['skills'][4] * 5 + $p['skills'][3] * 5; # uklon $t[3] = $p['skills'][1] * 10 + $p['skills'][4] * 10 + $p['skills'][3] * 2; # parirovanie $t[4] = $p['skills'][2] * 8 + $p['skills'][4] * 3; // pri primenenii dobavitq magija na 9 # uron magija $t[5] = $p['skills'][2] * 4 + $p['skills'][4] * 2 + $p['skills'][4] * 6; // pri primenenii dobavitq magija na 3 # ochki blok magija $t[6] = $p['skills'][2] * 8 + $p['skills'][4] * 2 + $p['skills'][4] * 8; // pri primenenii dobavitq magija na 3 # soprotivlenie magii $t[7] = $p['skills'][2] * 5 + $p['skills'][4] * 5 + $p['skills'][4] + $p['skills'][4] * 3; // pri ispolqzovanii dobavitq magija na 3; # uklon ot magii $t[8] = $p['skills'][1] * 3 + $p['skills'][4] * 3 + $p['skills'][4] * 3; # uklon ot strelqby $t[9] = $p['skills'][1] * 5 + $p['skills'][3] * 5 + $p['skills'][4] * 5; $life = $p['skills'][0] * 71 + $p['skills'][1] * 32; $n['life'] = $life . '|' . $life; $n['chanse'] = $t[0] . '~' . $t[1] . '~' . $t[2] . '~' . $t[3] . '~' . $t[4] . '~' . $t[5] . '~' . $t[6] . '~' . $t[7] . '~' . $t[8] . '~' . $t[9]; $n['exp'] = $n['lvl'] * 20 + $n['str'] * 5; $dmgmin = $n['lvl'] * 21 + $p['skills'][0] * 4 + $p['skills'][4] * 5 + $p['skills'][1] * 3; $dmgmax = $n['lvl'] * 22 + $p['skills'][0] * 8 + $p['skills'][4] * 7 + $p['skills'][1] * 4; // $n['dmg'] = str_replace ('1-1', $dmgmin.'-'.$dmgmax, $n['dmg']); $primea = round(($dmgmin + $dmgmax) / 3); $seconda = round(($dmgmin + $dmgmax) / 5); // $dmgmin = round ($dmgmin * 0.7); // $dmgmax = round ($dmgmax * 0.7); // $n['dmg'] = str_replace ('2-2', $dmgmin.'-'.$dmgmax, $n['dmg']); $n['dmg'] = explode('~', $npc['dmg']); for ($i = 0; $i < 5; $i++) { if ($n['dmg'][$i] == '1-1') { $n['dmg'][$i] = $dmgmin . '-' . $dmgmax; } if ($n['dmg'][$i] == '2-2') { $n['dmg'][$i] = round($dmgmin * 0.7) . '-' . round($dmgmax * 0.7); } } $n['dmg'] = implode('~', $n['dmg']); $n['armor'] = explode('~', $npc['armor']); for ($i = 0; $i < 5; $i++) { if ($n['armor'][$i] == 1) { $n['armor'][$i] = $primea; } if ($n['armor'][$i] == 2) { $n['armor'][$i] = $seconda; } } $n['armor'] = implode('~', $n['armor']); //echo '<pre>'; //print_r ($n); //print_r ($npc); do_mysql("UPDATE npc SET life = '" . $n['life'] . "', dmg = '" . $n['dmg'] . "', armor = '" . $n['armor'] . "', exp = '" . $n['exp'] . "', chanse = '" . $n['chanse'] . "', str = '" . $n['str'] . "', dex = '" . $n['dex'] . "', other = '" . $n['other'] . "', expto = '" . $n['expto'] . "', sp = '" . $n['sp'] . "', lvl = '" . $n['lvl'] . "' WHERE id_npc = '" . $id . "';"); } return 1; }
function attack($who, $to) { // prosto vnosit imena. esli nelzja dostatq, v funkcii nanesti uron bitva okonchitsja $id = is_player($who); if ($id) { if ($who == $to) { put_g_error('суицид кармически наказуем'); } // berem spisok - imja, kto v boju uzhe: $whp = 1; $q = do_mysql("SELECT id_player, login, name, gender, location, in_battle, status1, last, clan FROM players WHERE id_player = '" . $id . "';"); $att = mysql_fetch_assoc($q); $att['last'] = explode('|', $att['last']); // takzhe, vozqmem informaciju o prizvanyh i priruchenyh. $q = do_mysql("SELECT id_npc, fullname, name, in_battle FROM npc WHERE belongs = '" . $who . "';"); if (mysql_num_rows($q)) { $whobel = mysql_fetch_assoc($q); } } else { $id = is_npc($who); if (!$id2) { return 0; } $whp = 0; // osnovnaja informacija monstra - $q = do_mysql("SELECT id_npc, fullname, name, location, in_battle FROM npc WHERE id_npc = '" . $id . "';"); $att = mysql_fetch_assoc($q); // pokachto nebudem schitatq partii monstrov } // teperq na togo na kogo napadaet soberem informaciju $id2 = is_player($to); if ($id2) { $tp = 1; // berem spisok - imja, kto v boju uzhe: $q = do_mysql("SELECT id_player, login, name, in_battle, location, status1, clan, active FROM players WHERE id_player = '" . $id2 . "';"); $def = mysql_fetch_assoc($q); if (!$def['active']) { return 0; } // takzhe, vozqmem informaciju o prizvanyh i priruchenyh. $q = do_mysql("SELECT id_npc, fullname, name, in_battle FROM npc WHERE belongs = '" . $to . "';"); if (mysql_num_rows($q)) { $tobel = mysql_fetch_assoc($q); } } else { $id2 = is_npc($to); if (!$id2) { return 0; } $tp = 0; // osnovnaja informacija monstra - $q = do_mysql("SELECT id_npc, fullname, name, in_battle, type, location, belongs FROM npc WHERE id_npc = '" . $id2 . "';"); $def = mysql_fetch_assoc($q); // napadatq na torgovcev i npc nelzja - tolqko na monstrov i zhivotnyh if ($def['type'] == 's' || $def['type'] == 't') { put_g_error('ну что тебе это существо плохого сделала то, а?'); } // esli na svoegozhe napadaem, to bolqshe ne svoj zhe - if ($def['belongs'] == $who) { $def['belongs'] = '0'; do_mysql("UPDATE npc SET belongs = '0' WHERE id_npc = '" . $id2 . "';"); } // pokachto nebudem schitatq partii monstrov } // esli uzhe v boju, to nichego ne budem delatq if ($att['in_battle'] > 0 && $def['in_battle'] > 0 && $att['in_battle'] != $def['in_battle']) { return 1; } if ($att['in_battle'] > 0 && $att['in_battle'] == $def['in_battle']) { put_g_error('он на вашей стороне!'); } if (!$att['in_battle']) { if (!$def['in_battle']) { $att['in_battle'] = 1; $def['in_battle'] = 2; } else { if ($def['in_battle'] == 1) { $att['in_battle'] = 2; } else { $att['in_battle'] = 1; } } } else { if ($att['in_battle'] == 1) { $def['in_battle'] = 2; } else { $def['in_battle'] = 1; } } // zony, svobodnye ot ataki: $toloc = $def['location']; if (substr($toloc, 0, 4) == 'rele' || substr($toloc, 0, 4) == 'elfc' || substr($toloc, 0, 4) == 'verg') { put_g_error('на этой локации атаковать нелзя'); } if ($whp) { do_mysql("UPDATE players SET in_battle = '" . $att['in_battle'] . "' WHERE id_player = '" . $att['id_player'] . "';"); } else { do_mysql("UPDATE npc SET in_battle = '" . $att['in_battle'] . "' WHERE id_npc = '" . $att['id_npc'] . "';"); } if ($tp) { do_mysql("UPDATE players SET in_battle = '" . $def['in_battle'] . "' WHERE id_player = '" . $def['id_player'] . "';"); } else { do_mysql("UPDATE npc SET in_battle = '" . $def['in_battle'] . "' WHERE id_npc = '" . $def['id_npc'] . "';"); } // teperq pitomcy if (isset($whobel)) { $whobel['in_battle'] = $att['in_battle']; do_mysql("UPDATE npc SET in_battle = '" . $whobel['in_battle'] . "' WHERE id_npc = '" . $whobel['id_npc'] . "';"); } if (isset($tobel)) { $tobel['in_battle'] = $def['in_battle']; do_mysql("UPDATE npc SET in_battle = '" . $tobel['in_battle'] . "' WHERE id_npc = '" . $tobel['id_npc'] . "';"); } // dela s karmoj svjazanye if (isset($def['login']) && isset($att['login']) && $def['status1'][0] != 1 && $def['status1'][0] != 2 && substr($def['location'], 0, 4) != 'pris' && substr($def['location'], 0, 3) != 'are') { // proverim togda vojnu klanovuju - $att['clan'] = explode('|', $att['clan']); $def['clan'] = explode('|', $def['clan']); $q = do_mysql("SELECT politics FROM clans WHERE clanname = '" . $att['clan'][0] . "';"); if (!mysql_num_rows($q)) { $pol = ''; } $pol = mysql_result($q, 0); $pol = explode('|', $pol); // 0 - war if (!is_in($def['clan'][0], $pol[0])) { $att['status1'][0] = 1; $att['last'][4] = time(); $att['last'] = implode('|', $att['last']); do_mysql("UPDATE players SET last = '" . $att['last'] . "', status1 = '" . $att['status1'] . "' WHERE id_player = '" . $att['id_player'] . "';"); } } if (isset($att['login']) && $att['gender'] == 'female') { $attacked = 'напалa'; } else { $attacked = 'напал'; } add_journal($att['name'] . ' ' . $attacked . ' на ' . $def['name'] . '!', 'l.' . $att['location']); return 1; }
function go_to_loc($who, $loc_go, $stor, $ok = 0) { # get_pl_info(), do_mysql();, get_npc_info();, loc();, put_error();, delete_from_loc();, add_to_loc();, addjournal(); require_once 'modules/f_get_pl_info.php'; require_once 'modules/f_get_npc_info.php'; require_once 'modules/f_loc.php'; require_once 'modules/f_add_to_loc.php'; // proverka dannyh // $who = preg_replace ('/[^a-z\._0-9]/i', '', $who); if (!$ok) { $loc_go = preg_replace('/[^a-z0-9\\|]/', '', $loc_go); $stor = preg_replace('/[^a-z0-9]/i', '', $stor); } // $stor - eto storona. dlja massiva // lokacija if (substr($who, 0, 2) == 'p.') { // login $login = substr($who, 2); $who = $login; $id = is_player($login); $lq = do_mysql("SELECT location FROM players WHERE id_player = '" . $id . "';"); $loc = mysql_result($lq, 0); $lq = do_mysql("SELECT name FROM players WHERE id_player = '" . $id . "';"); $name = mysql_result($lq, 0); //$loc = get_pl_info ($login, 'location'); $qg = do_mysql("SELECT gender FROM players WHERE id_player = '" . $id . "';"); $gender = mysql_result($qg, 0); $qg = do_mysql("SELECT walking FROM players WHERE id_player = '" . $id . "';"); $w = mysql_result($qg, 0); if ($w > 0) { $CAN_JUMP = 1; } $qg = do_mysql("SELECT carry FROM players WHERE id_player = '" . $id . "';"); $carry = mysql_result($qg, 0); include_once 'modules/f_get_pl_weight.php'; if ($carry < get_pl_weight($login)) { put_g_error('вы перегруженны'); } $n = 0; $who = $login; // proverka na boj - $q = do_mysql("SELECT in_battle FROM players WHERE id_player = '" . $id . "';"); $inb = mysql_result($q, 0); $type = 'a'; } if (substr($who, 0, 2) == 'n.') { $loc = get_npc_info($who, 'location'); $id = is_npc($who); // adding npc to move log - global $NPC_MOVED; $NPC_MOVED[$id] = 1; $alo = do_mysql("SELECT name FROM npc WHERE id_npc = '" . $id . "';"); $login = mysql_result($alo, 0); $name = $login; $alo = do_mysql("SELECT type FROM npc WHERE id_npc = '" . $id . "';"); $type = mysql_result($alo, 0); $n = 1; $inb = 0; } # vozmozhny dva puti - na druguju kartu ili prosto na druguju lokaciju # na druguju kartu ne storony, potomu prosto stor = 'nmap'; # na druguju lokaciju - togda cherez near // ESLI NA DRUGUJU KARU $show_info = 0; if (substr($loc, 0, 4) != substr($loc_go, 0, 4)) { global $NEWMAP; $NEWMAP = 1; // a eshe ustanovim flag show_info, po kotoromu potom opredelim, nado li pokazatq vstupitelqnyj tekst k loakacci $show_info = 1; // zlye npc nemogut idti v goroda if ($type == 'x') { $toloc = substr($loc_go, 0, 4); if ($toloc == 'rele' || $toloc == 'elfc' || $toloc == 'verg') { return 0; } } } $li = ''; // voobshem eto tazhe lokacija include_once 'modules/f_can_u_reach.php'; $depth = 1; if (isset($_GET['jump']) && isset($CAN_JUMP)) { $depth = 2; } // esli v okruzhnoj lokacii netu takoj loki v takuju storonu, to idti nelzja if (!can_u_reach($who, $loc_go, $stor, $depth)) { //put_error ('<p>извините, но в указаном направлении такой локации нет</p>'); return 0; } if ($depth == 2) { // get loc v can u reach $ll = get_loc($who, $stor, 1); add_journal($name . ' пронесся мимо!', 'l.' . $ll); } // est9q li loka na kotoruju idut? ////////////////////////////// // pitomec $an = do_mysql("SELECT name, fullname FROM npc WHERE belongs = '" . $who . "' AND location = '" . $loc . "' AND move <> 0;"); $an = mysql_fetch_assoc($an); if ($an['fullname']) { $pit = ' и ' . $an['name'] . ' '; add_to_loc($loc_go, $an['fullname']); } else { $pit = ''; } if (substr($who, 0, 2) == 'n.') { $map = substr($loc_go, 0, 4); do_mysql("UPDATE npc SET location = '" . $loc_go . "', map = '" . $map . "' WHERE id_npc = '" . $id . "';"); } else { do_mysql("UPDATE players SET location = '" . $loc_go . "' WHERE id_player = '" . $id . "';"); } $loc2 = 'l.' . $loc; // pogonja if ($inb && substr($loc_go, 0, 4) != 'rele' && substr($loc_go, 0, 4) != 'elfc' && substr($loc_go, 0, 4) != 'verg') { $tinb = 0; if ($inb == 1) { $tinb = 2; } else { $tinb = 1; } $q = do_mysql("SELECT fullname FROM npc WHERE location = '" . $loc . "' AND in_battle = '" . $tinb . "';"); while ($nt = mysql_fetch_assoc($q)) { go_to_loc($nt['fullname'], $loc_go, $stor, 1); } } // formiruem soobshenie. $pere = ''; if (isset($near)) { $pere = $near[$stor][2]; } if ($li) { $pere = $li[2]; } if ($pit) { $gone = 'ушли'; $come = 'пришли'; } else { if (!isset($gender)) { // dlja npc, esliimja konchaetsja na 'a', to skorej vsego devushka $len = strlen($login); $len2 = $len - 1; if (substr($login, $len2) == 'а') { $gone = 'ушла'; $come = 'пришла'; } else { $gone = 'ушел'; $come = 'пришел'; } } else { if ($gender == 'male') { $gone = 'ушел'; $come = 'пришел'; } if ($gender == 'female') { $gone = 'ушла'; $come = 'пришла'; } } } // proverim $n, esli 1 to eto npc i nado vsem pisatq, esli net to perehodjashemu ne nado if ($n) { $need = 1; } else { $need = 0; } // v byvshuju lokaciju add_journal('<b>' . $name . '' . $pit . ' ' . $gone . ' ' . $pere . '</b>', 'l.' . $loc, $need); // v novuju add_journal('<b>' . $come . ' ' . $name . '' . $pit . '</b>', 'l.' . $loc_go, $need); //echo '<br/>show info = '.$show_info.'<br/>'; //echo 'n = '.$n.'<br/>'; //echo 'settings 4 = '.$p['settings'][4].'<br/>'; // takzhe, esli showinfo = 1, perehodjashemu chelu pokazatq info toj karty if ($show_info && !$n) { global $p; if ($p['settings'][4] == 1) { $lg = loc($loc_go, 'locinfo'); // kartinki v locpics/(nazvanie karty).jpg $map = substr($loc_go, 0, 4); //$mapi = gen_header ($lg[1]); $mapi = ''; //$mapi .= '<div class="y" id="adg"><b>'.$lg[1].'</div>'; if (file_exists('modules/locpics/' . $map . '.JPEG')) { $mapi .= '<p><img src="modules/locpics/' . $map . '.JPEG" alt="."/></p>'; } // teperq infa // '/mapinfo/'.$map.'.mapi' if (file_exists('modules/mapinfo/' . $map . '.txt')) { $mapi .= '<p>'; $mapi .= file_get_contents('modules/mapinfo/' . $map . '.txt'); $mapi .= '</p>'; } else { $mapi .= '<p>нет информации</p>'; } //global $sid; //$mapi .= '<p><a class="blue" href="game.php?sid='.$sid.'">в игру</a></p>'; //$mapi .= gen_footer(); add_journal($mapi, $p['login']); } } }
function comp_reaction($off, $pass) { //$off = preg_replace ('/[^a-z0-9_\.]/i', '', $off); //$pass = preg_replace ('/[^a-z0-9_\.]/i', '', $pass); include_once 'modules/f_get_affected.php'; $aff = get_affected($off); if (is_in('oglushen', $aff)) { return 0; } if (is_in('zamerz', $aff)) { return 0; } if (is_in('okamenel', $aff)) { return 0; } if (is_in('odubel', $aff)) { return 0; } if (is_in('paralizovan', $aff)) { return 0; } $aff = get_affected($pass); if (is_in('oglushen', $aff)) { return 1; } if (is_in('zamerz', $aff)) { return 1; } if (is_in('okamenel', $aff)) { return 1; } if (is_in('odubel', $aff)) { return 1; } if (is_in('paralizovan', $aff)) { return 1; } $id = is_npc($off); if ($id) { $q = do_mysql("SELECT dex FROM npc WHERE id_npc = '" . $id . "';"); if (!mysql_num_rows($q)) { return 0; } $rea_off = mysql_result($q, 0); } else { $id = is_player($off); $q = do_mysql("SELECT skills FROM players WHERE id_player = '" . $id . "';"); if (!mysql_num_rows($q)) { return 0; } $off_s = mysql_result($q, 0); $off_s = explode('|', $off_s); $rea_off = $off_s[1]; } $id = is_npc($pass); if (is_npc($pass)) { $q = do_mysql("SELECT rea FROM npc WHERE id_npc = '" . $id . "';"); if (!mysql_num_rows($q)) { return 0; } $rea_pass = mysql_result($q, 0); } else { $id = is_player($pass); $q = do_mysql("SELECT skills FROM players WHERE id_player = '" . $id . "';"); if (!mysql_num_rows($q)) { return 0; } $pass_s = mysql_result($q, 0); $pass_s = explode('|', $pass_s); $rea_pass = $pass_s[3]; } $ch = $rea_off * 100 / ($rea_off + $rea_pass); if (rand(0, 100) <= $ch) { return 1; } else { return 0; } }
<?php // razgovarivatq s priruchennym $npc = preg_replace('/[^a-z0-9\\._]/i', '', $_GET['npc']); if (!$npc) { put_error('where is animal taklk to'); } if (isset($_GET['part'])) { $part = preg_replace('/[^a-z0-9_]/i', '', $_GET['part']); } else { $part = ''; } $nid = is_npc($npc); $nn = do_mysql("SELECT * FROM npc WHERE id_npc = '" . $nid . "';"); $nn = mysql_fetch_assoc($nn); if ($nn['belongs'] != $LOGIN) { put_error('это не ваш нпц'); } if ($nn['location'] != $p['location']) { put_g_error('рядом с вами нету этого нпц'); } $f = gen_header($nn['name']); $f .= '<div class="y" href="aof"><b>' . $nn['name'] . '</b></div><p>'; if (!$part) { $f .= '» <a class="blue" href="game.php?sid=' . $sid . '&action=talk_to_priru&part=har&npc=' . $npc . '">'; $f .= 'просмотреть информацию</a><br/>'; $f .= '» <a class="blue" href="game.php?sid=' . $sid . '&action=talk_to_priru&part=name1&npc=' . $npc . '">'; $f .= 'дать кличку</a><br/>'; if ($nn['move'] != 0) { $f .= '» <a class="blue" href="game.php?sid=' . $sid . '&action=talk_to_priru&part=stay&npc=' . $npc . '">стой тут!</a><br/>'; } else { $f .= '» <a class="blue" href="game.php?sid=' . $sid . '&action=talk_to_priru&part=stay&npc=' . $npc . '">иди за мной!</a><br/>';
function teleport($who, $loc_go) { # get_pl_info(), do_mysql();, get_npc_info();, loc();, put_error();, delete_from_loc();, add_to_loc();, addjournal(); require_once 'modules/f_get_pl_info.php'; require_once 'modules/f_get_npc_info.php'; require_once 'modules/f_loc.php'; require_once 'modules/f_add_to_loc.php'; // proverka dannyh //$who = preg_replace ('/[^a-z\._0-9]/i', '', $who); //$loc_go = preg_replace ('/[^a-z0-9\|]/i', '', $loc_go); global $LOGIN; $id; $pi = is_player($who); if ($pi) { $id = $pi; $login = $who; $lq = do_mysql("SELECT location FROM players WHERE id_player = '" . $id . "';"); $loc = mysql_result($lq, 0); //$loc = get_pl_info ($login, 'location'); $qg = do_mysql("SELECT gender FROM players WHERE id_player = '" . $id . "';"); $gender = mysql_result($qg, 0); $n = 0; // proverka na boj - $q = do_mysql("SELECT in_battle FROM players WHERE id_player = '" . $id . "';"); $inb = mysql_result($q, 0); $qg = do_mysql("SELECT name FROM players WHERE id_player = '" . $id . "';"); $name = mysql_result($qg, 0); } else { if (substr($who, 0, 2) == 'n.') { $id = is_npc(substr($who, 2)); if (!$id) { return 0; } $loc = get_npc_info($who, 'location'); $alo = do_mysql("SELECT name FROM npc WHERE id_npc = '" . $id . "';"); $login = mysql_result($alo, 0); $name = $login; $n = 1; } } // karta na kotoroj stoit $map_is = substr($loc, 0, 4); // karta toj loki, na kotoruju poidut $map_will = substr($loc_go, 0, 4); // ESLI NA DRUGUJU KARU if ($map_is != $map_will) { // a eshe ustanovim flag show_info, po kotoromu potom opredelim, nado li pokazatq vstupitelqnyj tekst k loakacci $show_info = 1; } else { // voobshem eto tazhe lokacija // vstupitelqnyj tekst ne pisatqi $show_info = 0; } global $NEWMAP; $NEWMAP = 1; if (!loc($loc_go, 'locinfo')) { return 0; } // sotrem byvshij inloc add_to_loc($loc_go, $who); ////////////////////////////// // pitomec $an = do_mysql("SELECT name, fullname FROM npc WHERE belongs = '" . $login . "' AND location = '" . $loc . "' AND move <> 0;"); $an = mysql_fetch_assoc($an); if ($an['fullname']) { $pit = ' и ' . $an['name'] . ' '; add_to_loc($loc_go, $an['fullname']); } else { $pit = ''; } if (substr($who, 0, 2) == 'n.') { $map = substr($loc_go, 0, 4); do_mysql("UPDATE npc SET location = '" . $loc_go . "', map = '" . $map . "' WHERE id_npc = '" . $id . "';"); } else { do_mysql("UPDATE players SET location = '" . $loc_go . "' WHERE id_player = '" . $id . "';"); } $loc2 = 'l.' . $loc; // formiruem soobshenie. if ($pit) { $gone = 'исчезли'; $come = 'появиись'; } else { if (!isset($gender)) { // dlja npc, esliimja konchaetsja na 'a', to skorej vsego devushka $len = strlen($login); $len2 = $len - 1; if (substr($login, $len2) == 'а') { $gone = 'исчезла'; $come = 'появилась'; } else { $gone = 'исчез'; $come = 'появился'; } } else { if ($gender == 'male') { $gone = 'исчез'; $come = 'появился'; } if ($gender == 'female') { $gone = 'исчезлa'; $come = 'появилась'; } } } // proverim $n, esli 1 to eto npc i nado vsem pisatq, esli net to perehodjashemu ne nado if ($n) { $need = 1; } else { $need = 0; } // v byvshuju lokaciju add_journal('<p>' . $name . '' . $pit . ' ' . $gone . '!</p>', 'l.' . $loc, $need); // v novuju add_journal('<p>' . $come . ' ' . $name . '' . $pit . '</p>', 'l.' . $loc_go, $need); $p = get_pl_info($who, 'all'); $NEWMAP = 1; include 'modules/s_loadmaps.php'; // zagruzim kartu unset($p); //echo '<br/>show info = '.$show_info.'<br/>'; //echo 'n = '.$n.'<br/>'; //echo 'settings 4 = '.$p['settings'][4].'<br/>'; // takzhe, esli showinfo = 1, perehodjashemu chelu pokazatq info toj karty if ($show_info && !$n && $who == $LOGIN) { global $p; do_mysql("UPDATE gamesys SET life_regen = 0;"); if ($p['settings'][4] == 1) { $lg = loc($loc_go, 'locinfo'); // kartinki v locpics/(nazvanie karty).jpg $map = substr($loc_go, 0, 4); $mapi = gen_header($lg[1]); $mapi .= '<div class="y" id="adg"><b>' . $lg[1] . '</div>'; if (file_exists('modules/locpics/' . $map . '.JPEG')) { $mapi .= '<p><img src="modules/locpics/' . $map . '.JPEG" alt="."/></p>'; } // teperq infa // '/mapinfo/'.$map.'.mapi' if (file_exists('modules/mapinfo/' . $map . '.txt')) { $mapi .= '<p>'; $mapi .= file_get_contents('modules/mapinfo/' . $map . '.txt'); $mapi .= '</p>'; } else { $mapi .= '<p>нет информации</p>'; } global $sid; $mapi .= '<p><a class="blue" href="game.php?sid=' . $sid . '">в игру</a></p>'; $mapi .= gen_footer(); exit($mapi); } } }
function npc_try_do_dmg($off, $pass) { //$off = preg_replace ('/[^a-z0-9_\.]/i', '', $off); //$pass = preg_replace ('/[^a-z0-9_\.]/i', '', $pass); if (!$off || !$pass) { return 0; } $id = is_npc($off); if (!$id) { return 0; } include_once 'modules/f_check_dead.php'; // proverjaem uspeshnostq ataki: include_once 'modules/f_is_attack_successful.php'; $result = is_attack_successful($off, $pass); if ($result) { // vse, delaem uron include_once 'modules/f_do_dmg.php'; if ($result > 1) { $PAR = 0; } else { $PAR = 1; } do_dmg($off, $pass, 'NONE', $PAR); } else { return 0; } /////////////////////////////////////////////////////////////////////////////////// // podvodim itogi // zhiv li include_once 'modules/f_check_dead.php'; if (check_dead($pass)) { // esli komu-to prinadlezhit, to obnovitq i ego reiting $q = do_mysql("SELECT belongs FROM npc WHERE id_npc = '" . $id . "';"); $bel = mysql_result($q, 0); if ($bel) { $id = is_player($pass); if ($id) { do_mysql("UPDATE players SET playerkill = playerkill + 1 WHERE login = '******';"); } else { do_mysql("UPDATE players SET monsterkill = monsterkill + 1 WHERE login = '******';"); } } // uvelichenie reitinga pobed: if (is_player($pass)) { do_mysql("UPDATE npc SET playerkill = playerkill + 1 WHERE id_npc = '" . $id . "';"); } else { do_mysql("UPDATE npc SET monsterkill = monsterkill + 1 WHERE id_npc = '" . $id . "';"); } include_once 'modules/f_make_die.php'; make_die($pass); return 1; } /////////////////////////////////////////////////////////////////////////////////// // otvetka, esli reakcija pozvolit include_once 'modules/f_comp_reaction.php'; if (comp_reaction($pass, $off) == 1) { // proverjaem uspeshnostq ataki: include_once 'modules/f_is_attack_successful.php'; $result = is_attack_successful($pass, $off, 1); if ($result) { // vse, delaem uron include_once 'modules/f_do_dmg.php'; if ($result > 1) { $PAR = 0; } else { $PAR = 1; } do_dmg($pass, $off, 'NONE', $PAR); } else { return 0; } /////////////////////////////////////////////////////////////////////////////////// // podvodim itogi // zhiv li include_once 'modules/f_check_dead.php'; if (check_dead($off)) { // uvelichenie reitinga pobed: $id = is_player($pass); if ($id) { do_mysql("UPDATE players SET monsterkill = monsterkill + 1 WHERE id_player = '" . $id . "';"); } else { $id = is_npc($pass); do_mysql("UPDATE npc SET monsterkill = monsterkill + 1 WHERE id_npc = '" . $id . "';"); // esli komu-nibudq prinadlezhit, obnovim egoo reiting $q = do_mydql("SELECT belongs FROM npc WHERE id_npc = '" . $id . "';"); $bel = mysql_result($q, 0); if ($bel) { do_mysql("UPDATE players SET monsterkill = monsterkill + 1 WHERE login = '******';"); } } include_once 'modules/f_make_die.php'; make_die($off); return 1; } } return 1; }
function is_attack_successful($who, $to, $re = 0) { // re oznachaet chto udar otvetnyj. // a esli udar otvetnyj, mozhno ne smotretq mozhet li on atakovatq, i ne fiksirovatq // etoj funkciej budem sravnivatq shansy include_once 'modules/f_get_chanses.php'; // proverjaem effekty // esli odin iz paralizujushih, to vsegda kto-to proigraet/vyjgraet include_once 'modules/f_get_affected.php'; $aff = get_affected($who); if (is_in('oglushen', $aff)) { return 0; } if (is_in('zamerz', $aff)) { return 0; } if (is_in('okamenel', $aff)) { return 0; } if (is_in('odubel', $aff)) { return 0; } if (is_in('paralizovan', $aff)) { return 0; } $aff = get_affected($to); if (is_in('oglushen', $aff)) { return 1; } if (is_in('zamerz', $aff)) { return 1; } if (is_in('okamenel', $aff)) { return 1; } if (is_in('odubel', $aff)) { return 1; } if (is_in('paralizovan', $aff)) { return 1; } $wid; $who_ranged = 0; $pi = is_player($who); if ($pi) { $wid = $pi; // berem informaciju igroka // shansy nanesti udar include_once 'modules/f_get_pl_battle_har.php'; $who_har = get_pl_battle_har($who); // kakoe oruzhie. toestq rasschityvatq li po sisteme dalqnego boja ili blizhnego // esli who_ranged == 1,, to togda schitajutsja formuly luchnikov $q = do_mysql("SELECT fullname FROM items WHERE belongs = '" . $who . "' AND is_in = 'wea'"); if (!mysql_num_rows($q)) { $who_ranged = 0; } else { $who_ranged = mysql_result($q, 0); } if (substr($who_ranged, 4, 3) == 'bow' || substr($who_ranged, 4, 3) == 'arb') { $who_ranged = 1; } else { $who_ranged = 0; } // zhiznq igroka dlja shansov (massiv) $q = do_mysql("SELECT life FROM players WHERE id_player = '" . $wid . "';"); $who_life = mysql_result($q, 0); $who_life = explode('|', $who_life); // proverka onlajn: do_mysql("SELECT active FROM players WHERE id_player = '" . $wid . "';"); $active = mysql_result($q, 0); if (!$active) { include_once 'modules/f_end_battle.php'; end_battle($who); } } else { $wid = is_npc($who); if (!$wid) { return -1; } // informacija npc : include_once 'modules/f_get_npc_battle_har.php'; $who_har = get_npc_battle_har($who); // napadatq s dali nemozhet npc // zhiznq npc dlja shansov (massiv) $q = do_mysql("SELECT life FROM npc WHERE id_npc = '" . $wid . "';"); $who_life = mysql_result($q, 0); $who_life = explode('|', $who_life); } // proverka vremeni ataki include_once 'modules/f_check_last_attack.php'; if (!check_last_attack($who, $re)) { return -1; } // esli ataka ne vovremja (s uchetom otvetki) // obnovim posledniju ataku, takzhe s uchetom otvetki if (!$re) { // ne proverjaem estq li patrony, lenq, proverim v do_dmg include_once 'modules/f_upd_last_attack.php'; upd_last_attack($who); } else { $aff = get_affected($to); if (is_in('ispugan', $aff)) { return 0; } // pri ispuge otvetka nevozmozhna } // harakteristika zawiwajusjago $tid; $pi = is_player($to); if ($pi) { $tid = $pi; // berem informaciju igroka // shansy nanesti udar include_once 'modules/f_get_pl_battle_har.php'; $to_har = get_pl_battle_har($to); // estq li shit (1, 0) $q = do_mysql("SELECT COUNT(*) FROM items WHERE belongs = '" . $to . "' AND is_in = 'shi' AND type = 'x'"); $to_shield = mysql_result($q, 0); // zhiznq igroka dlja shansov (massiv) $q = do_mysql("SELECT life FROM players WHERE id_player = '" . $tid . "';"); $to_life = mysql_result($q, 0); $to_life = explode('|', $to_life); // proverka onlajn: do_mysql("SELECT active FROM players WHERE id_player = '" . $tid . "';"); $active = mysql_result($q, 0); if (!$active) { include_once 'modules/f_end_battle.php'; end_battle($to); } } else { $tid = is_npc($to); if (!$tid) { return -1; } // informacija npc : include_once 'modules/f_get_npc_battle_har.php'; $to_har = get_npc_battle_har($to); // napadatq s dali nemozhet npc // zhiznq npc dlja shansov (massiv) $q = do_mysql("SELECT life FROM npc WHERE id_npc = '" . $tid . "';"); $to_life = mysql_result($q, 0); $to_life = explode('|', $to_life); } // proschityvaem shansy - $ch = get_chanses($who_har, $who_life, $to_har, $to_life); // sluchajnoe chislo $rnd = rand(0, 100); if ($rnd <= $ch[1][1]) { // udar blokirovan: if ($who_ranged) { include_once 'modules/f_promah.php'; promah($who); } else { include_once 'modules/f_block.php'; block($to); } $NO = 1; } else { $ntdl = rand(0, 1); if ($ntdl == 0) { if ($who_ranged) { if (rand(0, 100) <= $ch[1][8]) { // uklonimsja include_once 'modules/f_uklon.php'; uklon($to); $NO = 1; } } else { if (rand(0, 100) <= $ch[1][2]) { // uklonimsja include_once 'modules/f_uklon.php'; uklon($to); $NO = 1; } } } else { if ($who_ranged) { if (rand(0, 100) <= $ch[1][3]) { // pariruem return 1; } } else { if (rand(0, 100) <= $ch[1][9]) { // pariruem return 1; } } } } if (isset($NO)) { // esli streljaem, nado rashodovatq strely, esli promahnulisq ili uklon. inache rashoduem v do_dmg if ($who_ranged) { // rashoduem odnu strelu include_once 'modules/f_decr_abstr_misc.php'; if (!decr_abstr_misc('i.m.arr.arr', $who, 1)) { add_journal('нехватает припасoв!', $who); } } return 0; } //esli vse horosho, vozvrashjaem 2: return 2; }
function mag_def($off, $skill, $location, $def) { //$off = preg_replace ('/[^a-z0-9_\.]/i', '', $off); //$def = preg_replace ('/[^a-z0-9_\.]/i', '', $def); // berem shansy $id = is_player($off); if ($id) { include_once 'modules/f_get_pl_battle_har.php'; $off_har = get_pl_battle_har($off); $off_har[5] += $skill * 3; $off_har[6] += $skill * 3; $off_har[7] += $skill * 3; $q = do_mysql("SELECT life FROM players WHERE id_player = '" . $id . "';"); $off_life = mysql_result($q, 0); $off_life = explode('|', $off_life); $off_name = $off; } else { $id = is_npc($off); include_once 'modules/f_get_npc_battle_har.php'; $off_har = get_npc_battle_har($off); $q = do_mysql("SELECT life, name FROM npc WHERE id_npc = '" . $id . "';"); $off_a = mysql_fetch_assoc($q); $off_life = explode('|', $off_a['life']); $off_name = $off_a['name']; } $tid = is_player($def); if ($tid) { include_once 'modules/f_get_pl_battle_har.php'; $def_har = get_pl_battle_har($def); $q = do_mysql("SELECT life FROM players WHERE id_player = '" . $tid . "';"); $def_life = mysql_result($q, 0); $def_life = explode('|', $def_life); $def_name = $def; } else { $tid = is_npc($def); include_once 'modules/f_get_npc_battle_har.php'; $def_har = get_npc_battle_har($def); $q = do_mysql("SELECT life, name FROM npc WHERE id_npc = '" . $tid . "';"); $def_a = mysql_fetch_assoc($q); $def_life = explode('|', $def_a['life']); $def_name = $def_a['name']; } // teperq formiruem shansy proporcianalqno: include_once 'modules/f_get_chanses.php'; $ch = get_chanses($off_har, $off_life, $def_har, $def_life); // ch[0] eto napadajushij, ch[1] eto zashishjajushijsja // 5 - blok, 6 - sopr, 7 - uklon // vyberem sluchaino: $do = rand(5, 7); // teperq shans eto sdelatq: $proc = rand(0, 100); // esli vyjdet to sdelaem i vozvratim znachenie: if ($proc <= $ch[1][$do]) { // znachit taki sdelali if ($do == 5) { // blok: add_journal($def_name . ' блокировал магию ' . $off_name . '!', 'l.' . $location); return 1; } elseif ($do == 6) { // soprotivlenie: add_journal($def_name . ' сопротивился магии ' . $off_name . '!', 'l.' . $location); return 2; } else { // uklon: add_journal($def_name . ' уклонился от магии ' . $off_name . '!', 'l.' . $location); return 3; } } else { return 0; } }
function do_dmg($who, $to, $type, $PAR, $KOMBO = 1) { include_once 'modules/f_get_dmg.php'; include_once 'modules/f_get_armor.php'; ////////////////////////////// NAPADAJUSHIJ ///////////////////// // esli napadajushij igrok to uron poluchim funkciej, esli npc to vozqmem sami: $wid; $pi = is_player($who); if ($pi) { $wid = $pi; include_once 'modules/f_get_dmg.php'; $dmg = get_dmg($who); // lomaem mechq include_once 'modules/f_damage_weapons.php'; damage_weapons($who); // razberemsja s oruzhiem, dobavim effekty i oglushim esli eto drob uron (prodelaet eto funkcija) $q = do_mysql("SELECT fullname FROM items WHERE belongs = '" . $who . "' AND is_in = 'wea';"); if (!mysql_num_rows($q)) { $weapon = ''; } else { $weapon = mysql_result($q, 0); } if ($weapon) { include_once 'modules/f_set_w_effects.php'; set_w_effects($weapon, $type, $to); } // lokacija igroka $q = do_mysql("SELECT location FROM players WHERE id_player = '" . $wid . "';"); $who_loc = mysql_result($q, 0); // letaet li $q = do_mysql("SELECT walking FROM players WHERE id_player = '" . $wid . "';"); $who_fly = mysql_result($q, 0); $q = do_mysql("SELECT clan FROM players WHERE id_player = '" . $wid . "';"); $who_clan = mysql_result($q, 0); $who_clan = explode('|', $who_clan); } else { $wid = is_npc($who); $npc = 1; if (!$wid) { return 0; } $q = do_mysql("SELECT dmg FROM npc WHERE id_npc = '" . $wid . "';"); if (!mysql_num_rows($q)) { return 0; } $dmg = mysql_result($q, 0); $dmg = explode('~', $dmg); for ($i = 0; $i < 5; $i++) { $dmg[$i] = explode('-', $dmg[$i]); } $weapon = ''; // lokacija npc $q = do_mysql("SELECT location FROM npc WHERE id_npc = '" . $wid . "';"); $who_loc = mysql_result($q, 0); // effekt $q = do_mysql("SELECT effect FROM npc WHERE id_npc = '" . $wid . "';"); $who_effect = mysql_result($q, 0); // letanie $q = do_mysql("SELECT move FROM npc WHERE id_npc = '" . $wid . "';"); $who_fly = mysql_result($q, 0); if ($who_fly != 7) { $who_fly = 0; } else { $who_fly = 2; } } //////////////////////////// ORONJAJUSHIJSJA //////////////////// $ni = is_npc($to); if ($ni) { $tid = $ni; $tonpc = 1; $q = do_mysql("SELECT armor FROM npc WHERE id_npc = '" . $tid . "';"); if (!mysql_num_rows($q)) { return 0; } $armor = mysql_result($q, 0); $armor = explode('~', $armor); // lokacija npc $q = do_mysql("SELECT location FROM npc WHERE id_npc = '" . $tid . "';"); $to_loc = mysql_result($q, 0); // letanie $q = do_mysql("SELECT move FROM npc WHERE id_npc = '" . $tid . "';"); $to_fly = mysql_result($q, 0); if ($to_fly != 7) { $to_fly = 0; } else { $to_fly = 2; } // golem soklana - $q = do_mysql("SELECT fullname FROM npc WHERE id_npc = '" . $tid . "';"); $to_fn = mysql_result($q, 0); if ($to_fn == 'n.x.golem' && isset($who_clan)) { $qc = do_mysql("SELECT belongs FROM castle WHERE name = 'telir'"); $bel = mysql_result($qc, 0); if ($bel == $who_clan[0]) { return 1; } } } else { $tid = is_player($to); if (!$tid) { return 0; } $armor = get_armor($to); // lomaem bronju include_once 'modules/f_damage_armor.php'; damage_armor($to, $PAR); // lokacija igroka $q = do_mysql("SELECT location FROM players WHERE id_player = '" . $tid . "';"); $to_loc = mysql_result($q, 0); // letit li igrok $q = do_mysql("SELECT walking FROM players WHERE id_player = '" . $tid . "';"); $to_fly = mysql_result($q, 0); } if ($to_fly == 2 && substr($weapon, 4, 3) != 'bow' && substr($weapon, 4, 3) != 'arb' && $who_fly != 2) { // nelzja dostatq include_once 'modules/f_comp_reaction.php'; if (!comp_reaction($who, $to) || !comp_reaction($who, $to) || !comp_reaction($who, $to)) { add_journal('нелзя так просто достать летящего!', $who); return 0; } } if (substr($weapon, 4, 3) == 'bow' || substr($weapon, 4, 3) == 'arb') { $RANGE = 1; } else { $RANGE = 0; } ////////////////////////////// lokacija //////////////////////////// if ($who_loc != $to_loc) { // esli ne na odnoj lokacii // ne dalqnostreljajushimi streljatq nelzja if (!$RANGE) { add_journal('1цель недоступна', $who); return 0; } // dalee berem zapros na okruzhajushie lokacii include_once 'modules/f_loc.php'; $near = loc($who_loc, 'near'); // teperq nado proveritq, netu li gde nechajanno takoj lokacii $all_ok = 0; for ($i = 1; $i < 9; $i++) { if (!isset($near[$i])) { continue; } if ($near[$i][0] == $to_loc) { $all_ok = 1; } } if (!$all_ok) { // nanesti uron nelzja: add_journal('цель недоступна', $who); return 0; } //////////////////////////////////// // TUT NPC HODJAT K LUCHNIKAM :D //////////////////////////////////// if (isset($tonpc)) { include_once 'modules/f_comp_reaction.php'; if (comp_reaction($to, $who)) { do_mysql("UPDATE npc SET location = '" . $who_loc . "' WHERE id_npc = '" . $tid . "';"); } } } if ($RANGE) { // rashoduem odnu strelu include_once 'modules/f_decr_abstr_misc.php'; if (!decr_abstr_misc('i.m.arr.arr', $who, 1)) { add_journal('нехватает припасoв!', $who); return 0; } } ////////////////////////////// podschet urona ////////////////////// switch ($type) { case 'rez': $num = 0; break; case 'kol': $num = 1; break; case 'drob': $num = 2; break; case 'rub': $num = 3; break; case 'mag': $num = 4; break; default: $tmp = 1; } if (isset($tmp)) { // vyberem sami nomer: do { $arr = array('rez', 'kol', 'drob', 'rub'); if (!$dmg[0][1] && !$dmg[1][1] && !$dmg[2][1] && !$dmg[3][1] || isset($npc)) { $arr[4] = 'mag'; } $num = array_rand($arr); $type = $arr[$num]; } while (!$dmg[$num][1]); } $damage = rand($dmg[$num][0], $dmg[$num][1]); include_once 'modules/f_crit.php'; $crit = crit($who); $damage *= $crit; // kombo $damage *= $KOMBO; if ($crit > 1) { $CR = 1; } else { $CR = 0; } if ($damage == 0) { $CR = 0; } ///////////////////////////// // magicheskij uron if ($dmg[4][1] > 0 && $type != 'mag') { $mdamage = rand($dmg[4][0], $dmg[4][1]); $marm = $armor[4]; $mdamage -= $marm; if ($mdamage < 0) { $mdamage = 0; } } else { $mdamage = 0; } //////////////////////// parirovanie ////////////////////// if ($PAR && is_player($to) && $type != 'mag') { $q = do_mysql("SELECT fullname FROM items WHERE belongs = '" . $to . "' AND is_in = 'shi' AND type = 'x';"); if (mysql_num_rows($q)) { $shi = mysql_result($q, 0); $q = do_mysql("SELECT armor FROM items WHERE fullname = '" . $shi . "';"); $shi_arm = mysql_result($q, 0); $shi_arm = explode('~', $shi_arm); $sta = round($shi_arm[$num] * 0.9); $shi_m = rand($sta, $shi_arm[$num]); $damage -= $shi_m; } } //////////////////////////// // bronja $arm = $armor[$num]; $damage -= $arm; if ($damage < 0) { $damage = 1; } $damage = round($damage); //////////////////////////// //////////////////////////// dalaem uron //////////////////// if (is_npc($to)) { $q = do_mysql("SELECT life FROM npc WHERE id_npc = '" . $tid . "';"); } else { if (is_player($to)) { $q = do_mysql("SELECT life FROM players WHERE id_player = '" . $tid . "';"); } } $life = mysql_result($q, 0); $life = explode('|', $life); if ($damage > $life[0]) { $damage = $life[0]; } $life[0] -= $damage; if ($mdamage) { $life[0] -= $mdamage; } if ($life[0] < 0) { $life[0] = 0; } $nlife = $life[0] . '|' . $life[1]; ///////////////////////EFFEKTY URONA NPC /////////////// if (isset($who_effect) && $who_effect) { if (rand(0, 100) < 33) { include_once 'modules/f_set_affected.php'; set_affected($to, $who_effect); } } /////////////////////// ITOGI //////////////////////////// if ($CR) { include_once 'modules/f_start_blood.php'; if (rand(0, 100) < 33) { start_blood($to); } $cz = '!!!'; } else { $cz = ''; } if (substr($to, 0, 2) == 'n.') { do_mysql("UPDATE npc SET life = '" . $nlife . "' WHERE id_npc = '" . $tid . "';"); } else { do_mysql("UPDATE players SET life = '" . $nlife . "' WHERE id_player = '" . $tid . "';"); } //include_once ('modules/f_add_b_journal.php'); if (substr($who, 0, 2) == 'n.') { $q = do_mysql("SELECT name FROM npc WHERE id_npc = '" . $wid . "';"); $name = mysql_result($q, 0); } else { $q = do_mysql("SELECT name FROM players WHERE id_player = '" . $wid . "';"); $name = mysql_result($q, 0); } if (substr($to, 0, 2) == 'n.') { $q = do_mysql("SELECT name FROM npc WHERE id_npc = '" . $tid . "';"); $name2 = mysql_result($q, 0); } else { $q = do_mysql("SELECT name FROM players WHERE id_player = '" . $tid . "';"); $name2 = mysql_result($q, 0); } if ($mdamage) { $mt = '< -' . $mdamage . '(M)>'; } else { $mt = ''; } if (isset($shi_m)) { $st = '< +' . $shi_m . '(X)>'; } else { $st = ''; } // tip urona include_once 'modules/f_translit.php'; $type = translit($type); // chem napadali include_once 'modules/f_attacked_with.php'; $attw = attacked_with($weapon); if ($to_loc == $who_loc) { add_journal($name2 . ' - ' . $damage . '' . $cz . ' [D: ' . $arm . ']' . $st . '' . $mt . ' (' . $name . ', ' . $type . '. ' . $attw . ')', 'l.' . $to_loc); } else { add_journal($name2 . ' - ' . $damage . '' . $cz . ' [D: ' . $arm . ']' . $st . '' . $mt . ' (' . $name . ', ' . $type . '. ' . $attw . ')', 'l.' . $to_loc); add_journal($name2 . ' - ' . $damage . '' . $cz . ' [D: ' . $arm . ']' . $st . '' . $mt . ' (' . $name . ', ' . $type . '. ' . $attw . ')', 'l.' . $who_loc); } /////////////////////// OPYT ///////////////////////////// include_once 'modules/f_gain_battle_exp.php'; gain_battle_exp($who, $to, $damage + $mdamage); }
function create_dead_body($who) { //$who = preg_replace ('/[^a-z\._0-9]/i', '', $who); $id = is_player($who); if ($id) { // veshi: $q = do_mysql("SELECT id_player, status1, location, karma, name FROM players WHERE id_player = '" . $id . "';"); $p = mysql_fetch_assoc($q); // imja trupa: $d_name = $p['name'] . ' (труп)'; $d_map = substr($p['location'], 0, 4); // polnoenimja $time = time(); $tmp = 'n'; if ($p['status1'][0] > 0) { $tmp = 'p'; } $d_fullname = 'd.' . $tmp . '.' . $p['id_player'] . '.' . $time; // veshi $q = do_mysql("SELECT COUNT(*) FROM items WHERE is_in = 'inv' AND belongs = '" . $who . "';"); $c = mysql_result($q, 0); if ($p['status1'][0] == 0) { $c = round($c / 3); } do_mysql("UPDATE items SET belongs = '" . $d_fullname . "', is_in = '' WHERE belongs = '" . $who . "' AND is_in = 'inv' AND realname <> 'i.q.que.wind_sign' LIMIT " . $c . ";"); if ($p['status1'][0] > 0) { do_mysql("UPDATE items SET belongs = '" . $d_fullname . "', is_in = '' WHERE belongs = '" . $who . "' AND is_in = 'wea';"); } if ($p['karma'] < 300) { $num = rand(0, 10); $q = do_mysql("SELECT fullname, on_use FROM items WHERE belongs = '" . $who . "' AND is_in = 'a" . $num . "';"); if (mysql_num_rows($q)) { $a = mysql_fetch_assoc($q); $prt = substr($a['fullname'], 4, 3); if ($prt == 'amu' || $prt == 'rin') { $q = do_mysql("SELECT skills FROM players WHERE id_player = '" . $id . "';"); $p2 = mysql_fetch_assoc($q); $p2['skills'] = explode('|', $p2['skills']); $jew = explode('~', $a['on_use']); $p2['skills'][0] -= $jew[0]; $p2['skills'][1] -= $jew[1]; $p2['skills'][2] -= $jew[2]; $p2['skills'][3] -= $jew[3]; $sk = implode('|', $p2['skills']); do_mysql("UPDATE players SET skills = '" . $sk . "' WHERE id_player = '" . $id . "';"); } } do_mysql("UPDATE items SET belongs = '" . $d_fullname . "', is_in = '' WHERE belongs = '" . $who . "' AND is_in = 'a" . $num . "';"); } // trofei - $d_hunt = ''; // lokacija $d_location = $p['location']; } else { $id = is_npc($who); // tozh samoe dlja npc // veshi: $q = do_mysql("SELECT id_npc, name, drop2, hunt, location FROM npc WHERE id_npc = '" . $id . "';"); $n = mysql_fetch_assoc($q); // imja trupa: $d_name = $n['name'] . ' (труп)'; // polnoe imja $time = time(); $d_fullname = 'd.p.' . $n['id_npc'] . $time; // sozdaem veshi if ($n['drop2']) { if (substr($n['drop2'], 2, 1) == 'm') { include_once 'modules/f_create_item_m.php'; $itc = create_item_m($n['drop2'], 1); } else { include_once 'modules/f_create_item.php'; $itc = create_item($n['drop2']); } do_mysql("UPDATE items SET belongs = '" . $d_fullname . "', map = '' WHERE fullname = '" . $itc . "';"); } $d_hunt = $n['hunt']; // lokacija $d_location = $n['location']; $d_map = substr($d_location, 0, 4); } // sozdaem: do_mysql("INSERT INTO dead VALUES ('" . $d_name . "', '" . $d_fullname . "', '" . $d_hunt . "', '" . $d_location . "', '" . $d_map . "', NOW());"); return 1; }