RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Autocast.java
1package com.osroyale.game.world.entity.combat.magic;
2
3import com.osroyale.Config;
4import com.osroyale.net.packet.out.SendConfig;
5import com.osroyale.net.packet.out.SendMessage;
6import com.osroyale.net.packet.out.SendString;
7import com.osroyale.game.world.entity.mob.player.Player;
8import com.osroyale.game.world.entity.mob.player.PlayerRight;
9import com.osroyale.content.skill.impl.magic.Spellbook;
10import com.osroyale.game.world.items.Item;
11import com.osroyale.util.MessageColor;
12import com.osroyale.util.StringUtils;
13
38
39public class Autocast {
40 private final static int[] ANCIENT_STAFFS = {21006, 4675, 4710, 11791, 12904, 6914};
41 private final static int[] NO_AUTOCAST = {12899, 11907, 11908};
42
43 public static boolean clickButton(Player player, int button) {
44 switch (button) {
45 case 2004:
46 case 6161:
47 case -20754:
48 case -21584:
49 player.interfaceManager.setSidebar(Config.ATTACK_TAB, 328);
50 player.getCombat().reset();
51 return true;
52 case 24111:
53 case 349:
54 if (!player.isAutocast()) {
55 Item weapon = player.equipment.getWeapon();
56
57 if (weapon != null) {
58 sendSelectionInterface(player, weapon.getId());
59 }
60 } else {
61 reset(player);
62 }
63 player.getCombat().reset();
64 return true;
65
66 //Strike spells
67 case 1830:
68 case -20753:
69 setAutocast(player, 1152);
70 return true;
71 case 1834:
72 case -20752:
73 setAutocast(player, 1154);
74 return true;
75 case 1838:
76 case -20751:
77 setAutocast(player, 1156);
78 return true;
79 case 1842:
80 case -20750:
81 setAutocast(player, 1158);
82 return true;
83
84 //Bolt
85 case 1831:
86 case -20749:
87 setAutocast(player, 1160);
88 return true;
89 case 1835:
90 case -20748:
91 setAutocast(player, 1163);
92 return true;
93 case 1839:
94 case -20747:
95 setAutocast(player, 1166);
96 return true;
97 case 1843:
98 case -20746:
99 setAutocast(player, 1169);
100 return true;
101
102 //Blast spells
103 case 1832:
104 case -20745:
105 setAutocast(player, 1172);
106 return true;
107 case 1836:
108 case -20744:
109 setAutocast(player, 1175);
110 return true;
111 case 1840:
112 case -20743:
113 setAutocast(player, 1177);
114 return true;
115 case 1844:
116 case -20742:
117 setAutocast(player, 1181);
118 return true;
119
120 //Wave
121 case 1833:
122 case -20741:
123 setAutocast(player, 1183);
124 return true;
125 case 1837:
126 case -20740:
127 setAutocast(player, 1185);
128 return true;
129 case 1841:
130 case -20739:
131 setAutocast(player, 1188);
132 return true;
133 case 1845:
134 case -20738:
135 setAutocast(player, 1189);
136 return true;
137
138 //Surge spells
139 case -20737:
140 setAutocast(player, 40140);
141 return true;
142 case -20736:
143 setAutocast(player, 40150);
144 return true;
145 case -20735:
146 setAutocast(player, 40170);
147 return true;
148 case -20734:
149 setAutocast(player, 40190);
150 return true;
151
152 //Smoke rush
153 case 13189:
154 case -21583:
155 setAutocast(player, 12939);
156 return true;
157 //Smoke burst
158 case 13215:
159 case -21579:
160 setAutocast(player, 12963);
161 return true;
162 case 13202:
163 //Smoke blitz
164 case -21575:
165 setAutocast(player, 12951);
166 return true;
167 //Smoke barrage
168 case 13228:
169 case -21571:
170 setAutocast(player, 12975);
171 return true;
172
173 //Shadow rush
174 case 13241:
175 case -21582:
176 setAutocast(player, 12987);
177 return true;
178 //Shadow burst
179 case 13267:
180 case -21578:
181 setAutocast(player, 13011);
182 return true;
183 //Shadow blitz
184 case 13254:
185 case -21574:
186 setAutocast(player, 12999);
187 return true;
188 //Smoke barrage
189 case 13280:
190 case -21570:
191 setAutocast(player, 13023);
192 return true;
193
194 //Blood rush
195 case 13147:
196 case -21581:
197 setAutocast(player, 12901);
198 return true;
199 //Blood burst
200 case 13167:
201 case -21577:
202 setAutocast(player, 12919);
203 return true;
204 //Blood blitz
205 case 13158:
206 case -21573:
207 setAutocast(player, 12911);
208 return true;
209 //Blood barrage
210 case 13178:
211 case -21569:
212 setAutocast(player, 12929);
213 return true;
214
215 //Ice rush
216 case 6162:
217 case -21580:
218 setAutocast(player, 12861);
219 return true;
220 //Ice burst
221 case 13125:
222 case -21576:
223 setAutocast(player, 12881);
224 return true;
225 //Ice blitz
226 case 13114:
227 case -21572:
228 setAutocast(player, 12871);
229 return true;
230 //Ice barrage
231 case 13136:
232 case -21568:
233 setAutocast(player, 12891);
234 return true;
235 }
236 return false;
237 }
238
239 public static void reset(Player player) {
240 if (player.isAutocast()) {
241 player.setAutocast(null);
242 player.send(new SendConfig(108, 0));
243 player.send(new SendString("Spell", 18584));
244 }
245 }
246
247 private static void sendSelectionInterface(Player player, int weaponId) {
248 for (int id : NO_AUTOCAST) {
249 if (weaponId == id) {
250 player.send(new SendMessage("You can't autocast with this weapon!"));
251 return;
252 }
253 }
254
255 if (player.spellbook == null) {
256 player.spellbook = Spellbook.MODERN;
257 }
258
259 switch (player.spellbook) {
260 case ANCIENT:
261 if (!player.equipment.containsAny(ANCIENT_STAFFS)) {
262 if (!player.equipment.hasWeapon()) {
263 return;
264 }
265
266 String def = player.equipment.getWeapon().getName().toLowerCase();
267 player.send(new SendMessage("You can't autocast ancient magicks with " + StringUtils.getAOrAn(def) + " " + def + "."));
268 return;
269 }
270 player.interfaceManager.setSidebar(Config.ATTACK_TAB, 43950); //1689
271 break;
272 case LUNAR:
273 player.send(new SendMessage("You can't autocast lunar magicks!"));
274 break;
275 case MODERN:
276 if (player.equipment.contains(4675)) {
277 player.send(new SendMessage("You can't autocast normal magicks with this staff!"));
278 return;
279 }
280 player.interfaceManager.setSidebar(Config.ATTACK_TAB, 44780); //1829
281 break;
282 }
283 }
284
285 private static void setAutocast(Player player, int id) {
286 CombatSpell spell = CombatSpell.get(id);
287
288 if (spell == null) {
289 player.send(new SendMessage("[ERROR] No spell definition found.", MessageColor.LIGHT_RED));
290 return;
291 }
292
293 if (!PlayerRight.isAdministrator(player) && !MagicRune.hasRunes(player, spell.getRunes())) {
294 player.send(new SendMessage("You don't have the runes required for this spell!"));
295 return;
296 }
297
298 player.setAutocast(spell);
299 player.send(new SendConfig(43, 3));
300 player.send(new SendConfig(108, 1));
301 player.interfaceManager.setSidebar(Config.ATTACK_TAB, 328);
302 }
303}
static final int ATTACK_TAB
Definition Config.java:232