X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_triggers.pas;h=e8891a06467dffaf806ba96cb96dabc9dbe824b1;hb=d0936017ccb8a078d1b03f55478af284bb015bbc;hp=ac5a523ff296172447c9b34579bd7cddf184aab3;hpb=5c72767aba48c236cd81972a6d79ff67b64ecd92;p=d2df-sdl.git diff --git a/src/game/g_triggers.pas b/src/game/g_triggers.pas index ac5a523..e8891a0 100644 --- a/src/game/g_triggers.pas +++ b/src/game/g_triggers.pas @@ -1,9 +1,8 @@ -(* Copyright (C) DooM 2D:Forever Developers +(* Copyright (C) Doom 2D: Forever Developers * * 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 @@ -106,7 +105,7 @@ uses Math, g_player, g_map, g_panel, g_gfx, g_game, g_textures, 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 @@ -235,7 +234,7 @@ begin if (Length(afldname) > 4) and (afldname[1] = 'u') and (afldname[2] = 's') and (afldname[3] = 'e') and (afldname[4] = 'r') then begin - if (me.userVars = nil) then me.userVars := hashNewStrVariant(); + if (me.userVars = nil) then me.userVars := THashStrVariant.Create(); me.userVars.put(afldname, aval); exit; end; @@ -592,17 +591,17 @@ begin if (gLifts[PanelID].PanelType = PANEL_LIFTUP) or (gLifts[PanelID].PanelType = PANEL_LIFTDOWN) then begin case d of - 0: t := 0; - 1: t := 1; - else t := IfThen(gLifts[PanelID].LiftType = 1, 0, 1); + 0: t := LIFTTYPE_UP; + 1: t := LIFTTYPE_DOWN; + else t := IfThen(gLifts[PanelID].LiftType = LIFTTYPE_DOWN, LIFTTYPE_UP, LIFTTYPE_DOWN); end end else if (gLifts[PanelID].PanelType = PANEL_LIFTLEFT) or (gLifts[PanelID].PanelType = PANEL_LIFTRIGHT) then begin case d of - 0: t := 2; - 1: t := 3; - else t := IfThen(gLifts[PanelID].LiftType = 2, 3, 2); + 0: t := LIFTTYPE_LEFT; + 1: t := LIFTTYPE_RIGHT; + else t := IfThen(gLifts[PanelID].LiftType = LIFTTYPE_LEFT, LIFTTYPE_RIGHT, LIFTTYPE_LEFT); end; end; @@ -806,6 +805,12 @@ begin snd := 'SOUND_WEAPON_EXPLODEBFG'; end; + TRIGGER_SHOT_FLAME: + begin + g_Weapon_flame(wx, wy, dx, dy, 0, -1, True); + snd := 'SOUND_GAME_BURNING'; + end; + else exit; end; @@ -847,7 +852,7 @@ begin dx += Random(tgcAccuracy)-Random(tgcAccuracy); dy += Random(tgcAccuracy)-Random(tgcAccuracy); - tr_SpawnShot(tgcShotType, wx, wy, dx, dy, not tgcQuiet, TargetUID); + tr_SpawnShot(tgcShotType, wx, wy, dx, dy, tgcShotSound, TargetUID); end else begin @@ -1219,7 +1224,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 @@ -1344,11 +1349,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 - g_Player_Get(ActivateUID).GetSecret(); - Inc(gCoopSecretsFound); - if g_Game_IsNet then MH_SEND_GameStats(); + MH_SEND_GameStats(); + MH_SEND_GameEvent(NET_EV_SECRET, p.UID, ''); end; end; @@ -1461,7 +1468,7 @@ begin for k := 1 to tgcMonsCount do begin if (actType = ACTIVATE_CUSTOM) and (tgcDelay > 0) then - SpawnCooldown := tgcDelay; + SpawnCooldown := -1; // Çàäåðæêà âûñòàâèòñÿ ìîíñòðîì ïðè óíè÷òîæåíèè if (tgcMax > 0) and (SpawnedCount >= tgcMax) then Break; @@ -1491,11 +1498,8 @@ begin gMonstersSpawned[High(gMonstersSpawned)] := mon.UID; end; - if tgcMax > 0 then - begin - mon.SpawnTrigger := ID; - Inc(SpawnedCount); - end; + mon.SpawnTrigger := ID; + if tgcMax > 0 then Inc(SpawnedCount); case tgcEffect of EFFECT_TELEPORT: begin @@ -1576,7 +1580,7 @@ begin for k := 1 to tgcItemCount do begin if (actType = ACTIVATE_CUSTOM) and (tgcDelay > 0) then - SpawnCooldown := tgcDelay; + SpawnCooldown := -1; // Çàäåðæêà âûñòàâèòñÿ èòåìîì ïðè óíè÷òîæåíèè if (tgcMax > 0) and (SpawnedCount >= tgcMax) then Break; @@ -1585,12 +1589,9 @@ begin Result := True; - if tgcMax > 0 then - begin - it := g_Items_ByIdx(iid); - it.SpawnTrigger := ID; - Inc(SpawnedCount); - end; + it := g_Items_ByIdx(iid); + it.SpawnTrigger := ID; + if tgcMax > 0 then Inc(SpawnedCount); case tgcEffect of EFFECT_TELEPORT: begin @@ -2101,7 +2102,14 @@ begin // Íàíîñèì óðîí èãðîêó if (TriggerType = TRIGGER_DAMAGE) and (tgcAmount > 0) then - p.Damage(tgcAmount, 0, 0, 0, HIT_SOME); + begin + // Êèñëîòíûé óðîí íå íàíîñèòñÿ êîãäà åñòü êîñòþì + // "Âîäÿíîé" óðîí íå íàíîñèòñÿ êîãäà åñòü êèñëîðîä + if not (((tgcKind = HIT_ACID) and (p.FMegaRulez[MR_SUIT] > gTime)) or + ((tgcKind = HIT_WATER) and (p.Air > 0))) then + p.Damage(tgcAmount, 0, 0, 0, tgcKind); + if (tgcKind = HIT_FLAME) then p.CatchFire(0); + end; // Ëå÷èì èãðîêà if (TriggerType = TRIGGER_HEALTH) and (tgcAmount > 0) then @@ -2121,7 +2129,10 @@ begin // Íàíîñèì óðîí ìîíñòðó if (TriggerType = TRIGGER_DAMAGE) and (tgcAmount > 0) then - m.Damage(tgcAmount, 0, 0, 0, HIT_SOME); + begin + m.Damage(tgcAmount, 0, 0, 0, tgcKind); + if (tgcKind = HIT_FLAME) then m.CatchFire(0); + end; // Ëå÷èì ìîíñòðà if (TriggerType = TRIGGER_HEALTH) and (tgcAmount > 0) then @@ -2329,7 +2340,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 @@ -2503,17 +2514,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 @@ -2539,18 +2540,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])); @@ -2605,8 +2595,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 @@ -2692,17 +2683,14 @@ begin begin if (SoundPlayCount > 0) and (not Sound.IsPlaying()) then begin - if tgcPlayCount > 0 then SoundPlayCount -= 1; // Åñëè 0 - èãðàåì çâóê áåñêîíå÷íî + if tgcPlayCount > 0 then Dec(SoundPlayCount); (* looped sound if zero *) if tgcLocal then - begin - Sound.PlayVolumeAt(X+(Width div 2), Y+(Height div 2), tgcVolume/255.0); - end + Sound.PlayVolumeAtRect(X, Y, Width, Height, tgcVolume / 255.0) else - begin - Sound.PlayPanVolume((tgcPan-127.0)/128.0, tgcVolume/255.0); - end; - if Sound.IsPlaying() and g_Game_IsNet and g_Game_IsServer then MH_SEND_TriggerSound(gTriggers[a]); - end; + Sound.PlayPanVolume((tgcPan - 127.0) / 128.0, tgcVolume / 255.0); + if Sound.IsPlaying() and g_Game_IsNet and g_Game_IsServer then + MH_SEND_TriggerSound(gTriggers[a]) + end end; // Òðèããåð "Ëîâóøêà" - ïîðà îòêðûâàòü @@ -3062,11 +3050,20 @@ end; procedure g_Triggers_DecreaseSpawner(ID: DWORD); begin if (gTriggers <> nil) then - if gTriggers[ID].SpawnedCount > 0 then - Dec(gTriggers[ID].SpawnedCount); + begin + if gTriggers[ID].tgcMax > 0 then + begin + if gTriggers[ID].SpawnedCount > 0 then + Dec(gTriggers[ID].SpawnedCount); + end; + if gTriggers[ID].tgcDelay > 0 then + begin + if gTriggers[ID].SpawnCooldown < 0 then + gTriggers[ID].SpawnCooldown := gTriggers[ID].tgcDelay; + end; + end; end; - procedure g_Triggers_Free (); var a: Integer; @@ -3337,7 +3334,7 @@ begin if (uvcount < 0) or (uvcount > 1024*1024) then raise XStreamError.Create('invalid number of user vars in trigger'); if (uvcount > 0) then begin - gTriggers[i].userVars := hashNewStrVariant(); + gTriggers[i].userVars := THashStrVariant.Create(); vv := Unassigned; while (uvcount > 0) do begin