mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-08 18:09:45 +01:00
Fix regression with companions not spawning
Companions would not spawn if you didn't load the current room via a room transition. This meant that companions wouldn't spawn if you loaded a save file with a companion, at least not until you moved to a different room and triggered a screen transition. But most importantly, it meant that the Intermission 1 supercrewmate would never spawn, because going to Intermission 1 does a straight gotoroom, and does not do a room transition. Turns out the roomchange refactor broke things, because of course it did. The companion logic was implicitly relying on that bool to be set, because...? Either way, it doesn't make sense. Using roomchange implied that the code wanted to be ran only when doing a room transition, which is clearly not the case here. The best thing to do here is to just move it to a separate function that gets called at the end of mapclass::gotoroom().
This commit is contained in:
parent
a7ae3e0fb0
commit
2991b2341a
3 changed files with 187 additions and 178 deletions
|
@ -1405,184 +1405,6 @@ void gamelogic(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (roomchange)
|
||||
{
|
||||
//We've changed room? Let's bring our companion along!
|
||||
int i = obj.getplayer();
|
||||
if (game.companion > 0 && INBOUNDS_VEC(i, obj.entities))
|
||||
{
|
||||
//ok, we'll presume our companion has been destroyed in the room change. So:
|
||||
switch(game.companion)
|
||||
{
|
||||
case 6:
|
||||
{
|
||||
obj.createentity(obj.entities[i].xp, 121.0f, 15.0f,1); //Y=121, the floor in that particular place!
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
if (game.roomy <= 105) //don't jump after him!
|
||||
{
|
||||
if (game.roomx == 110)
|
||||
{
|
||||
obj.createentity(320, 86, 16, 1); //Y=86, the ROOF in that particular place!
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.createentity(obj.entities[i].xp, 86.0f, 16.0f, 1); //Y=86, the ROOF in that particular place!
|
||||
}
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if (game.roomy >= 104) //don't jump after him!
|
||||
{
|
||||
if (game.roomx == 102)
|
||||
{
|
||||
obj.createentity(310, 177, 17, 1);
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.createentity(obj.entities[i].xp, 177.0f, 17.0f, 1);
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
if (!map.towermode) //don't go back into the tower!
|
||||
{
|
||||
if (game.roomx == 110 && obj.entities[i].xp<20)
|
||||
{
|
||||
obj.createentity(100, 185, 18, 15, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.createentity(obj.entities[i].xp, 185.0f, 18.0f, 15, 0, 1);
|
||||
}
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
//intermission 2, choose colour based on lastsaved
|
||||
if (game.roomy == 51)
|
||||
{
|
||||
if (!obj.flags[59])
|
||||
{
|
||||
obj.createentity(225.0f, 169.0f, 18, graphics.crewcolour(game.lastsaved), 0, 10);
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (game.roomy >= 52)
|
||||
{
|
||||
if (obj.flags[59])
|
||||
{
|
||||
obj.createentity(160.0f, 177.0f, 18, graphics.crewcolour(game.lastsaved), 0, 18, 1);
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.flags[59] = true;
|
||||
obj.createentity(obj.entities[i].xp, -20.0f, 18.0f, graphics.crewcolour(game.lastsaved), 0, 10, 0);
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
//Intermission 1: We're using the SuperCrewMate instead!
|
||||
if(game.roomx-41==game.scmprogress)
|
||||
{
|
||||
switch(game.scmprogress)
|
||||
{
|
||||
case 0:
|
||||
obj.createentity(76, 161, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 1:
|
||||
obj.createentity(10, 169, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 2:
|
||||
obj.createentity(10, 177, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 3:
|
||||
obj.createentity(10, 177, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 4:
|
||||
obj.createentity(10, 185, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 5:
|
||||
obj.createentity(10, 185, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 6:
|
||||
obj.createentity(10, 185, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 7:
|
||||
obj.createentity(10, 41, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 8:
|
||||
obj.createentity(10, 169, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 9:
|
||||
obj.createentity(10, 169, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 10:
|
||||
obj.createentity(10, 129, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 11:
|
||||
obj.createentity(10, 129, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 12:
|
||||
obj.createentity(10, 65, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 13:
|
||||
obj.createentity(10, 177, 24, graphics.crewcolour(game.lastsaved));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
game.activeactivity = obj.checkactivity();
|
||||
|
||||
if (game.hascontrol && !script.running
|
||||
|
|
|
@ -1095,6 +1095,191 @@ void mapclass::gotoroom(int rx, int ry)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (game.companion > 0)
|
||||
{
|
||||
//We've changed room? Let's bring our companion along!
|
||||
spawncompanion();
|
||||
}
|
||||
}
|
||||
|
||||
void mapclass::spawncompanion(void)
|
||||
{
|
||||
int i = obj.getplayer();
|
||||
if (!INBOUNDS_VEC(i, obj.entities))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//ok, we'll presume our companion has been destroyed in the room change. So:
|
||||
switch(game.companion)
|
||||
{
|
||||
case 6:
|
||||
{
|
||||
obj.createentity(obj.entities[i].xp, 121.0f, 15.0f,1); //Y=121, the floor in that particular place!
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
if (game.roomy <= 105) //don't jump after him!
|
||||
{
|
||||
if (game.roomx == 110)
|
||||
{
|
||||
obj.createentity(320, 86, 16, 1); //Y=86, the ROOF in that particular place!
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.createentity(obj.entities[i].xp, 86.0f, 16.0f, 1); //Y=86, the ROOF in that particular place!
|
||||
}
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if (game.roomy >= 104) //don't jump after him!
|
||||
{
|
||||
if (game.roomx == 102)
|
||||
{
|
||||
obj.createentity(310, 177, 17, 1);
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.createentity(obj.entities[i].xp, 177.0f, 17.0f, 1);
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
if (!towermode) //don't go back into the tower!
|
||||
{
|
||||
if (game.roomx == 110 && obj.entities[i].xp<20)
|
||||
{
|
||||
obj.createentity(100, 185, 18, 15, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.createentity(obj.entities[i].xp, 185.0f, 18.0f, 15, 0, 1);
|
||||
}
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
//intermission 2, choose colour based on lastsaved
|
||||
if (game.roomy == 51)
|
||||
{
|
||||
if (!obj.flags[59])
|
||||
{
|
||||
obj.createentity(225.0f, 169.0f, 18, graphics.crewcolour(game.lastsaved), 0, 10);
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (game.roomy >= 52)
|
||||
{
|
||||
if (obj.flags[59])
|
||||
{
|
||||
obj.createentity(160.0f, 177.0f, 18, graphics.crewcolour(game.lastsaved), 0, 18, 1);
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.flags[59] = true;
|
||||
obj.createentity(obj.entities[i].xp, -20.0f, 18.0f, graphics.crewcolour(game.lastsaved), 0, 10, 0);
|
||||
int j = obj.getcompanion();
|
||||
if (INBOUNDS_VEC(j, obj.entities))
|
||||
{
|
||||
obj.entities[j].vx = obj.entities[i].vx;
|
||||
obj.entities[j].dir = obj.entities[i].dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
//Intermission 1: We're using the SuperCrewMate instead!
|
||||
if(game.roomx-41==game.scmprogress)
|
||||
{
|
||||
switch(game.scmprogress)
|
||||
{
|
||||
case 0:
|
||||
obj.createentity(76, 161, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 1:
|
||||
obj.createentity(10, 169, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 2:
|
||||
obj.createentity(10, 177, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 3:
|
||||
obj.createentity(10, 177, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 4:
|
||||
obj.createentity(10, 185, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 5:
|
||||
obj.createentity(10, 185, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 6:
|
||||
obj.createentity(10, 185, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 7:
|
||||
obj.createentity(10, 41, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 8:
|
||||
obj.createentity(10, 169, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 9:
|
||||
obj.createentity(10, 169, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 10:
|
||||
obj.createentity(10, 129, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 11:
|
||||
obj.createentity(10, 129, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 12:
|
||||
obj.createentity(10, 65, 24, graphics.crewcolour(game.lastsaved), 2);
|
||||
break;
|
||||
case 13:
|
||||
obj.createentity(10, 177, 24, graphics.crewcolour(game.lastsaved));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::string mapclass::currentarea(int t)
|
||||
|
|
|
@ -81,6 +81,8 @@ public:
|
|||
|
||||
void gotoroom(int rx, int ry);
|
||||
|
||||
void spawncompanion(void);
|
||||
|
||||
std::string currentarea(int t);
|
||||
|
||||
void loadlevel(int rx, int ry);
|
||||
|
|
Loading…
Reference in a new issue