22 #ifndef HARVESTER_COMBAT_H 23 #define HARVESTER_COMBAT_H 25 #include "common/error.h" 26 #include "harvester/scene/room_support.h" 33 class HarvesterEngine;
35 class InteractionCallbacks;
40 extern const int kRoomMonsterAnimationRate;
41 extern const int kNativeMonsterAttackAnimationRate;
42 extern const int kNativeMonsterHitAnimationRate;
43 extern const uint32 kNativeMonsterAttackCooldownBaseTicks;
44 extern const float kNativeNpcMonsterZExtent;
45 extern const int kRoomNpcAmbientLastFrame;
46 extern const float kNativeMonsterPursuitZTolerance;
47 extern const float kNativeMonsterHorizontalWaypointTolerance;
48 extern const uint32 kNativeKeyboardAttackRepeatTicks;
49 extern const int kNativeAttackSideWindow;
50 extern const int kNativeCombatHitKnockbackDecayStep;
51 extern const char *
const kNativeHitEffectResourcePath;
52 extern const int kNativeHitEffectAnimationRate;
53 extern const float kNativeHitEffectRenderZBias;
54 extern const uint32 kCombatDebugDamagePopupDurationMs;
55 extern const int kCombatDebugDamagePopupRisePixels;
56 extern const int kCombatDebugDamagePopupVerticalGap;
57 extern const char *
const kInnerSanctumRoomName;
58 extern const char *
const kHerrillLogNpcName;
59 extern const char *
const kMuckeyMonsterName;
60 extern const char *
const kActivateInnerSanctumDoorActionTag;
61 extern const int kNativeDefaultNpcDeathDamageType;
66 : firstFrame(firstFrame), lastFrame(lastFrame), resumeFacing(resumeFacing) {}
76 : firstFrame(firstFrame), lastFrame(lastFrame) {}
84 HitAnimationRange(
int firstFrame,
int lastFrame,
int resumeFacing,
int knockbackX)
85 : firstFrame(firstFrame), lastFrame(lastFrame), resumeFacing(resumeFacing),
86 knockbackX(knockbackX) {}
90 int resumeFacing = -1;
95 bool attackActive =
false;
96 int attackFirstFrame = -1;
97 int attackLastFrame = -1;
98 int attackContactFrame = -1;
99 int attackResumeFacing = -1;
100 bool attackSoundPlayed =
false;
101 bool attackContactResolved =
false;
103 bool hitActive =
false;
104 int hitFirstFrame = -1;
105 int hitLastFrame = -1;
106 int hitResumeFacing = -1;
107 int hitKnockbackRemainingX = 0;
108 int hitKnockbackDecayStep = 0;
109 bool hitSoundPlayed =
false;
110 bool deathActive =
false;
111 int deathFirstFrame = -1;
112 int deathLastFrame = -1;
113 int deathDamageType = 0;
114 int loggedPursuitStallDirections = 0;
115 bool allowInitialPursuitStep =
true;
116 uint32 nextMovementTick = 0;
117 uint32 attackCooldownSeedTick = 0;
121 bool deathActive =
false;
122 int deathFirstFrame = -1;
123 int deathLastFrame = -1;
124 int deathDamageType = 0;
129 bool finalizedDeath =
false;
140 void initializeCombatStates();
145 void resetForSceneRefresh();
147 void capturePlayerAttackTargetForKeyboard(
bool attackLeft,
bool attackRight,
bool attackUp,
bool attackDown)
const;
151 void captureOverlappingNpcAttackTarget()
const;
161 Common::Error resolvePlayerNpcAttackContact(
Script &script,
int damageType,
bool &needsRedraw);
163 int damageType,
int damageAmount,
bool &needsRedraw);
165 struct MonsterPursuitResult;
173 const MonsterPursuitResult &pursuit, uint32 now,
bool &needsRedraw)
const;
175 void resizeCombatStates();
176 bool queueInnerSanctumHerrillDeathAfterMuck(
const MonsterRecord &monster)
const;
181 int deathDamageType,
bool &needsRedraw)
const;
185 int attackerAttackFirstFrame,
bool &needsRedraw)
const;
200 NpcRecord *findOverlappingNpcTarget()
const;
201 bool playerAttackCanReachTarget(
Entity *targetEntity,
int engageDistance = 0)
const;
222 float renderZ = 0.0f;
223 bool finished =
false;
229 uint32 startTick = 0;
230 int damageAmount = 0;
237 void clearHitEffects();
238 bool hasDamagePopups()
const {
return !_damagePopupStates.empty(); }
240 void spawnCombatDamagePopup(
Entity &targetEntity,
const Common::String &followTargetName,
int damageAmount);
241 bool syncCombatHitEffects();
242 void drawCombatDamagePopups(
Graphics::Screen &screen,
bool combatDebugEnabled);
243 bool pruneCombatHitEffects();
244 bool pruneCombatDamagePopups();
247 static void resolveHitEffectAnchor(
const Entity &targetEntity,
Common::Point &anchorPoint,
float &renderZ);
248 static void resolveCombatDamagePopupAnchor(
const Entity &targetEntity,
Common::Point &anchorPoint);
253 uint _nextCombatEffectId = 0;
258 int maxVisibleCount = 0;
259 const char *unitLabel =
nullptr;
265 _script->pushDeferredLiveNpcDeathTransitions();
270 _script->popDeferredLiveNpcDeathTransitions();
276 const char *describeCombatTargetClass(
int classId);
277 bool shouldRetainNpcDeathEntityInCurrentRoom(
const NpcRecord &npc);
278 bool isRetainedCurrentRoomNpcDeathRecord(
const NpcRecord &npc);
281 int previousLoadout,
int currentLoadout);
282 bool setRoomMonsterAnimation(
Entity &entity,
int facing,
bool walking);
283 bool runtimeEntityHasFrameRange(
const Entity &entity,
int firstFrame,
int lastFrame);
284 bool runtimeEntityHasDrawableFrameRange(
const Entity &entity,
int firstFrame,
int lastFrame);
286 const Entity &entity,
int actorCenterX,
int targetCenterX,
288 bool resolveMonsterDeathAnimationRange(
const Entity &entity,
int facing,
290 bool resolveNpcDeathAnimationRange(
const Entity &entity,
bool hasMonsterfyTarget,
292 int stepTowardsRoomCombatInt(
int current,
int target,
int step);
293 int computeRuntimeEntityHorizontalGap(
const Entity &left,
const Entity &right);
294 bool doRuntimeEntityDepthExtentsOverlap(
const Entity &first,
const Entity &second);
295 bool areCombatantsWithinRoomCombatReach(
const RoomSetupState &state,
296 const Entity &attacker,
float attackerZ,
297 const Entity &target,
float targetZ,
int engageDistance);
298 bool isWithinNativeMonsterAttackEntryRange(
const Entity &monster,
float monsterZ,
299 const Entity &player,
float playerZ,
int engageDistance);
302 bool resolveRoomMonsterHitAnimationRange(
const Entity &entity,
304 float clampRoomDepthForEvent(
const RoomSetupState &state,
float z);
305 int roundRoomCombatFloat(
float value);
306 int mapRoomDepthToScreenYForCombat(
const RoomSetupState &state,
float z,
int fallbackY);
307 int resolveMonsterAttackContactFrameOffset(
const MonsterRecord &monster);
315 #endif // HARVESTER_COMBAT_H
Definition: room_support.h:46
Definition: interaction.h:43
No error occurred.
Definition: error.h:48
Definition: scene_entities.h:31
Definition: interaction.h:104
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: harvester.h:47