mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-20 05:20:22 -07:00
Updated PoisonFountain plugin to listener
This commit is contained in:
parent
c74048425c
commit
7233c968f6
2 changed files with 57 additions and 77 deletions
|
|
@ -1,77 +0,0 @@
|
||||||
package core.game.interaction.item.withobject;
|
|
||||||
|
|
||||||
import core.game.interaction.NodeUsageEvent;
|
|
||||||
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 rs09.game.world.GameWorld;
|
|
||||||
import core.game.world.update.flag.context.Animation;
|
|
||||||
import core.plugin.Initializable;
|
|
||||||
import core.plugin.Plugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the poison fountain plugin.
|
|
||||||
* @author 'Vexia
|
|
||||||
* @date 24/12/2013
|
|
||||||
*/
|
|
||||||
@Initializable
|
|
||||||
public class PoisonFountainPlugin extends UseWithHandler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the searching animation.
|
|
||||||
*/
|
|
||||||
private static final Animation SEARCH_ANIM = new Animation(881);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the poisoned fish food.
|
|
||||||
*/
|
|
||||||
private static final Item POISONED_FOOD = new Item(274);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new {@code PoisonFountainPlugin} {@code Object}.
|
|
||||||
*/
|
|
||||||
public PoisonFountainPlugin() {
|
|
||||||
super(274);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
|
||||||
addHandler(153, OBJECT_TYPE, this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(NodeUsageEvent event) {
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
if (player.getAttribute("piranhas-killed", false)) {
|
|
||||||
player.getPacketDispatch().sendMessage("The piranhas are dead already.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (player.getInventory().remove(POISONED_FOOD)) {
|
|
||||||
player.lock();
|
|
||||||
player.setAttribute("/save:piranhas-killed", true);
|
|
||||||
player.animate(SEARCH_ANIM);
|
|
||||||
player.getPacketDispatch().sendMessage("You pour the poisoned fish food into the fountain.");
|
|
||||||
GameWorld.getPulser().submit(new Pulse(1) {
|
|
||||||
int counter = 0;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean pulse() {
|
|
||||||
switch (counter++) {
|
|
||||||
case 1:
|
|
||||||
player.getPacketDispatch().sendMessage("The piranhas start eating the food...");
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
player.getPacketDispatch().sendMessage("... then die and float to the surface.");
|
|
||||||
player.unlock();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
package rs09.game.interaction.item.withobject
|
||||||
|
|
||||||
|
import api.*
|
||||||
|
import core.game.system.task.Pulse
|
||||||
|
import core.game.world.update.flag.context.Animation
|
||||||
|
import org.rs09.consts.Items
|
||||||
|
import org.rs09.consts.Scenery
|
||||||
|
import rs09.game.interaction.IntType
|
||||||
|
import rs09.game.interaction.InteractionListener
|
||||||
|
import rs09.game.world.GameWorld.Pulser
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener for using poisoned fish food on Draynor Manor fountain
|
||||||
|
* @author Byte
|
||||||
|
*/
|
||||||
|
@Suppress("unused")
|
||||||
|
class PoisonFountainListener : InteractionListener {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val ANIMATION = Animation(881)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun defineListeners() {
|
||||||
|
onUseWith(IntType.SCENERY, Items.POISONED_FISH_FOOD_274, Scenery.FOUNTAIN_153) { player, used, _ ->
|
||||||
|
if (getAttribute(player, "piranhas-killed", false)) {
|
||||||
|
sendMessage(player, "The piranhas are dead already.")
|
||||||
|
return@onUseWith true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!removeItem(player, used)) {
|
||||||
|
return@onUseWith false
|
||||||
|
}
|
||||||
|
|
||||||
|
lock(player, 5)
|
||||||
|
animate(player, ANIMATION)
|
||||||
|
sendMessage(player, "You pour the poisoned fish food into the fountain.")
|
||||||
|
setAttribute(player, "/save:piranhas-killed", true)
|
||||||
|
|
||||||
|
submitIndividualPulse(player, object : Pulse(1) {
|
||||||
|
var counter = 0
|
||||||
|
override fun pulse(): Boolean {
|
||||||
|
when (counter++) {
|
||||||
|
1 -> sendMessage(player, "The piranhas start eating the food...")
|
||||||
|
2 -> {
|
||||||
|
sendMessage(player, "... then die and float to the surface.")
|
||||||
|
unlock(player)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return@onUseWith true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue