Skip to content

Commit 983c63e

Browse files
author
src
authored
Merge branch 'develop' into development
2 parents 60c951a + 842d97e commit 983c63e

File tree

8 files changed

+86
-103
lines changed

8 files changed

+86
-103
lines changed

package-lock.json

Lines changed: 40 additions & 85 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/game-engine/net/outbound-packets.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,26 @@ export class OutboundPackets {
6868
packet.putBytes(Buffer.from(message));
6969
this.queue(packet);
7070
}
71-
71+
//packet - 129 - freezes client?
72+
//packet - 202 - directly to login screen
73+
74+
public sendProjectile(position: Position, offsetX: number, offsetY: number, id: number, startHeight: number, endHeight: number, speed: number, lockon: number, delay: number) {
75+
this.updateReferencePosition(position);
76+
77+
const packet = new Packet(1);
78+
packet.put(0);
79+
packet.put(offsetY, 'byte');
80+
packet.put(offsetX, 'byte');
81+
packet.put(lockon, 'SHORT', 'BIG_ENDIAN');
82+
packet.put(id, 'SHORT', 'BIG_ENDIAN');
83+
packet.put(startHeight);
84+
packet.put(endHeight);
85+
packet.put(delay, 'SHORT', 'BIG_ENDIAN');
86+
packet.put(speed, 'SHORT', 'BIG_ENDIAN');
87+
packet.put(16);
88+
packet.put(64);
89+
this.queue(packet);
90+
}
7291
public updateFriendStatus(friendName: string, worldId: number): void {
7392
const packet = new Packet(156);
7493
packet.put(stringToLong(friendName.toLowerCase()), 'LONG');

src/game-engine/world/action/magic-on-npc.action.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ const magicOnNpcActionPipe = (npc:Npc, player: Player, widgetId: number, buttonI
5353

5454
// Find all object action plugins that reference this location object
5555
const matchingHooks = getActionHooks<MagicOnNPCActionHook>('magic_on_npc');
56-
5756

5857
return {
5958
hooks: matchingHooks,

src/game-engine/world/action/npc-interaction.action.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ const npcInteractionActionPipe = (player: Player, npc: Npc, position: Position,
5353
return;
5454
}
5555

56+
57+
5658
const morphedNpc = player.getMorphedNpcDetails(npc);
5759

5860
// Find all NPC action plugins that reference this NPC
@@ -61,6 +63,7 @@ const npcInteractionActionPipe = (player: Player, npc: Npc, position: Position,
6163
(!plugin.npcs || stringHookFilter(plugin.npcs, morphedNpc?.key || npc.key)) &&
6264
(!plugin.options || stringHookFilter(plugin.options, option)));
6365
const questActions = matchingHooks.filter(plugin => plugin.questRequirement !== undefined);
66+
6467

6568
if(questActions.length !== 0) {
6669
matchingHooks = questActions;
@@ -74,6 +77,7 @@ const npcInteractionActionPipe = (player: Player, npc: Npc, position: Position,
7477
return null;
7578
}
7679

80+
console.log(`WE ARE INTERACTING WITH NPC quests: ${questActions.length} ${matchingHooks.length}`);
7781
return {
7882
hooks: matchingHooks,
7983
actionPosition: position,

src/game-engine/world/actor/behaviors/auto-attack.behavior.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class AutoAttackBehavior extends Behavior {
6767
console.log(`you attack ${(this.Them as Npc).name} for ${_damage} damage! (after the CD)`);
6868
this.Them.damage(_damage);
6969
if (this.Them.hitPoints <= 0) {
70-
(this.Them as Npc).npcEvents.emit('death', this.Me);
70+
(this.Them as Npc).npcEvents.emit('death', this.Me, this.Them);
7171
}
7272

7373
});

src/game-engine/world/actor/npc/npc.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,25 +126,18 @@ export class Npc extends Actor {
126126

127127
//This is useful so that we can tie into things like "spell casts" or events, or traps, etc to finish quests or whatever
128128

129-
public async processDeath(assailant: Actor): Promise<void> {
129+
public async processDeath(assailant: Actor, defender:Actor): Promise<void> {
130+
130131
return new Promise<void>(resolve => {
131-
const deathPosition = this.position;
132+
const deathPosition = defender.position;
132133

133134
let deathAnim: number = animationIds.death;
134-
deathAnim = findNpc(this.id)?.combatAnimations?.death || animationIds.death
135-
135+
deathAnim = findNpc((defender as Npc).id)?.combatAnimations?.death || animationIds.death
136136

137-
//ToDo: all this is broken
138-
try {
137+
defender.playAnimation(deathAnim);
138+
world.playLocationSound(deathPosition, soundIds.npc.human.maleDeath, 5);
139+
world.globalInstance.spawnWorldItem(itemIds.bones, deathPosition, { owner: assailant instanceof Player ? assailant : undefined, expires: 300 });
139140

140-
this.playAnimation(deathAnim);
141-
world.playLocationSound(deathPosition, soundIds.npc.human.maleDeath, 5);
142-
world.globalInstance.spawnWorldItem(itemIds.bones, deathPosition,
143-
{ owner: assailant instanceof Player ? assailant : undefined, expires: 300 });
144-
}
145-
catch (err) {
146-
logger.debug(err);
147-
}
148141
});
149142

150143
}

src/plugins/buttons/magic-attack.plugin.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ export const activate = (task: TaskExecutor<MagicOnNPCAction>, elapsedTicks: num
2828
buttonId
2929
} = task.actionData;
3030

31+
const attackerX = player.position.x;
32+
const attackerY = player.position.y
33+
const victimX = npc.position.x
34+
const victimY = npc.position.y;
35+
const offsetX = ((victimY - attackerY));
36+
const offsetY = ((victimX - attackerX));
37+
38+
//https://oldschool.runescape.wiki/w/Attack_range#:~:text=All%20combat%20magic%20spells%20have,also%20allow%20longrange%20attack%20style
39+
// range should be within 10 tiles for magic
40+
// range should be within 7 for magic staff
41+
42+
//npc world index would be -1 for players
43+
player.outgoingPackets.sendProjectile(player.position, offsetX, offsetY, 250, 40, 36, 100, npc.worldIndex + 1, 1);
3144
console.info(`${player.username} smites ${npc.name} with ${spells[buttonId]}`);
3245
};
3346

src/plugins/combat/combat.plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default {
4242
{
4343
type: 'npc_interaction',
4444
options: 'attack',
45-
walkTo: true,
45+
walkTo: false,
4646
task: {
4747
activate,
4848
}

0 commit comments

Comments
 (0)