1#include "Game/MapObj/WaterPressureBullet.hpp"
2#include "Game/LiveActor/ActorCameraInfo.hpp"
3#include "JSystem/JMath/JMath.hpp"
5WaterPressureBullet::WaterPressureBullet(
const char *pName) :
LiveActor(pName) {
18 mCameraInfo =
nullptr;
22 initModelManagerWithAnm(
"WaterBullet",
nullptr,
false);
23 MR::connectToSceneMapObjStrongLight(
this);
25 MR::addHitSensor(
this,
"body", 24, 4, 100.0f, TVec3f(0.0f, 0.0f, 0.0f));
26 MR::addHitSensor(
this,
"binder", 106, 4, 100.0f, TVec3f(0.0f, 0.0f, 0.0f));
27 initBinder(100.0f, 0.0f, 0);
28 initEffectKeeper(0,
nullptr,
false);
34 MR::initStarPointerTarget(
this, 100.0f, offs);
35 MR::initShadowVolumeSphere(
this, 75.0f);
36 MR::setShadowDropLength(
this,
nullptr, 1500.0f);
37 MR::registerDemoSimpleCastAll(
this);
38 initNerve(&NrvWaterPressureBullet::WaterPressureBulletNrvFly::sInstance);
42void WaterPressureBullet::kill() {
43 if (MR::isPlayerInRush() && mHostActor) {
44 MR::startBckPlayer(
"GCaptureBreak", (
const char*)
nullptr);
45 MR::endBindAndPlayerJumpWithRollLanding(
this,
mVelocity, 0);
50 MR::emitEffect(
this,
"Break");
51 MR::startSound(
this,
"SE_OJ_W_PRESS_BUBBLE_BREAK", -1, -1);
56void WaterPressureBullet::control() {
60 if (_B2 && mHostActor ==
nullptr) {
68 if (v1 && MR::isStarPointerPointing2POnTriggerButton(
this,
"弱",
true,
false)) {
80 f32 val = (45.511112f * MR::negFloat(2.5f));
81 MR::turnVecToVecCosOnPlane(&_8C, stack_8, _98, JMASCos(val));
88 MR::makeMtxFrontSidePos(&pos, _8C, _98,
mPosition);
89 MR::setBaseTRMtx(
this, pos);
92void WaterPressureBullet::shotWaterBullet(
LiveActor *pActor,
const TPos3f &rPos, f32 a3,
bool a4,
bool a5,
bool a6,
ActorCameraInfo **pInfo) {
93 f32 z = rPos.mMtx[2][2];
94 f32 y = rPos.mMtx[1][2];
95 f32 x = rPos.mMtx[0][2];
102 _8C.set<f32>(x, y, z);
111 _98.set<f32>(x, y, z);
114 MR::validateHitSensors(
this);
115 MR::invalidateClipping(
this);
116 MR::setShadowDropLength(
this,
nullptr, 1500.0f);
119 MR::onCalcGravity(
this);
122 setNerve(&NrvWaterPressureBullet::WaterPressureBulletNrvFly::sInstance);
125void WaterPressureBullet::exeFly() {
126 if (MR::isFirstStep(
this)) {
127 MR::startBck(
this,
"Shot",
nullptr);
130 if (MR::isBckOneTimeAndStopped(
this)) {
131 MR::startBck(
this,
"Move",
nullptr);
134 if (mHostActor !=
nullptr && MR::isBckOneTimeAndStopped(mHostActor)) {
135 MR::startBckPlayer(
"WaterBulletWait", (
const char*)
nullptr);
138 if (mHostActor !=
nullptr) {
139 MR::startLevelSound(
this,
"SE_OJ_LV_W_PRESS_BUBBLE_SUS", -1, -1, -1);
146 if (MR::isPadSwing(0) && mHostActor !=
nullptr && !_B2) {
147 MR::startSound(mHostActor,
"SE_PV_TWIST_START", -1, -1);
148 MR::startSound(mHostActor,
"SE_PM_SPIN_ATTACK", -1, -1);
149 MR::tryRumblePadMiddle(
this, 0);
150 setNerve(&NrvWaterPressureBullet::WaterPressureBulletNrvSpinKill::sInstance);
156 if (MR::isBinded(
this) || MR::isInWater(
this, TVec3f(0.0f, 0.0f, 0.0f))) {
161 if (!_B1 || mHostActor ==
nullptr || MR::isBindedGroundSand(
this)) {
169 JMAVECScaleAdd(grav->toCVec(), vel->toCVec(), vel->toVec(), -dot);
172 if (!_B2 && MR::isGreaterEqualStep(
this, 180) || _B2 && MR::isGreaterEqualStep(
this, 300)) {
177void WaterPressureBullet::exeSpinKill() {
178 if (MR::isFirstStep(
this)) {
179 MR::startBckPlayer(
"Spin2nd", (
const char*)
nullptr);
181 MR::invalidateHitSensors(
this);
183 if (MR::isPlayerInRush()) {
184 if (mHostActor !=
nullptr) {
185 MR::endBindAndPlayerJump(
this,
mVelocity, 0);
186 mHostActor =
nullptr;
196 if (MR::isSensorMapObj(a2)) {
202 if (MR::isMsgFireBallAttack(msg)) {
211 if (MR::isDead(
this)) {
215 if (MR::isMsgAutoRushBegin(msg) && MR::isSensorPlayer(a2) && mHostActor ==
nullptr) {
216 if (MR::isDemoActive()) {
221 if (!inviteMario(a2)) {
225 MR::startSound(
this,
"SE_OJ_W_PRESS_BUBBLE_IN", -1, -1);
226 MR::startSound(mHostActor,
"SE_PV_CATCH", -1, -1);
230 else if (msg == 152) {
233 else if (msg == 147) {
237 else if (msg == 161 && mHostActor !=
nullptr) {
245bool WaterPressureBullet::startHostCamera()
const {
246 if (_A4 !=
nullptr && mCameraInfo !=
nullptr) {
247 MR::startActorCameraNoTarget(_A4, *mCameraInfo, -1);
254bool WaterPressureBullet::endHostCamera()
const {
255 if (_A4 !=
nullptr && mCameraInfo !=
nullptr) {
256 MR::endActorCamera(_A4, *mCameraInfo,
true, -1);
263bool WaterPressureBullet::inviteMario(
HitSensor *pSensor) {
264 MR::tryRumblePadMiddle(
this, 0);
266 if (MR::isOnGroundPlayer() && MR::isNearAngleDegree(
mVelocity,
mGravity, 60.0f)) {
271 JMAVECScaleAdd(grav->toCVec(), vel->toCVec(), vel->toVec(), -dot);
275 MR::sendArbitraryMsg(76, pSensor,
getSensor(
"body"));
280 mHostActor = pSensor->mActor;
281 MR::startBckWithInterpole(
this,
"Touch", 0);
282 MR::startBckPlayer(
"WaterBulletStart", 2);
284 MR::setShadowDropLength(
this,
nullptr, 2000.0f);
288void WaterPressureBullet::updateSuffererMtx() {
292 if (isNerve(&NrvWaterPressureBullet::WaterPressureBulletNrvSpinKill::sInstance)) {
294 MR::calcFrontVec(&front, mHostActor);
295 MR::calcMtxFromGravityAndZAxis(&pos, mHostActor,
mGravity, front);
302 MR::setBaseTRMtx(
this, pos);
305WaterPressureBullet::~WaterPressureBullet() {
309namespace NrvWaterPressureBullet {
310 INIT_NERVE(WaterPressureBulletNrvFly);
311 INIT_NERVE(WaterPressureBulletNrvSpinKill);
313 void WaterPressureBulletNrvSpinKill::execute(
Spine *pSpine)
const {
315 bullet->exeSpinKill();
318 void WaterPressureBulletNrvFly::execute(
Spine *pSpine)
const {
The basis of a drawable actor that can contain states (see: Nerve)
TVec3f mRotation
3D vector of the actor's rotation.
TVec3f mPosition
3D vector of the actor's position.
TVec3f mVelocity
3D vector of the actor's velocity.
TVec3f mGravity
3D vector of the actor's gravity.
virtual MtxPtr getBaseMtx() const
Gets the base matrix of the model used for the actor.
HitSensor * getSensor(const char *pSensorName) const
Gets a sensor.
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
virtual void calcAndSetBaseMtx()
Calculates and sets the base matrix of the actor.