Exemplo n.º 1
0
 public function hasToLeave()
 {
     if (!$this->hasConst(self::HIRE_END)) {
         return false;
     }
     return $this->getConst(self::HIRE_END) < Shadowrun4::getTime();
 }
Exemplo n.º 2
0
 /**
  * Reply to the current origin and user, display as a table
  * @todo Write a class that can display ascii art tables and stuff.
  * @author digitalseraphim
  * @since Shadowlamb 3.1
  * @param array $table where each entry is 'row label' => array(values)
  * @return true|false
  */
 public function replyTable(array $table, $langkey = '5044')
 {
     $maxRowLabelWidth = 0;
     $maxWidths = array(-1 => 0);
     foreach ($table as $key => $value) {
         $maxWidths[-1] = max($maxWidths[-1], strlen($key));
         foreach ($value as $k => $v) {
             $charcounts = count_chars($v, 0);
             $vlen = strlen($v) - $charcounts[2];
             if (!array_key_exists($k, $maxWidths)) {
                 $maxWidths[$k] = $vlen;
             } else {
                 $maxWidths[$k] = max($maxWidths[$k], $vlen);
             }
         }
     }
     foreach ($table as $key => $value) {
         $s = sprintf('%-' . ($maxWidths[-1] + 1) . 's', $key);
         foreach ($value as $k => $v) {
             $charcounts = count_chars($v, 0);
             $s .= sprintf('| %-' . ($maxWidths[$k] + 1 + $charcounts[2]) . 's', $v);
         }
         $this->reply(Shadowrun4::lang($langkey, array($s)));
         // 			$this->reply($s);
     }
 }
Exemplo n.º 3
0
 public static function execute(SR_Player $player, array $args)
 {
     $bot = Shadowrap::instance($player);
     if (count($args) !== 2) {
         $bot->reply(Shadowhelp::getHelp($player, 'gmloot'));
         return false;
     }
     $target = Shadowrun4::getPlayerByShortName($args[0]);
     if ($target === -1) {
         $player->message('The username is ambigious.');
         return false;
     }
     if ($target === false) {
         $player->message('The player is not in memory or unknown.');
         return false;
     }
     if (false === $target->isCreated()) {
         $bot->reply(sprintf('The player %s has not started a game yet.', $args[0]));
         return false;
     }
     if (Common::isNumeric($args[1])) {
         $target->giveItems(Shadowfunc::randLoot($target, $args[1]), 'gmloot');
     } else {
     }
     return true;
 }
Exemplo n.º 4
0
 public function getSlogan()
 {
     if ('' === ($slogan = $this->getVar('sr4bs_message'))) {
         return Shadowrun4::lang('stub_shop_slogan', array($this->getVar('sr4bs_pname')));
     }
     return $slogan;
 }
Exemplo n.º 5
0
 public static function execute(SR_Player $player, array $args)
 {
     $bot = Shadowrap::instance($player);
     if (count($args) < 2 || count($args) > 3) {
         $bot->reply(Shadowhelp::getHelp($player, 'gmi'));
         return false;
     }
     $target = Shadowrun4::getPlayerByShortName($args[0]);
     if ($target === -1) {
         $player->message('The username is ambigious.');
         return false;
     }
     if ($target === false) {
         $player->message('The player is not in memory or unknown.');
         return false;
     }
     if (false === $target->isCreated()) {
         $bot->reply(sprintf('The player %s has not started a game yet.', $args[0]));
         return false;
     }
     if (false === ($item = SR_Item::createByName($args[1]))) {
         $bot->reply(sprintf('The item %s could not be created.', $args[1]));
         return false;
     }
     if (isset($args[2])) {
         if (!$item->isItemStackable()) {
             $bot->reply('No amount for equipment!');
             return false;
         }
         $item->saveVar('sr4it_amount', intval($args[2]));
     }
     $b = chr(2);
     $target->giveItems(array($item), sprintf("{$b}[GM]_%s{$b}", $player->getName()));
     return true;
 }
Exemplo n.º 6
0
 public static function execute(SR_Player $player, array $args)
 {
     $pp = Shadowrun4::getParties();
     foreach ($pp as $i => $p) {
         $p instanceof SR_Party;
         if (!$p->isHuman()) {
             unset($pp[$i]);
         }
     }
     $page = isset($args[0]) ? intval($args[0]) : 1;
     $nItems = count($pp);
     $nPages = GWF_PageMenu::getPagecount(self::PPP, $nItems);
     $page = Common::clamp($page, 1, $nPages);
     $from = GWF_PageMenu::getFrom($page, self::PPP);
     $slice = array_slice($pp, $from, self::PPP);
     $out = '';
     $format = $player->lang('fmt_list');
     foreach ($slice as $p) {
         $p instanceof SR_Party;
         $leader = $p->getLeader()->displayName();
         $l = $p->getSum('level', true);
         $ll = $p->getSum('level', false);
         $mc = $p->getMemberCount();
         $item = sprintf('%s(L%s(%s))(M%s)', $leader, $l, $ll, $mc);
         $out .= sprintf($format, $item);
         // 			$out .= sprintf(', %s(L%s(%s))(M%s)', $leader, $l, $ll, $mc);
     }
     return self::rply($player, '5248', array($page, $nPages, ltrim($out, ',; ')));
     // 		$bot = Shadowrap::instance($player);
     // 		$bot->reply(sprintf('Parties page %s from %s: %s.', $page, $nPages, substr($out, 2)));
 }
Exemplo n.º 7
0
 public function getRespawnLocation(SR_Player $player)
 {
     if ($player->getNuyen() > 200 && $player->hasKnowledge('places', 'Vegas_Hotel')) {
         return 'Vegas_Hotel';
     }
     return Shadowrun4::getCity('Chicago')->getRespawnLocation($player);
 }
Exemplo n.º 8
0
 /**
  * Beam a party to a target location.
  * @param SR_Player $player
  * @param string $target
  * @param string $action
  */
 public function beam(SR_Player $player, $target = 'Redmond_Hotel', $action = 'inside')
 {
     if (false === ($location = Shadowrun4::getLocationByTarget($target))) {
         $player->message('Unknown location to beam to, report to gizmore!');
         Dog_Log::error('Unknown $target "' . $target . '" for ' . __METHOD__ . ' in ' . __FILE__ . ' line ' . __LINE__ . '.');
         return false;
     }
     $party = $player->getParty();
     # City changed?
     $oldcity = $party->getCity();
     $party->pushAction($action, $target);
     $newcity = $party->getCity();
     if ($oldcity !== $newcity) {
         $city = $party->getCityClass();
         $city->onCityEnter($party);
     }
     // 		if ($action === 'inside')
     // 		{
     // 			foreach ($party->getMembers() as $member)
     // 			{
     // 				$member->message($location->getEnterText($member));
     // 			}
     // 		}
     $party->giveKnowledge('places', $target);
     return true;
 }
Exemplo n.º 9
0
 public static function executeLook(SR_Player $player, $command_mode = true)
 {
     $bot = Shadowrap::instance($player);
     $p = $player->getParty();
     $pid = $player->getPartyID();
     $format = $player->lang('fmt_list');
     $back = '';
     foreach (Shadowrun4::getParties() as $party) {
         $party instanceof SR_Party;
         if ($party->getID() === $pid) {
             continue;
         }
         if (!$party->sharesLocation($p)) {
             continue;
         }
         foreach ($party->getMembers() as $member) {
             $member instanceof SR_Player;
             $back .= sprintf($format, $member->getName());
         }
     }
     if ($back === '') {
         # You see no other players.
         return $command_mode ? self::rply($player, '5120') : true;
     }
     // 		$player->setOption(SR_Player::RESPONSE_PLAYERS);
     # You see these players: %s.
     if ($command_mode) {
         self::rply($player, '5121', array(ltrim($back, ',; ')));
     } else {
         $player->msg('5121', array(ltrim($back, ',; ')));
     }
     return true;
 }
Exemplo n.º 10
0
 public static function execute(SR_Player $player, array $args)
 {
     $bot = Shadowrap::instance($player);
     if (count($args) !== 1) {
         $bot->reply(Shadowhelp::getHelp($player, 'gmp'));
         return false;
     }
     if (false === ($target = Shadowrun4::getPlayerByShortName($args[0]))) {
         $bot->reply(sprintf('The user %s is unknown.', $args[0]));
         return false;
     } elseif ($target === -1) {
         $bot->reply('The player name is ambigious.');
         return false;
     }
     if (false === $target->isCreated()) {
         $bot->reply(sprintf('The player %s has not started a game yet.', $args[0]));
         return false;
     }
     $p = $target->getParty();
     $a = $p->getAction();
     if ($a !== SR_Party::ACTION_INSIDE && $a !== SR_Party::ACTION_OUTSIDE) {
         $bot->reply('The party with ' . $args[0] . ' is moving.');
         return false;
     }
     $p->pushAction(SR_Party::ACTION_INSIDE, 'Prison_Block1');
 }
Exemplo n.º 11
0
 public static function execute(SR_Player $player, array $args)
 {
     return self::rply($player, '5241', array(SR_NPC::$NPC_COUNTER, Shadowrun4::getCityCount(), SR_Location::$LOCATION_COUNT, SR_Item::getTotalItemCount(), SR_Spell::getTotalSpellCount(), SR_Quest::getTotalQuestCount(), Shadowcmd::translate('stats')));
     // 		$bot = Shadowrap::instance($player);
     // 		$message = sprintf('In Shadowlamb v3 there are: %s different NPC in %s Areas with %s Locations. %s Items, %s Spells and %s Quests. Try #stats to show how many are playing.', SR_NPC::$NPC_COUNTER, Shadowrun4::getCityCount(), SR_Location::$LOCATION_COUNT, SR_Item::getTotalItemCount(), SR_Spell::getTotalSpellCount(), SR_Quest::getTotalQuestCount());
     // 		return $bot->reply($message);
 }
Exemplo n.º 12
0
 public static function execute(SR_Player $player, array $args)
 {
     $p = $player->getParty();
     if (false === ($location = $p->getLocationClass('outside'))) {
         return self::rply($player, '1031');
         // 			return $player->message('This command only works when you are outside a location.');
     }
     $bot = Shadowrap::instance($player);
     $loc = $location->getName();
     if (count($args) > 1) {
         return $bot->reply(Shadowhelp::getHelp($player, 'hijack'));
     }
     $victims = array();
     foreach (Shadowrun4::getParties() as $pa) {
         $pa instanceof SR_Party;
         if (false === ($city = $pa->getCityClass())) {
             continue;
             # not even city
         }
         # Hax!
         if ($city->isDungeon() && $city->getCityLocation() === $loc || $pa->getLocation('inside') === $loc) {
             foreach ($pa->getMembers() as $pl) {
                 $pl instanceof SR_Player;
                 if ($pl->hasEquipment('mount')) {
                     $victims[] = $pl;
                 }
             }
         }
     }
     if (count($victims) === 0) {
         self::rply($player, '5128');
         return false;
         // 			return $player->message('You see no mounts from other players to rob.');
     }
     $format = $player->lang('fmt_sumlist');
     if (count($args) === 0) {
         $out = '';
         foreach ($victims as $i => $victim) {
             $victim instanceof SR_Player;
             $mount = $victim->getMount();
             $out .= sprintf($format, $i + 1, $victim->getName(), $mount->getName());
             // 				$out .= sprintf(", \x02%s\x02-%s(%s)", ($i+1), $victim->getName(), $mount->getName());
         }
         return self::rply($player, '5130', array(ltrim($out, ',; ')));
         // 			return $bot->reply(substr($out, 2));
     }
     if (false === ($target = Shadowfunc::getTarget($victims, $args[0], true))) {
         self::rply($player, '5128');
         // 			$player->message('You see no mounts from other players to rob.');
         return false;
     }
     $mount = $target->getMount();
     if ($mount->getMountWeight() === 0) {
         self::rply($player, '1037');
         // 			$player->message('This mount cannot store anything.');
         return false;
     }
     return $mount->initHijackBy($player);
 }
Exemplo n.º 13
0
 public function getCity()
 {
     $arg = $this->getArg(0, 'Redmond');
     if (false === ($city = Shadowrun4::getCity($arg))) {
         return Shadowrun4::getCity('Redmond');
     }
     return $city;
 }
Exemplo n.º 14
0
 public function setAlert(SR_Party $party, $duration = 600, $announce = true)
 {
     $party->setTemp($this->getAlertKey($party), Shadowrun4::getTime() + $duration);
     if ($announce) {
         $party->ntice('5021');
         // 			$party->notice(sprintf('You hear the alarm sound!'));
     }
 }
Exemplo n.º 15
0
 public function getRespawnLocation(SR_Player $player)
 {
     if ($player->getNuyen() > 300 && $player->hasKnowledge('places', 'Chicago_Hotel')) {
         return 'Chicago_Hotel';
     } else {
         return Shadowrun4::getCity('Delaware')->getRespawnLocation($player);
     }
 }
Exemplo n.º 16
0
 public function resetTimer(SR_Player $player)
 {
     $time = Seattle::TIME_TO_DELAWARE + 60;
     $player->setConst('__AURIS_TIMEOUT', Shadowrun4::getTime() + $time);
     $player->message($this->lang('fluid', array(GWF_Time::humanDuration($time))));
     // 		$player->message(sprintf("Your pot of Auris is fluid for %s.", GWF_Time::humanDuration($time)));
     return true;
 }
Exemplo n.º 17
0
 public function ai_tick($function, $args = null)
 {
     if (0 < ($interval = $this->getInterval())) {
         if (Shadowrun4::getTime() % $interval === 0) {
             call_user_func_array($this->getArg(1), $this->getArg(2, array()));
         }
     }
 }
Exemplo n.º 18
0
 public function checkLocation()
 {
     parent::checkLocation();
     if (false !== ($exit_location = $this->getExitLocation())) {
         if (false === Shadowrun4::getLocationByTarget($exit_location)) {
             die(sprintf("%s has an invalid Exit location!\n", $this->getName()));
         }
     }
 }
Exemplo n.º 19
0
 public function onHacked(SR_Player $player, $hits)
 {
     $party = $player->getParty();
     $player->message(sprintf('This computer is able to activate the elevator to floor 2 and 3.'));
     $elevator = Shadowrun4::getLocationByTarget('Renraku_Elevator');
     $elevator instanceof Renraku_Elevator;
     $elevator->setElevatorFlagsParty($party, 6, true);
     $party->notice(sprintf('%s managed to unlock the elevator to floor 2 and 3.', $player->getName()));
 }
Exemplo n.º 20
0
 public static function isNoShout($pid)
 {
     $pid = (int) $pid;
     if (false === ($ends = self::table(__CLASS__)->selectVar('sr4ns_ends', "sr4ns_pid={$pid}"))) {
         return -1;
     }
     if ($ends == 0) {
         return GWF_Time::ONE_DAY;
     }
     return $ends - Shadowrun4::getTime();
 }
Exemplo n.º 21
0
 public static function execute(SR_Player $player, array $args)
 {
     $bot = Shadowrap::instance($player);
     $path = Shadowrun4::getShadowDir() . 'dog_module/Shadowlamb/shadowlamb_motd.txt';
     if (false === ($motd = @file_get_contents($path))) {
         $bot->reply('Can not read ' . $path);
     }
     return $bot->rply('5249', array($motd));
     // 		$bot->reply(sprintf('Message of the day: %s', $motd));
     // 		return true;
 }
Exemplo n.º 22
0
 /**
  * Get all online members for a clan.
  * @param int $cid
  * @return array
  */
 public static function getOnlineMembers($cid)
 {
     $back = array();
     $cid = (int) $cid;
     foreach (self::table(__CLASS__)->selectColumn('sr4cm_pid', "sr4cm_cid={$cid}") as $playerid) {
         if (false !== ($player = Shadowrun4::getPlayerByPID($playerid))) {
             $back[] = $player;
         }
     }
     return $back;
 }
Exemplo n.º 23
0
 public function getRandomPlayer($only = 'all')
 {
     $back = array();
     foreach (Shadowrun4::getPlayers() as $player) {
         $player instanceof SR_Player;
         if ($player->isHuman() && $only !== 'npc') {
             $back[] = $player;
         } elseif ($player->isNPC() && $only !== 'human') {
             $back[] = $player;
         }
     }
 }
Exemplo n.º 24
0
 private static function getWBTarget(SR_Player $player)
 {
     $pid = $player->getID();
     if (!isset(Shadowcmd_whisper::$WHISPER[$pid])) {
         return -1;
     }
     $data = Shadowcmd_whisper::$WHISPER[$pid];
     if (count($data) === 1) {
         return Shadowrun4::getPlayerByPID(key($data));
     }
     return -2;
 }
Exemplo n.º 25
0
 public static function displayBadKarmaParty(SR_Party $party)
 {
     $back = '';
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         $bk = $member->getBase('bad_karma');
         if ($bk > 0) {
             $back .= Shadowrun4::lang('info_bk', array($member->getName(), $bk));
             // 				$back .= sprintf(', %s has %d bad_karma', $member->getName(), $bk);
         }
     }
     return $back === '' ? '' : sprintf(' %s.', substr($back, 2));
 }
Exemplo n.º 26
0
 private static function cleanupWhisper($pid)
 {
     $data = self::$WHISPER[$pid];
     if (count($data) < 2) {
         return;
     }
     $time = Shadowrun4::getTime() - self::WB_TIME;
     foreach ($data as $fid => $t) {
         if ($t < $time) {
             unset(self::$WHISPER[$pid][$fid]);
         }
     }
 }
Exemplo n.º 27
0
 public static function execute(SR_Player $player, array $args)
 {
     if (count($args) === 0) {
         Shadowrap::instance($player)->reply(Shadowhelp::getHelp($player, 'gmn'));
         return false;
     }
     $message = "[Shadowlamb] " . implode(' ', $args);
     foreach (Shadowrun4::getPlayers() as $player) {
         $player instanceof SR_Player;
         $player->message($message);
     }
     return true;
 }
Exemplo n.º 28
0
 /**
  * Get the player for a join request.
  * @param SR_Player $leader
  * @param SR_Clan $clan
  * @param string $pname
  * @return SR_Player
  */
 public static function getRequest(SR_Player $leader, SR_Clan $clan, $pname)
 {
     $ename = GDO::escape($pname);
     if (false === ($pid = self::table(__CLASS__)->selectVar('sr4cr_pid', "sr4cr_pname='{$ename}'"))) {
         return false;
     }
     if (false === ($player = Shadowrun4::getPlayerByPID($pid))) {
         if (false === ($player = SR_Player::getByID($pid))) {
             return false;
         }
     }
     return $player;
 }
Exemplo n.º 29
0
 /**
  * @param string $cityname
  * @param string $arg
  * @return SR_Location
  */
 public static function getLocationByAbbrev($cityname, $arg)
 {
     $player = Shadowrun4::getCurrentPlayer();
     if (false !== ($c = Common::substrUntil($arg, '_', false))) {
         $cityname = $c;
         $arg = Common::substrFrom($arg, '_', $arg);
     }
     if (false === ($city = Shadowrun4::getCityByAbbrev($cityname))) {
         self::reply($player, 'Unknown city: ' . $cityname);
         return false;
     }
     $city instanceof SR_City;
     return $city->getLocationByAbbrev($arg);
 }
Exemplo n.º 30
0
 public static function displayBountyParty(SR_Party $party)
 {
     $back = '';
     $format = Shadowrun4::lang('fmt_sumlist');
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         $bounty = $member->getBase('bounty');
         if ($bounty > 0) {
             $back .= sprintf($format, $member->getEnum(), $member->getName(), Shadowfunc::displayNuyen($bounty));
             // 				$back .= sprintf(", {$b}%s{$b}-%s(%s)", $i++, $member->getName(), Shadowfunc::displayNuyen($bounty));
         }
     }
     return $back === '' ? '' : Shadowrun4::lang('meet_bounty', array(ltrim($back, ',; ')));
     // 		return $back === '' ? '' : sprintf(" There is a {$b}bounty{$b} on %s.", substr($back, 2));
 }