@@ -2,7 +2,7 @@ import { WalkingQueue } from './walking-queue';
2
2
import { ItemContainer } from '../items/item-container' ;
3
3
import { Animation , DamageType , Graphic , UpdateFlags } from './update-flags' ;
4
4
import { Npc } from './npc/npc' ;
5
- import { Skills } from '@engine/world/actor/skills' ;
5
+ import { Skill , Skills } from '@engine/world/actor/skills' ;
6
6
import { Item } from '@engine/world/items/item' ;
7
7
import { Position } from '@engine/world/position' ;
8
8
import { DirectionData , directionFromIndex } from '@engine/world/direction' ;
@@ -14,6 +14,11 @@ import { WorldInstance } from '@engine/world/instances';
14
14
import { Player } from '@engine/world/actor/player/player' ;
15
15
import { ActionCancelType , ActionPipeline } from '@engine/world/action' ;
16
16
import { LandscapeObject } from '@runejs/filestore' ;
17
+ import { Behavior } from './behaviors/behavior' ;
18
+ import { soundIds } from '../config/sound-ids' ;
19
+ import { animationIds } from '../config/animation-ids' ;
20
+ import { findNpc } from '../../config' ;
21
+ import { itemIds } from '../config/item-ids' ;
17
22
18
23
19
24
/**
@@ -36,6 +41,25 @@ export abstract class Actor {
36
41
37
42
public pathfinding : Pathfinding = new Pathfinding ( this ) ;
38
43
public lastMovementPosition : Position ;
44
+ // #region Behaviors and Combat flags/checks
45
+ public inCombat : boolean = false ;
46
+ public meleeDistance : number = 1 ;
47
+ public Behaviors : Behavior [ ] = [ ] ;
48
+ public isDead : boolean = false ;
49
+ public combatTargets : Actor [ ] = [ ] ;
50
+ public hitPoints = this . skills . hitpoints . level * 4 ;
51
+ public maxHitPoints = this . skills . hitpoints . level * 4 ;
52
+ public get highestCombatSkill ( ) : Skill {
53
+ const attack = this . skills . getLevel ( 'attack' ) ;
54
+ const magic = this . skills . getLevel ( 'magic' ) ;
55
+ const ranged = this . skills . getLevel ( 'ranged' ) ;
56
+
57
+ if ( ranged > magic && ranged > ranged ) return ranged ;
58
+ else if ( magic > attack && magic > ranged ) return magic ;
59
+ else return attack ;
60
+ }
61
+
62
+ // #endregion
39
63
40
64
protected randomMovementInterval ;
41
65
@@ -59,20 +83,36 @@ export abstract class Actor {
59
83
this . _busy = false ;
60
84
}
61
85
62
- public damage ( amount : number , damageType : DamageType = DamageType . DAMAGE ) : 'alive' | 'dead' {
63
- let remainingHitpoints : number = this . skills . hitpoints . level - amount ;
64
- const maximumHitpoints : number = this . skills . hitpoints . levelForExp ;
65
- if ( remainingHitpoints < 0 ) {
66
- remainingHitpoints = 0 ;
67
- }
68
-
69
- this . skills . setHitpoints ( remainingHitpoints ) ;
86
+ public damage ( amount : number , damageType : DamageType = DamageType . DAMAGE ) {
87
+ const armorReduction = 0 ;
88
+ const spellDamageReduction = 0 ;
89
+ const poisonReistance = 0 ;
90
+ amount -= armorReduction ;
91
+ this . hitPoints -= amount ;
92
+ this . skills . setHitpoints ( this . hitPoints ) ;
70
93
this . updateFlags . addDamage ( amount , amount === 0 ? DamageType . NO_DAMAGE : damageType ,
71
- remainingHitpoints , maximumHitpoints ) ;
72
-
73
- return remainingHitpoints === 0 ? 'dead' : 'alive' ;
94
+ this . hitPoints , this . maxHitPoints ) ;
95
+ //this actor should respond when hit
96
+ world . playLocationSound ( this . position , soundIds . npc . human . noArmorHitPlayer , 5 )
97
+ this . playAnimation ( this . getBlockAnimation ( ) ) ;
74
98
}
75
99
100
+
101
+
102
+ //public damage(amount: number, damageType: DamageType = DamageType.DAMAGE): 'alive' | 'dead' {
103
+ // let remainingHitpoints: number = this.skills.hitpoints.level - amount;
104
+ // const maximumHitpoints: number = this.skills.hitpoints.levelForExp;
105
+ // if(remainingHitpoints < 0) {
106
+ // remainingHitpoints = 0;
107
+ // }
108
+
109
+ // this.skills.setHitpoints(remainingHitpoints);
110
+ // this.updateFlags.addDamage(amount, amount === 0 ? DamageType.NO_DAMAGE : damageType,
111
+ // remainingHitpoints, maximumHitpoints);
112
+
113
+ // return remainingHitpoints === 0 ? 'dead' : 'alive';
114
+ //}
115
+
76
116
/**
77
117
* Waits for the actor to reach the specified position before resolving it's promise.
78
118
* The promise will be rejected if the actor's walking queue changes or their movement is otherwise canceled.
@@ -549,4 +589,5 @@ export abstract class Actor {
549
589
} ;
550
590
}
551
591
592
+
552
593
}
0 commit comments