diff --git a/Server/src/main/java/core/game/node/entity/npc/familiar/CompostMoundNPC.java b/Server/src/main/java/core/game/node/entity/npc/familiar/CompostMoundNPC.java index 43e2858b6..4e5b50253 100644 --- a/Server/src/main/java/core/game/node/entity/npc/familiar/CompostMoundNPC.java +++ b/Server/src/main/java/core/game/node/entity/npc/familiar/CompostMoundNPC.java @@ -1,24 +1,27 @@ package core.game.node.entity.npc.familiar; -import core.plugin.Initializable; import core.game.content.dialogue.DialogueInterpreter; import core.game.content.dialogue.DialoguePlugin; -import core.game.node.entity.skill.Skills; -import core.game.node.entity.skill.summoning.familiar.Familiar; -import core.game.node.entity.skill.summoning.familiar.FamiliarSpecial; -import core.game.node.entity.skill.summoning.familiar.Forager; import core.game.interaction.NodeUsageEvent; import core.game.interaction.UseWithHandler; import core.game.node.entity.combat.ImpactHandler.HitsplatType; import core.game.node.entity.combat.equipment.WeaponInterface; import core.game.node.entity.player.Player; +import core.game.node.entity.skill.Skills; +import core.game.node.entity.skill.summoning.familiar.Familiar; +import core.game.node.entity.skill.summoning.familiar.FamiliarSpecial; +import core.game.node.entity.skill.summoning.familiar.Forager; import core.game.node.item.Item; import core.game.node.object.GameObject; 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.plugin.PluginManager; import core.tools.RandomFunction; +import org.rs09.consts.Items; +import rs09.game.node.entity.skill.farming.CompostBin; +import rs09.game.node.entity.skill.farming.CompostBins; +import rs09.plugin.PluginManager; /** * Represents the Compost Mound familiar. @@ -74,15 +77,20 @@ public class CompostMoundNPC extends Forager { owner.getPacketDispatch().sendMessage("This scroll can only be used on an empty compost bin."); return false; } - /*final CompostBin bin = owner.getFarmingManager().getCompostManager().getBin(object); - if (bin.getState(owner) != 0) { - owner.getPacketDispatch().sendMessage("This scroll can only be used on an empty compost bin."); + CompostBins cbin = CompostBins.forObject(special.getNode().asObject()); + if(cbin == null){ return false; - }*/ + } + CompostBin bin = cbin.getBinForPlayer(owner); + if(bin.isFinished() || bin.isFull() || bin.isClosed()){ + return false; + } final boolean superCompost = RandomFunction.random(10) == 1; faceLocation(object.getLocation()); - /*bin.getContainer().add(new Item(superCompost ? 6034 : 6032, 15)); - bin.addConfigValue(owner, 31 << bin.getBitShift());*/ + Item toAdd = new Item(superCompost ? Items.PINEAPPLE_2114 : Items.POTATO_1942); + toAdd.setAmount(15); + bin.addItem(toAdd); + bin.close(); animate(Animation.create(7775)); graphics(Graphics.create(1424)); return true; diff --git a/Server/src/main/java/core/game/node/entity/skill/magic/lunar/CurePlantSpell.java b/Server/src/main/java/core/game/node/entity/skill/magic/lunar/CurePlantSpell.java index 765b81c2a..7be16a307 100644 --- a/Server/src/main/java/core/game/node/entity/skill/magic/lunar/CurePlantSpell.java +++ b/Server/src/main/java/core/game/node/entity/skill/magic/lunar/CurePlantSpell.java @@ -14,6 +14,8 @@ import core.game.node.object.GameObject; import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Graphics; import core.plugin.Plugin; +import rs09.game.node.entity.skill.farming.FarmingPatch; +import rs09.game.node.entity.skill.farming.Patch; /** * Cures a diseased plant. @@ -53,36 +55,28 @@ public final class CurePlantSpell extends MagicSpell { return false; } final GameObject object = ((GameObject) target); - /*if (FarmingPatch.forObject(object.getWrapper().getId()) == null) { - return false; - }*/ - /*final PatchWrapper wrapper = player.getFarmingManager().getPatchWrapper(object.getWrapper().getId()); - if (wrapper == null) { - player.getPacketDispatch().sendMessage("Umm... this spell won't cure that!"); + FarmingPatch fPatch = FarmingPatch.forObject(object); + if(fPatch == null){ + player.sendMessage("This spell is for plants... not whatever the heckies that is."); return false; } - if (!wrapper.getCycle().getDiseaseHandler().isDiseased() && (wrapper.getCycle().getGrowthHandler().isGrowing() || wrapper.getCycle().getWaterHandler().isWatered())) { - player.getPacketDispatch().sendMessage("It is growing just fine."); + Patch patch = fPatch.getPatchFor(player); + if(!patch.isDiseased() && !patch.isWeedy()){ + player.sendMessage("It seems to be growing fine already, lad."); return false; } - if (wrapper.isWeedy()) { - player.getPacketDispatch().sendMessage("The weeds are healthy enough already."); + if(patch.isWeedy()){ + player.sendMessage("Trust me lad, the weeds are healthy enough as is."); return false; - }*/ - /*if (wrapper.isEmpty()) { - player.getPacketDispatch().sendMessage("There's nothing there to cure."); + } + if(patch.isDead()){ + player.sendMessage("It says 'Cure' not 'Resurrect'. Although death may arise from disease, it is not in itself a disease and hence cannot be cured. So there."); return false; - }*/ - /*if (wrapper.getCycle().getDeathHandler().isDead()) { - player.getPacketDispatch().sendMessage("It says 'Cure' not 'Resurrect'. Although death may arise from disease, it is not in itself a disease and hence cannot be cured. So there."); - return false; - }*/ + } if (!super.meetsRequirements(player, true, true)) { return false; } -/* - wrapper.getCycle().getDiseaseHandler().cure(player, true); -*/ + patch.cureDisease(); player.animate(ANIMATION); player.graphics(GRAPHIC); player.getSkills().addExperience(Skills.FARMING, 91.5, true); diff --git a/Server/src/main/java/core/game/node/entity/skill/magic/lunar/FertileSoilSpell.java b/Server/src/main/java/core/game/node/entity/skill/magic/lunar/FertileSoilSpell.java index d46f3fd3d..79b74a404 100644 --- a/Server/src/main/java/core/game/node/entity/skill/magic/lunar/FertileSoilSpell.java +++ b/Server/src/main/java/core/game/node/entity/skill/magic/lunar/FertileSoilSpell.java @@ -1,18 +1,21 @@ package core.game.node.entity.skill.magic.lunar; -import core.game.node.entity.skill.magic.MagicSpell; -import core.game.node.entity.skill.magic.Runes; 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.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.object.GameObject; 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. @@ -49,17 +52,20 @@ public final class FertileSoilSpell extends MagicSpell { public boolean cast(Entity entity, Node target) { final Player player = ((Player) entity); final GameObject object = (GameObject) target; - /*if (FarmingPatch.forObject(object.getWrapper().getId()) == null) { + final FarmingPatch fPatch = FarmingPatch.forObject(object); + if(fPatch == null){ return false; - }*/ - /*final PatchWrapper wrapper = player.getFarmingManager().getPatchWrapper(object.getWrapper().getId()); - if (!wrapper.isEmpty() && !wrapper.getCycle().getGrowthHandler().isGrowing()) { - player.getPacketDispatch().sendMessage("You can't fertilize the patch."); + } + 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); return true; diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CompostBin.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CompostBin.kt index 6c3608856..887f047c5 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CompostBin.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/farming/CompostBin.kt @@ -87,7 +87,13 @@ class CompostBin(val player: Player, val bin: CompostBins) { } fun addItem(item: Item){ - addItem(item.id) + val remaining = 15 - items.size + val amount = if(item.amount > remaining){ + remaining + } else item.amount + for(i in 0 until amount) { + addItem(item.id) + } } fun updateBit(){ diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/skillcapeperks/SkillcapePerks.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/skillcapeperks/SkillcapePerks.kt index 9a5a379e3..3b7b5091f 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/skillcapeperks/SkillcapePerks.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/skillcapeperks/SkillcapePerks.kt @@ -46,26 +46,17 @@ enum class SkillcapePerks(val attribute: String, val effect: ((Player) -> Unit)? SEED_ATTRACTION("cape_perks:seed_attract",{player -> val time = player.getAttribute("cape_perks:seed_attract_timer",0L) if(System.currentTimeMillis() > time){ - /*for(i in 0 until 10) { - when (core.tools.RandomFunction.random(100) % 4) { - 0 -> { - val seedID = core.game.node.entity.skill.farming.patch.Allotments.values().random().farmingNode.seed.id - player.inventory.add(core.game.node.item.Item(seedID,1)) - } - 1 -> { - val seedID = core.game.node.entity.skill.farming.patch.Herbs.values().random().farmingNode.seed.id - player.inventory.add(core.game.node.item.Item(seedID, 1)) - } - 2 -> { - val seedID = core.game.node.entity.skill.farming.patch.Hops.values().random().farmingNode.seed.id - player.inventory.add(core.game.node.item.Item(seedID, 1)) - } - 3 -> { - val seedID = core.game.node.entity.skill.farming.patch.Flowers.values().random().farmingNode.seed.id - player.inventory.add(core.game.node.item.Item(seedID, 1)) - } + val possibleSeeds = rs09.game.node.entity.skill.farming.Plantable.values() + for(i in 0 until 10){ + var seed = possibleSeeds.random() + while(seed == rs09.game.node.entity.skill.farming.Plantable.SCARECROW || seed.applicablePatch == rs09.game.node.entity.skill.farming.PatchType.FRUIT_TREE || seed.applicablePatch == rs09.game.node.entity.skill.farming.PatchType.TREE || seed.applicablePatch == rs09.game.node.entity.skill.farming.PatchType.SPIRIT_TREE){ + seed = possibleSeeds.random() } - }*/ + val reward = core.game.node.item.Item(seed.itemID) + if(!player.inventory.add(reward)){ + core.game.node.item.GroundItemManager.create(reward,player) + } + } player.dialogueInterpreter.sendDialogue("You pluck off the seeds that were stuck to your cape.") player.setAttribute("/save:cape_perks:seed_attract_timer",System.currentTimeMillis() + java.util.concurrent.TimeUnit.DAYS.toMillis(1)) } else {