生化危机2
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
// 全局常量定义(避免魔法数字,兼容旧编译器)
#define MAX_INVENTORY 15
#define SAVE_FILE "umbrella_down_save.dat"
#define CRITICAL_CHANCE 15
#define ESCAPE_BASE_CHANCE 25
#define MAX_NAME_LEN 20
#define MAX_ITEM_NAME_LEN 30
#define MAX_LOCATION_LEN 50
// 道具枚举(添加typedef兼容Dev-C++)
typedef enum _ItemType {
ITEM_NONE,
ITEM_HERB_GREEN, // 绿草药(+50血)
ITEM_HERB_RED, // 红草药(+100血)
ITEM_FIRST_AID, // 急救喷雾(+200血)
ITEM_PISTOL_AMMO, // 手枪弹药(15发)
ITEM_SHOTGUN_AMMO, // 霰弹枪弹药(8发)
ITEM_SNIPER_AMMO, // 狙击枪弹药(5发)
ITEM_PISTOL, // 贝雷塔手枪(基础武器)
ITEM_SHOTGUN, // 霰弹枪(范围伤害)
ITEM_SNIPER, // 狙击枪(暴击率翻倍)
ITEM_LAB_KEY, // 实验室钥匙
ITEM_SAFE_KEY, // 保险箱钥匙
ITEM_VIRUS_DATA, // 病毒数据(结局道具)
ITEM_ANTIDOTE, // 解毒剂(对抗毒系敌人)
ITEM_SURVIVOR_TAG // 幸存者标识(分支剧情道具)
} ItemType;
// 敌人类型枚举
typedef enum _EnemyType {
ENEMY_ZOMBIE, // 普通丧尸
ENEMY_POISON_ZOMBIE,// 毒丧尸(附带中毒效果)
ENEMY_DOG, // 丧尸犬
ENEMY_SPIDER, // 变异蜘蛛(中期精英)
ENEMY_TYRANT, // 暴君T-002(中期Boss)
ENEMY_ALBERT // 阿尔伯特(最终Boss)
} EnemyType;
// 玩家状态枚举(中毒/正常)
typedef enum _PlayerStatus {
STATUS_NORMAL,
STATUS_POISONED // 中毒(每回合掉10血)
} PlayerStatus;
// 道具结构体(明确字段长度,避免对齐问题)
typedef struct _Item {
ItemType type;
char name[MAX_ITEM_NAME_LEN];
int count;
int usable; // 是否可直接使用(0=否,1=是)
} Item;
// 敌人结构体
typedef struct _Enemy {
EnemyType type;
char name[MAX_ITEM_NAME_LEN];
int hp;
int max_hp;
int attack;
int speed;
int drop_rate;
int is_poison; // 是否有毒(0=否,1=是)
Item drop_item;
} Enemy;
// 玩家结构体
typedef struct _Player {
char name[MAX_NAME_LEN];
int hp;
int max_hp;
int attack;
int dodge_rate;
int critical_rate;
PlayerStatus status;
int location; // 1-7:市区→医院→实验室→最终基地
Item inventory[MAX_INVENTORY];
int inventory_count;
int has_pistol;
int has_shotgun;
int has_sniper;
int key_count;
int has_virus_data;
int survivor_rescued; // 拯救幸存者数量(0-3)
int game_progress; // 0-100
} Player;
// 全局变量(简化模块间传递)
Player player;
Enemy current_enemy;
int game_over = 0;
int battle_win = 0;
char location_names[8][MAX_LOCATION_LEN] = {
"",
"浣熊市市区(废弃街道)",
"浣熊市医院(急诊部)",
"医院地下室(病毒研究室)",
"保护伞郊区实验室",
"实验室核心区",
"阿尔伯特私人基地",
"最终决战场地"
};
// 函数声明(严格按调用顺序,避免未声明警告)
void init_game(void);
void load_game(void);
void save_game(void);
void print_title(void);
void main_menu(void);
void create_character(void);
void display_status(void);
void display_inventory(void);
void use_item(int index);
void drop_item(int index);
int add_item(ItemType type, int count);
int has_item(ItemType type); // 新增:判断道具是否存在
void check_player_status(void);
void location_description(void);
void explore_location(void);
void random_encounter(void);
Enemy generate_enemy(void);
void battle_system(void);
void player_attack(int weapon_type); // 0=手枪,1=霰弹枪,2=狙击枪
void enemy_attack(void);
int calculate_critical(int weapon_bonus);
int calculate_dodge(int enemy_speed);
int try_escape(void);
void boss_battle(EnemyType boss_type);
void game_ending(void);
void clear_screen(void);
void press_any_key(void);
void delay(int ms);
int has_weapon_ammo(int weapon_type); // 检查武器弹药是否充足
// 主函数(程序入口)
int main(void) {
srand((unsigned int)time(NULL));
init_game();
return 0;
}
// 初始化游戏(主菜单)
void init_game(void) {
int choice;
clear_screen();
print_title();
printf("\n\t1. 新游戏");
printf("\n\t2. 读取存档");
printf("\n\t3. 退出游戏");
printf("\n\n\t请选择(1-3):");
while(scanf("%d", &choice) != 1 || choice < 1 || choice > 3) {
printf("\n\t选择无效!请输入1-3:");
while(getchar() != '\n');
}
switch(choice) {
case 1:
create_character();
break;
case 2:
load_game();
break;
case 3:
printf("\n\t感谢游玩《生化危机:保护伞覆灭》!再见!\n");
exit(0);
default:
printf("\n\t选择无效!2秒后重新初始化...\n");
delay(2000);
init_game();
}
}
// 打印游戏标题
void print_title(void) {
printf("======================================================");
printf("\n\t\t生化危机:保护伞覆灭");
printf("\n\t\t Resident Evil: Umbrella Down");
printf("\n======================================================");
}
// 主菜单(核心流程控制)
void main_menu(void) {
int choice;
while(!game_over) {
check_player_status(); // 每回合检查玩家状态(中毒掉血)
clear_screen();
print_title();
printf("\n\n【当前位置】:%s", location_names[player.location]);
printf("\n【剧情进度】:%d%%", player.game_progress);
printf("\n【当前状态】:%s", (player.status == STATUS_NORMAL) ? "正常" : "中毒(每回合掉10血)");
printf("\n\n【主菜单】");
printf("\n\t1. 查看状态");
printf("\n\t2. 查看背包(可丢弃道具)");
printf("\n\t3. 探索当前区域");
printf("\n\t4. 保存游戏");
printf("\n\t5. 退出游戏");
printf("\n\n\t请选择(1-5):");
while(scanf("%d", &choice) != 1 || choice < 1 || choice > 5) {
printf("\n\t选择无效!请输入1-5:");
while(getchar() != '\n');
}
switch(choice) {
case 1:
display_status();
break;
case 2:
display_inventory();
break;
case 3:
explore_location();
break;
case 4:
save_game();
break;
case 5:
{
int confirm;
printf("\n\t确定要退出吗?(1=是/0=否):");
while(scanf("%d", &confirm) != 1 || confirm < 0 || confirm > 1) {
printf("\n\t输入无效!请输入1或0:");
while(getchar() != '\n');
}
if(confirm == 1) {
printf("\n\t感谢游玩!再见!\n");
exit(0);
}
}
break;
default:
printf("\n\t选择无效!2秒后返回主菜单...\n");
delay(2000);
}
}
game_ending();
}
// 创建角色(初始化属性)
void create_character(void) {
clear_screen();
print_title();
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;
player.dodge_rate = 12;
player.critical_rate = CRITICAL_CHANCE;
player.status = STATUS_NORMAL;
player.location = 1;
player.inventory_count = 0;
player.has_pistol = 0;
player.has_shotgun = 0;
player.has_sniper = 0;
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();
}
// 显示玩家状态(341行错误修复核心区域)
void display_status(void) {
clear_screen();
print_title();
printf("\n\n【玩家状态】");
printf("\n\t姓名:%s", player.name);
printf("\n\t生命值:%d/%d", player.hp, player.max_hp);
printf("\n\t攻击力:%d", player.attack);
printf("\n\t闪避率:%d%%", player.dodge_rate);
printf("\n\t暴击率:%d%%", player.critical_rate);
printf("\n\t当前状态:%s", (player.status == STATUS_NORMAL) ? "正常" : "中毒(每回合掉10血)");
printf("\n\t当前位置:%s", location_names[player.location]);
printf("\n\t剧情进度:%d%%", player.game_progress);
printf("\n\t持有钥匙:%d把", player.key_count);
printf("\n\t拯救幸存者:%d人", player.survivor_rescued);
printf("\n\t持有武器:");
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();
}
// 显示背包(支持丢弃道具)
void display_inventory(void) {
int choice, index;
clear_screen();
print_title();
printf("\n\n【背包】(容量:%d/%d)", player.inventory_count, MAX_INVENTORY);
if(player.inventory_count == 0) {
printf("\n\t背包为空!");
} else {
for(int i=0; i<player.inventory_count; i++) {
printf("\n\t%d. %s(数量:%d)", i+1, player.inventory[i].name, player.inventory[i].count);
switch(player.inventory[i].type) {
case ITEM_HERB_GREEN: printf(" - 恢复50点生命值"); break;
case ITEM_HERB_RED: printf(" - 恢复100点生命值"); break;
case ITEM_FIRST_AID: printf(" - 恢复200点生命值"); break;
case ITEM_PISTOL_AMMO: printf(" - 手枪专用弹药"); break;
case ITEM_SHOTGUN_AMMO: printf(" - 霰弹枪专用弹药"); break;
case ITEM_SNIPER_AMMO: printf(" - 狙击枪专用弹药"); break;
case ITEM_PISTOL: printf(" - 基础武器(攻击力+10)"); break;
case ITEM_SHOTGUN: printf(" - 范围武器(伤害x1.8,暴击率-5%%)"); break;
case ITEM_SNIPER: printf(" - 精准武器(暴击率x2,伤害x1.5)"); break;
case ITEM_LAB_KEY: printf(" - 解锁实验室大门"); break;
case ITEM_SAFE_KEY: printf(" - 打开核心区保险箱"); break;
case ITEM_VIRUS_DATA: printf(" - 揭露保护伞阴谋的关键"); break;
case ITEM_ANTIDOTE: printf(" - 解除中毒状态"); break;
case ITEM_SURVIVOR_TAG: printf(" - 幸存者身份标识"); break;
default: break;
}
}
}
printf("\n\n\t1. 使用道具 2. 丢弃道具 3. 返回主菜单");
printf("\n\t请选择:");
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);
while(getchar() != '\n');
}
use_item(index-1);
} else if(choice == 2 && 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);
while(getchar() != '\n');
}
drop_item(index-1);
}
}
// 使用道具
void use_item(int index) {
Item *item = &player.inventory[index];
if(!item->usable) {
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;
printf("\n\t使用了绿色草药!生命值恢复至%d/%d", player.hp, player.max_hp);
break;
case ITEM_HERB_RED:
player.hp += 100;
if(player.hp > player.max_hp) player.hp = player.max_hp;
printf("\n\t使用了红色草药!生命值恢复至%d/%d", player.hp, player.max_hp);
break;
case ITEM_FIRST_AID:
player.hp += 200;
if(player.hp > player.max_hp) player.hp = player.max_hp;
printf("\n\t使用了急救喷雾!生命值恢复至%d/%d", player.hp, player.max_hp);
break;
case ITEM_ANTIDOTE:
if(player.status == STATUS_POISONED) {
player.status = STATUS_NORMAL;
printf("\n\t使用了解毒剂!成功解除中毒状态!");
} else {
printf("\n\t你当前状态正常,无需使用解毒剂!");
press_any_key();
return;
}
break;
case ITEM_PISTOL:
if(!player.has_pistol) {
player.has_pistol = 1;
player.attack += 10;
printf("\n\t装备了贝雷塔手枪!攻击力+10!");
} else {
printf("\n\t你已经装备了手枪!");
press_any_key();
return;
}
break;
case ITEM_SHOTGUN:
if(!player.has_shotgun) {
player.has_shotgun = 1;
player.attack += 25;
player.critical_rate -= 5;
printf("\n\t装备了霰弹枪!攻击力+25,暴击率-5%%!");
} else {
printf("\n\t你已经装备了霰弹枪!");
press_any_key();
return;
}
break;
case ITEM_SNIPER:
if(!player.has_sniper) {
player.has_sniper = 1;
player.attack += 20;
player.critical_rate *= 2;
printf("\n\t装备了狙击枪!攻击力+20,暴击率翻倍!");
} else {
printf("\n\t你已经装备了狙击枪!");
press_any_key();
return;
}
break;
default:
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) {
drop_item(index);
}
}
press_any_key();
}
// 丢弃道具
void drop_item(int index) {
char confirm;
printf("\n\t确定要丢弃%s吗?(y/n):", player.inventory[index].name);
while(getchar() != '\n'); // 清空缓冲区
scanf("%c", &confirm);
if(confirm != 'y' && confirm != 'Y') {
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];
}
player.inventory_count--;
press_any_key();
}
// 添加道具(支持叠加)
int add_item(ItemType type, int count) {
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;
switch(type) {
case ITEM_HERB_GREEN:
strncpy(new_item.name, "绿色草药", MAX_ITEM_NAME_LEN-1);
new_item.usable = 1;
break;
case ITEM_HERB_RED:
strncpy(new_item.name, "红色草药", MAX_ITEM_NAME_LEN-1);
new_item.usable = 1;
break;
case ITEM_FIRST_AID:
strncpy(new_item.name, "急救喷雾", MAX_ITEM_NAME_LEN-1);
new_item.usable = 1;
break;
case ITEM_PISTOL_AMMO:
strncpy(new_item.name, "手枪弹药", MAX_ITEM_NAME_LEN-1);
new_item.usable = 0;
break;
case ITEM_SHOTGUN_AMMO:
strncpy(new_item.name, "霰弹枪弹药", MAX_ITEM_NAME_LEN-1);
new_item.usable = 0;
break;
case ITEM_SNIPER_AMMO:
strncpy(new_item.name, "狙击枪弹药", MAX_ITEM_NAME_LEN-1);
new_item.usable = 0;
break;
case ITEM_PISTOL:
strncpy(new_item.name, "贝雷塔手枪", MAX_ITEM_NAME_LEN-1);
new_item.usable = 1;
break;
case ITEM_SHOTGUN:
strncpy(new_item.name, "霰弹枪", MAX_ITEM_NAME_LEN-1);
new_item.usable = 1;
break;
case ITEM_SNIPER:
strncpy(new_item.name, "狙击枪", MAX_ITEM_NAME_LEN-1);
new_item.usable = 1;
break;
case ITEM_LAB_KEY:
strncpy(new_item.name, "实验室钥匙", MAX_ITEM_NAME_LEN-1);
new_item.usable = 0;
player.key_count++;
break;
case ITEM_SAFE_KEY:
strncpy(new_item.name, "保险箱钥匙", MAX_ITEM_NAME_LEN-1);
new_item.usable = 0;
player.key_count++;
break;
case ITEM_VIRUS_DATA:
strncpy(new_item.name, "病毒数据U盘", MAX_ITEM_NAME_LEN-1);
new_item.usable = 0;
player.has_virus_data = 1;
break;
case ITEM_ANTIDOTE:
strncpy(new_item.name, "解毒剂", MAX_ITEM_NAME_LEN-1);
new_item.usable = 1;
break;
case ITEM_SURVIVOR_TAG:
strncpy(new_item.name, "幸存者标识", MAX_ITEM_NAME_LEN-1);
new_item.usable = 0;
break;
default:
strncpy(new_item.name, "未知道具", MAX_ITEM_NAME_LEN-1);
new_item.usable = 0;
break;
}
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你获得了保护伞的核心病毒数据,距离真相更近一步!");
}
return 1;
}
// 新增:判断背包中是否存在指定道具(修复341行的核心函数)
int has_item(ItemType type) {
for(int i=0; i<player.inventory_count; i++) {
if(player.inventory[i].type == type) {
return 1; // 存在返回1
}
}
return 0; // 不存在返回0
}
// 检查玩家状态(中毒掉血)
void check_player_status(void) {
if(player.status == STATUS_POISONED) {
player.hp -= 10;
if(player.hp < 0) player.hp = 0;
if(player.hp == 0) {
printf("\n\t你因中毒太深,倒地不起...游戏结束!");
game_over = 1;
}
}
}
// 场景描述
void location_description(void) {
clear_screen();
print_title();
printf("\n\n【场景描述】");
switch(player.location) {
case 1:
printf("\n\t浣熊市市区街道 - 车辆废弃,建筑烧毁,丧尸在街头游荡。");
printf("\n\t远处的医院大楼灯火通明,隐约传来求救声。");
printf("\n\t街角的便利店可能藏有物资,但也可能有危险...");
break;
case 2:
printf("\n\t浣熊市医院急诊部 - 医疗设备散落一地,血迹斑斑。");
printf("\n\t挂号台后有一个锁住的柜子,走廊深处传来怪物的嘶吼。");
printf("\n\t一位受伤的护士躲在病房里,需要你的帮助...");
break;
case 3:
printf("\n\t医院地下室 - 保护伞的秘密病毒研究室,充满刺鼻的化学气味。");
printf("\n\t实验台上残留着变异生物的组织,墙角的保险箱可能有关键道具。");
printf("\n\t这里的丧尸都带有病毒,具有毒性...");
break;
case 4:
printf("\n\t保护伞郊区实验室 - 高墙环绕,戒备森严(但已被突破)。");
printf("\n\t大门需要专用钥匙才能进入,周围有大量变异蜘蛛出没。");
printf("\n\t实验室广场上停放着一架救援直升机,但需要启动密码...");
break;
case 5:
printf("\n\t实验室核心区 - 保护伞的技术中枢,大型显示屏显示着病毒扩散数据。");
printf("\n\t中央控制室有一个保险箱,里面可能存放着病毒数据。");
printf("\n\t突然,地面开始震动,一个巨大的身影从阴影中走出...");
break;
case 6:
printf("\n\t阿尔伯特私人基地 - 保护伞CEO的秘密据点,装修奢华却布满杀机。");
printf("\n\t书房里有通往最终场地的电梯,书架后藏有大量弹药和医疗物资。");
printf("\n\t阿尔伯特已经知道你的到来,他在电梯口等着你...");
break;
case 7:
printf("\n\t最终决战场地 - 保护伞的地下竞技场,四周是防弹玻璃。");
printf("\n\t阿尔伯特穿着特制战斗服,手持生物武器,眼神冰冷。");
printf("\n\t这里没有退路,只有击败他,才能彻底终结保护伞的阴谋...");
break;
default:
printf("\n\t未知区域 - 数据异常,小心行事!");
break;
}
}
// 探索场景(剧情推进)
void explore_location(void) {
int choice;
location_description();
printf("\n\n【探索选项】");
switch(player.location) {
case 1:
printf("\n\t1. 搜索便利店(获取物资)");
printf("\n\t2. 前往医院急诊部");
printf("\n\t3. 检查废弃车辆");
printf("\n\t4. 返回主菜单");
break;
case 2:
printf("\n\t1. 救援病房里的护士(分支剧情)");
printf("\n\t2. 撬开挂号台柜子(获取道具)");
printf("\n\t3. 前往医院地下室");
printf("\n\t4. 返回市区");
break;
case 3:
printf("\n\t1. 打开墙角保险箱(需要钥匙)");
printf("\n\t2. 搜索实验台(获取病毒样本)");
printf("\n\t3. 返回急诊部");
printf("\n\t4. 尝试联系外界");
break;
case 4:
printf("\n\t1. 使用实验室钥匙开门(进入核心区)");
printf("\n\t2. 搜索直升机(获取弹药)");
printf("\n\t3. 清理周围蜘蛛(必遇敌)");
printf("\n\t4. 返回医院地下室");
break;
case 5:
printf("\n\t1. 与暴君T-002战斗(Boss战)");
printf("\n\t2. 打开中央控制室保险箱(需要钥匙)");
printf("\n\t3. 搜索物资(医疗+弹药)");
printf("\n\t4. 返回郊区实验室");
break;
case 6:
printf("\n\t1. 乘坐电梯前往最终场地");
printf("\n\t2. 搜索书架后的物资");
printf("\n\t3. 检查阿尔伯特的电脑(获取情报)");
printf("\n\t4. 返回核心区");
break;
case 7:
printf("\n\t1. 与阿尔伯特决战(最终Boss战)");
printf("\n\t2. 使用道具(战前准备)");
printf("\n\t3. 查看状态");
printf("\n\t4. 返回基地");
break;
default:
printf("\n\t1. 四处探索 2. 返回主菜单");
break;
}
printf("\n\n\t请选择:");
while(scanf("%d", &choice) != 1) {
printf("\n\t输入无效!请输入数字:");
while(getchar() != '\n');
}
switch(player.location) {
case 1:
switch(choice) {
case 1:
printf("\n\t你闯入便利店,找到了红色草药和手枪弹药!");
add_item(ITEM_HERB_RED, 1);
add_item(ITEM_PISTOL_AMMO, 15);
if(rand()%100 < 35) {
printf("\n\t便利店深处冲出一只丧尸犬!");
press_any_key();
do {
current_enemy = generate_enemy();
} while(current_enemy.type != ENEMY_DOG);
battle_system();
}
press_any_key();
break;
case 2:
printf("\n\t你穿过丧尸群,成功抵达医院急诊部!");
player.location = 2;
player.game_progress += 10;
press_any_key();
break;
case 3:
printf("\n\t你在废弃车辆的后备箱里找到了急救喷雾和解毒剂!");
add_item(ITEM_FIRST_AID, 1);
add_item(ITEM_ANTIDOTE, 1);
press_any_key();
break;
case 4:
break;
default:
printf("\n\t选择无效!2秒后返回...");
delay(2000);
}
break;
case 2:
switch(choice) {
case 1:
printf("\n\t你救出了受伤的护士,她送给你幸存者标识和实验室钥匙!");
add_item(ITEM_SURVIVOR_TAG, 1);
add_item(ITEM_LAB_KEY, 1);
player.survivor_rescued++;
player.game_progress += 15;
printf("\n\t你的善良得到了回报,闪避率永久+5%%!");
player.dodge_rate += 5;
press_any_key();
break;
case 2:
printf("\n\t你撬开了挂号台柜子,找到了霰弹枪和霰弹枪弹药!");
add_item(ITEM_SHOTGUN, 1);
add_item(ITEM_SHOTGUN_AMMO, 16);
if(rand()%100 < 40) {
printf("\n\t柜子后面藏着一只毒丧尸!");
press_any_key();
do {
current_enemy = generate_enemy();
} while(current_enemy.type != ENEMY_POISON_ZOMBIE);
battle_system();
}
press_any_key();
break;
case 3:
printf("\n\t你打开了通往地下室的门,一股刺鼻的气味扑面而来...");
player.location = 3;
player.game_progress += 10;
press_any_key();
break;
case 4:
player.location = 1;
press_any_key();
break;
default:
printf("\n\t选择无效!2秒后返回...");
delay(2000);
}
break;
case 3:
switch(choice) {
case 1:
{
int has_key = 0;
for(int i=0; i<player.inventory_count; i++) {
if(player.inventory[i].type == ITEM_SAFE_KEY) {
has_key = 1;
break;
}
}
if(has_key) {
printf("\n\t你打开了保险箱,获得了狙击枪、狙击枪弹药和病毒数据!");
add_item(ITEM_SNIPER, 1);
add_item(ITEM_SNIPER_AMMO, 10);
add_item(ITEM_VIRUS_DATA, 1);
} else {
printf("\n\t保险箱需要专用钥匙才能打开!");
if(rand()%100 < 50) {
printf("\n\t你在附近的实验服口袋里找到了保险箱钥匙!");
add_item(ITEM_SAFE_KEY, 1);
}
}
press_any_key();
}
break;
case 2:
printf("\n\t你在实验台上找到了病毒样本和绿色草药!");
add_item(ITEM_HERB_GREEN, 2);
if(rand()%100 < 45) {
printf("\n\t实验台下方爬出一只巨大的变异蜘蛛!");
press_any_key();
do {
current_enemy = generate_enemy();
} while(current_enemy.type != ENEMY_SPIDER);
battle_system();
}
press_any_key();
break;
case 3:
player.location = 2;
press_any_key();
break;
case 4:
printf("\n\t你找到了一台可用的对讲机,但信号混乱,只收到部分情报:");
printf("\n\t\"保护伞...核心...阿尔伯特...最终基地...\"");
player.game_progress += 5;
press_any_key();
break;
default:
printf("\n\t选择无效!2秒后返回...");
delay(2000);
}
break;
case 4:
switch(choice) {
case 1:
{
int has_key = 0;
for(int i=0; i<player.inventory_count; i++) {
if(player.inventory[i].type == ITEM_LAB_KEY) {
has_key = 1;
break;
}
}
if(has_key) {
printf("\n\t实验室钥匙验证通过,大门缓缓打开!");
player.location = 5;
player.game_progress += 15;
} else {
printf("\n\t你没有实验室钥匙,无法进入核心区!");
}
press_any_key();
}
break;
case 2:
printf("\n\t你在直升机上找到了大量弹药和急救喷雾!");
add_item(ITEM_PISTOL_AMMO, 30);
add_item(ITEM_SHOTGUN_AMMO, 12);
add_item(ITEM_SNIPER_AMMO, 8);
add_item(ITEM_FIRST_AID, 1);
press_any_key();
break;
case 3:
printf("\n\t你决定清理周围的变异蜘蛛,为后续行动扫清障碍!");
press_any_key();
do {
current_enemy = generate_enemy();
} while(current_enemy.type != ENEMY_SPIDER);
battle_system();
press_any_key();
break;
case 4:
player.location = 3;
press_any_key();
break;
default:
printf("\n\t选择无效!2秒后返回...");
delay(2000);
}
break;
case 5:
switch(choice) {
case 1:
printf("\n\t暴君T-002发现了你,它咆哮着向你发起攻击!");
press_any_key();
boss_battle(ENEMY_TYRANT);
break;
case 2:
{
int has_key = 0;
for(int i=0; i<player.inventory_count; i++) {
if(player.inventory[i].type == ITEM_SAFE_KEY) {
has_key = 1;
break;
}
}
if(has_key) {
printf("\n\t你打开了中央控制室的保险箱,获得了大量医疗物资和病毒数据!");
add_item(ITEM_HERB_RED, 2);
add_item(ITEM_FIRST_AID, 1);
add_item(ITEM_VIRUS_DATA, 1);
} else {
printf("\n\t你没有保险箱钥匙,无法打开!");
}
press_any_key();
}
break;
case 3:
printf("\n\t你在核心区找到了急救喷雾和各种弹药!");
add_item(ITEM_FIRST_AID, 1);
add_item(ITEM_PISTOL_AMMO, 20);
add_item(ITEM_SHOTGUN_AMMO, 10);
add_item(ITEM_SNIPER_AMMO, 5);
press_any_key();
break;
case 4:
player.location = 4;
press_any_key();
break;
default:
printf("\n\t选择无效!2秒后返回...");
delay(2000);
}
break;
case 6:
switch(choice) {
case 1:
printf("\n\t电梯启动,你正前往最终决战场地...");
player.location = 7;
player.game_progress += 10;
press_any_key();
break;
case 2:
printf("\n\t你在书架后找到了大量高级物资!");
add_item(ITEM_FIRST_AID, 2);
add_item(ITEM_ANTIDOTE, 1);
add_item(ITEM_SNIPER_AMMO, 10);
press_any_key();
break;
case 3:
printf("\n\t你破解了阿尔伯特的电脑,获得了保护伞的终极计划:");
printf("\n\t\"将病毒武器化,控制全球生物链...\"");
player.game_progress += 5;
printf("\n\t你获得了关键情报,攻击力永久+10!");
player.attack += 10;
press_any_key();
break;
case 4:
player.location = 5;
press_any_key();
break;
default:
printf("\n\t选择无效!2秒后返回...");
delay(2000);
}
break;
case 7:
switch(choice) {
case 1:
boss_battle(ENEMY_ALBERT);
break;
case 2:
display_inventory();
break;
case 3:
display_status();
break;
case 4:
player.location = 6;
press_any_key();
break;
default:
printf("\n\t选择无效!2秒后返回...");
delay(2000);
}
break;
default:
switch(choice) {
case 1:
printf("\n\t你在未知区域遭遇了丧尸!");
press_any_key();
random_encounter();
break;
case 2:
break;
default:
printf("\n\t选择无效!2秒后返回...");
delay(2000);
}
break;
}
}
// 随机遇敌
void random_encounter(void) {
current_enemy = generate_enemy();
printf("\n\t遭遇了%s!战斗开始!", current_enemy.name);
press_any_key();
battle_system();
}
// 生成敌人(根据场景动态调整难度)
Enemy generate_enemy(void) {
Enemy enemy;
int type;
if(player.location <= 2) {
type = rand()%3;
} else if(player.location <= 4) {
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);
enemy.max_hp = 100 + rand()%50;
enemy.hp = enemy.max_hp;
enemy.attack = 25 + rand()%10;
enemy.speed = 25;
enemy.drop_rate = 35;
enemy.is_poison = 0;
enemy.drop_item.type = ITEM_HERB_GREEN;
enemy.drop_item.count = 1;
break;
case 1: // 毒丧尸
enemy.type = ENEMY_POISON_ZOMBIE;
strncpy(enemy.name, "毒丧尸", MAX_ITEM_NAME_LEN-1);
enemy.max_hp = 120 + rand()%40;
enemy.hp = enemy.max_hp;
enemy.attack = 30 + rand()%15;
enemy.speed = 20;
enemy.drop_rate = 50;
enemy.is_poison = 1;
enemy.drop_item.type = ITEM_ANTIDOTE;
enemy.drop_item.count = 1;
break;
case 2: // 丧尸犬
enemy.type = ENEMY_DOG;
strncpy(enemy.name, "丧尸犬", MAX_ITEM_NAME_LEN-1);
enemy.max_hp = 150 + rand()%30;
enemy.hp = enemy.max_hp;
enemy.attack = 40 + rand()%10;
enemy.speed = 70;
enemy.drop_rate = 45;
enemy.is_poison = 0;
enemy.drop_item.type = ITEM_PISTOL_AMMO;
enemy.drop_item.count = 15;
break;
case 3: // 变异蜘蛛
enemy.type = ENEMY_SPIDER;
strncpy(enemy.name, "变异蜘蛛", MAX_ITEM_NAME_LEN-1);
enemy.max_hp = 300 + rand()%50;
enemy.hp = enemy.max_hp;
enemy.attack = 60 + rand()%15;
enemy.speed = 40;
enemy.drop_rate = 75;
enemy.is_poison = 1;
enemy.drop_item.type = ITEM_SHOTGUN_AMMO;
enemy.drop_item.count = 8;
break;
default:
enemy.type = ENEMY_ZOMBIE;
strncpy(enemy.name, "普通丧尸", MAX_ITEM_NAME_LEN-1);
enemy.max_hp = 100;
enemy.hp = 100;
enemy.attack = 30;
enemy.speed = 25;
enemy.drop_rate = 35;
enemy.is_poison = 0;
enemy.drop_item.type = ITEM_HERB_GREEN;
enemy.drop_item.count = 1;
break;
}
enemy.name[MAX_ITEM_NAME_LEN-1] = '\0';
return enemy;
}
// 战斗系统(修复选项编号未声明问题)
void battle_system(void) {
int choice;
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",
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;
}
if(player.has_sniper && has_sniper_ammo > 0) {
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();
break;
}
player_attack(0);
if(current_enemy.hp <= 0) {
battle_win = 1;
break;
}
enemy_attack();
press_any_key();
} else if(choice == 2 && player.has_shotgun && has_shotgun_ammo > 0) { // 霰弹枪攻击
player_attack(1);
if(current_enemy.hp <= 0) {
battle_win = 1;
break;
}
enemy_attack();
press_any_key();
} else if(choice == 3 && player.has_sniper && has_sniper_ammo > 0) { // 狙击枪攻击
player_attack(2);
if(current_enemy.hp <= 0) {
battle_win = 1;
break;
}
enemy_attack();
press_any_key();
} else if(choice == item_choice) { // 使用道具
display_inventory();
} else if(choice == escape_choice) { // 尝试逃跑
if(try_escape()) {
printf("\n\t你成功逃跑了!");
press_any_key();
return;
} else {
printf("\n\t逃跑失败!被敌人追上了!");
enemy_attack();
press_any_key();
}
} else {
printf("\n\t选择无效!2秒后重新选择...");
delay(2000);
}
}
// 战斗结束处理
if(player.hp <= 0) {
player.hp = 0;
printf("\n\t你被%s击败了!游戏结束!", current_enemy.name);
game_over = 1;
} else if(battle_win) {
printf("\n\t你击败了%s!", current_enemy.name);
if(rand()%100 < current_enemy.drop_rate) {
add_item(current_enemy.drop_item.type, current_enemy.drop_item.count);
} else {
printf("\n\t敌人没有掉落任何道具。");
}
// 角色成长
int grow_type = rand()%3;
switch(grow_type) {
case 0:
player.max_hp += 15;
player.hp = player.max_hp;
printf("\n\t你的生命值上限提升了15点!");
break;
case 1:
player.attack += 8;
printf("\n\t你的攻击力提升了8点!");
break;
case 2:
player.dodge_rate += 4;
printf("\n\t你的闪避率提升了4%%!");
break;
}
// Boss战特殊奖励
if(current_enemy.type == ENEMY_TYRANT) {
printf("\n\t你击败了暴君T-002,获得了阿尔伯特基地的通行权限!");
player.location = 6;
player.game_progress += 20;
} else if(current_enemy.type == ENEMY_ALBERT) {
player.game_progress = 100;
game_over = 1;
}
}
press_any_key();
}
// 玩家攻击(按武器类型计算伤害)
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);
for(int i=0; i<player.inventory_count; i++) {
if(player.inventory[i].type == ITEM_PISTOL_AMMO) {
ammo_index = i;
break;
}
}
break;
case 1: // 霰弹枪
damage *= 1.8;
critical = calculate_critical(-5);
for(int i=0; i<player.inventory_count; i++) {
if(player.inventory[i].type == ITEM_SHOTGUN_AMMO) {
ammo_index = i;
break;
}
}
break;
case 2: // 狙击枪
damage *= 1.5;
critical = calculate_critical(100);
for(int i=0; i<player.inventory_count; i++) {
if(player.inventory[i].type == ITEM_SNIPER_AMMO) {
ammo_index = i;
break;
}
}
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) ? "霰弹枪" : "狙击枪",
current_enemy.name, damage);
}
// 敌人攻击(含中毒判定)
void enemy_attack(void) {
int dodge = calculate_dodge(current_enemy.speed);
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你受到了致命伤害!");
}
}
// 计算暴击(支持武器额外加成)
int calculate_critical(int weapon_bonus) {
int total_rate = player.critical_rate + weapon_bonus;
if(total_rate < 0) total_rate = 0;
return (rand()%100 < total_rate) ? 1 : 0;
}
// 计算闪避
int calculate_dodge(int enemy_speed) {
int rate = player.dodge_rate - (enemy_speed / 5);
if(rate < 0) rate = 0;
return (rand()%100 < rate) ? 1 : 0;
}
// 尝试逃跑
int try_escape(void) {
int rate = ESCAPE_BASE_CHANCE + player.dodge_rate - (current_enemy.speed / 4);
if(rate < 5) rate = 5;
if(rate > 60) rate = 60;
return (rand()%100 < rate) ? 1 : 0;
}
// 检查武器弹药是否充足
int has_weapon_ammo(int weapon_type) {
ItemType ammo_type;
switch(weapon_type) {
case 0: ammo_type = ITEM_PISTOL_AMMO; break;
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;
}
}
return 0;
}
// Boss战(初始化Boss属性)
void boss_battle(EnemyType boss_type) {
switch(boss_type) {
case ENEMY_TYRANT: // 暴君T-002
current_enemy.type = ENEMY_TYRANT;
strncpy(current_enemy.name, "暴君T-002", MAX_ITEM_NAME_LEN-1);
current_enemy.max_hp = 1200;
current_enemy.hp = 1200;
current_enemy.attack = 100;
current_enemy.speed = 35;
current_enemy.drop_rate = 100;
current_enemy.is_poison = 0;
current_enemy.drop_item.type = ITEM_SAFE_KEY;
current_enemy.drop_item.count = 1;
break;
case ENEMY_ALBERT: // 阿尔伯特(最终Boss)
current_enemy.type = ENEMY_ALBERT;
strncpy(current_enemy.name, "阿尔伯特(保护伞CEO)", MAX_ITEM_NAME_LEN-1);
current_enemy.max_hp = 2000;
current_enemy.hp = 2000;
current_enemy.attack = 150;
current_enemy.speed = 50;
current_enemy.drop_rate = 100;
current_enemy.is_poison = 1;
current_enemy.drop_item.type = ITEM_VIRUS_DATA;
current_enemy.drop_item.count = 1;
break;
default:
return;
}
current_enemy.name[MAX_ITEM_NAME_LEN-1] = '\0';
battle_system();
}
// 游戏结局(多结局分支)
void game_ending(void) {
clear_screen();
print_title();
printf("\n\n【游戏结局】");
if(player.hp <= 0) {
printf("\n\t很遗憾,你没能击败保护伞的邪恶势力。");
printf("\n\t你的尸体成为了病毒的新载体,浣熊市的悲剧仍在继续...");
printf("\n\t结局:黑暗陨落");
} else if(player.game_progress == 100) {
if(player.has_virus_data && player.survivor_rescued >= 2) {
printf("\n\t你成功击败了阿尔伯特,掌握了保护伞的完整病毒数据!");
printf("\n\t你拯救了多名幸存者,凭借病毒数据研发出特效药,终结了病毒危机。");
printf("\n\t你被全球誉为救世主,保护伞公司彻底覆灭!");
printf("\n\t结局:正义凯旋");
} else if(player.has_virus_data) {
printf("\n\t你成功击败了阿尔伯特,摧毁了保护伞的核心设施!");
printf("\n\t你将病毒数据公之于众,保护伞公司声名狼藉,最终破产。");
printf("\n\t你为浣熊市的牺牲者报了仇,但拯救的人并不多...");
printf("\n\t结局:复仇之刃");
} else if(player.survivor_rescued >= 2) {
printf("\n\t你虽然没有获得完整的病毒数据,但拯救了大量幸存者。");
printf("\n\t你带领幸存者成功撤离浣熊市,建立了安全区。");
printf("\n\t保护伞公司仍在逃亡,但你成为了幸存者心中的守护者。");
printf("\n\t结局:守护之光");
} else {
printf("\n\t你成功击败了阿尔伯特,逃离了最终场地。");
printf("\n\t但你既没有获得病毒数据,也没有拯救多少人。");
printf("\n\t保护伞的残余势力仍在,世界仍面临潜在威胁...");
printf("\n\t结局:孤独幸存者");
}
} else {
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人 持有武器:",
player.game_progress, player.survivor_rescued);
if(player.has_pistol) printf("手枪 ");
if(player.has_shotgun) printf("霰弹枪 ");
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();
}
// 保存游戏(多重数据校验)
void save_game(void) {
FILE *file = fopen(SAVE_FILE, "wb");
if(file == NULL) {
printf("\n\t存档失败!无法创建文件!");
press_any_key();
return;
}
int version = 1;
fwrite(&version, sizeof(int), 1, file);
fwrite(&player, sizeof(Player), 1, file);
fclose(file);
printf("\n\t存档成功!进度已保存至 %s", SAVE_FILE);
press_any_key();
}
// 读取存档(兼容旧存档)
void load_game(void) {
FILE *file = fopen(SAVE_FILE, "rb");
if(file == NULL) {
int choice;
printf("\n\t没有找到存档文件!是否创建新游戏?(1=是/0=否):");
while(scanf("%d", &choice) != 1 || choice < 0 || choice > 1) {
printf("\n\t输入无效!请输入1或0:");
while(getchar() != '\n');
}
if(choice == 1) {
create_character();
} else {
printf("\n\t退出游戏...");
exit(0);
}
return;
}
int version;
fread(&version, sizeof(int), 1, file);
if(version != 1) {
printf("\n\t存档版本不兼容!是否创建新游戏?(1=是/0=否):");
int choice;
while(scanf("%d", &choice) != 1 || choice < 0 || choice > 1) {
printf("\n\t输入无效!请输入1或0:");
while(getchar() != '\n');
}
if(choice == 1) {
create_character();
} else {
printf("\n\t退出游戏...");
exit(0);
}
fclose(file);
return;
}
fread(&player, sizeof(Player), 1, file);
fclose(file);
player.name[MAX_NAME_LEN-1] = '\0';
printf("\n\t存档读取成功!欢迎回来,%s!", player.name);
press_any_key();
main_menu();
}
// 清屏(Dev-C++稳定支持)
void clear_screen(void) {
system("cls");
}
// 按任意键继续(纯C实现)
void press_any_key(void) {
printf("\n\n\t按回车键继续...");
while(getchar() != '\n');
getchar();
}
// 纯C延迟函数(毫秒级)
void delay(int ms) {
clock_t start = clock();
while((clock() - start) * 1000 / CLOCKS_PER_SEC < ms);
}