public function aic_idle(SR_RealNPC $npc) { $fear = SR_Feelings::getFear($npc); if ($fear > rand(0.4, 0.6)) { $ncp->ai_add_goal(new SR_AIGoal('flee', $fear)); } }
public function onItemUse(SR_Player $player, array $args) { $busy = $player->isFighting() ? $this->getItemUseTime() : 0; // if ($this->isBroken()) // { // $player->message(sprintf('Your %s is broken and cannot get consumed.', $this->getItemName())); // return false; // } # Consume it if ($this->useAmount($player, 1, false)) { $this->onConsume($player); SR_Feelings::consume($player, $this); $player->modify(); } if ($busy > 0) { $busy = $player->busy($busy); } # Announce Usage $pname = $player->getName(); $p = $player->getParty(); $p->ntice('5201', array($pname, $this->getName(), $busy)); if ($p->isFighting()) { $ep = $p->getEnemyParty(); $ep->ntice('5201', array($pname, $this->getName(), $busy)); } # Announce Usage // $message = $this->getConsumeMessage($busy); // $p = $player->getParty(); // $p->message($player, $message); // if ($p->isFighting()) { // $player->getEnemyParty()->message($player, $message); // } }
public function ai_goal(SR_RealNPC $npc) { if (SR_Feelings::isHungry($npc)) { if (false !== ($food = self::getFood($npc))) { $npc->ai_use($food); } } }
public static function shadowTimerHunger() { foreach (self::$players as $player) { $player instanceof SR_Player; if ($player->isCreated() && $player->hasFeelings()) { SR_Feelings::timer($player); } } }
public function isFeelingFine() { return SR_Feelings::isFeelingFine($this); }
public function on_sleep($done) { $this->timestamp = time(); $sleeping = count($this->members); foreach ($this->members as $playerid => $player) { $player instanceof SR_Player; if ($player->hasFullHPMP() && !$player->isSleepy()) { $sleeping--; continue; } $body = Common::clamp($player->getBase('body'), 1); $magic = Common::clamp($player->getBase('magic'), 1); $player->healHP($body / 10); $player->healMP($magic / 10); SR_Feelings::sleep($player); if ($player->hasFullHPMP() && !$player->isSleepy()) { $sleeping--; $player->msg('5001'); # You awake and have a delicous breakfast. } } if ($sleeping === 0) { $this->popAction(); $this->ntice('5002'); # You are ready to go. } }