public function onItemUse(SR_Player $player, array $args) { $p = $player->getParty(); if (false === ($l = $p->getLocationClass(SR_Party::ACTION_INSIDE))) { $player->msg('hlp_cyberdeck'); // $player->message('This item only works inside locations with computers.'); return false; } $computers = $l->getComputers(); $bot = Shadowrap::instance($player); if (count($computers) === 0) { $player->msg('hlp_cyberdeck_targets'); // $bot->reply('You don\'t see any Computers with a Headcomputer interface here.'); return false; } if (count($args) !== 1) { $i = 1; $format = $player->lang('fmt_rawitems'); $out = ''; foreach ($computers as $pc) { $out .= sprintf($format, $i++, $pc); // $out .= sprintf(", \x02%s\x02-%s", $i++, $pc); } return $bot->rply('5202', array(substr($out, 2))); // $bot->reply(sprintf('Possible targets: %s.', substr($out, 2))); // return true; } if (false === ($computer = $this->getComputerTarget($player, $computers, $args[0]))) { $bot->rply('1012'); # The target is unknown. // $bot->reply('The target computer is invalid.'); return false; } if (false === ($computer = SR_Computer::getInstance($computer, $l))) { $bot->reply('Database error.'); return false; } if (!$player->hasHeadcomputer()) { $bot->rply('1050', array('headcomputer')); // $bot->reply('You don\'t have a headcomputer.'); return false; } if ($player->getBase('computers') < 0) { $bot->rply('1025', 'computers'); // $bot->reply('You need to learn the computers skill first.'); return false; } $computer->onHack($player, $this); return true; }
public function onCleanComputers(SR_Party $party) { foreach ($this->getComputers() as $computer) { if (false !== ($computer = SR_Computer::getInstance($computer, $this))) { $computer->onReset($party); } } }