public function hasToLeave() { if (!$this->hasConst(self::HIRE_END)) { return false; } return $this->getConst(self::HIRE_END) < Shadowrun4::getTime(); }
public function ai_tick($function, $args = null) { if (0 < ($interval = $this->getInterval())) { if (Shadowrun4::getTime() % $interval === 0) { call_user_func_array($this->getArg(1), $this->getArg(2, array())); } } }
public function resetTimer(SR_Player $player) { $time = Seattle::TIME_TO_DELAWARE + 60; $player->setConst('__AURIS_TIMEOUT', Shadowrun4::getTime() + $time); $player->message($this->lang('fluid', array(GWF_Time::humanDuration($time)))); // $player->message(sprintf("Your pot of Auris is fluid for %s.", GWF_Time::humanDuration($time))); return true; }
public function setAlert(SR_Party $party, $duration = 600, $announce = true) { $party->setTemp($this->getAlertKey($party), Shadowrun4::getTime() + $duration); if ($announce) { $party->ntice('5021'); // $party->notice(sprintf('You hear the alarm sound!')); } }
public static function isNoShout($pid) { $pid = (int) $pid; if (false === ($ends = self::table(__CLASS__)->selectVar('sr4ns_ends', "sr4ns_pid={$pid}"))) { return -1; } if ($ends == 0) { return GWF_Time::ONE_DAY; } return $ends - Shadowrun4::getTime(); }
private static function cleanupWhisper($pid) { $data = self::$WHISPER[$pid]; if (count($data) < 2) { return; } $time = Shadowrun4::getTime() - self::WB_TIME; foreach ($data as $fid => $t) { if ($t < $time) { unset(self::$WHISPER[$pid][$fid]); } } }
public static function tell($pid, $msg) { // print('TELL: '.$msg.PHP_EOL); $pid = (int) $pid; $table = self::table(__CLASS__); if (false === $table->insertAssoc(array('sr4tl_pid' => $pid, 'sr4tl_time' => Shadowrun4::getTime(), 'sr4tl_msg' => $msg))) { return false; } $where = "sr4tl_pid={$pid}"; $rows = $table->countRows($where); if ($rows > self::MAX_MSGS) { // @todo: This is currently broken Oo // if (false === $table->deleteWhere($where, 'sr4tl_time ASC', NULL, 5, 0)) // { // return false; // } } return true; }
private static function checkKillProtection(SR_Player $player, SR_Party $ep) { $p = $player->getParty(); // $ep = $p->getEnemyParty(); if (SR_KillProtect::isKillProtectedRealNPCParty($ep)) { return false; } if (SR_KillProtect::isKillProtectedPartyLevel($p, $ep, $player, true)) { return false; } if (false !== ($time = SR_KillProtect::isKillProtectedParty($p, $ep))) { $wait = GWF_Time::humanDuration($time - Shadowrun4::getTime()); self::rply($player, '1060', array($wait)); // $player->message(sprintf('You cannot attack this party again. Please wait %s.', $wait)); return false; } SR_BadKarma::onFight($player, $ep); return true; }
private static function cleanupItems() { echo __METHOD__ . PHP_EOL; $players = GDO::table('SR_Player'); $pids = $players->selectColumn('sr4pl_id'); $items = GDO::table('SR_Item'); $before = $items->countRows(); if (false === ($result = $items->select('sr4it_id, sr4it_uid', 'sr4it_uid!=0'))) { echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); return; } $sr_time = Shadowrun4::getTime(); while (false !== ($row = $items->fetch($result, GDO::ARRAY_N))) { if (!in_array($row[1], $pids, true)) { $items->deleteWhere("sr4it_id={$row[0]}"); } } $items->free($result); $after = $items->countRows(); printf("I removed %s items from the database and %s are left.\n", $before - $after, $after); }
public function isOver() { return $this->time_end < Shadowrun4::getTime(); }
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 displayContactETA() { $duration = $this->getVar('sr4pa_contact_eta') - Shadowrun4::getTime(); return $duration <= 0 ? '0s' : GWF_Time::humanDuration($duration); }
public function getBusyLeft() { return $this->combat_eta - Shadowrun4::getTime(); }
public static function getEffects(SR_Player $player) { // $b = chr(2); $e = $player->getEffects(); if (count($e) === 0) { return Shadowrun4::lang('none'); } $sorted = array(); foreach ($e as $effect) { $effect instanceof SR_Effect; $t = $effect->getTimeEnd(); $raw = $effect->getModifiersRaw(); foreach ($raw as $k => $v) { if (isset($sorted[$k])) { $sorted[$k][0] += $v; if ($t < $sorted[$k][1]) { $sorted[$k][1] = $t; } } else { $sorted[$k] = array($v, $t); } } } $t2 = Shadowrun4::getTime(); $format = Shadowrun4::lang('fmt_effect'); $back = ''; foreach ($sorted as $k => $data) { list($v, $t) = $data; $back .= sprintf($format, $k, $v, GWF_Time::humanDuration($t - $t2)); // $back .= sprintf(', %s:%s(%s)', $b.$k.$b, $v, GWF_Time::humanDuration($t-$t2)); } return ltrim($back, ',; '); }
public function isBreaking() { if ($this->isItemStackable()) { return false; } $d = $this->getDuration(); if ($d > 0) { return $d < Shadowrun4::getTime(); } else { return false; } }
public static function onAddStorage(SR_Clan $clan, SR_Player $player) { $event = new self(array('sr4ch_id' => '0', 'sr4ch_cid' => $clan->getID(), 'sr4ch_time' => Shadowrun4::getTime(), 'sr4ch_pname' => $player->getName(), 'sr4ch_action' => self::ADD_STORAGE, 'sr4ch_iname' => NULL, 'sr4ch_amt' => $clan->getMaxStorage())); return self::insertAndSend($clan, $event); }
/** * Make a player join this clan. * @param SR_Player $player */ public function join(SR_Player $player) { $members = GDO::table('SR_ClanMembers'); if (false === $members->insertAssoc(array('sr4cm_pid' => $player->getID(), 'sr4cm_cid' => $this->getID(), 'sr4cm_jointime' => Shadowrun4::getTime(), 'sr4cm_options' => '0'), true)) { return false; } if (false === $this->fixMembercount()) { return false; } return SR_ClanHistory::onJoin($this, $player); }