private static function DEBUGresetFeelings(SR_Player $player) { echo "Resetting!\n"; foreach (SR_Player::$FEELINGS as $field) { $player->saveBase($field, '10000'); } $player->modify(); }
protected static function onEnable(SR_Player $player, $bit, $bool, $name) { $text = $bool === true ? 'enabled' : 'disabled'; $text = $player->lang($text); $old = $player->isOptionEnabled($bit); if ($bool === $old) { $player->msg('5070', array($name, $text)); // $player->message(sprintf('%s has been already %s.', $name, $text)); return true; } if (false === $player->saveOption($bit, $bool)) { return false; } $player->msg('5071', array($name, $text)); // $player->message(sprintf('%s has been %s for your character.', $name, $text)); $player->modify(); return true; }
public function onReload(SR_Player $player) { if (false === ($ammo = $player->getItemByName($this->getAmmoName()))) { $player->msg('5205'); // $player->message('You are out of ammo!'); $player->unequip($this); $player->modify(); return true; } $p = $player->getParty(); $now = $this->getAmmo(); $max = $this->getBulletsMax(); $avail = $ammo->getAmount(); $put = Common::clamp($max - $now, 0, $avail); if ($put == 0) { $player->msg('1156'); // $player->message('Your weapon is already loaded.'); return false; } // Dog_Log::debug(sprintf('%s reloads his %s: Nee')) $ammo->useAmount($player, $put); $this->increase('sr4it_ammo', $put); if ($p->isFighting()) { $ep = $p->getEnemyParty(); $busy = $player->busy(round($this->getReloadTime() + rand(0, 10))); $p->ntice('5206', array($player->getName(), $put, $this->getName(), $busy)); $ep->ntice('5206', array($player->getName(), $put, $this->getName(), $busy)); // $message = sprintf(' load(s) %d bullet(s) into his %s. %s', $put, $this->getItemName(), Shadowfunc::displayBusy($busy)); // $message = sprintf(' load(s) %d bullet(s) into his %s. %s busy.', $put, $this->getItemName(), $player->busy(round($this->getReloadTime()+rand(0, 10)))); // $p->message($player, $message); // $p->getEnemyParty()->message($player, $message); } else { // $message = sprintf('You load %d bullet(s) into your %s.', $put, $this->getItemName()); // $bot = Shadowrap::instance($player); // $bot->rply('5207', array($put, $this->getName())); $player->msg('5207', array($put, $this->getName())); // $bot->reply($message); } return true; }
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 function onTrollReward(SR_NPC $npc, SR_Player $player) { $max = $player->isRunner() ? Shadowcmd_lvlup::MAX_VAL_ATTRIBUTE_RUNNER : Shadowcmd_lvlup::MAX_VAL_ATTRIBUTE; $base = $player->getBase('magic'); if ($base >= $max) { $ny = 5000; $player->giveNuyen($ny); return $player->message($this->lang('reward_ny', array($ny))); // return $player->message('Larry hands you another 5000 nuyen!'); } $player->message($this->lang('reward1')); // $player->message('Larry leads you to a shamane: "This is our shamane, Srando, he can help you."'); $race = $player->getRace(); if ($race === 'Ork' || $race === 'Troll') { $player->message($this->lang('reward2', array($race))); // $player->message('The shamane says: "You are a strong '.$race.'. You just need to calm down sometime."'); $player->message($this->lang('reward3')); // $player->message('You are starting to argue, but the shamane continues: "If you calm you have more time to strengthen yourself. Focus yourself, and the path is clear."'); $player->message($this->lang('reward4')); // $player->message('The shamane touches your head: "Your mind is now clear from anything. You can focus yourself from now on."'); $player->message($this->lang('reward5')); // $player->message('Your character is now allowed to learn magic and spells.'); } else { $player->message($this->lang('reward5')); // $player->message('The shamane mumbles some magic spells and raises your base value for magic by 1.'); } $player->alterField('magic', 1); $player->modify(); return true; }
/** * Use the amount of an item. Delete item when empty. * @param SR_Player $player * @param int $amount * @return true|false */ public function useAmount(SR_Player $player, $amount = 1, $modify = true) { if ($amount > $this->getAmount()) { Dog_Log::error(sprintf('Item %s(%d) has not %d amount to use!', $this->getItemName(), $this->getID(), $amount)); return false; } if (false === $this->increase('sr4it_amount', -$amount)) { Dog_Log::error(sprintf('Item %s(%d) can not decrease amount %d!', $this->getItemName(), $this->getID(), $amount)); return false; } if ($modify) { $player->modify(); } return $this->getAmount() < 1 ? $this->deleteItem($player) : true; }
private function teachNinja(SR_Player $player, $price) { $p = Shadowfunc::displayNuyen($price); if ($player->hasSkill('ninja')) { $this->rply('enough'); // $this->reply('Thank you, but you already donated enough :)'); } elseif ($player->hasNuyen($price)) { $player->pay($price); $player->levelupFieldTo('ninja', 0); // $player->updateField('ninja', 0); $this->rply('come'); $player->message($this->langNPC('teaching')); // $this->reply("Thank you my friend. Come with me..."); // $player->message('The monk teaches you the Ninja Skill. This will improve attack and damage for ninja weapons.'); $player->modify(); } else { $this->rply('sry', array($p)); // $this->reply("I am sorry, but learning the ninja skill cost $p."); } }