NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_enemy.hpp
1#pragma once
2
3#include <game/bases/d_actor_state.hpp>
4#include <game/bases/d_en_boyo_manager.hpp>
5#include <game/bases/d_en_combo.hpp>
6#include <game/bases/d_en_fumi_check.hpp>
7#include <game/bases/d_ice_manager.hpp>
9
10/// @unofficial
12 float mXSpeed;
13 float mYSpeed;
14 float mMaxYSpeed;
15 float mYAccel;
16 const sStateIDIf_c *mDeathState;
17 int mScore;
18 int m_18;
19 u8 mDirection;
20 u8 mKilledBy;
21};
22
23/// @unofficial
24class dDeathInfo_c {
25public:
26 dDeathInfo_c() : mIsDead(false) {}
27
28 dDeathInfo_c &operator=(const sDeathInfoData &other) {
29 mIsDead = true;
30 mSpeed.set(other.mXSpeed, other.mYSpeed);
31 mMaxYSpeed = other.mMaxYSpeed;
32 mYAccel = other.mYAccel;
33 mDeathState = other.mDeathState;
34 mScore = other.mScore;
35 m_18 = other.m_18;
36 mDirection = other.mDirection;
37 mKilledBy = other.mKilledBy;
38 return *this;
39 }
40
41 float getXSpeed() const {
42 return mSpeed.x;
43 }
44
45 float getYSpeed() const {
46 return mSpeed.y;
47 }
48
49 float getMaxYSpeed() const {
50 return mMaxYSpeed;
51 }
52
53 float getYAccel() const {
54 return mYAccel;
55 }
56
57 static const u8 smc_UNKNOWN_HIT = 50; ///< @unofficial
58
59private:
60 mVec2_c mSpeed;
61 float mMaxYSpeed;
62 float mYAccel;
63public:
64 const sStateIDIf_c *mDeathState;
65 int mScore;
66 int m_18;
67 u8 mDirection;
68 s8 mKilledBy;
69 bool mIsDead;
70};
71
72/// @unofficial
74public:
75 void update(int idx) {
76 if (mTimer[idx] != 0) {
77 mTimer[idx]--;
78 }
79 }
80
81 u16 mTimer[PLAYER_COUNT];
82};
83
84/// @brief An enemy actor.
85/// Note that the definition of "enemy" in this context is actually
86/// any interactible stage entity, not just ones that can hurt the player.
87/// @ingroup bases
88class dEn_c : public dActorMultiState_c {
89public:
90 /// @unofficial
91 enum FLAGS_e {
92 EN_IS_SHELL = BIT_FLAG(0),
93 EN_IS_HARD = BIT_FLAG(1),
94 EN_FLAG_4 = BIT_FLAG(4),
95 EN_FLAG_16 = BIT_FLAG(16),
96 EN_FLAG_24 = BIT_FLAG(24)
97 };
98
99 dEn_c(); ///< Constructs a new enemy actor.
100 virtual ~dEn_c(); ///< @copydoc dActorMultiState_c::~dActorMultiState_c
101
102 // Base class overrides
103
104 virtual void postCreate(fBase_c::MAIN_STATE_e status);
105 virtual int preExecute();
106 virtual void postExecute(fBase_c::MAIN_STATE_e status);
107 virtual int preDraw();
108
109 virtual void block_hit_init();
110
111 virtual void setEatTongue(dActor_c*);
112 virtual void setEatTongueOff(dActor_c*);
113 virtual bool setEatSpitOut(dActor_c*);
114
115 virtual void calcEatInScale(dActor_c *);
116
117 virtual void yoganSplashEffect(const mVec3_c&, float);
118 virtual void poisonSplashEffect(const mVec3_c&, float);
119
120 virtual void changeState(const sStateIDIf_c &newState);
121
122 // New virtual functions
123
124 virtual bool EnDamageCheck(dCc_c *self, dCc_c *other);
125 virtual bool PlDamageCheck(dCc_c *self, dCc_c *other);
126 virtual bool YoshiDamageCheck(dCc_c *self, dCc_c *other);
127 virtual bool EtcDamageCheck(dCc_c *self, dCc_c *other);
128
129 virtual void Normal_VsEnHitCheck(dCc_c *self, dCc_c *other);
130 virtual void Normal_VsPlHitCheck(dCc_c *self, dCc_c *other);
131 virtual void Normal_VsYoshiHitCheck(dCc_c *self, dCc_c *other);
132
133 virtual bool hitCallback_Star(dCc_c *self, dCc_c *other);
134 virtual bool hitCallback_Slip(dCc_c *self, dCc_c *other);
135 virtual bool hitCallback_Large(dCc_c *self, dCc_c *other);
136 virtual bool hitCallback_Spin(dCc_c *self, dCc_c *other);
137 virtual bool hitCallback_Rolling(dCc_c *self, dCc_c *other);
138 virtual bool hitCallback_WireNet(dCc_c *self, dCc_c *other);
139 virtual bool hitCallback_HipAttk(dCc_c *self, dCc_c *other);
140 virtual bool hitCallback_YoshiHipAttk(dCc_c *self, dCc_c *other);
141 virtual bool hitCallback_Screw(dCc_c *self, dCc_c *other);
142 virtual bool hitCallback_PenguinSlide(dCc_c *self, dCc_c *other);
143 virtual bool hitCallback_Cannon(dCc_c *self, dCc_c *other);
144 virtual bool hitCallback_Shell(dCc_c *self, dCc_c *other);
145 virtual bool hitCallback_Fire(dCc_c *self, dCc_c *other);
146 virtual bool hitCallback_Ice(dCc_c *self, dCc_c *other);
147 virtual bool hitCallback_YoshiBullet(dCc_c *self, dCc_c *other);
148 virtual bool hitCallback_YoshiFire(dCc_c *self, dCc_c *other);
149
150 virtual void setDeathInfo_Other(dActor_c *killedBy);
151 virtual void setDeathInfo_Quake(int);
152 virtual void setDeathInfo_IceBreak();
153 virtual void setDeathInfo_IceVanish();
154 void setDeathInfo_Smoke(dActor_c *killedBy);
155 void setDeathInfo_Fumi(dActor_c *killedBy, mVec2_c, const sStateIDIf_c &, int);
156 void setDeathInfo_YoshiFumi(dActor_c *killedBy);
157 void setDeathInfo_SpinFumi(dActor_c *killedBy, int);
158
159 virtual bool isQuakeDamage();
160 virtual void hitYoshiEat(dCc_c *self, dCc_c *other);
161
162 virtual void setDeathSound_HipAttk();
163 virtual void setDeathSound_Fire();
164 virtual void setDeathSound_Slip(dActor_c *actor);
165 virtual void setDeathSound_Spin();
166 virtual void setDeathSound_Rolling();
167
168 STATE_VIRTUAL_FUNC_DECLARE(dEn_c, DieFumi); ///< Being squished by a jump.
169 STATE_VIRTUAL_FUNC_DECLARE(dEn_c, DieFall); ///< Falling out of the screen.
172 STATE_VIRTUAL_FUNC_DECLARE(dEn_c, DieYoshiFumi);
173 STATE_VIRTUAL_FUNC_DECLARE(dEn_c, DieIceVanish);
181
182 virtual void fumidamageEffect(const mVec3_c &pos);
183 virtual void hipatkEffect(const mVec3_c &pos);
184 virtual void fumidamageSE(const mVec3_c &pos, int);
185
186 virtual void quakeAction(); ///< @unofficial
187
188 virtual bool checkDispIn();
189 virtual void setWaterSpeed();
190 virtual bool setDamage(dActor_c *actor);
191
192 void boyonInit();
193 virtual void boyonBegin();
194 virtual void calcBoyonScale();
195
196 virtual bool createIceActor();
197 virtual void setIceAnm();
198 virtual void returnAnm_Ice();
199 virtual void returnState_Ice();
200
201 virtual void beginFunsui();
202 virtual void endFunsui();
203 virtual BOOL isFunsui() const;
204
205 virtual bool checkComboClap(int max);
206
207 virtual void FumiJumpSet(dActor_c *actor);
208 virtual void FumiScoreSet(dActor_c *actor);
209 virtual void MameFumiJumpSet(dActor_c *actor);
210 virtual void YoshiFumiJumpSet(dActor_c *actor);
211 virtual void YoshiFumiScoreSet(dActor_c *actor);
212 void SpinFumiJumpSet(dActor_c *actor);
213 void SpinFumiScoreSet(dActor_c *actor);
214 virtual void fumiSE(dActor_c *actor);
215 virtual void fumiEffect(dActor_c *actor);
216 virtual void spinfumiSE(dActor_c *actor);
217 virtual void spinfumiEffect(dActor_c *actor);
218 virtual void mamefumiSE(dActor_c *actor);
219 virtual void mamefumiEffect(dActor_c *actor);
220 virtual void yoshifumiSE(dActor_c *actor);
221 virtual void yoshifumiEffect(dActor_c *actor);
222 void fumistepSE(dActor_c *actor);
223 void yoshifumistepSE(dActor_c *actor);
224 void PlayerFumiJump(dActor_c *actor, float jumpSpeed);
225 void setFumiComboScore(dActor_c *actor);
226
227 // Nonvirtuals
228
229 void hitdamageEffect(const mVec3_c &pos);
230
231 u32 checkWallAndBg(); ///< @unofficial
232 int Enfumi_check(dCc_c *self, dCc_c *other, int step);
233 u32 EnBgCheck();
234 u32 EnBgCheckFoot();
235 u32 EnBgCheckWall();
236 bool LineBoundaryCheck(dActor_c *actor);
237
238 void WaterCheck(mVec3_c &pos, float h); ///< @unofficial
239 dBc_c::WATER_TYPE_e WaterLineProc(const mVec3_c &pos, float h);
240 bool EnLavaCheck(const mVec3_c &pos);
241 bool EnWaterCheck(const mVec3_c &pos);
242 bool EnWaterFlagCheck(const mVec3_c &pos);
243
244 bool getPl_LRflag(const mVec3_c &pos); ///< Checks whether the nearest player is to the left of @p pos.
245 bool getPl_UDflag(const mVec3_c &pos); ///< Checks whether the nearest player is below @p pos.
246 bool Area_X_check(float x);
247 bool Area_XY_check(float x, float y);
248 bool carry_check(dActor_c *other);
249 bool PlayerCarryCheck(dActor_c *actor);
250 mVec3_c calcCarryPos(const mVec3_c &pos);
251
252 void Bound(float epsY, float scaleX, float scaleY);
253 void slipBound(dActor_c *actor);
254 void posMove();
255 bool turnangle_calc(const short *target, const short *delta);
256
257 void fireballInvalid(dCc_c *self, dCc_c *other);
258 void iceballInvalid(dCc_c *self, dCc_c *other);
259
260 void setNicePoint_Death();
261 void setDeadMode(dActor_c *actor, int);
262 void killIce();
263
264 static void normal_collcheck(dCc_c *self, dCc_c *other);
265 static bool CeilCheck(float y, dCc_c *cc);
266
267 int getIceMode() const { return 0; }
268
269 u8 getDeathFallDirection() const { return mDeathFallDirection; }
270
271 dDeathInfo_c mDeathInfo; ///< The parameters for the death animation.
272 u32 mCcValue;
273 u16 m_24; ///< @unused
274 u8 mPad1[6];
275 mVec3_c mFootPush;
276 mVec3_c mFootPush2;
277 u8 mDeathFallDirection; ///< The X direction to move towards on death.
278 u8 mIceDeathDirection; ///< The X direction to move towards on ice death.
279 bool mKilled; ///< Whether the enemy was killed.
280 u8 mPad2[1];
281 bool mFootAttr3;
282 bool mInLiquid; ///< Whether the enemy is in a liquid.
283 bool mFootAttr1;
284 u8 mPad3[5];
285 dEnBoyoMng_c mBoyoMng;
286 dIceMng_c mIceMng; ///< The ice manager for this enemy.
287 float mAirAccelY; ///< The Y acceleration before entering a liquid.
288 float mAirSpeedMaxY; ///< The maximum Y speed before entering a liquid.
289 float mAirMaxFallSpeed; ///< The maximum fall speed before entering a liquid.
290 u32 mFlags; ///< Flags for this actor. See FLAGS_e.
291 u16 mTimer1; ///< [Used in EN_HATENA_BALLON, for example]
292 u16 mTimer2; ///< [Used in EN_HATENA_BALLON, for example]
293
294 /// @brief Hit cooldown timers for each player.
295 /// This is used to prevent, for example, a thrown shell from hitting
296 /// the player that threw it.
298
299 u8 mTimer3; /// @todo Unused?
300 dEnCombo_c mCombo; ///< The enemy combo manager.
301 dEnFumiProc_c mFumiProc;
302
303 static const float smc_WATER_GRAVITY;
304 static const float smc_WATER_YMAXSPD;
305 static const float smc_WATER_FALLMAXSPD;
306 static const float smc_WATER_ROLL_DEC_RATE;
307
308 static const float smc_DEADFALL_GRAVITY;
309 static const float smc_DEADFALL_YSPEED;
310 static const float smc_DEADFALL_YSPEED_MAX;
311 static const s16 smc_DEADFALL_SPINSPEED;
312
313 static const u16 smc_NO_HIT_PLAYER_TIMER_DEFAULT = 5; ///< @unofficial
314 static const u16 smc_NO_HIT_PLAYER_TIMER_SPIT_OUT = 16; ///< @unofficial
315};
316
317extern const s8 l_EnMuki[]; ///< Multiplier for directions.
318extern const s16 l_base_angleY[]; ///< Default Y rotation angles per direction.
319extern const s16 l_base_angleY_add[]; ///< Default Y rotation animation increments per direction.
320extern const float l_base_fall_speed_x[]; ///< Default X fall speeds for death animation per direction.
dActorMultiState_c()
Constructs a new actor.
The minimum required implementation for a stage actor.
Definition d_actor.hpp:15
dActor_c()
Constructs a new actor.
Definition d_actor.cpp:46
void posMove()
Moves the actor by its speed.
Collider ("Collision Check") class - handles collisions between actors.
Definition d_cc.hpp:133
static const u8 smc_UNKNOWN_HIT
Definition d_enemy.hpp:57
static const u16 smc_NO_HIT_PLAYER_TIMER_DEFAULT
Definition d_enemy.hpp:313
float mAirMaxFallSpeed
The maximum fall speed before entering a liquid.
Definition d_enemy.hpp:289
virtual ~dEn_c()
Destroys the actor.
Definition d_enemy.cpp:52
u16 mTimer2
[Used in EN_HATENA_BALLON, for example]
Definition d_enemy.hpp:292
bool getPl_LRflag(const mVec3_c &pos)
Checks whether the nearest player is to the left of pos.
Definition d_enemy.cpp:398
u8 mDeathFallDirection
The X direction to move towards on death.
Definition d_enemy.hpp:277
u16 m_24
Definition d_enemy.hpp:273
u8 mIceDeathDirection
The X direction to move towards on ice death.
Definition d_enemy.hpp:278
void WaterCheck(mVec3_c &pos, float h)
Definition d_enemy.cpp:729
virtual bool setEatSpitOut(dActor_c *)
Callback for when the actor is about to be spat out.
Definition d_enemy.cpp:957
u32 checkWallAndBg()
Definition d_enemy.cpp:429
float mAirAccelY
The Y acceleration before entering a liquid.
Definition d_enemy.hpp:287
bool mKilled
Whether the enemy was killed.
Definition d_enemy.hpp:279
dDeathInfo_c mDeathInfo
The parameters for the death animation.
Definition d_enemy.hpp:271
virtual void postCreate(fBase_c::MAIN_STATE_e status)
post method for the create operation.
Definition d_enemy.cpp:54
dIceMng_c mIceMng
The ice manager for this enemy.
Definition d_enemy.hpp:286
dEnCombo_c mCombo
The enemy combo manager.
Definition d_enemy.hpp:300
u16 mTimer1
[Used in EN_HATENA_BALLON, for example]
Definition d_enemy.hpp:291
virtual void changeState(const sStateIDIf_c &newState)
Changes the actor's state to the given state.
dEn_c()
Constructs a new enemy actor.
Definition d_enemy.cpp:28
static const u16 smc_NO_HIT_PLAYER_TIMER_SPIT_OUT
Definition d_enemy.hpp:314
virtual void quakeAction()
Definition d_enemy.cpp:144
virtual void setEatTongueOff(dActor_c *)
Callback for when the eating action is canceled.
Definition d_enemy.cpp:951
virtual int preExecute()
pre method for the execute operation.
Definition d_enemy.cpp:63
virtual void block_hit_init()
Callback for when a block directly beneath the actor is hit.
Definition d_enemy.cpp:1005
float mAirSpeedMaxY
The maximum Y speed before entering a liquid.
Definition d_enemy.hpp:288
dPlayerDownTimer_c mNoHitPlayer
Hit cooldown timers for each player. This is used to prevent, for example, a thrown shell from hittin...
Definition d_enemy.hpp:297
virtual void postExecute(fBase_c::MAIN_STATE_e status)
post method for the execute operation.
Definition d_enemy.cpp:108
virtual void calcEatInScale(dActor_c *)
Adjusts the actor's scale while being eaten.
Definition d_enemy.cpp:968
virtual void poisonSplashEffect(const mVec3_c &, float)
Generates a poison water splash effect.
Definition d_enemy.cpp:807
virtual void setEatTongue(dActor_c *)
Callback for when the actor is targeted by Yoshi's tongue.
Definition d_enemy.cpp:945
virtual void yoganSplashEffect(const mVec3_c &, float)
Generates a lava splash effect.
Definition d_enemy.cpp:792
virtual int preDraw()
pre method for the draw operation.
Definition d_enemy.cpp:115
u32 mFlags
Flags for this actor. See FLAGS_e.
Definition d_enemy.hpp:290
bool getPl_UDflag(const mVec3_c &pos)
Checks whether the nearest player is below pos.
Definition d_enemy.cpp:407
bool mInLiquid
Whether the enemy is in a liquid.
Definition d_enemy.hpp:282
virtual bool checkComboClap(int max)
Definition d_enemy.cpp:544
MAIN_STATE_e
The possible operation results.
Definition f_base.hpp:36
A two-dimensional floating point vector.
Definition m_vec.hpp:26
A three-dimensional floating point vector.
Definition m_vec.hpp:122
The interface for state IDs.
#define STATE_VIRTUAL_FUNC_DECLARE(class, name)
Declares a virtual state.
Definition s_State.hpp:22