/*
- 键位更新 */
#include <windows.h> #include <conio.h> // getch #include <bits/stdc++.h> using namespace std;
namespace _MD5 { #define A 0x67452301 #define B 0xefcdab89 #define C 0x98badcfe #define D 0x10325476
const char str16[] = "0123456789abcdef";
const unsigned long long T[] =
{
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
};
const unsigned long long s[] = { 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21
};
class MD5
{
private:
unsigned long long tempA, tempB, tempC, tempD, strlength;
public:
MD5()
{
tempA = A;
tempB = B;
tempC = C;
tempD = D;
strlength = 0;
}
// F函数
unsigned long long F(unsigned long long b, unsigned long long c, unsigned long long d)
{
return (b & c) | ((~b) & d);
}
// G函数
unsigned long long G(unsigned long long b, unsigned long long c, unsigned long long d)
{
return (b & d) | (c & (~d));
}
// H函数
unsigned long long H(unsigned long long b, unsigned long long c, unsigned long long d)
{
return b ^ c ^ d;
}
// I函数
unsigned long long I(unsigned long long b, unsigned long long c, unsigned long long d)
{
return c ^ (b | (~d));
}
// 移位操作函数
unsigned long long shift(unsigned long long a, unsigned long long n)
{
return (a << n) | (a >> (32 - n));
}
// 编码函数
string encode(string src)
{
vector<unsigned long long> rec = padding(src);
for (unsigned long long i = 0; i < strlength / 16; i++)
{
unsigned long long num[16];
for (long long j = 0; j < 16; j++)
{
num[j] = rec[i * 16 + j];
}
iterateFunc(num, 16);
}
return format(tempA) + format(tempB) + format(tempC) + format(tempD);
}
// 循环压缩
void iterateFunc(unsigned long long *X, long long size = 16)
{
unsigned long long a = tempA,
b = tempB,
c = tempC,
d = tempD,
rec = 0,
g, k;
for (long long i = 0; i < 64; i++)
{
if (i < 16)
{
// F迭代
g = F(b, c, d);
k = i;
}
else if (i < 32)
{
// G迭代
g = G(b, c, d);
k = (1 + 5 * i) % 16;
}
else if (i < 48)
{
// H迭代
g = H(b, c, d);
k = (5 + 3 * i) % 16;
}
else
{
// I迭代
g = I(b, c, d);
k = (7 * i) % 16;
}
rec = d;
d = c;
c = b;
b = b + shift(a + g + X[k] + T[i], s[i]);
a = rec;
}
tempA += a;
tempB += b;
tempC += c;
tempD += d;
}
// 填充字符串
vector<unsigned long long> padding(string src)
{
// 以512位,64个字节为一组
unsigned long long num = ((src.length() + 8) / 64) + 1;
vector<unsigned long long> rec(num * 16);
strlength = num * 16;
for (unsigned long long i = 0; i < src.length(); i++)
{
// 一个unsigned int对应4个字节,保存4个字符信息
rec[i >> 2] |= (long long)(src[i]) << ((i % 4) * 8);
}
// 补充1000...000
rec[src.length() >> 2] |= (0x80 << ((src.length() % 4) * 8));
// 填充原文长度
rec[rec.size() - 2] = (src.length() << 3);
return rec;
}
// 整理输出
string format(unsigned long long num)
{
string res = "";
unsigned long long base = 1 << 8;
for (long long i = 0; i < 4; i++)
{
string tmp = "";
unsigned long long b = (num >> (i * 8)) % base & 0xff;
for (long long j = 0; j < 2; j++)
{
tmp = str16[b % 16] + tmp;
b /= 16;
}
res += tmp;
}
return res;
}
};} using namespace _MD5;
// 常量区 HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE); HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); long long dx[] = {-1, 1, 0, 0, 0}, dy[] = {0, 0, -1, 1, 0}; const long long LEFT = 2, RIGHT = 1, UP = 8, DOWN = 4, STILL = 0; const long long PLAYER = 0, MONSTER = 1, BULLET = 2; vector<long long> inv = { -1 }; vector<long long> nomove = { 5 }; const long long LINE = 10; // 区块行数 const long long COL = 10; // 区块列数 const long long WLINE = 10; // 地图行数 const long long WCOL = 10; // 地图列数 const long long DIM = 3; // 维度总数 long long FPS = 100; #define SUCCESS 0 #define FAIL 1
// 类型定义区 #define mtime_t unsigned long long // 精确到毫秒的时间单位定义 class Cursor // 控制台光标移动 { protected: stack<COORD> pre; public: Cursor() { CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo(hOut, &csbi); pre.push(csbi.dwCursorPosition); } void Goto(long long x, long long y) { pre.push({x, y}); SetConsoleCursorPosition(hOut, pre.top()); } BOOL Back() { if (pre.empty()) return FAIL; pre.pop(); if (pre.empty()) return FAIL; SetConsoleCursorPosition(hOut, pre.top()); } BOOL Empty() { return pre.empty(); } }; struct pos // 位置结构体 { long long x; long long y; long long mapx; long long mapy; long long dim; string mp[LINE + 5][COL + 5]; long long dir; // bullet mtime_t stattm; // bullet long long tox; // portal long long toy; // portal long long tomapx; // portal long long tomapy; // portal long long todim; // portal bool operator==(pos p) { return dim == p.dim && x == p.x && y == p.y && mapx == p.mapx && mapy == p.mapy; } };
struct DOC // 存档结构体 { string player; long long level; long long monsterhp; string pas; long long num; };
// 变量区 pos monster, player, airdrop/空投/, portal[DIM][DIM]; // 传送门 [起始维度][目标维度] Cursor cur; vector<pos> bullet; mtime_t st; long long monsterhp; long long speed; long long teleport = 20; long long level = 0; long long &mx = player.mapx, &my = player.mapy; long long &monx = monster.x, &mony = monster.y; long long &wmx = monster.mapx, &wmy = monster.mapy; long long &x = player.x, &y = player.y; long long bullcnt; // 弹药数量 long long clip; // 弹夹数量 bool autoload = false; bool autotp = false; bool is_dodge = false; bool is_defeat = false; bool is_die = false; long long whole[DIM][WLINE + 5][WCOL + 5]; long long cmx = 0, cmy = 0; string s_dim[DIM] = {“主世界”, “炙热域”, “寒冰界”}; bool wrote; mt19937 mt; map<pair<long long, long long>, vector<long long>> mem; long long numini; MD5 md5; mtime_t last_print; long long ar_less = 5, at_less = 7; long long delta = 10;
// 键位 long long k_att_u = ‘I’, k_att_d = ‘K’, k_att_l = ‘J’, k_att_r = ‘L’, k_reload = ‘E’, k_drop = ‘R’, k_tp = ‘Q’, k_ender_pearl = VK_SPACE, k_speed = VK_OEM_1, k_autoreload = ‘U’, k_autotp = ‘O’, k_hl_u = VK_UP, k_hl_d = VK_DOWN, k_hl_l = VK_LEFT, k_hl_r = VK_RIGHT, k_pl_u = ‘W’, k_pl_d = ‘S’, k_pl_l = ‘A’, k_pl_r = ‘D’; // att : attack, hl : highlight, pl : player long long *keymap[] = {&k_att_d, &k_att_u, &k_att_l, &k_att_r, &k_pl_d, &k_pl_u, &k_pl_l, &k_pl_r, &k_hl_d, &k_hl_u, &k_hl_l, &k_hl_r, &k_autoreload, &k_autotp, &k_drop, &k_ender_pearl, &k_reload, &k_tp, &k_speed};
// 键表 string keymp[256] = { "", // 00 “Mouse Left”, // 01 “Mouse Right”, // 02 "", // 03 “Mouse Mid”, // 04 “Mouse X1”, // 05 “Mouse X2”, // 06 "", // 07 “Backspace”, // 08 “Tab”, // 09 "", // 0A "", // 0B "", // 0C “Enter”, // 0D "", // 0E "", // 0F "", // 10 "", // 11 "", // 12 "", // 13 “Caps”, // 14 "", // 15 "", // 16 "", // 17 "", // 18 "", // 19 "", // 1A “Esc”, // 1B "", // 1C "", // 1D "", // 1E "", // 1F “Space”, // 20 “Pg up”, // 21 “Pg dn”, // 22 “End”, // 23 “Home”, // 24 “Left Arrow”, // 25 “Up Arrow”, // 26 “Right Arrow”, // 27 “Down Arrow”, // 28 "", // 29 "", // 2A "", // 2B "", // 2C "", // 2D "", // 2E "", // 2F “0”, // 30 “1”, // 31 “2”, // 32 “3”, // 33 “4”, // 34 “5”, // 35 “6”, // 36 “7”, // 37 “8”, // 38 “9”, // 39 "", // 3A "", // 3B "", // 3C "", // 3D "", // 3E "", // 3F "", // 40 “A”, // 41 “B”, // 42 “C”, // 43 “D”, // 44 “E”, // 45 “F”, // 46 “G”, // 47 “H”, // 48 “I”, // 49 “J”, // 4A “K”, // 4B “L”, // 4C “M”, // 4D “N”, // 4E “O”, // 4F “P”, // 50 “Q”, // 51 “R”, // 52 “S”, // 53 “T”, // 54 “U”, // 55 “V”, // 56 “W”, // 57 “X”, // 58 “Y”, // 59 “Z”, // 5A "", // 5B "", // 5C "", // 5D "", // 5E "", // 5F “Num 0”, // 60 “Num 1”, // 61 “Num 2”, // 62 “Num 3”, // 63 “Num 4”, // 64 “Num 5”, // 65 “Num 6”, // 66 “Num 7”, // 67 “Num 8”, // 68 “Num 9”, // 69 “Num *”, // 6A “Num +”, // 6B "", // 6C “Num -”, // 6D “Num .”, // 6E “Num /”, // 6F “F1”, // 70 “F2”, // 71 “F3”, // 72 “F4”, // 73 “F5”, // 74 “F6”, // 75 “F7”, // 76 “F8”, // 77 “F9”, // 78 “F10”, // 79 “F11”, // 7A “F12”, // 7B “F13”, // 7C “F14”, // 7D “F15”, // 7E “F16”, // 7F “F17”, // 80 “F18”, // 81 “F19”, // 82 “F20”, // 83 “F21”, // 84 “F22”, // 85 “F23”, // 86 “F24”, // 87 "", // 88 "", // 89 "", // 8A "", // 8B "", // 8C "", // 8D "", // 8E "", // 8F “Num Lock”, // 90 “Scroll Lock”, // 91 "", // 92 "", // 93 "", // 94 "", // 95 "", // 96 "", // 97 "", // 98 "", // 99 "", // 9A "", // 9B "", // 9C "", // 9D "", // 9E "", // 9F “Left Shift”, // A0 “Right Shift”, // A1 “Left Ctrl”, // A2 “Right Ctrl”, // A3 “Left Alt”, // A4 “Right Alt”, // A5 "", // A6 "", // A7 "", // A8 "", // A9 "", // AA "", // AB "", // AC "", // AD "", // AE "", // AF "", // B0 "", // B1 "", // B2 "", // B3 "", // B4 "", // B5 "", // B6 "", // B7 "", // B8 "", // B9 ”;”, // BA ”=”, // BB ”,”, // BC ”-”, // BD ”.”, // BE ”/”, // BF ”`”, // C0 "", // C1 "", // C2 "", // C3 "", // C4 "", // C5 "", // C6 "", // C7 "", // C8 "", // C9 "", // CA "", // CB "", // CC "", // CD "", // CE "", // CF "", // D0 "", // D1 "", // D2 "", // D3 "", // D4 "", // D5 "", // D6 "", // D7 "", // D8 "", // D9 "", // DA ”[”, // DB ”\”, // DC ”]”, // DD ”’”, // DE "", // DF "", // E0 "", // E1 "", // E2 "", // E3 "", // E4 "", // E5 "", // E6 "", // E7 "", // E8 "", // E9 "", // EA "", // EB "", // EC "", // ED "", // EE "", // EF "", // F0 "", // F1 "", // F2 "", // F3 "", // F4 "", // F5 "", // F6 "", // F7 "", // F8 "", // F9 "", // FA "", // FB "", // FC "", // FD "", // FE "", // FF }; vector<long long> prockeys;
// 预处理函数区
#define kd(vk) (GetAsyncKeyState(vk) & 0x8000 ? 1 : 0)
#define SetColor(attr) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), (attr))
#define defmap(n, b) void map##n(long long ismon = false, long long bn = 0)
{
for (long long i = 1; i <= LINE; i++)
{
for (long long j = 1; j <= COL; j++)
{
if (b == 1)
{
if (ismon == 1) monster.mp[i][j] = “墙”;
else if (ismon == 2) bullet[bn].mp[i][j] = “墙”;
else player.mp[i][j] = “墙”;
}
else
{
if (ismon) monster.mp[i][j] = ” “;
else if (ismon == 2) bullet[bn].mp[i][j] = ” “;
else player.mp[i][j] = ” ”;
}
}
}
}
#define prockeyspush prockeys.push_back
#define map(n) map##n()
#define defifmp(k) if(n == k) map##k(1);
#define bullmp(k, bn) if(n == k) map##k(2, bn);
#define IF(q) if (n == q)
{
map##q();
for (long long i = 1; i <= LINE; i++)
{
for (long long j = 1; j <= COL; j++)
{
long long isbull = false;
for (long long k = 0; k < bullet.size(); k++)
if (i == bullet[k].x && j == bullet[k].y && mx == bullet[k].mapx && my == bullet[k].mapy && bullet[k].dir != -1)
{
isbull = bullet[k].dir == UP || bullet[k].dir == DOWN ? 1 : 2;
break;
}
SetColor(player.mp[i][j] == “墙” ? 0xf0 : i == x && j == y ? 0xc0 : i == monx && j == mony && mx == wmx && my == wmy ? 0xa0 : isbull ? 0x0e : i == airdrop.x && j == airdrop.y && mx == airdrop.mapx && my == airdrop.mapy ? BACKGROUND_BLUE | 0x80 : 0x07);
cout << (isbull == 1 ? ”||” : isbull == 2 ? ”==” : ” ”);
}
cout << endl;
}
}
// 函数定义区 defmap(0, (i == 1 || i == 10) && (j == 1 || j == 10)) // 各种地图 defmap(1, j == 10 || (j == 1 && (i == 1 || i == 10))) defmap(2, j == 1 || (j == 10 && (i == 1 || i == 10))) defmap(3, j == 1 || j == 10) defmap(4, i == 10 || (i == 1 && (j == 1 || j == 10))) defmap(5, i == 10 || j == 10 || (i == 1 && j == 1)) defmap(6, i == 10 || j == 1 || (i == 1 && j == 10)) defmap(7, i == 10 || j == 1 || j == 10) defmap(8, i == 1 || (i == 10 && (j == 1 || j == 10))) defmap(9, i == 1 || j == 10 || (i == 10 && j == 1)) defmap(10, i == 1 || j == 1 || (i == 10 && j == 10)) defmap(11, i == 1 || j == 1 || j == 10) defmap(12, i == 1 || i == 10) defmap(13, i == 1 || i == 10 || j == 10) defmap(14, i == 1 || i == 10 || j == 1) defmap(15, i == 1 || i == 10 || j == 1 || j == 10) void monstermap(long long n) // 控制怪物地图 { defifmp(0) defifmp(1) defifmp(2) defifmp(3) defifmp(4) defifmp(5) defifmp(6) defifmp(8) defifmp(9) defifmp(10) defifmp(11) defifmp(12) defifmp(13) defifmp(14) defifmp(15) } void bulletmap(long long n, long long bn) // 子弹地图 { bullmp(0, bn) bullmp(1, bn) bullmp(2, bn) bullmp(3, bn) bullmp(4, bn) bullmp(5, bn) bullmp(6, bn) bullmp(7, bn) bullmp(8, bn) bullmp(9, bn) bullmp(10, bn) bullmp(11, bn) bullmp(12, bn) bullmp(13, bn) bullmp(14, bn) bullmp(15, bn) }
mtime_t getmtime() // 精确到毫秒的计时器 { SYSTEMTIME st; GetSystemTime(&st); mtime_t ret = st.wMilliseconds; ret += time(NULL) * 1000ull; return ret; }
void debugf(const char *format, …) // 格式化调试 { va_list va; va_start(va, format); char *buf = new char[1048576]; vsprintf(buf, format, va); string s = buf; delete[] buf; va_end(va); if (format[0] == ’@’) MessageBoxA(NULL, s.data(), “debug”, MB_OK); }
string INIread(string sec, string key, string file = ”./config.ini”) // 配置文件读取 { char *buf = new char[1048576]; string s(buf, GetPrivateProfileStringA(sec.data(), key.data(), "", buf, 1048576, file.data())); delete []buf; return s; } void nINIwrite(string sec, string key, long long &val, string file = ”./config.ini”) // not write { string tmp = INIread(sec, key); val = stoi(tmp); } void INIwrite(string sec, string key, string val = "", string file = ”./config.ini”) // 配置文件写入 { WritePrivateProfileStringA(sec.data(), key.data(), val.data(), file.data()); }
void transfer(pos &who, long long dim_from, long long dim_to) // 传送 { if (who == portal[dim_from][dim_to]) { who.dim = portal[dim_from][dim_to].todim; who.mapx = portal[dim_from][dim_to].tomapx; who.mapy = portal[dim_from][dim_to].tomapy; who.x = portal[dim_from][dim_to].tox; who.y = portal[dim_from][dim_to].toy; } } void setwall(long long x, long long y, long long w, long long d = 0) // 在某区块设置某方向的墙 { whole[d][x][y] |= w; } bool mov(long long x, long long y, long long &m = ::x, long long &n = ::y, long long ismon = false, long long bn = 0) // 移动实体 return stucked {
if (ismon == MONSTER)
{
monstermap(whole[monster.dim][monster.mapx][monster.mapy] & 0xf);
if (monster.mp[x][y] == "墙")
return 1;
m = x, n = y;
return 0;
}
else if (ismon == BULLET)
{
bulletmap(whole[bullet[bn].dim][bullet[bn].mapx][bullet[bn].mapy] & 0xf, bn);
if (bullet[bn].mp[x][y] == "墙")
return 1;
m = x, n = y;
return 0;
}
else
{
{
if (player.mp[x][y] == "墙")
return 1;
m = x, n = y;
return 0;
}
}} mtime_t now_fps; void printm(long long n) // 输出地图(界面) { now_fps = getmtime() - last_print; last_print = getmtime(); IF(0) IF(1) IF(2) IF(3) IF(4) IF(5) IF(6) IF(7) IF(8) IF(9) IF(10) IF(11) IF(12) IF(13) IF(14) IF(15) for (long long i = 0; i <= WLINE; i++) { cur.Goto(COL * 2 + 6, i); cout << hex; for (long long j = 0; j <= WCOL; j++) { SetColor ( (i == mx && j == my ? FOREGROUND_RED : 0x08) | (i == wmx && j == wmy ? FOREGROUND_GREEN : 0x08) | ((i == airdrop.mapx && j == airdrop.mapy) ? FOREGROUND_BLUE : 0x08) | (cmx == i && cmy == j ? 0xf0 : 0x08) ); cout << ”[]”; SetColor(0x07); } cur.Back(); } cout << dec; cur.Goto(COL * 2 + 10 + WCOL * 2, 0); cout << “用时: ” << time(NULL) - st << ” sec.”; cur.Back(); cur.Goto(COL * 2 + 10 + WCOL * 2, 1); cout << “怪血: ” << monsterhp << ” ”; cur.Back(); cur.Goto(COL * 2 + 10 + WCOL * 2, 2); cout << “等级: ” << level; cur.Back(); cur.Goto(COL * 2 + 10 + WCOL * 2, 3); cout << “弹药: ” << bullcnt << ” ”; cur.Back(); cur.Goto(COL * 2 + 10 + WCOL * 2, 4); cout << “弹夹: ” << clip << ” ”; cur.Back(); cur.Goto(COL * 2 + 10 + WCOL * 2, 5); cout << “紫颂果: ” << teleport << ” ”; cur.Back(); cur.Goto(COL * 2 + 10 + WCOL * 2, 6); cout << (speed ? “快” : “慢”); cur.Back(); cur.Goto(COL * 2 + 10 + WCOL * 2, 7); cout << “自动换弹: ” << (level < 5 ? “禁用” : autoload ? “开” : “关”); cur.Back(); cur.Goto(COL * 2 + 10 + WCOL * 2, 8); cout << “保命瞬移: ” << (level < 7 ? “禁用” : autotp ? “开” : “关”); cur.Back(); cur.Goto(COL * 2 + 10 + WCOL * 2, 9); cout << “你当前维度:” << s_dim[player.dim]; cur.Back(); cur.Goto(COL * 2 + 10 + WCOL * 2, 10); cout << “鬼当前维度:” << s_dim[monster.dim]; cur.Back(); cur.Goto(COL * 2 + 10 + WCOL * 2, 11); cout << “高亮区块墙状态: ”; cout << (whole[player.dim][cmx][cmy] & UP ? “上” : ” ”); cout << (whole[player.dim][cmx][cmy] & DOWN ? “下” : ” ”); cout << (whole[player.dim][cmx][cmy] & LEFT ? “左” : ” ”); cout << (whole[player.dim][cmx][cmy] & RIGHT ? “右” : ” ”); cur.Back(); cur.Goto(COL * 2 + 10 + WCOL * 2, 12); cout << (wrote ? “记录已保存” : is_dodge ? “闪避 ” : is_defeat ? “击退 ” : ” ”); cur.Back(); cur.Goto(COL * 2 + 10 + WCOL * 2, 13); cout << “FPS: ” << now_fps << ” ”; cur.Back(); } long long judge(long long &x, long long &y, long long &mx = ::mx, long long &my = ::my) // 判断是否出区块 { if (x < 1) { x = LINE; mx—; return UP; } if (y < 1) { my—; y = COL; return LEFT; } if (x > LINE) { mx++; x = 1; return DOWN; } if (y > COL) { my++; y = 1; return RIGHT; } return STILL; } vector<long long> dfsmap(pos now, pos man) // 怪物单次dfs { vector<long long> ret = inv; if (man.mapx != now.mapx || man.mapy != now.mapy) for (long long i = 0; i < 4; i++) { pos n = now; n.mapx += dx[i]; n.mapy += dy[i]; pair<long long, long long> pii = make_pair(n.mapx, n.mapy); if (whole[now.dim][now.mapx][now.mapy] & (1 << (3 - i))) continue; if (whole[now.dim][n.mapx][n.mapy] & 16) continue; // 16 : visited vector<long long> tmp; tmp = inv; if (mem[pii].empty()) { whole[n.dim][n.mapx][n.mapy] |= 16; tmp.clear(); mem[pii] = tmp = dfsmap(n, man); if (tmp == nomove) { tmp.clear(); tmp.push_back(i); } else if (tmp != inv) tmp.insert(tmp.begin(), i); whole[n.dim][n.mapx][n.mapy] &= ~16; } else { tmp.clear(); tmp = mem[pii]; if (tmp == nomove) { tmp.clear(); tmp.push_back(i); } else if (tmp != inv) tmp.insert(tmp.begin(), i); } if (ret == inv) { ret = tmp; } else if (ret.size() >= tmp.size()) { ret = tmp; } // Sleep(2); } else { ret.clear(); ret.push_back(5); // debugf(“@finded”); } return ret; } vector<long long> dfs(pos now, pos man) // 怪物dfs 接下来:和人不同维度就直接奔传送门 { for (long long d = 0; d < DIM; d++) { for (long long i = 0; i < WLINE; i++) { for (long long j = 0; j < WCOL; j++) { whole[d][i][j] &= ~16; } } }
vector<long long> ret;
whole[now.dim][now.mapx][now.mapy] |= 16;
ret = dfsmap(now, man);
whole[now.dim][now.mapx][now.mapy] &= ~16;
return ret;} void DelayPrint(string s, long long del = 50) // 延时输出 { for (auto u : s) { if (u != ‘\b’) { putchar(u); } else { printf(“\b \b”); } Sleep(del); } } void shoot(long long dir) // 射击函数(生成子弹实体) { if (bullcnt == 0) return; pos b; b.x = x; b.y = y; b.mapx = mx; b.mapy = my; b.stattm = getmtime(); b.dir = dir; // debugf(“@s”); bullet.push_back(b); Beep(320, 100); bullcnt—; // debugf(“@OK”); } bool cmp(DOC m, DOC d) // 比较函数(排名) { return m.level > d.level ? 1 : m.level == d.level ? m.monsterhp < d.monsterhp : 0; }
string filename;
void Start(long long level, long long num) { string f = FILE; ShellExecuteA(NULL, “open”, filename.data(), (to_string(level) + ” ” + to_string(num)).data(), NULL, SW_SHOW); }
// 线程函数区 DWORD WINAPI T_MonsterProc(LPVOID lpIgnore) // 怪物处理线程 { pos &me = monster, &man = player; // TODO: Process (AI): eat the man vector<long long> method; long long num = 0; pos lastman = {-1, -1, -1, -1}; while (1) { if (is_die) ExitThread(0); long long delay; if (level > 50) delay = 5; else if (level > 10) delay = 20; else if (level == 10) delay = 25; else if (level == 9) delay = 35; else if (level == 8) delay = 40; else if (level == 7) delay = 45; else if (level == 6) delay = 50; else if (level == 5) delay = 65; else if (level == 4) delay = 65; else if (level == 3) delay = 75; else if (level == 2) delay = 100; else if (level == 1) delay = 200; else delay = 500; delay *= 2; if (lastman.mapx != man.mapx || lastman.mapy != man.mapy) { // debugf(“@ifmethod”); lastman = man; mem.clear(); debugf(“dfs start”); method = dfs(me, man); debugf(“dfs end, size %d, isinv %d”, method.size(), method == inv); while (method == inv && (lastman.mapx == man.mapx && lastman.mapy == man.mapy)) { mem.clear(); debugf(“dfs start”);
method = dfs(me, {me.x + (me.x == LINE ? -1 : 1), me.y + (me.y == COL ? -1 : 1), me.mapx, me.mapy});
// debugf("@dfs end, size %d, isinv %d", method.size(), method == inv);
mem.clear();
debugf("dfs start");
method = dfs(me, man);
// debugf("@dfs end, size %d, isinv %d", method.size(), method == inv);
}
num = 0;
}
// lastman = man;
// debugf("lastman = man");
if (num < method.size())
{
pos lastme = me;
while (me.mapx == lastme.mapx && me.mapy == lastme.mapy)
{
if (me.mapx == man.mapx && me.mapy == man.mapy)
{
break;
}
bool stucked = mov(me.x + dx[method[num]], me.y + dy[method[num]], me.x, me.y, 1);
debugf("mov %d %d %d %d", me.mapx, me.mapy, me.x, me.y);
debugf("judge %d", judge(me.x, me.y, me.mapx, me.mapy));
Sleep(delay);
if (stucked)
{
long long xx = me.x - WLINE / 2, yy = me.y - WCOL / 2;
if ((mt() & 1))
{
mov(me.x, me.y - (yy < 0 ? -1 : yy > 0 ? 1 : 0), me.x, me.y, 1);
}
else
{
mov(me.x - (xx < 0 ? -1 : xx > 0 ? 1 : 0), me.y, me.x, me.y, 1);
}
}
}
debugf("num++");
num++;
}
else if (me.mapx == man.mapx && me.mapy == man.mapy)
{
// debugf("@elif");
long long xx = me.x - man.x, yy = me.y - man.y;
if (mt() & 1)
{
mov(me.x, me.y - (yy < 0 ? -1 : yy > 0 ? 1 : 0), me.x, me.y, 1);
debugf("mov %d %d %d %d", me.mapx, me.mapy, me.x, me.y);
}
else
{
mov(me.x - (xx < 0 ? -1 : xx > 0 ? 1 : 0), me.y, me.x, me.y, 1);
debugf("mov %d %d %d %d", me.mapx, me.mapy, me.x, me.y);
}
}
else
{
// debugf("@");
}
// else
// {
// long long xx = me.x - WLINE / 2, yy = me.y - WCOL / 2;
// if(xx == 0)
// {
// mov(me.x, me.y - (yy < 0 ? -1 : yy > 0 ? 1 : 0), me.x, me.y, 1);
// }
// else
// {
// mov(me.x - (xx < 0 ? -1 : xx > 0 ? 1 : 0), me.y, me.x, me.y, 1);
// }
// }
Sleep(delay);
// debugf("@@");
}}
DWORD WINAPI T_LetBulletFly(LPVOID lpIgnore) // 子弹移动处理线程 { mtime_t lastdefeat = 0; while (1) { if (is_die) ExitThread(0); for (long long i = 0; i < bullet.size(); i++) { if (is_defeat && getmtime() - lastdefeat >= 20) is_defeat = false; if (bullet[i].dir == -1) continue; mtime_t tim = getmtime(); long long dtim = tim - bullet[i].stattm; if (dtim >= 5) { bullet[i].stattm = tim; if (mov(bullet[i].x + dx[bullet[i].dir], bullet[i].y + dy[bullet[i].dir], bullet[i].x, bullet[i].y, 2, i)) bullet.erase(bullet.begin() + i); debugf(“bul %d %d”, i, judge(bullet[i].x, bullet[i].y, bullet[i].mapx, bullet[i].mapy)); if (bullet[i] == monster) { if (monsterhp != 0) monsterhp—; if (mt() % (level) == 0) // 击退 { lastdefeat = getmtime(); is_defeat = true; mov(monster.x + dx[bullet[i].dir], monster.y + dy[bullet[i].dir], monster.x, monster.y, 1); judge(monster.x, monster.y, monster.mapx, monster.mapy); } if (monsterhp != 0) // 中弹提示 Beep(650, 100); bullet.erase(bullet.begin() + i); } } } } }
void write_setting() { INIwrite(“key”, “att_d”, to_string(k_att_d)); INIwrite(“key”, “att_u”, to_string(k_att_u)); INIwrite(“key”, “att_l”, to_string(k_att_l)); INIwrite(“key”, “att_r”, to_string(k_att_r)); INIwrite(“key”, “atrld”, to_string(k_autoreload)); INIwrite(“key”, “attp”, to_string(k_autotp)); INIwrite(“key”, “drp”, to_string(k_drop)); INIwrite(“key”, “ender”, to_string(k_ender_pearl)); INIwrite(“key”, “hl_d”, to_string(k_hl_d)); INIwrite(“key”, “hl_u”, to_string(k_hl_u)); INIwrite(“key”, “hl_l”, to_string(k_hl_l)); INIwrite(“key”, “hl_r”, to_string(k_hl_r)); INIwrite(“key”, “pl_d”, to_string(k_pl_d)); INIwrite(“key”, “pl_u”, to_string(k_pl_u)); INIwrite(“key”, “pl_l”, to_string(k_pl_l)); INIwrite(“key”, “pl_r”, to_string(k_pl_r)); INIwrite(“key”, “rld”, to_string(k_reload)); INIwrite(“key”, “tp”, to_string(k_tp)); INIwrite(“key”, “spd”, to_string(k_speed)); INIwrite(“display”, “fps”, to_string(FPS)); INIwrite(“display”, “delta”, to_string(delta)); }
DWORD WINAPI T_WriteMsg(LPVOID lpIgnore) // 保存记录线程 { while (1) { INIwrite(to_string(numini), “level”, to_string(level)); INIwrite(to_string(numini), “mhp”, to_string(monsterhp)); write_setting(); wrote = true; Sleep(500); wrote = false; Sleep(4500); } }
DWORD WINAPI T_GOBeep(LPVOID lpIgnore) // 死亡音效线程 { Beep(1234, 1000); return 0; }
DWORD WINAPI T_Shoot(LPVOID lpIgnore) // 射击管理线程(兼管高亮区块) { while (1) { if (is_die) ExitThread(0); // Sleep(25); if ((kd(k_att_u))) { shoot(0); } if ((kd(k_att_l))) { shoot(2); } if ((kd(k_att_d))) { shoot(1); } if ((kd(k_att_r))) { shoot(3); } if (kd(k_reload) && clip) { Sleep(level > 10 ? 10 : (1000 / level)); bullcnt += 20; clip—; } if (autoload && bullcnt == 0) { Sleep(level > 10 ? 10 : (1000 / level)); bullcnt = 20; clip—; } if (level >= ar_less && kd(k_autoreload)) { autoload = !autoload; Sleep(200); } if (level >= at_less && kd(k_autotp)) { autotp = !autotp; Sleep(200); } if (kd(k_hl_u)) { if (cmx) cmx—; Sleep(100); } if (kd(k_hl_d)) { if (cmx < WLINE) cmx++; Sleep(100); } if (kd(k_hl_l)) { if (cmy) cmy—; Sleep(100); } if (kd(k_hl_r)) { if (cmy < WCOL) cmy++; Sleep(100); } } }
DWORD WINAPI T_Move(LPVOID lpInore) // 玩家移动信息处理线程(兼管瞬移、空投、速度) { long long &m = x, &n = y; while (1) { if (is_die) ExitThread(0); if ((kd(k_pl_u))) { // getch(); mov(m - 1, n); judge(x, y); } if ((kd(k_pl_l))) { // getch(); mov(m, n - 1); judge(x, y); } if ((kd(k_pl_d))) { // getch(); mov(m + 1, n); judge(x, y); } if ((kd(k_pl_r))) { // getch(); mov(m, n + 1); judge(x, y); } if (kd(k_tp)) { // getch(); if (teleport != 0) { player.mapx = mt() % WLINE; player.mapy = mt() % WCOL; player.x = LINE / 2; player.y = COL / 2; teleport—; } Sleep(100); } if (kd(k_ender_pearl)) { if (teleport >= 5 || teleport < 0) { player.mapx = cmx; player.mapy = cmy; player.x = LINE / 2; player.y = COL / 2; teleport -= 5; } Sleep(100); } if (kd(k_drop)) { // getch(); airdrop.dim = player.dim; airdrop.mapx = mt() % WLINE; airdrop.mapy = mt() % WCOL; airdrop.x = 1 + mt() % (LINE - 1); airdrop.y = 1 + mt() % (COL - 1); } if (kd(k_speed)) { speed = !speed; Sleep(100); } else Sleep(speed ? 1 : 50); if(player.mapx < 0 || player.mapy < 0 || player.mapx > WLINE || player.mapy > WCOL) { player.mapx = monster.mapx; player.mapy = monster.mapy; player.x = LINE / 2; player.y = COL / 2; } } }
DWORD WINAPI T_Print(LPVOID lpIg) // 界面输出线程 { last_print = getmtime(); cur.Goto(0, 0); printm(whole[player.dim][mx][my] & 0xf); Sleep(1000 / FPS); if (is_die) ExitThread(0); cur.Goto(0, 0); printm(whole[player.dim][mx][my] & 0xf); long long lastfps = now_fps; long long delay = 1000 / FPS; if(lastfps > FPS) delay += delta; else if(lastfps < FPS && delay >= 5) delay -= delta; Sleep(delay); while (1) { if (is_die) ExitThread(0); cur.Goto(0, 0); printm(whole[player.dim][mx][my] & 0xf); lastfps = now_fps; if(lastfps > FPS) delay += delta; else if(lastfps < FPS && delay >= 5) delay -= delta; Sleep(delay); } } // 设置GUI void printGUI(long long NowSection = 0, long long NowKey = 0, bool edit = 0) { cur.Goto(0, 0); system(“color 0f & cls”); cout << “键位设置 (DELETE 编辑)” << endl << ”--------” << endl; cout << “向下攻击\t”; if (NowSection == 0 && NowKey == 0) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_att_d] << endl; if (NowSection == 0 && NowKey == 0) SetColor(0x0f); cout << “向上攻击\t”; if (NowSection == 0 && NowKey == 1) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_att_u] << endl; if (NowSection == 0 && NowKey == 1) SetColor(0x0f); cout << “向左攻击\t”; if (NowSection == 0 && NowKey == 2) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_att_l] << endl; if (NowSection == 0 && NowKey == 2) SetColor(0x0f); cout << “向右攻击\t”; if (NowSection == 0 && NowKey == 3) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_att_r] << endl; if (NowSection == 0 && NowKey == 3) SetColor(0x0f); cout << “向下移动\t”; if (NowSection == 0 && NowKey == 4) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_pl_d] << endl; if (NowSection == 0 && NowKey == 4) SetColor(0x0f); cout << “向上移动\t”; if (NowSection == 0 && NowKey == 5) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_pl_u] << endl; if (NowSection == 0 && NowKey == 5) SetColor(0x0f); cout << “向左移动\t”; if (NowSection == 0 && NowKey == 6) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_pl_l] << endl; if (NowSection == 0 && NowKey == 6) SetColor(0x0f); cout << “向右移动\t”; if (NowSection == 0 && NowKey == 7) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_pl_r] << endl; if (NowSection == 0 && NowKey == 7) SetColor(0x0f); cout << “高亮向下\t”; if (NowSection == 0 && NowKey == 8) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_hl_d] << endl; if (NowSection == 0 && NowKey == 8) SetColor(0x0f); cout << “高亮向上\t”; if (NowSection == 0 && NowKey == 9) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_hl_u] << endl; if (NowSection == 0 && NowKey == 9) SetColor(0x0f); cout << “高亮向左\t”; if (NowSection == 0 && NowKey == 10) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_hl_l] << endl; if (NowSection == 0 && NowKey == 10) SetColor(0x0f); cout << “高亮向右\t”; if (NowSection == 0 && NowKey == 11) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_hl_r] << endl; if (NowSection == 0 && NowKey == 11) SetColor(0x0f); cout << “自动换弹\t”; if (NowSection == 0 && NowKey == 12) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_autoreload] << endl; if (NowSection == 0 && NowKey == 12) SetColor(0x0f); cout << “保命瞬移\t”; if (NowSection == 0 && NowKey == 13) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_autotp] << endl; if (NowSection == 0 && NowKey == 13) SetColor(0x0f); cout << “召唤空投\t”; if (NowSection == 0 && NowKey == 14) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_drop] << endl; if (NowSection == 0 && NowKey == 14) SetColor(0x0f); cout << “末影珍珠\t”; if (NowSection == 0 && NowKey == 15) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_ender_pearl] << endl; if (NowSection == 0 && NowKey == 15) SetColor(0x0f); cout << “补充弹药\t”; if (NowSection == 0 && NowKey == 16) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_reload] << endl; if (NowSection == 0 && NowKey == 16) SetColor(0x0f); cout << “随机瞬移\t”; if (NowSection == 0 && NowKey == 17) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_tp] << endl; if (NowSection == 0 && NowKey == 17) SetColor(0x0f); cout << “速度切换\t”; if (NowSection == 0 && NowKey == 18) SetColor(edit ? 0xb0 : 0x70); cout << keymp[k_speed] << endl; if (NowSection == 0 && NowKey == 18) SetColor(0x0f); cout << endl << “显示设置” << endl << ”--------” << endl; cout << “输出帧率\t”; if (NowSection == 1 && NowKey == 0) SetColor(edit ? 0xb0 : 0x70); cout << FPS << endl; if (NowSection == 1 && NowKey == 0) SetColor(0x0f); cout << “调节幅度\t”; if (NowSection == 1 && NowKey == 1) SetColor(edit ? 0xb0 : 0x70); cout << delta << endl; if (NowSection == 1 && NowKey == 1) SetColor(0x0f); } void settingGUI() { printGUI(); long long sec = 0, key = 0; long long totsec = 2; vector<long long> totkey = {19, 2}; while (1) { // TODO: Edit if (kd(VK_TAB)) { getch(); sec = (sec + 1) % totsec; key = 0; printGUI(sec, key); } if (kd(VK_UP)) { key = (key - 1 + totkey[sec]) % totkey[sec]; printGUI(sec, key); } if (kd(VK_DOWN)) { key = (key + 1) % totkey[sec]; printGUI(sec, key); } if (sec == 0) { if (kd(VK_DELETE)) { printGUI(sec, key, true); long long keyvk = 0; while (1) { bool f = 1; for (auto vk : prockeys) { if (kd(vk)) { if (isupper(vk) || isdigit(vk) || vk == VK_RETURN || 0x60 <= vk && vk <= 0x6f || 0xba <= vk) getch(); keyvk = vk; f = 0; break; } } if (f == 0) break; } *keymap[key] = keyvk; printGUI(sec, key); } } if (sec == 1) { if (kd(VK_DELETE)) { printGUI(sec, key, true); long long num = 0; while (!kd(VK_RETURN)) { for (long long i = 0; i <= 9; i++) { if (kd(‘0’ + i)) { getch(); num = num * 10 + i; if (key == 0) FPS = num; if (key == 1) delta = num; printGUI(sec, key, true); Sleep(200); } if(kd(VK_BACK)) { num /= 10; if (key == 0) FPS = num; if (key == 1) delta = num; printGUI(sec, key, true); Sleep(200); } } } printGUI(sec, key); } } if (kd(VK_ESCAPE)) { return; } Sleep(100); write_setting(); } } // 主函数 signed main(signed argc, char *argv[]) { filename = argv[0]; DWORD fdwMode; GetConsoleMode(hIn, &fdwMode); fdwMode |= ENABLE_INSERT_MODE; fdwMode &= ~ ENABLE_QUICK_EDIT_MODE; SetConsoleMode(hIn, fdwMode);
memset(&airdrop, -1, sizeof(airdrop));
if (argc == 1) // 刚点进来,存档管理界面
{
long long n;
if (INIread("doc", "num") == "") // 新人,没有配置文件
{
n = 0;
INIwrite("doc", "num", "0");
// 键位绑定配置
write_setting();
}
else
{
n = stoi(INIread("doc", "num"));
// 键位绑定配置
nINIwrite("key", "att_d", (k_att_d));
nINIwrite("key", "att_u", (k_att_u));
nINIwrite("key", "att_l", (k_att_l));
nINIwrite("key", "att_r", (k_att_r));
nINIwrite("key", "atrld", (k_autoreload));
nINIwrite("key", "attp", (k_autotp));
nINIwrite("key", "drp", (k_drop));
nINIwrite("key", "ender", (k_ender_pearl));
nINIwrite("key", "hl_d", (k_hl_d));
nINIwrite("key", "hl_u", (k_hl_u));
nINIwrite("key", "hl_l", (k_hl_l));
nINIwrite("key", "hl_r", (k_hl_r));
nINIwrite("key", "pl_d", (k_pl_d));
nINIwrite("key", "pl_u", (k_pl_u));
nINIwrite("key", "pl_l", (k_pl_l));
nINIwrite("key", "pl_r", (k_pl_r));
nINIwrite("key", "rld", (k_reload));
nINIwrite("key", "tp", (k_tp));
nINIwrite("key", "spd", (k_speed));
nINIwrite("display", "fps", (FPS));
nINIwrite("display", "delta", (delta));
}
DOC doc[n + 1];
for (long long i = 1; i <= n; i++)
{
doc[i].player = INIread(to_string(i), "player");
doc[i].level = stoi(INIread(to_string(i), "level"));
doc[i].monsterhp = stoi(INIread(to_string(i), "mhp"));
doc[i].pas = INIread(to_string(i), "pas");
doc[i].num = i;
}
sort(doc + 1, doc + n + 1, cmp);
bool N = false, O = false, S = false;
DelayPrint("地牢 Version 2.2\n", 1);
if (INIread("program", "version") != "2.2")
{
DelayPrint("2.1 New features:\n*\t=) 排名 & 存档\n*\t=) md5加密存档\n*\t人性化的瞬移\n", 1);
DelayPrint("2.2 News: Keysetting\n", 1);
INIwrite("program", "version", "2.2");
}
while (1)
{
system("cls");
DelayPrint("当前存档:\n", 1);
DelayPrint("Rank INI No. Player Level MonsterHpLast\n---------------------------------------------------\n", 1);
for (long long i = 1; i <= n; i++)
{
printf("%-5d %-8d %-14s %-7d %-12d\n", i, doc[i].num, doc[i].player.data(), doc[i].level, doc[i].monsterhp);
}
DelayPrint("---------------------------------------------------\n新建存档(N)\n打开存档(O)\n选项设置(S)\n", 1);
char c;
while((c = tolower(getch())) != 'n' && c != 'o' && c != 's');
if (c == 'n' || c == 'N') // 新建存档
{
system("cls");
cout << "Player name: \nPassword: ";
cur.Goto(13, 0);
string pl;
getline(cin, pl);
cur.Back();
cur.Goto(10, 1);
string psd;
getline(cin, psd);
INIwrite("doc", "num", to_string(n + 1));
INIwrite(to_string(n + 1), "player", pl);
INIwrite(to_string(n + 1), "level", "1");
INIwrite(to_string(n + 1), "mhp", "10");
INIwrite(to_string(n + 1), "pas", md5.encode(psd));
// start
Start(1, n + 1);
exit(0);
}
else if (c == 'o' || c == 'O') // 打开存档
{
bool c = 0;
system("cls");
long long num = 0;
while (num <= 0 || num > n)
{
cout << "Input rank: ";
string tmp;
getline(cin, tmp);
try
{
num = stoi(tmp);
}
catch(...)
{
c = 1;
break;
}
// cin.setstate(ios::goodbit);
}
if(c) continue;
cout << "Input password: " << flush;
string psd;
getline(cin, psd);
MD5 md5;
if (md5.encode(psd) != doc[num].pas)
{
system("cls");
continue;
}
// start
Start(doc[num].level, doc[num].num);
exit(0);
}
else if (c == 's' || c == 'S')
{
if (prockeys.empty())
{
prockeyspush(0x01);
prockeyspush(0x02);
prockeyspush(0x04);
prockeyspush(0x05);
prockeyspush(0x06);
prockeyspush(0x08);
prockeyspush(0x09);
prockeyspush(0x0d);
prockeyspush(0x14);
prockeyspush(0x1b);
prockeyspush(0x90);
prockeyspush(0x91);
for (long long i = 0x20; i <= 0x28; i++) prockeyspush(i);
for (long long i = 0x30; i <= 0x39; i++) prockeyspush(i);
for (long long i = 0x41; i <= 0x5a; i++) prockeyspush(i);
for (long long i = 0x60; i <= 0x6b; i++) prockeyspush(i);
for (long long i = 0x6d; i <= 0x87; i++) prockeyspush(i);
for (long long i = 0xa0; i <= 0xa5; i++) prockeyspush(i);
for (long long i = 0xba; i <= 0xc0; i++) prockeyspush(i);
for (long long i = 0xdb; i <= 0xde; i++) prockeyspush(i);
}
// 设置界面
settingGUI();
system("cls");
continue;
}// CloseHandle(hIn); return 0; } } else if (argc == 2) return 0; // 不合规矩 else // 开始吧 { monsterhp = (level = stoi(argv[1])) * 10; numini = stoi(argv[2]); } SetConsoleTitle(level ? (“地牢 Lvl.” + to_string(level)).data() : “地牢”);
clip = 5 * level; // 开始5弹夹
teleport = level * 2;
speed = 0;
inv.resize(WLINE * WCOL + 5);
fill(inv.begin(), inv.end(), -1);
string cmd = "mode con cols=" + to_string(COL * 2 + 50 + WCOL * 2) + " lines=" + to_string(max(WLINE, LINE) + 5);
cout << cmd << endl;
Sleep(1000);
system(cmd.data());
Sleep(1000);
monx = mony = 5;
x = y = 2;
wmx = WLINE;
wmy = WCOL;
mt.seed(st = time(NULL));
long long cnt = 0;
for (long long d = DIM - 1; d >= 0; d--) // 生成各维度的地图
{
do
{
++cnt;
if (cnt >= 5)
{
Start(level, numini);
CloseHandle(hIn);
return 0;
}
memset(whole, 0, sizeof whole);
for (long long i = 0; i <= WLINE; i++)
{
for (long long j = 0; j <= WCOL; j++)
{
if (i == j && j == 0)
continue;
if (i == WLINE && j == WCOL)
continue;
setwall(i, j, (mt() % 10 == UP) * UP);
setwall(i, j, (mt() % 10 == DOWN) * DOWN);
setwall(i, j, (mt() % 10 == LEFT) * LEFT);
setwall(i, j, (mt() % 10 == RIGHT) * RIGHT);
}
}
for (long long i = 0; i <= WLINE; i++)
{
setwall(i, 0, LEFT);
setwall(i, WCOL, RIGHT);
}
for (long long i = 0; i <= WCOL; i++)
{
setwall(0, i, UP);
setwall(WLINE, i, DOWN);
}
for (long long i = 0; i <= WLINE; i++) // 免得穿墙
{
for (long long j = 0; j <= WCOL; j++)
{
if (i != 0)
{
setwall(i, j, ((whole[0][i - 1][j] & DOWN) == DOWN) ? UP : 0);
}
if (i != WLINE)
{
setwall(i, j, ((whole[0][i + 1][j] & UP) == UP) ? DOWN : 0);
}
if (j != 0)
{
setwall(i, j, ((whole[0][i][j - 1] & RIGHT) == RIGHT) ? LEFT : 0);
}
if (j != WCOL)
{
setwall(i, j, ((whole[0][i][j + 1] & LEFT) == LEFT) ? RIGHT : 0);
}
}
}
cout << '@';
}
while (dfs(monster, player) == inv);
memcpy(whole[d], whole[0], sizeof(whole[d]));
}
//keybd_event(VK_LSHIFT, 0, 0, 0); // 帮你按一下shift
//keybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP, 0);
system("cls");
CreateThread(NULL, 0, T_MonsterProc, NULL, 0, NULL); // 启动线程
CreateThread(NULL, 0, T_LetBulletFly, NULL, 0, NULL);
CreateThread(NULL, 0, T_WriteMsg, NULL, 0, NULL);
CreateThread(NULL, 0, T_Shoot, NULL, 0, NULL);
CreateThread(NULL, 0, T_Move, NULL, 0, NULL);
CreateThread(NULL, 0, T_Print, NULL, 0, NULL);
// TODO
CONSOLE_CURSOR_INFO cci; // 不显示光标
GetConsoleCursorInfo(hOut, &cci);
cci.bVisible = 0;
SetConsoleCursorInfo(hOut, &cci);
mtime_t lasthide = 0;
while (1)
{
Sleep(10);
if (monster == player) // 碰到了
{
if (autotp && teleport) // 瞬移
{
player.mapx = mt() % WLINE;
player.mapy = mt() % WCOL;
player.x = LINE / 2;
player.y = COL / 2;
teleport--;
}
else if (mt() % (level * 2) >= 2) // 死
break;
else // 闪避
{
is_dodge = 1;
lasthide = getmtime();
}
}
if (is_dodge && getmtime() - lasthide > 50) is_dodge = 0;
if (airdrop == player) // 获得空投
{
clip += mt() % (level * 3);
teleport += mt() % (level);
memset(&airdrop, -1, sizeof(airdrop));
}
if (monsterhp == 0) // 怪死庆祝
{
INIwrite(to_string(numini), "level", to_string(level));
INIwrite(to_string(numini), "mhp", to_string(monsterhp));
SetColor(0x2d);
CreateThread(NULL, 0, T_GOBeep, NULL, 0, NULL);
DelayPrint("WIN!!!");
Sleep(1000);
Start(level + 1, numini);
CloseHandle(hIn);
return 0;
}
}
is_die = true; // 死了,通知其他线程结束
INIwrite(to_string(numini), "level", to_string(level));
INIwrite(to_string(numini), "mhp", to_string(monsterhp));
SetColor(0xc3);
CreateThread(NULL, 0, T_GOBeep, NULL, 0, NULL);
DelayPrint("Your computer has been fucked by the MEMZ trojan\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bGAME OVER!!!");
Sleep(10000);
CloseHandle(hIn);
return 0;}