NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_enemy_carry.cpp
1#include <game/bases/d_enemy_carry.hpp>
2#include <game/bases/d_a_player_manager.hpp>
3
6
7const float dEnemyCarry_c::smc_DIR_MODE0[2] = {2.5f, -2.5f};
8const float dEnemyCarry_c::smc_DIR_MODE1[2] = {3.0f, -3.0f};
9
11
13 float endSpeed;
14 if (mThrowSpeed == 0) {
15 endSpeed = smc_DIR_MODE0[mDirection];
16 } else {
17 endSpeed = smc_DIR_MODE1[mDirection];
18 }
19 if (mDirection == (actor->mSpeed.x < 0.0f)) {
20 endSpeed += actor->mSpeed.x * 0.5f;
21 }
22
23 // [Either programmer error or some inline stuff, this never changes the value of endSpeed]
24 if (endSpeed < mSpeedMax.x) {
25 endSpeed = (endSpeed > mSpeedMax.x) ? mSpeedMax.x : endSpeed;
26 } else if (endSpeed > mSpeedMax.x) {
27 endSpeed = (endSpeed < mSpeedMax.x) ? mSpeedMax.x : endSpeed;
28 }
29 mSpeed.set(endSpeed, 0.0f, 0.0f);
30}
31
36
41
44 0.0f,
45 3.0f,
46 -4.0f,
47 -0.1875f,
48 &StateID_DieFall,
49 -1,
50 -1,
52 (u8) *actor->getPlrNo()
53 };
54}
55
56void dEnemyCarry_c::initializeState_Carry() {
57 dAcPy_c *player = daPyMng_c::getPlayer(mPlayerNo);
58
59 if (player->mAmiLayer == 1) {
60 mAmiLayer = 0;
61 } else {
62 mAmiLayer = 1;
63 }
64 mCc.mAmiLine = l_Ami_Line[mAmiLayer];
65 mBc.mAmiLine = l_Ami_Line[mAmiLayer];
66 mCc.mCcData.mVsKind |= BIT_FLAG(CC_KIND_KILLER);
67 mCc.mCcData.mAttack = CC_ATTACK_SHELL;
68 mRc.setRide(nullptr);
69 mWasDropped = false;
70}
71
72void dEnemyCarry_c::finalizeState_Carry() {
73 dAcPy_c *player = daPyMng_c::getPlayer(mPlayerNo);
74
75 player->cancelCarry(this);
76 mCc.mCcData.mAttack = CC_KIND_PLAYER;
77 mCc.mCcData.mVsKind &= ~BIT_FLAG(CC_KIND_KILLER);
78 mRc.setRide(nullptr);
79 mBc.mFlags = 0;
81}
82
83void dEnemyCarry_c::executeState_Carry() {
84 dAcPy_c *player = daPyMng_c::getPlayer(mPlayerNo);
85
88 mAngle.y = l_base_angleY[mDirection];
89 if (checkWallAndBg()) {
91 } else {
92 if (!(mBc.mFlags & 0x15 << mDirection)) {
93 mPos.x += l_EnMuki[mDirection] * 6.0f;
94 }
95 mPlayerNo = *player->getPlrNo();
97 setThrowSpeed(player);
99 } else {
100 mPos.y += 2.0f;
102 }
103 }
104 }
105}
106
107void dEnemyCarry_c::initializeState_Throw() {
108 mNoHitPlayer.mTimer[mPlayerNo] = 12;
109 mCc.mCcData.mVsKind |= BIT_FLAG(CC_KIND_KILLER) | BIT_FLAG(CC_KIND_ITEM);
110 if (!mWasDropped) {
111 mCc.mCcData.mAttack = CC_ATTACK_SHELL;
112 }
113}
114
115void dEnemyCarry_c::finalizeState_Throw() {
116 mCc.mCcData.mVsKind &= ~(BIT_FLAG(CC_KIND_KILLER) | BIT_FLAG(CC_KIND_ITEM));
117 mCc.mCcData.mAttack = CC_KIND_PLAYER;
118 mAccelF = 0.0f;
119 mSpeedMax.x = 0.0f;
120}
121
122void dEnemyCarry_c::executeState_Throw() {}
@ CARRY_RELEASE
The actor is being released from carry.
Definition d_actor.hpp:54
@ CARRY_THROW
The actor is being actively thrown by the player.
Definition d_actor.hpp:55
dBc_c mBc
The actor-to-tile collision sensor.
Definition d_actor.hpp:342
u32 mCarryingFlags
The actor's carry actions. See CARRY_ACTION_e.
Definition d_actor.hpp:333
u8 mAmiLayer
The actor's layer for chainlink fences.
Definition d_actor.hpp:379
u8 mDirection
The actor's facing direction.
Definition d_actor.hpp:351
dCc_c mCc
The actor-to-actor collision sensor.
Definition d_actor.hpp:341
u8 mThrowDirection
The actor's direction when thrown or dropped after carrying.
Definition d_actor.hpp:334
s8 mPlayerNo
The player associated with the actor, -1 if not associated to any player.
Definition d_actor.hpp:375
dActor_c()
Constructs a new actor.
Definition d_actor.cpp:46
dRc_c mRc
The actor's ride surface manager.
Definition d_actor.hpp:343
virtual s8 * getPlrNo()
Gets the player number associated with the actor. See mPlayerNo.
Definition d_actor.hpp:105
float mAccelF
The actor's horizontal acceleration.
mVec3_c mSpeed
The actor's speed.
mVec3_c mPos
The actor's position.
mVec3_c mSpeedMax
The actor's maximum speed.
mAng3_c mAngle
The actor's rotation (for 2D actors).
u32 checkWallAndBg()
Definition d_enemy.cpp:429
dDeathInfo_c mDeathInfo
The parameters for the death animation.
Definition d_enemy.hpp:267
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:293
virtual void changeState(const sStateIDIf_c &newState)
Changes the actor's state to the given state.
A carryable enemy. This class is only used as a base for daEnJumpdai_c.
void setDeathInfo_CarryBgIn(dActor_c *)
Sets the death info for when the enemy is stuck in background collision.
virtual void setPutOnChangeState()
Drops this enemy.
static const float smc_DIR_MODE1[]
dEnemyCarry_c()
Constructs a new carryable enemy.
bool mWasDropped
Whether the enemy was dropped or thrown. If dropped, it will not collide with other entities.
virtual void setThrowSpeed(dActor_c *actor)
Sets the throw speed based on the actor throwing it.
virtual void setThrowChangeState()
Throws this enemy.
static const float smc_DIR_MODE0[]
u8 mThrowSpeed
0 => X speed = 2.5, 1 => X speed = 3.0
static sFStateVirtualID_c< dEnemyCarry_c > StateID_Throw
The enemy is being thrown / put down.
const u8 l_Ami_Line[]
The sub-layer for each side of chainlink fences.
Definition d_actor.cpp:38
#define STATE_VIRTUAL_DEFINE(class, name)
Defines a virtual state.
Definition s_State.hpp:46