1#include "Game/MapObj/PowerStar.hpp"
2#include "Game/MapObj/PowerStarHolder.hpp"
3#include "Game/LiveActor/LiveActorGroup.hpp"
4#include "Game/Util.hpp"
5#include "JSystem/JMath.hpp"
7const GXColor lightColor[5] = { { 0x96, 0x96, 0x32, 0 },
8 { 0x32, 0x32, 0x96, 0 },
9 { 0x32, 0x96, 0x32, 0 },
10 { 0x96, 0x32, 0x32, 0 },
11 { 0x64, 0x64, 0x64, 0}
15 void setupColor(
LiveActor *pActor,
bool useFrame,
int frame) NO_INLINE {
16 MR::startBtp(pActor,
"PowerStar");
17 MR::setBtpFrameAndStop(pActor, useFrame ? 0.0f : frame);
18 MR::startBva(pActor,
"PowerStar");
19 MR::setBvaFrameAndStop(pActor, useFrame ? 1.0f : 0.0f);
22 void setupColorGrandStar(
LiveActor *pActor,
bool dontStartRecover) NO_INLINE {
23 if (dontStartRecover) {
24 MR::showMaterial(pActor,
"GrandStarEmpty");
25 MR::hideMaterial(pActor,
"FooMat");
28 MR::showMaterial(pActor,
"FooMat");
29 MR::hideMaterial(pActor,
"GrandStarEmpty");
30 MR::startBrk(pActor,
"Recover");
31 MR::setBrkFrameEndAndStop(pActor);
35 void requestPointLight(
const LiveActor *pActor,
int a2) NO_INLINE {
37 MR::copyJointPos(pActor,
"PowerStar", &joint_pos);
38 MR::requestPointLight(pActor, TVec3f(joint_pos), lightColor[a2], 1.0f, -1);
42PowerStar::PowerStar(
const char *pName) :
LiveActor(pName),
43 mPowerStarId(-1), mIsInDemo(false), mAppearPosition(gZeroVec), _A0(gZeroVec), _AC(gZeroVec) {
45 mPowerStarModelObj = 0;
62 mIsGrandStar = MR::isEqualObjectName(rIter,
"GrandStar");
63 initMapToolInfo(rIter);
67 MR::connectToSceneIndirectMapObj(
this);
68 initSensorGrandStar();
71 MR::connectToSceneNoSilhouettedMapObj(
this);
73 MR::addHitSensor(
this,
"body", 0x67, 8, 75.0f, TVec3f(0.0f, 0.0f, 0.0f));
76 initEffectKeeper(0, 0,
false);
77 if (MR::isGalaxyGhostCometAppearInCurrentStage()) {
78 MR::invalidateClipping(
this);
81 MR::setClippingTypeSphere(
this, 5000.0f);
85 MR::initActorCamera(
this, rIter, &mCameraInfo);
86 ModelObj* power_star_mdl = mPowerStarModelObj;
88 MR::initAnimCamera(power_star_mdl, cam_info, mIsGrandStar ?
"GrandStarGet" :
"PowerStarGet");
91 if (MR::isStageKoopaVs()) {
92 bool isStageV3 = MR::isStageKoopaVs3();
93 power_star_mdl = mPowerStarModelObj;
94 cam_info = mCameraInfo;
95 MR::initAnimCamera(power_star_mdl, cam_info, isStageV3 ?
"DemoKoopaGrandStarVs3" :
"DemoKoopaGrandStar");
97 if (MR::isStageKoopaVs3()) {
98 MR::initAnimCamera(mPowerStarModelObj, mCameraInfo, cStageClearAnimNameKoopaVs3);
103 if (MR::tryRegisterDemoCast(
this, rIter)) {
104 MR::registerDemoActionNerve(
this, &NrvPowerStar::PowerStarNrvWeakNoRotate::sInstance,
"ミニ太陽消失");
105 MR::registerDemoActionNerve(
this, &NrvPowerStar::PowerStarNrvWeakToWait::sInstance,
"グランドスター復活");
106 MR::registerDemoSimpleCastAll(
this);
110 initNerve(&NrvPowerStar::PowerStarNrvWait::sInstance);
112 if (mPowerStarId == -1) {
132void PowerStar::initAfterPlacement() {
136void PowerStar::appear() {
138 MR::invalidateClipping(
this);
139 requestAppearOrWait();
142void PowerStar::makeActorAppeared() {
145 LiveActor::makeActorAppeared();
148void PowerStar::requestAppear() {
150 MR::invalidateClipping(
this);
152 MR::invalidateHitSensors(
this);
153 setNerve(&NrvPowerStar::PowerStarNrvWaitStartAppear::sInstance);
155 if (MR::isStageKoopaVs()) {
156 MR::requestStartDemoMarioPuppetableWithoutCinmeaFrame(
this, cAppearDemoName, &NrvPowerStar::PowerStarNrvAppearDemoKoopa::sInstance, 0);
159 MR::requestStartDemoWithoutCinemaFrame(
this, cAppearDemoName, &NrvPowerStar::PowerStarNrvAppearDemoRise::sInstance, 0);
163void PowerStar::setDemoAppearPos(
const TVec3f &rVec) {
164 bool isinArray = MR::getGroupFromArray(
this);
166 mCameraActor = getNearestAppearPoint(rVec);
167 mAppearPosition.set(mCameraActor->
mPosition);
173bool PowerStar::isEndAppearDemo()
const {
176 if (isNerve(&NrvPowerStar::PowerStarNrvWait::sInstance) || isNerve(&NrvPowerStar::PowerStarNrvStageClearDemo::sInstance)) {
183void PowerStar::offAppearDemo() {
190 hasPowerStar = MR::hasPowerStarInCurrentStageWithDeclarer(a2->
mName, a3);
192 if (MR::isPowerStarGreenInCurrentStageWithDeclarer(a2->
mName, a3)) {
195 else if (MR::isPowerStarRedInCurrentStageWithDeclarer(a2->
mName, a3)) {
199 if (MR::isGrandStarInCurrentStageWithDeclarer(a2->
mName, a3)) {
200 ::setupColorGrandStar(pActor, hasPowerStar);
203 ::setupColor(pActor, hasPowerStar, val);
207void PowerStar::setupColorAtResultSequence(
LiveActor *pPowerStar,
bool a2) {
210 hasStarAtRes = MR::hasPowerStarAtResultSequence();
212 if (MR::isPowerStarGreenAtResultSequence()) {
215 else if (MR::isPowerStarRedAtResultSequence()) {
220 ::setupColorGrandStar(pPowerStar, hasStarAtRes);
223 ::setupColor(pPowerStar, hasStarAtRes, val);
227void PowerStar::requestPointLight(
const LiveActor *pActor,
const NameObj *a2, s32 a3) {
230 if (MR::hasPowerStarInCurrentStageWithDeclarer(a2->
mName, a3)) {
233 else if (MR::isPowerStarGreenInCurrentStageWithDeclarer(a2->
mName, a3)) {
236 else if (MR::isPowerStarRedInCurrentStageWithDeclarer(a2->
mName, a3)) {
240 ::requestPointLight(pActor, colorIdx);
243void PowerStar::requestPointLightAtResultSequence(
const LiveActor *pActor) {
246 if (MR::hasPowerStarAtResultSequence()) {
249 else if (MR::isPowerStarGreenAtResultSequence()) {
252 else if (MR::isPowerStarRedAtResultSequence()) {
256 ::requestPointLight(pActor, val);
259f32 PowerStar::getPowerStarWaitRotateSpeed() {
263s32 PowerStar::getBtpFrameCurrentStage(s32 a1) {
264 if (MR::isPowerStarGreenInCurrentStage(a1)) {
268 return MR::isPowerStarRedInCurrentStage(a1) ? 3 : 0;
271bool PowerStar::isCurrentStageKoopaVs3() {
272 return MR::isStageKoopaVs3();
275void PowerStar::initShadowPowerStar(
LiveActor *pActor,
bool a2) {
276 MR::initShadowFromCSV(pActor,
"Shadow");
277 MR::invalidateShadowAll(pActor);
278 MR::validateShadowGroup(pActor, a2 ?
"円柱" :
"通常");
282 if (MR::isPowerStarGetDemoWithLuigiCurrentGalaxy()) {
283 pCollector->addArchive(
"LuigiNPC");
287void PowerStar::control() {
288 if (!isNerve(&NrvPowerStar::PowerStarNrvWaitStartAppear::sInstance)) {
291 if (isNerve(&NrvPowerStar::PowerStarNrvStageClearDemo::sInstance)) {
292 MR::copyJointPos(mPowerStarModelObj,
"PowerStar", &joint_pos);
295 MR::copyJointPos(
this,
"PowerStar", &joint_pos);
298 bool cond = (isNerve(&NrvPowerStar::PowerStarNrvAppearDemoKoopa::sInstance) && MR::isStageKoopaVs3()) ?
true : false;
299 s32 val = cond ? 0x78 : -1;
300 MR::requestPointLight(
this, TVec3f(joint_pos), lightColor[mColorFrame], 1.0f, val);
307 TVec3f stack_14(0.0f, 1.0f, 0.0f);
311 stack_8.set(stack_14);
312 PSVECMag(stack_8.toCVec());
313 PSVECNormalize(stack_8.toCVec(), stack_8.toVec());
314 f32 _sin = sin(derp);
315 f32 _cos = cos(derp);
316 pos.mMtx[0][0] = _cos + ((1.0f - _cos) * (stack_8.x * stack_8.x));
317 pos.mMtx[1][1] = _cos + ((1.0f - _cos) * (stack_8.y * stack_8.y));
318 pos.mMtx[2][2] = _cos + ((1.0f - _cos) * (stack_8.z * stack_8.z));
319 pos.mMtx[0][1] = (stack_8.y * ((1.0f - _cos) * stack_8.x)) - (_sin * stack_8.z);
320 pos.mMtx[0][2] = (stack_8.z * ((1.0f - _cos) * stack_8.x)) - (_sin * stack_8.y);
321 pos.mMtx[1][0] = (stack_8.y * ((1.0f - _cos) * stack_8.x)) - (_sin * stack_8.z);
322 pos.mMtx[2][0] = (stack_8.z * ((1.0f - _cos) * stack_8.x)) - (_sin * stack_8.y);
323 pos.mMtx[1][2] = (stack_8.z * ((1.0f - _cos) * stack_8.y)) - (_sin * stack_8.x);
324 pos.mMtx[2][1] = (stack_8.z * ((1.0f - _cos) * stack_8.y)) - (_sin * stack_8.x);
326 mtx.concat(_B8, pos);
328 MR::setBaseTRMtx(
this, mtx);
333 if (MR::isMsgStarPieceReflect(msg)) {
337 return MR::isMsgJetTurtleAttack(msg);
346 if (isNerve(&NrvPowerStar::PowerStarNrvWait::sInstance)) {
347 MR::startSystemSE(
"SE_SY_STAR_GET", -1, -1);
348 MR::stopSoundPlayer(
"SE_PV_BURN_RUN", 0);
349 MR::stopSoundPlayer(
"SE_PV_NEEDLE_DAMAGE_RUN", 0);
350 MR::makeMtxTR((MtxPtr)&_E8, *MR::getPlayerRotate(), *MR::getPlayerPos());
351 setNerve(&NrvPowerStar::PowerStarNrvStageClearDemo::sInstance);
356 MR::setPlayerBaseMtx((MtxPtr)&_E8);
364void PowerStar::initMapToolInfo(
const JMapInfoIter &rIter) {
365 MR::initDefaultPos(
this, rIter);
366 MR::getJMapInfoArg0NoInit(rIter, &mPowerStarId);
367 MR::getJMapInfoArg1NoInit(rIter, &_125);
368 MR::getJMapInfoArg2NoInit(rIter, &_126);
369 MR::getJMapInfoArg4NoInit(rIter, &_127);
372 MR::registerPowerStar(
this, mPowerStarId);
373 MR::joinToGroupArray(
this, rIter,
"パワースター出現ポイントグループ", 0x10);
375 if (mPowerStarId > 0) {
376 if (!MR::hasPowerStarInCurrentStage(mPowerStarId)) {
382 frame = getBtpFrameCurrentStage(mPowerStarId);
393void PowerStar::initModel() {
394 initModelManagerWithAnm(isGrandStar() ?
"GrandStar" :
"PowerStar", 0, false);
397 ::setupColorGrandStar(
this, mColorFrame_v == 4);
400 ::setupColor(
this, mColorFrame_v == 4, mColorFrame_v);
404 MtxPtr mtx = (MtxPtr)&_E8;
405 const char* name =
"グランドスターデモモデル";
406 mPowerStarModelObj = MR::createModelObjIndirectMapObj(name, mIsGrandStar ?
"GrandStar" :
"PowerStar", mtx);
407 ::setupColorGrandStar(mPowerStarModelObj, mColorFrame_v == 4);
410 MtxPtr mtx = (MtxPtr)&_E8;
411 const char* name =
"パワースターデモモデル";
412 mPowerStarModelObj = MR::createModelObjNoSilhouettedMapObj(name, mIsGrandStar ?
"GrandStar" :
"PowerStar", mtx);
413 ::setupColor(mPowerStarModelObj, mColorFrame_v == 4, mColorFrame_v);
416 MR::invalidateClipping(mPowerStarModelObj);
417 mPowerStarModelObj->makeActorDead();
419 if (MR::isPowerStarGetDemoWithLuigiCurrentGalaxy()) {
420 mLuigiNPC = MR::createModelObjNpc(
"ルイージデモモデル",
"LuigiNPC", (MtxPtr)&_E8);
421 MR::initLightCtrl(mLuigiNPC);
422 MR::invalidateClipping(mLuigiNPC);
423 mLuigiNPC->makeActorDead();
426 MR::tryCreateMirrorActor(
this, isGrandStar() ?
"GrandStar" :
"PowerStar");
429void PowerStar::initSensorGrandStar() {
431 TVec3f body1Offs = TVec3f(0.0f, 100.0f, 0.0f);
432 const char* body1Name =
"body1";
433 MR::addHitSensorMtx(
this, body1Name, 0x67, 8, 60.0f,
getBaseMtx(), body1Offs);
434 TVec3f body2Offs = TVec3f(-95.0f, 35.0f, 0.0f);
435 const char* body2Name =
"body2";
436 MR::addHitSensorMtx(
this, body2Name, 0x67, 8, 60.0f,
getBaseMtx(), body2Offs);
437 TVec3f body3Offs = TVec3f(-55.0f, -75.0f, 0.0f);
438 const char* body3Name =
"body3";
439 MR::addHitSensorMtx(
this, body3Name, 0x67, 8, 60.0f,
getBaseMtx(), body3Offs);
440 TVec3f body4Offs = TVec3f(55.0f, -75.0f, 0.0f);
441 const char* body4Name =
"body4";
442 MR::addHitSensorMtx(
this, body4Name, 0x67, 8, 60.0f,
getBaseMtx(), body4Offs);
443 TVec3f body5Offs = TVec3f(95.0f, 35.0f, 0.0f);
444 const char* body5Name =
"body5";
445 MR::addHitSensorMtx(
this, body5Name, 0x67, 8, 60.0f,
getBaseMtx(), body5Offs);
446 TVec3f body6Offs = TVec3f(0.0f, 0.0f, 0.0f);
447 const char* body6Name =
"body6";
448 MR::addHitSensorMtx(
this, body6Name, 0x67, 8, 80.0f,
getBaseMtx(), body6Offs);
454 MR::getJMapInfoArg3NoInit(rIter, &arg_3);
456 MR::initShadowFromCSV(
this,
"Shadow");
457 MR::invalidateShadowAll(
this);
458 MR::validateShadowGroup(
this, thing ?
"円柱" :
"通常");
461 MR::initShadowFromCSV(
this,
"Shadow");
465void PowerStar::initPosture() {
466 MR::calcGravity(
this, mAppearPosition);
468 MR::makeMtxRotate((MtxPtr)&rotate, _A0);
472 f32 z = rotate.mMtx[2][2];
473 f32 y = rotate.mMtx[1][2];
474 f32 x = rotate.mMtx[0][2];
475 stack_14.set(x, y, z);
478 negGravity.negateInline_2(
mGravity);
480 if (!MR::isSameDirection(negGravity, stack_14, 0.0099999998f)) {
481 MR::makeMtxUpFront(&_B8, negGravity, stack_14);
484 MR::makeMtxUpNoSupport(&_B8, negGravity);
488 JMath::gekko_ps_copy12(&_B8, &rotate);
495void PowerStar::endAppearDemo() {
497 MR::endDemo(
this, cAppearDemoName);
500 MR::moveVolumeStageBGM(1.0f, 0x3C);
501 MR::moveVolumeSubBGM(1.0f, 0x3C);
502 setNerve(&NrvPowerStar::PowerStarNrvWait::sInstance);
507 f32 curDist = 3.4028235e38f;
510 for (
int i = 0; i < group->mObjectCount; i++) {
514 f32 dist = PSVECDistance(rPos.toCVec(), actor->
mPosition.toCVec());
516 if (dist < curDist) {
527LiveActor* PowerStar::getAppearCameraActor() {
528 LiveActor* cam_actor = this->mCameraActor;
534void PowerStar::requestAppearOrWait() {
535 if (MR::isDemoCast(
this, 0)) {
536 setNerve(&NrvPowerStar::PowerStarNrvWeak::sInstance);
538 else if (mIsInDemo) {
540 MR::invalidateClipping(
this);
541 MR::requestMovementOn(
this);
543 if (MR::isStageKoopaVs()) {
544 setNerve(&NrvPowerStar::PowerStarNrvAppearDemoKoopa::sInstance);
547 setNerve(&NrvPowerStar::PowerStarNrvAppearDemoRise::sInstance);
555 setNerve(&NrvPowerStar::PowerStarNrvWait::sInstance);
559void PowerStar::calcAppearDemoRiseTrans(TVec3f *pOutTrans, f32 a2)
const {
561 MR::calcGravityVector(
this, _AC, pOutTrans, 0, 0);
563 pOutTrans->y = (pOutTrans->y * -a2);
564 pOutTrans->z = (pOutTrans->z * -a2);
571 _B8.mult(vec, *pOutTrans);
578void PowerStar::processWait(f32 val) {
580 f32 rot_y = fmod((360.0f + derp), 360.0f);
584 if (MR::changeShowModelFlagSyncNearClipping(
this, 250.0f)) {
585 MR::onDrawEffect(
this);
588 MR::offDrawEffect(
this);
592 if (MR::isGalaxyGhostCometAppearInCurrentStage()) {
593 if (MR::isJudgedToClipFrustum100m(
mPosition, 5000.0f)) {
594 MR::hideModelAndOnCalcAnimIfShown(
this);
595 MR::forceDeleteEffect(
this,
"Light");
598 MR::showModelIfHidden(
this);
599 MR::emitEffect(
this,
"Light");
604 if (MR::isInWater(
this, TVec3f(0.0f, 0.0f, 0.0f))) {
605 MR::startLevelSound(
this,
"SE_OJ_LV_POW_STAR_EXIST_W", -1, -1, -1);
608 MR::startLevelSound(
this,
"SE_OJ_LV_POW_STAR_EXIST", -1, -1, -1);
615void PowerStar::exeAppearDemoRise() {
616 if (MR::isFirstStep(
this)) {
617 MR::showModelIfHidden(
this);
618 MR::moveVolumeStageBGM(0.0f, 5);
619 MR::moveVolumeSubBGM(0.0f, 5);
622 MR::startActorCameraTargetOther(getAppearCameraActor(), getAppearCameraInfo(), target_arg, 0);
624 MR::emitEffect(
this,
"Light");
627 TVec3f stack_8(0.0f, 0.0f, 0.0f);
628 if (MR::isInWater(
this, stack_8)) {
629 MR::startLevelSound(
this,
"SE_OJ_LV_POW_STAR_EXIST_W", -1, -1, -1);
632 MR::startLevelSound(
this,
"SE_OJ_LV_POW_STAR_EXIST", -1, -1, -1);
635 f32 easeOut = MR::calcNerveEaseOutValue(
this, 0x3C, 0.0f, 300.0f);
636 calcAppearDemoRiseTrans(&
mPosition, easeOut);
639 if (MR::isStep(
this, 0x50)) {
640 setNerve(&NrvPowerStar::PowerStarNrvAppearDemoMove::sInstance);
647void PowerStar::exeWait() {
648 if (MR::isFirstStep(
this)) {
649 if (MR::isGalaxyGhostCometAppearInCurrentStage()) {
650 MR::validateClipping(
this);
653 MR::validateHitSensors(
this);
654 MR::emitEffect(
this,
"Light");
657 processWait(mIsGrandStar ? 2.0f : 3.0f);
660void PowerStar::exeWeak() {
661 if (MR::isFirstStep(
this)) {
662 MR::invalidateHitSensors(
this);
663 MR::validateClipping(
this);
665 if (mColorFrame != 4) {
666 MR::startBrkAndSetFrameAndStop(
this,
"Recover", 0.0f);
671 processWait(0.30000001f);
674void PowerStar::exeWeakNoRotate() {
675 if (MR::isFirstStep(
this)) {
683void PowerStar::exeWeakToWait() {
684 if (MR::isFirstStep(
this)) {
685 if (mColorFrame != 4) {
686 MR::setBrkRate(
this, 1.0f);
691 f32 easeIn = MR::calcNerveEaseInValue(
this, 0x1E, 0.30000001f, mIsGrandStar ? 2.0f : 3.0f);
693 MR::setNerveAtStep(
this, &NrvPowerStar::PowerStarNrvWait::sInstance, 0x1E);
698PowerStar::~PowerStar() {
702namespace NrvPowerStar {
703 INIT_NERVE(PowerStarNrvWaitStartAppear);
704 INIT_NERVE(PowerStarNrvAppearDemoRise);
705 INIT_NERVE(PowerStarNrvAppearDemoMove);
706 INIT_NERVE(PowerStarNrvAppearDemoKoopa);
707 INIT_NERVE(PowerStarNrvWait);
708 INIT_NERVE(PowerStarNrvWeak);
709 INIT_NERVE(PowerStarNrvWeakNoRotate);
710 INIT_NERVE(PowerStarNrvWeakToWait);
711 INIT_NERVE(PowerStarNrvStageClearDemo);
713 void PowerStarNrvStageClearDemo::execute(
Spine *pSpine)
const {
715 star->exeStageClearDemo();
718 void PowerStarNrvWeakToWait::execute(
Spine *pSpine)
const {
720 star->exeWeakToWait();
723 void PowerStarNrvWeakNoRotate::execute(
Spine *pSpine)
const {
725 star->exeWeakNoRotate();
728 void PowerStarNrvWeak::execute(
Spine *pSpine)
const {
733 void PowerStarNrvWait::execute(
Spine *pSpine)
const {
738 void PowerStarNrvAppearDemoKoopa::execute(
Spine *pSpine)
const {
740 star->exeAppearDemoKoopa();
743 void PowerStarNrvAppearDemoMove::execute(
Spine *pSpine)
const {
745 return star->exeAppearDemoMove();
748 void PowerStarNrvAppearDemoRise::execute(
Spine *pSpine)
const {
750 return star->exeAppearDemoRise();
753 void PowerStarNrvWaitStartAppear::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 mGravity
3D vector of the actor's gravity.
virtual MtxPtr getBaseMtx() const
Gets the base matrix of the model used for the actor.
Stores archive names of NameObjs.
The most basic form of an object.
const char * mName
A string to identify the NameObj.
virtual void calcAndSetBaseMtx()
Calculates and sets the base matrix of the actor.
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.