Exemplo n.º 1
0
function start_chaos($tur)
{
    global $char;
    //все места заняты - начинаем бой
    //создаем бой
    $combat_type = 11;
    $uid = create_combat($combat_type, $char['map_name'], $char['map_xpos'], $char['map_ypos'], $tur['format']);
    //закидываем туда игроков рандомно
    $sel_users = myquery("SELECT game_users_active_host.host_more,game_users_active.host,game_turnir_users.side,view_active_users.*,game_users_data.sex FROM game_turnir_users,view_active_users,game_users_data,game_users_active,game_users_active_host WHERE game_users_data.user_id=game_turnir_users.user_id AND game_turnir_users.user_id=view_active_users.user_id AND game_turnir_users.turnir_id=" . $tur['id'] . " AND game_users_active.user_id=view_active_users.user_id AND game_users_active_host.user_id=view_active_users.user_id ORDER BY RAND()");
    $user_side = 2;
    while ($us = mysql_fetch_array($sel_users)) {
        $user_side = 3 - $user_side;
        $hod = 1;
        $join = 0;
        $svit = 0;
        $k_komu = 0;
        $k_exp = 1;
        $k_gp = 0;
        $skill = 0;
        $func = 5;
        $delay = 44;
        $no_rejoin = 1;
        combat_insert($us, 0, $uid, $combat_type, $user_side, $hod, $join, $svit, $k_komu, $k_exp, $k_gp, $skill, $func, $delay, $no_rejoin);
        $pismo = iconv("Windows-1251", "UTF-8//IGNORE", "<span style=\"font-style:italic;font-size:12px;color:gold;\">Начинается турнирный хаотичный бой</span>");
        myquery("INSERT INTO game_log (`message`,`date`,`fromm`,`too`,ptype) VALUES ('" . mysql_real_escape_string($pismo) . "'," . time() . ",-1," . $us['user_id'] . ",1)");
    }
    myquery("DELETE game_turnir,game_turnir_users FROM game_turnir,game_turnir_users WHERE (game_turnir.id=" . $tur['id'] . ") AND (game_turnir.id=game_turnir_users.turnir_id) ");
    setLocation("http://" . domain_name . "/combat.php");
}
Exemplo n.º 2
0
function join_attack_user($char, $player, $svit)
{
    $user_id = $char['user_id'];
    $map = mysql_fetch_array(myquery("SELECT * FROM game_maps WHERE id='" . $char['map_name'] . "'"));
    list($type, $npc) = mysql_fetch_array(myquery("SELECT combat_type, npc FROM combat WHERE combat_id=" . $player['boy'] . ""));
    switch ($type) {
        case 1:
            list($side) = mysql_fetch_array(myquery("SELECT side FROM combat_users WHERE combat_id=" . $player['boy'] . " and user_id=" . $player['user_id'] . " and npc=0"));
            break;
        case 2:
            $error = 'duel';
            break;
        case 3:
            $sred_level = 0;
            $sred_level_1 = 0;
            $side_1 = 0;
            $sred_level_2 = 0;
            $side_2 = 0;
            $kol = 0;
            $sel = myquery("SELECT clevel,side FROM combat_users WHERE combat_id='" . $player['boy'] . "' AND `join`=0 AND svitok=0");
            while ($boyuser = mysql_fetch_array($sel)) {
                $sred_level += $boyuser['clevel'];
                $kol++;
                if ($side_1 == 0 or $side_1 == $boyuser['side']) {
                    $side_1 = $boyuser['side'];
                    $sred_level_1 += $boyuser['clevel'];
                } elseif ($side_2 == 0 or $side_2 == $boyuser['side']) {
                    $side_2 = $boyuser['side'];
                    $sred_level_2 += $boyuser['clevel'];
                }
            }
            $sred_level = round($sred_level / $kol);
            if ($sred_level_1 <= $sred_level_2) {
                $side = $side_1;
            } else {
                $side = $side_2;
            }
            break;
        case 4:
            $side = $char['clan_id'];
            break;
        case 5:
            $side = $char['user_id'];
            break;
        case 6:
            $side = $char['sklon'];
            break;
        case 7:
            $side = $char['race'];
            break;
    }
    if ($svit == 2 and clans_war == 0) {
        list($side) = mysql_fetch_array(myquery("SELECT side FROM combat_users WHERE combat_id=" . $player['boy'] . " AND user_id=" . $player['user_id'] . ""));
    }
    if (!isset($side)) {
        list($side) = mysql_fetch_array(myquery("SELECT side FROM combat_users WHERE combat_id=" . $player['boy'] . " AND user_id=" . $player['user_id'] . ""));
    }
    $k_komu = 0;
    $svit_id = 0;
    //используем свиток
    if ($svit == 1) {
        $svit_id = svitok_small_item_id;
    } elseif ($svit == 2) {
        $svit_id = svitok_sred_item_id;
    }
    if ($svit_id != 0) {
        $ch = myquery("SELECT id FROM game_items WHERE user_id={$user_id} AND priznak=0 AND used IN (12,13,14) AND item_id='" . $svit_id . "' LIMIT 1");
        if (mysql_num_rows($ch)) {
            $svitok = mysql_fetch_array($ch);
            $Item = new Item($svitok['id']);
            $Item->use_item();
        }
        $k_komu = $player['user_id'];
    }
    save_stat($char['user_id'], '', '', 1, '', '', $player['user_id'], '', '', '', '', '');
    $nam = 0;
    if ($type == 1) {
        $nam = 14;
    }
    if ($type == 2) {
        $nam = 15;
    }
    if ($type == 3) {
        $nam = 16;
    }
    if ($type == 4) {
        $nam = 17;
    }
    if ($type == 5) {
        $nam = 18;
    }
    if ($type == 6) {
        $nam = 49;
    }
    if ($type == 7) {
        $nam = 48;
    }
    //Снимем с атакующего игрока эффект неуязвимости, если бой не с ботом
    if ($npc == 0) {
        myquery("DELETE FROM game_obelisk_users WHERE user_id=" . $char['user_id'] . " AND type=6");
    }
    list($current_hod) = mysql_fetch_array(myquery("SELECT hod FROM combat WHERE combat_id=" . $player['boy'] . ""));
    //Кидаем в бой игрока
    combat_insert($char, 0, $player['boy'], $type, $side, $current_hod, 1, $svit, $k_komu, $map['k_exp'] / 100, $map['k_gp'] / 100, 0, 6, $nam, 1);
    setLocation("http://" . domain_name . "/combat.php");
}
Exemplo n.º 3
0
function create_chaoscombat($min_users = 6, $check_time = 1)
{
    $name = "Битва Хаоса";
    $check_time = 1;
    $min_users = 6;
    $map = 24;
    $xpos = 0;
    $ypos = 0;
    $type = 12;
    $func = 5;
    $nam = 50;
    $full_stats = 1;
    $k_map = 1;
    $select = myquery("SELECT time FROM game_obj WHERE town like '" . $name . "' and time is not null");
    if (mysql_num_rows($select) > 0) {
        list($time) = mysql_fetch_array($select);
        $d = explode(" ", $time);
        $dat = explode(".", $d[0]);
        $tim = explode(":", $d[1]);
        $timestamp_open = mktime($tim[0], $tim[1], 0, $dat[1], $dat[0], $dat[2]);
        $diff = time() - $timestamp_open;
        if ($diff > 0 and $diff < 600 or $check_time == 0) {
            $check = myquery("SELECT * FROM combat WHERE combat_type = 12");
            if (mysql_num_rows($check) == 0) {
                $select = myquery("SELECT user_id FROM game_users_map WHERE map_name = " . $map . " ");
                $kol_users = mysql_num_rows($select);
                if ($kol_users >= $min_users) {
                    // Создаём бой Хаоса
                    $ins = myquery("INSERT INTO combat (hod,combat_type,map_name,map_xpos,map_ypos,start_time,time_last_hod,turnir_type) VALUES (1," . $type . ",'" . $map . "','" . $xpos . "','" . $ypos . "'," . time() . "," . time() . ",0)");
                    $uid = mysql_insert_id();
                    myquery("INSERT INTO game_combats_log (boy,hod,time,type,map_name,map_xpos,map_ypos) VALUES (" . $uid . ",1," . time() . "," . $type . ",'" . $map . "','" . $xpos . "','" . $ypos . "') ");
                    while (list($id) = mysql_fetch_array($select)) {
                        combat_insert(0, $id, $uid, $type, $id, 1, 0, 0, 0, $k_map, $k_map, 0, $func, $nam, 1, $full_stats);
                    }
                    myquery("INSERT INTO game_log (message,date,FROMm,ob) VALUES ('" . iconv("Windows-1251", "UTF-8//IGNORE", "<span style=\"font-weight:900;font-size:14px;color:red;font-family:Verdana,Tahoma,Arial,Helvetica,sans-serif\"> ВНИМАНИЕ! Начат Хаотический Бой!</span>'") . "," . time() . ",-1,1)");
                    echo 'Хаотический бой начат!<br>';
                } else {
                    echo 'Для проведения Битвы Хаоса недостаточно игроков. Сейчас на Арене Хаоса: ' . $kol_users . ' игроков!<br>';
                }
            } else {
                echo 'Хаотический бой не может быть начат, т.к. 2 хаотических боя не могут проходить одновременно!<br>';
            }
        } else {
            echo 'Условия по времени для начала боя некорректны!<br>';
        }
    } else {
        echo 'Переход для Битвы Хаоса не найден!<br>';
    }
}