Вход Регистрация
Файл: vobljatrol/bk/fight.php
Строк: 124
<?php


$setMsg 
= '';
$sesTime = isset($_SESSION['bot_trainers_health'])  ? $_SESSION['bot_trainers_health'] : 0;
if (
100 > $user['bk_health'] &&  time() > $sesTime) {     $user['bk_health'] = $user['bk_health']+5;
    if (
100<$user['bk_health']) $user['bk_health'] = 100;
    
mysql_query("UPDATE users SET bk_health = '".$user['bk_health']."' WHERE id = '" . $user['id'] . "'");
    
$_SESSION['bot_trainers_health'] = time()+30;
}
#if ($user['room'] != 7) mysql_query("UPDATE users SET room = '7' WHERE id = '" . $user['id'] . "'");

$stop = false;
function 
minus($all, $minus) {
    
$all -= $minus;
    if (
0>$all) $all = 0;
    return 
$all;
}

function 
getRandMsg($file, $user_1 = '', $user_2 = '') {
    
$file = file('data/bk/'.$file.'.dat');
    return 
sprintf($file[array_rand($file)], $user_1, $user_2);
}

if (
preg_match("#!(.*?)[(.*?)](s|$)#i", $msg, $arr)) {
    
$_res = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE user = '".mysql_real_escape_string($arr[2])."'"));
    if (!isset(
$_SESSION['blow_time'])) $_SESSION['blow_time'] = 0;
    if (
$_SESSION['blow_time'] > time()) {
        
$setMsg = '<b>' . $user['user'] . '</b>, передохни '.($_SESSION['blow_time']-time()).' сек.';
    } elseif (!isset(
$_res['id']) || $rm != 7) {         $setMsg = getRandMsg('no_user', $user['user'], $arr[2]);
    } elseif (
$_res['id'] == 7) {         $setMsg = getRandMsg('vip_user', $user['user']);     } else {

        
$data = file_get_contents('data/bk/hands_feet.dat');
        if (
preg_match('/'.$arr[1].'|::|.*?n/is', $data, $force_preg)) {
            
$ex = explode('|::|', $force_preg[0]);
            if (
count($ex) == 3) {
                if (
time() > $_res['bk_trauma'] && $_res['bk_health']) {

                    
$blowStart = 10;
                    
$blow = ceil(($blowStart/mt_rand(70, 100))*(mt_rand(1, ($user['bk_force']+$ex[1]))-mt_rand(1, $_res['bk_endurance'])));
                    if (
0 >= $blow) $blow = mt_rand(1, ceil($blowStart/2));
                    
$mazila = mt_rand(1,$_res['bk_adroitness'])-mt_rand(1,$user['bk_accuracy']);
                    
$sql_us_1 = '';
                    
$sql_us_2 = '';

                    if (
$mazila > mt_rand(1, 100)) {
                        
$sql_us_1 = " bk_accuracy = '".minus($user['bk_accuracy'], mt_rand(1, 3))."',";
                        
$sql_us_2 = " bk_adroitness = '".minus($_res['bk_adroitness'], mt_rand(1, 3))."',";
                        
$blow = 0;
                        
$setMsg = getRandMsg('mazila', $user['user'], $_res['user']);
                    } else {
                        if (
minus($_res['bk_health'], $blow)) {                             $ex2 = explode('#', $ex[2]);
                            
$setMsg = '<b>' . $user['user'] . '</b>, '.$ex2[array_rand($ex2)].'<br /><b>'.$_res['user'].'</b> потерял '.$blow.'% здоровья.';
                        } else {
                            
$setMsg = getRandMsg('victory', $user['user'], $_res['user']);
                            
$sql_us_1 = " bk_victories = bk_victories+1,";
                            
$sql_us_2 = " bk_defeats = (bk_defeats+1), bk_trauma = '".(time()+120)."',";
                        }
                    }

                    
mysql_query("UPDATE users SET
                        bk_force = '"
.minus($user['bk_force'], mt_rand(1, 3))."',
                        
$sql_us_1
                        bk_endurance = '"
.minus($user['bk_endurance'], mt_rand(1, 3))."'
                    WHERE id = '" 
. $user['id'] . "'");

                    
mysql_query("UPDATE users SET
                        bk_force = '"
.minus($_res['bk_force'], mt_rand(1, 3))."',
                        
$sql_us_2
                        bk_endurance = '"
.minus($_res['bk_endurance'], mt_rand(1, 3))."',
                        bk_health = '"
.minus($_res['bk_health'], $blow)."'
                    WHERE id = '" 
. $_res['id'] . "'");
                    
$_SESSION['blow_time'] = time()+10;
                    
$_SESSION['bot_trainers_health'] = time()+30;
                } else 
$setMsg = getRandMsg('trauma', $user['user'], $_res['user']);
            }
            
$stop = true;
        }

        
$data = file_get_contents('data/bk/weapons.dat');
        if (!
$stop && preg_match('/'.$arr[1].'|::|.*?n/is', $data, $force_preg)) {
            
$ex = explode('|::|', $force_preg[0]);
            if (
count($ex) == 5) {                 if ($user['bk_weapons'] != $ex[0]) {                     $setMsg = getRandMsg('no_weapons', $user['user']);                 } elseif(time() > $_res['bk_trauma'] && $_res['bk_health']) {
                    
$blowStart = 20;
                    
$blow = ceil(($blowStart/mt_rand(70, 100))*(mt_rand(1, ($user['bk_force']+$ex[1]))-mt_rand(1, $_res['bk_endurance'])));
                    if (
0 >= $blow) $blow = mt_rand(1, ceil($blowStart/2));
                    
$mazila = mt_rand(1,$_res['bk_adroitness'])-mt_rand(1,$user['bk_accuracy']);
                    
$sql_us_1 = '';
                    
$sql_us_2 = '';
                    if (
$mazila > mt_rand(1, 100)) {
                        
$sql_us_1 = " bk_accuracy = '".minus($user['bk_accuracy'], mt_rand(1, 3))."',";
                        
$sql_us_2 = " bk_adroitness = '".minus($_res['bk_adroitness'], mt_rand(1, 3))."',";
                        
$blow = 0;
                        
$setMsg = getRandMsg('mazila', $user['user'], $_res['user']);
                    } else {

                        if (
minus($_res['bk_health'], $blow)) {                             $ex2 = explode('#', $ex[4]);
                            
$setMsg = '<b>' . $user['user'] . '</b>, '.$ex2[array_rand($ex2)].'<br /><b>'.$_res['user'].'</b> потерял '.$blow.'% здоровья.';
                        } else {                             
$setMsg = getRandMsg('victory', $user['user'], $_res['user']);
                            
$sql_us_1 = " bk_victories = bk_victories+1,";
                            
$sql_us_2 = " bk_defeats = (bk_defeats+1), bk_trauma = '".(time()+120)."',";
                        }
                    }
                    
mysql_query("UPDATE users SET
                        bk_force = '"
.minus($user['bk_force'], mt_rand(1, 3))."',
                        
$sql_us_1
                        bk_endurance = '"
.minus($user['bk_endurance'], mt_rand(1, 3))."'
                    WHERE id = '" 
. $user['id'] . "'");
                    
mysql_query("UPDATE users SET
                        bk_force = '"
.minus($_res['bk_force'], mt_rand(1, 3))."',
                        
$sql_us_2
                        bk_endurance = '"
.minus($_res['bk_endurance'], mt_rand(1, 3))."',
                        bk_health = '"
.minus($_res['bk_health'], $blow)."'
                    WHERE id = '" 
. $_res['id'] . "'");
                    
$_SESSION['blow_time'] = time()+10;
                    
$_SESSION['bot_trainers_health'] = time()+30;
                }else 
$setMsg = getRandMsg('trauma', $user['user'], $_res['user']);
            }
            
$stop = true;
        }
    }

}

if (!
$stop && preg_match("#!(.*?)(s|$)#i", $msg, $arr)) {
    
$data = file_get_contents('data/bk/weapons.dat');
    if (
preg_match('/'.$arr[1].'|::|.*?n/is', $data, $force_preg)) {
        
$ex = explode('|::|', $force_preg[0]);
        if (
count($ex) == 5) {
            if (
$user['rur'] > $ex[2]) {
                
$ex2 = explode('#', $ex[3]);
                
$setMsg = '<b>' . $user['user'] . '</b>, '.$ex2[array_rand($ex2)];
                
mysql_query("UPDATE users SET rur = (rur-".$ex[2]."), bk_weapons = '".mysql_real_escape_string($ex[0])."' WHERE id = '" . $user['id'] . "'");
            } else 
$setMsg = getRandMsg('little_rur', $user['user']);
        }
        
$stop = true;
    }
}

$defeat = isset($_SESSION['bot_bk_defeat'])  ? $_SESSION['bot_bk_defeat'] : 0;
if (
time() < $user['bk_trauma'] && time() > $defeat) {     $_SESSION['bot_bk_defeat'] = time()+20;    
mysql_query("INSERT INTO message SET
                    user = '
$user[user]',
                    user_id = '
$user[id]',
                    time = '"
.(time()+1)."',
                    msg = '"
.mysql_real_escape_string(getRandMsg('defeat', $user['user']))."',
                    rm = '7',
                    emo = '0',
                    bb = '0',
                    color = '0'
            "
);
    }

if (
$setMsg != '') {
mysql_query("INSERT INTO message SET
                    user = 'Рефери',
                    user_id = '0',
                    time = '"
.(time()+1)."',
                    msg = '"
.mysql_real_escape_string($setMsg)."',
                    rm = '7',
                    emo = '0',
                    bb = '0',
                    color = '0'
            "
);
    }
?>
Онлайн: 2
Реклама