Example #1
0
 private function i_onKill(Player $killer, Player $victim, $isFall = false, $isLadder = false, $isArrow = false)
 {
     $killerSession = $this->main->getSessions()->getSession($killer);
     $killerData = $this->playerData[$killerSession->getUID()];
     $killerData->incrementKills();
     if ($isFall) {
         $action = $isArrow ? "shot" : "knocked";
         if ($isLadder) {
             $killerSession->tell("%s was {$action} off a ladder by you and fell to death! Your number of kills: %d", $victim->getDisplayName(), $killerData->getKills());
             $victim->sendMessage("You were {$action} off a ladder by {$killerSession} and fell to death!");
         } else {
             $killerSession->tell("%s was {$action} to a deadly fall by you! Your number of kills: %d", $victim->getDisplayName(), $killerData->getKills());
             $victim->sendMessage("You were {$action} to a deadly fall by {$killerSession}!");
         }
     } else {
         $action = $isArrow ? "shot" : "killed";
         $kills = $killerData->getKills();
         $ord = MUtils::num_getOrdinal($kills);
         $killerSession->tell("%s is your {$kills}{$ord} kill!", $victim->getDisplayName());
         $victim->sendMessage("You were {$action} by {$killerSession}!");
     }
     $factor = Settings::coinsFactor($killerSession);
     $killerSession->setCoins($killerSession->getCoins() + $factor);
     Settings::kitpvp_killHeal($killerSession);
     $killerSession->tell("Your coins +{$factor} => {$killerSession->getCoins()} coins");
     $killerData->setStreakCnt($streak = $killerData->getStreakCnt() + 1);
     if ($streak % 5 === 0) {
         $this->pvpChannel->broadcast(sprintf("%s has a continuous streak of %d kills, totally getting %d kills!", $killerSession->getPlayer()->getDisplayName(), $streak, $killerData->getKills()));
         $more = (4 + $streak / 5) * $factor;
         $killerSession->setCoins($killerSession->getCoins() + $more);
         $killerSession->tell("You got {$more} extra coins for a killstreak!");
     }
     if (mt_rand(0, 99) === 0) {
         $bonus = mt_rand(25, 50);
     } elseif (mt_rand(0, 499) === 0) {
         $bonus = mt_rand(150, 300);
     } elseif (mt_rand(0, 749) === 0) {
         $bonus = mt_rand(250, 500);
     }
     if (isset($bonus)) {
         $this->getDefaultChatChannel()->broadcast("{$killerSession} received a bonus of {$bonus} coins!");
         $killerSession->setCoins($killerSession->getCoins() + $bonus);
     }
 }