RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.itemaction.impl.ToxicBlowpipe Class Reference
Inheritance diagram for com.runehive.content.itemaction.impl.ToxicBlowpipe:
Collaboration diagram for com.runehive.content.itemaction.impl.ToxicBlowpipe:

Public Member Functions

boolean drop (Player player, Item item)
boolean equipment (Player player, Item item, int opcode)
boolean inventory (Player player, Item item, int opcode)
 The execution method of the action.
boolean itemOnItem (Player player, Item first, Item second)
String name ()
 The name of the action.
 ToxicBlowpipe ()
Public Member Functions inherited from com.runehive.content.itemaction.ItemAction
int delay ()
 The item click delay of the action.
String message (Item item)
 The message of the action.
String toString ()

Static Public Member Functions

static void check (Player player)

Static Private Member Functions

static void charge (Player player, Item scales)
static void load (Player player, Item ammo)
static void uncharge (Player player)
static void unload (Player player, Item item)

Static Private Attributes

static final short CHARGED_BLOWPIPE = 12_926
static final DecimalFormat FORMATTER = new DecimalFormat("#.#")
static final short FULL = 16_383
static final short UNCHARGED_BLOWPIPE = 12_924
static final short ZULRAH_SCALES = 12_934

Detailed Description

Definition at line 13 of file ToxicBlowpipe.java.

Constructor & Destructor Documentation

◆ ToxicBlowpipe()

com.runehive.content.itemaction.impl.ToxicBlowpipe.ToxicBlowpipe ( )

Definition at line 20 of file ToxicBlowpipe.java.

20 {
21 FORMATTER.setRoundingMode(RoundingMode.FLOOR);
22 }

References FORMATTER.

Member Function Documentation

◆ charge()

void com.runehive.content.itemaction.impl.ToxicBlowpipe.charge ( Player player,
Item scales )
staticprivate

Definition at line 119 of file ToxicBlowpipe.java.

119 {
120 if (player.blowpipeScales >= FULL) {
121 player.send(new SendMessage("Your blowpipe is already fully charged."));
122 return;
123 }
124
125 if (Integer.MAX_VALUE - scales.getAmount() < FULL) {
126 scales = scales.copy();
127 scales.setAmount((int) (FULL - player.blowpipeScales));
128 }
129
130 if (player.blowpipeScales + scales.getAmount() > FULL) {
131 scales = scales.copy();
132 scales.setAmount((int) (FULL - player.blowpipeScales));
133 }
134
135 player.blowpipeScales += scales.getAmount();
136 player.inventory.remove(scales);
137 player.inventory.replace(UNCHARGED_BLOWPIPE, CHARGED_BLOWPIPE, true);
138 player.send(new SendMessage(String.format("You load %s scales into your blowpipe.", Utility.formatDigits(scales.getAmount()))));
139 }

References com.runehive.game.world.entity.mob.player.Player.blowpipeScales, CHARGED_BLOWPIPE, com.runehive.game.world.items.Item.copy(), com.runehive.util.Utility.formatDigits(), FULL, com.runehive.game.world.items.Item.getAmount(), com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.game.world.items.containers.ItemContainer.remove(), com.runehive.game.world.items.containers.ItemContainer.replace(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.game.world.items.Item.setAmount(), and UNCHARGED_BLOWPIPE.

Referenced by itemOnItem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check()

void com.runehive.content.itemaction.impl.ToxicBlowpipe.check ( Player player)
static

Definition at line 82 of file ToxicBlowpipe.java.

82 {
83 String ammo = "None";
84 if (player.blowpipeDarts != null && player.blowpipeDarts.getAmount() > 0)
85 ammo = player.blowpipeDarts.getName() + " x " + player.blowpipeDarts.getAmount();
86 String scales = FORMATTER.format(player.blowpipeScales * 100 / FULL) + "%";
87 player.send(new SendMessage("Darts: <col=007F00>" + ammo + "</col>. Charges: <col=007F00>" + scales));
88 }

References com.runehive.game.world.entity.mob.player.Player.blowpipeDarts, com.runehive.game.world.entity.mob.player.Player.blowpipeScales, FORMATTER, FULL, com.runehive.game.world.items.Item.getAmount(), com.runehive.game.world.items.Item.getName(), and com.runehive.game.world.entity.mob.player.Player.send().

Referenced by equipment(), and inventory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drop()

boolean com.runehive.content.itemaction.impl.ToxicBlowpipe.drop ( Player player,
Item item )

Reimplemented from com.runehive.content.itemaction.ItemAction.

Definition at line 77 of file ToxicBlowpipe.java.

77 {
78 uncharge(player);
79 return true;
80 }

References uncharge().

Here is the call graph for this function:

◆ equipment()

boolean com.runehive.content.itemaction.impl.ToxicBlowpipe.equipment ( Player player,
Item item,
int opcode )

Reimplemented from com.runehive.content.itemaction.ItemAction.

Definition at line 69 of file ToxicBlowpipe.java.

69 {
70 if (opcode == 1) {
71 check(player);
72 }
73 return true;
74 }

References check().

Here is the call graph for this function:

◆ inventory()

boolean com.runehive.content.itemaction.impl.ToxicBlowpipe.inventory ( Player player,
Item item,
int opcode )

The execution method of the action.

Reimplemented from com.runehive.content.itemaction.ItemAction.

Definition at line 59 of file ToxicBlowpipe.java.

59 {
60 if (opcode == 2) {
61 check(player);
62 } else if (opcode == 3) {
63 unload(player, item);
64 }
65 return true;
66 }

References check(), and unload().

Here is the call graph for this function:

◆ itemOnItem()

boolean com.runehive.content.itemaction.impl.ToxicBlowpipe.itemOnItem ( Player player,
Item first,
Item second )

Reimplemented from com.runehive.content.itemaction.ItemAction.

Definition at line 30 of file ToxicBlowpipe.java.

30 {
31 Item item = first;
32
33 if ((first.getId() == UNCHARGED_BLOWPIPE && second.getId() != ZULRAH_SCALES)
34 || (second.getId() == UNCHARGED_BLOWPIPE && first.getId() != ZULRAH_SCALES)) {
35 player.send(new SendMessage("You can't load an uncharged blowpipe!"));
36 return true;
37 }
38
39 if (first.getId() == UNCHARGED_BLOWPIPE || first.getId() == CHARGED_BLOWPIPE) {
40 item = second;
41 }
42
43 if (item.getId() == ZULRAH_SCALES) {
44 charge(player, item);
45 return true;
46 }
47
48 RangedAmmunition ammo = RangedAmmunition.find(null, item);
49 if (ammo == null || !ammo.isDart()) {
50 player.send(new SendMessage("You can't load your blowpipe with this!"));
51 return true;
52 }
53
54 load(player, item);
55 return true;
56 }

References charge(), CHARGED_BLOWPIPE, com.runehive.game.world.entity.combat.ranged.RangedAmmunition.find(), com.runehive.game.world.items.Item.getId(), com.runehive.game.world.entity.combat.ranged.RangedAmmunition.isDart(), load(), com.runehive.game.world.entity.mob.player.Player.send(), UNCHARGED_BLOWPIPE, and ZULRAH_SCALES.

Here is the call graph for this function:

◆ load()

void com.runehive.content.itemaction.impl.ToxicBlowpipe.load ( Player player,
Item ammo )
staticprivate

Definition at line 164 of file ToxicBlowpipe.java.

164 {
165 if (player.blowpipeDarts != null && player.blowpipeDarts.getAmount() >= FULL) {
166 player.send(new SendMessage("Your blowpipe is already fully loaded."));
167 return;
168 }
169
170 if (ammo.getAmount() > FULL) {
171 ammo = new Item(ammo.getId(), FULL);
172 }
173
174 if (player.blowpipeDarts == null) {
175 player.blowpipeDarts = ammo;
176 player.inventory.remove(ammo);
177 player.send(new SendMessage(String.format("You load your blowpipe with %s %ss.", Utility.formatDigits(ammo.getAmount()), ammo.getName())));
178 return;
179 }
180
181 if (player.blowpipeDarts.getId() != ammo.getId()) {
182 player.send(new SendMessage("You need to unload your blowpipe before adding a different type of dart!"));
183 return;
184 }
185
186 int remove;
187 if (player.blowpipeDarts.getAmount() + ammo.getAmount() > FULL) {
188 remove = FULL - player.blowpipeDarts.getAmount();
189 } else {
190 remove = ammo.getAmount();
191 }
192
193 player.blowpipeDarts.incrementAmountBy(remove);
194 player.inventory.remove(ammo.getId(), remove);
195 player.send(new SendMessage(String.format("You load your blowpipe with %s %s.", Utility.formatDigits(ammo.getAmount()), ammo.getName())));
196 }

References com.runehive.game.world.entity.mob.player.Player.blowpipeDarts, com.runehive.util.Utility.formatDigits(), FULL, com.runehive.game.world.items.Item.getAmount(), com.runehive.game.world.items.Item.getId(), com.runehive.game.world.items.Item.getName(), com.runehive.game.world.items.Item.incrementAmountBy(), com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.game.world.items.containers.ItemContainer.remove(), and com.runehive.game.world.entity.mob.player.Player.send().

Referenced by itemOnItem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ name()

String com.runehive.content.itemaction.impl.ToxicBlowpipe.name ( )

The name of the action.

Reimplemented from com.runehive.content.itemaction.ItemAction.

Definition at line 25 of file ToxicBlowpipe.java.

25 {
26 return "Toxic Blowpipe";
27 }

◆ uncharge()

void com.runehive.content.itemaction.impl.ToxicBlowpipe.uncharge ( Player player)
staticprivate

Definition at line 141 of file ToxicBlowpipe.java.

141 {
142 if (player.blowpipeScales <= 0) {
143 player.send(new SendMessage("Your blowpipe doesn't have any charges."));
144 return;
145 }
146
147 if (player.blowpipeDarts != null && player.blowpipeDarts.getAmount() > 0) {
148 player.send(new SendMessage("You need to unload your blowpipe first."));
149 return;
150 }
151
152 Item scales = new Item(ZULRAH_SCALES, (int) player.blowpipeScales);
153 if (!player.inventory.hasCapacityFor(scales)) {
154 player.send(new SendMessage("You need more inventory space to do this."));
155 return;
156 }
157
158 player.blowpipeScales = 0;
159 player.inventory.add(scales);
160 player.inventory.replace(CHARGED_BLOWPIPE, UNCHARGED_BLOWPIPE, true);
161 player.send(new SendMessage(String.format("You uncharged your blowpipe and received %s of Zulra's scales.", Utility.formatDigits(scales.getAmount()))));
162 }

References com.runehive.game.world.items.containers.ItemContainer.add(), com.runehive.game.world.entity.mob.player.Player.blowpipeDarts, com.runehive.game.world.entity.mob.player.Player.blowpipeScales, CHARGED_BLOWPIPE, com.runehive.util.Utility.formatDigits(), com.runehive.game.world.items.Item.getAmount(), com.runehive.game.world.items.containers.ItemContainer.hasCapacityFor(), com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.game.world.items.containers.ItemContainer.replace(), com.runehive.game.world.entity.mob.player.Player.send(), UNCHARGED_BLOWPIPE, and ZULRAH_SCALES.

Referenced by drop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unload()

void com.runehive.content.itemaction.impl.ToxicBlowpipe.unload ( Player player,
Item item )
staticprivate

Definition at line 90 of file ToxicBlowpipe.java.

90 {
91 if (item.getId() == 12924) {
92 int current = player.inventory.computeAmountForId(ZULRAH_SCALES);
93 if (Integer.MAX_VALUE - current < 20_000) {
94 player.send(new SendMessage("You need to deposit some of your scales first."));
95 return;
96 }
97
98 player.inventory.remove(item);
99 player.inventory.add(new Item(ZULRAH_SCALES, 20_000));
100 player.send(new SendMessage("You dismantle your blowpipe and receive 20,000 of Zulra's scales."));
101 } else {
102 if (player.inventory.getFreeSlots() < 1) {
103 player.send(new SendMessage("You need at least one free slot to unload your blowpipe."));
104 return;
105 }
106
107 Item darts = player.blowpipeDarts;
108 if (darts == null) {
109 player.send(new SendMessage("You have no darts to unload."));
110 return;
111 }
112
113 player.inventory.add(darts);
114 player.blowpipeDarts = null;
115 player.send(new SendMessage("You unload the darts out of your blowpipe."));
116 }
117 }

References com.runehive.game.world.items.containers.ItemContainer.add(), com.runehive.game.world.entity.mob.player.Player.blowpipeDarts, com.runehive.game.world.items.containers.ItemContainer.computeAmountForId(), com.runehive.game.world.items.containers.ItemContainer.getFreeSlots(), com.runehive.game.world.items.Item.getId(), com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.game.world.items.containers.ItemContainer.remove(), com.runehive.game.world.entity.mob.player.Player.send(), and ZULRAH_SCALES.

Referenced by inventory().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ CHARGED_BLOWPIPE

final short com.runehive.content.itemaction.impl.ToxicBlowpipe.CHARGED_BLOWPIPE = 12_926
staticprivate

Definition at line 17 of file ToxicBlowpipe.java.

Referenced by charge(), itemOnItem(), and uncharge().

◆ FORMATTER

final DecimalFormat com.runehive.content.itemaction.impl.ToxicBlowpipe.FORMATTER = new DecimalFormat("#.#")
staticprivate

Definition at line 18 of file ToxicBlowpipe.java.

Referenced by check(), and ToxicBlowpipe().

◆ FULL

final short com.runehive.content.itemaction.impl.ToxicBlowpipe.FULL = 16_383
staticprivate

Definition at line 14 of file ToxicBlowpipe.java.

Referenced by charge(), check(), and load().

◆ UNCHARGED_BLOWPIPE

final short com.runehive.content.itemaction.impl.ToxicBlowpipe.UNCHARGED_BLOWPIPE = 12_924
staticprivate

Definition at line 16 of file ToxicBlowpipe.java.

Referenced by charge(), itemOnItem(), and uncharge().

◆ ZULRAH_SCALES

final short com.runehive.content.itemaction.impl.ToxicBlowpipe.ZULRAH_SCALES = 12_934
staticprivate

Definition at line 15 of file ToxicBlowpipe.java.

Referenced by itemOnItem(), uncharge(), and unload().


The documentation for this class was generated from the following file: