#include<iostream>
#include<string>
#include<windows.h>
#include<cstdlib>
#include<ctime>
using namespace std;
// 全局变量 - 游戏状态
int currentLevel = 1; // 当前关卡
bool foundLinYun = false; // 是否找到林云(第三关关键目标)
// 第一关状态变量
bool level1_gun = true; // 炮管状态
bool level1_engine = true; // 发动机状态
bool level1_radar = true; // 火控雷达状态
bool level1_loader = true; // 装填装置状态
int level1_enemyTanks = 15; // 敌方坦克数量
int level1_health = 100; // 坦克生命值
// 第二关状态变量
bool level2_gun = true; // 炮管状态
bool level2_engine = true; // 发动机状态
bool level2_radar = true; // 火控雷达状态
bool level2_loader = true; // 装填装置状态
bool level2_comms = true; // 通信系统状态
int level2_enemyTanks = 24; // 敌方坦克数量
int level2_enemyJets = 8; // 敌方喷气式战机数量
int level2_health = 100; // 坦克生命值
int level2_allies = 3; // 友军单位数量
bool level2_jammingActive = false; // 全频带阻塞干扰状态
int level2_jammingTimer = 0; // 干扰计时器
// 第三关状态变量
bool level3_gun = true; // 炮管状态
bool level3_engine = true; // 发动机状态
bool level3_radar = true; // 火控雷达状态
bool level3_loader = true; // 装填装置状态
bool level3_comms = true; // 通信系统状态
bool level3_scanner = true; // 生命探测扫描器状态
int level3_enemyTanks = 30; // 敌方坦克数量
int level3_enemyJets = 12; // 敌方喷气式战机数量
int level3_enemyInfantry = 20; // 敌方步兵数量
int level3_health = 100; // 坦克生命值
int level3_allies = 5; // 友军单位数量
bool level3_jammingActive = false; // 全频带阻塞干扰状态
int level3_jammingTimer = 0; // 干扰计时器
int level3_searchProgress = 0; // 搜索林云的进度(0-100)
// 设置控制台中文显示
void setConsoleEncoding() {
}
// 关卡函数声明
void level1_fight();
void level1_repair();
void level1_mobile();
int level1_battle();
int level1_story();
int level1_start();
void level2_fight();
void level2_repair();
void level2_mobile();
void level2_commsSystem();
void level2_activateJamming();
int level2_battle();
int level2_story();
int level2_start();
void level3_fight();
void level3_repair();
void level3_mobile();
void level3_commsSystem();
void level3_activateJamming();
void level3_searchSystem();
void level3_launchAssault();
int level3_battle();
int level3_story();
int level3_start();
// 通用函数
void game_over();
void next_level();
void game_complete();
// 第一关战斗系统
void level1_fight() {
system("cls");
if (!level1_gun || !level1_loader) {
cout << "====>>> 战斗系统 <<<====" << endl;
if (!level1_gun) cout << "警告:炮管损坏,无法开火!" << endl;
if (!level1_loader) cout << "警告:装填装置损坏,无法装填弹药!" << endl;
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level1_battle();
return;
}
cout << "====>>> 战斗系统 <<<====" << endl;
cout << "发现" << level1_enemyTanks << "辆敌方坦克!" << endl;
cout << "1. 精准射击" << endl;
cout << "2. 范围攻击" << endl;
cout << "3. 穿甲弹攻击" << endl;
cout << "4. 返回" << endl;
cout << "请选择:";
int choice;
cin >> choice;
srand(time(0));
int hitProbability = rand() % 100;
bool hit = false;
system("cls");
cout << "====>>> 战斗结果 <<<====" << endl;
if (choice == 1) {
if (level1_enemyTanks <= 0) {
cout << "当前区域已无敌方坦克!" << endl;
} else if (hitProbability > 30) { // 70%命中率
cout << "精准命中敌方坦克!成功摧毁一辆!" << endl;
level1_enemyTanks--;
hit = true;
} else {
cout << "射击未命中目标!" << endl;
}
}
else if (choice == 2) {
if (level1_enemyTanks <= 0) {
cout << "当前区域已无敌方坦克!" << endl;
} else if (hitProbability > 60) { // 40%命中率
int destroy = rand() % 2 + 1;
cout << "范围攻击成功!摧毁" << destroy << "辆敌方坦克!" << endl;
level1_enemyTanks -= destroy;
if (level1_enemyTanks < 0) level1_enemyTanks = 0;
hit = true;
} else {
cout << "范围攻击效果不佳!" << endl;
}
}
else if (choice == 3) {
if (level1_enemyTanks <= 0) {
cout << "当前区域已无敌方坦克!" << endl;
} else if (hitProbability > 40) { // 60%命中率
cout << "穿甲弹精准命中!摧毁了一辆重型坦克!" << endl;
level1_enemyTanks--;
hit = true;
} else {
cout << "穿甲弹射击失败,敌方坦克发起反击!" << endl;
level1_health -= 15;
}
}
else if (choice == 4) {
system("cls");
level1_battle();
return;
}
else {
cout << "无效选择!" << endl;
}
// 敌方反击
if (hit && level1_enemyTanks > 0) {
if (rand() % 100 < 40) { // 40%概率反击
cout << "敌方坦克发起了反击!" << endl;
level1_health -= 10;
// 随机损坏部件
if (rand() % 100 < 20) { // 20%概率损坏部件
int damagePart = rand() % 4;
if (damagePart == 0) { level1_gun = false; cout << "炮管被击中损坏!" << endl; }
else if (damagePart == 1) { level1_engine = false; cout << "发动机受损!" << endl; }
else if (damagePart == 2) { level1_radar = false; cout << "雷达被摧毁!" << endl; }
else { level1_loader = false; cout << "装填系统故障!" << endl; }
}
}
}
cout << "剩余敌方坦克:" << level1_enemyTanks << endl;
cout << "我方生命值:" << level1_health << endl;
if (level1_enemyTanks <= 0) {
cout << "恭喜!成功突破敌方防线!第一关任务完成!" << endl;
cout << "准备进入下一关..." << endl;
Sleep(3000);
next_level();
return;
}
if (level1_health <= 0) {
game_over();
return;
}
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level1_battle();
}
// 第一关修复系统
void level1_repair() {
system("cls");
cout << "====>>> 修复系统 <<<====" << endl;
cout << "1. 修复炮管 (" << (level1_gun ? "正常" : "损坏") << ")" << endl;
cout << "2. 修复发动机 (" << (level1_engine ? "正常" : "损坏") << ")" << endl;
cout << "3. 修复火控雷达 (" << (level1_radar ? "正常" : "损坏") << ")" << endl;
cout << "4. 修复装填装置装置 (" << (level1_loader ? "正常" : "损坏") << ")" << endl;
cout << "5. 返回" << endl;
cout << "请选择要修复的部件:";
int choice;
cin >> choice;
system("cls");
srand(time(0));
int repairSuccess = rand() % 100;
cout << "====>>> 修复结果 <<<====" << endl;
switch (choice) {
case 1:
if (level1_gun) {
cout << "炮管本来就是正常的,无需修复!" << endl;
break;
}
if (repairSuccess > 30) { // 70%修复成功率
level1_gun = true;
cout << "炮管修复成功!" << endl;
} else {
cout << "修复失败,炮管仍然损坏!" << endl;
}
break;
case 2:
if (level1_engine) {
cout << "发动机本来就是正常的,无需修复!" << endl;
break;
}
if (repairSuccess > 40) { // 60%修复成功率
level1_engine = true;
cout << "发动机修复成功!" << endl;
} else {
cout << "修复失败,发动机仍然损坏!" << endl;
}
break;
case 3:
if (level1_radar) {
cout << "火控雷达本来就是正常的,无需修复!" << endl;
break;
}
if (repairSuccess > 20) { // 80%修复成功率
level1_radar = true;
cout << "火控雷达修复成功!" << endl;
} else {
cout << "修复失败,火控雷达仍然损坏!" << endl;
}
break;
case 4:
if (level1_loader) {
cout << "装填装置本来就是正常的,无需修复!" << endl;
break;
}
if (repairSuccess > 25) { // 75%修复成功率
level1_loader = true;
cout << "装填装置修复成功!" << endl;
} else {
cout << "修复失败,装填装置装置仍然损坏!" << endl;
}
break;
case 5:
system("cls");
level1_battle();
return;
default:
cout << "无效选择!" << endl;
}
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level1_battle();
}
// 第一关移动系统
void level1_mobile() {
system("cls");
if (!level1_engine) {
cout << "====>>> 移动系统 <<<====" << endl;
cout << "发动机损坏,无法移动!请先修复发动机。" << endl;
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level1_battle();
return;
}
cout << "====>>> 移动系统 <<<====" << endl;
cout << "1. 快速推进" << endl;
cout << "2. 隐蔽前进" << endl;
cout << "3. 防御姿态" << endl;
cout << "4. 后撤休整" << endl;
cout << "5. 返回" << endl;
cout << "请选择移动方式:";
int choice;
cin >> choice;
system("cls");
cout << "====>>> 移动结果 <<<====" << endl;
switch (choice) {
case 1:
cout << "坦克快速推进,抢占了有利位置!" << endl;
if (rand() % 100 > 40) {
level1_enemyTanks--;
cout << "途中遭遇敌方侦察车并将其摧毁!" << endl;
} else {
cout << "敌方发现了我们的动向,做好战斗准备!" << endl;
}
break;
case 2:
cout << "坦克隐蔽前进,避开了敌方侦察!" << endl;
cout << "下一次攻击命中率提升!" << endl;
break;
case 3:
cout << "坦克进入防御姿态,减少受到的伤害。" << endl;
cout << "防御力提升,持续到下一回合!" << endl;
break;
case 4:
cout << "坦克后撤至安全区域进行休整。" << endl;
level1_health += 20;
if (level1_health > 100) level1_health = 100;
cout << "生命值恢复到:" << level1_health << endl;
break;
case 5:
system("cls");
level1_battle();
return;
default:
cout << "无效选择!" << endl;
}
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level1_battle();
}
// 第一关战斗面板
int level1_battle() {
cout << "====>>> 第一关 - 突破防线 <<<====" << endl;
cout << " 炮管旋转:" << (level1_gun ? "正常" : "损坏") << " " << endl;
cout << " 发动机:" << (level1_engine ? "正常" : "损坏") << " " << endl;
cout << " 火控雷达: " << (level1_radar ? "正常" : "损坏") << " " << endl;
cout << " 装填装置: " << (level1_loader ? "正常" : "损坏") << " " << endl;
cout << " 剩余敌方坦克: " << level1_enemyTanks << "辆" << endl;
cout << " 坦克生命值: " << level1_health << endl;
cout << " 1: 打开火控系统" << endl;
cout << " 2: 打开修复系统" << endl;
cout << " 3: 打开移动系统" << endl;
cout << "====>>> 请选择: <<<====" << endl;
int sg;
cin >> sg;
switch(sg) {
case 1:
level1_fight();
break;
case 2:
level1_repair();
break;
case 3:
level1_mobile();
break;
default:
cout << "错误:无效的选择!" << endl;
system("pause");
system("cls");
level1_battle();
}
return 0;
}
// 第一关剧情
int level1_story() {
system("cls");
cout << "====>>> 第一关 - 剧情 <<<====" << endl;
cout << "战争已经持续了三个月,敌方构筑了坚固的防线。" << endl; Sleep(1500);
cout << "你的任务是指挥一辆主战坦克,突破敌方的第一道防线," << endl; Sleep(1500);
cout << "为后续部队打开通道。" << endl; Sleep(1000);
cout << endl << "指挥官:" << endl; Sleep(500);
cout << "我们的情报显示,前方有大约一个连的敌方坦克部队驻守," << endl; Sleep(1500);
cout << "他们的火力配置包括反坦克导弹和重型坦克。" << endl; Sleep(1200);
cout << "你的坦克是我们最先进的型号,但记住,你孤军深入," << endl; Sleep(1200);
cout << "保持警惕,合理利用战术,你一定能成功!" << endl; Sleep(1500);
system("pause");
system("cls");
cout << "正在接近敌方防线..." << endl; Sleep(1000);
cout << "雷达显示前方10公里处有装甲部队活动。" << endl; Sleep(1000);
cout << "发动机运转正常,武器系统准备就绪。" << endl; Sleep(1000);
cout << "前方发现敌方巡逻队!准备战斗!" << endl; Sleep(1000);
system("pause");
system("cls");
return 0;
}
// 第一关开场
int level1_start() {
system("cls");
cout << "##################" << endl;
cout << "# 全频带阻塞干扰 #" << endl;
cout << "# 第一关:突破防线 #" << endl;
cout << "##################" << endl;
system("pause");
system("cls");
cout << "2"; Sleep(100); cout << "0"; Sleep(100); cout << "0"; Sleep(100);
cout << "5"; Sleep(100); cout << "."; Sleep(100);
cout << "0"; Sleep(100); cout << "1"; Sleep(100); cout << "."; Sleep(100);
cout << "0"; Sleep(100); cout << "1"; Sleep(100);
cout << endl;
cout << "前"; Sleep(100); cout << "线"; Sleep(100); cout << "防"; Sleep(100); cout << "线"; Sleep(100);
cout << endl;
cout << "作"; Sleep(100); cout << "战"; Sleep(100); cout << "任"; Sleep(100); cout << "务"; Sleep(100);
cout << ":"; Sleep(100);
cout << endl;
cout << "突"; Sleep(100); cout << "破"; Sleep(100); cout << "敌"; Sleep(100); cout << "方"; Sleep(100);
cout << "第"; Sleep(100); cout << "一"; Sleep(100); cout << "道"; Sleep(100); cout << "防"; Sleep(100);
cout << "线"; Sleep(100);
cout << endl;
system("pause");
system("cls");
return 0;
}
// 第二关战斗系统
void level2_fight() {
system("cls");
if (!level2_gun || !level2_loader) {
cout << "====>>> 战斗系统 <<<====" << endl;
if (!level2_gun) cout << "警告:炮管损坏,无法开火!" << endl;
if (!level2_loader) cout << "警告:装填装置损坏,无法装填弹药!" << endl;
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level2_battle();
return;
}
cout << "====>>> 战斗系统 <<<====" << endl;
cout << "发现" << level2_enemyTanks << "辆敌方坦克和" << level2_enemyJets << "架战机!" << endl;
cout << (level2_jammingActive ? "全频带阻塞干扰已激活!雷达和远程通信受限!" : "") << endl;
cout << "1. 瞄准坦克" << endl;
cout << "2. 对空防御" << endl;
cout << "3. 群发攻击" << endl;
cout << "4. 呼叫友军支援" << (level2_allies <= 0 ? "(已无友军)" : "") << endl;
cout << "5. 返回" << endl;
cout << "请选择:";
int choice;
cin >> choice;
srand(time(0));
int hitProbability = rand() % 100;
bool hit = false;
system("cls");
cout << "====>>> 战斗结果 <<<====" << endl;
// 干扰状态影响命中率
int effectiveProb = level2_jammingActive ? hitProbability - 20 : hitProbability;
if (choice == 1) {
if (level2_enemyTanks <= 0) {
cout << "当前区域已无敌方坦克!" << endl;
} else if (effectiveProb > 30) { // 基础70%命中率,干扰时降为50%
cout << "命中敌方坦克!成功摧毁一辆!" << endl;
level2_enemyTanks--;
hit = true;
} else {
cout << "射击未命中目标!" << endl;
}
}
else if (choice == 2) {
if (level2_enemyJets <= 0) {
cout << "当前区域已无敌方战机!" << endl;
} else if (effectiveProb > 50) { // 基础50%命中率,干扰时降为30%
cout << "成功击落一架敌方战机!" << endl;
level2_enemyJets--;
hit = true;
} else {
cout << "对空防御失败,敌方战机进行了轰炸!" << endl;
level2_health -= 15;
if (rand() % 100 < 30) { // 30%概率损坏部件
int damagePart = rand() % 5;
if (damagePart == 0) { level2_gun = false; cout << "炮管被炸毁!" << endl; }
else if (damagePart == 1) { level2_engine = false; cout << "发动机受损!" << endl; }
else if (damagePart == 2) { level2_radar = false; cout << "雷达被摧毁!" << endl; }
else if (damagePart == 3) { level2_loader = false; cout << "装填系统故障!" << endl; }
else { level2_comms = false; cout << "通信系统被毁!" << endl; }
}
}
}
else if (choice == 3) {
if (effectiveProb > 60) { // 基础40%命中率,干扰时降为20%
int destroyTanks = rand() % 2 + 1;
int destroyJets = level2_enemyJets > 0 ? rand() % 2 : 0;
cout << "群发攻击成功!摧毁" << destroyTanks << "辆坦克和" << destroyJets << "架战机!" << endl;
level2_enemyTanks -= destroyTanks;
level2_enemyJets -= destroyJets;
if (level2_enemyTanks < 0) level2_enemyTanks = 0;
if (level2_enemyJets < 0) level2_enemyJets = 0;
hit = true;
} else {
cout << "群发攻击效果不佳!敌方发动了联合反击!" << endl;
level2_health -= 25;
}
}
else if (choice == 4) {
if (level2_allies <= 0) {
cout << "已没有友军可以支援!" << endl;
} else if (!level2_comms) {
cout << "通信系统损坏,无法呼叫支援!" << endl;
} else if (rand() % 100 > 40) { // 60%成功率
cout << "友军支援到达!摧毁了2辆敌方坦克!" << endl;
level2_enemyTanks -= 2;
if (level2_enemyTanks < 0) level2_enemyTanks = 0;
level2_allies--;
} else {
cout << "友军支援被敌方拦截,未能到达!" << endl;
level2_allies--;
}
}
else if (choice == 5) {
system("cls");
level2_battle();
return;
}
else {
cout << "无效选择!" << endl;
}
// 敌方反击
if (hit && (level2_enemyTanks > 0 || level2_enemyJets > 0)) {
if (rand() % 100 < 50) { // 50%概率反击
cout << "敌方发起了反击!" << endl;
level2_health -= 10;
}
}
// 更新干扰状态
if (level2_jammingActive) {
level2_jammingTimer--;
if (level2_jammingTimer <= 0) {
level2_jammingActive = false;
cout << "全频带阻塞干扰效果消失!系统恢复正常!" << endl;
} else {
cout << "全频带阻塞干扰剩余时间:" << level2_jammingTimer << "回合" << endl;
}
}
cout << "剩余敌方坦克:" << level2_enemyTanks << endl;
cout << "剩余敌方战机:" << level2_enemyJets << endl;
cout << "剩余友军:" << level2_allies << endl;
cout << "我方生命值:" << level2_health << endl;
if (level2_enemyTanks <= 0 && level2_enemyJets <= 0) {
cout << "恭喜!成功突破封锁线!第二关任务完成!" << endl;
cout << "准备进入最终关卡..." << endl;
Sleep(3000);
next_level();
return;
}
if (level2_health <= 0) {
game_over();
return;
}
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level2_battle();
}
// 第二关修复系统
void level2_repair() {
system("cls");
cout << "====>>> 修复系统 <<<====" << endl;
cout << "1. 修复炮管 (" << (level2_gun ? "正常" : "损坏") << ")" << endl;
cout << "2. 修复发动机 (" << (level2_engine ? "正常" : "损坏") << ")" << endl;
cout << "3. 修复火控雷达 (" << (level2_radar ? "正常" : "损坏") << ")" << endl;
cout << "4. 修复装填装置 (" << (level2_loader ? "正常" : "损坏") << ")" << endl;
cout << "5. 修复通信系统 (" << (level2_comms ? "正常" : "损坏") << ")" << endl;
cout << "6. 返回" << endl;
cout << "请选择要修复的部件:";
int choice;
cin >> choice;
system("cls");
srand(time(0));
int repairSuccess = rand() % 100;
cout << "====>>> 修复结果 <<<====" << endl;
switch (choice) {
case 1:
if (level2_gun) {
cout << "炮管本来就是正常的,无需修复!" << endl;
break;
}
if (repairSuccess > 30) { // 70%修复成功率
level2_gun = true;
cout << "炮管修复成功!" << endl;
} else {
cout << "修复失败,炮管仍然损坏!" << endl;
}
break;
case 2:
if (level2_engine) {
cout << "发动机本来就是正常的,无需修复!" << endl;
break;
}
if (repairSuccess > 40) { // 60%修复成功率
level2_engine = true;
cout << "发动机修复成功!" << endl;
} else {
cout << "修复失败,发动机仍然损坏!" << endl;
}
break;
case 3:
if (level2_radar) {
cout << "火控雷达本来就是正常的,无需修复!" << endl;
break;
}
if (repairSuccess > 20) { // 80%修复成功率
level2_radar = true;
cout << "火控雷达修复成功!" << endl;
} else {
cout << "修复失败,火控雷达仍然损坏!" << endl;
}
break;
case 4:
if (level2_loader) {
cout << "装填装置本来就是正常的,无需修复!" << endl;
break;
}
if (repairSuccess > 25) { // 75%修复成功率
level2_loader = true;
cout << "装填装置修复成功!" << endl;
} else {
cout << "修复失败,装填装置仍然损坏!" << endl;
}
break;
case 5:
if (level2_comms) {
cout << "通信系统本来就是正常的,无需修复!" << endl;
break;
}
if (repairSuccess > 35) { // 65%修复成功率
level2_comms = true;
cout << "通信系统修复成功!" << endl;
} else {
cout << "修复失败,通信系统仍然损坏!" << endl;
}
break;
case 6:
system("cls");
level2_battle();
return;
default:
cout << "无效选择!" << endl;
}
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level2_battle();
}
// 第二关移动系统
void level2_mobile() {
system("cls");
if (!level2_engine) {
cout << "====>>> 移动系统 <<<====" << endl;
cout << "发动机损坏,无法移动!请先修复发动机。" << endl;
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level2_battle();
return;
}
cout << "====>>> 移动系统 <<<====" << endl;
cout << "1. 沿公路推进" << endl;
cout << "2. 进入森林隐蔽" << endl;
cout << "3. 占领高地" << endl;
cout << "4. 后撤休整" << endl;
cout << "5. 返回" << endl;
cout << "请选择移动方式:";
int choice;
cin >> choice;
system("cls");
cout << "====>>> 移动结果 <<<====" << endl;
switch (choice) {
case 1:
cout << "坦克沿公路快速推进,提前到达了预定位置。" << endl;
level2_enemyTanks--;
cout << "遭遇并摧毁了一辆落单的敌方侦察坦克!" << endl;
break;
case 2:
cout << "坦克进入森林隐蔽,敌方战机无法锁定目标。" << endl;
if (level2_enemyJets > 0) {
cout << "成功躲避了敌方的空中侦察和打击!" << endl;
}
break;
case 3:
cout << "坦克占领了高地,获得了更好的射击视野!" << endl;
cout << "下一次攻击命中率提升!" << endl;
break;
case 4:
cout << "坦克后撤至安全区域进行休整。" << endl;
level2_health += 15;
if (level2_health > 100) level2_health = 100;
cout << "生命值恢复到:" << level2_health << endl;
break;
case 5:
system("cls");
level2_battle();
return;
default:
cout << "无效选择!" << endl;
}
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level2_battle();
}
// 第二关通信系统
void level2_commsSystem() {
system("cls");
if (!level2_comms) {
cout << "====>>> 通信系统 <<<====" << endl;
cout << "通信系统损坏,无法使用!请先修复通信系统。" << endl;
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level2_battle();
return;
}
cout << "====>>> 通信系统 <<<====" << endl;
cout << "1. 接收战场情报" << endl;
cout << "2. 呼叫空中支援" << (rand() % 100 > 70 ? "(可用)" : "(冷却中)") << endl;
cout << "3. 激活全频带阻塞干扰" << (level2_jammingActive ? "(已激活)" : "") << endl;
cout << "4. 返回" << endl;
cout << "请选择:";
int choice;
cin >> choice;
system("cls");
cout << "====>>> 操作结果 <<<====" << endl;
switch (choice) {
case 1:
cout << "收到最新战场情报:" << endl;
if (rand() % 100 > 30) {
cout << "- 敌方主力位于东北方向3公里处" << endl;
cout << "- 敌方防空系统部署在高地" << endl;
cout << "- 友军小队正在西侧发起佯攻" << endl;
cout << "获得了战术优势!" << endl;
} else {
cout << "信号受到干扰,未能获取有效情报。" << endl;
}
break;
case 2:
if (rand() % 100 > 70) {
cout << "空中支援到达!对敌方阵地进行了轰炸!" << endl;
int destroyed = rand() % 3 + 1;
level2_enemyTanks -= destroyed;
if (level2_enemyTanks < 0) level2_enemyTanks = 0;
cout << "成功摧毁" << destroyed << "辆敌方坦克!" << endl;
} else {
cout << "空中支援暂时无法到达,请稍后再试。" << endl;
}
break;
case 3:
if (level2_jammingActive) {
cout << "全频带阻塞干扰已经处于激活状态!" << endl;
} else {
level2_activateJamming();
}
break;
case 4:
system("cls");
level2_battle();
return;
default:
cout << "无效选择!" << endl;
}
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level2_battle();
}
// 激活全频带阻塞干扰(第二关)
void level2_activateJamming() {
level2_jammingActive = true;
level2_jammingTimer = 3; // 持续3回合
cout << "全频带阻塞干扰已激活!" << endl;
cout << "所有敌方电子设备和通信受到强烈干扰!" << endl;
cout << "警告:我方雷达和远程通信也将受到影响!" << endl;
}
// 第二关战斗面板
int level2_battle() {
cout << "====>>> 第二关 - 城市攻坚战 <<<====" << endl;
cout << " 炮管旋转:" << (level2_gun ? "正常" : "损坏") << " " << endl;
cout << " 发动机:" << (level2_engine ? "正常" : "损坏") << " " << endl;
cout << " 火控雷达: " << (level2_radar ? "正常" : "损坏") << " " << endl;
cout << " 装填装置: " << (level2_loader ? "正常" : "损坏") << " " << endl;
cout << " 通信系统: " << (level2_comms ? "正常" : "损坏") << " " << endl;
cout << " 剩余敌方坦克: " << level2_enemyTanks << "辆" << endl;
cout << " 剩余敌方战机: " << level2_enemyJets << "架" << endl;
cout << " 剩余友军: " << level2_allies << "个单位" << endl;
cout << " 坦克生命值: " << level2_health << endl;
if (level2_jammingActive) {
cout << " 全频带干扰: 激活中(" << level2_jammingTimer << ")" << endl;
}
cout << " 1: 打开火控系统" << endl;
cout << " 2: 打开修复系统" << endl;
cout << " 3: 打开移动系统" << endl;
cout << " 4: 打开通信系统" << endl;
cout << "====>>> 请选择: <<<====" << endl;
int sg;
cin >> sg;
switch(sg) {
case 1:
level2_fight();
break;
case 2:
level2_repair();
break;
case 3:
level2_mobile();
break;
case 4:
level2_commsSystem();
break;
default:
cout << "错误:无效的选择!" << endl;
system("pause");
system("cls");
level2_battle();
}
return 0;
}
// 第二关剧情
int level2_story() {
system("cls");
cout << "====>>> 第二关 - 剧情 <<<====" << endl;
cout << "你成功突破了敌方的第一道防线,但战斗远未结束。" << endl; Sleep(1500);
cout << "指挥部消息:敌人正在城市区域部署重武器,试图阻止我军推进。" << endl; Sleep(1500);
cout << "更严峻的是,敌方已获得空中支援,掌握了制空权。" << endl; Sleep(1500);
cout << "你的任务是配合友军单位,清除城市中的敌方装甲力量," << endl; Sleep(1200);
cout << "为后续部队打开通道。" << endl; Sleep(1000);
cout << endl << "通信器中传来嘈杂的声音:" << endl; Sleep(500);
cout << "这里是鹰巢,你们已进入城市作战区域," << endl; Sleep(1000);
cout << "敌方拥有先进的电子战系统,我们的雷达经常受到干扰。" << endl; Sleep(1200);
cout << "记住,在必要时可以激活全频带阻塞干扰," << endl; Sleep(1000);
cout << "这会让双方的电子设备都失效,但也许能为你们争取一线生机。" << endl; Sleep(1500);
cout << endl << "友军指挥官:" << endl; Sleep(500);
cout << "我们的兵力不多了,每辆坦克都至关重要。" << endl; Sleep(1000);
cout << "保存实力,精准打击,我们必须赢得这场城市攻坚战!" << endl; Sleep(1500);
system("pause");
system("cls");
cout << "正在进入塘沽市区..." << endl; Sleep(1000);
cout << "街道上到处是废弃的车辆和瓦砾,形成了天然的障碍。" << endl; Sleep(1500);
cout << "远处传来坦克引擎的轰鸣声和枪炮声..." << endl; Sleep(1000);
cout << "突然,通讯器里传来紧急呼叫:" << endl; Sleep(800);
cout << "发现敌方装甲纵队!数量约24辆,伴有空中支援!" << endl; Sleep(1200);
cout << "准备战斗!" << endl; Sleep(500);
system("pause");
system("cls");
return 0;
}
// 第二关开场
int level2_start() {
system("cls");
cout << "##################" << endl;
cout << "# 全频带阻塞干扰 #" << endl;
cout << "# 第二关:城市攻坚战 #" << endl;
cout << "##################" << endl;
system("pause");
system("cls");
cout << "2"; Sleep(100); cout << "0"; Sleep(100); cout << "0"; Sleep(100);
cout << "5"; Sleep(100); cout << "."; Sleep(100);
cout << "0"; Sleep(100); cout << "1"; Sleep(100); cout << "."; Sleep(100);
cout << "0"; Sleep(100); cout << "7"; Sleep(100);
cout << endl;
cout << "塘"; Sleep(100); cout << "沽"; Sleep(100); cout << "市"; Sleep(100); cout << "区"; Sleep(100);
cout << endl;
cout << "作"; Sleep(100); cout << "战"; Sleep(100); cout << "任"; Sleep(100); cout << "务"; Sleep(100);
cout << ":"; Sleep(100);
cout << endl;
cout << "清"; Sleep(100); cout << "除"; Sleep(100); cout << "城"; Sleep(100); cout << "市"; Sleep(100);
cout << "敌"; Sleep(100); cout << "军"; Sleep(100);
cout << endl;
cout << "关"; Sleep(100); cout << "键"; Sleep(100); cout << "技"; Sleep(100); cout << "术"; Sleep(100);
cout << ":"; Sleep(100); cout << "全"; Sleep(100); cout << "频"; Sleep(100); cout << "带"; Sleep(100);
cout << "阻"; Sleep(100); cout << "塞"; Sleep(100); cout << "干"; Sleep(100); cout << "扰"; Sleep(100);
cout << endl;
system("pause");
system("cls");
return 0;
}
// 第三关战斗系统
void level3_fight() {
system("cls");
if (!level3_gun || !level3_loader) {
cout << "====>>> 战斗系统 <<<====" << endl;
if (!level3_gun) cout << "警告:炮管损坏,无法开火!" << endl;
if (!level3_loader) cout << "警告:装填装置损坏,无法装填弹药!" << endl;
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level3_battle();
return;
}
cout << "====>>> 战斗系统 <<<====" << endl;
cout << "发现" << level3_enemyTanks << "辆敌方坦克、" << level3_enemyJets << "架战机和"
<< level3_enemyInfantry << "名步兵!" << endl;
cout << (level3_jammingActive ? "全频带阻塞干扰已激活!雷达和远程通信受限!" : "") << endl;
cout << "1. 瞄准坦克" << endl;
cout << "2. 对空防御" << endl;
cout << "3. 压制步兵" << endl;
cout << "4. 群发攻击" << endl;
cout << "5. 呼叫友军支援" << (level3_allies <= 0 ? "(已无友军)" : "") << endl;
cout << "6. 返回" << endl;
cout << "请选择:";
int choice;
cin >> choice;
srand(time(0));
int hitProbability = rand() % 100;
bool hit = false;
system("cls");
cout << "====>>> 战斗结果 <<<====" << endl;
// 干扰状态影响命中率
int effectiveProb = level3_jammingActive ? hitProbability - 20 : hitProbability;
if (choice == 1) {
if (level3_enemyTanks <= 0) {
cout << "当前区域已无敌方坦克!" << endl;
} else if (effectiveProb > 30) { // 基础70%命中率,干扰时降为50%
cout << "命中敌方坦克!成功摧毁一辆!" << endl;
level3_enemyTanks--;
hit = true;
} else {
cout << "射击未命中目标!" << endl;
}
}
else if (choice == 2) {
if (level3_enemyJets <= 0) {
cout << "当前区域已无敌方战机!" << endl;
} else if (effectiveProb > 50) { // 基础50%命中率,干扰时降为30%
cout << "成功击落一架敌方战机!" << endl;
level3_enemyJets--;
hit = true;
} else {
cout << "对空防御失败,敌方战机进行了轰炸!" << endl;
level3_health -= 15;
}
}
else if (choice == 3) {
if (level3_enemyInfantry <= 0) {
cout << "当前区域已无敌方步兵!" << endl;
} else if (effectiveProb > 20) { // 基础80%命中率,干扰时降为60%
int destroy = rand() % 5 + 1;
cout << "成功压制敌方步兵!消灭了" << destroy << "名步兵!" << endl;
level3_enemyInfantry -= destroy;
if (level3_enemyInfantry < 0) level3_enemyInfantry = 0;
hit = true;
} else {
cout << "压制失败,敌方步兵使用火箭筒反击!" << endl;
level3_health -= 10;
}
}
else if (choice == 4) {
if (effectiveProb > 60) { // 基础40%命中率,干扰时降为20%
int destroyTanks = rand() % 2 + 1;
int destroyJets = level3_enemyJets > 0 ? rand() % 2 : 0;
int destroyInfantry = rand() % 3 + 1;
cout << "群发攻击成功!摧毁" << destroyTanks << "辆坦克、" << destroyJets << "架战机和"
<< destroyInfantry << "名步兵!" << endl;
level3_enemyTanks -= destroyTanks;
level3_enemyJets -= destroyJets;
level3_enemyInfantry -= destroyInfantry;
if (level3_enemyTanks < 0) level3_enemyTanks = 0;
if (level3_enemyJets < 0) level3_enemyJets = 0;
if (level3_enemyInfantry < 0) level3_enemyInfantry = 0;
hit = true;
} else {
cout << "群发攻击效果不佳!敌方发动了联合反击!" << endl;
level3_health -= 25;
}
}
else if (choice == 5) {
if (level3_allies <= 0) {
cout << "已没有友军可以支援!" << endl;
} else if (!level3_comms) {
cout << "通信系统损坏,无法呼叫支援!" << endl;
} else if (rand() % 100 > 40) { // 60%成功率
cout << "友军支援到达!摧毁了3辆敌方坦克和若干步兵!" << endl;
level3_enemyTanks -= 3;
level3_enemyInfantry -= 5;
if (level3_enemyTanks < 0) level3_enemyTanks = 0;
if (level3_enemyInfantry < 0) level3_enemyInfantry = 0;
level3_allies--;
} else {
cout << "友军支援被敌方拦截,损失惨重!" << endl;
level3_allies--;
}
}
else if (choice == 6) {
system("cls");
level3_battle();
return;
}
else {
cout << "无效选择!" << endl;
}
// 敌方反击
if (hit && (level3_enemyTanks > 0 || level3_enemyJets > 0 || level3_enemyInfantry > 0)) {
if (rand() % 100 < 60) { // 60%概率反击
cout << "敌方发起了猛烈反击!" << endl;
level3_health -= 15;
}
}
// 更新干扰状态
if (level3_jammingActive) {
level3_jammingTimer--;
if (level3_jammingTimer <= 0) {
level3_jammingActive = false;
cout << "全频带阻塞干扰效果消失!系统恢复正常!" << endl;
} else {
cout << "全频带阻塞干扰剩余时间:" << level3_jammingTimer << "回合" << endl;
}
}
// 如果还没找到林云,每次战斗后有机会获得线索
if (!foundLinYun && rand() % 100 < 30) {
int progress = rand() % 15 + 5;
level3_searchProgress += progress;
if (level3_searchProgress > 100) level3_searchProgress = 100;
cout << "在战斗中发现了林云的踪迹线索!搜索进度:" << level3_searchProgress << "%" << endl;
if (level3_searchProgress >= 100 && !foundLinYun) {
foundLinYun = true;
cout << endl << "===== 重要发现 =====" << endl;
cout << "成功定位到林云的位置!她被围困在敌方指挥中心!" << endl;
cout << "立即发起进攻,营救林云并摧毁敌方指挥系统!" << endl;
cout << "====================" << endl << endl;
}
}
cout << "剩余敌方坦克:" << level3_enemyTanks << endl;
cout << "剩余敌方战机:" << level3_enemyJets << endl;
cout << "剩余敌方步兵:" << level3_enemyInfantry << endl;
cout << "剩余友军:" << level3_allies << endl;
cout << "我方生命值:" << level3_health << endl;
// 找到林云后,敌方指挥中心被摧毁即为胜利
if (foundLinYun && level3_enemyTanks <= 0 && level3_enemyJets <= 0 && level3_enemyInfantry <= 0) {
cout << "恭喜!成功摧毁敌方指挥中心,营救出林云!" << endl;
cout << "第三关任务完成!你成功完成了所有使命!" << endl;
Sleep(3000);
game_complete();
return;
}
if (level3_health <= 0) {
game_over();
return;
}
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level3_battle();
}
// 第三关修复系统
void level3_repair() {
system("cls");
cout << "====>>> 修复系统 <<<====" << endl;
cout << "1. 修复炮管 (" << (level3_gun ? "正常" : "损坏") << ")" << endl;
cout << "2. 修复发动机 (" << (level3_engine ? "正常" : "损坏") << ")" << endl;
cout << "3. 修复火控雷达 (" << (level3_radar ? "正常" : "损坏") << ")" << endl;
cout << "4. 修复装填装置 (" << (level3_loader ? "正常" : "损坏") << ")" << endl;
cout << "5. 修复通信系统 (" << (level3_comms ? "正常" : "损坏") << ")" << endl;
cout << "6. 修复生命探测扫描器 (" << (level3_scanner ? "正常" : "损坏") << ")" << endl;
cout << "7. 返回" << endl;
cout << "请选择要修复的部件:";
int choice;
cin >> choice;
system("cls");
srand(time(0));
int repairSuccess = rand() % 100;
cout << "====>>> 修复结果 <<<====" << endl;
switch (choice) {
case 1:
if (level3_gun) {
cout << "炮管本来就是正常的,无需修复!" << endl;
break;
}
if (repairSuccess > 30) { // 70%修复成功率
level3_gun = true;
cout << "炮管修复成功!" << endl;
} else {
cout << "修复失败,炮管仍然损坏!" << endl;
}
break;
case 2:
if (level3_engine) {
cout << "发动机本来就是正常的,无需修复!" << endl;
break;
}
if (repairSuccess > 40) { // 60%修复成功率
level3_engine = true;
cout << "发动机修复成功!" << endl;
} else {
cout << "修复失败,发动机仍然损坏!" << endl;
}
break;
case 3:
if (level3_radar) {
cout << "火控雷达本来就是正常的,无需修复!" << endl;
break;
}
if (repairSuccess > 20) { // 80%修复成功率
level3_radar = true;
cout << "火控雷达修复成功!" << endl;
} else {
cout << "修复失败,火控雷达仍然损坏!" << endl;
}
break;
case 4:
if (level3_loader) {
cout << "装填装置本来就是正常的,无需修复!" << endl;
break;
}
if (repairSuccess > 25) { // 75%修复成功率
level3_loader = true;
cout << "装填装置修复成功!" << endl;
} else {
cout << "修复失败,装填装置仍然损坏!" << endl;
}
break;
case 5:
if (level3_comms) {
cout << "通信系统本来就是正常的,无需修复!" << endl;
break;
}
if (repairSuccess > 35) { // 65%修复成功率
level3_comms = true;
cout << "通信系统修复成功!" << endl;
} else {
cout << "修复失败,通信系统仍然损坏!" << endl;
}
break;
case 6:
if (level3_scanner) {
cout << "生命探测扫描器本来就是正常的,无需修复!" << endl;
break;
}
if (repairSuccess > 30) { // 70%修复成功率
level3_scanner = true;
cout << "生命探测扫描器修复成功!" << endl;
} else {
cout << "修复失败,生命探测扫描器仍然损坏!" << endl;
}
break;
case 7:
system("cls");
level3_battle();
return;
default:
cout << "无效选择!" << endl;
}
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level3_battle();
}
// 第三关移动系统
void level3_mobile() {
system("cls");
if (!level3_engine) {
cout << "====>>> 移动系统 <<<====" << endl;
cout << "发动机损坏,无法移动!请先修复发动机。" << endl;
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level3_battle();
return;
}
cout << "====>>> 移动系统 <<<====" << endl;
cout << "1. 向工业区推进" << endl;
cout << "2. 搜索住宅区" << endl;
cout << "3. 占领制高点" << endl;
cout << "4. 后撤休整" << endl;
cout << "5. 返回" << endl;
cout << "请选择移动方式:";
int choice;
cin >> choice;
system("cls");
cout << "====>>> 移动结果 <<<====" << endl;
switch (choice) {
case 1:
cout << "坦克向工业区推进,遭遇敌方装甲巡逻队!" << endl;
level3_enemyTanks--;
cout << "摧毁了一辆敌方坦克,但也暴露了位置!" << endl;
// 工业区搜索林云的机会
if (!foundLinYun && rand() % 100 < 40) {
int progress = rand() % 10 + 5;
level3_searchProgress += progress;
cout << "在工业区发现了可疑踪迹!搜索进度:" << level3_searchProgress << "%" << endl;
}
break;
case 2:
cout << "坦克在住宅区进行搜索,行进缓慢但隐蔽性好。" << endl;
// 住宅区搜索林云的机会更高
if (!foundLinYun && rand() % 100 < 60) {
int progress = rand() % 15 + 10;
level3_searchProgress += progress;
cout << "在住宅区发现重要线索!搜索进度:" << level3_searchProgress << "%" << endl;
}
break;
case 3:
cout << "坦克占领了制高点,获得了广阔的视野!" << endl;
cout << "下一次攻击命中率大幅提升!" << endl;
// 制高点可以观察更大范围
if (!foundLinYun && rand() % 100 < 50) {
int progress = rand() % 12 + 8;
level3_searchProgress += progress;
cout << "从高处发现了可疑活动区域!搜索进度:" << level3_searchProgress << "%" << endl;
}
break;
case 4:
cout << "坦克后撤至安全区域进行休整。" << endl;
level3_health += 20;
if (level3_health > 100) level3_health = 100;
cout << "生命值恢复到:" << level3_health << endl;
break;
case 5:
system("cls");
level3_battle();
return;
default:
cout << "无效选择!" << endl;
}
// 检查是否已找到林云
if (level3_searchProgress >= 100 && !foundLinYun) {
foundLinYun = true;
cout << endl << "===== 重要发现 =====" << endl;
cout << "成功定位到林云的位置!她被围困在敌方指挥中心!" << endl;
cout << "立即发起进攻,营救林云并摧毁敌方指挥系统!" << endl;
cout << "====================" << endl << endl;
}
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level3_battle();
}
// 第三关通信系统
void level3_commsSystem() {
system("cls");
if (!level3_comms) {
cout << "====>>> 通信系统 <<<====" << endl;
cout << "通信系统损坏,无法使用!请先修复通信系统。" << endl;
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level3_battle();
return;
}
cout << "====>>> 通信系统 <<<====" << endl;
cout << "1. 接收情报更新" << endl;
cout << "2. 呼叫空中支援" << (rand() % 100 > 60 ? "(可用)" : "(冷却中)") << endl;
cout << "3. 激活全频带阻塞干扰" << (level3_jammingActive ? "(已激活)" : "") << endl;
cout << "4. 联系友军搜索队" << (level3_allies > 0 ? "" : "(已无友军)") << endl;
cout << "5. 返回" << endl;
cout << "请选择:";
int choice;
cin >> choice;
system("cls");
cout << "====>>> 操作结果 <<<====" << endl;
switch (choice) {
case 1:
cout << "收到最新情报:" << endl;
if (rand() % 100 > 30) {
cout << "- 敌方指挥中心位于城市中心广场" << endl;
cout << "- 林云可能被关押在地下掩体中" << endl;
cout << "- 敌方正在增派援兵,尽快行动!" << endl;
if (!foundLinYun) {
level3_searchProgress += 15;
cout << "搜索进度增加15%,当前:" << level3_searchProgress << "%" << endl;
}
} else {
cout << "信号受到强烈干扰,情报不完整。" << endl;
}
break;
case 2:
if (rand() % 100 > 60) {
cout << "空中支援到达!对敌方阵地进行了地毯式轰炸!" << endl;
int destroyedTanks = rand() % 3 + 1;
int destroyedInfantry = rand() % 10 + 5;
level3_enemyTanks -= destroyedTanks;
level3_enemyInfantry -= destroyedInfantry;
if (level3_enemyTanks < 0) level3_enemyTanks = 0;
if (level3_enemyInfantry < 0) level3_enemyInfantry = 0;
cout << "成功摧毁" << destroyedTanks << "辆坦克和" << destroyedInfantry << "名步兵!" << endl;
} else {
cout << "空中支援被敌方防空系统拦截,无法到达!" << endl;
}
break;
case 3:
if (level3_jammingActive) {
cout << "全频带阻塞干扰已经处于激活状态!" << endl;
} else {
level3_activateJamming();
}
break;
case 4:
if (level3_allies <= 0) {
cout << "已没有友军搜索队可以联系!" << endl;
} else {
cout << "友军搜索队收到指令,正在进行大范围搜索!" << endl;
if (!foundLinYun) {
int progress = rand() % 20 + 10;
level3_searchProgress += progress;
cout << "友军发现了新线索!搜索进度:" << level3_searchProgress << "%" << endl;
if (level3_searchProgress >= 100 && !foundLinYun) {
foundLinYun = true;
cout << endl << "===== 重要发现 =====" << endl;
cout << "友军找到了林云的位置!她被围困在敌方指挥中心!" << endl;
cout << "立即发起进攻,营救林云并摧毁敌方指挥系统!" << endl;
cout << "====================" << endl << endl;
}
} else {
cout << "友军正在向敌方指挥中心集结,准备配合进攻!" << endl;
level3_allies++; // 增加友军数量
if (level3_allies > 5) level3_allies = 5;
}
level3_allies--;
}
break;
case 5:
system("cls");
level3_battle();
return;
default:
cout << "无效选择!" << endl;
}
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level3_battle();
}
// 第三关生命探测扫描系统(用于寻找林云)
void level3_searchSystem() {
system("cls");
if (!level3_scanner) {
cout << "====>>> 生命探测扫描系统 <<<====" << endl;
cout << "生命探测扫描器损坏,无法使用!请先修复。" << endl;
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level3_battle();
return;
}
if (foundLinYun) {
cout << "====>>> 生命探测扫描系统 <<<====" << endl;
cout << "林云的位置已确认:敌方指挥中心地下掩体!" << endl;
cout << "1. 规划进攻路线" << endl;
cout << "2. 标记敌方防御薄弱点" << endl;
cout << "3. 返回" << endl;
cout << "请选择:";
int choice;
cin >> choice;
system("cls");
cout << "====>>> 操作结果 <<<====" << endl;
switch (choice) {
case 1:
cout << "进攻路线规划完成!避开了敌方主要火力点。" << endl;
cout << "下一次进攻敌方指挥中心时受到的伤害减少50%!" << endl;
break;
case 2:
cout << "敌方防御薄弱点已标记!" << endl;
cout << "对敌方指挥中心的攻击效果提升!" << endl;
break;
case 3:
system("cls");
level3_battle();
return;
default:
cout << "无效选择!" << endl;
}
} else {
cout << "====>>> 生命探测扫描系统 <<<====" << endl;
cout << "当前搜索进度:" << level3_searchProgress << "%" << endl;
cout << "1. 进行区域扫描" << endl;
cout << "2. 分析已知线索" << endl;
cout << "3. 扩大扫描范围(消耗更多能量)" << endl;
cout << "4. 返回" << endl;
cout << "请选择:";
int choice;
cin >> choice;
system("cls");
cout << "====>>> 扫描结果 <<<====" << endl;
srand(time(0));
switch (choice) {
case 1:
if (rand() % 100 > 40) { // 60%成功率
int progress = rand() % 15 + 5;
level3_searchProgress += progress;
cout << "区域扫描成功!发现生命信号痕迹!" << endl;
cout << "搜索进度增加到:" << level3_searchProgress << "%" << endl;
} else {
cout << "扫描受到干扰,未发现有效信号。" << endl;
}
break;
case 2:
if (level3_searchProgress > 0) {
int progress = rand() % 10 + 3;
level3_searchProgress += progress;
cout << "线索分析完成,缩小了搜索范围!" << endl;
cout << "搜索进度增加到:" << level3_searchProgress << "%" << endl;
} else {
cout << "没有足够的线索进行分析,请先进行区域扫描。" << endl;
}
break;
case 3:
cout << "扩大扫描范围,能量消耗增加..." << endl;
if (rand() % 100 > 20) { // 80%成功率
int progress = rand() % 25 + 15;
level3_searchProgress += progress;
cout << "大范围扫描成功!发现重要生命信号!" << endl;
cout << "搜索进度增加到:" << level3_searchProgress << "%" << endl;
} else {
cout << "能量耗尽,扫描失败,扫描器暂时损坏!" << endl;
level3_scanner = false;
}
break;
case 4:
system("cls");
level3_battle();
return;
default:
cout << "无效选择!" << endl;
}
}
// 检查是否已找到林云
if (level3_searchProgress >= 100 && !foundLinYun) {
foundLinYun = true;
cout << endl << "===== 重要发现 =====" << endl;
cout << "成功定位到林云的位置!她被围困在敌方指挥中心!" << endl;
cout << "立即发起进攻,营救林云并摧毁敌方指挥系统!" << endl;
cout << "====================" << endl << endl;
}
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level3_battle();
}
// 第三关最终进攻(找到林云后解锁)
void level3_launchAssault() {
system("cls");
if (!foundLinYun) {
cout << "====>>> 无法发起进攻 <<<====" << endl;
cout << "尚未找到林云的位置,请先使用搜索系统确定目标位置!" << endl;
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level3_battle();
return;
}
cout << "====>>> 进攻敌方指挥中心 <<<====" << endl;
cout << "林云被关押在指挥中心地下掩体,我们需要突破外层防御!" << endl;
cout << "敌方剩余防御力量:" << endl;
cout << "- 坦克:" << level3_enemyTanks << "辆" << endl;
cout << "- 战机:" << level3_enemyJets << "架" << endl;
cout << "- 步兵:" << level3_enemyInfantry << "名" << endl;
cout << endl;
cout << "1. 正面强攻" << endl;
cout << "2. 侧翼突袭" << endl;
cout << "3. 配合友军多路进攻" << (level3_allies > 0 ? "" : "(已无友军)") << endl;
cout << "4. 返回" << endl;
cout << "请选择进攻方式:";
int choice;
cin >> choice;
system("cls");
cout << "====>>> 进攻结果 <<<====" << endl;
srand(time(0));
bool success = false;
switch (choice) {
case 1:
cout << "发起正面强攻!突破敌方防线!" << endl;
if (rand() % 100 > 50) { // 50%成功率
int destroyTanks = rand() % 5 + 3;
int destroyJets = rand() % 3 + 1;
int destroyInfantry = rand() % 10 + 5;
level3_enemyTanks -= destroyTanks;
level3_enemyJets -= destroyJets;
level3_enemyInfantry -= destroyInfantry;
cout << "成功突破正面防线!摧毁大量敌方装备!" << endl;
success = true;
// 强攻代价较大
level3_health -= 20;
} else {
cout << "正面进攻受阻,敌方防御坚固!" << endl;
level3_health -= 30;
}
break;
case 2:
cout << "实施侧翼突袭,绕过敌方主力!" << endl;
if (rand() % 100 > 30) { // 70%成功率
int destroyTanks = rand() % 3 + 1;
int destroyInfantry = rand() % 8 + 3;
level3_enemyTanks -= destroyTanks;
level3_enemyInfantry -= destroyInfantry;
cout << "侧翼突袭成功!对敌方造成出其不意的打击!" << endl;
success = true;
level3_health -= 10;
} else {
cout << "侧翼突袭被发现,陷入包围!" << endl;
level3_health -= 25;
}
break;
case 3:
if (level3_allies <= 0) {
cout << "已没有友军可以配合进攻!" << endl;
system("pause");
system("cls");
level3_launchAssault();
return;
}
cout << "与友军协同,发起多路进攻!" << endl;
if (rand() % 100 > 20) { // 80%成功率
int destroyTanks = rand() % 6 + 4;
int destroyJets = rand() % 4 + 2;
int destroyInfantry = rand() % 15 + 8;
level3_enemyTanks -= destroyTanks;
level3_enemyJets -= destroyJets;
level3_enemyInfantry -= destroyInfantry;
cout << "协同进攻大获成功!敌方防线全面崩溃!" << endl;
success = true;
level3_health -= 15;
level3_allies--;
} else {
cout << "友军进攻受阻,协同作战失败!" << endl;
level3_health -= 20;
level3_allies--;
}
break;
case 4:
system("cls");
level3_battle();
return;
default:
cout << "无效选择!" << endl;
}
// 确保数值不为负
if (level3_enemyTanks < 0) level3_enemyTanks = 0;
if (level3_enemyJets < 0) level3_enemyJets = 0;
if (level3_enemyInfantry < 0) level3_enemyInfantry = 0;
cout << "剩余敌方坦克:" << level3_enemyTanks << endl;
cout << "剩余敌方战机:" << level3_enemyJets << endl;
cout << "剩余敌方步兵:" << level3_enemyInfantry << endl;
cout << "我方生命值:" << level3_health << endl;
if (level3_enemyTanks <= 0 && level3_enemyJets <= 0 && level3_enemyInfantry <= 0) {
cout << "恭喜!成功摧毁敌方指挥中心,营救出林云!" << endl;
cout << "第三关任务完成!你成功完成了所有使命!" << endl;
Sleep(3000);
game_complete();
return;
}
if (level3_health <= 0) {
game_over();
return;
}
cout << "按任意键返回..." << endl;
system("pause");
system("cls");
level3_battle();
}
// 激活全频带阻塞干扰(第三关)
void level3_activateJamming() {
level3_jammingActive = true;
level3_jammingTimer = 4; // 持续4回合,比前两关更长
cout << "全频带阻塞干扰已激活!" << endl;
cout << "所有敌方电子设备和通信受到强烈干扰!" << endl;
cout << "警告:我方雷达和远程通信也将受到影响!" << endl;
}
// 第三关战斗面板
int level3_battle() {
cout << "====>>> 第三关 - 寻找林云并进攻 <<<====" << endl;
cout << " 炮管旋转:" << (level3_gun ? "正常" : "损坏") << " " << endl;
cout << " 发动机:" << (level3_engine ? "正常" : "损坏") << " " << endl;
cout << " 火控雷达: " << (level3_radar ? "正常" : "损坏") << " " << endl;
cout << " 装填装置: " << (level3_loader ? "正常" : "损坏") << " " << endl;
cout << " 通信系统: " << (level3_comms ? "正常" : "损坏") << " " << endl;
cout << " 生命探测扫描器: " << (level3_scanner ? "正常" : "损坏") << " " << endl;
cout << " 剩余敌方坦克: " << level3_enemyTanks << "辆" << endl;
cout << " 剩余敌方战机: " << level3_enemyJets << "架" << endl;
cout << " 剩余敌方步兵: " << level3_enemyInfantry << "名" << endl;
cout << " 剩余友军: " << level3_allies << "个单位" << endl;
cout << " 坦克生命值: " << level3_health << endl;
cout << " 搜索林云进度: " << (foundLinYun ? "已发现" : level3_searchProgress + "%") << endl;
if (level3_jammingActive) {
cout << " 全频带干扰: 激活中(" << level3_jammingTimer << ")" << endl;
}
cout << " 1: 打开火控系统" << endl;
cout << " 2: 打开修复系统" << endl;
cout << " 3: 打开移动系统" << endl;
cout << " 4: 打开通信系统" << endl;
cout << " 5: 生命探测扫描系统" << endl;
if (foundLinYun) {
cout << " 6: 发起最终进攻" << endl;
}
cout << "====>>> 请选择: <<<====" << endl;
int sg;
cin >> sg;
// 如果已找到林云,最终进攻选项可用
if (foundLinYun) {
switch(sg) {
case 1:
level3_fight();
break;
case 2:
level3_repair();
break;
case 3:
level3_mobile();
break;
case 4:
level3_commsSystem();
break;
case 5:
level3_searchSystem();
break;
case 6:
level3_launchAssault();
break;
default:
cout << "错误:无效的选择!" << endl;
system("pause");
system("cls");
level3_battle();
}
} else {
// 未找到林云时没有最终进攻选项
if (sg == 6) {
cout << "错误:无效的选择!" << endl;
system("pause");
system("cls");
level3_battle();
return 0;
}
switch(sg) {
case 1:
level3_fight();
break;
case 2:
level3_repair();
break;
case 3:
level3_mobile();
break;
case 4:
level3_commsSystem();
break;
case 5:
level3_searchSystem();
break;
default:
cout << "错误:无效的选择!" << endl;
system("pause");
system("cls");
level3_battle();
}
}
return 0;
}
// 第三关剧情
int level3_story() {
system("cls");
cout << "====>>> 第三关 - 剧情 <<<====" << endl;
cout << "经过艰苦战斗,你成功突破了敌方的城市防线," << endl; Sleep(1500);
cout << "但我们的科学家林云博士仍然下落不明。" << endl; Sleep(1500);
cout << "情报显示,她被敌方俘虏,关押在城市中心区域的指挥中心。" << endl; Sleep(1500);
cout << "林云博士掌握着对抗敌方电子战系统的关键技术," << endl; Sleep(1200);
cout << "必须不惜一切代价找到她并将其安全救出!" << endl; Sleep(1000);
cout << endl << "最高指挥部直接通讯:" << endl; Sleep(500);
cout << "这是一项最高优先级的任务。林云博士的研究对战争走向至关重要。" << endl; Sleep(1500);
cout << "我们的情报显示她可能被关押在敌方指挥中心的地下掩体中," << endl; Sleep(1200);
cout << "那里防御严密,有大量装甲部队和步兵守卫。" << endl; Sleep(1200);
cout << "你的坦克已配备最新的生命探测扫描系统,用于定位林云博士的位置。" << endl; Sleep(1500);
cout << endl << "友军指挥官:" << endl; Sleep(500);
cout << "我们会派出小队配合你的搜索行动,但要小心," << endl; Sleep(1000);
cout << "敌方在这一区域部署了最精锐的部队,他们知道林云的价值。" << endl; Sleep(1500);
cout << "找到林云后,立即发起总攻,我们会全力支援你!" << endl; Sleep(1500);
system("pause");
system("cls");
cout << "正在进入城市中心区域..." << endl; Sleep(1000);
cout << "生命探测扫描系统启动,开始搜索林云博士的信号..." << endl; Sleep(1500);
cout << "前方发现大量敌方部队,他们似乎在保护某个重要目标!" << endl; Sleep(1500);
cout << "扫描系统显示该区域有多个生命信号,但无法确定哪个是林云博士。" << endl; Sleep(1500);
cout << "准备战斗并继续搜索!" << endl; Sleep(500);
system("pause");
system("cls");
return 0;
}
// 第三关开场
int level3_start() {
system("cls");
cout << "##################" << endl;
cout << "# 全频带阻塞干扰 #" << endl;
cout << "# 第三关:寻找林云并进攻 #" << endl;
cout << "##################" << endl;
system("pause");
system("cls");
cout << "2"; Sleep(100); cout << "0"; Sleep(100); cout << "0"; Sleep(100);
cout << "5"; Sleep(100); cout << "."; Sleep(100);
cout << "0"; Sleep(100); cout << "1"; Sleep(100); cout << "."; Sleep(100);
cout << "1"; Sleep(100); cout << "0"; Sleep(100);
cout << endl;
cout << "城"; Sleep(100); cout << "市"; Sleep(100); cout << "中"; Sleep(100); cout << "心"; Sleep(100);
cout << endl;
cout << "作"; Sleep(100); cout << "战"; Sleep(100); cout << "任"; Sleep(100); cout << "务"; Sleep(100);
cout << ":"; Sleep(100);
cout << endl;
cout << "寻"; Sleep(100); cout << "找"; Sleep(100); cout << "林"; Sleep(100); cout << "云"; Sleep(100);
cout << ","; Sleep(100); cout << "进"; Sleep(100); cout << "攻"; Sleep(100); cout << "敌"; Sleep(100);
cout << "指"; Sleep(100); cout << "挥"; Sleep(100); cout << "中"; Sleep(100); cout << "心"; Sleep(100);
cout << endl;
cout << "关"; Sleep(100); cout << "键"; Sleep(100); cout << "技"; Sleep(100); cout << "术"; Sleep(100);
cout << ":"; Sleep(100); cout << "生"; Sleep(100); cout << "命"; Sleep(100); cout << "探"; Sleep(100);
cout << "测"; Sleep(100); cout << "扫"; Sleep(100); cout << "描"; Sleep(100); cout << "系"; Sleep(100);
cout << "统"; Sleep(100);
cout << endl;
system("pause");
system("cls");
return 0;
}
// 游戏结束处理
void game_over() {
system("cls");
cout << "##################" << endl;
cout << "# 游戏结束 #" << endl;
cout << "##################" << endl << endl;
cout << "很遗憾,你的坦克被摧毁了!" << endl;
cout << "在第" << currentLevel << "关英勇牺牲!" << endl << endl;
cout << "按任意键退出游戏..." << endl;
system("pause");
exit(0);
}
// 游戏通关处理
void game_complete() {
system("cls");
cout << "##################" << endl;
cout << "# 游戏通关 #" << endl;
cout << "##################" << endl << endl;
cout << "恭喜你成功完成了所有任务!" << endl;
cout << "你突破了敌方防线,攻占了城市区域," << endl;
cout << "最终成功营救出林云博士!" << endl << endl;
cout << "林云博士的研究将帮助我们破解敌方的电子战系统," << endl;
cout << "为战争的胜利奠定了基础!" << endl << endl;
cout << "按任意键退出游戏..." << endl;
system("pause");
exit(0);
}
// 切换到下一关
void next_level() {
currentLevel++;
if (currentLevel == 2) {
level2_start();
level2_story();
level2_battle();
} else if (currentLevel == 3) {
level3_start();
level3_story();
level3_battle();
}
}
// 主函数
int main() {
setConsoleEncoding(); // 设置中文显示
level1_start();
level1_story();
level1_battle();
return 0;
}
← 更新的一篇
游戏
更早的一篇 →
7硬币/战争(作弊版)
💬 评论 0
登录 后就可以参与讨论啦。
还没有评论,来说两句吧~