C++#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>
using namespace std;
typedef long long ll;
const int N = 10000;
HANDLE hConsole;
void fastClear() {
cout.flush();
COORD topLeft = {0, 0};
CONSOLE_SCREEN_BUFFER_INFO screen;
DWORD written;
GetConsoleScreenBufferInfo(hConsole, &screen);
FillConsoleOutputCharacterA(hConsole, ' ', screen.dwSize.X * screen.dwSize.Y, topLeft, &written);
FillConsoleOutputAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, screen.dwSize.X * screen.dwSize.Y, topLeft, &written);
SetConsoleCursorPosition(hConsole, topLeft);
}
long long n=N,cs=15,hp=10,mxhp=10,pw=5,d=3,s=4,px=0,py=0,m=1,num=1,cnt=0;
double sum = 1.0;
int x = n/2,y = n/2;
char mp[N+5][N+5];
bool flag = 1;
bool mdao = true;
bool nuwaSaved = false;
bool autoBattle = false;
int kx = -1, ky = -1;
bool bossHinted = false;
set<pair<int,int> > pathSet;
int slot = 1;
ll gold = 0;
set<pair<int,int> > ruinsSet;
int zx[4], zy[4];
bool zAlive[4] = {false};
int zKillCount = 0;
int myColor = 12;
int enemyColor = 15;
int pathColor = 14;
int battleDelay = 100;
int infoDelay = 1000;
int diffLevel = 2;
double diffMul = 1.0;
bool showBloodBar = true;
bool ach[30] = {false};
int achCount = 0;
int totalBonus = 0;
int totalWin = 0;
int totalMove = 0;
int winStreak = 0;
int noHurtStreak = 0;
int ruinsVisited = 0;
bool battleHurt = false;
ll basePw = 5, baseD = 3, baseS = 4, baseHp = 10;
struct Eq {
int sub;
int q;
ll atk, spd;
int crit, combo, ls, rf;
string name;
};
Eq bag[30];
int bagN = 0;
Eq eqp;
int eqCrit = 0, eqCombo = 0, eqLs = 0, eqRf = 0;
int stunRound = 0;
struct EqData {
int sub, q;
ll atk, spd;
int crit, combo, ls, rf;
string name;
};
EqData wlib[] = {
{0, 0, 5, 0, 0, 0, 0, 0, "铁剑"}, {1, 0, 3, 1, 0, 0, 0, 0, "铁匕首"},
{2, 0, 4, 0, 0, 0, 0, 0, "生锈双刀"}, {3, 0, 5, 0, 0, 0, 0, 0, "朴刀"},
{4, 0, 6, -1, 0, 0, 0, 0, "齐眉棍"}, {5, 0, 7, -1, 0, 0, 0, 0, "砍柴斧"},
{6, 0, 7, -2, 0, 0, 0, 0, "八角锤"}, {7, 0, 5, 0, 0, 0, 0, 0, "白蜡杆枪"},
{8, 0, 6, 0, 0, 0, 0, 0, "长镰"},
{0, 1, 12, 0, 5, 0, 0, 0, "青钢剑"}, {1, 1, 8, 3, 10, 0, 0, 0, "峨眉刺"},
{2, 1, 10, 0, 5, 0, 5, 0, "柳叶双刀"}, {3, 1, 12, 0, 5, 0, 0, 0, "雁翎刀"},
{4, 1, 15, 0, 0, 0, 0, 0, "熟铜锏"}, {5, 1, 15, -1, 5, 0, 0, 0, "宣花板斧"},
{6, 1, 14, -2, 0, 0, 0, 0, "流星锤"}, {7, 1, 13, 0, 0, 0, 0, 0, "红缨枪"},
{8, 1, 15, 0, 0, 0, 5, 0, "月牙铲"},
{0, 2, 25, 0, 5, 5, 0, 0, "龙泉剑"}, {1, 2, 15, 5, 15, 0, 0, 0, "鱼肠剑"},
{2, 2, 22, 0, 10, 0, 0, 0, "子母双刀"}, {3, 2, 25, 0, 10, 0, 15, 0, "九环大刀"},
{4, 2, 30, 0, 5, 0, 0, 0, "混铁棍"}, {5, 2, 35, -5, 10, 0, 0, 0, "八卦宣花斧"},
{6, 2, 30, -5, 5, 0, 0, 0, "擂鼓瓮金锤"}, {7, 2, 30, 0, 0, 0, 0, 0, "亮银枪"},
{8, 2, 32, 0, 5, 0, 10, 0, "方天画戟"},
{0, 3, 60, 0, 10, 0, 10, 0, "太阿剑"}, {1, 3, 35, 15, 20, 10, 0, 0, "打神鞭"},
{2, 3, 50, 5, 15, 10, 0, 0, "干将莫邪"}, {3, 3, 65, 0, 15, 0, 15, 0, "青龙偃月刀"},
{4, 3, 85, -10, 10, 0, 0, 0, "降魔杵"}, {5, 3, 80, -10, 15, 0, 0, 0, "开山巨斧"},
{6, 3, 90, -10, 0, 0, 0, 0, "雷神锤"}, {7, 3, 75, 0, 10, 0, 0, 0, "丈八蛇矛"},
{8, 3, 80, 0, 10, 0, 15, 0, "霸王戟"},
{0, 4, 150, 20, 15, 10, 10, 0, "轩辕夏禹剑"}, {1, 4, 100, 30, 30, 20, 0, 0, "女娲补天石"},
{2, 4, 120, 20, 15, 15, 0, 0, "东皇混沌钟"}, {3, 4, 160, 20, 20, 0, 25, 0, "鸣鸿刀"},
{4, 4, 180, -10, 20, 0, 0, 0, "番天印"}, {5, 4, 200, -20, 25, 0, 0, 0, "盘古开天斧"},
{6, 4, 220, -20, 20, 0, 0, 0, "神农造化鼎"}, {7, 4, 180, 10, 15, 0, 0, 0, "鸿蒙弑神枪"},
{8, 4, 190, 0, 15, 0, 30, 0, "太极乾坤圈"}
};
int wlibSize = sizeof(wlib) / sizeof(wlib[0]);
const string achName[30] = {
"怪物猎手", "天才少年", "肝帝!!", "钢铁是如何练成的", "强者愈弱",
"他出了个名刀司命!!!", "半步踏神", "神!!", "连击达人", "绝地反击",
"常客", "秒杀", "无伤战神", "隐世高手", "地狱归来", "百战百胜",
"万里长征", "一步登天", "战略撤退", "初露锋芒",
"神兵降世", "富甲一方", "背包客", "屠戮机器", "边境行者",
"探险家", "欧皇", "徒步达人", "天赋异禀", "大满贯"
};
const string achDesc[30] = {
"击败 100 个敌人", "击败 500 个敌人", "击败 1000 个敌人",
"与同一敌人打满 30 轮,且结束时血量 >= 50%", "击败最终 BOSS「K」",
"触发名刀·司命的复活效果", "达到 50 级", "达到 100 级",
"单场战斗内触发 5 次连击", "血量 <= 5% 时击败敌人",
"累计拾取 10 次奖励点", "第 1 回合就击杀敌人",
"连续 10 场战斗未受任何伤害就击败敌人", "使用隐藏角色 O 击败 BOSS K",
"在地狱难度下击败 BOSS K", "连续胜利 100 场",
"累计移动 10000 步", "单次升级跨越 5 级或以上",
"名刀触发后选择退出战斗", "击败 10 个敌人",
"获得一件神话级武器", "持有 100000 金币", "背包同时拥有 30 件装备",
"累计击杀 5000 个敌人", "到达世界尽头的边境之地",
"探索 3 处上古遗址", "在补给点开出神话武器", "累计移动 50000 步",
"达到 200 级", "解锁其余全部 29 个成就"
};
void draw();
void refreshStat();
void showEqName(int q, string name);
void printRainbow(string s);
void printHP() {
if (showBloodBar) {
int w = 20;
int f = (int)(hp * w / max(1LL, mxhp));
if (f < 0) f = 0;
if (f > w) f = w;
cout << "血量:[";
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY);
for (int i = 0; i < f; i++) cout << "█";
SetConsoleTextAttribute(hConsole, 7);
for (int i = f; i < w; i++) cout << "?";
cout << "] " << hp << "/" << mxhp << endl;
} else {
cout << "血量:" << hp << "/" << mxhp << endl;
}
}
int r(int i,int j){ return rand()%(j-i+1)+i; }
void unlockAch(int id){
if (id < 0 || id >= 30) return;
if (ach[id]) return;
ach[id] = true; achCount++;
cout << "\n★★★★★★★★★★ 成就解锁 ★★★★★★★★★★" << endl;
cout << " ★ " << achName[id] << "\n " << achDesc[id] << endl;
cout << "★★★★★★★★★★★★★★★★★★★★★★★★★★" << endl;
Sleep(800);
if (id != 29 && achCount == 29 && !ach[29]) unlockAch(29);
}
void showAchBook(){
fastClear();
cout << "================= 成就图鉴 ================= " << endl;
cout << " 已解锁:" << achCount << " / 30" << endl;
cout << " 当前连胜:" << winStreak << " 场\n 连续无伤:" << noHurtStreak << " 场\n 亲卫进度:" << zKillCount << " / 4" << endl;
cout << "--------------------------------------------" << endl;
for (int i = 0; i < 30; i++) {
if (ach[i]) {
cout << " ★ [" << (i+1 < 10 ? " " : "") << i+1 << "] " << achName[i] << endl;
cout << " 获取方式:" << achDesc[i] << endl;
} else {
cout << " ☆ [" << (i+1 < 10 ? " " : "") << i+1 << "] ???(未解锁)" << endl;
cout << " 获取方式:" << achDesc[i] << endl;
}
}
cout << "============================================\n按任意键返回游戏" << endl;
getch();
}
void printRainbow(string s) {
int colors[6] = {12, 14, 10, 11, 9, 13};
for (size_t i = 0; i < s.size(); i++) {
SetConsoleTextAttribute(hConsole, colors[i % 6]);
cout << s[i];
}
SetConsoleTextAttribute(hConsole, 7);
}
void showEqName(int q, string name) {
if (q == 0) { SetConsoleTextAttribute(hConsole, 7); cout << name; }
else if (q == 1) { SetConsoleTextAttribute(hConsole, 9); cout << name; }
else if (q == 2) { SetConsoleTextAttribute(hConsole, 13); cout << name; }
else if (q == 3) { SetConsoleTextAttribute(hConsole, 14); cout << name; }
else if (q == 4) { printRainbow(name); }
SetConsoleTextAttribute(hConsole, 7);
}
string getEqEffect(int sub, int q) {
if (q == 3) {
if (sub == 0) return "威道剑气:暴击率+20%,暴击附带20%真伤";
if (sub == 1) return "专打神性:对满血敌人伤害翻倍";
if (sub == 2) return "雌雄双股:必定触发连击";
if (sub == 3) return "武圣之威:必定先手,对满血敌人造成2倍伤害";
if (sub == 4) return "降妖除魔:30%概率眩晕敌人";
if (sub == 5) return "力劈华山:无视50%防御,暴击2.5倍";
if (sub == 6) return "天雷引:30%概率附加50%攻击真伤";
if (sub == 7) return "长驱直入:必定连击,无视30%防御";
if (sub == 8) return "霸王本色:每回合攻击力提升10%";
} else if (q == 4) {
if (sub == 0) return "圣道剑气:无视所有防御,附带10%自身最大生命真伤";
if (sub == 1) return "造化生机:每回合回血10%,免死一次";
if (sub == 2) return "混沌镇压:附带100%防御真伤,30%概率击晕敌人";
if (sub == 3) return "屠戮天下:攻击满血敌人伤害翻倍且必定暴击,溢出伤害转化为吸血";
if (sub == 4) return "不周镇压:100%攻击真伤,每次攻击永久降敌20%防御";
if (sub == 5) return "开天辟地:暴击3.5倍,暴击必连击";
if (sub == 6) return "万物鼎:吸取敌人10%攻击力加给自己";
if (sub == 7) return "弑神之力:对>50%血敌人伤害翻倍且无视防御";
if (sub == 8) return "阴阳合一:必定暴击,暴击偷取敌人10%速度";
}
return "凡铁兵刃,无特殊效果";
}
void showWeaponDisplay(Eq e, string title = "获得神兵") {
fastClear();
cout << "\n==============================================" << endl;
cout << " " << title << "\n----------------------------------------------\n 名字:";
showEqName(e.q, e.name);
cout << "\n 评级:";
string qStr[5] = {"白", "蓝", "紫", "金", "彩"};
showEqName(e.q, qStr[e.q] + " 级(神兵)");
cout << "\n----------------------------------------------" << endl;
cout << " 攻击力:" << e.atk << " 速度:" << e.spd << "\n 附加属性:";
if (e.crit) cout << " 暴击+" << e.crit << "%";
if (e.combo) cout << " 连击+" << e.combo << "%";
if (e.ls) cout << " 吸血+" << e.ls << "%";
if (e.rf) cout << " 反伤+" << e.rf << "%";
if (!e.crit && !e.combo && !e.ls && !e.rf) cout << " 无";
cout << "\n----------------------------------------------" << endl;
SetConsoleTextAttribute(hConsole, 11);
cout << " ★ 特殊效果:" << getEqEffect(e.sub, e.q) << endl;
SetConsoleTextAttribute(hConsole, 7);
cout << "==============================================\n按任意键继续..." << endl;
getch();
if (e.q == 4) unlockAch(20);
}
Eq genWeapon(int lv, int forceQ) {
Eq e;
vector<int> pool;
for (int i = 0; i < wlibSize; i++) {
if (forceQ == -1 || wlib[i].q == forceQ) pool.push_back(i);
}
if (pool.empty()) { forceQ = 0; for (int i = 0; i < wlibSize; i++) if (wlib[i].q == 0) pool.push_back(i); }
EqData data = wlib[pool[rand() % pool.size()]];
e.sub = data.sub; e.q = data.q; e.name = data.name;
double mul = 1.0 + (lv * 0.15) * (1.0 + data.q * 0.6);
e.atk = data.atk * mul; e.spd = data.spd * mul;
e.crit = data.crit; e.combo = data.combo; e.ls = data.ls; e.rf = data.rf;
return e;
}
void refreshStat() {
pw = basePw; s = baseS; d = baseD; mxhp = baseHp;
eqCrit = 0; eqCombo = 0; eqLs = 0; eqRf = 0;
if (eqp.q >= 0) {
pw += eqp.atk; s += eqp.spd;
eqCrit += eqp.crit; eqCombo += eqp.combo; eqLs += eqp.ls; eqRf += eqp.rf;
}
if (hp > mxhp) hp = mxhp;
}
// [修复] 背包已满时禁止更换武器,避免 bag[30] 越界
void wearWeapon(int idx) {
if (idx < 0 || idx >= bagN) return;
if (eqp.q >= 0 && bagN >= 30) {
cout << "背包已满,无法更换武器!按任意键继续..." << endl;
getch();
return;
}
Eq e = bag[idx];
for (int i = idx; i < bagN - 1; i++) bag[i] = bag[i + 1];
bagN--;
if (eqp.q >= 0) bag[bagN++] = eqp;
eqp = e;
if (eqp.q == 4 && eqp.sub == 1) nuwaSaved = false;
refreshStat();
}
void showItemDetail(int idx) {
if (idx < 0 || idx >= bagN) return;
Eq e = bag[idx];
while (true) {
fastClear();
cout << "\n==============================================" << endl;
cout << " 名字:";
showEqName(e.q, e.name);
cout << "\n 评级:";
string qStr[5] = {"白", "蓝", "紫", "金", "彩"};
showEqName(e.q, qStr[e.q] + " 级");
cout << "\n----------------------------------------------" << endl;
cout << " 攻击力:" << e.atk << " 速度:" << e.spd << "\n 附加属性:";
if (e.crit) cout << " 暴击+" << e.crit << "%";
if (e.combo) cout << " 连击+" << e.combo << "%";
if (e.ls) cout << " 吸血+" << e.ls << "%";
if (e.rf) cout << " 反伤+" << e.rf << "%";
if (!e.crit && !e.combo && !e.ls && !e.rf) cout << " 无";
cout << "\n----------------------------------------------" << endl;
SetConsoleTextAttribute(hConsole, 11);
cout << " ★ 特殊效果:" << getEqEffect(e.sub, e.q) << endl;
SetConsoleTextAttribute(hConsole, 7);
cout << "==============================================" << endl;
cout << " [1] 佩戴此武器" << endl;
cout << " [Q] 丢弃此武器" << endl;
cout << " [其他任意键] 返回" << endl;
char c = getch();
if (c == '1') {
wearWeapon(idx);
break;
} else if (c == 'q' || c == 'Q') {
for (int i = idx; i < bagN - 1; i++) bag[i] = bag[i + 1];
bagN--;
break;
} else break;
}
}
void showBag() {
int page = 0;
while (true) {
fastClear();
cout << "================= 武器背包 =================" << endl;
cout << " [当前武器] ";
if (eqp.q < 0) cout << "空手" << endl;
else { showEqName(eqp.q, eqp.name); cout << " 攻:" << eqp.atk << " 速:" << eqp.spd << endl; }
cout << "----------------------------------------------" << endl;
int st = page * 5;
for (int i = st; i < st + 5 && i < bagN; i++) {
cout << " " << i - st + 1 << ". ";
showEqName(bag[i].q, bag[i].name);
cout << " 攻:" << bag[i].atk << " 速:" << bag[i].spd;
if (bag[i].crit) cout << " 暴:" << bag[i].crit << "%";
if (bag[i].combo) cout << " 连:" << bag[i].combo << "%";
if (bag[i].ls) cout << " 吸:" << bag[i].ls << "%";
cout << endl;
}
cout << "==============================================" << endl;
cout << "页数: " << page + 1 << "/" << max(1, (bagN + 4) / 5) << "\n按 [1-5] 查看详情 [7] 卸下当前武器\n按 [A]上一页 [D]下一页 [ESC]退出" << endl;
char c = getch();
if (c == 27) break;
if ((c == 'd' || c == 'D') && (page + 1) * 5 < bagN) page++;
if ((c == 'a' || c == 'A') && page > 0) page--;
if (c >= '1' && c <= '5') showItemDetail(st + c - '1');
if (c == '7') {
if (eqp.q >= 0) {
if (bagN < 30) {
bag[bagN++] = eqp;
eqp.q = -1;
refreshStat();
} else {
cout << "背包已满,无法卸下!按任意键继续..." << endl;
getch();
}
}
}
}
}
void saveGame(){
char fn[32]; sprintf(fn, "save%d.txt", slot);
ofstream fout(fn);
fout << "V3 ";
fout << m << " " << hp << " " << mxhp << " " << pw << " " << d << " " << s << " " << sum << " " << cnt << " " << mdao << " " << nuwaSaved;
for (int i = 0; i < 30; i++) fout << " " << ach[i];
fout << " " << totalBonus << " " << totalWin << " " << winStreak << " " << noHurtStreak << " " << totalMove << " " << zKillCount << " " << ruinsVisited << " ";
fout << basePw << " " << baseD << " " << baseS << " " << baseHp << " " << bagN << " ";
if (eqp.q >= 0) fout << eqp.sub << " " << eqp.q << " " << eqp.atk << " " << eqp.spd << " " << eqp.crit << " " << eqp.combo << " " << eqp.ls << " " << eqp.rf << " ";
else fout << "-1 -1 0 0 0 0 0 0 ";
for (int i = 0; i < bagN; i++) fout << bag[i].sub << " " << bag[i].q << " " << bag[i].atk << " " << bag[i].spd << " " << bag[i].crit << " " << bag[i].combo << " " << bag[i].ls << " " << bag[i].rf << " ";
fout << endl << gold << " " << ruinsSet.size() << " ";
for (auto it = ruinsSet.begin(); it != ruinsSet.end(); ++it) fout << it->first << " " << it->second << " ";
fout << endl << diffLevel << " " << myColor << " " << enemyColor << " " << pathColor << " " << battleDelay << " " << infoDelay << " " << showBloodBar << endl;
fout.close();
}
bool loadGame(){
char fn[32]; sprintf(fn, "save%d.txt", slot);
ifstream fin(fn);
if(!fin) return false;
string ver;
if (!(fin >> ver)) return false;
if (ver == "V3" || ver == "V2") {
fin >> m >> hp >> mxhp >> pw >> d >> s >> sum >> cnt >> mdao;
if(m < 1 || m > 5 || hp <= 0 || mxhp <= 0){ fin.close(); return false; }
if (ver == "V3") {
if (!(fin >> nuwaSaved)) nuwaSaved = false;
} else {
nuwaSaved = false;
}
achCount = 0;
int nAch = (ver == "V3") ? 30 : 20;
for (int i = 0; i < nAch; i++) { int v = 0; if (!(fin >> v)) v = 0; ach[i] = (v != 0); if (ach[i]) achCount++; }
for (int i = nAch; i < 30; i++) ach[i] = false;
fin >> totalBonus >> totalWin >> winStreak >> noHurtStreak >> totalMove >> zKillCount;
if (ver == "V3") fin >> ruinsVisited;
else ruinsVisited = 0;
// [修复] 读取 bagN 并做范围保护,防止旧存档 bagN=31 越界
int savedBagN = 0;
if (fin >> basePw >> baseD >> baseS >> baseHp >> savedBagN) {
if (savedBagN < 0) savedBagN = 0;
int storeN = (savedBagN > 30) ? 30 : savedBagN;
if (fin >> eqp.sub >> eqp.q >> eqp.atk >> eqp.spd >> eqp.crit >> eqp.combo >> eqp.ls >> eqp.rf) {
for (int i = 0; i < savedBagN; i++) {
Eq tmp;
fin >> tmp.sub >> tmp.q >> tmp.atk >> tmp.spd >> tmp.crit >> tmp.combo >> tmp.ls >> tmp.rf;
if (i < storeN) {
bag[i] = tmp;
for (int j = 0; j < wlibSize; j++) if (wlib[j].sub == bag[i].sub && wlib[j].q == bag[i].q) { bag[i].name = wlib[j].name; break; }
}
}
bagN = storeN;
if (eqp.q >= 0) {
for (int j = 0; j < wlibSize; j++) if (wlib[j].sub == eqp.sub && wlib[j].q == eqp.q) { eqp.name = wlib[j].name; break; }
}
}
} else { basePw = pw; baseD = d; baseS = s; baseHp = mxhp; bagN = 0; eqp.q = -1; }
} else {
m = atoi(ver.c_str());
fin >> hp >> mxhp >> pw >> d >> s >> sum >> cnt >> mdao;
if(m < 1 || m > 5 || hp <= 0 || mxhp <= 0){ fin.close(); return false; }
nuwaSaved = false;
achCount = 0;
for (int i = 0; i < 20; i++) { int v = 0; if (!(fin >> v)) v = 0; ach[i] = (v != 0); if (ach[i]) achCount++; }
for (int i = 20; i < 30; i++) ach[i] = false;
ruinsVisited = 0;
fin >> totalBonus >> totalWin >> winStreak >> noHurtStreak >> totalMove >> zKillCount;
int savedBagN = 0;
if (fin >> basePw >> baseD >> baseS >> baseHp >> savedBagN) {
if (savedBagN < 0) savedBagN = 0;
int storeN = (savedBagN > 30) ? 30 : savedBagN;
if (fin >> eqp.sub >> eqp.q >> eqp.atk >> eqp.spd >> eqp.crit >> eqp.combo >> eqp.ls >> eqp.rf) {
for (int i = 0; i < savedBagN; i++) {
Eq tmp;
fin >> tmp.sub >> tmp.q >> tmp.atk >> tmp.spd >> tmp.crit >> tmp.combo >> tmp.ls >> tmp.rf;
if (i < storeN) {
bag[i] = tmp;
for (int j = 0; j < wlibSize; j++) if (wlib[j].sub == bag[i].sub && wlib[j].q == bag[i].q) { bag[i].name = wlib[j].name; break; }
}
}
bagN = storeN;
if (eqp.q >= 0) {
for (int j = 0; j < wlibSize; j++) if (wlib[j].sub == eqp.sub && wlib[j].q == eqp.q) { eqp.name = wlib[j].name; break; }
}
}
} else { basePw = pw; baseD = d; baseS = s; baseHp = mxhp; bagN = 0; eqp.q = -1; }
}
ruinsSet.clear();
if (fin >> gold) {
int rnum = 0; if (fin >> rnum) {
for (int i = 0; i < rnum; i++) { int rx, ry; fin >> rx >> ry; ruinsSet.insert(make_pair(rx, ry)); }
}
} else gold = 0;
fin >> diffLevel >> myColor >> enemyColor >> pathColor >> battleDelay >> infoDelay >> showBloodBar;
diffMul = (diffLevel==1?0.7:diffLevel==2?1.0:diffLevel==3?1.5:2.5);
zKillCount = 0;
kx = -1; ky = -1;
for(int i=0; i<4; i++) zAlive[i] = false;
if (bagN < 0 || bagN > 30) bagN = 0;
fin.close(); refreshStat();
return true;
}
void peekSlot(int sl){
char fn[32]; sprintf(fn, "save%d.txt", sl);
ifstream fin(fn);
if(!fin){ cout << " 槽位 " << sl << ":空" << endl; return; }
string ver;
if (!(fin >> ver)) { cout << " 槽位 " << sl << ":损坏" << endl; return; }
ll mm, h, mh, p, dd, ss, c, md; double sm;
if (ver == "V3" || ver == "V2") {
fin >> mm >> h >> mh >> p >> dd >> ss >> sm >> c >> md;
} else {
mm = atoi(ver.c_str());
fin >> h >> mh >> p >> dd >> ss >> sm >> c >> md;
}
fin.close();
if(mm < 1 || mm > 5 || h <= 0 || mh <= 0){ cout << " 槽位 " << sl << ":损坏" << endl; return; }
string role = mm==1?"战士":mm==2?"盾兵":mm==3?"治疗兵":mm==4?"生物学家":"隐藏";
cout << " 槽位 " << sl << ":" << role << ",等级 " << (int)sm << ",分数 " << c << ",血量 " << h << "/" << mh << endl;
}
void settings(){
int choice;
while (true) {
fastClear();
cout << "================ 设置 ================" << endl;
cout << " 1. 难度等级:" << (diffLevel==1?"简单":diffLevel==2?"普通":diffLevel==3?"困难":"地狱") << "(倍率 " << diffMul << ")" << endl;
cout << " 2. 自身颜色(@):" << myColor << "\n 3. 敌方颜色:" << enemyColor << "\n 4. BOSS路径颜色:" << pathColor << endl;
cout << " 5. 战斗延迟:" << battleDelay << " ms\n 6. 信息停顿:" << infoDelay << " ms\n 7. 成就图鉴\n 8. 血条可视化:" << (showBloodBar ? "开启" : "关闭") << "\n 0. 返回游戏\n======================================\n请选择(0-8):";
if (!(cin >> choice)) { cin.clear(); cin.ignore(1024, '\n'); continue; }
cin.ignore(1024, '\n');
if (choice == 0) break;
if (choice == 1) {
fastClear(); cout << "难度等级:\n 1. 简单(×0.7)\n 2. 普通(×1.0)\n 3. 困难(×1.5)\n 4. 地狱(×2.5)\n请选择(1-4):";
if (!(cin >> diffLevel)) diffLevel = 2; cin.ignore(1024, '\n');
if (diffLevel < 1) diffLevel = 1; if (diffLevel > 4) diffLevel = 4;
diffMul = (diffLevel==1?0.7:diffLevel==2?1.0:diffLevel==3?1.5:2.5);
} else if (choice == 2) { cout << "输入1-15:"; cin >> myColor; cin.ignore(1024, '\n'); if(myColor<1)myColor=1; if(myColor>15)myColor=15; }
else if (choice == 3) { cout << "输入1-15:"; cin >> enemyColor; cin.ignore(1024, '\n'); if(enemyColor<1)enemyColor=1; if(enemyColor>15)enemyColor=15; }
else if (choice == 4) { cout << "输入1-15:"; cin >> pathColor; cin.ignore(1024, '\n'); if(pathColor<1)pathColor=1; if(pathColor>15)pathColor=15; }
else if (choice == 5) { cout << "输入0-2000:"; cin >> battleDelay; cin.ignore(1024, '\n'); if(battleDelay<0)battleDelay=0; if(battleDelay>2000)battleDelay=2000; }
else if (choice == 6) { cout << "输入0-3000:"; cin >> infoDelay; cin.ignore(1024, '\n'); if(infoDelay<0)infoDelay=0; if(infoDelay>3000)infoDelay=3000; }
else if (choice == 7) showAchBook();
else if (choice == 8) { showBloodBar = !showBloodBar; }
}
}
int tryMingDao() {
if (hp <= 0 && eqp.q == 4 && eqp.sub == 1 && !nuwaSaved) {
nuwaSaved = true;
hp = mxhp;
cout << "\n【造化生机】女娲补天石碎裂,抵挡了致命伤害!你的血量已回满!" << endl;
getch();
return 1;
}
if (mdao && hp <= 0) {
mdao = false; unlockAch(5);
cout << "\n名刀·司命触发!是否继续战斗?1继续 2退出战斗" << endl;
char ch; do { ch = getch(); } while (ch != '1' && ch != '2');
cout << ch << endl; hp = (ll)ceil(mxhp * 0.25); if (hp < 1) hp = 1;
if (ch == '2') { unlockAch(18); winStreak = 0; noHurtStreak = 0; return 2; }
cout << "以 " << hp << " 点血量复活!" << endl; getch(); return 1;
}
return 0;
}
long long healAmount(long long base) { if (m == 3 && int(sum) >= 10) return (long long)ceil(base * 1.2); return base; }
void up(int g_s){
int g = rand()%55+1; int f = rand()%4+1;
cout << "已开始抽取加成,按任意键抽取"<<endl; getch();
if(g<=1)g=10; else if(g<=3)g=9; else if(g<=6)g=8; else if(g<=10)g=7; else if(g<=15)g=6;
else if(g<=21)g=5; else if(g<=28)g=4; else if(g<=36)g=3; else if(g<=45)g=2; else g=1;
int SUM = sum;
if(f==1)cout << "生命增加"<<SUM*2*g<<endl; else if(f==2)cout << "攻击力增加"<<ceil(SUM*g*0.6)<<endl;
else if(f==3)cout << "防御增加"<<ceil(SUM*g*0.8)<<endl; else cout << "移速增加"<<SUM*g<<endl;
if(f==1) { long long add = healAmount(SUM*2*g); baseHp += add; }
else if(f==2) basePw += ceil(SUM*g*0.6); else if(f==3) baseD += ceil(SUM*g*0.8); else baseS += SUM*g;
if(g_s) { baseHp += healAmount(2*pow(sum,1.5)); basePw += ceil(pow(sum,1.5)/1.8); baseD += pow(sum,1.5)/1.6; baseS += pow(sum,1.5)/1.4; }
refreshStat(); hp = mxhp; getch();
}
void spawnZ(int idx){
int bx, by, tries = 0; bool ok;
do {
bx = n/2 + (rand()%801) - 400; by = n/2 + (rand()%801) - 400; tries++; ok = true;
if (bx<1||bx>n||by<1||by>n||abs(bx-n/2)+abs(by-n/2)>400||abs(bx-n/2)+abs(by-n/2)<30) ok = false;
if (kx != -1 && abs(bx-kx) + abs(by-ky) < 30) ok = false;
for (int i = 0; i < 4; i++) { if (i == idx || !zAlive[i]) continue; if (abs(bx-zx[i]) + abs(by-zy[i]) < 30) ok = false; }
} while (!ok && tries < 2000);
if (!ok) { bx = n/2 + 50 + idx * 40; by = n/2 + 50 + idx * 40; }
for (int ii = bx - 4; ii <= bx + 4; ii++) for (int jj = by - 4; jj <= by + 4; jj++) {
if (ii<1||ii>n||jj<1||jj>n||(ii==n/2&&jj==n/2)||mp[ii][jj]=='@'||mp[ii][jj]=='K') continue; mp[ii][jj] = '.';
}
mp[bx][by] = 'Z'; zx[idx] = bx; zy[idx] = by; zAlive[idx] = true;
}
void spawnAllZ(){ for (int i = 0; i < 4; i++) zAlive[i] = false; int needZ = 4 - zKillCount; for (int i = 0; i < needZ; i++) spawnZ(i); }
void win(char co, ll hh, long long gp, long long gd, long long gs){
cout << "你赢了"<<endl << "汲取了敌人的血量:"<<hh<<"*40%="<<(int)(hh*0.4)<<endl;
hp += healAmount(hh * 0.4); if(hp>mxhp)hp = mxhp;
if (int(sum) >= 5) {
if (m == 1) basePw += gp * 0.1; else if (m == 2) baseD += gd * 0.1;
else if (m == 3) baseS += gs * 0.1; else if (m == 4) baseHp += healAmount(hh * 0.1);
refreshStat();
}
ll dropMoney = num * 5 + rand() % (num * 10 + 1);
gold += dropMoney;
cout << "获得了 " << dropMoney << " 金币!" << endl;
if (gold >= 100000) unlockAch(21);
int _ = sum;
if(co=='C')sum+=1.0/pow(sum,1.25)*num*0.5; if(co=='B')sum+=1.0/pow(sum,1.25)*num*1;
if(co=='A')sum+=1.0/pow(sum,1.25)*num*5; if(co=='S')sum+=1.0/pow(sum,1.25)*num*10;
if(co=='X')sum+=1.0/pow(sum,1.25)*num*20; if(co=='Z')sum+=1.0/pow(sum,1.25)*num*30;
if(co=='K')sum+=1.0/pow(sum,1.25)*num*40;
cnt++; totalWin++; winStreak++;
if (cnt >= 5000) unlockAch(23);
if (winStreak >= 100) unlockAch(15);
if (!battleHurt) { noHurtStreak++; if (noHurtStreak >= 10) unlockAch(12); } else noHurtStreak = 0;
if (int(sum) - _ >= 5) unlockAch(17);
int dr = (co=='K') ? 100 : (co=='Z') ? 80 : (co=='X') ? 30 : (co=='S') ? 15 : 5;
if (rand() % 100 < dr) {
int fq = -1;
int mythicChance = 0;
if (co == 'K') mythicChance = 5;
else if (co == 'Z') mythicChance = 3;
else if (co == 'X') mythicChance = 1;
if (rand() % 100 < mythicChance) fq = 4;
else {
if (co == 'K') fq = 3;
else if (co == 'Z') fq = (rand()%10 < 5) ? 3 : 2;
else if (co == 'X') fq = (rand()%10 < 5) ? 3 : 2;
}
Eq e = genWeapon((int)sum, fq);
if (bagN < 30) {
bag[bagN++] = e;
if (bagN >= 30) unlockAch(22);
if (e.q >= 3) showWeaponDisplay(e, "爆出传说/神话神兵!");
else { cout << "★★★ 掉落武器:"; showEqName(e.q, e.name); cout << "(按 B 查看背包)" << endl; getch(); }
}
}
if(co=='Z'){
for (int i = 0; i < 4; i++) if (zAlive[i] && zx[i] == x && zy[i] == y) { zAlive[i] = false; zKillCount++; break; }
cout << endl << "亲卫已被击败!剩余:" << (4 - zKillCount) << " / 4" << endl;
if (zKillCount >= 4) cout << "【全部亲卫已击败!BOSS K 的位置已解锁】" << endl;
}
if(co=='K'){
cout << "======= 击败 BOSS!获得巨额经验! =======" << endl;
unlockAch(4); if (m == 5) unlockAch(13); if (diffLevel == 4) unlockAch(14);
kx = -1; ky = -1; pathSet.clear();
if (rand() % 10 == 0) {
int dxs[4] = {-1, 1, 0, 0};
int dys[4] = {0, 0, -1, 1};
int rx = -1, ry = -1;
for (int di = 0; di < 4; di++) {
int nx = x + dxs[di], ny = y + dys[di];
if (nx >= 1 && nx <= n && ny >= 1 && ny <= n &&
mp[nx][ny] != '@' && mp[nx][ny] != 'K' && mp[nx][ny] != '#') {
rx = nx; ry = ny; break;
}
}
if (rx != -1) {
mp[rx][ry] = '#';
ruinsSet.insert(make_pair(rx, ry));
cout << "※ BOSS 陨落之地,浮现出了一座【上古遗址】!(按任意键继续)" << endl; getch();
}
}
}
if (cnt >= 10) unlockAch(19);
if (cnt >= 100) unlockAch(0); if (cnt >= 500) unlockAch(1); if (cnt >= 1000) unlockAch(2);
if (int(sum) >= 50) unlockAch(6); if (int(sum) >= 100) unlockAch(7);
if (int(sum) >= 200) unlockAch(28);
getch();
if(int(sum)>_){ cout << "恭喜你从"<<_<<"级升到了"<<int(sum)<<"级" << endl; cout << "你可以抽取"<<int(sum)-_<<"次奖励" << endl; for(int i=1;i<=int(sum)-_;i++) up(1); }
if (int(sum) >= 50 && _ < 50 && !bossHinted) {
bossHinted = true;
if (kx == -1) {
int bx, by, tries = 0;
do { bx = x + (rand() % 401) - 200; by = y + (rand() % 401) - 200; tries++; } while ((bx < 1 || bx > n || by < 1 || by > n || abs(bx - x) + abs(by - y) < 100) && tries < 1000);
if (bx<1||bx>n||by<1||by>n) { bx = n/2+150; by = n/2+150; }
for (int i = bx - 4; i <= bx + 4; i++) for (int j = by - 4; j <= by + 4; j++) { if (i<1||i>n||j<1||j>n||(i==x&&j==y)) continue; mp[i][j] = '.'; }
mp[bx][by] = 'K'; kx = bx; ky = by; zKillCount = 0; spawnAllZ();
}
fastClear(); vector<string> chars = {"你","的","力","量","足","够","了",",","去","找","那","个","神","吧",".",".","."," ","(","按","下","C","键","指","引",")"};
for (size_t ci = 0; ci < chars.size(); ci++) { cout << chars[ci]; Sleep(80); }
cout << endl << "按任意键继续..." << endl; getch(); draw();
}
}
void init(){
int cx=rand()%n+1,cy = rand()%n+1; x = y = n/2;
ruinsSet.clear();
for(int i=0;i<=n+1;i++) for(int j=0;j<=n+1;j++){
if(i<1 or i>n or j<1 or j>n){ mp[i][j] = '#'; continue; }
if(i==cx and j==cy){ mp[i][j] = '$'; continue; }
if(i==n/2 and j==n/2){ mp[i][j] = '@'; continue; }
int num = rand()%128+1;
if(num>=64)mp[i][j] = '.'; else if(num>=32)mp[i][j] = 'C'; else if(num>=16)mp[i][j] = 'B';
else if(num>=8)mp[i][j] = 'A'; else if(num>=4)mp[i][j] = '$'; else if(num>=2)mp[i][j] = 'S'; else mp[i][j] = 'X';
}
mp[1][1] = '#'; mp[1][n] = '#'; mp[n][1] = '#'; mp[n][n] = '#';
if ((ll)sum >= 50) {
int bx, by, tries = 0;
do { bx = x + (rand() % 401) - 200; by = y + (rand() % 401) - 200; tries++; } while ((bx < 1 || bx > n || by < 1 || by > n || abs(bx - x) + abs(by - y) < 100) && tries < 1000);
if (bx<1||bx>n||by<1||by>n) { bx = n/2+150; by = n/2+150; }
for (int i = bx - 4; i <= bx + 4; i++) for (int j = by - 4; j <= by + 4; j++) { if (i<1||i>n||j<1||j>n||(i==n/2&&j==n/2)) continue; mp[i][j] = '.'; }
mp[bx][by] = 'K'; kx = bx; ky = by; spawnAllZ();
}
}
void calcPath(){
int tx = -1, ty = -1;
int aliveZ = 0;
for(int i=0; i<4; i++) if(zAlive[i]) aliveZ++;
if (aliveZ > 0) {
int best = 2000000000;
for (int i = 0; i < 4; i++) {
if (!zAlive[i]) continue;
int dist = abs(x - zx[i]) + abs(y - zy[i]);
if (dist < best) { best = dist; tx = zx[i]; ty = zy[i]; }
}
} else if (kx != -1) { tx = kx; ty = ky; }
if (tx == -1) return;
pathSet.clear(); int cx = x, cy = y;
while (cx != tx) { if (cx < tx) cx++; else cx--; pathSet.insert(make_pair(cx, cy)); }
while (cy != ty) { if (cy < ty) cy++; else cy--; pathSet.insert(make_pair(cx, cy)); }
pathSet.erase(make_pair(x, y)); pathSet.erase(make_pair(tx, ty));
}
void redText(string s){ SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY); cout << s << endl; SetConsoleTextAttribute(hConsole, 7); }
void draw(){
fastClear();
for(int i=x-cs/2;i<=x+cs/2;i++){
for(int j=y-cs/2;j<=y+cs/2;j++){
if(i<0 or j<0 or i>N+1 or j>N+1){ cout << " "; }
else if(mp[i][j] == '@'){ SetConsoleTextAttribute(hConsole, myColor); cout << mp[i][j] << " "; SetConsoleTextAttribute(hConsole, 7); }
else if(pathSet.count(make_pair(i, j))){ SetConsoleTextAttribute(hConsole, pathColor); cout << mp[i][j] << " "; SetConsoleTextAttribute(hConsole, 7); }
else if(mp[i][j]=='C'||mp[i][j]=='B'||mp[i][j]=='A'||mp[i][j]=='S'||mp[i][j]=='X'||mp[i][j]=='K'||mp[i][j]=='Z'){
SetConsoleTextAttribute(hConsole, enemyColor); cout << mp[i][j] << " "; SetConsoleTextAttribute(hConsole, 7);
} else { cout << mp[i][j] << " "; }
}
cout << endl;
}
cout << endl;
num = (abs(x-n/2)+abs(y-n/2))/6+1;
printHP();
cout << "攻击力:"<<pw<<endl << "防御力:"<<d<<endl << "速度:"<<s<<endl;
cout << "当前等级:"<<(int)sum<<endl << "怪物等级:"<<num<<endl;
long long lv = (long long)sum; long long need = 48 + (lv - 1) * 12;
if (need < 1) need = 48; long long cur = (long long)round((sum - lv) * need);
if (cur < 0) cur = 0; if (cur > need) cur = need;
cout << "当前经验:" << cur << "/" << need << endl << "当前分数:" << cnt << endl;
cout << "当前模式:" << (autoBattle ? "自动(按Tab切换)" : "手动(按Tab切换)") << endl << "当前槽位:save" << slot << ".txt" << endl;
cout << "当前金币:" << gold << " G" << endl;
cout << "难度:" << (diffLevel==1?"简单":diffLevel==2?"普通":diffLevel==3?"困难":"地狱") << endl;
cout << "成就:" << achCount << " / 30 连胜:" << winStreak << " 无伤:" << noHurtStreak << endl;
cout << "当前武器:"; if (eqp.q < 0) cout << "空手" << endl; else { showEqName(eqp.q, eqp.name); cout << "(按 B 打开背包)" << endl; }
if (kx != -1) {
int aliveZ = 0;
for (int i = 0; i < 4; i++) if (zAlive[i]) aliveZ++;
if (aliveZ > 0) {
int best = 2000000000;
for (int i = 0; i < 4; i++) if (zAlive[i]) best = min(best, abs(x - zx[i]) + abs(y - zy[i]));
cout << "剩余亲卫:" << aliveZ << " / 4 最近距离:" << best << "(按 C 追踪)" << endl;
} else cout << "与“K”的距离:" << abs(x-kx)+abs(y-ky) << "(按 C 追踪)" << endl;
}
}
bool move(int dx,int dy){
mp[x][y] = '.'; x += dx; y += dy;
totalMove++; if (totalMove >= 10000) unlockAch(16);
if (totalMove >= 50000) unlockAch(27);
battleHurt = false; stunRound = 0;
char co = mp[x][y]; mp[x][y] = '@';
num = (abs(x-n/2)+abs(y-n/2))/6+1; if(num<=0)num = 1;
if(co=='O')return 2;
if(co=='#'){
bool isCorner = ((x==1&&y==1) || (x==1&&y==n) || (x==n&&y==1) || (x==n&&y==n));
bool isRuins = (ruinsSet.count(make_pair(x, y)) > 0);
if (isRuins) {
fastClear(); cout << "你踏入了【上古遗址】..." << endl; Sleep(1000);
ruinsVisited++;
if (ruinsVisited >= 3) unlockAch(25);
if (rand() % 100 < 10) {
Eq e = genWeapon((int)sum, 4);
showWeaponDisplay(e, "上古遗址出世!");
if (bagN < 30) bag[bagN++] = e; else cout << "背包已满,神兵遗失!" << endl;
} else {
ll mny = 5000 + rand() % 5000;
gold += mny; if (gold >= 100000) unlockAch(21);
cout << "你在遗迹深处发现了大量金币:" << mny << " G!" << endl;
}
ruinsSet.erase(make_pair(x, y)); mp[x][y] = '.'; getch(); return 1;
}
else if (isCorner) {
fastClear(); cout << "你来到了世界的尽头【边境之地】..." << endl; Sleep(1000);
unlockAch(24);
cout << "你打开了尘封的宝箱!" << endl; ll mny = 10000; gold += mny;
if (gold >= 100000) unlockAch(21);
cout << "获得了 " << mny << " G!" << endl;
Eq e = genWeapon((int)sum, 4); showWeaponDisplay(e, "边境宝箱开启");
if (bagN < 30) bag[bagN++] = e; else cout << "背包已满,武器遗失!" << endl;
if (bagN >= 30) unlockAch(22);
mp[x][y] = '.'; getch(); return 1;
}
mp[x][y] = '#'; x-=dx; y-=dy; mp[x][y] = '@'; return 1;
}
draw();
long long gh,gp,gd,gs;
ll lv = (ll)sum; ll k = (ll)(lv * num * diffMul); if(k < 1) k = 1;
if(co=='.')return 1;
else if(co=='C'){ gh = k * r(2, 5); gp = k * r(1, 2); gd = k * r(1, 1); gs = k * r(1, 2); }
else if(co=='B'){ gh = k * r(8, 15); gp = k * r(2, 4); gd = k * r(1, 2); gs = k * r(2, 3); }
else if(co=='A'){ gh = k * r(20, 40); gp = k * r(4, 8); gd = k * r(2, 4); gs = k * r(3, 5); }
else if(co=='S'){ gh = k * r(40, 80); gp = k * r(6, 12); gd = k * r(3, 6); gs = k * r(5, 10); }
else if(co=='X'){ gh = k * r(80, 150); gp = k * r(10, 18); gd = k * r(5, 10); gs = k * r(8, 15); }
else if(co=='Z'){
double zmul = (1.0 + diffMul) / 2.0;
gh = (ll)(mxhp * r(10, 20) * zmul); gp = (ll)(d * r(80, 100) / 100.0 * zmul);
gd = (ll)(d * r(30, 60) / 100.0 * zmul); gs = (ll)(s * r(70, 110) / 100.0 * zmul);
}
else if(co=='K'){
int aliveZ = 0;
for(int i=0; i<4; i++) if(zAlive[i]) aliveZ++;
if (aliveZ > 0) {
fastClear(); vector<string> chars = {"你","还","不","够","格"};
for (size_t ci = 0; ci < chars.size(); ci++) { cout << chars[ci]; Sleep(200); }
cout << endl; Sleep(1200); cout << "先击败剩余的 " << aliveZ << " 个亲卫 Z 吧..." << endl; Sleep(800);
mp[x][y] = co; x -= dx; y -= dy; mp[x][y] = '@'; draw(); return 1;
}
double bossMul = (1.0 + diffMul) / 2.0;
gh = (ll)(mxhp * r(30, 45) * bossMul); gp = (ll)(d * r(105, 115) / 100.0 * bossMul);
gd = (ll)(d * r(50, 80) / 100.0 * bossMul); gs = (ll)(s * r(80, 120) / 100.0 * bossMul);
}
else if(co=='$'){
up(0); totalBonus++; if (totalBonus >= 10) unlockAch(10);
int luck = rand() % 100;
if (luck < 10) {
cout << "【补给点】你发现了一个尘封的武器箱!" << endl;
int fq = -1;
if (rand() % 1000 < 2) fq = 4;
Eq e = genWeapon((int)sum, fq);
if (bagN < 30) {
bag[bagN++] = e; cout << "获得装备:"; showEqName(e.q, e.name); cout << "(按B查看)" << endl;
if (bagN >= 30) unlockAch(22);
if (e.q == 4) unlockAch(26);
if (e.q == 4) unlockAch(20);
} else cout << "但背包已满,无法带走..." << endl;
getch();
} else if (luck < 30) {
ll mny = 100 + rand() % 300;
gold += mny; if (gold >= 100000) unlockAch(21);
cout << "【补给点】你搜刮到了物资,换取金币:" << mny << " G" << endl; getch();
}
if(rand()%2==0){
double add = 0.5 / pow(sum, 1.25) * num; ll lv0 = (ll)sum;
ll need0 = 48 + (lv0 - 1) * 12; if (need0 < 1) need0 = 48;
ll gain = (ll)ceil(add * need0); if (gain < 1) gain = 1;
sum += (double)gain / need0; cout << "获得少量经验:" << gain << endl;
int _ = lv0; if(int(sum)>_){ cout << "恭喜你从"<<_<<"级升到了"<<int(sum)<<"级"<<endl; if (int(sum) >= 200) unlockAch(28); for(int i=1;i<=int(sum)-_;i++)up(1); }
}
return 1;
}
cout << endl;
if(co=='K') cout << "================ 最终 BOSS ================\n 代号:K\n============================================" << endl;
else if(co=='Z') cout << "=============== 亲卫 ===============\n 代号:Z\n 剩余:" << (4-zKillCount) << " / 4\n====================================" << endl;
else cout << "对方是"<<co<<"级怪"<<endl;
cout << "对方实力:" << endl << "血量:"<<gh<<endl << "攻击力:"<<gp<<endl << "防御力:"<<gd<<endl << "速度:"<<gs<<endl;
if(co=='K') cout << "技能:每3回合最大血量10%真伤\n技能:每5回合攻击翻倍" << endl;
cout << endl << "我方实力:" << endl;
printHP();
cout << "攻击力:"<<pw<<endl << "防御力:"<<d<<endl << "速度:"<<s<<endl<<endl;
Sleep(infoDelay);
int dominate = 0;
if (hp > gh * 5) dominate++; if (pw > gp * 5) dominate++; if (d > gd * 5) dominate++; if (s > gs * 5) dominate++;
if (dominate >= 2) { cout << endl << "【碾压】我方实力远超敌人,直接判胜!" << endl; getch(); win(co, gh, gp, gd, gs); draw(); return 1; }
int cntHigher = 0; if (gh > hp) cntHigher++; if (gp > pw) cntHigher++; if (gd > d) cntHigher++; if (gs > s) cntHigher++;
bool needAsk = (num > (long long)sum) || (cntHigher >= 2) || (co=='K') || (co=='Z');
if (needAsk) {
cout << "是否挑战?挑战输入1,不挑战输入2" << endl;
char choice; do { choice = getch(); } while (choice != '1' && choice != '2'); cout << choice << endl;
if (choice == '2') { mp[x][y] = co; x -= dx; y -= dy; mp[x][y] = '@'; draw(); return 1; }
}
ll hh = gh;
int ds = 0, ms = battleDelay, poison = 0, round = 0, comboTotal = 0;
ll effS = s + ((eqp.q == 3 && eqp.sub == 3) ? 999999LL : 0);
if(gs > effS){
cout << "敌方移速更高" << endl;
if(!autoBattle){ cout << "(按回车继续,按 Tab 切换模式)" << endl; char c0 = getch(); if(c0 == '\t') autoBattle = !autoBattle; }
cout << endl;
if(m==2 and rand()%100>60){
cout << "盾兵被动触发,免疫这次伤害!" << endl;
ll reflect = max(gp * 3 / 10, d * 2 / 10);
if (reflect < 1) reflect = 1;
cout << "【反震】对敌人造成 " << reflect << " 点真实伤害!" << endl;
gh -= reflect;
cout << "他还剩" << gh << "点血" << endl;
if(gh<=0){ win(co,hh,gp,gd,gs); draw(); return 1; }
}
else { cout << "他对你造成了"<<(d>=gp?1:gp-d)<<"点伤害"<<endl; hp -= (d>=gp?1:gp-d); battleHurt = true; cout << "你还剩"<<hp<<"点血"<<endl; }
if(m==3){ long long heal = healAmount(ceil(0.1*mxhp)); cout << "回复了"<<heal<<"点生命值"<<endl; hp += heal; hp = min(hp,mxhp); }
Sleep(ms); cout << endl;
if(hp<=0){
int mr = tryMingDao();
if (mr == 1) { battleHurt = true; } else if (mr == 2) { mp[x][y] = co; x -= dx; y -= dy; mp[x][y] = '@'; draw(); return 1; }
else { cout << "你输了"; flag = 0; getch(); return 0; }
}
}else cout << "我方移速更高" << endl;
while(true){
round++; cout << endl << "--------- 第 " << round << " 轮 ---------" << endl << endl;
if(gs>50)ms=0; Sleep(ms);
if (eqp.q == 4 && eqp.sub == 6) { ll st = gp/10; pw += st; gp -= st; cout << "【神农鼎】吸取敌人10%攻击力!\n"; }
if (eqp.q == 3 && eqp.sub == 8) { ll add = basePw / 10; pw += add; cout << "【霸王本色】攻击力提升 " << add << "!\n"; }
double comboChance = 0.2 + eqCombo / 100.0;
if (eqp.q == 3 && eqp.sub == 2) comboChance = 1.0;
if (eqp.q == 3 && eqp.sub == 7) comboChance = 1.0;
bool comboActive = (m == 1 && int(sum) >= 10);
while (true) {
int pp = 0;
ll curGd = gd;
if (eqp.q == 4 && eqp.sub == 0) curGd = 0;
if (eqp.q == 4 && eqp.sub == 7 && gh > hh / 2) curGd = 0;
if (eqp.q >= 3 && eqp.sub == 5) curGd = gd / 2;
if (eqp.q == 3 && eqp.sub == 7) curGd = gd * 7 / 10;
if (eqp.q == 4 && eqp.sub == 4) curGd = gd * 8 / 10;
if (curGd < 0) curGd = 0;
long long baseDmg = (curGd >= pw ? 1 : pw - curGd);
if (eqp.q == 3 && eqp.sub == 3 && gh == hh) baseDmg *= 2;
if (eqp.q == 4 && eqp.sub == 7 && gh > hh / 2) baseDmg *= 2;
bool crit = false;
int critRate = 60 + eqCrit;
if (eqp.q == 4 && eqp.sub == 3 && gh == hh) {
baseDmg *= 2;
critRate = 100;
}
if (eqp.q == 3 && eqp.sub == 0) critRate += 20;
if (eqp.q == 4 && eqp.sub == 8) critRate = 100;
if (m == 1 && rand() % 100 < critRate) {
crit = true;
if (eqp.q == 4 && eqp.sub == 5) baseDmg = baseDmg * 35 / 10;
else if (eqp.q == 3 && eqp.sub == 5) baseDmg = baseDmg * 25 / 10;
else baseDmg *= 2;
}
long long extraDmg = 0; if (m == 2 && int(sum) >= 10) extraDmg = d * 0.1;
if(m==4 && rand()%100 < 30 && !ds){ ds = 2; long long poisonDmg = pw * 0.4; cout << "生物学家被动触发!造成" << baseDmg << "+" << poisonDmg << "点伤害" << endl; pp = poisonDmg; poison += 1; }
else if(ds){ long long poisonDmg = pw * 0.4; cout << "你对他造成了" << baseDmg << "+" << poisonDmg << "点伤害" << endl; pp = poisonDmg; ds--; }
else { if (crit) cout << "暴击!"; cout << "你对他造成了" << baseDmg; if (extraDmg > 0) cout << "+" << extraDmg << "(以守为攻)"; if (pp > 0) cout << "+" << pp << "(毒)"; cout << "点伤害" << endl; }
if (m == 4 && int(sum) >= 10) poison += 1;
long long totalDmg = baseDmg + extraDmg + pp; gh -= totalDmg;
if (eqp.q == 4 && eqp.sub == 3 && gh <= 0) {
ll overflow = -gh;
hp += overflow;
if(hp > mxhp) hp = mxhp;
cout << "【屠戮天下】溢出伤害转化为生命,回复 " << overflow << " 点血!" << endl;
}
if (m == 4 && int(sum) >= 10 && poison >= 3) {
long long boom = pw * 1.5 + hh * 0.1;
cout << "毒素爆炸!造成" << boom << "点真实伤害" << endl;
gh -= boom;
poison = 0;
}
if (eqp.q >= 3) {
ll trueDmg = 0;
if (eqp.q == 3 && eqp.sub == 0 && crit) trueDmg += pw * 2 / 10;
if (eqp.q == 3 && eqp.sub == 4 && rand() % 100 < 30) { stunRound = 1; cout << "【降妖除魔】敌人被降魔杵震慑,陷入眩晕!\n"; }
if (eqp.q == 3 && eqp.sub == 6 && rand() % 100 < 30) { trueDmg += pw / 2; cout << "【天雷引】天雷滚滚!额外造成真实伤害!\n"; }
if (eqp.q == 4 && eqp.sub == 0) trueDmg += mxhp / 10;
if (eqp.q == 4 && eqp.sub == 2) {
trueDmg += d;
if (rand() % 100 < 30) {
stunRound = 1;
cout << "【混沌镇压】东皇钟响,敌人被震晕了!\n";
} else cout << "【混沌镇压】东皇钟响,震碎敌人护甲!\n";
}
if (eqp.q == 4 && eqp.sub == 4) { trueDmg += pw; gd = gd * 8 / 10; cout << "【不周镇压】降防并造成真伤!\n"; }
if (eqp.q == 4 && eqp.sub == 8 && crit) { ll st = gs/10; s += st; gs -= st; }
if (trueDmg > 0) { gh -= trueDmg; cout << "【神兵真伤】造成 " << trueDmg << " 点真实伤害!" << endl; }
}
cout << "他还剩" << gh << "点血" << endl;
if(gh<=0){
if (round == 1) unlockAch(11); if (hp * 20 <= mxhp) unlockAch(9);
if (comboTotal >= 5) unlockAch(8); if (round >= 30 && hp * 2 >= mxhp) unlockAch(3);
win(co,hh,gp,gd,gs); draw(); return 1;
}
if (comboActive && rand() % 100 < comboChance * 100) {
cout << "连击触发!" << endl; comboTotal++; if (comboTotal >= 5) unlockAch(8);
comboChance -= 0.02; if (comboChance < 0) comboChance = 0; continue;
} else break;
}
if(co=='K' && round % 3 == 0){
ll bd = mxhp / 20; if (bd < 1) bd = 1;
cout << "【BOSS 技能】真实打击!造成 " << bd << " 点真实伤害" << endl; hp -= bd; battleHurt = true; cout << "你还剩 " << hp << " 点血" << endl;
if(hp<=0){ int mr = tryMingDao(); if (mr == 1) { battleHurt = true; } else if (mr == 2) { mp[x][y] = co; x -= dx; y -= dy; mp[x][y] = '@'; draw(); return 1; } else { cout << "你输了"; getch(); flag = 0; return 0; } }
}
ll egp = gp;
if(co=='K' && round % 5 == 0){ egp = gp * 2; cout << "【BOSS 技能】蓄力猛击!本回合攻击力翻倍!" << endl; }
if (stunRound > 0) { stunRound--; cout << "敌人处于眩晕状态,无法行动!" << endl; }
else {
if(m==2 and rand()%100>60){
cout << "盾兵被动触发,免疫这次伤害!" << endl;
ll reflect = max(egp * 3 / 10, d * 2 / 10);
if (reflect < 1) reflect = 1;
cout << "【反震】对敌人造成 " << reflect << " 点真实伤害!" << endl;
gh -= reflect;
cout << "他还剩" << gh << "点血" << endl;
if(gh<=0){
if (round >= 30 && hp * 2 >= mxhp) unlockAch(3);
win(co,hh,gp,gd,gs); draw(); return 1;
}
}
else { cout << "他对你造成了"<<(d>=egp?1:egp-d)<<"点伤害"<<endl; hp -= (d>=egp?1:egp-d); battleHurt = true; cout << "你还剩"<<hp<<"点血"<<endl; }
}
if(m==3){ long long heal = healAmount(ceil(0.1*mxhp)); cout << "回复了"<<heal<<"点生命值"<<endl; hp += heal; hp = min(hp,mxhp); }
if (eqp.q == 4 && eqp.sub == 1) { ll heal = mxhp / 10; hp += heal; if(hp>mxhp)hp=mxhp; cout << "【造化生机】每回合回复 " << heal << " 生命!\n"; }
if(hp<=0){
int mr = tryMingDao();
if (mr == 1) { battleHurt = true; } else if (mr == 2) { mp[x][y] = co; x -= dx; y -= dy; mp[x][y] = '@'; draw(); return 1; }
else { cout << "你输了"; getch(); flag = 0; return 0; }
}
if(!autoBattle){
cout << "(按回车继续,按 Tab 切换模式)" << endl;
char c1 = getch();
if(c1 == '\t') autoBattle = !autoBattle;
}
cout << endl;
}
}
void showIntro() {
fastClear();
cout << "\n==============================================" << endl;
cout << " 《 寻 锋 录 》 " << endl;
cout << " —— 地牢探险 —— " << endl;
cout << "==============================================" << endl;
cout << " 传闻在一座深不见底的古代地牢中,埋藏着无数" << endl;
cout << " 失传的神兵利器。" << endl;
cout << " 从“生锈的铁剑”到“轩辕夏禹剑”," << endl;
cout << " 从普通的凡铁到传说中的创世神器。" << endl;
cout << endl;
cout << " 你,一名初出茅庐的冒险者," << endl;
cout << " 为了寻找那把属于自己的“锋芒”," << endl;
cout << " 毅然踏入了这座危机四伏的地牢。" << endl;
cout << endl;
cout << " 在这里,有凶猛的怪物、神秘的上古遗址、" << endl;
cout << " 以及世界尽头的“边境之地”。" << endl;
cout << " 击败最终的 BOSS「K」,证明你的实力吧!" << endl;
cout << "==============================================" << endl;
cout << "按任意键返回主菜单..." << endl;
getch();
}
void showManual() {
fastClear();
cout << "\n================= 游 戏 说 明 =================" << endl;
cout << "【基本操作】" << endl;
cout << " W / A / S / D :在地图上移动(每走一步自动存档)" << endl;
cout << " Tab :切换手动 / 自动战斗模式" << endl;
cout << " C :追踪 BOSS「K」或亲卫「Z」" << endl;
cout << " B :打开武器背包(查看/佩戴/丢弃)" << endl;
cout << " H :查看成就图鉴" << endl;
cout << " M :系统设置" << endl;
cout << endl;
cout << "【游戏机制】" << endl;
cout << " 1. 地图分五个危险等级,离中心越远怪物越强。" << endl;
cout << " 2. 击杀怪物会掉落装备和金币,金币目前用于计数。" << endl;
cout << " 3. 角色达到 50 级后,会刷出 BOSS K 和 4 个亲卫 Z。" << endl;
cout << " 必须击败所有亲卫,才能挑战 BOSS K。" << endl;
cout << " 4. 寻找地图边缘的「边境之地」,必得神话武器。" << endl;
cout << " 5. 击败 BOSS K 后,有概率出现「上古遗址」。" << endl;
cout << endl;
cout << "【职业介绍】" << endl;
cout << " 战士:暴击率高,10级解锁连击,一回合多次攻击。" << endl;
cout << " 盾兵:概率免伤并反弹真实伤害,防御越高反伤越高。" << endl;
cout << " 治疗兵:受击回血,续航无敌,10级回血增加20%。" << endl;
cout << " 生物学家:叠毒爆炸,造成真实伤害,无视防御。" << endl;
cout << endl;
cout << "【物品品质】" << endl;
cout << " 白(普通) < 蓝(稀有) < 紫(史诗) < 金(传说) < 彩(神话)" << endl;
cout << "==============================================" << endl;
cout << "按任意键返回主菜单..." << endl;
getch();
}
int main(){
srand(time(0));
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
bool loaded = false;
eqp.q = -1; refreshStat();
while (true) {
fastClear();
cout << "==============================================" << endl;
cout << " 《 寻 锋 录 》 " << endl;
cout << " —— 地牢探险 —— " << endl;
cout << "==============================================" << endl;
cout << " 1. 踏入地牢(新游戏) " << endl;
cout << " 2. 读取存档(继续探索) " << endl;
cout << " 3. 游戏介绍 " << endl;
cout << " 4. 操作说明书 " << endl;
cout << " 0. 退出游戏 " << endl;
cout << "==============================================" << endl;
cout << "请选择(0-4):";
int menuCh;
cin >> menuCh;
cin.ignore(1024, '\n');
if (menuCh == 0) return 0;
if (menuCh == 3) { showIntro(); continue; }
if (menuCh == 4) { showManual(); continue; }
if (menuCh == 2) {
cout << "=========== 存档列表 ===========" << endl;
peekSlot(1); peekSlot(2); peekSlot(3);
cout << "================================" << endl << "选择要读取的槽位(1-3):" << endl;
while(true){ cin >> slot; cin.ignore(1024, '\n'); if(slot >= 1 && slot <= 3) break; cout << "无效,请输入 1-3:" << endl; }
loaded = loadGame();
if(loaded){
if (int(sum) >= 50) bossHinted = true;
zKillCount = 0;
fastClear();
cout << "==============================================" << endl;
cout << " 读取成功,角色已创建! " << endl;
cout << "----------------------------------------------" << endl;
string roleName = m==1?"战士":m==2?"盾兵":m==3?"治疗兵":m==4?"生物学家":"隐藏角色";
cout << " 职业:" << roleName << endl;
cout << " 等级:" << (int)sum << " 级" << endl;
cout << " 血量:" << hp << " / " << mxhp << endl;
cout << " 攻击:" << pw << " 防御:" << d << " 速度:" << s << endl;
cout << " 金币:" << gold << " G" << endl;
cout << " 武器:";
if (eqp.q < 0) cout << "空手" << endl; else { showEqName(eqp.q, eqp.name); cout << endl; }
cout << "==============================================" << endl;
cout << "按任意键进入地图(每走一步自动存档)..." << endl;
getch();
fastClear();
break;
}
else { cout << "该槽位没有存档或已损坏,按任意键返回主菜单" << endl; getch(); continue; }
} else if (menuCh == 1) {
loaded = false;
cout << "选择要保存到的槽位(1-3):" << endl;
while(true){ cin >> slot; cin.ignore(1024, '\n'); if(slot >= 1 && slot <= 3) break; cout << "无效,请输入 1-3:" << endl; }
break;
}
}
if(!loaded){
cout << "请选择你的角色"<<endl;
cout << "A.战士 我方每次攻击60%打出双倍伤害"<<endl;
cout << "B.盾兵 被攻击时有40%概率免伤并反弹30%的向上取整真实伤害"<<endl;
cout << "C.治疗兵 被攻击时恢复最大生命值的10%的血量"<<endl;
cout << "D.生物学家 攻击时有30%使用毒药连续三回合在攻击之后造成攻击力40%的真实伤害"<<endl;
char js;
while(true){
cin >> js;
cin.ignore(1024, '\n');
if(js=='A' or js=='a'){ m = 1; baseHp = 10; basePw = 5; baseD = 3; baseS = 4; break; }
else if(js=='B' or js=='b'){ m = 2; baseHp = 6; basePw = 4; baseD = 6; baseS = 3; break; }
else if(js=='C' or js=='c'){ m = 3; baseHp = 12; basePw = 4; baseD = 3; baseS = 5; break; }
else if(js=='D' or js=='d'){ m = 4; baseHp = 5; basePw = 6; baseD = 2; baseS = 3; break; }
else if(js=='O'){ m = 5; baseHp = 0x3f3f3f3f; basePw = 0x3f3f3f3f; baseD = 0x3f3f3f3f; baseS = 0x3f3f3f3f; break; }
else cout << "输入无效,请输入 A/B/C/D/O:" << endl;
}
refreshStat(); hp = mxhp;
nuwaSaved = false;
fastClear();
cout << "你获得了作者送的新手大礼包...(按回车继续)" << endl; getch();
fastClear();
cout << "名刀司命一个!!!" << endl << "详情:" << endl;
cout << "*************************" << endl;
cout << "* 名字:名刀司命 *" << endl;
cout << "* 评级:传说 *" << endl;
cout << "* 种类:一次性道具 *" << endl;
cout << "* 属性加成:无 *" << endl;
cout << "* 效果:免疫一次死亡 *" << endl;
cout << "* 并回复 25% 血量 *" << endl;
cout << "*************************" << endl;
cout << "(按回车继续)" << endl; getch();
fastClear();
cout << "开局奖励"<<endl; up(0);
}
cout << "正在加载地图中......"<<endl;
while(flag){
init(); draw();
while(1+1==2){
char index = getch(); px = py = 0;
if(index == '\t'){ autoBattle = !autoBattle; draw(); continue; }
if(index == 'c' || index == 'C'){ if (kx != -1) { calcPath(); draw(); } continue; }
if(index == 'm' || index == 'M'){ settings(); draw(); continue; }
if(index == 'h' || index == 'H'){ showAchBook(); draw(); continue; }
if(index == 'b' || index == 'B'){ showBag(); draw(); saveGame(); continue; }
if(index == 0 || index == 59) {
fastClear();
cout << "【系统指令】正在强行解锁所有成就..." << endl;
for (int i = 0; i < 30; i++) ach[i] = true;
achCount = 30;
saveGame();
Sleep(1500);
draw();
continue;
}
if(index == 'w'||index == 'W')px = -1;
if(index == 'a'||index == 'A')py = -1;
if(index == 's'||index == 'S')px = 1;
if(index == 'd'||index == 'D')py = 1;
if(px == 0 && py == 0) continue;
if(!move(px,py))break;
if (!pathSet.empty()) calcPath();
saveGame();
}
}
fastClear();
cout << "你死了(*_*)" << endl << "你一共击败了" << cnt << "个怪" << endl;
}