mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-10 10:20:41 -07:00
Fixed plank make without sufficient funds
Fixed potions not taking doses in some cases
This commit is contained in:
parent
3d20bb97d0
commit
f5711fcf8f
4 changed files with 31 additions and 34 deletions
|
|
@ -224,7 +224,7 @@ class LunarListeners : SpellListener("lunar"), Commands {
|
|||
sendMessage(player, "You need to use this spell on logs.")
|
||||
return
|
||||
}
|
||||
if (!removeItem(player, Item(Items.COINS_995, plankType.price))) {
|
||||
if (amountInInventory(player, Items.COINS_995) < plankType.price || !removeItem(player, Item(Items.COINS_995, plankType.price))) {
|
||||
sendMessage(player, "You need ${plankType.price} coins to convert that log into a plank.")
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,22 +53,16 @@ public final class StatBoostSpell extends MagicSpell {
|
|||
List<Player> pl = RegionManager.getLocalPlayers(player, 1);
|
||||
int plSize = pl.size() - 1;
|
||||
int doses = potion.getDose(item);
|
||||
if (plSize > doses) {
|
||||
player.getPacketDispatch().sendMessage("You don't have enough doses.");
|
||||
return false;
|
||||
}
|
||||
if (doses > plSize) {
|
||||
doses = plSize;
|
||||
}
|
||||
if (pl.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (!super.meetsRequirements(player, true, false)) {
|
||||
return false;
|
||||
}
|
||||
int size = 1;
|
||||
int size = 0;
|
||||
for (Player players : pl) {
|
||||
Player o = (Player) players;
|
||||
if (size >= doses) break;
|
||||
if (!o.isActive() || o.getLocks().isInteractionLocked() || o == player) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -80,7 +74,7 @@ public final class StatBoostSpell extends MagicSpell {
|
|||
potion.getEffect().activate(o);
|
||||
size++;
|
||||
}
|
||||
if (size == 1) {
|
||||
if (size == 0) {
|
||||
player.getPacketDispatch().sendMessage("There is nobody around that has accept aid on to share the potion with you.");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -90,7 +84,12 @@ public final class StatBoostSpell extends MagicSpell {
|
|||
player.animate(ANIMATION);
|
||||
player.graphics(GRAPHICS);
|
||||
player.getInventory().remove(item);
|
||||
player.getInventory().add(new Item(potion.getIds()[size - 1]));
|
||||
int newIndex = (potion.getIds().length - doses) + size;
|
||||
if (newIndex > potion.getIds().length - 1) {
|
||||
player.getInventory().add(new Item(229));
|
||||
return true;
|
||||
}
|
||||
player.getInventory().add(new Item(potion.getIds()[newIndex]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ public class StatRestoreSpell extends MagicSpell {
|
|||
|
||||
private static final Animation ANIMATION = new Animation(4413);
|
||||
private static final Graphics GRAPHICS = new Graphics(733, 130);
|
||||
|
||||
private static final int[] IDS = new int[] { 2434, 139, 141, 143, 2430, 127, 129, 131, 3024, 3026, 3028, 3030 };
|
||||
private static final Consumables[] acceptedPotions = new Consumables[] { Consumables.RESTORE, Consumables.SUPER_RESTO, Consumables.PRAYER, Consumables.ENERGY, Consumables.SUPER_ENERGY };
|
||||
|
||||
public StatRestoreSpell() {
|
||||
super(SpellBook.LUNAR, 81, 84, null, null, null, new Item[] { new Item(Runes.ASTRAL_RUNE.getId(), 2), new Item(Runes.EARTH_RUNE.getId(), 10), new Item(Runes.WATER_RUNE.getId(), 10) });
|
||||
|
|
@ -48,28 +47,22 @@ public class StatRestoreSpell extends MagicSpell {
|
|||
player.getPacketDispatch().sendMessage("You can only cast this spell on a potion.");
|
||||
return false;
|
||||
}
|
||||
if (!item.getDefinition().isTradeable() || !isRestore(item.getId())) {
|
||||
if (!item.getDefinition().isTradeable() || !isRestore(potion)) {
|
||||
player.getPacketDispatch().sendMessage("You can't cast this spell on that item.");
|
||||
return false;
|
||||
}
|
||||
List<Player> pl = RegionManager.getLocalPlayers(player, 1);
|
||||
List<Player> pl = RegionManager.getLocalPlayers(player, 2);
|
||||
int plSize = pl.size() - 1;
|
||||
int doses = potion.getDose(item);
|
||||
if (plSize > doses) {
|
||||
player.getPacketDispatch().sendMessage("You don't have enough doses.");
|
||||
return false;
|
||||
}
|
||||
if (doses > plSize) {
|
||||
doses = plSize;
|
||||
}
|
||||
if (pl.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (!super.meetsRequirements(player, true, false)) {
|
||||
return false;
|
||||
}
|
||||
int size = 1;
|
||||
for (Player players : pl) {
|
||||
int size = 0;
|
||||
for (Player players : pl) {
|
||||
if (size >= doses) break;
|
||||
Player o = (Player) players;
|
||||
if (!o.isActive() || o.getLocks().isInteractionLocked() || o == player) {
|
||||
continue;
|
||||
|
|
@ -78,11 +71,10 @@ public class StatRestoreSpell extends MagicSpell {
|
|||
continue;
|
||||
}
|
||||
o.graphics(GRAPHICS);
|
||||
player.getPacketDispatch().sendMessage("You can only cast this spell on a potion.");
|
||||
potion.getEffect().activate(o);
|
||||
size++;
|
||||
}
|
||||
if (size == 1) {
|
||||
if (size == 0) {
|
||||
player.getPacketDispatch().sendMessage("There is nobody around that has accept aid on to share the potion with you.");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -92,16 +84,20 @@ public class StatRestoreSpell extends MagicSpell {
|
|||
player.animate(ANIMATION);
|
||||
player.graphics(GRAPHICS);
|
||||
player.getInventory().remove(item);
|
||||
player.getInventory().add(new Item(potion.getIds()[size - 1]));
|
||||
int newIndex = (potion.getIds().length - doses) + size;
|
||||
if (newIndex > potion.getIds().length - 1) {
|
||||
player.getInventory().add(new Item(229));
|
||||
return true;
|
||||
}
|
||||
player.getInventory().add(new Item(potion.getIds()[newIndex]));
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isRestore(int id) {
|
||||
for (int i : IDS) {
|
||||
if (i == id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
private boolean isRestore(Potion p) {
|
||||
for (int i = 0; i < acceptedPotions.length; i++) {
|
||||
if (p == acceptedPotions[i].getConsumable())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,9 @@ public class Potion extends Drink {
|
|||
}
|
||||
}
|
||||
|
||||
public static int getDose(Item potion){
|
||||
public int getDose(Item potion){
|
||||
for (int i = 0; i < ids.length; i++)
|
||||
if (ids[i] == potion.getId()) return ids.length - i;
|
||||
return Integer.parseInt(potion.getName().replaceAll("[^\\d.]",""));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue