public function ai_can($command, $flush = false) { if ($flush || $this->npc_can === null) { $this->npc_can = Shadowcmd::getCurrentCommands($this, true, false, false, false, false, false); } return in_array($command, $this->npc_can, true); }
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); }
private function cmd($cmd = 'say ERROR :D', $args = NULL) { if (is_string($args)) { $cmd .= $args; } elseif (is_array($args)) { $cmd .= implode(' ', $args); } Shadowcmd::onTrigger($player, $cmd); }
/** * Execute a remote command. * @param SR_Player $player * @param SR_Player $remote * @param array $args */ public static function onRemote(SR_Player $player, SR_Player $remote, array $args) { # Enable remote output. $remote->setRemotePlayer($player); # Execute command. $back = Shadowcmd::onTrigger($remote, implode(' ', $args)); # Disable remote output. $remote->unsetRemotePlayer(); # Return result. return $back; }
public static function unshortcut($word) { if ('' === ($word = strtolower(trim($word)))) { return 'root'; } $shortcuts = array('def' => 'defense', 'dmg' => 'damage', 'skill' => 'skills', 'attribute' => 'attributes', 'bmi' => 'body_mass', 'die' => 'death'); $shortcuts = array_merge($shortcuts, Shadowcmd::getCommandShortcutMap(), SR_Player::$ATTRIBUTE, SR_Player::$SKILL, SR_Player::$KNOWLEDGE, SR_Player::$MOUNT_STATS); if (true === isset($shortcuts[$word])) { return $shortcuts[$word]; } return $word; }
public static function onCreateLangFiles() { $player = Shadowrun4::getDummyPlayer(); // Shadowcmd::$CURRENT_PLAYER = $player; // $spells = SR_Spell::getSpells(); // ksort($spells); // foreach ($spells as $name => $spell) // { // printf("'%s' => '%s'\n", $name, $name); // } // die(); $back = self::createItemLangFile() && self::createItemTypeFile() && self::createStatUUIDFile(); # && self::createItemDataFile(); Shadowcmd::$CURRENT_PLAYER = NULL; return $back; // return true; // return // (true === self::createNPCLangFiles()) && // (true === self::createQuestLangFiles()) && // (true === self::createLocationLangFiles()) && // (true === self::createItemLangFile()) && // (true === self::createHelpLangFile()); }
public static function onTrigger(SR_Player $player, $message) { self::$CURRENT_PLAYER = $player; if ($player->isFighting()) { $cmd = Common::substrUntil($message, ' ', $message); $cmd = self::unshortcut($cmd); $cmd = self::untranslate($cmd); if (true === in_array($cmd, self::$CMDS['fight'], true)) { $player->combatPush($message); return true; } } return self::onExecute($player, $message); }
public static function onTrigger(Dog_User $user, $msg) { if ($user->isRegistered() && !$user->isLoggedIn()) { if (false !== ($mod_al = Dog_Module::getModule('AutoLogin'))) { $mod_al instanceof DOGMOD_AutoLogin; $mod_al->onTryAutoLogin(); } # You need to login to play. return Dog::reply(DOGMOD_Shadowlamb::instance()->lang('0001')); } if (false === ($player = self::getPlayerForUser($user))) { return Dog::reply('Can not get Player for user ' . $user->getName() . '.'); } SR_Tell::onTell($player); # Do it! Shadowcmd::onTrigger($player, $msg); }
public function iExecAnyway() { $anyway = array('eq', 'equip', 'g', 'give', 'uq', 'unequip', 'ca', 'cast', 'u', 'use'); $cmd = $this->combat_stack; $cmd = Common::substrUntil($cmd, ' ', $cmd); if (in_array($cmd, $anyway, true)) { return Shadowcmd::onExecute($this, $this->combat_stack); } $this->combat_stack = ''; $this->old_combat_stack = ''; return true; }
public function execute(SR_RealNPC $npc) { return Shadowcmd::onTrigger($npc, $this->command); }
public function on_unpierce(SR_Player $player, array $args) { $bot = Shadowrap::instance($player); if (count($args) > 1) { $bot->reply(Shadowhelp::getHelp($player, 'unpierce')); return false; } if (!$player->hasEquipment('piercing')) { $bot->rply('1182'); return false; } if (false === ($piercing = $player->getEquipment('piercing'))) { $bot->reply('Database error 3'); return false; } $price = Shadowfunc::calcBuyPrice($this->getPriceUnpierce(), $player); $dprice = Shadowfunc::displayNuyen($price); if (!isset($args[0]) || $args[0] !== self::CONFIRM_UNPIERCE) { return $bot->rply('5288', array($dprice, $piercing->displayFullName($player), Shadowcmd::translate('unpierce'), self::CONFIRM_UNPIERCE)); } if (!$player->hasNuyen($price)) { $bot->rply('1063', array($dprice, $player->displayNuyen())); return false; } $player->unsetEquipment('piercing'); // if (!$player->updateEquipment('piercing', NULL)) // { // $bot->reply('Database error 1'); // return false; // } if (!$piercing->deleteItem($player)) { $bot->reply('Database error 2'); return false; } $player->modify(); return $bot->rply('5289', array($dprice, $piercing->displayFullName($player))); }
public function on_fight($done) { if (false === ($ep = $this->getEnemyParty())) { $this->popAction(true); } else { $this->timestamp = time(); foreach ($this->members as $player) { $player instanceof SR_Player; # Make sure player hasn't left because of something like #cast bunny. if ($player->getParty() !== $this) { continue; } Shadowcmd::$CURRENT_PLAYER = $player; if ($player->combatTimer()) { # No more enemies! \o/ break; } } } }
private function onBuyslotInfo(SR_Player $player) { $pname = $player->getName(); if (false === ($shop = SR_BazarShop::getShop($pname))) { $used_slots = 0; } else { $used_slots = SR_BazarItem::getUsedSlots($pname); } $avail_slots = $this->getBazarSlots($player); $price = $this->calcBuySlotPrice($player); $player->msg('5157', array($used_slots, $avail_slots, Shadowfunc::displayNuyen($price), Shadowcmd::translate('buyslot'))); // return $player->message(sprintf('You currently have %d of %d bazar slots in use. Another slot would cost you %s. Type #buyslot yesplease to confirm.', $used_slots, $avail_slots, Shadowfunc::displayNuyen($price))); }
public function on_exit(SR_Player $player, array $args) { $bot = Shadowrap::instance($player); $party = $player->getParty(); if (false === Shadowcmd::checkMove($party)) { return false; } $party->pushAction(SR_Party::ACTION_OUTSIDE); $party->ntice('5020', array($party->getLocation())); // $party->notice(sprintf('You exit the %s.', $party->getLocation())); return true; }