X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_monsters.pas;h=3d9e43d2a279aebff18278c46f3db96cf3a3a373;hb=fbbc2cfe8253d61c8a5eb27d352df4103a59b7fb;hp=a70364bca6a7e4c4c512dc7fb6081c3d48c1cbf3;hpb=bba5c4a7b77b3be25c3b872b21c96e28a57cee32;p=d2df-sdl.git diff --git a/src/game/g_monsters.pas b/src/game/g_monsters.pas index a70364b..3d9e43d 100644 --- a/src/game/g_monsters.pas +++ b/src/game/g_monsters.pas @@ -2,8 +2,7 @@ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * the Free Software Foundation, version 3 of the License ONLY. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -125,6 +124,7 @@ type function Damage(aDamage: Word; VelX, VelY: Integer; SpawnerUID: Word; t: Byte): Boolean; function Heal(Value: Word): Boolean; procedure BFGHit(); + procedure PreUpdate(); procedure Update(); procedure ClientUpdate(); procedure ClientAttack(wx, wy, atx, aty: Integer); @@ -233,6 +233,7 @@ procedure g_Monsters_Init (); procedure g_Monsters_Free (clearGrid: Boolean=true); function g_Monsters_Create (MonsterType: Byte; X, Y: Integer; Direction: TDirection; AdjCoord: Boolean = False; ForcedUID: Integer = -1): TMonster; +procedure g_Monsters_PreUpdate (); procedure g_Monsters_Update (); procedure g_Monsters_Draw (); procedure g_Monsters_DrawHealth (); @@ -1378,6 +1379,8 @@ begin FStartDirection := Direction; FStartX := GameX; FStartY := GameY; + FObj.oldX := FObj.X; + FObj.oldY := FObj.Y; end; mon.positionChanged(); @@ -1413,6 +1416,16 @@ begin end; end; +procedure g_Monsters_PreUpdate(); +var + a: Integer; +begin + if gMonsters = nil then Exit; + for a := 0 to High(gMonsters) do + if (gMonsters[a] <> nil) and (not gMonsters[a].FRemoved) then + gMonsters[a].PreUpdate(); +end; + procedure g_Monsters_Update(); var a: Integer; @@ -1994,6 +2007,9 @@ var begin Result := False; +// Ìîíñòð ñòàòè÷åí ïîêà èäåò warmup + if (gLMSRespawn > LMS_RESPAWN_NONE) then exit; + // Óìèðàåò, óìåð èëè âîñêðåøàåòñÿ => óðîí äåëàòü íåêîìó: if (FState = MONSTATE_DEAD) or (FState = MONSTATE_DIE) or (FState = MONSTATE_REVIVE) then Exit; @@ -2207,12 +2223,14 @@ end; procedure TMonster.Draw(); var m: TMirrorType; - dx, dy, c: Integer; + dx, dy, c, fX, fY: Integer; o: TObj; begin //e_CharFont_Print(gMenuSmallFont, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, 'TYPE: '+IntToStr(FMonsterType)); //e_CharFont_Print(gMenuSmallFont, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y+16, 'STATE: '+IntToStr(FState)); + FObj.lerp(gLerpFactor, fX, fY); + // Åñëè êîëäóí ñòðåëÿåò, òî ðèñóåì îãîíü: if FMonsterType = MONSTER_VILE then if FState = MONSTATE_SHOOT then @@ -2272,7 +2290,7 @@ begin end; // Ðèñóåì: - FAnim[FCurAnim, FDirection].Draw(Obj.X+dx, Obj.Y+dy, m); + FAnim[FCurAnim, FDirection].Draw(fX+dx, fY+dy, m); end; if g_debug_Frames then @@ -2404,6 +2422,8 @@ begin FObj.X := X - FObj.Rect.X; FObj.Y := Y - FObj.Rect.Y; + FObj.oldX := FObj.X; // don't interpolate after teleport + FObj.oldY := FObj.Y; positionChanged(); if dir = 1 then @@ -2437,6 +2457,12 @@ begin Result := True; end; +procedure TMonster.PreUpdate(); +begin + FObj.oldX := FObj.X; + FObj.oldY := FObj.Y; +end; + procedure TMonster.Update(); var a, b, sx, sy, wx, wy, oldvelx: Integer; @@ -2451,6 +2477,9 @@ label begin fall := True; +// Ìîíñòð ñòàòè÷åí ïîêà èäåò warmup + if (gLMSRespawn > LMS_RESPAWN_NONE) then exit; + // Ðûáû "ëåòàþò" òîëüêî â âîäå: if FMonsterType = MONSTER_FISH then if g_Obj_CollidePanel(@FObj, 0, 0, PANEL_WATER or PANEL_ACID1 or PANEL_ACID2) then @@ -2909,9 +2938,9 @@ begin FObj.Rect.Width, 8, @co) and (Random(3) = 0) then // Ïèíàåì òðóïû if FObj.Vel.X < 0 then - gCorpses[a].Damage(b*2, -b, Random(7)) // íàëåâî + gCorpses[a].Damage(b*2, FUID, -b, Random(7)) // íàëåâî else - gCorpses[a].Damage(b*2, b, Random(7)); // íàïðàâî + gCorpses[a].Damage(b*2, FUID, b, Random(7)); // íàïðàâî end; end; // Åñëè öåëü âûñîêî, òî, âîçìîæíî, ïðûãàåì: @@ -3440,6 +3469,10 @@ begin sx := 0; // SHUT UP COMPILER sy := 0; fall := True; + +// Ìîíñòð ñòàòè÷åí ïîêà èäåò warmup + if (gLMSRespawn > LMS_RESPAWN_NONE) then exit; + // Ðûáû "ëåòàþò" òîëüêî â âîäå: if FMonsterType = MONSTER_FISH then if g_Obj_CollidePanel(@FObj, 0, 0, PANEL_WATER or PANEL_ACID1 or PANEL_ACID2) then @@ -3755,9 +3788,9 @@ begin FObj.Rect.Width, 8, @co) and (Random(3) = 0) then // Ïèíàåì òðóïû if FObj.Vel.X < 0 then - gCorpses[a].Damage(b*2, -b, Random(7)) // íàëåâî + gCorpses[a].Damage(b*2, FUID, -b, Random(7)) // íàëåâî else - gCorpses[a].Damage(b*2, b, Random(7)); // íàïðàâî + gCorpses[a].Damage(b*2, FUID, b, Random(7)); // íàïðàâî end; end; end; @@ -4630,6 +4663,8 @@ begin FAnim[i, TDirection.D_RIGHT].LoadState(st); end; end; + // update cache + self.positionChanged end;