示例#1
0
 /**
  * Check the database for a recent kill.
  * @param SR_Player $killer
  * @param SR_Player $victim
  * @return false|int timestamp
  */
 private static function isKillProtectedB(SR_Player $killer, SR_Player $victim)
 {
     if (true === $killer->isNPC() || true === $victim->isNPC()) {
         return false;
     }
     foreach (self::$CACHE as $entry) {
         $search = $killer->getID() . ':' . $victim->getID() . ':';
         $pos = strpos($entry, $search);
         if ($pos !== false) {
             return (int) substr($entry, strlen($search));
         }
     }
     return false;
 }
示例#2
0
 public static function reply(SR_Player $player, $message)
 {
     return $player->isNPC() || $player->isFighting() && self::isCombatCommand() ? $player->message($message) : Dog::reply($message);
 }
示例#3
0
 public function gotKilledByNPC(SR_Player $killer)
 {
     // 		$this->looseItem($killer);
     if ($this->isRunner()) {
         # Forever a dead?
         if ($killer->isNPC() || $killer->isRunner()) {
             $this->saveOption(self::DEAD, true);
         }
     }
     // 		$this->announceKilled($killer);
 }
示例#4
0
 /**
  * Do damage to multiple targets and announce the kills and damage in a compressed way.
  * @param SR_Player $player
  * @param array $damage
  */
 public static function multiDamage(SR_Player $player, array $damage, $spellname = 'Spell')
 {
     $p = $player->getParty();
     $mc = $p->getMemberCount();
     $ep = $p->getEnemyParty();
     $loot_xp = array();
     $loot_ny = array();
     foreach ($p->getMembers() as $member) {
         $loot_xp[$member->getID()] = 0;
         $loot_ny[$member->getID()] = 0;
     }
     $out = array();
     // 		$out = '';
     // 		$out_ep = '';
     foreach ($damage as $pid => $dmg) {
         if ($dmg <= 0) {
             continue;
         }
         $target = $ep->getMemberByPID($pid);
         $target->dealDamage($dmg);
         if (true === $target->isDead()) {
             $xp = $target->isHuman() ? 0 : $target->getLootXP();
             //				$xp = $target->getLootXP();
             $nuyen = $target->getLootNuyen();
             if ($player->isNPC()) {
                 $target->resetXP();
             }
             $target->giveNuyen(-$nuyen);
             // 				$app = Shadowrun4::lang('kills', array($target->getName(), $dmg));
             $out[$target->getID()] = array($target, $dmg, true);
             // 				$out .= $app;
             // 				$out_ep .= $app;
             // 				$out .= sprintf(', kills %s with %s', $target->getName(), $dmg);
             // 				$out_ep .= sprintf(', kills %s with %s', $target->getName(), $dmg);
             $pxp = 0;
             foreach ($p->getMembers() as $member) {
                 $lxp = $xp / $mc;
                 $leveldiff = ($target->getBase('level') + 1) / ($member->getBase('level') + 1);
                 $lxp *= $leveldiff;
                 $lxp = round(Common::clamp($lxp, 0.01), 2);
                 $pxp += $lxp;
                 $loot_xp[$member->getID()] += $lxp;
                 $loot_ny[$member->getID()] += $nuyen / $mc;
             }
             $p->givePartyXP($pxp);
         } else {
             $out[$target->getID()] = array($target, $dmg, false);
             // 				$out .= Shadowrun4::lang('hits1', array($target->getName(), $dmg));
             // 				$out_ep .= Shadowrun4::lang('hits2', array($target->getName(), $dmg, $target->getHP(), $target->getMaxHP()));
             // 				$out .= sprintf(', hits %s with %s damage', $target->getName(), $dmg);
             // 				$out_ep .= sprintf(', hits %s with %s(%s/%s)HP left', $target->getName(), $dmg, $target->getHP(), $target->getMaxHP());
         }
     }
     ### OUTPUT
     if (count($out) === 0) {
         $p->ntice('1057', array($spellname, $player->getName()));
         // 			$p->notice($failmsg);
         return;
     }
     ### FRIEND PARTY
     // 		$out = substr($out, 2);
     foreach ($p->getMembers() as $member) {
         $member instanceof SR_Player;
         $loot_out = '';
         $ny = $loot_ny[$member->getID()];
         $xp = $loot_xp[$member->getID()];
         // 			$xp = round($xp, 2);
         if ($ny > 0 || $xp > 0) {
             $loot_out = $member->lang('loot_nyxp', array(Shadowfunc::displayNuyen($ny), $xp));
             // 				$loot_out = sprintf('. You loot %s and %.02f XP', Shadowfunc::displayNuyen($ny), $xp);
             $member->giveNuyen($ny);
             $member->giveXP($xp);
         }
         $msg = $player->getName();
         foreach ($out as $pid => $data) {
             list($target, $dmg, $is_kill) = $data;
             $target instanceof SR_Player;
             $key = true === $is_kill ? 'kills' : 'hits1';
             // 				$app = Shadowrun4::lang('kills', array($target->getName(), $dmg));
             $msg .= $member->lang($key, array($target->getName(), $dmg));
         }
         $member->message($msg . $loot_out . '.');
     }
     # ENEMY PARTY
     // 		$out_ep = substr($out_ep, 2);
     // 		$ep->message($player, $out_ep.'.');
     foreach ($ep->getMembers() as $member) {
         $msg = '';
         foreach ($out as $pid => $data) {
             list($target, $dmg, $is_kill) = $data;
             $target instanceof SR_Player;
             $key = true === $is_kill ? 'kills' : 'hits2';
             $msg .= $member->lang($key, array($target->getName(), $dmg, $target->getHP(), $target->getMaxHP()));
         }
         $member->message($msg . $loot_out . '.');
         if ($member->isDead()) {
             $member->gotKilledBy($player);
         }
     }
 }