Yaks now have their unique usewith interaction
This commit is contained in:
@@ -112,6 +112,8 @@ public abstract class MapZone implements Zone {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean handleUseWith(Player player, Item used, Node with){return false;}
|
||||
|
||||
/**
|
||||
* Handles an reward button.
|
||||
* @param player The player.
|
||||
|
||||
@@ -7,6 +7,7 @@ import core.game.node.entity.combat.CombatStyle;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.music.MusicZone;
|
||||
import core.game.node.entity.player.link.request.RequestType;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.map.Location;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -149,6 +150,18 @@ public final class ZoneMonitor {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a zone handles a useWith interaction
|
||||
*/
|
||||
public boolean useWith(Item used, Node with){
|
||||
for (RegionZone z : zones) {
|
||||
if (z.getZone().handleUseWith(entity.asPlayer(), used,with)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player handled the reward button using a map zone.
|
||||
* @param interfaceId The interface id.
|
||||
|
||||
@@ -72,6 +72,9 @@ public class ItemActionPacket implements IncomingPacket {
|
||||
if(InteractionListeners.run(item,npc,2,player)){
|
||||
return;
|
||||
}
|
||||
if(player.getZoneMonitor().useWith(used,npc)){
|
||||
return;
|
||||
}
|
||||
event = new NodeUsageEvent(player, interfaceId, item, npc);
|
||||
try {
|
||||
UseWithHandler.run(event);
|
||||
@@ -97,6 +100,9 @@ public class ItemActionPacket implements IncomingPacket {
|
||||
if(PluginInteractionManager.handle(player,event)){
|
||||
return;
|
||||
}
|
||||
if(player.getZoneMonitor().useWith(used,player)){
|
||||
return;
|
||||
}
|
||||
event = new NodeUsageEvent(player, interfaceId, item, target);
|
||||
try {
|
||||
UseWithHandler.run(event);
|
||||
@@ -131,6 +137,9 @@ public class ItemActionPacket implements IncomingPacket {
|
||||
if(InteractionListeners.run(used,with,0,player)){
|
||||
return;
|
||||
}
|
||||
if(player.getZoneMonitor().useWith(used,with)){
|
||||
return;
|
||||
}
|
||||
if (usedItemId < usedWithItemId) {
|
||||
item = used;
|
||||
used = with;
|
||||
@@ -182,6 +191,9 @@ public class ItemActionPacket implements IncomingPacket {
|
||||
if(InteractionListeners.run(used,object,1,player)){
|
||||
return;
|
||||
}
|
||||
if(player.getZoneMonitor().useWith(used,object)){
|
||||
return;
|
||||
}
|
||||
event = new NodeUsageEvent(player, 0, used, object);
|
||||
|
||||
/**
|
||||
|
||||
@@ -151,6 +151,9 @@ object InteractionListeners {
|
||||
if(player.locks.isMovementLocked) return false
|
||||
player.pulseManager.run(object : MovementPulse(player, with, flag) {
|
||||
override fun pulse(): Boolean {
|
||||
if (player.zoneMonitor.useWith(used.asItem(), with)) {
|
||||
return true
|
||||
}
|
||||
player.faceLocation(with.location)
|
||||
if(flipped) method.invoke(player,with,used)
|
||||
else method.invoke(player,used,with)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package rs09.game.interaction.region.rellekka
|
||||
|
||||
import api.ContentAPI
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.game.world.map.zone.MapZone
|
||||
import core.game.world.map.zone.ZoneBorders
|
||||
import org.rs09.consts.NPCs
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
class NeitiznotListeners : InteractionListener() {
|
||||
override fun defineListeners() {
|
||||
val zone = object : MapZone("Yakzone", true){
|
||||
override fun handleUseWith(player: Player, used: Item?, with: Node?): Boolean {
|
||||
if(with is NPC && with.id == NPCs.YAK_5529){
|
||||
ContentAPI.sendMessage(player, "The cow doesn't want that.")
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
ContentAPI.registerMapZone(zone, ZoneBorders(2313,3786,2331,3802))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user