mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-11 09:00:23 -07:00
Updated const lib, Toy Horsey rewrite
This commit is contained in:
parent
0b047b513c
commit
efaf44fee4
4 changed files with 41 additions and 49 deletions
|
|
@ -26,7 +26,7 @@ dependencies {
|
||||||
implementation group: 'com.moandjiezana.toml', name: 'toml4j', version: '0.7.2'
|
implementation group: 'com.moandjiezana.toml', name: 'toml4j', version: '0.7.2'
|
||||||
implementation files(
|
implementation files(
|
||||||
"libs/PrimitiveExtensions-1.0.jar",
|
"libs/PrimitiveExtensions-1.0.jar",
|
||||||
"libs/ConstLib-1.3.jar",
|
"libs/ConstLib-1.4.jar",
|
||||||
"libs/json-simple-1.1.1.jar",
|
"libs/json-simple-1.1.1.jar",
|
||||||
"libs/markdown-jvm-0.2.4.jar",
|
"libs/markdown-jvm-0.2.4.jar",
|
||||||
"libs/classgraph-4.8.98.jar",
|
"libs/classgraph-4.8.98.jar",
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1,48 +0,0 @@
|
||||||
package core.game.interaction.item;
|
|
||||||
|
|
||||||
import core.cache.def.impl.ItemDefinition;
|
|
||||||
import core.game.interaction.OptionHandler;
|
|
||||||
import core.game.node.Node;
|
|
||||||
import core.game.node.entity.player.Player;
|
|
||||||
import core.game.node.item.Item;
|
|
||||||
import core.game.world.update.flag.context.Animation;
|
|
||||||
import core.plugin.Plugin;
|
|
||||||
import core.plugin.Initializable;
|
|
||||||
import core.tools.RandomFunction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles the option for the toy horse.
|
|
||||||
* @author Vexia
|
|
||||||
*/
|
|
||||||
@Initializable
|
|
||||||
public class ToyHorsePlugin extends OptionHandler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The force chat's you can say.
|
|
||||||
*/
|
|
||||||
private static final String CHATS[] = { "Come-on Dobbin, we can win the race!", "Hi-ho Silver, and away!", "Neaahhhyyy!" };
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(Player player, Node node, String option) {
|
|
||||||
player.lock(2);
|
|
||||||
int id = ((Item) node).getId();
|
|
||||||
int anim = id == 2524 ? 920 : id == 2526 ? 921 : id == 2522 ? 919 : 918;
|
|
||||||
player.animate(new Animation(anim));
|
|
||||||
player.sendChat(CHATS[RandomFunction.random(CHATS.length)]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isWalk() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
|
||||||
int[] ids = new int[] { 2524, 2526, 2522 };
|
|
||||||
for (int id : ids) {
|
|
||||||
ItemDefinition.forId(id).getHandlers().put("play-with", this);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package rs09.game.interaction.item
|
||||||
|
|
||||||
|
import api.animate
|
||||||
|
import api.sendChat
|
||||||
|
import api.stopWalk
|
||||||
|
import org.rs09.consts.Animations
|
||||||
|
import org.rs09.consts.Items
|
||||||
|
import rs09.game.interaction.InteractionListener
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interaction listener for the Toy Horsey item
|
||||||
|
* @author Woah
|
||||||
|
*/
|
||||||
|
class ToyHorseListener : InteractionListener() {
|
||||||
|
|
||||||
|
// Map of horse item ids to their correct emote
|
||||||
|
val HORSEY_MAP = mapOf(
|
||||||
|
Items.TOY_HORSEY_2520 to Animations.HUMAN_PLAY_WITH_BROWN_HORSE_918,
|
||||||
|
Items.TOY_HORSEY_2522 to Animations.HUMAN_PLAY_WITH_WHITE_HORSE_919,
|
||||||
|
Items.TOY_HORSEY_2524 to Animations.HUMAN_PLAY_WITH_BLACK_HORSE_920,
|
||||||
|
Items.TOY_HORSEY_2526 to Animations.HUMAN_PLAY_WITH_GRAY_HORSE_921
|
||||||
|
)
|
||||||
|
|
||||||
|
// Array of phrases used during the interaction
|
||||||
|
val PHRASES = arrayOf(
|
||||||
|
"Come-on Dobbin, we can win the race!",
|
||||||
|
"Hi-ho Silver, and away",
|
||||||
|
"Neaahhhyyy! Giddy-up horsey!"
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun defineListeners() {
|
||||||
|
on(HORSEY_MAP.keys.toIntArray(), ITEM, "play-with") { player, node ->
|
||||||
|
// "high-priority" interaction, so movement is stopped
|
||||||
|
stopWalk(player)
|
||||||
|
animate(player, HORSEY_MAP.get(node.id))
|
||||||
|
sendChat(player, PHRASES.random())
|
||||||
|
return@on true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue