index ec3bb7144f67e6ae7f1c2f05c62890134968af8a..e39b8c66a3dfdd7b6a2491f85087cae51e119ddb 100644 (file)
--- a/src/game/g_triggers.pas
+++ b/src/game/g_triggers.pas
with gWalls[PanelID] do
begin
if g_CollidePlayer(X, Y, Width, Height) or
- g_CollideMonster(X, Y, Width, Height) then Exit;
+ g_Mons_IsAnyAliveAt(X, Y, Width, Height) then Exit;
if not Enabled then
begin
with gWalls[gDoorMap[c, b]] do
begin
if g_CollidePlayer(X, Y, Width, Height) or
- g_CollideMonster(X, Y, Width, Height) then Exit;
+ g_Mons_IsAnyAliveAt(X, Y, Width, Height) then Exit;
end;
if not NoSound then
a, b, c: Integer;
wx, wy, wh, ww: Integer;
- function monsDamage (monidx: Integer; mon: TMonster): Boolean;
+ function monsDamage (mon: TMonster): Boolean;
begin
result := false; // don't stop
- if (mon <> nil) and mon.Live and g_Obj_Collide(wx, wy, ww, wh, @mon.Obj) then
- begin
- mon.Damage(TRAP_DAMAGE, 0, 0, 0, HIT_TRAP);
- end;
+ if g_Obj_Collide(wx, wy, ww, wh, @mon.Obj) then mon.Damage(TRAP_DAMAGE, 0, 0, 0, HIT_TRAP);
end;
begin
gPlayers[a].Collide(X, Y, Width, Height) then
gPlayers[a].Damage(TRAP_DAMAGE, 0, 0, 0, HIT_TRAP);
- g_Mons_ForEach(monsDamage);
+ //g_Mons_ForEach(monsDamage);
+ g_Mons_ForEachAliveAt(wx, wy, ww, wh, monsDamage);
if not Enabled then g_Map_EnableWall(PanelID);
end;
gPlayers[a].Collide(X, Y, Width, Height) then
gPlayers[a].Damage(TRAP_DAMAGE, 0, 0, 0, HIT_TRAP);
- g_Mons_ForEach(monsDamage);
+ //g_Mons_ForEach(monsDamage);
+ g_Mons_ForEachAliveAt(wx, wy, ww, wh, monsDamage);
(*
if gMonsters <> nil then
for a := 0 to High(gMonsters) do
dx := dx + Random(Data.ShotAccuracy) - Random(Data.ShotAccuracy);
dy := dy + Random(Data.ShotAccuracy) - Random(Data.ShotAccuracy);
-
+
tr_SpawnShot(Data.ShotType, wx, wy, dx, dy, Data.ShotSound, TargetUID);
end
else
UID_MONSTER:
begin
- m := g_Monsters_Get(ActivateUID);
+ m := g_Monsters_ByUID(ActivateUID);
if m = nil then
Exit;
UID_MONSTER:
begin
- m := g_Monsters_Get(ActivateUID);
+ m := g_Monsters_ByUID(ActivateUID);
if m = nil then
Exit;
it: PItem;
mon: TMonster;
- function monsShotTarget (monidx: Integer; mon: TMonster): Boolean;
+ function monsShotTarget (mon: TMonster): Boolean;
begin
result := false; // don't stop
- if (mon <> nil) and mon.Live and tr_ShotAimCheck(Trigger, @(mon.Obj)) then
+ if mon.Live and tr_ShotAimCheck(Trigger, @(mon.Obj)) then
begin
xd := mon.GameX + mon.Obj.Rect.Width div 2;
yd := mon.GameY + mon.Obj.Rect.Height div 2;
end;
end;
- function monsShotTargetMonPlr (monidx: Integer; mon: TMonster): Boolean;
+ function monsShotTargetMonPlr (mon: TMonster): Boolean;
begin
result := false; // don't stop
- if (mon <> nil) and mon.Live and tr_ShotAimCheck(Trigger, @(mon.Obj)) then
+ if mon.Live and tr_ShotAimCheck(Trigger, @(mon.Obj)) then
begin
xd := mon.GameX + mon.Obj.Rect.Width div 2;
yd := mon.GameY + mon.Obj.Rect.Height div 2;
end;
end;
- function monShotTargetPlrMon (monidx: Integer; mon: TMonster): Boolean;
+ function monShotTargetPlrMon (mon: TMonster): Boolean;
begin
result := false; // don't stop
- if (mon <> nil) and mon.Live and tr_ShotAimCheck(Trigger, @(mon.Obj)) then
+ if mon.Live and tr_ShotAimCheck(Trigger, @(mon.Obj)) then
begin
xd := mon.GameX + mon.Obj.Rect.Width div 2;
yd := mon.GameY + mon.Obj.Rect.Height div 2;
if Data.ItemMax > 0 then
begin
- it := g_ItemByIdx(iid);
+ it := g_Items_ByIdx(iid);
it.SpawnTrigger := ID;
Inc(SpawnedCount);
end;
case Data.ItemEffect of
EFFECT_TELEPORT: begin
- it := g_ItemByIdx(iid);
+ it := g_Items_ByIdx(iid);
if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then
begin
Anim := TAnimation.Create(FramesID, False, 3);
NET_GFX_TELE);
end;
EFFECT_RESPAWN: begin
- it := g_ItemByIdx(iid);
+ it := g_Items_ByIdx(iid);
if g_Frames_Get(FramesID, 'FRAMES_ITEM_RESPAWN') then
begin
Anim := TAnimation.Create(FramesID, False, 4);
NET_GFX_RESPAWN);
end;
EFFECT_FIRE: begin
- it := g_ItemByIdx(iid);
+ it := g_Items_ByIdx(iid);
if g_Frames_Get(FramesID, 'FRAMES_FIRE') then
begin
Anim := TAnimation.Create(FramesID, False, 4);
UID_MONSTER:
begin
- m := g_Monsters_Get(ActivateUID);
+ m := g_Monsters_ByUID(ActivateUID);
if m = nil then
Exit;
case Data.ShotTarget of
TRIGGER_SHOT_TARGET_MON: // monsters
- g_Mons_ForEach(monsShotTarget);
+ //TODO: accelerate this!
+ g_Mons_ForEachAlive(monsShotTarget);
TRIGGER_SHOT_TARGET_PLR: // players
if gPlayers <> nil then
TRIGGER_SHOT_TARGET_MONPLR: // monsters then players
begin
- g_Mons_ForEach(monsShotTargetMonPlr);
+ //TODO: accelerate this!
+ g_Mons_ForEachAlive(monsShotTargetMonPlr);
if (TargetUID = 0) and (gPlayers <> nil) then
for idx := Low(gPlayers) to High(gPlayers) do
TargetUID := gPlayers[idx].UID;
break;
end;
- if TargetUID = 0 then g_Mons_ForEach(monShotTargetPlrMon);
+ if TargetUID = 0 then
+ begin
+ //TODO: accelerate this!
+ g_Mons_ForEachAlive(monShotTargetPlrMon);
+ end;
end;
else begin
a, b, i: Integer;
Affected: array of Integer;
- function monsNear (monidx: Integer; mon: TMonster): Boolean;
+ {function monsNear (mon: TMonster): Boolean;
begin
result := false; // don't stop
if mon.Collide(gTriggers[a].X, gTriggers[a].Y, gTriggers[a].Width, gTriggers[a].Height) then
gTriggers[a].ActivateUID := mon.UID;
ActivateTrigger(gTriggers[a], ACTIVATE_MONSTERCOLLIDE);
end;
+ end;}
+
+ function monsNear (mon: TMonster): Boolean;
+ begin
+ result := false; // don't stop
+ gTriggers[a].ActivateUID := mon.UID;
+ ActivateTrigger(gTriggers[a], ACTIVATE_MONSTERCOLLIDE);
end;
begin
if ByteBool(ActivateType and ACTIVATE_MONSTERCOLLIDE) and
(TimeOut = 0) and (Keys = 0) then // Åñëè íå íóæíû êëþ÷è
begin
- g_Mons_ForEach(monsNear);
+ //g_Mons_ForEach(monsNear);
+ //Alive?!
+ g_Mons_ForEachAt(gTriggers[a].X, gTriggers[a].Y, gTriggers[a].Width, gTriggers[a].Height, monsNear);
end;
// "Ìîíñòðîâ íåò"
if ByteBool(ActivateType and ACTIVATE_NOMONSTER) and
(TimeOut = 0) and (Keys = 0) then
- if not g_CollideMonster(X, Y, Width, Height) then
+ if not g_Mons_IsAnyAliveAt(X, Y, Width, Height) then
begin
gTriggers[a].ActivateUID := 0;
ActivateTrigger(gTriggers[a], ACTIVATE_NOMONSTER);