game/_incl_data/class/Priems.php

2848 lines
108 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use Core\Db;
use Insallah\Math;
/*
- äîäåëàòü äîáàâëåíèå ïðèåìà â $btl->users[]['eff'] ïîñëå èñïîëüçîâàíèÿ, â ïðîòèâíîì ñëó÷àè íåêîòðûå ïðèåìû èñïîëüçóþòñÿ ÷åðåç 1 õîä
*/
class Priems
{
private $btl;
private $u;
const FIRE = 'fire';
const WATER = 'water';
const AIR = 'air';
const EARTH = 'earth';
private $mname = [
'îãîíü' => 1,
'âîçäóõ' => 2,
'âîäà' => 3,
'çåìëÿ' => 4,
'ñâåò' => 5,
'òüìà' => 6,
'ñåðàÿ' => 7,
];
public $ue = [];
private $logColor = [
'crit' => '#f00',
'miss' => '#888',
self::FIRE => '#a00',
self::WATER => '#00a',
self::EARTH => '#0a0',
self::AIR => '#0af',
];
public function __construct()
{
global $btl;
$this->btl = $btl;
$this->u = User::start();
}
/**@deprecated try to use getDynamicInfo()*/
private function getdr($s, $v, $d)
{
$i = 0;
while ($i < count($v)) {
if (isset($v[$i])) {
$s = str_replace('{' . $v[$i] . '}', $d[$i], $s);
}
$i++;
}
$s = eval("return (" . $s . ");");
return floor($s);
}
/**
* @param $match
* @return false|float
*/
private function getDynamicInfo($match)
{
$tmpl = [
'lvl1' => $this->u->info['level'],
'ts5' => $this->u->stats['s5'],
'mpAll' => $this->u->stats['mpAll'],
];
foreach ($tmpl as $k => $v) {
$match = str_ireplace('{' . $k . '}', $v, $match);
}
$p = $match[2];
if (preg_match('/(\d+)(?:\s*)([+\-*\/])(?:\s*)(\d+)/', $match[2], $matches) !== false) {
$operator = $matches[2];
switch ($operator) {
case '+':
$p = $matches[1] + $matches[3];
break;
case '-':
$p = $matches[1] - $matches[3];
break;
case '*':
$p = $matches[1] * $matches[3];
break;
case '/':
$p = $matches[1] / $matches[3];
break;
default:
}
}
return floor($p);
}
/** Íàáèâ Ñòàòèêè
* @param int $uid åñëè 0, áóäåò èñïîëüçîâàòüñÿ id ïðîòèâíèêà íàïðîòèâ.
* @return void
*/
public function addAirStaticPoints($uid = 0)
{
if ($uid == 0) {
$uid = $this->ue['id'];
}
$x = Db::getValue(
'select x from eff_users where uid = ? and `delete` = 0 and v2 = 260 and user_use = ? order by id desc limit 1',
[$uid, $this->u->info['id']]
);
if (empty($x) || $x >= 5) {
return;
}
$x++;
$data['add_mg2static_points'] = $x;
$data = $this->impStats($data);
Db::sql(
'update eff_users set x = ?, data = ? where uid = ? and `delete` = 0 and v2 = 260 and user_use = ?',
[$x, $data, $uid, $this->u->info['id']]
);
}
/** îòíèìàåì ìàíó
* @param $uid
* @param $mp
* @param $tp [not used]
* @return bool
*/
public function minMana($uid, $mp, $tp = null)
{
global $btl;
/* óìåíüøàåì ðàñõîä ìàíû, åñëè $mp > 0 */
//ñ âû÷åòîì óìåíüøåíèÿ ðàçñõîäà ìàíûss
$mp -= round($mp / 100 * $btl->stats[$btl->uids[$uid]]['min_use_mp']);
$btl->stats[$btl->uids[$uid]]['mpNow'] -= $mp;
$mpNow = $this->zeromax($btl->stats[$btl->uids[$uid]]['mpNow'], $btl->stats[$btl->uids[$uid]]['mpAll']);
if ($mpNow > 0) {
Db::sql(
'update stats set mpNow = ? where id = ?',
[$btl->stats[$btl->uids[$uid]]['mpNow'], $uid]
);
}
return $mpNow > 0;
}
/** Êàêîé-òî íåñòàíäàðòíûé ÷àñòíûé ðàñ÷åò ìàã.êðèòà
* @param $l2
* @param $t
* @return int
*/
public function magKrit($l2, $t)
{
$r = $l2 * 2 - 7;
if ($r > $t) {
//ìàãè÷åñêèé ïðîìàõ (ñåðûé óäàð, â 2 ðàçà ìåíüøå) 6%
//250 åä. çàùèòû îò ìàãèè äàåò 1% øàíñà óâåðíóòüñÿ îò ìàãèè
//$r = -1; , ïðîìàõ --
$r = 0;
} else {
//êàæäàÿ âëàäåëêà äàåò 3% øàíñ êðèòà
$r = ceil($t * 0.75);
if ($r > 30) {
$r = 30;
}
if (rand(0, 10000) < $r * 100) {
//êðèò óäàð
$r = 1;
} else {
$r = 0;
}
}
return $r;
}
/** èñïîëüçóåì ïðèåì êàæäûé õîä
* @param $eff
* @param $pr
* @return bool
*/
public function hodUsePriem($eff, $pr)
{
global $btl;
$u = $this->u; // Äëÿ ïðèñîåäèÿíåìûõ ôàéëîâ.
$return_main = true;
$ue = Db::getRow(
'select * from users left join stats on (users.id = stats.id) where users.id = ? and battle = ? and hpNow > 0',
[$eff['uid'], $btl->info['id']]
);
if (!empty($pr['file'])) {
if (file_exists('../../_incl_data/class/priems/' . $pr['file'] . '.php')) {
$hod = $eff['hod'];
require_once 'priems/' . $pr['file'] . '.php';
}
} elseif (!empty($pr['file3'])) {
if (file_exists('../../_incl_data/class/priems/' . $pr['file3'] . '.php')) {
$hod = $eff['hod'];
require_once 'priems/' . $pr['file3'] . '.php';
}
}
return $return_main;
}
/** Ïîëó÷àåò ñòðîêó data c øàáëîííîé çàïèñüþ òèïà add_m11=2*{lvl1} è êîíâåðòèðóåò â ðåàëüíóþ ñòðîêó.
* <br>Øàáëîí: <br>lvl1 = $uid[level] <br>ts5 = $uid[s5] <br>mpAll = $uid[mpAll]
* @param string $pl ñòðîêà â ôîðìàòå data
* @param int $uid ïîëüçîâàòåëü, ïàðàìåòðû êîòîðîãî èñïîëüçóþòñÿ äëÿ ïîäñòàâêè â øàáëîí.
* @return string ñòðîêà â ôîðìàòå data ñ ðàçâ¸ðíóòûìè øàáëîíàìè.
*/
public function redate($pl, $uid)
{
global $btl;
$i = 0;
if ($pl != '') {
$e = explode('|', $pl);
while ($i < count($e)) {
$f = explode('=', $e[$i]);
// $f[1] = $this->getdr(
// $f[1], [0 => 'lvl1', 1 => 'ts5', 2 => 'mpAll'], [
// 0 => $btl->users[$btl->uids[$uid]]['level'],
// 1 => $btl->stats[$btl->uids[$uid]]['s5'],
// 2 => $btl->stats[$btl->uids[$uid]]['mpAll'],
// ]
// );
$f[1] = $this->getDynamicInfo($f[1]);
if ($f[0] != '' && $f[1] != '') {
$e[$i] = implode('=', $f);
}
$i++;
}
$pl = implode('|', $e);
}
return $pl;
}
private function cancelEffects($effects_ids, $uid, Battle $btl)
{
$arr = explode(',', $effects_ids);
if (!is_array($arr) || empty($arr)) {
return;
}
foreach ($arr as $eid) {
if ($eid <= 0) {
continue;
}
$p = Db::getRow(
'select * from eff_users where uid = ? and v1 = ? and v2 = ? and `delete` = 0', [$uid, 'priem', $eid]
);
if (!$p['id']) {
continue;
}
$p['priem'] = Db::getRow('select * from priems where id = ?', [$eid]);
$btl->delPriem($p, $btl->users[$btl->uids[$uid]], 2);
}
}
/* uid - íà êîãî êàñòóåì
pr - id ïðèåìà
data - äàòà, åñëè -1, òî äîáàâëÿåì äàòó3
d2 - äîáàâëÿåì äàòó3
tm - âðåìÿ èñïîëüçîâàíèÿ, 77 - âå÷íî
h - êîë-âî "âå÷íûõ" õîäîâ
uu - id þçåðà êîòîðûé èñïîëüçîâàë
tp - òèï ïðèåìà
*/
/**
* @param int $uid íà êîãî êàñòóåì
* @param int $pr id ïðèåìà
* @param int|string $data äàòà, åñëè -1, òî äîáàâëÿåì äàòó3
* @param int $d2
* @param $tm
* @param int $h õîä
* @param int $uu id þçåðà êîòîðûé èñïîëüçîâàë
* @param $max
* @param $bj
* @param $tp
* @param $ch
* @param $rdt
* @param $tr_life_user
* @param $noupdatebtl
* @param $noplus
* @param $pname
* @return bool
*/
public function addPriem(
$uid,
$pr,
$data,
$d2,
$tm,
$h,
$uu,
$max,
$bj,
$tp = 0,
$ch = 0,
$rdt = 0,
$tr_life_user = 0,
$noupdatebtl = 0,
$noplus = 0,
$pname = null
) {
global $btl;
//$pl = mysql_fetch_assoc(mysql_query('SELECT * FROM `priems` WHERE `id` = ' . (int)$pr));
$pl = Db::getRow('select * from priems where id = ?', [$pr]);
$r = false;
if (!$pl['id']) {
return false;
}
if ($data == -1) {
$data = $this->redate($pl['date3'], $this->u->info['id']);
} elseif ($d2 == 1) {
$data .= '|' . $this->redate($pl['date3'], $this->u->info['id']);
}
$this->cancelEffects($pl['cancel_eff2'], $uid, $btl);
if ($max <= 0) {
return false;
}
if ($noplus == 0) {
if ($pl['zmu'] == 1) {
$num = Db::getRow(
'select * from eff_users where bj = ? and user_use = ? and uid = ? and `delete` = 0',
[$bj, $this->u->info['id'], $uid]
);
} else {
$num = Db::getRow(
'select * from eff_users where bj = ? and uid = ? and `delete` = 0',
[$bj, $uid]
);
}
}
if (isset($num['id']) && ($num['user_use'] != $this->u->info['id'] && $pl['zmu'] != 2)) {
// óäàëÿåì ýôôåêò
Db::sql(
'update eff_users set `delete` = unix_timestamp() where id = ?',
[$num['id']]
);
$i = 0;
while ($i < count($btl->stats[$btl->uids[$uid]]['effects'])) {
if ($btl->stats[$btl->uids[$uid]]['effects'][$i]['id'] == $num['id']) {
//îáíîâëÿåì
$btl->stats[$btl->uids[$uid]]['effects'][$i]['delete'] = time();
}
$i++;
}
unset($num);
}
if (!isset($num['id'])) {
$q = 'insert into eff_users (tr_life_user, bj, user_use, hod, v2, img2, id_eff, uid, name, data, overType, timeUse, v1) values (?,?,?,?,?,?,?,?,?,?,?,?,?)';
$image = !empty($pl['img']) ? $pl['img'] : $pl['id'];
$name = !empty($pname) ? $pname : $pl['name'];
$image .= '.gif';
Db::sql(
$q, [floor($tr_life_user), $bj, $uu, $h, $pl['id'], $image, 22, $uid, $name, $data, 0, $tm, 'priem']
);
$lid = Db::lastInsertId();
if ($lid) {
$r = true;
}
/* äîáàâëÿåì äàííûå ê $btl->eff */
if ($noupdatebtl == 0) {
$btl->stats[$btl->uids[$uid]] = $this->u->getStats($uid, 0);
}
} elseif ($num['x'] < $max) {
//Äîáàâëÿåì åùå è îáíîâëÿåì çàðÿäû
$num['x']++;
$num['hod'] = $h;
if ($data != -1 && $data != '' && $d2 == 2) {
$num['data'] .= '|' . $data;
Db::sql(
'update eff_users set x = x + 1, hod = ?, data = ? where id = ?',
[$h, $num['data'], $num['id']]
);
} else {
Db::sql(
'update eff_users set x = x + 1, hod = ? where id = ?',
[$h, $num['id']]
);
}
$r = true;
} else {
//îáíîâëÿåì çàðÿäû
$num['hod'] = $h;
if ($data != -1 && $data != '' && $d2 == 2) {
$num['data'] .= '|' . $data;
Db::sql("update eff_users set hod = ?, data = ? where id = ?", [$h, $num['data'], $num['id']]);
} else {
Db::sql(
'update eff_users set hod = ? where id = ?',
[$h, $num['id']]
);
}
$r = true;
}
if (isset($num['id'])) {
foreach ($btl->stats[$btl->uids[$uid]]['effects'] as $effect) {
if ($effect['id'] != $num['id']) {
continue;
}
$effect['data'] = $num['data'];
$effect['hod'] = $num['hod'];
$effect['x'] = $num['x'];
}
}
return $r;
}
/** Ïðåâðàùàåò ñòðîêó data ('a=1|b=2|c=3') èç ÁÄ â ìàññèâ [a=>1, b=>2, c=>3].
* @param $m
* @return array
*/
public function lookStatsArray($m)
{
$arr = json_decode(str_replace(['=', '|'], ['":', ',"'], '{"' . $m . '}'), true);
return $arr ?: [];
}
/** Ïðåâðàùàåò ìàññèâ [a=>1, b=>2, c=>3] â ñòðîêó data ('a=1|b=2|c=3') äëÿ ÁÄ.
* @param array $m
* @return string
*/
private function impStats(array $m)
{
$str = json_encode($m);
return $str ? str_replace(['":', ',"', '{"', '}'], ['=', '|'], $str) : '';
}
/**
* @param $data
* @param array $values
* @return string
*/
private function changeStatsData($data, array $values)
{
$arr = $this->lookStatsArray($data);
foreach ($values as $key => $value) {
$arr[$key] = $value;
}
return $this->impStats($arr);
}
public function magicRegen($ue, $hpmin, $tmp, $pl, $eff, $rp = 0, $dp = 0, $krituet = true, $dopyrn = 0)
{
global $btl;
$rr = [];
$uen = $ue['id'];
$usu = $eff['user_use'];
if ($eff['user_use'] < 1) {
$usu = $this->u->info['id'];
}
$k = $this->magKrit($ue['level'], $btl->stats[$btl->uids[$usu]]['mg' . $tmp]);
if (!$krituet) {
$k = 0;
}
$hpmin = $this->testPower($btl->stats[$btl->uids[$usu]], $btl->stats[$btl->uids[$uen]], $hpmin, $tmp, 2);
$hpmin = round($hpmin);
$dopyrn = $this->testPower($btl->stats[$btl->uids[$usu]], $btl->stats[$btl->uids[$uen]], $dopyrn, $tmp, 2);
$dopyrn = round($dopyrn);
if ($btl->users[$btl->uids[$uen]]['tactic7'] <= 0 && $dp == 0) {
$hpmin = 0;
$k = -1;
$dopyrn = 0;
}
if ($k == 1 && $hpmin != 0 && $krituet) {
//êðèò
$hpmin = $hpmin * 2;
} elseif ($k == -1 && $hpmin != 0) {
//ïðîìàõ
$hpmin = $hpmin / 2;
$dopyrn = $dopyrn / 2;
}
if ($hpmin < 1) {
$hpmin = 0;
} else {
$hpmin = rand(($hpmin * 0.97), $hpmin);
}
$hpmin += floor($dopyrn);
if (isset($btl->stats[$btl->uids[$uen]]['min_heal_proc'])) {
if ($btl->stats[$btl->uids[$uen]]['min_heal_proc'] > 100) {
$btl->stats[$btl->uids[$uen]]['min_heal_proc'] = 100;
}
$hpmin = round($hpmin / 100 * (100 + $btl->stats[$btl->uids[$uen]]['min_heal_proc']));
}
if ($btl->users[$btl->uids[$uen]]['tactic7'] > 0 && $dp == 0) {
//Îòíèìàåì òàêòèêè, åñëè ýòî âîçìîæíî
$btl->users[$btl->uids[$uen]]['tactic7'] -= $hpmin / $btl->stats[$btl->uids[$uen]]['hpAll'];
$btl->users[$btl->uids[$uen]]['tactic7'] = round($btl->users[$btl->uids[$uen]]['tactic7'], 2);
$btl->stats[$btl->uids[$uen]]['tactic7'] = $btl->users[$btl->uids[$uen]]['tactic7'];
if ($uen == $this->u->info['id']) {
$this->u->info['tactic7'] = $btl->users[$btl->uids[$uen]]['tactic7'];
$this->u->stats['tactic7'] = $btl->users[$btl->uids[$uen]]['tactic7'];
}
if ($btl->users[$btl->uids[$uen]]['tactic7'] < 0) {
$btl->users[$btl->uids[$uen]]['tactic7'] = 0;
}
}
$hp2 = floor($btl->stats[$btl->uids[$uen]]['hpNow'] + $hpmin);
if ($hp2 > $btl->stats[$btl->uids[$uen]]['hpAll']) {
$hpmin = floor($hp2 - $btl->stats[$btl->uids[$uen]]['hpAll']);
$hp2 = $btl->stats[$btl->uids[$uen]]['hpAll'];
} elseif ($hp2 < 0) {
$hp2 = 0;
}
$rr[0] = $hpmin; //óðîí
$rr[1] = $k; //òèï
/* ïðîâåðÿåì ïðèåìû çàùèòû */
//ïîëó÷àåì ìàññèâ ñ ïðèåìàìè ïðîòèâíèêà
$miny = 0; //íà ñêîëüêî åäåíèö óðîí áóäå ìåíüøå (çàùèòà ïðèåìà)
$minu = 0;
$sp1 = mysql_query(
'SELECT `e`.* FROM `eff_users` AS `e` WHERE `e`.`uid` = "' . $uen . '" AND `e`.`id_eff` = "22" AND `e`.`delete` = "0" AND `e`.`v1` = "priem" LIMIT 25'
);
while ($pl2 = mysql_fetch_assoc($sp1)) {
$pl2['priem'] = mysql_fetch_assoc(
mysql_query('SELECT * FROM `priems` WHERE `id` = "' . $pl2['v2'] . '" LIMIT 1')
);
if (isset($pl2['priem']['id'])) {
$dt1 = $this->lookStatsArray($pl2['priem']['date2']);
if (isset($dt1['yron_u2'])) {
$minu = $this->getdr(
$dt1['yron_u2'], [0 => 'lvl1', 1 => 'yr1', 2 => 'ts5', 3 => 'ts6'],
[0 => $btl->users[$btl->uids[$level]], 1 => $hpmin, 2 => 0, 3 => 0]
);
$miny -= $minu;
$hpmin += $minu;
$btl->delPriem($pl2, $btl->users[$btl->uids[$uen]]);
}
}
}
/* ïðîâåðÿåì ïðèåìû îñëàáëåíèÿ */
//îòíèìàåì ÍÐ
$btl->users[$btl->uids[$uen]]['hpNow'] = $hp2;
$btl->stats[$btl->uids[$uen]]['hpNow'] = $hp2;
mysql_query(
'UPDATE `stats` SET `hpNow` = ' . $hp2 . ',`tactic7` = ' . $btl->users[$btl->uids[$uen]]['tactic7'] . ' WHERE `id` = "' . $uen . '" LIMIT 1'
);
//çàíîñèì â ëîã áîÿ
$vLog =
'time1=' . time() .
'||s1=' . $this->u->info['sex'] .
'||t1=' . $this->u->info['team'] .
'||login1=' . $this->u->info['login'] .
'||s2=' . $btl->users[$btl->uids[$uen]]['sex'] .
'||t2=' . $btl->users[$btl->uids[$uen]]['team'] .
'||login2=' . $btl->users[$btl->uids[$uen]]['login'];
$mas1 = [
'time' => time(),
'battle' => $btl->info['id'],
'id_hod' => ($btl->hodID + 1),
'text' => '',
'vars' => $vLog,
'zona1' => '',
'zonb1' => '',
'zona2' => '',
'zonb2' => '',
'type' => '1',
];
if ($rp == 1) {
$mas1['id_hod']--;
}
$btl->takeExp($this->u->info['id'], ($hpmin * 0.33), $this->u->info['id'], $uen, true);
if ($hpmin > 0) {
$hpmin = '+' . ceil($hpmin);
} else {
$hpmin = '--';
}
$tco = [1 => '006699', 2 => '006699', 3 => '006699', 4 => '006699']; //íå êðèò
$tcl = [1 => 'A00000', 2 => '008080', 3 => '0000FF', 4 => 'A52A2A']; //íå êðèò
$tco = $tco[$tmp];
$tcl = $tcl[$tmp];
if ($k == 1) {
//êðèò
$tco = 'FF0000';
$tcl = 'FF0000';
} elseif ($k == -1) {
//ïðîìàõ
$tco = '979797';
$tcl = '979797';
}
$nmz = [
1 => [0 => 'îãíÿ', 1 => 'îãíåííàÿ'],
2 => [0 => 'âîçäóõà', 1 => 'ýëåêòðè÷åñêàÿ'],
3 => [0 => 'âîäû', 1 => 'âîäíàÿ'],
4 => [0 => 'çåìëè', 1 => 'çåìëÿíàÿ'],
];
$nmz = $nmz[$tmp];
if ($rp == 1) {
$sx = [0 => '', 1 => 'à'];
$mas1['text'] = '{tm1} Çàêëèíàíèå &quot;<b><font color=#' . $tcl . '>' . $pl['name'] . '</font></b>&quot; âîññòàíîâèëî çäîðîâüå ïåðñîíàæà {u2}. <b><font title=Òèï&nbsp;ðåãåíåðàöèè:&nbsp;' . $nmz[1] . ' color=#' . $tco . '>' . $hpmin . '</font></b> [' . ceil(
$hp2
) . '/' . $btl->stats[$btl->uids[$uen]]['hpAll'] . ']';
} else {
$mas1['text'] = '{tm1} {u1} {1x16x0} çàêëèíàíèå &quot;<b><font color=#' . $tcl . '>' . $pl['name'] . '</font></b>&quot; è âîññòàíîâèë çäîðîâüå ïåðñîíàæà {u2} ìàãèåé ' . $nmz[0] . '. <b><font title=Òèï&nbsp;ðåãåíåðàöèè:&nbsp;' . $nmz[1] . ' color=#' . $tco . '>' . $hpmin . '</font></b> [' . ceil(
$hp2
) . '/' . $btl->stats[$btl->uids[$uen]]['hpAll'] . ']';
}
$btl->add_log($mas1);
$pz[(int)$id] = 1;
return $rr;
}
/** Ïðîâåðêà åñòü ëè íà ïåðñîíàæå ïðèçðà÷íûå çàùèòû äëÿ ðàññ÷¸òà óðîíà ÷åðåç magicAttack
* @return array
*/
private function hasGhostDefence($uid)
{
$def = [
'all' => false,
self::FIRE => false,
self::AIR => false,
self::EARTH => false,
self::WATER => false,
];
$priems = Db::getRows('select v2 from eff_users where uid = ? and v2 in (141, 142, 144, 145, 146)', [$uid]);
foreach ($priems as $priem) {
if ($priem['v2'] == 141) {
$def['all'] = true;
}
if ($priem['v2'] == 142) {
$def[self::FIRE] = true;
}
if ($priem['v2'] == 144) {
$def[self::AIR] = true;
}
if ($priem['v2'] == 145) {
$def[self::WATER] = true;
}
if ($priem['v2'] == 146) {
$def[self::EARTH] = true;
}
}
return $def;
}
/**
* Íîâàÿ ôóíêöèÿ ìàãè÷åñêîãî çàêëèíàíèÿ ñ ïðè¸ìà.
* Ðàáîòàåò ñ ÷èñëîâûìè ïðè¸ìàìè â ïàïêå [priem].
* @param int $attackerId êòî èñïîëüçóåò ïðè¸ì
* @param int $defenderId íà êîãî èñïîëüçóåò ïðè¸ì
* @param float $damage áàçîâûé óðîí ïðè¸ìà
* @param string $damageType òèï óðîíà (ñòèõèÿ?) ïðèõîäèò ñòðîêîé, è êîíâåðòèðóåòñÿ ôóíêöèåé.
* @param bool $hasCritical ôëàã, ÷òî ïðè¸ì ÌÎÆÅÒ êðèòîâàòü
* @return array [0|damage] int óðîí, [1|crit] bool áûë ëè êðèò, [2|miss] bool áûë ëè ïðîìàõ, [3|miss_type] int òèï ïðîìàõà (âñåãäà = 2).
* @author Insallah
*/
public function magicAttack(Battle $btl, $attackerId, $defenderId, $damage, $damageType, $hasCritical = false)
{
// Íå òàê ïàðøèâî êàê ïðîøëàÿ, íî âñ¸ åù¸ ïàðøèâî. Òåïåðü õîòü ÷òî-òî ïîíÿòü ìîæíî.
$dmgRuNames = [
self::FIRE => 'îãîíü',
self::WATER => 'âîäà',
self::AIR => 'âîçäóõ',
self::EARTH => 'çåìëÿ',
];
if (in_array($damageType, array_keys($dmgRuNames))) {
$damageType = $dmgRuNames[$damageType];
}
// Ìîùü.
// pm# = Ìô. ìîùíîñòè ìàãèè îïðåäåëåííîãî òèïà
// m11 = Ìô. ìîùíîñòè ìàãèè ñòèõèé
// m11a = Ìô. ìîùíîñòè ìàãèè
// ÎÊÀÇÛÂÀÅÒÑß [pm# = m11 + m11a] ãäå-òî âûøå ïî êîäó!
$power = $btl->stats[$btl->uids[$attackerId]]['pm' . $this->mname[$damageType]];
// Ïîäàâëåíèå â ïðîöåíòàõ.
$suppression = 0;
$suppression += $btl->stats[$btl->uids[$attackerId]]['pzm'];
// Óÿçâèìîñòü ìàãèè ñòèõèé, èç ïðè¸ìà 250.
$suppression += $btl->stats[$btl->uids[$attackerId]]['yzm'];
// Ñêîëüêî ó èñïîëüçóþùåãî óìåíèé ÷èñëîì.
$skills = $btl->stats[$btl->uids[$attackerId]]['mg' . $this->mname[$damageType]];
// Çàùèòà öåëè ÷èñëîì
// zm# = Çàùèòà îò ìàãèè îïðåäåëåííîãî òèïà
// zm = Çàùèòà îò ìàãèè ñòèõèé
// zma = Çàùèòà îò ìàãèè
// ÎÊÀÇÛÂÀÅÒÑß [zm# = zm + zma] ãäå-òî âûøå ïî êîäó!
$defence = $btl->stats[$btl->uids[$defenderId]]['zm' . $this->mname[$damageType]];
// Ìèíèìóì óìåíèé äëÿ 100% óñïåõà ïðè¸ìà.
// Ó 8 åêðî-ìàãà ñî ñòàðòà 20, ýòî î÷åíü ìíîãî: 8 áü¸ò 10 áåç ïðîìàõà.
$requiredSkills = $btl->users[$btl->uids[$defenderId]]['level'] * 2;
// ׸ðòîâî "Ñëåäóþùèé êàñò áóäåò êðèòè÷åñêèì".
$isGarantCrit = $btl->stats[$btl->uids[$attackerId]]['acestar'] > 0;
// Ïîäàâëÿåì çàùèòó, ïîíèæàÿ ÷èñëî íà ïðîöåíò ïîäàâëåíèÿ.
$supressedDefence = Math::addPercent($defence, -min($suppression, 100));
// Óðîí çàâèñèò îò óìåíèé è óðîâíÿ ïðîòèâíèêà.
$damage *= $skills - $requiredSkills;
// Óâåëè÷èâàåì óðîí, ïîâûøàÿ ÷èñëî íà ìîùü åñëè óðîí > 0.
$poweredDamage = $damage > 0 ? $damage + $power : 0;
// Øàíñ êðèòà ðàâåí óðîâíþ ìàãè÷åñêîãî íàâûêà
$isCritical = $hasCritical && $skills >= mt_rand(0, 100);
if ($isGarantCrit) {
$isCritical = true;
Db::sql(
'delete from eff_users where uid = ? and `delete` = 0 and data like ?',
[$attackerId, '%add_acestar%']
);
unset($q);
}
if ($skills >= $requiredSkills || $isCritical) {
$isHit = true;
} else {
$isCritical = false;
$missChance = 3 * ($requiredSkills - $skills);
$isHit = mt_rand(0, 100) > $missChance;
}
// Äëÿ ñîâìåñòèìîñòè. Ñòàðàÿ ôóíêöèÿ âîçâðàùàåò ýòî çíà÷åíèå, âäðóã îíî ãäå-òî èñïîëüçóåòñÿ.
$pType = 0;
if ($isHit) {
// Óðîí = Ïîâðåæäåíèÿ - Çàùèòà, íî íå ìåíüøå 0. Îêðóãëåíî äî öåëûõ.
//$finalDamage = max(round(Math::addPercent($poweredDamage, -$supressedDefence)), 0);
$finalDamage = $poweredDamage - $supressedDefence;
if ($isCritical) {
$finalDamage *= 2;
}
} else {
$finalDamage = 0;
// Äëÿ ñîâìåñòèìîñòè. Ñòàðàÿ ôóíêöèÿ âîçâðàùàåò ýòî çíà÷åíèå, âäðóã îíî ãäå-òî èñïîëüçóåòñÿ.
$pType = 2;
}
// Ïðèçðà÷êè, ðåæóò êîíå÷íûé óðîí ïîñëå âû÷åòà çàùèòû.
$ghostDefences = $this->hasGhostDefence($defenderId);
if ($ghostDefences['all']) {
$finalDamage /= 4;
}
// Êîñòûëü äëÿ ïðèçðà÷åê. Êîãäà âûçîâû ðóññêèõ ñòèõèé óáåðóòñÿ, áóäåò íå íóæåí.
if (in_array($damageType, $dmgRuNames)) {
$damageType = array_search($damageType, $dmgRuNames);
}
if ($ghostDefences[$damageType]) {
$finalDamage /= 2;
}
$finalDamage = max(round($finalDamage), 0);
// Äëÿ îòëàäêè.
if ($btl->users[$btl->uids[$attackerId]]['admin'] > 0) {
$s = "Ïîäàâëåíèå çàùèòû: $suppression%, Áîíóñ óðîíà: $power, Íàâûêè: $skills,
<br> Óñèëåíèå óðîíà îò óðîâíÿ è ñêèëëà: damage x ($skills - $requiredSkills)<br> $damageType
Åãî Çàùèòà: ($defence -$suppression%) = $supressedDefence |
Ìîé Óðîí: ($damage +$power) = $poweredDamage<br>
Ìîé Óäàð: ($poweredDamage -$supressedDefence) = $finalDamage";
$s .= $isCritical ? ' (êðèò *2)' : '';
echo "<div style='background-color: #C5C5C5; border: 1px solid coral; margin-top: 15px;'>$s</div>";
}
// !isHit ïîòîìó ÷òî ïðîøëàÿ ôóíêóöèÿ âîçâðàùàëà Ïðîìàõ.
// pType íè íà ÷òî íå âëèÿåò, = 0 è ïðîñòî ñòàíîâèòñÿ = 2 ïðè ïðîìàõå. Çà÷åì - çàãàäêà.
// -damage ïîòîìó ÷òî ãäå-òî äàëüøå êîä ðàçâîðà÷èâàåò ðåçóëüòàò ìåíÿÿ åìó çíàê.
return [
(int)$finalDamage,
$isCritical,
!$isHit,
$pType, // äëÿ ñîâìåñòèìîñòè
'damage' => (int)$finalDamage,
'crit' => $isCritical,
'miss' => !$isHit,
'miss_type' => $pType,
];
}
/** Îñòàâëåíà äëÿ ñîâìåñòèìîñòè. Íà íå¸ ññûëàåòñÿ êó÷à âñåãî. */
public function magatack($u1, $u2, $yron, $type, $krit)
{
global $btl;
return $this->magicAttack($btl, $u1, $u2, $yron, $type, $krit);
}
public function magatackfiz($u1, $u2, $yron, $type, $krit, $ymelki)
{
global $btl;
$cof_mag = [
0 => 250,
1 => 250,
2 => 250,
3 => 250,
4 => 250,
5 => 250,
6 => 250,
7 => 250,
8 => 250,
9 => 300,
10 => 360,
11 => 475,
12 => 520,
13 => 625,
14 => 750,
15 => 895,
16 => 1075,
17 => 1290,
18 => 1550,
19 => 1860,
20 => 2230,
21 => 2675,
];
$r = $yron;
//
if (!isset($ymelki) || $ymelki == '0') {
$ymelki = $type;
}
//
$prm = [
'ym' => $btl->stats[$btl->uids[$u1]]['mg' . $this->mname[$ymelki]], //óìåëêè (ìàãè÷åñêèå óìåëêè)
'y' => $btl->stats[$btl->uids[$u1]]['a' . $this->mname[$ymelki]], //óìåëêè
'yv' => 0, //óìåíèÿ, çíà÷åíèå êîô.
'max_krit' => 0 //âåðîÿòíîñòü êðèòà
];
//
// (óðîâåíü öåíè)*2 - 7 - ìèíèìàëüíîå óìåëîê, ÷òîáû íå áûëî ïðîìàõîâ
/*
Äëÿ ìàãèè Ñâåòà/Òüìû ïî ôîðìóëå: Óðîâåíü Öåëè * 2 9
êàæäàÿ óìåëêà âûøå ýòîé íîðìû óâåëè÷èâàåò ìàã êðèò íà 3%. íî íå áîëüøå 30%
*/
//Ðàññ÷åò óðîíà îò ïðèåìà
/*
b - áàçîâûé óðîí
m - ìîùü
z - çàùèòà öåëè [åä.]
p - ïîäàâëåíèå [åä.]
k - êîýôôèöèåíò ; k=250 äëÿ 8êè, k=300 äëÿ 9êè è ò.ä. +20% íà óðîâåíü
*/
$prm['b'] = $r; //áàçîâûé óðîí
$prm['m'] = $btl->stats[$btl->uids[$u1]]['pa' . $this->mname[$type]]; //ìîùü
$prm['z'] = $btl->stats[$btl->uids[$u2]]['za' . $this->mname[$type]]; //çàùèòà öåëè (åä.)
$prm['p'] = $btl->stats[$btl->uids[$u1]]['pza' . $this->mname[$type]]; //ïîäàâëåíèå (åä.)
$prm['k'] = $cof_mag[$btl->users[$btl->uids[$u1]]['level']]; //êîýôôèöåíò
//
if ($prm['p'] * 10 > $prm['k']) {
$prm['p'] = floor($prm['k'] / 10);
}
//
$r = $prm['b'] * (1 + $prm['m'] / 100) * pow(2, (($prm['p'] * 10 - $prm['z']) / $prm['k']));
if ($r < floor($prm['b'] * 0.2)) {
$r = floor($prm['b'] * 0.2);
} elseif ($r > floor($prm['b'] * 10)) {
$r = floor($prm['b'] * 10);
}
//
//$prm['y'] -= 5;
if ($type < $this->mname[$type]) {
$prm['yv'] = ($btl->users[$btl->uids[$u2]]['level'] * 2 - 7);
} else {
$prm['yv'] = ($btl->users[$btl->uids[$u2]]['level'] * 2 - 9);
}
//
if ($prm['y'] >= $prm['yv'] || (isset($this->mname[$ymelki]) && $prm['ym'] >= $prm['yv'])) {
if ($krit == 1) {
if (isset($this->mname[$ymelki])) {
$prm['max_krit'] = 3 * ($prm['ym'] - $prm['yv']);
} else {
$prm['max_krit'] = 3 * ($prm['y'] - $prm['yv']);
}
//echo '[Magical crit: '.$prm['max_krit'].'%]';
if ($prm['max_krit'] < 0) {
$prm['max_krit'] = 0;
} elseif ($prm['max_krit'] > 30) {
$prm['max_krit'] = 30;
}
//$prm['max_krit'] = round($prm['max_krit']/2);
//Êðèò âîçìîæåí
if (rand(0, 100) <= $prm['max_krit']) {
$krit = true;
} else {
$krit = false;
}
} else {
$krit = false;
}
$promah = false;
} else {
$krit = false;
//Âåðîÿòíîñòü ïðîìîõà
$prm['promah'] = 3 * ($prm['yv'] - $prm['ym']);
if ($prm['promah'] < 0) {
$prm['promah'] = 0;
} elseif ($prm['promah'] > 30) {
$prm['promah'] = 30;
}
if (rand(0, 100) <= $prm['promah']) {
$promah = true;
} else {
$promah = false;
}
}
//
if ($krit) {
$r = $r * 2;
$promah_type = 0;
} elseif ($promah) {
$r = rand(1, floor($r / 4));
$promah_type = 1;
if (rand(0, 100) < 50) {
$r = 0;
$promah_type = 2;
}
}
//
unset($prm);
//
return [floor($r), $krit, $promah, $promah_type];
}
//äëÿ ïàïêè priems
public function magicAtack(
$ue,
$hpmin,
$tmp,
$pl,
$eff,
$rp = 0,
$mxx = 0,
$fiz = 0,
$nomf = 0,
$krituet = true,
$heal = 0,
$namenew = null
) {
$trawm_off = false;
global $btl;
if ($namenew != null) {
$pl['name'] = $namenew;
}
$rr = [];
$nhpmin = $hpmin;
$uen = $ue['id'];
$usu = $eff['user_use'];
if ($eff['user_use'] < 1) {
$usu = $this->u->info['id'];
}
if ($nomf == 0) {
$k = $this->magKrit($ue['level'], $btl->stats[$btl->uids[$usu]]['mg' . $tmp]);
if (!$krituet) {
$k = 0;
}
if ($fiz == 0) {
//ìàãè÷åñêèé óðîí
$hpmin = $this->testPower(
$btl->stats[$btl->uids[$usu]], $btl->stats[$btl->uids[$uen]], $hpmin, $tmp,
2
);
} else {
//ôèçè÷åñêèé óðîí
$wAp = $btl->stats[$btl->uids[$usu]]['pa' . $tmp . ''];
$wAp += $btl->stats[$btl->uids[$usu]]['m10'];
$wAp -= $btl->stats[$btl->uids[$uen]]['antpa' . $tmp . ''] * 1.75;
$wAp -= $btl->stats[$btl->uids[$uen]]['antm10'] * 1.75;
$hpmin += ceil((0.01 + $hpmin / 100) * (0.01 + 0.98 * $wAp)) - 1;
$hpmin -= round(
$hpmin / 100 * (35 * ($btl->stats[$btl->uids[$uen]]['za'] + $btl->stats[$btl->uids[$uen]]['za' . $tmp]) / 1200)
);
$hpmin = round($hpmin);
if (isset($btl->stats[$btl->uids[$uen]]['zaproc']) || isset($btl->stats[$btl->uids[$uen]]['za' . $fiz . 'proc'])) //çàùèòà îò óðîíà (ïðèçðà÷êè)
{
$hpmin = floor(
$hpmin / 100 * (100 - $btl->stats[$btl->uids[$uen]]['zaproc'] - $btl->stats[$btl->uids[$uen]]['za' . $fiz . 'proc'])
);
if ($hpmin < 0) {
$hpmin = 0;
}
}
}
}
$hpmin = round($hpmin);
if ($k == 1 and $krituet) {
//êðèò
$hpmin = $hpmin * 2;
} elseif ($k == -1) {
//ïðîìàõ
$hpmin = $hpmin / 2;
}
if ($hpmin < $nhpmin * 0.2) {
$hpmin = $nhpmin * 0.2;
}
if ($hpmin < 1) {
$hpmin = 0;
} else {
if ($nomf == 0) {
$hpmin = rand(($hpmin * 0.97), $hpmin);
}
}
if ($mxx > 0 && $hpmin > $mxx) {
if ($k == 0) {
$hpmin = $mxx;
} elseif ($k == 1 && $hpmin / 2 > $mxx) {
$hpmin = $mxx * 2;
}
}
$rr[0] = $hpmin; //óðîí
$rr[1] = $k; //òèï
/* ïðîâåðÿåì ïðèåìû çàùèòû */
//ïîëó÷àåì ìàññèâ ñ ïðèåìàìè ïðîòèâíèêà
$miny = 0; //íà ñêîëüêî åäåíèö óðîí áóäå ìåíüøå (çàùèòà ïðèåìà)
$sp1 = mysql_query(
'SELECT `e`.* FROM `eff_users` AS `e` WHERE `e`.`uid` = "' . $uen . '" AND `e`.`id_eff` = "22" AND `e`.`delete` = "0" AND `e`.`v1` = "priem" LIMIT 25'
);
while ($pl2 = mysql_fetch_assoc($sp1)) {
$pl2['priem'] = mysql_fetch_assoc(
mysql_query('SELECT * FROM `priems` WHERE `id` = "' . $pl2['v2'] . '" LIMIT 1')
);
if (isset($pl2['priem']['id'])) {
$dt1 = $this->lookStatsArray($pl2['priem']['date2']);
if (isset($dt1['yron_u2'])) {
$minu = $this->getdr(
$dt1['yron_u2'], [0 => 'lvl1', 1 => 'yr1', 2 => 'ts5', 3 => 'ts6'],
[0 => $btl->users[$btl->uids[$level]], 1 => $hpmin, 2 => 1, 3 => 0]
);
$miny -= $minu;
$hpmin += $minu;
if (isset($dt1['rzEndMg']) && $dt1['rzEndMg'] == 1) {
$btl->delPriem($pl2, $btl->users[$btl->uids[$uen]]);
}
} elseif (isset($dt1['rzEndMg']) && $dt1['rzEndMg'] == 1) {
$btl->delPriem($pl2, $btl->users[$btl->uids[$uen]]);
}
}
}
$hpmin = $btl->testPogB($uen, $hpmin);
$hp2 = floor($btl->stats[$btl->uids[$uen]]['hpNow'] - $hpmin);
if ($btl->stats[$btl->uids[$usu]]['yrnhealmpprocmg' . $tmp] > 0 && $fiz == 0) {
//×àñòü óðîíà âîññòàâíàâëèâàåò ìàíó
$btl->stats[$btl->uids[$usu]]['mpNow'] += round(
$hpmin / 100 * $btl->stats[$btl->uids[$usu]]['yrnhealmpprocmg' . $tmp]
);
//if($btl->stats[$btl->uids[$usu]]['mpNow'] > $btl->stats[$btl->uids[$usu]]['mpAll']) {
//$btl->stats[$btl->uids[$usu]]['mpNow'] = $btl->stats[$btl->uids[$usu]]['mpAll'];
//}
$btl->users[$btl->uids[$usu]]['mpNow'] = $btl->stats[$btl->uids[$usu]]['mpNow'];
if ($usu == $this->u->info['id']) {
$this->u->info['mpNow'] = $btl->stats[$btl->uids[$usu]]['mpNow'];
$this->u->stats['mpNow'] = $btl->stats[$btl->uids[$usu]]['mpNow'];
}
}
if ($hp2 < 0) {
$hp2 = 0;
} elseif ($hp2 > $btl->stats[$btl->uids[$uen]]['hpAll']) {
$hp2 = $btl->stats[$btl->uids[$uen]]['hpAll'];
}
$btl->stats[$btl->uids[$uen]]['last_hp'] = -floor($hpmin);
if ($heal != 0) {
if ($heal == -1) {
//õèë íà òåêóùèé óðîí ñ ó÷åòîì ìô
$btl->stats[$btl->uids[$eff['user_use']]]['hpNow'] += $hpmin;
if ($btl->stats[$btl->uids[$eff['user_use']]]['hpNow'] < 0) {
$btl->stats[$btl->uids[$eff['user_use']]]['hpNow'] = 0;
} elseif ($btl->stats[$btl->uids[$eff['user_use']]]['hpNow'] > $btl->stats[$btl->uids[$eff['user_use']]]['hpAll']) {
$btl->stats[$btl->uids[$eff['user_use']]]['hpNow'] = $btl->stats[$btl->uids[$eff['user_use']]]['hpAll'];
}
if ($eff['user_use'] == $this->u->info['id']) {
$this->u->stats['hpNow'] = $btl->stats[$btl->uids[$eff['user_use']]]['hpNow'];
}
$btl->users[$btl->uids[$eff['user_use']]]['hpNow'] = $btl->stats[$btl->uids[$eff['user_use']]]['hpNow'];
mysql_query(
'UPDATE `stats` SET `hpNow` = "' . $btl->stats[$btl->uids[$eff['user_use']]]['hpNow'] . '" WHERE `id` = "' . $eff['user_use'] . '" LIMIT 1'
);
} else {
//õèë íà êîíêðåòíîå ÷èñëî
}
}
/* ïðîâåðÿåì ïðèåìû îñëàáëåíèÿ */
//îòíèìàåì ÍÐ
$btl->users[$btl->uids[$uen]]['hpNow'] = $hp2;
$btl->stats[$btl->uids[$uen]]['hpNow'] = $hp2;
if ($uen == $this->u->info['id']) {
$this->u->stats['hpNow'] = $hp2;
}
// òÿæ òðàâìà äëÿ êðîâàâûõ
if ($btl->info['type'] == 99 and $hp2 == 0 and !$trawm_off) {
//$eff['user_use']
//$sp1 = mysql_query('SELECT `e`.* FROM `eff_users` AS `e` WHERE `e`.`uid` = "'.$uen.'" AND `e`.`id_eff` = "22" AND `e`.`delete` = "0" AND `e`.`v1` = "priem" LIMIT 25');
$trawm_off = true;
//$at[2][$i]['ttravm']='ïîëó÷èë <font color=red><b>Òÿæåëóþ òðàâìó</b></font>.';
$btl->addTravm($btl->users[$btl->uids[$uen]]['id'], 3, $btl->users[$btl->uids[$eff['user_use']]]['level']);
}
$upd = mysql_query(
'UPDATE `stats` SET `hpNow` = ' . $hp2 . ',`last_hp` = "' . $btl->stats[$btl->uids[$uen]]['last_hp'] . '" WHERE `id` = "' . $uen . '" LIMIT 1'
);
//çàíîñèì â ëîã áîÿ
$vLog = 'time1=' . time(
) . '||s1=' . $btl->users[$btl->uids[$usu]]['sex'] . '||t1=' . $btl->users[$btl->uids[$usu]]['team'] . '||login1=' . $btl->users[$btl->uids[$usu]]['login'] . '||s2=' . $btl->users[$btl->uids[$uen]]['sex'] . '||t2=' . $btl->users[$btl->uids[$uen]]['team'] . '||login2=' . $btl->users[$btl->uids[$uen]]['login'] . '';
$mas1 = [
'time' => time(),
'battle' => $btl->info['id'],
'id_hod' => ($btl->hodID + 1),
'text' => '',
'vars' => $vLog,
'zona1' => '',
'zonb1' => '',
'zona2' => '',
'zonb2' => '',
'type' => '1',
];
if ($rp > 0) {
$mas1['id_hod']--;
}
$hpminkrit = 0;
if ($k == 1) {
$hpminkrit = $hpmin;
}
$btl->addNewStat(
[
'battle' => $this->u->info['battle'],
'uid1' => $this->u->info['id'],
'uid2' => $uen,
'time' => time(),
'type' => 0,
'a' => '10000',
'b' => 0,
'type_a' => 1,
'type_b' => 0,
'ma' => 1,
'mb' => 1,
'yrn' => $hpmin,
'yrn_krit' => $hpminkrit,
'tm1' => $this->u->info['team'],
'tm2' => $btl->users[$btl->uid[$uen]]['team'],
]
);
$btl->takeExp($this->u->info['id'], $hpmin, $usu, $uen);
if ($hpmin > 0) {
$hpmin = '-' . ceil($hpmin);
} else {
$hpmin = '--';
}
$tco = [
1 => '006699',
2 => '006699',
3 => '006699',
4 => '006699',
5 => '006699',
6 => '006699',
7 => '006699',
]; //íå êðèò
$tcl = [
1 => 'A00000',
2 => '008080',
3 => '0000FF',
4 => 'A52A2A',
5 => '006699',
6 => '006699',
7 => '006699',
]; //íå êðèò
$tco = $tco[$tmp];
$tcl = $tcl[$tmp];
if ($k == 1) {
//êðèò
$tco = 'FF0000';
$tcl = 'FF0000';
} elseif ($k == -1) {
//ïðîìàõ
$tco = 'CCCCCC';
$tcl = 'CCCCCC';
}
$nmz = [
1 => [0 => 'îãíÿ', 1 => 'îãíåííûé'],
2 => [0 => 'âîçäóõà', 1 => 'ýëåêòðè÷åñêèé'],
3 => [0 => 'âîäû', 1 => 'õîëîä'],
4 => [0 => 'çåìëè', 1 => 'çåìëÿíîé'],
5 => [0 => 'Ñâåò', 1 => 'Ñâåò'],
6 => [0 => 'Òüìà', 1 => 'Òüìà'],
7 => [0 => 'Ñåðàÿ&nbsp;ìàãèÿ', 1 => 'Ñåðàÿ&nbsp;ìàãèÿ'],
];
$nmz = $nmz[$tmp];
if ($fiz > 0) {
$nmz = [
1 => [0 => ', êîëþùàÿ àòàêà , ', 1 => 'êîëþùèé'],
2 => [0 => ', ðóáÿùàÿ àòàêà , ', 1 => 'ðóáÿùèé'],
3 => [0 => ', äðîáÿùàÿ àòàêà , ', 1 => 'äðîáÿùèé'],
4 => [0 => ', ðåæóùàÿ àòàêà , ', 1 => 'ðåæóùèé'],
];
$nmz = $nmz[$fiz];
}
if ($rp == 1) {
if ($k == 0) {
$tcl = '000000';
$tco = '008000';
}
$sx = [0 => '', 1 => 'à'];
$mas1['text'] = '{tm1} {u2} óòðàòèë' . $sx[$btl->users[$btl->uids[$uen]]['sex']] . ' çäîðîâüå îò &quot;<b><font color=#' . $tcl . '>' . $pl['name'] . '</font></b>&quot;. <b><font title=Òèï&nbsp;óðîíà:&nbsp;' . $nmz[1] . ' color=#' . $tco . '>' . $hpmin . '</font></b> [' . ceil(
$hp2
) . '/' . $btl->stats[$btl->uids[$uen]]['hpAll'] . ']';
} else {
if ($fiz == 1) {
$mas1['text'] = '{tm1} {u1} {1x16x0} ïðèåì &quot;<b><font color=#' . $tcl . '>' . $pl['name'] . '</font></b>&quot; è ïîðàçèë {u2}. <b><font title=Òèï&nbsp;óðîíà:&nbsp;' . $nmz[1] . ' color=#' . $tco . '>' . $hpmin . '</font></b> [' . ceil(
$hp2
) . '/' . $btl->stats[$btl->uids[$uen]]['hpAll'] . ']';
} else {
$mas1['text'] = '{tm1} {u1} {1x16x0} çàêëèíàíèå &quot;<b><font color=#' . $tcl . '>' . $pl['name'] . '</font></b>&quot; è ïîðàçèë ìàãèåé ' . $nmz[0] . ' {u2}. <b><font title=Òèï&nbsp;óðîíà:&nbsp;' . $nmz[1] . ' color=#' . $tco . '>' . $hpmin . '</font></b> [' . ceil(
$hp2
) . '/' . $btl->stats[$btl->uids[$uen]]['hpAll'] . ']';
}
}
$btl->add_log($mas1);
$pz[(int)$id] = 1;
return $rr;
}
private function testActiv($id)
{
$r = 0;
if (
$this->u->info['admin'] > 0 ||
$this->u->info['nadmin'] > 0 ||
$this->u->info['id'] > 0) {
$r = 1;
} else {
$tst = $this->u->testAction(
'`uid` = "' . $this->u->info['id'] . '" AND `time` < ' . time(
) . ' AND `vars` = "read" AND `vals` = "' . $id . '" LIMIT 1',
1
);
if (isset($tst['id'])) {
$r = 1;
}
}
return $r;
}
private function testRazmenOldUser($u2, $u1, $plid)
{
global $btl, $u;
$r = 0;
//Óðîâåíü -ïðîòèâíèêà- íèæå óðîâíÿ -öåëè-
if ($btl->users[$btl->uids[$u2]]['id'] != $this->u->info['id']) {
if ($btl->users[$btl->uids[$u1]]['level'] < $btl->users[$btl->uids[$u2]]['level']) {
$r = 1;
echo '<div style="color: red; font-weight: bold; text-align: center;">Íåëüçÿ êàñòîâàòü ÷åðåç ñëàáîãî ïðîòèâíèêà â ñèëüíîãî</div>';
} elseif ($btl->users[$btl->uids[$u1]]['bot'] > 0 && $btl->users[$btl->uids[$u2]]['bot'] == 0) {
echo '<div style="color: red; font-weight: bold; text-align: center;">Íåëüçÿ êàñòîâàòü ÷åðåç ìîíñòðîâ èëè çâåðÿ</div>';
$r = 1;
} elseif (
$btl->users[$btl->uids[$u1]]['id'] != $btl->users[$btl->uids[$u2]]['id'] &&
!in_array($plid, [35, 63, 64, 65, 66, 85, 86, 87, 88, 89, 90, 104, 105, 106, 107, 134, 135, 136, 137])
) //Àòàêà â òåìíóþ 90,89,88,87,86,85,35
{
$this->addPriem(
$this->u->info['id'], '344', 'add_m11=-' . round($this->u->stats['m11'] * 75 / 100), 1, 77, 1,
$this->u->stats['id'], 3, 'òüìà', 0, 0, 1
); //ÒÓÒ ïîíèæåíèå óðîíà ïðè óðîíå ÷åðåç ïåðñîíàæà
}
}
return $r;
}
public function testDie($u1)
{
global $btl;
//Ïåðñîíàæ 1 ïîãèá îò ðóê ïåðñîíàæ 2
$btl->spaCheck($btl->stats[$btl->uids[$u1]]['id']);
}
public function pruse($id)
{
global $btl;
$u = $this->u; // Äëÿ ïðèñîåäèÿíåìûõ ôàéëîâ.
if ($id == 100500 && $this->u->info['animal'] > 0) {
$use_lst = $this->u->testAction(
'`uid` = "' . $this->u->info['id'] . '" AND `vars` = "animal_use' . $btl->info['id'] . '" LIMIT 1',
1
);
if (!isset($use_lst['id'])) {
$a = mysql_fetch_assoc(
mysql_query(
'SELECT * FROM `users_animal` WHERE `uid` = "' . $this->u->info['id'] . '" AND `id` = "' . $this->u->info['animal'] . '" AND `pet_in_cage` = "0" AND `delete` = "0" LIMIT 1'
)
);
if ($this->u->stats['hpNow'] < 1) {
echo 'Âû íå ìîæåòå âûïóñòèòü çâåðÿ, âû ïîòåðÿëè âñå ÍÐ';
} elseif (isset($a['id']) && $a['eda'] < 1) {
echo 'Âû íå íàêîðìèëè çâåðÿ...';
} elseif (isset($a['id'])) {
//Äîáàâëÿåì çâåðÿ â áîé
$tp = [
1 => 'Êîò',
2 => 'Ñîâà',
3 => 'Ñâåòëÿê',
4 => '×åðòÿêà',
5 => 'Ïåñ',
6 => 'Ñâèí',
7 => 'Äðàêîí',
];
$id = mysql_fetch_assoc(
mysql_query(
'SELECT `id` FROM `test_bot` WHERE `login` = "' . $tp[$a['type']] . ' [' . $a['level'] . ']" LIMIT 1'
)
);
if (isset($id['id']) && $btl->info['type'] != 500) {
$b = $this->u->addNewbot($id['id'], null, null);
if ($b > 0 && $b) {
$a['eda'] -= 4;
if ($a['eda'] < 0) {
$a['eda'] = 0;
}
$vLog = 'time1=' . time(
) . '||s1=' . $this->u->info['sex'] . '||t1=' . $this->u->info['team'] . '||login1=' . $this->u->info['login'] . '';
$mas1 = [
'time' => time(),
'battle' => $btl->info['id'],
'id_hod' => $btl->hodID,
'vars' => $vLog,
'zona1' => '',
'zonb1' => '',
'zona2' => '',
'zonb2' => '',
'type' => '1',
];
$sex = $this->u->info['sex'] === 1 ? 'a' : '';
$mas1['text'] = "{tm1} {u1} âûïóñòèë$sex çâåðÿ &quot;<b>" . $a['name'] . '&quot;</b>';
$btl->add_log($mas1);
mysql_query(
'UPDATE `users` SET `login` = "' . $a['name'] . ' (çâåðü ' . $this->u->info['login'] . ')",`obraz` = "' . $a['obraz'] . '.gif",`battle` = "' . $btl->info['id'] . '" WHERE `id` = "' . $b['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `stats` SET `team` = "' . $this->u->info['team'] . '" WHERE `id` = "' . $b['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `users_animal` SET `eda` = "' . $a['eda'] . '" WHERE `id` = "' . $a['id'] . '" LIMIT 1'
);
$this->u->addAction(time(), 'animal_use' . $btl->info['id'], $a['level']);
} else {
echo 'Íå óäàëîñü âûïóñòèòü çâåðÿ...';
}
} else {
//Áîò íå íàéäåí
echo '<br>Íå óäàëîñü âûïóñòèòü çâåðÿ - îí áîèòñÿ...';
}
} else {
//çâåðü íå íàéäåí
echo 'Ó Âàñ íåò çâåðÿ ...';
}
} else {
//çâåðü óæå âûïóùåí
echo 'Âû óæå âûïóñêàëè çâåðÿ â ýòîì áîþ ...';
}
} else {
$p = explode('|', $this->u->info['priems']);
$pz = explode('|', $this->u->info['priems_z']);
if ($p[(int)$id] > 0 && $pz[(int)$id] <= 0 && $this->u->info['hpNow'] >= 1) {
$pl = mysql_fetch_assoc(
mysql_query(
'SELECT * FROM `priems` WHERE `level`<=' . $this->u->info['level'] . ' AND `id` = ' . $p[(int)$id]
)
);
if (isset($pl['id']) && $pl['activ'] != 1) {
if ($pl['activ'] == 0) {
unset($pl);
} elseif ($pl['activ'] > 1) {
//Êíèæíûé ïðèåì
if ($this->testActiv($pl['activ']) == 0) {
unset($pl);
}
}
}
if (isset($pl['id'])) {
$notr = 0;
$pl['useon_user'] = $this->u->info['enemy'];
if (isset($_POST['useon']) && $_POST['useon'] != '' && $_POST['useon'] != 'none') {
$_POST['useon'] = iconv('UTF-8', 'windows-1251', $_POST['useon']);
$this->ue = mysql_fetch_assoc(
mysql_query(
'SELECT
`u`.`id`,`u`.`login`,`u`.`login2`,`u`.`online`,`u`.`admin`,`u`.`city`,`u`.`cityreg`,`u`.`align`,`u`.`clan`,
`u`.`level`,`u`.`money`,`u`.`money3`,`u`.`money4`,`u`.`battle`,`u`.`sex`,`u`.`obraz`,`u`.`win`,`u`.`win_t`,
`u`.`lose`,`u`.`lose_t`,`u`.`nich`,`u`.`timeMain`,`u`.`invis`,`u`.`bot_id`,`u`.`animal`,`u`.`type_pers`,
`u`.`notrhod`,`u`.`bot_room`,`u`.`inUser`,`u`.`inTurnir`,`u`.`inTurnirnew`,`u`.`stopexp`,`u`.`real`,
`st`.*
FROM `users` AS `u`
LEFT JOIN `stats` AS `st` ON (`u`.`id`=`st`.`id`)
WHERE (
`u`.`login`="' . mysql_real_escape_string($_POST['useon']) . '" OR
(
`u`.`login2` = "' . mysql_real_escape_string($_POST['useon']) . '" AND
`u`.`login2` != "")
) AND
(
`u`.`inUser` > 0 OR
(
`u`.`battle`="' . $btl->info['id'] . '" AND
`st`.`hpNow` > 0
)
) ORDER BY `u`.`id` DESC LIMIT 1'
)
);
if (isset($this->ue['id']) && $this->ue['inUser'] > 0) {
$this->ue = mysql_fetch_assoc(
mysql_query(
'SELECT
`u`.`id`,`u`.`login`,`u`.`login2`,`u`.`online`,`u`.`admin`,`u`.`city`,`u`.`cityreg`,`u`.`align`,`u`.`clan`,
`u`.`level`,`u`.`money`,`u`.`money3`,`u`.`money4`,`u`.`battle`,`u`.`sex`,`u`.`obraz`,`u`.`win`,`u`.`win_t`,
`u`.`lose`,`u`.`lose_t`,`u`.`nich`,`u`.`timeMain`,`u`.`invis`,`u`.`bot_id`,`u`.`animal`,`u`.`type_pers`,
`u`.`notrhod`,`u`.`bot_room`,`u`.`inUser`,`u`.`inTurnir`,`u`.`inTurnirnew`,`u`.`stopexp`,`u`.`real`,
`st`.*
FROM `users` AS `u`
LEFT JOIN `stats` AS `st` ON (`u`.`id`=`st`.`id`)
WHERE
`u`.`battle`="' . $btl->info['id'] . '" AND
`st`.`hpNow` > 0) AND
`u`.`id` = "' . $this->ue['inUser'] . '" ORDER BY `u`.`id` ASC LIMIT 1'
)
);
}
if (!isset($this->ue['id']) && $pl['trUser'] > 0) {
$notr++;
}
if ($pl['team'] == 1) {
//ñâîè
if ($this->u->info['team'] != $this->ue['team']) {
$notr++;
}
} elseif ($pl['team'] == 2) {
//ïðîòèâíèêè
if ($this->u->info['team'] == $this->ue['team']) {
$notr++;
}
}
} else {
$ga = mysql_fetch_assoc(
mysql_query(
'SELECT * FROM `battle_act` WHERE `battle` = "' . $btl->info['id'] . '" AND `uid1` = "' . $this->u->info['id'] . '" AND `uid2` = "' . $this->u->info['enemy'] . '" LIMIT 1'
)
);
if (($this->u->info['enemy'] == 0 || isset($ga['id'])) && ($pl['tr_hod'] > 0 || $pl['trUser'] > 0)) {
$notr++;
}
}
$notr += $this->testpriem($pl, 1, $this->ue['id']);
if ($this->ue['id'] > 0) {
$notr += $this->testRazmenOldUser($this->ue['id'], $this->u->info['enemy'], $pl['id']);
}
if ($notr == 0) {
mysql_query(
'UPDATE `stats` SET `last_pr` = "' . $pl['id'] . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
);
//Ïðèåìû íà ïåðñîíàæàõ
if ($this->ue['id'] > 0) {
$btl->priemsRazmen([$this->u->info['id'], $this->ue['id']], 'fast');
mysql_query(
'UPDATE `eff_users` SET `mark` = 1 WHERE `uid` = "' . $this->ue['id'] . '" AND `delete` = 0'
);
} else {
$btl->priemsRazmen([$this->u->info['id'], $this->u->info['enemy']], 'fast');
mysql_query(
'UPDATE `eff_users` SET `mark` = 1 WHERE `uid` = "' . $this->u->info['enemy'] . '" AND `delete` = 0'
);
}
mysql_query(
'UPDATE `eff_users` SET `mark` = 1 WHERE `uid` = "' . $this->u->info['id'] . '" AND `delete` = 0'
);
if (file_exists('../../_incl_data/class/priem/' . $pl['id'] . '.php')) {
require('../../_incl_data/class/priem/' . $pl['id'] . '.php');
$this->testDie($this->ue['id']);
} else {
echo 'useSkill' . $pl['id'];
}
if (!isset($cup)) {
$this->uppz($pl, $id);
//Îòíèìàåì òàêòèêè
//$this->mintr($pl);
if ($pl['tr_hod'] > 0) {
$this->trhod($pl);
}
if ($pl['id'] != 258) {
if ($pl['cancel_eff'] == '') {
$pl['cancel_eff'] = '258';
} else {
$pl['cancel_eff'] .= ',258';
}
}
if ($pl['cancel_eff'] != '') {
$i = 0;
$e = explode(',', $pl['cancel_eff']);
while ($i < count($e)) {
if ($e[$i] > 0) {
if ($e[$i] == 258) {
$nem = mysql_fetch_assoc(
mysql_query(
'SELECT * FROM `eff_users` WHERE `uid` = "' . $this->u->info['id'] . '" AND `v1` = "priem" AND `v2` = "' . $e[$i] . '" AND `delete` = "0" AND `mark` = 1 LIMIT 1'
)
);
} else {
$nem = mysql_fetch_assoc(
mysql_query(
'SELECT * FROM `eff_users` WHERE `uid` = "' . $this->ue['id'] . '" AND `v1` = "priem" AND `v2` = "' . $e[$i] . '" AND `delete` = "0" AND `mark` = 1 LIMIT 1'
)
);
}
if (isset($nem['id'])) {
$nem['priem'] = mysql_fetch_assoc(
mysql_query(
'SELECT * FROM `priems` WHERE `id` = "' . $e[$i] . '" LIMIT 1'
)
);
if (isset($nem['id'])) {
$btl->delPriem($nem, $btl->users[$btl->uids[$this->ue['id']]], 500);
}
}
}
$i++;
}
}
}
}
}
}
}
}
private function rezadEff($uid, $mg)
{
global $btl;
//$this->rezadEff($this->u->info['id'],'wis_fire_');
$md = '';
$md2 = '';
$ex = explode('|', $btl->users[$btl->uids[$uid]]['priems']);
$ex2 = explode('|', $btl->users[$btl->uids[$uid]]['priems_z']);
$i = 0;
$ty = [];
while ($i < count($ex)) {
if ($ex[$i] > 0) {
$md .= '`id` = "' . ((int)$ex[$i]) . '" OR ';
$ty[$ex[$i]] = $i;
}
$i++;
}
$md = rtrim($md, ' OR ');
if ($md != '') {
$md = '( ' . $md . ' ) AND ';
}
$sp = mysql_query('SELECT * FROM `priems` WHERE ' . $md . ' `img` LIKE "%' . $mg . '%"');
while ($pl = mysql_fetch_assoc($sp)) {
$ex2[$ty[$pl['id']]] = 0;
}
$md2 = implode('|', $ex2);
$btl->users[$btl->uids[$uid]]['priems_z'] = $md2;
$this->u->info['priems_z'] = $md2;
$upd = mysql_query('UPDATE `stats` SET `priems_z` = "' . $md2 . '" WHERE `id` = "' . ((int)$uid) . '" LIMIT 1');
unset($md, $md2, $ty);
return $upd;
}
private function trhod($pl)
{
global $u, $btl;
if ($this->u->info['notrhod'] == -1) {
$this->u->info['notrhod'] = 0;
if ($this->u->stats['magic_cast'] > 0) {
$this->u->info['notrhod'] = $this->u->stats['magic_cast'];
}
mysql_query(
'UPDATE `users` SET `notrhod` = "' . $this->u->info['notrhod'] . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
);
}
if ($this->u->info['notrhod'] > 0) {
if ($pl['tr_hod'] > 0) {
$this->u->info['notrhod']--;
mysql_query(
'UPDATE `users` SET `notrhod` = "' . $this->u->info['notrhod'] . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
);
}
} else {
$a1 = mysql_fetch_assoc(
mysql_query(
'SELECT * FROM `battle_act` WHERE `battle` = "' . $btl->info['id'] . '" AND `uid2` = "' . $this->u->info['id'] . '" AND `uid1` = "' . $this->u->info['enemy'] . '" LIMIT 1'
)
);
if (isset($a1['id'])) {
//ïðîòèâíèê óäàðèë, ïèøåì ÷òî èãðîê 2 ïðîïóñòèë õîä
mysql_query(
'UPDATE `battle_act` SET `out2` = "1",`tpo2` = "2" WHERE `id` = "' . $a1['id'] . '" LIMIT 1'
);
$a1['out2'] = 1;
$a1['tpo2'] = 2;
$btl->atacks[$a1['id']] = $a1;
$btl->users[$this->u->info['id']]['priems_z'] = $this->u->info['priems_z'];
$btl->startAtack($a1['id']);
} else {
//áüåì ïðîòèâíèêà ñ ïðîïóñêîì õîäà
mysql_query(
'INSERT INTO `battle_act` (`battle`,`uid1`,`uid2`,`time`,`out1`,`type`,`tpo1`) VALUES ("' . $btl->info['id'] . '","' . $this->u->info['id'] . '","' . $this->u->info['enemy'] . '","' . time(
) . '","1","1","2")'
);
}
}
}
public function plusData($d1, $d2)
{
global $u;
$j1 = $this->lookStatsArray($d1);
$j2 = $this->lookStatsArray($this->redate($d2, $this->u->info['id']));
$v = $this->u->lookKeys($this->redate($d2, $this->u->info['id']), 0); // êëþ÷è 2
//äîáàâëÿåì äàííûå äðóã ê äðóãó
$i = 0;
$inf = '';
while ($i < count($v)) {
$j1[$v[$i]] += $j2[$v[$i]];
$vi = str_replace('add_', '', $v[$i]);
if ($this->u->is[$vi] != '') {
if ($j2[$v[$i]] > 0) {
$inf .= $this->u->is[$vi] . ': +' . ($j2[$v[$i]] * (1 + $mpr['x'])) . ', ';
} elseif ($j2[$v[$i]] < 0) {
$inf .= $this->u->is[$vi] . ': ' . ($j2[$v[$i]] * (1 + $mpr['x'])) . ', ';
}
}
$i++;
}
$inf = rtrim($inf, ', ');
$j1 = $this->u->impStats($j1);
return $j1;
}
private function addEffPr($pl, $id)
{
global $u, $btl;
$rcu = false;
$j = $this->lookStatsArray($pl['date2']);
$mpr = false;
$addch = 0;
$uid = $this->u->info['id'];
if (isset($this->ue['id'])) {
$uid = $this->ue['id'];
}
if (isset($j['onlyOne'])) {
$mpr = Db::getRow(
'select * from eff_users where v2 = ? and uid = ? and `delete` = 0 and mark = 1',
[$pl['id'], $uid]
);
//$mpr = mysql_fetch_assoc(mysql_query('SELECT * FROM `eff_users` WHERE `v2` = "' . $pl['id'] . '" AND `uid` = "' . $uid . '" AND `delete` = "0" AND `mark` = 1 LIMIT 1'));
}
// if ($pl['cancel_eff2'] != '') {
// $i = 0;
// $e = explode(',', $pl['cancel_eff2']);
// while ($i < count($e)) {
// if ($e[$i] > 0) {
// $nem = mysql_fetch_assoc(mysql_query('SELECT * FROM `eff_users` WHERE `uid` = "' . $uid . '" AND `v1` = "priem" AND `v2` = "' . $e[$i] . '" AND `delete` = "0" AND `mark` = 1 LIMIT 1'));
// if (isset($nem['id'])) {
// $nem['priem'] = mysql_fetch_assoc(mysql_query('SELECT * FROM `priems` WHERE `id` = "' . $e[$i] . '" LIMIT 1'));
// if (isset($nem['id'])) {
// $btl->delPriem($nem, $btl->users[$btl->uids[$uid]], 2);
// if ($nem['id'] == $mpr['id']) {
// unset($mpr);
// }
// }
// }
// }
// $i++;
// }
// }
if (!empty($pl['cancel_eff2'])) {
$this->cancelEffects($pl['cancel_eff2'], $uid, $btl);
}
$pld = [0 => ''];
$nc = 0;
if (isset($mpr['id']) && $j['onlyOne'] == 1) {
//îòíèìàåì òàêòèêè
$addch = 1;
$this->mintr($pl);
$this->uppz($pl, $id);
//äîáàâëÿåì ïðèåì â ýôôåêòû
if (isset($this->ue['id'])) {
$btl->stats[$btl->uids[$uid]] = $this->u->getStats($this->ue, 0);
} else {
$btl->stats[$btl->uids[$uid]] = $this->u->getStats($this->u->info, 0);
}
$nc = 1;
} elseif (!isset($mpr['id'])) {
$data = '';
if (isset($j['date3Plus'])) {
$data = $this->redate($pl['date3'], $this->u->info['id']);
}
$hd1 = -1;
if ($pl['limit'] > 0) {
$tm = 77;
$hd1 = $pl['limit'];
} else {
$tm = 77;
}
if ($pl['limit'] == -2) {
$hd1 = $pl['limit'];
}
if ($pl['id'] == 239) //Âûâîä ïðèåìîâ êîòîðûå íå ìîìåíòàëüíûå êàê áû
{
$btl->priemAddLogFast(
$uid, 0, $pl['name'],
'{tm' . $this->u->info['team'] . '} ' . $btl->addlt(
1, 17, $btl->users[$btl->uids[$uid]]['sex'],
null
) . '',
1, time()
);
}
$uu = $pl['id'] === 260 ? '' : $this->u->info['id'];
Db::sql(
'insert into eff_users (hod, v1, v2, img2, id_eff, uid, name, data, overType, timeUse, user_use) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
[$hd1, 'priem', $pl['id'], $pl['img'] . '.gif', 22, $uid, $pl['name'], $data, 0, $tm, $uu]
);
unset($hd1, $uu);
//îòíèìàåì òàêòèêè
$addch = 1;
$rcu = true;
$nc = 1;
$this->mintr($pl);
//$this->uppz($pl,$id);
//äîáàâëÿåì ïðèåì â ýôôåêòû
if (isset($this->ue['id'])) {
$btl->stats[$btl->uids[$uid]] = $this->u->getStats($this->ue, 0);
} else {
$btl->stats[$btl->uids[$uid]] = $this->u->getStats($this->u->info, 0);
}
} elseif ($j['onlyOne'] > 1) {
if ($mpr['x'] < $j['onlyOne'] && isset($j['date3Plus'])) {
$j1 = $this->lookStatsArray($mpr['data']);
$j2 = $this->lookStatsArray($this->redate($pl['date3'], $this->u->info['id']));
$v = $this->u->lookKeys($this->redate($pl['date3'], $this->u->info['id']), 0); // êëþ÷è 2
//äîáàâëÿåì äàííûå äðóã ê äðóãó
$i = 0;
$inf = '';
while ($i < count($v)) {
$j1[$v[$i]] += $j2[$v[$i]];
$vi = str_replace('add_', '', $v[$i]);
if ($this->u->is[$vi] != '') {
if ($j2[$v[$i]] > 0) {
$inf .= $this->u->is[$vi] . ': +' . ($j2[$v[$i]] * (1 + $mpr['x'])) . ', ';
} elseif ($j2[$v[$i]] < 0) {
$inf .= $this->u->is[$vi] . ': ' . ($j2[$v[$i]] * (1 + $mpr['x'])) . ', ';
}
}
$i++;
}
$inf = rtrim($inf, ', ');
$j1 = $this->u->impStats($j1);
$pld[0] = ' x' . ($mpr['x'] + 1);
if ($j['refHod'] == 1) {
$mpr['hod'] = $pl['limit'];
}
$upd = mysql_query(
'UPDATE `eff_users` SET `hod` = "' . $mpr['hod'] . '",`data` = "' . $j1 . '",`x` = `x`+1 WHERE `id` = "' . $mpr['id'] . '" LIMIT 1'
);
if ($upd) {
//îòíèìàåì òàêòèêè
$this->mintr($pl);
$this->uppz($pl, $id);
//äîáàâëÿåì ïðèåì â ýôôåêòû
if (isset($this->ue['id'])) {
$btl->stats[$btl->uids[$uid]] = $this->u->getStats($this->ue, 0);
} else {
$btl->stats[$btl->uids[$uid]] = $this->u->getStats($this->u->info, 0);
}
$addch = 1;
$rcu = true;
$nc = 1;
}
}
}
/* òðàòèì ñâîé õîä */
if ($nc == 1 && $pl['tr_hod'] > 0) {
$this->trhod($pl);
}
//return $rcu;
}
public function mintr($pl)
{
global $u, $btl;
$x = 1;
$rt = '';
while ($x <= 7) {
if ($pl['ndt' . $x] == 0) {
$this->u->info['tactic' . $x] -= $pl['tt' . $x];
$btl->users[$btl->uids[$this->u->info['id']]]['tactic' . $x] -= $pl['tt' . $x];
}
if ($this->u->info['tactic' . $x] < 0) {
$this->u->info['tactic' . $x] = 0;
}
if ($btl->users[$btl->uids[$this->u->info['id']]]['tactic' . $x] < 0) {
$btl->users[$btl->uids[$this->u->info['id']]]['tactic' . $x] = 0;
}
//$rt .= ',`tactic'.$x.'`="'.$this->u->info['tactic'.$x].'"';
$rt .= ',`tactic' . $x . '`="' . $btl->users[$btl->uids[$this->u->info['id']]]['tactic' . $x] . '"';
$x++;
}
if ($pl['xuse'] > 0) {
$this->u->addAction(time(), 'use_priem_' . $btl->info['id'] . '_' . $this->u->info['id'], $pl['id']);
}
$rt = ltrim($rt, ',');
mysql_query('UPDATE `stats` SET ' . $rt . ' WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1');
}
public function maxtr($x, $val)
{
global $u, $btl;
$this->u->info['tactic' . $x] += $val;
$btl->users[$btl->uids[$this->u->info['id']]]['tactic' . $x] += $val;
if ($this->u->info['tactic' . $x] < 0) {
$this->u->info['tactic' . $x] = 0;
}
if ($btl->users[$btl->uids[$this->u->info['id']]]['tactic' . $x] < 0) {
$btl->users[$btl->uids[$this->u->info['id']]]['tactic' . $x] = 0;
}
$rt = '`tactic' . $x . '`="' . $this->u->info['tactic' . $x] . '"';
mysql_query('UPDATE `stats` SET ' . $rt . ' WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1');
}
private function actpridMax($pl)
{
global $u, $btl;
if ($pl['actprid2'] > 0 || $pl['actprid3'] > 0) {
$i = 0;
$pe = explode('|', $this->u->info['priems']);
$piz = [];
while ($i < count($pe)) {
if ($pl['sbr'] == 0) {
//âñå áëîêèðóåì
$psp = mysql_fetch_assoc(
mysql_query('SELECT * FROM `priems` WHERE `id` = "' . ((int)$pe[$i]) . '" LIMIT 1')
);
} else {
//Òîëüêî òåêóùóþ øêîëó ìàãèè
$imgnm = '';
$nm = explode('_', $pl['img']);
if ($nm[0] == 'wis') { //ìàãèÿ
$imgnm = $nm[0] . '_' . $nm[1] . '%';
} else {
$imgnm = $nm[0] . '%';
}
//òîëüêî äàííîé øêîëû
$psp = mysql_fetch_assoc(
mysql_query(
'SELECT * FROM `priems` WHERE `id` = "' . ((int)$pe[$i]) . '" AND `img` LIKE "' . $imgnm . '" LIMIT 1'
)
);
}
if ($pl['noprid'] == 0 && isset($psp['id']) && $psp['tr_hod'] == 0 && $psp['type_pr'] == 1 && $psp['noprid'] == 0) {
if ($pl['actprid2'] > 0) {
$piz[$pe[$i]] = (int)$pl['actprid2'];
} elseif ($pl['actprid3'] > 0) {
$piz[$pe[$i]] = $psp['zad'];
}
}
$i++;
}
$pz = explode('|', $this->u->info['priems_z']);
$p = explode('|', $this->u->info['priems']);
$i = 0;
while ($i < count($p)) {
if ($p[$i] > 0 && isset($piz[$p[$i]]) && $pz[$i] == 0) {
$pz[$i] = $piz[$p[$i]];
}
$i++;
}
$pz = implode('|', $pz);
$this->u->info['priems_z'] = $pz;
$btl->users[$btl->uids[$this->u->info['id']]]['priems_z'] = $pz;
$btl->stats[$btl->uids[$this->u->info['id']]]['priems_z'] = $pz;
}
}
public function uppz($pl, $id)
{
global $u, $btl;
$this->actpridMax($pl);
$p = explode('|', $this->u->info['priems']);
$pz = explode('|', $this->u->info['priems_z']);
$pz[(int)$id] = $pl['zad'];
$i = 0;
$pe = explode(',', $pl['actprid']);
$piz = [];
while ($i < count($pe)) {
$piz[$pe[$i]] = 1;
$i++;
}
$i = 0;
$pe = explode(',', $pl['actprid_one']);
$piz2 = [];
while ($i < count($pe)) {
$piz2[$pe[$i]] = 1;
$i++;
}
$i = 0;
while ($i < count($p)) {
if ($p[$i] > 0) {
if (isset($piz[$p[$i]])) {
if ($pl['id'] == 281) {
//Æåðòâà âîäå + âîçäóõó äàåò 5 åä. çàäåðæêè íà çåìëþ è îãîíü
if ($p[$i] == 246 || $p[$i] == 186) {
$pz[$i] = 5;
} else {
$pz[$i] = $pl['zad'];
}
} else {
$pz[$i] = $pl['zad'];
}
}
if (isset($piz2[$p[$i]]) && $pz[$i] == 0) {
$pz[$i] = 1;
}
}
$i++;
}
$pz = implode('|', $pz);
$this->u->info['priems_z'] = $pz;
$btl->users[$btl->uids[$this->u->info['id']]]['priems_z'] = $pz;
$btl->stats[$btl->uids[$this->u->info['id']]]['priems_z'] = $pz;
$tr = $this->lookStatsArray($pl['tr']);
if (isset($tr['tr_mpNow'])) {
$tr['tr_mpNow'] = round($tr['tr_mpNow'] / 100 * (100 - $this->u->stats['min_use_mp']));
$btl->users[$btl->uids[$this->u->info['id']]]['mpNow'] -= $tr['tr_mpNow'];
$btl->stats[$btl->uids[$this->u->info['id']]]['mpNow'] -= $tr['tr_mpNow'];
if ($btl->stats[$btl->uids[$this->u->info['id']]]['mpNow'] < $btl->users[$btl->uids[$this->u->info['id']]]['mpNow']) {
$btl->users[$btl->uids[$this->u->info['id']]]['mpNow'] = $btl->stats[$btl->uids[$this->u->info['id']]]['mpNow'];
}
}
$this->u->info['mpNow'] = $btl->users[$btl->uids[$this->u->info['id']]]['mpNow'];
mysql_query(
'UPDATE `stats` SET `mpNow` = "' . $this->u->info['mpNow'] . '",`priems_z` = "' . $pz . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
);
}
public function reuns($id)
{
global $u, $c, $code;
$p = explode('|', $this->u->info['priems']);
if ($p[(int)$id] > 0) {
//ñíèìàåì ïðèåì
$p[(int)$id] = 0;
$p = implode('|', $p);
mysql_query(
'UPDATE `stats` SET `priems` = "' . mysql_real_escape_string(
$p
) . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
);
$this->u->info['priems'] = $p;
}
}
/** Îäåòü ïðè¸ì â ñëîò?
* @param $id
* @return void
*/
public function uns($id)
{
global $u, $c, $code;
$pl = mysql_fetch_assoc(
mysql_query(
'SELECT * FROM `priems` WHERE `level`<="' . $this->u->info['level'] . '" AND `activ` > "0" AND `id` = "' . $id . '" LIMIT 1'
)
);
if (!isset($pl['id']) || $this->testpriem($pl, 1) != 0) {
return;
}
$yes = -1;
$non = -1;
$i = 0;
$p = explode('|', $this->u->info['priems']);
while ($i < $this->u->info['priemslot']) {
if ($non == -1 && $p[$i] == 0) {
$non = $i;
}
if ($p[$i] == $pl['id']) {
$yes = $i;
}
$i++;
}
if ($yes != -1) {
//òàêîé ïðèåì óæå ñòîèò, íè÷åãî íå äåëàåì
return;
}
if ($non != -1) {
//îäåâàåì ïðèåì
$p[$non] = $pl['id'];
$p = implode('|', $p);
$upd = mysql_query(
'UPDATE `stats` SET `priems` = "' . $p . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
);
if ($upd) {
$this->u->info['priems'] = $p;
}
} else {
//ñíèìàåì ïîñëåäíèé ïðèåì
echo 'Ñíèìàåì ïîñëåäíèé ïðèåì...';
}
}
//âûâîäèì ïðèåìû $id - 1 (âíå áîÿ), 2 - â áîþ
public function seeMy($t)
{
global $btl;
$i = 0;
$p = explode('|', $this->u->info['priems']);
$lvar = '';
$pr = '';
while ($i < $this->u->info['priemslot']) {
if ($p[$i] > 0) {
$pl = mysql_fetch_assoc(
mysql_query(
'SELECT * FROM `priems` WHERE `level`<="' . $this->u->info['level'] . '" AND `activ` > "0" AND `id` = "' . mysql_real_escape_string(
$p[$i]
) . '" LIMIT 1'
)
);
$lvar = $this->priemInfo($pl, $t, $i);
$pz = $lvar[1];
$lvar = $lvar[0];
if ($t == 1) {
if (isset($_GET['inv'])) {
$cl = 'href="javascript:void(0)" onclick="location.href=\'main.php?all=' . ((int)$_GET['all']) . '&skills=1&rz=4&p_raz=all\'"';
} else {
$cl = 'href="javascript:void(0)" onclick="location.href=\'main.php?all=' . ((int)$_GET['all']) . '&skills=1&unuse_priem=' . $i . '&rz=4&p_raz=\' + p_raz"';
}
} else {
if ($pl['type'] == 1) {
//ìîìåíòàëüíî
if ($pl['onUser'] == 1) {
$oninuser = '';
if ($pl['team'] == 1) {
if ($this->u->info['login2'] != '') {
$oninuser = $this->u->info['login2'];
} else {
$oninuser = $this->u->info['login'];
}
} else {
if ($btl->users[$btl->uids[$this->u->info['enemy']]]['login2'] != '') {
$oninuser = $btl->users[$btl->uids[$this->u->info['enemy']]]['login2'];
} else {
$oninuser = $btl->users[$btl->uids[$this->u->info['enemy']]]['login'];
}
}
$cl = 'href="javascript:void(0);" onClick="top.priemOnUser(' . $i . ',1,\'' . $pl['name'] . '\',\'' . $oninuser . '\',\'' . $pl['img'] . '\');"';
unset($oninuser);
} else {
$cl = 'href="javascript:void(0);" onClick="usepriem(' . $i . ',1,\'' . $pl['img'] . '\');"';
}
} elseif ($pl['type'] == 2) {
//äëèòåëüíîå
$cl = 'href="javascript:void(0);" onClick="usepriem(' . $i . ',1,\'' . $pl['img'] . '\');"';
} elseif ($pl['type'] == 3) {
$cl = 'href="javascript:void(0);" onClick="alert(\'Âîçìîæíî èñïîëüçóåì?\');"';
}
}
$notr = $this->testpriem($pl, $t);
$cl2 = '';
$cli2 = '';
if ((($pz[$i] > 0 || $notr > 0) && $t == 2) || (isset($this->u->stats['nopriems']) && $pl['nosh'] == 0) || $this->u->stats['notuse_last_pr'] == $pl['id']) {
$cli2 = ' class="nopriemuse" ';
}
$pr .= '<a onMouseOver="top.hi(this,\'<b>' . $pl['name'] . '</b><Br>' . $lvar . '\',event,3,0,1,1,\'width:240px\');" onMouseOut="top.hic();" onMouseDown="top.hic();" ' . $cl . '><img ' . $cli2 . ' style="margin-top:3px; ' . $cl2 . ' margin-left:4px;" src="https://img.new-combats.com/i/eff/' . $pl['img'] . '.gif" width="40" height="25" /></a>';
} else {
if (isset($_GET['inv'])) {
$pr .= '<a title="Ïåðåéòè ê íàñòðîéêàì ïðèåìîâ" href="javascript:void(0)" onclick="location.href=\'main.php?all=' . ((int)$_GET['all']) . '&skills=1&rz=4&p_raz=all\'"><img style="margin-top:4px; margin-left:4px;" src="https://img.new-combats.com/i/items/w/clearPriem.gif" width="40" height="25" /></a>';
} else {
$pr .= '<img style="margin-top:4px; margin-left:4px;" src="https://img.new-combats.com/i/items/w/clearPriem.gif" width="40" height="25" />';
}
}
$i++;
}
if ($this->u->info['animal'] > 0 && $t == 2) {
$use_lst = $this->u->testAction(
'`uid` = "' . $this->u->info['id'] . '" AND `vars` = "animal_use' . $btl->info['id'] . '" LIMIT 1',
1
);
if (!isset($use_lst['id'])) {
$cl2 = '';
$pr .= '<a onMouseOver="top.hi(this,\'<b>Âûïóñòèòü çâåðÿ</b><Br>Âàø çâåðü âìåøèâàåòñÿ â ïîåäèíîê. Ìîæíî ïðèìåíÿòü îäèí ðàç çà áîé.\',event,3,0,1,1,\'width:240px\');" onMouseOut="top.hic();" onMouseDown="top.hic();" href="javascript:void(0);" onClick="usepriem(100500,1,\'\');"><img style="margin-top:1px; ' . $cl2 . ' margin-left:3px;" src="https://img.new-combats.com/i/eff/pet_unleash.gif" width="40" height="25" /></a>';
} else {
$cl2 = '" class="nopriemuse';
$pr .= '<img onMouseOver="top.hi(this,\'<b>Âûïóñòèòü çâåðÿ</b><Br>Âàø çâåðü âìåøèâàåòñÿ â ïîåäèíîê. Ìîæíî ïðèìåíÿòü îäèí ðàç çà áîé.\',event,3,0,1,1,\'width:240px\');" onMouseOut="top.hic();" onMouseDown="top.hic();" style="margin-top:1px; margin-left:2px;' . $cl2 . '" src="https://img.new-combats.com/i/eff/pet_unleash.gif" width="40" height="25" />';
}
}
if ($t == 1) {
echo '<div style="width:230px;">' . $pr . '</div>';
} elseif ($t == 2) {
return str_replace('"', '\\"', $pr);
}
}
public function testpriem($pl, $t = 1, $o = 0)
{
global $c, $u, $code, $btl;
$tr = $this->lookStatsArray($pl['tr']);
$d2 = $this->lookStatsArray($pl['date2']);
$x = 1;
$notr = 0;
if ($t == 2 && $pl['id'] == 181) {
$imun = mysql_fetch_assoc(
mysql_query(
'SELECT * FROM `eff_users` WHERE `uid` = "' . $this->u->info['enemy'] . '" and `v2`="191" and `delete`="0" LIMIT 1'
)
);
if ($imun) {
$notr++;
}
}
if (isset($btl->stats[$btl->uids[$this->u->info['id']]]['nousepriem']) && $btl->stats[$btl->uids[$this->u->info['id']]]['nousepriem'] > 0 && $pl['nosh'] == 0) {
if ($btl->stats[$btl->uids[$this->u->info['id']]]['noshock_voda'] > 0 && substr(
$pl['img'], 0,
10
) == 'wis_water_') {
//âîäà
} else {
$notr++;
}
}
if ($pl['id'] == $btl->stats[$btl->uids[$this->u->info['id']]]['notuse_last_pr']) {
$notr++;
}
while ($x <= 7) {
if (isset($btl->uids[$this->u->info['id']], $btl->users[$btl->uids[$this->u->info['id']]])) {
if ($btl->users[$btl->uids[$this->u->info['id']]]['tactic' . $x] < $pl['tt' . $x] && $x != 7 && $pl['tt' . $x] > 0) {
$notr++;
} elseif ($x == 7) {
if ($pl['tt' . $x] > 0 && $btl->users[$btl->uids[$this->u->info['id']]]['tactic' . $x] <= 0) {
$notr++;
}
}
}
$x++;
}
if ($pl['xuse'] > 0) {
$xu = $this->u->testAction(
'`vars` = "use_priem_' . $btl->info['id'] . '_' . $this->u->info['id'] . '" AND `vals` = "' . $pl['id'] . '" LIMIT ' . $pl['xuse'] . '',
2
);
if ($xu[0] >= $pl['xuse']) {
$notr++;
}
}
$x = 0;
$t = $this->u->items['tr'];
while ($x < count($t)) {
$n = $t[$x];
if (isset($tr['tr_' . $n])) {
if ($n == 'lvl') {
if ($tr['tr_' . $n] > $this->u->info['level']) {
$notr++;
}
} elseif ($tr['tr_' . $n] > $this->u->stats[$n]) {
$notr++;
}
}
$x++;
}
if ($pl['activ'] == 0 || ($this->testActiv($pl['activ']) == 0 && $pl['activ'] > 1)) {
$notr++;
}
//if($t==2)
//{
if (isset($d2['onlyOne']) || isset($d2['onlyOneX1'])) {
if (isset($d2['onlyOneX1'])) {
if ($d2['onlyOneX1'] == 1) {
$pru = mysql_fetch_assoc(
mysql_query(
'SELECT * FROM `eff_users` WHERE `uid` = "' . $this->u->info['id'] . '" AND `v2` = "' . $pl['id'] . '" AND `delete` = "0" AND `x` >= 1 LIMIT 1'
)
);
if (isset($pru['id']) && $pru['x'] >= $d2['onlyOne']) {
$notr++;
}
}
} elseif (isset($d2['onlyOne'])) {
if ($d2['onlyOne'] > 1) {
$pru = mysql_fetch_assoc(
mysql_query(
'SELECT * FROM `eff_users` WHERE `uid` = "' . $this->u->info['id'] . '" AND `v2` = "' . $pl['id'] . '" AND `delete` = "0" AND `x` > 1 LIMIT 1'
)
);
if (isset($pru['id']) && $pru['x'] >= $d2['onlyOne']) {
$notr++;
}
}
}
}
//Òðåáóåò ÷òîáû íå áûëî
if (isset($tr['tr_nousepriem'])) {
$x = 0;
$nouse = explode(',', $tr['tr_nousepriem']);
while ($x < count($nouse)) {
$nousev = explode('.', $nouse[$x]);
if (isset($btl->stats[$btl->uids[$this->u->info['id']]]['prsu'][$nousev[0]]) && $btl->stats[$btl->uids[$this->u->info['id']]]['prsu'][$nousev[0]] >= 0) {
if ($nousev[2] > 1) {
if ($nousev[2] <= $btl->stats[$btl->uids[$this->u->info['id']]]['prsu'][$nousev[0]]) {
$notr++;
}
} else {
$notr++;
}
}
$x++;
}
unset($nouse, $nousev);
}
if (isset($tr['tr_type_itm1'])) {
//òðåáóåò íàëè÷èå ïðåäìåòà îïðåäåëåííîãî òèïà
$itmt = mysql_fetch_assoc(
mysql_query(
'SELECT `u`.`id` FROM `items_users` AS `u` LEFT JOIN `items_main` AS `m` ON `m`.`id` = `u`.`item_id` WHERE `m`.`type` = "' . $tr['tr_type_itm1'] . '" AND `u`.`inOdet` > 0 AND `u`.`uid` = "' . $this->u->info['id'] . '" AND `u`.`delete` = "0" LIMIT 1'
)
);
if (!isset($itmt['id'])) {
$notr++;
}
}
if (isset($tr['tr_mpNow'])) {
if (isset($btl->stats[$btl->uids[$this->u->info['id']]])) {
if ($btl->stats[$btl->uids[$this->u->info['id']]]['mpNow'] < round(
$tr['tr_mpNow'] / 100 * (100 - $btl->stats[$btl->uids[$this->u->info['id']]]['min_use_mp'])
)) {
$notr++;
}
} elseif ($this->u->info['mpNow'] < $tr['tr_mpNow']) {
$notr++;
}
}
if (isset($btl->uids[$this->u->info['id']], $btl->stats[$btl->uids[$this->u->info['id']]])) {
if ($pl['trUser'] == 1) {
//òðåáóåò ÷òîáû ïîëüçîâàòåëü ñ êåì-òî ðàçìåíèâàëñÿ (ïðè îæèäàíèè ïðèåì ãàñíèò)
if (isset($btl->ga[$this->u->info['id']][$this->u->info['enemy']])) {
$notr++;
}
} elseif ($pl['trUser'] == 2 && $o > 0) {
//òðåáóåò ÷òîáû ïîëüçîâàòåëü ñ êåì-òî ðàçìåíèâàëñÿ (ïðè îæèäàíèè íå ïðîïàäàåò, íî íå èñïîëüçóåòñÿ)
$ga = mysql_fetch_assoc(
mysql_query(
'SELECT * FROM `battle_act` WHERE `battle` = "' . $btl->info['id'] . '" AND `uid1` = "' . $this->u->info['id'] . '" AND `uid2` = "' . $btl->users[$btl->uids[$this->u->info['id']]]['enemy'] . '" LIMIT 1'
)
);
if (isset($ga['id'])) {
$notr++;
}
}
}
return $notr;
}
public function priemInfo($pl, $t, $id = false)
{
global $u, $c, $code, $btl;
$pz = explode('|', $this->u->info['priems_z']);
$tr = $this->lookStatsArray($pl['tr']);
$trs = '';
$x = 0;
$notr = 0;
$t = $this->u->items['tr'];
while ($x < count($t)) {
$n = $t[$x];
if (isset($tr['tr_' . $n])) {
if ($tr['tr_' . $n] > $this->u->stats[$n]) {
$trs .= '<font color=red>';
$notr++;
}
$trs .= '<br>• ';
$trs .= $this->u->is[$n] . ': ' . $tr['tr_' . $n];
if ($tr['tr_' . $n] > $this->u->stats[$n]) {
$trs .= '</font>';
}
}
$x++;
}
$lvar = '';
$j = 1;
$nm = [1 => 'hit', 2 => 'krit', 3 => 'counter', 4 => 'block', 5 => 'parry', 6 => 'hp', 7 => 'spirit'];
while ($j <= 6) {
if ($pl['tt' . $j] > 0) {
$lvar .= '<img src=https://img.new-combats.com/i/micro/' . $nm[$j] . '.gif width=8 height=8 /> ' . round(
$pl['tt' . $j],
2
) . ' &nbsp; ';
}
$j++;
}
if ($pl['tt7'] > 0) {
if ($lvar != '') {
$lvar .= '<br>';
}
$lvar .= 'Ñèëà äóõà: ' . round($pl['tt' . $j], 2) . '<br>';
}
$lvar .= '<br>';
if ($pl['zad'] > 0) {
$lvar .= 'Çàäåðæêà: ' . $pl['zad'];
if ($pz[$id] > 0) {
$lvar .= ' (åùå ' . $pz[$id] . ')';
}
$lvar .= '<br>';
}
if (isset($tr['tr_mpNow']) && $tr['tr_mpNow'] > 0) {
$tr['tr_mpNow'] -= round($tr['tr_mpNow'] / 100 * $this->u->stats['min_use_mp']);
if ($this->u->info['mpNow'] < $tr['tr_mpNow'] || (isset($btl->stats[$btl->uids[$this->u->info['id']]]) && $btl->stats[$btl->uids[$this->u->info['id']]]['mpNow'] < $tr['tr_mpNow'])) {
$lvar .= '<font color=red>• Ðàñõîä ìàíû: ' . $tr['tr_mpNow'] . '</font><br>';
} else {
$lvar .= '• Ðàñõîä ìàíû: ' . $tr['tr_mpNow'] . '<br>';
}
}
if ($pl['tr_hod'] > 0) {
$lvar .= '• Ïðèåì òðàòèò õîä<br>';
}
if ($trs != '') {
$lvar .= '<b>Òðåáîâàíèÿ:</b>' . $trs . '<br><br>';
} else {
$lvar .= '<br>';
}
$pl['info'] = preg_replace_callback("!(#)(.*?)(#)!is", [$this, 'getDynamicInfo'], $pl['info']);
$lvar .= $pl['info'];
return [0 => $lvar, 1 => $pz];
}
//Ìîùíîñòü / ïîäàâëåíèå / ñîïðîòèâëåíèå è ò.ä.
public function testPower($s1, $s2, $y, $t, $t2)
{
global $u, $btl;
$r = 0;
if ($t2 == 2) {
//óðîí ìàãèåé
$pm = [0 => 0, 1 => 0, 2 => 0, 3 => 0];
if ($t < 5) {
$pm[0] = $s1['m11'];
$pm[1] = $s2['zm'];
$pm[2] = $s2['antm11'];
}
if (isset($btl->info['id'])) {
$pm[3] = $btl->zmgo($s2['zm' . $t]);
$pm[3] = round($pm[3]);
}
//óðîí = b*(1+m/100)*2^((p*10-z)/k)
$fx_vl = [
250,
250,
250,
250,
250,
250,
250,
250,
250,
350,
400,
450,
500,
550,
600,
650,
700,
750,
800,
850,
900,
950,
];
$fx = [
'b' => $y, //áàçîâûé óðîí
'm' => round($s1['pm' . $t] * 1 - $s2['antpm' . $t]), //ìîùü
'z' => round($s2['zm' . $t]), //çàùèòà öåëè åä.
'p' => round(($s1['pzm'] + $s1['pzm' . $t])), //ïîäàâëåíèå
'k' => $fx_vl[(0 + $s1['lvl'])] //êîýôôèöèåíò ; k=250 äëÿ 8êè, k=300 äëÿ 9êè è ò.ä. +20% íà óðîâåíü
];
if (($fx['z'] + 250) - $fx['p'] * 10 < 0) { //çàùèòà íå ìîæåò óéòè áîëüøå, ÷åì â 250 åä.
$fx['p'] = ($fx['z'] + 250) / 10;
}
$fx['p'] = 0;
//
$p = $fx['b'] * (1 + $fx['m'] / 100) * pow(2, (($fx['z'] - $fx['p'] * 10) / $fx['k']));
//$p += $p/100*10;
$p -= $p / 100 * $pm[3];
//$p += floor($s1['s5']*0.25);
if ($p < round($y * 0.1)) {
$p = round($y * 0.1);
} elseif ($p > round($y * 10)) {
$p = $y * 10;
}
if (isset($s2['zm' . $t . 'proc'])) //çàùèòà îò ìàãèè ñòèõèé (ïðèçðà÷êè)
{
$p = floor($p / 100 * (100 - $s2['zm' . $t . 'proc']));
if ($p < 0) {
$p = 0;
}
}
if (isset($s2['zmproc'])) //çàùèòà îò ìàãèè ñòèõèé (ïðèçðà÷êè)
{
if ($s2['zmproc'] >= 75) {
$p = floor($p / 100 * (100 - 75));
} else {
$p = floor($p / 100 * (100 - $s2['zmproc']));
if ($p < 0) {
$p = 0;
}
}
}
$r = $p;
}
return round($r / 100 * 70);
}
private function pyes($id)
{
global $u;
$p = explode('|', $this->u->info['priems']);
$r = false;
$i = 0;
while ($i < count($p)) {
if ($p[$i] == $id) {
$r = true;
}
$i++;
}
return $r;
}
//âûâîäèì âñå äîñòóïíûå ïðèåìû èãðîêó íà åãî óðîâíå - 1, âûâîäèì âñå äîñòóïíûå ïðèåìû òîëüêî èãðîêó - 2
public function seePriems($mt)
{
global $code;
$t = $this->u->items['tr'];
$nm = [1 => 'hit', 2 => 'krit', 3 => 'counter', 4 => 'block', 5 => 'parry', 6 => 'hp', 7 => 'spirit'];
$lvlfe = $this->u->info['level'];
if (isset($_GET['all'])) {
$lvlfe = 21;
}
$sp = mysql_query(
'SELECT * FROM `priems` WHERE `level`<="' . $lvlfe . '" AND `activ` > "0" ORDER BY `img`,`level` ASC'
);
$this->u->info['lvl'] = $this->u->info['level'];
$lvar = '';
while ($pl = mysql_fetch_assoc($sp)) {
$noaki = 0;
if ($pl['activ'] == 1 || $this->testActiv($pl['activ']) == 1) {
$lvar = $this->priemInfo($pl, 1);
$lvar = $lvar[0];
$cl = '';
$a1 = '<a href="javascript:void(0)" onclick="location.href=\'main.php?skills=1&all=' . ((int)$_GET['all']) . '&rz=4&use_priem=' . $pl['id'] . '&rnd=' . $code . '&p_raz=\' + p_raz;">';
$a2 = '</a>';
if ($this->pyes($pl['id']) || $this->testpriem($pl, 1) > 0) {
if ((isset($_GET['all']) && $_GET['all'] == 1) || $this->pyes($pl['id'])) {
$cl = 'filter: alpha(opacity=35); -moz-opacity: 0.35; -khtml-opacity: 0.35; opacity: 0.35;';
$a1 = '';
$a2 = '';
} else {
$noaki = 1;
}
}
if ($noaki == 0) {
$mtnu = explode('_', $pl['img']);
if ($mtnu[0] != 'wis') {
$mtnu = $mtnu[0];
} else {
$mtnu = 'wis_' . $mtnu[1];
}
echo $a1 . '<img class="pwq' . $mtnu . ' pwqall" onMouseOver="top.hi(this,\'(#' . $pl['id'] . ') <b>' . $pl['name'] . '</b><Br>' . $lvar . '\',event,3,0,1,1,\'width:240px\');" onMouseOut="top.hic();" onMouseDown="top.hic();" style="margin-top:2px; ' . $cl . ' margin-left:1px;" src="https://img.new-combats.com/i/eff/' . $pl['img'] . '.gif" width="40" height="25" />' . $a2;
}
}
}
}
private function zeromax($num, $max)
{
if ($num <= 0) {
return 0;
}
if ($num > $max) {
$num = $max;
}
return $num;
}
/** Ïðè¸ì: Âñïûøêà.
* Ôàéëû: 34, 67, 68, 69.
* @param $level
* @param Battle $btl
* @param $id
* ïåðåäà¸òñÿ ÷åðåç pruse() â íîìåðíîé ôàéë è âûçûâàåòñÿ îòòóäà.
* @return void
*/
private function fireFlash($level, Battle $btl, $id)
{
if (empty($this->ue) || $this->ue['hpNow'] <= 0 || $btl->users[$this->ue['id']]['team'] == $this->u->info['team']) {
return;
}
$baseDamage = [8 => 40, 9 => 45, 10 => 50, 11 => 60];
$pvr = [];
$magicTargetTier = Db::getValue(
'select x from eff_users where uid = ? and v2 = 26 and `delete` = 0',
[$this->ue['id']]
);
$leveledDamage = $baseDamage[$level] + 40 / 100 * (5 * $magicTargetTier);
list($damage, $isCrit, $isMiss) = $this->magicAttack(
$btl, $this->u->info['id'], $this->ue['id'], $leveledDamage, self::FIRE, 1
);
//Èñïîëüçóåì ïðîâåðêó íà óðîí ïðèåìîâ
$damage = $btl->testYronPriem(
$this->u->info['id'], $this->ue['id'], 21, $damage, 5,
true
);
$btl->priemYronSave($this->u->info['id'], $this->ue['id'], $damage, 0);
$this->ue['hpNow'] -= $damage;
$this->ue['hpNow'] = $this->zeromax($this->ue['hpNow'], $this->ue['hpAll']);
$btl->stats[$btl->uids[$this->ue['id']]]['hpNow'] = $this->ue['hpNow'];
Db::sql('update stats set hpNow = ? where id = ?', [$this->ue['hpNow'], $this->ue['id']]);
if ($isMiss) {
$color = $this->logColor['miss'];
} elseif ($isCrit) {
$color = $this->logColor['crit'];
} else {
$color = $this->logColor[self::FIRE];
}
$btl->priemAddLog(
$id,
1,
2,
$this->u->info['id'],
$this->ue['id'],
"<span style^^^^'color: $color'>Âñïûøêà [$level]</span>",
'{tm1}' . sprintf(
" %s <b style='color: %s'>%s</b> [%d/%d]",
$btl->addlt(1, 19, $this->u->info['sex'], null),
$pvr['color'],
$isMiss ? '--' : -$damage,
(int)$this->ue['hpNow'],
(int)$this->ue['hpAll']
),
$btl->hodID + 1
);
}
/** Ïðè¸ì: Öåëü {ñòèõèÿ}
* Ôàéëû: 25, 26, 27, 28.
* @param $element
* @param $pl
* @param $id
* @param Battle $btl
* @return bool (bool) äîñòèãíóò ëè ëèìèò ïî ñòàêó çàêëèíàíèé.
*/
private function magicTarget($element, $pl, $id, Battle $btl)
{
$data = [
self::WATER => [25, 'âîäû'],
self::FIRE => [26, 'îãíÿ'],
self::AIR => [27, 'âîçäóõà'],
self::EARTH => [28, 'çåìëè'],
];
if (!in_array($element, array_keys($data)) || empty($this->ue)) {
return false;
}
$stacked = Db::getRow(
'select id, x from eff_users where uid = ? and v2 = ? and `delete` = 0',
[$this->ue['id'], $data[$element][0]]
);
$stackNumStr = $stacked['x'] > 0 ? $stacked['x'] + 1 : '';
if ($stacked['x'] >= 5) {
echo "<b style='color: {$this->logColor['crit']};'>Íà ïåðîñíàæå äîñòèãíóòî ìàêñèàëüíîå êîëè÷åñòâî öåëåé</b>";
return true;
}
// Íàáðîñ ýôôåêòà îò ïðè¸ìà.
$this->addEffPr($pl, $id);
$dataStr = $stacked['x'] > 0 ? Db::getValue(
'select data from eff_users where id = ?',
[$stacked['id']]
) : $pl['date3'];
// Êîñòûëü. Áóäåò ðàáîòàòü, ïîêà ïðè¸ì èçìåíÿåò ÎÄÈÍ ïàðàìåòð.
$effect = "Çàùèòà îò ìàãèè {$data[$element][1]}: " . current($this->lookStatsArray($dataStr));
$color = $this->logColor[$element];
$name = "Öåëü {$data[$element][1]}";
if ($stacked['x'] > 0) {
$name .= " x($stackNumStr)";
}
$btl->priemAddLog(
$id,
1,
2,
$this->u->info['id'],
$this->ue['id'],
"<span style^^^^'color: $color'>$name</span>",
'{tm1}' . sprintf(
" %s. <i>(%s)</i>",
$btl->addlt(1, 19, $this->u->info['sex'], null), $effect
),
$btl->hodID
);
return false;
}
public function devouringFlame($id, $uid, $j_id, Battle $btl)
{
$a = 0;
$u1 = 0;
$u2 = 0;
//
$uid1 = $btl->atacks[$id]['uid1'];
$uid2 = $btl->atacks[$id]['uid2'];
if ($uid == $uid1) {
$a = 1;
$u1 = $uid1;
$u2 = $uid2;
} elseif ($uid == $uid2) {
$a = 2;
$u1 = $uid2;
$u2 = $uid1;
}
if ($a <= 0) {
return;
}//Ïðîâåðÿåì ýôôåêò
$prv['j_priem'] = $btl->stats[$btl->uids[$u1]]['u_priem'][$j_id][0];
$pvr['data'] = $this->lookStatsArray($btl->stats[$btl->uids[$u1]]['effects'][$prv['j_priem']]['data']);
$pName = $btl->stats[$btl->uids[$u1]]['effects'][$prv['j_priem']]['name'];
$pvr['hp'] = $pvr['data']['atgm'];
$pvr['hpNow'] = floor($btl->stats[$btl->uids[$u1]]['hpNow']);
$pvr['hpAll'] = $btl->stats[$btl->uids[$u1]]['hpAll'];
//Èñïîëüçóåì ïðîâåðêó íà óðîí ïðèåìîâ
$pvr['hp'] = $btl->testYronPriem(
$btl->stats[$btl->uids[$u1]]['effects'][$prv['j_priem']]['user_use'], $u1, 12, $pvr['hp'], 7, true, false, 1
);
$pvr['hpNow'] -= $pvr['hp'];
$btl->priemYronSave($btl->stats[$btl->uids[$u1]]['effects'][$prv['j_priem']]['user_use'], $u1, $pvr['hp'], 0);
$pvr['hpNow'] = $this->zeromax($pvr['hpNow'], $pvr['hpAll']);
$btl->stats[$btl->uids[$u1]]['hpNow'] = $pvr['hpNow'];
Db::sql('update stats set hpNow = ? where id = ?', [$btl->stats[$btl->uids[$u1]]['hpNow'], $u1]);
$color = $this->logColor[self::FIRE];
$prv['text'] = '{u2} óòðàòèë çäîðîâüå îò &quot;{pr}&quot; ';
if ($pvr['promah_type'] == 2) {
$pvr['hp'] = '-';
}
$prv['text'] .= sprintf(
"<b style='color: %s'>%s</b> [%d/%d]", $color, -$pvr['hp'], $pvr['hpNow'], $pvr['hpAll']
);
$btl->priemAddLog(
$id, 1, 2, $u2, $u1, "<span style='color: $color'>$pName</span>", $prv['text'], ($btl->hodID)
);
}
/** Ïîæèðàþùåå ïëàìÿ. Ïåðâè÷íûé êàñò íà ïðîòèâíèêà, íà êîòîðîì íåò ýôôåêòà.
* Êàñòóåòñÿ íà 5 õîäîâ. Ñ÷èòàåò ñêîëüêî óðîíà áóäåò íàíîñèòüñÿ ñëåäóþùèå 5 õîäîâ.
* Êîíå÷íûé damage ïîñëå ìíîæèòåëåé äåëèòñÿ íà 5 è ïèøåòñÿ â ÁÄ (atgm=).
* Ôàéëû: 33, 56, 57, 58, 59, 60.
* @param $id
* @param array $pl ìàññèâ çíà÷åíèé èç ÁÄ priems.
* @param Battle $btl
* @return void
*/
private function devouringFlameInit($id, array $pl, Battle $btl)
{
$baseDamage = [6 => 53, 7 => 63, 8 => 77, 9 => 91, 10 => 110, 11 => 133,];
list($damage, , $isMiss) = $this->magicAttack(
$btl, $this->u->info['id'], $this->ue['id'], $baseDamage[$pl['level']], self::FIRE
);
if ($isMiss || $damage <= 0) {
return;
}
$color = $this->logColor[self::FIRE];
$logText = '{tm1}' . $btl->addlt(1, 19, $btl->users[$btl->uids[$this->u->info['id']]]['sex'], null) . '.';
$btl->priemAddLog(
$id, 1, 2, $this->u->info['id'], $this->ue['id'], "<span style^^^^'color: $color'>{$pl['name']}</span>",
$logText, $btl->hodID + 1
);
$data = $this->impStats(['atgm' => max(floor($damage / 5), 1)]);
$this->addPriem(
$this->ue['id'], $pl['id'], $data, 0, 77, 5, $this->u->info['id'], 1, 'ïîæèðàþùååïëàìÿ', 0, 0, 1
);
}
/** Êðèñòàëëèçàöèÿ. Îòíèìàåò îò ìàêñèìàëüíîãî ñòàòà (êðîìå âûíîñëèâîñòè) 20 íà 3 õîäà.
* Åñëè åñòü îäèíàêîâûå ñòàòû èç íèõ âûáèðàåòñÿ ñëó÷àéíûé.
* Ôàéë:267, ïðè¸ì 268. Ïîíèìàé êàê õî÷åøü.
* @param $id
* @param array $pl
* @param Battle $btl
* @return void
*/
private function crystalize($id, array $pl, Battle $btl)
{
$q = 'select stats as data from stats where id = ?
union all select stats as data from test_bot where id = ?
union all select data from eff_users where `delete` = 0 and uid = ?
union all select data from items_users where inOdet > 0 and `delete` = 0 and uid = ?';
$datas = Db::getColumn($q, array_fill(0, 3, $this->ue['id']));
$stats = array_fill_keys(['s1', 's2', 's3', 's5', 's6'], 0);
foreach ($datas as $data) {
$data = $this->lookStatsArray($data);
print_r($data);
foreach (array_keys($stats) as $stat) {
if (isset($data[$stat])) {
$stats[$stat] += $data[$stat];
}
if (isset($data['add_' . $stat])) {
$stats[$stat] += $data['add_' . $stat];
}
}
}
$maxValue = max($stats);
$maxKeys = [];
foreach ($stats as $k => $v) {
if ($maxValue == $v) {
$maxKeys[] = $k;
}
}
shuffle($maxKeys);
$datastr = "|add_{$maxKeys[0]}=-20";
$debuffstr = "Çàìîðîæåííàÿ " . mb_strtolower($this->u->is[$maxKeys[0]]);
$color = $this->logColor[self::WATER];
$logText = '{tm1}' . $btl->addlt(1, 19, $btl->users[$btl->uids[$this->u->info['id']]]['sex'], null) . '.';
$btl->priemAddLog(
$id, 1, 2, $this->u->info['id'], $this->ue['id'],
"<span style^^^^'color: $color'>{$pl['name']}:</span> $debuffstr", $logText, $btl->hodID + 1
);
$this->addPriem($this->ue['id'], 268, $datastr, 2, 77, 3, $this->u->info['id'], 3, 0, 0, 1);
}
}