public static function giveNuyen(SR_Player $player, SR_Player $target, $what, $amt) { if ($amt <= 0) { $player->msg('1062'); // $player->message(sprintf('You can only give away a positive amount of %s.', $what)); return false; } $have = $player->getBase($what); if ($amt > $have) { $player->msg('1063', array(Shadowfunc::displayNuyen($amt), Shadowfunc::displayNuyen($have))); // $player->message(sprintf('You only have %s %s.', $have, $what)); return false; } # Thx jjk // if (($have - $amt) <= SR_Player::START_NUYEN) // { // $player->message(sprintf('You can\'t give all your money away, you need at least %s', Shadowfunc::displayNuyen(SR_Player::START_NUYEN))); // $player->message(sprintf('Maximum you can give is %s', Shadowfunc::displayNuyen($have-SR_Player::START_NUYEN))); // return false; // } if (false === $target->alterField($what, $amt)) { $player->message('Database error in giveNyKa()... 1'); return false; } if (false === $player->alterField($what, -$amt)) { $player->message('Database error II in giveNyKa()... 2'); return false; } $target->msg('5118', array(Shadowfunc::displayNuyen($amt), $player->getName())); $player->msg('5119', array(Shadowfunc::displayNuyen($amt), $target->getName())); // $target->message(sprintf('You received %s %s from %s.', $amt, $what, $player->getName())); // $player->message(sprintf('You gave %s %s %s.', $target->getName(), $amt, $what)); 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; }
public static function execute(SR_Player $player, array $args) { if ($player->getBase('age') > 0) { $player->msg('1016', array(Shadowfunc::displayASL($player))); // $player->message(sprintf("You already have your asl set to: %s.", Shadowfunc::displayASL($player))); return false; } if (count($args) === 0) { $player->message(self::getASLSetHelp($player)); return false; } if (count($args) === 1 && $args[0] === 'RANDOM') { return self::onASLSetRandom($player); } $arg = implode(' ', $args); $age = round(self::parseValue($arg, 'y')); $bmi = round(self::parseValue($arg, 'kg') * 1000); $height = self::parseValue($arg, 'cm'); if ($height > 1 && $height < 2) { // $player->message(sprintf('Auto corrected your height "%.03f" to "%dcm"', $height, round($height*100))); $height = round($height * 100); } $errors = ''; $errors .= self::validateAge($player, $age); $errors .= self::validateHeight($player, $height); $errors .= self::validateBMI($player, $bmi, $height); if ($errors !== '') { $message = sprintf('Error: %s.', $errors); self::reply($player, $message); $player->message(self::getASLSetHelp($player)); return false; } return self::onASLSetCustom($player, $age, $bmi, $height); }
private static function beamToRedmond(SR_Player $player) { $p = $player->getParty(); $xp = $player->getBase('xp'); $player->resetXP(); $player->msg('5299', array(self::BEAM_TARGET)); # Your XP stack got reset and you get beamed back to %s. $p->pushAction(SR_Party::ACTION_INSIDE, self::BEAM_TARGET); }
public static function alchemicFactory(SR_Player $player, $spellname, $level) { $ma = $player->get('magic'); $in = $player->get('intelligence'); $wi = $player->get('wisdom'); $alc = $player->get('alchemy'); # 10 - 80 percent randomness $randomness = 100 - ($wi + $alc * 2 + $in + $ma); $randomness = Common::clamp($randomness, 10, 80); $randomness = Shadowfunc::diceFloat(10, $randomness) * 0.01; # Dice! $minlevel = round($level - $level * $randomness, 1); $maxlevel = $level; $level = Shadowfunc::diceFloat($minlevel, $maxlevel, 1); $potion = SR_Item::createByName('AlchemicPotion'); $potion->addModifiers(array($spellname => $level, 'magic' => $player->getBase('magic'), 'intelligence' => $player->getBase('intelligence'), 'wisdom' => $player->getBase('wisdom'))); return $potion; }
private static function getShoutWait(SR_Player $player) { $range = self::MAX_DELAY - self::MIN_DELAY; $tpl = $range / self::MAX_LEVEL; $level = Common::clamp($player->getBase('level'), 0, self::MAX_LEVEL); $delay = self::MIN_DELAY + $tpl * (self::MAX_LEVEL - $level); $last = $player->hasTemp(self::TEMP_KEY) ? $player->getTemp(self::TEMP_KEY) : 0; $next = $last + $delay; return $next - time(); }
public static function displayBountyPlayer(SR_Player $player) { $bounty = $player->getBase('bounty'); if ($bounty <= 0) { return $player->lang('no_bounty'); # This player has no bounty. } $total = Shadowfunc::displayNuyen($bounty); return $player->lang('total_bounty', array($total, $player->getName(), self::displayBountyPlayerDetails($player))); // return sprintf("There is a total {$b}bounty of %s{$b} for %s: %s.", $total, $player->getName(), self::displayBountyPlayerDetails($player)); }
public static function onASLShowPlayer(SR_Player $player, array $args) { $b = chr(2); if ($player->getBase('age') > 0) { return self::rply($player, '5012', array(Shadowfunc::displayASL($player), self::translate('asl'))); // return self::reply($player, sprintf("Your asl: %s. Use #asl [<age|bmi|height>] for party sums.", Shadowfunc::displayASL($player))); } else { $player->msg('1011', array(self::translate('aslset'))); // $player->message(sprintf("You did not setup your asl with {$b}#aslset{$b} yet. You need to do this to start moving in the game.")); return false; } }
public function getReward(SR_Player $player) { $possible = array(array('LO_Rune_of_attack:0.3', 'Rune_of_body:0.5')); if ($player->getBase('bows') >= 0) { $possible[] = array('SportBow_of_bows:1,attack:1', 'Ammo_Arrow', 'Ammo_Arrow'); } if ($player->getBase('pistols') >= 0) { $possible[] = array('AresPredator_of_attack:1,max_dmg:1', 'Ammo_9mm'); } if ($player->getBase('ninja') >= 0) { $possible[] = array('NinjaSword'); } if ($player->getBase('magic') >= 0) { $possible[] = array('ElvenStaff_of_magic:2,max_hp:2'); } $reward = $possible[array_rand($possible, 1)]; $back = array(); foreach ($reward as $itemname) { $back[] = SR_Item::createByName($itemname); } return $back; }
private function meleeSkill(SR_Player $player, $word) { if ($player->getBase('melee') >= 0) { return true; } $this->rply('unsure'); // $this->reply('MMMh... You are unsure about your path...'); $player->message($this->langNPC('confident')); // $player->message('The monk strengthens your self confidence... You have learned the melee skill!'); $player->levelupFieldTo('melee', 0); // $player->updateField('melee', 0); // $player->modify(); return false; }
private function onPraySins(SR_Player $player, $price) { $nuyen = $player->getNuyen(); $dp = Shadowfunc::displayNuyen($price); $dn = Shadowfunc::displayNuyen($nuyen); if ($price > $nuyen) { return $this->rply('cost', array($dp, $dn)); // return $this->reply(sprintf('My son, it would cost %s to forgive your sins, but you have only %s.', $dp, $dn)); } $player->giveNuyen(-$price); $dl = Shadowfunc::displayNuyen($nuyen - $price); $player->message($this->langNPC('pay', array($dp, $dl))); // $player->message("You pay the price of {$dp} and have {$dl} left."); $player->alterField('bad_karma', -1); $badkarma = $player->getBase('bad_karma'); return $this->rply('thx', array($badkarma)); // return $this->reply("Thank you my son. You now have only {$badkarma} bad karma left."); }
public function onSolveDuo(SR_Player $player) { $this->msg('solve2a'); $this->msg('solve2b'); // $player->message('The dwarfs look very pleased.'); // $player->message('"Thank you so much", Aron says, "For your help we have thought of a special reward..."'); $max = $player->isRunner() ? Shadowcmd_lvlup::MAX_VAL_SKILL_RUNNER : Shadowcmd_lvlup::MAX_VAL_SKILL; if ($player->getBase('melee') > $max) { $this->msg('solve2c', array(Shadowfunc::displayNuyen(5000))); $player->giveNuyenEvent(5000); // $player->message('You received another 5000 nuyen!'); } else { $this->msg('solve2d'); // $player->message('Your melee skill has increased by 1.'); $player->levelupField('melee', 1); // $player->modify(); } return true; }
public function checkQuest(SR_NPC $npc, SR_Player $player) { if ($player->getBase('bad_karma') > 0) { $npc->reply($this->lang('thx1')); // $npc->reply('Excellent ... let me try to free you from your sins ...'); $player->message($this->lang('thx2')); // $player->message('The shamane is praying and mumbling ... and you feel better!'); $player->increaseField('bad_karma', -1); $npc->reply($this->lang('thx3')); // $npc->reply('It seems like i get better and better doing this ... let me teach you something!'); $player->levelupSpell('bunny', 1); $player->message($this->lang('thx4')); // $player->message('You have learned the bunny spell, which allows you to flee from combats.'); return $this->onSolve($player); } else { return $npc->reply($this->lang('more')); // return $npc->reply('You still have not enough bad karma.'); } }
public static function getCurrentCommands(SR_Player $player, $show_hidden = true, $boldify = false, $long_versions = true, $translate = false, $filter_hidden = false, $hidden_only = false) { if ($player->isOptionEnabled(SR_Player::DEAD)) { return array_merge(self::$CMDS_ALWAYS_CREATE, array('reset')); } if (false === $player->isCreated()) { return self::$CMDS_ALWAYS_CREATE; } if (false === ($party = $player->getParty())) { return array(); } $action = $party->getAction(); $leader = $player->isLeader(); $commands = array(); # Allways commands if (!$hidden_only) { $commands = array_merge($commands, self::$CMDS_ALWAYS); } # Always if ($show_hidden) { $commands = array_merge($commands, self::$CMDS_ALWAYS_CREATE); } # GM commands if ($show_hidden && $player->isGM()) { $commands = array_merge($commands, self::$CMDS_GM); } # Hidden commands if ($show_hidden) { $commands = array_merge($commands, self::$CMDS_ALWAYS_HIDDEN); } # Player actions if (!$hidden_only) { $commands = array_merge($commands, self::$CMDS[$action]); if (false !== ($scanner = $player->getInvItemByName('Scanner_v6', false))) { $commands[] = 'spy'; } if ($player->getBase('alchemy') >= 0) { $commands[] = 'brew'; } } # Leader actions if ($leader) { if ($show_hidden) { $commands = array_merge($commands, self::$CMDS_LEADER_ALWAYS); } if (!$hidden_only) { # Outside location? if (false !== ($location = $party->getLocationClass('outside'))) { if ($location->isEnterAllowed($player)) { # We can enter $commands[] = 'enter'; } } # Action $commands = array_merge($commands, self::$CMDS_LEADER[$action]); } } # Location commands if (!$hidden_only) { if (false !== ($location = $party->getLocationClass('inside'))) { # Leader if ($leader === true) { // $commands = array_merge($commands, self::shortcutArray($location->getLeaderCommands($player))); $commands = array_merge($commands, $location->getLeaderCommands($player)); if ($location->isPVP()) { $commands[] = 'fight'; } } # Talk $commands = array_merge($commands, $location->getNPCTalkCommands($player)); # Special // $commands = array_merge($commands, self::shortcutArray($location->getCommands($player))); $commands = array_merge($commands, $location->getCommands($player)); } elseif (false !== ($location = $party->getLocationClass('outside'))) { if ($location->isHijackable()) { $commands[] = 'hijack'; } // if ($location->isPVP()) // { $commands[] = 'fight'; // } } } // if ($long_versions === false) // { // $commands = array_map(array(__CLASS__, 'shortcut'), $commands); // } // if ($long_versions === true) // { // $commands = array_map(array(__CLASS__, 'unshortcut'), $commands); // } ############## ### FORMAT ### ############## if ($filter_hidden) { $commands = array_values(array_diff($commands, self::$REALLY_HIDDEN)); } if ($boldify) { // if ($long_versions === true) // { // $commands = array_map(array(__CLASS__, 'boldify_longs'), $commands); // } // else // { $commands = array_map(array(__CLASS__, 'boldify'), $commands); // } } # Shortcut if (!$long_versions) { $commands = array_map(array(__CLASS__, 'shortcut_bolded'), $commands); } # Translate if ($translate) { $commands = array_map(array(__CLASS__, 'translate_bolded'), $commands); } # \o/ return $commands; }
public function allowShopSteal(SR_Player $player) { return $player->getBase('thief') > 0; }
private static function getSleep(SR_Player $player) { return $player->getBase('sleepy'); }
public static function execute(SR_Player $player, array $args) { $p = $player->getParty(); # Can lvlup in combat? // if ($p->isFighting()) // { // $player->message('You cannot lvlup when your party is fighting.'); // return false; // } // $bot = Shadowrap::instance($player); $runner = $player->isRunner(); $have = $player->getBase('karma'); if (count($args) !== 1) { $cost = self::KARMA_COST_SPELL; // $b = chr(2); $max = $runner ? self::MAX_VAL_SKILL_RUNNER : self::MAX_VAL_SKILL; $player->msg('5057', array($max, Shadowfunc::getStatsLvlUpArray($player, SR_Player::$SKILL, self::KARMA_COST_SKILL, $max))); // $player->message('Skills to upgrade: ' . Shadowfunc::getStatsLvlUpArray($player, SR_Player::$SKILL, self::KARMA_COST_SKILL, $runner?self::MAX_VAL_SKILL_RUNNER:self::MAX_VAL_SKILL)); $arr = SR_Player::$ATTRIBUTE; unset($arr['es']); //ignore essence $max = $runner ? self::MAX_VAL_ATTRIBUTE_RUNNER : self::MAX_VAL_ATTRIBUTE; $player->msg('5058', array($max, Shadowfunc::getStatsLvlUpArray($player, $arr, self::KARMA_COST_ATTRIBUTE, $max))); // $player->message('Attributes to upgrade: ' . Shadowfunc::getStatsLvlUpArray($player, $arr, self::KARMA_COST_ATTRIBUTE, $runner?self::MAX_VAL_ATTRIBUTE_RUNNER:self::MAX_VAL_ATTRIBUTE)); $max = $runner ? self::MAX_VAL_KNOWLEDGE_RUNNER : self::MAX_VAL_KNOWLEDGE; $player->msg('5059', array($max, Shadowfunc::getStatsLvlUpArray($player, SR_Player::$KNOWLEDGE, self::KARMA_COST_KNOWLEDGE, $max))); // $player->message('Knowledge to upgrade: ' . Shadowfunc::getStatsLvlUpArray($player, SR_Player::$KNOWLEDGE, self::KARMA_COST_KNOWLEDGE, $runner?self::MAX_VAL_KNOWLEDGE_RUNNER:self::MAX_VAL_KNOWLEDGE)); $s = ''; if ($player->getSpellData()) { $format = $player->lang('fmt_lvlup'); $max = $runner ? self::MAX_VAL_SPELL_RUNNER : self::MAX_VAL_SPELL; $nl = $player->getSpellData(); asort($nl); foreach (array_reverse($nl) as $name => $base) { $k = 'K'; $bold = ''; $could = 0; if ($base >= $max) { $n = '*'; $k = ''; } else { $n = ($base + 1) * 2; if ($n <= $have) { $bold = chr(2); $could = 1; // $n = $b.$n.'K'.$b; // $name = $b.$name.$b; } else { // $n = $n.'K'; } } $s .= sprintf($format, $name, $base + 1, $n, $bold, $k, $could); // $s .= sprintf(', %s:%s(%s)', $name, ($base+1), $n); } } $s = $s === '' ? $player->lang('none') : ltrim($s, ',; '); return $player->msg('5060', array($max, $s)); // $player->message('Spells to upgrade: '.$s); // return true; } $f = strtolower($args[0]); # Shortcuts if (isset(SR_Player::$SKILL[$f])) { $f = SR_Player::$SKILL[$f]; } if (isset(SR_Player::$ATTRIBUTE[$f])) { $f = SR_Player::$ATTRIBUTE[$f]; } if (isset(SR_Player::$KNOWLEDGE[$f])) { $f = SR_Player::$KNOWLEDGE[$f]; } // if ($f === 'essence') { $bot->reply('You can not levelup your essence.'); return false; } if ($f === 'essence') { $player->msg('1024'); // $bot->reply('You can not levelup your essence.'); return false; } $is_spell = false; $cost = self::getKarmaCostFactor($f); if (in_array($f, SR_Player::$SKILL)) { $level = $player->getBase($f); // $cost = self::KARMA_COST_SKILL; $max = $runner ? self::MAX_VAL_SKILL_RUNNER : self::MAX_VAL_SKILL; } elseif (in_array($f, SR_Player::$ATTRIBUTE)) { $level = $player->getBase($f); // $cost = self::KARMA_COST_ATTRIBUTE; $max = $runner ? self::MAX_VAL_ATTRIBUTE_RUNNER : self::MAX_VAL_ATTRIBUTE; } elseif (in_array($f, SR_Player::$KNOWLEDGE)) { $level = $player->getBase($f); // $cost = self::KARMA_COST_KNOWLEDGE; $max = $runner ? self::MAX_VAL_KNOWLEDGE_RUNNER : self::MAX_VAL_KNOWLEDGE; } elseif (false !== ($spell = SR_Spell::getSpell($f))) { $level = $spell->getBaseLevel($player); // $cost = self::KARMA_COST_SPELL; $is_spell = true; $max = $runner ? self::MAX_VAL_SPELL_RUNNER : self::MAX_VAL_SPELL; } else { $player->msg('1024'); // $bot->reply('You can only levelup attributes, skills, knowledge and spells.'); return false; } if ($level < 0) { $player->msg('1025', array($f)); // $bot->reply(sprintf('You need to learn %s first.', $f)); return false; } if ($level >= $max) { $player->msg('1026', array($max, $f)); // $bot->reply(sprintf('You already have reached the max level of %d for %s.', $max, $f)); return false; } $need = ($level + 1) * $cost; if ($need > $have) { $player->msg('1027', array($need, $f, $level, $level + 1, $have)); // $bot->reply(sprintf('You need %d karma to increase your base level for %s from %d to %d, but you only have %d karma.', $need, $f, $level, $level+1, $have)); return false; } # Reduce Karma $player->alterField('karma', -$need); # Lvlup if ($is_spell === true) { $player->levelupSpell($f, 1); } else { $player->levelupField($f, 1); // $player->alterField($f, 1); } // $player->modify(); return self::rply($player, '5061', array($need, $f, $level, $level + 1)); // return $bot->reply(sprintf('You used %d karma and leveled up your %s from %d to %d.', $need, $f, $level, $level+1)); }
/** * @deprecated * @param SR_Player $player */ public static function displayLevel(SR_Player $player) { $base = $player->getBase('level'); $adj = $player->get('level'); return $base == $adj ? "(L{$base})" : "(L{$base}({$adj}))"; }
/** * Multiply a player stat and return as modifiers. Used by cyberware and MON_Rings. * @param SR_Player $player * @param array $matrix * @param boolean $base_values true for base, false for modified * @return array modifiers */ public static function multiplyStats(SR_Player $player, array $matrix, $base_values = true) { $back = array(); foreach ($matrix as $field => $multiplier) { $value = $base_values ? $player->getBase($field) : $player->get($field); if ($value > 0) { $back[$field] = round($value * $multiplier, 2); } } return $back; }