mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-01 14:39:13 -06:00
Rewrote ring of stone and easter ring, which also fixes a teleblock bug
This commit is contained in:
parent
37b30d7561
commit
592138d904
3 changed files with 83 additions and 113 deletions
|
|
@ -539,6 +539,12 @@
|
|||
"walkable": "true",
|
||||
"tabIndex": "-1"
|
||||
},
|
||||
{
|
||||
"id": "375",
|
||||
"interfaceType": "3",
|
||||
"walkable": "false",
|
||||
"tabIndex": "-1"
|
||||
},
|
||||
{
|
||||
"id": "377",
|
||||
"interfaceType": "8",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
package content.global.handlers.item
|
||||
|
||||
import core.api.*
|
||||
import core.game.interaction.InteractionListener
|
||||
import core.game.interaction.InterfaceListener
|
||||
import core.game.node.entity.player.Player
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.NPCs
|
||||
import org.rs09.consts.Sounds
|
||||
|
||||
/**
|
||||
* Handles morphing with the Ring of Stone and Easter Ring.
|
||||
*/
|
||||
|
||||
class MorphItemListener : InteractionListener, InterfaceListener {
|
||||
|
||||
// the morphing items
|
||||
private val morphItems = intArrayOf(Items.RING_OF_STONE_6583, Items.EASTER_RING_7927)
|
||||
|
||||
// the NPCs to morph into
|
||||
private val easterEggs = intArrayOf(
|
||||
NPCs.EGG_3689,
|
||||
NPCs.EGG_3690,
|
||||
NPCs.EGG_3691,
|
||||
NPCs.EGG_3692,
|
||||
NPCs.EGG_3693,
|
||||
NPCs.EGG_3694
|
||||
)
|
||||
private val stone = intArrayOf(NPCs.ROCKS_2626)
|
||||
|
||||
// the "unmorph" interface
|
||||
private val morphIface = 375
|
||||
|
||||
// equipping the morph items
|
||||
override fun defineListeners() {
|
||||
onEquip(morphItems) { player, item ->
|
||||
morph(player, item.id)
|
||||
return@onEquip false
|
||||
}
|
||||
}
|
||||
|
||||
// the interface that appears when you morph
|
||||
override fun defineInterfaceListeners() {
|
||||
|
||||
// hitting the 'unmorph' button
|
||||
on(morphIface){ player, _, _, buttonID, _, _ ->
|
||||
when(buttonID) {
|
||||
3 -> closeAllInterfaces(player)
|
||||
}
|
||||
return@on true
|
||||
}
|
||||
|
||||
// after the interface closes
|
||||
onClose(morphIface) { player, _ ->
|
||||
unmorph(player)
|
||||
return@onClose true
|
||||
}
|
||||
}
|
||||
|
||||
// morphs the player
|
||||
private fun morph(player: Player, item: Int) {
|
||||
val morphId = when (item) {
|
||||
Items.RING_OF_STONE_6583 -> stone.random()
|
||||
else -> easterEggs.random()
|
||||
}
|
||||
playAudio(player, Sounds.EASTER06_HUMAN_INTO_EGG_1520)
|
||||
stopWalk(player)
|
||||
closeAllInterfaces(player)
|
||||
player.appearance.transformNPC(morphId)
|
||||
openInterface(player, morphIface)
|
||||
}
|
||||
|
||||
// unmorphs the player
|
||||
private fun unmorph(player: Player) {
|
||||
player.appearance.transformNPC(-1)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
package content.global.handlers.item;
|
||||
|
||||
import core.cache.def.impl.ItemDefinition;
|
||||
import core.game.component.CloseEvent;
|
||||
import core.game.component.Component;
|
||||
import core.game.component.ComponentDefinition;
|
||||
import core.game.component.ComponentPlugin;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.world.GameWorld;
|
||||
import core.plugin.Initializable;
|
||||
import core.plugin.Plugin;
|
||||
import core.plugin.ClassScanner;
|
||||
import core.tools.RandomFunction;
|
||||
import org.rs09.consts.Sounds;
|
||||
|
||||
import static core.api.ContentAPIKt.playAudio;
|
||||
|
||||
/**
|
||||
* Handles a morph item.
|
||||
* @author Vexia
|
||||
*/
|
||||
@Initializable
|
||||
public class MorphItemPlugin implements Plugin<Object> {
|
||||
|
||||
/**
|
||||
* The easter egg ids.
|
||||
*/
|
||||
protected static final int[] EASTER_EGG_IDS = new int[] { 3689, 3690, 3691, 3692, 3693, 3694 };
|
||||
|
||||
/**
|
||||
* The morph component.
|
||||
*/
|
||||
private static final Component COMPONENT = new Component(375).setCloseEvent(new CloseEvent() {
|
||||
|
||||
@Override
|
||||
public boolean close(Player player, Component c) {
|
||||
unmorph(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
ItemDefinition.forId(7927).getHandlers().put("equipment", this);
|
||||
ItemDefinition.forId(6583).getHandlers().put("equipment", this);
|
||||
ClassScanner.definePlugin(new MorphInterfacePlugin());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object fireEvent(String identifier, Object... args) {
|
||||
final Player player = (Player) args[0];
|
||||
final Item item = (Item) args[1];
|
||||
switch (identifier) {
|
||||
case "equip":
|
||||
morph(player, item);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Morphs the player.
|
||||
* @param player the player.
|
||||
* @param item the item.
|
||||
*/
|
||||
private void morph(Player player, Item item) {
|
||||
int morphId = item.getId() == 6583 ? 2626 : EASTER_EGG_IDS[RandomFunction.random(EASTER_EGG_IDS.length)];
|
||||
playAudio(player, 1520);
|
||||
player.getInterfaceManager().close();
|
||||
player.getAppearance().transformNPC(morphId);
|
||||
player.getInterfaceManager().removeTabs(0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14);
|
||||
player.getLocks().lockMovement(GameWorld.getTicks() + 900000000);
|
||||
player.getLocks().lockInteractions(GameWorld.getTicks() + 90000000);
|
||||
player.getLocks().lockTeleport(GameWorld.getTicks() + 900000000);
|
||||
player.getInterfaceManager().openSingleTab(COMPONENT);
|
||||
player.getAppearance().sync();
|
||||
player.getWalkingQueue().reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmorphs the player.
|
||||
* @param player the player.
|
||||
*/
|
||||
private static void unmorph(Player player) {
|
||||
player.getAppearance().transformNPC(-1);
|
||||
player.unlock();
|
||||
player.getInterfaceManager().restoreTabs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the morph interface plugin.
|
||||
* @author Vexia
|
||||
*/
|
||||
public class MorphInterfacePlugin extends ComponentPlugin {
|
||||
|
||||
@Override
|
||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
||||
ComponentDefinition.forId(375).setPlugin(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) {
|
||||
player.getInterfaceManager().closeSingleTab();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue