Skip to content

Commit

Permalink
Merge pull request #166 from rune-js/feature/fix-damage-flag
Browse files Browse the repository at this point in the history
Fixing an issue where the damage update flag wouldn't trigger an update
  • Loading branch information
TheBlackParade committed Jun 6, 2020
2 parents a04137c + 34e2b93 commit 211a0a9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions plugins/combat/combat.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const { NPC_ACTION, DamageType, wait } = require('../rune.js');
const { NPC_ACTION, DamageType, schedule } = require('../rune.js');

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

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

await wait(100);
await schedule(4);

player.updateFlags.addDamage(1, DamageType.DAMAGE, 9, 10);
player.updateFlags.addDamage(1, DamageType.DAMAGE, 4, 5);
};

module.exports = {
Expand Down
7 changes: 2 additions & 5 deletions plugins/rune.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ const { InteractingAction, loopingAction, walkToAction } = require('../dist/worl
const { DamageType, Damage, Animation, Graphic, ChatMessage } = require('../dist/world/actor/update-flags');
const { Skill, Skills } = require('../dist/world/actor/skills');
const { Achievements, giveAchievement } = require('../dist/world/actor/player/achievements');
const { of } = require('rxjs');
const { delay } = require('rxjs/operators');
const { wait, schedule } = require('../dist/task/task');

module.exports = {

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

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

wait: async (waitLength) => {
await of(null).pipe(delay(waitLength)).toPromise();
}
wait, schedule

};
7 changes: 6 additions & 1 deletion src/task/task.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { timer } from 'rxjs';
import { of, timer } from 'rxjs';
import { World } from '@server/world/world';
import { delay } from 'rxjs/operators';

export abstract class Task<T> {

Expand All @@ -10,3 +11,7 @@ export abstract class Task<T> {
export const schedule = async (ticks: number): Promise<number> => {
return timer(ticks * World.TICK_LENGTH).toPromise();
};

export const wait = async (waitLength): Promise<void> => {
return of(null).pipe(delay(waitLength)).toPromise();
};
2 changes: 1 addition & 1 deletion src/world/actor/update-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class UpdateFlags {

public get updateBlockRequired(): boolean {
return this._appearanceUpdateRequired || this._chatMessages.length !== 0 || this._facePosition !== null ||
this._graphics !== null || this._animation !== undefined || this._faceActor !== undefined;
this._graphics !== null || this._animation !== undefined || this._faceActor !== undefined || this._damage !== null;
}

public get mapRegionUpdateRequired(): boolean {
Expand Down

0 comments on commit 211a0a9

Please sign in to comment.