Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

home teleport and player graphics command #91

Merged
merged 3 commits into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions src/plugins/buttons/magic-teleports-plugin.ts
Original file line number Diff line number Diff line change
@@ -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});
28 changes: 28 additions & 0 deletions src/plugins/commands/player-graphics-command.ts
Original file line number Diff line number Diff line change
@@ -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
});
6 changes: 6 additions & 0 deletions src/world/config/animation-ids.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export const animationIds = {
milkCow: 2305,
lightingFire: 733,
homeTeleportDraw: 4847,
homeTeleportSit: 4850,
homeTeleportPullOutAndReadBook: 4853,
homeTeleportReadBookAndGlowCircle: 4855,
homeTeleport: 4857,

};
6 changes: 6 additions & 0 deletions src/world/config/gfx-ids.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const gfxIds = {
homeTeleportDraw: 800,
homeTeleportPullOutBook: 802,
homeTeleportCircleGlow: 803,
homeTeleport: 804,
};
4 changes: 4 additions & 0 deletions src/world/config/sound-ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ export const soundIds = {
closeDoor: 60,
openGate: 67,
closeGate: 66,
homeTeleportDraw: 193,
homeTeleportSit: 196,
homeTeleportPullOutBook: 194,
homeTeleportCircleGlowAndTeleport: 195,
};