<?php
require_once './element_options/element_options.php';
if (!$user) { header('Location: /'); exit; }
$params = readcache('element_mission_user_'.$user['lost_id']);
if (!$params) { header('Location: /mission'); exit; } // Если нет данных боя, переадрес в миссии
require_once './element_function/element_function_mission.php';
require_once './element_function/element_function_battle.php';
$status_game = status_game($params['user_params']['life'], $params['bot_params']['life'], $params['user_params']['avto_battle']);
$journal = readcache('element_mission_journal'.$user['lost_id']);
if (!is_array($journal)) $journal = array();
$count_journal = count($journal);
$avto_battle = (isset($_GET['avto_battle'])) ? true : false;
// Бой руками!
if ($status_game == 0 AND !$avto_battle) {
$abil_ogon = AbilitiesOgon($user['lost_abilities_ogon'], $user['lost_race'], false, $user['lost_id']);
$abil_voda = AbilitiesVoda($user['lost_abilities_voda'], $user['lost_race'], false, $user['lost_id']);
$abil_zeml = AbilitiesZemlya($user['lost_abilities_zemlya'], $user['lost_race'], false, $user['lost_id']);
$abil_vosd = AbilitiesVozdyh($user['lost_abilities_vozduh'], $user['lost_race'], false, $user['lost_id']);
$add_hp = 0;
//abilities_race_zemla($time, $time_refresh)
if ($params['bot_params']['time']) {
$time_bot = explode(' ', $params['bot_params']['time']);
$time_fre = explode(' ', microtime());
$time_udar_bot = ceil(($time_fre[1] + $time_fre[0]) - ($time_bot[1] + $time_bot[0]));
} else $time_udar_bot = 5;
$rand_udar_s = rand(3,4);
// Удары бота по мне
if ($time_udar_bot > $rand_udar_s) {
$other_count_udat = (int)($time_udar_bot / $rand_udar_s);
$bot_uron = 0;
for($i = 0; $i < $other_count_udat; $i++) {
$uron = GenerationUron($params['bot_params']['strlen'], $params['bot_params']['time'], 0, 0, $abil_zeml['add_procent'], GenerationProtection($user['lost_params_protection']));
$params['user_params']['hp'] = $params['user_params']['hp'] - $uron;
array_unshift($journal, '<span class="small red"><img src="/images/icons/arena.gif"> '.$params['bot_params']['name'].' ударил '.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' на <span class="bold">'.$uron.'</span> урон</span>');
if (count($journal) > 15) unset($journal[15]);
if ($params['user_params']['hp'] <= 0) {
array_unshift($journal, '<span class="small red"><img src="/images/icons/arena.gif"> '.$params['bot_params']['name'].' убил '.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].'</span>');
array_unshift($journal, '<span class="lngreen bold">Бой закончен</span>');
if (count($journal) > 15) unset($journal[15]);
$crst = handler_cristalls(1, $user_blessing['nagrada']);
$params['missions']['cristalls'] = $crst;
update_money_exp($user, 1, $crst, 0, 0);
$params['user_params']['life'] = 1;
writecache('element_mission_user_'.$user['lost_id'],$params);
writecache('element_mission_journal'.$user['lost_id'], $journal);
writecache('element_users_battle'.$user['lost_id'], '');
$status_game = 2;
break;
}
$bot_uron = $bot_uron + $uron;
}
$params['bot_params']['time'] = microtime();
writecache('element_mission_user_'.$user['lost_id'],$params);
writecache('element_mission_journal'.$user['lost_id'], $journal);
} else {
$bot_uron = 0;
$abil_zeml = abilities_race_zemlya(0, $abilities_zeml[2], $abilities_zeml[1], $abilities_zeml[3], $abilities_zeml[4], 0);
}
if ($status_game != 2) {
// Мой удар по боту
if ($go == 'attaka') {
// Активация Огненной силы
if ($id == 1 AND !$abil_ogon['activate']) {
$abil_ogon = AbilitiesOgon($user['lost_abilities_ogon'], $user['lost_race'], true, $user['lost_id']);
$image = quality_item_name($user['lost_abilities_ogon']);
array_unshift($journal, '<span class="small admin">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' активировал <span class="bold yellow1">'.$image['image'].' огненную силу</span></span>');
}
// Активация Водяного крита
if ($id == 2 AND !$abil_voda['activate']) {
$abil_voda = AbilitiesVoda($user['lost_abilities_voda'], $user['lost_race'], true, $user['lost_id']);
$image = quality_item_name($user['lost_abilities_voda']);
array_unshift($journal, '<span class="small admin">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' активировал <span class="bold yellow1">'.$image['image'].' водяной крит</span></span>');
}
// Активация Ловушки ветра
if ($id == 3 AND !$abil_vosd['active']) {
$abil_vosd = AbilitiesVozdyh($user['lost_abilities_vozduh'], $user['lost_race'], true, $user['lost_id']);
$image = quality_item_name($user['lost_abilities_vozduh']);
array_unshift($journal, '<span class="small admin">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' активировал <span class="bold yellow1">'.$image['image'].' ловушку ветра</span></span>');
// Если шанс сработал, забираем хп
if ($abil_vosd['add_hp'] > 0) {
$add_hp = (int)(($params['bot_params']['other_hp'] / 100) * $abil_vosd['add_hp']);
$my_ras_hp = $params['user_params']['other_hp'] - $params['user_params']['hp'];
if ($add_hp > $my_ras_hp) $add_hp = $my_ras_hp;
$params['bot_params']['hp'] = $params['bot_params']['hp'] - $add_hp;
$params['user_params']['hp'] = $params['user_params']['hp'] + $add_hp;
array_unshift($journal, '<span class="small admin">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' забрал у '.$params['bot_params']['name'].' <span class="bold">'.$add_hp.'</span> здоровья</span>');
}
}
// Активация Земляной стойкости
if ($id == 4 AND !$abil_zeml['activate']) {
$abil_zeml = AbilitiesZemlya($user['lost_abilities_zemlya'], $user['lost_race'], true, $user['lost_id']);
$image = quality_item_name($user['lost_abilities_zemlya']);
array_unshift($journal, '<span class="small admin">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' активировал <span class="bold yellow1">'.$image['image'].' земляной щит</span></span>');
}
// quality_item_name($quality)
$user_uron = GenerationUron($user['lost_params_strlen'], $params['user_params']['time'], $abil_ogon['add_procent'], $abil_voda['add_procent'], 0, 40);
$params['bot_params']['hp'] = $params['bot_params']['hp'] - $user_uron;
$params['user_params']['time'] = microtime();
array_unshift($journal, '<span class="small yellow1">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' ударил '.$params['bot_params']['name'].' на <span class="bold">'.$user_uron.'</span> урон '.(($abil_voda['add_procent'] > 0) ? 'крит' : '').'</span>');
if ($params['bot_params']['hp'] <= 0) {
require_once './element_function/element_function_item.php';
$params['bot_params']['life'] = 1;
array_unshift($journal, '<span class="small yellow1">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' убил '.$params['bot_params']['name'].'</span>');
array_unshift($journal, '<span class="lngreen bold">Бой закончен</span>');
if (count($journal) > 15) unset($journal[15]);
$status_game = 2;
writecache('element_users_battle'.$user['lost_id'], '');
$shoot_item = users_shoot_item($user['lost_id']);
$create_item = create_item($user['lost_id'], $shoot_item, RandEquipMission($params['missions']['equip']), false, false, false, false, false, false, false, false);
$params['missions']['equipment'] = $create_item;
if ($params['missions']['end_count'] > $params['missions']['my_count']) $count_c = $params['missions']['my_count'] + 1; else $count_c = $params['missions']['my_count'];
if ($count_c > $params['missions']['other_count']) $params['missions'] = $params['other_count'];
$params['missions']['my_count'] = $count_c;
$location = $params['missions']['location'];
mysql_query("UPDATE `element_mission_user` SET `lost_location$location` = '$count_c' WHERE `lost_user` = '$user[lost_id]' LIMIT 1");
$user_quests = user_quests($user['lost_id']);
$count_quests = quests_id_count('missions_10');
if ($user_quests['missions_10'] < $count_quests) {
$user_quests['missions_10'] = $user_quests['missions_10'] + 1;
if ($user_quests['missions_10'] == $count_quests) $user_quests['lost_new'] = $user_quests['lost_new'] + 1;
writecache('element_quests_user'.$user['lost_id'], $user_quests);
quests_list_update($user['lost_id']);
}
$expooint = handler_expoint($params['missions']['expoint'], $user['lost_add_user_exp'], $user['lost_add_town_exp']);
$params['missions']['expoint'] = $expooint['user'];
update_money_exp($user, $expooint, $params['missions']['cristalls'], 0, $params['missions']['gold']);
$lost_exp = explode(' ', $user['lost_exp']);
}
writecache('element_mission_user_'.$user['lost_id'],$params);
writecache('element_mission_journal'.$user['lost_id'], $journal);
} else {
$user_uron = 0;
$abit_ogon = abilities_race_ogon(0, $abilities_ogon[2], $abilities_ogon[1], $abilities_ogon[3], $abilities_ogon[4], 0);
$abit_voda = abilities_race_voda(0, $abilities_voda[1], $abilities_voda[2], $abilities_voda[3], 0);
}
if ($status_game != 2) {
$title = 'Битва стихий';
require_once './element_include/element_head.php';
echo '<body><div class="p5">';
$my_user = array('user_race' => $user['lost_race'], 'user_hp' => $params['user_params']['hp'],
'user_other_hp' => $params['user_params']['other_hp'], 'user_name' => $user['lost_login'],
'user_uron' => $bot_uron, 'user_add_hp' => $add_hp);
$no_user = array('user_race' => 0, 'user_hp' => $params['bot_params']['hp'],
'user_other_hp' => $params['bot_params']['other_hp'], 'user_name' => $params['bot_params']['name'],
'user_uron' => $user_uron, 'user_add_hp' => 0);
EchoTableUsersBattle($my_user, $no_user);
EchoAbiliteBattle($abil_ogon, $abil_voda, $abil_vosd, $abil_zeml, false, 'w19', '35', 0, '/mission/battle');
if ($count_journal > 0) {
echo '<div class="nfl p5 mb5 small mlra">';
foreach (array_slice($journal, 0, 10, true) as $value) {
echo '<span class="white">'.$value.'<span><br/>';
}
echo '</div>';
}
echo '<div class="mb5 cntr small"><a class="button w50" href="/mission/battle?avto_battle">Автобой</a><br/><a class="button mt5 w50" href="/">Сбежать с боя</a></div>';
require_once './element_include/element_foot_user_battle_true.php';
exit;
}
}
}
// Автобой!
if ($status_game == 1 OR $status_game == 0 AND $avto_battle) {
require_once './element_function/element_function_battle.php';
$close = 0;
if (!$avto_battle) $params['user_params']['hp'] = ceil($params['user_params']['hp'] * 0.75);
$lost_protection = ceil($user['lost_params_protection'] * 0.75);
do {
$bot_uron = GenerationUron($params['bot_params']['strlen'], false, 10, 0, 0, GenerationProtection($user['lost_params_protection']));
$user_uron = GenerationUron($user['lost_params_strlen'], false, 0, 0, 0, 0);
//$user_protection = Protection(50, element_settings_game('lost_max_protection'));
//$user_uron = GenerateUron($user['lost_params_strlen'],$params['user_params']['time'],$user_protection);
//$user_uron = ceil($user_uron * 0.75);
$params['user_params']['hp'] = $params['user_params']['hp'] - $bot_uron;
array_unshift($journal, '<span class="small red"><img src="/images/icons/arena.gif"> '.$params['bot_params']['name'].' ударил '.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' на <span class="bold">'.$bot_uron.'</span> урон</span>');
$params['bot_params']['hp'] = $params['bot_params']['hp'] - $user_uron;
array_unshift($journal, '<span class="small yellow1">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' ударил '.$params['bot_params']['name'].' на <span class="bold">'.$user_uron.'</span> урон</span>');
if ($params['user_params']['hp'] <= 0) {
$params['user_params']['life'] = 1;
array_unshift($journal, '<span class="small red"><img src="/images/icons/arena.gif"> '.$params['bot_params']['name'].' убил '.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].'</span>');
array_unshift($journal, '<span class="lngreen bold">Бой закончен</span>');
$crst = handler_cristalls(1, $user_blessing['nagrada']);
$params['missions']['cristalls'] = $crst;
update_money_exp($user, 1, $crst, 0, 0);
writecache('element_mission_user_'.$user['lost_id'],$params);
writecache('element_mission_journal'.$user['lost_id'], $journal);
writecache('element_users_battle'.$user['lost_id'], '');
$status_game = 2;
$close = 1;
break;
}
if ($params['bot_params']['hp'] <= 0) {
require_once './element_function/element_function_item.php';
$params['bot_params']['life'] = 1;
array_unshift($journal, '<span class="small yellow1">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' убил '.$params['bot_params']['name'].'</span>');
array_unshift($journal, '<span class="lngreen bold">Бой закончен</span>');
if (count($journal) > 15) unset($journal[15]);
$status_game = 2;
$shoot_item = users_shoot_item($user['lost_id']);
$create_item = create_item($user['lost_id'], $shoot_item, chanse_mission(), false, false, false, false, false, false, false, false);
$params['missions']['equipment'] = $create_item;
if ($params['missions']['end_count'] > $params['missions']['my_count']) $count_c = $params['missions']['my_count'] + 1; else $count_c = $params['missions']['my_count'];
if ($count_c > $params['missions']['other_count']) $params['missions'] = $params['other_count'];
$params['missions']['my_count'] = $count_c;
$location = $params['missions']['location'];
mysql_query("UPDATE `element_mission_user` SET `lost_location$location` = '$count_c' WHERE `lost_user` = '$user[lost_id]' LIMIT 1");
$expooint = handler_expoint($params['missions']['expoint'], $user['lost_add_user_exp'], $user['lost_add_town_exp']);
$params['missions']['expoint'] = $expooint['user'];
$user_quests = user_quests($user['lost_id']);
$count_quests = quests_id_count('missions_10');
if ($user_quests['missions_10'] < $count_quests) {
$user_quests['missions_10'] = $user_quests['missions_10'] + 1;
if ($user_quests['missions_10'] == $count_quests) $user_quests['lost_new'] = $user_quests['lost_new'] + 1;
writecache('element_quests_user'.$user['lost_id'], $user_quests);
quests_list_update($user['lost_id']);
}
update_money_exp($user, $expooint, $params['missions']['cristalls'], 0, $params['missions']['gold']);
writecache('element_users_battle'.$user['lost_id'], '');
writecache('element_mission_user_'.$user['lost_id'],$params);
writecache('element_mission_journal'.$user['lost_id'], $journal);
$lost_exp = explode(' ', $user['lost_exp']);
$status_game = 2;
$close = 1;
break;
}
//echo '<span class="lngreen">'.$params['user_params']['hp'].'/ '.$user_uron.'</span><br/>';
//echo '<span class="ccc">'.$params['bot_params']['hp'].'/ '.$bot_uron.'</span><br/>';
} while($close == 0);
}
// Результат боя!
if ($status_game == 2) {
if ($params['bot_params']['life'] == 0) $pobeda = 0; else $pobeda = 1;
$title = 'Результат боя';
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
echo '<div class="nfl p5 mb5 cntr small mlra">';
if ($pobeda == 1) {
echo '<div class="medium bold"><span class="lngreen">Вы выиграли</span></div>';
echo '<div class="cntr p5 small yellow1">Награда: ';
echo ($params['missions']['gold'] > 0) ? '<img src="/images/icons/gold.png">'.$params['missions']['gold'].' золота, ' : '';
echo '<img src="/images/icons/cristall.png">'.$params['missions']['cristalls'].' кристаллов, ';
echo '<img width="13" height="12" src="/images/icons/experience.png">'.$params['missions']['expoint'].' опыта';
echo '</div>';
// Найденная вещь
if ($params['missions']['equipment'] > 0) {
require_once './element_function/element_function_item.php';
$item_id = cache_item($params['missions']['equipment']);
$genaration_params = item_generation_params($item_id['lost_strlen'], $item_id['lost_heatpoints'], $item_id['lost_protection'], $item_id['lost_comparison']);
$quality = quality_item_name($item_id['lost_quality']);
echo '<div class="mlra"><table class="mlra"><td><img width="50" height="50" src="'.$item_id['lost_avatar'].'"></td>';
echo '<td class="small left" valign="top">';
echo '<span class="ml5 small yellow1">'.$quality['image'].' <a href="/item?id='.$item_id['lost_id'].'">'.$item_id['lost_name'].'</a></span><br/>';
echo '<span class="ml5 small lngreen">'.name_item_mesto($item_id['lost_mesto']).'</span>';
echo '</td></table></div>';
}
}
if ($pobeda == 0) {
echo '<div class="medium bold"><span class="red">Вы проиграли</span></div>';
echo '<div class="cntr p5 small yellow1">Награда: ';
echo '<img src="/images/icons/cristall.png">'.$params['missions']['cristalls'].' кристалл, ';
echo '<img width="13" height="12" src="/images/icons/experience.png">1 опыта';
echo '</div>';
}
echo '<div><a class="button w50" href="/mission/location?id='.$params['missions']['location'].'&mission='.$params['missions']['mission'].'&go=start&z='.$params['missions']['end_count'].'">'.(($params['missions']['my_count'] < $params['missions']['end_count']) ? 'Ещё раз' : 'Повторить').'</a>';
echo '<br/><a class="button mt5 w50" href="/mission/location?id='.$params['missions']['location'].'">К списку миссий</a></div>';
echo '</div>';
if ($count_journal > 0) {
echo '<div class="nfl p5 mb5 small mlra">';
foreach (array_slice($journal, 0, 10, true) as $value) {
echo '<span class="white">'.$value.'<span><br/>';
}
echo '</div>';
}
require_once './element_include/element_foot_user_true.php';
}
?>