mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-09 16:45:44 -07:00
Some other farming improvements
This commit is contained in:
parent
99f93e8c60
commit
f4576ff3d3
9 changed files with 8677 additions and 11 deletions
|
|
@ -122,7 +122,7 @@ public final class VarbitDefinition {
|
|||
*/
|
||||
public int getValue(Player player) {
|
||||
int size = BITS[bitSize - bitShift];
|
||||
int bitValue = player.varpManager.get(getConfigId()).getBitRangeValue(getBitShift(), getBitShift() + (bitSize - bitShift) + 1);
|
||||
int bitValue = player.varpManager.get(getConfigId()).getBitRangeValue(getBitShift(), getBitShift() + (bitSize - bitShift));
|
||||
if(bitValue != 0){
|
||||
return bitValue >>> bitShift;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,9 @@ public final class FieldPickingPlugin extends OptionHandler {
|
|||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
ObjectDefinition.setOptionHandler("pick", this);
|
||||
for(PickingPlant p : PickingPlant.values()){
|
||||
ObjectDefinition.forId(p.objectId).getHandlers().put("option:pick",this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import core.game.system.task.Pulse
|
|||
import core.game.world.update.flag.context.Animation
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import core.tools.Items
|
||||
|
||||
@Initializable
|
||||
class CropHarvester : OptionHandler() {
|
||||
|
|
@ -18,6 +19,7 @@ class CropHarvester : OptionHandler() {
|
|||
|
||||
override fun newInstance(arg: Any?): Plugin<Any> {
|
||||
ObjectDefinition.setOptionHandler("harvest",this)
|
||||
ObjectDefinition.setOptionHandler("pick",this)
|
||||
return this
|
||||
}
|
||||
|
||||
|
|
@ -38,9 +40,29 @@ class CropHarvester : OptionHandler() {
|
|||
player.pulseManager.run(object : Pulse(0){
|
||||
override fun pulse(): Boolean {
|
||||
if(!player.inventory.hasSpaceFor(Item(plantable.harvestItem,1))){
|
||||
player.sendMessage("You don't have enough inventory space for that.")
|
||||
return true
|
||||
}
|
||||
player.animator.animate(spadeAnim)
|
||||
var requiredItem = when(fPatch.type){
|
||||
PatchType.HERB -> Items.SECATEURS_5329
|
||||
else -> Items.SPADE_952
|
||||
}
|
||||
if(requiredItem == Items.SECATEURS_5329){
|
||||
if(player.inventory.contains(Items.MAGIC_SECATEURS_7409,1)){
|
||||
requiredItem = Items.MAGIC_SECATEURS_7409
|
||||
}
|
||||
}
|
||||
val anim = when(requiredItem){
|
||||
Items.SPADE_952 -> Animation(830)
|
||||
Items.SECATEURS_5329 -> Animation(7227)
|
||||
Items.MAGIC_SECATEURS_7409 -> Animation(7228)
|
||||
else -> Animation(0)
|
||||
}
|
||||
if(!player.inventory.containsItem(Item(requiredItem))){
|
||||
player.sendMessage("You lack the needed tool to harvest these crops.")
|
||||
return true
|
||||
}
|
||||
player.animator.animate(anim)
|
||||
delay = 2
|
||||
player.inventory.add(Item(plantable.harvestItem,1))
|
||||
player.skills.addExperience(Skills.FARMING,plantable.harvestXP)
|
||||
|
|
|
|||
|
|
@ -6,13 +6,14 @@ import core.game.interaction.UseWithHandler
|
|||
import core.game.node.item.Item
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import core.tools.NPCs
|
||||
|
||||
@Initializable
|
||||
class LeprechaunNoter : UseWithHandler(*Plantable.values().map{ it.harvestItem }.toIntArray()) {
|
||||
override fun newInstance(arg: Any?): Plugin<Any> {
|
||||
addHandler(3021, NPC_TYPE,this)
|
||||
addHandler(8000, NPC_TYPE,this)
|
||||
addHandler(4965, NPC_TYPE,this)
|
||||
addHandler(NPCs.TOOL_LEPRECHAUN_3021, NPC_TYPE,this)
|
||||
addHandler(NPCs.GOTH_LEPRECHAUN_8000, NPC_TYPE,this)
|
||||
addHandler(NPCs.TOOL_LEPRECHAUN_4965, NPC_TYPE,this)
|
||||
return this
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,11 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl
|
|||
fun setNewHarvestAmount() {
|
||||
if(patch.type == PatchType.ALLOTMENT){
|
||||
harvestAmt = RandomFunction.random(4,17)
|
||||
} else if(patch.type == PatchType.FLOWER) {
|
||||
harvestAmt = when (plantable) {
|
||||
Plantable.LIMPWURT_SEED, Plantable.WOAD_SEED -> 3
|
||||
else -> 1
|
||||
}
|
||||
} else {
|
||||
harvestAmt = RandomFunction.random(1,4)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@ import core.game.node.entity.player.Player
|
|||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import core.tools.Components
|
||||
import core.tools.NPCs
|
||||
|
||||
val TL_IDS = arrayOf(3021,8000,4965)
|
||||
val TL_IDS = arrayOf(NPCs.TOOL_LEPRECHAUN_3021,NPCs.GOTH_LEPRECHAUN_8000,NPCs.TOOL_LEPRECHAUN_4965)
|
||||
@Initializable
|
||||
class ToolLeprechaunHandler : OptionHandler() {
|
||||
override fun newInstance(arg: Any?): Plugin<Any> {
|
||||
|
|
|
|||
|
|
@ -201,6 +201,12 @@ class ToolLeprechaunInterface : ComponentPlugin() {
|
|||
|
||||
if(!player.inventory.contains(item,finalAmount)){
|
||||
player.dialogueInterpreter.sendDialogue("You don't have any of those to store.")
|
||||
return
|
||||
}
|
||||
|
||||
if(finalAmount > spaceLeft){
|
||||
player.dialogueInterpreter.sendDialogue("You can't store any more of those.")
|
||||
return
|
||||
}
|
||||
|
||||
player.inventory.remove(Item(item,finalAmount))
|
||||
|
|
|
|||
|
|
@ -45,8 +45,37 @@ object UseWithPatchHandler{
|
|||
RAKE -> PatchRaker.rake(player,patch)
|
||||
SEED_DIBBER -> player.sendMessage("I should plant a seed, not the seed dibber.")
|
||||
SPADE -> player.dialogueInterpreter.open(67984003,patch.getPatchFor(player)) //DigUpPatchDialogue.kt
|
||||
SECATEURS -> TODO()
|
||||
TROWEL -> TODO()
|
||||
SECATEURS -> {}
|
||||
TROWEL -> {
|
||||
val p = patch.getPatchFor(player)
|
||||
if(!p.isWeedy()){
|
||||
player.sendMessage("This patch has something growing in it.")
|
||||
return true
|
||||
} else if (p.currentGrowthStage != 3){
|
||||
player.sendMessage("I should clear this of weeds before trying to take some dirt.")
|
||||
return true
|
||||
}
|
||||
|
||||
val potAmount = player.inventory.getAmount(Items.PLANT_POT_5356)
|
||||
|
||||
if(potAmount == 0){
|
||||
player.sendMessage("You have no plant pots to fill.")
|
||||
return true
|
||||
}
|
||||
|
||||
val anim = Animation(2272)
|
||||
|
||||
player.pulseManager.run(object : Pulse(anim.duration){
|
||||
override fun pulse(): Boolean {
|
||||
if(player.inventory.remove(Item(Items.PLANT_POT_5356))){
|
||||
player.animator.animate(anim)
|
||||
player.inventory.add(Item(Items.PLANT_POT_5354))
|
||||
} else return true
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Items.PLANT_CURE_6036 -> {
|
||||
val p = patch.getPatchFor(player)
|
||||
if(p.isDiseased && !p.isDead){
|
||||
|
|
@ -64,9 +93,11 @@ object UseWithPatchHandler{
|
|||
player.sendMessage("I have no reason to do this right now.")
|
||||
}
|
||||
}
|
||||
|
||||
Items.WATERING_CAN1_5333,Items.WATERING_CAN2_5334,Items.WATERING_CAN3_5335,Items.WATERING_CAN4_5336,Items.WATERING_CAN5_5337,Items.WATERING_CAN6_5338,Items.WATERING_CAN7_5339,Items.WATERING_CAN8_5340 -> {
|
||||
val p = patch.getPatchFor(player)
|
||||
if(!p.isWatered){
|
||||
val t = p.patch.type
|
||||
if(!p.isWatered && (t == PatchType.ALLOTMENT || t == PatchType.FLOWER || t == PatchType.HOPS) && !p.isGrown()){
|
||||
player.pulseManager.run(object : Pulse(){
|
||||
override fun pulse(): Boolean {
|
||||
player.animator.animate(wateringCanAnim)
|
||||
|
|
@ -79,13 +110,14 @@ object UseWithPatchHandler{
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
Items.SUPERCOMPOST_6034, Items.COMPOST_6032 -> {
|
||||
val p = patch.getPatchFor(player)
|
||||
if(p.compost == CompostType.NONE) {
|
||||
player.animator.animate(pourBucketAnim)
|
||||
player.pulseManager.run(object : Pulse(){
|
||||
override fun pulse(): Boolean {
|
||||
if(player.inventory.remove(event.usedItem)){
|
||||
if(player.inventory.remove(event.usedItem,false)){
|
||||
p.compost = if(usedItem.id == Items.SUPERCOMPOST_6034) CompostType.SUPER else CompostType.NORMAL
|
||||
player.inventory.add(Item(Items.BUCKET_1925))
|
||||
}
|
||||
|
|
@ -96,6 +128,7 @@ object UseWithPatchHandler{
|
|||
player.sendMessage("This patch has already been treated with compost.")
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
val plantable = Plantable.forItemID(usedItem.id)
|
||||
if(plantable == null) return false
|
||||
|
|
|
|||
8596
Server/src/main/java/Server/core/tools/NPCs.kt
Normal file
8596
Server/src/main/java/Server/core/tools/NPCs.kt
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue