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
8 changes: 3 additions & 5 deletions src/plugins/buttons/magic-teleports-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { buttonAction, ButtonActionDetails } from '@server/world/actor/player/action/button-action';
import { buttonAction } 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';
Expand All @@ -27,9 +25,9 @@ const buttonIds: number[] = [

function HomeTeleport(player: Player): void {
let elapsedTicks = 0;
const loop = loopingAction(player);
loop.event.subscribe(() => {

const loop = loopingAction({ player });
loop.event.subscribe(() => {
if (elapsedTicks === 0) {
player.playAnimation(animationIds.homeTeleportDraw);
player.playGraphics({id: gfxIds.homeTeleportDraw, delay: 0, height: 0});
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/buttons/player-emotes-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const action: buttonAction = (details) => {
const emote = emotes[buttonId];

if(emote.name === 'SKILLCAPE') {
player.outgoingPackets.chatboxMessage(`You need to be wearing a skillcape in order to perform that emote.`);
player.sendMessage(`You need to be wearing a skillcape in order to perform that emote.`);
} else {
if(emote.unlockable) {
const unlockedEmotes: string[] = player.savedMetadata.unlockedEmotes || [];
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/commands/current-position-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { commandAction } from '@server/world/actor/player/action/input-command-a

const action: commandAction = (details) => {
const { player } = details;
player.outgoingPackets.chatboxMessage(`@[ ${player.position.x}, ${player.position.y}, ${player.position.level} ]`);
player.sendMessage(`@[ ${player.position.x}, ${player.position.y}, ${player.position.level} ]`);
};

export default new RunePlugin({
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/commands/give-item-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const action: commandAction = (details) => {
const inventorySlot = player.inventory.getFirstOpenSlot();

if(inventorySlot === -1) {
player.outgoingPackets.chatboxMessage(`You don't have enough free space to do that.`);
player.sendMessage(`You don't have enough free space to do that.`);
return;
}

Expand Down Expand Up @@ -43,7 +43,7 @@ const action: commandAction = (details) => {
}
}

player.outgoingPackets.chatboxMessage(`Added ${actualAmount}x ${itemDefinition.name} to inventory.`);
player.sendMessage(`Added ${actualAmount}x ${itemDefinition.name} to inventory.`);
};

export default new RunePlugin({
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/commands/item-selection-test-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const action: commandAction = (details) => {
return;
}

player.outgoingPackets.chatboxMessage(`Player selected itemId ${choice.itemId} with amount ${choice.amount}`);
player.sendMessage(`Player selected itemId ${choice.itemId} with amount ${choice.amount}`);
}).catch(error => { console.log('action cancelled'); }); // <- CATCH IS REQUIRED FOR ALL ITEM SELECTION ACTIONS!
// Always catch these, as the promise returned by `itemSelectionAction` will reject if actions have been cancelled!
// The console.log is not required, it's only here for testing purposes.
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/commands/reload-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { injectPlugins } from '@server/game-server';
const action: commandAction = (details) => {
const { player } = details;

player.outgoingPackets.chatboxMessage('Reloading plugins...');
player.sendMessage('Reloading plugins...');

injectPlugins()
.then(() => player.outgoingPackets.chatboxMessage('Plugins reloaded.'))
.catch(() => player.outgoingPackets.chatboxMessage('Error reloading plugins.'));
.then(() => player.sendMessage('Plugins reloaded.'))
.catch(() => player.sendMessage('Error reloading plugins.'));
};

export default new RunePlugin({ type: ActionType.COMMAND, commands: 'plugins', action });
2 changes: 1 addition & 1 deletion src/plugins/commands/sound-song-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const songAction: commandAction = (details) => {

const soundAction: commandAction = (details) => {
const { player, args } = details;
player.outgoingPackets.playSound(args.soundId as number, args.volume as number);
player.playSound(args.soundId as number, args.volume as number);
};

const quickSongAction: commandAction = (details) => {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/commands/tracking-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ const quadtreeAction: commandAction = (details) => {

const trackedPlayersAction: commandAction = (details) => {
const { player } = details;
player.outgoingPackets.chatboxMessage(`Tracked players: ${player.trackedPlayers.length}`);
player.sendMessage(`Tracked players: ${player.trackedPlayers.length}`);
};

const trackedNpcsAction: commandAction = (details) => {
const { player } = details;
player.outgoingPackets.chatboxMessage(`Tracked npcs: ${player.trackedNpcs.length}`);
player.sendMessage(`Tracked npcs: ${player.trackedNpcs.length}`);
};

export default new RunePlugin([{
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/equipment/equip-item-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function unequipItem(player: Player, inventory: ItemContainer, equipment: ItemCo
const inventorySlot = inventory.getFirstOpenSlot();

if(inventorySlot === -1) {
player.outgoingPackets.chatboxMessage(`You don't have enough free space to do that.`);
player.sendMessage(`You don't have enough free space to do that.`);
return false;
}

Expand Down Expand Up @@ -40,7 +40,7 @@ export const action: itemAction = (details) => {
}

if(!itemDetails || !itemDetails.equipment || !itemDetails.equipment.slot) {
player.outgoingPackets.chatboxMessage(`Unable to equip item ${itemId}/${itemDetails.name}: Missing equipment data.`);
player.sendMessage(`Unable to equip item ${itemId}/${itemDetails.name}: Missing equipment data.`);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/equipment/equipment-stats-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export function updateBonusStrings(player: Player) {
{ id: 117, text: 'Range', value: player.bonuses.defencive.ranged },
{ id: 119, text: 'Strength', value: player.bonuses.skill.strength },
{ id: 120, text: 'Prayer', value: player.bonuses.skill.prayer },
].forEach(bonus => player.outgoingPackets.updateWidgetString(widgets.equipmentStats.widgetId, bonus.id,
`${bonus.text}: ${bonus.value > 0 ? `+${bonus.value}` : bonus.value}`));
].forEach(bonus => player.modifyWidget(widgets.equipmentStats.widgetId, { childId: bonus.id,
text: `${bonus.text}: ${bonus.value > 0 ? `+${bonus.value}` : bonus.value}` }));
}

export const action: buttonAction = (details) => {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/equipment/unequip-item-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const action: itemAction = (details) => {
const inventorySlot = inventory.getFirstOpenSlot();

if(inventorySlot === -1) {
player.outgoingPackets.chatboxMessage(`You don't have enough free space to do that.`);
player.sendMessage(`You don't have enough free space to do that.`);
return;
}

Expand Down
4 changes: 3 additions & 1 deletion src/plugins/items/buckets/empty-container-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const action: itemAction = (details) => {
}

inventory.remove(itemSlot);
player.outgoingPackets.playSound(soundIds.emptyBucket, 5);
player.playSound(soundIds.emptyBucket, 5);
switch (itemId) {
case itemIds.jugOfWater:
player.giveItem(itemIds.jug);
Expand All @@ -25,6 +25,8 @@ export const action: itemAction = (details) => {
player.giveItem(itemIds.bucket);
break;
}

// @TODO only update necessary slots
player.outgoingPackets.sendUpdateAllWidgetItems(widgets.inventory, inventory);
};

Expand Down
6 changes: 3 additions & 3 deletions src/plugins/items/buckets/fill-container-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ export const action: itemOnObjectAction = (details) => {
const {player, objectDefinition, item} = details;
const itemDef = gameCache.itemDefinitions.get(item.itemId);
if (item.itemId !== itemIds.bucket && WellIds.indexOf(objectDefinition.id) > -1) {
player.outgoingPackets.chatboxMessage(`If I drop my ${itemDef.name.toLowerCase()} down there, I don't think I'm likely to get it back.`);
player.sendMessage(`If I drop my ${itemDef.name.toLowerCase()} down there, I don't think I'm likely to get it back.`);
return;
}

player.playAnimation(animationIds.fillContainerWithWater);
player.outgoingPackets.playSound(soundIds.fillContainerWithWater, 7);
player.playSound(soundIds.fillContainerWithWater, 7);
player.removeFirstItem(item.itemId);
switch (item.itemId) {
case itemIds.bucket:
Expand All @@ -30,7 +30,7 @@ export const action: itemOnObjectAction = (details) => {

}

player.outgoingPackets.chatboxMessage(`You fill the ${itemDef.name.toLowerCase()} from the ${objectDefinition.name.toLowerCase()}.`);
player.sendMessage(`You fill the ${itemDef.name.toLowerCase()} from the ${objectDefinition.name.toLowerCase()}.`);

};

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/items/drop-item-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const action: itemAction = (details) => {

inventory.remove(itemSlot);
player.outgoingPackets.sendUpdateSingleWidgetItem(widgets.inventory, itemSlot, null);
player.outgoingPackets.playSound(soundIds.dropItem, 5);
player.playSound(soundIds.dropItem, 5);
world.spawnWorldItem(item, player.position, player, 300);
};

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/items/pickup-item-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const action: worldItemAction = (details) => {
}

if(slot === -1) {
player.outgoingPackets.chatboxMessage(`You don't have enough free space to do that.`);
player.sendMessage(`You don't have enough free space to do that.`);
return;
}

Expand All @@ -43,7 +43,7 @@ export const action: worldItemAction = (details) => {

inventory.add(item);
player.outgoingPackets.sendUpdateSingleWidgetItem(widgets.inventory, slot, item);
player.outgoingPackets.playSound(soundIds.pickupItem, 3);
player.playSound(soundIds.pickupItem, 3);
};

export default new RunePlugin({
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/items/pots/empty-pot-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const action: itemAction = (details) => {
}

inventory.remove(itemSlot);
player.outgoingPackets.playSound(soundIds.potContentModified, 5);
player.playSound(soundIds.potContentModified, 5);
player.giveItem(itemIds.pot);
};

Expand Down
8 changes: 4 additions & 4 deletions src/plugins/items/shopping/buy-from-shop-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const action: itemAction = (details) => {
const coinsIndex = player.hasCoins(buyCost);

if(coinsIndex === -1) {
player.outgoingPackets.chatboxMessage(`You don't have enough coins.`);
player.sendMessage(`You don't have enough coins.`);
return;
}

Expand All @@ -65,13 +65,13 @@ export const action: itemAction = (details) => {

if(inventoryStackSlot === -1) {
if(inventory.getFirstOpenSlot() === -1) {
player.outgoingPackets.chatboxMessage(`You don't have enough space in your inventory.`);
player.sendMessage(`You don't have enough space in your inventory.`);
return;
}
} else {
const inventoryItem = inventory.items[inventoryStackSlot];
if(inventoryItem.amount + buyAmount >= 2147483647) {
player.outgoingPackets.chatboxMessage(`You don't have enough space in your inventory.`);
player.sendMessage(`You don't have enough space in your inventory.`);
return;
}

Expand All @@ -97,7 +97,7 @@ export const action: itemAction = (details) => {
}

if(bought !== buyAmount) {
player.outgoingPackets.chatboxMessage(`You don't have enough space in your inventory.`);
player.sendMessage(`You don't have enough space in your inventory.`);
}

shopContainer.set(itemSlot, { itemId, amount: shopItem.amount - bought });
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/items/shopping/item-value-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ export const shopSellValueAction: itemAction = (details) => {

const itemValue = item.value || 1;

player.outgoingPackets.chatboxMessage(`${item.name}: currently costs ${itemValue} coins.`);
player.sendMessage(`${item.name}: currently costs ${itemValue} coins.`);
};

export const shopPurchaseValueAction: itemAction = (details) => {
const { player } = details;

player.outgoingPackets.chatboxMessage(`Shop purchase value is TBD`);
player.sendMessage(`Shop purchase value is TBD`);
};

export default new RunePlugin([{
Expand Down
6 changes: 1 addition & 5 deletions src/plugins/items/shopping/sell-to-shop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@ import { widgets } from '@server/world/config/widget';
import { ActionType, RunePlugin } from '@server/plugins/plugin';
import { Shop, shopItemContainer } from '@server/world/config/shops';
import { world } from '@server/game-server';
import { ItemContainer } from '@server/world/items/item-container';
import { itemIds } from '@server/world/config/item-ids';

export const action: itemAction = (details) => {
const { player, itemId, itemSlot, widgetId, containerId, option } = details;

if(!player.activeWidget || player.activeWidget.widgetId !== widgets.shop.widgetId) {
console.log('no widget');
return;
}

const openedShop: Shop = player.metadata['lastOpenedShop'];
if(!openedShop) {
console.log('no shop');
return;
}

Expand All @@ -25,7 +22,6 @@ export const action: itemAction = (details) => {

if(!inventoryItem) {
// The specified item was not found in the specified slot.
console.log('no item');
return;
}

Expand All @@ -41,7 +37,7 @@ export const action: itemAction = (details) => {

const shopItemIndex = shopContainer.items.findIndex(item => item !== null && item.itemId === itemId);
if(shopItemIndex === -1 && shopSpaces.length === 0) {
player.outgoingPackets.chatboxMessage(`There isn't enough space in the shop.`);
player.sendMessage(`There isn't enough space in the shop.`);
return;
}

Expand Down
4 changes: 1 addition & 3 deletions src/plugins/npcs/al-kharid/gem-trader-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { ActionType, RunePlugin } from '@server/plugins/plugin';
import { openShop } from '@server/world/actor/player/action/shop-action';
import { dialogueAction, DialogueEmote } from '@server/world/actor/player/action/dialogue-action';

const shopIdentification = 'ALKHARID_GEM_TRADER';

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

const talkToAction : npcAction = (details) => {
Expand Down
9 changes: 5 additions & 4 deletions src/plugins/npcs/lumbridge/hans-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,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';
import { animationIds } from '@server/world/config/animation-ids';

const action: npcAction = (details) => {
const { player, npc } = details;
Expand Down Expand Up @@ -41,11 +42,11 @@ const action: npcAction = (details) => {
player.clearFaceActor();

if(d.action === 1) {
npc.updateFlags.animation = { id: 860 };
npc.updateFlags.addChatMessage({ message: 'Jerk!' });
player.outgoingPackets.chatboxMessage('Hans wanders off rather dejectedly.');
npc.playAnimation(animationIds.cry);
npc.say('Jerk!');
player.sendMessage('Hans wanders off rather dejectedly.');
} else {
player.outgoingPackets.chatboxMessage('Hans wanders off aimlessly through the courtyard.');
player.sendMessage('Hans wanders off aimlessly through the courtyard.');
}
});
};
Expand Down
1 change: 0 additions & 1 deletion src/plugins/npcs/lumbridge/shopkeeper-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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) => {
openShop(details.player, 'LUMBRIDGE_GENERAL_STORE');
};
Expand Down
8 changes: 5 additions & 3 deletions src/plugins/npcs/lumbridge/tramp-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { ActionType, RunePlugin } from '@server/plugins/plugin';
import { npcIds } from '@server/world/config/npc-ids';
import { npcInitAction } from '@server/world/actor/npc/npc';
import { loopingAction } from '@server/world/actor/player/action/action';

const action: npcInitAction = (details) => {
setInterval(() => {
details.npc.updateFlags.addChatMessage({ message: `Welcome to RuneJS!` });
}, 10000);
const { npc } = details;

loopingAction({ ticks: 16, npc }).event
.subscribe(() => npc.say('Welcome to RuneJS!'));
};

export default new RunePlugin({ type: ActionType.NPC_INIT, npcIds: npcIds.tramp, action });
4 changes: 2 additions & 2 deletions src/plugins/objects/cows/cow-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ function milkCow(details: {objectDefinition: LandscapeObjectDefinition, player:

if (player.hasItemInInventory(itemIds.bucket)) {
player.playAnimation(animationIds.milkCow);
player.outgoingPackets.playSound(soundIds.milkCow, 7);
player.playSound(soundIds.milkCow, 7);
player.removeFirstItem(itemIds.bucket);
player.giveItem(itemIds.bucketOfMilk);
player.outgoingPackets.chatboxMessage(`You milk the ${objectDefinition.name} and receive some milk.`);
player.sendMessage(`You milk the ${objectDefinition.name} and receive some milk.`);
} else {
dialogueAction(player)
.then(d => d.npc(npcIds.gillieGroats, DialogueEmote.LAUGH_1, [`Tee hee! You've never milked a cow before, have you?`]))
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/objects/doors/door-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const action: objectAction = (details): void => {

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

export default new RunePlugin({ type: ActionType.OBJECT_ACTION, objectIds: [1530, 4465, 4467, 3014, 3017, 3018,
Expand Down
Loading