版本比较
The Backrooms 后室·无限 游戏代码
正文
增加 264 行删除 264 行
12345567896 行未改动1617181920202122232425242526272827282930313212 行未改动454647484949505151525354559 行未改动656667686969707172737475767778797980818283848584858687888911 行未改动1011021031041051061051061071081091102 行未改动11311411511611711711811912012112112212312412512612712812812913013113213313413313413513613713713813914014114214314414214314414514614614714814915015115215315115215315415515515615715815916016116016116216316416416516616716816916917017117217217317417517617717817717817918018118118218318418518618718618718818919019019119219319419519619719519619719819919920020120220320420520620420520620720820820921021121221321421321421521621721721821922022122222322222322422522622622722822923023123223123223323423523610 行未改动2472482492502512512522532542553 行未改动25926026126226326326426526626726726826927027158 行未改动33033133233333433433533633633733833933934034134234334434534634734834834935035135235335435535635635735835935835936036136136236336436536636736736836937037120 行未改动39239339439539639639739839940052 行未改动45345445545645745845745845946046146246346446546646646746846947017 行未改动48848949049149249349249349449549649719 行未改动51751851952052152252152252352452552632 行未改动5595605615625635645655635645655665675685692 行未改动57257357457557657757657757857958058126 行未改动60860961061161261261361461561661761861861962062162231 行未改动6546556566576586586596606616622 行未改动665666667668669669670671672673199 行未改动全部展开8738748758768778778788798808818818828838848858868878888898908908918928938948948958968978987 行未改动906907908909910910911912913914914915916917918918919920921922922923924925926926927928929930103 行未改动全部展开1034103510361037103810381039104010411042104310441045104610471047104810491050105110521053105410551055105610571058105810591060106110623 行未改动106610671068106910701070107110721073107410751074107510761077107810791080108110821082108310841085108610871087108810891090109110921093109310941095109610974 行未改动11021103110411051106110611071108110911101111111211131114111511151116111711181119111911201121112211231123112411251126112711271128112911301131113111321133113411357 行未改动114311441145114611471147114811491150115120 行未改动11721173117411751176117711761177117811791180118011811182118311841185118611861187118811891190220 行未改动全部展开141114121413141414151415141614171418141948 行未改动1468146914701471147214721473147414751476147714781479148014811482148214831484148514861487148814891490149114911492149314941495149614971498149915001500150115021503150415051506150615071508150915104 行未改动1515151615171518151915191520152115221523152415251525152615271528152915301531153115321533153415351536153715371538153915401541154215431543154415451546154715481549154915501551155215531554155415551556155715581559156015601561156215631564156515661566156715681569157015711571157215731574157515761577157715781579158015814 行未改动15861587158815891590159015911592159315944 行未改动159916001601160216031603160416051606160716081609161016091610161116121613161416151616161716161617161816191620162116221623162416231624162516261627162816291630163116301631163216331634163516361637163816371638163916401641164116421643164416452 行未改动16481649165016511652165316521653165416551656165716581659166016591660166116621663166416651666166716661667166816691670167116711672167316741675167616771678167916791680168116821683168416851686168716881688168916901691169262 行未改动1755175617571758175917601759176017611762176217631764176517661767176817691770177017711772177317745 行未改动1780178117821783178417841785178617861787178817891790179117921792179317941795179617971798179817991800180118029 行未改动18121813181418151816181618171818181918201821182218221823182418251826182718281828182918301831183118321833183418351835183618371837183818391840184118421843184418451845184618471848184818491850185118521853185418551855185618571858185818591860186118625 行未改动1868186918701871187218731874187218731874187518761877187818791880188118821876187718781879188018811882188318841885188619 行未改动19061907190819091910191019111912191319141915191619171918191819191920192119221923192419251925192619271928192984 行未改动201420152016201720182018201920202021202211 行未改动20342035203620372038203820392040204120412042204320442045204620472047204820492050205120522053205420552055205620572058205911 行未改动207120722073207420752075207620772078207975 行未改动215521562157215821592160216121622159216021612162216321642165216621672168216921702171217221722173217421752176217721782175217621772178217921802181218221832183218421852186218721852186218721882189219021912192219221932194219521962197219421952196219721982199220022012202220222032204220522062207220822092205220622072208220922102211221222132214221422152216221722182219222022212216221722182219222022212222222322242225222622272227222822292230223131 行未改动22632264226522662267226722682269227022712 行未改动22742275227622772278227822792280228122822 行未改动22852286228722882289228922902291229222932293229422952296229713 行未改动231123122313231423152316231523162317231823182319232023212321232223232324232523262327232823292329233023312332233323342335233523362337233723382339234023413 行未改动23452346234723482349234923502351235223512352235323542355235623562357235823582359236023602361236223632364236523662367236823692369237023712371237223732374237533 行未改动24092410241124122413241324142415241624172418241924202421242124222423242424253 行未改动24292430243124322433243324342435243624372 行未改动24402441244224432444244424452446244724482449244924502451245224532454245524562457245824582459246024612462246324642465246624662467246824692470247124722473247424732474247524762477247824772478247924802481248217 行未改动25002501250225032504250525042505250625072508250825092510251125122511251225132514251525162517251825192520252125212522252325242525252625272527252825292530253194 行未改动2626262726282629263026302631263226332634263526362637263826392640264026412642264326442 行未改动26472648264926502651265126522653265326542655265626575 行未改动266326642665266626672667266826692670# **The** **Backrooms** *后室·无限*
*你终于累垮了,在平地上摔了一跤,切出了地板。你回过神来,站起身,却发现脚下并不是潮湿的地毯,而是一片草地……“我真的逃出来了吗?”“我回家了吗?”*
初次游玩请看菜单内<关于>了解游戏及操作 初次游玩请看菜单内<关于>了解游戏及操作菜单内请用W/S选择
~~不知为何层级简介的文字介绍部分不能过QAQ~~6 行未改动#include<time.h>using namespace std;int level = 0, san = 120, food = 120, hp = 120, buff = 0, sbuff[5], tili = 120;int wuping = 0, xrs = 0, jjyz = 0, hy = 0, hjkl = 0, gzlr = 0, zsq = 0, swfecj = 0;int st = 0, sjcs, sxz, xd, yglgy = 0, man = 0, bbrl = 20, ynmht, rhmht, hf = 0, jj = 0; int st = 0, sjcs, sxz, xd, yglgy = 0, man = 0, bbrl = 20, ynmht, rhmht, hf = 0, jj = 0;int shiti[100], wuzi[101], sdt, dl, dc, sqdy, bsxh, kj = 0, duandao = 0, equip_duandao = 0;int xrscj = 0, scj = 0, ts = 0, yqlyy = 0, sc = 0, llz = 0, ffht = 0, dz = 0, bd = 0, cjyscs = 0, xrssy = 0, LL, ttcg = 0, ha = 0;map<int, int >L;vector <int > swuping; //新层级 物品发现地点 分界线 层级名称 实体多少 vector <int > swuping;//新层级 物品发现地点 分界线 层级名称 实体多少//新物品 物品简介 背包物品名称 使用 丢弃int cjys = 0, xydn = 0, xsqqj = 0; int xydn_buff = 0, mosun_budai; int cjys = 0, xydn = 0, xsqqj = 0;int xydn_buff = 0, mosun_budai;void setsize(int col, int row) {char cmd[64];sprintf(cmd, "mode con cols=%d lines=%d", col, row);system(cmd);12 行未改动 DWORD cellCount = csbi.dwSize.X * csbi.dwSize.Y; COORD homeCoords = {0, 0}; DWORD count;
FillConsoleOutputCharacter(hStdOut, ' ', cellCount, homeCoords, &count);
SetConsoleCursorPosition(hStdOut, homeCoords);}
void Color(int a)9 行未改动 if(a == 8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED); if(a == 9) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_BLUE); if(a == 10) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN); if(a == 11) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
}void cj(int x){ cls(); Color(0); cout << endl << endl << " 成就 "; if (x == 1) cout << "流浪者" << endl; if (x == 2) cout << "反复横跳" << endl; if (x == 3) cout << "生存" << endl; if (x == 4) cout << "杏仁水" << endl; if (x == 5) cout << "收藏家" << endl; if (x == 6) cout << "训蛾者" << endl; if (x == 6) cout << "训蛾者" << endl; else cout << "一千零一夜" << endl; Sleep(1200); cls();}// 0 1 2 3 4 5 6 7 8 9 10 11 // 白 较青蓝 绿 紫 大红 青 淡黄 深灰 较深红 较深蓝 较棕黄 浅灰 // 0 1 2 3 4 5 6 7 8 9 10 11// 白 较青蓝 绿 紫 大红 青 淡黄 深灰 较深红 较深蓝 较棕黄 浅灰// 清除所有数据(精简版)
void saveGame() { ofstream f("save.dat",ios::binary);11 行未改动 f.write((char*)&sqdy,sizeof(sqdy)) .write((char*)&bsxh,sizeof(bsxh)) .write((char*)&dz,sizeof(dz)); f.write((char*)&kj,sizeof(kj)) .write((char*)&duandao,sizeof(duandao)) .write((char*)&equip_duandao,sizeof(equip_duandao)); f.write((char*)&cjys,sizeof(cjys)) .write((char*)&xydn,sizeof(xydn)) .write((char*)&xsqqj,sizeof(xsqqj)); f.write((char*)&xydn_buff,sizeof(xydn_buff)) .write((char*)&mosun_budai,sizeof(mosun_budai)); f.write((char*)&xrscj, sizeof(xrscj))
f.write((char*)&xrscj, sizeof(xrscj)) .write((char*)&scj, sizeof(scj)) // 收藏家成就标记 .write((char*)&sc, sizeof(sc)) // 生存成就标记 .write((char*)&llz, sizeof(llz)) // 流浪者成就标记 .write((char*)&ffht, sizeof(ffht)) // 反复横跳成就标记2 行未改动 .write((char*)&xrssy, sizeof(xrssy)) // 杏仁水使用次数 .write((char*)&LL, sizeof(LL)) // 探索层级数量 .write((char*)&ttcg, sizeof(ttcg)) // 逃离实体次数 .write((char*)&ha, sizeof(ha)); // 黑暗buff标记
f.close(); cout << endl << " 存档成功" << endl; Sleep(1200); cls(); cls();}void cenjijianjie(){ cls(); Color(0); cout << endl; if (level == 0){ cout << " Level 0 前厅 "<< endl; cout << " Level 0 前厅 "<< endl; cout << " 生存难度 class 1" << endl; cout << " >> 安全" << endl; cout << " >> 不稳定" << endl; cout << " >> 无实体" << endl; cout << " >> 物资正常" << endl; cout << " >> 物资正常" << endl;
} else if (level == 1){ cout << " Level 1 宜居区 "<< endl; cout << " Level 1 宜居区 "<< endl; cout << " 生存难度 class 1" << endl; cout << " >> 安全" << endl; cout << " >> 稳定" << endl; cout << " >> 实体数量极少" << endl; cout << " >> 物资较丰富" << endl; } cout << " >> 物资较丰富" << endl;
} else if (level == 2){ cout << " Level 2 管道噩梦 "<< endl; cout << " Level 2 管道噩梦 "<< endl; cout << " 生存难度 class 2" << endl; cout << " >> 不安全" << endl; cout << " >> 稳定" << endl; cout << " >> 实体相对较少" << endl; cout << " >> 物资较匮乏" << endl; } cout << " >> 物资较匮乏" << endl;
} else if (level == 3){ cout << " Level 3 电气室 "<< endl; cout << " Level 3 电气室 "<< endl; cout << " 生存难度 class 2" << endl; cout << " >> 不安全" << endl; cout << " >> 不稳定" << endl; cout << " >> 少量实体" << endl; cout << " >> 少量物资" << endl; cout << " >> 少量物资" << endl;
} else if (level == 4){ cout << " Level 4 废弃办公室 "<< endl; cout << " Level 4 废弃办公室 "<< endl; cout << " 生存难度 class 宜居" << endl; cout << " >> 安全" << endl; cout << " >> 稳定" << endl; cout << " >> 无实体存在" << endl; cout << " >> 物资较丰富" << endl; cout << " >> 物资较丰富" << endl; } else if (level == 5){ cout << " Level 5 恐怖旅馆 "<< endl; cout << " Level 5 恐怖旅馆 "<< endl; cout << " 生存难度 class 5" << endl; cout << " >> 不安全" << endl; cout << " >> 未勘探完全" << endl; cout << " >> 未经证实的实体目击" << endl; cout << " >> 物资正常" << endl; cout << " >> 物资正常" << endl;
} if (level == 6){ cout << " Level 6 熄灯 "<< endl; cout << " Level 6 熄灯 "<< endl; cout << " 生存难度 待分" << endl; cout << " >> 安全性未知" << endl; cout << " >> 不稳定" << endl; cout << " >> 未探明实体存在" << endl; cout << " >> 物资极少" << endl; cout << " >> 物资极少" << endl;
} else if (level == 7){ cout << " Level 7 深海恐惧症 "<< endl; cout << " Level 7 深海恐惧症 "<< endl; cout << " 生存难度 class 4" << endl; cout << " >> 不安全" << endl; cout << " >> 不稳定" << endl; cout << " >> 中量实体" << endl; cout << " >> 物资较稀缺" << endl; } cout << " >> 物资较稀缺" << endl;
} else if (level == 8){ cout << " Level 8 岩洞系统 "<< endl; cout << " Level 8 岩洞系统 "<< endl; cout << " 生存难度 class 4" << endl; cout << " >> 不安全" << endl; cout << " >> 极端环境风险" << endl; cout << " >> 极多敌意存在" << endl; cout << " >> 物资匮乏" << endl; } cout << " >> 物资匮乏" << endl;
} else if (level == 9){ cout << " Level 9 郊区 "<< endl; cout << " Level 9 郊区 "<< endl; cout << " 生存难度 class 5" << endl; cout << " >> 不安全" << endl; cout << " >> 不稳定" << endl; cout << " >> 实体横行" << endl; cout << " >> 少量物资" << endl; cout << " >> 少量物资" << endl;
} else if (level == 10){ cout << " Level 10 丰裕 "<< endl; cout << " Level 10 丰裕 "<< endl; cout << " 生存难度 class 宜居" << endl; cout << " >> 安全" << endl; cout << " >> 低环境风险" << endl; cout << " >> 无敌对实体" << endl; cout << " >> 物资极丰富" << endl; cout << " >> 物资极丰富" << endl;
} else if (level == 11){ cout << " Level 11 不夜城 "<< endl; cout << " Level 11 不夜城 "<< endl; cout << " 生存难度 class 2" << endl; cout << " >> 安全" << endl; cout << " >> 不稳定" << endl; cout << " >> 少量实体" << endl; cout << " >> 物资极丰富" << endl; cout << " >> 物资极丰富" << endl;
}}void loadGame() { ifstream f("save.dat",ios::binary);10 行未改动 f.read((char*)&sqdy,sizeof(sqdy)) .read((char*)&bsxh,sizeof(bsxh)) .read((char*)&dz,sizeof(dz)); f.read((char*)&kj,sizeof(kj)) .read((char*)&duandao,sizeof(duandao)) .read((char*)&equip_duandao,sizeof(equip_duandao)); f.read((char*)&cjys,sizeof(cjys)) .read((char*)&xydn,sizeof(xydn)) .read((char*)&xsqqj,sizeof(xsqqj)); f.read((char*)&xydn_buff,sizeof(xydn_buff)) .read((char*)&mosun_budai,sizeof(mosun_budai));
f.read((char*)&xrscj, sizeof(xrscj)) .read((char*)&scj, sizeof(scj)) .read((char*)&sc, sizeof(sc)) .read((char*)&llz, sizeof(llz))3 行未改动 .read((char*)&xrssy, sizeof(xrssy)) .read((char*)&LL, sizeof(LL)) .read((char*)&ttcg, sizeof(ttcg)) .read((char*)&ha, sizeof(ha));
f.close(); cout << " 读档成功" << endl; Sleep(1200); cls(); cls();}void ksfm(){ Color(0); cout << "" << endl;58 行未改动 cout << " 我应该干什么" << endl; cout << " 探索,求生,寻找,并时刻保持警惕?......" << endl; cout << " 操作" << endl; cout << " E打开背包 A/D选择物品 空格使用 P丢弃 Q退出" << endl; cout << " M 查看层级信息 L 存档 O 读档 B 返回菜单 K 清除所有数据" << endl; cout << " M 查看层级信息 L 存档 O 读档 B 返回菜单 K 清除所有数据" << endl; sjcs ++;
while (1){ if(kbhit()){ cls(); cls(); return; } }}void clearAllData() { cls(); Color(4); cout << "========== 确认清除所有数据?==========\n 按 Y 确认 | 按 N 取消\n=====================================" << endl;
while (kbhit() ? (_getch(), true) : true) { // 简化循环 char c = _getch(); if (c == 'Y' || c == 'y') { // 1. 批量重置基础变量(合并赋值) level = san = food = hp = buff = tili = wuping = xrs = jjyz = hy = hjkl = gzlr = zsq = st = sjcs = sxz = yglgy = man = 0; san = food = hp = tili = 120; // 初始值单独赋值 xd = 1, bbrl = 20;
// 2. 重置状态/成就变量(添加 yqlyy 和 swfecj 的重置) ynmht = rhmht = hf = jj = sdt = dl = dc = sqdy = bsxh = kj = duandao = equip_duandao = xrscj = scj = sc = llz = ffht = dz = bd = cjyscs = xrssy = LL = ttcg = ha = cjys = xydn = ynmht = rhmht = hf = jj = sdt = dl = dc = sqdy = bsxh = kj = duandao = equip_duandao = xrscj = scj = sc = llz = ffht = dz = bd = cjyscs = xrssy = LL = ttcg = ha = cjys = xydn = xsqqj = xydn_buff = mosun_budai = swfecj = yqlyy = 0; // 新增 swfecj(训蛾者)、yqlyy(一千零一夜)
// 3. 清空数组/容器(简化写法) memset(sbuff, 0, sizeof(sbuff)); memset(shiti, 0, sizeof(shiti)); memset(wuzi, 0, sizeof(wuzi)); L.clear(), swuping.clear();
// 4. 删除存档文件(简化提示) Color(2); cout << "\n " << (remove("save.dat") == 0 ? "存档已删除!" : "无存档/删除失败!") << endl; cout << " 所有数据已重置!" << endl;20 行未改动 cls(); cout << endl;cout << endl;cout << endl; Color(11); cout << " - The Backrooms -" << endl; Color(7); Color(7); cout << " 你曾经来过这里"; Sleep(1500);}void my (int x){52 行未改动 while (1){ if(kbhit()){ char c=_getch(); if(c==' '){ cls(); return; cls(); return; } } }
}void kscd(){ int kk = 1, k = 1, xz = 1, stou[10]={0, 3, 2, 1, 0}; while (k){ while (k){ if (GetAsyncKeyState(38)&0x8000) xz = 1; if (GetAsyncKeyState(40)&0x8000) xz = 2; if(kbhit()){ char c=_getch();17 行未改动 Color(11); cout << "■■"; Color(7); cout << "■■" << endl;
int tou = stou[k], jiange = 0; cout << " "; Color(7); cout << "==";19 行未改动 Color(11); cout << "=="; Color(7); cout << "==";
int bian = rand() % 100; if (bian % 24 == 0){ cout << endl; Color(8);32 行未改动 Color(11); cout << " |" << endl; } } cout << " ";
cout << " "; Color(7); cout << "■■"; Color(11); cout << "■■";2 行未改动 Color(11); cout << "■■"; Color(7); cout << "■■" << endl;
if (xz == 1) Color(11); else Color(7); cout << " 关于 " << endl; if (xz == 2) Color(11);26 行未改动 } } } }
k ++; kk ++; if (k == 5) k = 1; cls(); }
}void cengji(){ Color(0); if (level == 0) cout << "Level 0 -- 前厅";31 行未改动 else if (i % 7 == 3){ Color(8); cout << "▌"; } else if (i % 7 <= 2 || i % 7 <= 5){ else if (i % 7 <= 2 || i % 7 <= 5){ Color(8); cout <<"■"; } }2 行未改动 for (int i = 0; i < 30; i ++){ if(i % 7 <= 2){ Color(7); cout <<"="; } } else if (i % 7 <= 5){ Color(11); cout << "#"; }199 行未改动全部展开 } else if (level == 1 || level == 2 || level == 3 || level == 6 || level == 7 || level == 9){ Color(7); cout << "[] "; } } else if (level == 5 || level == 10){ Color(6); cout << "[] "; } } else if (level == 4 || level == 11){ Color(11); cout << "[] "; }}void Buff(){ if (bsxh > 0) { Color(7); cout << "悲尸循环 " ; cout << "悲尸循环 " ; } if (hf > 0){ Color(2); cout << "恢复 " ; cout << "恢复 " ; } if (jj > 0){ Color(9); cout << "安静 ";7 行未改动 } else if (x == 2){ cout << "罐装龙肉" << endl; cout << "food+40 hp+5 体力+5"; } } else if (x == 3){ cout << "皇家口粮" << endl; cout << "珍贵的食物 food+60 san-5 hp+10"; } } else if (x == 4){ cout << "火盐" << endl; cout << "投掷 击退!"; } } else if (x == 5){ cout << "寂静液汁" << endl; cout << "使用后处于安静状态中,不易被发现"; } } else if (x == 6){ cout << "滋水枪" << endl; cout << "加入杏仁水,发射!"; } } else if (x == 7){ cout << "亚格鲁格亚果实" << endl; cout << "恢复效果 food+5 san+5 hp+5"; }103 行未改动全部展开 } else if (x == 10){ if (dl == 0){ dl = 100; dc --; dc --; } else { wuping ++; cout << endl; cout << " 手电筒还有电!"; Sleep(500); } } else if (x == 11){ else if (x == 11){ cjys --; cout << endl << " 请输入层级编号 " << endl; cout << " 0 1 2 3 4 5 6 7 8 9 A B"; char ch = _getch(); int target_level = -1; if (ch >= '0' && ch <= '9') { target_level = ch - '0'; } } else if (ch == 'A' || ch == 'a') { target_level = 10; } } else if (ch == 'B' || ch == 'b') { target_level = 11; }
3 行未改动 } if (target_level >= 0 && target_level <= 11 ){ level = target_level; cjyscs ++;
} else { cjys ++; cout << endl << " 无效层级"; wuping ++; } wuping ++; } Sleep(1000); } else if (x == 12){ // 幸运豆奶 xydn --; food += 10; san += 10; xydn_buff = 8 + rand() % 3; xydn_buff = 8 + rand() % 3; sbuff[++buff] = 4; } else if (x == 13){ // 现实清新剂 xsqqj --; san = 120; san = 120; if (bsxh > 0){ bsxh = 0; buff --; } } else if (x == 14){ else if (x == 14){ mosun_budai --; bbrl += 10; } // ===== 新增短刀使用逻辑(装备)=====4 行未改动}void dqwp(int x){ man = 0; Color(0); cout << endl << "丢弃 "; cout << endl << "丢弃 "; wuping --; if (x == 1){ cout << "一瓶杏仁水" << endl; xrs --; } else if (x == 2){ cout << "一罐罐装龙肉" << endl; gzlr --; } } else if (x == 3){ cout << "一盒皇家口粮" << endl; hjkl --; } } else if (x == 4){ cout << "一块火盐" << endl; hy --; } } else if (x == 5){ cout << "一瓶寂静液汁" << endl; jjyz --; } } else if (x == 6){ cout << "一把滋水枪" << endl; zsq --; } } else if (x == 7){ cout << "一颗亚格鲁格亚果实" << endl; yglgy --; }7 行未改动 } else if (x == 10){ cout << "电池" << endl; dc --; } } else if (x == 11){ cout << "一把层级钥匙" << endl; cjys --; }20 行未改动 cls(); sjcs = rand() % sjcs; int xz = 0, xzwp, tc = 0; if (wuping > 0) xz = 1; while (1){
while (1){ if (wuping > bbrl) man = 1; else man = 0;
int wp = 0, zs = 0, xzwp = 0; cout << endl; Color(0); cout << "背包"; if (man) cout << "已满,请丢弃或使用物品"; cout << endl; cout << endl; Color(11); cout << "------------------------------" << endl; if (xrs > 0){ for (int i = 1; i <= xrs; i ++){220 行未改动全部展开 cout << "手电筒 " ; cout << "电量 "; if (dl <= 20) Color(4); cout << dl << "% " << endl; } } // 显示已装备的短刀 if (equip_duandao == 1){ Color(0); cout << "短刀 " << endl;48 行未改动 cls();}void tsyy(){ int sj; sjcs ++; sjcs ++; int k = max((sjcs + 11) % 24, 1); for (int i = 1; i <= k; i ++) sj = rand() % 78; if (sj <= 14 || sj >= 72) cout << "继续探索这里" << endl; else if (sj > 14 && sj <= 31) cout << "向四处走走" << endl; else if (sj > 31 && sj <= 56) cout << "碰碰运气,搜寻一番" << endl; else cout << "环顾四周,继续探索" << endl;}void xxyy(){ int sj; sjcs ++; sjcs ++; int k = max((sjcs + 11) % 24, 1); for (int i = 1; i <= k; i ++) sj = rand() % 78; if (sj <= 14 || sj >= 63) cout << "探索很久了,歇歇吧" << endl; else if (sj > 14 && sj <= 31) cout << "休息一会" << endl; else cout << "找处安静地休息" << endl;}void xzyy(){ int sj; sjcs ++; sjcs ++; int k = max((sjcs + 11) % 24, 1); for (int i = 1; i <= k; i ++) sj = rand() % 78; if (sj <= 14 || sj >= 63) cout << "想办法离开这儿" << endl; else if (sj > 14 && sj <= 31) cout << "寻找层级出口" << endl; else cout << "尝试离开这里" << endl;}void mysh(){ int sj; sjcs ++; sjcs ++; int k = max((sjcs + 11) % 24, 1); for (int i = 1; i <= k; i ++) sj = rand() % 78; if (sj <= 14 || sj >= 63) cout << " 嗯..没有任何收获" << endl; else if (sj > 14 && sj <= 31) cout << " 没有任何结果.." << endl; else cout << " 空手而回.." << endl;} }void ckdf(){ if (level == 0){ int sj = rand() % 3; if (sj == 0) cout << "一个通风管道口";4 行未改动 int sj = rand() % 3; if (sj == 0) cout << "一扇门"; else if (sj == 1) cout << "一段阶梯"; else cout << "一面带有排水口的墙体"; } } else if (level == 2){ int sj = rand() % 3; if (sj == 0) cout << "一条廊道"; else if (sj == 1) cout << "一扇金色大门"; else cout << "一个消防出口"; } } else if (level == 3){ int sj = rand() % 3; if (sj == 0) cout << "一扇标有记号的门"; else if (sj == 1) cout << "一个破旧机器"; else cout << "一条走道"; } } else if (level == 4){ int sj = rand() % 3; if (sj == 0) cout << "一扇活板门"; else if (sj == 1) cout << "一个天花板门"; else cout << "一个小房间"; } } else if (level == 5){ int sj = rand() % 3; if (sj == 0) cout << "一扇黑暗的门"; else if (sj == 1) cout << "一条异常宽敞的走廊"; else cout << "一面中式风格的墙"; } } else if (level == 6){ int sj = rand() % 3; if (sj == 0) cout << "一个楼梯井"; else if (sj == 1) cout << "一个门径"; else cout << "一扇巨大铁门"; } } else if (level == 7){ int sj = rand() % 2; if (sj == 0) cout << "一个岩洞"; else if (sj == 1) cout << "一条笔直的路"; } } else if (level == 8){ int sj = rand() % 3; if (sj == 0) cout << "一个通风管道"; else if (sj == 1) cout << "一个焦油坑"; else cout << "一个狭窄的隧道"; } } else if (level == 9){ int sj = rand() % 3; if (sj == 0) cout << "一片田地"; else if (sj == 1) cout << "一片草地"; else cout << "一栋房子"; } } else if (level == 10){ int sj = rand() % 2; if (sj == 0) cout << "一条小径"; else if (sj == 1) cout << "一片芥花籽"; } } else if (level == 11){ int sj = rand() % 3; if (sj == 0) cout << "一片灌木丛"; else if (sj == 1) cout << "一个游戏厅"; else cout << "一所房子外表奇形怪的医院"; } }}int xzcksh(){ cout << endl; Color(0);4 行未改动 return 1; } else { int sj; sjcs ++; sjcs ++; int k = max((sjcs + 11) % 24, 1); for (int i = 1; i <= k; i ++) sj = rand() % 78; if (sj <= 34 || sj >= 63) cout << " 好吧,这很难." << endl; else cout << " 什么都没发现" << endl;4 行未改动 if (level == 0){ int k = rand() % 2; if (k == 0) cout << "地板上"; else cout << "墙角边"; } } else if (level == 1){ int k = rand() % 4; if (k == 0) cout << "板条箱里"; else if (k == 1) cout << "地板上"; else if (k == 2) cout << "墙角"; else cout << "柱子边" ; } else cout << "柱子边" ; } else if (level == 2){ int k = rand() % 4; if (k == 0) cout << "电箱上"; else if (k == 1) cout << "地板上"; else if (k == 2) cout << "墙边"; else cout << "管道上" ; } else cout << "管道上" ; } else if (level == 3){ int k = rand() % 4; if (k == 0) cout << "隧道里"; else if (k == 1) cout << "地板上"; else if (k == 2) cout << "墙边"; else cout << "机器上" ; } else cout << "机器上" ; } else if (level == 4){ int k = rand() % 4; if (k == 0) cout << "办公桌上"; else if (k == 1) cout << "地板上"; else if (k == 2) cout << "墙边"; else cout << "椅子上" ; } else cout << "椅子上" ; } else if (level == 5){ int k = rand() % 4; if (k == 0) cout << "椅子上"; else if (k == 1) cout << "地毯上"; else if (k == 2) cout << "墙角"; else cout << "餐桌上" ; } else cout << "餐桌上" ; } else if (level == 6 || level == 8){ cout << "黑暗中"; } } else if (level == 7){ int k = rand() % 2; if (k == 0) cout << "海面上"; else cout << "房间里";2 行未改动 int k = rand() % 4; if (k == 0) cout << "路灯下"; else if (k == 1) cout << "街道上"; else if (k == 2) cout << "房子内"; else cout << "田地边" ; } else cout << "田地边" ; } else if (level == 10){ int k = rand() % 4; if (k == 0) cout << "田里"; else if (k == 1) cout << "仓库里"; else if (k == 2) cout << "湖边"; else cout << "门阶上" ; } else cout << "门阶上" ; } else if (level == 11){ int k = rand() % 4; if (k == 0) cout << "车上"; else if (k == 1) cout << "马路上"; else if (k == 2) cout << "草地上"; else cout << "房子边" ; } else cout << "房子边" ; }}void ysh(){ int sj; sjcs ++; sjcs ++; int k = max((sjcs + 11) % 24, 1); Color(0); wuping ++; cout << "你在"; fxdf(); cout << "发现了 "; for (int i = 1; i <= k; i ++) sj = rand() % 1200;
// ========== 概率等级1(3%):层级钥匙(分散为2个区间) ========== if ((sj >= 0 && sj <= 14) || (sj >= 800 && sj <= 814)) { cout << "一把层级钥匙" << endl; cjys ++; } // ========== 概率等级2(5%):磨损的布袋(分散为2个区间) ========== else if ((sj >= 15 && sj <= 40) || (sj >= 815 && sj <= 829)) { cout << "一个磨损的布袋" << endl; bd ++; bd ++; mosun_budai ++; } // ========== 概率等级2(5%):现实清新剂(分散为2个区间) ========== else if ((sj >= 45 && sj <= 74) || (sj >= 830 && sj <= 844)) {62 行未改动 xrs ++; }}int tssh(){ int total_range = 1000; int sj = rand() % total_range; int total_range = 1000; int sj = rand() % total_range; int has_item = 0;
if (sj == 234 || sj == 567 || sj == 345 || sj == 456 || sj == 678 && swfecj == 0){ cout << " 你遇到了一只死亡飞蛾" << endl; cout << " e 洒杏仁水 p 离开" << endl; while (1){ if (kbhit()){ char c=_getch(); if (c == 'e') { int sj = rand() % 5; int sj = rand() % 5; if (sj >= 3) { cout << " 你驯服了死亡飞蛾" << endl; swfecj = 1; cj(6);5 行未改动 return 0; } else return 0; } } } }
if (level == 0) { // (22%概率):分散为3个区间 if ((sj >= 0 && sj <= 99) || (sj >= 300 && sj <= 399) || (sj >= 700 && sj <= 729)) { has_item = 1; } } } else if (level == 1) { // (35%概率):分散为3个区间 if ((sj >= 0 && sj <= 99) || (sj >= 300 && sj <= 399) || (sj >= 700 && sj <= 799) || (sj >= 800 && sj <= 849)) { has_item = 1; } } } else if (level == 2 || level == 6 || level == 8) { // (18%概率):分散为2个区间 if ((sj >= 200 && sj <= 299) || (sj >= 500 && sj <= 579)) { has_item = 1;9 行未改动 // (30%概率):分散为3个区间 if ((sj >= 0 && sj <= 99) || (sj >= 300 && sj <= 399) || (sj >= 700 && sj <= 799)) { has_item = 1; } } } else if (level == 5 ) { // (37%概率):分散为3个区间 if ((sj >= 0 && sj <= 99) || (sj >= 300 && sj <= 399) || (sj >= 700 && sj <= 799) || (sj >= 800 && sj <= 869)) { has_item = 1; } } } else if (level == 10 || level == 11) { // (60%概率):分散为3个区间 if ((sj >= 200 && sj <= 239) || (sj >= 500 && sj <= 599) || (sj >= 0 && sj <= 99) || (sj >= 300 && sj <= 399) || (sj >= 700 && sj <= 799) || (sj >= 800 && sj <= 869)) { has_item = 1; } } } if (xydn_buff > 0 && sj >= 700) has_item = 1; if (dl > 0 && sj >= 800) has_item = 1;
return has_item;}void sw(int x){ cls(); cls(); cout << endl << endl; Color(4); Color(4); cout << " YOU DEAD" << endl; cout << endl; cout << " reason: "; Color(7); if (x == 1){ cout << "悲尸循环"; } else if (x == 2){ else if (x == 2){ cout << "饥饿"; } else if (x == 3){ else if (x == 3){ cout << "实体攻击"; } else if (x == 4){ cout << "恐惧"; } Sleep(1800); exit(0); exit(0);}int taotuo(int x){ int cg = 0, sj = rand() % 200; int cg = 0, sj = rand() % 200; if(x==1 && ((sj>=10&&sj<=29)||(sj>=80&&sj<=99))) cg=1; // 40/200=20% if(x==2 && ((sj>=5&&sj<=24)||(sj>=50&&sj<=99))) cg=1; // 80/200=40% if(x==3 && ((sj>=0&&sj<=39)||(sj>=60&&sj<=139))) cg=1; // 110/200=55% if(x==4 && ((sj>=2&&sj<=71)||(sj>=90&&sj<=189))) cg=1; // 150/200=75%5 行未改动 int gw; cls(); int sj = rand() % 200; if ((sj >= 34 && sj <= 38 || sj >= 140 && sj <= 148 || sj >= 88 && sj <= 93) || (dl == 0 && sj >= 111 && sj <= 113)) gw = 1;//笑魇 else if(sj >= 41 && sj <= 49 || sj >= 21 && sj <= 28 ) gw = 2;//死亡飞蛾 else if(sj >= 160 && sj <= 167 || sj >= 189 && sj <= 194 || (dl == 0 && sj >= 111 && sj <= 113)) gw = 1;//笑魇 else if(sj >= 41 && sj <= 49 || sj >= 21 && sj <= 28 ) gw = 2;//死亡飞蛾 else if(sj >= 160 && sj <= 167 || sj >= 189 && sj <= 194 || sj >= 127 && sj <= 130) gw = 3;// 窃皮者 else if(sj >= 190 && sj <= 195 || sj >= 30 && sj <= 33 || sj >= 100 && sj <= 108) gw = 4;// 钝人 else if(sj >= 63 && sj <= 68 || sj >= 151 && sj <= 158 || sj >= 177 && sj <= 181) gw = 5;//肢团 else if(sj >= 69 && sj <= 73 || sj >= 168 && sj <= 170) gw = 6;//悲尸 if (level == 7 && sj >= 130) gw = 8; else gw = 7;//猎犬 else if(sj >= 190 && sj <= 195 || sj >= 30 && sj <= 33 || sj >= 100 && sj <= 108) gw = 4;// 钝人 else if(sj >= 63 && sj <= 68 || sj >= 151 && sj <= 158 || sj >= 177 && sj <= 181) gw = 5;//肢团 else if(sj >= 69 && sj <= 73 || sj >= 168 && sj <= 170) gw = 6;//悲尸 if (level == 7 && sj >= 130) gw = 8; else gw = 7;//猎犬 int xh = 0; while (xh <= 460000){ cls(); san -= rand() % 9;19 行未改动 else Color(4); cout << hp << " "; if (hp < 100) cout << " "; if (hp < 10) cout << " ";
Color(0); cout << "FOOD "; if (food > 20) Color(0); else Color(4); cout << food << " "; if (food < 100) cout << " "; if (food < 10) cout << " ";
Color(0); cout << "SAN "; if (san > 20) Color(0); else Color(4); cout << san << " "; if (san < 100) cout << " "; if (san < 10) cout << " ";//基础数值 if (san < 10) cout << " ";//基础数值 cout << endl; Color(8); cout << " ○ z 逃跑" << endl; if (xrs > 0) cout << " ○ x 洒杏仁水" << endl;84 行未改动 // 购买模式:显示可购买物品 Color(7); cout << "【可购买】\n"; for (int i=0; i<buy_list.size(); i++) { if (i+1 == select_item) Color(2); else Color(7); cout << "[" << i+1 << "]" << buy_list[i].name cout << "[" << i+1 << "]" << buy_list[i].name << " 价格:" << buy_list[i].cost << " 获得:" << buy_list[i].num << "\n"; } } else { // 出售模式:仅过滤 数量>0 + 不是杏仁水(装备无限制)11 行未改动 // 遍历可售卖物品,选中时显示预计获得的物品 for (int i=0; i<sellable.size(); i++) { ItemInfo& item = sellable[i]; if (i+1 == select_item) { Color(2); Color(2); cout << "[" << i+1 << "]" << item.name << " ×" << *item.count << "\n"; Color(10); // 浅绿色显示预计奖励
// 提前计算选中物品卖出后会获得的物品(仅显示,不执行) vector<ItemInfo> rewards; for (auto& it : items) if (it.can_get) rewards.push_back(it); int r = rand()%rewards.size(); ItemInfo& get_item = rewards[r];
// 计算价值(控制差值≤1.5) double base_value = item.value; // 波动范围:base_value-1.5 ~ base_value+1.5,且不低于0.1 double min_total = max(base_value - 1.5, 0.1); double max_total = base_value + 1.5; double total = min_total + (rand() % (int)((max_total - min_total)*100))/100.0; int cnt = max((int)(total / get_item.value), 1); // 至少1个
cout << " → 卖出可获得:" << cnt << "个" << get_item.name << "\n"; Color(7); } else { Color(7);11 行未改动 // 处理用户输入 while (true) { if (!_kbhit()) continue; char op = _getch();
// 预筛选可售卖物品(用于上下选择逻辑) vector<ItemInfo> sellable; for (auto& it : items) { if (*it.count <=0 || it.id ==1) continue;75 行未改动 } cls();}bool check_entity_spawn() { int total_range = 1000; int sj = rand() % total_range; int spawn = 0; int total_range = 1000; int sj = rand() % total_range; int spawn = 0;
int entity_level = 0; if (level == 0 || level == 5 || level == 4) entity_level = 0; // 0级 - 0% else if (level == 1 || level == 11) entity_level = 1; // 1级 - 3% else if (level == 2) entity_level = 2; // 2级 - 6% else if (level == 3 || level == 7) entity_level = 3; else if (level == 8) entity_level = 4; else if (level == 9) entity_level = 5;
switch(entity_level) { case 0: case 0: spawn = 0; break; case 1: if ((sj >= 10 && sj <= 19) || (sj >= 210 && sj <= 219) ||
case 1: if ((sj >= 10 && sj <= 19) || (sj >= 210 && sj <= 219) || (sj >= 410 && sj <= 419)) { spawn = 1; } break;
case 2: // 2级 - 6% 概率(4个分散区间,总计60个值) if ((sj >= 20 && sj <= 34) || (sj >= 220 && sj <= 234) || (sj >= 420 && sj <= 434) || if ((sj >= 20 && sj <= 34) || (sj >= 220 && sj <= 234) || (sj >= 420 && sj <= 434) || (sj >= 620 && sj <= 634)) { spawn = 1; } break;
case 3: // 3级 - 9% 概率(5个分散区间,总计90个值) if ((sj >= 35 && sj <= 52) || (sj >= 235 && sj <= 252) || (sj >= 435 && sj <= 452) || (sj >= 635 && sj <= 652) || if ((sj >= 35 && sj <= 52) || (sj >= 235 && sj <= 252) || (sj >= 435 && sj <= 452) || (sj >= 635 && sj <= 652) || (sj >= 835 && sj <= 852)) { spawn = 1; } break;
case 4: // 4级 - 12% 概率(6个分散区间,总计120个值) // 区间1: 53-72 (20个) + 区间2: 253-272 (20个) + 区间3: 453-472 (20个) + 区间4: 653-672 (20个) + 区间5: 853-872 (20个) + 区间6: 953-972 (20个) if ((sj >= 53 && sj <= 72) || (sj >= 253 && sj <= 272) || (sj >= 453 && sj <= 472) || (sj >= 653 && sj <= 672) || (sj >= 853 && sj <= 872) || if ((sj >= 53 && sj <= 72) || (sj >= 253 && sj <= 272) || (sj >= 453 && sj <= 472) || (sj >= 653 && sj <= 672) || (sj >= 853 && sj <= 872) || (sj >= 953 && sj <= 972)) { spawn = 1; } break;
case 5: // 5级 - 15% 概率(7个分散区间,总计147个值) if ((sj >= 73 && sj <= 93) || (sj >= 173 && sj <= 193) || (sj >= 273 && sj <= 293) || (sj >= 473 && sj <= 493) || (sj >= 673 && sj <= 693) || (sj >= 873 && sj <= 893) || if ((sj >= 73 && sj <= 93) || (sj >= 173 && sj <= 193) || (sj >= 273 && sj <= 293) || (sj >= 473 && sj <= 493) || (sj >= 673 && sj <= 693) || (sj >= 873 && sj <= 893) || (sj >= 973 && sj <= 993)) { spawn = 1; } break; }
return spawn == 1;}
int main(){31 行未改动 ttcg = 0; }
ksfm();
cls(); xd = 1; wuzi[0] = 1; shiti[1] = 1;2 行未改动 wuzi[2] = -1; shiti[3] = 3; shiti[7] = shiti[8] = shiti[9] = shiti[11] = 3; while (1){
kscd(); while (1){ int tc = 0, ymy = 0; cls();2 行未改动 if (LL == 12 && llz == 0) LL ++, llz = 1, cj(1), ymy = 1; if (cjyscs == 4 && ffht == 0) ffht = 1, cj(2), ymy = 1; if (ttcg == 15 && sc == 0) sc = 1, cj(3), ymy = 1; if (xrssy == 31 && xrscj == 0) xrscj = 1, cj(4), ymy = 1; if (bd == 5 && scj == 0) scj = 1, cj(5), ymy = 1; if (bd == 5 && scj == 0) scj = 1, cj(5), ymy = 1; if (swfecj == 1) swfecj = 2, ymy = 1; if (ts = 101 && yqlyy == 0)yqlyy = 1, ymy = 1; if (ymy){
ifstream f("save.dat",ios::binary);if (f.is_open()) { // 新增:检查文件是否打开 f.read((char*)&xrscj, sizeof(xrscj)) .read((char*)&scj, sizeof(scj))13 行未改动 xrscj = 0, scj = 0, sc = 0, llz = 0, ffht = 0; bd = 0, cjyscs = 0, xrssy = 0, LL = 0, ttcg = 0, yqlyy = 0;} }
if (level != 2) dz = 0;
int ssj = rand() % 200; if (ssj >= 30 && ssj <= 32 || ssj >= 150 && ssj <= 153 || ((level == 8 || level == 9 || level == 3 || level == 10 || level == 11)&& (ssj >= 60 && ssj <= 63 || ssj >= 160 && ssj <= 161))) qhcj();
if (level == 2){ int sj = rand() % 200; if (sj >= 12 && sj <= 15 || sj >= 120 && sj <= 122){ cls(); dz = 7; } }
int nd = shiti[level]; if (shiti[level] != 0) { int my = 0; int ssj = rand() % 90; if (jj > 0 && ssj >= 68) { my = 1; my = 1; }
if (!my && check_entity_spawn()) { guaiwu(); cls(); st = 0;3 行未改动 cls(); st = 0; } }
if (sdt) dl = max(0, dl - 1); sjcs ++; sjcs ++;
// 幸运豆奶buff if (xydn_buff > 0) { xydn_buff --; if (xydn_buff == 0) buff --; if (xydn_buff == 0) buff --; } //恐惧buff //恐惧buff if (kj > 0){ buff ++; buff ++; kj --; san -= rand() % 4; if (kj == 0) buff --; } if (level == 6 || level == 8){ buff ++; ha = 1; san -= rand() % 2; } } else if (ha == 1)buff --, ha = 0;
if (food == 0) hp -= rand() % 3; if (!xd) food -= rand() % 2, san -= rand() % 3, san += rand() % 2, tili -= rand() % 2, tili += rand() % 2; if (hf){ hf --;33 行未改动 buff --; bsxh = 0; } }
if((level == 5 || level == 7 )&& dl == 0 && tili < 40){ int sj = rand() % 200; if (sj >= 130 && sj <= 140 || sj >= 170 && sj <= 180 || sj >= 50 && sj <= 55){ if (kj == 0) kj += 4; if (kj > 0) kj += rand() % 2 + 1; } }
tili = min(tili, 120); tili = max(tili, 0); hp = min(hp, 120); hp = max(hp, 0);3 行未改动 san = max(san, 0); if (food == 0) hp -= rand() % 3; xd = 0; if (food == 0 && hp == 0) sw(2);
cout << endl; cout << " "; cengji(); cout << endl;2 行未改动 Color(6); cout << "地震 -实体频出" << endl; } fenjie1(); cout << endl;//层级及分界 cout << endl;//层级及分界 if (food == 0) hp -= rand() % 3; if (hp <= 0 && food == 0) { sw(2); }
zhuangtai(); Color(0); cout << "HP "; if (hp > 20) Color(0); else Color(4); cout << hp << " "; if (hp < 100) cout << " "; if (hp < 10) cout << " ";
Color(0); cout << "FOOD "; if (food > 20) Color(0); else Color(4); cout << food << " "; if (food < 100) cout << " "; if (food < 10) cout << " ";
Color(0); cout << "SAN "; if (san > 20) Color(0); else Color(4); cout << san << " "; if (san < 100) cout << " "; if (san < 10) cout << " ";//基础数值 if (san < 10) cout << " ";//基础数值
cout << endl; fenjie2(); cout << endl;//分界 cout << endl;//分界
Color(0); cout << "BUFF "; if (buff == 0) cout << "--"; else {17 行未改动 hp -= rand() % 2; san -= rand() % 2; tili -= rand() % 2; } }//BUFF }//BUFF
cout << endl; Color(0), cout << "体力 " << tili;
cout << endl; fenjie2(); cout << endl;//分界 cout << endl;//分界
if (!st){ Color(0); cout << "我可以.." << endl; cout << " ○ 1 "; tsyy(); cout << " ○ 2 "; xxyy(); cout << " ○ 3 "; xzyy(); xzyy(); if (level == 11){ cout << " ○ 4 交易 "; cout << endl; } }
long long xhcs = 0; while(++ xhcs < 50000){ if(kbhit()){ char c=_getch();94 行未改动 } if(c=='o'){ loadGame(); break; } } if(c=='k' || c=='K'){ clearAllData(); break; } if (c == 'b'){ tc = 1; break; } } }//操作 }//操作 if (tc == 1) { cls(); cout << " 1 仅退出 2 退出(重新开始)"; while (1){2 行未改动 if (c == '2') { level = san = food = hp = buff = tili = wuping = xrs = jjyz = hy = hjkl = gzlr = zsq = st = sjcs = sxz = yglgy = man = 0; san = food = hp = tili = 120; // 初始值单独赋值 xd = 1, bbrl = 20;
ynmht = rhmht = hf = jj = sdt = dl = dc = sqdy = bsxh = kj = duandao = equip_duandao = xrscj = scj = sc = llz = ffht = dz = bd = cjyscs = xrssy = LL = ttcg = ha = cjys = xydn = xsqqj = xydn_buff = mosun_budai = 0;
memset(sbuff, 0, sizeof(sbuff)); break; } else break;5 行未改动 ts ++; } cls(); }
return 0;}```