From: TerminalHash Date: Thu, 31 Aug 2023 21:19:35 +0000 (+0300) Subject: game: added commands for randomized powerups respawn (g_rulez_time_multiplier and... X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=94590b18ecb2eeb8b0527d1eee20c7f85ada60b7;p=d2df-sdl.git game: added commands for randomized powerups respawn (g_rulez_time_multiplier and g_rulez_randomize_respawn) --- diff --git a/src/game/g_console.pas b/src/game/g_console.pas index 1caeaf8..6ff8ec3 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -1117,6 +1117,8 @@ begin AddCommand('g_warmup_time', GameCVars); AddCommand('g_spawn_invul', GameCVars); AddCommand('g_item_respawn_time', GameCVars); + AddCommand('g_rulez_randomize_respawn', GameCVars); + AddCommand('g_rulez_time_multiplier', GameCVars); AddCommand('sv_intertime', GameCVars); AddCommand('sv_name', NetServerCVars); @@ -1246,6 +1248,8 @@ begin WhitelistCommand('g_warmup_time'); WhitelistCommand('g_spawn_invul'); WhitelistCommand('g_item_respawn_time'); + WhitelistCommand('g_rulez_randomize_respawn'); + WhitelistCommand('g_rulez_time_multiplier'); g_Console_ResetBinds; g_Console_ReadConfig(gConfigScript); @@ -2234,12 +2238,14 @@ begin WriteLn(f, 'g_timelimit ', gsTimeLimit); WriteLn(f, 'g_maxlives ', gsMaxLives); WriteLn(f, 'g_item_respawn_time ', gsItemRespawnTime); + WriteLn(f, 'g_rulez_time_multiplier ', gsRulezTimeMultiplier); WriteLn(f, 'g_spawn_invul ', gsSpawnInvul); WriteLn(f, 'g_warmup_time ', gsWarmupTime); WriteFlag('g_friendlyfire ', GAME_OPTION_TEAMDAMAGE); WriteFlag('g_friendly_hit_trace ', GAME_OPTION_TEAMHITTRACE); WriteFlag('g_friendly_hit_projectile ', GAME_OPTION_TEAMHITPROJECTILE); + WriteFlag('g_rulez_randomize_respawn ', GAME_OPTION_RULEZRANDOM); WriteFlag('g_allow_exit ', GAME_OPTION_ALLOWEXIT); WriteFlag('g_allow_monsters ', GAME_OPTION_MONSTERS); WriteFlag('g_allow_dropflag ', GAME_OPTION_ALLOWDROPFLAG); diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 0cca553..303d036 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -33,6 +33,7 @@ type WarmupTime: Word; SpawnInvul: Word; ItemRespawnTime: Word; + RulezTimeMultiplier: Word; MaxLives: Byte; Options: LongWord; WAD: String; @@ -195,6 +196,7 @@ const GAME_OPTION_TEAMABSORBDAMAGE = 1024; GAME_OPTION_ALLOWDROPFLAG = 2048; GAME_OPTION_THROWFLAG = 4096; + GAME_OPTION_RULEZRANDOM = 8192; STATE_NONE = 0; STATE_MENU = 1; @@ -4495,6 +4497,7 @@ begin gGameSettings.Options := gGameSettings.Options + GAME_OPTION_BOTVSMONSTER; gGameSettings.Options := gGameSettings.Options + GAME_OPTION_TEAMHITPROJECTILE; gGameSettings.Options := gGameSettings.Options + GAME_OPTION_TEAMHITTRACE; + gGameSettings.Options := gGameSettings.Options + GAME_OPTION_RULEZRANDOM; gSwitchGameMode := GM_SINGLE; gLMSRespawn := LMS_RESPAWN_NONE; @@ -5531,6 +5534,7 @@ var a, b: Integer; stat: TPlayerStatArray; cmd: string; + it: PItem; procedure ParseGameFlag(Flag: LongWord; OffMsg, OnMsg: TStrings_Locale; OnMapChange: Boolean = False); var @@ -5610,6 +5614,10 @@ begin begin ParseGameFlag(GAME_OPTION_TEAMHITPROJECTILE, I_MSG_FRIENDLY_PROJECT_TRACE_OFF, I_MSG_FRIENDLY_PROJECT_TRACE_ON); end + else if cmd = 'g_rulez_randomize_respawn' then + begin + ParseGameFlag(GAME_OPTION_RULEZRANDOM, I_MSG_RULEZ_RANDOM_ON, I_MSG_RULEZ_RANDOM_OFF); + end else if cmd = 'g_weaponstay' then begin ParseGameFlag(GAME_OPTION_WEAPONSTAY, I_MSG_WEAPONSTAY_OFF, I_MSG_WEAPONSTAY_ON); @@ -5706,6 +5714,21 @@ begin g_Console_Add(Format('%s %d', [cmd, Integer(gsItemRespawnTime)])); if g_Game_IsServer then g_Console_Add(_lc[I_MSG_ONMAPCHANGE]); end + else if cmd = 'g_rulez_time_multiplier' then + begin + if Length(P) > 1 then + begin + gsRulezTimeMultiplier := nclamp(StrToIntDef(P[1], gsRulezTimeMultiplier), 0, $FFFF); + if g_Game_IsServer then + begin + gGameSettings.RulezTimeMultiplier := gsRulezTimeMultiplier; + if g_Game_IsNet then MH_SEND_GameSettings; + end; + end; + + g_Console_Add(Format('%s %d', [cmd, Integer(gsRulezTimeMultiplier)])); + if g_Game_IsServer then g_Console_Add(_lc[I_MSG_ONMAPCHANGE]); + end else if cmd = 'sv_intertime' then begin if (Length(P) > 1) then diff --git a/src/game/g_items.pas b/src/game/g_items.pas index a69ceaa..b0cd320 100644 --- a/src/game/g_items.pas +++ b/src/game/g_items.pas @@ -740,10 +740,19 @@ begin ggItems[ID].Obj.oldY := ggItems[ID].Obj.Y; ggItems[ID].alive := false; ggItems[ID].RespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.ItemRespawnTime, 15) * 36; + + if ((gGameSettings.Options and GAME_OPTION_RULEZRANDOM) = 0) then // Random powerup respawn + begin + if ggItems[ID].ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL, + ITEM_INVIS, ITEM_MEDKIT_BLACK, ITEM_JETPACK] then + begin + ggItems[ID].RespawnTime := Random(gGameSettings.RulezTimeMultiplier) * 36; + //e_logwritefln ('Randomized number', []); + end; + end; end; end; - procedure g_Items_Remove (ID: DWORD); var it: PItem; diff --git a/src/game/g_language.pas b/src/game/g_language.pas index 975360b..341a457 100644 --- a/src/game/g_language.pas +++ b/src/game/g_language.pas @@ -174,6 +174,8 @@ type I_MENU_ENABLE_EXITS, I_MENU_WEAPONS_STAY, I_MENU_ENABLE_MONSTERS, + I_MENU_ENABLE_RULEZ_RANDOM, + I_MENU_RULEZ_RESPAWN_MULTIPLIER, I_MENU_BOTS_VS, I_MENU_BOTS_VS_PLAYERS, I_MENU_BOTS_VS_MONSTERS, @@ -627,6 +629,8 @@ type I_MSG_SPECT_HUD_OFF, I_MSG_PING_ON, I_MSG_PING_OFF, + I_MSG_RULEZ_RANDOM_ON, + I_MSG_RULEZ_RANDOM_OFF, I_MSG_NO_WAD, I_MSG_NO_MAPS, I_MSG_NO_MAP, @@ -981,6 +985,10 @@ const 'Îðóæèå îñòà¸òñÿ:'), ('MENU ENABLE MONSTERS', 'Enable monsters:', 'Ìîíñòðû:'), + ('MENU ENABLE RULEZ RANDOM', 'Enable random powerup respawn:', + 'Ðàíäîìíûé ðåñïàóí ïîâåðàïîâ:'), + ('MENU RULEZ RESPAWN MULTIPLIER', 'Time multiplier for powerup respawn:', + 'Ìíîæèòåëü âðåìåíè äëÿ ðåñïàóíà ïîâåðàïîâ:'), ('MENU BOTS VS', 'Bots fight with:', 'Áîòû ïðîòèâ:'), ('MENU BOTS VS PLAYERS', 'Players', @@ -1847,6 +1855,10 @@ const 'Ïèíã êëèåíòà ïîêàçûâàåòñÿ'), ('MSG PING OFF', 'Client ping display off', 'Ïèíã êëèåíòà íå ïîêàçûâàåòñÿ'), + ('MSG RULEZ RANDOM ON', 'Random respawn for powerups on', + 'Ðàíäîìíûé ðåñïàóí äëÿ ïîâåðàïîâ âêëþ÷¸í'), + ('MSG RULEZ RANDOM OFF', 'Random respawn for powerups off', + 'Ðàíäîìíûé ðåñïàóí äëÿ ïîâåðàïîâ âûêëþ÷åí'), ('MSG NO WAD', 'WAD "%s" doesn''t exist!', 'WAD ôàéë "%s" íå íàéäåí!'), ('MSG NO MAPS', 'WAD "%s" doesn''t contain any maps!', diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index ff6757f..ed4e25d 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -736,6 +736,7 @@ begin gsScoreLimit := StrToIntDef(TGUIEdit(GetControl('edScoreLimit')).Text, 0); gsMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0); gsItemRespawnTime := StrToIntDef(TGUIEdit(GetControl('edItemRespawnTime')).Text, 0); + gsRulezTimeMultiplier := StrToIntDef(TGUIEdit(GetControl('edRulezTimeMultiplier')).Text, 0); gsPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex; gsMap := Map; @@ -750,6 +751,8 @@ begin gsGameFlags := gsGameFlags or GAME_OPTION_WEAPONSTAY; if TGUISwitch(GetControl('swMonsters')).ItemIndex = 0 then gsGameFlags := gsGameFlags or GAME_OPTION_MONSTERS; + if TGUISwitch(GetControl('swRulezRandom')).ItemIndex = 0 then + gsGameFlags := gsGameFlags or GAME_OPTION_RULEZRANDOM; case TGUISwitch(GetControl('swTeamHit')).ItemIndex of 1: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITTRACE; @@ -771,6 +774,7 @@ begin // TODO: get this crap out of here gGameSettings.ItemRespawnTime := gsItemRespawnTime; + gGameSettings.RulezTimeMultiplier := gsRulezTimeMultiplier; gGameSettings.WarmupTime := gsWarmupTime; gGameSettings.SpawnInvul := gsSpawnInvul; end; @@ -2325,6 +2329,15 @@ begin if gsItemRespawnTime > 0 then Text := IntToStr(gsItemRespawnTime); end; + with AddEdit(_lc[I_MENU_RULEZ_RESPAWN_MULTIPLIER]) do + begin + Name := 'edRulezTimeMultiplier'; + OnlyDigits := True; + Width := 4; + MaxLength := 5; + if gsRulezTimeMultiplier > 0 then + Text := IntToStr(gsRulezTimeMultiplier); + end; with AddSwitch(_lc[I_MENU_PLAYERS]) do begin Name := 'swPlayers'; @@ -2399,6 +2412,16 @@ begin else ItemIndex := 1; end; + with AddSwitch(_lc[I_MENU_ENABLE_RULEZ_RANDOM]) do + begin + Name := 'swRulezRandom'; + AddItem(_lc[I_MENU_NO]); + AddItem(_lc[I_MENU_YES]); + if LongBool(gsGameFlags and GAME_OPTION_RULEZRANDOM) then + ItemIndex := 0 + else + ItemIndex := 1; + end; with AddSwitch(_lc[I_MENU_BOTS_VS]) do begin Name := 'swBotsVS'; @@ -2573,6 +2596,15 @@ begin if gsItemRespawnTime > 0 then Text := IntToStr(gsItemRespawnTime); end; + with AddEdit(_lc[I_MENU_RULEZ_RESPAWN_MULTIPLIER]) do + begin + Name := 'edRulezTimeMultiplier'; + OnlyDigits := True; + Width := 4; + MaxLength := 5; + if gsRulezTimeMultiplier > 0 then + Text := IntToStr(gsRulezTimeMultiplier); + end; with AddSwitch(_lc[I_MENU_PLAYERS]) do begin Name := 'swPlayers'; @@ -2647,6 +2679,16 @@ begin else ItemIndex := 1; end; + with AddSwitch(_lc[I_MENU_ENABLE_RULEZ_RANDOM]) do + begin + Name := 'swRulezRandom'; + AddItem(_lc[I_MENU_NO]); + AddItem(_lc[I_MENU_YES]); + if LongBool(gsGameFlags and GAME_OPTION_RULEZRANDOM) then + ItemIndex := 0 + else + ItemIndex := 1; + end; with AddSwitch(_lc[I_MENU_BOTS_VS]) do begin Name := 'swBotsVS'; diff --git a/src/game/g_options.pas b/src/game/g_options.pas index ace7191..4024943 100644 --- a/src/game/g_options.pas +++ b/src/game/g_options.pas @@ -74,6 +74,7 @@ var gsGameFlags: LongWord; gsSpawnInvul: Integer = 0; gsItemRespawnTime: Word = 60; + gsRulezTimeMultiplier: Word = 60; gsWarmupTime: Word = 30; implementation @@ -267,10 +268,11 @@ begin gsPlayers := 1; gsSpawnInvul := 0; gsItemRespawnTime := 60; + gsRulezTimeMultiplier := 60; gsGameFlags := GAME_OPTION_ALLOWEXIT or GAME_OPTION_DMKEYS or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER or GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE or - GAME_OPTION_ALLOWDROPFLAG; + GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_RULEZRANDOM; gsPlayers := 1; if not gGameOn then @@ -315,6 +317,7 @@ begin MaxLives := gsMaxLives; SpawnInvul := gsSpawnInvul; ItemRespawnTime := gsItemRespawnTime; + RulezTimeMultiplier := gsRulezTimeMultiplier; WarmupTime := gsWarmupTime; Options := gsGameFlags; end;