Skip to content

Commit 7d41151

Browse files
RyanHubcapp
authored andcommitted
Chain Top Fixes
1 parent 66f4347 commit 7d41151

2 files changed

Lines changed: 88 additions & 33 deletions

File tree

server/plugins/com/openrsc/server/plugins/authentic/quests/free/BlackKnightsFortress.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public void onOpBound(final Player player, final GameObject obj, Integer click)
286286
switch (obj.getID()) {
287287
case DOOR_ENTRANCE:
288288
if (obj.getLocation().equals(DOOR_LOCATION) && player.getX() <= 270) {
289-
if (player.getCarriedItems().getEquipment().hasEquipped(ItemId.IRON_CHAIN_MAIL_BODY.id())
289+
if ((player.getCarriedItems().getEquipment().hasEquipped(ItemId.IRON_CHAIN_MAIL_BODY.id()) || player.getCarriedItems().getEquipment().hasEquipped(ItemId.IRON_CHAIN_MAIL_TOP.id()))
290290
&& player.getCarriedItems().getEquipment().hasEquipped(ItemId.MEDIUM_BRONZE_HELMET.id())) {
291291
doDoor(obj, player);
292292
player.teleport(271, 441, false);

server/src/com/openrsc/server/model/container/Equipment.java

Lines changed: 87 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,27 @@ public class Equipment {
2020
private final Item[] list = new Item[SLOT_COUNT];
2121
private final Player player;
2222

23+
private static final int[] chainBodyIds = {
24+
ItemId.BRONZE_CHAIN_MAIL_BODY.id(),
25+
ItemId.IRON_CHAIN_MAIL_BODY.id(),
26+
ItemId.STEEL_CHAIN_MAIL_BODY.id(),
27+
ItemId.BLACK_CHAIN_MAIL_BODY.id(),
28+
ItemId.MITHRIL_CHAIN_MAIL_BODY.id(),
29+
ItemId.ADAMANTITE_CHAIN_MAIL_BODY.id(),
30+
ItemId.RUNE_CHAIN_MAIL_BODY.id(),
31+
ItemId.DRAGON_SCALE_MAIL.id()
32+
};
33+
private static final int[] chainTopIds = {
34+
ItemId.BRONZE_CHAIN_MAIL_TOP.id(),
35+
ItemId.IRON_CHAIN_MAIL_TOP.id(),
36+
ItemId.STEEL_CHAIN_MAIL_TOP.id(),
37+
ItemId.BLACK_CHAIN_MAIL_TOP.id(),
38+
ItemId.MITHRIL_CHAIN_MAIL_TOP.id(),
39+
ItemId.ADAMANTITE_CHAIN_MAIL_TOP.id(),
40+
ItemId.RUNE_CHAIN_MAIL_TOP.id(),
41+
ItemId.DRAGON_SCALE_MAIL_TOP.id()
42+
};
43+
2344
public Equipment(Player player) {
2445
synchronized (list) {
2546
this.player = player;
@@ -167,6 +188,20 @@ public boolean unequipItem(UnequipRequest request, boolean updateClient) {
167188
curEquipDef.getWearableId(),
168189
false
169190
);
191+
192+
if (player.getConfig().WANT_CUSTOM_SPRITES && player.getConfig().FORM_FITTING_CHAINMAIL) {
193+
for (int i = 0; i < chainTopIds.length; ++i) {
194+
if (request.item.getCatalogId() == chainTopIds[i]) {
195+
// If we can't remove the item, just worry about the swap
196+
if (player.getCarriedItems().remove(request.item) == -1) {
197+
break;
198+
}
199+
player.getCarriedItems().getInventory().add(new Item(chainBodyIds[i]));
200+
break;
201+
}
202+
}
203+
}
204+
170205
break;
171206
case FROM_EQUIPMENT:
172207
synchronized (list) {
@@ -179,7 +214,18 @@ public boolean unequipItem(UnequipRequest request, boolean updateClient) {
179214
if (remove(request.item, request.item.getAmount()) == -1)
180215
return false;
181216
request.item.setWielded(false);
182-
player.getCarriedItems().getInventory().add(request.item, updateClient);
217+
218+
Item itemToAdd = request.item;
219+
if (player.getConfig().WANT_CUSTOM_SPRITES && player.getConfig().FORM_FITTING_CHAINMAIL) {
220+
for (int i = 0; i < chainTopIds.length; ++i) {
221+
if (request.item.getCatalogId() == chainTopIds[i]) {
222+
itemToAdd = new Item(chainBodyIds[i]);
223+
break;
224+
}
225+
}
226+
}
227+
228+
player.getCarriedItems().getInventory().add(itemToAdd, updateClient);
183229

184230
}
185231
}
@@ -189,13 +235,24 @@ public boolean unequipItem(UnequipRequest request, boolean updateClient) {
189235
synchronized (player.getBank().getItems()) {
190236
// Can't unequip something if bank is full
191237
if (player.getBank().full()) {
192-
player.message("You need more inventory space to unequip that.");
238+
player.message("You need more bank space to unequip that.");
193239
return false;
194240
}
195241
if (remove(request.item, request.item.getAmount()) == -1)
196242
return false;
197243
request.item.setWielded(false);
198-
player.getBank().add(request.item, updateClient);
244+
245+
Item itemToAdd = request.item;
246+
if (player.getConfig().WANT_CUSTOM_SPRITES && player.getConfig().FORM_FITTING_CHAINMAIL) {
247+
for (int i = 0; i < chainTopIds.length; ++i) {
248+
if (request.item.getCatalogId() == chainTopIds[i]) {
249+
itemToAdd = new Item(chainBodyIds[i]);
250+
break;
251+
}
252+
}
253+
}
254+
255+
player.getBank().add(itemToAdd, updateClient);
199256
if (updateClient) {
200257
ActionSender.showBank(player);
201258
}
@@ -241,38 +298,17 @@ public boolean equipItem(EquipRequest request, boolean updateClient) {
241298

242299
// Turn chain tops into chain bodies and vice-versa
243300
if (player.getConfig().WANT_CUSTOM_SPRITES && player.getConfig().FORM_FITTING_CHAINMAIL) {
244-
int[] bodyIds = {
245-
ItemId.BRONZE_CHAIN_MAIL_BODY.id(),
246-
ItemId.IRON_CHAIN_MAIL_BODY.id(),
247-
ItemId.STEEL_CHAIN_MAIL_BODY.id(),
248-
ItemId.BLACK_CHAIN_MAIL_BODY.id(),
249-
ItemId.MITHRIL_CHAIN_MAIL_BODY.id(),
250-
ItemId.ADAMANTITE_CHAIN_MAIL_BODY.id(),
251-
ItemId.RUNE_CHAIN_MAIL_BODY.id(),
252-
ItemId.DRAGON_SCALE_MAIL.id()
253-
};
254-
int[] topIds = {
255-
ItemId.BRONZE_CHAIN_MAIL_TOP.id(),
256-
ItemId.IRON_CHAIN_MAIL_TOP.id(),
257-
ItemId.STEEL_CHAIN_MAIL_TOP.id(),
258-
ItemId.BLACK_CHAIN_MAIL_TOP.id(),
259-
ItemId.MITHRIL_CHAIN_MAIL_TOP.id(),
260-
ItemId.ADAMANTITE_CHAIN_MAIL_TOP.id(),
261-
ItemId.RUNE_CHAIN_MAIL_TOP.id(),
262-
ItemId.DRAGON_SCALE_MAIL_TOP.id()
263-
};
264-
265301
Item newItem = null;
266302
if (player.isMale()) {
267-
for (int i = 0; i < topIds.length; ++i) {
268-
if (topIds[i] == request.item.getCatalogId()) {
269-
newItem = new Item(bodyIds[i]);
303+
for (int i = 0; i < chainTopIds.length; ++i) {
304+
if (chainTopIds[i] == request.item.getCatalogId()) {
305+
newItem = new Item(chainBodyIds[i]);
270306
}
271307
}
272308
} else {
273-
for (int i = 0; i < bodyIds.length; ++i) {
274-
if (bodyIds[i] == request.item.getCatalogId()) {
275-
newItem = new Item(topIds[i]);
309+
for (int i = 0; i < chainBodyIds.length; ++i) {
310+
if (chainBodyIds[i] == request.item.getCatalogId()) {
311+
newItem = new Item(chainTopIds[i]);
276312
}
277313
}
278314
}
@@ -379,8 +415,17 @@ private boolean equipItemFromInventory(EquipRequest request, boolean updateClien
379415
player.getCarriedItems().getInventory().remove(toEquip, updateClient); // Remove from inventory
380416

381417
for (Item item : items) {
418+
int id = item.getCatalogId();
419+
if (player.getConfig().WANT_CUSTOM_SPRITES && player.getConfig().FORM_FITTING_CHAINMAIL) {
420+
for (int i = 0; i < chainTopIds.length; ++i) {
421+
if (chainTopIds[i] == item.getCatalogId()) {
422+
id = chainBodyIds[i];
423+
break;
424+
}
425+
}
426+
}
382427
player.getCarriedItems().getInventory().add( // Add to inventory
383-
new Item(item.getCatalogId(), item.getAmount()), updateClient);
428+
new Item(id, item.getAmount()), updateClient);
384429
}
385430
add(new Item(toEquip.getCatalogId(), toEquip.getAmount())); // Add to equipment
386431

@@ -439,7 +484,17 @@ private boolean equipItemFromBank(EquipRequest request, boolean updateClient) {
439484
if (!itemDef.isStackable()) {
440485
player.getBank().remove(toEquip.getCatalogId(), 1, updateClient);
441486
for (Item item : itemsToUnequip) {
442-
player.getBank().add(new Item(item.getCatalogId(), item.getAmount()), updateClient);
487+
int id = item.getCatalogId();
488+
if (player.getConfig().WANT_CUSTOM_SPRITES && player.getConfig().FORM_FITTING_CHAINMAIL) {
489+
for (int i = 0; i < chainTopIds.length; ++i) {
490+
if (chainTopIds[i] == item.getCatalogId()) {
491+
id = chainBodyIds[i];
492+
break;
493+
}
494+
}
495+
}
496+
497+
player.getBank().add(new Item(id, item.getAmount()), updateClient);
443498
}
444499

445500
if (toEquip.getAmount() > 1) {

0 commit comments

Comments
 (0)