Merge branch 'farming-fixes' into 'master'

Farming fixes:

See merge request 2009scape/2009scape!268
This commit is contained in:
Ceikry
2021-09-22 23:46:26 +00:00
5 changed files with 21 additions and 8 deletions
@@ -65,9 +65,11 @@ enum class FarmingPatch(val varpIndex: Int, val varpOffset: Int, val type: Patch
//Other
DRAYNOR_BELLADONNA(512, 16, PatchType.BELLADONNA),
CANIFIS_MUSHROOM(512, 8, PatchType.MUSHROOM),
ALKHARID_CACTUS(512, 0, PatchType.CACTUS),
EVIL_TURNIP(1171, 7, PatchType.EVIL_TURNIP);
companion object {
@JvmField
val patches = FarmingPatch.values().map { (it.varpIndex shl it.varpOffset) to it }.toMap()
@@ -2,6 +2,7 @@ package rs09.game.node.entity.skill.farming
import core.game.node.entity.player.Player
import core.tools.RandomFunction
import org.rs09.consts.Items
import rs09.game.system.SystemLogger
import java.util.concurrent.TimeUnit
import kotlin.math.ceil
@@ -16,11 +17,16 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl
var cropLives = 3
fun setNewHarvestAmount() {
val compostMod = if(compost == CompostType.SUPER) 2 else 1
harvestAmt = when (plantable) {
Plantable.LIMPWURT_SEED, Plantable.WOAD_SEED -> 3
Plantable.MUSHROOM_SPORE -> 6
else -> 1
}
cropLives = 3
if(plantable != null && plantable?.applicablePatch != PatchType.FLOWER) {
harvestAmt += compostMod
}
cropLives = 3 + compostMod
}
fun rollLivesDecrement(farmingLevel: Int, magicSecateurs: Boolean){
@@ -290,9 +296,12 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl
FarmingPatch.ARDOUGNE_ALLOTMENT_S,FarmingPatch.ARDOUGNE_ALLOTMENT_N -> FarmingPatch.ARDOUGNE_FLOWER_C
FarmingPatch.CATHERBY_ALLOTMENT_S,FarmingPatch.CATHERBY_ALLOTMENT_N -> FarmingPatch.CATHERBY_FLOWER_C
FarmingPatch.PORT_PHAS_ALLOTMENT_SE,FarmingPatch.PORT_PHAS_ALLOTMENT_NW -> FarmingPatch.PORT_PHAS_FLOWER_C
FarmingPatch.TROLL_STRONGHOLD_HERB -> return true
else -> return false
}.getPatchFor(player)
return (fpatch.plantable != null && fpatch.plantable == plantable?.protectionFlower && fpatch.isGrown())
return (fpatch.plantable != null &&
(fpatch.plantable == plantable?.protectionFlower || fpatch.plantable == Plantable.forItemID(Items.WHITE_LILY_SEED_14589))
&& fpatch.isGrown())
}
}
@@ -9,6 +9,7 @@ enum class PatchType(val stageGrowthTime: Int) {
FLOWER(5),
HERB(20),
SPIRIT_TREE(293),
MUSHROOM(30),
BELLADONNA(80),
CACTUS(60),
EVIL_TURNIP(5)
@@ -78,6 +78,7 @@ enum class Plantable(val itemID: Int, val value: Int, val stages: Int, val plant
//Other
BELLADONNA_SEED(5281, 4, 4, 91.0, 128.0, 0.0, 63, PatchType.BELLADONNA, Items.CAVE_NIGHTSHADE_2398),
MUSHROOM_SPORE(Items.MUSHROOM_SPORE_5282, 6, 7, 61.5, 57.7, 0.0, 53, PatchType.MUSHROOM, Items.MUSHROOM_6004),
CACTUS_SEED(Items.CACTUS_SEED_5280, 8, 7, 66.5, 25.0, 374.0, 55, PatchType.CACTUS, Items.CACTUS_SPINE_6016),
EVIL_TURNIP_SEED(Items.EVIL_TURNIP_SEED_12148, 4, 1, 41.0, 46.0, 0.0, 42, PatchType.EVIL_TURNIP, Items.EVIL_TURNIP_12134)
;
@@ -125,7 +125,7 @@ object UseWithPatchHandler{
if(player.inventory.remove(event.usedItem,false)){
p.compost = if(usedItem.id == Items.SUPERCOMPOST_6034) CompostType.SUPER else CompostType.NORMAL
if(p.compost == CompostType.SUPER) ContentAPI.rewardXP(player, Skills.FARMING, 26.0) else ContentAPI.rewardXP(player, Skills.FARMING, 18.5)
if(p.plantable != null){
if(p.plantable != null && p.plantable?.applicablePatch != PatchType.FLOWER) {
p.harvestAmt += if(p.compost == CompostType.NORMAL) 1 else if(p.compost == CompostType.SUPER) 2 else 0
}
p.cropLives += if(p.compost == CompostType.SUPER) 2 else 1