Skip to content

Commit 3706893

Browse files
Merge branch 'master' into feature/combat
2 parents 2b6277c + c7da69b commit 3706893

File tree

15 files changed

+529
-330
lines changed

15 files changed

+529
-330
lines changed

README.md

Lines changed: 85 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,110 @@ The server runs on the 435 revision of the game, which was a game update made on
2525

2626
### Game World
2727

28-
* Bank :white_check_mark:
28+
* Bank :yellow_square:
2929
* Withdraw/Deposit 1,5,10,All :heavy_check_mark:
30-
* As note :x:
30+
* As note :heavy_check_mark:
3131
* Swap slot :heavy_check_mark:
32-
* Insert mode: :x:
33-
* Audio :white_check_mark:
34-
* Music :white_check_mark:
32+
* Insert mode: :heavy_check_mark:
33+
* Deposit box :yellow_square:
34+
* Audio :yellow_square:
35+
* Music :yellow_square:
3536
* Playing music :heavy_check_mark:
3637
* Music Regions :x:
3738
* Music Player tab :x:
38-
* Sounds :white_check_mark:
39+
* Sounds :yellow_square:
3940
* Playing sounds :heavy_check_mark:
40-
* Sound effects for actions :white_check_mark:
41-
* Climbing ladders :white_check_mark:
42-
* Climbing stairs :white_check_mark:
43-
* Lumbridge mill :white_check_mark:
41+
* Sound effects for actions :yellow_square:
42+
* Climbing ladders :yellow_square:
43+
* Climbing stairs :yellow_square:
44+
* Lumbridge mill :yellow_square:
4445
* Replacing objects for local player only :x:
46+
* Grain in hopper :heavy_check_mark:
47+
* Operating levers :heavy_check_mark:
48+
* Removing flour if and only if grain has been processed :heavy_check_mark:
49+
* Cow milking :heavy_check_mark:
50+
* Container filling
51+
* Buckets :heavy_check_mark:
52+
* Jugs :heavy_check_mark:
53+
* Wells :heavy_check_mark:
54+
* Sinks :heavy_check_mark:
55+
* Fountains :heavy_check_mark:
56+
* Emptying Containers :heavy_check_mark:
57+
* Home Teleport :yellow_square:
58+
* Animation :yellow_square:
59+
* Emotes :yellow_square:
60+
* Skillcape :yellow_square:
61+
* Normal emotes :heavy_check_mark:
62+
* Shops :yellow_square:
63+
* Shop logic :heavy_check_mark:
64+
* World Shops :yellow_square:
65+
* Al Kahrid gem trader :heavy_check_mark:
66+
* Louie Armoured legs :heavy_check_mark:
67+
* Dommik craftin shop :heavy_check_mark:
68+
* Raneal Super skirt :heavy_check_mark:
69+
* Bob's axes :heavy_check_mark:
70+
* Intentory :yellow_square:
71+
* Swap Items :heavy_check_mark:
72+
* Drop Item :heavy_check_mark:
73+
* Pickup item :heavy_check_mark:
74+
* Equip item :yellow_square:
75+
* Complete equiment stats and slot info :yellow_square:
76+
* Wielding logic (Weight, Stats, Equipping) :heavy_check_mark:
77+
* Pickables :heavy_check_mark:
78+
* Wheat :heavy_check_mark:
79+
* Flax :heavy_check_mark:
80+
* Potato :heavy_check_mark:
81+
* Onion :heavy_check_mark:
82+
* Cabbage :heavy_check_mark:
83+
* Doors :yellow_square:
84+
* Door logic :heavy_check_mark:
85+
* Door ids :yellow_square:
86+
* Clue Scrolls :x:
4587

4688
### Skills
4789

48-
* Woodcutting :white_check_mark:
49-
* Formula for success :white_check_mark:
50-
* Chopping Trees :white_check_mark:
90+
* Combat :yellow_square:
91+
* Melee :x:
92+
* Ranged :x:
93+
* Magic :x:
94+
* Prayer :x:
95+
* Cooking :x:
96+
* Fletching :x:
97+
* Fishing :x:
98+
* Firemaking :yellow_square:
99+
* Herblore :x:
100+
* Agility :x:
101+
* Thieving :x:
102+
* Slayer :x:
103+
* Farming :x:
104+
* Runecraft :x:
105+
* Construction :x:
106+
107+
108+
* Woodcutting :yellow_square:
109+
* Formula for success :heavy_check_mark:
110+
* Chopping Trees :heavy_check_mark:
51111
* Axes :heavy_check_mark:
52112
* Birds nests :x:
53-
* Stump ids :white_check_mark:
113+
* Stump ids :yellow_square:
54114
* Mining
55-
* Formula for success :white_check_mark:
56-
* Mining ores :white_check_mark:
115+
* Formula for success :heavy_check_mark:
116+
* Mining ores :heavy_check_mark:
57117
* Pickaxes :heavy_check_mark:
58118
* Random gems :x:
59119
* Gem ores :x:
60120
* Essence mining :x:
61-
* Empty Rock ids :white_check_mark:
121+
* Empty Rock ids :yellow_square:
62122
* Crafting
63123
* Spinning wheel :heavy_check_mark:
124+
* Smithing
125+
* Smelting ore to bars :heavy_check_mark:
126+
* Forging :yellow_square:
127+
* Correct items :heavy_check_mark:
128+
* Hiding non applicable items :yellow_square:
129+
130+
### Quests
131+
* Cook's Assistant :heavy_check_mark:
64132

65133
### Technical Features
66134

src/game-server.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,16 @@ export async function runGameServer(): Promise<void> {
121121
});
122122
generateCrcTable();
123123

124-
delete cache.dataChannel;
125-
delete cache.metaChannel;
126-
delete cache.indexChannels;
127-
delete cache.indices;
124+
// @TODO keep these in the login server so they don't eat game server memory :)
125+
// delete cache.dataChannel;
126+
// delete cache.metaChannel;
127+
// delete cache.indexChannels;
128+
// delete cache.indices;
128129

129130
world = new World();
130131
await injectPlugins();
131132

132-
world.init().then(() => delete cache.mapData);
133+
world.init();//.then(() => delete cache.mapData);
133134

134135
if(process.argv.indexOf('-fakePlayers') !== -1) {
135136
world.generateFakePlayers();

src/net/incoming-packets/item-swap-packet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { incomingPacket } from '../incoming-packet';
22
import { Player } from '../../world/actor/player/player';
3-
import { swapItemAction } from '../../world/actor/player/action/swap-item-action';
3+
import { insertItemAction, swapItemAction } from '../../world/actor/player/action/swap-item-action';
44
import { ByteBuffer } from '@runejs/byte-buffer';
55

66
export const itemSwapPacket: incomingPacket = (player: Player, packetId: number, packetSize: number, packet: ByteBuffer): void => {
@@ -18,6 +18,6 @@ export const itemSwapPacket: incomingPacket = (player: Player, packetId: number,
1818
// Swap
1919
swapItemAction(player, fromSlot, toSlot, { widgetId, containerId });
2020
} else if(swapType === 1) {
21-
// @TODO insert
21+
insertItemAction(player, fromSlot, toSlot, { widgetId, containerId });
2222
}
2323
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ActionType, RunePlugin } from '@server/plugins/plugin';
2+
import { commandAction } from '@server/world/actor/player/action/input-command-action';
3+
import { openBankInterface } from '@server/plugins/objects/bank/bank-plugin';
4+
5+
const action: commandAction = (details) => {
6+
openBankInterface(details as any);
7+
};
8+
9+
export default new RunePlugin({
10+
type: ActionType.COMMAND,
11+
commands: [ 'bank' ],
12+
action
13+
});

src/plugins/objects/bank/bank-booth-plugin.ts renamed to src/plugins/objects/bank/bank-plugin.ts

Lines changed: 62 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
import { ActionType, RunePlugin } from '@server/plugins/plugin';
22
import { objectIds } from '@server/world/config/object-ids';
3-
import { widgets } from '@server/world/config/widget';
3+
import { widgets, widgetScripts } from '@server/world/config/widget';
44
import { objectAction } from '@server/world/actor/player/action/object-action';
55
import { ItemContainer } from '@server/world/items/item-container';
66
import { itemAction } from '@server/world/actor/player/action/item-action';
7-
import { Item } from '@server/world/items/item';
8-
7+
import { fromNote, Item, toNote } from '@server/world/items/item';
8+
import { buttonAction } from '@server/world/actor/player/action/button-action';
9+
import { logger } from '@runejs/logger/dist/logger';
10+
import { hasValueNotNull } from '@server/util/data';
11+
12+
const buttonIds: number[] = [
13+
92, // as note
14+
93, // as item
15+
98, // swap
16+
99, // insert
17+
];
918

1019
export const openBankInterface: objectAction = (details) => {
1120
details.player.activeWidget = {
@@ -17,9 +26,8 @@ export const openBankInterface: objectAction = (details) => {
1726

1827
details.player.outgoingPackets.sendUpdateAllWidgetItems(widgets.bank.tabWidget, details.player.inventory);
1928
details.player.outgoingPackets.sendUpdateAllWidgetItems(widgets.bank.screenWidget, details.player.bank);
20-
details.player.outgoingPackets.updateClientConfig(304, details.player.sessionMetadata['bankRearrangeMode'] === 'insert' ? 1 : 0);
21-
details.player.outgoingPackets.updateClientConfig(115, details.player.sessionMetadata['bankWithdrawAs'] === 'note' ? 1 : 0);
22-
29+
details.player.outgoingPackets.updateClientConfig(widgetScripts.bankInsertMode, details.player.settings.bankInsertMode);
30+
details.player.outgoingPackets.updateClientConfig(widgetScripts.bankWithdrawNoteMode, details.player.settings.bankWithdrawNoteMode);
2331
};
2432

2533
export const depositItem: itemAction = (details) => {
@@ -31,17 +39,26 @@ export const depositItem: itemAction = (details) => {
3139
}
3240

3341
// Check if the player has the item
42+
3443
if (!details.player.hasItemInInventory(details.itemId)) {
3544
return;
3645
}
3746

47+
48+
let itemIdToAdd: number = details.itemId;
49+
const fromNoteId: number = fromNote(details.itemId);
50+
if (fromNoteId > -1) {
51+
itemIdToAdd = fromNoteId;
52+
}
53+
3854
let countToRemove: number;
3955
if (details.option.endsWith('all')) {
4056
countToRemove = -1;
4157
} else {
4258
countToRemove = +details.option.replace('deposit-', '');
4359
}
4460

61+
4562
const playerInventory: ItemContainer = details.player.inventory;
4663
const playerBank: ItemContainer = details.player.bank;
4764
const slotsWithItem: number[] = playerInventory.findAll(details.itemId);
@@ -51,13 +68,13 @@ export const depositItem: itemAction = (details) => {
5168
countToRemove = itemAmount;
5269
}
5370

54-
if (!playerBank.canFit({itemId: details.itemId, amount: countToRemove}, true)) {
71+
if (!playerBank.canFit({itemId: itemIdToAdd, amount: countToRemove}, true)) {
5572
details.player.sendMessage('Your bank is full.');
5673
return;
5774
}
5875

5976

60-
const itemToAdd: Item = {itemId: details.itemId, amount: 0};
77+
const itemToAdd: Item = {itemId: itemIdToAdd, amount: 0};
6178
while (countToRemove > 0 && playerInventory.has(details.itemId)) {
6279
const invIndex = playerInventory.findIndex(details.itemId);
6380
const invItem = playerInventory.items[invIndex];
@@ -71,6 +88,7 @@ export const depositItem: itemAction = (details) => {
7188
countToRemove = 0;
7289
}
7390
}
91+
7492
playerBank.addStacking(itemToAdd);
7593

7694

@@ -91,6 +109,18 @@ export const withdrawItem: itemAction = (details) => {
91109
if (!details.player.hasItemInBank(details.itemId)) {
92110
return;
93111
}
112+
113+
let itemIdToAdd: number = details.itemId;
114+
if (details.player.settings.bankWithdrawNoteMode) {
115+
const toNoteId: number = toNote(details.itemId);
116+
if (toNoteId > -1) {
117+
itemIdToAdd = toNoteId;
118+
} else {
119+
details.player.sendMessage('This item can not be withdrawn as a note.');
120+
}
121+
}
122+
123+
94124
let countToRemove: number;
95125
if (details.option.endsWith('all')) {
96126
countToRemove = -1;
@@ -112,14 +142,13 @@ export const withdrawItem: itemAction = (details) => {
112142
countToRemove = slots;
113143
}
114144
}
115-
116-
if (!playerInventory.canFit({itemId: details.itemId, amount: countToRemove})) {
145+
if (!playerInventory.canFit({itemId: itemIdToAdd, amount: countToRemove}) || countToRemove === 0) {
117146
details.player.sendMessage('Your inventory is full.');
118147
return;
119148
}
120149

121150

122-
const itemToAdd: Item = {itemId: details.itemId, amount: 0};
151+
const itemToAdd: Item = {itemId: itemIdToAdd, amount: 0};
123152
while (countToRemove > 0 && playerBank.has(details.itemId)) {
124153
const invIndex = playerBank.findIndex(details.itemId);
125154
const invItem = playerBank.items[invIndex];
@@ -133,14 +162,34 @@ export const withdrawItem: itemAction = (details) => {
133162
countToRemove = 0;
134163
}
135164
}
136-
playerInventory.addStacking(itemToAdd);
165+
for (let i = 0; i < itemToAdd.amount; i++) {
166+
playerInventory.add({itemId: itemIdToAdd, amount: 1});
167+
}
137168

138169

139170
details.player.outgoingPackets.sendUpdateAllWidgetItems(widgets.bank.tabWidget, details.player.inventory);
140171
details.player.outgoingPackets.sendUpdateAllWidgetItems(widgets.inventory, details.player.inventory);
141172
details.player.outgoingPackets.sendUpdateAllWidgetItems(widgets.bank.screenWidget, details.player.bank);
142173
};
143174

175+
export const btnAction: buttonAction = (details) => {
176+
const {player, buttonId} = details;
177+
player.settingChanged(buttonId);
178+
179+
const settingsMappings = {
180+
92: {setting: 'bankWithdrawNoteMode', value: 1},
181+
93: {setting: 'bankWithdrawNoteMode', value: 0},
182+
98: {setting: 'bankInsertMode', value: 0},
183+
99: {setting: 'bankInsertMode', value: 1},
184+
};
185+
if (!settingsMappings.hasOwnProperty(buttonId)) {
186+
return;
187+
}
188+
189+
const config = settingsMappings[buttonId];
190+
player.settings[config.setting] = config.value;
191+
};
192+
144193

145194
export default new RunePlugin([{
146195
type: ActionType.OBJECT_ACTION,
@@ -158,4 +207,4 @@ export default new RunePlugin([{
158207
widgets: widgets.bank.screenWidget,
159208
options: ['withdraw-1', 'withdraw-5', 'withdraw-10', 'withdraw-all'],
160209
action: withdrawItem,
161-
}]);
210+
}, {type: ActionType.BUTTON, widgetId: widgets.bank.screenWidget.widgetId, buttonIds: buttonIds, action: btnAction}]);

src/plugins/player/login-update-settings-plugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const action: playerInitAction = (details) => {
2121
player.outgoingPackets.updateClientConfig(widgetScripts.autoRetaliate, settings.autoRetaliateEnabled ? 0 : 1);
2222
player.outgoingPackets.updateClientConfig(widgetScripts.attackStyle, settings.attackStyle);
2323
player.outgoingPackets.updateClientConfig(widgetScripts.bankInsertMode, settings.bankInsertMode);
24+
player.outgoingPackets.updateClientConfig(widgetScripts.bankWithdrawNoteMode, settings.bankWithdrawNoteMode);
2425
};
2526

2627
export default new RunePlugin({ type: ActionType.PLAYER_INIT, action });

0 commit comments

Comments
 (0)