diff --git a/src/plugins/buttons/magic-teleports-plugin.ts b/src/plugins/buttons/magic-teleports-plugin.ts new file mode 100644 index 000000000..7b8fc5b13 --- /dev/null +++ b/src/plugins/buttons/magic-teleports-plugin.ts @@ -0,0 +1,76 @@ +import { buttonAction, ButtonActionDetails } from '@server/world/actor/player/action/button-action'; +import { ActionType, RunePlugin } from '@server/plugins/plugin'; +import { Player } from '@server/world/actor/player/player'; +import { World } from '@server/world/world'; +import { loopingAction } from '@server/world/actor/player/action/action'; +import { Skill } from '@server/world/actor/skills'; +import { Position } from '@server/world/position'; +import { animationIds } from '@server/world/config/animation-ids'; +import { soundIds } from '@server/world/config/sound-ids'; +import { gfxIds } from '@server/world/config/gfx-ids'; + +enum Teleports { + Home = 591, + Varrock = 12, + Lumbridge = 15, + Falador = 18, + Camelot = 22, + Ardougne = 388, + Watchtower = 389, + Trollheim = 492, + Ape_atoll = 569 +} + +const buttonIds: number[] = [ + 591, // Home Teleport +]; + +function HomeTeleport(player: Player): void { + let elapsedTicks = 0; + const loop = loopingAction(player); + loop.event.subscribe(() => { + + if (elapsedTicks === 0) { + player.playAnimation(animationIds.homeTeleportDraw); + player.playGraphics({id: gfxIds.homeTeleportDraw, delay: 0, height: 0}); + player.outgoingPackets.playSound(soundIds.homeTeleportDraw, 10); + } + if (elapsedTicks === 7) { + player.playAnimation(animationIds.homeTeleportPullOutAndReadBook); + player.outgoingPackets.playSound(soundIds.homeTeleportSit, 10); + } + if (elapsedTicks === 12) { + player.playAnimation(animationIds.homeTeleportSit); + player.playGraphics({id: gfxIds.homeTeleportPullOutBook, delay: 0, height: 0}); + player.outgoingPackets.playSound(soundIds.homeTeleportPullOutBook, 10); + } + if (elapsedTicks === 16) { + player.playAnimation(animationIds.homeTeleportReadBookAndGlowCircle); + player.playGraphics({id: gfxIds.homeTeleportCircleGlow, delay: 0, height: 0}); + player.outgoingPackets.playSound(soundIds.homeTeleportCircleGlowAndTeleport, 10); + + } + if (elapsedTicks === 20) { + player.playAnimation(animationIds.homeTeleport); + player.playGraphics({id: gfxIds.homeTeleport, delay: 0, height: 0}); + } + if (elapsedTicks === 22) { + player.teleport(new Position(3218, 3218)); + loop.cancel(); + return; + } + elapsedTicks++; + }); +} + +export const action: buttonAction = (details) => { + const {player, buttonId} = details; + + switch (buttonId) { + case Teleports.Home: + HomeTeleport(player); + break; + } +}; + +export default new RunePlugin({type: ActionType.BUTTON, widgetId: 192, buttonIds: buttonIds, action}); diff --git a/src/plugins/commands/player-graphics-command.ts b/src/plugins/commands/player-graphics-command.ts new file mode 100644 index 000000000..052edddf7 --- /dev/null +++ b/src/plugins/commands/player-graphics-command.ts @@ -0,0 +1,28 @@ +import { ActionType, RunePlugin } from '@server/plugins/plugin'; +import { commandAction } from '@server/world/actor/player/action/input-command-action'; + +const action: commandAction = (details) => { + const { player, args } = details; + + const graphicsId: number = args.graphicsId as number; + const height: number = args.height as number; + + player.playGraphics({id: graphicsId, delay: 0, height: height}); +}; + +export default new RunePlugin({ + type: ActionType.COMMAND, + commands: [ 'gfx', 'graphics'], + args: [ + { + name: 'graphicsId', + type: 'number' + }, + { + name: 'height', + type: 'number', + defaultValue: 120 + } + ], + action +}); diff --git a/src/world/config/animation-ids.ts b/src/world/config/animation-ids.ts index baa9bcff1..25e6b4a40 100644 --- a/src/world/config/animation-ids.ts +++ b/src/world/config/animation-ids.ts @@ -1,4 +1,10 @@ export const animationIds = { milkCow: 2305, lightingFire: 733, + homeTeleportDraw: 4847, + homeTeleportSit: 4850, + homeTeleportPullOutAndReadBook: 4853, + homeTeleportReadBookAndGlowCircle: 4855, + homeTeleport: 4857, + }; diff --git a/src/world/config/gfx-ids.ts b/src/world/config/gfx-ids.ts new file mode 100644 index 000000000..c3d8354d4 --- /dev/null +++ b/src/world/config/gfx-ids.ts @@ -0,0 +1,6 @@ +export const gfxIds = { + homeTeleportDraw: 800, + homeTeleportPullOutBook: 802, + homeTeleportCircleGlow: 803, + homeTeleport: 804, +}; diff --git a/src/world/config/sound-ids.ts b/src/world/config/sound-ids.ts index e93c13a18..14f74abc6 100644 --- a/src/world/config/sound-ids.ts +++ b/src/world/config/sound-ids.ts @@ -6,4 +6,8 @@ export const soundIds = { closeDoor: 60, openGate: 67, closeGate: 66, + homeTeleportDraw: 193, + homeTeleportSit: 196, + homeTeleportPullOutBook: 194, + homeTeleportCircleGlowAndTeleport: 195, };