Lunar spell Fertile Soil translated to Kotlin

This commit is contained in:
bushtail
2022-10-01 05:51:09 +00:00
committed by Ryan
parent 6edc2eb81c
commit 5af39b5b21
5 changed files with 93 additions and 106 deletions
@@ -1,76 +0,0 @@
package core.game.node.entity.skill.magic.lunar;
import core.game.node.Node;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.equipment.SpellType;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.audio.Audio;
import core.game.node.entity.player.link.SpellBookManager.SpellBook;
import core.game.node.entity.skill.magic.MagicSpell;
import core.game.node.entity.skill.magic.Runes;
import core.game.node.item.Item;
import core.game.node.scenery.Scenery;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
import core.plugin.Initializable;
import core.plugin.Plugin;
import rs09.game.node.entity.skill.farming.CompostType;
import rs09.game.node.entity.skill.farming.FarmingPatch;
import rs09.game.node.entity.skill.farming.Patch;
/**
* Represents the fertile soil spell plugin.
* @author 'Vexia
* @version 1.0
*/
@Initializable
public final class FertileSoilSpell extends MagicSpell {
/**
* Represents the graphic to use.
*/
private static final Graphics GRAPHIC = new Graphics(141, 96);
/**
* Represents the animaton to use.
*/
private static final Animation ANIMATION = new Animation(724);
/**
* Constructs a new {@code FertileSoilSpell} {@code Object}.
*/
public FertileSoilSpell() {
super(SpellBook.LUNAR, 83, 87, null, null, null, new Item[] { new Item(Runes.NATURE_RUNE.getId(), 2), new Item(Runes.ASTRAL_RUNE.getId(), 3), new Item(Runes.EARTH_RUNE.getId(), 15) });
}
@Override
public Plugin<SpellType> newInstance(SpellType arg) throws Throwable {
SpellBook.LUNAR.register(2, this);
return this;
}
@Override
public boolean cast(Entity entity, Node target) {
final Player player = ((Player) entity);
final Scenery object = (Scenery) target;
final FarmingPatch fPatch = FarmingPatch.forObject(object);
if(fPatch == null){
player.sendMessage("Um... I don't want to fertilize that!");
return false;
}
final Patch patch = fPatch.getPatchFor(player);
if(patch.getCompost() != CompostType.NONE){
player.sendMessage("This patch has already been composted.");
return false;
}
if (!super.meetsRequirements(player, true, true)) {
return false;
}
patch.setCompost(CompostType.SUPER);
player.sendMessage("You fertilize the soil.");
player.graphics(GRAPHIC);
player.animate(ANIMATION);
player.getAudioManager().send(2891, 1, 1);
return true;
}
}
@@ -96,6 +96,10 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl
updateBit()
}
fun isFertilized(): Boolean {
return compost != CompostType.NONE
}
fun isGrown(): Boolean{
return currentGrowthStage == (plantable?.stages ?: 0)
}
@@ -4,22 +4,27 @@ import core.game.world.update.flag.context.Animation
import core.game.world.update.flag.context.Graphics
import org.rs09.consts.Items
// Animations
val BAKE_PIE_ANIM = Animation(4413)
val BAKE_PIE_GFX = Graphics(746,75)
val STATSPY_ANIM = Animation(6293)
val STATSPY_GFX = Graphics(1059)
val CURE_PLANT_ANIM = Animation(4409)
val CURE_PLANT_GFX = Graphics(742,100)
val NPC_CONTACT_ANIM = Animation(4413)
val NPC_CONTACT_GFX = Graphics(730,130)
val PLANK_MAKE_ANIM = Animation(6298)
val PLANK_MAKE_GFX = Graphics(1063, 120)
val STRING_JEWELLERY_ANIM = Animation(4412)
val STRING_JEWELLERY_GFX = Graphics(728, 100)
val SUPERGLASS_MAKE_ANIM = Animation(4413)
val SUPERGLASS_MAKE_GFX = Graphics(729, 120)
val FERTILE_SOIL_ANIM = Animation(724)
// Graphics
val BAKE_PIE_GFX = Graphics(746,75)
val STATSPY_GFX = Graphics(1059)
val CURE_PLANT_GFX = Graphics(742,100)
val NPC_CONTACT_GFX = Graphics(730,130)
val PLANK_MAKE_GFX = Graphics(1063, 120)
val STRING_JEWELLERY_GFX = Graphics(728, 100)
val SUPERGLASS_MAKE_GFX = Graphics(729, 120)
val FERTILE_SOIL_GFX = Graphics(141, 96)
enum class JewelleryString(val unstrung: Int, val strung: Int) {
GOLD(Items.GOLD_AMULET_1673, Items.GOLD_AMULET_1692),
SAPPHIRE(Items.SAPPHIRE_AMULET_1675, Items.SAPPHIRE_AMULET_1694),
@@ -13,11 +13,11 @@ import core.game.node.item.Item
import core.game.system.task.Pulse
import core.game.world.map.Location
import core.game.world.map.RegionManager
import core.game.world.update.flag.context.Animation
import core.game.world.update.flag.context.Graphics
import core.tools.RandomFunction
import org.rs09.consts.Components
import org.rs09.consts.Items
import rs09.game.node.entity.skill.farming.CompostBins
import rs09.game.node.entity.skill.farming.CompostType
import rs09.game.node.entity.skill.farming.FarmingPatch
import rs09.game.node.entity.skill.magic.spellconsts.Lunar
import rs09.game.system.config.NPCConfigParser
@@ -161,6 +161,10 @@ class LunarListeners : SpellListener("lunar") {
requires(player, 77, arrayOf(Item(Items.ASTRAL_RUNE_9075, 2), Item(Items.FIRE_RUNE_554, 6), Item(Items.AIR_RUNE_556, 10)))
superglassMake(player)
}
onCast(Lunar.FERTILE_SOIL, OBJECT) { player, node ->
fertileSoil(player, node!!.asScenery())
}
}
private fun plankMake(player: Player, item: Item) {
@@ -393,4 +397,37 @@ class LunarListeners : SpellListener("lunar") {
addXP(player, 78.0)
}
}
private fun fertileSoil(player: Player, target: Scenery) {
if (CompostBins.forObjectID(target.id) != null) {
sendMessage(player, "No, that would be silly.")
return
}
val fPatch = FarmingPatch.forObject(target)
if(fPatch == null) {
sendMessage(player, "Um... I don't want to fertilize that!")
return
}
val patch = fPatch.getPatchFor(player)
if (patch.isGrown()) {
sendMessage(player, "Composting isn't going to make it get any bigger.")
return
}
if (patch.isFertilized()) {
sendMessage(player, "This patch has already been composted.")
return
}
requires(player, 83, arrayOf(Item(Items.ASTRAL_RUNE_9075, 3), Item(Items.NATURE_RUNE_561, 2), Item(Items.EARTH_RUNE_557, 15)))
removeRunes(player, true)
visualizeSpell(player, FERTILE_SOIL_ANIM, FERTILE_SOIL_GFX, 2891)
patch.compost = CompostType.SUPER
sendMessage(player, "You fertilize the soil.")
addXP(player, 87.0)
}
}
@@ -2,19 +2,36 @@ package rs09.game.node.entity.skill.magic.spellconsts
object Lunar {
const val BARBARIAN_TELEPORT = 0
const val CURE_OTHER = 1
const val FERTILE_SOIL = 2
const val CURE_GROUP = 3
const val NPC_CONTACT = 4
const val ENERGY_TRANSFER = 5
const val MONSTER_EXAMINE = 6
const val HUMIDIFY = 7
const val HUNTER_KIT = 8
const val STAT_SPY = 9
const val DREAM = 10
const val PLANK_MAKE = 11
const val SPELLBOOK_SWAP = 12
const val MAGIC_IMBUE = 13
const val VENGEANCE = 14
const val BAKE_PIE = 15
const val HOME_TELEPORT = 16
const val FISHING_GUILD_TELEPORT = 17
const val KHAZARD_TELEPORT = 18
const val VENGEANCE_OTHER = 19
const val MOONCLAN_TELEPORT = 20
const val CATHERBY_TELEPORT = 21
const val STRING_JEWELLERY = 22
const val CURE_ME = 23
const val WATERBIRTH_TELEPORT = 24
const val SUPERGLASS_MAKE = 25
const val BOOST_POTION_SHARE = 26
const val STAT_RESTORE_POT_SHARE = 27
const val ICE_PLATEAU_TELEPORT = 28
const val HEAL_OTHER = 29
const val HEAL_GROUP = 30
const val OURANIA_TELEPORT = 31
const val CURE_PLANT = 32
const val MOONCLAN_GR_TELEPORT = 33