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 static function initRuneData() { ### NAME TWICE min, maxLEVEL, DROP_C, PRICE, FAIL_C, BRK_C, MIN, MAX // self::$RUNEDATA['elephants'] = array('elephants', 3, 200, 20.00, 200.00, 30.00, 12.00, 0.2, 4.0); // self::$RUNEDATA['orcas'] = array('orcas', 6, 200, 20.00, 200.00, 30.00, 10.00, 0.2, 4.0); self::$RUNEDATA['max_hp'] = array('max_hp', 1, 150, 80.0, 200.0, 10.0, 2.0, 0.2, 3.0); self::$RUNEDATA['max_mp'] = array('max_mp', 4, 150, 80.0, 250.0, 10.0, 2.0, 0.2, 6.0); self::$RUNEDATA['max_weight'] = array('max_weight', 2, 100, 100.0, 300.0, 15.0, 4.0, 100.0, 3000.0); // self::$RUNEDATA['attack'] = array('attack', 5, 100, 60.00, 650.00, 20.00, 6.00, 0.2, 2.0); self::$RUNEDATA['attack'] = array('attack', 3, 32, 60.0, 250.0, 1.5, 0.5, 0.5, 5.0); self::$RUNEDATA['attack_time'] = array('attack_time', 3, 64, 50.0, 300.0, 2.5, 0.6, 0.4, 4.0); self::$RUNEDATA['defense'] = array('defense', 5, 150, 50.0, 900.0, 22.0, 7.0, 0.2, 2.0); // self::$RUNEDATA['spellatk'] = array('spellatk', 10, 120, 40.00, 750.00, 20.00, 6.00, 0.2, 2.0); // self::$RUNEDATA['spelldef'] = array('spelldef', 6, 160, 30.00, 1000.00, 22.00, 7.00, 0.2, 2.0); self::$RUNEDATA['min_dmg'] = array('min_dmg', 10, 120, 40.0, 900.0, 21.0, 6.5, 0.2, 2.0); self::$RUNEDATA['max_dmg'] = array('max_dmg', 10, 110, 55.0, 900.0, 21.0, 6.5, 0.2, 2.0); self::$RUNEDATA['marm'] = array('marm', 10, 120, 25.0, 1250.0, 24.0, 8.0, 0.2, 2.0); self::$RUNEDATA['farm'] = array('farm', 10, 130, 22.0, 1250.0, 24.0, 8.0, 0.2, 2.0); # Mount self::$RUNEDATA['lock'] = array('lock', 10, 140, 50.0, 800.0, 25.0, 6.5, 0.2, 2.0); self::$RUNEDATA['transport'] = array('transport', 10, 120, 50.0, 600.0, 20.0, 6.5, 0.2, 2.0); self::$RUNEDATA['tuneup'] = array('tuneup', 10, 100, 50.0, 400.0, 15.0, 6.5, 0.2, 2.0); foreach (SR_Player::$ATTRIBUTE as $a) { self::$RUNEDATA[$a] = array($a, 6, 100, 100.0, 400.0, 12.0, 4.0, 0.1, 1.0); } foreach (SR_Player::$SKILL as $sk) { self::$RUNEDATA[$sk] = array($sk, 8, 120, 70.0, 600.0, 16.0, 8.0, 0.1, 2.0); } foreach (SR_Spell::getSpells() as $sp => $spell) { self::$RUNEDATA[$sp] = array($sp, 8, 130, 60.0, 800.0, 18.0, 9.0, 0.5, 3.0); } # Override essence self::$RUNEDATA['essence'] = array('essence', 2000, 2000, 0.0, 500.0, 45.0, 25.0, 0.1, 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; }
private static function getSpellHelp(SR_Spell $spell, SR_Player $player) { $maxlevel = $spell->getLevel($player); $costs = ''; for ($level = 0; $level <= $maxlevel; $level++) { $costs .= sprintf(", L%d(%sMP)", $level, $spell->getManaCost($player, $level)); } $costs = substr($costs, 2); return sprintf('%s %s. %s %s.', $spell->displayType(), $spell->displayClass(), $spell->getHelp(), $costs); }
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!')); }
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)); } } }
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; }
public static function isSpell($spellname) { foreach (SR_Spell::getSpells() as $spell) { $spell instanceof SR_Spell; if ($spell->getName() === $spellname) { return true; } } return false; }
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; }
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; }
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; }
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; } }
private function displaySurgeryPrices(SR_Player $player, $section = NULL) { if ($section === NULL) { return $this->displayAllSurgeryPrices($player); } $prices = array(); switch ($section) { case 'race': foreach (SR_Player::$RACE as $race => $data) { if (false !== ($price = $this->getRacePrice($race))) { $prices[$race] = $price; } } break; case 'skill': foreach (SR_Player::$SKILL as $skill) { if (false !== ($price = $this->getSkillPrice($skill))) { $prices[$skill] = $price; } } break; case 'gender': foreach (array('male', 'female') as $gender) { if (false !== ($price = $this->getGenderPrice($gender))) { $prices[$gender] = $gender; } } break; case 'attribute': foreach (SR_Player::$ATTRIBUTE as $attribute) { if (false !== ($price = $this->getAttributePrice($attribute))) { $prices[$attribute] = $price; } } break; case 'spell': foreach (SR_Spell::getSpells() as $spell) { $spell instanceof SR_Spell; $spellname = $spell->getName(); if (false !== ($price = $this->getSpellPrice($spellname))) { $prices[$spellname] = $price; } } break; case 'knowledge': foreach (SR_Player::$KNOWLEDGE as $knowledge) { if (false !== ($price = $this->getKnowledgePrice($knowledge))) { $prices[$knowledge] = $price; } } break; default: return $this->displayAllSurgeryPrices($player); } return $this->displaySurgeryPricesB($player, $section, $prices); }