game/_incl_data/class/dnaction/101/viboina.php
2022-06-07 00:30:34 +03:00

93 lines
4.2 KiB
PHP

<?
if( isset($s[1]) && $s[1] == '101/viboina' ) {
/*
Ñóíäóê: Âûáîèíà
* Ìîæíî íàéòè Ñòàëü , Ìèôðèë , Ïóñòûå áóòûëêè
* Ìîæåò îòíÿòü 100-1000 ÍÐ
* Ìîãóò èñïîëüçîâàòü òîëüêî 2 ÷åëîâåêà èç êîìàíäû
*/
//Âñå ïåðåìåííûå ñîõðàíÿòü â ìàññèâå $vad !
$vad = array(
'go' => true
);
$vad['test1'] = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `dungeon_actions` WHERE `dn` = "'.$u->info['dnow'].'" AND `vars` = "obj_act'.$obj['id'].'" LIMIT 1'));
$vad['test2'] = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `dungeon_actions` WHERE `dn` = "'.$u->info['dnow'].'" AND `vars` = "obj_act'.$obj['id'].'" AND `uid` = "'.$u->info['id'].'" LIMIT 1'));
$vad['test3'] = mysql_fetch_array(mysql_query('SELECT `id`,`vals` FROM `dungeon_actions` WHERE `dn` = "'.$u->info['dnow'].'" AND `vars` = "obj_act'.$obj['id'].'_bad" LIMIT 1'));
$vad['test4'] = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `dungeon_actions` WHERE `dn` = "'.$u->info['dnow'].'" AND `vars` = "obj_act'.$obj['id'].'_bad_use" AND `uid` = "'.$u->info['id'].'" LIMIT 1'));
$vad['test5'] = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `dungeon_actions` WHERE `dn` = "'.$u->info['dnow'].'" AND `vars` = "obj_act'.$obj['id'].'_bad_use" AND `uid` != "'.$u->info['id'].'" LIMIT 1'));
if( !isset($vad['test3']['id']) ) {
//Îïðåäåëÿåì ëîâóøêà èëè íåò
if( rand(0,100) < 50 ) {
$vad['bad'] = 1;
}else{
$vad['bad'] = 0;
}
mysql_query('INSERT INTO `dungeon_actions` (`dn`,`time`,`x`,`y`,`uid`,`vars`,`vals`) VALUES (
"'.$u->info['dnow'].'","'.time().'","'.$obj['x'].'","'.$obj['y'].'","'.$u->info['id'].'","obj_act'.$obj['id'].'_bad","'.$vad['bad'].'"
)');
}else{
$vad['bad'] = $vad['test3']['vals'];
}
if( $vad['test2'][0] > 0 ) {
//$r = 'Âû óæå îáûñêàëè çäåñü âñå...';
$r = 'Êàæåòñÿ, âû çäåñü ïîáûâàëè ðàíüøå...';
$vad['go'] = false;
}elseif( $vad['test1'][0] > 1 || ( $vad['test4'] == 0 && $vad['test5'] >= 2 ) ) {
$r = 'Êàæåòñÿ, êòî-òî çäåñü ïîáûâàë ðàíüøå âàñ...';
$vad['go'] = false;
}
if( $vad['bad'] == 1 && $vad['go'] == true ) {
//Âû óãîäèëè â ëîâóøêó
$vad['test3'] = mysql_fetch_array(mysql_query('SELECT `id`,`vals` FROM `dungeon_actions` WHERE `dn` = "'.$u->info['dnow'].'" AND `vars` = "obj_act'.$obj['id'].'_bad_use" AND `uid` = "'.$u->info['id'].'" LIMIT 1'));
if( !isset($vad['test3']['id']) ) {
//Ëîâóøêà íà 50% ÍÐ , Åñëè ÍÐ áàîëüøå 2 åä.
$vad['go'] = false;
mysql_query('INSERT INTO `dungeon_actions` (`dn`,`time`,`x`,`y`,`uid`,`vars`,`vals`) VALUES (
"'.$u->info['dnow'].'","'.time().'","'.$obj['x'].'","'.$obj['y'].'","'.$u->info['id'].'","obj_act'.$obj['id'].'_bad_use",""
)');
$r = 'Â ñóíäóêå áûëà ëîâóøêà óñòàíîâëåííàÿ îäíèì èç îáèòàòåëåé ïîäçåìåëüÿ!';
$vad['min_hp'] = round(2+$u->stats['hpNow']/4);
$u->stats['hpNow'] -= $vad['min_hp'];
if( $u->stats['hpNow'] < 0 ) {
$u->stats['hpNow'] = 0;
}
if($u->info['sex'] == 0) {
$vad['text'] = '[img[items/trap.gif]] <b>'.$u->info['login'].'</b> óãîäèë â ëîâóøêó îñòàâëåííóþ â &quot;'.$obj['name'].'&quot;. <b>-'.$vad['min_hp'].'</b> ['.floor($u->stats['hpNow']).'/'.round($u->stats['hpAll']).']';
}else{
$vad['text'] = '[img[items/trap.gif]] <b>'.$u->info['login'].'</b> óãîäèëà â ëîâóøêó îñòàâëåííóþ â &quot;'.$obj['name'].'&quot;. <b>-'.$vad['min_hp'].'</b> ['.floor($u->stats['hpNow']).'/'.round($u->stats['hpAll']).']';
}
$this->sys_chat($vad['text']);
$u->info['hpNow'] = $u->stats['hpNow'];
mysql_query('UPDATE `stats` SET `regHP` = "'.time().'",`hpNow` = "'.$u->stats['hpNow'].'" WHERE `id` = "'.$u->stats['id'].'" LIMIT 1');
//
$this->testDie();
}
}
if( $vad['go'] == true ) {
//Âûêèäûâàåì áóòûëêó, ìèôðèë, ëèáî ñòàëü
$vad['items'] = array(2,877,896);
$vad['items'] = $vad['items'][rand(0,count($vad['items'])-1)];
if( $vad['items'] != 0 ) {
//Âûáðàñûâàåì ïðåäìåò
mysql_query('INSERT INTO `dungeon_actions` (`dn`,`time`,`x`,`y`,`uid`,`vars`,`vals`) VALUES (
"'.$u->info['dnow'].'","'.time().'","'.$obj['x'].'","'.$obj['y'].'","'.$u->info['id'].'","obj_act'.$obj['id'].'",""
)');
if( $this->pickitem($obj,$vad['items'],$u->info['id']) ) {
$r = 'Âû îáíàðóæèëè ïðåäìåòû...';
}else{
$r = '×òî-òî ïîøëî íå òàê, ïðåäìåòû ðàñòâîðèëèñü...';
}
}else{
$r = 'Âû íå íàøëè íè÷åãî ïîëåçíîãî...';
}
}
unset($vad);
}
?>