mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-21 09:02:07 -07:00
Merge branch 'add-cactus-patch' into 'master'
Added Cactus Patch See merge request 2009scape/2009scape!201
This commit is contained in:
commit
e9491c6ee2
6 changed files with 28 additions and 9 deletions
|
|
@ -64,7 +64,8 @@ enum class FarmingPatch(val varpIndex: Int, val varpOffset: Int, val type: Patch
|
|||
KARAMJA_SPIRIT_TREE(507,16,PatchType.SPIRIT_TREE),
|
||||
|
||||
//Other
|
||||
DRAYNOR_BELLADONNA(512, 16, PatchType.BELLADONNA);
|
||||
DRAYNOR_BELLADONNA(512, 16, PatchType.BELLADONNA),
|
||||
ALKHARID_CACTUS(512, 0, PatchType.CACTUS);
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ class FruitAndBerryPicker : OptionHandler() {
|
|||
SceneryDefinition.setOptionHandler("pick-leaf",this)
|
||||
SceneryDefinition.setOptionHandler("pick-from",this)
|
||||
SceneryDefinition.setOptionHandler("pick-fruit",this)
|
||||
SceneryDefinition.setOptionHandler("pick-spine",this)
|
||||
return this
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class HealthChecker : OptionHandler(){
|
|||
val patch = fPatch.getPatchFor(player)
|
||||
val type = patch.patch.type
|
||||
|
||||
if(type != PatchType.BUSH && type != PatchType.FRUIT_TREE && type != PatchType.TREE){
|
||||
if(type != PatchType.BUSH && type != PatchType.FRUIT_TREE && type != PatchType.TREE && type != PatchType.CACTUS){
|
||||
player.sendMessage("This shouldn't be happening. Please report this.")
|
||||
return true
|
||||
}
|
||||
|
|
@ -38,6 +38,7 @@ class HealthChecker : OptionHandler(){
|
|||
PatchType.TREE -> patch.setCurrentState(patch.getCurrentState() + 1)
|
||||
PatchType.FRUIT_TREE -> patch.setCurrentState(patch.getCurrentState() - 14)
|
||||
PatchType.BUSH -> patch.setCurrentState(patch.plantable!!.value + patch.plantable!!.stages + 4)
|
||||
PatchType.CACTUS -> patch.setCurrentState(patch.plantable!!.value + patch.plantable!!.stages + 3)
|
||||
else -> SystemLogger.logErr("Unreachable patch type from when(type) switch in HealthChecker.kt line 36")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl
|
|||
when(patch.type){
|
||||
PatchType.FRUIT_TREE -> player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset,plantable!!.value + plantable!!.stages + 20)
|
||||
PatchType.BUSH -> player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset,250 + (plantable!!.ordinal - Plantable.REDBERRY_SEED.ordinal))
|
||||
PatchType.CACTUS -> player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, 31)
|
||||
else -> SystemLogger.logWarn("Invalid setting of isCheckHealth for patch type: " + patch.type.name)
|
||||
}
|
||||
} else {
|
||||
|
|
@ -77,6 +78,10 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl
|
|||
else if(isDiseased && !isDead) player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, getBelladonnaDiseaseValue())
|
||||
else player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, (plantable?.value ?: 0) + currentGrowthStage)
|
||||
}
|
||||
PatchType.CACTUS -> {
|
||||
if(isDead) player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, getCactusDeathValue())
|
||||
else if(isDiseased && !isDead) player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, getCactusDiseaseValue())
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
|
@ -88,6 +93,7 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl
|
|||
when(patch.type){
|
||||
PatchType.BUSH,PatchType.FRUIT_TREE -> player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset,(plantable?.value ?: 0) + currentGrowthStage)
|
||||
PatchType.TREE -> player.varpManager.get(patch.varpIndex).clearBitRange(patch.varpOffset + 6, patch.varpOffset + 7)
|
||||
PatchType.CACTUS -> player.varpManager.get(patch.varpIndex).setVarbit(patch.varpOffset, (plantable?.value ?: 0) + currentGrowthStage)
|
||||
else -> {}
|
||||
}
|
||||
updateBit()
|
||||
|
|
@ -130,6 +136,14 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl
|
|||
return (plantable?.value ?: 0) + currentGrowthStage + 7
|
||||
}
|
||||
|
||||
private fun getCactusDiseaseValue(): Int {
|
||||
return (plantable?.value ?: 0) + currentGrowthStage + 10
|
||||
}
|
||||
|
||||
private fun getCactusDeathValue(): Int {
|
||||
return (plantable?.value ?: 0) + currentGrowthStage + 16
|
||||
}
|
||||
|
||||
private fun grow(){
|
||||
if(isWeedy() && getCurrentState() > 0) {
|
||||
nextGrowth = System.currentTimeMillis() + 60000
|
||||
|
|
@ -150,19 +164,19 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl
|
|||
}
|
||||
|
||||
if(RandomFunction.random(128) <= (17 - diseaseMod) && !isWatered && !isGrown() && !protectionPaid && !isFlowerProtected()){
|
||||
//bush, tree, fruit tree can not disease on stage 1(0) of growth.
|
||||
if(!((patch.type == PatchType.BUSH || patch.type == PatchType.TREE || patch.type == PatchType.FRUIT_TREE) && currentGrowthStage == 0)) {
|
||||
//bush, tree, fruit tree and cactus can not disease on stage 1(0) of growth.
|
||||
if(!((patch.type == PatchType.BUSH || patch.type == PatchType.TREE || patch.type == PatchType.FRUIT_TREE || patch.type == PatchType.CACTUS) && currentGrowthStage == 0)) {
|
||||
isDiseased = true
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if((patch.type == PatchType.FRUIT_TREE || patch.type == PatchType.TREE || patch.type == PatchType.BUSH) && plantable != null && plantable?.stages == currentGrowthStage + 1){
|
||||
if((patch.type == PatchType.FRUIT_TREE || patch.type == PatchType.TREE || patch.type == PatchType.BUSH || patch.type == PatchType.CACTUS) && plantable != null && plantable?.stages == currentGrowthStage + 1){
|
||||
isCheckHealth = true
|
||||
}
|
||||
|
||||
if((patch.type == PatchType.FRUIT_TREE || patch.type == PatchType.BUSH) && plantable?.stages == currentGrowthStage){
|
||||
if((patch.type == PatchType.BUSH && getFruitOrBerryCount() < 4) || (patch.type == PatchType.FRUIT_TREE && getFruitOrBerryCount() < 6)){
|
||||
if((patch.type == PatchType.FRUIT_TREE || patch.type == PatchType.BUSH || patch.type == PatchType.CACTUS) && plantable?.stages == currentGrowthStage){
|
||||
if((patch.type == PatchType.BUSH && getFruitOrBerryCount() < 4) || (patch.type == PatchType.FRUIT_TREE && getFruitOrBerryCount() < 6) || (patch.type == PatchType.CACTUS && getFruitOrBerryCount() < 3)){
|
||||
setCurrentState(getCurrentState() + 1)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,5 +9,6 @@ enum class PatchType(val stageGrowthTime: Int) {
|
|||
FLOWER(5),
|
||||
HERB(20),
|
||||
SPIRIT_TREE(293),
|
||||
BELLADONNA(80)
|
||||
BELLADONNA(80),
|
||||
CACTUS(60)
|
||||
}
|
||||
|
|
@ -76,7 +76,8 @@ enum class Plantable(val itemID: Int, val value: Int, val stages: Int, val plant
|
|||
TORSTOL_SEED(5304,103,4,199.5,224.5,0.0,85,PatchType.HERB,Items.GRIMY_TORSTOL_219),
|
||||
|
||||
//Other
|
||||
BELLADONNA_SEED(5281, 4, 4, 91.0, 128.0, 0.0, 63, PatchType.BELLADONNA, Items.CAVE_NIGHTSHADE_2398)
|
||||
BELLADONNA_SEED(5281, 4, 4, 91.0, 128.0, 0.0, 63, PatchType.BELLADONNA, Items.CAVE_NIGHTSHADE_2398),
|
||||
CACTUS_SEED(Items.CACTUS_SEED_5280, 8, 7, 66.5, 25.0, 374.0, 55, PatchType.CACTUS, Items.CACTUS_SPINE_6016)
|
||||
;
|
||||
|
||||
constructor(itemID: Int, value: Int, stages: Int, plantingXP: Double, harvestXP: Double, checkHealthXP: Double, requiredLevel: Int, applicablePatch: PatchType, harvestItem: Int, protectionFlower: Plantable)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue