X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_monsters.pas;h=e7ee1d0eb784275870b6aa872acb8158049d3256;hb=6820eae460a9c99136ab5e679ffe2f6236c3540f;hp=4cba5acb10b21bd2487e25d577e7a4611455449a;hpb=4eec31fb4339e1eedd7380506e344a69af9976f5;p=d2df-sdl.git diff --git a/src/game/g_monsters.pas b/src/game/g_monsters.pas index 4cba5ac..e7ee1d0 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 @@ -40,6 +39,8 @@ const MONSTATE_REVIVE = 10; MONSTATE_RUNOUT = 11; + MON_BURN_TIME = 100; + { in mapdef now BH_NORMAL = 0; BH_KILLER = 1; @@ -145,7 +146,7 @@ type function AnimIsReverse: Boolean; function shoot(o: PObj; immediately: Boolean): Boolean; function kick(o: PObj): Boolean; - procedure CatchFire(Attacker: Word); + procedure CatchFire(Attacker: Word; Timeout: Integer = MON_BURN_TIME); procedure OnFireFlame(Times: DWORD = 1); procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right! @@ -322,8 +323,8 @@ uses procedure g_Mons_ProfilersBegin (); begin if (profMonsLOS = nil) then profMonsLOS := TProfiler.Create('LOS CALC', g_profile_history_size); - profMonsLOS.mainBegin(g_profile_los); - if g_profile_los then + if (profMonsLOS <> nil) then profMonsLOS.mainBegin(g_profile_los); + if g_profile_los and (profMonsLOS <> nil) then begin profMonsLOS.sectionBegin('loscalc'); profMonsLOS.sectionEnd(); @@ -332,17 +333,17 @@ end; procedure g_Mons_ProfilersEnd (); begin - if (profMonsLOS <> nil) and (g_profile_los) then profMapCollision.mainEnd(); + if (profMonsLOS <> nil) and (g_profile_los) then profMonsLOS.mainEnd(); end; procedure g_Mons_LOS_Start (); inline; begin - profMonsLOS.sectionBeginAccum('loscalc'); + if (profMonsLOS <> nil) then profMonsLOS.sectionBeginAccum('loscalc'); end; procedure g_Mons_LOS_End (); inline; begin - profMonsLOS.sectionEnd(); + if (profMonsLOS <> nil) then profMonsLOS.sectionEnd(); end; @@ -1992,6 +1993,9 @@ var begin Result := False; +// Ìîíñòð ñòàòè÷åí ïîêà èäåò warmup + if (gLMSRespawn = LMS_RESPAWN_WARMUP) then exit; + // Óìèðàåò, óìåð èëè âîñêðåøàåòñÿ => óðîí äåëàòü íåêîìó: if (FState = MONSTATE_DEAD) or (FState = MONSTATE_DIE) or (FState = MONSTATE_REVIVE) then Exit; @@ -2006,6 +2010,15 @@ begin 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; @@ -2433,11 +2446,16 @@ var o, co: TObj; fall: Boolean; mon: TMonster; + mit: PMonster; + it: TMonsterGrid.Iter; label _end; begin fall := True; +// Ìîíñòð ñòàòè÷åí ïîêà èäåò warmup + if (gLMSRespawn = LMS_RESPAWN_WARMUP) then exit; + // Ðûáû "ëåòàþò" òîëüêî â âîäå: if FMonsterType = MONSTER_FISH then if g_Obj_CollidePanel(@FObj, 0, 0, PANEL_WATER or PANEL_ACID1 or PANEL_ACID2) then @@ -2469,6 +2487,15 @@ begin st := g_Obj_Move(@FObj, fall, True, True); positionChanged(); // this updates spatial accelerators +// Åñëè ãîðèì - ïîäæèãàåì äðóãèõ ìîíñòðîâ, íî íå íà 100 òèêîâ êàæäûé ðàç: + if FFireTime > 0 then + 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 (FObj.X > gMapInfo.Width+1000) or (FObj.Y < -1000) then @@ -2825,7 +2852,7 @@ begin // Ðûáà ïëûâåò ââåðõ: if FObj.Vel.Y < 0 then - if not g_Obj_CollideWater(@FObj, 0, -16) then + if not g_Obj_CollideLiquid(@FObj, 0, -16) then begin // Âñïëûëè äî ïîâåðõíîñòè - ñòîï: FObj.Vel.Y := 0; @@ -3243,6 +3270,19 @@ _end: wx := FObj.X + wx; wy := FObj.Y + MONSTER_ANIMTABLE[FMonsterType].wY; + // Ìîíñòð íå ìîæåò öåëèòüñÿ â îáúåêò çà ñïèíîé, ñòðåëÿÿ âëåâî: + if (FDirection = TDirection.D_LEFT) and (tx > wx) then + begin + tx := wx - 32; + ty := wy + Random(11) - 5; + end; + // È àíàëîãè÷íî, ñòðåëÿÿ âïðàâî: + if (FDirection = TDirection.D_RIGHT) and (tx < wx) then + begin + tx := wx + 32; + ty := wy + Random(11) - 5; + end; + // Äåëàåì âûñòðåë íóæíûì îðóæèåì: case FMonsterType of MONSTER_IMP: @@ -3405,6 +3445,10 @@ begin sx := 0; // SHUT UP COMPILER sy := 0; fall := True; + +// Ìîíñòð ñòàòè÷åí ïîêà èäåò warmup + if (gLMSRespawn = LMS_RESPAWN_WARMUP) then exit; + // Ðûáû "ëåòàþò" òîëüêî â âîäå: if FMonsterType = MONSTER_FISH then if g_Obj_CollidePanel(@FObj, 0, 0, PANEL_WATER or PANEL_ACID1 or PANEL_ACID2) then @@ -3661,7 +3705,7 @@ begin // Ðûáà ïëûâåò ââåðõ: if FObj.Vel.Y < 0 then - if not g_Obj_CollideWater(@FObj, 0, -16) then + if not g_Obj_CollideLiquid(@FObj, 0, -16) then begin // Âñïëûëè äî ïîâåðõíîñòè - ñòîï: FObj.Vel.Y := 0; @@ -4623,9 +4667,16 @@ begin SetLength(FDieTriggers, 0); end; -procedure TMonster.CatchFire(Attacker: Word); +procedure TMonster.CatchFire(Attacker: Word; Timeout: Integer = MON_BURN_TIME); begin - FFireTime := 100; + if FMonsterType in [MONSTER_SOUL, MONSTER_VILE] 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; FFireAttacker := Attacker; if g_Game_IsNet and g_Game_IsServer then MH_SEND_MonsterState(FUID); end;