Esempio n. 1
0
 /**
  * Remove a party from memory.
  * @param SR_Party $party
  */
 public static function removeParty(SR_Party $party)
 {
     $partyid = $party->getID();
     foreach ($party->getMembers() as $member) {
         self::removePlayer($member);
     }
     unset(self::$parties[$partyid]);
 }
Esempio n. 2
0
 private function partyContact(SR_Party $p)
 {
     if (rand(0, 60) > 0) {
         return false;
         # fail
     }
     foreach (Shadowrun4::getParties() as $ep) {
         if ($ep->isMoving() && $p->getCity() === $ep->getCity() && $ep->getID() !== $p->getID()) {
             $p->talk($ep, true);
             return true;
         }
     }
     return false;
     //		$sqkm = $this->getSquareKM();
     //		$possible = array();
     //		$total = 0;
     //		$total_sqkm = $sqkm * 3; // total slots in city
     //
     //		foreach (Shadowrun4::getParties() as $ep)
     //		{
     //			if ( ($ep->isMoving()) && ($p->getCity() === $ep->getCity()) && ($ep->getID() !== $p->getID()) )
     //			{
     ////				$total += 50;
     ////				$possible[] = array($ep, 50);
     //				$possible[] = array($ep, 1);
     //			}
     //		}
     //
     ////		$chance_none = $sqkm * 30 - count($possible);
     ////		$chance_none = Common::clamp($chance_none, 50);
     //
     //		$chance_none = $total_sqkm - count($possible);
     //		$chance_none = Common::clamp($chance_none, round($sqkm*2.5)); // at least N empty slots
     //
     //		if (false === ($ep = Shadowfunc::randomData($possible, $total, $chance_none))) {
     //			return false;
     //		}
     //
     //		$p->talk($ep, true);
     //
     //		return true;
 }
Esempio n. 3
0
 public function getAlertKey(SR_Party $party)
 {
     return sprintf('__dung_%s_alert_%s', get_class($this), $party->getID());
 }
Esempio n. 4
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);
 }
Esempio n. 5
0
 /**
  * Set two parties fighting each other.
  * @param SR_Party $party
  */
 public function fight(SR_Party $party, $announce = true)
 {
     if ($this->getID() === $party->getID()) {
         Dog_Log::error('Party should not fight itself!');
         return false;
     }
     if ($party->getMemberCount() === 0) {
         Dog_Log::error('Cannot fight empty party!');
         return false;
     }
     if ($party->getAction() === self::ACTION_DELETE) {
         $party->cloneAction($this);
     } elseif ($this->getAction() === self::ACTION_DELETE) {
         $this->cloneAction($party);
     }
     $this->pushAction(self::ACTION_FIGHT, $party->getID(), 0);
     $party->pushAction(self::ACTION_FIGHT, $this->getID(), 0);
     $this->initNPCb($party);
     $this->setContactEta(rand(10, 25));
     $party->setContactEta(rand(10, 25));
     $this->initFightBusy(1);
     $party->initFightBusy(-1);
     if ($announce === true) {
         $this->ntice('5095', array($party->displayMembers(true, true)));
         $party->ntice('5095', array($this->displayMembers(true, true)));
         // 			$this->notice(sprintf('You encounter %s.', $party->displayMembers(true, true)));
         // 			$party->notice(sprintf('You encounter %s.', $this->displayMembers(true, true)));
     }
     // 		$this->setMemberOptions(SR_Player::PARTY_DIRTY, true);
     // 		$party->setMemberOptions(SR_Player::PARTY_DIRTY, true);
     return true;
 }
Esempio n. 6
0
 public static function getByeKey(SR_Party $a, SR_Party $b)
 {
     $ids = array($a->getID(), $b->getID());
     sort($ids);
     return implode(':', $ids);
 }