?? missions.cpp
字號:
/*Copyright (C) 2003 Parallel RealitiesThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/#include "missions.h"// God, I hate this file! :((void initPlanetMissions(signed char system){ for (int i = 0 ; i < 10 ; i++) { systemPlanet[i].missionNumber = -1; // no mission for this planet systemPlanet[i].missionCompleted = 1; } switch(system) { // Spirit case 0: for (int i = 0 ; i < 4 ; i++) { systemPlanet[i].missionNumber = i + 1; systemPlanet[i].missionCompleted = 0; } systemPlanet[4].missionNumber = 5; systemPlanet[4].missionCompleted = -1; break; // Eyananth case 1: systemPlanet[0].missionNumber = 7; systemPlanet[0].missionCompleted = 0; systemPlanet[1].missionNumber = 8; systemPlanet[1].missionCompleted = 0; systemPlanet[2].missionNumber = 9; systemPlanet[2].missionCompleted = -1; systemPlanet[3].missionNumber = 10; systemPlanet[3].missionCompleted = -1; systemPlanet[4].missionNumber = 11; systemPlanet[4].missionCompleted = -2; // This one is for the slaves systemPlanet[9].missionNumber = 6; systemPlanet[9].missionCompleted = 0; break; // Mordor case 2: systemPlanet[0].missionNumber = 13; systemPlanet[0].missionCompleted = 0; systemPlanet[1].missionNumber = 14; systemPlanet[1].missionCompleted = 0; systemPlanet[2].missionNumber = 15; systemPlanet[2].missionCompleted = -1; systemPlanet[3].missionNumber = 16; systemPlanet[3].missionCompleted = -1; systemPlanet[4].missionNumber = 17; systemPlanet[4].missionCompleted = -2; systemPlanet[5].missionNumber = 18; systemPlanet[5].missionCompleted = -3; // This one is for the experimental fighter systemPlanet[9].missionNumber = 12; systemPlanet[9].missionCompleted = 0; break; // Sol case 3: systemPlanet[8].missionNumber = 19; systemPlanet[8].missionCompleted = 0; systemPlanet[7].missionNumber = 20; systemPlanet[7].missionCompleted = 0; systemPlanet[6].missionNumber = 21; systemPlanet[6].missionCompleted = 0; systemPlanet[5].missionNumber = 22; systemPlanet[5].missionCompleted = -1; systemPlanet[4].missionNumber = 23; systemPlanet[4].missionCompleted = -2; systemPlanet[3].missionNumber = 24; systemPlanet[3].missionCompleted = -3; systemPlanet[2].missionNumber = 25; systemPlanet[2].missionCompleted = -4; systemPlanet[1].missionNumber = 26; systemPlanet[1].missionCompleted = -5; break; }}void checkForBossMission(){ for (int i = 0 ; i < 10 ; i++) { if ((systemPlanet[i].missionCompleted == 0) && (systemPlanet[i].missionNumber != -1)) return; } for (int i = 0 ; i < 10 ; i++) { if (systemPlanet[i].missionCompleted < 0) systemPlanet[i].missionCompleted++; }}void updateSystemStatus(){ if (currentGame.area == 0) { currentGame.stationedPlanet = 0; currentGame.area = 1; strcpy(currentGame.stationedName, "Hail"); initPlanetMissions(currentGame.system); } else if (currentGame.area == 5) { currentGame.stationedPlanet = 0; currentGame.system = 1; currentGame.area = 6; strcpy(currentGame.stationedName, "Nerod"); initPlanetMissions(currentGame.system); currentGame.shieldUnits = 2; } else if (currentGame.area == 11) { currentGame.stationedPlanet = 0; currentGame.system = 2; currentGame.area = 12; strcpy(currentGame.stationedName, "Odeon"); initPlanetMissions(currentGame.system); currentGame.shieldUnits = 3; } else if (currentGame.area == 18) { currentGame.stationedPlanet = 8; currentGame.system = 3; currentGame.area = 19; strcpy(currentGame.stationedName, "Pluto"); initPlanetMissions(currentGame.system); currentGame.shieldUnits = 4; } else // Update the mission for the planet { systemPlanet[currentGame.stationedPlanet].missionCompleted = 1; } strcpy(currentGame.destinationName, "None"); currentGame.destinationPlanet = currentGame.stationedPlanet;}/*Mission Completed Variables:0 : Not Completed1 : Completed2 : Just Completed3 : Constraint-1 : Mission Failed-2 : Just FailedTimer Variable:1+ : Time in minutes-1 : Time up-2 : No timer*/void clearAllMissions(){ for (int m = 0 ; m < MAX_MISSIONS ; m++) { for (int i = 0 ; i < 3 ; i++) { strcpy(missions[m].primaryObjective[i], ""); missions[m].primaryType[i] = NONE; missions[m].target1[i] = -1; missions[m].targetValue1[i] = -1; missions[m].timeLimit1[i] = -2; missions[m].completed1[i] = 1; } for (int i = 0 ; i < 3 ; i++) { strcpy(missions[m].secondaryObjective[i], ""); missions[m].secondaryType[i] = NONE; missions[m].target2[i] = -1; missions[m].targetValue2[i] = -1; missions[m].timeLimit2[i] = -2; missions[m].completed2[i] = 1; } missions[m].addAliens = -1; }}/*Sets the currentMission object to the mission number the playeris currently on. Timing is assigned if it is required. The rateat which to add enemies in this mission is also set.*/void setMission(int mission){ currentMission = missions[mission]; engine.minutes = currentMission.timeLimit1[0]; for (int i = 0 ; i < 3 ; i++) { if (currentMission.timeLimit1[i] > engine.minutes) engine.minutes = currentMission.timeLimit1[i]; if (currentMission.timeLimit2[i] > engine.minutes) engine.minutes = currentMission.timeLimit2[i]; if (currentMission.completed1[i] == 0) currentMission.remainingObjectives1++; if (currentMission.completed2[i] == 0) currentMission.remainingObjectives1++; } engine.addAliens = currentMission.addAliens; if (engine.minutes > -1) { engine.timeMission = 1; engine.seconds = 0; } engine.counter2 = 0; engine.timeTaken = 0;}void checkTimer(){ for (int i = 0 ; i < 3 ; i++) { if ((currentMission.timeLimit1[i] == -1) && (currentMission.completed1[i] == OB_INCOMPLETE)) currentMission.completed1[i] = -2; } for (int i = 0 ; i < 3 ; i++) { if ((currentMission.timeLimit2[i] == -1) && (currentMission.completed2[i] == OB_INCOMPLETE)) currentMission.completed2[i] = -2; } // Find out if there are any uncompleted missions that require the timer engine.timeMission = 0; for (int i = 0 ; i < 3 ; i++) { if ((currentMission.timeLimit1[i] > -1) && (currentMission.completed1[i] == OB_INCOMPLETE)) engine.timeMission = 1; if ((currentMission.timeLimit2[i] > -1) && (currentMission.completed2[i] == OB_INCOMPLETE)) engine.timeMission = 1; } // specific to Spirit Boss if ((currentGame.area == 5) && (currentMission.completed1[0] < OB_INCOMPLETE)) engine.timeMission = 1; // specific to the Asteroid belt if ((currentGame.area == 24) && (currentMission.completed1[0] < OB_INCOMPLETE)) { currentMission.completed1[0] = OB_COMPLETED; killAllAliens(); engine.addAliens = -1; setInfoLine("*** All Primary Objectives Completed ***", FONT_GREEN); }}void evaluteRequirement(int type, int id, int value, int *completed, int *targetValue, int fontColor){ char message[25]; if ((*targetValue <= 0) && (type != M_PROTECT_TARGET) && (type != M_PROTECT_PICKUP)) { *completed = 2; checkTimer(); if ((currentGame.area == 9) && (type == M_DISABLE_TARGET)) setRadioMessage(FACE_SID, "All vessels disabled!", 1); } else { strcpy(message, ""); switch(type) { case M_COLLECT: switch(id) { case P_CASH: sprintf(message, "Collect $%d more...", *targetValue); if ((rand() % 2) == 0) sprintf(message, "$%d more to go...", *targetValue); break; case P_CARGO: sprintf(message, "Collect %d more...", *targetValue); if ((rand() % 2) == 0) sprintf(message, "%d more to go...", *targetValue); break; case P_ORE: sprintf(message, "Collect %d more...", *targetValue); if ((rand() % 2) == 0) sprintf(message, "%d more to go...", *targetValue); break; } break; case M_PROTECT_PICKUP: *completed = -2; switch(id) { case P_CARGO: sprintf(message, "Cargo pod destroy!"); if (currentGame.area == 2) // Get lectured by Sid setRadioMessage(FACE_SID, "Chris, we needed that pod!! I warned you that we couldn't afford to lose a single one!!", 1); break; case P_ESCAPEPOD: sprintf(message, "Escape Pod lost!"); if (currentGame.area == 13) // Get lectured by Phoebe setRadioMessage(FACE_PHOEBE, "No... Ursula...", 1); break; } break; case M_PROTECT_TARGET: if (*targetValue <= 0) { *completed = -2; switch (currentGame.area) { case 7: setRadioMessage(FACE_SID, "Dammit, Chris! We just lost her!", 1); break; case 8: setRadioMessage(FACE_CREW, "Noooo!! Hull bre...", 1); break; case 9: setRadioMessage(FACE_SID, "Chris, we've got to disable them, not destroy them!!", 1); break; } } break; case M_DESTROY_TARGET_TYPE: if ((*targetValue <= 10) || (*targetValue % 10 == 0)) { sprintf(message, "Destroy %d more...", *targetValue); if ((rand() % 2) == 0) sprintf(message, "%d more to go...", *targetValue); } break; case M_DISABLE_TARGET: sprintf(message, "Disable %d more...", *targetValue); break; } if (strcmp(message, "") != 0) setInfoLine(message, fontColor); }}void updateMissionRequirements(int type, int id, int value){ // Can't complete missions if you're dead! if (engine.missionCompleteTimer != 0) return; char message[25]; char matched = 0; // We don't need to worry here since if Sid dies, // you will automatically fail the mission(!) if ((type == M_DESTROY_TARGET_TYPE) && (id == CD_SID)) { setInfoLine("Sid has been killed!!", FONT_RED); setRadioMessage(FACE_CHRIS, "Sid... I... I'm sorry...", 1); currentMission.completed1[0] = -2; } for (int i = 0 ; i < 3 ; i++) { if ((currentMission.completed1[i] == OB_INCOMPLETE) || (currentMission.completed1[i] == OB_CONDITION)) { if ((currentMission.primaryType[i] == type) && ((currentMission.target1[i] == id) || (currentMission.target1[i] == CD_ANY))) { matched = 1; currentMission.targetValue1[i] -= value; evaluteRequirement(type, id, value, ¤tMission.completed1[i], ¤tMission.targetValue1[i], FONT_CYAN); } } } // Don't evaluate secondary objectives at the same time! if (matched) return; for (int i = 0 ; i < 3 ; i++) { if ((currentMission.completed2[i] == OB_INCOMPLETE) || (currentMission.completed2[i] == OB_CONDITION)) { if ((currentMission.secondaryType[i] == type) && ((currentMission.target2[i] == id) || (currentMission.target2[i] == CD_ANY))) { currentMission.targetValue2[i] -= value; evaluteRequirement(type, id, value, ¤tMission.completed2[i], ¤tMission.targetValue2[i], FONT_YELLOW); return; } } } // Special Case - Interceptions if (currentGame.area == MAX_MISSIONS - 1) { if ((type == M_COLLECT) && (id == P_SLAVES)) { if (systemPlanet[9].missionCompleted == 0) { if (currentGame.slavesRescued >= 250) { setInfoLine("*** Slaves Rescued - Mission Completed ***", FONT_GREEN); systemPlanet[9].missionCompleted = 1; } else { sprintf(message, "Rescue %d more...", 250 - currentGame.slavesRescued); setInfoLine(message, FONT_CYAN); } } } if ((type == M_DESTROY_TARGET_TYPE) && (id == CD_CLOAKFIGHTER)) { setInfoLine("*** Experimental Fighter Destroyed - Mission Completed ***", FONT_GREEN); systemPlanet[9].missionCompleted = 1; setRadioMessage(FACE_CHRIS, "That's one less suprise that WEAPCO can spring on us!", 1); currentGame.experimentalShield = 0; } }}/*This is only used as few times in the game.Missions 11 and 23 to be exact!*/char revealHiddenObjectives(){ char allDone = 1; char string[255]; strcpy(string, ""); for (int i = 0 ; i < 3 ; i++) { if (currentMission.completed1[i] == OB_HIDDEN) { currentMission.completed1[i] = OB_INCOMPLETE; sprintf(string, "New Objective - %s", currentMission.primaryObjective[i]);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -