Exemplo n.º 1
0
function npc_call($npc_id, $kogo, $kol, $uid)
{
    while ($kol > 0) {
        $templ = mysql_fetch_array(myquery("SELECT * FROM game_npc_template WHERE npc_id={$kogo}"));
        myquery("INSERT INTO game_npc SET stay=2,npc_id={$kogo},map_name=672,xpos=0,ypos=0,view=0,dropable=1,HP=" . $templ['npc_max_hp'] . ",MP=" . $templ['npc_max_mp'] . ", EXP=" . $templ['npc_exp_max'] . "");
        $new = mysql_insert_id();
        $npc = mysql_fetch_array(myquery("SELECT game_npc.*,game_npc_template.* FROM game_npc,game_npc_template WHERE game_npc.id={$new} AND game_npc.npc_id=game_npc_template.npc_id"));
        $npc_ms_kulak = 0;
        $npc_ms_weapon = 0;
        $npc_ms_art = 0;
        $npc_ms_parir = 0;
        $npc_ms_luk = 0;
        $npc_ms_sword = 0;
        $npc_ms_axe = 0;
        $npc_ms_spear = 0;
        $npc_ms_throw = 0;
        $ins = myquery("INSERT INTO combat_users (\n\t\t\tcombat_id,user_id,npc,time_last_active,name,clevel,reinc,side,\n\t\t\tHP,MP,STM,STR,DEX,SPD,VIT,NTL,PIE,HP_MAX,MP_MAX,STM_MAX,lucky,pol,avatar,race,HP_start,`join`,hod_start\n\t\t\t) VALUES (\n\t\t\t{$uid},{$new},1," . time() . ",'" . $npc['npc_name'] . "'," . $npc['npc_level'] . ",0,{$npc_id},\n\t\t\t" . $npc['HP'] . "," . $npc['MP'] . ",10000,\n\t\t\t" . mt_rand($npc['npc_str'] - $npc['npc_str_deviation'], $npc['npc_str'] + $npc['npc_str_deviation']) . ",\n\t\t\t" . mt_rand($npc['npc_dex'] - $npc['npc_dex_deviation'], $npc['npc_dex'] + $npc['npc_dex_deviation']) . ",\n\t\t\t" . mt_rand($npc['npc_spd'] - $npc['npc_spd_deviation'], $npc['npc_spd'] + $npc['npc_spd_deviation']) . ",\n\t\t\t" . mt_rand($npc['npc_vit'] - $npc['npc_vit_deviation'], $npc['npc_vit'] + $npc['npc_vit_deviation']) . ",\n\t\t\t" . mt_rand($npc['npc_ntl'] - $npc['npc_ntl_deviation'], $npc['npc_ntl'] + $npc['npc_ntl_deviation']) . ",\n\t\t\t" . mt_rand($npc['npc_pie'] - $npc['npc_pie_deviation'], $npc['npc_pie'] + $npc['npc_pie_deviation']) . ",\t\t\t\n\t\t\t" . $npc['npc_max_hp'] . "," . $npc['npc_max_mp'] . ",10000,\n\t\t\t5,'','" . $npc['npc_img'] . "','" . $npc['npc_race'] . "'," . $npc['npc_max_hp'] . ", 1,1)");
        combat_setFunc($new, 6, $uid);
        $kol--;
    }
}
Exemplo n.º 2
0
                $kol_items[5] = 120;
                if (isset($kol_items[$kol_kills]) and $kol_items[$kol_kills] > 0) {
                    $Item = new Item();
                    $Item->add_user($item_id, $mas_u[$i]['user_id'], 0, 0, 0, $kol_items[$kol_kills]);
                }
                $i++;
            }
        }
        // Увеличение количества побед у клана победителя
        myquery("UPDATE game_clans SET cw_wins=cw_wins+1 WHERE clan_id = " . $win_side . " ");
    } elseif ($this->combat['combat_type'] == 12) {
        $say = 'Завершилась Битва Хаоса! Имя победителя - [color=yellow][b]' . $this->all[$win_side]['name'] . '![/b][/color]. Слава герою!!!';
        $say = iconv("Windows-1251", "UTF-8//IGNORE", "<span style=\"font-style:italic;font-size:12px;color:gold;font-family:Verdana,Tahoma,Arial,Helvetica,sans-serif\">" . $say . "</b></span>");
        myquery("INSERT INTO game_log (`message`,`date`,`fromm`) VALUES ('" . mysql_real_escape_string($say) . "'," . time() . ",-1)");
        $hawk = 28591;
        $ma = myquery("INSERT INTO game_pm (komu, otkogo, theme, post, view, time) VALUES (" . $hawk . ", '0', 'Битва Хаоса', 'Завершилась Битва Хаоса! Победитель - " . $this->all[$win_side]['name'] . "','0','" . time() . "')");
    }
    $sel_users = myquery("SELECT user_id  FROM combat_users_state WHERE combat_id=" . $this->combat['combat_id'] . " AND state IN (5,6)");
    while ($us = mysql_fetch_array($sel_users)) {
        //Начислим опыт/деньги за лечебные/защитные действия в бою
        $this->nachisl_exp_gp_def($us['user_id']);
        combat_setFunc($us['user_id'], 7, $this->combat['combat_id'], $this->combat['hod']);
    }
    // Удаляем ботов и шаблоны ботов, которые живут 1 бой
    if ($this->combat['npc'] == 1) {
        myquery("DELETE gnt FROM combat_users cu \n\t\t\t\t           JOIN combat_users_state cus ON cu.combat_id=cus.combat_id \n\t\t\t\t           JOIN game_npc gn ON cu.user_id = gn.id\n                           JOIN game_npc_template gnt ON gn.npc_id = gnt.npc_id\n\t\t\t\t\t\t  WHERE cu.npc = 1 AND cu.combat_id = " . $this->combat['combat_id'] . " AND cus.state = 7 AND gn.stay = 3\n\t\t\t\t\t\t");
        myquery("DELETE gn FROM combat_users cu \n\t\t\t\t           JOIN combat_users_state cus ON cu.combat_id=cus.combat_id \n\t\t\t\t           JOIN game_npc gn ON cu.user_id = gn.id                           \n\t\t\t\t\t\t  WHERE cu.npc = 1 AND cu.combat_id = " . $this->combat['combat_id'] . " AND cus.state = 7 AND gn.stay in (2, 3)\n\t\t\t\t\t\t");
    }
    $this->clear_combat();
    return 1;
}
Exemplo n.º 3
0
function combat_insert($char = 0, $user_id = 0, $combat_id, $type, $side, $hod = 1, $join = 0, $svit = 0, $k_komu = 0, $k_map_exp = 1, $k_map_gp = 1, $skill = 0, $func = 5, $delay, $no_rejoin = 0, $full_stats = 0)
{
    if ($char == 0 and $user_id == 0) {
        return 0;
    }
    if ($char == 0) {
        $check_user = myquery("SELECT * FROM game_users WHERE user_id=" . $user_id . "");
        if (mysql_num_rows($check_user) > 0) {
            $char = mysql_fetch_array($check_user);
        } else {
            $char = mysql_fetch_array(myquery("SELECT * FROM game_users_archive WHERE user_id=" . $user_id . ""));
        }
    }
    $user_id = $char['user_id'];
    $injury = ceil($char['injury'] / 13);
    //Определим травму игрока
    list($pol) = mysql_fetch_array(myquery("SELECT sex FROM game_users_data WHERE user_id=" . $user_id . ""));
    if ($skill == 0) {
        $skill = take_skills($user_id);
    }
    myquery("DELETE FROM combat_users WHERE user_id=" . $user_id . "");
    myquery("DELETE FROM combat_users_exp WHERE user_id=" . $user_id . "");
    //Восстановим жизни, ману, энергию, если надо
    if ($full_stats == 1) {
        $char['HP'] = $char['HP_MAX'];
        $char['MP'] = $char['MP_MAX'];
        $char['STM'] = $char['STM_MAX'];
    }
    $k_exp = skill_exp_effect($skill['MS_EXP'], $type) * $k_map_exp;
    $k_gp = skill_gp_effect($skill['MS_GP'], $type) * $k_map_gp;
    if ($svit > 0) {
        $k_exp = 0;
        if ($svit > 1) {
            $k_gp = 0;
        }
    }
    myquery("INSERT INTO combat_users (\n\t\tcombat_id,user_id,npc,time_last_active,name,clevel,reinc,side,\n\t\tHP,MP,STM,STR,DEX,SPD,VIT,NTL,PIE,HP_MAX,MP_MAX,STM_MAX,lucky,injury,\n\t\tk_komu,k_exp,k_gp,pol,avatar,sklon,race,clan_id,`join`,HP_start,hod_start,\n\t\tclass_type,class_level,MS_WEAPON,MS_KULAK,MS_PARIR,MS_ART,MS_LUK,MS_THROW,MS_BERSERK,MS_PRUDENCE,MS_VAMPIRE,MS_SPIKES,NPC_DEFENCE) \n\t\tVALUES (" . $combat_id . "," . $user_id . ",0," . time() . ",'" . $char['name'] . "'," . $char['clevel'] . "," . $char['reinc'] . "," . $side . ",\n\t\t" . $char['HP'] . "," . $char['MP'] . "," . $char['STM'] . "," . $char['STR'] . "," . $char['DEX'] . "," . $char['SPD'] . "," . $char['VIT'] . "," . $char['NTL'] . "," . $char['PIE'] . ",\t\t\t\n\t\t" . $char['HP_MAX'] . "," . $char['MP_MAX'] . "," . $char['STM_MAX'] . ",'" . $char['lucky'] . "','" . $injury . "',\n\t\t" . $k_komu . "," . $k_exp . "," . $k_gp . ",'" . $pol . "','" . $char['avatar'] . "','" . $char['sklon'] . "',\n\t\t'" . mysql_result(myquery("SELECT name FROM game_har WHERE id=" . $char['race'] . ""), 0, 0) . "'," . $char['clan_id'] . "," . $join . "," . $char['HP_MAX'] . ",'" . $hod . "',\n\t\t" . $skill['class_type'] . "," . $skill['class_level'] . "," . $skill['MS_WEAPON'] . "," . $skill['MS_KULAK'] . "," . $skill['MS_PARIR'] . "," . $skill['MS_ART'] . "," . $skill['MS_LUK'] . "," . $skill['MS_THROW'] . ",\n\t\t" . $skill['MS_BERSERK'] . "," . $skill['MS_PRUDENCE'] . "," . $skill['MS_VAMPIRE'] . "," . $skill['MS_SPIKES'] . "," . $skill['NPC_DEFENCE'] . ")\n\t\t");
    combat_setFunc($user_id, $func, $combat_id);
    set_delay_reason_id($user_id, $delay);
    //Отработаем действие навыка "Паладин"
    if ($skill['PALADIN'] > 0) {
        $r = mt_rand(1, 100);
        if ($r <= $skill['PALADIN'] + 5) {
            if ($hod == 0) {
                $hod = 1;
            }
            $effect = $skill['PALADIN'] * 5;
            insert_fast_effect($user_id, $user_id, $combat_id, $hod + $join, 41, $effect);
        }
    }
    if ($no_rejoin == 1) {
        list($host) = mysql_fetch_array(myquery("SELECT host FROM game_users_active WHERE user_id=" . $user_id . ""));
        list($host_more) = mysql_fetch_array(myquery("SELECT host_more FROM game_users_active_host WHERE user_id=" . $user_id . ""));
        myquery("INSERT INTO combat_lose_user (combat_id,user_id,host,host_more) VALUES (" . $combat_id . "," . $user_id . "," . $host . ",'" . $host_more . "')");
    }
    //Проверим - надо ли вести лог боя
    $check1 = 0;
    $check2 = 0;
    if ($hod == 1) {
        $check = myquery("SELECT * FROM combat_users WHERE npc=1 AND combat_id=" . $combat_id . "");
        if (mysql_num_rows($check) == 0) {
            $check1 = 1;
        }
    } else {
        $check = myquery("SELECT * FROM game_combats_users WHERE boy=" . $combat_id . "");
        if (mysql_num_rows($check) > 0) {
            $check2 = 1;
        }
    }
    if ($check1 == 1 or $check2 == 1) {
        myquery("INSERT INTO game_combats_users (boy, user_id, side) VALUES (" . $combat_id . ", " . $user_id . ", " . $side . ")");
    }
    $sel_arco = myquery("SELECT * FROM arcomage_users WHERE user_id=" . $user_id . "");
    if (mysql_num_rows($sel_arco) > 0) {
        $arco = mysql_fetch_array($sel_arco);
        myquery("DELETE FROM arcomage WHERE id='" . $arco['arcomage_id'] . "'");
        myquery("DELETE FROM arcomage_users_cards WHERE arcomage_id='" . $arco['arcomage_id'] . "'");
        myquery("DELETE FROM arcomage_history WHERE arcomage_id='" . $arco['arcomage_id'] . "'");
        myquery("DELETE FROM arcomage_users WHERE arcomage_id='" . $arco['arcomage_id'] . "'");
    }
    myquery("DELETE FROM arcomage_call WHERE user_id=" . $user_id . "");
    ForceFunc($user_id, 1);
}
Exemplo n.º 4
0
 public function user_out($user_id)
 {
     $this->break_items($user_id, 0);
     //уменьшим текущий ресурс прочности предметов
     $this->user_teleport($user_id);
     $travma = 0;
     if ($this->combat['npc'] == 0) {
         if ($this->all[$user_id]['clevel'] >= 15) {
             $travma = 1;
         }
         myquery("UPDATE game_users_data SET last_timeout=" . time() . ",last_timeout_boy=" . $this->combat['combat_id'] . " WHERE user_id={$user_id}");
         //!!!Отключено!!!
         //если среди противников только 1 живой игрок - тогда победу дадим ему, если несколько, то победу даем рандомно
         // $prot = array();
         // foreach($this->all AS $key=>$value)
         // {
         // if ($value['side']!=$this->all[$user_id]['side'])
         // {
         // $prot[] = $key;
         // }
         // }
         // $user_win_id = 0;
         // if (count($prot)==1)
         // {
         // $user_win_id = $prot[0];
         // }
         // else
         // {
         // $r = mt_rand(0,count($prot)-1);
         // $user_win_id = $prot[$r];
         // }
         // if ($user_win_id>0)
         // {
         // if ($this->all[$user_win_id]['npc']==0)
         // {
         // myquery("UPDATE game_users SET WIN=WIN+1 WHERE user_id=$user_win_id");
         // }
         // else
         // {
         // myquery("UPDATE game_npc SET WIN=WIN+1 WHERE id=$user_win_id");
         // }
         // }
     } else {
         //таймаут в бою с ботами
         $this->check_quest_lose($user_id);
     }
     //статистика
     if (function_exists("save_stat")) {
         save_stat($user_id, '', '', 3, '', '', '', '', '', '', '', '');
     }
     //за вылетевшего по тайму дадим опыта = опыт за полное убийство/количество противников, но не более 10% и если вылет идет на первом ходу
     $all = array();
     foreach ($this->all as $key => $value) {
         if ($this->all[$key]['side'] == $this->all[$user_id]['side']) {
             continue;
         }
         if ($this->all[$key]['npc'] == 0) {
             if ($this->all[$key]['HP'] > 0) {
                 $all[] = $key;
             }
         }
     }
     if (count($all) > 0) {
         $k = min(0.1, 1 / count($all));
     } else {
         $k = 0;
     }
     $gp = 0;
     foreach ($all as $key => $value) {
         $exp = $this->formula_exp($this->all[$user_id], $this->all[$value], -1);
         if ($exp != 0 or $gp != 0) {
             myquery("INSERT INTO combat_users_exp (combat_id,user_id,prot_id,exp,gp) VALUES (" . $this->combat['combat_id'] . "," . $value . "," . $user_id . ",{$exp},{$gp}) ON DUPLICATE KEY UPDATE exp=exp+{$exp},gp=gp+{$gp}");
         }
     }
     //переводим накопленный опыт в очки опыта
     $this->nachisl_exp_gp($user_id, 1);
     $query = "UPDATE game_users SET HP=1,MP=1,STM=1";
     //$travma = 0;//Временно убираем травмы!
     if ($travma == 1) {
         $query .= ",injury=LEAST(1300,injury+13)";
     }
     if ($this->combat['npc'] == 0) {
         $query .= ",LOSE=LOSE+1";
     }
     $query .= " WHERE user_id={$user_id}";
     myquery($query);
     combat_setFunc($user_id, 8, $this->combat['combat_id'], $this->combat['hod']);
     $this->clear_user($user_id);
     check_boy($this->combat['combat_id']);
     //запишем в лог хода
     if ($this->all[$user_id]['pol'] == 'female') {
         $log_id = 53;
         $mes = "Ты сбежала с поля боя";
     } else {
         $log_id = 54;
         $mes = "Ты сбежал с поля боя";
     }
     $text_id = 0;
     $sel_text_id = myquery("SELECT id FROM game_combats_log_text WHERE name='" . $this->all[$user_id]['name'] . "' AND mode='" . $user_id . "'");
     if (mysql_num_rows($sel_text_id) == 0) {
         myquery("INSERT INTO game_combats_log_text (combat_id, name,mode) VALUES ('" . $this->combat['combat_id'] . "', '" . $this->all[$user_id]['name'] . "', " . $user_id . ")");
         $text_id = mysql_insert_id();
     } else {
         list($text_id) = mysql_fetch_array($sel_text_id);
     }
     myquery("INSERT INTO game_combats_log_data (boy,user_id,hod,action,na_kogo) VALUES (" . $this->combat['combat_id'] . ", 0, " . $this->combat['hod'] . ", " . $log_id . ", " . $text_id . ")");
     myquery("INSERT game_battles SET attacker_id=" . $user_id . ", target_id=0, map_name=" . $this->combat['map_name'] . ", map_xpos=" . $this->combat['map_xpos'] . ", map_ypos=" . $this->combat['map_ypos'] . ", contents='" . mysql_real_escape_string($mes) . "', post_time=" . time() . "");
 }
Exemplo n.º 5
0
         while (list($name) = mysql_fetch_array($sel)) {
             $ret_str .= '<div style="color:#00FFFF;font-size:11px;">' . $name . '</div>';
         }
         echo iconv('windows-1251', 'utf-8//IGNORE', $ret_str);
     } else {
         echo 'nopass';
     }
     die;
 }
 //Проверим на автозавершение боя по отказу от боя всех участников
 $count_users = mysql_result(myquery("SELECT COUNT(*) FROM combat_users WHERE HP>0 AND combat_id='{$boy}'"), 0, 0);
 $count_pass_users = mysql_result(myquery("SELECT COUNT(*) FROM combat_users WHERE HP>0 AND combat_id='{$boy}' AND pass=1"), 0, 0);
 if ($count_users == $count_pass_users) {
     $sel = myquery("SELECT user_id FROM combat_users WHERE combat_id={$boy}");
     while (list($comb_user_id) = mysql_fetch_array($sel)) {
         combat_setFunc($comb_user_id, 10, $boy);
     }
     echo 'pass';
     die;
 }
 $sel = myquery("SELECT combat_users.name,game_maps.name AS map FROM combat_users,combat,game_maps WHERE combat.combat_id=combat_users.combat_id AND combat.map_name=game_maps.id AND combat_users.combat_id={$boy} AND combat_users.join=1");
 $ret_str = '';
 if (mysql_num_rows($sel)) {
     $ret_str .= '<div style="width:100%;text-align:right;font-weight:800;color:#8080FF;text-decoration:underline;">Вступают:</div>';
     while (list($name_new_user, $map) = mysql_fetch_array($sel)) {
         if ($map == 'Арена Хаоса') {
             $name_new_user = '******';
         }
         $ret_str .= '<div style="color:#80FF80;font-size:11px;">' . $name_new_user . '</div>';
     }
     echo iconv('windows-1251', 'utf-8//IGNORE', $ret_str);