Skip to content

Commit 3dca8b5

Browse files
KatilithKatilith
andauthored
Command Improvements (#460)
* Adds new commands goup/up, godown/down, setheightlevel/heightlevel/hl to change player height level easily. Also adds the lumbridge bank booth to the list of bank booths * Removed hans cry emote and overhead text to prevent client crash * Fixes issue with the travel command picking incorrect locations * Fixes rotten potato banking and bank command --------- Co-authored-by: Katilith <[email protected]>
1 parent 02e3b06 commit 3dca8b5

6 files changed

Lines changed: 90 additions & 46 deletions

File tree

src/engine/world/config/object-ids.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export const objectIds = {
33
milkableCow: 8689,
44
fire: 2732,
55
spinningWheel: 2644,
6-
bankBooth: 2213,
6+
bankBooth: [2213,18491],
77
depositBox: 9398,
88
shortCuts: {
99
stile: 12982,

src/engine/world/config/travel-locations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ export class TravelLocations {
3535
}
3636

3737
public find(search: string): TravelLocation | null {
38-
search = search.toLowerCase().trim();
38+
search = search.toLowerCase().trim().replace(/_/g, ' ');
3939
for (const location of this.locations) {
40-
if (location.key.indexOf(search) >= 0) {
40+
if (location.key.toLowerCase() === search) {
4141
return location;
4242
}
4343
}

src/plugins/commands/bank-command.plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { objectIds } from '@engine/world/config/object-ids';
66

77
const action: commandActionHandler = details => {
88
const interactionActions = getActionHooks<ObjectInteractionActionHook>('object_interaction').filter(plugin =>
9-
advancedNumberHookFilter(plugin.objectIds, objectIds.bankBooth, plugin.options, 'use-quickly'),
9+
advancedNumberHookFilter(plugin.objectIds, objectIds.bankBooth[0], plugin.options, 'use-quickly'),
1010
);
1111
interactionActions.forEach(plugin => {
1212
if (!plugin.handler) {
@@ -16,7 +16,7 @@ const action: commandActionHandler = details => {
1616
plugin.handler({
1717
player: details.player,
1818
object: {
19-
objectId: objectIds.bankBooth,
19+
objectId: objectIds.bankBooth[0],
2020
level: details.player.position.level,
2121
x: details.player.position.x,
2222
y: details.player.position.y,

src/plugins/commands/teleport-command.plugin.ts

Lines changed: 80 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,95 @@ import { activeWorld } from '@engine/world';
33
import { Position } from '@engine/world/position';
44

55
const action: commandActionHandler = details => {
6-
const { player, args } = details;
6+
const { player, args } = details;
77

8-
const x = args.XorPlayerName;
8+
const x = args.XorPlayerName;
99

10-
if (typeof x === 'string') {
11-
const playerWithName = activeWorld.findPlayer(x);
12-
if (playerWithName) {
13-
player.teleport(playerWithName.position);
14-
return;
15-
}
10+
if (typeof x === 'string') {
11+
const playerWithName = activeWorld.findPlayer(x);
12+
if (playerWithName) {
13+
player.teleport(playerWithName.position);
14+
return;
1615
}
16+
}
1717

18-
const xCoord: number = typeof x === 'string' ? parseInt(x, 10) : x;
18+
const xCoord: number = typeof x === 'string' ? parseInt(x, 10) : x;
1919

20-
if (isNaN(xCoord)) {
21-
return;
22-
}
23-
const y: number = args.y as number;
24-
const level: number = args.level as number;
20+
if (isNaN(xCoord)) {
21+
return;
22+
}
23+
const y: number = args.y as number;
24+
const level: number = args.level as number;
25+
26+
player.teleport(new Position(xCoord, y, level));
27+
};
28+
29+
const goUpAction: commandActionHandler = details => {
30+
const { player } = details;
2531

26-
player.teleport(new Position(xCoord, y, level));
32+
player.teleport(new Position(player.position.x, player.position.y, player.position.level + 1));
2733
};
2834

35+
const goDownAction: commandActionHandler = details => {
36+
const { player } = details;
37+
38+
if (player.position.level > 0) {
39+
player.teleport(new Position(player.position.x, player.position.y, player.position.level - 1));
40+
}
41+
};
42+
43+
const setLevelCommand: commandActionHandler = details => {
44+
const { player, args } = details;
45+
const level: number = args.level as number;
46+
if (!isNaN(level) && level >= 0 && level <= 255) {
47+
player.teleport(new Position(player.position.x, player.position.y, level));
48+
}
49+
}
50+
2951
export default {
30-
pluginId: 'rs:teleport_command_plugin',
31-
hooks: [
52+
pluginId: 'rs:teleport_command_plugin',
53+
hooks: [
54+
{
55+
type: 'player_command',
56+
commands: [ 'move', 'goto', 'teleport', 'tele', 'moveto', 'setpos' ],
57+
args: [
3258
{
33-
type: 'player_command',
34-
commands: ['move', 'goto', 'teleport', 'tele', 'moveto', 'setpos'],
35-
args: [
36-
{
37-
name: 'XorPlayerName',
38-
type: 'string',
39-
},
40-
{
41-
name: 'y',
42-
type: 'number',
43-
defaultValue: 3222,
44-
},
45-
{
46-
name: 'level',
47-
type: 'number',
48-
defaultValue: 0,
49-
},
50-
],
51-
handler: action,
59+
name: 'XorPlayerName',
60+
type: 'string',
5261
},
53-
],
62+
{
63+
name: 'y',
64+
type: 'number',
65+
defaultValue: 3222,
66+
},
67+
{
68+
name: 'level',
69+
type: 'number',
70+
defaultValue: 0,
71+
},
72+
],
73+
handler: action,
74+
},
75+
{
76+
type: 'player_command',
77+
commands: [ 'up', 'goup' ],
78+
handler: goUpAction,
79+
},
80+
{
81+
type: 'player_command',
82+
commands: [ 'down', 'godown' ],
83+
handler: goDownAction,
84+
},
85+
{
86+
type: 'player_command',
87+
commands: [ 'setheightlevel', 'heightlevel', 'hl' ],
88+
args: [
89+
{
90+
name: 'level',
91+
type: 'number',
92+
},
93+
],
94+
handler: setLevelCommand,
95+
}
96+
],
5497
};

src/plugins/items/rotten-potato/hooks/rotten-potato-peel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { openTravel } from '@plugins/items/rotten-potato/helpers/rotten-potato-t
99

1010
function openBank(player: Player) {
1111
const interactionActions = getActionHooks<ObjectInteractionActionHook>('object_interaction').filter(plugin =>
12-
advancedNumberHookFilter(plugin.objectIds, objectIds.bankBooth, plugin.options, 'use-quickly'),
12+
advancedNumberHookFilter(plugin.objectIds, objectIds.bankBooth[0], plugin.options, 'use-quickly'),
1313
);
1414
interactionActions.forEach(plugin => {
1515
if (!plugin.handler) {
@@ -19,7 +19,7 @@ function openBank(player: Player) {
1919
plugin.handler({
2020
player: player,
2121
object: {
22-
objectId: objectIds.bankBooth,
22+
objectId: objectIds.bankBooth[0],
2323
level: player.position.level,
2424
x: player.position.x,
2525
y: player.position.y,

src/plugins/npcs/lumbridge/hans.plugin.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ const handler = async ({ player, npc }) => {
4545

4646
if (dialogueSuccessful) {
4747
if (sadEnding) {
48-
npc.playAnimation(animationIds.cry);
49-
npc.say(`Jerk!`);
48+
// @todo These appear to be broken, debug
49+
// npc.playAnimation(animationIds.cry);
50+
// npc.say(`Jerk!`);
5051
player.sendMessage(`Hans wanders off rather dejectedly.`);
5152
} else {
5253
player.sendMessage(`Hans wanders off aimlessly through the courtyard.`);

0 commit comments

Comments
 (0)