Файл: msmenu/msbattle.php
Строк: 343
<?php
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `ms_mythings` WHERE `clothed` = '".num(1)."' AND `user` = '".num($user['id'])."'"),0)>=20)
{
$_SESSION['msg'] = 'Вы не можете приступить к выполнению поручения, так как в Вашем
<a class="item-n" href="../msthings">рюкзаке</a> нет места для награды.
Разберите ненужные вещи, чтобы освободить место.';
header("Location: ../");
exit;
}elseif(isset($_GET['msset']) && intval($_GET['msset'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `ms_include` WHERE `id` = '".intval($_GET['msset'])."' AND `user` = '".$user['id']."'"),0)!=0)
{
$msmon = mysql_fetch_array(mysql_query("SELECT * FROM `ms_include` WHERE `id` = '".intval($_GET['msset'])."' LIMIT 1"));
$msbat = mysql_fetch_array(mysql_query("SELECT * FROM `ms_monster` WHERE `id` = '".$msmon['id_monster']."' LIMIT 1"));
if(isset($_GET['aoeHit']) && $user['mstimeelixir'] < time()){
$msaoehit = num(1);
}else{
$msaoehit = num(0);
}
$msifuserlife = $user['time']-time();
if($user['mstimeshield'] < time()){
$msprocshield = num(0);
}else{
$msprocshield = $msmon['attack']*$user['msshield']/100;
}
$msbotsq = $msmon['attack']-$msprocshield-$user['protection'];
if($msbotsq < 0)$msbot = 0; else $msbot = $msbotsq;
$mstraning_attack = $user['attack']*$user['traning_attack']/100;
$msuseruron = $user['attack']+$mstraning_attack;
if($msuseruron == 0){
$msuser = $user['attack'];
}else{
if($msaoehit == 1){
$mshit = $msuseruron*2;
}else{
$mshit = $msuseruron;
}
if($user['mstimerage'] < time()){
$msrage = num(0);
}else{
$msproc = $user['attack']*$user['msrage']/100;
$msrage = $msproc;
}
if($user['mstimescroll'] > time())$msscrollsprocent = $user['scroll_procent'];else $msscrollsprocent = num(0);
$msuser = $mshit+$msrage+$msscrollsprocent;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `ms_clan_user` WHERE `user` = '".$user['id']."' LIMIT 1"),0)!=0){
$msuser_clan = mysql_fetch_array(mysql_query("SELECT * FROM `ms_clan_user` WHERE `user` = '".$user['id']."' LIMIT 1"));
$ms_clan = mysql_fetch_array(mysql_query("SELECT * FROM `ms_clan` WHERE `clan_id` = '".$msuser_clan['clan']."' LIMIT 1"));
$msbonusclan = array("1" => 5, "2" => 6, "3" => 7, "4" => 8, "5" => 9, "6" => 10,
"7" => 12, "8" => 14, "9" => 16, "10" => 18, "11" => 21, "12" => 23,
"13" => 25, "14" => 27, "15" => 30, "16" => 35, "17" => 38, "18" => 40,
"19" => 44, "20" => 48, "21" => 53, "22" => 58, "23" => 65, "24" => 71,
"25" => 75, "26" => 81, "27" => 86, "28" => 92, "29" => 96, "30" => 100,
"31" => 105, "32" => 112, "33" => 118, "34" => 125, "35" => 135, "36" => 145,
"37" => 155, "38" => 165, "39" => 175, "40" => 185, "41" => 195, "42" => 205,
"43" => 215, "44" => 225, "45" => 235, "46" => 245, "47" => 255, "48" => 265,
"49" => 275, "50" => 285, "51" => 295, "52" => 300, "53" => 310, "54" => 320,
"55" => 330, "56" => 340, "57" => 350, "58" => 360, "59" => 370, "60" => 380,
"61" => 390, "62" => 400, "63" => 410, "64" => 420, "65" => 430, "66" => 440,
"67" => 450, "68" => 460, "69" => 470, "70" => 480, "71" => 490, "72" => 500,
"73" => 510, "74" => 520, "75" => 530, "76" => 540, "77" => 550, "78" => 560,
"79" => 570, "80" => 580, "81" => 590, "82" => 600, "83" => 610, "84" => 620
);
$msclan_proc_exp = $msbonusclan[''.$ms_clan['level'].''];
$msclanexp = $msbat['exp']*$msclan_proc_exp/100;
}else{
$msclanexp = num(0);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$msuser1 = $user['life']-$msbot;
$msbot1 = $msmon['life']-$msuser;
if($user['double_experience'] > time()){
$userexp = $msbat['exp']*4;
}else{
$userexp = $msbat['exp']*2;
}
$msuserexp = $userexp+$msclanexp;
if($msbot1 < 1){
mysql_query("UPDATE `ms_user` SET `rating` = '".($user['rating']+$msuserexp)."' WHERE `id` = '".$user['id']."' LIMIT 1");
mysql_query("DELETE FROM `ms_include` WHERE `id` = '".$msmon['id']."' AND `user` = '".$user['id']."'");
mysql_query("DELETE FROM `msbattle_log` WHERE `include` = '".$msmon['id']."'");
///////////////////////////////////////////////////////////////////////////////
//////////////////////Выпадение вещей /////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
$msact = rand(1,8);
$msf = mysql_query("SELECT * FROM `ms_things` WHERE `act` = '".num($msact)."' ORDER BY RAND() LIMIT 1");
while($msact_ms = mysql_fetch_array($msf))
{
$msrand_start1 = rand(1,10);
$msrand_start2 = rand(1,5);
if($msrand_start1 == $msrand_start2){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `ms_mythings` WHERE `clothed` = '".num(1)."' AND `user` = '".num($user['id'])."'"),0)<20)
{
if($user['level'] < 5)$msrand_act = 10;
else if($user['level'] < 10)$msrand_act = 25;
else if($user['level'] < 15)$msrand_act = 35;
else if($user['level'] < 20)$msrand_act = 45;
else if($user['level'] < 25)$msrand_act = 50;
else if($user['level'] < 30)$msrand_act = 55;
else if($user['level'] < 35)$msrand_act = 60;
else if($user['level'] < 40)$msrand_act = 65;
else if($user['level'] < 45)$msrand_act = 70;
else if($user['level'] < 50)$msrand_act = 80;
else if($user['level'] < 100)$msrand_act = 100;
else $msrand_act = 100;
if($msact_ms['act'] == 1) $ms_act_get = '<img src="/img/items/helm.png" alt="" width="24" height="24" title="'.$msact_ms['name'].'"/>';
if($msact_ms['act'] == 2) $ms_act_get = '<img src="/img/items/shoulders.png" alt="" width="24" height="24" title="'.$msact_ms['name'].'"/>';
if($msact_ms['act'] == 3) $ms_act_get = '<img src="/img/items/weapon.png" alt="" width="24" height="24" title="'.$msact_ms['name'].'"/>';
if($msact_ms['act'] == 4) $ms_act_get = '<img src="/img/items/shield.png" alt="" width="24" height="24" title="'.$msact_ms['name'].'"/>';
if($msact_ms['act'] == 5) $ms_act_get = '<img src="/img/items/armor.png" alt="" width="24" height="24" title="'.$msact_ms['name'].'"/>';
if($msact_ms['act'] == 6) $ms_act_get = '<img src="/img/items/belt.png" alt="" width="24" height="24" title="'.$msact_ms['name'].'"/>';
if($msact_ms['act'] == 7) $ms_act_get = '<img src="/img/items/legs.png" alt="" width="24" height="24" title="'.$msact_ms['name'].'"/>';
if($msact_ms['act'] == 8) $ms_act_get = '<img src="/img/items/boots.png" alt="" width="24" height="24" title="'.$msact_ms['name'].'"/>';
/////////////////////////////////////////////////
/////////////////////////////////////////////////
////////////////Выбираем тип вещи по цвету //////
/////////////////////////////////////////////////
/////////////////////////////////////////////////
if($user['level'] < 5){
$ms_color_rand1 = rand(0,1);
$ms_color_rand2 = rand(0,1);
if($ms_color_rand1 == $ms_color_rand2){
$mscolor = $ms_color_rand2;
if($ms_color_rand2 == 0) $msmultiply = 1;
if($ms_color_rand2 == 1) $msmultiply = 2;
$mscolor_multiply = num($msmultiply);
}else{
$msmultiply = 5;
$mscolor_multiply = num(1);
}
$mssmsmm = 10;
}elseif($user['level'] < 10){
$ms_color_rand1 = rand(0,1);
$ms_color_rand2 = rand(0,2);
if($ms_color_rand1 == $ms_color_rand2){
$mscolor = $ms_color_rand2;
if($ms_color_rand2 == 0) $msmultiply = 1;
if($ms_color_rand2 == 1) $msmultiply = 2;
if($ms_color_rand2 == 2) $msmultiply = 3;
$mscolor_multiply = num($msmultiply);
}else{
$msmultiply = 1;
$mscolor_multiply = num(1);
}
$mssmsmm = 10;
}elseif($user['level'] < 15){
$ms_color_rand1 = rand(0,1);
$ms_color_rand2 = rand(0,2);
if($ms_color_rand1 == $ms_color_rand2){
$mscolor = $ms_color_rand2;
if($ms_color_rand2 == 0) $msmultiply = 1;
if($ms_color_rand2 == 1) $msmultiply = 3;
if($ms_color_rand2 == 2) $msmultiply = 4;
$mscolor_multiply = num($msmultiply);
}else{
$mscolor = 1;
$msmultiply = 1;
$mscolor_multiply = num(2);
}
}elseif($user['level'] < 20){
$ms_color_rand1 = rand(0,1);
$ms_color_rand2 = rand(0,2);
if($ms_color_rand1 == $ms_color_rand2){
$mscolor = $ms_color_rand2;
if($ms_color_rand2 == 0) $msmultiply = 2;
if($ms_color_rand2 == 1) $msmultiply = 3;
if($ms_color_rand2 == 2) $msmultiply = 4;
$mscolor_multiply = num($msmultiply);
}else{
$mscolor = 1;
$msmultiply = 1;
$mscolor_multiply = num(2);
}
$mssmsmm = 30;
}elseif($user['level'] < 25){
$ms_color_rand1 = rand(1,3);
$ms_color_rand2 = rand(1,3);
if($ms_color_rand1 == $ms_color_rand2){
$mscolor = $ms_color_rand2;
if($ms_color_rand2 == 1) $msmultiply = 2;
if($ms_color_rand2 == 2) $msmultiply = 4;
if($ms_color_rand2 == 3) $msmultiply = 5;
$mscolor_multiply = num($msmultiply);
}else{
$mscolor = 1;
$msmultiply = 1;
$mscolor_multiply = num(3);
}
}elseif($user['level'] < 30){
$ms_color_rand1 = rand(1,4);
$ms_color_rand2 = rand(1,4);
if($ms_color_rand1 == $ms_color_rand2){
$mscolor = $ms_color_rand2;
if($ms_color_rand2 == 1) $msmultiply = 4;
if($ms_color_rand2 == 2) $msmultiply = 5;
if($ms_color_rand2 == 3) $msmultiply = 6;
if($ms_color_rand2 == 4) $msmultiply = 7;
$mscolor_multiply = num($msmultiply);
}else{
$mscolor = 2;
$msmultiply = 2;
$mscolor_multiply = num(3);
}
}elseif($user['level'] < 40){
$ms_color_rand1 = rand(1,6);
$ms_color_rand2 = rand(1,4);
if($ms_color_rand1 == $ms_color_rand2){
$mscolor = $ms_color_rand2;
if($ms_color_rand2 == 1) $msmultiply = 6;
if($ms_color_rand2 == 2) $msmultiply = 7;
if($ms_color_rand2 == 3) $msmultiply = 8;
if($ms_color_rand2 == 4) $msmultiply = 9;
$mscolor_multiply = num($msmultiply);
}else{
$mscolor = 1;
$msmultiply = 1;
$mscolor_multiply = num(4);
}
$mssmsmm = 60;
}elseif($user['level'] < 50){
$ms_color_rand1 = rand(1,4);
$ms_color_rand2 = rand(1,4);
if($ms_color_rand1 == $ms_color_rand2){
$mscolor = $ms_color_rand2;
if($ms_color_rand2 == 1) $msmultiply = 6;
if($ms_color_rand2 == 2) $msmultiply = 8;
if($ms_color_rand2 == 3) $msmultiply = 12;
if($ms_color_rand2 == 4) $msmultiply = 14;
$mscolor_multiply = num($msmultiply);
}else{
$mscolor = 2;
$msmultiply = 2;
$mscolor_multiply = num(6);
}
}elseif($user['level'] < 70){
$ms_color_rand1 = rand(1,4);
$ms_color_rand2 = rand(1,4);
if($ms_color_rand1 == $ms_color_rand2){
$mscolor = $ms_color_rand2;
if($ms_color_rand2 == 1) $msmultiply = 12;
if($ms_color_rand2 == 2) $msmultiply = 14;
if($ms_color_rand2 == 3) $msmultiply = 18;
if($ms_color_rand2 == 4) $msmultiply = 24;
$mscolor_multiply = num($msmultiply);
}else{
$mscolor = 3;
$msmultiply = 3;
$mscolor_multiply = num(15);
}
}
/////////////////////////////////////////////////
/////////////////////////////////////////////////
////////////////Выбираем тип вещи по цвету //////
////////////////Конец кода //////////////////////
/////////////////////////////////////////////////
if($mscolor == 0) $msallow = 0; else
if($mscolor == 1) $msallow = 0; else
if($mscolor == 2) $msallow = 1; else
if($mscolor == 3) $msallow = 1; else
if($mscolor == 4) $msallow = 1;
/////////////////////////////////////////////////
$regeneration_act1 = rand(1,$msbat['level']);
$attack_act1 = rand(1,$msrand_act);
$mslifeact = $msrand_act+rand(10,100);
$life_act1 = rand($user['level'],$mslifeact);
$regeneration_act = $regeneration_act1*$mscolor_multiply;
$attack_act = $attack_act1*$mscolor_multiply;
$life_act = $life_act1*$mscolor_multiply;
if($mscolor == 0) $mscolors = '<span class="log_miss">'.$msact_ms['name'].'</span>';
if($mscolor == 1) $mscolors = '<span class="item-n">'.$msact_ms['name'].'</span>';
if($mscolor == 2) $mscolors = '<span class="item-e">'.$msact_ms['name'].'</span>';
if($mscolor == 3) $mscolors = '<span class="item-l">'.$msact_ms['name'].'</span>';
if($mscolor == 4) $mscolors = '<span class="item-r">'.$msact_ms['name'].'</span>';
$ms_act_msg = '<br />'.@$ms_act_get.' <a href="../msthings" class="item-n">'.$mscolors.'</a> <span class="small minor"><span>'.$msbat['level'].'</span> ур</span>';
$msrand_ms_user1 = rand(1,8);
$msrand_ms_user2 = rand(1,8);
if($msrand_ms_user1 == $msrand_ms_user2){
$msruby_act = num(1);
}else{
$msruby_act = num(0);
}
$protection_act = rand($user['level'],$msrand_act);
$protection = $protection_act*$mscolor_multiply;
mysql_query("INSERT INTO `ms_mythings` SET `allow` = '".$msallow."', `protection` = '".$protection."', `rubin` = '".$msruby_act."', `ms_level_color` = '".$mscolor."', `id_things` = '".$msact_ms['id']."', `user` = '".num($user['id'])."', `act` = '".num($msact_ms['act'])."', `name` = '".my_esc($msact_ms['name'])."', `life` = '".$life_act."', `level` = '".$msbat['level']."', `attack` = '".$attack_act."', `regeneration` = '".num($regeneration_act)."'");
$msidruby = mysql_insert_id();
if($msrand_ms_user1 == $msrand_ms_user2){
mysql_query("INSERT INTO `ms_rubin` SET `user` = '".$user['id']."', `act` = '".$msidruby."'");
}
}else{
$ms_act_msg = '<br />В рюкзаке не хватает места<br />
Освободите рюкзак чтобы получить вещь.';
}
}
}
///////////////////////////////////////////////////////////////////////////////
////////////////////////Конец /////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
mysql_query("UPDATE `ms_user` SET `minuslife` = '".num(0)."', `life` = '".$user['lifes']."' WHERE `id` = '".$user['id']."' LIMIT 1");
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `ms_clan_user` WHERE `user` = '".$user['id']."' LIMIT 1"),0)!=0){
$msuser_clan = mysql_fetch_array(mysql_query("SELECT * FROM `ms_clan_user` WHERE `user` = '".$user['id']."' LIMIT 1"));
$ms_clan = mysql_fetch_array(mysql_query("SELECT * FROM `ms_clan` WHERE `clan_id` = '".$msuser_clan['clan']."' LIMIT 1"));
mysql_query("UPDATE `ms_clan` SET `rating` = '".num($ms_clan['rating']+$msuserexp)."' WHERE `clan_id` = '".$msuser_clan['clan']."' LIMIT 1");
}
$text = '
Опыта + '.num($msuserexp).'<br />
'.@$ms_act_msg;
$_SESSION['msg'] = $text;
header("Location: ../msusermenu");
exit;
}else
if($msuser1 < 1){
mysql_query("UPDATE `ms_user` SET `endbattle` = '".(time()+300)."', `minuslife` = '".num(0)."', `life` = '".num(0)."' WHERE `id` = '".$user['id']."' LIMIT 1");
mysql_query("DELETE FROM `ms_include` WHERE `id` = '".$msmon['id']."' AND `user` = '".$user['id']."'");
mysql_query("DELETE FROM `msbattle_log` WHERE `include` = '".$msmon['id']."'");
header("Location: ../msusermenu");
exit;
}else{
mysql_query("UPDATE `ms_user` SET `minuslife` = '".$msbot."', `life` = '".$msuser1."' WHERE `id` = '".$user['id']."' LIMIT 1");
if($msaoehit == 1){
if($user['mstimeelixir_bonus'] < time()){
mysql_query("UPDATE `ms_user` SET `mstimeelixir` = '".(time()+3)."' WHERE `id` = '".$user['id']."' LIMIT 1");
}
}
mysql_query("UPDATE `ms_include` SET `msblood` = '".num(rand(0,3))."', `life` = '".$msbot1."', `minuslife` = '".$msuser."' WHERE `id` = '".$msmon['id']."' LIMIT 1");
if($msprocshield)$msprocshields = '<span class="log_crit">(- '.$msprocshield.' <img src="/img/aura_shield.png" width="24" height="24" alt="" />) Получено: '.$msbot.' </span>';
if($msrage)$msrages = '<span class="log_crit">(+ '.$msrage.' <img src="/img/aura_attack.png" width="24" height="24" alt="" />) </span>';
if($msscrollsprocent)$msscrollsprocents = '<span class="log_crit">(+ '.$msscrollsprocent.' <img src="/img/scroll.png" width="24" height="24" alt="" />) </span>';
$msmsgbattle = '
<span class="log_damage">Удар противника: '.$msmon['attack'].' урона.</span> '.@$msprocshields.'<br />
<span class="log_damage">Вы нанесли урона противнику: '.$msuser.' урона. </span> '.@$msrages.' '.@$msscrollsprocents.'<br />';
mysql_query("INSERT INTO `msbattle_log` SET `user` = '".$user['id']."', `include` = '".$msmon['id']."', `msg` = '".$msmsgbattle."'");
header("Location: ../msusermenu");
exit;
}
}
?>