X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_game.pas;h=e79845b5c88d12ebf3323269822cc25dacf81065;hb=847038a14751d192fcc4af172d7a963e28144c72;hp=8e3f80845b6be7acf54a4a67544da68c3b1e0c19;hpb=a64e75f513d36924da087b8d68d725918b2639f8;p=d2df-sdl.git diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 8e3f808..e79845b 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -176,14 +176,17 @@ const EXIT_ENDLEVELSINGLE = 4; EXIT_ENDLEVELCUSTOM = 5; - GAME_OPTION_RESERVED = 1; - GAME_OPTION_TEAMDAMAGE = 2; - GAME_OPTION_ALLOWEXIT = 4; - GAME_OPTION_WEAPONSTAY = 8; - GAME_OPTION_MONSTERS = 16; - GAME_OPTION_BOTVSPLAYER = 32; - GAME_OPTION_BOTVSMONSTER = 64; - GAME_OPTION_DMKEYS = 128; + GAME_OPTION_RESERVED = 1; + GAME_OPTION_TEAMDAMAGE = 2; + GAME_OPTION_ALLOWEXIT = 4; + GAME_OPTION_WEAPONSTAY = 8; + GAME_OPTION_MONSTERS = 16; + GAME_OPTION_BOTVSPLAYER = 32; + GAME_OPTION_BOTVSMONSTER = 64; + GAME_OPTION_DMKEYS = 128; + GAME_OPTION_TEAMHITTRACE = 256; + GAME_OPTION_TEAMHITPROJECTILE = 512; + GAME_OPTION_TEAMABSORBDAMAGE = 1024; STATE_NONE = 0; STATE_MENU = 1; @@ -337,6 +340,7 @@ var gDelayedEvents: Array of TDelayedEvent; gUseChatSounds: Boolean = True; gChatSounds: Array of TChatSound; + gWeaponAction: Array [0..1, WP_FACT..WP_LACT] of Boolean; // [player, weapon_action] gSelectWeapon: Array [0..1, WP_FIRST..WP_LAST] of Boolean; // [player, weapon] gInterReadyCount: Integer = 0; @@ -1687,12 +1691,16 @@ begin if gPlayerAction[p, ACTION_LOOKUP] then plr.PressKey(KEY_UP, time); if gPlayerAction[p, ACTION_LOOKDOWN] then plr.PressKey(KEY_DOWN, time); if gPlayerAction[p, ACTION_ATTACK] then plr.PressKey(KEY_FIRE); - if gPlayerAction[p, ACTION_WEAPNEXT] then plr.PressKey(KEY_NEXTWEAPON); - if gPlayerAction[p, ACTION_WEAPPREV] then plr.PressKey(KEY_PREVWEAPON); if gPlayerAction[p, ACTION_ACTIVATE] then plr.PressKey(KEY_OPEN); - gPlayerAction[p, ACTION_WEAPNEXT] := False; // HACK, remove after readyweaon&pendinweapon implementation - gPlayerAction[p, ACTION_WEAPPREV] := False; // HACK, remove after readyweaon&pendinweapon implementation + for i := WP_FACT to WP_LACT do + begin + if gWeaponAction[p, i] then + begin + plr.ProcessWeaponAction(i); + gWeaponAction[p, i] := False + end + end; for i := WP_FIRST to WP_LAST do begin @@ -2053,17 +2061,17 @@ begin gSpectY := Max(gSpectY - gSpectStep, 0); if gPlayerAction[0, ACTION_LOOKDOWN] then gSpectY := Min(gSpectY + gSpectStep, gMapInfo.Height - gScreenHeight); - if gPlayerAction[0, ACTION_WEAPPREV] then + if gWeaponAction[0, WP_PREV] then begin // decrease step if gSpectStep > 4 then gSpectStep := gSpectStep shr 1; - gSpectKeyPress := True; + gWeaponAction[0, WP_PREV] := False; end; - if gPlayerAction[0, ACTION_WEAPNEXT] then + if gWeaponAction[0, WP_NEXT] then begin // increase step if gSpectStep < 64 then gSpectStep := gSpectStep shl 1; - gSpectKeyPress := True; + gWeaponAction[0, WP_NEXT] := False; end; end; if (gSpectMode = SPECT_PLAYERS) @@ -2093,17 +2101,17 @@ begin gSpectPID1 := GetActivePlayerID_Next(gSpectPID1); gSpectKeyPress := True; end; - if gPlayerAction[0, ACTION_WEAPPREV] then + if gWeaponAction[0, WP_PREV] then begin // prev player (view 2) gSpectPID2 := GetActivePlayerID_Prev(gSpectPID2); - gSpectKeyPress := True; + gWeaponAction[0, WP_PREV] := False; end; - if gPlayerAction[0, ACTION_WEAPNEXT] then + if gWeaponAction[0, WP_NEXT] then begin // next player (view 2) gSpectPID2 := GetActivePlayerID_Next(gSpectPID2); - gSpectKeyPress := True; + gWeaponAction[0, WP_NEXT] := False; end; end; if gPlayerAction[0, ACTION_ATTACK] then @@ -2130,9 +2138,7 @@ begin (not gPlayerAction[0, ACTION_MOVELEFT]) and (not gPlayerAction[0, ACTION_MOVERIGHT]) and (not gPlayerAction[0, ACTION_LOOKUP]) and - (not gPlayerAction[0, ACTION_LOOKDOWN]) and - (not gPlayerAction[0, ACTION_WEAPPREV]) and - (not gPlayerAction[0, ACTION_WEAPNEXT]) then + (not gPlayerAction[0, ACTION_LOOKDOWN]) then gSpectKeyPress := False; if gSpectAuto then @@ -3998,7 +4004,8 @@ begin Round(gScreenHeight / 2.75)-(h div 2), MessageText); end; - if IsDrawStat or (gSpectMode = 1) then DrawStat(); + if IsDrawStat or (gSpectMode = SPECT_STATS) then + DrawStat(); if gSpectHUD and (not gChatShow) and (gSpectMode <> SPECT_NONE) and (not gSpectAuto) then begin @@ -4436,6 +4443,8 @@ begin gGameSettings.Options := gGameSettings.Options + GAME_OPTION_ALLOWEXIT; gGameSettings.Options := gGameSettings.Options + GAME_OPTION_MONSTERS; gGameSettings.Options := gGameSettings.Options + GAME_OPTION_BOTVSMONSTER; + gGameSettings.Options := gGameSettings.Options + GAME_OPTION_TEAMHITPROJECTILE; + gGameSettings.Options := gGameSettings.Options + GAME_OPTION_TEAMHITTRACE; gSwitchGameMode := GM_SINGLE; gLMSRespawn := LMS_RESPAWN_NONE; @@ -5509,6 +5518,18 @@ begin begin ParseGameFlag(GAME_OPTION_TEAMDAMAGE, I_MSG_FRIENDLY_FIRE_OFF, I_MSG_FRIENDLY_FIRE_ON); end + else if cmd = 'g_friendly_absorb_damage' then + begin + ParseGameFlag(GAME_OPTION_TEAMABSORBDAMAGE, I_MSG_FRIENDLY_ABSORB_DAMAGE_OFF, I_MSG_FRIENDLY_ABSORB_DAMAGE_ON); + end + else if cmd = 'g_friendly_hit_trace' then + begin + ParseGameFlag(GAME_OPTION_TEAMHITTRACE, I_MSG_FRIENDLY_HIT_TRACE_OFF, I_MSG_FRIENDLY_HIT_TRACE_ON); + end + else if cmd = 'g_friendly_hit_projectile' then + begin + ParseGameFlag(GAME_OPTION_TEAMHITPROJECTILE, I_MSG_FRIENDLY_PROJECT_TRACE_OFF, I_MSG_FRIENDLY_PROJECT_TRACE_ON); + end else if cmd = 'g_weaponstay' then begin ParseGameFlag(GAME_OPTION_WEAPONSTAY, I_MSG_WEAPONSTAY_OFF, I_MSG_WEAPONSTAY_ON); @@ -5733,6 +5754,17 @@ end; procedure PlayerSettingsCVars(P: SSArray); var cmd: string; + team: Byte; + + function ParseTeam(s: string): Byte; + begin + result := 0; + case s of + 'red', '1': result := TEAM_RED; + 'blue', '2': result := TEAM_BLUE; + else result := TEAM_NONE; + end; + end; begin cmd := LowerCase(P[0]); case cmd of @@ -5826,6 +5858,34 @@ begin end; end; end; + 'p1_team': + begin + // TODO: switch teams if in game or store this separately + if (Length(P) > 1) then + begin + team := ParseTeam(P[1]); + if team = TEAM_NONE then + g_Console_Add('expected ''red'', ''blue'', 1 or 2') + else if not gGameOn and not g_Game_IsNet then + gPlayer1Settings.Team := team + else + g_Console_Add(_lc[I_MSG_ONMAPCHANGE]); + end; + end; + 'p2_team': + begin + // TODO: switch teams if in game or store this separately + if (Length(P) > 1) then + begin + team := ParseTeam(P[1]); + if team = TEAM_NONE then + g_Console_Add('expected ''red'', ''blue'', 1 or 2') + else if not gGameOn and not g_Game_IsNet then + gPlayer2Settings.Team := team + else + g_Console_Add(_lc[I_MSG_ONMAPCHANGE]); + end; + end; end; end; @@ -7138,6 +7198,14 @@ begin begin g_TakeScreenShot() end + else if (cmd = 'weapnext') or (cmd = 'weapprev') then + begin + a := 1 - (ord(cmd[5]) - ord('n')); + if a = -1 then + gWeaponAction[0, WP_PREV] := True; + if a = 1 then + gWeaponAction[0, WP_NEXT] := True; + end else if cmd = 'weapon' then begin if Length(p) = 2 then @@ -7147,6 +7215,16 @@ begin gSelectWeapon[0, a] := True end end + else if (cmd = 'p1_weapnext') or (cmd = 'p1_weapprev') + or (cmd = 'p2_weapnext') or (cmd = 'p2_weapprev') then + begin + a := 1 - (ord(cmd[8]) - ord('n')); + b := ord(cmd[2]) - ord('1'); + if a = -1 then + gWeaponAction[b, WP_PREV] := True; + if a = 1 then + gWeaponAction[b, WP_NEXT] := True; + end else if (cmd = 'p1_weapon') or (cmd = 'p2_weapon') then begin if Length(p) = 2 then