function list_inloc($pl, $action, $s = 0)
{
    global $sid;
    global $LOGIN;
    global $p;
    //$pl = preg_replace ('/[^a-z0-9_]/i', '', $pl);
    $action = preg_replace('/[^a-z0-9_&=\\.]/i', '', $action);
    $loc = $p['location'];
    // snachala igrokov: vyvedem
    $q = do_mysql("SELECT login, life, name FROM players WHERE location = '" . $loc . "' AND active = '1' AND id_player <> '" . $p['id_player'] . "' AND hidden = '0';");
    $inl = '<a class="blue" href="game.php?sid=' . $sid . '&action=' . $action . '&to=' . $LOGIN . '">на себя</a><br/>';
    while ($pp = mysql_fetch_assoc($q)) {
        $pp['life'] = explode('|', $pp['life']);
        $inl .= '<a class="blue" href="game.php?sid=' . $sid . '&action=' . $action . '&to=' . $pp['login'] . '">';
        $inl .= $pp['name'] . '</a>[' . round($pp['life'][0] / $pp['life'][1] * 100) . '%]<br/>';
    }
    $q = do_mysql("SELECT name, fullname, life, type FROM npc WHERE location = '" . $loc . "' AND (hidden = '0' OR hidden = '');");
    while ($n = mysql_fetch_assoc($q)) {
        if (!$s) {
            // znachit nelzja piokazyvatq govorjashih npc i torgovcev:
            if ($n['type'] == 's' || $n['type'] == 't') {
                continue;
            }
        }
        $n['life'] = explode('|', $n['life']);
        $inl .= '<a class="blue" href="game.php?sid=' . $sid . '&action=' . $action . '&to=' . $n['fullname'] . '">';
        $inl .= $n['name'] . '</a>[' . round($n['life'][0] / $n['life'][1] * 100) . '%]<br/>';
    }
    return $inl;
}
function decrease_misc($item, $count)
{
    //$item = preg_replace ('/[^a-z0-9_\.]/i', '', $item);
    $count = preg_replace('/[^0-9]/', '', $count);
    // vozmem nachalqnoe kolichestvo
    $sc = do_mysql("SELECT on_take FROM items WHERE fullname = '" . $item . "';");
    $sc = mysql_result($sc, 0);
    // esli count menqshe nulja, tupaja oshibka
    if ($count <= 0) {
        //put_error ('уменьшить на минусовое число нелзя, надо использовать увеличить');
        return 0;
    }
    // esli otnjav poluchitsja menqshe 0 tozhe nelzja, ob etom pozabotitsja nado v skriptah
    if ($sc - $count < 0) {
        //put_error ('как ты считал балбес, ведь меньше 0 получается');
        return 0;
    }
    // esli vse prodolzhaetsja, uvelichim i obnovim
    $nc = $sc - $count;
    if ($nc < 1) {
        include_once 'modules/f_delete.php';
        delete_item($item);
    }
    do_mysql("UPDATE items SET on_take = '" . $nc . "' WHERE fullname = '" . $item . "';");
    return 1;
}
Ejemplo n.º 3
0
function get_loc($who, $stor, $depth = 1)
{
    // lokacija
    $id = is_player($who);
    if ($id) {
        $lq = do_mysql("SELECT location FROM players WHERE id_player = '" . $id . "';");
        $loc = mysql_result($lq, 0);
    } else {
        include_once 'modules/f_get_npc_info.php';
        $loc = get_npc_info($who, 'location');
    }
    $near = loc($loc, 'near');
    $lc = $near[$stor][0];
    if (!$lc) {
        return 0;
    }
    if ($depth == 2) {
        unset($near);
        $near = loc($lc, 'near');
    }
    if (!isset($near[$stor][0])) {
        return 0;
    }
    return $near[$stor][0];
}
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 use_reagents($spell, $login)
{
    //$spell = preg_replace ('/[^a-z0-9_]/i', '', $spell);
    //$login = preg_replace ('/[^a-z0-9_]/i', '', $login);
    if (!is_player($login)) {
        return 0;
    }
    // spisok reagentov:
    $q = do_mysql("SELECT reagents FROM magic WHERE fullname = '" . $spell . "';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $rea = mysql_result($q, 0);
    if (!$rea) {
        return 1;
    }
    $rea = explode('|', $rea);
    // funkcija kotoroj udalim:
    include_once 'modules/f_decr_abstr_misc.php';
    $c = count($rea);
    for ($i = 0; $i < $c; $i++) {
        $rea[$i] = explode(':', $rea[$i]);
        decr_abstr_misc($rea[$i][0], $login, $rea[$i][1]);
    }
    return 1;
}
function set_w_effects($weapon, $dmg_type, $name)
{
    //$weapon = preg_replace ('/[^a-z0-9_\.]/', '', $weapon);
    //$name = preg_replace ('/[^a-z0-9_\.]/', '', $name);
    if (!$weapon) {
        return 0;
    }
    $q = do_mysql("SELECT on_drop FROM items WHERE fullname = '" . $weapon . "';");
    if (!mysql_num_rows($q)) {
        put_error('ner to weapo');
    }
    $effs = mysql_result($q, 0);
    $effs = explode('|', $effs);
    $c = count($effs);
    for ($i = 0; $i < $c; $i++) {
        if (rand(0, 100) <= 30) {
            include_once 'modules/f_set_affected.php';
            set_affected($name, $effs[$i]);
        }
    }
    // otdelqnyj razgovor s oglusheniem
    if ($dmg_type == 'drob') {
        if (rand(0, 100) <= 30) {
            include_once 'modules/f_set_affected.php';
            set_affected($name, 'oglushen');
        }
    }
    return 1;
}
function start_blood($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[2] = 1;
        do_mysql("UPDATE players SET status1 = '" . $st . "' WHERE id_player = '" . $id . "';");
        // regeneracija sposobna so vremenem pereborotq krovotechenie:
        $q = do_mysql("SELECT skills, last FROM players WHERE id_player = '" . $id . "';");
        $r = mysql_fetch_assoc($q);
        $r['skills'] = explode('|', $r['skills']);
        $r['last'] = explode('|', $r['last']);
        if ($r['skills'][5] > 0) {
            $time = time();
            $plus = 130 - 10 * $r['skills'][5];
            if ($plus < 30) {
                $plus = 30;
            }
            $r['last'][5] = $time + $plus;
            $last = $r['last'][0] . '|' . $r['last'][1] . '|' . $r['last'][2] . '|' . $r['last'][3] . '|' . $r['last'][4] . '|' . $r['last'][5] . '|' . $r['last'][6] . '|' . $r['last'][7] . '|' . $r['last'][8];
            do_mysql("UPDATE players SET last = '" . $last . "' WHERE id_player = '" . $id . "';");
        }
        return 1;
    }
    // proverjatq na npc nenado set_affected proverit
    include_once 'modules/f_set_affected.php';
    set_affected($name, 'krovotechenie');
    return 1;
}
Ejemplo n.º 8
0
function use_mana($spell, $login)
{
    //$spell = preg_replace ('/[^a-z0-9_]/i', '', $spell);
    //$login = preg_replace ('/[^a-z0-9_]/i', '', $login);
    $q = do_mysql("SELECT mana FROM magic WHERE fullname = '" . $spell . "';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $minus = mysql_result($q, 0);
    $id = is_player($login);
    $q = do_mysql("SELECT mana FROM players WHERE id_player = '" . $id . "';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $mana = mysql_result($q, 0);
    $mana = explode('|', $mana);
    $mana[0] -= $minus;
    if ($mana[0] < 0) {
        return 0;
    }
    // many nehvatilo.
    $nmana = $mana[0] . '|' . $mana[1];
    do_mysql("UPDATE players SET mana = '" . $nmana . "' WHERE id_player = '" . $id . "';");
    return 1;
}
function add_b_journal($what)
{
    return 1;
    global $p;
    global $LOGIN;
    $what = strip_tags(mysql_real_escape_string(trim($what)));
    // dlja togo, chtob i avtoru dobavili, (sohranen takoj in_battle nebudet)
    $c = count($p['in_battle']);
    for ($i = 0; $i < $c; $i++) {
        if (!$p['in_battle'][$i]) {
            continue;
        }
        if (substr($p['in_battle'][$i], 0, 2) == 'n.') {
            continue;
        }
        // ostaetsja igrok, emu dobavim
        $q = do_mysql("SELECT journal FROM players WHERE login = '******'in_battle'][$i] . "';");
        $j = mysql_result($q, 0);
        $j .= '<br/>' . $what;
        do_mysql("UPDATE players SET journal = '" . $j . "' WHERE login = '******'in_battle'][$i] . "';");
    }
    $q = do_mysql("SELECT journal FROM players WHERE id_player = '" . $p['id_player'] . "' AND in_battle > 0;");
    $j = mysql_fetch_assoc($q);
    if ($j['journal']) {
        $j['journal'] .= $what . '<br/>';
        do_mysql("UPDATE players SET journal = '" . $j['journal'] . "' WHERE id_player = '" . $p['id_player'] . "';");
    }
}
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 decr_abstr_misc($prot, $who, $count, $other = 0)
{
    //$prot = preg_replace ('/[^a-z0-9_\.]/i', '', $prot);
    $count = preg_replace('/[^0-9]/', '', $count);
    //$who = preg_replace ('/[^a-z0-9_]/i', '', $who);
    if (!is_player($who)) {
        return 0;
    }
    if ($count < 1) {
        return 0;
    }
    $q = do_mysql("SELECT on_take FROM items WHERE belongs = '" . $who . "' AND is_in = 'inv' AND realname = '" . $prot . "' AND type = 'm';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $ci = mysql_result($q, 0);
    if ($ci < $count) {
        return 0;
    }
    $ci -= $count;
    if ($ci) {
        do_mysql("UPDATE items SET on_take = '" . $ci . "' WHERE  belongs = '" . $who . "' AND is_in = 'inv' AND realname = '" . $prot . "';");
    } else {
        include_once 'modules/f_delete_item.php';
        $q = do_mysql("SELECT fullname FROM items WHERE belongs = '" . $who . "' AND is_in = 'inv' AND realname = '" . $prot . "' AND type = 'm';");
        $item = mysql_result($q, 0);
        delete_item($item);
    }
    return 1;
}
Ejemplo n.º 12
0
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 check_reagents($spell, $login)
{
    //$spell = preg_replace ('/[^a-z0-9_]/i', '', $spell);
    //$login = preg_replace ('/[^a-z0-9_]/i', '', $login);
    if (!is_player($login)) {
        return 0;
    }
    // spisok reagentov:
    $q = do_mysql("SELECT reagents FROM magic WHERE fullname = '" . $spell . "';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $rea = mysql_result($q, 0);
    if (!$rea) {
        return 1;
    }
    $rea = explode('|', $rea);
    // funkcija kotoroj proverim:
    include_once 'modules/f_has_misc_count.php';
    $c = count($rea);
    $has = 1;
    for ($i = 0; $i < $c; $i++) {
        $rea[$i] = explode(':', $rea[$i]);
        // esli menqshe - 0
        if (has_misc_count($rea[$i][0], $rea[$i][1], $login) < 1) {
            $has = 0;
        }
    }
    return $has;
}
function damage_armor($login, $shield = 0)
{
    do_mysql("UPDATE items SET str = str - 1 WHERE belongs = '" . $login . "' AND is_in LIKE 'a%' AND str > 0;");
    if ($shield) {
        do_mysql("UPDATE items SET str = str - 1 WHERE belongs = '" . $login . "' AND is_in = 'shi' AND str > 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;
}
Ejemplo n.º 16
0
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;
}
Ejemplo n.º 17
0
function crit($login)
{
    //$login = preg_replace ('/[^a-z-0-9_\.]/i', '', $login);
    $id = is_player($login);
    if (!$id) {
        include_once 'modules/f_get_npc_info.php';
        $life = get_npc_info($login, 'life');
        $life = explode('|', $life);
        $cr = round(100 - $life[0] / $life[1] * 100);
        if (rand(0, 100) <= $cr) {
            return 2;
        } else {
            return 1;
        }
    }
    $p = do_mysql("SELECT life, skills FROM players WHERE id_player = '" . $id . "';");
    $p = mysql_fetch_assoc($p);
    $p['skills'] = explode('|', $p['skills']);
    $p['life'] = explode('|', $p['life']);
    $cr = round(100 - $p['life'][0] / $p['life'][1] * 100 + $p['skills'][0]);
    include_once 'modules/f_get_affected.php';
    $aff = get_affected($login);
    if (is_in('ispugan', $aff)) {
        return 1;
    }
    if (rand(0, 100) <= $cr) {
        return 2;
    } else {
        return 1;
    }
}
function upd_last_cast($pl, $spell)
{
    //$pl = preg_replace ('/[^a-z0-9_]/i', '', $pl);
    //$spell = preg_replace ('/[^a-z0-9_]/i', '', $spell);
    $now = time();
    $id = is_player($pl);
    if (!$id) {
        put_error('npc cant cast spell');
    }
    $q = do_mysql("SELECT last FROM players WHERE id_player = '" . $id . "';");
    $last = mysql_result($q, 0);
    $last = explode('|', $last);
    // vremja zaklinanija:
    $q = do_mysql("SELECT timewait FROM magic WHERE fullname = '" . $spell . "';");
    if (!mysql_num_rows($q)) {
        put_error('there are no such spell: ' . $spell . '');
    }
    $tw = mysql_result($q, 0);
    $last[3] = $now + $tw;
    // obrabotka effektami:
    #include_once ('modules/f_get_affected.php');
    // effecty:
    #$aff = get_affected ($LOGIN);
    // primer: if (is_in ('oglushen', $aff)) $last[3] += 10;
    $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 get_it_info($item)
{
    //$item = preg_replace ('/[^a-z0-9\._]/i', '', $item);
    $q = do_mysql("SELECT * FROM items WHERE fullname = '" . $item . "';");
    $nit = mysql_fetch_assoc($q);
    return $nit;
}
function rem_sc_from_book($spell, $book, $login)
{
    // v has_item proveritsja
    //$spell = preg_replace ('/[^a-z0-9_\.]/i', '', $spell);
    //$book = preg_replace ('/[^a-z0-9_\.]/i', '', $book);
    //$login = preg_replace ('/[^a-z0-9_]/i', '', $login);
    include_once 'modules/f_has_item.php';
    if (!has_item($book, $login)) {
        put_g_error('у вас нету книги');
    }
    // zapros na magiju chto v knige:
    $q = do_mysql("SELECT on_take FROM items WHERE fullname = '" . $book . "' AND type = 'b';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $magic = mysql_result($q, 0);
    if (strpos($magic, $spell) === false) {
        put_g_error('в этой книге нету этого заклинания!');
    }
    // esli prodolzhaetsja skript, znachit magija estq, izvlekem ee (snachala udalim, togda bagov skryvatq nebvudut:)
    $magic = string_drop($magic, $spell);
    // terq sozdadim:
    //include_once ('modules/f_create_item.php');
    $q = do_mysql("SELECT type FROM magic WHERE fullname = '" . $spell . "';");
    if (!mysql_num_rows($q)) {
        put_error('netu takogo zaklinanija');
    }
    $tp = mysql_result($q, 0);
    //#####$scroll = create_item ('i.s.'.$tp.'.'.$spell);
    include_once 'modules/f_gain_item.php';
    gain_item('i.s.' . $tp . '.' . $spell, 1, $login);
    // obnovim knigu i vse:
    do_mysql("UPDATE items SET on_take = '" . $magic . "' WHERE fullname = '" . $book . "';");
    return 1;
}
function get_weight($item)
{
    # do_mysql();
    //$item = preg_replace ('/[^a-z0-9_\.]/i', '', $item);
    $a = do_mysql("SELECT weight FROM items WHERE fullname = '" . $item . "';");
    $w = mysql_result($a, 0);
    return $w;
}
function damage_weapons($login)
{
    do_mysql("UPDATE items SET str = str - 1 WHERE belongs = '" . $login . "' AND is_in = 'wea' AND str > 0;");
    $q = do_mysql("SELECT fullname, str FROM items WHERE belongs = '" . $login . "' AND is_in = 'shi' AND type = 'w' AND str > 0;");
    if (mysql_num_rows($q)) {
        $it = mysql_fetch_assoc($q);
        do_mysql("UPDATE items SET str = str - 1 WHERE fullname = '" . $it['fullname'] . "';");
    }
}
Ejemplo n.º 23
0
function next_q()
{
    global $p;
    do_mysql("UPDATE players SET qlvl = qlvl + 1 WHERE id_player = '" . $p['id_player'] . "';");
    $q = do_mysql("SELECT qlvl FROM players WHERE id_player = '" . $p['id_player'] . "';");
    $qlvl = mysql_result($q, 0);
    // podkljuchaem fail novogo kvesta :
    include 'modules/mainq/q_' . $qlvl . '.php';
}
function learn_skill($skill, $price)
{
    global $p;
    global $sid;
    $skill = preg_replace('/[^0-9]/', '', $skill);
    $price = preg_replace('/[^0-9]/', '', $price);
    if ($skill === false) {
        put_error('неуказан навык');
    }
    if ($price === false) {
        put_error('неуказанa цена');
    }
    if (!isset($p['skills'][$skill])) {
        put_error('такого навыка нету');
    }
    if ($p['skills'][$skill]) {
        put_g_error('вы уже имеете этот навык!');
    }
    $mage = array(22, 23, 24, 25, 26, 27, 28, 29, 30);
    $warrior = array(7, 8, 9, 10, 41);
    $ranger = array(11, 12);
    // proverka na klassy:
    if ($p['classof'] != 3 && in_array($skill, $mage)) {
        put_g_error('только для магов!');
    }
    if ($p['classof'] != 1 && in_array($skill, $warrior)) {
        put_g_error('только для воина!');
    }
    if ($p['classof'] != 2 && in_array($skill, $ranger)) {
        put_g_error('только для лучников!');
    }
    if ($p['money'] < $price) {
        put_g_error('у вас нехватает серебра - надо ' . $price . ' монет!');
    }
    if (!$p['stats'][3]) {
        put_g_error('у вас нету очка навыка!');
    }
    // nelzja vychitq vtoroj navyk iz serii parirovanie - dvuruchnoe - dva
    if (($p['skills'][18] || $p['skills'][40] || $p['skills'][41]) && ($skill == 18 || $skill == 40 || $skill == 41)) {
        put_g_error('нелзя выучить два навыка из серии двуручное - два - парирование. Либо щит, либо двуручное, либо два.');
    }
    // esli vsju proverku proshli, podnimem i zabudem
    $p['skills'][$skill] = 1;
    $p['stats'][3] -= 1;
    $skills = implode('|', $p['skills']);
    $stats = implode('|', $p['stats']);
    $p['money'] -= $price;
    do_mysql("UPDATE players SET skills = '" . $skills . "', stats = '" . $stats . "', money = '" . $p['money'] . "' WHERE id_player = '" . $p['id_player'] . "';");
    $f = gen_header('навыки');
    $f .= '<div class="y" id="sodhg"><b>навыки:</b></div><p>';
    include 'modules/sp/sp_skillnames.php';
    $f .= 'вы выучили ' . $skn[$skill] . '!<br/>';
    $f .= '<a class="blue" href="game.php?sid=' . $sid . '">в игру</a></p>';
    $f .= gen_footer();
    exit($f);
}
function check_pl_exp($login)
{
    //$login = preg_replace ('/[^a-z0-9_]/i', '', $login);
    $id = is_player($login);
    if (!$id) {
        return 0;
    }
    $q = do_mysql("SELECT stats FROM players WHERE id_player = '" . $id . "';");
    $stats = mysql_result($q, 0);
    $stats = explode('|', $stats);
    if ($stats[1] >= $stats[2]) {
        $q = do_mysql("SELECT skills, rase FROM players WHERE id_player = '" . $id . "';");
        $sk = mysql_fetch_assoc($q);
        $sk['skills'] = explode('|', $sk['skills']);
        switch ($sk['rase']) {
            case 1:
                $sk['skills'][0] += 1;
                $sk['skills'][2] += 1;
                break;
            case 2:
                $sk['skills'][1] += 1;
                $sk['skills'][3] += 1;
                break;
            case 3:
                $sk['skills'][0] += 1;
                $sk['skills'][3] += 1;
                break;
        }
        $sk['skills'] = implode('|', $sk['skills']);
        if (substr($sk['skills'], 0, 1) == '|') {
            $sk['skills'] = substr($sk['skills'], 1);
        }
        $stats[0] += 1;
        if ($stats[0] <= 12 || $stats[0] % 10 == 0) {
            $stats[3] += 1;
        }
        $stats[1] -= $stats[2];
        $stats[2] = 600 * $stats[0] * $stats[0] + 1000 * $stats[0];
        $nstats = $stats[0] . '|' . $stats[1] . '|' . $stats[2] . '|' . $stats[3] . '|' . $stats[4] . '|' . $stats[5] . '|' . $stats[6] . '|' . $stats[7];
        do_mysql("UPDATE players SET stats = '" . $nstats . "', skills = '" . $sk['skills'] . "' WHERE id_player = '" . $id . "';");
        add_journal('новый уровень: ' . $stats[0] . '!', $login);
        add_journal('вы получили очко навыка!', $login);
    }
    if ($stats[4] >= $stats[5]) {
        // poluchitq ochko opyta:
        $stats[6] += 1;
        $stats[4] -= $stats[5];
        $stats[7] += 1;
        $stats[5] = round((600 * $stats[0] * $stats[0] + 1000 * $stats[0]) / 9);
        $nstats = $stats[0] . '|' . $stats[1] . '|' . $stats[2] . '|' . $stats[3] . '|' . $stats[4] . '|' . $stats[5] . '|' . $stats[6] . '|' . $stats[7];
        do_mysql("UPDATE players SET stats = '" . $nstats . "' WHERE id_player = '" . $id . "';");
        add_journal('вы получили очко опыта!', $login);
    }
    return 1;
}
function get_it_name($item)
{
    # do_mysql();
    //$item = preg_replace ('/[^a-z0-9\._]/i', '', $item);
    $a = do_mysql("SELECT name, on_drop FROM items WHERE fullname = '" . $item . "';");
    $w = mysql_fetch_assoc($a);
    if (substr($item, 4, 3) == 'tra') {
        return $w['on_drop'];
    }
    return $w['name'];
}
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;
}
Ejemplo n.º 29
0
function gen_quest($location)
{
    //echo 'starts';
    // kolichestvo kvestov v odnom regione max;
    $qcount = 1;
    // region
    $reg = substr($location, 0, 4);
    // kolichestvo zanjatyh kvestov:
    $q = do_mysql("SELECT COUNT(*) FROM quests WHERE npc <> '' AND region = '" . $reg . "';");
    $qc_on = mysql_result($q, 0);
    //echo '<br/>'.$qc_on.'<br/>';
    // esli dostatochno to dalqshe proverjatq nebudem:
    if ($qcount <= $qc_on) {
        return 1;
    }
    // dalee esli menqshe to berem kolichestvo svobodnyh:
    $q = do_mysql("SELECT COUNT(*) FROM quests WHERE npc = '' AND region = '" . $reg . "';");
    $qc_off = mysql_result($q, 0);
    //echo '<br/>'.$qc_off.'<br/>';
    // esli takih net to bolqshe niche delatq nebudem
    if ($qc_off == 0) {
        return 1;
    }
    // zapros, estq li svobodnye npc v regione:
    $q = do_mysql("SELECT COUNT(*) FROM npc WHERE quest = '' AND map = '" . $reg . "' AND type = 's';");
    $cnpc = mysql_result($q, 0);
    //echo '<br/>'.$cnpc.'<br/>';
    if ($cnpc == 0) {
        return 1;
    }
    // dalee u nas zapros na vse svobodnye kvesty -
    $q = do_mysql("SELECT * FROM quests WHERE npc = '' AND region = '" . $reg . "';");
    $qst = '';
    while ($qst1 = mysql_fetch_assoc($q)) {
        $qst[] = $qst1;
    }
    $rnd = array_rand($qst);
    // zapros na svobodnogo npc
    $q = do_mysql("SELECT realname FROM npc WHERE type = 's' AND quest = '' AND map = '" . $reg . "' AND realname <> 'n.s.relen_vernol';");
    $npc = '';
    while ($r = mysql_fetch_assoc($q)) {
        $npc[] = $r;
    }
    //print_r ($npc);
    $rnd_npc = array_rand($npc);
    // opredelennomu kvestu opredelennyj npc:
    do_mysql("UPDATE quests SET npc = '" . $npc[$rnd_npc]['realname'] . "' WHERE id_quest = '" . $qst[$rnd]['id_quest'] . "';");
    // opredelennomu npc opredelennyj kvest:
    do_mysql("UPDATE npc SET quest = '" . $qst[$rnd]['questname'] . "' WHERE realname = '" . $npc[$rnd_npc]['realname'] . "';");
    // use, return 1;
    //echo 'ends';
    return 1;
}
function get_dead_info($dead)
{
    //$dead = preg_replace ('/[^a-z0-9\.]/i', '', $dead);
    if (substr($dead, 0, 2) != 'd.') {
        put_error('это не труп');
    }
    $q = do_mysql("SELECT * FROM dead WHERE fullname = '" . $dead . "';");
    $d = mysql_fetch_assoc($q);
    $d['l_hunt'] = $d['hunt'];
    $d['hunt'] = explode('|', $d['hunt']);
    return $d;
}