2022-06-06 21:30:34 +00:00
< ? php
if ( ! defined ( 'GAME' ))
{
die ();
}
2022-12-19 20:16:24 +00:00
class Magic
2022-06-06 21:30:34 +00:00
{
public $youuse = 0 ;
2023-01-10 16:29:32 +00:00
//Ослабление после боя
2022-06-06 21:30:34 +00:00
public function oslablenie ( $uid )
{
2023-01-10 16:29:32 +00:00
$ins = mysql_query ( 'INSERT INTO `eff_users` (`id_eff`,`uid`,`name`,`data`,`timeUse`) VALUES ("5","' . $uid . '","Ослабление после боя","add_m10=-1000|add_m11=-1000","' . time () . '")' );
2022-06-06 21:30:34 +00:00
if ( $ins )
{
return true ;
} else {
return false ;
}
}
2023-01-10 16:29:32 +00:00
//Использование предмета
2022-06-06 21:30:34 +00:00
public function useItems ( $id )
{
global $u , $c , $code ;
$itm = mysql_fetch_array ( mysql_query ( 'SELECT `im`.*,`iu`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) WHERE `iu`.`uid` = "' . $u -> info [ 'id' ] . '" AND `iu`.`id` = "' . mysql_real_escape_string (( int ) $id ) . '" LIMIT 1' ));
if ( isset ( $itm [ 'id' ]))
{
$st = $u -> lookStats ( $itm [ 'data' ]);
if ( isset ( $st [ 'usefromfile' ]) && $st [ 'usefromfile' ] == 1 )
{
if ( file_exists ( '_incl_data/class/magic/' . $itm [ 'magic_inci' ] . '.php' ))
{
require ( '_incl_data/class/magic/' . $itm [ 'magic_inci' ] . '.php' );
} else {
2023-01-10 16:29:32 +00:00
$u -> error = '7Н е удалось использовать (' . $itm [ 'magic_inci' ] . ')' ;
2022-06-06 21:30:34 +00:00
}
} elseif ( $itm [ 'type' ] == 30 )
{
2023-01-10 16:29:32 +00:00
//Эликсиры
2022-06-06 21:30:34 +00:00
$goodUse = 0 ; $use = array ();
if ( isset ( $st [ 'moment' ]))
{
2023-01-10 16:29:32 +00:00
//Эликсир используется моментально (Восстановление Н Р или М Р )
2022-06-06 21:30:34 +00:00
if ( isset ( $st [ 'moment_hp' ]))
{
2023-01-10 16:29:32 +00:00
//Восстанавливаем здоровье
2022-06-06 21:30:34 +00:00
if ( $u -> stats [ 'hpNow' ] < $u -> stats [ 'hpAll' ])
{
$goodUse = 1 ;
$use [ 'moment_hp' ] = $st [ 'moment_hp' ];
if ( $u -> stats [ 'hpNow' ] + $use [ 'moment_hp' ] > $u -> stats [ 'hpAll' ])
{
$use [ 'moment_hp' ] = ceil ( $u -> stats [ 'hpAll' ] - $u -> stats [ 'hpNow' ]);
}
2023-01-10 16:29:32 +00:00
$u -> error .= 'Вы восстановили ' . ( $use [ 'moment_hp' ]) . ' HP.<br>' ;
2022-06-06 21:30:34 +00:00
} else {
2023-01-10 16:29:32 +00:00
$u -> error = 'Ваше здоровье и так полностью восстановлено' ;
2022-06-06 21:30:34 +00:00
$goodUse = 0 ;
}
}
if ( isset ( $st [ 'moment_mp' ]))
{
2023-01-10 16:29:32 +00:00
//Восстанавливаем здоровье
2022-06-06 21:30:34 +00:00
if ( $u -> stats [ 'mpNow' ] < $u -> stats [ 'mpAll' ])
{
$goodUse = 1 ;
$use [ 'moment_mp' ] = $st [ 'moment_mp' ];
if ( $u -> stats [ 'mpNow' ] + $use [ 'moment_mp' ] > $u -> stats [ 'mpAll' ])
{
$use [ 'moment_mp' ] = ceil ( $u -> stats [ 'mpAll' ] - $u -> stats [ 'mpNow' ]);
}
2023-01-10 16:29:32 +00:00
$u -> error .= 'Вы восстановили ' . ( $use [ 'moment_mp' ]) . ' MP.<br>' ;
2022-06-06 21:30:34 +00:00
} else {
2023-01-10 16:29:32 +00:00
$u -> error = 'Ваша манна и так полностью восстановлена' ;
2022-06-06 21:30:34 +00:00
$goodUse = 0 ;
}
}
if ( $itm [ 'iznosNOW' ] >= $itm [ 'iznosMAX' ])
{
2023-01-10 16:29:32 +00:00
$u -> error = 'Эликсир был испорчен...' ;
2022-06-06 21:30:34 +00:00
$goodUse = 0 ;
}
if (( $u -> info [ 'align' ] == 2 || $u -> info [ 'haos' ] > time ()) && isset ( $st [ 'nohaos' ]))
{
$goodUse = 0 ;
2023-01-10 16:29:32 +00:00
$u -> error = 'Хаосники не могут использовать данный эликсир' ;
2022-06-06 21:30:34 +00:00
}
2023-01-10 16:29:32 +00:00
//Заносим данные в БД
2022-06-06 21:30:34 +00:00
if ( $goodUse == 1 )
{
$itm [ 'iznosNOW' ] ++ ;
$upd = mysql_query ( 'UPDATE `items_users` SET `iznosNOW` = "' . $itm [ 'iznosNOW' ] . '" WHERE `id` = "' . $itm [ 'id' ] . '" AND `uid` = "' . $u -> info [ 'id' ] . '" LIMIT 1' );
if ( $upd )
{
$u -> stats [ 'hpNow' ] += $use [ 'moment_hp' ];
$u -> info [ 'hpNow' ] += $use [ 'moment_hp' ];
mysql_query ( 'UPDATE `stats` SET `hpNow` = "' . $u -> info [ 'hpNow' ] . '" WHERE `id` = "' . $u -> info [ 'id' ] . '" LIMIT 1' );
2023-01-10 16:29:32 +00:00
$u -> addDelo ( 1 , $u -> info [ 'id' ], '"<font color="maroon">System.inventory</font>": Персонаж использовал эликсир "' . $itm [ 'name' ] . '" (+' . $use [ 'moment_hp' ] . ' HP) [itm:' . $itm [ 'id' ] . '].' , time (), $u -> info [ 'city' ], 'System.inventory' , 0 , 0 );
2022-06-06 21:30:34 +00:00
$this -> youuse ++ ;
2023-01-10 16:29:32 +00:00
$u -> error = 'Вы успешно использовали эликсир "' . $itm [ 'name' ] . '"<br>' . $u -> error . '' ;
2022-06-06 21:30:34 +00:00
} else {
2023-01-10 16:29:32 +00:00
$u -> error = 'Н е удалось использовать эликсир...' ;
2022-06-06 21:30:34 +00:00
}
}
} else {
2023-01-10 16:29:32 +00:00
//Эликсиры с продолжительным эффектом
2022-06-06 21:30:34 +00:00
$goodUse = 1 ;
if (( $u -> info [ 'align' ] == 2 || $u -> info [ 'haos' ] > time ()) && isset ( $st [ 'nohaos' ]))
{
$goodUse = 0 ;
2023-01-10 16:29:32 +00:00
$u -> error = 'Хаосники не могут использовать данный эликсир' ;
2022-06-06 21:30:34 +00:00
}
if ( $goodUse == 1 )
{
$upd1 = 1 ;
$upd2 = 1 ;
2023-01-10 16:29:32 +00:00
//добавляем эффект персонажу
2022-06-06 21:30:34 +00:00
if ( isset ( $st [ 'onlyOne' ]))
{
2023-01-10 16:29:32 +00:00
//убираем прошлые эффекты
2022-06-06 21:30:34 +00:00
$goodUse = 0 ;
$upd1 = mysql_query ( 'UPDATE `eff_users` SET `delete` = "' . time () . '" WHERE `uid` = "' . $u -> info [ 'id' ] . '" AND `delete` = "0" AND `id_eff` = "' . $itm [ 'magic_inc' ] . '"' );
if ( $upd1 )
{
$goodUse = 1 ;
}
}
if ( isset ( $st [ 'oneType' ]))
{
2023-01-10 16:29:32 +00:00
//убираем прошлые эффекты
2022-06-06 21:30:34 +00:00
$goodUse = 0 ;
$upd2 = mysql_query ( 'UPDATE `eff_users` SET `delete` = "' . time () . '" WHERE `uid` = "' . $u -> info [ 'id' ] . '" AND `delete` = "0" AND `overType` = "' . $itm [ 'overType' ] . '"' );
if ( $upd1 )
{
$goodUse = 1 ;
}
}
if ( $goodUse == 1 )
{
$us = $this -> add_eff ( $u -> info [ 'id' ], $itm [ 'magic_inc' ]);
if ( $us [ 0 ] == 1 )
{
$itm [ 'iznosNOW' ] ++ ;
mysql_query ( 'UPDATE `items_users` SET `iznosNOW` = "' . $itm [ 'iznosNOW' ] . '" WHERE `id` = "' . $itm [ 'id' ] . '" AND `uid` = "' . $u -> info [ 'id' ] . '" LIMIT 1' );
2023-01-10 16:29:32 +00:00
$u -> addDelo ( 1 , $u -> info [ 'id' ], '"<font color="maroon">System.inventory</font>": Персонаж использовал эликсир "' . $itm [ 'name' ] . '" (' . $us [ 1 ] . ') [itm:' . $itm [ 'id' ] . '].' , time (), $u -> info [ 'city' ], 'System.inventory' , 0 , 0 );
2022-06-06 21:30:34 +00:00
$this -> youuse ++ ;
2023-01-10 16:29:32 +00:00
$u -> error = 'Вы успешно использовали эликсир "' . $itm [ 'name' ] . '"<br>' . $us [ 1 ] . '' ;
2022-06-06 21:30:34 +00:00
} else {
2023-01-10 16:29:32 +00:00
$u -> error = '6Н е удалось использовать "' . $itm [ 'name' ] . '"' ;
2022-06-06 21:30:34 +00:00
}
} else {
2023-01-10 16:29:32 +00:00
$u -> error = '5Н е удалось использовать "' . $itm [ 'name' ] . '"' ;
2022-06-06 21:30:34 +00:00
}
}
}
//---------------
} elseif ( $itm [ 'type' ] == 29 )
{
2023-01-10 16:29:32 +00:00
//используем заклятие
2022-06-06 21:30:34 +00:00
$st = $u -> lookStats ( $itm [ 'data' ]);
$jl = $_GET [ 'login' ];
$_GET [ 'login' ] = urlencode ( $_GET [ 'login' ]);
2023-01-10 16:29:32 +00:00
//используем на персонажа (все кроме себя)
2022-06-06 21:30:34 +00:00
$_GET [ 'login' ] = str_replace ( '%' , ' ' , $_GET [ 'login' ]);
$_GET [ 'login' ] = str_replace ( '25' , '' , $_GET [ 'login' ]);
$jl = str_replace ( '%' , ' ' , $jl );
$jl = str_replace ( '25' , '' , $jl );
if ( isset ( $st [ 'useOnLogin' ]) && $st [ 'useOnLogin' ] == 1 )
{
$usr = mysql_fetch_array ( mysql_query ( 'SELECT `st`.`hpNow`,`u`.`login`,`st`.`dnow`,`u`.`id`,`u`.`align`,`u`.`admin`,`u`.`clan`,`u`.`level`,`u`.`room`,`u`.`online`,`u`.`battle`,`st`.`team` FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON (`u`.`id` = `st`.`id`) WHERE `u`.`city` = "' . $u -> info [ 'city' ] . '" AND (`u`.`login`="' . mysql_real_escape_string ( $_GET [ 'login' ]) . '" OR `u`.`login`="' . mysql_real_escape_string ( $jl ) . '") LIMIT 1' ));
if ( isset ( $usr [ 'id' ]))
{
if ( $itm [ 'iznosNOW' ] >= $itm [ 'iznosMAX' ])
{
2023-01-10 16:29:32 +00:00
$u -> error = 'Свиток был исполчен...' ;
2022-06-06 21:30:34 +00:00
} elseif ( $itm [ 'magic_inci' ] == 'snowball' )
{
if ( $usr [ 'id' ] == $u -> info [ 'id' ])
{
2023-01-10 16:29:32 +00:00
$u -> error = 'Нельзя кидаться в самого себя' ;
2022-06-06 21:30:34 +00:00
} elseif ( $usr [ 'online' ] < time () - 120 )
{
2023-01-10 16:29:32 +00:00
$u -> error = 'Персонаж находится в реальном мире ;)' ;
2022-06-06 21:30:34 +00:00
} elseif ( $usr [ 'room' ] != $u -> info [ 'room' ])
{
2023-01-10 16:29:32 +00:00
$u -> error = 'Персонаж находится в другой комнате [' . $usr [ 'room' ] . ' ' . $u -> info [ 'room' ] . ']' ;
2022-06-06 21:30:34 +00:00
} elseif ( $usr [ 'admin' ] > 0 && $u -> info [ 'admin' ] == 0 )
{
2023-01-10 16:29:32 +00:00
$u -> error = 'Нельзя кидаться в Ангелов' ;
2022-06-06 21:30:34 +00:00
} elseif ( $usr [ 'battle' ] > 0 && $u -> info [ 'battle' ] != $usr [ 'battle' ])
{
2023-01-10 16:29:32 +00:00
$u -> error = 'Персонаж находится в бою' ;
2022-06-06 21:30:34 +00:00
} else {
$usr [ 'hpNow' ] -= 1000 ;
if ( $usr [ 'hpNow' ] < 0 )
{
$usr [ 'hpNow' ] = 0 ;
}
$upd = mysql_query ( 'UPDATE `stats` SET `hpNow` = "' . $usr [ 'hpNow' ] . '" WHERE `id` = "' . $usr [ 'id' ] . '" LIMIT 1' );
if ( $upd )
{
2023-01-10 16:29:32 +00:00
$sx = 'ый' ; $sx2 = '' ;
2022-06-06 21:30:34 +00:00
if ( $u -> info [ 'sex' ] == 1 )
{
2023-01-10 16:29:32 +00:00
$sx = 'ая' ; $sx2 = 'а ' ;
2022-06-06 21:30:34 +00:00
}
$itm [ 'iznosNOW' ] ++ ;
mysql_query ( 'UPDATE `items_users` SET `iznosNOW` = "' . $itm [ 'iznosNOW' ] . '" WHERE `id` = "' . $itm [ 'id' ] . '" AND `uid` = "' . $u -> info [ 'id' ] . '" LIMIT 1' );
2023-01-10 16:29:32 +00:00
$rtxt = '[img[items/snowball1.gif]] Хитр' . $sx . ' "' . $u -> info [ 'login' ] . '" бросил' . $sx2 . ' кусок снега в "' . $usr [ 'login' ] . '". <font color=red><b>-1000</b></font> [' . $usr [ 'hpNow' ] . '/????]' ;
2022-06-06 21:30:34 +00:00
mysql_query ( " INSERT INTO `chat` (`city`,`room`,`login`,`to`,`text`,`time`,`type`,`toChat`,`typeTime`) VALUES (' " . $u -> info [ 'city' ] . " ',' " . $u -> info [ 'room' ] . " ','','',' " . $rtxt . " ',' " . time () . " ','11','0','1') " );
unset ( $sx , $sx2 );
} else {
2023-01-10 16:29:32 +00:00
$u -> error = 'Н е удалось кинуть снежок...' ;
2022-06-06 21:30:34 +00:00
}
}
} elseif ( $itm [ 'magic_inci' ] == 'atack' )
{
2023-01-10 16:29:32 +00:00
//заклятье нападения
$usta = $u -> getStats ( $usr [ 'id' ], 0 ); // статы цели
$minHp = $usta [ 'hpAll' ] / 100 * 33 ; // минимальный запас здоровья цели при котором можно напасть
2022-06-06 21:30:34 +00:00
if ( $u -> info [ 'dnow' ] != $usr [ 'dnow' ]){
2023-01-10 16:29:32 +00:00
$u -> error = 'Персонаж находится в другой комнате [пещера]' ;
2022-06-06 21:30:34 +00:00
} elseif ( $u -> info [ 'battle' ] > 0 ){
2023-01-10 16:29:32 +00:00
$u -> error = 'Вы уже находитесь в бою' ;
2022-06-06 21:30:34 +00:00
} elseif ( $usr [ 'id' ] == $u -> info [ 'id' ]){
2023-01-10 16:29:32 +00:00
$u -> error = 'Нельзя нападать на самого себя' ;
2022-06-06 21:30:34 +00:00
} elseif ( $usr [ 'online' ] < time () - 120 ){
2023-01-10 16:29:32 +00:00
$u -> error = 'Персонаж находится в реальном мире' ;
2022-06-06 21:30:34 +00:00
} elseif ( $usr [ 'room' ] != $u -> info [ 'room' ]){
2023-01-10 16:29:32 +00:00
$u -> error = 'Персонаж находится в другой комнате [' . $usr [ 'room' ] . ' ' . $u -> info [ 'room' ] . ']' ;
2022-06-06 21:30:34 +00:00
} elseif ( $usr [ 'admin' ] > 0 && $u -> info [ 'admin' ] == 0 ){
2023-01-10 16:29:32 +00:00
$u -> error = 'Нельзя нападать на Ангелов' ;
2022-06-06 21:30:34 +00:00
} elseif ( $minHp > $usta [ 'hpNow' ]){
2023-01-10 16:29:32 +00:00
//мало хп
$u -> error = 'Персонаж имеет слишком малый уровень жизней.' ;
2022-06-06 21:30:34 +00:00
} else {
$atc = $this -> atackUser ( $u -> info [ 'id' ], $usr [ 'id' ], $usr [ 'team' ], $usr [ 'battle' ]);
if ( $atc == 1 && $u -> info [ 'align' ] != 2 ){
2023-01-10 16:29:32 +00:00
//отправляем системку в чат
2022-06-06 21:30:34 +00:00
$sx = '' ;
if ( $u -> info [ 'sex' ] == 1 ){
2023-01-10 16:29:32 +00:00
$sx = 'а ' ;
2022-06-06 21:30:34 +00:00
}
$itm [ 'iznosNOW' ] ++ ;
mysql_query ( 'UPDATE `items_users` SET `iznosNOW` = "' . $itm [ 'iznosNOW' ] . '" WHERE `id` = "' . $itm [ 'id' ] . '" AND `uid` = "' . $u -> info [ 'id' ] . '" LIMIT 1' );
2023-01-10 16:29:32 +00:00
$rtxt = '[img[items/pal_button8.gif]] "' . $u -> info [ 'login' ] . '" использовал' . $sx . ' магию нападения на персонажа "' . $usr [ 'login' ] . '".' ;
2022-06-06 21:30:34 +00:00
mysql_query ( " INSERT INTO `chat` (`city`,`room`,`login`,`to`,`text`,`time`,`type`,`toChat`,`typeTime`) VALUES (' " . $u -> info [ 'city' ] . " ',' " . $u -> info [ 'room' ] . " ','','',' " . $rtxt . " ',' " . time () . " ','11','0','1') " );
2023-01-10 16:29:32 +00:00
//напали, обновляем экран
2022-06-06 21:30:34 +00:00
die ( '<script>top.frames[\'main\'].location = "main.php";</script>' );
} else {
2023-01-10 16:29:32 +00:00
$u -> error = 'Н е удалось напасть на персонажа...' ;
2022-06-06 21:30:34 +00:00
}
}
} else {
2023-01-10 16:29:32 +00:00
//просто используем на персонажа
2022-06-06 21:30:34 +00:00
if ( $u -> info [ 'dnow' ] != $usr [ 'dnow' ])
{
2023-01-10 16:29:32 +00:00
$u -> error = 'Персонаж находится в другой комнате [пещера]' ;
2022-06-06 21:30:34 +00:00
} elseif ( $usr [ 'id' ] == $u -> info [ 'id' ] && isset ( $st [ 'useOnlyUser' ]))
{
2023-01-10 16:29:32 +00:00
$u -> error = 'Нельзя использовать это заклятие на самого себя' ;
2022-06-06 21:30:34 +00:00
} elseif ( $usr [ 'online' ] < time () - 120 )
{
2023-01-10 16:29:32 +00:00
$u -> error = 'Персонаж находится в реальном мире ;)' ;
2022-06-06 21:30:34 +00:00
} elseif ( $usr [ 'room' ] != $u -> info [ 'room' ])
{
2023-01-10 16:29:32 +00:00
$u -> error = 'Персонаж находится в другой комнате [' . $usr [ 'room' ] . ' ' . $u -> info [ 'room' ] . ']' ;
2022-06-06 21:30:34 +00:00
} elseif ( $usr [ 'admin' ] > 0 && $u -> info [ 'admin' ] == 0 && isset ( $st [ 'useNoAdmin' ]))
{
2023-01-10 16:29:32 +00:00
$u -> error = 'Нельзя использовать данное заклятие на Ангелов' ;
2022-06-06 21:30:34 +00:00
} elseif ( $usr [ 'battle' ] > 0 && $u -> info [ 'battle' ] != $usr [ 'battle' ])
{
2023-01-10 16:29:32 +00:00
$u -> error = 'Персонаж находится в бою' ;
2022-06-06 21:30:34 +00:00
} elseif (( $u -> info [ 'align' ] == 2 || $u -> info [ 'haos' ] > time ()) && isset ( $st [ 'nohaos' ]))
{
2023-01-10 16:29:32 +00:00
$u -> error = 'Хаосники не могут использовать данное заклятие' ;
2022-06-06 21:30:34 +00:00
} else {
2023-01-10 16:29:32 +00:00
//добавляем эффект персонажу
2022-06-06 21:30:34 +00:00
$goodUse = 1 ;
if ( isset ( $st [ 'onlyOne' ]))
{
2023-01-10 16:29:32 +00:00
//убираем прошлые эффекты
2022-06-06 21:30:34 +00:00
$goodUse = 0 ;
$upd1 = mysql_query ( 'UPDATE `eff_users` SET `delete` = "' . time () . '" WHERE `uid` = "' . $usr [ 'id' ] . '" AND `delete` = "0" AND `id_eff` = "' . $itm [ 'magic_inc' ] . '"' );
if ( $upd1 )
{
$goodUse = 1 ;
}
}
if ( isset ( $st [ 'oneType' ]))
{
2023-01-10 16:29:32 +00:00
//убираем прошлые эффекты
2022-06-06 21:30:34 +00:00
$goodUse = 0 ;
$upd2 = mysql_query ( 'UPDATE `eff_users` SET `delete` = "' . time () . '" WHERE `uid` = "' . $usr [ 'id' ] . '" AND `delete` = "0" AND `overType` = "' . $itm [ 'overType' ] . '"' );
if ( $upd1 )
{
$goodUse = 1 ;
}
}
if ( $goodUse == 1 )
{
$us = $this -> add_eff ( $usr [ 'id' ], $itm [ 'magic_inc' ]);
if ( $us [ 0 ] == 1 )
{
$itm [ 'iznosNOW' ] ++ ;
mysql_query ( 'UPDATE `items_users` SET `iznosNOW` = "' . $itm [ 'iznosNOW' ] . '" WHERE `id` = "' . $itm [ 'id' ] . '" AND `uid` = "' . $u -> info [ 'id' ] . '" LIMIT 1' );
if ( $u -> info [ 'id' ] != $usr [ 'id' ])
{
2023-01-10 16:29:32 +00:00
$u -> addDelo ( 1 , $u -> info [ 'id' ], '"<font color="maroon">System.inventory</font>": Персонаж использовал заклинание "' . $itm [ 'name' ] . '" (' . $us [ 1 ] . ') на персонажа "' . $usr [ 'login' ] . '" (id' . $usr [ 'id' ] . ') [itm:' . $itm [ 'id' ] . '].' , time (), $u -> info [ 'city' ], 'System.inventory' , 0 , 0 );
$u -> addDelo ( 1 , $usr [ 'id' ], '"<font color="maroon">System.inventory</font>": Персонаж "' . $u -> info [ 'login' ] . '" (id' . $u -> info [ 'id' ] . ') использовал заклинание "' . $itm [ 'name' ] . '" (' . $us [ 1 ] . ') на персонажа [itm:' . $itm [ 'id' ] . '].' , time (), $usr [ 'city' ], 'System.inventory' , 0 , 0 );
$u -> error = 'Вы успешно использовали заклинание "' . $itm [ 'name' ] . '" на персонажа "' . $usr [ 'login' ] . '"<br>' . $us [ 1 ] . '' ;
$rtxt = '[img[items/' . $itm [ 'img' ] . ']] "' . $u -> info [ 'login' ] . '" использовал' . $sx . ' заклинание "' . $itm [ 'name' ] . '" на персонажа "' . $usr [ 'login' ] . '".' ;
2022-06-06 21:30:34 +00:00
mysql_query ( " INSERT INTO `chat` (`city`,`room`,`login`,`to`,`text`,`time`,`type`,`toChat`,`typeTime`) VALUES (' " . $u -> info [ 'city' ] . " ',' " . $u -> info [ 'room' ] . " ','','',' " . $rtxt . " ',' " . time () . " ','11','0','1') " );
} else {
2023-01-10 16:29:32 +00:00
$u -> addDelo ( 1 , $u -> info [ 'id' ], '"<font color="maroon">System.inventory</font>": Персонаж использовал заклинание "' . $itm [ 'name' ] . '" (' . $us [ 1 ] . ') на персонажа самого себя [itm:' . $itm [ 'id' ] . '].' , time (), $u -> info [ 'city' ], 'System.inventory' , 0 , 0 );
$u -> error = 'Вы успешно использовали заклинание "' . $itm [ 'name' ] . '" на самого себя<br>' . $us [ 1 ] . '' ;
$rtxt = '[img[items/' . $itm [ 'img' ] . ']] "' . $u -> info [ 'login' ] . '" использовал' . $sx . ' заклинание "' . $itm [ 'name' ] . '" на себя.' ;
2022-06-06 21:30:34 +00:00
mysql_query ( " INSERT INTO `chat` (`city`,`room`,`login`,`to`,`text`,`time`,`type`,`toChat`,`typeTime`) VALUES (' " . $u -> info [ 'city' ] . " ',' " . $u -> info [ 'room' ] . " ','','',' " . $rtxt . " ',' " . time () . " ','11','0','1') " );
}
$this -> youuse ++ ;
} else {
2023-01-10 16:29:32 +00:00
$u -> error = '1Н е удалось использовать "' . $itm [ 'name' ] . '"' ;
2022-06-06 21:30:34 +00:00
}
} else {
2023-01-10 16:29:32 +00:00
$u -> error = '2Н е удалось использовать "' . $itm [ 'name' ] . '"' ;
2022-06-06 21:30:34 +00:00
}
}
}
} else {
2023-01-10 16:29:32 +00:00
$u -> error = 'Персонаж "' . $jl . '" не найден в этом городе (' . $u -> info [ 'city' ] . ')' ;
2022-06-06 21:30:34 +00:00
}
} elseif ( isset ( $st [ 'useOnItem' ]) && $st [ 'useOnItem' ] == 1 )
{
2023-01-10 16:29:32 +00:00
//используем на предмет
2022-06-06 21:30:34 +00:00
} else {
2023-01-10 16:29:32 +00:00
//на себя
2022-06-06 21:30:34 +00:00
$goodUse = 1 ;
if (( $u -> info [ 'align' ] == 2 || $u -> info [ 'haos' ] > time ()) && isset ( $st [ 'nohaos' ]))
{
$goodUse = 0 ;
2023-01-10 16:29:32 +00:00
$u -> error = 'Хаосники не могут использовать данное заклятие' ;
2022-06-06 21:30:34 +00:00
}
if ( $goodUse == 1 )
{
$upd1 = 1 ;
$upd2 = 1 ;
2023-01-10 16:29:32 +00:00
//добавляем эффект персонажу
2022-06-06 21:30:34 +00:00
if ( isset ( $st [ 'onlyOne' ]))
{
2023-01-10 16:29:32 +00:00
//убираем прошлые эффекты
2022-06-06 21:30:34 +00:00
$goodUse = 0 ;
$upd1 = mysql_query ( 'UPDATE `eff_users` SET `delete` = "' . time () . '" WHERE `uid` = "' . $u -> info [ 'id' ] . '" AND `delete` = "0" AND `id_eff` = "' . $itm [ 'magic_inc' ] . '"' );
if ( $upd1 )
{
$goodUse = 1 ;
}
}
if ( isset ( $st [ 'oneType' ]))
{
2023-01-10 16:29:32 +00:00
//убираем прошлые эффекты
2022-06-06 21:30:34 +00:00
$goodUse = 0 ;
$upd2 = mysql_query ( 'UPDATE `eff_users` SET `delete` = "' . time () . '" WHERE `uid` = "' . $u -> info [ 'id' ] . '" AND `delete` = "0" AND `overType` = "' . $itm [ 'overType' ] . '"' );
if ( $upd1 )
{
$goodUse = 1 ;
}
}
if ( $itm [ 'magic_inci' ] == 'add_animal' )
{
if ( $u -> info [ 'animal' ] > 0 )
{
2023-01-10 16:29:32 +00:00
$u -> error = 'Н е удалось использовать "' . $itm [ 'name' ] . '", у В а с уже есть зверь.' ;
2022-06-06 21:30:34 +00:00
} else {
$anm = array ( 'type' => 1 , 'name' => '' , 'obraz' => '' , 'stats' => '' , 'sex' => 0 );
if ( $anm [ 'type' ] == 1 )
{
2023-01-10 16:29:32 +00:00
$anm [ 'name' ] = 'Кот' ;
2022-06-06 21:30:34 +00:00
$anm [ 'sex' ] = 0 ;
$anm [ 'obraz' ] = array ( 1 => '20132.gif' , 2 => '21139.gif' , 3 => '20864.gif' , 4 => '21301.gif' );
$anm [ 'stats' ] = 's1=2|s2=2|s3=2|s4=5|rinv=40|m9=5|m6=10' ;
}
$anm [ 'obraz' ] = $anm [ 'obraz' ][ rand ( 1 , count ( $anm [ 'obraz' ]))];
$ins = mysql_query ( 'INSERT INTO `users_animal` (`type`,`name`,`uid`,`obraz`,`stats`,`sex`) VALUES ("' . $anm [ 'type' ] . '","' . $anm [ 'name' ] . '","' . $u -> info [ 'id' ] . '","' . $anm [ 'obraz' ] . '","' . $anm [ 'stats' ] . '","' . $anm [ 'sex' ] . '")' );
if ( $ins )
{
$u -> info [ 'animal' ] = mysql_insert_id ();
mysql_query ( 'UPDATE `users` SET `animal` = "' . $u -> info [ 'animal' ] . '" WHERE `id` = "' . $u -> info [ 'id' ] . '" LIMIT 1' );
2023-01-10 16:29:32 +00:00
$u -> error = 'Вы успешно использовали "' . $itm [ 'name' ] . '" и помните - "Мы в ответе за тех, кого приручили".' ;
2022-06-06 21:30:34 +00:00
$itm [ 'iznosNOW' ] ++ ;
mysql_query ( 'UPDATE `items_users` SET `iznosNOW` = "' . $itm [ 'iznosNOW' ] . '" WHERE `id` = "' . $itm [ 'id' ] . '" AND `uid` = "' . $u -> info [ 'id' ] . '" LIMIT 1' );
2023-01-10 16:29:32 +00:00
$u -> addDelo ( 1 , $u -> info [ 'id' ], '"<font color="maroon">System.inventory</font>": Персонаж использовал заклинание "' . $itm [ 'name' ] . '" (' . $us [ 1 ] . ') [itm:' . $itm [ 'id' ] . '].' , time (), $u -> info [ 'city' ], 'System.inventory' , 0 , 0 );
2022-06-06 21:30:34 +00:00
} else {
2023-01-10 16:29:32 +00:00
$u -> error = 'Н е удалось использовать "' . $itm [ 'name' ] . '", что-то здесь не так ...' ;
2022-06-06 21:30:34 +00:00
}
}
} elseif ( $goodUse == 1 )
{
$us = $this -> add_eff ( $u -> info [ 'id' ], $itm [ 'magic_inc' ]);
if ( $us [ 0 ] == 1 )
{
$itm [ 'iznosNOW' ] ++ ;
mysql_query ( 'UPDATE `items_users` SET `iznosNOW` = "' . $itm [ 'iznosNOW' ] . '" WHERE `id` = "' . $itm [ 'id' ] . '" AND `uid` = "' . $u -> info [ 'id' ] . '" LIMIT 1' );
2023-01-10 16:29:32 +00:00
$u -> addDelo ( 1 , $u -> info [ 'id' ], '"<font color="maroon">System.inventory</font>": Персонаж использовал заклинание "' . $itm [ 'name' ] . '" (' . $us [ 1 ] . ') [itm:' . $itm [ 'id' ] . '].' , time (), $u -> info [ 'city' ], 'System.inventory' , 0 , 0 );
2022-06-06 21:30:34 +00:00
$this -> youuse ++ ;
2023-01-10 16:29:32 +00:00
$u -> error = 'Вы успешно использовали заклинание "' . $itm [ 'name' ] . '"<br>' . $us [ 1 ] . '' ;
$rtxt = '[img[items/' . $itm [ 'img' ] . ']] "' . $u -> info [ 'login' ] . '" использовал' . $sx . ' заклинание "' . $itm [ 'name' ] . '" на себя.' ;
2022-06-06 21:30:34 +00:00
mysql_query ( " INSERT INTO `chat` (`city`,`room`,`login`,`to`,`text`,`time`,`type`,`toChat`,`typeTime`) VALUES (' " . $u -> info [ 'city' ] . " ',' " . $u -> info [ 'room' ] . " ','','',' " . $rtxt . " ',' " . time () . " ','11','0','1') " );
} else {
2023-01-10 16:29:32 +00:00
$u -> error = '3Н е удалось использовать "' . $itm [ 'name' ] . '"' ;
2022-06-06 21:30:34 +00:00
}
} else {
2023-01-10 16:29:32 +00:00
$u -> error = '4Н е удалось использовать "' . $itm [ 'name' ] . '"' ;
2022-06-06 21:30:34 +00:00
}
}
//------------------------------
}
}
} else {
2023-01-10 16:29:32 +00:00
$u -> error = 'Предмет не найден в инвентаре' ;
2022-06-06 21:30:34 +00:00
}
}
public function add_eff ( $uid , $id )
{
$g = array ( 0 => 0 , 1 => '' );
$eff = mysql_fetch_array ( mysql_query ( 'SELECT * FROM `eff_main` WHERE `id2` = "' . $id . '" LIMIT 1' ));
if ( isset ( $eff [ 'id2' ]))
{
$n = $eff [ 'mname' ];
$d = $eff [ 'mdata' ];
$ins = mysql_query ( 'INSERT INTO `eff_users` (`overType`,`id_eff`,`uid`,`name`,`timeUse`,`data`) VALUES ("' . $eff [ 'oneType' ] . '","' . $eff [ 'id2' ] . '","' . $uid . '","' . $n . '","' . time () . '","' . $d . '")' );
if ( $ins )
{
$g [ 0 ] = 1 ;
$g [ 1 ] = '...' ;
}
}
return $g ;
}
2023-01-10 16:29:32 +00:00
//создаем нападение на персонажа
2022-06-06 21:30:34 +00:00
public function atackUser ( $uid1 , $uid2 , $tm , $btl , $addExp = 0 )
{
$good = 0 ;
if ( $btl == 0 )
{
2023-01-10 16:29:32 +00:00
//нападаем на персонажа
2022-06-06 21:30:34 +00:00
$ins = mysql_query ( ' INSERT INTO `battle` ( `city` , `time_start` , `players` , `timeout` , `type` , `invis` , `noinc` , `travmChance` , `typeBattle` , `addExp` , `money` ) VALUES (
" '. $u->info ['city'].' " ,
" '.time().' " ,
" '. $u->info ['login'].','. $usr['login'] .' " ,
" 180 " ,
" 0 " ,
" 0 " ,
" 0 " ,
" 50 " ,
" 9 " ,
" '. $addExp .' " ,
" 0 " ) ' );
if ( $ins )
{
$btl_id = mysql_insert_id ();
$upd2 = mysql_query ( 'UPDATE `users` SET `battle`="' . $btl_id . '" WHERE `id` = "' . $uid1 . '" OR `id` = "' . $uid2 . '" LIMIT 2' );
mysql_query ( 'UPDATE `stats` SET `team`="1",`zv` = "0" WHERE `id` = "' . $uid1 . '" LIMIT 1' );
mysql_query ( 'UPDATE `stats` SET `team`="2",`zv` = "0" WHERE `id` = "' . $uid2 . '" LIMIT 1' );
$good = 1 ;
}
} else {
2023-01-10 16:29:32 +00:00
//вмешиваемся в бой
2022-06-06 21:30:34 +00:00
$upd = mysql_query ( 'UPDATE `users` SET `battle`="' . $btl . '" WHERE `id` = "' . $uid1 . '" LIMIT 1' );
if ( $upd )
{
$ltm = array ( 1 => 2 , 2 => 1 );
mysql_query ( 'UPDATE `stats` SET `team`="' . $ltm [ $tm ] . '" WHERE `id` = "' . $uid1 . '" LIMIT 1' );
$good = 1 ;
}
}
return $good ;
}
2023-01-10 16:29:32 +00:00
//Нападение на центральной площади
2022-06-06 21:30:34 +00:00
public function magicCentralAttack ()
{
global $c , $code , $u , $re ;
}
}
$magic = new Magic ;
?>