index af000f0dda34bff1a628859e0ba878dd6d129ad0..2509650d413b5ccc9af45f390ad91339bd4a30ad 100644 (file)
--- a/src/game/g_triggers.pas
+++ b/src/game/g_triggers.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
- * 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
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, g_main, e_log, g_language, e_res,
g_options, g_net, g_netmsg, utils, xparser, xstreams;
const
TRIGGER_SHOT_IMP:
begin
- g_Weapon_ball1(wx, wy, dx, dy, 0, -1, True);
+ g_Weapon_ball1(wx, wy, dx, dy, 0, -1, True, False);
snd := 'SOUND_WEAPON_FIREBALL';
end;
TRIGGER_SHOT_PLASMA:
begin
- g_Weapon_Plasma(wx, wy, dx, dy, 0, -1, True);
+ g_Weapon_Plasma(wx, wy, dx, dy, 0, -1, True, False);
snd := 'SOUND_WEAPON_FIREPLASMA';
end;
TRIGGER_SHOT_SPIDER:
begin
- g_Weapon_aplasma(wx, wy, dx, dy, 0, -1, True);
+ g_Weapon_aplasma(wx, wy, dx, dy, 0, -1, True, False);
snd := 'SOUND_WEAPON_FIREPLASMA';
end;
TRIGGER_SHOT_CACO:
begin
- g_Weapon_ball2(wx, wy, dx, dy, 0, -1, True);
+ g_Weapon_ball2(wx, wy, dx, dy, 0, -1, True, False);
snd := 'SOUND_WEAPON_FIREBALL';
end;
TRIGGER_SHOT_BARON:
begin
- g_Weapon_ball7(wx, wy, dx, dy, 0, -1, True);
+ g_Weapon_ball7(wx, wy, dx, dy, 0, -1, True, False);
snd := 'SOUND_WEAPON_FIREBALL';
end;
TRIGGER_SHOT_MANCUB:
begin
- g_Weapon_manfire(wx, wy, dx, dy, 0, -1, True);
+ g_Weapon_manfire(wx, wy, dx, dy, 0, -1, True, False);
snd := 'SOUND_WEAPON_FIREBALL';
end;
TRIGGER_SHOT_ROCKET:
begin
- g_Weapon_Rocket(wx, wy, dx, dy, 0, -1, True);
+ g_Weapon_Rocket(wx, wy, dx, dy, 0, -1, True, False);
snd := 'SOUND_WEAPON_FIREROCKET';
end;
TRIGGER_SHOT_BFG:
begin
- g_Weapon_BFGShot(wx, wy, dx, dy, 0, -1, True);
+ g_Weapon_BFGShot(wx, wy, dx, dy, 0, -1, True, False);
snd := 'SOUND_WEAPON_FIREBFG';
end;
TRIGGER_SHOT_FLAME:
begin
- g_Weapon_flame(wx, wy, dx, dy, 0, -1, True);
+ g_Weapon_flame(wx, wy, dx, dy, 0, -1, True, False);
snd := 'SOUND_GAME_BURNING';
end;
TRIGGER_EFFECT_DLIQUID: g_GFX_SimpleWater(X, Y, 1, VX, VY, 5, CR, CG, CB);
TRIGGER_EFFECT_BLOOD: g_GFX_Blood(X, Y, 1, VX, VY, 0, 0, CR, CG, CB);
TRIGGER_EFFECT_SPARK: g_GFX_Spark(X, Y, 1, GetAngle2(VX, VY), 0, 0);
- TRIGGER_EFFECT_BUBBLE: g_GFX_Bubbles(X, Y, 1, 0, 0);
+ TRIGGER_EFFECT_BUBBLE:
+ begin
+ g_GFX_Bubbles(X, Y, 1, 0, 0);
+ if not Silent then if Random(2) = 0
+ then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', X, Y)
+ else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', X, Y);
+ end;
end;
end;
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
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, '', p.FClientID);
- end;
+ MH_SEND_GameStats();
+ MH_SEND_GameEvent(NET_EV_SECRET, p.UID, '');
end;
end;
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;
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
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;
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
if ((tgcScoreAction = TRIGGER_SCORE_ACTION_ADD) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_RED))
or ((tgcScoreAction = TRIGGER_SCORE_ACTION_ADD) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_BLUE)) then
begin
- Inc(gTeamStat[TEAM_RED].Goals, tgcScoreCount); // Red Scores
+ Inc(gTeamStat[TEAM_RED].Score, tgcScoreCount); // Red Scores
if tgcScoreCon then
begin
if ((tgcScoreAction = TRIGGER_SCORE_ACTION_SUB) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_RED))
or ((tgcScoreAction = TRIGGER_SCORE_ACTION_SUB) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_BLUE)) then
begin
- Dec(gTeamStat[TEAM_RED].Goals, tgcScoreCount); // Red Fouls
+ Dec(gTeamStat[TEAM_RED].Score, tgcScoreCount); // Red Fouls
if tgcScoreCon then
begin
if ((tgcScoreAction = TRIGGER_SCORE_ACTION_ADD) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_BLUE))
or ((tgcScoreAction = TRIGGER_SCORE_ACTION_ADD) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_RED)) then
begin
- Inc(gTeamStat[TEAM_BLUE].Goals, tgcScoreCount); // Blue Scores
+ Inc(gTeamStat[TEAM_BLUE].Score, tgcScoreCount); // Blue Scores
if tgcScoreCon then
begin
if ((tgcScoreAction = TRIGGER_SCORE_ACTION_SUB) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_BLUE))
or ((tgcScoreAction = TRIGGER_SCORE_ACTION_SUB) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_RED)) then
begin
- Dec(gTeamStat[TEAM_BLUE].Goals, tgcScoreCount); // Blue Fouls
+ Dec(gTeamStat[TEAM_BLUE].Score, tgcScoreCount); // Blue Fouls
if tgcScoreCon then
begin
begin
if (tgcScoreAction = TRIGGER_SCORE_ACTION_ADD) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_RED) then
begin
- Inc(gTeamStat[TEAM_RED].Goals, tgcScoreCount); // Red Scores
+ Inc(gTeamStat[TEAM_RED].Score, tgcScoreCount); // Red Scores
if tgcScoreCon then
begin
end;
if (tgcScoreAction = TRIGGER_SCORE_ACTION_SUB) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_RED) then
begin
- Dec(gTeamStat[TEAM_RED].Goals, tgcScoreCount); // Red Fouls
+ Dec(gTeamStat[TEAM_RED].Score, tgcScoreCount); // Red Fouls
if tgcScoreCon then
begin
end;
if (tgcScoreAction = TRIGGER_SCORE_ACTION_ADD) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_BLUE) then
begin
- Inc(gTeamStat[TEAM_BLUE].Goals, tgcScoreCount); // Blue Scores
+ Inc(gTeamStat[TEAM_BLUE].Score, tgcScoreCount); // Blue Scores
if tgcScoreCon then
begin
end;
if (tgcScoreAction = TRIGGER_SCORE_ACTION_SUB) and (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_BLUE) then
begin
- Dec(gTeamStat[TEAM_BLUE].Goals, tgcScoreCount); // Blue Fouls
+ Dec(gTeamStat[TEAM_BLUE].Score, tgcScoreCount); // Blue Fouls
if tgcScoreCon then
begin
end;
end;
// Âûèãðûø
- if (tgcScoreAction = TRIGGER_SCORE_ACTION_WIN) and (gGameSettings.GoalLimit > 0) then
+ if (tgcScoreAction = TRIGGER_SCORE_ACTION_WIN) and (gGameSettings.ScoreLimit > 0) then
begin
// Ñâîåé èëè ÷óæîé êîìàíäû
if (tgcScoreTeam in [TRIGGER_SCORE_TEAM_MINE_RED, TRIGGER_SCORE_TEAM_MINE_BLUE]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
if ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_RED)) // Red Wins
or ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_BLUE)) then
begin
- if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
+ if gTeamStat[TEAM_RED].Score < SmallInt(gGameSettings.ScoreLimit) then
begin
- gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
+ gTeamStat[TEAM_RED].Score := gGameSettings.ScoreLimit;
if tgcScoreCon then
begin
if ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_BLUE)) // Blue Wins
or ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_RED)) then
begin
- if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
+ if gTeamStat[TEAM_BLUE].Score < SmallInt(gGameSettings.ScoreLimit) then
begin
- gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
+ gTeamStat[TEAM_BLUE].Score := gGameSettings.ScoreLimit;
if tgcScoreCon then
begin
begin
if (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_RED) then // Red Wins
begin
- if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
+ if gTeamStat[TEAM_RED].Score < SmallInt(gGameSettings.ScoreLimit) then
begin
- gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
+ gTeamStat[TEAM_RED].Score := gGameSettings.ScoreLimit;
Result := True;
end;
end;
if (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_BLUE) then // Blue Wins
begin
- if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
+ if gTeamStat[TEAM_BLUE].Score < SmallInt(gGameSettings.ScoreLimit) then
begin
- gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
+ gTeamStat[TEAM_BLUE].Score := gGameSettings.ScoreLimit;
Result := True;
end;
end;
end;
end;
// Ïðîèãðûø
- if (tgcScoreAction = TRIGGER_SCORE_ACTION_LOOSE) and (gGameSettings.GoalLimit > 0) then
+ if (tgcScoreAction = TRIGGER_SCORE_ACTION_LOOSE) and (gGameSettings.ScoreLimit > 0) then
begin
// Ñâîåé èëè ÷óæîé êîìàíäû
if (tgcScoreTeam in [TRIGGER_SCORE_TEAM_MINE_RED, TRIGGER_SCORE_TEAM_MINE_BLUE]) and (g_GetUIDType(ActivateUID) = UID_PLAYER) then
p := g_Player_Get(ActivateUID);
if ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_BLUE)) // Red Wins
or ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_RED)) then
- if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
+ if gTeamStat[TEAM_RED].Score < SmallInt(gGameSettings.ScoreLimit) then
begin
- gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
+ gTeamStat[TEAM_RED].Score := gGameSettings.ScoreLimit;
if tgcScoreCon then
if tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED then
end;
if ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED) and (p.Team = TEAM_RED)) // Blue Wins
or ((tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_BLUE) and (p.Team = TEAM_BLUE)) then
- if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
+ if gTeamStat[TEAM_BLUE].Score < SmallInt(gGameSettings.ScoreLimit) then
begin
- gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
+ gTeamStat[TEAM_BLUE].Score := gGameSettings.ScoreLimit;
if tgcScoreCon then
if tgcScoreTeam = TRIGGER_SCORE_TEAM_MINE_RED then
begin
if (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_BLUE) then // Red Wins
begin
- if gTeamStat[TEAM_RED].Goals < SmallInt(gGameSettings.GoalLimit) then
+ if gTeamStat[TEAM_RED].Score < SmallInt(gGameSettings.ScoreLimit) then
begin
- gTeamStat[TEAM_RED].Goals := gGameSettings.GoalLimit;
+ gTeamStat[TEAM_RED].Score := gGameSettings.ScoreLimit;
Result := True;
end;
end;
if (tgcScoreTeam = TRIGGER_SCORE_TEAM_FORCE_RED) then // Blue Wins
begin
- if gTeamStat[TEAM_BLUE].Goals < SmallInt(gGameSettings.GoalLimit) then
+ if gTeamStat[TEAM_BLUE].Score < SmallInt(gGameSettings.ScoreLimit) then
begin
- gTeamStat[TEAM_BLUE].Goals := gGameSettings.GoalLimit;
+ gTeamStat[TEAM_BLUE].Score := gGameSettings.ScoreLimit;
Result := True;
end;
end;
// Íàíîñèì óðîí èãðîêó
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
// Íàíîñèì óðîí ìîíñòðó
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
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
// Åùå íåò òàêîãî çâóêà
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
// Åùå íåò òàêîé ìóçûêè
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]));
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
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;
// Òðèããåð "Ëîâóøêà" - ïîðà îòêðûâàòü
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;