Uses Key,Dos; Const PalMask = $36C; PalRegR = $3C7; PalRegW = $3C8; PalData = $3C9; FadeSpeed = 20; { Скорость гашения/проявления экрана } OwnCol : Array[1..3] of Byte = (40,20,30); DirName : Array[1..8] of String = ('TASM','MASM','DEBUGGER','RealMode','PMode','WORKS','SUPPORT','DOC'); DirCost : Array[1..8] of LongInt= (500, 1000, 1000, 2000, 4000, 1250, 1500, 700); PrevDir : Array[1..8] of Byte = (0, 1, 2, 2, 4, 2, 1, 0); Stock : Array[1..5] of Byte = (15,7,5,4,3); HP : Array[1..5] of LongInt = (1,10,15,25,30); Atak : Array[1..5,1..2] of Byte = ((1,1),(2,3),(3,4),(4,6),(5,10)); Cost : Array[1..5] of LongInt = (20,150,200,250,300); Mov : Array[1..5] of Byte = (2,2,4,4,6); Spells : Array[1..5] of String = ('Защита','Ламер','Win95','SmartDrv','Нет ошибок'); Exp : Array[1..5] of Integer = (1,10,25,50,75); Type TPalette = Array[0..255] of record R,G,B : Byte; End; { Палитра } TSpr = Array[0..15,0..15] of byte; TFont = Array[128..239,1..8] of byte; TMouseBuf = Array[1..16,1..16] of byte; THacker = record X,Y : LongInt; own : Byte; CurMove : Byte; Army : Array[1..5] of LongInt; Move,Know : Byte; Exp : LongInt; End; TComp = record X,Y : LongInt; own : Byte; Army : Array[1..5] of LongInt; Stock : Array[1..5] of LongInt; Dir : Array[0..8] of Boolean; Built : Boolean; End; Var DBuf : Pointer; { Double Buffer } MouseBuf : ^TMouseBuf; Int1CSave : Pointer; MouseVis : Boolean; MouseX,MouseY : Integer; MouseSpr : ^TSpr; Fnt : ^TFont; SegDB : Word; { Сегмент double-buffer'a } Pal,NullPal : TPalette; { Палитра для спрайтов и "пустая" палитра } Spr : Array[1..11] of Pointer; { Спрайты } A,B,C,D,E : LongInt; U : Array[1..50] of THacker; H : Array[1..50] of TComp; NU,NH : Integer; MX,MY : LongInt; Xm,Ym : Integer; Lb,Mb,Rb : Boolean; Time : LongInt; Timer : LongInt absolute $40:$6c; Mon1,Mon2 : LongInt; SelW : Boolean; {True=hacker,False=comp} Sel : Integer; {# of selected unit} X,Y,X1,Y1 : LongInt; Xp,Yp : ShortInt; S : String; Trade : Boolean; Day : Byte; {$L spr} {$L rus} {$L mouse} Procedure Sprites; far; external; Procedure RusFont; far; external; Procedure MouseSp; far; external; Procedure ReSetMouse; Var R : Registers; Begin R.ax:=0; Intr($33,R); End; Procedure ReadMouseState(Var XMo,YMo : Integer;Var Lb,Mb,Rb : Boolean); Var R : Registers; Begin R.ax:=3; Intr($33,R); XMo:=R.cx; YMo:=R.dx; Lb:=R.bx and 1=1; Rb:=R.bx and 2=2; Mb:=R.bx and 4=4; End; Procedure WaitRelBut; Var Xm,Ym : Integer; Lb,Mb,Rb : Boolean; Begin Repeat ReadMouseState(Xm,Ym,Lb,Mb,Rb); Until Not Lb and Not Rb; End; Procedure DrawSpriteD(Spr : TSpr;x,y : Word); assembler; Asm Mov ax,SegDB Mov es,ax Mov di,y Shl di,6 Mov bx,di Shl di,2 Add di,bx Add di,x push ds lds si,spr mov cx,16 @Me1 : push cx mov cx,16 @Me2 : Mov al,[si] Cmp al,0 Je @Me3 Mov es:[di],al @Me3 : Inc di Inc si Loop @Me2 pop cx add di,304 Loop @Me1 Pop ds End; Procedure ReadUnderMouse; assembler; Asm Push ds Les di,MouseBuf Mov si,MouseY Shl si,6 Mov bx,si Shl si,2 Add si,bx Add si,MouseX Mov ax,SegA000 Mov ds,ax Mov cx,16 Cld @m1 : Push cx Mov cx,8 Rep MovsW Pop cx Add si,304 Loop @m1 Pop ds End; Procedure ShowUnderMouse; assembler; Asm Push ds Mov ax,SegA000 Mov es,ax Mov di,MouseY Shl di,6 Mov bx,di Shl di,2 Add di,bx Add di,MouseX Lds si,MouseBuf Cld Mov cx,16 @mm1 : Push cx Mov cx,8 Rep MovsW Pop cx Add di,304 Loop @mm1 Pop ds End; Procedure DrawSpriteT(Spr : TSpr;x,y : Word); assembler; Asm Mov ax,SegA000 Mov es,ax Mov di,y Shl di,6 Mov bx,di Shl di,2 Add di,bx Add di,x push ds lds si,spr mov cx,16 @Metk1 : push cx mov cx,16 @metk2 : Mov al,[si] Cmp al,0 Je @metk3 Mov es:[di],al @metk3 : Inc si Inc di Loop @metk2 pop cx add di,304 Loop @Metk1 Pop ds End; Procedure ShowMous; Begin DrawSpriteT(MouseSpr^,MouseX,MouseY); End; Procedure ShowMous2; Begin DrawSpriteD(MouseSpr^,MouseX,MouseY); End; Procedure ShowMouse; Var Lb,Mb,Rb : Boolean; Begin ReadMouseState(MouseX,MouseY,Lb,Mb,Rb); MouseX:=MouseX Shr 1; MouseVis:=True; ReadUnderMouse; ShowMous; End; Procedure HideMouse; Begin MouseVis:=False; ShowUnderMouse; End; Procedure ShMo; Begin DrawSpriteD(MouseSpr^,MouseX,MouseY); End; Procedure RdMo; assembler; Asm Push ds Les di,MouseBuf Mov si,MouseY Shl si,6 Mov bx,si Shl si,2 Add si,bx Add si,MouseX Push si Mov ax,SegDB Mov ds,ax Pop si Mov cx,16 Cld @m1 : Push cx Mov cx,8 Rep MovsW Pop cx Add si,304 Loop @m1 Pop ds End; {$F+,S-,W-} procedure TimerHandler; interrupt; Var xm,ym : Integer; Lb,Rb,Mb : Boolean; begin { Timer ISR } If MouseVis then Begin ReadMouseState(xm,ym,Lb,Mb,Rb); If (xm Shr 1<>MouseX) or (ym<>MouseY) then Begin ShowUnderMouse; MouseX:=Xm Shr 1; MouseY:=Ym; If MouseX>304 then MouseX:=304; If MouseY>184 then MouseY:=184; ReadUnderMouse; ShowMous; End; End; end; {$F-,S+} Procedure GrInit; var a,b,c : longint; s,o : Word; Begin New(Fnt); S:=Seg(RusFont); O:=Ofs(RusFont); c:=0; For a:=128 to 239 do For b:=1 to 8 do Begin Fnt^[a,b]:=Mem[S:O+c]; Inc(c); End; MouseSpr:=@MouseSp; New(MouseBuf); MouseVis:=False; ResetMouse; GetIntVec($1C,Int1CSave); SetIntVec($1C,@TimerHandler); GetMem(DBuf,64000+16); SegDB:=Seg(DBuf^)+1; asm mov ax,13h int 10h end; End; Procedure GrDone; Begin SetIntVec($1C,Int1CSave); FreeMem(DBuf,64000+16); asm mov ax,3 int 10h end; End; Procedure PixelD(x,y : Word;Color : Byte); assembler; Asm Mov ax,SegDB Mov es,ax Mov di,y Shl di,6 Mov bx,di Shl di,2 Add di,bx Add di,x Mov al,Byte Ptr color Mov es : [di],al End; Procedure SetPalReg(index,Red,Green,Blue : Byte); Begin Port[PalMask]:=$FF; Port[PalRegW]:=index; Port[PalData]:=Red; Port[PalData]:=Green; Port[PalData]:=Blue; End; Procedure SetPalette(Pal : TPalette); Var I : Byte; Begin For I:=0 to 255 do SetPalReg(I,Pal[I].R,Pal[I].G,Pal[I].B); End; Procedure FadePal(Pal : TPalette); Var A,B : LongInt; P : TPalette; T : LongInt; Begin For B:=FadeSpeed downto 0 do Begin For A:=0 to 255 do Begin P[A].R:=Trunc(Pal[A].R*B/FadeSpeed); P[A].G:=Trunc(Pal[A].G*B/FadeSpeed); P[A].B:=Trunc(Pal[A].B*B/FadeSpeed); End; SetPalette(P); T:=MemL[$40:$6c]; Repeat Until MemL[$40:$6c]-T>=1; End; End; Procedure LightPal(Pal : TPalette); Var A,B : LongInt; P : TPalette; T : LongInt; Begin For B:=0 to FadeSpeed do Begin For A:=0 to 255 do Begin P[A].R:=Trunc(Pal[A].R*B/FadeSpeed); P[A].G:=Trunc(Pal[A].G*B/FadeSpeed); P[A].B:=Trunc(Pal[A].B*B/FadeSpeed); End; SetPalette(P); T:=MemL[$40:$6c]; Repeat Until MemL[$40:$6c]-T>=1; End; End; Procedure ShowDouble; assembler; Asm Mov dl,MouseVis Push dx Mov MouseVis,0 Cmp dl,1 Jne @dal1 Call RdMo Call ShMo @dal1 : Push ds Mov ax,SegA000 Mov es,ax Mov di,0 Mov cx,32000 Mov ax,SegDB Mov ds,ax Mov si,0 Cld Rep MovsW Pop ds Pop dx Mov MouseVis,dl End; Procedure Cls(Color : Byte); assembler; asm mov ax,0A000h mov es,ax xor di,di mov al,Color mov ah,al mov cx,32000 Cld rep stosw End; Procedure ClsD(Color : Byte); assembler; asm mov es,SegDB xor di,di mov al,Color mov ah,al mov cx,32000 Cld rep stosw End; Procedure PrintD(S : String;x,y : Word; color : Byte); Var Segm,i,x1,y1,Off : Word; Procedure PrtD(Ch : Char;x,y,off : Word; color : Byte); Var WrkSeg,WrkOff,x2,y2,TOff : Word; BitMask,O : Byte; Begin If Ord(Ch)<128 then Begin TOff:=Off; WrkSeg:=$F000; WrkOff:=$FA6E+(Ord(Ch) shl 3); For y:=0 to 7 do Begin BitMask:=$80; For x:=0 to 7 do Begin If Mem[WrkSeg:WrkOff] and BitMask<>0 then Mem[Segm:(TOff+x)]:=color; BitMask:=BitMask shr 1; End; Inc(TOff,320); Inc(WrkOff); End; End else Begin TOff:=Off; O:=Ord(CH); For y:=1 to 8 do Begin BitMask:=$80; For x:=0 to 7 do Begin If Fnt^[o,y] and BitMask<>0 then Mem[Segm:(TOff+x)]:=color; BitMask:=BitMask shr 1; End; Inc(TOff,320); End; End; End; Begin x1:=x;y1:=y; Off:=(y shl 8)+(y shl 6)+x; Segm:=SegDB; For i:=1 to length(s) do Begin PrtD(s[i],x1,y1,off,color); Inc(x1,8); Inc(off,8); End; End; Procedure ShowTransD(x,y : Word;Spr : Pointer); assembler; Asm Mov ax,SegDB Mov es,ax Mov di,y Shl di,6 Mov bx,di Shl di,2 Add di,bx Add di,x push ds mov cx,32 mov bx,32 lds si,spr @Met1 : push cx mov cx,bx @Met2 : mov al,ds:[si] cmp al,7 jz @Met3 mov es:[di],al @Met3: inc di inc si loop @Met2 pop cx add di,320 sub di,bx Loop @Met1 Pop ds End; Procedure ShowSprD(x,y : Word;col:byte;Spr : Pointer); assembler; Asm Mov ax,SegDB Mov es,ax Mov di,y Shl di,6 Mov bx,di Shl di,2 Add di,bx Add di,x push ds mov cx,32 mov bx,32 lds si,spr @Met1 : push cx mov cx,bx @Met2 : mov al,ds:[si] cmp al,255 jnz @Met4 mov al,col @Met4: mov es:[di],al @Met3: inc di inc si loop @Met2 pop cx add di,320 sub di,bx Loop @Met1 Pop ds End; Procedure ShowRevD(x,y : Word;Spr : Pointer); assembler; Asm Mov ax,SegDB Mov es,ax Mov di,y Shl di,6 Mov bx,di Shl di,2 Add di,bx Add di,x add di,32 dec di push ds mov cx,32 mov bx,32 lds si,spr @Met1 : push cx mov cx,bx @Met2 : mov al,ds:[si] cmp al,7 jz @Met3 mov es:[di],al @Met3: dec di inc si loop @Met2 pop cx add di,320 add di,bx Loop @Met1 Pop ds End; procedure VRT; assembler; asm mov dx,3DAh @VRT1: in al,dx test al,8 jnz @VRT1 @VRT2: in al,dx test al,8 jz @VRT2 end; Procedure InitAll; Begin Day:=1; NH:=20; For A:=1 to NH do With H[A] do Begin X:=Random(58)+3; Y:=Random(58)+3; own:=3; Army[1]:=Random(11)+20; Army[2]:=Random(5)+10; Army[3]:=Random(5); Army[4]:=Random(2); FillChar(Dir,SizeOf(Dir),False); FillChar(Stock,SizeOf(Stock),0); End; H[1].own:=1; H[2].own:=2; NU:=2; FillChar(H[1].Army,20,0); FillChar(H[2].Army,20,0); With U[1] do Begin X:=H[1].X; Y:=H[1].Y+2; own:=1; CurMove:=5; Army[1]:=Random(6)+5; Army[2]:=Random(4)+2; Army[3]:=0; Army[4]:=0; Army[5]:=0; Move:=0;Know:=0;Exp:=0; End; MX:=U[1].X-3; MY:=U[1].Y-3; If MX<0 then MX:=0; If MY<0 then MY:=0; If MX>58 then MX:=58; If MY>58 then MY:=58; With U[2] do Begin X:=H[2].X; Y:=H[2].Y+2; own:=2; CurMove:=5; Army[1]:=Random(6)+5; Army[2]:=Random(4)+2; Army[3]:=0; Army[4]:=0; Army[5]:=0; Move:=0;Know:=0;Exp:=0; End; Mon1:=3000; Mon2:=3000; SelW:=True; Sel:=1; End; Procedure DrawAll; Var TX,TY : LongInt; Begin Trade:=False; ClsD(0); For A:=1 to NH do Begin If (H[A].X>=MX) and (H[A].X=MY) and (H[A].Y=MX) and (U[A].X=MY) and (U[A].Y1 then PrintD('Вражеский хакер',200,70,20) else Begin B:=0; For A:=1 to NU do Begin If U[A].own=1 then Inc(B); If A=Sel then Break; End; Str(B,S); PrintD('Хакер N'+S,200,70,20); Str(U[Sel].CurMove,S); PrintD('Ост. ходов:'+S,200,90,20); Str(U[Sel].Move,S); PrintD('движение:'+S,200,120,20); Str(U[Sel].Know,S); PrintD('знание:'+S,200,128,20); Str(U[Sel].Exp,S); PrintD('Опыт:'+S,200,136,20); For A:=1 to NH do If (H[A].own=1) and (H[A].X=U[Sel].X) and (H[A].Y+1=U[Sel].Y) then Begin PrintD('Обмен с компом',200,110,27); Trade:=True; End; End End else If H[Sel].own<>1 then PrintD('Вражеский комп',200,70,20) else Begin B:=0; For A:=1 to NH do Begin If H[A].own=1 then Inc(B); If A=Sel then Break; End; Str(B,S); PrintD('Компьютер N'+S,200,70,20); PrintD('Каталоги...',200,80,27); PrintD('Купить...',200,90,27); End; If SelW then Begin PrintD('Следующий хакер',200,80,27); End; Str(Mon1,S); PrintD('$'+S,200,190,30); Str(Day,S); PrintD('День:'+S,200,180,20); PrintD('Закончить ход',200,170,27); End; Procedure ShowStat(SelW : Boolean;Sel : Integer); Begin DrawAll; asm mov es,SegDB mov di,20*320+40 mov bx,80 mov ax,$0505 @m1: mov cx,120 rep stosw add di,320-120*2 dec bx jnz @m1 End; ShowTransD(42,22,Spr[3]); ShowTransD(42,62,Spr[4]); ShowTransD(122,22,Spr[7]); ShowTransD(122,62,Spr[8]); ShowTransD(202,22,Spr[10]); If SelW then Begin If U[Sel].own=1 then Begin Str(U[Sel].Army[1],S); PrintD(S,80,35,15); Str(U[Sel].Army[2],S); PrintD(S,80,75,15); Str(U[Sel].Army[3],S); PrintD(S,160,35,15); Str(U[Sel].Army[4],S); PrintD(S,160,75,15); Str(U[Sel].Army[5],S); PrintD(S,240,35,15); End else Begin A:=U[Sel].Army[1]; If A=0 then S:=' нет' else If A<5 then S:='омало' else If A<15 then S:=' мало' else If A<30 then S:=' средне' else If A<75 then S:=' много' else S:='омного'; If S[1]='о' then PrintD('очень',80,27,15); Delete(S,1,1); PrintD(S,74,35,15); A:=U[Sel].Army[2]; If A=0 then S:=' нет' else If A<5 then S:='омало' else If A<15 then S:=' мало' else If A<30 then S:=' средне' else If A<75 then S:=' много' else S:='омного'; If S[1]='о' then PrintD('очень',80,67,15); Delete(S,1,1); PrintD(S,74,75,15); A:=U[Sel].Army[3]; If A=0 then S:=' нет' else If A<5 then S:='омало' else If A<15 then S:=' мало' else If A<30 then S:=' средне' else If A<75 then S:=' много' else S:='омного'; If S[1]='о' then PrintD('очень',160,27,15); Delete(S,1,1); PrintD(S,154,35,15); A:=U[Sel].Army[4]; If A=0 then S:=' нет' else If A<5 then S:='омало' else If A<15 then S:=' мало' else If A<30 then S:=' средне' else If A<75 then S:=' много' else S:='омного'; If S[1]='о' then PrintD('очень',160,67,15); Delete(S,1,1); PrintD(S,154,75,15); A:=U[Sel].Army[5]; If A=0 then S:=' нет' else If A<5 then S:='омало' else If A<15 then S:=' мало' else If A<30 then S:=' средне' else If A<75 then S:=' много' else S:='омного'; If S[1]='о' then PrintD('очень',240,27,15); Delete(S,1,1); PrintD(S,234,35,15); End; End else Begin If H[Sel].own=1 then Begin Str(H[Sel].Army[1],S); PrintD(S,80,35,15); Str(H[Sel].Army[2],S); PrintD(S,80,75,15); Str(H[Sel].Army[3],S); PrintD(S,160,35,15); Str(H[Sel].Army[4],S); PrintD(S,160,75,15); Str(H[Sel].Army[5],S); PrintD(S,240,35,15); End else Begin A:=H[Sel].Army[1]; If A=0 then S:=' нет' else If A<5 then S:='омало' else If A<15 then S:=' мало' else If A<30 then S:=' средне' else If A<75 then S:=' много' else S:='омного'; If S[1]='о' then PrintD('очень',80,27,15); Delete(S,1,1); PrintD(S,74,35,15); A:=H[Sel].Army[2]; If A=0 then S:=' нет' else If A<5 then S:='омало' else If A<15 then S:=' мало' else If A<30 then S:=' средне' else If A<75 then S:=' много' else S:='омного'; If S[1]='о' then PrintD('очень',80,67,15); Delete(S,1,1); PrintD(S,74,75,15); A:=H[Sel].Army[3]; If A=0 then S:=' нет' else If A<5 then S:='омало' else If A<15 then S:=' мало' else If A<30 then S:=' средне' else If A<75 then S:=' много' else S:='омного'; If S[1]='о' then PrintD('очень',160,27,15); Delete(S,1,1); PrintD(S,154,35,15); A:=H[Sel].Army[4]; If A=0 then S:=' нет' else If A<5 then S:='омало' else If A<15 then S:=' мало' else If A<30 then S:=' средне' else If A<75 then S:=' много' else S:='омного'; If S[1]='о' then PrintD('очень',160,67,15); Delete(S,1,1); PrintD(S,154,75,15); A:=H[Sel].Army[5]; If A=0 then S:=' нет' else If A<5 then S:='омало' else If A<15 then S:=' мало' else If A<30 then S:=' средне' else If A<75 then S:=' много' else S:='омного'; If S[1]='о' then PrintD('очень',240,27,15); Delete(S,1,1); PrintD(S,234,35,15); End; End; VRT; ShowDouble; End; Procedure ShowDirs; Var Recr : Boolean; Begin WaitRelBut; Repeat DrawAll; asm mov es,SegDB mov di,20*320+40 mov bx,168 mov ax,$0505 @m1: mov cx,120 rep stosw add di,320-120*2 dec bx jnz @m1 End; H[Sel].Dir[0]:=True; For A:=0 to 7 do Begin PrintD(DirName[A+1],42,A*16+22,14); Str(DirCost[A+1],S); PrintD('$'+S,140,A*16+22,20); If H[Sel].Dir[A+1] then PrintD('есть',200,A*16+22,25) else If H[Sel].Built or Not H[Sel].Dir[PrevDir[A+1]] or (Mon1Sel) and (H[B].X=H[Sel].X) and (H[B].Y=H[Sel].Y+1) then Recr:=False; End; If Recr then PrintD('нанять хакера $2500',42,150,25) else PrintD('нанять хакера $2500',42,150,40); PrintD('OK',155,170,22); VRT; ShowDouble; Repeat ReadMouseState(Xm,Ym,Lb,Mb,Rb); Until Pressed[scEsc] or Lb; Xm:=Xm shr 1; If (Xm>=150) and (Xm<=175) and (Ym>=168) and (Ym<=180) then Break; If Recr and (Xm>=42) and (Xm<=200) and (Ym>=150) and (Ym<=158) then Begin Dec(Mon1,2500); Inc(NU); With U[NU] do Begin X:=H[Sel].X; Y:=H[Sel].Y+1; own:=1; CurMove:=5; Army[1]:=Random(6)+5; Army[2]:=Random(4)+2; Army[3]:=0; Army[4]:=0; Army[5]:=0; Move:=0;Know:=0;Exp:=0; End; End; If (Xm>=200) and (Xm<=300) and (Ym>=22) and (Ym<150) then Begin A:=(Ym-22) div 16 +1; If Not H[Sel].Dir[A] and Not H[Sel].Built and H[Sel].Dir[PrevDir[A]] and (Mon1>=DirCost[A]) then Begin H[Sel].Built:=True; H[Sel].Dir[A]:=True; Dec(Mon1,DirCost[A]); If A<6 then H[Sel].Stock[A]:=Stock[A]; End; End; If Pressed[scEsc] then Break; Until False; Repeat Until Not Pressed[scEsc]; WaitRelBut; End; Procedure Buy; Var Order : Array[1..5] of LongInt; Cst : LongInt; Ok : Boolean; Begin FillChar(Order,SizeOf(Order),0); Cst:=0; Repeat DrawAll; asm mov es,SegDB mov di,20 mov bx,188 mov ax,$0505 @m1: mov cx,140 rep stosw add di,320-140*2 dec bx jnz @m1 End; For A:=0 to 4 do Begin Case A of 0:B:=3; 1:B:=4; 2:B:=7; 3:B:=8; 4:B:=10; End; ShowTransD(22,2+A*34,Spr[B]); Str(H[Sel].Stock[A+1],S); PrintD(S,60,20+A*34,20); Str(Cost[A+1],S); PrintD('$'+S,95,20+A*34,25); Str(Order[A+1],S); PrintD(S,135,20+A*34,20); PrintD('+',160,20+A*34,25); PrintD('-',170,20+A*34,25); PrintD('ВСЕ',180,20+A*34,25); Str(H[Sel].Army[A+1],S); PrintD(S,210,20+A*34,20); End; PrintD('Доступно',60,2,30); PrintD('Заказать',135,2,30); PrintD('В наличии',210,2,30); Str(Cst,S); PrintD('ИТОГО:$'+S,20,175,30); PrintD('OK',155,175,22); PrintD('Отмена',190,175,22); VRT; ShowDouble; Repeat ReadMouseState(Xm,Ym,Lb,Mb,Rb); Until Pressed[scEsc] or Pressed[scEnter] or Lb; Xm:=Xm shr 1; If (Xm>=150) and (Xm<=175) and (Ym>=172) and (Ym<=185) then Begin Ok:=True; Break; End; If (Xm>=185) and (Xm<=240) and (Ym>=172) and (Ym<=185) then Begin Ok:=False; Break; End; If Pressed[scEsc] then Begin Ok:=False; Break; End; If Pressed[scEnter] then Begin Ok:=True; Break; End; If (Xm>=160) and (Xm<=168) and (Ym>=10) and (Ym<180) then Begin WaitRelBut; A:=(Ym-10) div 34 +1; If (H[Sel].Stock[A]>0) and (Mon1-Cst>=Cost[A]) then Begin Dec(H[Sel].Stock[A]); Inc(Order[A]); Inc(Cst,Cost[A]); End; End; If (Xm>=170) and (Xm<=178) and (Ym>=10) and (Ym<180) then Begin WaitRelBut; A:=(Ym-10) div 34 +1; If Order[A]>0 then Begin Inc(H[Sel].Stock[A]); Dec(Order[A]); Dec(Cst,Cost[A]); End; End; If (Xm>=180) and (Xm<=204) and (Ym>=10) and (Ym<180) then Begin WaitRelBut; A:=(Ym-10) div 34 +1; Dec(Cst,Order[A]*Cost[A]); Inc(H[Sel].Stock[A],Order[A]); B:=(Mon1-Cst) div Cost[A]; If B>H[Sel].Stock[A] then B:=H[Sel].Stock[A]; Dec(H[Sel].Stock[A],B); Order[A]:=B; Inc(Cst,B*Cost[A]); End; Until False; If Ok then Begin Dec(Mon1,Cst); For A:=1 to 5 do Inc(H[Sel].Army[A],Order[A]); End else Begin For A:=1 to 5 do Inc(H[Sel].Stock[A],Order[A]); End; Repeat Until Not Pressed[scEsc] and Not Pressed[scEnter]; WaitRelBut; End; Procedure MakeTrade; Var SH : Integer; Begin SH:=1; For A:=1 to NH do If (H[A].X=U[Sel].X) and (H[A].Y+1=U[Sel].Y) and (H[A].own=1) then SH:=A; Repeat DrawAll; asm mov es,SegDB mov di,20 mov bx,188 mov ax,$0505 @m1: mov cx,140 rep stosw add di,320-140*2 dec bx jnz @m1 End; For A:=0 to 4 do Begin Case A of 0:B:=3; 1:B:=4; 2:B:=7; 3:B:=8; 4:B:=10; End; ShowTransD(22,2+A*34,Spr[B]); Str(H[SH].Army[A+1],S); PrintD(S,60,20+A*34,20); PrintD('+',160,20+A*34,25); PrintD('-',170,20+A*34,25); PrintD('ВСЕ',180,20+A*34,25); Str(U[Sel].Army[A+1],S); PrintD(S,210,20+A*34,20); End; PrintD('Компьютер',60,2,30); PrintD('Хакер',210,2,30); PrintD('OK',155,175,22); VRT; ShowDouble; Repeat ReadMouseState(Xm,Ym,Lb,Mb,Rb); Until Pressed[scEsc] or Lb; Xm:=Xm shr 1; If (Xm>=150) and (Xm<=175) and (Ym>=172) and (Ym<=185) then Break; If Pressed[scEsc] then Break; If (Xm>=160) and (Xm<=168) and (Ym>=10) and (Ym<180) then Begin WaitRelBut; A:=(Ym-10) div 34 +1; If (H[SH].Army[A]>0) then Begin Dec(H[Sel].Army[A]); Inc(U[Sel].Army[A]); End; End; If (Xm>=170) and (Xm<=178) and (Ym>=10) and (Ym<180) then Begin WaitRelBut; A:=(Ym-10) div 34 +1; If (U[Sel].Army[A]>0) then Begin Inc(H[SH].Army[A]); Dec(U[Sel].Army[A]); End; End; If (Xm>=180) and (Xm<=204) and (Ym>=10) and (Ym<180) then Begin WaitRelBut; A:=(Ym-10) div 34 +1; Inc(U[Sel].Army[A],H[SH].Army[A]); H[SH].Army[A]:=0; End; Until False; Repeat Until Not Pressed[scEsc]; WaitRelBut; End; Procedure Fight(own1 : Byte;SelW1 : Boolean;Sel1 : Integer;own2 : Byte;SelW2 : Boolean;Sel2 : Integer); Type TUnit = record N : LongInt; HP : Integer; X,Y : ShortInt; Spells : Array[1..5] of Boolean; SpellD : Array[1..5] of Byte; Moves : Byte; Beat : Boolean; End; Var A1,A2 : Array[1..5] of TUnit; Field : Array[1..10,1..6] of Boolean; CurM,CurMO : Byte; D : LongInt; Cast1,Cast2 : Boolean; SP1,SP2 : LongInt; Spl1,Spl2 : Byte; Bol : Boolean; Procedure InitFight; Begin Cast1:=False; Cast2:=False; If SelW1 then Begin SP1:=U[Sel1].Know*5+20; Spl1:=U[Sel1].Exp div 1000; If Spl1>4 then Spl1:=4; End else If H[Sel1].Dir[8] then Begin SP1:=20; Spl1:=1; End else Begin SP1:=0; Spl1:=0; End; If SelW2 then Begin SP2:=U[Sel2].Know*5+20; Spl2:=U[Sel2].Exp div 1000; If Spl2>4 then Spl2:=4; End else If H[Sel2].Dir[8] then Begin SP2:=20; Spl2:=1; End else Begin SP2:=0; Spl2:=0; End; FillChar(Field,SizeOf(Field),False); For A:=1 to Random(5)+1 do Field[Random(6)+3,Random(6)+1]:=True; For A:=1 to 5 do Begin If SelW1 then A1[A].N:=U[Sel1].Army[A] else A1[A].N:=H[Sel1].Army[A]; If SelW2 then A2[A].N:=U[Sel2].Army[A] else A2[A].N:=H[Sel2].Army[A]; A1[A].HP:=HP[A]; A2[A].HP:=HP[A]; A1[A].Moves:=Mov[A]; A2[A].Moves:=Mov[A]; A1[A].Beat:=False; A2[A].Beat:=False; FillChar(A1[A].Spells,5,False); FillChar(A2[A].Spells,5,False); FillChar(A1[A].SpellD,5,0); FillChar(A2[A].SpellD,5,0); A1[A].Y:=A; A2[A].Y:=A; A1[A].X:=1; A2[A].X:=9+(A and 1); End; CurM:=1; CurMO:=1; End; Procedure ShowFrame; Var A,B,C,D : LongInt; Begin ClsD(0); For A:=0 to 5 do For B:=0 to 9 do If (A and 1=0) or (B<9) then If Field[B+1,A+1] then If A and 1=0 then ShowTransD(B*32,A*32+10,Spr[5]) else ShowTransD(B*32+16,A*32+10,Spr[5]); For A:=1 to 5 do Begin Case A of 1:D:=3; 2:D:=4; 3:D:=7; 4:D:=8; 5:D:=10; End; If A1[A].Y and 1=1 then C:=A1[A].X*32-32 else C:=A1[A].X*32-16; If A1[A].N>0 then Begin If A=1 then ShowRevD(C,A1[A].Y*32-22,Spr[D]) else ShowTransD(C,A1[A].Y*32-22,Spr[D]); If (CurMO=1) and (CurM=A) then For B:=0 to 31 do Begin PixelD(C+B,A1[A].Y*32-22,20); PixelD(C+B,A1[A].Y*32+9,20); PixelD(C,A1[A].Y*32-22+B,20); PixelD(C+31,A1[A].Y*32-22+B,20); End; Str(A1[A].N,S); PrintD(S,C,A1[A].Y*32,20); End; If A2[A].Y and 1=1 then C:=A2[A].X*32-32 else C:=A2[A].X*32-16; If A2[A].N>0 then Begin If A<>1 then ShowRevD(C,A2[A].Y*32-22,Spr[D]) else ShowTransD(C,A2[A].Y*32-22,Spr[D]); If (CurMO=2) and (CurM=A) then For B:=0 to 31 do Begin PixelD(C+B,A2[A].Y*32-22,20); PixelD(C+B,A2[A].Y*32+9,20); PixelD(C,A2[A].Y*32-22+B,20); PixelD(C+31,A2[A].Y*32-22+B,20); End; Str(A2[A].N,S); PrintD(S,C,A2[A].Y*32,20); End; End; PrintD('Хак-меню',0,0,30); PrintD('Skip',288,0,30); If CurMO=1 then Str(A1[CurM].Moves,S) else Str(A2[CurM].Moves,S); PrintD('ходов:'+S,100,0,20); End; Procedure ShowStat(SelM,Sel : Integer); Var T : String; Begin ShowFrame; asm mov es,SegDB mov di,20+40*320 mov bx,120 mov ax,$0505 @m1: mov cx,140 rep stosw add di,320-140*2 dec bx jnz @m1 End; Case Sel of 1:D:=3; 2:D:=4; 3:D:=7; 4:D:=8; 5:D:=10; End; ShowTransD(140,42,Spr[D]); If SelM=1 then Str(A1[Sel].N,S) else Str(A2[Sel].N,S); PrintD('кол-во:'+S,120,80,20); If SelM=1 then Str(A1[Sel].HP,S) else Str(A2[Sel].HP,S); Str(HP[Sel],T); PrintD('жизнь:'+S+'(из '+T+')',120,90,20); For A:=1 to 5 do Begin S:=''; If ((SelM=1) and (A1[Sel].Spells[A])) or ((SelM=2) and (A2[Sel].Spells[A])) then S:=Spells[A]; PrintD(S,50,90+A*10,25); End; VRT; ShowDouble; Repeat ReadMouseState(Xm,Ym,Lb,Mb,Rb); Until Not Rb; End; Procedure Beat(W1,S1,W2,S2 : Integer); Var AT,BT,CT,C : LongInt; Begin If W1=1 then Begin If A1[S1].N=0 then Exit; AT:=Atak[S1,1]*A1[S1].N; BT:=Atak[S1,2]*A1[S1].N; CT:=Random(BT-AT+1)+AT; If A1[S1].Spells[5] then Inc(CT,CT); C:=CT; BT:=0; If CT>=A2[S2].HP then Begin Dec(CT,A2[S2].HP); Dec(A2[S2].N); BT:=1; AT:=CT div HP[S2]; If AT>A2[S2].N then Begin Inc(BT,A2[S2].N); A2[S2].N:=0; End else Begin Inc(BT,AT); Dec(A2[S2].N,AT); A2[S2].HP:=HP[S2]-(CT mod HP[S2]); End; End else Dec(A2[S2].HP,CT); End else Begin If A2[S1].N=0 then Exit; AT:=Atak[S1,1]*A2[S1].N; BT:=Atak[S1,2]*A2[S1].N; CT:=Random(BT-AT+1)+AT; If A2[S1].Spells[5] then Inc(CT,CT); C:=CT; BT:=0; If CT>A1[S2].HP then Begin Dec(CT,A1[S2].HP); Dec(A1[S2].N); BT:=1; AT:=CT div HP[S2]; If AT>A1[S2].N then Begin Inc(BT,A1[S2].N); A1[S2].N:=0; End else Begin Inc(BT,AT); Dec(A1[S2].N,AT); A1[S2].HP:=HP[S2]-(CT mod HP[S2]); End; End else Dec(A1[S2].HP,CT); End; ShowFrame; asm mov es,SegDB mov di,20+40*320 mov bx,40 mov ax,$0505 @m1: mov cx,140 rep stosw add di,320-140*2 dec bx jnz @m1 End; If ((W1=1) and (own1=1)) or ((W1=2) and (own2=1)) then S:='наши' else S:='враги'; PrintD(S+' нанесли удар',90,42,20); Str(C,S); PrintD('силой '+S,100,52,20); If BT>0 then Begin Str(BT,S); S:=' и убили '+S; If ((W1=1) and (own1=1)) or ((W1=2) and (own2=1)) then S:=S+' врагов' else S:=S+' наших'; PrintD(S,90,62,20); End; VRT; ShowDouble; WaitRelBut; Repeat ReadMouseState(Xm,Ym,Lb,Mb,Rb); Until Pressed[scEsc] or Pressed[scEnter] or Pressed[scSpace] or Lb; Repeat Until Not Pressed[scEsc] and not Pressed[scEnter] and Not Pressed[scSpace]; WaitRelBut; End; Procedure ShowCast(X,Y : LongInt); Var A : Word; Begin If Y and 1=1 then X:=(X-1) shl 5 else X:=X shl 5-16; Y:=Y shl 5-22; For A:=1 to 3 do Begin Time:=Timer; ShowFrame; ShowTransD(X,Y,Spr[6]); VRT; ShowDouble; Repeat Until Timer-Time>4; Time:=Timer; ShowFrame; VRT; ShowDouble; Repeat Until Timer-Time>4; End; End; Procedure HackMenu; Var A,B,C : LongInt; Begin WaitRelBut; ShowFrame; asm mov es,SegDB mov di,20+40*320 mov bx,140 mov ax,$0505 @m1: mov cx,140 rep stosw add di,320-140*2 dec bx jnz @m1 End; If (own1=1) then A:=SP1 else A:=SP2; If (own1=1) then B:=Spl1 else B:=Spl2; If B>0 then Begin PrintD('Заразить вирусом (5)',22,42,20); If A>4 then PrintD('OK',200,42,30) else PrintD('OK',200,42,40); PrintD('Поставить защиту (5)',22,52,20); If A>4 then PrintD('OK',200,52,30) else PrintD('OK',200,52,40); PrintD('Исправить ошибки (3)',22,62,20); If A>2 then PrintD('OK',200,62,30) else PrintD('OK',200,62,40); End; If B>1 then Begin PrintD('Наслать Win95 (3)',22,72,20); If A>2 then PrintD('OK',200,72,30) else PrintD('OK',200,72,40); PrintD('Запустить SmartDrv (3)',22,82,20); If A>2 then PrintD('OK',200,82,30) else PrintD('OK',200,82,40); End; If B>2 then Begin PrintD('Массовая защита (8)',22,92,20); If A>7 then PrintD('OK',200,92,30) else PrintD('OK',200,92,40); PrintD('Массовый SmartDrv (5)',22,102,20); If A>4 then PrintD('OK',200,102,30) else PrintD('OK',200,102,40); PrintD('Масс. исправление (7)',22,112,20); If A>6 then PrintD('OK',200,112,30) else PrintD('OK',200,112,40); End; If B>3 then Begin PrintD('Запустить ламера (5)',22,122,20); If A>4 then PrintD('OK',200,122,30) else PrintD('OK',200,122,40); End; Str(A,S); PrintD('Пока сил:'+S,40,142,20); PrintD('Отмена',140,160,15); VRT; ShowDouble; Repeat Repeat ReadMouseState(Xm,Ym,Lb,Mb,Rb); Until Pressed[scEsc] or Lb; Xm:=Xm shr 1; If Pressed[scEsc] then Break; If Lb then If (Xm>=140) and (Xm<=188) and (Ym>=160) and (Ym<=168) then Break else If (Ym>=42) and (Ym<130) then Begin Y:=(Ym-42) div 10 +1; C:=0; Case Y of 1: If (B>0) and (A>4) then C:=5; 2: If (B>0) and (A>4) then C:=5; 3: If (B>0) and (A>2) then C:=3; 4: If (B>1) and (A>2) then C:=3; 5: If (B>1) and (A>2) then C:=3; 6: If (B>2) and (A>7) then C:=8; 7: If (B>2) and (A>4) then C:=5; 8: If (B>2) and (A>6) then C:=7; 9: If (B>3) and (A>4) then C:=5; End; If C>0 then Begin ShowFrame; VRT; ShowDouble; WaitRelBut; C:=A-C; B:=Y; If (B>=6) and (B<=8) then Begin If own1=1 then Begin SP1:=C; Cast1:=True; End else Begin SP2:=C; Cast2:=True; End; For A:=1 to 5 do If (own1=1) then Begin If A1[A].N>0 then ShowCast(A1[A].X,A1[A].Y); Case B of 6: Begin A1[A].Spells[1]:=True; A1[A].SpellD[1]:=3; End; 7: Begin A1[A].Spells[4]:=True; A1[A].SpellD[4]:=3; If CurM=A then Inc(A1[A].Moves,2); End; 8: Begin A1[A].Spells[5]:=True; A1[A].SpellD[5]:=3; End; End End else Begin If A2[A].N>0 then ShowCast(A2[A].X,A2[A].Y); Case B of 6: Begin A2[A].Spells[1]:=True; A2[A].SpellD[1]:=3; End; 7: Begin A2[A].Spells[4]:=True; A2[A].SpellD[4]:=3; If CurM=A then Inc(A2[A].Moves,2); End; 8: Begin A2[A].Spells[5]:=True; A2[A].SpellD[5]:=3; End; End; End; Break; End; Repeat ReadMouseState(Xm,Ym,Lb,Mb,Rb); Until Lb or Pressed[scEsc]; If Pressed[scEsc] then Break; Xm:=Xm shr 1; Y:=(Ym-10) shr 5; If Y and 1=0 then X:=Xm shr 5 else If Xm<16 then X:=0 else If Xm>272 then X:=8 else X:=(Xm-16) shr 5; Inc(X); Inc(Y); For A:=1 to 5 do If (A1[A].X=X) and (A1[A].Y=Y) and (A1[A].N>0) then Begin If own1=1 then Begin SP1:=C; Cast1:=True; End else Begin SP2:=C; Cast2:=True; End; ShowCast(X,Y); If Not A1[A].Spells[1] then Case B of 1: Begin C:=Random(11)+40; If C>=A1[A].HP then Begin Dec(C,A1[A].HP); Dec(A1[A].N); D:=C div HP[A]; If D>A1[A].N then A1[A].N:=0 else Begin Dec(A1[A].N,D); A1[A].HP:=HP[A]-C mod HP[A]; End; End else Dec(A1[A].HP,C); End; 2: Begin A1[A].Spells[1]:=True; A1[A].SpellD[1]:=3; End; 3: Begin A1[A].Spells[5]:=True; A1[A].SpellD[5]:=3; End; 4: Begin A1[A].Spells[3]:=True; A1[A].SpellD[3]:=3; End; 5: Begin A1[A].Spells[4]:=True; A1[A].SpellD[4]:=3; If (own1=1) and (A=CurM) then Inc(A1[A].Moves,2); End; 9: Begin A1[A].Spells[2]:=True; A1[A].SpellD[2]:=3; End; End; Break; End; For A:=1 to 5 do If (A2[A].X=X) and (A2[A].Y=Y) and (A2[A].N>0) then Begin If own1=1 then Begin SP1:=C; Cast1:=True; End else Begin SP2:=C; Cast2:=True; End; ShowCast(X,Y); If Not A2[A].Spells[1] then Case B of 1: Begin C:=Random(11)+40; If C>=A2[A].HP then Begin Dec(C,A2[A].HP); Dec(A2[A].N); D:=C div HP[A]; If D>A2[A].N then A2[A].N:=0 else Begin Dec(A2[A].N,D); A2[A].HP:=HP[A]-C mod HP[A]; End; End else Dec(A2[A].HP,C); End; 2: Begin A2[A].Spells[1]:=True; A2[A].SpellD[1]:=3; End; 3: Begin A2[A].Spells[5]:=True; A2[A].SpellD[5]:=3; End; 4: Begin A2[A].Spells[3]:=True; A2[A].SpellD[3]:=3; End; 5: Begin A2[A].Spells[4]:=True; A2[A].SpellD[4]:=3; If (own2=1) and (A=CurM) then Inc(A2[A].Moves,2); End; 9: Begin A2[A].Spells[2]:=True; A2[A].SpellD[2]:=3; End; End; Break; End; Break; End; End; Until False; Repeat Until Not Pressed[scEsc]; WaitRelBut; End; Procedure CPUMove; Var X1,Y1 : LongInt; Begin If (CurMO=1) and Not Cast1 and (Spl1>0) and (SP1>4) then Begin Dec(SP1,5); Cast1:=True; If A2[2].N>0 then A:=2 else Begin C:=0; For B:=1 to 5 do If A2[B].N*HP[B]>C then Begin C:=A2[B].N*HP[B]; A:=B; End; End; ShowCast(A2[A].X,A2[A].Y); C:=Random(11)+40; If C>=A2[A].HP then Begin Dec(C,A2[A].HP); Dec(A2[A].N); D:=C div HP[A]; If D>A2[A].N then A2[A].N:=0 else Begin Dec(A2[A].N,D); A2[A].HP:=HP[A]-C mod HP[A]; End; End else Dec(A2[A].HP,C); End else If (CurMO=2) and Not Cast2 and (Spl2>0) and (SP2>4) then Begin Dec(SP2,5); Cast2:=True; If A1[2].N>0 then A:=2 else Begin C:=0; For B:=1 to 5 do If A1[B].N*HP[B]>C then Begin C:=A1[B].N*HP[B]; A:=B; End; End; ShowCast(A1[A].X,A1[A].Y); C:=Random(11)+40; If C>=A1[A].HP then Begin Dec(C,A1[A].HP); Dec(A1[A].N); D:=C div HP[A]; If D>A1[A].N then A1[A].N:=0 else Begin Dec(A1[A].N,D); A1[A].HP:=HP[A]-C mod HP[A]; End; End else Dec(A1[A].HP,C); End; If CurM=2 then Begin If CurMO=1 then Begin X:=A1[CurM].X;Y:=A1[CurM].Y; For A:=1 to 5 do If ((A2[A].Y=Y) and (Abs(A2[A].X-X)<2)) or ((Abs(A2[A].Y-Y)<2) and (((Y and 1=1) and ((X-A2[A].X=0) or (X-A2[A].X=1))) or ((Y and 1=0) and ((A2[A].X-X=0) or (A2[A].X-X=1))))) then Begin Beat(CurMO,CurM,2,A); If Not A2[A].Beat then Beat(2,A,CurMO,CurM); A2[A].Beat:=True; A1[CurM].Moves:=0; Exit; End; End else Begin X:=A2[CurM].X;Y:=A2[CurM].Y; For A:=1 to 5 do If ((A1[A].Y=Y) and (Abs(A1[A].X-X)<2)) or ((Abs(A1[A].Y-Y)<2) and (((Y and 1=1) and ((X-A1[A].X=0) or (X-A1[A].X=1))) or ((Y and 1=0) and ((A1[A].X-X=0) or (A1[A].X-X=1))))) then Begin Beat(CurMO,CurM,1,A); If Not A1[A].Beat then Beat(1,A,CurMO,CurM); A1[A].Beat:=True; A2[CurM].Moves:=0; Exit; End; End; If (CurMO=1) and (A2[2].N>0) then Begin Beat(CurMO,CurM,2,2); A1[CurM].Moves:=0; Exit; End else If (CurMO=2) and (A1[2].N>0) then Begin Beat(CurMO,CurM,1,2); A2[CurM].Moves:=0; Exit; End; B:=0;C:=0; For A:=1 to 5 do If (CurMO=1) and (A2[A].N>0) then Begin If B0) then Begin If B0 then Begin Beat(CurMO,CurM,3-CurMO,C); If CurMO=1 then A1[CurM].Moves:=0 else A2[CurM].Moves:=0; Exit; End; If CurMO=1 then A1[CurM].Moves:=0 else A2[CurM].Moves:=0; Exit; End; If CurMO=1 then Begin X:=A1[CurM].X; Y:=A1[CurM].Y; End else Begin X:=A2[CurM].X; Y:=A2[CurM].Y; End; B:=0;C:=0; For A:=1 to 5 do If (CurMO=1) and (A2[A].N>0) then Begin If B0) then Begin If B0 then C:=2; X1:=A2[C].X; Y1:=A2[C].Y; End else Begin If A1[2].N>0 then C:=2; X1:=A1[C].X; Y1:=A1[C].Y; End; Xp:=0; Yp:=0; If YY1 then Yp:=-1; If Yp<>0 then Begin If Y and 1=1 then If X>X1 then Xp:=-1 else else If XX1 then Xp:=-1; For B:=1 to 9 do Begin X1:=X+Xp; Y1:=Y+Yp; D:=0; If Field[X1,Y1] then D:=1; If (X1>10) or (X1<1) or (Y1<1) or (Y1>6) then D:=1; If (Y1 and 1=0) and (X1>9) then D:=1; If D=0 then For A:=1 to 5 do If (CurMO=1) then If (A1[A].X=X1) and (A1[A].Y=Y1) and (A1[A].N>0) then Begin D:=1; Break; End else If (A2[A].X=X1) and (A2[A].Y=Y1) and (A2[A].N>0) then Begin Beat(CurMO,CurM,2,A); If Not A2[A].Beat then Beat(2,A,CurMO,CurM); A2[A].Beat:=False; A1[CurM].Moves:=0; Exit; End else else If (A2[A].X=X1) and (A2[A].Y=Y1) and (A2[A].N>0) then Begin D:=1; Break; End else If (A1[A].X=X1) and (A1[A].Y=Y1) and (A1[A].N>0) then Begin Beat(CurMO,CurM,1,A); If Not A1[A].Beat then Beat(1,A,CurMO,CurM); A1[A].Beat:=False; A2[CurM].Moves:=0; Exit; End; If D=0 then Begin If CurMO=1 then Begin A1[CurM].X:=X1; A1[CurM].Y:=Y1; Dec(A1[CurM].Moves); End else Begin A2[CurM].X:=X1; A2[CurM].Y:=Y1; Dec(A2[CurM].Moves); End; ShowFrame; VRT; ShowDouble; Time:=Timer; Repeat Until Timer-Time>5; Exit; End; If B=1 then Begin If XX1 then Xp:=-1; Yp:=0; End else If Y=6 then Begin If Y and 1=1 then If (Xp=0) and (Yp=1) then Xp:=-1 else If (Xp=-1) and (Yp=1) then Yp:=0 else If (Xp=-1) and (Yp=0) then Yp:=-1 else If (Xp=-1) and (Yp=-1) then Xp:=0 else If (Xp=0) and (Yp=-1) then Begin Xp:=1; Yp:=0; End else If (Xp=1) and (Yp=0) then Begin Xp:=0; Yp:=1; End; If Y and 1=0 then If (Xp=1) and (Yp=1) then Xp:=0 else If (Xp=0) and (Yp=1) then Begin Xp:=-1; Yp:=0; End else If (Xp=-1) and (Yp=0) then Begin Xp:=0; Yp:=-1; End else If (Xp=0) and (Yp=-1) then Xp:=1 else If (Xp=1) and (Yp=-1) then Yp:=0 else If (Xp=1) and (Yp=0) then Yp:=1; End else Begin If Y and 1=1 then If (Xp=0) and (Yp=1) then Begin Xp:=1; Yp:=0; End else If (Xp=-1) and (Yp=1) then Xp:=0 else If (Xp=-1) and (Yp=0) then Yp:=1 else If (Xp=-1) and (Yp=-1) then Yp:=0 else If (Xp=0) and (Yp=-1) then Xp:=-1 else If (Xp=1) and (Yp=0) then Begin Xp:=0; Yp:=-1; End; If Y and 1=0 then If (Xp=1) and (Yp=1) then Yp:=0 else If (Xp=0) and (Yp=1) then Xp:=1 else If (Xp=-1) and (Yp=0) then Begin Xp:=0; Yp:=1; End else If (Xp=0) and (Yp=-1) then Begin Xp:=-1; Yp:=0; End else If (Xp=1) and (Yp=-1) then Xp:=0 else If (Xp=1) and (Yp=0) then Yp:=-1; End; End; If CurMO=1 then A1[CurM].Moves:=0 else A2[CurM].Moves:=0; End; Begin WaitRelBut; InitFight; Repeat If ((CurMO=1) and (A1[CurM].Moves=0)) or ((CurMO=2) and (A2[CurM].Moves=0)) then Repeat If CurMO=1 then CurMO:=2 else Begin CurMO:=1; Inc(CurM); If CurM>5 then Begin CurM:=1; Cast1:=False;Cast2:=False; End; End; If CurMO=1 then Begin For A:=1 to 5 do If A1[CurM].Spells[A] then Begin Dec(A1[CurM].SpellD[A]); If A1[CurM].SpellD[A]=0 then A1[CurM].Spells[A]:=False; End; A1[CurM].Moves:=Mov[CurM]; If A1[CurM].Spells[3] then A1[CurM].Moves:=Mov[CurM] shr 1; If A1[CurM].Spells[4] then A1[CurM].Moves:=A1[CurM].Moves+2; A1[CurM].Beat:=False; End; If CurMO=2 then Begin For A:=1 to 5 do If A2[CurM].Spells[A] then Begin Dec(A2[CurM].SpellD[A]); If A2[CurM].SpellD[A]=0 then A2[CurM].Spells[A]:=False; End; A2[CurM].Moves:=Mov[CurM]; If A2[CurM].Spells[3] then A2[CurM].Moves:=Mov[CurM] shr 1; If A2[CurM].Spells[4] then A2[CurM].Moves:=A2[CurM].Moves+2; A2[CurM].Beat:=False; End; If (CurMO=1) and (A1[CurM].N>0) and Not A1[CurM].Spells[2] then Break; If (CurMO=2) and (A2[CurM].N>0) and Not A2[CurM].Spells[2] then Break; Until False; ShowFrame; VRT; ShowDouble; If ((CurMO=1) and (own1<>1)) or ((CurMO=2) and (own2<>1)) then CPUMove else Begin Repeat ReadMouseState(Xm,Ym,Lb,Mb,Rb); Until Lb or Rb or Pressed[scLeft] or Pressed[scRight] or Pressed[scHome] or Pressed[scEnd] or Pressed[scPgUp] or Pressed[scPgDn]; Xm:=Xm shr 1; If Lb then Begin WaitRelBut; If (Xm>=288) and (Ym<8) then Begin If CurMO=1 then A1[CurM].Moves:=0 else A2[CurM].Moves:=0; End else If (Xm<=64) and (Ym<8) then Begin If ((own1=1) and Not Cast1 and (Spl1>0)) or ((own2=1) and Not Cast2 and (Spl2>0)) then HackMenu; End else If CurM=2 then Begin B:=0; If CurMO=1 then Begin X:=A1[CurM].X;Y:=A1[CurM].Y; For A:=1 to 5 do If ((A2[A].Y=Y) and (Abs(A2[A].X-X)<2)) or ((Abs(A2[A].Y-Y)<2) and (((Y and 1=1) and ((X-A2[A].X=0) or (X-A2[A].X=1))) or ((Y and 1=0) and ((A2[A].X-X=0) or (A2[A].X-X=1))))) then B:=1; End else Begin X:=A2[CurM].X;Y:=A2[CurM].Y; For A:=1 to 5 do If ((A1[A].Y=Y) and (Abs(A1[A].X-X)<2)) or ((Abs(A1[A].Y-Y)<2) and (((Y and 1=1) and ((X-A1[A].X=0) or (X-A1[A].X=1))) or ((Y and 1=0) and ((A1[A].X-X=0) or (A1[A].X-X=1))))) then B:=1; End; If B=0 then Begin Y:=(Ym-10) shr 5; If Y and 1=0 then X:=Xm shr 5 else If Xm<16 then X:=0 else If Xm>272 then X:=8 else X:=(Xm-16) shr 5; Inc(X); Inc(Y); If CurMO=1 then Begin For A:=1 to 5 do If (A2[A].X=X) and (A2[A].Y=Y) and (A2[A].N>0) then Begin Beat(CurMO,CurM,2,A); A1[CurM].Moves:=0; End; End else Begin For A:=1 to 5 do If (A1[A].X=X) and (A1[A].Y=Y) and (A1[A].N>0) then Begin Beat(CurMO,CurM,1,A); A2[CurM].Moves:=0; End; End; End; End; End else If Rb and (Ym>9) then Begin Y:=(Ym-10) shr 5; If Y and 1=0 then X:=Xm shr 5 else If Xm<16 then X:=0 else If Xm>272 then X:=8 else X:=(Xm-16) shr 5; Inc(X); Inc(Y); B:=0; For A:=1 to 5 do If (A1[A].X=X) and (A1[A].Y=Y) and (A1[A].N>0) then Begin B:=1; Break; End; If B=1 then ShowStat(1,A) else Begin For A:=1 to 5 do If (A2[A].X=X) and (A2[A].Y=Y) and (A2[A].N>0) then Begin B:=1; Break; End; If B=1 then ShowStat(2,A); End; End; Xp:=0;Yp:=0; If Pressed[scLeft] then Xp:=-1; If Pressed[scRight] then Xp:=1; If Pressed[scHome] then Yp:=-1; If Pressed[scEnd] then Yp:=1; If Pressed[scPgUp] then Begin Xp:=1; Yp:=-1; End; If Pressed[scPgDn] then Begin Xp:=1; Yp:=1; End; Repeat Until Not (Pressed[scLeft] or Pressed[scRight] or Pressed[scHome] or Pressed[scPgUp] or Pressed[scPgDn] or Pressed[scEnd]); If (Yp<>0) and (((CurMO=1) and (A1[CurM].Y and 1=1)) or ((CurMO=2) and (A2[CurM].Y and 1=1))) then Dec(Xp); If (Xp<>0) or (Yp<>0) then Begin If CurMO=1 then Begin X:=A1[CurM].X; Y:=A1[CurM].Y; End; If CurMO=2 then Begin X:=A2[CurM].X; Y:=A2[CurM].Y; End; Inc(X,Xp); Inc(Y,Yp); B:=0; If (X<1) or (X>10) or (Y<1) or (Y>6) then B:=1; If (Y and 1=0) and (X>9) then B:=1; If (B=0) and (Field[X,Y]) then B:=1; If B=0 then If CurMO=1 then Begin For A:=1 to 5 do If (A1[A].X=X) and (A1[A].Y=Y) and (A1[A].N>0) then B:=1; End else For A:=1 to 5 do If (A2[A].X=X) and (A2[A].Y=Y) and (A2[A].N>0) then B:=1; If B=0 then If CurMO=1 then Begin For A:=1 to 5 do If (A2[A].X=X) and (A2[A].Y=Y) and (A2[A].N>0) then Begin B:=1; Beat(CurMO,CurM,2,A); If Not A2[A].Beat then Beat(2,A,CurMO,CurM); A2[A].Beat:=True; A1[CurM].Moves:=0; End; End else For A:=1 to 5 do If (A1[A].X=X) and (A1[A].Y=Y) and (A1[A].N>0) then Begin B:=1; Beat(CurMO,CurM,1,A); If Not A1[A].Beat then Beat(1,A,CurMO,CurM); A1[A].Beat:=True; A2[CurM].Moves:=0; End; If B=0 then Begin If CurMO=1 then Begin A1[CurM].X:=X; A1[CurM].Y:=Y; Dec(A1[CurM].Moves); End else Begin A2[CurM].X:=X; A2[CurM].Y:=Y; Dec(A2[CurM].Moves); End; End; End; End; B:=0; For A:=1 to 5 do If A1[A].N>0 then B:=1; If B=1 then Begin For A:=1 to 5 do If A2[A].N>0 then B:=2; If B=1 then Break; End else Break; Until False; If ((B=0) and (own1=1)) or ((B=1) and (own2=1)) then Begin If own1=1 then C:=Sel1 else C:=Sel2; If own1=1 then Bol:=SelW1 else Bol:=SelW2; D:=0; For A:=1 to NU do If (U[A].own=1) and ((A<>C) or Not Bol) then Begin SelW:=True; Sel:=A; D:=1; Break; End; If D=0 then Begin For A:=1 to NH do If (H[A].own=1) and ((A<>C) or Bol) then Begin SelW:=False; Sel:=A; D:=1; Break; End; If D=0 then Begin HideMouse; Restore_Handler; GrDone; WriteLn('You lose...'); Halt(1); End; End; End; If B=1 then Begin If SelW2 then Begin B:=0; For A:=1 to 5 do Inc(B,U[Sel2].Army[A]*Exp[A]); For A:=Sel2 to NU-1 do U[A]:=U[A+1]; Dec(NU); End else Begin B:=0; For A:=1 to 5 do Inc(B,H[Sel2].Army[A]*Exp[A]); FillChar(H[Sel2].Army,20,0); End; If SelW1 then Begin For A:=1 to 5 do U[Sel1].Army[A]:=A1[A].N; Inc(U[Sel1].Exp,B); If (U[Sel1].Exp-B) div 1000<>U[Sel1].Exp div 1000 then Begin Inc(U[Sel1].Move); Inc(U[Sel1].Know); End; End else For A:=1 to 5 do H[Sel1].Army[A]:=A1[A].N; End else Begin If SelW1 then Begin B:=0; For A:=1 to 5 do Inc(B,U[Sel1].Army[A]*Exp[A]); For A:=Sel1 to NU-1 do U[A]:=U[A+1]; Dec(NU); End else Begin B:=0; For A:=1 to 5 do Inc(B,H[Sel1].Army[A]*Exp[A]); FillChar(H[Sel1].Army,20,0); End; If SelW2 then Begin For A:=1 to 5 do U[Sel2].Army[A]:=A2[A].N; Inc(U[Sel2].Exp,B); If (U[Sel2].Exp-B) div 1000<>U[Sel2].Exp div 1000 then Begin Inc(U[Sel2].Move); Inc(U[Sel2].Know); End; End else For A:=1 to 5 do H[Sel2].Army[A]:=A2[A].N; End; End; Procedure CPUMove; Procedure CPUFight(S1,S2 : LongInt); Var A,B,C : LongInt; Begin B:=0; For A:=1 to 5 do Inc(B,U[S1].Army[A]*HP[A]); C:=0; For A:=1 to 5 do Inc(C,H[S2].Army[A]*HP[A]); If C=0 then Begin H[S2].own:=2; Exit; End; If B>C then Begin For A:=1 to 5 do Begin If C>U[S1].Army[A]*HP[A] then Begin Dec(C,U[S1].Army[A]*HP[A]); U[S1].Army[A]:=0; End else Begin Dec(U[S1].Army[A],C div HP[A]); C:=0; End; Inc(U[S1].Exp,H[S2].Army[A]*Exp[A]); H[S2].Army[A]:=0; End; Inc(U[S1].Army[1]); Exit; End else Begin For A:=1 to 5 do Begin If C>H[S2].Army[A]*HP[A] then Begin Dec(C,H[S2].Army[A]*HP[A]); H[S2].Army[A]:=0; End else Begin Dec(H[S2].Army[A],C div HP[A]); C:=0; Break; End; End; Inc(H[S2].Army[1]); For A:=S1 to NU-1 do U[A]:=U[A+1]; Dec(NU); End; End; Function CheckMove : Boolean; Var F,G : LongInt; Begin CheckMove:=True; For F:=1 to NU do If (U[F].X=X1) and (U[F].Y=Y1) and (U[F].own=1) then Begin Fight(2,True,A,1,True,F); If H[F].own=2 then CheckMove:=True else CheckMove:=False; Exit; End; For F:=1 to NH do If (H[F].X=X1) and (H[F].Y+1=Y1) and (H[F].own<>2) then Begin If H[F].own=1 then Fight(2,True,A,1,False,F) else CPUFight(A,F); If H[F].own=2 then CheckMove:=True else CheckMove:=False; Exit; End; End; Begin For A:=1 to NH do If H[A].own=2 then Begin For B:=1 to 5 do Begin C:=H[A].Stock[B]*Cost[B]; If C<=Mon2 then Begin Dec(Mon2,C); Inc(H[A].Army[B],H[A].Stock[B]); H[A].Stock[B]:=0; End else Begin C:=Mon2 div Cost[B]; Dec(Mon2,C*Cost[B]); Inc(H[A].Army[B],C); Dec(H[A].Stock[B],C); End; End; End; For A:=1 to NH do If H[A].own=2 then Begin H[A].Dir[0]:=True; If Mon2>2500 then For B:=1 to 5 do If (Mon2>=DirCost[B]) and Not H[A].Dir[B] and H[A].Dir[PrevDir[B]] and not H[A].Built then Begin Dec(Mon2,DirCost[B]); H[A].Dir[B]:=True; H[A].Built:=False; H[A].Stock[B]:=Stock[B]; End; End; For A:=1 to NU do If U[A].own=2 then Begin For B:=1 to NH do If (H[B].own=2) and (H[B].X=U[A].X) and (H[B].Y=U[A].Y-1) then Begin For C:=1 to 5 do Begin Inc(U[A].Army[C],H[B].Army[C]); H[B].Army[C]:=0; End; End; C:=MaxLongInt; For B:=1 to NU do If U[B].own<>2 then Begin If Abs(U[B].X-U[A].X)>Abs(U[B].Y-U[A].Y) then D:=Abs(U[B].X-U[A].X) else D:=Abs(U[B].Y-U[A].Y); If D2 then Begin If Abs(H[B].X-U[A].X)>Abs(H[B].Y-U[A].Y) then D:=Abs(H[B].X-U[A].X) else D:=Abs(H[B].Y-U[A].Y); If DB then Begin C:=MaxLongInt; For B:=1 to NH do If H[B].own=2 then Begin If Abs(H[B].X-U[A].X)>Abs(H[B].Y-U[A].Y) then D:=Abs(H[B].X-U[A].X) else D:=Abs(H[B].Y-U[A].Y); If D0) and ((X<>U[A].X) or (Y<>U[A].Y)) do Begin If U[A].X>X then Xp:=-1 else If U[A].XY then Yp:=-1 else If U[A].Y0 then Xp:=0 else If Yp<>0 then Yp:=0; If D>1 then Begin If U[A].X>X then Xp:=-1 else If U[A].XY then Yp:=-1 else If U[A].Y0 then Yp:=0 else If Xp<>0 then Xp:=0; End; If D=3 then Begin If Xp<>0 then Yp:=1; End; If D=4 then Begin If Xp<>0 then Yp:=-1; End; If D=5 then Begin If Yp<>0 then Xp:=1 End; If D=6 then Begin If Yp<>0 then Xp:=-1; End; End; If C=0 then Begin Dec(U[A].CurMove); If CheckMove then Begin U[A].X:=X1; U[A].Y:=Y1; End; End else U[A].CurMove:=0; If U[A].own<>2 then Break; End; If (U[A].X=X) and (U[A].Y=Y) and (U[A].own=1) then Begin For B:=1 to NH do If (H[B].own=2) and (H[B].X=X) and (H[B].Y=Y-1) then Begin For C:=1 to 5 do Begin Inc(U[A].Army[C],H[B].Army[C]); H[B].Army[C]:=0; End; End; End; U[A].CurMove:=0; End else Begin While (U[A].CurMove>0) and ((X<>U[A].X) or (Y<>U[A].Y)) do Begin If U[A].X>X then Xp:=-1 else If U[A].XY then Yp:=-1 else If U[A].Y0 then Xp:=0 else If Yp<>0 then Yp:=0; If D>1 then Begin If U[A].X>X then Xp:=-1 else If U[A].XY then Yp:=-1 else If U[A].Y0 then Yp:=0 else If Xp<>0 then Xp:=0; End; If D=3 then Begin If Xp<>0 then Yp:=1; End; If D=4 then Begin If Xp<>0 then Yp:=-1; End; If D=5 then Begin If Yp<>0 then Xp:=1 End; If D=6 then Begin If Yp<>0 then Xp:=-1; End; End; If C=0 then Begin Dec(U[A].CurMove); If CheckMove then Begin U[A].X:=X1; U[A].Y:=Y1; End; End else U[A].CurMove:=0; If U[A].own<>2 then Break; End; End; End; For A:=1 to NH do If (H[A].own=2) and (Mon2>=5000) and (NU<30) then Begin C:=0; For B:=1 to NU do If (U[B].X=H[A].X) and (U[B].Y=H[A].Y+1) then C:=1; If C=0 then Begin Inc(NU); With U[NU] do Begin X:=H[A].X; Y:=H[A].Y+1; own:=2; CurMove:=5; Army[1]:=Random(6)+5; Army[2]:=Random(4)+2; Army[3]:=0; Army[4]:=0; Army[5]:=0; Move:=0;Know:=0;Exp:=0; End; Dec(Mon2,2500); End; End; End; Procedure EndMove; Begin WaitRelBut; CPUMove; For A:=1 to NU do Begin U[A].CurMove:=5+U[A].Move; End; For A:=1 to NH do Begin H[A].Built:=False; If H[A].own=1 then Begin Inc(Mon1,1000); If H[A].Dir[6] then Inc(Mon1,250); End else If H[A].own=2 then Begin Inc(Mon2,1000); If H[A].Dir[6] then Inc(Mon2,250); End; End; Inc(Day); If Day=8 then Begin Day:=1; For A:=1 to NH do Begin For B:=1 to 5 do Begin If H[A].Dir[B] then Begin If H[A].Dir[7] then Inc(H[A].Stock[B],Stock[B]+Stock[B] shr 1) else Inc(H[A].Stock[B],Stock[B]); End; End; End; End; End; Begin Randomize; GrInit; Install_Handler; Cls(0); For A:=1 to 11 do Spr[A]:=Ptr(Seg(Sprites),Ofs(Sprites)+32*32*(A-1)); Move(Ptr(Seg(Sprites),Ofs(Sprites)+32*32*11)^,Pal,768); FillChar(NullPal,768,0); ClsD(0); SetPalette(Pal); InitAll; ShowMouse; Repeat DrawAll; VRT; ShowDouble; Time:=Timer; Repeat ReadMouseState(Xm,Ym,Lb,Mb,Rb); Xm:=Xm shr 1; If Timer-Time>1 then Begin If (Xm<=0) and (MX>0) then Dec(MX); If (Ym<=0) and (MY>0) then Dec(MY); If (Xm>=303) and (MX<58) then Inc(MX); If (Ym>=183) and (MY<58) then Inc(MY); If (Xm<=0) or (Ym<=0) or (Xm>=303) or (Ym>=183) then Break; End; Until Lb or Rb or Pressed[scEsc] or (SelW and (Pressed[scLeft] or Pressed[scRight] or Pressed[scUp] or Pressed[scDown] or Pressed[scHome] or Pressed[scEnd] or Pressed[scPgUp] or Pressed[scPgDn] or Pressed[scTab])); If Lb then Begin If (Xm>=230) and (Xm<=230+65) and (Ym<=65) then Begin MX:=Xm-230-3; MY:=Ym-3; If MX<0 then MX:=0; If MY<0 then MY:=0; If MX>58 then MX:=58; If MY>58 then MY:=58; End else If (Xm>=4) and (Xm<196) and (Ym>=4) and (Ym<196) then Begin X:=MX+(Xm-4) shr 5; Y:=MY+(Ym-4) shr 5; B:=0; For A:=1 to NU do If (U[A].X=X) and (U[A].Y=Y) then Begin SelW:=True; Sel:=A; B:=1; End; For A:=1 to NH do If (H[A].X=X) and (H[A].Y=Y) then Begin SelW:=False; Sel:=A; B:=1; End; If B=0 then If SelW and (U[Sel].own=1) and (Abs(U[Sel].X-X)<2) and (Abs(U[Sel].Y-Y)<2) then If U[Sel].CurMove>0 then Begin For A:=1 to NU do If (Sel<>A) and (U[A].X=X) and (U[A].Y=Y) then If U[A].own=1 then B:=1 else Begin B:=1; Dec(U[Sel].CurMove); Fight(1,True,Sel,2,True,A); Break; End; If B=0 then For A:=1 to NH do If (H[A].X=X) and (H[A].Y+1=Y) and (H[A].own<>1) then If (H[A].Army[1]=0) and (H[A].Army[2]=0) and (H[A].Army[3]=0) and (H[A].Army[4]=0) and (H[A].Army[5]=0) then H[A].own:=1 else Begin B:=1; Dec(U[Sel].CurMove); Fight(1,True,Sel,H[A].own,False,A); Break; End else else If (H[A].X=X) and (H[A].Y=Y) then B:=1; If B=0 then Begin Dec(U[Sel].CurMove); U[Sel].X:=X; U[Sel].Y:=Y; End; End; End else If SelW and (Xm>200) and (Ym>=80) and (Ym<=88) then Begin WaitRelBut; A:=Sel; Repeat Inc(A); If A>NU then A:=1; Until (A=Sel) or (U[A].own=1); Sel:=A; MX:=U[Sel].X-3; MY:=U[Sel].Y-3; If MX<0 then MX:=0; If MY<0 then MY:=0; If MX>58 then MX:=58; If MY>58 then MY:=58; End else If SelW and Trade and (Xm>200) and (Ym>=110) and (Ym<=118) then Begin WaitRelBut; MakeTrade; End else If Not SelW and (Xm>200) and (Ym>=80) and (Ym<=88) and (H[Sel].own=1) then Begin ShowDirs; End else If Not SelW and (Xm>200) and (Ym>=90) and (Ym<=98) and (H[Sel].own=1) then Begin WaitRelBut; Buy; End else If (Xm>200) and (Ym>170) and (Ym<=178) then Begin EndMove; End; End else If Rb then Begin If (Xm>=4) and (Xm<196) and (Ym>=4) and (Ym<196) then Begin X:=MX+(Xm-4) shr 5; Y:=MY+(Ym-4) shr 5; B:=0; For A:=1 to NU do If (U[A].X=X) and (U[A].Y=Y) then Begin ShowStat(True,A); B:=1; Repeat ReadMouseState(Xm,Ym,Lb,Mb,Rb); Until Not Rb; Break; End; If B=0 then For A:=1 to NH do If (H[A].X=X) and (H[A].Y=Y) then Begin ShowStat(False,A); Repeat ReadMouseState(Xm,Ym,Lb,Mb,Rb); Until Not Rb; Break; End; End; End; If Pressed[scTab] then Begin Repeat Until Not Pressed[scTab]; A:=Sel; Repeat Inc(A); If A>NU then A:=1; Until (A=Sel) or (U[A].own=1); Sel:=A; MX:=U[Sel].X-3; MY:=U[Sel].Y-3; If MX<0 then MX:=0; If MY<0 then MY:=0; If MX>58 then MX:=58; If MY>58 then MY:=58; End; Xp:=0; Yp:=0; If Pressed[scLeft] then Xp:=-1; If Pressed[scRight] then Xp:=1; If Pressed[scDown] then Yp:=1; If Pressed[scUp] then Yp:=-1; If Pressed[scHome] then Begin Xp:=-1; Yp:=-1; End; If Pressed[scPgUp] then Begin Xp:=1; Yp:=-1; End; If Pressed[scPgDn] then Begin Xp:=1; Yp:=1; End; If Pressed[scEnd] then Begin Xp:=-1; Yp:=1; End; Repeat Until Not (Pressed[scLeft] or Pressed[scRight] or Pressed[scDown] or Pressed[scUp] or Pressed[scHome] or Pressed[scPgUp] or Pressed[scPgDn] or Pressed[scEnd]); If (Xp<>0) or (Yp<>0) then Begin X:=U[Sel].X+Xp; Y:=U[Sel].Y+Yp; B:=0; If SelW and (U[Sel].own=1) and (Abs(U[Sel].X-X)<2) and (Abs(U[Sel].Y-Y)<2) then If U[Sel].CurMove>0 then Begin For A:=1 to NU do If (Sel<>A) and (U[A].X=X) and (U[A].Y=Y) then If U[A].own=1 then B:=1 else Begin B:=1; Dec(U[Sel].CurMove); Fight(1,True,Sel,2,True,A); Break; End; If B=0 then For A:=1 to NH do If (H[A].X=X) and (H[A].Y+1=Y) and (H[A].own<>1) then Begin If (H[A].Army[1]=0) and (H[A].Army[2]=0) and (H[A].Army[3]=0) and (H[A].Army[4]=0) and (H[A].Army[5]=0) then H[A].own:=1 else Begin B:=1; Dec(U[Sel].CurMove); Fight(1,True,Sel,H[A].own,False,A); Break; End; End else If (H[A].X=X) and (H[A].Y=Y) then B:=1; If B=0 then Begin Dec(U[Sel].CurMove); U[Sel].X:=X; U[Sel].Y:=Y; MX:=U[Sel].X-3; MY:=U[Sel].Y-3; If MX<0 then MX:=0; If MY<0 then MY:=0; If MX>58 then MX:=58; If MY>58 then MY:=58; End; End; End; B:=0; For A:=1 to NU do If U[A].own=1 then B:=1; If B=0 then For A:=1 to NH do If H[A].own=1 then B:=1; If B=0 then Begin HideMouse; Restore_Handler; GrDone; WriteLn('You lose'); Halt(1); End; B:=0; For A:=1 to NU do If U[A].own=2 then B:=1; If B=0 then For A:=1 to NH do If H[A].own=2 then B:=1; If B=0 then Begin HideMouse; Restore_Handler; GrDone; WriteLn('You win'); Halt(1); End; Until Pressed[scEsc]; HideMouse; Restore_Handler; GrDone; End.