From: TerminalHash Date: Fri, 1 Sep 2023 14:50:12 +0000 (+0300) Subject: game: improve rulez respawn timer X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=d0c37e245a31713f3207059347ded7e97dfb5564;p=d2df-sdl.git game: improve rulez respawn timer --- diff --git a/src/game/g_console.pas b/src/game/g_console.pas index febe7e9..9ea8051 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -1118,7 +1118,8 @@ begin AddCommand('g_spawn_invul', GameCVars); AddCommand('g_item_respawn_time', GameCVars); AddCommand('g_powerup_randomize_respawn', GameCVars); - AddCommand('g_powerup_time_multiplier', GameCVars); + AddCommand('g_powerup_respawn_time', GameCVars); + AddCommand('g_powerup_time_random', GameCVars); AddCommand('sv_intertime', GameCVars); AddCommand('sv_name', NetServerCVars); @@ -1249,7 +1250,8 @@ begin WhitelistCommand('g_spawn_invul'); WhitelistCommand('g_item_respawn_time'); WhitelistCommand('g_powerup_randomize_respawn'); - WhitelistCommand('g_powerup_time_multiplier'); + WhitelistCommand('g_powerup_respawn_time'); + WhitelistCommand('g_powerup_time_random'); g_Console_ResetBinds; g_Console_ReadConfig(gConfigScript); @@ -2238,7 +2240,8 @@ begin WriteLn(f, 'g_timelimit ', gsTimeLimit); WriteLn(f, 'g_maxlives ', gsMaxLives); WriteLn(f, 'g_item_respawn_time ', gsItemRespawnTime); - WriteLn(f, 'g_powerup_time_multiplier ', gsRulezTimeMultiplier); + WriteLn(f, 'g_powerup_respawn_time ', gsRulezRespawnTime); + WriteLn(f, 'g_powerup_time_random ', gsRulezRespawnRandom); WriteLn(f, 'g_spawn_invul ', gsSpawnInvul); WriteLn(f, 'g_warmup_time ', gsWarmupTime); diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 7c499d4..9f399b6 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -33,7 +33,8 @@ type WarmupTime: Word; SpawnInvul: Word; ItemRespawnTime: Word; - RulezTimeMultiplier: Word; + RulezRespawnTime: Word; + RulezRespawnRandom: Word; MaxLives: Byte; Options: LongWord; WAD: String; @@ -5714,19 +5715,34 @@ 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_powerup_time_multiplier' then + else if cmd = 'g_powerup_respawn_time' then begin if Length(P) > 1 then begin - gsRulezTimeMultiplier := nclamp(StrToIntDef(P[1], gsRulezTimeMultiplier), 0, $FFFF); + gsRulezRespawnTime := nclamp(StrToIntDef(P[1], gsRulezRespawnTime), 0, $FFFF); if g_Game_IsServer then begin - gGameSettings.RulezTimeMultiplier := gsRulezTimeMultiplier; + gGameSettings.RulezRespawnTime := gsRulezRespawnTime; if g_Game_IsNet then MH_SEND_GameSettings; end; end; - g_Console_Add(Format('%s %d', [cmd, Integer(gsRulezTimeMultiplier)])); + g_Console_Add(Format('%s %d', [cmd, Integer(gsRulezRespawnTime)])); + if g_Game_IsServer then g_Console_Add(_lc[I_MSG_ONMAPCHANGE]); + end + else if cmd = 'g_powerup_time_random' then + begin + if Length(P) > 1 then + begin + gsRulezRespawnRandom := nclamp(StrToIntDef(P[1], gsRulezRespawnRandom), 0, $FFFF); + if g_Game_IsServer then + begin + gGameSettings.RulezRespawnRandom := gsRulezRespawnRandom; + if g_Game_IsNet then MH_SEND_GameSettings; + end; + end; + + g_Console_Add(Format('%s %d', [cmd, Integer(gsRulezRespawnRandom)])); if g_Game_IsServer then g_Console_Add(_lc[I_MSG_ONMAPCHANGE]); end else if cmd = 'sv_intertime' then diff --git a/src/game/g_items.pas b/src/game/g_items.pas index a7cbe4a..30e8db9 100644 --- a/src/game/g_items.pas +++ b/src/game/g_items.pas @@ -546,13 +546,14 @@ var i, j, k: Integer; ID: DWord; Anim: TAnimation; - m, ItemRespawnTime: Word; + m, ItemRespawnTime, RulezRespawnTime: Word; r, nxt: Boolean; begin if (ggItems = nil) then exit; // respawn items in 15 seconds regardless of settings during warmup ItemRespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.ItemRespawnTime, 15); + RulezRespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.RulezRespawnTime, 15); for i := 0 to High(ggItems) do begin @@ -739,15 +740,24 @@ begin ggItems[ID].Obj.oldX := ggItems[ID].Obj.X; ggItems[ID].Obj.oldY := ggItems[ID].Obj.Y; ggItems[ID].alive := false; + + // Items respawn timer ggItems[ID].RespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.ItemRespawnTime, 15) * 36; + // Rulez respawn timer + if ggItems[ID].ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL, + ITEM_INVIS, ITEM_MEDKIT_BLACK, ITEM_JETPACK, ITEM_SUIT] then + begin + ggItems[ID].RespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.RulezRespawnTime, 15) * 36; + end; + if LongBool(gGameSettings.Options and GAME_OPTION_RULEZRANDOM) 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, ITEM_SUIT] then + ITEM_INVIS, ITEM_MEDKIT_BLACK, ITEM_JETPACK, ITEM_SUIT] then begin - ggItems[ID].RespawnTime := Random(gGameSettings.RulezTimeMultiplier) * 36; - e_logwritefln ('Randomized number', []); + ggItems[ID].RespawnTime := Max(1, (gGameSettings.RulezRespawnTime + RandomRange(-gGameSettings.RulezRespawnRandom, gGameSettings.RulezRespawnRandom + 1)) * 36); + //e_logwritefln ('Randomized number: %s', [ggItems[ID].RespawnTime]); end; end; end; diff --git a/src/game/g_language.pas b/src/game/g_language.pas index 22b589a..1d67347 100644 --- a/src/game/g_language.pas +++ b/src/game/g_language.pas @@ -176,7 +176,8 @@ type I_MENU_ENABLE_TEAM_DAMAGE_ABSOBR, I_MENU_ENABLE_MONSTERS, I_MENU_ENABLE_RULEZ_RANDOM, - I_MENU_RULEZ_RESPAWN_MULTIPLIER, + I_MENU_RULEZ_RESPAWN_TIME, + I_MENU_RULEZ_RESPAWN_RANDOM, I_MENU_BOTS_VS, I_MENU_BOTS_VS_PLAYERS, I_MENU_BOTS_VS_MONSTERS, @@ -990,8 +991,10 @@ const 'Ìîíñòðû:'), ('MENU ENABLE RULEZ RANDOM', 'Enable random powerup respawn:', 'Ðàíäîìíûé ðåñïàóí ïîâåðàïîâ:'), - ('MENU RULEZ RESPAWN MULTIPLIER', 'Time multiplier for powerup respawn:', - 'Ìíîæèòåëü âðåìåíè äëÿ ðåñïàóíà ïîâåðàïîâ:'), + ('MENU RULEZ RESPAWN TIME', 'Powerup respawn time:', + 'Âðåìÿ ðåñïàóíà ïîâåðàïîâ:'), + ('MENU RULEZ RESPAWN RANDOM', 'Additive time for powerup timer:', + 'Äîïîëíèòåëüíîå ÷èñëî ê òàéìåðó ïàâåðàïîâ:'), ('MENU BOTS VS', 'Bots fight with:', 'Áîòû ïðîòèâ:'), ('MENU BOTS VS PLAYERS', 'Players', diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index b4a4dfd..d9a8c6d 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -736,7 +736,8 @@ 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); + gsRulezRespawnTime := StrToIntDef(TGUIEdit(GetControl('edRulezRespawnTime')).Text, 0); + gsRulezRespawnRandom := StrToIntDef(TGUIEdit(GetControl('edRulezRespawnRandom')).Text, 0); gsPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex; gsMap := Map; @@ -776,7 +777,8 @@ begin // TODO: get this crap out of here gGameSettings.ItemRespawnTime := gsItemRespawnTime; - gGameSettings.RulezTimeMultiplier := gsRulezTimeMultiplier; + gGameSettings.RulezRespawnTime := gsRulezRespawnTime; + gGameSettings.RulezRespawnRandom := gsRulezRespawnRandom; gGameSettings.WarmupTime := gsWarmupTime; gGameSettings.SpawnInvul := gsSpawnInvul; end; @@ -2331,15 +2333,36 @@ begin if gsItemRespawnTime > 0 then Text := IntToStr(gsItemRespawnTime); end; - with AddEdit(_lc[I_MENU_RULEZ_RESPAWN_MULTIPLIER]) do + AddSpace(); // Rulez Respawn block + with AddEdit(_lc[I_MENU_RULEZ_RESPAWN_TIME]) do begin - Name := 'edRulezTimeMultiplier'; + Name := 'edRulezRespawnTime'; OnlyDigits := True; Width := 4; MaxLength := 5; - if gsRulezTimeMultiplier > 0 then - Text := IntToStr(gsRulezTimeMultiplier); + if gsRulezRespawnTime > 0 then + Text := IntToStr(gsRulezRespawnTime); end; + with AddEdit(_lc[I_MENU_RULEZ_RESPAWN_RANDOM]) do + begin + Name := 'edRulezRespawnRandom'; + OnlyDigits := True; + Width := 4; + MaxLength := 5; + if gsRulezRespawnRandom > 0 then + Text := IntToStr(gsRulezRespawnRandom); + end; + with AddSwitch(_lc[I_MENU_ENABLE_RULEZ_RANDOM]) do + begin + Name := 'swRulezRandom'; + AddItem(_lc[I_MENU_YES]); + AddItem(_lc[I_MENU_NO]); + if LongBool(gsGameFlags and GAME_OPTION_RULEZRANDOM) then + ItemIndex := 0 + else + ItemIndex := 1; + end; + AddSpace(); with AddSwitch(_lc[I_MENU_PLAYERS]) do begin Name := 'swPlayers'; @@ -2424,16 +2447,6 @@ begin else ItemIndex := 1; end; - with AddSwitch(_lc[I_MENU_ENABLE_RULEZ_RANDOM]) do - begin - Name := 'swRulezRandom'; - AddItem(_lc[I_MENU_YES]); - AddItem(_lc[I_MENU_NO]); - 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'; @@ -2608,15 +2621,36 @@ begin if gsItemRespawnTime > 0 then Text := IntToStr(gsItemRespawnTime); end; - with AddEdit(_lc[I_MENU_RULEZ_RESPAWN_MULTIPLIER]) do + AddSpace(); // Rulez Respawn block + with AddEdit(_lc[I_MENU_RULEZ_RESPAWN_TIME]) do begin - Name := 'edRulezTimeMultiplier'; + Name := 'edRulezRespawnTime'; OnlyDigits := True; Width := 4; MaxLength := 5; - if gsRulezTimeMultiplier > 0 then - Text := IntToStr(gsRulezTimeMultiplier); + if gsRulezRespawnTime > 0 then + Text := IntToStr(gsRulezRespawnTime); end; + with AddEdit(_lc[I_MENU_RULEZ_RESPAWN_RANDOM]) do + begin + Name := 'edRulezRespawnRandom'; + OnlyDigits := True; + Width := 4; + MaxLength := 5; + if gsRulezRespawnRandom > 0 then + Text := IntToStr(gsRulezRespawnRandom); + end; + with AddSwitch(_lc[I_MENU_ENABLE_RULEZ_RANDOM]) do + begin + Name := 'swRulezRandom'; + AddItem(_lc[I_MENU_YES]); + AddItem(_lc[I_MENU_NO]); + if LongBool(gsGameFlags and GAME_OPTION_RULEZRANDOM) then + ItemIndex := 0 + else + ItemIndex := 1; + end; + AddSpace(); with AddSwitch(_lc[I_MENU_PLAYERS]) do begin Name := 'swPlayers'; @@ -2701,16 +2735,6 @@ begin else ItemIndex := 1; end; - with AddSwitch(_lc[I_MENU_ENABLE_RULEZ_RANDOM]) do - begin - Name := 'swRulezRandom'; - AddItem(_lc[I_MENU_YES]); - AddItem(_lc[I_MENU_NO]); - 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 4024943..b015319 100644 --- a/src/game/g_options.pas +++ b/src/game/g_options.pas @@ -74,7 +74,8 @@ var gsGameFlags: LongWord; gsSpawnInvul: Integer = 0; gsItemRespawnTime: Word = 60; - gsRulezTimeMultiplier: Word = 60; + gsRulezRespawnTime: Word = 60; + gsRulezRespawnRandom: Word = 0; gsWarmupTime: Word = 30; implementation @@ -268,7 +269,8 @@ begin gsPlayers := 1; gsSpawnInvul := 0; gsItemRespawnTime := 60; - gsRulezTimeMultiplier := 60; + gsRulezRespawnTime := 60; + gsRulezRespawnRandom := 0; 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 @@ -317,7 +319,8 @@ begin MaxLives := gsMaxLives; SpawnInvul := gsSpawnInvul; ItemRespawnTime := gsItemRespawnTime; - RulezTimeMultiplier := gsRulezTimeMultiplier; + RulezRespawnTime := gsRulezRespawnTime; + RulezRespawnRandom := gsRulezRespawnRandom; WarmupTime := gsWarmupTime; Options := gsGameFlags; end;