版本比较
保护伞覆灭
正文
增加 34 行删除 34 行
156 行未改动全部展开15715815916016116116216316416538 行未改动20420520620720820820921021121235 行未改动2482492502512522522532542552568 行未改动26526626726826926927027127227327427427527627727818 行未改动29729829930030130130230330430530630630730830931031 行未改动34234334434534634634734834935017 行未改动36836937037137237237337437537658 行未改动43543643743843943944044144244313 行未改动4574584594604614614624634644657 行未改动47347447547647747747847948048148248348448548648648748848949064 行未改动555556557558559559560561562563125 行未改动全部展开689690691692693693694695696697302 行未改动全部展开100010011002100310041004100510061007100865 行未改动1074107510761077107810781079108010811082108310831084108510861087108810891090109110911092109310941095109510961097109810992 行未改动1102110311041105110611061107110811091110111111121113111411151115111611171118111911201120112111221123112438 行未改动116311641165116611671167116811691170117139 行未改动121112121213121412151215121612171218121924 行未改动1244124512461247124812481249125012511252125312531254125512561257125812591260126012611262126312646 行未改动12711272127312741275127512761277127812791280128012811282128312841285128612871287128812891290129128 行未改动132013211322132313241324132513261327132870 行未改动13991400140114021403140314041405140614073 行未改动141114121413141414151415141614171418141979 行未改动156 行未改动全部展开 while(scanf("%d", &choice) != 1 || choice < 1 || choice > 3) { printf("\n\t选择无效!请输入1-3:"); while(getchar() != '\n'); }
switch(choice) { case 1: create_character(); break;38 行未改动 while(scanf("%d", &choice) != 1 || choice < 1 || choice > 5) { printf("\n\t选择无效!请输入1-5:"); while(getchar() != '\n'); }
switch(choice) { case 1: display_status(); break;35 行未改动 printf("\n\n【创建角色】"); printf("\n\t请输入你的名字(不超过19个字符):"); scanf("%s", player.name); player.name[MAX_NAME_LEN-1] = '\0'; // 截断过长名字
// 初始化玩家基础属性 player.max_hp = 200; player.hp = 200; player.attack = 25;8 行未改动 player.key_count = 0; player.has_virus_data = 0; player.survivor_rescued = 0; player.game_progress = 5;
// 初始道具:绿草药x2 + 贝雷塔手枪 + 手枪弹药x30 add_item(ITEM_PISTOL, 1); add_item(ITEM_HERB_GREEN, 2); add_item(ITEM_PISTOL_AMMO, 30);
printf("\n\t角色创建成功!%s,欢迎来到沦陷的浣熊市!", player.name); printf("\n\t市区已被丧尸占领,医院方向传来幸存者的求救信号..."); press_any_key(); main_menu();18 行未改动 if(player.has_pistol) printf("贝雷塔手枪 "); if(player.has_shotgun) printf("霰弹枪 "); if(player.has_sniper) printf("狙击枪 "); if(!player.has_pistol && !player.has_shotgun && !player.has_sniper) printf("无");
// 341行:修复核心——用has_item函数判断道具,参数匹配ITEM_ANTIDOTE枚举 printf("\n\t关键道具:%s(病毒数据) | %s(解毒剂)", player.has_virus_data ? "?" : "?", has_item(ITEM_ANTIDOTE) ? "?" : "?");
press_any_key();}
// 显示背包(支持丢弃道具)31 行未改动 while(scanf("%d", &choice) != 1 || choice < 1 || choice > 3) { printf("\n\t选择无效!请输入1-3:"); while(getchar() != '\n'); }
if(choice == 1 && player.inventory_count > 0) { printf("\n\t请选择要使用的道具编号(1-%d):", player.inventory_count); while(scanf("%d", &index) != 1 || index < 1 || index > player.inventory_count) { printf("\n\t编号无效!请输入1-%d:", player.inventory_count);17 行未改动 printf("\n\t该道具无法直接使用!"); press_any_key(); return; }
switch(item->type) { case ITEM_HERB_GREEN: player.hp += 50; if(player.hp > player.max_hp) player.hp = player.max_hp;58 行未改动 printf("\n\t该道具无法直接使用!"); press_any_key(); return; }
// 消耗道具(武器类不消耗,仅装备) if(item->type != ITEM_PISTOL && item->type != ITEM_SHOTGUN && item->type != ITEM_SNIPER) { item->count--; if(item->count <= 0) {13 行未改动 printf("\n\t丢弃取消!"); press_any_key(); return; }
// 移除道具 printf("\n\t成功丢弃%s!", player.inventory[index].name); for(int i=index; i<player.inventory_count-1; i++) { player.inventory[i] = player.inventory[i+1];7 行未改动 if(player.inventory_count >= MAX_INVENTORY) { printf("\n\t背包已满!无法拾取该道具!"); return 0; }
// 相同道具叠加 for(int i=0; i<player.inventory_count; i++) { if(player.inventory[i].type == type) { player.inventory[i].count += count; printf("\n\t获得了%d个%s!当前数量:%d", count, player.inventory[i].name, player.inventory[i].count); return 1; } }
// 添加新道具 Item new_item; new_item.type = type; new_item.count = count;64 行未改动 } new_item.name[MAX_ITEM_NAME_LEN-1] = '\0'; // 确保字符串结束符 player.inventory[player.inventory_count++] = new_item; printf("\n\t获得了%s x%d!", new_item.name, count);
if(type == ITEM_VIRUS_DATA) { player.game_progress += 15; printf("\n\t你获得了保护伞的核心病毒数据,距离真相更近一步!"); }125 行未改动全部展开 while(scanf("%d", &choice) != 1) { printf("\n\t输入无效!请输入数字:"); while(getchar() != '\n'); }
switch(player.location) { case 1: switch(choice) { case 1:302 行未改动全部展开 type = rand()%3 + 1; } else { type = rand()%3 + 1; }
switch(type) { case 0: // 普通丧尸 enemy.type = ENEMY_ZOMBIE; strncpy(enemy.name, "普通丧尸", MAX_ITEM_NAME_LEN-1);65 行未改动 int has_pistol_ammo = has_weapon_ammo(0); // 0=手枪 int has_shotgun_ammo = has_weapon_ammo(1); // 1=霰弹枪 int has_sniper_ammo = has_weapon_ammo(2); // 2=狙击枪 battle_win = 0;
while(current_enemy.hp > 0 && player.hp > 0) { clear_screen(); print_title(); printf("\n\n【战斗中】"); printf("\n\t玩家:%s HP:%d/%d 状态:%s", printf("\n\t玩家:%s HP:%d/%d 状态:%s", player.name, player.hp, player.max_hp, (player.status == STATUS_NORMAL) ? "正常" : "中毒"); printf("\n\t敌人:%s HP:%d/%d 特性:%s", current_enemy.name, current_enemy.hp, current_enemy.max_hp, current_enemy.is_poison ? "有毒(击中可能中毒)" : "无特性"); printf("\n\n【战斗选项】"); printf("\n\t1. 手枪攻击(消耗手枪弹药)");
// 修复:提前声明选项编号变量,避免未定义错误 int item_choice = 2; int escape_choice = 3;
if(player.has_shotgun && has_shotgun_ammo > 0) { printf("\n\t2. 霰弹枪攻击(消耗霰弹枪弹药,范围伤害)"); item_choice = 3; escape_choice = 4;2 行未改动 printf("\n\t3. 狙击枪攻击(消耗狙击枪弹药,高暴击)"); item_choice = 4; escape_choice = 5; }
// 用声明后的变量打印选项,避免未定义错误 printf("\n\t%d. 使用道具", item_choice); printf("\n\t%d. 尝试逃跑", escape_choice); printf("\n\n\t请选择:"); while(scanf("%d", &choice) != 1) { printf("\n\t输入无效!请输入数字:"); while(getchar() != '\n'); }
// 刷新弹药状态 has_pistol_ammo = has_weapon_ammo(0); has_shotgun_ammo = has_weapon_ammo(1); has_sniper_ammo = has_weapon_ammo(2);
if(choice == 1) { // 手枪攻击 if(has_pistol_ammo <= 0) { printf("\n\t手枪弹药耗尽!无法攻击!"); press_any_key();38 行未改动 printf("\n\t选择无效!2秒后重新选择..."); delay(2000); } }
// 战斗结束处理 if(player.hp <= 0) { player.hp = 0; printf("\n\t你被%s击败了!游戏结束!", current_enemy.name);39 行未改动void player_attack(int weapon_type) { int critical = 0; int damage = player.attack; int ammo_index = -1;
switch(weapon_type) { case 0: // 手枪 damage *= 1.0; critical = calculate_critical(0);24 行未改动 } } break; }
if(critical) { damage = (int)(damage * 1.5); printf("\n\t暴击!"); }
if(ammo_index != -1) { player.inventory[ammo_index].count--; if(player.inventory[ammo_index].count <= 0) { drop_item(ammo_index); } }
current_enemy.hp -= damage; if(current_enemy.hp < 0) current_enemy.hp = 0; printf("\n\t你使用%s对%s造成了%d点伤害!", (weapon_type == 0) ? "手枪" : (weapon_type == 1) ? "霰弹枪" : "狙击枪",6 行未改动 if(dodge) { printf("\n\t你成功闪避了%s的攻击!", current_enemy.name); return; }
int damage = current_enemy.attack; player.hp -= damage; if(player.hp < 0) player.hp = 0; printf("\n\t%s对你造成了%d点伤害!", current_enemy.name, damage);
if(current_enemy.is_poison && player.status == STATUS_NORMAL) { if(rand()%100 < 40) { player.status = STATUS_POISONED; printf("\n\t你被病毒感染,进入中毒状态!每回合掉10血!"); } }
if(player.hp == 0) { printf("\n\t你受到了致命伤害!"); }}28 行未改动 case 1: ammo_type = ITEM_SHOTGUN_AMMO; break; case 2: ammo_type = ITEM_SNIPER_AMMO; break; default: return 0; }
for(int i=0; i<player.inventory_count; i++) { if(player.inventory[i].type == ammo_type) { return player.inventory[i].count; }70 行未改动 printf("\n\t你在对抗保护伞的过程中选择了放弃,逃离了浣熊市。"); printf("\n\t但病毒的阴影永远笼罩着你,你将在愧疚中度过一生..."); printf("\n\t结局:懦弱逃亡"); }
printf("\n\n\t你的最终战绩:"); printf("\n\t姓名:%s 生命值:%d/%d 攻击力:%d 闪避率:%d%% 暴击率:%d%%", player.name, player.hp, player.max_hp, player.attack, player.dodge_rate, player.critical_rate); printf("\n\t剧情进度:%d%% 拯救幸存者:%d人 持有武器:",3 行未改动 if(player.has_sniper) printf("狙击枪 "); printf("\n\t关键道具:%s(病毒数据) | %s(幸存者标识)", player.has_virus_data ? "?" : "?", has_item(ITEM_SURVIVOR_TAG) ? "?" : "?");
printf("\n\n\t按回车键退出游戏..."); while(getchar() != '\n'); getchar();}79 行未改动