public function check_aggro($char) { if ($this->error == 1) { return; } if ($this->npc['prizrak'] == 1) { if ($this->npc['for_user_id'] != 0 and $this->npc['for_user_id'] != $char['user_id']) { return; } //if ($this->templ['npc_level']<($char['clevel']-3)) return; //if ($this->templ['npc_level']>($char['clevel']+3)) return; } $check_level = myquery("SELECT t2.value FROM game_npc_set_option as t1\n\t\t\t\t\t\t\t Join game_npc_set_option_value as t2 on t1.id=t2.id\n\t\t\t\t\t\t\t WHERE t1.opt_id=7 and t1.npc_id=" . $this->templ['npc_id'] . " \n\t\t\t\t\t\t\t Order By t2.number\n\t\t\t\t\t\t\t"); if (mysql_num_rows($check_level) == 2) { list($min_level) = mysql_fetch_array($check_level); list($max_level) = mysql_fetch_array($check_level); if ($char['clevel'] < $min_level or $char['clevel'] > $max_level) { return; } } $level_for_aggressive = 9999; //Проверка на автонападение бота if ($this->templ['agressive'] == '2' and $char['clevel'] < $this->templ['npc_level'] + $level_for_aggressive and $char['clevel'] > $this->templ['npc_level'] - $level_for_aggressive or $this->templ['agressive'] == '1' and $char['clevel'] > $this->templ['npc_level'] + $this->templ['agressive_level']) { attack_npc($char, $this->npc['id'], 1); } }
function attack_npc_quest() { global $user_id, $char; //начинаем бой с ботом охранником myquery("INSERT INTO game_quest_users SET user_id={$user_id},quest_id=1,last_time=" . time() . ",sost=2 ON DUPLICATE KEY UPDATE sost=2"); //создадим бота-охранника //$sel111=myquery("select npc_id from game_npc order by npc_id DESC limit 1"); //list($nid)=mysql_fetch_array($sel111); //$n=''.($nid+1).''; if ($_SESSION['quest1_step'] == 7 or $_SESSION['quest1_step'] == 51) { $npc_img = 'Monster-07'; $npc_name = 'Охранник тюрьмы'; $npc_race = 'Человек'; $npc_hp = round(0.4 * $char['HP_MAX']); $npc_max_hp = round(0.4 * $char['HP_MAX']); $npc_mp = round(0.4 * $char['MP_MAX']); $npc_max_mp = round(0.4 * $char['MP_MAX']); $npc_str = round(0.4 * $char['STR']); $npc_dex = round(0.4 * $char['DEX']); $npc_wis = round(0.4 * $char['PIE']); $npc_basefit = round(0.4 * $char['VIT']); $npc_basedef = round(0.4 * $char['SPD']); $npc_exp = 5; $npc_gold = 0; $npc_map_name = 0; $npc_xpos = 0; $npc_ypos = 0; $npc_time = 0; $npc_ntl = round(0.4 * $char['NTL']); $npc_level = $char['clevel']; $npc_item = 'мечом'; } if ($_SESSION['quest1_step'] == 14) { $npc_img = 'Clear/scorpy'; $npc_name = 'Жуки и скорпионы'; $npc_race = 'Пресмыкающееся'; $npc_hp = 1000; if ($_SESSION['quest1_bad_portal'] == 1) { $npc_hp = 2100; } else { $npc_hp = 10; } if ($_SESSION['quest1_bad_portal'] == 1) { $npc_max_hp = 2100; } else { $npc_max_hp = 1000; } $npc_mp = 1; $npc_max_mp = 1; $npc_str = 0; $npc_dex = 9; $npc_wis = 2; $npc_basefit = 5; $npc_basedef = 0; $npc_exp = 15; $npc_gold = 0; $npc_map_name = 0; $npc_xpos = 0; $npc_ypos = 0; $npc_time = 0; $npc_ntl = -5; $npc_level = $char['clevel']; $npc_item = 'жалом'; } if ($_SESSION['quest1_step'] == 24) { $npc_img = 'blackknight'; $npc_name = 'Парень с ятаганом'; $npc_race = 'Человек'; $npc_hp = round(0.9 * $char['HP_MAX']); $npc_max_hp = round(0.9 * $char['HP_MAX']); $npc_mp = round(0.7 * $char['MP_MAX']); $npc_max_mp = round(0.7 * $char['MP_MAX']); $npc_str = $char['STR'] + 2; $npc_dex = $char['DEX'] - 2; $npc_wis = $char['PIE'] - 3; $npc_basefit = $char['VIT']; $npc_basedef = $char['SPD']; $npc_exp = 6; $npc_gold = 0; $npc_map_name = 0; $npc_xpos = 0; $npc_ypos = 0; $npc_time = 0; $npc_ntl = $char['NTL']; $npc_level = $char['clevel']; $npc_item = 'ятаганом'; } if ($_SESSION['quest1_step'] == 27) { $npc_img = 'ettim'; $npc_name = 'Два охранника'; $npc_race = 'Человек'; $npc_hp = $char['HP_MAX']; $npc_max_hp = $char['HP_MAX']; $npc_mp = round(1 * $char['MP_MAX']); $npc_max_mp = round(1 * $char['MP_MAX']); $npc_str = round(1 * $char['STR']); $npc_dex = round(1 * $char['DEX']); $npc_wis = round(1 * $char['PIE']); $npc_basefit = round(1 * $char['VIT']); $npc_basedef = round(1 * $char['SPD']); $npc_exp = 8; $npc_gold = 0; $npc_map_name = 0; $npc_xpos = 0; $npc_ypos = 0; $npc_time = 0; $npc_ntl = $char['NTL']; $npc_level = $char['clevel']; $npc_item = 'ятаганом'; } if ($_SESSION['quest1_step'] == 30) { $npc_img = 'ettim'; $npc_name = '5 разбойников'; $npc_race = 'Человек'; $npc_hp = round(1.5 * $char['HP_MAX']); $npc_max_hp = round(1.5 * $char['HP_MAX']); $npc_mp = round(1.5 * $char['MP_MAX']); $npc_max_mp = round(1.5 * $char['MP_MAX']); $npc_str = round(1.5 * $char['STR']); $npc_dex = round(1.5 * $char['DEX']); $npc_wis = round(1.5 * $char['PIE']); $npc_basefit = round(1.5 * $char['VIT']); $npc_basedef = round(1.5 * $char['SPD']); $npc_exp = 10; $npc_gold = 0; $npc_map_name = 0; $npc_xpos = 0; $npc_ypos = 0; $npc_time = 0; $npc_ntl = round(1.5 * $char['NTL']); $npc_level = $char['clevel']; $npc_item = 'мечами'; } if ($_SESSION['quest1_step'] == 32 or $_SESSION['quest1_step'] == 34 or $_SESSION['quest1_step'] == 36 or $_SESSION['quest1_step'] == 38 or $_SESSION['quest1_step'] == 40 or $_SESSION['quest1_step'] == 42 or $_SESSION['quest1_step'] == 44) { $npc_img = 'blackknight'; $npc_name = 'Разбойник'; $npc_race = 'Человек'; $npc_hp = $char['HP_MAX']; $npc_max_hp = $char['HP_MAX']; $npc_mp = $char['MP_MAX']; $npc_max_mp = $char['MP_MAX']; $npc_str = $char['STR']; $npc_dex = $char['DEX']; $npc_wis = $char['PIE']; $npc_basefit = $char['VIT']; $npc_basedef = $char['SPD']; $npc_exp = 2; $npc_gold = 0; $npc_map_name = 0; $npc_xpos = 0; $npc_ypos = 0; $npc_time = 0; $npc_ntl = $char['NTL']; $npc_level = $char['clevel']; $npc_item = 'мечом'; } if ($_SESSION['quest1_step'] == 44) { $npc_item = 'булавой'; } $ins = myquery("INSERT INTO game_npc_template\n\t(npc_name, npc_race, npc_img, npc_max_hp, npc_max_mp, npc_str, npc_dex, npc_pie, npc_vit, npc_spd, npc_exp_max, npc_gold, npc_opis, npc_ntl, npc_level, respawn, item, to_delete)\n\tVALUES\n\t('{$npc_name}', '{$npc_race}', '{$npc_img}', '{$npc_max_hp}', '{$npc_max_mp}', '{$npc_str}', '{$npc_dex}', '{$npc_wis}', '{$npc_basefit}', '{$npc_basedef}', '{$npc_exp}', '{$npc_gold}', '', '{$npc_ntl}', '{$npc_level}', '0', '{$npc_item}', '1')"); $npc_id = mysql_insert_id(); $ins = myquery("INSERT INTO game_npc\n\t(npc_id, HP, MP, EXP, map_name, xpos, ypos, time_kill, stay, view, prizrak, npc_quest_id)\n\tVALUES\n\t('{$npc_id}', '{$npc_hp}', '{$npc_mp}', '{$npc_exp}', '{$npc_map_name}', '{$npc_xpos}', '{$npc_ypos}', '{$npc_time}', '0', '0', '1', '1')"); $id = mysql_insert_id(); attack_npc($char, $id, 0); }
//создадим шаблон бота $level = $char['clevel'] + 1; $clevel = $char['clevel']; $new_clevel = $clevel * ($clevel + 1) * 200; if ($clevel == 0) { $new_clevel = 200; } $exp = $new_clevel * 0.1 / ($level * $level); if ($level > 5) { $exp = 0; } myquery("INSERT INTO game_npc_template (npc_name,npc_img,npc_race,npc_max_hp,npc_max_mp,npc_str,npc_dex,npc_pie,npc_vit,npc_spd,item,npc_ntl,agressive,npc_level,npc_exp_max,to_delete) VALUES ('Тень игрока " . $char['name'] . "','ghost','Тень','" . $char['HP_MAX'] . "','" . $char['MP_MAX'] . "','" . $char['STR'] . "','" . $char['DEX'] . "','" . $char['PIE'] . "','" . $char['VIT'] . "','" . $char['SPD'] . "','тенью оружия','" . $char['NTL'] . "','0',0,{$exp},1)"); $npc_id = mysql_insert_id(); myquery("INSERT INTO game_npc (npc_id,prizrak,for_user_id,map_name,xpos,ypos,HP,MP,view,EXP,stay) VALUES ({$npc_id},'1',{$user_id}," . $char['map_name'] . "," . $char['map_xpos'] . "," . $char['map_ypos'] . "," . $char['HP_MAX'] . ",'" . $char['MP_MAX'] . "',0,{$exp},3)"); $npc_id = mysql_insert_id(); attack_npc($char, $npc_id, 0, 1); } } } $maze = mysql_num_rows(myquery("SELECT * FROM game_users_map t1 Join game_maps t2 On t1.map_name=t2.id Where t2.maze=1 and t1.user_id='" . $user_id . "'")); if ($maze == 0) { $check = mysql_result(myquery("SELECT COUNT(*) FROM game_turnir_users WHERE user_id={$user_id}"), 0, 0); if ($from_boy) { echo '<table width="100%"><tr bgcolor=#333333><td style="color:#F0E68C">Турнирные поединки:</td></tr></table>'; } if ($check == 0) { ?> <div style="height:20px;text-align:center;width:100%"><input type="button" value="Подать заявку" style="padding:3px;border:3px groove darkblue;background-color:#282828;color:white;" onclick="location.replace('<?php echo $main_url; ?> &zayavka')"></div>
$current_time = time(); $online_range = $current_time; $Npc = new Npc($_GET['id']); if ($Npc->can_attack($char)) { if ($Npc->npc_for_level($char)) { //движок квестов. проверка на ненападение на квестового бота другим игроком во время квеста if ($Npc->npc['npc_quest_engine_id'] > 0) { list($fin_time) = mysql_fetch_array(myquery("SELECT quest_finish_time FROM quest_engine_users WHERE quest_type=1 AND par1_value='" . $id . "'")); if ($Npc->npc['npc_quest_engine_id'] != $user_id and $fin_time > time()) { if (function_exists("save_debug")) { save_debug(); } setLocation("act.php?func=main"); exit; } } attack_npc($char, $_GET['id'], 0); } else { echo '<center><b>Бот не подходит для вашего уровня!</b></center>'; } } else { echo '<center><b>Вы не можете напасть на бота!</b></center>'; } } break; } } setLocation("act.php"); if (function_exists("save_debug")) { save_debug(); }