本文整理汇总了PHP中SR_Player::setSpellData方法的典型用法代码示例。如果您正苦于以下问题:PHP SR_Player::setSpellData方法的具体用法?PHP SR_Player::setSpellData怎么用?PHP SR_Player::setSpellData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SR_Player
的用法示例。
在下文中一共展示了SR_Player::setSpellData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onUsePotion
public function onUsePotion(SR_Player $player, array $args)
{
// echo "Using potion".implode(',', $args).PHP_EOL;
$receive_bottle = true;
$mods = $this->getItemModifiersB();
$spellname = key($mods);
$level = array_shift($mods);
if (false === ($spell = SR_Spell::getSpell($spellname))) {
$player->message('Unknown spell');
return false;
}
$spell->setCaster($player);
$spell->setMode(SR_Spell::MODE_POTION);
if (count($args) === 0) {
$args[] = '';
}
if ($spell->isOffensive()) {
$receive_bottle = false;
if (!$player->isFighting()) {
$player->msg('1180');
// $player->message('This potion works in combat only.');
return false;
}
}
if (false !== ($target = $spell->getTarget($player, $args, false))) {
if (!$spell->isOffensive() && $target->getID() !== $player->getID()) {
$player->msg('1181');
// $player->message('You cannot inject potions into other peoples mouth\'.');
return false;
}
}
// echo "Using potion 2222 ".implode(',', $args).PHP_EOL;
# Dummy player
$mods['magic'] = false === isset($mods['magic']) ? $player->getBase('magic') : $mods['magic'];
$mods['intelligence'] = false === isset($mods['intelligence']) ? $player->getBase('intelligence') : $mods['intelligence'];
$mods['wisdom'] = false === isset($mods['wisdom']) ? $player->getBase('wisdom') : $mods['wisdom'];
$dummy = new SR_Player(SR_Player::getPlayerData(0));
$dummy->setVar('sr4pl_magic', $mods['magic']);
$dummy->setVar('sr4pl_intelligence', $mods['intelligence']);
$dummy->setVar('sr4pl_wisdom', $mods['wisdom']);
$dummy->setSpellData(array($spellname => $level));
$dummy->modify();
$spell->setCaster($dummy);
if (false === $spell->onCast($player, $args, $level)) {
return false;
}
if ($receive_bottle) {
$player->giveItems(array(SR_Item::createByName('EmptyBottle')));
}
return true;
}