Skip to content

Commit 34e2b93

Browse files
Fixing an issue where the damage update flag wouldn't trigger an update
1 parent a04137c commit 34e2b93

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

plugins/combat/combat.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
const { NPC_ACTION, DamageType, wait } = require('../rune.js');
1+
const { NPC_ACTION, DamageType, schedule } = require('../rune.js');
22

33
const action = async details => {
44
const { player, npc } = details;
55

66
npc.updateFlags.addDamage(1, DamageType.DAMAGE, 4, 5);
77
npc.say(`Ow!`);
88

9-
await wait(100);
9+
await schedule(4);
1010

11-
player.updateFlags.addDamage(1, DamageType.DAMAGE, 9, 10);
11+
player.updateFlags.addDamage(1, DamageType.DAMAGE, 4, 5);
1212
};
1313

1414
module.exports = {

plugins/rune.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ const { InteractingAction, loopingAction, walkToAction } = require('../dist/worl
1313
const { DamageType, Damage, Animation, Graphic, ChatMessage } = require('../dist/world/actor/update-flags');
1414
const { Skill, Skills } = require('../dist/world/actor/skills');
1515
const { Achievements, giveAchievement } = require('../dist/world/actor/player/achievements');
16-
const { of } = require('rxjs');
17-
const { delay } = require('rxjs/operators');
16+
const { wait, schedule } = require('../dist/task/task');
1817

1918
module.exports = {
2019

@@ -33,8 +32,6 @@ module.exports = {
3332

3433
DamageType, Damage, Animation, Graphic, ChatMessage, Skill, Skills, Achievements, giveAchievement,
3534

36-
wait: async (waitLength) => {
37-
await of(null).pipe(delay(waitLength)).toPromise();
38-
}
35+
wait, schedule
3936

4037
};

src/task/task.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { timer } from 'rxjs';
1+
import { of, timer } from 'rxjs';
22
import { World } from '@server/world/world';
3+
import { delay } from 'rxjs/operators';
34

45
export abstract class Task<T> {
56

@@ -10,3 +11,7 @@ export abstract class Task<T> {
1011
export const schedule = async (ticks: number): Promise<number> => {
1112
return timer(ticks * World.TICK_LENGTH).toPromise();
1213
};
14+
15+
export const wait = async (waitLength): Promise<void> => {
16+
return of(null).pipe(delay(waitLength)).toPromise();
17+
};

src/world/actor/update-flags.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class UpdateFlags {
9595

9696
public get updateBlockRequired(): boolean {
9797
return this._appearanceUpdateRequired || this._chatMessages.length !== 0 || this._facePosition !== null ||
98-
this._graphics !== null || this._animation !== undefined || this._faceActor !== undefined;
98+
this._graphics !== null || this._animation !== undefined || this._faceActor !== undefined || this._damage !== null;
9999
}
100100

101101
public get mapRegionUpdateRequired(): boolean {

0 commit comments

Comments
 (0)