Skip to content
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
2 changes: 1 addition & 1 deletion src/net/incoming-packets/character-design-packet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { incomingPacket } from '../incoming-packet';
import { Player } from '../../world/actor/player/player';
import { RsBuffer } from '@server/net/rs-buffer';
import { widgetIds } from '../../world/actor/player/widget';
import { widgetIds } from '../../world/config/widget';

export const characterDesignPacket: incomingPacket = (player: Player, packetId: number, packetSize: number, packet: RsBuffer): void => {
if(!player.activeWidget || player.activeWidget.widgetId !== widgetIds.characterDesign) {
Expand Down
2 changes: 1 addition & 1 deletion src/net/incoming-packets/drop-item-packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { incomingPacket } from '../incoming-packet';
import { Player } from '../../world/actor/player/player';
import { RsBuffer } from '@server/net/rs-buffer';
import { logger } from '@runejs/logger/dist/logger';
import { widgetIds } from '../../world/actor/player/widget';
import { widgetIds } from '../../world/config/widget';
import { dropItemAction } from '@server/world/actor/player/action/drop-item-action';

export const dropItemPacket: incomingPacket = (player: Player, packetId: number, packetSize: number, packet: RsBuffer): void => {
Expand Down
2 changes: 1 addition & 1 deletion src/net/incoming-packets/item-equip-packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { incomingPacket } from '../incoming-packet';
import { Player } from '../../world/actor/player/player';
import { RsBuffer } from '@server/net/rs-buffer';
import { logger } from '@runejs/logger/dist/logger';
import { widgetIds } from '../../world/actor/player/widget';
import { widgetIds } from '../../world/config/widget';
import { equipItemAction } from '../../world/actor/player/action/equip-item-action';

export const itemEquipPacket: incomingPacket = (player: Player, packetId: number, packetSize: number, packet: RsBuffer): void => {
Expand Down
2 changes: 1 addition & 1 deletion src/net/incoming-packets/item-on-item-packet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { incomingPacket } from '../incoming-packet';
import { Player } from '../../world/actor/player/player';
import { RsBuffer } from '@server/net/rs-buffer';
import { widgetIds } from '@server/world/actor/player/widget';
import { widgetIds } from '@server/world/config/widget';
import { logger } from '@runejs/logger/dist/logger';
import { itemOnItemAction } from '@server/world/actor/player/action/item-on-item-action';

Expand Down
2 changes: 1 addition & 1 deletion src/net/incoming-packets/item-option-1-packet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { incomingPacket } from '../incoming-packet';
import { RsBuffer } from '@server/net/rs-buffer';
import { Player } from '../../world/actor/player/player';
import { widgetIds } from '../../world/actor/player/widget';
import { widgetIds } from '../../world/config/widget';
import { logger } from '@runejs/logger/dist/logger';
import { unequipItemAction } from '../../world/actor/player/action/unequip-item-action';
import { ItemContainer } from '@server/world/items/item-container';
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/buttons/logout-button-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { buttonAction } from '@server/world/actor/player/action/button-action';
import { ActionType, RunePlugin } from '@server/plugins/plugin';
import { widgetIds } from '@server/world/config/widget';

export const action: buttonAction = (details) => {
const { player } = details;
player.logout();
};

export default new RunePlugin({ type: ActionType.BUTTON, widgetId: 182, buttonIds: 6, action });
export default new RunePlugin({ type: ActionType.BUTTON, widgetId: widgetIds.logoutTab, buttonIds: 6, action });
3 changes: 2 additions & 1 deletion src/plugins/buttons/player-setting-button-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { buttonAction } from '@server/world/actor/player/action/button-action';
import { ActionType, RunePlugin } from '@server/plugins/plugin';
import { widgetIds } from '@server/world/config/widget';

const buttonIds: number[] = [
0, // walk/run
Expand All @@ -19,4 +20,4 @@ export const action: buttonAction = (details) => {
player.settingChanged(buttonId);
};

export default new RunePlugin({ type: ActionType.BUTTON, widgetId: 261, buttonIds: buttonIds, action });
export default new RunePlugin({ type: ActionType.BUTTON, widgetId: widgetIds.settingsTab, buttonIds: buttonIds, action });
4 changes: 2 additions & 2 deletions src/plugins/npcs/lumbridge/bob-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { npcAction } from '@server/world/actor/player/action/npc-action';
import { openShop } from '@server/world/actor/player/action/shop-action';
import { ActionType, RunePlugin } from '@server/plugins/plugin';
import { npcIds } from '@server/world/config/npc-ids';

const tradeAction: npcAction = (details) => {
const { player, npc } = details;
openShop(details.player, 'BOBS_AXES');
};

export default new RunePlugin({ type: ActionType.NPC_ACTION, npcIds: 519, options: 'trade', walkTo: true, action: tradeAction });
export default new RunePlugin({ type: ActionType.NPC_ACTION, npcIds: npcIds.lumbridgeBob, options: 'trade', walkTo: true, action: tradeAction });
3 changes: 2 additions & 1 deletion src/plugins/npcs/lumbridge/hans-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { npcAction } from '@server/world/actor/player/action/npc-action';
import { dialogueAction, DialogueEmote } from '@server/world/actor/player/action/dialogue-action';
import { ActionType, RunePlugin } from '@server/plugins/plugin';
import { npcIds } from '@server/world/config/npc-ids';

const action: npcAction = (details) => {
const { player, npc } = details;
Expand Down Expand Up @@ -49,4 +50,4 @@ const action: npcAction = (details) => {
});
};

export default new RunePlugin({ type: ActionType.NPC_ACTION, npcIds: 0, options: 'talk-to', walkTo: true, action });
export default new RunePlugin({ type: ActionType.NPC_ACTION, npcIds: npcIds.hans, options: 'talk-to', walkTo: true, action });
4 changes: 2 additions & 2 deletions src/plugins/npcs/lumbridge/shopkeeper-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { npcAction } from '@server/world/actor/player/action/npc-action';
import { openShop } from '@server/world/actor/player/action/shop-action';
import { ActionType, RunePlugin } from '@server/plugins/plugin';
import { npcIds } from '@server/world/config/npc-ids';


const action: npcAction = (details) => {
const { player, npc } = details;
openShop(details.player, 'LUMBRIDGE_GENERAL_STORE');
};

export default new RunePlugin({ type: ActionType.NPC_ACTION, npcIds: 520, options: 'trade', walkTo: true, action });
export default new RunePlugin({ type: ActionType.NPC_ACTION, npcIds: npcIds.shopKeeper, options: 'trade', walkTo: true, action });
31 changes: 17 additions & 14 deletions src/plugins/objects/cows/cow-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
import { objectAction } from '@server/world/actor/player/action/object-action';
import { gameCache, world } from '@server/game-server';
import { gameCache } from '@server/game-server';
import { ActionType, RunePlugin } from '@server/plugins/plugin';
import { dialogueAction, DialogueEmote } from '@server/world/actor/player/action/dialogue-action';
import { Npc } from '@server/world/actor/npc/npc';
import { npcIds } from '@server/world/config/npc-ids';
import { animationIds } from '@server/world/config/animation-ids';
import { soundIds } from '@server/world/config/sound-ids';
import { itemIds } from '@server/world/config/item-ids';
import { objectIds } from '@server/world/config/object-ids';


export const action: objectAction = (details) => {
const {player, option, objectDefinition, object} = details;
const emptyBucketItem = gameCache.itemDefinitions.get(1925);
const milkBucketItem = gameCache.itemDefinitions.get(1927);
const emptyBucketItem = gameCache.itemDefinitions.get(itemIds.bucket);

if(player.hasItemInInventory(emptyBucketItem.id)) {
player.playAnimation(2305);
player.outgoingPackets.playSound(372, 7);
player.removeFirstItem(emptyBucketItem.id);
player.giveItem(milkBucketItem.id);
if(player.hasItemInInventory(itemIds.bucket)) {
player.playAnimation(animationIds.milkCow);
player.outgoingPackets.playSound(soundIds.milkCow, 7);
player.removeFirstItem(itemIds.bucket);
player.giveItem(itemIds.bucketOfMilk);
player.outgoingPackets.chatboxMessage(`You ${option} the ${objectDefinition.name} and receive some milk.`);
} else {
dialogueAction(player)
.then(d => d.npc(3807, DialogueEmote.LAUGH_1, [`Tee hee! You've never milked a cow before, have you?`]))
.then(d => d.npc(npcIds.gillieGroats, DialogueEmote.LAUGH_1, [`Tee hee! You've never milked a cow before, have you?`]))
.then(d => d.player(DialogueEmote.CALM_TALK_1, ['Erm... No. How could you tell?']))
.then(d => d.npc(3807, DialogueEmote.LAUGH_2, [`Because you're spilling milk all over the floor. What a`, 'waste! You need something to hold the milk.']))
.then(d => d.npc(npcIds.gillieGroats, DialogueEmote.LAUGH_2, [`Because you're spilling milk all over the floor. What a`, 'waste! You need something to hold the milk.']))
.then(d => d.player(DialogueEmote.CONSIDERING, [`Ah yes, I really should have guessed that one, shouldn't`, 'I?']))
.then(d => d.npc(3807, DialogueEmote.LAUGH_2, [`You're from the city aren't you... Try it again with a`, `${emptyBucketItem.name.toLowerCase()}.`]))
.then(d => d.npc(npcIds.gillieGroats, DialogueEmote.LAUGH_2, [`You're from the city aren't you... Try it again with a`, `${emptyBucketItem.name.toLowerCase()}.`]))
.then(d => d.player(DialogueEmote.CALM_TALK_2, [`Right, I'll do that.`]))
.then(d => {
d.close();
Expand All @@ -32,8 +35,8 @@ export const action: objectAction = (details) => {

export default new RunePlugin({
type: ActionType.OBJECT_ACTION,
objectIds: [8689],
options: ['milk'],
objectIds: objectIds.milkableCow,
options: 'milk',
walkTo: true,
action
});
3 changes: 2 additions & 1 deletion src/plugins/objects/doors/door-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { world } from '@server/game-server';
import { Chunk } from '@server/world/map/chunk';
import { objectAction } from '@server/world/actor/player/action/object-action';
import { ActionType, RunePlugin } from '@server/plugins/plugin';
import { soundIds } from '@server/world/config/sound-ids';

// @TODO move to yaml config
const doors = [
Expand Down Expand Up @@ -89,7 +90,7 @@ export const action: objectAction = (details): void => {

world.chunkManager.toggleObjects(replacementDoor, door, endPosition, position, replacementDoorChunk, startDoorChunk, !cacheOriginal);
// 70 = close gate, 71 = open gate, 62 = open door, 60 = close door
player.outgoingPackets.playSound(opening ? 62 : 60, 7);
player.outgoingPackets.playSound(opening ? soundIds.openDoor : soundIds.closeDoor, 7);
};

export default new RunePlugin({ type: ActionType.OBJECT_ACTION, objectIds: [1530, 4465, 4467, 3014, 3017, 3018,
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/objects/doors/gate-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { world } from '@server/game-server';
import { ModifiedLandscapeObject } from '@server/world/map/landscape-object';
import { objectAction } from '@server/world/actor/player/action/object-action';
import { ActionType, RunePlugin } from '@server/plugins/plugin';
import { soundIds } from '@server/world/config/sound-ids';

const gates = [
{
Expand All @@ -25,7 +26,7 @@ const action: objectAction = (details) => {

world.chunkManager.toggleObjects(metadata.originalMain, metadata.main, metadata.originalMainPosition, metadata.mainPosition, metadata.originalMainChunk, metadata.mainChunk, true);
world.chunkManager.toggleObjects(metadata.originalSecond, metadata.second, metadata.originalSecondPosition, metadata.secondPosition, metadata.originalSecondChunk, metadata.secondChunk, true);
player.outgoingPackets.playSound(66, 7); // @TODO find correct gate closing sound
player.outgoingPackets.playSound(soundIds.closeGate, 7);
} else {
let details = gates.find(g => g.main === gate.objectId);
let clickedSecondary = false;
Expand Down Expand Up @@ -205,7 +206,7 @@ const action: objectAction = (details) => {

world.chunkManager.toggleObjects(newHinge, gate, newPosition, position, newHingeChunk, hingeChunk, !cacheOriginal);
world.chunkManager.toggleObjects(newSecond, secondGate, newSecondPosition, gateSecondPosition, newSecondChunk, gateSecondChunk, !cacheOriginal);
player.outgoingPackets.playSound(67, 7); // @TODO find correct gate opening sound
player.outgoingPackets.playSound(soundIds.openGate, 7);
}
};

Expand Down
22 changes: 13 additions & 9 deletions src/plugins/skills/firemaking-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ import { WorldItem } from '@server/world/items/world-item';
import { Position } from '@server/world/position';
import { randomBetween } from '@server/util/num';
import { ActionType, RunePlugin } from '@server/plugins/plugin';
import { objectIds } from '@server/world/config/object-ids';
import { itemIds } from '@server/world/config/item-ids';
import { soundIds } from '@server/world/config/sound-ids';
import { animationIds } from '@server/world/config/animation-ids';

const logs = [
{
logId: 1511,
logId: itemIds.logs,
requiredLevel: 1,
burnExp: 40
}
Expand All @@ -38,7 +42,7 @@ const fireDuration = (): number => {
const lightFire = (player: Player, position: Position, worldItemLog: WorldItem, burnExp: number): void => {
world.chunkManager.removeWorldItem(worldItemLog);
const fireObject: LandscapeObject = {
objectId: 2732,
objectId: objectIds.fire,
x: position.x,
y: position.y,
level: position.level,
Expand All @@ -58,7 +62,7 @@ const lightFire = (player: Player, position: Position, worldItemLog: WorldItem,
}
}
world.chunkManager.addTemporaryLandscapeObject(fireObject, position, fireDuration()).then(() => {
world.chunkManager.spawnWorldItem({ itemId: 592, amount: 1 }, position, null, 300);
world.chunkManager.spawnWorldItem({ itemId: itemIds.ashes, amount: 1 }, position, null, 300);
});

player.face(position, false);
Expand All @@ -73,8 +77,8 @@ const action: itemOnItemAction = (details) => {
return;
}

const log = usedItem.itemId !== 590 ? usedItem : usedWithItem;
const removeFromSlot = usedItem.itemId !== 590 ? usedSlot : usedWithSlot;
const log = usedItem.itemId !== itemIds.tinderbox ? usedItem : usedWithItem;
const removeFromSlot = usedItem.itemId !== itemIds.tinderbox ? usedSlot : usedWithSlot;
const skillInfo = logs.find(l => l.logId === log.itemId);
const position = player.position;

Expand Down Expand Up @@ -114,20 +118,20 @@ const action: itemOnItemAction = (details) => {
// @TODO check for tinderbox in-case it was removed

if(elapsedTicks === 0 || elapsedTicks % 12 === 0) {
player.playAnimation(733);
player.playAnimation(animationIds.lightingFire);
}

canLightFire = elapsedTicks > 10 && canLight(skillInfo.requiredLevel, player.skills.values[Skill.WOODCUTTING].level);

if(!canLightFire && (elapsedTicks === 0 || elapsedTicks % 4 === 0)) {
player.outgoingPackets.playSound(2599, 10, 0);
player.outgoingPackets.playSound(soundIds.lightingFire, 10, 0);
} else if(canLightFire) {
player.outgoingPackets.playSound(2594, 7);
player.outgoingPackets.playSound(soundIds.fireLit, 7);
}

elapsedTicks++;
});
}
};

export default new RunePlugin({ type: ActionType.ITEM_ON_ITEM, items: [ { item1: 590, item2: 1511 } ], action });
export default new RunePlugin({ type: ActionType.ITEM_ON_ITEM, items: logs.map(log => ({item1: itemIds.tinderbox, item2: log.logId})), action });
44 changes: 14 additions & 30 deletions src/plugins/skills/skill-guide-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { readFileSync } from 'fs';
import { ActionType, RunePlugin } from '@server/plugins/plugin';
import { Player } from '@server/world/actor/player/player';
import { widgetAction } from '@server/world/actor/player/action/widget-action';
import { widgetIds } from '@server/world/config/widget';

// @TODO fix me!

Expand Down Expand Up @@ -52,66 +53,49 @@ const buttonIds = guides.map(g => g.id);
function loadGuide(player: Player, guideId: number, subGuideId: number = 0, refreshSidebar: boolean = true): void {
let guide: SkillGuide = guides.find(g => g.id === guideId);

/*if(!refreshSidebar) {
const activeSkillGuide = player.metadata['activeSkillGuide'];
if(!activeSkillGuide) {
return;
}

guide = guides.find(g => g.id === activeSkillGuide);
subGuideIndex = sidebarTextIds.indexOf(buttonId);

if(subGuideIndex >= guide.subGuides.length) {
return;
}

buttonId = activeSkillGuide;
refreshSidebar = false;
}*/

if(refreshSidebar) {
player.outgoingPackets.updateWidgetString(308, 133, guide.members ? 'Members only skill' : '');
player.outgoingPackets.updateWidgetString(widgetIds.skillGuide, 133, guide.members ? 'Members only skill' : '');

for(let i = 0; i < sidebarTextIds.length; i++) {
const sidebarId = sidebarIds[i];
let hide: boolean = true;

if(i >= guide.subGuides.length) {
player.outgoingPackets.updateWidgetString(308, sidebarTextIds[i], '');
player.outgoingPackets.updateWidgetString(widgetIds.skillGuide, sidebarTextIds[i], '');
hide = true;
} else {
player.outgoingPackets.updateWidgetString(308, sidebarTextIds[i], guide.subGuides[i].name);
player.outgoingPackets.updateWidgetString(widgetIds.skillGuide, sidebarTextIds[i], guide.subGuides[i].name);
hide = false;
}

if(sidebarId !== -1) {
// Apparently you can never have only TWO subguides...
// Because childId 98 deletes both options 2 AND 3. So, good thing there are no guides with only 2 sections, I guess?...
// Verified this in an interface editor, and they are indeed grouped in a single layer for some reason...
player.outgoingPackets.toggleWidgetVisibility(308, sidebarIds[i], hide);
player.outgoingPackets.toggleWidgetVisibility(widgetIds.skillGuide, sidebarIds[i], hide);
}
}
}

const subGuide: SkillSubGuide = guide.subGuides[subGuideId];

player.outgoingPackets.updateWidgetString(308, 1, guide.name + ' - ' + subGuide.name);
player.outgoingPackets.updateWidgetString(widgetIds.skillGuide, 1, guide.name + ' - ' + subGuide.name);

const itemIds: number[] = subGuide.lines.map(g => g.itemId).concat(new Array(30 - subGuide.lines.length).fill(null));
player.outgoingPackets.sendUpdateAllWidgetItemsById({ widgetId: 308, containerId: 132 }, itemIds);
player.outgoingPackets.sendUpdateAllWidgetItemsById({ widgetId: widgetIds.skillGuide, containerId: 132 }, itemIds);

for(let i = 0; i < 30; i++) {
if(subGuide.lines.length <= i) {
player.outgoingPackets.updateWidgetString(308, 5 + i, '');
player.outgoingPackets.updateWidgetString(308, 45 + i, '');
player.outgoingPackets.updateWidgetString(widgetIds.skillGuide, 5 + i, '');
player.outgoingPackets.updateWidgetString(widgetIds.skillGuide, 45 + i, '');
} else {
player.outgoingPackets.updateWidgetString(308, 5 + i, subGuide.lines[i].level.toString());
player.outgoingPackets.updateWidgetString(308, 45 + i, subGuide.lines[i].text);
player.outgoingPackets.updateWidgetString(widgetIds.skillGuide, 5 + i, subGuide.lines[i].level.toString());
player.outgoingPackets.updateWidgetString(widgetIds.skillGuide, 45 + i, subGuide.lines[i].text);
}
}

player.activeWidget = {
widgetId: 308,
widgetId: widgetIds.skillGuide,
type: 'SCREEN',
closeOnWalk: false
};
Expand Down Expand Up @@ -143,6 +127,6 @@ export const openSubGuideAction: widgetAction = (details) => {
};

export default new RunePlugin([
{ type: ActionType.BUTTON, widgetId: 320, buttonIds, action: openGuideAction },
{ type: ActionType.WIDGET_ACTION, widgetIds: 308, childIds: sidebarTextIds, optionId: 0, action: openSubGuideAction }
{ type: ActionType.BUTTON, widgetId: widgetIds.skillsTab, buttonIds, action: openGuideAction },
{ type: ActionType.WIDGET_ACTION, widgetIds: widgetIds.skillGuide, childIds: sidebarTextIds, optionId: 0, action: openSubGuideAction }
]);
2 changes: 1 addition & 1 deletion src/world/actor/player/action/buy-item-action.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Player } from '@server/world/actor/player/player';
import { gameCache } from '@server/game-server';
import { widgetIds } from '@server/world/actor/player/widget';
import { widgetIds } from '@server/world/config/widget';

export const buyItemAction = (player: Player, itemId: number, amount: number, slot: number, interfaceId: number) => {
const purchasedItem = gameCache.itemDefinitions.get(itemId);
Expand Down
Loading