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

Added Karim to the kebab shop in al-kharid. Let's enjoy a kebab. #147

Merged
merged 3 commits into from
May 30, 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
4 changes: 4 additions & 0 deletions data/config/npc-spawns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,7 @@
x: 3168
y: 3306
radius: 3
- npcId: 543
x: 3272
y: 3182
radius: 2
55 changes: 55 additions & 0 deletions src/plugins/npcs/al-kharid/karim-plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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 { itemIds } from '@server/world/config/item-ids';
import { widgets } from '@server/world/config/widget';
import { dialogue, Emote, execute, goto } from '@server/world/actor/dialogue';

const talkToAction : npcAction = (details) => {
const { player, npc } = details;

dialogue([player, { npc, key: 'karim' }], [
karim => [ Emote.HAPPY, `Would you like to buy a nice kebab? Only one gold.`],
options => [
`I think i'll give it a miss.`, [
player => [Emote.DROWZY, `I think i'll give it a miss.`],
],
`Yes please.`, [
player => [Emote.HAPPY, `Yes please.`],
execute(() => {
const inventory = player.inventory;
if (inventory.has(itemIds.coins)) {
const index = inventory.findIndex(itemIds.coins);
const item = inventory.items[index];

if (!inventory.hasSpace()) {
player.sendMessage(`You don't have enough space in your inventory.`);
return;
}

inventory.remove(index);
if (item.amount !== 1) {
inventory.add( { itemId: itemIds.coins, amount: item.amount - 1 });
}

inventory.add({ itemId: itemIds.kebab, amount: 1 });
player.outgoingPackets.sendUpdateAllWidgetItems(widgets.inventory, inventory);
return;
}

if (!inventory.has(itemIds.coins)) {
dialogue([player, { npc, key: 'karim' }], [
player => [Emote.ANGRY, `Oops, I forgot to bring any money with me.`],
karim => [Emote.GENERIC, `Come back when you have some.`]
]);
}
})
]
]
]);
};

export default new RunePlugin([
{ type: ActionType.NPC_ACTION, npcIds: npcIds.karim, options: 'talk-to', walkTo: true, action: talkToAction }
]);
2 changes: 1 addition & 1 deletion src/world/config/item-ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ export const itemIds = {
recruitmentDrive: {
shears: 5603,
},

kebab: 1971

};
1 change: 1 addition & 0 deletions src/world/config/npc-ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const npcIds = {
dommik: 545,
louieLegs: 542,
gemTrader: 540,
karim: 543,
gillieGroats: 3807,
ranael: 544,
millieMiller: 3806
Expand Down