RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Killstreak.java
1package com.osroyale.content.combat;
2
3import com.osroyale.content.achievement.AchievementHandler;
4import com.osroyale.content.achievement.AchievementKey;
5import com.osroyale.game.world.World;
6import com.osroyale.game.world.entity.mob.player.Player;
7import com.osroyale.game.world.entity.mob.player.PlayerRight;
8import com.osroyale.game.world.items.Item;
9import com.osroyale.util.Utility;
10
39
40public class Killstreak {
41 private final Player player;
42 public int streak;
43
44 public Killstreak(Player player) {
45 this.player = player;
46 }
47
48 public void add() {
49 streak++;
50
51 if (announcementNeeded()) {
52 reward();
53 announce();
54 }
55 }
56
57 public void end(Player killer) {
58 if (announcementNeeded()) {
59 String icon = "<icon=0>";
60 String name = PlayerRight.getCrown(player) + " " + player.getName();
61 int bounty = streak * 150;
62 World.sendMessage("" + icon + " <col=FF0000>" + name + "</col> has lost their kill streak of <col=FF0000>" + streak + "</col> to <col=FF0000>" + killer.getName() + "</col>!");
63 killer.inventory.addOrDrop(new Item(13307, bounty));
64 killer.message("You were rewarded with " + Utility.formatDigits(bounty) + " blood money for claiming " + player.getName() + "'s bounty!");
65 }
66
67 streak = 0;
68 }
69
70 public void reward() {
71 int bm = streak * 500;
72 player.inventory.addOrDrop(new Item(13307, bm));
73 player.message("<col=FF0000>You are rewarded with " + Utility.formatDigits(bm) + " blood money.");
74 }
75
76 private void announce() {
77 String icon = "<icon=0>";
78 String name = PlayerRight.getCrown(player) + " " + player.getName();
79 int bounty = streak * 150;
80 World.sendMessage("<col=FF0000>" + icon + " " + name + " </col>is now on a killstreak of <col=FF0000>" + streak + "</col>. Bounty: <col=FF0000>" + Utility.formatDigits(bounty) + "</col> BM.");
81
82 if (streak == 5) {
83 AchievementHandler.activate(player, AchievementKey.KILLSTKREAK_5);
84 } else if (streak == 10) {
85 AchievementHandler.activate(player, AchievementKey.KILLSTKREAK_10);
86 } else if (streak == 15) {
87 AchievementHandler.activate(player, AchievementKey.KILLSTKREAK_15);
88 } else if (streak == 25) {
89 AchievementHandler.activate(player, AchievementKey.KILLSTKREAK_25);
90 }
91 }
92
93 private boolean announcementNeeded() {
94 return streak >= 5;
95 }
96}
static void activate(Player player, AchievementKey achievement)
static void sendMessage(String... messages)
Definition World.java:433
static String formatDigits(final int amount)
Definition Utility.java:78