RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
CrawsBow.java
1package com.osroyale.content.itemaction.impl;
2
3import com.osroyale.content.itemaction.ItemAction;
4import com.osroyale.game.world.entity.mob.player.Player;
5import com.osroyale.game.world.items.Item;
6import com.osroyale.game.world.items.ItemDefinition;
7import com.osroyale.net.packet.out.SendInputAmount;
8import com.osroyale.util.Utility;
9
38
39public class CrawsBow extends ItemAction {
40
41 public static final short CRAWS_UNCHARGED_ID = 22547;
42 public static final short CRAWS_CHARGED_ID = 22550;
43 public static final short ETHER_ID = 21820;
44
45 @Override
46 public String name() {
47 return "Craw's bow";
48 }
49
50 @Override
51 public boolean itemOnItem(Player player, Item first, Item second) {
52 if ((first.getId() != CRAWS_UNCHARGED_ID && second.getId() != CRAWS_UNCHARGED_ID) && (first.getId() != CRAWS_CHARGED_ID && second.getId() != CRAWS_CHARGED_ID)) {
53 return false;
54 }
55
56 if(first.getId() == ETHER_ID || second.getId() == ETHER_ID) {
57 if (first.getId() == CRAWS_UNCHARGED_ID || second.getId() == CRAWS_UNCHARGED_ID) {
58 if(!player.inventory.contains(ETHER_ID, 1000)) {
59 player.message("You need at least 1000 "+ ItemDefinition.get(ETHER_ID).getName() +" to charge the "+name()+".");
60 return true;
61 }
62 player.inventory.remove(ETHER_ID, 1000);
63 player.inventory.remove(CRAWS_UNCHARGED_ID);
64 player.inventory.add(CRAWS_CHARGED_ID, 1);
65 player.inventory.refresh();
66 } else {
67 System.out.println("Recharge craws bow");
68 player.send(new SendInputAmount("How many charges would you like add? (0-"+player.inventory.computeAmountForId(ETHER_ID)+")", 10, input -> charge(player, Integer.parseInt(input))));
69 }
70 return true;
71 }
72
73 return false;
74 }
75
76 @Override
77 public boolean inventory(Player player, Item item, int opcode) {
78 if (item.getId() != CRAWS_CHARGED_ID) {
79 return false;
80 }
81
82 if (opcode == 2) {
83 check(player);
84 return true;
85 }
86
87 return false;
88 }
89
90 @Override
91 public boolean equipment(Player player, Item item, int opcode) {
92 if (item.getId() != CRAWS_CHARGED_ID) {
93 return false;
94 }
95 if (opcode == 1) {
96 check(player);
97 return true;
98 }
99 return true;
100 }
101
102 @Override
103 public boolean drop(Player player, Item item) {
104 if (item.getId() != CRAWS_CHARGED_ID) {
105 return false;
106 }
107
108 player.inventory.remove(CRAWS_CHARGED_ID);
109 player.inventory.add(CRAWS_UNCHARGED_ID, 1);
110 player.inventory.add(ETHER_ID, 1000 + player.crawsBowCharges);
111 player.crawsBowCharges = 0;
112
113 player.message("You uncharge your "+name()+".");
114
115 return true;
116 }
117
118 private void check(Player player) {
119 player.message("You have " + Utility.formatDigits(player.crawsBowCharges) + " charges in your "+name()+".");
120 }
121
122 private void charge(Player player, int amount) {
123 if (amount > player.inventory.computeAmountForId(ETHER_ID)) {
124 amount = player.inventory.computeAmountForId(ETHER_ID);
125 }
126 if (amount > 0) {
127 player.inventory.remove(ETHER_ID, amount);
128 player.inventory.refresh();
129 player.crawsBowCharges += amount;
130 player.message("You added " + amount + " charges to your "+name()+"");
131 }
132 }
133
134}
boolean inventory(Player player, Item item, int opcode)
Definition CrawsBow.java:77