NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_boss_life.hpp
1#pragma once
2
3/// @brief Interface for managing a boss's hit points, damage values, and damage state.
4/// @ingroup bases
6public:
7 /// @brief Constructs a new boss life manager.
8 /// @param life Initial hit point total for the boss.
9 dBossLifeInf_c(int life) : mLife(life) {}
10 virtual ~dBossLifeInf_c() {} ///< Destroys the boss life manager.
11
12 virtual bool isNonDamage() const = 0; ///< Checks whether the boss has not yet been damaged.
13 virtual bool isOneDamage() const = 0; ///< Checks whether the boss has been damaged once.
14 virtual bool isTwoDamage() const = 0; ///< Checks whether the boss has been damaged twice.
15
16 /**
17 * @brief Checks whether the current HP is at a damage section boundary.
18 * @return @p true if the implementation considers the current HP to be at a
19 * damage-section boundary; otherwise @p false .
20 * @details The default implementation always returns @p false . Implementations that divide
21 * boss HP into sections can override this method to expose those boundaries.
22 */
23 virtual bool isDmgSection() const { return false; }
24
25 virtual int getDamage_Fire() const = 0; ///< Gets the damage dealt by fireball attacks.
26 virtual int getDamage_Fumi() const = 0; ///< Gets the damage dealt by stomp (Fumi) attacks.
27 virtual int getDamage_HipAtk() const = 0; ///< Gets the damage dealt by ground pound (Hip) attacks.
28 virtual int getDamage_Star() const = 0; ///< Gets the damage dealt by Star invincibility attacks.
29 virtual int getDamage_PenguinSlide() const = 0; ///< Gets the damage dealt by Penguin slide attacks.
30 virtual int getDamage_BlockHit() const = 0; ///< Gets the damage dealt by block hit attacks.
31 virtual int getDamage_Shell() const = 0; ///< Gets the damage dealt by shell attacks.
32 virtual int getDamage_Quake() const = 0; ///< Gets the damage dealt by multiplayer ground pound (Quake) attacks.
33
34 /// @brief Post-damage callback invoked when a boss survives an attack.
35 /// @param dmg The amount of damage applied.
36 virtual void damageRev(int dmg) {}
37
38 /// @brief Common update logic for all the @p update methods.
39 /// @param dmg The amount of damage applied.
40 /// @return The updated HP total.
41 int updateCommon(int dmg) {
42 mLife -= dmg;
43 if (mLife > 0) {
44 damageRev(dmg);
45 }
46 return mLife;
47 }
48
49 /// @brief Applies fireball damage to the boss.
50 /// @return The updated HP total.
52
53 /// @brief Applies stomp (Fumi) damage to the boss.
54 /// @return The updated HP total.
56
57 /// @brief Applies ground pound (Hip) damage to the boss.
58 /// @return The updated HP total.
60
61 /// @brief Applies Star damage to the boss.
62 /// @return The updated HP total.
64
65 /// @brief Applies Penguin slide damage to the boss.
66 /// @return The updated HP total.
68
69 /// @brief Applies block hit damage to the boss.
70 /// @return The updated HP total.
72
73 /// @brief Applies shell damage to the boss.
74 /// @return The updated HP total.
76
77 /// @brief Applies multiplayer ground pound (Quake) damage to the boss.
78 /// @return The updated HP total.
80
81 int mLife; ///< The current hit point total.
82};
83
84/**
85 * @brief Standard boss life manager implementation, using 6-HP sections.
86 * @ingroup bases
87 * @details This class provides a section-based implementation of dBossLifeInf_c.
88 * Boss HP is divided into sections of 6 HP, with the current section determining the
89 * boss's damage state.
90 */
92public:
93 dBossLife_Common_c(int num) : dBossLifeInf_c(num) {} ///< @copydoc dBossLifeInf_c::dBossLifeInf_c
94 virtual ~dBossLife_Common_c() {} ///< @copydoc dBossLifeInf_c::~dBossLifeInf_c
95
96 /// @brief Gets the current section (zero-indexed).
97 int getSection() const { return (mLife - 1) / 6; }
98
99 virtual bool isNonDamage() const override {
100 return getSection() > 1;
101 }
102
103 virtual bool isOneDamage() const override {
104 return getSection() > 0 && getSection() < 2;
105 }
106
107 virtual bool isTwoDamage() const override {
108 return getSection() <= 0;
109 }
110
111 /// @copybrief dBossLifeInf_c::isDmgSection
112 virtual bool isDmgSection() const override { return mLife % 6 == 0; }
113
114 /**
115 * @copybrief dBossLifeInf_c::damageRev
116 * @param dmg The amount of damage applied.
117 * @details If the boss survives, the damage was at least 6 HP, and the resulting HP lies
118 * partway through a section, HP is rounded up to the next multiple of 6. This behavior
119 * is used to preserve complete 6-HP sections after heavy attacks.
120 */
121 virtual void damageRev(int dmg) override {
122 int sections = mLife / 6;
123 if (mLife - sections * 6 != 0 && dmg >= 6) {
124 mLife = (sections + 1) * 6;
125 };
126 }
127
128 virtual int getDamage_Fire() const override { return 1; }
129 virtual int getDamage_Fumi() const override { return 6; }
130 virtual int getDamage_HipAtk() const override { return 6; }
131 virtual int getDamage_Star() const override { return 6; }
132 virtual int getDamage_PenguinSlide() const override { return 6; }
133 virtual int getDamage_BlockHit() const override { return 6; }
134 virtual int getDamage_Shell() const override { return 6; }
135 virtual int getDamage_Quake() const override { return 6; }
136};
virtual bool isOneDamage() const =0
Checks whether the boss has been damaged once.
virtual int getDamage_Fire() const =0
Gets the damage dealt by fireball attacks.
virtual int getDamage_Star() const =0
Gets the damage dealt by Star invincibility attacks.
virtual int getDamage_BlockHit() const =0
Gets the damage dealt by block hit attacks.
int updateHipAtk()
Applies ground pound (Hip) damage to the boss.
virtual int getDamage_PenguinSlide() const =0
Gets the damage dealt by Penguin slide attacks.
int updateStar()
Applies Star damage to the boss.
virtual int getDamage_Shell() const =0
Gets the damage dealt by shell attacks.
int updatePenguinSlide()
Applies Penguin slide damage to the boss.
virtual int getDamage_Fumi() const =0
Gets the damage dealt by stomp (Fumi) attacks.
int updateQuake()
Applies multiplayer ground pound (Quake) damage to the boss.
dBossLifeInf_c(int life)
Constructs a new boss life manager.
virtual bool isNonDamage() const =0
Checks whether the boss has not yet been damaged.
int updateFire()
Applies fireball damage to the boss.
int mLife
The current hit point total.
virtual bool isTwoDamage() const =0
Checks whether the boss has been damaged twice.
virtual bool isDmgSection() const
Checks whether the current HP is at a damage section boundary.
int updateBlockHit()
Applies block hit damage to the boss.
virtual int getDamage_Quake() const =0
Gets the damage dealt by multiplayer ground pound (Quake) attacks.
int updateFumi()
Applies stomp (Fumi) damage to the boss.
virtual void damageRev(int dmg)
Post-damage callback invoked when a boss survives an attack.
int updateCommon(int dmg)
Common update logic for all the update methods.
virtual ~dBossLifeInf_c()
Destroys the boss life manager.
int updateShell()
Applies shell damage to the boss.
virtual int getDamage_HipAtk() const =0
Gets the damage dealt by ground pound (Hip) attacks.
int getSection() const
Gets the current section (zero-indexed).
dBossLife_Common_c(int num)
Constructs a new boss life manager.
virtual int getDamage_Fire() const override
Gets the damage dealt by fireball attacks.
virtual ~dBossLife_Common_c()
Destroys the boss life manager.
virtual bool isDmgSection() const override
Checks whether the current HP is at a damage section boundary.
virtual bool isTwoDamage() const override
Checks whether the boss has been damaged twice.
virtual int getDamage_Fumi() const override
Gets the damage dealt by stomp (Fumi) attacks.
virtual int getDamage_Star() const override
Gets the damage dealt by Star invincibility attacks.
virtual int getDamage_HipAtk() const override
Gets the damage dealt by ground pound (Hip) attacks.
virtual int getDamage_Shell() const override
Gets the damage dealt by shell attacks.
virtual bool isOneDamage() const override
Checks whether the boss has been damaged once.
virtual int getDamage_PenguinSlide() const override
Gets the damage dealt by Penguin slide attacks.
virtual int getDamage_Quake() const override
Gets the damage dealt by multiplayer ground pound (Quake) attacks.
virtual void damageRev(int dmg) override
Post-damage callback invoked when a boss survives an attack.
virtual bool isNonDamage() const override
Checks whether the boss has not yet been damaged.
virtual int getDamage_BlockHit() const override
Gets the damage dealt by block hit attacks.