正文
增加 279 行删除 259 行
37 行未改动383940414243444546474849505152535455565758598 行未改动686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712821 行未改动15015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728836 行未改动3253263273283293303313323333343353363373383393403413423433443453467 行未改动35435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341415 行未改动43043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057137 行未改动HANDLE hConsole;int mx,my,tx,ty,omx,omy,otx,oty,ldx,ldy,mhp=10,thp=10;bool fr,rp=true,mr=false,tr=false,go=false,hfa=false;DWORD fs,acd=0,ru=0,hfs;// 技能系统int skillChoice=0;DWORD qcd=0;bool speedBoost=false;DWORD lastQDisplay=0;// 射线相关(仅本地显示)bool rayActive=false;DWORD rayEndTime=0;int raySx=0,raySy=0;int rayDirX=0,rayDirY=0;bool sd(int x,int y){return x>=0&&y>=0&&x<W&&y<H&&MAP[y][x]==0;}bool sa(int x,int y){return x>=4&&x<=17&&y>=4&&y<=17;}bool rhe(int sx,int sy,int dx,int dy,int ex,int ey){int x=sx+dx,y=sy+dy;8 行未改动void dcell(int x,int y){dc(x,y,MAP[y][x]?'#':' ',7);}void drawRayLine(int sx,int sy,int dx,int dy,char ch,int col){int x=sx+dx,y=sy+dy;while(sd(x,y)){dc(x,y,ch,col);x+=dx;y+=dy;}}void clearRayLine(int sx,int sy,int dx,int dy){int x=sx+dx,y=sy+dy;while(sd(x,y)){dcell(x,y);x+=dx;y+=dy;}}void redrawPlayers(){dc(mx,my,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);if(ru&&GetTickCount()<=ru)dc(tx,ty,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);elsedcell(tx,ty);}void fsr(int col){CONSOLE_SCREEN_BUFFER_INFO c;GetConsoleScreenBufferInfo(hConsole,&c);SMALL_RECT s=c.srWindow;DWORD w;FillConsoleOutputAttribute(hConsole,(WORD)col,(s.Right-s.Left+1)*(s.Bottom-s.Top+1),{s.Left,s.Top},&w);}void srs(){SetConsoleCursorPosition(hConsole,{0,0});cout<<"===== 对战准备阶段 ====="<<endl;cout<<"我方: "<<(mr?"已准备":"未准备")<<" 对方: "<<(tr?"已准备":"未准备")<<endl;cout<<"按 空格 切换准备状态,按 Q 选择技能"<<endl;cout<<"当前技能: "<<(skillChoice==0?"加速":"射线")<<endl;}void shp(){int mc=FOREGROUND_RED|FOREGROUND_INTENSITY,tc=FOREGROUND_BLUE|FOREGROUND_INTENSITY;if(hfa&&GetTickCount()-hfs<500)mc=FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY;SetConsoleCursorPosition(hConsole,{W+2,0});SetConsoleTextAttribute(hConsole,mc);cout<<"我方 HP: "<<mhp<<" ";SetConsoleCursorPosition(hConsole,{W+2,1});SetConsoleTextAttribute(hConsole,tc);cout<<"对方 HP: "<<thp<<" ";SetConsoleCursorPosition(hConsole,{W+2,2});SetConsoleTextAttribute(hConsole,FOREGROUND_GREEN|FOREGROUND_INTENSITY);DWORD now=GetTickCount();string skillName = (skillChoice==0) ? "加速" : "射线";if(qcd>now){int remainSec = ((qcd-now)+999)/1000;cout<<"[Q]技能: "<<skillName<<" ("<<remainSec<<"s) ";}else if(speedBoost){cout<<"[Q]技能: 加速中 ";}else{cout<<"[Q]技能: "<<skillName<<" ";}SetConsoleTextAttribute(hConsole,7);}21 行未改动srs();char bf[256];string ca;DWORD lm=0;while(true){int r=recv(cli,bf,255,0);if(r>0){bf[r]=0;ca+=bf;size_t p;while((p=ca.find('\n'))!=string::npos){string msg=ca.substr(0,p);ca.erase(0,p+1);if(rp){if(msg=="[READY]"){tr=true;srs();if(mr&&tr){send(cli,"[START]\n",8,0);system("cls");for(int y=0;y<H;++y)for(int x=0;x<W;++x)dcell(x,y);dc(mx,my,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);dc(tx,ty,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);omx=mx;omy=my;otx=tx;oty=ty;rp=false;mhp=10;thp=10;shp();}}else if(msg=="[UNREADY]"){tr=false;srs();}}else if(!go){int x,y;if(sscanf(msg.c_str(),"[MOVE|%d|%d]",&x,&y)==2){if(sd(x,y)&&!(x==mx&&y==my)){dcell(otx,oty);tx=x;ty=y;otx=tx;oty=ty;if(ru&&GetTickCount()<=ru)dc(x,y,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);}}else if(msg=="[HIT]"){mhp--;fr=true;fs=GetTickCount();fsr(BACKGROUND_RED);hfa=true;hfs=GetTickCount();shp();char hm[64];sprintf(hm,"[HP|%d|%d]\n",mhp,thp);send(cli,hm,strlen(hm),0);if(mhp<=0){go=true;send(cli,"[GAMEOVER|对方]\n",16,0);sgo("对方");}}else if(msg=="[REVEAL]"){ru=GetTickCount()+1000;dcell(otx,oty);dc(tx,ty,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);}else if(msg=="[DEAD]"){go=true;send(cli,"[GAMEOVER|我方]\n",16,0);sgo("我方");}else if(sscanf(msg.c_str(),"[HP|%d|%d]",&x,&y)==2){thp=x;mhp=y;shp();}else if(msg=="[SPEED_ON]"){speedBoost=true;shp();}else if(msg=="[SPEED_OFF]"){speedBoost=false;shp();}// ★★★ 关键修复:客户端射线命中服务端 → 服务端自己掉血 ★★★else if(msg=="[RAY_HIT]"){mhp-=3; // 原来是 thp-=3,改为 mhp-=3shp();char hm[64];sprintf(hm,"[HP|%d|%d]\n",mhp,thp);send(cli,hm,strlen(hm),0);if(mhp<=0){go=true;send(cli,"[GAMEOVER|对方]\n",16,0);sgo("对方");}}}}}if(_kbhit()&&GetTickCount()-lm>120&&!go){char k=_getch();DWORD nw=GetTickCount();if(rp){if(k==' '){mr=!mr;send(cli,mr?"[READY]\n":"[UNREADY]\n",mr?8:11,0);srs();if(mr&&tr){send(cli,"[START]\n",8,0);system("cls");for(int y=0;y<H;++y)for(int x=0;x<W;++x)dcell(x,y);dc(mx,my,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);dc(tx,ty,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);omx=mx;omy=my;otx=tx;oty=ty;rp=false;mhp=10;thp=10;shp();}lm=nw;}else if(k=='q'||k=='Q'){skillChoice=(skillChoice+1)%2;srs();lm=nw;}}else{int nx=mx,ny=my,dx=0,dy=0;if(k=='w'||k=='W'){ny--;dy=-1;}else if(k=='s'||k=='S'){ny++;dy=1;}else if(k=='a'||k=='A'){nx--;dx=-1;}else if(k=='d'||k=='D'){nx++;dx=1;}else if(k==' '){if(nw-acd>=1000){acd=nw;char rv[64];sprintf(rv,"[REVEAL|%d|%d]\n",mx,my);send(cli,rv,strlen(rv),0);dcell(tx,ty);ru=0;if(rhe(mx,my,ldx,ldy,tx,ty))send(cli,"[HIT]\n",7,0);}lm=nw;continue;}else if(k=='q'||k=='Q'){DWORD cdDuration = (skillChoice==0) ? 4000 : 10000;if(nw>=qcd){qcd=nw+cdDuration;if(skillChoice==0){speedBoost=true;send(cli,"[SPEED_ON]\n",11,0);shp();}else{// 射线 - 仅本地显示if(ldx!=0||ldy!=0){raySx=mx;raySy=my;rayDirX=ldx;rayDirY=ldy;drawRayLine(mx,my,ldx,ldy,'*',FOREGROUND_RED|FOREGROUND_INTENSITY);rayActive=true;rayEndTime=nw+200;// 服务端射线命中客户端 → 扣客户端血量if(rhe(mx,my,ldx,ldy,tx,ty)){send(cli,"[RAY_HIT]\n",10,0);thp-=3; // 这是正确的:服务端视角扣对方(客户端)的血量shp();char hm[64];sprintf(hm,"[HP|%d|%d]\n",mhp,thp);send(cli,hm,strlen(hm),0);if(thp<=0){go=true;send(cli,"[GAMEOVER|我方]\n",16,0);sgo("我方");}}}shp();}}lm=nw;continue;}else continue;if(speedBoost){int stepX=dx,stepY=dy;int maxSteps=0;for(int i=1;i<=3;i++){int cx=mx+stepX*i,cy=my+stepY*i;if(!sd(cx,cy)||(cx==tx&&cy==ty))break;maxSteps=i;}if(maxSteps>0){nx=mx+stepX*maxSteps;ny=my+stepY*maxSteps;}else{lm=nw;continue;}}if(sd(nx,ny)&&!(nx==tx&&ny==ty)){dcell(omx,omy);dc(nx,ny,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);mx=nx;my=ny;omx=mx;omy=my;ldx=dx;ldy=dy;sprintf(bf,"[MOVE|%d|%d]\n",mx,my);send(cli,bf,strlen(bf),0);if(speedBoost){speedBoost=false;send(cli,"[SPEED_OFF]\n",12,0);shp();}lm=nw;}}}if(!rp&&!go){if(fr&&GetTickCount()-fs>200){fr=false;fsr(0);for(int y=0;y<H;++y)for(int x=0;x<W;++x)dcell(x,y);redrawPlayers();shp();}if(hfa&&GetTickCount()-hfs>300){hfa=false;shp();}if(ru&&GetTickCount()<=ru)dc(tx,ty,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);else dcell(tx,ty);if(ru&&GetTickCount()>ru){ru=0;dcell(tx,ty);}if(rayActive&&GetTickCount()>rayEndTime){rayActive=false;clearRayLine(raySx,raySy,rayDirX,rayDirY);redrawPlayers();}DWORD now=GetTickCount();if(now-lastQDisplay>=1000){lastQDisplay=now;shp();}}Sleep(10);}}36 行未改动HANDLE hConsole;int mx,my,ex,ey,omx,omy,oex,oey,ldx=0,ldy=0,mhp=10,ehp=10;bool fr,rp=true,mr=false,er=false,gs=false,go=false,hfa=false;DWORD fs,acd=0,ru=0,hfs;// 技能系统int skillChoice=0;DWORD qcd=0;bool speedBoost=false;DWORD lastQDisplay=0;// 射线相关(仅本地显示)bool rayActive=false;DWORD rayEndTime=0;int raySx=0,raySy=0;int rayDirX=0,rayDirY=0;bool sd(int x,int y){return x>=0&&y>=0&&x<W&&y<H&&MAP[y][x]==0;}bool rhe(int sx,int sy,int dx,int dy,int ex,int ey){int x=sx+dx,y=sy+dy;while(sd(x,y)){if(x==ex&&y==ey)return true;x+=dx;y+=dy;}7 行未改动void dcell(int x,int y){dc(x,y,MAP[y][x]?'#':' ',7);}void drawRayLine(int sx,int sy,int dx,int dy,char ch,int col){int x=sx+dx,y=sy+dy;while(sd(x,y)){dc(x,y,ch,col);x+=dx;y+=dy;}}void clearRayLine(int sx,int sy,int dx,int dy){int x=sx+dx,y=sy+dy;while(sd(x,y)){dcell(x,y);x+=dx;y+=dy;}}void redrawPlayers(){dc(mx,my,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);if(ru&&GetTickCount()<=ru)dc(ex,ey,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);elsedcell(ex,ey);}void fsr(int col){CONSOLE_SCREEN_BUFFER_INFO c;GetConsoleScreenBufferInfo(hConsole,&c);SMALL_RECT s=c.srWindow;DWORD w;FillConsoleOutputAttribute(hConsole,(WORD)col,(s.Right-s.Left+1)*(s.Bottom-s.Top+1),{s.Left,s.Top},&w);}void srs(){SetConsoleCursorPosition(hConsole,{0,0});cout<<"===== 对战准备阶段 ====="<<endl;cout<<"我方: "<<(mr?"已准备":"未准备")<<" 对方: "<<(er?"已准备":"未准备")<<endl;cout<<"按 空格 切换准备状态,按 Q 切换技能"<<endl;cout<<"当前技能: "<<(skillChoice==0?"加速":"射线")<<endl;}void shp(){int mc=FOREGROUND_RED|FOREGROUND_INTENSITY,ec=FOREGROUND_BLUE|FOREGROUND_INTENSITY;if(hfa&&GetTickCount()-hfs<500)mc=FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY;SetConsoleCursorPosition(hConsole,{W+2,0});SetConsoleTextAttribute(hConsole,mc);cout<<"我方 HP: "<<mhp<<" ";SetConsoleCursorPosition(hConsole,{W+2,1});SetConsoleTextAttribute(hConsole,ec);cout<<"对方 HP: "<<ehp<<" ";SetConsoleCursorPosition(hConsole,{W+2,2});SetConsoleTextAttribute(hConsole,FOREGROUND_GREEN|FOREGROUND_INTENSITY);DWORD now=GetTickCount();string skillName = (skillChoice==0) ? "加速" : "射线";if(qcd>now){int remainSec = ((qcd-now)+999)/1000;cout<<"[Q]技能: "<<skillName<<" ("<<remainSec<<"s) ";}else if(speedBoost){cout<<"[Q]技能: 加速中 ";}else{cout<<"[Q]技能: "<<skillName<<" ";}SetConsoleTextAttribute(hConsole,7);}15 行未改动u_long md=1;ioctlsocket(sk,FIONBIO,&md);char bf[256];string ca;bool ok=false;while(!ok){int n=recv(sk,bf,255,0);if(n>0){bf[n]=0;ca+=bf;size_t p;while((p=ca.find('\n'))!=string::npos){string m=ca.substr(0,p);ca.erase(0,p+1);int a,b,c,d;if(sscanf(m.c_str(),"[INIT|%d|%d|%d|%d]",&a,&b,&c,&d)==4){ex=a;ey=b;mx=c;my=d;ok=true;break;}}}Sleep(10);}system("cls");srs();DWORD lm=0;while(true){int n=recv(sk,bf,255,0);if(n>0){bf[n]=0;ca+=bf;size_t p;while((p=ca.find('\n'))!=string::npos){string msg=ca.substr(0,p);ca.erase(0,p+1);if(rp){if(msg=="[START]"){system("cls");for(int y=0;y<H;++y)for(int x=0;x<W;++x)dcell(x,y);dc(mx,my,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);dc(ex,ey,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);omx=mx;omy=my;oex=ex;oey=ey;rp=false;gs=true;mhp=10;ehp=10;shp();}else if(msg=="[READY]"){er=true;srs();}else if(msg=="[UNREADY]"){er=false;srs();}}else if(!go){int x,y;if(sscanf(msg.c_str(),"[MOVE|%d|%d]",&x,&y)==2){if(sd(x,y)&&!(x==mx&&y==my)){dcell(oex,oey);ex=x;ey=y;oex=ex;oey=ey;if(ru&&GetTickCount()<=ru)dc(x,y,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);}}else if(msg=="[HIT]"){mhp--;fr=true;fs=GetTickCount();fsr(BACKGROUND_RED);hfa=true;hfs=GetTickCount();shp();char hm[64];sprintf(hm,"[HP|%d|%d]\n",mhp,ehp);send(sk,hm,strlen(hm),0);if(mhp<=0){go=true;send(sk,"[DEAD]\n",7,0);sgo("对方");}}else if(sscanf(msg.c_str(),"[REVEAL|%d|%d]",&x,&y)==2){dcell(oex,oey);ex=x;ey=y;oex=ex;oey=ey;ru=GetTickCount()+1000;dc(ex,ey,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);}else if(sscanf(msg.c_str(),"[GAMEOVER|%[^]]]",bf)==1){go=true;sgo(string(bf));}else if(sscanf(msg.c_str(),"[HP|%d|%d]",&x,&y)==2){ehp=x;mhp=y;shp();}else if(msg=="[SPEED_ON]"){speedBoost=true;shp();}else if(msg=="[SPEED_OFF]"){speedBoost=false;shp();}// ★★★ 关键修复:服务端射线命中客户端 → 客户端自己掉血 ★★★else if(msg=="[RAY_HIT]"){mhp-=3; // 原来是 ehp-=3,改为 mhp-=3shp();char hm[64];sprintf(hm,"[HP|%d|%d]\n",mhp,ehp);send(sk,hm,strlen(hm),0);if(mhp<=0){go=true;send(sk,"[DEAD]\n",7,0);sgo("对方");}}}}}if(_kbhit()&&GetTickCount()-lm>120&&!go){char k=_getch();DWORD nw=GetTickCount();if(rp){if(k==' '){mr=!mr;send(sk,mr?"[READY]\n":"[UNREADY]\n",mr?8:11,0);srs();lm=nw;}else if(k=='q'||k=='Q'){skillChoice=(skillChoice+1)%2;srs();lm=nw;}}else{int nx=mx,ny=my,dx=0,dy=0;if(k=='w'||k=='W'){ny--;dy=-1;}else if(k=='s'||k=='S'){ny++;dy=1;}else if(k=='a'||k=='A'){nx--;dx=-1;}else if(k=='d'||k=='D'){nx++;dx=1;}else if(k==' '){if(nw-acd>=1000){acd=nw;send(sk,"[REVEAL]\n",9,0);dcell(ex,ey);ru=0;if(rhe(mx,my,ldx,ldy,ex,ey))send(sk,"[HIT]\n",7,0);}lm=nw;continue;}else if(k=='q'||k=='Q'){DWORD cdDuration = (skillChoice==0) ? 4000 : 10000;if(nw>=qcd){qcd=nw+cdDuration;if(skillChoice==0){speedBoost=true;send(sk,"[SPEED_ON]\n",11,0);shp();}else{if(ldx!=0||ldy!=0){raySx=mx;raySy=my;rayDirX=ldx;rayDirY=ldy;drawRayLine(mx,my,ldx,ldy,'*',FOREGROUND_RED|FOREGROUND_INTENSITY);rayActive=true;rayEndTime=nw+200;// 客户端射线命中服务端 → 扣服务端血量if(rhe(mx,my,ldx,ldy,ex,ey)){send(sk,"[RAY_HIT]\n",10,0);ehp-=3; // 这是正确的:客户端视角扣对方(服务端)的血量shp();char hm[64];sprintf(hm,"[HP|%d|%d]\n",mhp,ehp);send(sk,hm,strlen(hm),0);if(ehp<=0){go=true;send(sk,"[DEAD]\n",7,0);sgo("我方");}}}shp();}}lm=nw;continue;}else continue;if(speedBoost){int stepX=dx,stepY=dy;int maxSteps=0;for(int i=1;i<=3;i++){int cx=mx+stepX*i,cy=my+stepY*i;if(!sd(cx,cy)||(cx==ex&&cy==ey))break;maxSteps=i;}if(maxSteps>0){nx=mx+stepX*maxSteps;ny=my+stepY*maxSteps;}else{lm=nw;continue;}}if(sd(nx,ny)&&!(nx==ex&&ny==ey)){dcell(omx,omy);dc(nx,ny,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);mx=nx;my=ny;omx=mx;omy=my;ldx=dx;ldy=dy;sprintf(bf,"[MOVE|%d|%d]\n",mx,my);send(sk,bf,strlen(bf),0);if(speedBoost){speedBoost=false;send(sk,"[SPEED_OFF]\n",12,0);shp();}lm=nw;}}}if(gs&&!go){if(fr&&GetTickCount()-fs>200){fr=false;fsr(0);for(int y=0;y<H;++y)for(int x=0;x<W;++x)dcell(x,y);redrawPlayers();shp();}if(hfa&&GetTickCount()-hfs>300){hfa=false;shp();}if(ru&&GetTickCount()<=ru)dc(ex,ey,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);else dcell(ex,ey);if(ru&&GetTickCount()>ru){ru=0;dcell(ex,ey);}if(rayActive&&GetTickCount()>rayEndTime){rayActive=false;clearRayLine(raySx,raySy,rayDirX,rayDirY);redrawPlayers();}DWORD now=GetTickCount();if(now-lastQDisplay>=1000){lastQDisplay=now;shp();}}Sleep(10);}}```37 行未改动38394041424344454647484950518 行未改动6061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513621 行未改动15815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628736 行未改动3243253263273283293303313323333343353363377 行未改动34534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042115 行未改动43743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059137 行未改动HANDLE hConsole;int mx,my,tx,ty,omx,omy,otx,oty,ldx,ldy,mhp=10,thp=10;bool fr,rp=true,mr=false,tr=false,go=false,hfa=false;DWORD fs,acd=0,ru=0,selfRu=0,hfs,qcd=0,detectCD=0;bool speedBoost=false,rayActive=false,normalRayActive=false,previewActive=false;DWORD rayEndTime=0,normalRayEndTime=0,previewEndTime=0;int raySx,raySy,rayDirX,rayDirY,normalRaySx,normalRaySy,normalRayDirX,normalRayDirY;int skillChoice=0,prevSkillType=0;bool sd(int x,int y){return x>=0&&y>=0&&x<W&&y<H&&MAP[y][x]==0;}bool sa(int x,int y){return x>=4&&x<=17&&y>=4&&y<=17;}bool rhe(int sx,int sy,int dx,int dy,int ex,int ey){int x=sx+dx,y=sy+dy;8 行未改动void dcell(int x,int y){dc(x,y,MAP[y][x]?'#':' ',7);}void drawRayLine(int sx,int sy,int dx,int dy,char ch,int col){int x=sx+dx,y=sy+dy;while(sd(x,y)){dc(x,y,ch,col);x+=dx;y+=dy;}}void clearRayLine(int sx,int sy,int dx,int dy){int x=sx+dx,y=sy+dy;while(sd(x,y)){dcell(x,y);x+=dx;y+=dy;}}void redrawPlayers(){dc(mx,my,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);if(ru&&GetTickCount()<=ru) dc(tx,ty,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);else dcell(tx,ty);}void showPreview(int st){if(previewActive&&prevSkillType==1&&ldx!=0&&ldy!=0) clearRayLine(mx,my,ldx,ldy);previewActive=false;if(st==1&&ldx!=0&&ldy!=0){drawRayLine(mx,my,ldx,ldy,'*',FOREGROUND_GREEN|FOREGROUND_INTENSITY);previewActive=true; previewEndTime=GetTickCount()+500; prevSkillType=1;}}void fsr(int col){CONSOLE_SCREEN_BUFFER_INFO c;GetConsoleScreenBufferInfo(hConsole,&c);SMALL_RECT s=c.srWindow;DWORD w;FillConsoleOutputAttribute(hConsole,(WORD)col,(s.Right-s.Left+1)*(s.Bottom-s.Top+1),{s.Left,s.Top},&w);}void clsLine(int y){SetConsoleCursorPosition(hConsole,{0,(SHORT)y});cout<<string(80,' ');SetConsoleCursorPosition(hConsole,{0,(SHORT)y});}void srs(){for(int i=0;i<5;i++) clsLine(i);SetConsoleCursorPosition(hConsole,{0,0});cout<<"===== 对战准备阶段 ====="<<endl;cout<<"我方: "<<(mr?"已准备":"未准备")<<" 对方: "<<(tr?"已准备":"未准备")<<endl;cout<<"按 空格 切换准备状态,按 Q 选择技能"<<endl;cout<<"当前技能: ";if(skillChoice==0) cout<<"加速 (向前冲刺3格, CD:4秒)";else if(skillChoice==1) cout<<"射线 (向前发射射线造成3点伤害, 自身暴露2秒, CD:10秒)";else cout<<"探测 (检测周围3格内的敌人并暴露3秒, CD:5秒)";cout<<" ";}void shp(){if(go) return;int mc=FOREGROUND_RED|FOREGROUND_INTENSITY,tc=FOREGROUND_BLUE|FOREGROUND_INTENSITY;if(hfa&&GetTickCount()-hfs<500) mc=FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY;SetConsoleCursorPosition(hConsole,{W+2,0});SetConsoleTextAttribute(hConsole,mc);cout<<"我方 HP: "<<mhp<<" ";SetConsoleCursorPosition(hConsole,{W+2,1});SetConsoleTextAttribute(hConsole,tc);cout<<"对方 HP: "<<thp<<" ";SetConsoleCursorPosition(hConsole,{W+2,2});SetConsoleTextAttribute(hConsole,FOREGROUND_GREEN|FOREGROUND_INTENSITY);DWORD now=GetTickCount();string sn;if(skillChoice==0) sn="加速";else if(skillChoice==1) sn="射线";else sn="探测";if(skillChoice==2){if(detectCD>now) cout<<"[Q]技能: "<<sn<<" ("<<((detectCD-now+999)/1000)<<"s) ";else cout<<"[Q]技能: "<<sn<<" ";}else{if(qcd>now) cout<<"[Q]技能: "<<sn<<" ("<<((qcd-now+999)/1000)<<"s) ";else if(speedBoost) cout<<"[Q]技能: 加速中 ";else cout<<"[Q]技能: "<<sn<<" ";}SetConsoleTextAttribute(hConsole,7);}21 行未改动srs();char bf[256];string ca;DWORD lm=0;while(true){int r=recv(cli,bf,255,0);if(r>0){bf[r]=0;ca+=bf;size_t p;while((p=ca.find('\n'))!=string::npos){string msg=ca.substr(0,p);ca.erase(0,p+1);if(rp){if(msg=="[READY]"){tr=true;srs();if(mr&&tr){send(cli,"[START]\n",8,0);system("cls");for(int y=0;y<H;++y)for(int x=0;x<W;++x)dcell(x,y);dc(mx,my,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);dcell(tx,ty);omx=mx;omy=my;otx=tx;oty=ty;rp=false;mhp=10;thp=10;shp();}}else if(msg=="[UNREADY]"){tr=false;srs();}}else if(!go){int x,y;if(sscanf(msg.c_str(),"[MOVE|%d|%d]",&x,&y)==2){if(sd(x,y)&&!(x==mx&&y==my)){dcell(otx,oty);tx=x;ty=y;otx=tx;oty=ty;if(ru&&GetTickCount()<=ru)dc(x,y,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);}}else if(msg=="[HIT]"){mhp--;fr=true;fs=GetTickCount();fsr(BACKGROUND_RED);hfa=true;hfs=GetTickCount();sprintf(bf,"[HP|%d|%d]\n",mhp,thp);send(cli,bf,strlen(bf),0);if(mhp<=0){go=true;send(cli,"[GAMEOVER|对方]\n",16,0);sgo("对方");}else shp();}else if(msg=="[REVEAL]"){ru=GetTickCount()+1000;dcell(otx,oty);dc(tx,ty,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);}else if(msg=="[DEAD]"){go=true;send(cli,"[GAMEOVER|我方]\n",16,0);sgo("我方");}else if(sscanf(msg.c_str(),"[HP|%d|%d]",&x,&y)==2){thp=x;mhp=y;shp();}else if(msg=="[SPEED_ON]"){speedBoost=true;shp();}else if(msg=="[SPEED_OFF]"){speedBoost=false;shp();}else if(msg=="[RAY_HIT]"){mhp-=3;fr=true;fs=GetTickCount();fsr(BACKGROUND_RED);hfa=true;hfs=GetTickCount();sprintf(bf,"[HP|%d|%d]\n",mhp,thp);send(cli,bf,strlen(bf),0);if(mhp<=0){go=true;send(cli,"[GAMEOVER|对方]\n",16,0);sgo("对方");}else shp();}else if(msg=="[DETECT]"){ru=GetTickCount()+3000;dcell(otx,oty);dc(tx,ty,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);}else if(msg=="[SELF_REVEAL]"){// 对方(客户端)使用射线,暴露了自己2秒 -> 服务端能看到客户端的位置ru=GetTickCount()+2000;dcell(otx,oty);dc(tx,ty,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);}}}}if(_kbhit()&&GetTickCount()-lm>120&&!go){char k=_getch();DWORD nw=GetTickCount();if(rp){if(k==' '){mr=!mr;send(cli,mr?"[READY]\n":"[UNREADY]\n",mr?8:11,0);srs();if(mr&&tr){send(cli,"[START]\n",8,0);system("cls");for(int y=0;y<H;++y)for(int x=0;x<W;++x)dcell(x,y);dc(mx,my,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);dcell(tx,ty);omx=mx;omy=my;otx=tx;oty=ty;rp=false;mhp=10;thp=10;shp();}lm=nw;}else if(k=='q'||k=='Q'){skillChoice=(skillChoice+1)%3;srs();showPreview(skillChoice);lm=nw;}}else{int nx=mx,ny=my,dx=0,dy=0;if(k=='w'||k=='W'){ny--;dy=-1;}else if(k=='s'||k=='S'){ny++;dy=1;}else if(k=='a'||k=='A'){nx--;dx=-1;}else if(k=='d'||k=='D'){nx++;dx=1;}else if(k==' '){if(nw-acd>=1000){acd=nw;sprintf(bf,"[REVEAL|%d|%d]\n",mx,my);send(cli,bf,strlen(bf),0);if(ldx!=0||ldy!=0){normalRaySx=mx;normalRaySy=my;normalRayDirX=ldx;normalRayDirY=ldy;drawRayLine(mx,my,ldx,ldy,'*',FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY);normalRayActive=true;normalRayEndTime=nw+200;}if(rhe(mx,my,ldx,ldy,tx,ty)) send(cli,"[HIT]\n",7,0);}lm=nw;continue;}else if(k=='q'||k=='Q'){if(skillChoice==2){if(nw>=detectCD){detectCD=nw+5000;int dist = abs(mx-tx)+abs(my-ty);if(dist <= 3){ru=GetTickCount()+3000;dcell(otx,oty);dc(tx,ty,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);send(cli,"[DETECT]\n",9,0);}shp();}}else{DWORD cd=skillChoice==0?4000:10000;if(nw>=qcd){qcd=nw+cd;if(skillChoice==0){speedBoost=true;send(cli,"[SPEED_ON]\n",11,0);shp();}else if(ldx!=0||ldy!=0){// 使用射线:自身暴露2秒selfRu=nw+2000;send(cli,"[SELF_REVEAL]\n",14,0);raySx=mx;raySy=my;rayDirX=ldx;rayDirY=ldy;drawRayLine(mx,my,ldx,ldy,'*',FOREGROUND_RED|FOREGROUND_INTENSITY);rayActive=true;rayEndTime=nw+200;if(rhe(mx,my,ldx,ldy,tx,ty)){send(cli,"[RAY_HIT]\n",10,0);thp-=3;sprintf(bf,"[HP|%d|%d]\n",mhp,thp);send(cli,bf,strlen(bf),0);if(thp<=0){go=true;send(cli,"[GAMEOVER|我方]\n",16,0);sgo("我方");}else shp();}else shp();}else shp();}}lm=nw;continue;}else continue;if(speedBoost){int sx=dx,sy=dy,ms=0;for(int i=1;i<=3;i++){int cx=mx+sx*i,cy=my+sy*i;if(!sd(cx,cy)||(cx==tx&&cy==ty))break;ms=i;}if(ms>0){nx=mx+sx*ms;ny=my+sy*ms;}else{lm=nw;continue;}}if(sd(nx,ny)&&!(nx==tx&&ny==ty)){dcell(omx,omy);dc(nx,ny,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);mx=nx;my=ny;omx=mx;omy=my;ldx=dx;ldy=dy;sprintf(bf,"[MOVE|%d|%d]\n",mx,my);send(cli,bf,strlen(bf),0);if(speedBoost){speedBoost=false;send(cli,"[SPEED_OFF]\n",12,0);shp();}lm=nw;}}}if(!rp&&!go){DWORD now=GetTickCount();if(fr&&now-fs>200){fr=false;fsr(0);for(int y=0;y<H;++y)for(int x=0;x<W;++x)dcell(x,y);redrawPlayers();shp();}if(hfa&&now-hfs>300){hfa=false;shp();}if(ru&&now<=ru) dc(tx,ty,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);else if(ru&&now>ru){ru=0;dcell(tx,ty);}if(selfRu&&now<=selfRu) dc(mx,my,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);else if(selfRu&&now>selfRu){selfRu=0;dcell(mx,my);dc(mx,my,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);}if(previewActive&&now>previewEndTime){previewActive=false;if(prevSkillType==1&&ldx!=0&&ldy!=0){clearRayLine(mx,my,ldx,ldy);redrawPlayers();}}if(rayActive&&now>rayEndTime){rayActive=false;clearRayLine(raySx,raySy,rayDirX,rayDirY);redrawPlayers();}if(normalRayActive&&now>normalRayEndTime){normalRayActive=false;clearRayLine(normalRaySx,normalRaySy,normalRayDirX,normalRayDirY);redrawPlayers();}static DWORD lastShp=0;if(now-lastShp>=1000){lastShp=now;shp();}}Sleep(10);}}36 行未改动HANDLE hConsole;int mx,my,ex,ey,omx,omy,oex,oey,ldx=0,ldy=0,mhp=10,ehp=10;bool fr,rp=true,mr=false,er=false,gs=false,go=false,hfa=false;DWORD fs,acd=0,ru=0,selfRu=0,hfs,qcd=0,detectCD=0;bool speedBoost=false,rayActive=false,normalRayActive=false,previewActive=false;DWORD rayEndTime=0,normalRayEndTime=0,previewEndTime=0;int raySx,raySy,rayDirX,rayDirY,normalRaySx,normalRaySy,normalRayDirX,normalRayDirY;int skillChoice=0,prevSkillType=0;bool sd(int x,int y){return x>=0&&y>=0&&x<W&&y<H&&MAP[y][x]==0;}bool rhe(int sx,int sy,int dx,int dy,int ex,int ey){int x=sx+dx,y=sy+dy;while(sd(x,y)){if(x==ex&&y==ey)return true;x+=dx;y+=dy;}7 行未改动void dcell(int x,int y){dc(x,y,MAP[y][x]?'#':' ',7);}void drawRayLine(int sx,int sy,int dx,int dy,char ch,int col){int x=sx+dx,y=sy+dy;while(sd(x,y)){dc(x,y,ch,col);x+=dx;y+=dy;}}void clearRayLine(int sx,int sy,int dx,int dy){int x=sx+dx,y=sy+dy;while(sd(x,y)){dcell(x,y);x+=dx;y+=dy;}}void redrawPlayers(){dc(mx,my,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);if(ru&&GetTickCount()<=ru) dc(ex,ey,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);else dcell(ex,ey);}void showPreview(int skillType){if(previewActive&&prevSkillType==1&&ldx!=0&&ldy!=0) clearRayLine(mx,my,ldx,ldy);previewActive=false;if(skillType==1&&ldx!=0&&ldy!=0){drawRayLine(mx,my,ldx,ldy,'*',FOREGROUND_GREEN|FOREGROUND_INTENSITY);previewActive=true; previewEndTime=GetTickCount()+500; prevSkillType=1;}}void fsr(int col){CONSOLE_SCREEN_BUFFER_INFO c;GetConsoleScreenBufferInfo(hConsole,&c);SMALL_RECT s=c.srWindow;DWORD w;FillConsoleOutputAttribute(hConsole,(WORD)col,(s.Right-s.Left+1)*(s.Bottom-s.Top+1),{s.Left,s.Top},&w);}void clsLine(int y){SetConsoleCursorPosition(hConsole,{0,(SHORT)y});cout<<string(80,' ');SetConsoleCursorPosition(hConsole,{0,(SHORT)y});}void srs(){clsLine(0); clsLine(1); clsLine(2); clsLine(3); clsLine(4);SetConsoleCursorPosition(hConsole,{0,0});cout<<"===== 对战准备阶段 ====="<<endl;cout<<"我方: "<<(mr?"已准备":"未准备")<<" 对方: "<<(er?"已准备":"未准备")<<endl;cout<<"按 空格 切换准备状态,按 Q 切换技能"<<endl;cout<<"当前技能: ";if(skillChoice==0) cout<<"加速 (向前冲刺3格, CD:4秒)";else if(skillChoice==1) cout<<"射线 (向前发射射线造成3点伤害, 自身暴露2秒, CD:10秒)";else cout<<"探测 (检测周围3格内的敌人并暴露3秒, CD:5秒)";cout<<" ";}void shp(){if(go) return;int mc=FOREGROUND_RED|FOREGROUND_INTENSITY,ec=FOREGROUND_BLUE|FOREGROUND_INTENSITY;if(hfa&&GetTickCount()-hfs<500) mc=FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY;SetConsoleCursorPosition(hConsole,{W+2,0});SetConsoleTextAttribute(hConsole,mc);cout<<"我方 HP: "<<mhp<<" ";SetConsoleCursorPosition(hConsole,{W+2,1});SetConsoleTextAttribute(hConsole,ec);cout<<"对方 HP: "<<ehp<<" ";SetConsoleCursorPosition(hConsole,{W+2,2});SetConsoleTextAttribute(hConsole,FOREGROUND_GREEN|FOREGROUND_INTENSITY);DWORD now=GetTickCount();string sn;if(skillChoice==0) sn="加速";else if(skillChoice==1) sn="射线";else sn="探测";if(skillChoice==2){if(detectCD>now) cout<<"[Q]技能: "<<sn<<" ("<<((detectCD-now+999)/1000)<<"s) ";else cout<<"[Q]技能: "<<sn<<" ";}else{if(qcd>now) cout<<"[Q]技能: "<<sn<<" ("<<((qcd-now+999)/1000)<<"s) ";else if(speedBoost) cout<<"[Q]技能: 加速中 ";else cout<<"[Q]技能: "<<sn<<" ";}SetConsoleTextAttribute(hConsole,7);}15 行未改动u_long md=1;ioctlsocket(sk,FIONBIO,&md);char bf[256];string ca;bool ok=false;while(!ok){int n=recv(sk,bf,255,0);if(n>0){bf[n]=0;ca+=bf;size_t p;while((p=ca.find('\n'))!=string::npos){string m=ca.substr(0,p);ca.erase(0,p+1);int a,b,c,d;if(sscanf(m.c_str(),"[INIT|%d|%d|%d|%d]",&a,&b,&c,&d)==4){ex=a;ey=b;mx=c;my=d;ok=true;break;}}}Sleep(10);}system("cls");srs();DWORD lm=0;while(true){int n=recv(sk,bf,255,0);if(n>0){bf[n]=0;ca+=bf;size_t p;while((p=ca.find('\n'))!=string::npos){string msg=ca.substr(0,p);ca.erase(0,p+1);if(rp){if(msg=="[START]"){system("cls");for(int y=0;y<H;++y) for(int x=0;x<W;++x) dcell(x,y);dc(mx,my,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);dcell(ex,ey);omx=mx; omy=my; oex=ex; oey=ey; rp=false; gs=true; mhp=10; ehp=10; shp();}else if(msg=="[READY]"){er=true; srs();}else if(msg=="[UNREADY]"){er=false; srs();}}else if(!go){int x,y;if(sscanf(msg.c_str(),"[MOVE|%d|%d]",&x,&y)==2){if(sd(x,y)&&!(x==mx&&y==my)){dcell(oex,oey); ex=x; ey=y; oex=ex; oey=ey;if(ru&&GetTickCount()<=ru) dc(x,y,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);}}else if(msg=="[HIT]"){mhp--; fr=true; fs=GetTickCount(); fsr(BACKGROUND_RED); hfa=true; hfs=GetTickCount();sprintf(bf,"[HP|%d|%d]\n",mhp,ehp); send(sk,bf,strlen(bf),0);if(mhp<=0){go=true; send(sk,"[DEAD]\n",7,0); sgo("对方");}else shp();}else if(sscanf(msg.c_str(),"[REVEAL|%d|%d]",&x,&y)==2){dcell(oex,oey); ex=x; ey=y; oex=ex; oey=ey; ru=GetTickCount()+1000;dc(ex,ey,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);}else if(sscanf(msg.c_str(),"[GAMEOVER|%[^]]]",bf)==1){go=true; sgo(string(bf));}else if(sscanf(msg.c_str(),"[HP|%d|%d]",&x,&y)==2){ehp=x; mhp=y; shp();}else if(msg=="[SPEED_ON]"){speedBoost=true; shp();}else if(msg=="[SPEED_OFF]"){speedBoost=false; shp();}else if(msg=="[RAY_HIT]"){mhp-=3; fr=true; fs=GetTickCount(); fsr(BACKGROUND_RED); hfa=true; hfs=GetTickCount();sprintf(bf,"[HP|%d|%d]\n",mhp,ehp); send(sk,bf,strlen(bf),0);if(mhp<=0){go=true; send(sk,"[DEAD]\n",7,0); sgo("对方");}else shp();}else if(msg=="[DETECT]"){ru=GetTickCount()+3000;dcell(oex,oey);dc(ex,ey,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);}else if(msg=="[SELF_REVEAL]"){// 对方(服务端)使用射线,暴露了自己2秒 -> 客户端能看到服务端的位置ru=GetTickCount()+2000;dcell(oex,oey);dc(ex,ey,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);}}}}if(_kbhit()&&GetTickCount()-lm>120&&!go){char k=_getch(); DWORD nw=GetTickCount();if(rp){if(k==' '){mr=!mr; send(sk,mr?"[READY]\n":"[UNREADY]\n",mr?8:11,0); srs(); lm=nw;}else if(k=='q'||k=='Q'){skillChoice=(skillChoice+1)%3; srs(); showPreview(skillChoice); lm=nw;}}else{int nx=mx,ny=my,dx=0,dy=0;if(k=='w'||k=='W'){ny--; dy=-1;}else if(k=='s'||k=='S'){ny++; dy=1;}else if(k=='a'||k=='A'){nx--; dx=-1;}else if(k=='d'||k=='D'){nx++; dx=1;}else if(k==' '){if(nw-acd>=1000){acd=nw; send(sk,"[REVEAL]\n",9,0);if(ldx!=0||ldy!=0){normalRaySx=mx; normalRaySy=my; normalRayDirX=ldx; normalRayDirY=ldy;drawRayLine(mx,my,ldx,ldy,'*',FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY);normalRayActive=true; normalRayEndTime=nw+200;}if(rhe(mx,my,ldx,ldy,ex,ey)) send(sk,"[HIT]\n",7,0);}lm=nw; continue;}else if(k=='q'||k=='Q'){if(skillChoice==2){if(nw>=detectCD){detectCD=nw+5000;int dist = abs(mx-ex)+abs(my-ey);if(dist <= 3){ru=GetTickCount()+3000;dcell(oex,oey);dc(ex,ey,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);send(sk,"[DETECT]\n",9,0);}shp();}}else{DWORD cd=skillChoice==0?4000:10000;if(nw>=qcd){qcd=nw+cd;if(skillChoice==0){speedBoost=true; send(sk,"[SPEED_ON]\n",11,0); shp();}else if(ldx!=0||ldy!=0){// 使用射线:自身暴露2秒selfRu=nw+2000;send(sk,"[SELF_REVEAL]\n",14,0);raySx=mx; raySy=my; rayDirX=ldx; rayDirY=ldy;drawRayLine(mx,my,ldx,ldy,'*',FOREGROUND_RED|FOREGROUND_INTENSITY);rayActive=true; rayEndTime=nw+200;if(rhe(mx,my,ldx,ldy,ex,ey)){send(sk,"[RAY_HIT]\n",10,0); ehp-=3;sprintf(bf,"[HP|%d|%d]\n",mhp,ehp); send(sk,bf,strlen(bf),0);if(ehp<=0){go=true; send(sk,"[DEAD]\n",7,0); sgo("我方");}else shp();}else shp();}else shp();}}lm=nw; continue;}else continue;if(speedBoost){int sx=dx,sy=dy,ms=0;for(int i=1;i<=3;i++){int cx=mx+sx*i,cy=my+sy*i; if(!sd(cx,cy)||(cx==ex&&cy==ey)) break; ms=i;}if(ms>0){nx=mx+sx*ms; ny=my+sy*ms;} else{lm=nw; continue;}}if(sd(nx,ny)&&!(nx==ex&&ny==ey)){dcell(omx,omy); dc(nx,ny,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);mx=nx; my=ny; omx=mx; omy=my; ldx=dx; ldy=dy;sprintf(bf,"[MOVE|%d|%d]\n",mx,my); send(sk,bf,strlen(bf),0);if(speedBoost){speedBoost=false; send(sk,"[SPEED_OFF]\n",12,0); shp();}lm=nw;}}}if(gs&&!go){DWORD now=GetTickCount();if(fr&&now-fs>200){fr=false; fsr(0); for(int y=0;y<H;++y) for(int x=0;x<W;++x) dcell(x,y); redrawPlayers(); shp();}if(hfa&&now-hfs>300){hfa=false; shp();}if(ru&&now<=ru) dc(ex,ey,'O',FOREGROUND_BLUE|FOREGROUND_INTENSITY);else if(ru&&now>ru){ru=0; dcell(ex,ey);}if(selfRu&&now<=selfRu) dc(mx,my,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);else if(selfRu&&now>selfRu){selfRu=0; dcell(mx,my);dc(mx,my,'O',FOREGROUND_RED|FOREGROUND_INTENSITY);}if(previewActive&&now>previewEndTime){previewActive=false; if(prevSkillType==1&&ldx!=0&&ldy!=0){clearRayLine(mx,my,ldx,ldy); redrawPlayers();}}if(rayActive&&now>rayEndTime){rayActive=false; clearRayLine(raySx,raySy,rayDirX,rayDirY); redrawPlayers();}if(normalRayActive&&now>normalRayEndTime){normalRayActive=false; clearRayLine(normalRaySx,normalRaySy,normalRayDirX,normalRayDirY); redrawPlayers();}static DWORD lastShp=0;if(now-lastShp>=1000){lastShp=now; shp();}}Sleep(10);}}```