mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-20 05:20:22 -07:00
Removed the unnecessary and annoying player lock when cooking an item
Moved all the achievement diary checks out into the achievement event receiver Refactored `ResourceGatheredEvent` -> `ResourceProducedEvent` and added a new optional field, `original` for item processing
This commit is contained in:
parent
f1cab8f6dc
commit
f93cee6952
13 changed files with 50 additions and 80 deletions
|
|
@ -1,6 +1,6 @@
|
|||
package core.game.interaction.item.withobject;
|
||||
|
||||
import api.events.ResourceGatheredEvent;
|
||||
import api.events.ResourceProducedEvent;
|
||||
import core.plugin.Initializable;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.entity.skill.smithing.smelting.Bar;
|
||||
|
|
@ -9,6 +9,7 @@ import core.game.interaction.UseWithHandler;
|
|||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.system.task.Pulse;
|
||||
import org.rs09.consts.Items;
|
||||
import rs09.game.world.GameWorld;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.plugin.Plugin;
|
||||
|
|
@ -40,7 +41,7 @@ public class TutorialFurnaceHandler extends UseWithHandler {
|
|||
player.getInventory().remove(new Item(436, 1));
|
||||
player.getInventory().add(Bar.BRONZE.getProduct());
|
||||
player.getSkills().addExperience(Skills.SMITHING, Bar.BRONZE.getExperience());
|
||||
player.dispatch(new ResourceGatheredEvent(Bar.BRONZE.getProduct().getId(), 1, player));
|
||||
player.dispatch(new ResourceProducedEvent(Bar.BRONZE.getProduct().getId(), 1, player, Items.COPPER_ORE_436));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,14 @@
|
|||
package core.game.node.entity.skill.cooking;
|
||||
|
||||
import api.events.ResourceGatheredEvent;
|
||||
import core.game.container.impl.EquipmentContainer;
|
||||
import api.events.ResourceProducedEvent;
|
||||
import core.game.node.entity.impl.Animator;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.audio.Audio;
|
||||
import core.game.node.entity.player.link.diary.DiaryType;
|
||||
import core.game.node.entity.skill.Skills;
|
||||
import core.game.node.item.GroundItemManager;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.scenery.Scenery;
|
||||
import core.game.system.task.Pulse;
|
||||
import core.game.world.map.Location;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.tools.RandomFunction;
|
||||
import org.rs09.consts.Items;
|
||||
|
|
@ -27,9 +24,11 @@ public class StandardCookingPulse extends Pulse {
|
|||
//Cooking sound
|
||||
public static final Audio SOUND = new Audio(2577, 1, 1);
|
||||
|
||||
private int initial, product, amount, level;
|
||||
private Scenery object;
|
||||
private Player player;
|
||||
private final int initial;
|
||||
private final int product;
|
||||
private int amount;
|
||||
private final Scenery object;
|
||||
private final Player player;
|
||||
private double experience;
|
||||
private boolean burned = false;
|
||||
public CookableItems properties;
|
||||
|
|
@ -65,7 +64,6 @@ public class StandardCookingPulse extends Pulse {
|
|||
}
|
||||
|
||||
public boolean checkRequirements() {
|
||||
this.level = 1;
|
||||
this.experience = 0;
|
||||
if (properties != null) {
|
||||
// Handle Cook's Assistant range
|
||||
|
|
@ -80,7 +78,6 @@ public class StandardCookingPulse extends Pulse {
|
|||
return false;
|
||||
}
|
||||
|
||||
this.level = properties.level;
|
||||
this.experience = properties.experience;
|
||||
this.burned = isBurned(player, object, initial);
|
||||
}
|
||||
|
|
@ -88,10 +85,7 @@ public class StandardCookingPulse extends Pulse {
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!object.isActive()){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return object.isActive();
|
||||
}
|
||||
|
||||
public boolean reward() {
|
||||
|
|
@ -139,13 +133,8 @@ public class StandardCookingPulse extends Pulse {
|
|||
public boolean cook(final Player player, final Scenery object, final boolean burned, final int initial, final int product) {
|
||||
Item initialItem = new Item(initial);
|
||||
Item productItem = new Item(product);
|
||||
player.lock(getDelay());
|
||||
animate();
|
||||
|
||||
//lumbridge diary
|
||||
if (object.getId() == 114 && player.getViewport().getRegion().getId() == 12850 && !player.getAchievementDiaryManager().getDiary(DiaryType.LUMBRIDGE).isComplete(0, 7)) {
|
||||
player.getAchievementDiaryManager().updateTask(player, DiaryType.LUMBRIDGE, 0, 7, true);
|
||||
}
|
||||
//handle special cooking results (spits, cake, etc) that don't justify separate plugin
|
||||
switch (initial) {
|
||||
case Items.RAW_BEAST_MEAT_9986:
|
||||
|
|
@ -171,40 +160,10 @@ public class StandardCookingPulse extends Pulse {
|
|||
if (player.getInventory().remove(initialItem)) {
|
||||
if (!burned) {
|
||||
player.getInventory().add(productItem);
|
||||
player.dispatch(new ResourceGatheredEvent(productItem.getId(), 1, object));
|
||||
player.dispatch(new ResourceProducedEvent(productItem.getId(), 1, object, initialItem.getId()));
|
||||
player.getSkills().addExperience(Skills.COOKING, experience, true);
|
||||
|
||||
int playerRegion = player.getViewport().getRegion().getId();
|
||||
|
||||
// Achievement Diary Handling
|
||||
if (productItem.getId() == Items.BASS_365
|
||||
&& playerRegion == 11317
|
||||
&& player.getAttribute("diary:seers:bass-caught", false)) {
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 1, 11);
|
||||
}
|
||||
|
||||
if (productItem.getId() == Items.SHARK_385
|
||||
&& playerRegion == 11317
|
||||
&& player.getEquipment().get(EquipmentContainer.SLOT_HANDS) != null && player.getEquipment().get(EquipmentContainer.SLOT_HANDS).getId() == Items.COOKING_GAUNTLETS_775
|
||||
&& !player.getAchievementDiaryManager().hasCompletedTask(DiaryType.SEERS_VILLAGE, 2, 8)) {
|
||||
player.setAttribute("/save:diary:seers:cooked-shark", 1 + player.getAttribute("diary:seers:cooked-shark", 0));
|
||||
if (player.getAttribute("diary:seers:cooked-shark", 0) >= 5) {
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 2, 8);
|
||||
}
|
||||
}
|
||||
|
||||
// Cook some rat meat on a campfire in Lumbridge Swamp
|
||||
if (initialItem.getId() == Items.RAW_RAT_MEAT_2134 && object.getName().toLowerCase().contains("fire") && (playerRegion == 12593 || playerRegion == 12849)) {
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.LUMBRIDGE, 1, 10);
|
||||
}
|
||||
|
||||
// Cook a lobster on the range in Lumbridge Castle kitchen
|
||||
if (productItem.getId() == Items.LOBSTER_379 && object.getId() == 114 && player.getLocation().withinDistance(Location.create(3211, 3215, 0))) {
|
||||
player.getAchievementDiaryManager().finishTask(player, DiaryType.LUMBRIDGE, 2, 4);
|
||||
}
|
||||
|
||||
} else {
|
||||
player.dispatch(new ResourceGatheredEvent(CookableItems.getBurnt(initial).getId(), 1, object));
|
||||
player.dispatch(new ResourceProducedEvent(CookableItems.getBurnt(initial).getId(), 1, object, initialItem.getId()));
|
||||
player.getInventory().add(CookableItems.getBurnt(initial));
|
||||
}
|
||||
player.getPacketDispatch().sendMessage(getMessage(initialItem, productItem, burned));
|
||||
|
|
@ -231,11 +190,7 @@ public class StandardCookingPulse extends Pulse {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean updateTutorial(Player player) {
|
||||
return cook(player, object, burned, initial, product);
|
||||
}
|
||||
|
||||
private Animation getAnimation(final Scenery object) {
|
||||
return !object.getName().toLowerCase().equals("fire") ? RANGE_ANIMATION : FIRE_ANIMATION;
|
||||
return !object.getName().equalsIgnoreCase("fire") ? RANGE_ANIMATION : FIRE_ANIMATION;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package core.game.node.entity.skill.gather.woodcutting;
|
||||
|
||||
import api.events.ResourceGatheredEvent;
|
||||
import api.events.ResourceProducedEvent;
|
||||
import core.cache.def.impl.ItemDefinition;
|
||||
import core.game.container.impl.EquipmentContainer;
|
||||
import core.game.content.dialogue.FacialExpression;
|
||||
|
|
@ -151,7 +151,7 @@ public class WoodcuttingSkillPulse extends Pulse {
|
|||
}
|
||||
//give the reward
|
||||
player.getInventory().add(new Item(reward, rewardAmount));
|
||||
player.dispatch(new ResourceGatheredEvent(reward, rewardAmount, node));
|
||||
player.dispatch(new ResourceProducedEvent(reward, rewardAmount, node, -1));
|
||||
int cutLogs = player.getAttribute(STATS_BASE + ":" + STATS_LOGS,0);
|
||||
player.setAttribute("/save:" + STATS_BASE + ":" + STATS_LOGS,++cutLogs);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package core.game.node.entity.skill.smithing;
|
||||
|
||||
import api.events.ResourceGatheredEvent;
|
||||
import api.events.ResourceProducedEvent;
|
||||
import core.cache.def.impl.ItemDefinition;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.diary.DiaryType;
|
||||
|
|
@ -89,7 +89,7 @@ public class SmithingPulse extends SkillPulse<Item> {
|
|||
player.getInventory().remove(new Item(bar.getBarType().getBarType(), bar.getSmithingType().getRequired()));
|
||||
final Item item = new Item(node.getId(), bar.getSmithingType().getProductAmount());
|
||||
player.getInventory().add(item);
|
||||
player.dispatch(new ResourceGatheredEvent(item.getId(), 1, player));
|
||||
player.dispatch(new ResourceProducedEvent(item.getId(), 1, player, bar.getBarType().getBarType()));
|
||||
player.getSkills().addExperience(Skills.SMITHING, bar.getBarType().getExperience() * bar.getSmithingType().getRequired(), true);
|
||||
String message = StringUtils.isPlusN(ItemDefinition.forId(bar.getProduct()).getName().toLowerCase()) ? "an" : "a";
|
||||
player.getPacketDispatch().sendMessage("You hammer the " + bar.getBarType().getBarName().toLowerCase().replace("smithing", "") + "and make " + message + " " + ItemDefinition.forId(bar.getProduct()).getName().toLowerCase() + ".");
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package core.game.node.entity.skill.smithing.smelting;
|
|||
|
||||
import static api.ContentAPIKt.*;
|
||||
import api.EquipmentSlot;
|
||||
import api.events.ResourceGatheredEvent;
|
||||
import api.events.ResourceProducedEvent;
|
||||
import core.game.container.impl.EquipmentContainer;
|
||||
import org.rs09.consts.Items;
|
||||
import core.game.world.map.Location;
|
||||
|
|
@ -143,7 +143,7 @@ public class SmeltingPulse extends SkillPulse<Item> {
|
|||
}
|
||||
}
|
||||
player.getInventory().add(new Item(bar.getProduct().getId(), amt));
|
||||
player.dispatch(new ResourceGatheredEvent(bar.getProduct().getId(), 1, player));
|
||||
player.dispatch(new ResourceProducedEvent(bar.getProduct().getId(), 1, player, -1));
|
||||
double xp = bar.getExperience() * amt;
|
||||
// Goldsmith gauntlets
|
||||
if (((player.getEquipment().get(EquipmentContainer.SLOT_HANDS) != null
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import core.game.node.entity.Entity
|
|||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.link.TeleportManager.TeleportType
|
||||
|
||||
data class ResourceGatheredEvent(val itemId: Int, val amount: Int, val source: Node) : Event
|
||||
data class ResourceProducedEvent(val itemId: Int, val amount: Int, val source: Node, val original: Int = -1) : Event
|
||||
data class NPCKillEvent(val npc: NPC) : Event
|
||||
data class TeleportEvent(val type: TeleportType, val source: Int = -1) : Event
|
||||
data class LitFireEvent(val logId: Int) : Event
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package rs09.game
|
|||
import api.events.*
|
||||
|
||||
object Event {
|
||||
val ResourceGathered = ResourceGatheredEvent::class.java
|
||||
val ResourceProduced = ResourceProducedEvent::class.java
|
||||
val NPCKilled = NPCKillEvent::class.java
|
||||
val Teleport = TeleportEvent::class.java
|
||||
val FireLit = LitFireEvent::class.java
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import core.game.node.entity.skill.gather.mining.MiningNode
|
|||
import core.game.node.entity.skill.gather.woodcutting.WoodcuttingNode
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.NPCs
|
||||
import rs09.game.system.SystemLogger
|
||||
|
||||
/**
|
||||
* Event receivers for tutorial island
|
||||
|
|
@ -191,9 +190,9 @@ object TutorialInteractionReceiver : EventHook<InteractionEvent>
|
|||
}
|
||||
}
|
||||
|
||||
object TutorialResourceReceiver : EventHook<ResourceGatheredEvent>
|
||||
object TutorialResourceReceiver : EventHook<ResourceProducedEvent>
|
||||
{
|
||||
override fun process(entity: Entity, event: ResourceGatheredEvent) {
|
||||
override fun process(entity: Entity, event: ResourceProducedEvent) {
|
||||
if(entity !is Player) return
|
||||
|
||||
when(getAttribute(entity, "tutorial:stage", 0))
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import core.game.system.task.Pulse
|
|||
import core.game.world.map.Location
|
||||
import org.rs09.consts.Components
|
||||
import rs09.game.Event
|
||||
import rs09.game.system.SystemLogger
|
||||
import rs09.game.world.GameWorld.Pulser
|
||||
import rs09.game.world.GameWorld.settings
|
||||
import rs09.game.world.repository.Repository
|
||||
|
|
@ -31,7 +30,7 @@ object TutorialStage {
|
|||
{
|
||||
player.hook(Event.ButtonClicked, TutorialButtonReceiver)
|
||||
player.hook(Event.Interaction, TutorialInteractionReceiver)
|
||||
player.hook(Event.ResourceGathered, TutorialResourceReceiver)
|
||||
player.hook(Event.ResourceProduced, TutorialResourceReceiver)
|
||||
player.hook(Event.UsedWith, TutorialUseWithReceiver)
|
||||
player.hook(Event.FireLit, TutorialFireReceiver)
|
||||
player.hook(Event.NPCKilled, TutorialKillReceiver)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import rs09.game.Event
|
|||
class DiaryEventHook : LoginListener
|
||||
{
|
||||
override fun login(player: Player) {
|
||||
player.hook(Event.ResourceGathered, DiaryGatherHooks)
|
||||
player.hook(Event.ResourceProduced, DiaryGatherHooks)
|
||||
player.hook(Event.Teleport, DiaryTeleportHooks)
|
||||
player.hook(Event.NPCKilled, DiaryCombatHooks)
|
||||
player.hook(Event.FireLit, DiaryFireHooks)
|
||||
|
|
@ -72,9 +72,9 @@ class DiaryEventHook : LoginListener
|
|||
}
|
||||
}
|
||||
|
||||
private object DiaryGatherHooks : EventHook<ResourceGatheredEvent>
|
||||
private object DiaryGatherHooks : EventHook<ResourceProducedEvent>
|
||||
{
|
||||
override fun process(entity: Entity, event: ResourceGatheredEvent) {
|
||||
override fun process(entity: Entity, event: ResourceProducedEvent) {
|
||||
if(entity !is Player) return
|
||||
val regionId = entity.viewport.region.id
|
||||
when(event.itemId)
|
||||
|
|
@ -129,19 +129,35 @@ class DiaryEventHook : LoginListener
|
|||
Items.SILVER_ORE_442 -> if(regionId == 13107) finishTask(entity, DiaryType.LUMBRIDGE, 2, 10)
|
||||
|
||||
Items.COAL_453 -> if(regionId == 12593) finishTask(entity, DiaryType.LUMBRIDGE, 2, 11)
|
||||
|
||||
Items.BASS_365 -> if(regionId == 11317 && getAttribute(entity, "diary:seers:bass-caught", false)) finishTask(entity, DiaryType.SEERS_VILLAGE, 1, 11)
|
||||
|
||||
Items.SHARK_385 -> if(regionId == 11317 && getAttribute(entity, "diary:seers:shark-cooked", false) && isEquipped(entity, Items.COOKING_GAUNTLETS_775)) entity.incrementAttribute("/save:diary:seers:shark-cooked")
|
||||
|
||||
Items.LOBSTER_379 -> if(event.source.id == Scenery.COOKING_RANGE_114) finishTask(entity, DiaryType.LUMBRIDGE, 2, 4)
|
||||
}
|
||||
|
||||
when(event.original)
|
||||
{
|
||||
Items.RAW_RAT_MEAT_2134 -> if((regionId == 12593 || regionId == 12849) && event.itemId == Items.COOKED_MEAT_2142) finishTask(entity, DiaryType.LUMBRIDGE, 1, 10)
|
||||
}
|
||||
|
||||
if(getAttribute(entity, "diary:seers:shark-caught", 0) >= 5)
|
||||
finishTask(entity, DiaryType.SEERS_VILLAGE, 2, 7)
|
||||
if(getAttribute(entity, "diary:seers:shark-cooked", 0) >= 5)
|
||||
finishTask(entity, DiaryType.SEERS_VILLAGE, 2, 8)
|
||||
|
||||
if((regionId == 12593 || regionId == 12849) && event.source.name.startsWith("dead", true))
|
||||
finishTask(entity, DiaryType.LUMBRIDGE, 1, 8)
|
||||
|
||||
if(event.source.id == 333 && entity.zoneMonitor.isInZone("karamja"))
|
||||
if(event.source.id == NPCs.FISHING_SPOT_333 && entity.zoneMonitor.isInZone("karamja"))
|
||||
finishTask(entity, DiaryType.KARAMJA, 0, 6)
|
||||
|
||||
if(event.source.id == Scenery.YEW_TREE_8513 && regionId == 11828)
|
||||
finishTask(entity, DiaryType.FALADOR, 2, 3)
|
||||
|
||||
if(event.source.id == Scenery.COOKING_RANGE_114 && regionId == 12850)
|
||||
finishTask(entity, DiaryType.LUMBRIDGE, 0, 7)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package rs09.game.node.entity.skill.cooking
|
||||
|
||||
import api.*
|
||||
import api.events.ResourceGatheredEvent
|
||||
import api.events.ResourceProducedEvent
|
||||
import core.game.node.item.Item
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.content.dialogue.DialogueFile
|
||||
|
|
@ -32,7 +32,7 @@ class DoughMakingListener : InteractionListener() {
|
|||
end()
|
||||
if(removeItem(player!!, used) && removeItem(player!!, with)){
|
||||
addItem(player!!, products[buttonID - 1])
|
||||
player!!.dispatch(ResourceGatheredEvent(products[buttonID - 1], 1, player!!))
|
||||
player!!.dispatch(ResourceProducedEvent(products[buttonID - 1], 1, player!!))
|
||||
sendMessage(player!!, "You mix the flower and the water to make some ${getItemName(products[buttonID - 1]).toLowerCase()}.")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package rs09.game.node.entity.skill.gather.fishing
|
||||
|
||||
import api.events.ResourceGatheredEvent
|
||||
import api.events.ResourceProducedEvent
|
||||
import core.game.content.global.SkillingPets
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
|
|
@ -113,7 +113,7 @@ class FishingPulse(player: Player?, npc: NPC, private val option: FishingOption?
|
|||
if (player.skillTasks.hasTask()) {
|
||||
updateSkillTask()
|
||||
}
|
||||
player.dispatch(ResourceGatheredEvent(fish!!.item.id, fish!!.item.amount, node!!))
|
||||
player.dispatch(ResourceProducedEvent(fish!!.item.id, fish!!.item.amount, node!!))
|
||||
SkillingPets.checkPetDrop(player, SkillingPets.HERON)
|
||||
val item = fish!!.item
|
||||
if (isActive(SkillcapePerks.GREAT_AIM, player) && RandomFunction.random(100) <= 5) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package rs09.game.node.entity.skill.gather.mining
|
||||
|
||||
import api.*
|
||||
import api.events.ResourceGatheredEvent
|
||||
import api.events.ResourceProducedEvent
|
||||
import core.cache.def.impl.ItemDefinition
|
||||
import core.game.container.impl.EquipmentContainer
|
||||
import core.game.content.dialogue.FacialExpression
|
||||
|
|
@ -118,7 +118,7 @@ class MiningSkillPulse(private val player: Player, private val node: Node) : Pul
|
|||
reward = calculateReward(reward) // calculate rewards
|
||||
rewardAmount = calculateRewardAmount(reward) // calculate amount
|
||||
|
||||
player.dispatch(ResourceGatheredEvent(reward, rewardAmount, node))
|
||||
player.dispatch(ResourceProducedEvent(reward, rewardAmount, node))
|
||||
SkillingPets.checkPetDrop(player, SkillingPets.GOLEM) // roll for pet
|
||||
|
||||
//add experience
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue