From 81a68b9ff71207e598bed6f0d7c5fe8df5d7daae Mon Sep 17 00:00:00 2001 From: Ketmar Dark Date: Wed, 23 Aug 2017 16:40:08 +0300 Subject: [PATCH] more holmes code --- src/game/g_holmes.inc | 635 ++++++++++++++++++++++++++++++++++++++++ src/game/g_holmes.pas | 162 ++++------ src/game/g_monsters.pas | 303 +++++++++---------- 3 files changed, 830 insertions(+), 270 deletions(-) create mode 100644 src/game/g_holmes.inc diff --git a/src/game/g_holmes.inc b/src/game/g_holmes.inc new file mode 100644 index 0000000..8df305c --- /dev/null +++ b/src/game/g_holmes.inc @@ -0,0 +1,635 @@ +// ////////////////////////////////////////////////////////////////////////// // +// cursor (hi, Death Track!) +const curWidth = 17; +const curHeight = 23; + +const cursorImg: array[0..curWidth*curHeight-1] of Byte = ( + 0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,3,2,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,0,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,3,3,2,2,0,0,0,0,0,0,0,0,0,0,0, + 1,1,3,3,4,2,2,0,0,0,0,0,0,0,0,0,0, + 1,1,3,3,4,4,2,2,0,0,0,0,0,0,0,0,0, + 1,1,3,3,4,4,4,2,2,0,0,0,0,0,0,0,0, + 1,1,3,3,4,4,4,4,2,2,0,0,0,0,0,0,0, + 1,1,3,3,4,4,4,5,6,2,2,0,0,0,0,0,0, + 1,1,3,3,4,4,5,6,7,5,2,2,0,0,0,0,0, + 1,1,3,3,4,5,6,7,5,4,5,2,2,0,0,0,0, + 1,1,3,3,5,6,7,5,4,5,6,7,2,2,0,0,0, + 1,1,3,3,6,7,5,4,5,6,7,7,7,2,2,0,0, + 1,1,3,3,7,5,4,5,6,7,7,7,7,7,2,2,0, + 1,1,3,3,5,4,5,6,8,8,8,8,8,8,8,8,2, + 1,1,3,3,4,5,6,3,8,8,8,8,8,8,8,8,8, + 1,1,3,3,5,6,3,3,1,1,1,1,1,1,1,0,0, + 1,1,3,3,6,3,3,1,1,1,1,1,1,1,1,0,0, + 1,1,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0, + 1,1,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +); +const cursorPal: array[0..9*4-1] of Byte = ( + 0, 0, 0, 0, + 0, 0, 0,163, + 85,255,255,255, + 85, 85,255,255, + 255, 85, 85,255, + 170, 0,170,255, + 85, 85, 85,255, + 0, 0, 0,255, + 0, 0,170,255 +); + + +var + curtexid: GLuint = 0; + +procedure createCursorTexture (); +var + tex, tpp: PByte; + c: Integer; + x, y: Integer; +begin + if (curtexid <> 0) then exit; //begin glDeleteTextures(1, @curtexid); curtexid := 0; end; + + GetMem(tex, curWidth*curHeight*4); + + tpp := tex; + for y := 0 to curHeight-1 do + begin + for x := 0 to curWidth-1 do + begin + c := cursorImg[y*curWidth+x]*4; + tpp^ := cursorPal[c+0]; Inc(tpp); + tpp^ := cursorPal[c+1]; Inc(tpp); + tpp^ := cursorPal[c+2]; Inc(tpp); + tpp^ := cursorPal[c+3]; Inc(tpp); + end; + end; + + glGenTextures(1, @curtexid); + if (curtexid = 0) then raise Exception.Create('can''t create Holmes texture'); + + glBindTexture(GL_TEXTURE_2D, curtexid); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + //GLfloat[4] bclr = 0.0; + //glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bclr.ptr); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, curWidth, curHeight, 0, GL_RGBA{gltt}, GL_UNSIGNED_BYTE, tex); + glFlush(); + + //FreeMem(tex); +end; + + +procedure drawCursor (); +begin + if (curtexid = 0) then createCursorTexture() else glBindTexture(GL_TEXTURE_2D, curtexid); + // blend it + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_TEXTURE_2D); + // color and opacity + glColor4f(1, 1, 1, 0.9); + Dec(msX, 2); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex2i(msX, msY); // top-left + glTexCoord2f(1.0, 0.0); glVertex2i(msX+curWidth, msY); // top-right + glTexCoord2f(1.0, 1.0); glVertex2i(msX+curWidth, msY+curHeight); // bottom-right + glTexCoord2f(0.0, 1.0); glVertex2i(msX, msY+curHeight); // bottom-left + glEnd(); + Inc(msX, 2); + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glColor4f(1, 1, 1, 1); + glBindTexture(GL_TEXTURE_2D, 0); +end; + + +// ////////////////////////////////////////////////////////////////////////// // +// fonts +const kgiFont6: array[0..256*8-1] of Byte = ( +$00,$00,$00,$00,$00,$00,$00,$00,$3c,$42,$a5,$81,$a5,$99,$42,$3c,$3c,$7e,$db,$ff,$ff,$db,$66,$3c,$6c,$fe, +$fe,$fe,$7c,$38,$10,$00,$10,$38,$7c,$fe,$7c,$38,$10,$00,$10,$38,$54,$fe,$54,$10,$38,$00,$10,$38,$7c,$fe, +$fe,$10,$38,$00,$00,$00,$00,$30,$30,$00,$00,$00,$ff,$ff,$ff,$e7,$e7,$ff,$ff,$ff,$38,$44,$82,$82,$82,$44, +$38,$00,$c7,$bb,$7d,$7d,$7d,$bb,$c7,$ff,$0f,$03,$05,$79,$88,$88,$88,$70,$38,$44,$44,$44,$38,$10,$7c,$10, +$30,$28,$24,$24,$28,$20,$e0,$c0,$3c,$24,$3c,$24,$24,$e4,$dc,$18,$10,$54,$38,$ee,$38,$54,$10,$00,$10,$10, +$10,$7c,$10,$10,$10,$10,$10,$10,$10,$ff,$00,$00,$00,$00,$00,$00,$00,$ff,$10,$10,$10,$10,$10,$10,$10,$f0, +$10,$10,$10,$10,$10,$10,$10,$1f,$10,$10,$10,$10,$10,$10,$10,$ff,$10,$10,$10,$10,$10,$10,$10,$10,$10,$10, +$10,$10,$00,$00,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$1f,$10,$10,$10,$10,$00,$00,$00,$f0,$10,$10,$10,$10, +$10,$10,$10,$1f,$00,$00,$00,$00,$10,$10,$10,$f0,$00,$00,$00,$00,$81,$42,$24,$18,$18,$24,$42,$81,$01,$02, +$04,$08,$10,$20,$40,$80,$80,$40,$20,$10,$08,$04,$02,$01,$00,$10,$10,$ff,$10,$10,$00,$00,$00,$00,$00,$00, +$00,$00,$00,$00,$20,$20,$20,$20,$00,$00,$20,$00,$50,$50,$50,$00,$00,$00,$00,$00,$50,$50,$f8,$50,$f8,$50, +$50,$00,$20,$78,$a0,$70,$28,$f0,$20,$00,$c0,$c8,$10,$20,$40,$98,$18,$00,$40,$a0,$40,$a8,$90,$98,$60,$00, +$10,$20,$40,$00,$00,$00,$00,$00,$10,$20,$40,$40,$40,$20,$10,$00,$40,$20,$10,$10,$10,$20,$40,$00,$88,$50, +$20,$f8,$20,$50,$88,$00,$00,$20,$20,$f8,$20,$20,$00,$00,$00,$00,$00,$00,$00,$20,$20,$40,$00,$00,$00,$78, +$00,$00,$00,$00,$00,$00,$00,$00,$00,$60,$60,$00,$00,$00,$08,$10,$20,$40,$80,$00,$70,$88,$98,$a8,$c8,$88, +$70,$00,$20,$60,$a0,$20,$20,$20,$f8,$00,$70,$88,$08,$10,$60,$80,$f8,$00,$70,$88,$08,$30,$08,$88,$70,$00, +$10,$30,$50,$90,$f8,$10,$10,$00,$f8,$80,$e0,$10,$08,$10,$e0,$00,$30,$40,$80,$f0,$88,$88,$70,$00,$f8,$88, +$10,$20,$20,$20,$20,$00,$70,$88,$88,$70,$88,$88,$70,$00,$70,$88,$88,$78,$08,$10,$60,$00,$00,$00,$20,$00, +$00,$20,$00,$00,$00,$00,$20,$00,$00,$20,$20,$40,$18,$30,$60,$c0,$60,$30,$18,$00,$00,$00,$f8,$00,$f8,$00, +$00,$00,$c0,$60,$30,$18,$30,$60,$c0,$00,$70,$88,$08,$10,$20,$00,$20,$00,$70,$88,$08,$68,$a8,$a8,$70,$00, +$20,$50,$88,$88,$f8,$88,$88,$00,$f0,$48,$48,$70,$48,$48,$f0,$00,$30,$48,$80,$80,$80,$48,$30,$00,$e0,$50, +$48,$48,$48,$50,$e0,$00,$f8,$80,$80,$f0,$80,$80,$f8,$00,$f8,$80,$80,$f0,$80,$80,$80,$00,$70,$88,$80,$b8, +$88,$88,$70,$00,$88,$88,$88,$f8,$88,$88,$88,$00,$70,$20,$20,$20,$20,$20,$70,$00,$38,$10,$10,$10,$90,$90, +$60,$00,$88,$90,$a0,$c0,$a0,$90,$88,$00,$80,$80,$80,$80,$80,$80,$f8,$00,$88,$d8,$a8,$a8,$88,$88,$88,$00, +$88,$c8,$c8,$a8,$98,$98,$88,$00,$70,$88,$88,$88,$88,$88,$70,$00,$f0,$88,$88,$f0,$80,$80,$80,$00,$70,$88, +$88,$88,$a8,$90,$68,$00,$f0,$88,$88,$f0,$a0,$90,$88,$00,$70,$88,$80,$70,$08,$88,$70,$00,$f8,$20,$20,$20, +$20,$20,$20,$00,$88,$88,$88,$88,$88,$88,$70,$00,$88,$88,$88,$88,$50,$50,$20,$00,$88,$88,$88,$a8,$a8,$d8, +$88,$00,$88,$88,$50,$20,$50,$88,$88,$00,$88,$88,$88,$70,$20,$20,$20,$00,$f8,$08,$10,$20,$40,$80,$f8,$00, +$70,$40,$40,$40,$40,$40,$70,$00,$00,$00,$80,$40,$20,$10,$08,$00,$70,$10,$10,$10,$10,$10,$70,$00,$20,$50, +$88,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$f8,$00,$40,$20,$10,$00,$00,$00,$00,$00,$00,$00,$70,$08, +$78,$88,$78,$00,$80,$80,$b0,$c8,$88,$c8,$b0,$00,$00,$00,$70,$88,$80,$88,$70,$00,$08,$08,$68,$98,$88,$98, +$68,$00,$00,$00,$70,$88,$f8,$80,$70,$00,$10,$28,$20,$f8,$20,$20,$20,$00,$00,$00,$68,$98,$98,$68,$08,$70, +$80,$80,$f0,$88,$88,$88,$88,$00,$20,$00,$60,$20,$20,$20,$70,$00,$10,$00,$30,$10,$10,$10,$90,$60,$40,$40, +$48,$50,$60,$50,$48,$00,$60,$20,$20,$20,$20,$20,$70,$00,$00,$00,$d0,$a8,$a8,$a8,$a8,$00,$00,$00,$b0,$c8, +$88,$88,$88,$00,$00,$00,$70,$88,$88,$88,$70,$00,$00,$00,$b0,$c8,$c8,$b0,$80,$80,$00,$00,$68,$98,$98,$68, +$08,$08,$00,$00,$b0,$c8,$80,$80,$80,$00,$00,$00,$78,$80,$f0,$08,$f0,$00,$40,$40,$f0,$40,$40,$48,$30,$00, +$00,$00,$90,$90,$90,$90,$68,$00,$00,$00,$88,$88,$88,$50,$20,$00,$00,$00,$88,$a8,$a8,$a8,$50,$00,$00,$00, +$88,$50,$20,$50,$88,$00,$00,$00,$88,$88,$98,$68,$08,$70,$00,$00,$f8,$10,$20,$40,$f8,$00,$18,$20,$20,$40, +$20,$20,$18,$00,$20,$20,$20,$00,$20,$20,$20,$00,$c0,$20,$20,$10,$20,$20,$c0,$00,$40,$a8,$10,$00,$00,$00, +$00,$00,$00,$00,$20,$50,$f8,$00,$00,$00,$00,$00,$00,$00,$00,$00,$ff,$ff,$f0,$f0,$f0,$f0,$0f,$0f,$0f,$0f, +$00,$00,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$3c,$3c,$00,$00,$00,$ff,$ff, +$ff,$ff,$ff,$ff,$00,$00,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$fc,$fc,$fc,$fc, +$fc,$fc,$fc,$fc,$03,$03,$03,$03,$03,$03,$03,$03,$3f,$3f,$3f,$3f,$3f,$3f,$3f,$3f,$11,$22,$44,$88,$11,$22, +$44,$88,$88,$44,$22,$11,$88,$44,$22,$11,$fe,$7c,$38,$10,$00,$00,$00,$00,$00,$00,$00,$00,$10,$38,$7c,$fe, +$80,$c0,$e0,$f0,$e0,$c0,$80,$00,$01,$03,$07,$0f,$07,$03,$01,$00,$ff,$7e,$3c,$18,$18,$3c,$7e,$ff,$81,$c3, +$e7,$ff,$ff,$e7,$c3,$81,$f0,$f0,$f0,$f0,$00,$00,$00,$00,$00,$00,$00,$00,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f, +$00,$00,$00,$00,$00,$00,$00,$00,$f0,$f0,$f0,$f0,$33,$33,$cc,$cc,$33,$33,$cc,$cc,$00,$20,$20,$50,$50,$88, +$f8,$00,$20,$20,$70,$20,$70,$20,$20,$00,$00,$00,$00,$50,$88,$a8,$50,$00,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff, +$00,$00,$00,$00,$ff,$ff,$ff,$ff,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$ff,$ff, +$ff,$ff,$00,$00,$00,$00,$00,$00,$68,$90,$90,$90,$68,$00,$30,$48,$48,$70,$48,$48,$70,$c0,$f8,$88,$80,$80, +$80,$80,$80,$00,$00,$50,$70,$88,$f8,$80,$70,$00,$00,$00,$78,$80,$f0,$80,$78,$00,$00,$00,$78,$90,$90,$90, +$60,$00,$20,$00,$60,$20,$20,$20,$70,$00,$50,$00,$70,$20,$20,$20,$70,$00,$f8,$20,$70,$a8,$a8,$70,$20,$f8, +$20,$50,$88,$f8,$88,$50,$20,$00,$70,$88,$88,$88,$50,$50,$d8,$00,$30,$40,$40,$20,$50,$50,$50,$20,$00,$00, +$00,$50,$a8,$a8,$50,$00,$08,$70,$a8,$a8,$a8,$70,$80,$00,$38,$40,$80,$f8,$80,$40,$38,$00,$70,$88,$88,$88, +$88,$88,$88,$00,$00,$f8,$00,$f8,$00,$f8,$00,$00,$20,$20,$f8,$20,$20,$00,$f8,$00,$c0,$30,$08,$30,$c0,$00, +$f8,$00,$50,$f8,$80,$f0,$80,$80,$f8,$00,$78,$80,$80,$f0,$80,$80,$78,$00,$20,$20,$20,$20,$20,$20,$a0,$40, +$70,$20,$20,$20,$20,$20,$70,$00,$50,$70,$20,$20,$20,$20,$70,$00,$00,$18,$24,$24,$18,$00,$00,$00,$00,$30, +$78,$78,$30,$00,$00,$00,$00,$00,$00,$00,$30,$00,$00,$00,$3e,$20,$20,$20,$a0,$60,$20,$00,$a0,$50,$50,$50, +$00,$00,$00,$00,$40,$a0,$20,$40,$e0,$00,$00,$00,$00,$38,$38,$38,$38,$38,$38,$00,$3c,$42,$99,$a1,$a1,$99, +$42,$3c,$00,$00,$90,$a8,$e8,$a8,$90,$00,$00,$00,$60,$10,$70,$90,$68,$00,$00,$00,$f0,$80,$f0,$88,$f0,$00, +$00,$00,$90,$90,$90,$f8,$08,$00,$00,$00,$30,$50,$50,$70,$88,$00,$00,$00,$70,$88,$f8,$80,$70,$00,$00,$20, +$70,$a8,$a8,$70,$20,$00,$00,$00,$78,$48,$40,$40,$40,$00,$00,$00,$88,$50,$20,$50,$88,$00,$00,$00,$88,$98, +$a8,$c8,$88,$00,$00,$50,$20,$00,$98,$a8,$c8,$00,$00,$00,$90,$a0,$c0,$a0,$90,$00,$00,$00,$38,$28,$28,$48, +$88,$00,$00,$00,$88,$d8,$a8,$88,$88,$00,$00,$00,$88,$88,$f8,$88,$88,$00,$00,$00,$70,$88,$88,$88,$70,$00, +$00,$00,$78,$48,$48,$48,$48,$00,$00,$00,$78,$88,$78,$28,$48,$00,$00,$00,$f0,$88,$f0,$80,$80,$00,$00,$00, +$78,$80,$80,$80,$78,$00,$00,$00,$f8,$20,$20,$20,$20,$00,$00,$00,$88,$50,$20,$40,$80,$00,$00,$00,$a8,$70, +$20,$70,$a8,$00,$00,$00,$f0,$48,$70,$48,$f0,$00,$00,$00,$40,$40,$70,$48,$70,$00,$00,$00,$88,$88,$c8,$a8, +$c8,$00,$00,$00,$f0,$08,$70,$08,$f0,$00,$00,$00,$a8,$a8,$a8,$a8,$f8,$00,$00,$00,$70,$88,$38,$88,$70,$00, +$00,$00,$a8,$a8,$a8,$f8,$08,$00,$00,$00,$48,$48,$78,$08,$08,$00,$00,$00,$c0,$40,$70,$48,$70,$00,$90,$a8, +$a8,$e8,$a8,$a8,$90,$00,$20,$50,$88,$88,$f8,$88,$88,$00,$f8,$88,$80,$f0,$88,$88,$f0,$00,$90,$90,$90,$90, +$90,$f8,$08,$00,$38,$28,$28,$48,$48,$f8,$88,$00,$f8,$80,$80,$f0,$80,$80,$f8,$00,$20,$70,$a8,$a8,$a8,$70, +$20,$00,$f8,$88,$88,$80,$80,$80,$80,$00,$88,$88,$50,$20,$50,$88,$88,$00,$88,$88,$98,$a8,$c8,$88,$88,$00, +$50,$20,$88,$98,$a8,$c8,$88,$00,$88,$90,$a0,$c0,$a0,$90,$88,$00,$18,$28,$48,$48,$48,$48,$88,$00,$88,$d8, +$a8,$a8,$88,$88,$88,$00,$88,$88,$88,$f8,$88,$88,$88,$00,$70,$88,$88,$88,$88,$88,$70,$00,$f8,$88,$88,$88, +$88,$88,$88,$00,$78,$88,$88,$78,$28,$48,$88,$00,$f0,$88,$88,$f0,$80,$80,$80,$00,$70,$88,$80,$80,$80,$88, +$70,$00,$f8,$20,$20,$20,$20,$20,$20,$00,$88,$88,$88,$50,$20,$40,$80,$00,$a8,$a8,$70,$20,$70,$a8,$a8,$00, +$f0,$48,$48,$70,$48,$48,$f0,$00,$80,$80,$80,$f0,$88,$88,$f0,$00,$88,$88,$88,$c8,$a8,$a8,$c8,$00,$f0,$08, +$08,$30,$08,$08,$f0,$00,$a8,$a8,$a8,$a8,$a8,$a8,$f8,$00,$70,$88,$08,$78,$08,$88,$70,$00,$a8,$a8,$a8,$a8, +$a8,$f8,$08,$00,$88,$88,$88,$88,$78,$08,$08,$00,$c0,$40,$40,$70,$48,$48,$70,$00 +); + +const kgiFont8: array[0..256*8-1] of Byte = ( +$00,$00,$00,$00,$00,$00,$00,$00,$7e,$81,$a5,$81,$bd,$99,$81,$7e,$7e,$ff,$db,$ff,$c3,$e7,$ff,$7e,$6c,$fe, +$fe,$fe,$7c,$38,$10,$00,$10,$38,$7c,$fe,$7c,$38,$10,$00,$38,$7c,$38,$fe,$fe,$d6,$10,$38,$10,$10,$38,$7c, +$fe,$7c,$10,$38,$00,$00,$18,$3c,$3c,$18,$00,$00,$ff,$ff,$e7,$c3,$c3,$e7,$ff,$ff,$00,$3c,$66,$42,$42,$66, +$3c,$00,$ff,$c3,$99,$bd,$bd,$99,$c3,$ff,$0f,$07,$0f,$7d,$cc,$cc,$cc,$78,$3c,$66,$66,$66,$3c,$18,$7e,$18, +$3f,$33,$3f,$30,$30,$70,$f0,$e0,$7f,$63,$7f,$63,$63,$67,$e6,$c0,$99,$5a,$3c,$e7,$e7,$3c,$5a,$99,$80,$e0, +$f8,$fe,$f8,$e0,$80,$00,$02,$0e,$3e,$fe,$3e,$0e,$02,$00,$18,$3c,$7e,$18,$18,$7e,$3c,$18,$66,$66,$66,$66, +$66,$00,$66,$00,$7f,$db,$db,$7b,$1b,$1b,$1b,$00,$7e,$c3,$78,$cc,$cc,$78,$8c,$f8,$00,$00,$00,$00,$7e,$7e, +$7e,$00,$18,$3c,$7e,$18,$7e,$3c,$18,$ff,$18,$3c,$7e,$18,$18,$18,$18,$00,$18,$18,$18,$18,$7e,$3c,$18,$00, +$00,$18,$0c,$fe,$0c,$18,$00,$00,$00,$30,$60,$fe,$60,$30,$00,$00,$00,$00,$c0,$c0,$c0,$fe,$00,$00,$00,$24, +$66,$ff,$66,$24,$00,$00,$00,$18,$3c,$7e,$ff,$ff,$00,$00,$00,$ff,$ff,$7e,$3c,$18,$00,$00,$00,$00,$00,$00, +$00,$00,$00,$00,$30,$78,$78,$30,$30,$00,$30,$00,$6c,$6c,$6c,$00,$00,$00,$00,$00,$6c,$6c,$fe,$6c,$fe,$6c, +$6c,$00,$30,$7c,$c0,$78,$0c,$f8,$30,$00,$00,$c6,$cc,$18,$30,$66,$c6,$00,$38,$6c,$38,$76,$dc,$cc,$76,$00, +$60,$60,$c0,$00,$00,$00,$00,$00,$18,$30,$60,$60,$60,$30,$18,$00,$60,$30,$18,$18,$18,$30,$60,$00,$00,$66, +$3c,$ff,$3c,$66,$00,$00,$00,$30,$30,$fc,$30,$30,$00,$00,$00,$00,$00,$00,$00,$70,$30,$60,$00,$00,$00,$fc, +$00,$00,$00,$00,$00,$00,$00,$00,$00,$30,$30,$00,$06,$0c,$18,$30,$60,$c0,$80,$00,$78,$cc,$dc,$fc,$ec,$cc, +$78,$00,$30,$f0,$30,$30,$30,$30,$fc,$00,$78,$cc,$0c,$38,$60,$cc,$fc,$00,$78,$cc,$0c,$38,$0c,$cc,$78,$00, +$1c,$3c,$6c,$cc,$fe,$0c,$0c,$00,$fc,$c0,$f8,$0c,$0c,$cc,$78,$00,$38,$60,$c0,$f8,$cc,$cc,$78,$00,$fc,$cc, +$0c,$18,$30,$60,$60,$00,$78,$cc,$cc,$78,$cc,$cc,$78,$00,$78,$cc,$cc,$7c,$0c,$18,$70,$00,$00,$00,$30,$30, +$00,$30,$30,$00,$00,$00,$30,$30,$00,$70,$30,$60,$18,$30,$60,$c0,$60,$30,$18,$00,$00,$00,$fc,$00,$fc,$00, +$00,$00,$60,$30,$18,$0c,$18,$30,$60,$00,$78,$cc,$0c,$18,$30,$00,$30,$00,$7c,$c6,$de,$de,$de,$c0,$78,$00, +$30,$78,$cc,$cc,$fc,$cc,$cc,$00,$fc,$66,$66,$7c,$66,$66,$fc,$00,$3c,$66,$c0,$c0,$c0,$66,$3c,$00,$fc,$6c, +$66,$66,$66,$6c,$fc,$00,$fe,$62,$68,$78,$68,$62,$fe,$00,$fe,$62,$68,$78,$68,$60,$f0,$00,$3c,$66,$c0,$c0, +$ce,$66,$3e,$00,$cc,$cc,$cc,$fc,$cc,$cc,$cc,$00,$78,$30,$30,$30,$30,$30,$78,$00,$1e,$0c,$0c,$0c,$cc,$cc, +$78,$00,$e6,$66,$6c,$78,$6c,$66,$e6,$00,$f0,$60,$60,$60,$62,$66,$fe,$00,$c6,$ee,$fe,$d6,$c6,$c6,$c6,$00, +$c6,$e6,$f6,$de,$ce,$c6,$c6,$00,$38,$6c,$c6,$c6,$c6,$6c,$38,$00,$fc,$66,$66,$7c,$60,$60,$f0,$00,$78,$cc, +$cc,$cc,$dc,$78,$1c,$00,$fc,$66,$66,$7c,$78,$6c,$e6,$00,$78,$cc,$e0,$38,$1c,$cc,$78,$00,$fc,$b4,$30,$30, +$30,$30,$78,$00,$cc,$cc,$cc,$cc,$cc,$cc,$fc,$00,$cc,$cc,$cc,$cc,$cc,$78,$30,$00,$c6,$c6,$c6,$d6,$fe,$ee, +$c6,$00,$c6,$c6,$6c,$38,$6c,$c6,$c6,$00,$cc,$cc,$cc,$78,$30,$30,$78,$00,$fe,$cc,$98,$30,$62,$c6,$fe,$00, +$78,$60,$60,$60,$60,$60,$78,$00,$c0,$60,$30,$18,$0c,$06,$02,$00,$78,$18,$18,$18,$18,$18,$78,$00,$10,$38, +$6c,$c6,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$ff,$30,$30,$18,$00,$00,$00,$00,$00,$00,$00,$78,$0c, +$7c,$cc,$76,$00,$e0,$60,$7c,$66,$66,$66,$bc,$00,$00,$00,$78,$cc,$c0,$cc,$78,$00,$1c,$0c,$0c,$7c,$cc,$cc, +$76,$00,$00,$00,$78,$cc,$fc,$c0,$78,$00,$38,$6c,$60,$f0,$60,$60,$f0,$00,$00,$00,$76,$cc,$cc,$7c,$0c,$f8, +$e0,$60,$6c,$76,$66,$66,$e6,$00,$30,$00,$70,$30,$30,$30,$78,$00,$18,$00,$78,$18,$18,$18,$d8,$70,$e0,$60, +$66,$6c,$78,$6c,$e6,$00,$70,$30,$30,$30,$30,$30,$78,$00,$00,$00,$ec,$fe,$d6,$c6,$c6,$00,$00,$00,$f8,$cc, +$cc,$cc,$cc,$00,$00,$00,$78,$cc,$cc,$cc,$78,$00,$00,$00,$dc,$66,$66,$7c,$60,$f0,$00,$00,$76,$cc,$cc,$7c, +$0c,$1e,$00,$00,$d8,$6c,$6c,$60,$f0,$00,$00,$00,$7c,$c0,$78,$0c,$f8,$00,$10,$30,$7c,$30,$30,$34,$18,$00, +$00,$00,$cc,$cc,$cc,$cc,$76,$00,$00,$00,$cc,$cc,$cc,$78,$30,$00,$00,$00,$c6,$c6,$d6,$fe,$6c,$00,$00,$00, +$c6,$6c,$38,$6c,$c6,$00,$00,$00,$cc,$cc,$cc,$7c,$0c,$f8,$00,$00,$fc,$98,$30,$64,$fc,$00,$1c,$30,$30,$e0, +$30,$30,$1c,$00,$18,$18,$18,$00,$18,$18,$18,$00,$e0,$30,$30,$1c,$30,$30,$e0,$00,$76,$dc,$00,$00,$00,$00, +$00,$00,$10,$38,$6c,$c6,$c6,$c6,$fe,$00,$78,$cc,$c0,$cc,$78,$18,$0c,$78,$00,$cc,$00,$cc,$cc,$cc,$7e,$00, +$1c,$00,$78,$cc,$fc,$c0,$78,$00,$7e,$c3,$3c,$06,$3e,$66,$3f,$00,$cc,$00,$78,$0c,$7c,$cc,$7e,$00,$e0,$00, +$78,$0c,$7c,$cc,$7e,$00,$30,$30,$78,$0c,$7c,$cc,$7e,$00,$00,$00,$7c,$c0,$c0,$7c,$06,$3c,$7e,$c3,$3c,$66, +$7e,$60,$3c,$00,$cc,$00,$78,$cc,$fc,$c0,$78,$00,$e0,$00,$78,$cc,$fc,$c0,$78,$00,$cc,$00,$70,$30,$30,$30, +$78,$00,$7c,$c6,$38,$18,$18,$18,$3c,$00,$e0,$00,$70,$30,$30,$30,$78,$00,$cc,$30,$78,$cc,$cc,$fc,$cc,$00, +$30,$30,$00,$78,$cc,$fc,$cc,$00,$1c,$00,$fc,$60,$78,$60,$fc,$00,$00,$00,$7f,$0c,$7f,$cc,$7f,$00,$3e,$6c, +$cc,$fe,$cc,$cc,$ce,$00,$78,$cc,$00,$78,$cc,$cc,$78,$00,$00,$cc,$00,$78,$cc,$cc,$78,$00,$00,$e0,$00,$78, +$cc,$cc,$78,$00,$78,$cc,$00,$cc,$cc,$cc,$7e,$00,$00,$e0,$00,$cc,$cc,$cc,$7e,$00,$00,$cc,$00,$cc,$cc,$fc, +$0c,$f8,$c6,$38,$7c,$c6,$c6,$7c,$38,$00,$cc,$00,$cc,$cc,$cc,$cc,$78,$00,$18,$18,$7e,$c0,$c0,$7e,$18,$18, +$38,$6c,$64,$f0,$60,$e6,$fc,$00,$cc,$cc,$78,$fc,$30,$fc,$30,$00,$f0,$d8,$d8,$f4,$cc,$de,$cc,$0e,$0e,$1b, +$18,$7e,$18,$18,$d8,$70,$1c,$00,$78,$0c,$7c,$cc,$7e,$00,$38,$00,$70,$30,$30,$30,$78,$00,$00,$1c,$00,$78, +$cc,$cc,$78,$00,$00,$1c,$00,$cc,$cc,$cc,$7e,$00,$00,$f8,$00,$f8,$cc,$cc,$cc,$00,$fc,$00,$cc,$ec,$fc,$dc, +$cc,$00,$3c,$6c,$6c,$3e,$00,$7e,$00,$00,$3c,$66,$66,$3c,$00,$7e,$00,$00,$30,$00,$30,$60,$c0,$cc,$78,$00, +$00,$00,$00,$fc,$c0,$c0,$00,$00,$00,$00,$00,$fc,$0c,$0c,$00,$00,$c6,$cc,$d8,$3e,$63,$ce,$98,$1f,$c6,$cc, +$d8,$f3,$67,$cf,$9f,$03,$00,$18,$00,$18,$18,$3c,$3c,$18,$00,$33,$66,$cc,$66,$33,$00,$00,$00,$cc,$66,$33, +$66,$cc,$00,$00,$22,$88,$22,$88,$22,$88,$22,$88,$55,$aa,$55,$aa,$55,$aa,$55,$aa,$dc,$76,$dc,$76,$dc,$76, +$dc,$76,$18,$18,$18,$18,$18,$18,$18,$18,$18,$18,$18,$18,$f8,$18,$18,$18,$18,$18,$f8,$18,$f8,$18,$18,$18, +$36,$36,$36,$36,$f6,$36,$36,$36,$00,$00,$00,$00,$fe,$36,$36,$36,$00,$00,$f8,$18,$f8,$18,$18,$18,$36,$36, +$f6,$06,$f6,$36,$36,$36,$36,$36,$36,$36,$36,$36,$36,$36,$00,$00,$fe,$06,$f6,$36,$36,$36,$36,$36,$f6,$06, +$fe,$00,$00,$00,$36,$36,$36,$36,$fe,$00,$00,$00,$18,$18,$f8,$18,$f8,$00,$00,$00,$00,$00,$00,$00,$f8,$18, +$18,$18,$18,$18,$18,$18,$1f,$00,$00,$00,$18,$18,$18,$18,$ff,$00,$00,$00,$00,$00,$00,$00,$ff,$18,$18,$18, +$18,$18,$18,$18,$1f,$18,$18,$18,$00,$00,$00,$00,$ff,$00,$00,$00,$18,$18,$18,$18,$ff,$18,$18,$18,$18,$18, +$1f,$18,$1f,$18,$18,$18,$36,$36,$36,$36,$37,$36,$36,$36,$36,$36,$37,$30,$3f,$00,$00,$00,$00,$00,$3f,$30, +$37,$36,$36,$36,$36,$36,$f7,$00,$ff,$00,$00,$00,$00,$00,$ff,$00,$f7,$36,$36,$36,$36,$36,$37,$30,$37,$36, +$36,$36,$00,$00,$ff,$00,$ff,$00,$00,$00,$36,$36,$f7,$00,$f7,$36,$36,$36,$18,$18,$ff,$00,$ff,$00,$00,$00, +$36,$36,$36,$36,$ff,$00,$00,$00,$00,$00,$ff,$00,$ff,$18,$18,$18,$00,$00,$00,$00,$ff,$36,$36,$36,$36,$36, +$36,$36,$3f,$00,$00,$00,$18,$18,$1f,$18,$1f,$00,$00,$00,$00,$00,$1f,$18,$1f,$18,$18,$18,$00,$00,$00,$00, +$3f,$36,$36,$36,$36,$36,$36,$36,$f7,$36,$36,$36,$18,$18,$ff,$00,$ff,$18,$18,$18,$18,$18,$18,$18,$f8,$00, +$00,$00,$00,$00,$00,$00,$1f,$18,$18,$18,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$00,$00,$00,$00,$ff,$ff,$ff,$ff, +$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$ff,$ff,$ff,$ff,$00,$00,$00,$00,$00,$00, +$76,$dc,$c8,$dc,$76,$00,$00,$78,$cc,$f8,$cc,$f8,$c0,$c0,$00,$fe,$c6,$c0,$c0,$c0,$c0,$00,$00,$fe,$6c,$6c, +$6c,$6c,$6c,$00,$fe,$66,$30,$18,$30,$66,$fe,$00,$00,$00,$7e,$cc,$cc,$cc,$78,$00,$00,$66,$66,$66,$66,$7c, +$60,$c0,$00,$76,$dc,$18,$18,$18,$18,$00,$fc,$30,$78,$cc,$cc,$78,$30,$fc,$38,$6c,$c6,$fe,$c6,$6c,$38,$00, +$38,$6c,$c6,$c6,$6c,$6c,$ee,$00,$1c,$30,$18,$7c,$cc,$cc,$78,$00,$00,$00,$7e,$db,$db,$7e,$00,$00,$06,$0c, +$7e,$db,$db,$7e,$60,$c0,$3c,$60,$c0,$fc,$c0,$60,$3c,$00,$78,$cc,$cc,$cc,$cc,$cc,$cc,$00,$00,$fc,$00,$fc, +$00,$fc,$00,$00,$30,$30,$fc,$30,$30,$00,$fc,$00,$60,$30,$18,$30,$60,$00,$fc,$00,$18,$30,$60,$30,$18,$00, +$fc,$00,$0e,$1b,$1b,$18,$18,$18,$18,$18,$18,$18,$18,$18,$18,$d8,$d8,$70,$30,$30,$00,$fc,$00,$30,$30,$00, +$00,$72,$9c,$00,$72,$9c,$00,$00,$38,$6c,$6c,$38,$00,$00,$00,$00,$00,$00,$00,$18,$18,$00,$00,$00,$00,$00, +$00,$00,$18,$00,$00,$00,$0f,$0c,$0c,$0c,$ec,$6c,$3c,$1c,$78,$6c,$6c,$6c,$6c,$00,$00,$00,$78,$0c,$38,$60, +$7c,$00,$00,$00,$00,$00,$3c,$3c,$3c,$3c,$00,$00,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff +); + +const kgiFont6PropWidth: array[0..256-1] of Byte = ( + $08,$08,$08,$07,$07,$07,$07,$04,$08,$07,$08,$08,$06,$06,$06,$07, + $06,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08, + $85,$21,$13,$05,$05,$05,$05,$13,$13,$13,$05,$05,$12,$14,$12,$05, + $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$21,$12,$05,$05,$05,$05, + $05,$05,$05,$05,$05,$05,$05,$05,$05,$13,$05,$05,$05,$05,$05,$05, + $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$13,$05,$13,$05,$05, + $13,$05,$05,$05,$05,$05,$05,$05,$05,$13,$04,$14,$13,$05,$05,$05, + $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$14,$21,$04,$05,$08, + $08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$04, + $44,$08,$08,$08,$08,$08,$08,$08,$05,$04,$05,$08,$08,$08,$08,$08, + $05,$05,$05,$05,$05,$05,$13,$13,$05,$05,$05,$04,$05,$05,$05,$05, + $05,$05,$05,$05,$05,$03,$04,$04,$06,$05,$04,$07,$04,$03,$05,$08, + $05,$05,$05,$05,$05,$05,$05,$14,$05,$05,$05,$04,$05,$05,$05,$05, + $14,$05,$05,$05,$05,$05,$05,$05,$14,$05,$05,$05,$05,$05,$14,$05, + $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05, + $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05 +); + +const kgiFont8PropWidth: array[0..256-1] of Byte = ( + $08,$08,$08,$07,$07,$07,$07,$06,$08,$07,$08,$08,$07,$08,$08,$08, + $07,$07,$07,$07,$08,$08,$07,$08,$07,$07,$07,$07,$07,$08,$08,$08, + $85,$14,$15,$07,$06,$07,$07,$03,$14,$14,$08,$06,$13,$06,$22,$07, + $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$22,$13,$05,$06,$15,$06, + $07,$06,$07,$07,$07,$07,$07,$07,$06,$14,$07,$07,$07,$07,$07,$07, + $07,$06,$07,$06,$06,$06,$06,$07,$07,$06,$07,$14,$07,$14,$07,$08, + $23,$07,$07,$06,$07,$06,$06,$07,$07,$14,$05,$07,$14,$07,$06,$06, + $07,$07,$06,$06,$15,$07,$06,$07,$07,$06,$06,$06,$32,$06,$07,$07, + $06,$07,$06,$08,$07,$07,$07,$07,$08,$06,$06,$06,$07,$05,$06,$06, + $06,$08,$07,$06,$06,$06,$07,$07,$06,$07,$06,$07,$07,$06,$07,$08, + $07,$05,$06,$07,$06,$06,$16,$16,$06,$06,$06,$08,$08,$06,$08,$08, + $08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08, + $38,$08,$08,$38,$08,$08,$38,$28,$28,$28,$08,$08,$28,$08,$08,$08, + $08,$08,$08,$28,$38,$38,$28,$08,$08,$08,$38,$08,$08,$08,$48,$08, + $07,$06,$07,$07,$07,$07,$07,$07,$06,$07,$07,$06,$08,$08,$06,$06, + $06,$06,$06,$06,$35,$05,$06,$07,$15,$32,$32,$08,$15,$15,$24,$08 +); + + +function createFontTexture (constref font: array of Byte; constref fontwdt: array of Byte; prop: Boolean): GLuint; +const + Width = 16*8; + Height = 16*8; +var + tex, tpp: PByte; + b: Byte; + cc: Integer; + x, y, dx, dy: Integer; +begin + GetMem(tex, Width*Height*4); + + for cc := 0 to 255 do + begin + x := (cc mod 16)*8; + y := (cc div 16)*8; + for dy := 0 to 7 do + begin + b := font[cc*8+dy]; + if prop then b := b shl (fontwdt[cc] shr 4); + tpp := tex+((y+dy)*(Width*4))+x*4; + for dx := 0 to 7 do + begin + if ((b and $80) <> 0) then + begin + tpp^ := 255; Inc(tpp); + tpp^ := 255; Inc(tpp); + tpp^ := 255; Inc(tpp); + tpp^ := 255; Inc(tpp); + end + else + begin + tpp^ := 0; Inc(tpp); + tpp^ := 0; Inc(tpp); + tpp^ := 0; Inc(tpp); + tpp^ := 0; Inc(tpp); + end; + b := (b and $7f) shl 1; + end; + end; + end; + + glGenTextures(1, @result); + if (result = 0) then raise Exception.Create('can''t create Holmes font texture'); + + glBindTexture(GL_TEXTURE_2D, result); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + //GLfloat[4] bclr = 0.0; + //glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bclr.ptr); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA{gltt}, GL_UNSIGNED_BYTE, tex); + glFlush(); + + //FreeMem(tex); +end; + + +var + font6texid: GLuint = 0; + font8texid: GLuint = 0; + prfont6texid: GLuint = 0; + prfont8texid: GLuint = 0; + +procedure createFonts (); +begin + if (font6texid = 0) then font6texid := createFontTexture(kgiFont6, kgiFont6PropWidth, false); + if (font8texid = 0) then font8texid := createFontTexture(kgiFont8, kgiFont8PropWidth, true); + if (prfont6texid = 0) then prfont6texid := createFontTexture(kgiFont6, kgiFont6PropWidth, false); + if (prfont8texid = 0) then prfont8texid := createFontTexture(kgiFont8, kgiFont8PropWidth, true); +end; + + +function textWidth6 (const s: AnsiString): Integer; +var + f: Integer; +begin + result := 0; + for f := 1 to Length(s) do Inc(result, Integer(kgiFont6PropWidth[Integer(s[f])] and $0f)+1); + if (result > 0) then Dec(result); // don't count last empty pixel +end; + + +function textWidth8 (const s: AnsiString): Integer; +var + f: Integer; +begin + result := 0; + for f := 1 to Length(s) do Inc(result, Integer(kgiFont8PropWidth[Integer(s[f])] and $0f)+1); + if (result > 0) then Dec(result); // don't count last empty pixel +end; + + +// return width (including last empty pixel) +function drawTextInternal (wdt, x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer; tid: GLuint; constref fontwdt: array of Byte; prop: Boolean): Integer; +var + f, c: Integer; + tx, ty: Integer; +begin + result := 0; + if (Length(s) = 0) then exit; + if (a < 0) then a := 0; + if (a > 255) then a := 255; + if (r < 0) then r := 0 else if (r > 255) then r := 255; + if (g < 0) then g := 0 else if (g > 255) then g := 255; + if (b < 0) then b := 0 else if (b > 255) then b := 255; + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_TEXTURE_2D); + // color and opacity + glColor4f(r/255.0, g/255.0, b/255.0, a/255.0); + glBindTexture(GL_TEXTURE_2D, tid); + + for f := 1 to Length(s) do + begin + c := Integer(s[f]) and $ff; + tx := (c mod 16)*8; + ty := (c div 16)*8; + glBegin(GL_QUADS); + glTexCoord2f((tx+0)/128.0, (ty+0)/128.0); glVertex2i(x+0, y+0); // top-left + glTexCoord2f((tx+8)/128.0, (ty+0)/128.0); glVertex2i(x+8, y+0); // top-right + glTexCoord2f((tx+8)/128.0, (ty+8)/128.0); glVertex2i(x+8, y+8); // bottom-right + glTexCoord2f((tx+0)/128.0, (ty+8)/128.0); glVertex2i(x+0, y+8); // bottom-left + glEnd(); + if prop then + begin + x += Integer(fontwdt[c] and $0f)+1; + result += Integer(fontwdt[c] and $0f)+1; + end + else + begin + x += wdt; + result += wdt; + end; + end; + + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glColor4f(1, 1, 1, 1); + glBindTexture(GL_TEXTURE_2D, 0); +end; + + +// ////////////////////////////////////////////////////////////////////////// // +procedure shadeRect (x, y, w, h: Integer; a: Integer); +begin + if (a < 0) then a := 0; + if (a > 255) then a := 255; + glEnable(GL_BLEND); + glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR); + //glBlendFunc(GL_ONE, GL_DST_COLOR); + //glBlendEquation(GL_FUNC_SUBTRACT); + glDisable(GL_TEXTURE_2D); + glColor4f(0.0, 0.0, a/255.0, 1.0); + glBegin(GL_QUADS); + glVertex2i(x, y); + glVertex2i(x+w, y); + glVertex2i(x+w, y+h); + glVertex2i(x, y+h); + glEnd(); + glColor4f(1, 1, 1, 1); + glDisable(GL_BLEND); + //glBlendEquation(GL_FUNC_ADD); +end; + + +// ////////////////////////////////////////////////////////////////////////// // +procedure fillRect (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255); +begin + if (a < 0) then a := 0; + if (a > 255) then a := 255; + if (r < 0) then r := 0 else if (r > 255) then r := 255; + if (g < 0) then g := 0 else if (g > 255) then g := 255; + if (b < 0) then b := 0 else if (b > 255) then b := 255; + glEnable(GL_BLEND); + //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + //glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glDisable(GL_TEXTURE_2D); + glColor4f(r/255.0, g/255.0, b/255.0, a/255.0); + glBegin(GL_QUADS); + glVertex2i(x, y); + glVertex2i(x+w, y); + glVertex2i(x+w, y+h); + glVertex2i(x, y+h); + glEnd(); + glColor4f(1, 1, 1, 1); + glDisable(GL_BLEND); +end; + + +// ////////////////////////////////////////////////////////////////////////// // +function drawText6 (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer; +begin + if (font6texid = 0) then createFonts(); + drawTextInternal(6, x, y, s, r, g, b, a, font6texid, kgiFont6PropWidth, false); + result := Length(s)*6; +end; + +function drawText8 (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer; +begin + if (font8texid = 0) then createFonts(); + drawTextInternal(8, x, y, s, r, g, b, a, font8texid, kgiFont8PropWidth, false); + result := Length(s)*8; +end; + +function drawText6Prop (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer; +begin + if (font6texid = 0) then createFonts(); + result := drawTextInternal(6, x, y, s, r, g, b, a, font6texid, kgiFont6PropWidth, true); +end; + +function drawText8Prop (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer; +begin + if (font8texid = 0) then createFonts(); + result := drawTextInternal(8, x, y, s, r, g, b, a, font8texid, kgiFont8PropWidth, true); +end; + + +// ////////////////////////////////////////////////////////////////////////// // +// x-centered at `x` +function drawText6XC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer; +begin + if (font6texid = 0) then createFonts(); + x -= Length(s)*6 div 2; + drawTextInternal(6, x, y, s, r, g, b, a, font6texid, kgiFont6PropWidth, false); + result := Length(s)*6; +end; + +function drawText8XC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer; +begin + if (font8texid = 0) then createFonts(); + x -= Length(s)*8 div 2; + drawTextInternal(8, x, y, s, r, g, b, a, font8texid, kgiFont8PropWidth, false); + result := Length(s)*8; +end; + +function drawText6PropXC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer; +begin + if (font6texid = 0) then createFonts(); + x -= textWidth6(s) div 2; + result := drawTextInternal(6, x, y, s, r, g, b, a, font6texid, kgiFont6PropWidth, true); +end; + +function drawText8PropXC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer; +begin + if (font8texid = 0) then createFonts(); + x -= textWidth8(s) div 2; + result := drawTextInternal(8, x, y, s, r, g, b, a, font8texid, kgiFont8PropWidth, true); +end; + + +// ////////////////////////////////////////////////////////////////////////// // +function monsTypeToString (mt: Byte): AnsiString; +begin + case mt of + MONSTER_NONE: begin result := 'none'; exit; end; + MONSTER_DEMON: begin result := 'demon'; exit; end; + MONSTER_IMP: begin result := 'imp'; exit; end; + MONSTER_ZOMBY: begin result := 'zombie'; exit; end; + MONSTER_SERG: begin result := 'serg'; exit; end; + MONSTER_CYBER: begin result := 'cyber'; exit; end; + MONSTER_CGUN: begin result := 'cgun'; exit; end; + MONSTER_BARON: begin result := 'baron'; exit; end; + MONSTER_KNIGHT: begin result := 'knight'; exit; end; + MONSTER_CACO: begin result := 'caco'; exit; end; + MONSTER_SOUL: begin result := 'soul'; exit; end; + MONSTER_PAIN: begin result := 'pain'; exit; end; + MONSTER_SPIDER: begin result := 'spider'; exit; end; + MONSTER_BSP: begin result := 'bsp'; exit; end; + MONSTER_MANCUB: begin result := 'mancubus'; exit; end; + MONSTER_SKEL: begin result := 'skel'; exit; end; + MONSTER_VILE: begin result := 'vile'; exit; end; + MONSTER_FISH: begin result := 'fish'; exit; end; + MONSTER_BARREL: begin result := 'barrel'; exit; end; + MONSTER_ROBO: begin result := 'robo'; exit; end; + MONSTER_MAN: begin result := 'man'; exit; end; + end; + result := 'unknown'; +end; + + +function monsBehToString (bt: Byte): AnsiString; +begin + case bt of + BH_NORMAL: begin result := 'normal'; exit; end; + BH_KILLER: begin result := 'killer'; exit; end; + BH_MANIAC: begin result := 'maniac'; exit; end; + BH_INSANE: begin result := 'insane'; exit; end; + BH_CANNIBAL: begin result := 'cannibal'; exit; end; + BH_GOOD: begin result := 'good'; exit; end; + end; + result := 'unknown'; +end; + + +function monsStateToString (st: Byte): AnsiString; +begin + case st of + MONSTATE_SLEEP: begin result := 'sleep'; exit; end; + MONSTATE_GO: begin result := 'go'; exit; end; + MONSTATE_RUN: begin result := 'run'; exit; end; + MONSTATE_CLIMB: begin result := 'climb'; exit; end; + MONSTATE_DIE: begin result := 'die'; exit; end; + MONSTATE_DEAD: begin result := 'dead'; exit; end; + MONSTATE_ATTACK: begin result := 'attack'; exit; end; + MONSTATE_SHOOT: begin result := 'shoot'; exit; end; + MONSTATE_PAIN: begin result := 'pain'; exit; end; + MONSTATE_WAIT: begin result := 'wait'; exit; end; + MONSTATE_REVIVE: begin result := 'revive'; exit; end; + MONSTATE_RUNOUT: begin result := 'runout'; exit; end; + end; + result := 'unknown'; +end; diff --git a/src/game/g_holmes.pas b/src/game/g_holmes.pas index 007ffbb..6683922 100644 --- a/src/game/g_holmes.pas +++ b/src/game/g_holmes.pas @@ -77,7 +77,7 @@ implementation uses SysUtils, GL, - g_options; + MAPDEF, g_options; var @@ -89,121 +89,18 @@ var // ////////////////////////////////////////////////////////////////////////// // -// cursor (hi, Death Track!) -const curWidth = 17; -const curHeight = 23; - -const cursorImg: array[0..curWidth*curHeight-1] of Byte = ( - 0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,3,2,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,0,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0, - 1,1,3,3,2,2,0,0,0,0,0,0,0,0,0,0,0, - 1,1,3,3,4,2,2,0,0,0,0,0,0,0,0,0,0, - 1,1,3,3,4,4,2,2,0,0,0,0,0,0,0,0,0, - 1,1,3,3,4,4,4,2,2,0,0,0,0,0,0,0,0, - 1,1,3,3,4,4,4,4,2,2,0,0,0,0,0,0,0, - 1,1,3,3,4,4,4,5,6,2,2,0,0,0,0,0,0, - 1,1,3,3,4,4,5,6,7,5,2,2,0,0,0,0,0, - 1,1,3,3,4,5,6,7,5,4,5,2,2,0,0,0,0, - 1,1,3,3,5,6,7,5,4,5,6,7,2,2,0,0,0, - 1,1,3,3,6,7,5,4,5,6,7,7,7,2,2,0,0, - 1,1,3,3,7,5,4,5,6,7,7,7,7,7,2,2,0, - 1,1,3,3,5,4,5,6,8,8,8,8,8,8,8,8,2, - 1,1,3,3,4,5,6,3,8,8,8,8,8,8,8,8,8, - 1,1,3,3,5,6,3,3,1,1,1,1,1,1,1,0,0, - 1,1,3,3,6,3,3,1,1,1,1,1,1,1,1,0,0, - 1,1,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0, - 1,1,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0, - 1,1,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -); -const cursorPal: array[0..9*4-1] of Byte = ( - 0, 0, 0, 0, - 0, 0, 0,163, - 85,255,255,255, - 85, 85,255,255, - 255, 85, 85,255, - 170, 0,170,255, - 85, 85, 85,255, - 0, 0, 0,255, - 0, 0,170,255 -); - - -var - curtexid: GLuint = 0; - -procedure createCursorTexture (); -var - tex, tpp: PByte; - c: Integer; - x, y: Integer; -begin - if (curtexid <> 0) then exit; //begin glDeleteTextures(1, @curtexid); curtexid := 0; end; - - GetMem(tex, curWidth*curHeight*4); - - tpp := tex; - for y := 0 to curHeight-1 do - begin - for x := 0 to curWidth-1 do - begin - c := cursorImg[y*curWidth+x]*4; - tpp^ := cursorPal[c+0]; Inc(tpp); - tpp^ := cursorPal[c+1]; Inc(tpp); - tpp^ := cursorPal[c+2]; Inc(tpp); - tpp^ := cursorPal[c+3]; Inc(tpp); - end; - end; - - glGenTextures(1, @curtexid); - if (curtexid = 0) then raise Exception.Create('can''t create Holmes texture'); - - glBindTexture(GL_TEXTURE_2D, curtexid); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - //GLfloat[4] bclr = 0.0; - //glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bclr.ptr); - - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, curWidth, curHeight, 0, GL_RGBA{gltt}, GL_UNSIGNED_BYTE, tex); - - //FreeMem(tex); -end; - - -procedure drawCursor (); -begin - if (curtexid = 0) then createCursorTexture() else glBindTexture(GL_TEXTURE_2D, curtexid); - // blend it - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_TEXTURE_2D); - // color and opacity - glColor4f(1, 1, 1, 0.9); - Dec(msX, 2); - glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); glVertex2i(msX, msY); // top-left - glTexCoord2f(1.0, 0.0); glVertex2i(msX+curWidth, msY); // top-right - glTexCoord2f(1.0, 1.0); glVertex2i(msX+curWidth, msY+curHeight); // bottom-right - glTexCoord2f(0.0, 1.0); glVertex2i(msX, msY+curHeight); // bottom-left - glEnd(); - Inc(msX, 2); - glDisable(GL_BLEND); - glDisable(GL_TEXTURE_2D); - glColor4f(1, 1, 1, 1); - glBindTexture(GL_TEXTURE_2D, 0); -end; - +{$INCLUDE g_holmes.inc} // ////////////////////////////////////////////////////////////////////////// // procedure g_Holmes_VidModeChanged (); begin e_WriteLog(Format('Inspector: videomode changed: %dx%d', [gScreenWidth, gScreenHeight]), MSG_NOTIFY); - curtexid := 0; // texture is possibly lost here, idc + // texture space is possibly lost here, idc + curtexid := 0; + font6texid := 0; + font8texid := 0; + prfont6texid := 0; + prfont8texid := 0; //createCursorTexture(); end; @@ -304,6 +201,40 @@ procedure plrDebugDraw (); end; end; + procedure drawMonsterInfo (mon: TMonster); + var + mx, my, mw, mh: Integer; + begin + if (mon = nil) then exit; + mon.getMapBox(mx, my, mw, mh); + //mx += mw div 2; + + //fillRect(mx-4, my-7*8-6, 110, 7*8+6, 0, 0, 94, 250); + shadeRect(mx-4, my-7*8-6, 110, 7*8+6, 128); + my -= 8; + my -= 2; + + // type + drawText6(mx, my, Format('%s(U:%u)', [monsTypeToString(mon.MonsterType), mon.UID]), 255, 127, 0); my -= 8; + // beh + drawText6(mx, my, Format('Beh: %s', [monsBehToString(mon.MonsterBehaviour)]), 255, 127, 0); my -= 8; + // state + drawText6(mx, my, Format('State:%s (%d)', [monsStateToString(mon.MonsterState), mon.MonsterSleep]), 255, 127, 0); my -= 8; + // health + drawText6(mx, my, Format('Health:%d', [mon.MonsterHealth]), 255, 127, 0); my -= 8; + // ammo + drawText6(mx, my, Format('Ammo:%d', [mon.MonsterAmmo]), 255, 127, 0); my -= 8; + // target + drawText6(mx, my, Format('TgtUID:%u', [mon.MonsterTargetUID]), 255, 127, 0); my -= 8; + drawText6(mx, my, Format('TgtTime:%d', [mon.MonsterTargetTime]), 255, 127, 0); my -= 8; + + { + property MonsterRemoved: Boolean read FRemoved write FRemoved; + property MonsterPain: Integer read FPain write FPain; + property MonsterAnim: Byte read FCurAnim write FCurAnim; + } + end; + var mon: TMonster; mx, my, mw, mh: Integer; @@ -325,6 +256,7 @@ begin begin mon.getMapBox(mx, my, mw, mh); e_DrawQuad(mx, my, mx+mw-1, my+mh-1, 255, 0, 0, 30); + drawMonsterInfo(mon); end; end; @@ -385,7 +317,13 @@ begin glDisable(GL_SCISSOR_TEST); glDisable(GL_TEXTURE_2D); - plrDebugDraw(); + if gGameOn then + begin + plrDebugDraw(); + end; + + //drawText6Prop(10, 10, 'Hi there, I''m Holmes!', 255, 255, 0); + //drawText8Prop(10, 20, 'Hi there, I''m Holmes!', 255, 255, 0); drawCursor(); end; diff --git a/src/game/g_monsters.pas b/src/game/g_monsters.pas index 719a2b7..4c354c3 100644 --- a/src/game/g_monsters.pas +++ b/src/game/g_monsters.pas @@ -349,19 +349,6 @@ const ANIM_ATTACK2 = 5; ANIM_PAIN = 6; - STATE_SLEEP = 0; - STATE_GO = 1; - STATE_RUN = 2; - STATE_CLIMB = 3; - STATE_DIE = 4; - STATE_DEAD = 5; - STATE_ATTACK = 6; - STATE_SHOOT = 7; - STATE_PAIN = 8; - STATE_WAIT = 9; - STATE_REVIVE = 10; - STATE_RUNOUT = 11; - MONSTER_SIGNATURE = $534E4F4D; // 'MONS' // Òàáëèöà òèïîâ àíèìàöèè ìîíñòðîâ: @@ -684,7 +671,7 @@ function isCorpse (o: PObj; immediately: Boolean): Integer; begin atag := atag; // shut up, fpc! result := false; // don't stop - if (mon.FState = STATE_DEAD) and g_Obj_Collide(o, @mon.FObj) then + if (mon.FState = MONSTATE_DEAD) and g_Obj_Collide(o, @mon.FObj) then begin case mon.FMonsterType of // Íå âîñêðåñèòü: MONSTER_SOUL, MONSTER_PAIN, MONSTER_CYBER, MONSTER_SPIDER, @@ -714,7 +701,7 @@ begin begin for a := 0 to High(gMonsters) do begin - if (gMonsters[a] <> nil) and (gMonsters[a].FState = STATE_DEAD) and g_Obj_Collide(o, @gMonsters[a].FObj) then + if (gMonsters[a] <> nil) and (gMonsters[a].FState = MONSTATE_DEAD) and g_Obj_Collide(o, @gMonsters[a].FObj) then begin case gMonsters[a].FMonsterType of // Íå âîñêðåñèòü: MONSTER_SOUL, MONSTER_PAIN, MONSTER_CYBER, MONSTER_SPIDER, @@ -1279,9 +1266,9 @@ begin if (gMonsters[a] <> nil) then with gMonsters[a] do if (FMonsterType = MONSTER_MAN) and - (FState <> STATE_DEAD) and - (FState <> STATE_SLEEP) and - (FState <> STATE_DIE) then + (FState <> MONSTATE_DEAD) and + (FState <> MONSTATE_SLEEP) and + (FState <> MONSTATE_DIE) then begin g_Sound_PlayExAt('SOUND_MONSTER_TRUP', FObj.X, FObj.Y); Exit; @@ -1682,7 +1669,7 @@ begin FChainFire := False; FShellTimer := -1; - FState := STATE_SLEEP; + FState := MONSTATE_SLEEP; FCurAnim := ANIM_SLEEP; positionChanged(); // this updates spatial accelerators @@ -1710,7 +1697,7 @@ begin g_Obj_Init(@FObj); - FState := STATE_SLEEP; + FState := MONSTATE_SLEEP; FCurAnim := ANIM_SLEEP; FHealth := MONSTERTABLE[MonsterType].Health; FMaxHealth := FHealth; @@ -1826,7 +1813,7 @@ begin Result := False; // Óìèðàåò, óìåð èëè âîñêðåøàåòñÿ => óðîí äåëàòü íåêîìó: - if (FState = STATE_DEAD) or (FState = STATE_DIE) or (FState = STATE_REVIVE) then + if (FState = MONSTATE_DEAD) or (FState = MONSTATE_DIE) or (FState = MONSTATE_REVIVE) then Exit; // Ðûáó â âîäå áüåò òîêîì => ïàíèêà áåç óðîíà: @@ -1838,7 +1825,7 @@ begin else FDirection := D_LEFT; Result := True; - SetState(STATE_RUN); + SetState(MONSTATE_RUN); Exit; end; @@ -1859,10 +1846,10 @@ begin FPain := FPain+aDamage; // Åñëè áîëü ñóùåñòâåííàÿ, òî ìåíÿåì ñîñòîÿíèå íà áîëåâîå: - if FState <> STATE_PAIN then + if FState <> MONSTATE_PAIN then if (FPain >= MONSTERTABLE[FMonsterType].MinPain) and (FMonsterType <> MONSTER_BARREL) then - SetState(STATE_PAIN); + SetState(MONSTATE_PAIN); // Åñëè ðàçðåøåíà êðîâü - ñîçäàåì áðûçãè êðîâè: if (gBloodCount > 0) then @@ -1951,12 +1938,12 @@ begin (FMonsterType = MONSTER_MAN)) then begin g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj.X, FObj.Y); - SetState(STATE_DIE, ANIM_MESS); + SetState(MONSTATE_DIE, ANIM_MESS); end else begin DieSound(); - SetState(STATE_DIE); + SetState(MONSTATE_DIE); end; // Àêòèâèðîâàòü òðèããåðû, æäóùèå ñìåðòè ýòîãî ìîíñòðà: @@ -1965,10 +1952,10 @@ begin FHealth := 0; end else - if FState = STATE_SLEEP then + if FState = MONSTATE_SLEEP then begin // Ñïàë, ðàçáóäèëè íåñìåðòåëüíûì óäàðîì: FPain := MONSTERTABLE[FMonsterType].Pain; - SetState(STATE_GO); + SetState(MONSTATE_GO); end; if g_Game_IsServer and g_Game_IsNet then MH_SEND_MonsterState(FUID); @@ -2034,7 +2021,7 @@ begin // Åñëè êîëäóí ñòðåëÿåò, òî ðèñóåì îãîíü: if FMonsterType = MONSTER_VILE then - if FState = STATE_SHOOT then + if FState = MONSTATE_SHOOT then if GetPos(FTargetUID, @o) then vilefire.Draw(o.X+o.Rect.X+(o.Rect.Width div 2)-32, o.Y+o.Rect.Y+o.Rect.Height-128, M_NONE); @@ -2045,7 +2032,7 @@ begin Exit; // Ýòè ìîíñòðû, óìèðàÿ, íå îñòàâëÿþò òðóïîâ: - if FState = STATE_DEAD then + if FState = MONSTATE_DEAD then case FMonsterType of MONSTER_BARREL, MONSTER_SOUL, MONSTER_PAIN: Exit; end; @@ -2133,14 +2120,14 @@ var begin // Åñëè ñîñòîÿíèå = íà÷àëè óìèðàòü, à ýòîò ìîíñòð = Lost_Soul, // òî ñîáëþäàåì îãðàíè÷åíèå êîëè÷åñòâà Lost_Soul'îâ: - if (State = STATE_DIE) and (MonsterType = MONSTER_SOUL) then + if (State = MONSTATE_DIE) and (MonsterType = MONSTER_SOUL) then soulcount := soulcount-1; // Ïðèñìåðòè - íåëüçÿ ñðàçó íà÷èíàòü àòàêîâàòü èëè áåãàòü: case FState of - STATE_DIE, STATE_DEAD, STATE_REVIVE: - if (State <> STATE_DEAD) and (State <> STATE_REVIVE) and - (State <> STATE_GO) then + MONSTATE_DIE, MONSTATE_DEAD, MONSTATE_REVIVE: + if (State <> MONSTATE_DEAD) and (State <> MONSTATE_REVIVE) and + (State <> MONSTATE_GO) then Exit; end; @@ -2151,14 +2138,14 @@ begin // Íîâàÿ àíèìàöèÿ ïðè íîâîì ñîñòîÿíèè: case FState of - STATE_SLEEP: Anim := ANIM_SLEEP; - STATE_PAIN: Anim := ANIM_PAIN; - STATE_WAIT: Anim := ANIM_SLEEP; - STATE_CLIMB, STATE_RUN, STATE_RUNOUT, STATE_GO: Anim := ANIM_GO; - STATE_SHOOT: Anim := ANIM_ATTACK; - STATE_ATTACK: Anim := ANIM_ATTACK; - STATE_DIE: Anim := ANIM_DIE; - STATE_REVIVE: + MONSTATE_SLEEP: Anim := ANIM_SLEEP; + MONSTATE_PAIN: Anim := ANIM_PAIN; + MONSTATE_WAIT: Anim := ANIM_SLEEP; + MONSTATE_CLIMB, MONSTATE_RUN, MONSTATE_RUNOUT, MONSTATE_GO: Anim := ANIM_GO; + MONSTATE_SHOOT: Anim := ANIM_ATTACK; + MONSTATE_ATTACK: Anim := ANIM_ATTACK; + MONSTATE_DIE: Anim := ANIM_DIE; + MONSTATE_REVIVE: begin // íà÷àëè âîñðåøàòüñÿ Anim := FCurAnim; FAnim[Anim, FDirection].Revert(True); @@ -2267,15 +2254,15 @@ begin // Ðûáû "ëåòàþò" òîëüêî â âîäå: if FMonsterType = MONSTER_FISH then if g_Obj_CollidePanel(@FObj, 0, 0, PANEL_WATER or PANEL_ACID1 or PANEL_ACID2) then - if (FState <> STATE_DIE) and (FState <> STATE_DEAD) then + if (FState <> MONSTATE_DIE) and (FState <> MONSTATE_DEAD) then fall := False; // Ëåòàþùèå ìîíòñðû: if ((FMonsterType = MONSTER_SOUL) or (FMonsterType = MONSTER_PAIN) or (FMonsterType = MONSTER_CACO)) and - (FState <> STATE_DIE) and - (FState <> STATE_DEAD) then + (FState <> MONSTATE_DIE) and + (FState <> MONSTATE_DEAD) then fall := False; // Ìåíÿåì ñêîðîñòü òîëüêî ïî ÷åòíûì êàäðàì: @@ -2313,7 +2300,7 @@ begin oldvelx := FObj.Vel.X; // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà: - if (FState = STATE_DIE) or (FState = STATE_DEAD) then + if (FState = MONSTATE_DIE) or (FState = MONSTATE_DEAD) then FObj.Vel.X := z_dec(FObj.Vel.X, 1); if FFireTime > 0 then @@ -2324,7 +2311,7 @@ begin begin OnFireFlame(1); FFireTime := FFireTime - 1; - if (FState <> STATE_DIE) and (FState <> STATE_DEAD) then + if (FState <> MONSTATE_DIE) and (FState <> MONSTATE_DEAD) then if FFirePainTime = 0 then begin Damage(5, FFireAttacker, 0, 0, HIT_FLAME); @@ -2336,15 +2323,15 @@ begin end; // Ìåðòâûé íè÷åãî íå äåëàåò: - if (FState = STATE_DEAD) then + if (FState = MONSTATE_DEAD) then goto _end; // AI ìîíñòðîâ âûêëþ÷åí: if g_debug_MonsterOff then begin FSleep := 1; - if FState <> STATE_SLEEP then - SetState(STATE_SLEEP); + if FState <> MONSTATE_SLEEP then + SetState(MONSTATE_SLEEP); end; // Âîçìîæíî, ñîçäàåì ïóçûðüêè â âîäå: @@ -2370,7 +2357,7 @@ begin // Åñëè ïðîøåë ïåðâûé êàäð àíèìàöèè âçðûâà áî÷êè, òî âçðûâ: if FMonsterType = MONSTER_BARREL then begin - if (FState = STATE_DIE) and (FAnim[FCurAnim, FDirection].CurrentFrame = 1) and + if (FState = MONSTATE_DIE) and (FAnim[FCurAnim, FDirection].CurrentFrame = 1) and (FAnim[FCurAnim, FDirection].Counter = 0) then g_Weapon_Explode(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2), FObj.Y+FObj.Rect.Y+FObj.Rect.Height-16, @@ -2415,8 +2402,8 @@ begin // Ïðîáóåì óâåðíóòüñÿ îò ëåòÿùåé ïóëè: if fall then - if (FState in [STATE_GO, STATE_RUN, STATE_RUNOUT, - STATE_ATTACK, STATE_SHOOT]) then + if (FState in [MONSTATE_GO, MONSTATE_RUN, MONSTATE_RUNOUT, + MONSTATE_ATTACK, MONSTATE_SHOOT]) then if g_Weapon_Danger(FUID, FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, FObj.Rect.Width, FObj.Rect.Height, 50) then if (g_Obj_CollideLevel(@FObj, 0, 1) or g_Obj_StayOnStep(@FObj)) and @@ -2424,7 +2411,7 @@ begin FObj.Vel.Y := -MONSTERTABLE[FMonsterType].Jump; case FState of - STATE_PAIN: // Ñîñòîÿíèå - Áîëü + MONSTATE_PAIN: // Ñîñòîÿíèå - Áîëü begin // Áîëü ñèëüíàÿ => ìîíñòð êðè÷èò: if FPain >= MONSTERTABLE[FMonsterType].Pain then @@ -2443,11 +2430,11 @@ begin begin FPain := 0; FAmmo := -9; - SetState(STATE_GO); + SetState(MONSTATE_GO); end; end; - STATE_SLEEP: // Ñîñòîÿíèå - Ñîí + MONSTATE_SLEEP: // Ñîñòîÿíèå - Ñîí begin // Ñïèì: FSleep := FSleep + 1; @@ -2471,7 +2458,7 @@ begin FTargetUID := gPlayers[a].UID; FTargetTime := 0; WakeUpSound(); - SetState(STATE_GO); + SetState(MONSTATE_GO); Break; end; @@ -2500,30 +2487,30 @@ begin FTargetUID := gMonsters[a].UID; FTargetTime := 0; WakeUpSound(); - SetState(STATE_GO); + SetState(MONSTATE_GO); Break; end; end; end; - STATE_WAIT: // Ñîñòîÿíèå - Îæèäàíèå + MONSTATE_WAIT: // Ñîñòîÿíèå - Îæèäàíèå begin // Æäåì: FSleep := FSleep - 1; // Âûæäàëè äîñòàòî÷íî - èäåì: if FSleep < 0 then - SetState(STATE_GO); + SetState(MONSTATE_GO); end; - STATE_GO: // Ñîñòîÿíèå - Äâèæåíèå (ñ îñìîòðîì ñèòóàöèè) + MONSTATE_GO: // Ñîñòîÿíèå - Äâèæåíèå (ñ îñìîòðîì ñèòóàöèè) begin // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî: if WordBool(st and MOVE_BLOCK) then begin Turn(); FSleep := 40; - SetState(STATE_RUNOUT); + SetState(MONSTATE_RUNOUT); goto _end; end; @@ -2533,7 +2520,7 @@ begin if isCorpse(@FObj, False) <> -1 then begin FObj.Vel.X := 0; - SetState(STATE_ATTACK, ANIM_ATTACK2); + SetState(MONSTATE_ATTACK, ANIM_ATTACK2); goto _end; end; @@ -2586,7 +2573,7 @@ begin if FMonsterType <> MONSTER_FISH then begin FSleep := 15; - SetState(STATE_RUN); + SetState(MONSTATE_RUN); if Random(2) = 0 then FDirection := D_LEFT else @@ -2602,7 +2589,7 @@ begin FObj.Rect.Height, FUID, ACTIVATE_MONSTERPRESS) <> nil then begin // Ñìîãëè íàæàòü êíîïêó - íåáîëüøîå îæèäàíèå FSleep := 4; - SetState(STATE_WAIT); + SetState(MONSTATE_WAIT); goto _end; end; @@ -2615,7 +2602,7 @@ begin begin // Ñòîèì íà òâåðäîì ïîëó èëè ñòóïåíè // Ïðûæîê ÷åðåç ñòåíó: FObj.Vel.Y := -MONSTERTABLE[FMonsterType].Jump; - SetState(STATE_CLIMB); + SetState(MONSTATE_CLIMB); end; end; @@ -2638,7 +2625,7 @@ begin end; // Ðûáå áîëüíî: - SetState(STATE_PAIN); + SetState(MONSTATE_PAIN); FPain := FPain + 50; end else // Ðûáà â âîäå @@ -2661,7 +2648,7 @@ begin else FDirection := D_RIGHT; FSleep := 20; - SetState(STATE_RUN); + SetState(MONSTATE_RUN); end; end; end @@ -2750,14 +2737,14 @@ begin FObj.Vel.X := 0; end; - STATE_RUN: // Ñîñòîÿíèå - Áåã + MONSTATE_RUN: // Ñîñòîÿíèå - Áåã begin // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî: if WordBool(st and MOVE_BLOCK) then begin Turn(); FSleep := 40; - SetState(STATE_RUNOUT); + SetState(MONSTATE_RUNOUT); goto _end; end; @@ -2768,7 +2755,7 @@ begin if (FSleep <= 0) or (WordBool(st and MOVE_HITWALL) and ((FObj.Vel.Y+FObj.Accel.Y) = 0)) then begin FSleep := 0; - SetState(STATE_GO); + SetState(MONSTATE_GO); // Ñòåíà - èäåì îáðàòíî: if WordBool(st and (MOVE_HITWALL or MOVE_BLOCK)) then Turn(); @@ -2791,7 +2778,7 @@ begin FObj.Vel.X := 0; end; - STATE_RUNOUT: // Ñîñòîÿíèå - Óáåãàåò îò ÷åãî-òî + MONSTATE_RUNOUT: // Ñîñòîÿíèå - Óáåãàåò îò ÷åãî-òî begin // Âûøëè èç ÁëîêÌîíà: if (not WordBool(st and MOVE_BLOCK)) and (FSleep > 0) then @@ -2803,7 +2790,7 @@ begin if FSleep <= -18 then begin FSleep := 0; - SetState(STATE_GO); + SetState(MONSTATE_GO); // Ñòåíà/ÁëîêÌîí - èäåì îáðàòíî: if WordBool(st and (MOVE_HITWALL or MOVE_BLOCK)) then Turn(); @@ -2826,21 +2813,21 @@ begin FObj.Vel.X := 0; end; - STATE_CLIMB: // Ñîñòîÿíèå - Ïðûæîê (÷òîáû îáîéòè ñòåíó) + MONSTATE_CLIMB: // Ñîñòîÿíèå - Ïðûæîê (÷òîáû îáîéòè ñòåíó) begin // Äîñòèãëè âûñøåé òî÷êè ïðûæêà èëè ñòåíà êîí÷èëàñü => ïåðåõîäèì íà øàã: if ((FObj.Vel.Y+FObj.Accel.Y) >= 0) or (not WordBool(st and MOVE_HITWALL)) then begin FSleep := 0; - SetState(STATE_GO); + SetState(MONSTATE_GO); // Ñòåíà íå êîí÷èëàñü => áåæèì îò íåå: if WordBool(st and (MOVE_HITWALL or MOVE_BLOCK)) then begin Turn(); FSleep := 15; - SetState(STATE_RUN); + SetState(MONSTATE_RUN); end; end; @@ -2858,14 +2845,14 @@ begin FObj.Vel.X := 0; end; - STATE_ATTACK, // Ñîñòîÿíèå - Àòàêà - STATE_SHOOT: // Ñîñòîÿíèå - Ñòðåëüáà + MONSTATE_ATTACK, // Ñîñòîÿíèå - Àòàêà + MONSTATE_SHOOT: // Ñîñòîÿíèå - Ñòðåëüáà begin // Lost_Soul âðåçàëñÿ â ñòåíó ïðè àòàêå => ïåðåõîäèò íà øàã: if FMonsterType = MONSTER_SOUL then begin if WordBool(st and (MOVE_HITWALL or MOVE_HITCEIL or MOVE_HITLAND)) then - SetState(STATE_GO); + SetState(MONSTATE_GO); goto _end; end; @@ -2875,12 +2862,12 @@ begin FObj.Vel.X := z_dec(FObj.Vel.X, 1); // Íóæíî ñòðåëÿòü, à ìîíñòð - êîëäóí: - if (FMonsterType = MONSTER_VILE) and (FState = STATE_SHOOT) then + if (FMonsterType = MONSTER_VILE) and (FState = MONSTATE_SHOOT) then begin // Öåëü ïîãèáëà => èäåì äàëüøå: if not GetPos(FTargetUID, @o) then begin - SetState(STATE_GO); + SetState(MONSTATE_GO); goto _end; end; @@ -2888,7 +2875,7 @@ begin // Öåëü íå âèäíî => èäåì äàëüøå: if not g_Look(@FObj, @o, FDirection) then begin - SetState(STATE_GO); + SetState(MONSTATE_GO); goto _end; end; @@ -2896,7 +2883,7 @@ begin // Öåëü â âîäå - íå çàãîðèòñÿ => èäåì äàëüøå: if g_Obj_CollideWater(@o, 0, 0) then begin - SetState(STATE_GO); + SetState(MONSTATE_GO); goto _end; end; @@ -2912,11 +2899,11 @@ begin _end: // Ñîñòîÿíèå - Âîñêðåøåíèå: - if FState = STATE_REVIVE then + if FState = MONSTATE_REVIVE then if FAnim[FCurAnim, FDirection].Played then begin // Îáðàòíàÿ àíèìàöèÿ óìèðàíèÿ çàêîí÷èëàñü - èäåì äàëüøå: FAnim[FCurAnim, FDirection].Revert(False); - SetState(STATE_GO); + SetState(MONSTATE_GO); end; // Åñëè åñòü àíèìàöèÿ îãíÿ êîëäóíà - ïóñòü îíà èäåò: @@ -2924,12 +2911,12 @@ _end: vilefire.Update(); // Ñîñòîÿíèå - Óìèðàåò è òåêóùàÿ àíèìàöèÿ ïðîèãðàíà: - if (FState = STATE_DIE) and + if (FState = MONSTATE_DIE) and (FAnim[FCurAnim, FDirection] <> nil) and (FAnim[FCurAnim, FDirection].Played) then begin // Óìåð: - SetState(STATE_DEAD); + SetState(MONSTATE_DEAD); // Pain_Elemental ïðè ñìåðòè âûïóñêàåò 3 Lost_Soul'à: if (FMonsterType = MONSTER_PAIN) then @@ -2938,7 +2925,7 @@ _end: FObj.Y+FObj.Rect.Y+20, D_LEFT); if mon <> nil then begin - mon.SetState(STATE_GO); + mon.SetState(MONSTATE_GO); mon.FNoRespawn := True; Inc(gTotalMonsters); if g_Game_IsNet then MH_SEND_MonsterSpawn(mon.UID); @@ -2948,7 +2935,7 @@ _end: FObj.Y+FObj.Rect.Y+20, D_RIGHT); if mon <> nil then begin - mon.SetState(STATE_GO); + mon.SetState(MONSTATE_GO); mon.FNoRespawn := True; Inc(gTotalMonsters); if g_Game_IsNet then MH_SEND_MonsterSpawn(mon.UID); @@ -2958,7 +2945,7 @@ _end: FObj.Y+FObj.Rect.Y, D_RIGHT); if mon <> nil then begin - mon.SetState(STATE_GO); + mon.SetState(MONSTATE_GO); mon.FNoRespawn := True; Inc(gTotalMonsters); if g_Game_IsNet then MH_SEND_MonsterSpawn(mon.UID); @@ -2975,22 +2962,22 @@ _end: end; // Ñîâåðøåíèå àòàêè è ñòðåëüáû: - if (FState = STATE_ATTACK) or (FState = STATE_SHOOT) then + if (FState = MONSTATE_ATTACK) or (FState = MONSTATE_SHOOT) then if (FAnim[FCurAnim, FDirection] <> nil) then // Àíèìàöèÿ àòàêè åñòü - ìîæíî àòàêîâàòü if (FAnim[FCurAnim, FDirection].Played) then begin // Àíèìàöèÿ àòàêè çàêîí÷èëàñü => ïåðåõîäèì íà øàã - if FState = STATE_ATTACK then + if FState = MONSTATE_ATTACK then begin // Ñîñòîÿíèå - Àòàêà // Åñëè ìîíñòð íå Lost_Soul, òî ïîñëå àòàêè ïåðåõîäèì íà øàã: if FMonsterType <> MONSTER_SOUL then - SetState(STATE_GO); + SetState(MONSTATE_GO); end else // Ñîñòîÿíèå - Ñòðåëüáà begin // Ïåðåõîäèì íà øàã, åñëè íå íàäî ñòðåëÿòü åùå ðàç: if not FChainFire then - SetState(STATE_GO) + SetState(MONSTATE_GO) else begin // Íàäî ñòðåëÿòü åùå FChainFire := False; @@ -3010,7 +2997,7 @@ _end: (FAnim[FCurAnim, FDirection].TotalFrames div 2)) ) then begin // Àòàêè åùå íå áûëî è ýòî ñåðåäèíà àíèìàöèè àòàêè - if FState = STATE_ATTACK then + if FState = MONSTATE_ATTACK then begin // Ñîñòîÿíèå - Àòàêà // Åñëè ýòî Lost_Soul, òî ñáðàñûâàåì àíèìàöèþ àòàêè: if FMonsterType = MONSTER_SOUL then @@ -3022,7 +3009,7 @@ _end: if g_Weapon_Hit(@FObj, 15, FUID, HIT_SOME) <> 0 then // Lost_Soul óêóñèë êîãî-òî => ïåðåõîäèò íà øàã: if FMonsterType = MONSTER_SOUL then - SetState(STATE_GO); + SetState(MONSTATE_GO); MONSTER_FISH: // Ðûáà êóñàåò ïåðâîãî ïîïàâøåãîñÿ ñî çâóêîì: @@ -3046,7 +3033,7 @@ _end: sx := isCorpse(@FObj, True); if sx <> -1 then begin // Íàøëè, êîãî âîñêðåñèòü - gMonsters[sx].SetState(STATE_REVIVE); + gMonsters[sx].SetState(MONSTATE_REVIVE); g_Sound_PlayExAt('SOUND_MONSTER_SLOP', FObj.X, FObj.Y); // Âîñêðåøàòü - ñåáå âðåäèòü: {g_Weapon_HitUID(FUID, 5, 0, HIT_SOME);} @@ -3133,7 +3120,7 @@ _end: GetPos(FTargetUID, @o); mon.FTargetTime := 0; mon.FNoRespawn := True; - mon.SetState(STATE_GO); + mon.SetState(MONSTATE_GO); mon.shoot(@o, True); Inc(gTotalMonsters); @@ -3167,7 +3154,7 @@ _end: // Ïîñëåäíèé êàäð òåêóùåé àíèìàöèè: if FAnim[FCurAnim, FDirection].Counter = FAnim[FCurAnim, FDirection].Speed-1 then case FState of - STATE_GO, STATE_RUN, STATE_CLIMB, STATE_RUNOUT: + MONSTATE_GO, MONSTATE_RUN, MONSTATE_CLIMB, MONSTATE_RUNOUT: // Çâóêè ïðè ïåðåäâèæåíèè: case FMonsterType of MONSTER_CYBER: @@ -3190,7 +3177,7 @@ _end: end; if g_Obj_CollidePanel(@FObj, 0, 0, PANEL_LIFTLEFT or PANEL_LIFTRIGHT) and - not ((FState = STATE_DEAD) or (FState = STATE_DIE)) then + not ((FState = MONSTATE_DEAD) or (FState = MONSTATE_DIE)) then FObj.Vel.X := oldvelx; // Åñëè åñòü àíèìàöèÿ, òî ïóñòü îíà èäåò: @@ -3234,15 +3221,15 @@ begin // Ðûáû "ëåòàþò" òîëüêî â âîäå: if FMonsterType = MONSTER_FISH then if g_Obj_CollidePanel(@FObj, 0, 0, PANEL_WATER or PANEL_ACID1 or PANEL_ACID2) then - if (FState <> STATE_DIE) and (FState <> STATE_DEAD) then + if (FState <> MONSTATE_DIE) and (FState <> MONSTATE_DEAD) then fall := False; // Ëåòàþùèå ìîíòñðû: if ((FMonsterType = MONSTER_SOUL) or (FMonsterType = MONSTER_PAIN) or (FMonsterType = MONSTER_CACO)) and - (FState <> STATE_DIE) and - (FState <> STATE_DEAD) then + (FState <> MONSTATE_DIE) and + (FState <> MONSTATE_DEAD) then fall := False; // Ìåíÿåì ñêîðîñòü òîëüêî ïî ÷åòíûì êàäðàì: @@ -3273,7 +3260,7 @@ begin oldvelx := FObj.Vel.X; // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà: - if (FState = STATE_DIE) or (FState = STATE_DEAD) then + if (FState = MONSTATE_DIE) or (FState = MONSTATE_DEAD) then FObj.Vel.X := z_dec(FObj.Vel.X, 1); if FFireTime > 0 then @@ -3288,7 +3275,7 @@ begin end; // Ìåðòâûé íè÷åãî íå äåëàåò: - if (FState = STATE_DEAD) then + if (FState = MONSTATE_DEAD) then goto _end; // Âîçìîæíî, ñîçäàåì ïóçûðüêè â âîäå: @@ -3314,7 +3301,7 @@ begin // Åñëè ïðîøåë ïåðâûé êàäð àíèìàöèè âçðûâà áî÷êè, òî âçðûâ: if FMonsterType = MONSTER_BARREL then begin - if (FState = STATE_DIE) and (FAnim[FCurAnim, FDirection].CurrentFrame = 1) and + if (FState = MONSTATE_DIE) and (FAnim[FCurAnim, FDirection].CurrentFrame = 1) and (FAnim[FCurAnim, FDirection].Counter = 0) then g_Weapon_Explode(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2), FObj.Y+FObj.Rect.Y+FObj.Rect.Height-16, @@ -3358,8 +3345,8 @@ begin // Ïðîáóåì óâåðíóòüñÿ îò ëåòÿùåé ïóëè: if fall then - if (FState in [STATE_GO, STATE_RUN, STATE_RUNOUT, - STATE_ATTACK, STATE_SHOOT]) then + if (FState in [MONSTATE_GO, MONSTATE_RUN, MONSTATE_RUNOUT, + MONSTATE_ATTACK, MONSTATE_SHOOT]) then if g_Weapon_Danger(FUID, FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, FObj.Rect.Width, FObj.Rect.Height, 50) then if (g_Obj_CollideLevel(@FObj, 0, 1) or g_Obj_StayOnStep(@FObj)) and @@ -3367,7 +3354,7 @@ begin FObj.Vel.Y := -MONSTERTABLE[FMonsterType].Jump; case FState of - STATE_PAIN: // Ñîñòîÿíèå - Áîëü + MONSTATE_PAIN: // Ñîñòîÿíèå - Áîëü begin // Áîëü ñèëüíàÿ => ìîíñòð êðè÷èò: if FPain >= MONSTERTABLE[FMonsterType].Pain then @@ -3384,12 +3371,12 @@ begin // Áîëü óæå íå îøóòèìàÿ => èäåì äàëüøå: if FPain <= MONSTERTABLE[FMonsterType].MinPain then begin - SetState(STATE_GO); + SetState(MONSTATE_GO); FPain := 0; end; end; - STATE_SLEEP: // Ñîñòîÿíèå - Ñîí + MONSTATE_SLEEP: // Ñîñòîÿíèå - Ñîí begin // Ñïèì: FSleep := FSleep + 1; @@ -3401,20 +3388,20 @@ begin goto _end; end; - STATE_WAIT: // Ñîñòîÿíèå - Îæèäàíèå + MONSTATE_WAIT: // Ñîñòîÿíèå - Îæèäàíèå begin // Æäåì: FSleep := FSleep - 1; end; - STATE_GO: // Ñîñòîÿíèå - Äâèæåíèå (ñ îñìîòðîì ñèòóàöèè) + MONSTATE_GO: // Ñîñòîÿíèå - Äâèæåíèå (ñ îñìîòðîì ñèòóàöèè) begin // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî: if WordBool(st and MOVE_BLOCK) then begin Turn(); FSleep := 40; - SetState(STATE_RUNOUT); + SetState(MONSTATE_RUNOUT); goto _end; end; @@ -3423,7 +3410,7 @@ begin if (FMonsterType = MONSTER_VILE) then if isCorpse(@FObj, False) <> -1 then begin - SetState(STATE_ATTACK, ANIM_ATTACK2); + SetState(MONSTATE_ATTACK, ANIM_ATTACK2); FObj.Vel.X := 0; goto _end; @@ -3433,7 +3420,7 @@ begin if Abs(sx) < 40 then if FMonsterType <> MONSTER_FISH then begin - SetState(STATE_RUN); + SetState(MONSTATE_RUN); FSleep := 15; goto _end; @@ -3450,7 +3437,7 @@ begin begin // Ñòîèì íà òâåðäîì ïîëó èëè ñòóïåíè // Ïðûæîê ÷åðåç ñòåíó: FObj.Vel.Y := -MONSTERTABLE[FMonsterType].Jump; - SetState(STATE_CLIMB); + SetState(MONSTATE_CLIMB); end; end; @@ -3474,7 +3461,7 @@ begin end; // Ðûáå áîëüíî: - SetState(STATE_PAIN); + SetState(MONSTATE_PAIN); FPain := FPain + 50; end else // Ðûáà â âîäå @@ -3492,7 +3479,7 @@ begin // Âñïëûëè äî ïîâåðõíîñòè - ñòîï: FObj.Vel.Y := 0; // Ïëàâàåì òóäà-ñþäà: - SetState(STATE_RUN); + SetState(MONSTATE_RUN); FSleep := 20; end; end; @@ -3577,12 +3564,12 @@ begin FObj.Vel.X := 0; end; - STATE_RUN: // Ñîñòîÿíèå - Áåã + MONSTATE_RUN: // Ñîñòîÿíèå - Áåã begin // Åñëè íàòêíóëèñü íà ÁëîêÌîí - óáåãàåì îò íåãî: if WordBool(st and MOVE_BLOCK) then begin - SetState(STATE_RUNOUT); + SetState(MONSTATE_RUNOUT); FSleep := 40; goto _end; @@ -3593,7 +3580,7 @@ begin // Ïðîáåæàëè äîñòàòî÷íî èëè âðåçàëèñü â ñòåíó => ïåðåõîäèì íà øàã: if (FSleep <= 0) or (WordBool(st and MOVE_HITWALL) and ((FObj.Vel.Y+FObj.Accel.Y) = 0)) then begin - SetState(STATE_GO); + SetState(MONSTATE_GO); FSleep := 0; // Èíîãäà ðû÷èì: @@ -3615,7 +3602,7 @@ begin FObj.Vel.X := 0; end; - STATE_RUNOUT: // Ñîñòîÿíèå - Óáåãàåò îò ÷åãî-òî + MONSTATE_RUNOUT: // Ñîñòîÿíèå - Óáåãàåò îò ÷åãî-òî begin // Âûøëè èç ÁëîêÌîíà: if (not WordBool(st and MOVE_BLOCK)) and (FSleep > 0) then @@ -3626,7 +3613,7 @@ begin // Óáàæåëè äîñòàòî÷íî äàëåêî => ïåðåõîäèì íà øàã: if FSleep <= -18 then begin - SetState(STATE_GO); + SetState(MONSTATE_GO); FSleep := 0; // Èíîãäà ðû÷èì: @@ -3648,19 +3635,19 @@ begin FObj.Vel.X := 0; end; - STATE_CLIMB: // Ñîñòîÿíèå - Ïðûæîê (÷òîáû îáîéòè ñòåíó) + MONSTATE_CLIMB: // Ñîñòîÿíèå - Ïðûæîê (÷òîáû îáîéòè ñòåíó) begin // Äîñòèãëè âûñøåé òî÷êè ïðûæêà èëè ñòåíà êîí÷èëàñü => ïåðåõîäèì íà øàã: if ((FObj.Vel.Y+FObj.Accel.Y) >= 0) or (not WordBool(st and MOVE_HITWALL)) then begin - SetState(STATE_GO); + SetState(MONSTATE_GO); FSleep := 0; // Ñòåíà íå êîí÷èëàñü => áåæèì îò íåå: if WordBool(st and (MOVE_HITWALL or MOVE_BLOCK)) then begin - SetState(STATE_RUN); + SetState(MONSTATE_RUN); FSleep := 15; end; end; @@ -3679,14 +3666,14 @@ begin FObj.Vel.X := 0; end; - STATE_ATTACK, // Ñîñòîÿíèå - Àòàêà - STATE_SHOOT: // Ñîñòîÿíèå - Ñòðåëüáà + MONSTATE_ATTACK, // Ñîñòîÿíèå - Àòàêà + MONSTATE_SHOOT: // Ñîñòîÿíèå - Ñòðåëüáà begin // Lost_Soul âðåçàëñÿ â ñòåíó ïðè àòàêå => ïåðåõîäèò íà øàã: if FMonsterType = MONSTER_SOUL then begin if WordBool(st and (MOVE_HITWALL or MOVE_HITCEIL or MOVE_HITLAND)) then - SetState(STATE_GO); + SetState(MONSTATE_GO); goto _end; end; @@ -3696,12 +3683,12 @@ begin FObj.Vel.X := z_dec(FObj.Vel.X, 1); // Íóæíî ñòðåëÿòü, à ìîíñòð - êîëäóí: - if (FMonsterType = MONSTER_VILE) and (FState = STATE_SHOOT) then + if (FMonsterType = MONSTER_VILE) and (FState = MONSTATE_SHOOT) then begin // Öåëü ïîãèáëà => èäåì äàëüøå: if not GetPos(FTargetUID, @o) then begin - SetState(STATE_GO); + SetState(MONSTATE_GO); goto _end; end; @@ -3709,7 +3696,7 @@ begin // Öåëü íå âèäíî => èäåì äàëüøå: if not g_Look(@FObj, @o, FDirection) then begin - SetState(STATE_GO); + SetState(MONSTATE_GO); goto _end; end; @@ -3717,7 +3704,7 @@ begin // Öåëü â âîäå - íå çàãîðèòñÿ => èäåì äàëüøå: if g_Obj_CollideWater(@o, 0, 0) then begin - SetState(STATE_GO); + SetState(MONSTATE_GO); goto _end; end; @@ -3728,11 +3715,11 @@ begin _end: // Ñîñòîÿíèå - Âîñêðåøåíèå: - if FState = STATE_REVIVE then + if FState = MONSTATE_REVIVE then if FAnim[FCurAnim, FDirection].Played then begin // Îáðàòíàÿ àíèìàöèÿ óìèðàíèÿ çàêîí÷èëàñü - èäåì äàëüøå: FAnim[FCurAnim, FDirection].Revert(False); - SetState(STATE_GO); + SetState(MONSTATE_GO); end; // Åñëè åñòü àíèìàöèÿ îãíÿ êîëäóíà - ïóñòü îíà èäåò: @@ -3740,12 +3727,12 @@ _end: vilefire.Update(); // Ñîñòîÿíèå - Óìèðàåò è òåêóùàÿ àíèìàöèÿ ïðîèãðàíà: - if (FState = STATE_DIE) and + if (FState = MONSTATE_DIE) and (FAnim[FCurAnim, FDirection] <> nil) and (FAnim[FCurAnim, FDirection].Played) then begin // Óìåð: - SetState(STATE_DEAD); + SetState(MONSTATE_DEAD); // Ó ýòèõ ìîíñòðîâ íåò òðóïîâ: if (FMonsterType = MONSTER_PAIN) or @@ -3757,22 +3744,22 @@ _end: end; // Ñîâåðøåíèå àòàêè è ñòðåëüáû: - if (FState = STATE_ATTACK) or (FState = STATE_SHOOT) then + if (FState = MONSTATE_ATTACK) or (FState = MONSTATE_SHOOT) then if (FAnim[FCurAnim, FDirection] <> nil) then // Àíèìàöèÿ àòàêè åñòü - ìîæíî àòàêîâàòü if (FAnim[FCurAnim, FDirection].Played) then begin // Àíèìàöèÿ àòàêè çàêîí÷èëàñü => ïåðåõîäèì íà øàã - if FState = STATE_ATTACK then + if FState = MONSTATE_ATTACK then begin // Ñîñòîÿíèå - Àòàêà // Åñëè ìîíñòð íå Lost_Soul, òî ïîñëå àòàêè ïåðåõîäèì íà øàã: if FMonsterType <> MONSTER_SOUL then - SetState(STATE_GO); + SetState(MONSTATE_GO); end else // Ñîñòîÿíèå - Ñòðåëüáà begin // Ïåðåõîäèì íà øàã, åñëè íå íàäî ñòðåëÿòü åùå ðàç: if not FChainFire then - SetState(STATE_GO) + SetState(MONSTATE_GO) else begin // Íàäî ñòðåëÿòü åùå FChainFire := False; @@ -3792,7 +3779,7 @@ _end: (FAnim[FCurAnim, FDirection].TotalFrames div 2)) ) then begin // Àòàêè åùå íå áûëî è ýòî ñåðåäèíà àíèìàöèè àòàêè - if FState = STATE_ATTACK then + if FState = MONSTATE_ATTACK then begin // Ñîñòîÿíèå - Àòàêà // Åñëè ýòî Lost_Soul, òî ñáðàñûâàåì àíèìàöèþ àòàêè: if FMonsterType = MONSTER_SOUL then @@ -3804,7 +3791,7 @@ _end: if g_Weapon_Hit(@FObj, 15, FUID, HIT_SOME) <> 0 then // Lost_Soul óêóñèë êîãî-òî => ïåðåõîäèò íà øàã: if FMonsterType = MONSTER_SOUL then - SetState(STATE_GO); + SetState(MONSTATE_GO); MONSTER_FISH: g_Weapon_Hit(@FObj, 10, FUID, HIT_SOME); @@ -3856,7 +3843,7 @@ _end: // Ïîñëåäíèé êàäð òåêóùåé àíèìàöèè: if FAnim[FCurAnim, FDirection].Counter = FAnim[FCurAnim, FDirection].Speed-1 then case FState of - STATE_GO, STATE_RUN, STATE_CLIMB, STATE_RUNOUT: + MONSTATE_GO, MONSTATE_RUN, MONSTATE_CLIMB, MONSTATE_RUNOUT: // Çâóêè ïðè ïåðåäâèæåíèè: case FMonsterType of MONSTER_CYBER: @@ -3880,7 +3867,7 @@ _end: // Êîñòûëü äëÿ ïîòîêîâ if g_Obj_CollidePanel(@FObj, 0, 0, PANEL_LIFTLEFT or PANEL_LIFTRIGHT) and - not ((FState = STATE_DEAD) or (FState = STATE_DIE)) then + not ((FState = MONSTATE_DEAD) or (FState = MONSTATE_DIE)) then FObj.Vel.X := oldvelx; // Åñëè åñòü àíèìàöèÿ, òî ïóñòü îíà èäåò: @@ -4091,24 +4078,24 @@ begin case FMonsterType of MONSTER_FISH: begin - SetState(STATE_ATTACK); + SetState(MONSTATE_ATTACK); Result := True; end; MONSTER_DEMON: begin - SetState(STATE_ATTACK); + SetState(MONSTATE_ATTACK); g_Sound_PlayExAt('SOUND_MONSTER_DEMON_ATTACK', FObj.X, FObj.Y); Result := True; end; MONSTER_IMP: begin - SetState(STATE_ATTACK); + SetState(MONSTATE_ATTACK); g_Sound_PlayExAt('SOUND_MONSTER_IMP_ATTACK', FObj.X, FObj.Y); Result := True; end; MONSTER_SKEL, MONSTER_ROBO, MONSTER_CYBER: begin - SetState(STATE_ATTACK, ANIM_ATTACK2); + SetState(MONSTATE_ATTACK, ANIM_ATTACK2); g_Sound_PlayExAt('SOUND_MONSTER_SKEL_ATTACK', FObj.X, FObj.Y); Result := True; end; @@ -4191,19 +4178,19 @@ begin case FMonsterType of MONSTER_IMP, MONSTER_BARON, MONSTER_KNIGHT, MONSTER_CACO: begin - SetState(STATE_SHOOT); + SetState(MONSTATE_SHOOT); {nn} end; MONSTER_SKEL: begin - SetState(STATE_SHOOT); + SetState(MONSTATE_SHOOT); {nn} end; MONSTER_VILE: begin // Çàæèãàåì îãîíü tx := o^.X+o^.Rect.X+(o^.Rect.Width div 2); ty := o^.Y+o^.Rect.Y; - SetState(STATE_SHOOT); + SetState(MONSTATE_SHOOT); vilefire.Reset(); @@ -4212,7 +4199,7 @@ begin end; MONSTER_SOUL: begin // Ëåòèò â ñòîðîíó öåëè: - SetState(STATE_ATTACK); + SetState(MONSTATE_ATTACK); g_Sound_PlayExAt('SOUND_MONSTER_SOUL_ATTACK', FObj.X, FObj.Y); xd := tx-(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2)); @@ -4232,7 +4219,7 @@ begin if FAmmo = 1 then g_Sound_PlayExAt('SOUND_MONSTER_MANCUB_ATTACK', FObj.X, FObj.Y); - SetState(STATE_SHOOT); + SetState(MONSTATE_SHOOT); end; else Exit; end; @@ -4242,7 +4229,7 @@ end; function TMonster.Live(): Boolean; begin - Result := (FState <> STATE_DIE) and (FState <> STATE_DEAD) and (FHealth > 0); + Result := (FState <> MONSTATE_DIE) and (FState <> MONSTATE_DEAD) and (FHealth > 0); end; procedure TMonster.SetHealth(aH: Integer); @@ -4258,7 +4245,7 @@ end; procedure TMonster.WakeUp(); begin if g_Game_IsClient then Exit; - SetState(STATE_GO); + SetState(MONSTATE_GO); FTargetTime := MAX_ATM; WakeUpSound(); end; @@ -4485,7 +4472,7 @@ begin Anim := TAnimation.Create(id, False, 3); Anim.Alpha := 0; g_GFX_OnceAnim(Obj.X+Obj.Rect.X+Random(Obj.Rect.Width+Times*2)-(Anim.Width div 2), - Obj.Y+8+Random(8+Times*2)+IfThen(FState = STATE_DEAD, 16, 0), Anim, ONCEANIM_SMOKE); + Obj.Y+8+Random(8+Times*2)+IfThen(FState = MONSTATE_DEAD, 16, 0), Anim, ONCEANIM_SMOKE); Anim.Free(); end; end; -- 2.29.2