diff --git a/desktop_version/src/Logic.cpp b/desktop_version/src/Logic.cpp index f3761a31..cb6f35e4 100644 --- a/desktop_version/src/Logic.cpp +++ b/desktop_version/src/Logic.cpp @@ -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 diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 8c5c4bdb..0bb2666c 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -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) diff --git a/desktop_version/src/Map.h b/desktop_version/src/Map.h index cdc9ecdd..264275a8 100644 --- a/desktop_version/src/Map.h +++ b/desktop_version/src/Map.h @@ -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);