1#include "Game/Enemy/PackunPetit.hpp"
2#include "Game/LiveActor/ModelObj.hpp"
3#include <JSystem/JMath/JMath.hpp>
5PackunPetit::PackunPetit(
const char *pName) :
LiveActor(pName) {
6 mScaleController =
nullptr;
7 mStarPointerState =
nullptr;
11 mBlownModel =
nullptr;
16 MR::initDefaultPos(
this, rIter);
17 initModelManagerWithAnm(
"PackunPetit",
nullptr,
false);
18 MR::connectToSceneEnemy(
this);
20 MR::addHitSensorAtJointMapObj(
this,
"body",
"Head", 8, 90.0f, TVec3f(50.0f, 0.0f, 0.0f));
21 MR::addHitSensorAtJointEnemyAttack(
this,
"attack",
"Head", 8, 50.0f, TVec3f(50.0f, 0.0f, 0.0f));
22 MR::addHitSensorMapObj(
this,
"stalk", 8, 100.0f, TVec3f(0.0f, 0.0f, 0.0f));
23 initEffectKeeper(2,
nullptr,
false);
24 MR::addEffectHitNormal(
this,
nullptr);
26 MR::initLightCtrl(
this);
27 MR::initShadowFromCSV(
this,
"Shadow");
28 MR::calcGravity(
this);
29 MR::useStageSwitchWriteDead(
this, rIter);
30 MR::declareCoin(
this, 1);
31 MR::declareStarPiece(
this, 6);
36 MR::initStarPointerTargetAtJoint(
this,
"Head", 100.0f, offs);
39 MR::getJMapInfoArg0NoInit(rIter, &mDontTurn);
40 MR::calcFrontVec(&_94,
this);
42 initNerve(&NrvPackunPetit::PackunPetitNrvWait::sInstance);
46void PackunPetit::initAfterPlacement() {
47 MR::initEffectAfterPlacement(
this);
50void PackunPetit::exeNonActive() {
51 if (MR::isFirstStep(
this)) {
52 MR::invalidateHitSensors(
this);
53 MR::offCalcAnim(
this);
54 MR::offCalcShadow(
this,
"JawA");
57 if (MR::isNearPlayerAnyTime(
this, 5000.0f)) {
58 setNerve(&NrvPackunPetit::PackunPetitNrvWait::sInstance);
62void PackunPetit::exeWait() {
63 if (MR::isFirstStep(
this)) {
64 MR::startBckWithInterpole(
this,
"Wait", 60);
67 if (MR::isNearPlayer(
this, 1700.0f)) {
68 setNerve(&NrvPackunPetit::PackunPetitNrvFind::sInstance);
75void PackunPetit::exeFind() {
76 if (MR::isFirstStep(
this)) {
77 MR::startBck(
this,
"Suspect",
nullptr);
80 if (MR::isBckStopped(
this)) {
81 setNerve(&NrvPackunPetit::PackunPetitNrvThreat::sInstance);
85void PackunPetit::exeThreat() {
86 if (MR::isFirstStep(
this)) {
87 MR::startBck(
this,
"Threat",
nullptr);
90 MR::startLevelSound(
this,
"SE_EM_LV_PACKUNPETIT_THREAT", -1, -1, -1);
96 TVec3f* pos = MR::getPlayerPos();
97 MR::turnDirectionToTargetUseGroundNormalDegree(
this, &_94, *pos, 2.0f);
100 if (MR::isGreaterStep(
this, 50) && MR::isNearPlayer(
this, 1100.0f) && (MR::isFaceToPlayerHorizontalDegree(
this, _94, 10.0f) || mDontTurn)) {
101 setNerve(&NrvPackunPetit::PackunPetitNrvAttackStart::sInstance);
103 else if (!MR::isNearPlayer(
this, 2000.0f)) {
104 setNerve(&NrvPackunPetit::PackunPetitNrvWait::sInstance);
108void PackunPetit::exeTurn() {
109 if (MR::isFirstStep(
this)) {
110 if (isNerve(&NrvPackunPetit::PackunPetitNrvLeftTurn::sInstance)) {
111 MR::startBck(
this,
"TurnLeft",
nullptr);
114 MR::startBck(
this,
"TurnRight",
nullptr);
118 f32 step = getNerveStep();
119 step = (10.0f - step);
123 TVec3f* pos = MR::getPlayerPos();
124 MR::turnDirectionToTargetUseGroundNormalDegree(
this, &_94, *pos, step);
125 if (MR::isBckStopped(
this)) {
126 setNerve(&NrvPackunPetit::PackunPetitNrvThreat::sInstance);
130void PackunPetit::exeAttackStart() {
131 if (MR::isFirstStep(
this)) {
132 MR::startBck(
this,
"Attack",
nullptr);
135 if (MR::isStep(
this, 70)) {
136 setNerve(&NrvPackunPetit::PackunPetitNrvAttack::sInstance);
140void PackunPetit::exeHitWaitForAttack() {
141 if (MR::isFirstStep(
this) && !MR::isBckPlaying(
this,
"Attack")) {
142 MR::startBck(
this,
"Impact",
nullptr);
145 if (MR::isBckStopped(
this)) {
146 setNerve(&NrvPackunPetit::PackunPetitNrvHit::sInstance);
150void PackunPetit::exeHit() {
151 if (MR::isFirstStep(
this)) {
152 MR::startBck(
this,
"Hit",
nullptr);
155 if (MR::isBckStopped(
this) && !tryTurn()) {
160void PackunPetit::exeTrampleDown() {
161 if (MR::isFirstStep(
this)) {
162 MR::startBck(
this,
"Press",
nullptr);
163 MR::startSound(
this,
"SE_EM_STOMPED_S", -1, -1);
164 MR::invalidateHitSensors(
this);
167 if (MR::isBckStopped(
this)) {
172void PackunPetit::exePunchDown() {
173 if (MR::isFirstStep(
this)) {
174 MR::invalidateHitSensor(
this,
"body");
175 MR::invalidateHitSensor(
this,
"attack");
176 mBlownModel->makeActorAppeared();
177 MR::copyJointPos(
this,
"Head", &mBlownModel->
mPosition);
178 MR::startBck(mBlownModel,
"BlowHead",
nullptr);
179 MR::startBck(
this,
"Blow",
nullptr);
180 MR::startBlowHitSound(
this);
185 if (!MR::isHiddenModel(mBlownModel) && (MR::isStep(
this, 20) || MR::checkStikeBallToMap(mBlownModel->
mPosition, 50.0f))) {
186 MR::emitEffect(mBlownModel,
"Death");
187 MR::appearStarPiece(
this, mBlownModel->
mPosition, 3, 10.0f, 40.0f,
false);
188 MR::startSound(
this,
"SE_OJ_STAR_PIECE_BURST", -1, -1);
189 MR::hideModel(mBlownModel);
192 if (MR::isStep(
this, 30)) {
197void PackunPetit::exeSwoonStart() {
198 if (MR::isFirstStep(
this)) {
199 MR::startBck(
this,
"SwoonStart",
nullptr);
202 if (MR::isBckStopped(
this)) {
203 setNerve(&NrvPackunPetit::PackunPetitNrvSwoon::sInstance);
207void PackunPetit::exeSwoon() {
208 if (MR::isFirstStep(
this)) {
209 MR::startBck(
this,
"Swoon",
nullptr);
212 MR::startLevelSound(
this,
"SE_EM_LV_SWOON_S", -1, -1, -1);
214 if (MR::isStep(
this, 250)) {
219void PackunPetit::exeSwoonToThreat() {
220 if (MR::isFirstStep(
this)) {
221 MR::startBck(
this,
"SwoonToThreat",
nullptr);
224 if (MR::isBckStopped(
this)) {
225 setNerve(&NrvPackunPetit::PackunPetitNrvThreat::sInstance);
229void PackunPetit::exeSwoonOnEnd() {
230 mStarPointerState->kill();
233void PackunPetit::exeDPDSwoon() {
234 if (MR::updateActorState(
this, mStarPointerState)) {
239void PackunPetit::exeAttackBack() {
240 if (MR::isBckStopped(
this)) {
247void PackunPetit::exeAttack() {
248 if (MR::isStep(
this, 0xC)) {
249 setNerve(&NrvPackunPetit::PackunPetitNrvAttackBack::sInstance);
253void PackunPetit::exeNonActiveOnEnd() {
254 MR::validateHitSensors(
this);
255 MR::onCalcAnim(
this);
256 MR::onCalcShadow(
this,
"JawA");
259void PackunPetit::kill() {
260 if (!MR::isDead(mBlownModel)) {
261 if (!MR::isHiddenModel(mBlownModel)) {
262 MR::emitEffect(mBlownModel,
"Death");
263 MR::appearStarPiece(
this, mBlownModel->
mPosition, 3, 10.0f, 40.0f,
false);
264 MR::startSound(mBlownModel,
"SE_OJ_STAR_PIECE_BURST", -1, -1);
270 if (!MR::isValidSwitchDead(
this)) {
275 if (MR::isValidSwitchDead(
this)) {
276 MR::onSwitchDead(
this);
279 MR::emitEffect(
this,
"Death");
280 MR::startSound(
this,
"SE_EM_EXPLODE_S", -1, -1);
286 MR::calcUpVec(&up,
this);
289 MR::makeMtxUpFrontPos(&mtxUp, up, _94,
mPosition);
291 mult.multPS(
mScale, mScaleController->_C);
292 MR::setBaseScale(
this, mult);
295void PackunPetit::control() {
296 mScaleController->update();
314 bool isTrampleOrPunch =
false;
316 if (isNerve(&NrvPackunPetit::PackunPetitNrvTrampleDown::sInstance) || isNerve(&NrvPackunPetit::PackunPetitNrvPunchDown::sInstance)) {
317 isTrampleOrPunch =
true;
320 if (isTrampleOrPunch) {
324 if (MR::isMsgLockOnStarPieceShoot(msg)) {
328 if (MR::isMsgStarPieceAttack(msg)) {
329 setNerve(&NrvPackunPetit::PackunPetitNrvSwoonStart::sInstance);
333 bool isWaitOrHit =
false;
335 if (isNerve(&NrvPackunPetit::PackunPetitNrvHitWaitForAttack::sInstance) || isNerve(&NrvPackunPetit::PackunPetitNrvHit::sInstance)) {
342 else if (MR::isMsgInvincibleAttack(msg) || MR::isMsgFireBallAttack(msg)) {
346 else if (isNerve(&NrvPackunPetit::PackunPetitNrvAttack::sInstance)) {
349 else if (MR::isMsgPlayerTrample(msg)) {
350 MR::tryRumbleDefaultHit(
this, 0);
351 setNerve(&NrvPackunPetit::PackunPetitNrvTrampleDown::sInstance);
354 else if (MR::isMsgPlayerHipDrop(msg)) {
355 MR::tryRumbleDefaultHit(
this, 0);
356 setNerve(&NrvPackunPetit::PackunPetitNrvTrampleDown::sInstance);
359 else if (MR::isMsgPlayerHitAll(msg)) {
360 MR::stopSceneForDefaultHit(5);
370 bool isTrampleOrPunch =
false;
372 if (isNerve(&NrvPackunPetit::PackunPetitNrvTrampleDown::sInstance) || isNerve(&NrvPackunPetit::PackunPetitNrvPunchDown::sInstance)) {
373 isTrampleOrPunch =
true;
376 if (isTrampleOrPunch) {
380 if (MR::isMsgToEnemyAttackBlow(msg)) {
382 setNerve(&NrvPackunPetit::PackunPetitNrvPunchDown::sInstance);
385 else if (MR::isMsgToEnemyAttackTrample(msg)) {
386 setNerve(&NrvPackunPetit::PackunPetitNrvTrampleDown::sInstance);
394 bool isSwoon =
false;
396 if (isNerve(&NrvPackunPetit::PackunPetitNrvSwoonStart::sInstance) || isNerve(&NrvPackunPetit::PackunPetitNrvSwoonStart::sInstance)) {
404 if (!MR::isSensorPlayer(a2)) {
408 if (MR::isMsgPlayerKick(msg)) {
409 MR::stopSceneForDefaultHit(5);
417void PackunPetit::initBlowModel() {
418 mBlownModel = MR::createModelObjMapObjStrongLight(
"吹っ飛びモデル",
"PackunPetitHead",
nullptr);
420 MR::initShadowVolumeSphere(mBlownModel, 70.0f);
421 MR::invalidateClipping(mBlownModel);
422 MR::initLightCtrl(mBlownModel);
423 mBlownModel->makeActorDead();
428 v6.subtract(a2->mPosition, a1->mPosition);
430 f32 dot = grav->dot(v6);
431 JMAVECScaleAdd(grav->toCVec(), v6.toCVec(), v6.toVec(), -dot);
436 JMAVECScaleAdd(
mGravity.toCVec(), v5.toCVec(), v5.toVec(), -40.0f);
438 setNerve(&NrvPackunPetit::PackunPetitNrvPunchDown::sInstance);
441void PackunPetit::selectNrvWait() {
442 if (!MR::isNearPlayer(
this, 1700.0f)) {
443 setNerve(&NrvPackunPetit::PackunPetitNrvWait::sInstance);
446 if (isNerve(&NrvPackunPetit::PackunPetitNrvSwoon::sInstance)) {
447 setNerve(&NrvPackunPetit::PackunPetitNrvSwoonToThreat::sInstance);
450 setNerve(&NrvPackunPetit::PackunPetitNrvThreat::sInstance);
455bool PackunPetit::tryNonActive() {
456 if (MR::isNearPlayerAnyTime(
this, 5000.0f)) {
460 setNerve(&NrvPackunPetit::PackunPetitNrvNonActive::sInstance);
464bool PackunPetit::tryTurn() {
469 if (MR::isFaceToPlayerHorizontalDegree(
this, _94, 90.0f)) {
473 TVec3f* pos = MR::getPlayerPos();
477 MR::calcSideVec(&sideVec,
this);
479 if (playerDist.dot(sideVec) > 0.0f) {
480 setNerve(&NrvPackunPetit::PackunPetitNrvLeftTurn::sInstance);
483 setNerve(&NrvPackunPetit::PackunPetitNrvRightTurn::sInstance);
489bool PackunPetit::tryDPDSwoon() {
490 if (isNerve(&NrvPackunPetit::PackunPetitNrvDPDSwoon::sInstance)) {
494 bool isSwoon =
false;
496 if (isNerve(&NrvPackunPetit::PackunPetitNrvSwoonStart::sInstance) || isNerve(&NrvPackunPetit::PackunPetitNrvSwoon::sInstance)) {
504 bool isTrampleOrPunch =
false;
506 if (isNerve(&NrvPackunPetit::PackunPetitNrvTrampleDown::sInstance) || isNerve(&NrvPackunPetit::PackunPetitNrvPunchDown::sInstance)) {
507 isTrampleOrPunch =
true;
510 if (isTrampleOrPunch) {
514 if (!mStarPointerState->tryStartPointBind()) {
518 setNerve(&NrvPackunPetit::PackunPetitNrvDPDSwoon::sInstance);
522PackunPetit::~PackunPetit() {
526namespace NrvPackunPetit {
527 INIT_NERVE(PackunPetitNrvNonActive);
528 INIT_NERVE(PackunPetitNrvWait);
529 INIT_NERVE(PackunPetitNrvFind);
530 INIT_NERVE(PackunPetitNrvThreat);
531 INIT_NERVE(PackunPetitNrvLeftTurn);
532 INIT_NERVE(PackunPetitNrvRightTurn);
533 INIT_NERVE(PackunPetitNrvAttackStart);
534 INIT_NERVE(PackunPetitNrvAttack);
535 INIT_NERVE(PackunPetitNrvAttackBack);
536 INIT_NERVE(PackunPetitNrvHitWaitForAttack);
537 INIT_NERVE(PackunPetitNrvHit);
538 INIT_NERVE(PackunPetitNrvTrampleDown);
539 INIT_NERVE(PackunPetitNrvPunchDown);
540 INIT_NERVE(PackunPetitNrvSwoonStart);
541 INIT_NERVE(PackunPetitNrvSwoon);
542 INIT_NERVE(PackunPetitNrvSwoonToThreat);
543 INIT_NERVE(PackunPetitNrvDPDSwoon);
The basis of a drawable actor that can contain states (see: Nerve)
TVec3f mPosition
3D vector of the actor's position.
TVec3f mScale
3D vector of the actor's scale.
TVec3f mVelocity
3D vector of the actor's velocity.
TVec3f mGravity
3D vector of the actor's gravity.
void initWithoutIter()
Initializes a NameObj without a JMapInfoIter instance.
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.