本文整理汇总了PHP中Shadowrun4::getNPCByAbbrev方法的典型用法代码示例。如果您正苦于以下问题:PHP Shadowrun4::getNPCByAbbrev方法的具体用法?PHP Shadowrun4::getNPCByAbbrev怎么用?PHP Shadowrun4::getNPCByAbbrev使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shadowrun4
的用法示例。
在下文中一共展示了Shadowrun4::getNPCByAbbrev方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public static function execute(SR_Player $player, array $args)
{
$bot = Shadowrap::instance($player);
if (count($args) !== 2) {
$bot->reply(Shadowhelp::getHelp($player, 'gmt'));
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;
}
# Check for valid enemies.
$npcnames = explode(',', $args[1]);
foreach ($npcnames as $i => $npcname) {
if (false === ($npc = Shadowrun4::getNPCByAbbrev($player, $npcname))) {
$bot->reply(sprintf('Unknown NPC: %s.', $npcname));
return false;
}
$npcnames[$i] = $npc->getNPCClassName();
}
# Prepare for action cases
$p = $target->getParty();
$a = $p->getAction();
$ep = NULL;
switch ($a) {
case SR_Party::ACTION_TALK:
$p->getEnemyParty()->popAction(true);
# we pop the enemies talking
# we pop the enemies talking
case SR_Party::ACTION_SLEEP:
$p->popAction(false);
# and pop our own fallthrough
break;
case SR_Party::ACTION_FIGHT:
$ep = $p->getEnemyParty();
# Stack and re-init the fight :)
break;
# Nothing todo here
# Nothing todo here
case SR_Party::ACTION_INSIDE:
case SR_Party::ACTION_OUTSIDE:
case SR_Party::ACTION_EXPLORE:
case SR_Party::ACTION_GOTO:
case SR_Party::ACTION_HUNT:
break;
# Impossibru
# Impossibru
case SR_Party::ACTION_HIJACK:
case SR_Party::ACTION_TRAVEL:
case SR_Party::ACTION_DELETE:
default:
$bot->reply('Cannot #gmt because target action is ' . $a . '!');
return false;
}
# Generate NPCs
if (false === ($ep2 = SR_NPC::createEnemyParty($npcnames))) {
$bot->reply('cannot create party! check logs');
return false;
}
# Merge?
if ($ep === NULL) {
$ep = $ep2;
} else {
$ep->mergeParty($ep2);
}
# Delegate new actions
if ($p->isFighting()) {
# Already fighting
$p->popAction(false);
$p->fight($ep, true);
} elseif ($ep->getLeader() instanceof SR_TalkingNPC) {
# Init a talk
$p->talk($ep, true);
} else {
# Init a fight
$p->fight($ep, true);
}
# That's it!
return $bot->reply('The party now encountered some enemies!');
}