⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 missions.cpp

📁 After decades of war one company, who had gained powerful supplying both sides with weaponary, steps
💻 CPP
📖 第 1 页 / 共 3 页
字号:
			setInfoLine(string, FONT_CYAN);			allDone = 0;		}	}	if (!allDone)	{		// Activate Kline!! :)		if (currentGame.area == 11)		{			killAllAliens();			syncScriptEvents();			enemy[WC_KLINE].active = 1;			enemy[WC_KLINE].x = player.x + 1000;			enemy[WC_KLINE].y = player.y;			enemy[WC_KLINE].flags += FL_IMMORTAL + FL_NOFIRE;			setTarget(WC_KLINE);			loadMusic("music/TranceGeneration.mod");			Mix_PlayMusic(engine.music, -1);		}	}	return allDone;}signed char allMissionsCompleted(){	for (int i = 0 ; i < 3 ; i++)	{		if (currentMission.completed1[i] == OB_INCOMPLETE)		{			if ((currentMission.primaryType[i] == M_DESTROY_ALL_TARGETS) && (engine.allAliensDead) && (currentMission.remainingObjectives1 + currentMission.remainingObjectives2 == 1))			{				currentMission.completed1[i] = 2;				checkTimer();			}		}	}	for (int i = 0 ; i < 3 ; i++)	{		if (currentMission.completed2[i] == OB_INCOMPLETE)		{			if ((currentMission.secondaryType[i] == M_DESTROY_ALL_TARGETS) && (engine.allAliensDead) && (currentMission.remainingObjectives1 + currentMission.remainingObjectives2 == 1))			{				currentMission.completed2[i] = 2;				checkTimer();			}		}	}	for (int i = 0 ; i < 3 ; i++)	{		if (currentMission.completed1[i] == 2)		{			if (currentMission.remainingObjectives1 > 1)			{				if ((currentGame.area != 17) || ((currentGame.area == 17) && (i != 1)))					setInfoLine("*** Primary Objective Completed ***", FONT_GREEN);				else					setInfoLine(">>> Primary Objective Failed <<<", FONT_RED);				currentMission.completed1[i] = OB_COMPLETED;			}			else			{				if (currentGame.area != MAX_MISSIONS - 1)					setInfoLine("*** All Primary Objectives Completed ***", FONT_GREEN);				else					setInfoLine("*** Interception Destroyed ***", FONT_GREEN);				currentMission.completed1[i] = OB_COMPLETED;    			// do some area specific things				if ((currentGame.area == 5) || (currentGame.area == 10) || (currentGame.area == 18) || (currentGame.area == 24))				{					if (currentMission.remainingObjectives2 == 0)					{						killAllAliens();						engine.addAliens = -1;					}				}				if (currentGame.area == 25)					setRadioMessage(FACE_CHRIS, "You guys stay here and keep things under control. I'm going after Kethlan!", 1);			}		}		if (currentMission.completed2[i] == 2)		{			if (currentMission.remainingObjectives2 > 1)			{				setInfoLine("*** Secondary Objective Completed ***", FONT_GREEN);				currentMission.completed2[i] = OB_COMPLETED;			}			else			{				setInfoLine("*** All Secondary Objectives Completed ***", FONT_GREEN);				currentMission.completed2[i] = OB_COMPLETED;				// do some area specific things				if ((currentGame.area == 10) && (currentMission.remainingObjectives1 == 0))				{					killAllAliens();					engine.addAliens = -1;				}			}		}		if (currentMission.completed1[i] == -2)		{			setInfoLine(">>> MISSION FAILED <<<", FONT_RED);			currentMission.completed1[i] = OB_FAILED;		}		if (currentMission.completed2[i] == -2)		{			setInfoLine(">>> Secondary Objective Failed <<<", FONT_RED);			currentMission.completed2[i] = OB_FAILED;		}	}	signed char remaining = 0;	signed char add = 0;	signed char allDone = 1;	// Zero objective list for a recount	currentMission.remainingObjectives1 = currentMission.remainingObjectives2 = 0;	for (int i = 0 ; i < 3 ; i++)	{		if (currentMission.primaryType[i] != NONE)		{			if (currentMission.completed1[i] == 0)			{				currentMission.remainingObjectives1++;				if (currentMission.primaryType[i] == M_DESTROY_ALL_TARGETS)					add = 1;				allDone = 0;			}			if (currentMission.completed1[i] < 0)				return 0;		}		if (currentMission.secondaryType[i] != NONE)		{			if (currentMission.completed2[i] == 0)			{				currentMission.remainingObjectives2++;				if (currentMission.secondaryType[i] == M_DESTROY_ALL_TARGETS)					add = 1;				allDone = 0;			}		}	}	if (allDone)		allDone = revealHiddenObjectives();	remaining = currentMission.remainingObjectives1 + currentMission.remainingObjectives2;	// We've only got one objective left and it's destroy all targets,	// so stop adding aliens (otherwise it might be impossible to finish!)	if ((add == 1) && (remaining == 1))		engine.addAliens = -1;	return allDone;}signed char missionFailed(){	for (int i = 0 ; i < 3 ; i++)	{		if (currentMission.completed1[i] < 0)		{			return 1;		}	}	return 0;}void drawBriefScreen(){	SDL_Rect r = {0, 0, 800, 2};	for (int i = 0 ; i < 120 ; i++)	{		r.y = (i * 2) + 60;		SDL_FillRect(graphics.screen, &r, SDL_MapRGB(graphics.screen->format, 0, i, 0));		r.y = (300 + (i * 2));		SDL_FillRect(graphics.screen, &r, SDL_MapRGB(graphics.screen->format, 0, (120 - i), 0));	}	graphics.blevelRect(140, 70, 500, 20, 0x00, 0x77, 0x00);	graphics.blevelRect(140, 90, 500, 130, 0x00, 0x33, 0x00);	graphics.drawString("Primary Objectives", 150, 74, FONT_WHITE);	for (int i = 0 ; i < 3 ; i++)	{		if ((currentMission.primaryType[i] != NONE) && (currentMission.completed1[i] != OB_HIDDEN))		{			graphics.drawString(currentMission.primaryObjective[i], 160, 114 + (i * 30), FONT_WHITE);		}	}	if (currentMission.secondaryType[0] != NONE)	{		graphics.blevelRect(140, 230, 500, 20, 0x00, 0x77, 0x77);		graphics.blevelRect(140, 250, 500, 130, 0x00, 0x33, 0x33);		graphics.drawString("Secondary Objectives", 150, 234, FONT_WHITE);		for (int i = 0 ; i < 3 ; i++)		{			if (currentMission.secondaryType[i] != NONE)			{				graphics.drawString(currentMission.secondaryObjective[i], 160, 274 + (i * 30), FONT_WHITE);				currentGame.secondaryMissions++;			}		}	}	graphics.blevelRect(140, 390, 500, 20, 0x77, 0x77, 0x00);	graphics.blevelRect(140, 410, 500, 130, 0x33, 0x33, 0x00);	graphics.drawString("Additional Information", 150, 394, FONT_WHITE);}/*Simply displays a screen with all the mission information on it, pulledback from the data stored in the currentMission object. The music for themission begins playing here.*/void missionBriefScreen(){	graphics.clearScreen(graphics.black);	graphics.updateScreen();	SDL_Delay(1000);	if (currentGame.area != MAX_MISSIONS - 1)	{		graphics.clearScreen(graphics.black);		drawBriefScreen();		if (currentMission.timeLimit1[0] > 0)		{			char temp[50];			strcpy(temp, "");			if (currentGame.area != 24)				sprintf(temp, "TIME LIMIT: %d minutes", currentMission.timeLimit1[0]);			else				sprintf(temp, "SURVIVAL FOR %d minutes", currentMission.timeLimit1[0]);			graphics.drawString(temp, -1, 500, FONT_RED);		}		switch (currentGame.area)		{			case 9:			case 10:			case 15:			case 16:			case 18:			case 24:			case 26:				graphics.drawString("Phoebe Lexx will not be present", 160, 420, FONT_WHITE);				if (currentGame.hasWingMate2)					graphics.drawString("Ursula Lexx will not be present", 160, 450, FONT_WHITE);				break;		}		if ((currentGame.area == 9) || (currentGame.area == 17) || (currentGame.area == 25))			graphics.drawString("Sid Wilson will join you on this mission", 160, 480, FONT_WHITE);		graphics.updateScreen();	}	loadGameGraphics();	graphics.textSurface(4, "Shield", 25, 550, FONT_WHITE);	graphics.textSurface(5, "Plasma:", 250, 550, FONT_WHITE);	if (player.weaponType[1] == W_CHARGER)		graphics.textSurface(6, "Charge", 385, 550, FONT_WHITE);	else if (player.weaponType[1] == W_LASER)		graphics.textSurface(6, "Heat", 405, 550, FONT_WHITE);	else		graphics.textSurface(6, "Rockets:", 385, 550, FONT_WHITE);	graphics.textSurface(7, "Target", 550, 550, FONT_WHITE);	graphics.textSurface(8, "Cash: $", 25, 20, FONT_WHITE);	graphics.textSurface(9, "Objectives Remaining:", 550, 20, FONT_WHITE);	graphics.textSurface(10, "Time Remaining - ", 260, 20, FONT_WHITE);	graphics.textSurface(11, "Power", 25, 570, FONT_WHITE);	graphics.textSurface(12, "Output", 250, 570, FONT_WHITE);	graphics.textSurface(13, "Cooler", 485, 570, FONT_WHITE);	playRandomTrack();	if (currentGame.area != MAX_MISSIONS - 1)	{		graphics.drawString("PRESS CTRL TO CONTINUE...", -1, 550, FONT_WHITE);		graphics.updateScreen();		flushInput();		engine.done = 0;		engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0;		while (true)		{			graphics.updateScreen();			getPlayerInput();			if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]))				break;		}		graphics.clearScreen(graphics.black);		graphics.updateScreen();		graphics.clearScreen(graphics.black);		SDL_Delay(1000);	}	engine.gameSection = SECTION_GAME;}/*Display a screen showing all the information from the missionthe player has just done. This includes objectives that have beencompleted and failed. A mission timer is also displayed at the bottomof the screen.*/void missionFinishedScreen(){	if (currentGame.area != MAX_MISSIONS - 1)	{		graphics.clearScreen(graphics.black);		graphics.updateScreen();		SDL_Delay(1000);		if (currentGame.shots > 0)			currentGame.accuracy = (currentGame.hits * 100) / currentGame.shots;		graphics.clearScreen(graphics.black);		drawBriefScreen();		char temp[100];		for (int i = 0 ; i < 3 ; i++)		{			if (currentMission.primaryType[i] != NONE)			{				if ((currentGame.area != 17) || ((currentGame.area == 17) && (i != 1)))					graphics.drawString("COMPLETED", 550, 114 + (i * 30), FONT_GREEN);				else					graphics.drawString("FAILED", 550, 114 + (i * 30), FONT_RED);			}		}		if (currentMission.secondaryType[0] != NONE)		{			for (int i = 0 ; i < 3 ; i++)			{				if (currentMission.secondaryType[i] != NONE)				{					sprintf(temp, currentMission.secondaryObjective[i]);					if (currentMission.completed2[i] >= 1)					{						graphics.drawString("COMPLETED", 550, 274 + (i * 30), FONT_GREEN);						currentGame.secondaryMissionsCompleted++;					}					else					{						graphics.drawString("FAILED", 550, 274 + (i * 30), FONT_RED);					}				}			}		}		if (currentMission.remainingObjectives1 + currentMission.remainingObjectives2 == 0)		{			sprintf(temp, "Shield Bonus: $%.3d", (player.shield * 10));			graphics.drawString(temp, -1, 430, FONT_WHITE);			currentGame.cash += (player.shield * 10);			currentGame.cashEarned += (player.shield * 10);		}		currentGame.timeTaken += engine.timeTaken;		signed char clock = 0;		while (engine.timeTaken > 3599)		{			clock++;			engine.timeTaken -= 3600;		}		sprintf(temp, "Mission Time: %.2d", clock);		clock = 0;		while (engine.timeTaken > 59)		{			clock++;			engine.timeTaken -= 60;		}		sprintf(temp, "%s:%.2d:%.2d", temp, clock, engine.timeTaken);		graphics.drawString(temp, -1, 500, FONT_WHITE);		// Do some mission specific stuff here...		if (currentGame.area == 1)			currentGame.cash -= 500;		else if (currentGame.area == 13)			currentGame.hasWingMate2 = 1;		else if (currentGame.area == 16)			currentGame.cash -= 2000;		checkForBossMission();		graphics.updateScreen();		flushInput();		engine.done = 0;		engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0;		while (true)		{			graphics.updateScreen();			getPlayerInput();			if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]))				break;		}	}	// Stop people from "selling" Laser ammo as rockets.	if (player.weaponType[1] == W_LASER)		player.ammo[1] = 1;	Mix_HaltMusic();}#if USEPACKvoid loadMissions(){	clearAllMissions();	FILE *fp;	int dataLocation;	char filename[65];	char objective[255];	int type, target, value, time, complete, add;	for (int i = 0 ; i < MAX_MISSIONS ; i++)	{		strcpy(filename, "");		sprintf(filename, "data/mission%.2d.dat", i);		#if USEPACK		dataLocation = locateDataInPak(filename, 1);		fp = fopen(PACKLOCATION, "rb");		fseek(fp, dataLocation, SEEK_SET);		#else		fp = fopen(filename, "rb");		#endif		for (int j = 0 ; j < 3 ; j++)		{			fscanf(fp, "%[^\n]%*c", objective);			fscanf(fp, "%d", &type);			fscanf(fp, "%d", &target);			fscanf(fp, "%d", &value);			fscanf(fp, "%d", &time);			fscanf(fp, "%d%*c", &complete);			strcpy(missions[i].primaryObjective[j], objective);			missions[i].primaryType[j] = type;			missions[i].target1[j] = target;			missions[i].targetValue1[j] = value;			missions[i].timeLimit1[j] = time;			missions[i].completed1[j] = complete;		}		for (int j = 0 ; j < 3 ; j++)		{			fscanf(fp, "%[^\n]%*c", objective);			fscanf(fp, "%d", &type);			fscanf(fp, "%d", &target);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -