Beispiel #1
0
 public function onCityExit(SR_Party $party)
 {
     if ($party->hasNPCClassed('PrisonB2_Malois')) {
         $party->notice('Malois says: "Hurry, we have to hurry!"');
     }
     parent::onCityExit($party);
 }
Beispiel #2
0
 public function onCityEnter(SR_Party $party)
 {
     if ($party->hasNPCClassed('PrisonB2_Malois')) {
         $this->setAlert($party, 9000000);
     }
     parent::onCityEnter($party);
 }
Beispiel #3
0
 public function onCityEnter(SR_Party $party)
 {
     $party->giveKnowledge('places', 'Prison_Registry');
     if ($party->hasNPCClassed('PrisonB2_Malois')) {
         $this->setAlert($party, 9000000);
     }
     $party->notice('You can see the registry from here.');
     parent::onCityEnter($party);
 }
Beispiel #4
0
 public function getNPCMeetPercent(SR_Party $party)
 {
     foreach ($party->getMembers() as $player) {
         $quest = SR_Quest::getQuest($player, 'Seattle_Ranger');
         if ($quest->getAmount() > 0) {
             return 90;
         }
     }
     return 0;
 }
Beispiel #5
0
 public static function displayBadKarmaParty(SR_Party $party)
 {
     $back = '';
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         $bk = $member->getBase('bad_karma');
         if ($bk > 0) {
             $back .= Shadowrun4::lang('info_bk', array($member->getName(), $bk));
             // 				$back .= sprintf(', %s has %d bad_karma', $member->getName(), $bk);
         }
     }
     return $back === '' ? '' : sprintf(' %s.', substr($back, 2));
 }
Beispiel #6
0
 public static function displayBountyParty(SR_Party $party)
 {
     $back = '';
     $format = Shadowrun4::lang('fmt_sumlist');
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         $bounty = $member->getBase('bounty');
         if ($bounty > 0) {
             $back .= sprintf($format, $member->getEnum(), $member->getName(), Shadowfunc::displayNuyen($bounty));
             // 				$back .= sprintf(", {$b}%s{$b}-%s(%s)", $i++, $member->getName(), Shadowfunc::displayNuyen($bounty));
         }
     }
     return $back === '' ? '' : Shadowrun4::lang('meet_bounty', array(ltrim($back, ',; ')));
     // 		return $back === '' ? '' : sprintf(" There is a {$b}bounty{$b} on %s.", substr($back, 2));
 }
Beispiel #7
0
 private static function cleanupPlayers()
 {
     echo __METHOD__ . PHP_EOL;
     $players = GDO::table('SR_Player');
     $before = $players->countRows();
     if (false === ($result = $players->select('sr4pl_id, sr4pl_partyid'))) {
         echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         return;
     }
     $sr_time = Shadowrun4::getTime();
     while (false !== ($row = $players->fetch($result, GDO::ARRAY_N))) {
         if (false !== ($player = SR_Player::getByID($row[0]))) {
             if (false === SR_Party::getByID($player->getPartyID())) {
                 if ($player->isHuman()) {
                     printf("WARNING: %s has not party!!\n", $player->getName());
                 } else {
                     $player->delete();
                 }
             }
         }
     }
     $players->free($result);
     $after = $players->countRows();
     printf("I removed %s players from the database and %s are left.\n", $before - $after, $after);
 }
Beispiel #8
0
 public static function execute(SR_Player $player, array $args)
 {
     $bot = Shadowrap::instance($player);
     if (count($args) !== 0) {
         $bot->reply(Shadowhelp::getHelp($player, 'part'));
         return false;
     }
     $p = $player->getParty();
     if ($p->getMemberCount() === 1) {
         self::rply($player, '1093');
         // 			$bot->reply('You are not in a party.');
         return false;
     }
     $p->ntice('5135', array($player->getName()));
     // 		$p->notice(sprintf('%s has left the party.', $player->getName()));
     $p->kickUser($player, true);
     $np = SR_Party::createParty();
     $np->addUser($player, true);
     $np->cloneAction($p);
     $np->clonePreviousAction($p);
     //		if ($np->isMoving())
     if (!$np->isIdle()) {
         Shadowcmd_stop::execute($player, $args);
     }
     return true;
 }
Beispiel #9
0
 private function onEventMushroom(SR_Party $party)
 {
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         if ($member->isHuman()) {
             $percent = 0.05;
             $luck = $member->get('luck');
             $percent += $luck / 200;
             if (Shadowfunc::dicePercent($percent)) {
                 $amt = rand(2, 4);
                 $member->giveItems(array(SR_Item::createByName('Bolete', $amt)));
                 $member->message($this->lang($member, 'mushrooms', array($amt)));
             }
         }
     }
 }
Beispiel #10
0
 public static function execute(SR_Player $player, array $args)
 {
     $bot = Shadowrap::instance($player);
     if (count($args) !== 1) {
         $bot->reply(Shadowhelp::getHelp($player, 'kick'));
         return false;
     }
     $p = $player->getParty();
     if (false === ($target = $p->getMemberByArg($args[0]))) {
         self::rply($player, '1089');
         // 			$bot->reply('This player is not in your party.');
         return false;
     }
     if ($target->getID() === $player->getID()) {
         self::rply($player, '1090');
         // 			$bot->reply('You can not kick yourself.');
         return false;
     }
     $p->ntice('5137', array($target->getName()));
     // 		$p->notice(sprintf('%s has been kicked off the party.', $target->getName()));
     if ($p->kickUser($target, false)) {
         $p->recomputeEnums();
         $p->updateMembers();
         $np = SR_Party::createParty();
         $np->cloneAction($p);
         $np->clonePreviousAction($p);
         $np->addUser($target, true);
         if (!$np->isIdle()) {
             $np->popAction(true);
         }
     }
     return true;
 }
Beispiel #11
0
 public function onEventWallet(SR_Party $party)
 {
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         if ($member->isHuman()) {
             $percent = 0.05;
             $luck = $member->get('luck');
             $percent += $luck / 200;
             if (Shadowfunc::dicePercent($percent)) {
                 $nuyen = rand(100, 1000);
                 $member->message(sprintf('You found a wallet with %s in it.', Shadowfunc::displayNuyen($nuyen)));
                 $member->giveNuyen($nuyen);
             }
         }
     }
 }
Beispiel #12
0
 public function onEnterLocation(SR_Party $party)
 {
     $player = $party->getLeader();
     if ('1' === SR_PlayerVar::getVal($player, self::SWORDKEY, '0')) {
         $numBansh = self::getNumBanshees($player);
         $this->partyMessage($player, 'magic1');
         $this->partyMessage($player, 'magic2');
         $this->partyMessage($player, 'magic3');
         $enemies = array('Forest_Mordak');
         for ($i = 0; $i < $numBansh; $i++) {
             $enemies[] = 'Forest_Banshee';
         }
         shuffle($enemies);
         # Legitimate use of shuffle!
         $party->fight(SR_NPC::createEnemyParty($enemies));
     }
 }
Beispiel #13
0
 public function onLeaveLocation(SR_Party $party)
 {
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         # The heat is on?
         if (!$member->hasConst(self::KEY)) {
             continue;
         }
         if (false !== ($milk = $member->getInvItemByName('Milk', false, false))) {
             $amt = $milk->getAmount();
             if (false !== $member->deleteFromInventory($milk)) {
                 $member->message($this->lang($member, 'sour'));
                 $member->giveItems(array(SR_Item::createByName('SourMilk', $amt)));
             }
         }
     }
 }
Beispiel #14
0
 public function onLeaveLocation(SR_Party $party)
 {
     $errors = '';
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         if (false === ($item = $member->getInvItemByName('ID4Card'))) {
             $errors .= sprintf(', %s', $member->getName());
         } else {
             $member->message($this->lang($member, 'usecard', array($item->getAmount())));
             // 				$member->message(sprintf('You use one of your %d ID4 cards...', $item->getAmount()));
             $item->useAmount($member, 1);
         }
     }
     if ($errors !== '') {
         $this->partyMessage($party->getLeader(), 'nocard', array(substr($errors, 2)));
         // 			$party->notice(sprintf('%s do(es) not have an ID4Card... You hear the alarm sound!', substr($errors, 2)));
         if (false !== ($city = $this->getCityClass())) {
             $city->setAlert($party, GWF_Time::ONE_HOUR * 2);
         }
     }
 }
Beispiel #15
0
 public static function onFlee(SR_Player $player)
 {
     $party = $player->getParty();
     $ep = $party->getEnemyParty();
     $party->ntice('5113', array($player->getName()));
     $ep->ntice('5114', array($player->getName()));
     // 		$party->notice(sprintf('%s has fled from the enemy.', $player->getName()));
     // 		$ep->notice(sprintf('%s has fled from combat.', $player->getName()));
     $player->resetXP();
     $party->kickUser($player, true);
     $np = SR_Party::createParty();
     $np->addUser($player, true);
     $np->cloneAction($party);
     $np->clonePreviousAction($party);
     $np->popAction(true);
     if ($np->isInsideLocation()) {
         $np->pushAction(SR_Party::ACTION_OUTSIDE);
     }
 }
Beispiel #16
0
 public function onCityExit(SR_Party $party)
 {
     $party->unsetTemp(self::WERE_KEY);
 }
Beispiel #17
0
 private static function cleanupNPC($player_id)
 {
     if (false === ($player = SR_Player::getByID($player_id))) {
         echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         return false;
     }
     if ($player->isHuman()) {
         return true;
     }
     if (false === ($party = SR_Party::getByID($player->getPartyID(), false))) {
         printf("Deleting lonely NPC %s.\n", $player->getVar('sr4pl_classname'));
         $player->deletePlayer();
         return true;
     }
     if (false === $party->getMemberByPID($player_id)) {
         printf("NPC is not in that party! deleting!\n", $player->getVar('sr4pl_classname'));
         $player->deletePlayer();
         return true;
     }
 }
Beispiel #18
0
 /**
  * Check if the party can move. Return false on success and string on error.
  * @param SR_Player $player
  * @return false|string
  */
 public static function checkMove(SR_Party $party)
 {
     $b = chr(2);
     $back = '';
     foreach ($party->getMembers() as $member) {
         $member instanceof SR_Player;
         if ($member->isDead()) {
             $party->ntice('1080', array($member->getName()));
             return false;
             // 				$back .= sprintf(', %s is dead', $member->getName());
         } elseif ($member->isOverloadedFull()) {
             $party->ntice('1081', array($member->getName()));
             return false;
             // 				$back .= sprintf(', %s is overloaded', $member->getName());
         }
         // 			elseif ($member->getBase('age') <= 0)
         // 			{
         // 				$party->ntice('1082', array($member->getName(), self::translate('aslset'));
         // 				return false;
         // // 				$back .= sprintf(", %s has no {$b}#asl{$b}", $member->getName());
         // 			}
     }
     return true;
     // 		if ($back === '')
     // 		{
     // 			return true;
     // 		}
     // 		$party->ntice('', array(substr($back, 2)));
     // 		return false;
     // 		return $back === '' ? false : 'You cannot move because '.substr($back, 2).'.';
 }
Beispiel #19
0
 public function onCityEnter(SR_Party $party)
 {
     $player = $party->getLeader();
     SR_PlayerVar::setVal($player, 'THQLVTRC', 0);
     return parent::onCityEnter($party);
 }
Beispiel #20
0
 public function onCityEnter(SR_Party $party)
 {
     $party->getLeader()->unsetTemp('HIDE_R2_ONCE');
     return parent::onCityEnter($party);
 }
Beispiel #21
0
 public function getNPCMeetPercent(SR_Party $party)
 {
     $player = $party->getLeader();
     $quest = SR_Quest::getQuest($player, 'Seattle_Ranger');
     return $quest->getAmount() > 0 ? 70 : 0;
 }
Beispiel #22
0
 private function maxEnemies(SR_Party $party)
 {
     $mc = $party->getMemberCount();
     return Common::clamp(round($party->getSum('level', true) / 14) + 1, $mc, 9);
 }
Beispiel #23
0
 private static function reloadParties()
 {
     $table = GWF_TABLE_PREFIX . 'sr4_party';
     $query = "SELECT * FROM {$table} WHERE sr4pa_action='talk' OR sr4pa_action='fight' OR sr4pa_action='sleep' OR sr4pa_action='travel' OR sr4pa_action='explore' OR sr4pa_action='goto' OR sr4pa_action='hunt'";
     $db = gdo_db();
     if (false === ($result = $db->queryRead($query))) {
         return false;
     }
     while (false !== ($row = $db->fetchAssoc($result))) {
         $pid = (int) $row['sr4pa_id'];
         $party = new SR_Party($row);
         if (true === $party->initMembers()) {
             self::$parties[$pid] = $party;
         }
     }
     $db->free($result);
     return true;
 }
Beispiel #24
0
 /**
  * Create an NPC and set a valid partyid.
  * @param string $classname
  * @return SR_NPC
  */
 private function createNPC($classname, SR_Party $party, SR_Party $attackers = NULL)
 {
     $data = $this->applyNPCStartData(self::getPlayerData(NULL));
     $data['sr4pl_classname'] = $classname;
     $npc = new $classname($data);
     $npc->setNPCClassName($classname);
     $npc instanceof SR_NPC;
     $npc->setOption(self::CREATED, true);
     $npc->setVar('sr4pl_name', $npc->getNPCPlayerName());
     if (false === $npc->insert()) {
         return false;
     }
     Shadowcmd_aslset::onASLSetRandom($npc);
     $party->addUser($npc, false);
     $npc->saveVar('sr4pl_partyid', $party->getID());
     return self::reloadPlayer($npc);
 }
Beispiel #25
0
 public function setElevatorFlagsParty(SR_Party $party, $floors = self::ALL_BITS, $bool = false)
 {
     foreach ($party->getMembers() as $member) {
         if (false === $this->setElevatorFlags($member, $floors, $bool)) {
             return false;
         }
     }
     return true;
 }
Beispiel #26
0
 /**
  * Check if the party sum levels match nicely.
  * @param SR_Party $attackers
  * @param SR_Party $defenders
  * @param boolean $verbose
  * @return true|false
  */
 public static function isKillProtectedPartyLevel(SR_Party $attackers, SR_Party $defenders, SR_Player $player, $verbose = true)
 {
     # NPC
     if (!$defenders->isHuman()) {
         return false;
     }
     # A member has bounty or bad karma
     foreach ($defenders->getMembers() as $defender) {
         $defender instanceof SR_Player;
         if ($defender->getBase('bounty') > 0) {
             return false;
         }
         if ($defender->getBase('bad_karma')) {
             return false;
         }
     }
     # Check party sums for effective level.
     $al = $attackers->getSum('level', false);
     $dl = $defenders->getSum('level', false);
     # Clamp to the level where game gets hard.
     $clamp = self::MAX_LEVEL_DIFF + self::DISABLE_LEVEL_DIFF;
     $al = Common::clamp($al, 0, $clamp);
     $dl = Common::clamp($dl, 0, $clamp);
     $dif = $al - $dl;
     if ($dif > self::MAX_LEVEL_DIFF) {
         if ($verbose) {
             $player->msg('1015', array($al, $dl, self::MAX_LEVEL_DIFF));
             // 				$player->message(sprintf('Your party (level sum %d) cannot attack a party with level sum %d because the level difference is larger than %d.', $al, $dl, self::MAX_LEVEL_DIFF));
         }
         # Protected by level
         return true;
     }
     # No protection
     return false;
 }
Beispiel #27
0
 public function respawn()
 {
     $this->sr4_effects = array();
     $this->updateEffects();
     $party = $this->getParty();
     $city = $party->getCityClass();
     $singleplayer = $party->getMemberCount() === 1;
     $party->kickUser($this, true);
     $oldlevel = $party->getPartyLevel();
     $newlevel = (int) round($oldlevel / 2);
     $new_party = SR_Party::createParty();
     $new_party->addUser($this, true);
     if ($singleplayer) {
         $new_party->savePartyLevel($newlevel);
     } else {
         $party->savePartyLevel($newlevel);
     }
     $location = $city === false ? 'Redmond_Hotel' : $city->getRespawnLocation($this);
     //		$location = $city->getRespawnLocation();
     $new_party->pushAction(SR_Party::ACTION_INSIDE, $location);
     $this->updateField('partyid', $new_party->getID());
     $this->msg('5252', array($location));
     // 		$this->message(sprintf('You respawn at %s.', $location));
     $this->heal('hp', 20);
     $this->heal('mp', 10);
 }
Beispiel #28
0
 public function onEnterLocation(SR_Party $party)
 {
     foreach ($party->getMembers() as $player) {
         $pid = $player->getID();
         unset(self::$UPGRADE_CONFIRM[$pid . 'X']);
         unset(self::$UPGRADE_CONFIRM[$pid . 'Y']);
         unset(self::$SPLIT_CONFIRM[$pid]);
         unset(self::$BREAK_CONFIRM[$pid]);
     }
 }
Beispiel #29
0
 public function onCityEnter(SR_Party $party)
 {
     $party->unsetTemp('FORLAKGRB');
 }
Beispiel #30
0
 public function onCityEnter(SR_Party $party)
 {
     $party->unsetTemp($this->getAlertKey($party));
     parent::onCityEnter($party);
 }