mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-10 10:20:41 -07:00
Converted abyssal titan to kotlin
Abyssal titan is now a beast of burden Fixed issue with abyssal titan that could result in lost essence when bank is full
This commit is contained in:
parent
675d576c58
commit
a88fde30ed
2 changed files with 90 additions and 65 deletions
|
|
@ -1,65 +0,0 @@
|
|||
package content.global.skill.summoning.familiar;
|
||||
|
||||
import core.game.node.entity.combat.equipment.WeaponInterface;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.plugin.Initializable;
|
||||
import core.game.world.update.flag.context.Graphics;
|
||||
|
||||
/**
|
||||
* Represents the Abyssal Titan familiar.
|
||||
* @author Aero
|
||||
* @author Splinter
|
||||
*/
|
||||
@Initializable
|
||||
public class AbyssalTitanNPC extends Familiar {
|
||||
|
||||
/**
|
||||
* Constructs a new {@code AbyssalTitanNPC} {@code Object}.
|
||||
*/
|
||||
public AbyssalTitanNPC() {
|
||||
this(null, 7349);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code AbyssalTitanNPC} {@code Object}.
|
||||
* @param owner The owner.
|
||||
* @param id The id.
|
||||
*/
|
||||
public AbyssalTitanNPC(Player owner, int id) {
|
||||
super(owner, id, 3200, 12796, 6, WeaponInterface.STYLE_ACCURATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Familiar construct(Player owner, int id) {
|
||||
return new AbyssalTitanNPC(owner, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean specialMove(FamiliarSpecial special) {
|
||||
Player player = owner;
|
||||
if (!player.getInventory().containsItem(new Item(1436, 1)) && !player.getInventory().containsItem(new Item(7936, 1))) {
|
||||
player.sendMessage("You have no essence to send to the bank.");
|
||||
return false;
|
||||
}
|
||||
int RUNE_ESSENCE_AMOUNT = player.getInventory().getAmount(1436);
|
||||
int PURE_ESSENCE_AMOUNT = player.getInventory().getAmount(7936);
|
||||
player.getInventory().remove(new Item(1436, RUNE_ESSENCE_AMOUNT), new Item(7936, PURE_ESSENCE_AMOUNT));
|
||||
player.getBank().add(new Item(1436, RUNE_ESSENCE_AMOUNT), new Item(7936, PURE_ESSENCE_AMOUNT));
|
||||
player.sendMessage("The titan sends " + RUNE_ESSENCE_AMOUNT + " rune essence and " + PURE_ESSENCE_AMOUNT + " pure essence to your bank.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visualizeSpecialMove() {
|
||||
owner.visualize(Animation.create(7660), Graphics.create(1316));
|
||||
this.visualize(Animation.create(7694), Graphics.create(1457));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getIds() {
|
||||
return new int[] { 7349, 7350 };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
package content.global.skill.summoning.familiar
|
||||
|
||||
import core.api.Container
|
||||
import core.api.addItem
|
||||
import core.api.amountInInventory
|
||||
import core.api.removeItem
|
||||
import core.game.node.entity.combat.equipment.WeaponInterface
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.game.world.update.flag.context.Graphics
|
||||
import core.plugin.Initializable
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.NPCs
|
||||
|
||||
/**
|
||||
* Represents the Abyssal Titan familiar.
|
||||
* @author Aero
|
||||
* @author Splinter
|
||||
*/
|
||||
@Initializable
|
||||
class AbyssalTitanNPC
|
||||
constructor(owner: Player? = null, id: Int = NPCs.ABYSSAL_TITAN_7349) :
|
||||
BurdenBeast(owner, id, 3200, Items.ABYSSAL_TITAN_POUCH_12796, 6, 7, WeaponInterface.STYLE_ACCURATE) {
|
||||
override fun construct(owner: Player, id: Int): Familiar {
|
||||
return AbyssalTitanNPC(owner, id)
|
||||
}
|
||||
|
||||
override fun isAllowed(owner: Player, item: Item): Boolean {
|
||||
return when (item.id) {
|
||||
Items.RUNE_ESSENCE_1436, Items.PURE_ESSENCE_7936 -> super.isAllowed(owner, item)
|
||||
else -> {
|
||||
owner.packetDispatch.sendMessage("Your familiar can only hold unnoted essence.")
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun specialMove(special: FamiliarSpecial): Boolean {
|
||||
val playerRuneEssenceAmount = amountInInventory(owner, Items.RUNE_ESSENCE_1436)
|
||||
val playerPureEssenceAmount = amountInInventory(owner, Items.PURE_ESSENCE_7936)
|
||||
val beastRuneEssenceAmount = this.container.getAmount(Items.RUNE_ESSENCE_1436)
|
||||
val beastPureEssenceAmount = this.container.getAmount(Items.PURE_ESSENCE_7936)
|
||||
val totalRuneEssence = playerRuneEssenceAmount + beastRuneEssenceAmount
|
||||
val totalPureEssence = playerPureEssenceAmount + beastPureEssenceAmount
|
||||
|
||||
if ((totalRuneEssence + totalPureEssence) == 0) {
|
||||
owner.sendMessage("You have no essence to send to the bank.")
|
||||
return false
|
||||
}
|
||||
|
||||
if (!owner.bank.hasSpaceFor(
|
||||
Item(Items.RUNE_ESSENCE_1436, totalRuneEssence),
|
||||
Item(Items.PURE_ESSENCE_7936, totalPureEssence)
|
||||
)
|
||||
) {
|
||||
owner.sendMessage("You have no space in your bank to deposit your essence.")
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
if (removeItem(owner, Item(Items.RUNE_ESSENCE_1436, playerRuneEssenceAmount))) {
|
||||
addItem(owner, Items.RUNE_ESSENCE_1436, playerRuneEssenceAmount, Container.BANK)
|
||||
}
|
||||
|
||||
if (removeItem(owner, Item(Items.PURE_ESSENCE_7936, playerPureEssenceAmount))) {
|
||||
addItem(owner, Items.PURE_ESSENCE_7936, playerPureEssenceAmount, Container.BANK)
|
||||
}
|
||||
|
||||
if (this.container.remove(Item(Items.RUNE_ESSENCE_1436, beastRuneEssenceAmount))) {
|
||||
addItem(owner, Items.RUNE_ESSENCE_1436, beastRuneEssenceAmount, Container.BANK)
|
||||
}
|
||||
|
||||
if (this.container.remove(Item(Items.PURE_ESSENCE_7936, beastPureEssenceAmount))) {
|
||||
addItem(owner, Items.PURE_ESSENCE_7936, beastPureEssenceAmount, Container.BANK)
|
||||
}
|
||||
|
||||
owner.sendMessage("The titan sends $totalRuneEssence rune essence and $totalPureEssence pure essence to your bank.")
|
||||
return true
|
||||
}
|
||||
|
||||
override fun visualizeSpecialMove() {
|
||||
owner.visualize(Animation.create(7660), Graphics.create(1316))
|
||||
visualize(Animation.create(7694), Graphics.create(1457))
|
||||
}
|
||||
|
||||
override fun getIds(): IntArray {
|
||||
return intArrayOf(NPCs.ABYSSAL_TITAN_7349, NPCs.ABYSSAL_TITAN_7350)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue