X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=blobdiff_plain;f=src%2Fgame%2Fg_triggers.pas;h=64e87c6679d3249581d15ba0eb1dac13b9276e10;hp=680d9ed266f26a8fbf486ba76376360b4ba0f8f6;hb=abda6900c041e39944de6a49aa088a60c170715e;hpb=883536c49995010477bfba3c16e34209e0b4d8ef diff --git a/src/game/g_triggers.pas b/src/game/g_triggers.pas index 680d9ed..64e87c6 100644 --- a/src/game/g_triggers.pas +++ b/src/game/g_triggers.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 @@ -20,7 +19,7 @@ interface uses SysUtils, Variants, Classes, - MAPDEF, e_graphics, g_basic, g_sound, + MAPDEF, g_basic, g_sound, xdynrec, hashtable, exoma; type @@ -104,9 +103,9 @@ implementation uses Math, - g_player, g_map, g_panel, g_gfx, g_game, g_textures, + g_player, g_map, g_panel, g_gfx, g_game, r_gfx, g_console, g_monsters, g_items, g_phys, g_weapons, - wadreader, g_main, e_log, g_language, + wadreader, e_log, g_language, e_res, g_options, g_net, g_netmsg, utils, xparser, xstreams; const @@ -665,11 +664,8 @@ function tr_SpawnShot (ShotType: Integer; wx, wy, dx, dy: Integer; ShotSound: Bo var snd: string; Projectile: Boolean; - TextureID: DWORD; - Anim: TAnimation; begin result := -1; - TextureID := DWORD(-1); snd := 'SOUND_WEAPON_FIREROCKET'; Projectile := true; @@ -780,13 +776,7 @@ begin TRIGGER_SHOT_EXPL: begin - if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_ROCKET') then - begin - Anim := TAnimation.Create(TextureID, False, 6); - Anim.Blending := False; - g_GFX_OnceAnim(wx-64, wy-64, Anim); - Anim.Free(); - end; + r_GFX_OnceAnim(R_GFX_EXPLODE_ROCKET, wx - 64, wy - 64); Projectile := False; g_Weapon_Explode(wx, wy, 60, 0); snd := 'SOUND_WEAPON_EXPLODEROCKET'; @@ -794,13 +784,7 @@ begin TRIGGER_SHOT_BFGEXPL: begin - if g_Frames_Get(TextureID, 'FRAMES_EXPLODE_BFG') then - begin - Anim := TAnimation.Create(TextureID, False, 6); - Anim.Blending := False; - g_GFX_OnceAnim(wx-64, wy-64, Anim); - Anim.Free(); - end; + r_GFX_OnceAnim(R_GFX_EXPLODE_BFG, wx - 64, wy - 64); Projectile := False; g_Weapon_BFG9000(wx, wy, 0); snd := 'SOUND_WEAPON_EXPLODEBFG'; @@ -867,9 +851,6 @@ end; procedure tr_MakeEffect (X, Y, VX, VY: Integer; T, ST, CR, CG, CB: Byte; Silent, Send: Boolean); -var - FramesID: DWORD; - Anim: TAnimation; begin if T = TRIGGER_EFFECT_PARTICLE then begin @@ -893,33 +874,18 @@ begin begin case ST of EFFECT_TELEPORT: begin - if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then - begin - Anim := TAnimation.Create(FramesID, False, 3); - if not Silent then g_Sound_PlayExAt('SOUND_GAME_TELEPORT', X, Y); - g_GFX_OnceAnim(X-32, Y-32, Anim); - Anim.Free(); - end; + if not Silent then g_Sound_PlayExAt('SOUND_GAME_TELEPORT', X, Y); + r_GFX_OnceAnim(R_GFX_TELEPORT_FAST, X - 32, Y - 32); if Send and g_Game_IsServer and g_Game_IsNet then MH_SEND_Effect(X, Y, Byte(not Silent), NET_GFX_TELE); end; EFFECT_RESPAWN: begin - if g_Frames_Get(FramesID, 'FRAMES_ITEM_RESPAWN') then - begin - Anim := TAnimation.Create(FramesID, False, 4); - if not Silent then g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', X, Y); - g_GFX_OnceAnim(X-16, Y-16, Anim); - Anim.Free(); - end; + if not Silent then g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', X, Y); + r_GFX_OnceAnim(R_GFX_ITEM_RESPAWN, X - 16, Y - 16); if Send and g_Game_IsServer and g_Game_IsNet then MH_SEND_Effect(X-16, Y-16, Byte(not Silent), NET_GFX_RESPAWN); end; EFFECT_FIRE: begin - if g_Frames_Get(FramesID, 'FRAMES_FIRE') then - begin - Anim := TAnimation.Create(FramesID, False, 4); - if not Silent then g_Sound_PlayExAt('SOUND_FIRE', X, Y); - g_GFX_OnceAnim(X-32, Y-128, Anim); - Anim.Free(); - end; + if not Silent then g_Sound_PlayExAt('SOUND_FIRE', X, Y); + r_GFX_OnceAnim(R_GFX_FIRE, X - 32, Y - 128); if Send and g_Game_IsServer and g_Game_IsNet then MH_SEND_Effect(X-32, Y-128, Byte(not Silent), NET_GFX_FIRE); end; end; @@ -1174,8 +1140,6 @@ var iid: LongWord; coolDown: Boolean; pAngle: Real; - FramesID: DWORD; - Anim: TAnimation; UIDType: Byte; TargetUID: Word; it: PItem; @@ -1225,7 +1189,7 @@ begin if not Trigger.Enabled then exit; if (Trigger.TimeOut <> 0) and (actType <> ACTIVATE_CUSTOM) then exit; - if (gLMSRespawn = LMS_RESPAWN_WARMUP) then exit; + if (gLMSRespawn > LMS_RESPAWN_NONE) then exit; if (Trigger.exoCheck <> nil) then begin @@ -1350,17 +1314,13 @@ begin begin Enabled := False; Result := True; - if gLMSRespawn = LMS_RESPAWN_NONE then + p := g_Player_Get(ActivateUID); + p.GetSecret(); + Inc(gCoopSecretsFound); + if g_Game_IsNet then begin - p := g_Player_Get(ActivateUID); - p.GetSecret(); - Inc(gCoopSecretsFound); - if g_Game_IsNet then - begin - MH_SEND_GameStats(); - if p.FClientID >= 0 then - MH_SEND_GameEvent(NET_EV_SECRET, p.UID, ''); - end; + MH_SEND_GameStats(); + MH_SEND_GameEvent(NET_EV_SECRET, p.UID, ''); end; end; @@ -1508,42 +1468,36 @@ begin case tgcEffect of EFFECT_TELEPORT: begin - if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then - begin - Anim := TAnimation.Create(FramesID, False, 3); - g_Sound_PlayExAt('SOUND_GAME_TELEPORT', tgcTX, tgcTY); - g_GFX_OnceAnim(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32, - mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-32, Anim); - Anim.Free(); - end; + g_Sound_PlayExAt('SOUND_GAME_TELEPORT', tgcTX, tgcTY); + r_GFX_OnceAnim( + R_GFX_TELEPORT_FAST, + mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32, + mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-32 + ); if g_Game_IsServer and g_Game_IsNet then MH_SEND_Effect(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32, mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-32, 1, NET_GFX_TELE); end; EFFECT_RESPAWN: begin - if g_Frames_Get(FramesID, 'FRAMES_ITEM_RESPAWN') then - begin - Anim := TAnimation.Create(FramesID, False, 4); - g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', tgcTX, tgcTY); - g_GFX_OnceAnim(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-16, - mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-16, Anim); - Anim.Free(); - end; + g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', tgcTX, tgcTY); + r_GFX_OnceAnim( + R_GFX_ITEM_RESPAWN, + mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-16, + mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-16 + ); if g_Game_IsServer and g_Game_IsNet then MH_SEND_Effect(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-16, mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2)-16, 1, NET_GFX_RESPAWN); end; EFFECT_FIRE: begin - if g_Frames_Get(FramesID, 'FRAMES_FIRE') then - begin - Anim := TAnimation.Create(FramesID, False, 4); - g_Sound_PlayExAt('SOUND_FIRE', tgcTX, tgcTY); - g_GFX_OnceAnim(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32, - mon.Obj.Y+mon.Obj.Rect.Y+mon.Obj.Rect.Height-128, Anim); - Anim.Free(); - end; + g_Sound_PlayExAt('SOUND_FIRE', tgcTX, tgcTY); + r_GFX_OnceAnim( + R_GFX_FIRE, + mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32, + mon.Obj.Y+mon.Obj.Rect.Y+mon.Obj.Rect.Height-128 + ); if g_Game_IsServer and g_Game_IsNet then MH_SEND_Effect(mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2)-32, mon.Obj.Y+mon.Obj.Rect.Y+mon.Obj.Rect.Height-128, 1, @@ -1601,14 +1555,12 @@ begin case tgcEffect of EFFECT_TELEPORT: begin it := g_Items_ByIdx(iid); - if g_Frames_Get(FramesID, 'FRAMES_TELEPORT') then - begin - Anim := TAnimation.Create(FramesID, False, 3); - g_Sound_PlayExAt('SOUND_GAME_TELEPORT', tgcTX, tgcTY); - g_GFX_OnceAnim(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32, - it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-32, Anim); - Anim.Free(); - end; + g_Sound_PlayExAt('SOUND_GAME_TELEPORT', tgcTX, tgcTY); + r_GFX_OnceAnim( + R_GFX_TELEPORT_FAST, + it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32, + it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-32 + ); if g_Game_IsServer and g_Game_IsNet then MH_SEND_Effect(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32, it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-32, 1, @@ -1616,14 +1568,12 @@ begin end; EFFECT_RESPAWN: begin it := g_Items_ByIdx(iid); - if g_Frames_Get(FramesID, 'FRAMES_ITEM_RESPAWN') then - begin - Anim := TAnimation.Create(FramesID, False, 4); - g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', tgcTX, tgcTY); - g_GFX_OnceAnim(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-16, - it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-16, Anim); - Anim.Free(); - end; + g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', tgcTX, tgcTY); + r_GFX_OnceAnim( + R_GFX_ITEM_RESPAWN, + it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-16, + it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-16 + ); if g_Game_IsServer and g_Game_IsNet then MH_SEND_Effect(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-16, it.Obj.Y+it.Obj.Rect.Y+(it.Obj.Rect.Height div 2)-16, 1, @@ -1631,14 +1581,12 @@ begin end; EFFECT_FIRE: begin it := g_Items_ByIdx(iid); - if g_Frames_Get(FramesID, 'FRAMES_FIRE') then - begin - Anim := TAnimation.Create(FramesID, False, 4); - g_Sound_PlayExAt('SOUND_FIRE', tgcTX, tgcTY); - g_GFX_OnceAnim(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32, - it.Obj.Y+it.Obj.Rect.Y+it.Obj.Rect.Height-128, Anim); - Anim.Free(); - end; + g_Sound_PlayExAt('SOUND_FIRE', tgcTX, tgcTY); + r_GFX_OnceAnim( + R_GFX_FIRE, + it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32, + it.Obj.Y+it.Obj.Rect.Y+it.Obj.Rect.Height-128 + ); if g_Game_IsServer and g_Game_IsNet then MH_SEND_Effect(it.Obj.X+it.Obj.Rect.X+(it.Obj.Rect.Width div 2)-32, it.Obj.Y+it.Obj.Rect.Y+it.Obj.Rect.Height-128, 1, @@ -2345,7 +2293,7 @@ end; function g_Triggers_Create (aTrigger: TTrigger; trec: TDynRecord; forceInternalIndex: Integer=-1): DWORD; var find_id: DWORD; - fn, mapw: AnsiString; + fn: AnsiString; f, olen: Integer; ptg: PTrigger; begin @@ -2519,17 +2467,7 @@ begin // Åùå íåò òàêîãî çâóêà if not g_Sound_Exists(ptg.tgcSoundName) then begin - fn := g_ExtractWadName(ptg.tgcSoundName); - if (fn = '') then - begin // Çâóê â ôàéëå ñ êàðòîé - mapw := g_ExtractWadName(gMapInfo.Map); - fn := mapw+':'+g_ExtractFilePathName(ptg.tgcSoundName); - end - else // Çâóê â îòäåëüíîì ôàéëå - begin - fn := GameDir + '/wads/' + ptg.tgcSoundName; - end; - + fn := e_GetResourcePath(WadDirs, ptg.tgcSoundName, g_ExtractWadName(gMapInfo.Map)); //e_LogWritefln('loading trigger sound ''%s''', [fn]); if not g_Sound_CreateWADEx(ptg.tgcSoundName, fn) then begin @@ -2555,18 +2493,7 @@ begin // Åùå íåò òàêîé ìóçûêè if not g_Sound_Exists(ptg.tgcMusicName) then begin - fn := g_ExtractWadName(ptg.tgcMusicName); - - if fn = '' then - begin // Ìóçûêà â ôàéëå ñ êàðòîé - mapw := g_ExtractWadName(gMapInfo.Map); - fn := mapw+':'+g_ExtractFilePathName(ptg.tgcMusicName); - end - else // Ìóçûêà â ôàéëå ñ êàðòîé - begin - fn := GameDir+'/wads/'+ptg.tgcMusicName; - end; - + fn := e_GetResourcePath(WadDirs, ptg.tgcMusicName, g_ExtractWadName(gMapInfo.Map)); if not g_Sound_CreateWADEx(ptg.tgcMusicName, fn, True) then begin g_FatalError(Format(_lc[I_GAME_ERROR_TR_SOUND], [fn, ptg.tgcMusicName])); @@ -2621,8 +2548,9 @@ var begin if (tgMonsList = nil) then tgMonsList := TSimpleMonsterList.Create(); - if gTriggers = nil then - Exit; + if gTriggers = nil then Exit; + if gLMSRespawn > LMS_RESPAWN_NONE then Exit; // don't update triggers at all + SetLength(Affected, 0); for a := 0 to High(gTriggers) do