Skip to content

Commit f7fc182

Browse files
committed
singleGS_DayEnd closer
1 parent 7a98094 commit f7fc182

File tree

3 files changed

+33
-22
lines changed

3 files changed

+33
-22
lines changed

docs/recommended_todo.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemCave.cpp">itemCave.cpp</a> | 20160 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/pathfinder.cpp">pathfinder.cpp</a> | 20316 |
9797
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemDownFloor.cpp">itemDownFloor.cpp</a> | 21092 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/dynCreature.cpp">dynCreature.cpp</a> | 21624 |
9898
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameDynamics.cpp">gameDynamics.cpp</a> | 24672 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemPikihead.cpp">itemPikihead.cpp</a> | 26216 |
99-
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameCPlate.cpp">gameCPlate.cpp</a> | 26452 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_DayEnd.cpp">singleGS_DayEnd.cpp</a> | 30300 |
99+
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gameCPlate.cpp">gameCPlate.cpp</a> | 26452 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_DayEnd.cpp">singleGS_DayEnd.cpp</a> | 30405 |
100100
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/vsCardMgr.cpp">vsCardMgr.cpp</a> | 30743 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/singleGS_MainGame.cpp">singleGS_MainGame.cpp</a> | 31230 |
101101
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/itemBridge.cpp">itemBridge.cpp</a> | 32134 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/gamePlayDataMemCard.cpp">gamePlayDataMemCard.cpp</a> | 36009 |
102102
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/piki.cpp">piki.cpp</a> | 36183 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectKandoU/routeMgr.cpp">routeMgr.cpp</a> | 39098 |

include/Game/GameSystem.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enum GameSystemFlags {
2626
GAMESYS_IsPlaying = 0x2, // set when the game is running
2727
GAMESYS_DisableCollision = 0x4, // disables collision detection
2828
GAMESYS_DisablePause = 0x8, // disables pausing
29-
GAMESYS_DisableDeathCounter = 0x10, // disables the death counter
29+
GAMESYS_DisableDeathCounter = 0x10, // disables the pikmin death counter, used to make left behind pikis not increase it in the cutscene
3030
GAMESYS_IsGameWorldActive = 0x20, // set when the game world is active
3131
};
3232

src/plugProjectKandoU/singleGS_DayEnd.cpp

+31-20
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,12 @@ void DayEndState::exec(SingleGameSection* game)
104104
switch (mDayEndType) {
105105
case 0:
106106
MoviePlayArg arg("s01_dayend", const_cast<char*>(game->mCurrentCourseInfo->mName), game->mMovieFinishCallback, 0);
107+
108+
// this is all wrong
107109
int treasures = 0;
108-
// treasures += playData->mMainCropMemory->mItem.calcCollectedNum();
109-
// treasures += playData->mMainCropMemory->mOtakara.calcCollectedNum();
110+
treasures += playData->mMainCropMemory->mItem.calcCollectedNum();
111+
treasures += playData->mMainCropMemory->mOtakara.calcCollectedNum();
112+
110113
if (treasures == 0) {
111114
arg.mStreamID = 0xc0011004;
112115
} else if (treasures <= 14) {
@@ -115,30 +118,32 @@ void DayEndState::exec(SingleGameSection* game)
115118
arg.mStreamID = 0xc0011003;
116119
}
117120
JUT_ASSERTLINE(222, naviMgr->getAliveOrima(ALIVEORIMA_Active), "no alive:s01_dayend");
118-
Navi* navi = naviMgr->getActiveNavi();
119-
arg.mPelletName = nullptr;
121+
Navi* navi = naviMgr->getActiveNavi();
122+
int id = 0;
120123
if (navi) {
121-
arg.mPelletName = (char*)navi->mNaviIndex;
122-
if ((int)arg.mPelletName == NAVIID_Captain2 && playData->isStoryFlag(STORY_DebtPaid)) {
123-
arg.mPelletName = (char*)2;
124+
id = navi->mNaviIndex;
125+
if (id == NAVIID_Captain2 && playData->isStoryFlag(STORY_DebtPaid)) {
126+
id++;
124127
}
125128
}
129+
arg.mPelletName = (char*)id;
126130
arg.mDelegateStart = game->mMovieStartCallback;
127131
moviePlayer->play(arg);
128132
gameSystem->setPause(true, "s01_dayend", 3);
129133
mStatus = 1;
130134
break;
131135
case 1: {
132-
MoviePlayArg arg("s06_dayend_pikminzero", const_cast<char*>(game->mCurrentCourseInfo->mName), game->mMovieFinishCallback,
133-
0);
136+
char* name = const_cast<char*>(game->mCurrentCourseInfo->mName);
137+
MoviePlayArg arg("s06_dayend_pikminzero", name, game->mMovieFinishCallback, 0);
134138
arg.mDelegateStart = game->mMovieStartCallback;
135139
moviePlayer->play(arg);
136-
gameSystem->setPause(1, "s06_dayend", 3);
140+
gameSystem->setPause(0, "s06_dayend", 3);
137141
mStatus = 1;
138142
break;
139143
}
140144
case 2: {
141-
MoviePlayArg arg("s04_dayend_orimadown", const_cast<char*>(game->mCurrentCourseInfo->mName), game->mMovieFinishCallback, 0);
145+
char* name = const_cast<char*>(game->mCurrentCourseInfo->mName);
146+
MoviePlayArg arg("s04_dayend_orimadown", name, game->mMovieFinishCallback, 0);
142147
arg.mDelegateStart = game->mMovieStartCallback;
143148
moviePlayer->play(arg);
144149
gameSystem->setPause(0, "s04_dayend", 3);
@@ -485,7 +490,7 @@ void DayEndState::onMovieStart(SingleGameSection* game, MovieConfig* config, u32
485490
PSMTXMultVec(mapMgr->getDemoMatrix()->mMatrix.mtxView, &origin, &out);
486491
origin = out;
487492

488-
Piki* pikiBuffer[103];
493+
Piki* pikiBuffer[100];
489494
int i = 0;
490495
Iterator<Piki> iterator(pikiMgr);
491496
CI_LOOP(iterator)
@@ -509,6 +514,7 @@ void DayEndState::onMovieStart(SingleGameSection* game, MovieConfig* config, u32
509514
JUT_ASSERTLINE(376, navi, "no alive navi");
510515
PikiAI::ActFormationInitArg arg(navi);
511516
piki->mNavi = navi;
517+
arg._09 = 1;
512518
piki->mBrain->start(PikiAI::ACT_Formation, &arg);
513519
piki->movie_begin(false);
514520
}
@@ -967,32 +973,37 @@ void DayEndState::onMovieCommand(SingleGameSection* game, int id)
967973
{
968974
switch (id) {
969975
case 1:
970-
Vector3f origin(0.0f);
976+
Vector3f origin = (0.0f);
971977
if (mapMgr->getDemoMatrix()) {
972978
Matrixf* mtx = mapMgr->getDemoMatrix();
973979
Vector3f out;
974980
PSMTXMultVec(mtx->mMatrix.mtxView, (Vec*)&origin, (Vec*)&out);
975981
origin = out;
976982
origin.y = mapMgr->getMinY(origin);
977983
}
984+
978985
Sys::Sphere bounds(origin, 180.0f);
979986
generalEnemyMgr->createDayendEnemies(bounds);
980-
for (int i = 0; i <= 4; i++) {
981-
for (int j = 0; j <= 2; j++) {
982-
for (int k = 0; k < mLeftBehindPikis.getCount(i, j); k++) {
987+
988+
// Spawn all left behind Pikmin
989+
for (int color = 0; color <= 4; color++) {
990+
for (int happa = 0; happa <= 2; happa++) {
991+
for (int i = 0; i < mLeftBehindPikis.getCount(color, happa); i++) {
983992
Piki* piki = pikiMgr->birth();
984993
if (piki) {
985994
PikiInitArg arg(PIKISTATE_Escape);
986995
piki->init(&arg);
996+
987997
f32 angle = randFloat() * TAU;
988-
f32 zero = 0.0f;
989-
Vector3f pos(cosf(angle) * 30.0f, origin.y + zero, sinf(angle) * 30.0f);
998+
Vector3f pos(sinf(angle) * 30.0f, 0.0f, cosf(angle) * 30.0f);
999+
pos += origin;
9901000
if (mapMgr) {
9911001
pos.y = mapMgr->getMinY(pos);
9921002
}
9931003
piki->setPosition(pos, false);
994-
piki->changeShape(i);
995-
piki->changeHappa(j);
1004+
1005+
piki->changeShape(color);
1006+
piki->changeHappa(happa);
9961007
piki->movie_begin(false);
9971008
}
9981009
}

0 commit comments

Comments
 (0)