Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
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, 'gmsp'));
         return false;
     }
     if (false === ($spell = SR_Spell::getSpell($args[1]))) {
         $bot->reply("The spell {$args[1]} is unknown.");
         return false;
     }
     $server = $player->getUser()->getServer();
     if (false === ($user = Dog::getUserByArg($args[0]))) {
         $bot->reply(sprintf('The user %s is unknown.', $args[0]));
         return false;
     }
     if (false === ($target = Shadowrun4::getPlayerByUID($user->getID()))) {
         $bot->reply(sprintf('The player %s is unknown.', $user->getName()));
         return false;
     }
     if (false === $target->isCreated()) {
         $bot->reply(sprintf('The player %s has not started a game yet.', $args[0]));
         return false;
     }
     $by = 1;
     if (count($args) === 3) {
         if (!Common::isNumeric($args[2])) {
             $bot->reply(Shadowhelp::getHelp($player, 'gmsp'));
             return false;
         }
         if (false === ($base = $player->getSpellBaseLevel($args[1]))) {
             $bot->reply(Shadowhelp::getHelp($player, 'gmsp'));
             return false;
         }
         $by = $args[2] - $base;
     }
     $target->levelupSpell($spell->getName(), $by);
     $target->modify();
     $base = $target->getSpellBaseLevel($args[1]);
     return $bot->reply(sprintf('The target got changed spells!'));
 }
Exemplo n.º 3
0
 private function checkNPCSpells(SR_NPC $npc)
 {
     foreach ($npc->getNPCSpells() as $spell => $level) {
         if (false === SR_Spell::getSpell($spell)) {
             die(sprintf('The NPC %s has an unknown spell: %s.', get_class($npc), $spell));
         }
     }
 }
Exemplo n.º 4
0
 public function getSpellByName($sn)
 {
     $sn = strtolower($sn);
     $spells = $this->getSpellData();
     if (false === isset($spells[$sn])) {
         return false;
     }
     $spell = SR_Spell::getSpell($sn);
     $spell->setCaster($this);
     return $spell;
 }
Exemplo n.º 5
0
 private function onLearn(SR_Player $player, $field, $price)
 {
     $have = false;
     $type = 'skill';
     if (false !== ($spell = SR_Spell::getSpell($field))) {
         $type = 'spell';
         if ($spell->getBaseLevel($player) > -1) {
             $have = true;
         }
     } elseif ($player->getBase($field) > -1) {
         $have = true;
     }
     if ($type !== 'spell') {
         if ($player->getBase($field) < -1) {
             $player->msg('1145', array($field));
             // 				$player->message(sprintf('Your character cannot learn %s.', $field));
             return false;
         }
     }
     if ($have === true) {
         $player->msg('1146', array($field));
         // 			$player->message(sprintf('You already learned the %s %s.', $type, $field));
         return false;
     }
     if ($type === 'spell') {
         if (false !== ($error = $spell->checkRequirements($player))) {
             $player->msg('1147', array($error));
             // 				$player->message(sprintf('You need %s to learn this spell.', $error));
             return false;
         }
     }
     $dp = Shadowfunc::displayNuyen($price);
     if (false === $player->pay($price)) {
         $player->msg('1063', array($dp, $player->displayNuyen()));
         // 			$player->message(sprintf('It cost %s to learn the %s %s, but you only have %s.', $dp, $type, $field, $player->displayNuyen()));
         return false;
     }
     if ($type === 'spell') {
         $player->levelupSpell($field, 1);
     } elseif ($type === 'skill') {
         $player->levelupFieldTo($field, 0);
     } else {
         $player->message('Database error!');
         return Dog_Log::error(sprintf('Learned field "%s" is neither a skill nor a spell!', $field));
     }
     // 		$player->modify();
     $player->msg('5184', array($dp, $field));
     // 		$player->message(sprintf('You pay %s and learned the %s %s.', $dp, $type, $field));
     return true;
 }
Exemplo n.º 6
0
 private static function isValidModifier($k)
 {
     return in_array($k, SR_Player::$ATTRIBUTE) || in_array($k, SR_Player::$SKILL) || in_array($k, SR_Player::$COMBAT_STATS) || in_array($k, SR_Player::$MAGIC_STATS) || in_array($k, SR_Player::$MOUNT_STATS) || SR_Spell::getSpell($k) !== false;
 }
Exemplo n.º 7
0
 private function getCombatSpells()
 {
     $back = array();
     foreach ($this->getSpellData() as $name => $level) {
         $spell = SR_Spell::getSpell($name);
         if ($spell instanceof SR_CombatSpell) {
             if ($spell->hasEnoughMP($this, $spell->getLevel($this))) {
                 $back[] = $spell;
             }
         }
     }
     return $back;
 }
Exemplo n.º 8
0
 public static function getMaxLevel(SR_Player $player, $field)
 {
     $runner = $player->isRunner();
     if ($field === 'essence') {
         return 6;
     }
     if (in_array($field, SR_Player::$SKILL)) {
         return $runner ? self::MAX_VAL_SKILL_RUNNER : self::MAX_VAL_SKILL;
     } elseif (in_array($field, SR_Player::$ATTRIBUTE)) {
         return $runner ? self::MAX_VAL_ATTRIBUTE_RUNNER : self::MAX_VAL_ATTRIBUTE;
     } elseif (in_array($field, SR_Player::$KNOWLEDGE)) {
         return $runner ? self::MAX_VAL_KNOWLEDGE_RUNNER : self::MAX_VAL_KNOWLEDGE;
     } elseif (false !== ($spell = SR_Spell::getSpell($field))) {
         return $runner ? self::MAX_VAL_SPELL_RUNNER : self::MAX_VAL_SPELL;
     } else {
         return false;
     }
 }