index 02bea1f632bb906c89b5b56a220b757ec2d1b484..3d9e43d2a279aebff18278c46f3db96cf3a3a373 100644 (file)
--- a/src/game/g_monsters.pas
+++ b/src/game/g_monsters.pas
*
* 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
*
* 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
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
function Damage(aDamage: Word; VelX, VelY: Integer; SpawnerUID: Word; t: Byte): Boolean;
function Heal(Value: Word): Boolean;
procedure BFGHit();
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);
procedure Update();
procedure ClientUpdate();
procedure ClientAttack(wx, wy, atx, aty: Integer);
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_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 ();
procedure g_Monsters_Update ();
procedure g_Monsters_Draw ();
procedure g_Monsters_DrawHealth ();
FStartDirection := Direction;
FStartX := GameX;
FStartY := GameY;
FStartDirection := Direction;
FStartX := GameX;
FStartY := GameY;
+ FObj.oldX := FObj.X;
+ FObj.oldY := FObj.Y;
end;
mon.positionChanged();
end;
mon.positionChanged();
end;
end;
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;
procedure g_Monsters_Update();
var
a: Integer;
begin
Result := False;
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;
// Óìèðàåò, óìåð èëè âîñêðåøàåòñÿ => óðîí äåëàòü íåêîìó:
if (FState = MONSTATE_DEAD) or (FState = MONSTATE_DIE) or (FState = MONSTATE_REVIVE) then
Exit;
Exit;
end;
Exit;
end;
+// Àð÷è íå ãîðÿò, ÷åðåïà óæå ãîðÿò
+ if (t = HIT_FLAME) and (FMonsterType in [MONSTER_VILE, MONSTER_SOUL]) then
+ begin
+ // Ïðîñíóòüñÿ âñå-òàêè ñòîèò
+ if FState = MONSTATE_SLEEP then
+ SetState(MONSTATE_GO);
+ Exit;
+ end;
+
// Ëîâóøêà óáèâàåò ñðàçó:
if t = HIT_TRAP then
FHealth := -100;
// Ëîâóøêà óáèâàåò ñðàçó:
if t = HIT_TRAP then
FHealth := -100;
procedure TMonster.Draw();
var
m: TMirrorType;
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));
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
// Åñëè êîëäóí ñòðåëÿåò, òî ðèñóåì îãîíü:
if FMonsterType = MONSTER_VILE then
if FState = MONSTATE_SHOOT then
end;
// Ðèñóåì:
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
end;
if g_debug_Frames then
FObj.X := X - FObj.Rect.X;
FObj.Y := Y - FObj.Rect.Y;
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
positionChanged();
if dir = 1 then
Result := True;
end;
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;
procedure TMonster.Update();
var
a, b, sx, sy, wx, wy, oldvelx: Integer;
o, co: TObj;
fall: Boolean;
mon: TMonster;
o, co: TObj;
fall: Boolean;
mon: TMonster;
+ mit: PMonster;
+ it: TMonsterGrid.Iter;
label
_end;
begin
fall := True;
label
_end;
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
// Ðûáû "ëåòàþò" òîëüêî â âîäå:
if FMonsterType = MONSTER_FISH then
if g_Obj_CollidePanel(@FObj, 0, 0, PANEL_WATER or PANEL_ACID1 or PANEL_ACID2) then
// Åñëè ãîðèì - ïîäæèãàåì äðóãèõ ìîíñòðîâ, íî íå íà 100 òèêîâ êàæäûé ðàç:
if FFireTime > 0 then
// Åñëè ãîðèì - ïîäæèãàåì äðóãèõ ìîíñòðîâ, íî íå íà 100 òèêîâ êàæäûé ðàç:
if FFireTime > 0 then
- for a := 0 to High(gMonsters) do
- if (gMonsters[a] <> nil) and (gMonsters[a].alive) and
- (gMonsters[a].FUID <> FUID) and
- g_Obj_Collide(@FObj, @gMonsters[a].Obj) then
- gMonsters[a].CatchFire(FFireAttacker, FFireTime);
+ begin
+ it := monsGrid.forEachInAABB(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, FObj.Rect.Width, FObj.Rect.Height);
+ for mit in it do
+ if mit.UID <> FUID then
+ mit.CatchFire(FFireAttacker, FFireTime);
+ end;
// Âûëåòåë çà êàðòó - óäàëÿåì è çàïóñêàåì òðèããåðû:
if WordBool(st and MOVE_FALLOUT) or (FObj.X < -1000) or
// Âûëåòåë çà êàðòó - óäàëÿåì è çàïóñêàåì òðèããåðû:
if WordBool(st and MOVE_FALLOUT) or (FObj.X < -1000) or
FObj.Rect.Width, 8, @co) and (Random(3) = 0) then
// Ïèíàåì òðóïû
if FObj.Vel.X < 0 then
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
else
- gCorpses[a].Damage(b*2, b, Random(7)); // íàïðàâî
+ gCorpses[a].Damage(b*2, FUID, b, Random(7)); // íàïðàâî
end;
end;
// Åñëè öåëü âûñîêî, òî, âîçìîæíî, ïðûãàåì:
end;
end;
// Åñëè öåëü âûñîêî, òî, âîçìîæíî, ïðûãàåì:
sx := 0; // SHUT UP COMPILER
sy := 0;
fall := True;
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
// Ðûáû "ëåòàþò" òîëüêî â âîäå:
if FMonsterType = MONSTER_FISH then
if g_Obj_CollidePanel(@FObj, 0, 0, PANEL_WATER or PANEL_ACID1 or PANEL_ACID2) then
FObj.Rect.Width, 8, @co) and (Random(3) = 0) then
// Ïèíàåì òðóïû
if FObj.Vel.X < 0 then
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
else
- gCorpses[a].Damage(b*2, b, Random(7)); // íàïðàâî
+ gCorpses[a].Damage(b*2, FUID, b, Random(7)); // íàïðàâî
end;
end;
end;
end;
end;
end;
FAnim[i, TDirection.D_RIGHT].LoadState(st);
end;
end;
FAnim[i, TDirection.D_RIGHT].LoadState(st);
end;
end;
+ // update cache
+ self.positionChanged
end;
end;
procedure TMonster.CatchFire(Attacker: Word; Timeout: Integer = MON_BURN_TIME);
begin
procedure TMonster.CatchFire(Attacker: Word; Timeout: Integer = MON_BURN_TIME);
begin
+ if FMonsterType in [MONSTER_SOUL, MONSTER_VILE] then
+ exit; // àð÷è íå ãîðÿò, ÷åðåïà óæå ãîðÿò
if Timeout <= 0 then exit;
if Timeout <= 0 then exit;
+ if g_Obj_CollidePanel(@FObj, 0, 0, PANEL_WATER or PANEL_ACID1 or PANEL_ACID2) then
+ exit; // íå ïîäãîðàåì â âîäå íà âñÿêèé ñëó÷àé
if FFireTime <= 0 then
g_Sound_PlayExAt('SOUND_IGNITE', FObj.X, FObj.Y);
FFireTime := Timeout;
if FFireTime <= 0 then
g_Sound_PlayExAt('SOUND_IGNITE', FObj.X, FObj.Y);
FFireTime := Timeout;