public function onNPCTalk(SR_Player $player, $word, array $args) { $key = 'Seattle_Citizen_Hire_' . $player->getID(); $key2 = 'Seattle_Citizen_Invite_' . $player->getID(); $b = chr(2); switch ($word) { case 'shadowrun': if ($this->getGender() === 'male') { $this->rply('job_male'); $player->giveKnowledge('words', 'Hire'); } else { $this->rply('job_female'); } return true; case 'no': return $this->rply('no_' . $this->getGender()); case 'hire': if ($this->getGender() === 'female') { return $this->rply('hire_female'); } $ch = $player->get('charisma'); $re = $player->get('reputation'); if ($player->getParty()->hasHireling()) { $this->rply('two_hirelings'); } elseif ($this->hasTemp($key) || rand(0, 32) > $ch + $re) { $this->rply('not_skilled'); $this->setTemp($key, 1); } else { $this->rply('lets_go'); $time = 400 + $ch * 40 + $re * 20; $p = $this->getParty(); $p->kickUser($this, true); $this->onHireC($player, $time); $p->popAction(true); $player->getParty()->popAction(true); } return true; case 'invite': $quest = SR_Quest::getQuest($player, 'Vegas_Voices'); $quest instanceof Quest_Vegas_Voices; $quest->onTryInvite($this, $player); break; default: case 'hello': $this->rply('hello' . $this->getGender()); $player->giveKnowledge('words', 'Yes'); $player->giveKnowledge('words', 'No'); $player->giveKnowledge('words', 'Shadowrun'); break; } return true; }
public function onNPCTalk(SR_Player $player, $word, array $args) { $key = 'Seattle_Citizen_Hire_' . $player->getID(); $key2 = 'Seattle_Citizen_Invite_' . $player->getID(); $b = chr(2); switch ($word) { case 'shadowrun': $quest = SR_Quest::getQuest($player, 'Delaware_Seraphim2'); if (!$quest->isInQuest($player)) { $this->reply("I am looking for a job. Would you like to {$b}hire{$b} me?"); $player->giveKnowledge('words', 'Hire'); return true; } return $this->seraphimQuest($player, $word, $args); case 'no': return $this->reply("Yo chummer, you're on a run?"); case 'hire': $ch = $player->get('charisma'); $re = $player->get('reputation'); if ($player->getParty()->hasHireling()) { $this->reply('You already have a hireling. So I say no anway.'); } elseif ($this->hasTemp($key) || rand(0, 32) > $ch + $re) { $this->reply('You don\'t look very skilled. I better follow my own way.'); $this->setTemp($key, 1); } else { $time = 400 + $ch * 40 + $re * 20; $p = $this->getParty(); $p->kickUser($this, true); $this->onHireC($player, $time); $p->popAction(true); $player->getParty()->popAction(true); $this->reply("Ok, let's go!"); } break; case 'invite': $quest = SR_Quest::getQuest($player, 'Seattle_Barkeeper'); $quest instanceof Quest_Seattle_Barkeeper; $quest->onTryInvite($this, $player); break; default: case 'hello': $this->reply("Hello chummer. Are you on a {$b}Shadowrun{$b}?"); $player->giveKnowledge('words', 'Yes'); $player->giveKnowledge('words', 'No'); $player->giveKnowledge('words', 'Shadowrun'); break; } return true; }
public static function createStats(SR_Player $player) { $stats = new self(array('sr4ps_pid' => $player->getID(), 'sr4ps_i_looted' => 0, 'sr4ps_i_sold' => 0, 'sr4ps_i_bought' => 0, 'sr4ps_i_dropped' => 0, 'sr4ps_i_given' => 0, 'sr4ps_i_received' => 0, 'sr4ps_ny_loot' => 0, 'sr4ps_ny_spent' => 0, 'sr4ps_ny_income' => 0, 'sr4ps_ny_given' => 0, 'sr4ps_ny_received' => 0, 'sr4ps_kill_mob' => 0, 'sr4ps_kill_npc' => 0, 'sr4ps_kill_human' => 0, 'sr4ps_kill_runner' => 0)); if (false === $stats->replace()) { return false; } return $stats; }
/** * Set who whispered who to allow implementation of whisper_back. * @param SR_Player $from * @param SR_Player $to */ private static function onWhispered(SR_Player $from, SR_Player $to) { $pid = $to->getID(); if (!isset(self::$WHISPER[$pid])) { self::$WHISPER[$pid] = array(); } self::cleanupWhisper($pid); self::$WHISPER[$pid][$from->getID()] = Shadowrun4::getTime(); }
private static function getWBTarget(SR_Player $player) { $pid = $player->getID(); if (!isset(Shadowcmd_whisper::$WHISPER[$pid])) { return -1; } $data = Shadowcmd_whisper::$WHISPER[$pid]; if (count($data) === 1) { return Shadowrun4::getPlayerByPID(key($data)); } return -2; }
/** * Compute the distances to an explosion. * Imagaine the game like this * A * B E * F * CD * ---0m--- * @param SR_Player $target * @param unknown_type $radius * @param unknown_type $atk * @param unknown_type $atk_delta */ public static function computeDistances(SR_Player $target, $inaccuracy = 3) { $party = $target->getParty(); $members = $party->getMembers(); $coords = array(); foreach ($members as $m) { $m instanceof SR_Player; $coords[$m->getID()] = array($m->getX(), $m->getY()); } # Point of impact. $g_x = $coords[$target->getID()][0] + Shadowfunc::diceFloat(-$inaccuracy, +$inaccuracy); $g_y = $coords[$target->getID()][1] + Shadowfunc::diceFloat(-$inaccuracy, +$inaccuracy); // echo sprintf("Grenade has coords %.02f / %.02f\n", $g_x, $g_y); $back = array(); foreach ($coords as $uid => $data) { list($p_x, $p_y) = $data; $d = Shadowfunc::calcDistanceB($g_x, $g_y, $p_x, $p_y); $p = Shadowrun4::getPlayerByPID($uid); $back[] = array($uid, $d); // echo sprintf("%s has coords %.02f / %.02f (distance: %.02f)\n", $p->getName(), $p_x, $p_y, $d); } return $back; }
public static function onTell(SR_Player $player) { $pid = $player->getID(); $where = 'sr4tl_pid=' . $pid; $table = self::table(__CLASS__); if (false === ($result = $table->selectAll('sr4tl_time, sr4tl_msg', $where, 'sr4tl_time DESC', NULL, 10, 0, GDO::ARRAY_N))) { return false; } foreach (array_reverse($result) as $row) { $player->msg('5019', array($row[1])); // $player->message('OldMessage: '.$row[1]); } return $table->deleteWhere($where); }
private static function onGMNS(SR_Player $player, SR_Player $target, $arg) { $pid = $target->getID(); if (strtolower($arg) === 'on') { if (false === SR_NoShout::setNoShout($pid, -1)) { return false; } return $player->message(sprintf('Banned %s from shouting.', $target->getName())); } elseif (strtolower($arg) === 'off') { if (false === SR_NoShout::setShout($pid)) { return false; } return $player->message(sprintf('Allowed %s to shout again.', $target->getName())); } elseif (0 < ($seconds = GWF_TimeConvert::humanToSeconds($arg))) { if (false === SR_NoShout::setNoShout($pid, $seconds)) { return false; } return $player->message(sprintf('Banned %s from shouting for %s.', $target->getName(), GWF_TimeConvert::humanDuration($seconds))); } else { $player->message(Shadowhelp::getHelp($player, 'gmns')); return false; } }
/** * Add a player to memory. * @param SR_Player $player */ public static function addPlayer(SR_Player $player) { self::$players[$player->getID()] = $player; }
public static function clearRequests(SR_Player $player) { $pid = $player->getID(); return self::table(__CLASS__)->deleteWhere("sr4cr_pid={$pid}"); }
public static function onKilled(SR_Player $killer, SR_Player $victim) { echo __METHOD__; return self::table(__CLASS__)->insertAssoc(array('sr4kp_killer' => $killer->getID(), 'sr4kp_victim' => $victim->getID(), 'sr4kp_srtime' => Shadowrun4::getTime() + self::getKillTime($killer, $victim))); }
public function setRemotePlayer(SR_Player $player) { $this->remote_pid = $player->getID(); }
public function swapMembers(SR_Player $a, SR_Player $b) { $this->members = GWF_Array::swapAssoc($this->members, $a->getID(), $b->getID()); $this->recomputeEnums(); return $this->updateMembers(); }
public static function deleteAllItems(SR_Player $player) { $pid = $player->getID(); return self::table(__CLASS__)->deleteWhere("sr4it_uid={$pid}"); }
public function hasHacked(SR_Player $player) { $pid = $player->getID(); if (!isset($this->hackers[$pid])) { $this->hackers[$pid] = 1; } else { $this->hackers[$pid]++; } return $this->hackers[$pid] > $this->getMaxAttempts(); }
public static function create(SR_Player $player, $name) { $clan = new self(array('sr4cl_id' => '0', 'sr4cl_name' => $name, 'sr4cl_founder' => $player->getID(), 'sr4cl_slogan' => '', 'sr4cl_date' => GWF_Time::getDate(), 'sr4cl_members' => '0', 'sr4cl_max_members' => self::MIN_MEMBERCOUNT, 'sr4cl_storage' => '0', 'sr4cl_max_storage' => self::MIN_STORAGE, 'sr4cl_money' => '0', 'sr4cl_max_money' => self::MIN_MONEY, 'sr4cl_options' => '0')); if (false === $clan->insert()) { echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); return false; } if (false === $clan->join($player)) { echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); return false; } if (false === SR_ClanMembers::setClanOptions($clan->getID(), $player->getID(), SR_ClanMembers::FOUNDER)) { echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); return false; } if (false === SR_ClanHistory::onCreate($clan, $player)) { echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); return false; } return $clan; }
public static function onKilled(SR_Player $killer, SR_Player $victim, $bountyid) { return self::insertAssoc(array('sr4bh_id' => 0, 'sr4bh_killer_id' => $killer->getID(), 'sr4bh_bounty_id' => $bountyid, 'sr4bh_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND))); }
public static function deletePlayer(SR_Player $player) { return self::table(__CLASS__)->deleteWhere('sr4pv_uid=' . $player->getID()); }
public function isLockClosedPlayer(SR_Player $player) { $pid = $player->getID(); return isset($this->LOCK[$pid]) && $this->LOCK[$pid] === 0; }
private function onSetSlogan(SR_Player $player, SR_Clan $clan, array $args) { if ($clan->getLeaderID() != $player->getID()) { $player->msg('1124'); // $player->message("You don't lead this clan, chummer!"); return false; } array_shift($args); $slogan = implode(' ', $args); $cost = self::COST_SLOGAN; $dcost = Shadowfunc::displayNuyen($cost); if (false === $player->hasNuyen($cost)) { $player->msg('1063', array($dcost, $player->displayNuyen())); // $player->message(sprintf('It cost %s to set a slogan for your clan, but you only have %s.', $dcost, $player->displayNuyen())); return false; } if (strlen($slogan) > 196) { $player->msg('1130', array(196)); // $player->message(sprintf('Your slogan exceeds the maxlength of %s characters.', 196)); return false; } if (false === $clan->saveVar('sr4cl_slogan', $slogan)) { $player->message('DB ERROR 6'); return false; } $player->msg('5169', array($dcost)); // $player->message(sprintf('You paid the fee of %s and set a new slogan for your clan.', $dcost)); return true; }
public function onUpgradeB(SR_Player $player, array $args, $safe) { $pid = $player->getID(); $safebit = $safe ? 'X' : 'Y'; $old_msg = isset(self::$UPGRADE_CONFIRM[$pid . $safebit]) ? self::$UPGRADE_CONFIRM[$pid . $safebit] : ''; unset(self::$UPGRADE_CONFIRM[$pid . $safebit]); $bot = Shadowrap::instance($player); if (count($args) !== 2) { $bot->reply(Shadowhelp::getHelp($player, $safe ? 'safeupgrade' : 'upgrade')); return false; } if (false === ($item = $player->getItem($args[0]))) { $bot->rply('1029'); // $bot->reply('You don`t have that item.'); return false; } if ($item instanceof SR_Mount) { /* thx noother */ } elseif (!$item instanceof SR_Equipment || !$item->isItemStattable()) { $bot->rply('1158'); // $bot->reply('The first item is not an equipment.'); return false; } if (false === ($rune = $player->getInvItem($args[1]))) { $bot->rply('1029'); // $bot->reply('You don`t have that rune.'); return false; } if (!$rune instanceof SR_Rune) { $bot->rply('1160'); // $bot->reply('The second item is not a rune.'); return false; } $modsRune = $rune->getModifiers(); if ($modsRune === NULL || count($modsRune) === 0) { $bot->reply('The rune has no modifiers. Somethings wrong! (BUG)'); return false; } if (!$this->checkCombination($player, $item, $rune)) { // $bot->rply('1161'); // $bot->reply('This item can not get this rune applied to it.'); return false; } # Check if equipped mount is loaded with items. (thx tehron) if ($item instanceof SR_Mount) { if ($item->isEquipped($player)) { if (count($player->getMountInvSorted()) !== 0) { $bot->rply('1164'); // $bot->reply("Please '#mount clean' before you '#upgrade' it."); return false; } } } if (false === SR_Item::canMergeModifiersLength($item, $rune)) { $bot->rply('1165'); // $bot->reply('The item string would get too long with another modifier.'); return false; } $mods = SR_Item::mergeModifiers($item->getItemModifiersB(), $rune->getItemModifiersB()); $luck = $player->get('luck'); $luck = Common::clamp($luck, 0, 30); $luckmod = 0.35; $luckmod -= $luck * 0.005; $fail = SR_Rune::calcFailChance($mods) * $luckmod * $this->getUpgradeFailModifier(); $break = SR_Rune::calcBreakChance($mods) * $luckmod * $this->getUpgradeBreakModifier(); $price_u = $this->calcUpgradePrice($player, $rune->getItemPriceStatted()); $dpu = Shadowfunc::displayNuyen($price_u); $fail = round(Common::clamp($fail, 5, 85), 2); $break = round(Common::clamp($break, 1, 50), 2); if ($safe) { $fail -= 5; $break = 0; } ## Confirm $msg = implode(' ', $args); if ($msg !== $old_msg) { self::$UPGRADE_CONFIRM[$pid . $safebit] = $msg; return $player->msg('5211', array(Shadowfunc::displayNuyen($price_u), $item->displayFullName($player), $rune->displayFullName($player), $fail, $break)); // return $player->message(sprintf( // 'The smith examines your items ... "It would cost you %s to upgrade your %s with %s. The fail chance is %.02f%% and the break chance is %.02f%%. Please retype to confirm.', // Shadowfunc::displayNuyen($price_u), $item->getItemName(), $rune->getItemName(), $fail, $break // )); } if (!$player->hasNuyen($price_u)) { $bot->rply('1063', array($dpu, $player->displayNuyen())); // $bot->reply(sprintf('The smith says: "I am sorry chummer, the upgrade would cost you %s."', $dpu)); return false; } # Safe mode if ($safe) { $break = 0; if (false === ($oil = $player->getInvItemByName('MagicOil'))) { $bot->rply('1187', array(Shadowlang::displayItemNameS('MagicOil'))); return false; } if (!$oil->useAmount($player, 1)) { $bot->reply('DB Error 19'); return false; } } $player->msg('5212'); // $player->message('The smith takes your items and goes to work...'); $player->removeItem($rune); $rune->delete(); if (Shadowfunc::dicePercent($fail)) { if (Shadowfunc::dicePercent($break)) { $player->removeItem($item); $item->delete(); $bot->rply('5213', array($item->displayFullName($player), $rune->displayFullName($player))); // $bot->reply(sprintf('The upgrade horrible failed and the item and the rune is lost. The smith is very sorry and you don`t need to pay any money.')); } else { $price_f = $this->calcUpgradePrice($player, 0); $player->pay($price_f); $dpf = Shadowfunc::displayNuyen($price_f); $bot->rply('5214', array($dpf, $rune->displayFullName($player))); // $bot->reply(sprintf('The upgrade failed and the rune is lost. You only need to pay %s for the work.', $dpf)); } } else { $player->pay($price_u); $old_name = $item->displayFullName($player); $item->addModifiers($rune->getItemModifiersB(), true); $item->addModifiers($rune->getItemModifiersA($player), true); $bot->rply('5215', array($dpu, $item->displayFullName($player), $old_name, $rune->displayFullName($player))); // $bot->reply(sprintf('The upgrade succeeded. You pay %s and the smith presents you a fine %s.', $dpu, $item->getItemName())); } $player->modify(); return true; }