22 #ifndef WORLD_ACTORS_ACTOR_H 23 #define WORLD_ACTORS_ACTOR_H 25 #include "ultima/ultima8/world/container.h" 26 #include "ultima/ultima8/usecode/intrinsics.h" 27 #include "ultima/ultima8/world/actors/animation.h" 32 class ActorAnimProcess;
33 struct PathfindingState;
44 int16 getStr()
const {
47 void setStr(int16 str) {
50 int16 getDex()
const {
53 void setDex(int16 dex) {
56 int16 getInt()
const {
59 void setInt(int16 intl) {
62 uint16 getHP()
const {
65 void setHP(uint16 hp) {
68 int16 getMana()
const {
71 void setMana(int16 mp) {
75 int16 getMaxMana()
const;
76 uint16 getMaxHP()
const;
79 return (_actorFlags & ACT_DEAD) != 0;
82 bool isInCombat()
const {
83 return (_actorFlags & ACT_INCOMBAT) != 0;
86 bool isKneeling()
const {
87 return (_actorFlags & ACT_KNEELING) != 0;
90 bool isFalling()
const;
94 virtual void setInCombat(
int activity);
95 virtual void clearInCombat();
97 uint16 getAlignment()
const {
100 void setAlignment(uint16 a) {
103 uint16 getEnemyAlignment()
const {
104 return _enemyAlignment;
106 void setEnemyAlignment(uint16 a) {
110 Animation::Sequence getLastAnim()
const {
113 void setLastAnim(Animation::Sequence anim) {
116 Direction getDir()
const {
119 void setDir(Direction dir) {
122 int32 getFallStart()
const {
125 void setFallStart(int32 zp) {
128 void setUnkByte(uint8 b) {
131 uint8 getUnkByte()
const {
135 bool hasActorFlags(uint32 flags)
const {
136 return (_actorFlags & flags) != 0;
138 void setActorFlag(uint32 mask) {
140 if (mask & ACT_KNEELING)
141 _cachedShapeInfo =
nullptr;
143 void clearActorFlag(uint32 mask) {
144 _actorFlags &= ~mask;
145 if (mask & ACT_KNEELING)
146 _cachedShapeInfo =
nullptr;
149 void setCombatTactic(
int no) {
162 virtual void teleport(
int mapnum, int32 x, int32 y, int32 z);
169 bool setEquip(
Item *item,
bool checkwghtvol =
false);
170 uint16 getEquip(uint32 type)
const;
172 virtual uint32 getArmourClass()
const;
173 virtual uint16 getDefenseType()
const;
174 virtual int16 getAttackingDex()
const;
175 virtual int16 getDefendingDex()
const;
178 virtual int getDamageAmount()
const;
180 void setDefaultActivity(
int no, uint16 activity);
181 uint16 getDefaultActivity(
int no)
const;
183 void setHomePosition(int32 x, int32 y, int32 z);
184 void getHomePosition(int32 &x, int32 &y, int32 &z)
const;
196 void receiveHit(uint16 other, Direction dir,
int damage, uint16 type)
override;
203 virtual ProcId
die(uint16 damageType, uint16 damagePts, Direction srcDir);
219 uint16 getCurrentActivityNo()
const {
223 uint16 getLastActivityNo()
const {
224 return _lastActivityNo;
227 void clearLastActivityNo() {
231 int32 getLastTickWasHit()
const {
237 uint16
doAnim(Animation::Sequence anim, Direction dir,
unsigned int steps = 0);
242 uint16
doAnimAfter(Animation::Sequence anim, Direction dir, ProcId waitfor);
245 bool hasAnim(Animation::Sequence anim);
258 Animation::Result
tryAnim(Animation::Sequence anim, Direction dir,
unsigned int steps = 0,
PathfindingState *state = 0);
261 DirectionMode
animDirMode(Animation::Sequence anim)
const;
267 int32
collideMove(int32 x, int32 y, int32 z,
bool teleport,
bool force,
268 ObjId *hititem = 0, uint8 *dirs = 0)
override;
290 uint16 getActiveWeapon()
const {
294 uint16 getCombatTactic()
const {
298 bool activeWeaponIsSmall()
const;
309 uint32 getAttackMoveTimeoutFinishFrame()
const {
313 uint16 getAttackMoveDodgeFactor()
const {
317 bool getAttackAimFlag()
const {
321 void setAttackAimFlag(
bool val) {
325 ENABLE_RUNTIME_CLASSTYPE()
329 INTRINSIC(I_getLastAnimSet);
330 INTRINSIC(I_pathfindToItem);
331 INTRINSIC(I_pathfindToPoint);
336 INTRINSIC(I_getMaxHp);
337 INTRINSIC(I_getMana);
338 INTRINSIC(I_getAlignment);
339 INTRINSIC(I_getEnemyAlignment);
344 INTRINSIC(I_setMana);
345 INTRINSIC(I_setAlignment);
346 INTRINSIC(I_setEnemyAlignment);
349 INTRINSIC(I_teleport);
351 INTRINSIC(I_isInCombat);
352 INTRINSIC(I_setInCombat);
353 INTRINSIC(I_clrInCombat);
354 INTRINSIC(I_setTarget);
355 INTRINSIC(I_getTarget);
356 INTRINSIC(I_isEnemy);
358 INTRINSIC(I_setDead);
359 INTRINSIC(I_clrDead);
360 INTRINSIC(I_isImmortal);
361 INTRINSIC(I_setImmortal);
362 INTRINSIC(I_clrImmortal);
363 INTRINSIC(I_isWithstandDeath);
364 INTRINSIC(I_setWithstandDeath);
365 INTRINSIC(I_clrWithstandDeath);
366 INTRINSIC(I_isFeignDeath);
367 INTRINSIC(I_setFeignDeath);
368 INTRINSIC(I_clrFeignDeath);
369 INTRINSIC(I_areEnemiesNear);
371 INTRINSIC(I_createActor);
372 INTRINSIC(I_createActorCru);
373 INTRINSIC(I_setActivity);
374 INTRINSIC(I_setAirWalkEnabled);
375 INTRINSIC(I_getAirWalkEnabled);
376 INTRINSIC(I_schedule);
377 INTRINSIC(I_getEquip);
378 INTRINSIC(I_setEquip);
379 INTRINSIC(I_setDefaultActivity0);
380 INTRINSIC(I_setDefaultActivity1);
381 INTRINSIC(I_setDefaultActivity2);
382 INTRINSIC(I_getDefaultActivity0);
383 INTRINSIC(I_getDefaultActivity1);
384 INTRINSIC(I_getDefaultActivity2);
385 INTRINSIC(I_setCombatTactic);
386 INTRINSIC(I_setUnkByte);
387 INTRINSIC(I_getUnkByte);
388 INTRINSIC(I_getLastActivityNo);
389 INTRINSIC(I_getCurrentActivityNo);
390 INTRINSIC(I_turnToward);
391 INTRINSIC(I_isKneeling);
392 INTRINSIC(I_isFalling);
395 ACT_INVINCIBLE = 0x000001,
396 ACT_ASCENDING = 0x000002,
397 ACT_DESCENDING = 0x000004,
398 ACT_ANIMLOCK = 0x000008,
400 ACT_KNEELING = 0x000100,
401 ACT_FIRSTSTEP = 0x000400,
402 ACT_INCOMBAT = 0x000800,
404 ACT_SURRENDERED = 0x002000,
405 ACT_WEAPONREADY = 0x004000,
406 ACT_COMBATRUN = 0x008000,
408 ACT_AIRWALK = 0x010000,
409 ACT_IMMORTAL = 0x040000,
410 ACT_WITHSTANDDEATH = 0x080000,
411 ACT_FEIGNDEATH = 0x100000,
412 ACT_STUNNED = 0x200000,
413 ACT_POISONED = 0x400000,
414 ACT_PATHFINDING = 0x800000
424 uint16 _alignment, _enemyAlignment;
426 Animation::Sequence _lastAnim;
428 Direction _direction;
451 uint16 _lastActivityNo;
479 bool loadMonsterStatsU8();
480 bool loadMonsterStatsCru();
482 void receiveHitU8(uint16 other, Direction dir,
int damage, uint16 type);
483 void receiveHitCru(uint16 other, Direction dir,
int damage, uint16 type);
485 void setInCombatU8();
486 void setInCombatCru(
int activity);
488 ProcId dieU8(uint16 damageType);
489 ProcId dieCru(uint16 damageType, uint16 damagePts, Direction srcDir);
virtual int receiveShieldHit(int damage, uint16 damage_type)
take a hit and optionally adjust it with the shields for this NPC.
Definition: actor.h:286
int32 _lastTickWasHit
Kernel timer last time NPC was hit (only used in Crusader)
Definition: actor.h:457
uint16 assignObjId() override
int32 _homeX
The "home" position used in some Crusader attack tactics.
Definition: actor.h:445
ProcId killAllButFallAnims(bool death)
uint16 turnTowardDir(Direction dir, ProcId prevpid=0)
static Actor * createActor(uint32 shape, uint32 frame)
create an actor, assign objid, make it ethereal and load monster stats.
Definition: actor_anim_process.h:38
uint16 setActivityU8(int activity)
virtual ProcId die(uint16 damageType, uint16 damagePts, Direction srcDir)
Common::String dumpInfo() const override
dump some info about this object to a string
uint16 setActivityCru(int activity)
int calculateAttackDamage(uint16 other, int damage, uint16 type)
uint16 getDamageType() const override
get the damage type this object does when hitting something
Definition: detection.h:27
DirectionMode animDirMode(Animation::Sequence anim) const
Get the number of directions supported by a given animation.
uint32 _attackMoveTimeout
The number of frames the above effect lasts for.
Definition: actor.h:463
void addFireAnimOffsets(int32 &x, int32 &y, int32 &z)
Add the x/y/z fire offsets given the current state of the actor.
uint16 doAnimAfter(Animation::Sequence anim, Direction dir, ProcId waitfor)
void receiveHit(uint16 other, Direction dir, int damage, uint16 type) override
bool removeItem(Item *item) override
int32 collideMove(int32 x, int32 y, int32 z, bool teleport, bool force, ObjId *hititem=0, uint8 *dirs=0) override
overrides the standard item collideMove so we can notify nearby objects.
bool isBusy() const
True if the actor is currently doing an animation.
void setToStartOfAnim(Animation::Sequence anim)
Definition: pathfinder.h:38
uint16 setActivity(int activity)
Definition: container.h:36
Definition: animation_tracker.h:36
uint16 _activeWeapon
Active weapon item (only used in Crusader)
Definition: actor.h:454
void tookHitCru()
A cru-specific behavior - mostly make "ugh" noises, or explode for some robots.
uint16 _defaultActivity[3]
the 3 default NPC activities from Crusader
Definition: actor.h:442
uint16 doAnim(Animation::Sequence anim, Direction dir, unsigned int steps=0)
uint16 _currentActivityNo
Current and last activity (only used in Crusader)
Definition: actor.h:450
bool _attackAimFlag
A flag used in Crusader attack process which adjusts the aim accuracy.
Definition: actor.h:469
uint8 _unkByte
Definition: actor.h:434
void killAllButCombatProcesses()
kill all processes except those related to combat
Definition: combat_process.h:33
bool hasAnim(Animation::Sequence anim)
check if this actor has a specific animation
bool canSeeControlledActor(bool forcombat)
Whether this NPC has the controlled actor in their sights (Crusader only)
bool areEnemiesNear()
check if NPCs are near which are in combat mode and hostile
uint16 _attackMoveDodgeFactor
Definition: actor.h:466
uint16 _combatTactic
tactic being used in combat (for Crusader), the entry in the combat.dat flex.
Definition: actor.h:437
Definition: attack_process.h:41
uint32 _attackMoveStartFrame
Definition: actor.h:461
Animation::Result tryAnim(Animation::Sequence anim, Direction dir, unsigned int steps=0, PathfindingState *state=0)
uint16 schedule(uint32 time)