From: fgsfds Date: Sun, 9 Feb 2020 02:17:27 +0000 (+0300) Subject: add 'respawn items' flag X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=commitdiff_plain;h=6f5375e6179294fde838bcf61f0dafeb4e018ee7 add 'respawn items' flag --- diff --git a/src/game/g_game.pas b/src/game/g_game.pas index cf87c94..0d31e22 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -180,6 +180,7 @@ const GAME_OPTION_BOTVSPLAYER = 32; GAME_OPTION_BOTVSMONSTER = 64; GAME_OPTION_DMKEYS = 128; + GAME_OPTION_RESPAWNITEMS = 256; STATE_NONE = 0; STATE_MENU = 1; @@ -5572,7 +5573,27 @@ begin g_Console_Add(_lc[I_MSG_DMKEYS_ON]) else g_Console_Add(_lc[I_MSG_DMKEYS_OFF]); - g_Console_Add(_lc[I_MSG_ONMAPCHANGE]); + + if g_Game_IsNet then MH_SEND_GameSettings; + end; + end + else if (cmd = 'g_respawn_items') and not g_Game_IsClient then + begin + with gGameSettings do + begin + if (Length(P) > 1) and + ((P[1] = '1') or (P[1] = '0')) then + begin + if (P[1][1] = '1') then + Options := Options or GAME_OPTION_RESPAWNITEMS + else + Options := Options and (not GAME_OPTION_RESPAWNITEMS); + end; + + if (LongBool(Options and GAME_OPTION_RESPAWNITEMS)) then + g_Console_Add(_lc[I_MSG_RESPAWNITEMS_ON]) + else + g_Console_Add(_lc[I_MSG_RESPAWNITEMS_OFF]); if g_Game_IsNet then MH_SEND_GameSettings; end; diff --git a/src/game/g_items.pas b/src/game/g_items.pas index 8efa5ca..07c4df2 100644 --- a/src/game/g_items.pas +++ b/src/game/g_items.pas @@ -453,8 +453,10 @@ begin it.slotIsUsed := true; it.ItemType := ItemType; - it.Respawnable := Respawnable; - if g_Game_IsServer and (ITEM_RESPAWNTIME = 0) then it.Respawnable := False; + if g_Game_IsServer and ((ITEM_RESPAWNTIME = 0) or not LongBool(gGameSettings.Options and GAME_OPTION_RESPAWNITEMS)) then + it.Respawnable := False + else + it.Respawnable := Respawnable; it.InitX := X; it.InitY := Y; it.RespawnTime := 0; diff --git a/src/game/g_language.pas b/src/game/g_language.pas index 8ccc8ea..1aad7c6 100644 --- a/src/game/g_language.pas +++ b/src/game/g_language.pas @@ -162,6 +162,7 @@ type I_MENU_GOAL_LIMIT, I_MENU_MAX_LIVES, I_MENU_TEAM_DAMAGE, + I_MENU_RESPAWN_ITEMS, I_MENU_ENABLE_EXITS, I_MENU_WEAPONS_STAY, I_MENU_ENABLE_MONSTERS, @@ -573,6 +574,8 @@ type I_MSG_ALLOWMON_OFF, I_MSG_DMKEYS_ON, I_MSG_DMKEYS_OFF, + I_MSG_RESPAWNITEMS_ON, + I_MSG_RESPAWNITEMS_OFF, I_MSG_BOTSVSPLAYERS_ON, I_MSG_BOTSVSPLAYERS_OFF, I_MSG_BOTSVSMONSTERS_ON, @@ -920,6 +923,8 @@ const 'Æèçíè:'), ('MENU TEAM DAMAGE', 'Friendly Fire:', 'Óðîí ñâîèõ:'), + ('MENU RESPAWN ITEMS', 'Respawn Items:', + 'Ðåñïàâíèòü ïðåäìåòû:'), ('MENU ENABLE EXITS', 'Enable Exit:', 'Âêëþ÷èòü âûõîä:'), ('MENU WEAPONS STAY', 'Weapons stay:', @@ -1699,10 +1704,14 @@ const 'Ìîíñòðû â DM âêëþ÷åíû*'), ('MSG ALLOWMON OFF', 'Monsters in DM disabled*', 'Ìîíñòðû â DM âûêëþ÷åíû*'), - ('MSG DMKEYS ON', 'Spawning with all keys in DM enabled*', - 'Ðåñïàâí ñî âñåìè êëþ÷àìè â DM âêëþ÷åí*'), - ('MSG DMKEYS OFF', 'Spawning with all keys in DM disabled*', - 'Ðåñïàâí ñî âñåìè êëþ÷àìè â DM âûêëþ÷åí*'), + ('MSG DMKEYS ON', 'Spawning with all keys in DM enabled', + 'Ðåñïàâí ñî âñåìè êëþ÷àìè â DM âêëþ÷åí'), + ('MSG DMKEYS OFF', 'Spawning with all keys in DM disabled', + 'Ðåñïàâí ñî âñåìè êëþ÷àìè â DM âûêëþ÷åí'), + ('MSG RESPAWNITEMS ON', 'Respawning items enabled', + 'Ðåñïàâí ïðåäìåòîâ âêëþ÷åí'), + ('MSG RESPAWNITEMS OFF', 'Respawning items disabled', + 'Ðåñïàâí ïðåäìåòîâ âûêëþ÷åí'), ('MSG BOTSVSPLAYERS ON', 'Bots attack players', 'Áîòû ïðîòèâ èãðîêîâ'), ('MSG BOTSVSPLAYERS OFF', 'Bots ignore players', diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index 3cfec36..8331660 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -667,12 +667,15 @@ begin gcMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0); gcTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0; + gcRespawnItems := TGUISwitch(GetControl('swRespawnItems')).ItemIndex = 0; gcAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0; gcWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0; gcMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0; Options := 0; if gcTeamDamage then Options := Options or GAME_OPTION_TEAMDAMAGE; + if gcRespawnItems then + Options := Options or GAME_OPTION_RESPAWNITEMS; if gcAllowExit then Options := Options or GAME_OPTION_ALLOWEXIT; if gcWeaponStay then @@ -731,12 +734,15 @@ begin NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0); gnTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0; + gnRespawnItems := TGUISwitch(GetControl('swRespawnItems')).ItemIndex = 0; gnAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0; gnWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0; gnMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0; Options := 0; if gnTeamDamage then Options := Options or GAME_OPTION_TEAMDAMAGE; + if gnRespawnItems then + Options := Options or GAME_OPTION_RESPAWNITEMS; if gnAllowExit then Options := Options or GAME_OPTION_ALLOWEXIT; if gnWeaponStay then @@ -2188,6 +2194,16 @@ begin else ItemIndex := 1; end; + with AddSwitch(_lc[I_MENU_RESPAWN_ITEMS]) do + begin + Name := 'swRespawnItems'; + AddItem(_lc[I_MENU_YES]); + AddItem(_lc[I_MENU_NO]); + if gnRespawnItems then + ItemIndex := 0 + else + ItemIndex := 1; + end; with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do begin Name := 'swEnableExits'; @@ -2388,6 +2404,16 @@ begin else ItemIndex := 1; end; + with AddSwitch(_lc[I_MENU_RESPAWN_ITEMS]) do + begin + Name := 'swRespawnItems'; + AddItem(_lc[I_MENU_YES]); + AddItem(_lc[I_MENU_NO]); + if gcRespawnItems then + ItemIndex := 0 + else + ItemIndex := 1; + end; with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do begin Name := 'swEnableExits'; diff --git a/src/game/g_options.pas b/src/game/g_options.pas index c923a67..0288931 100644 --- a/src/game/g_options.pas +++ b/src/game/g_options.pas @@ -74,6 +74,7 @@ var gcMonsters: Boolean; gcBotsVS: String; gcDeathmatchKeys: Boolean = True; + gcRespawnItems: Boolean = True; gcSpawnInvul: Integer = 0; gnMap: String; gnGameMode: String; @@ -87,6 +88,7 @@ var gnMonsters: Boolean; gnBotsVS: String; gnDeathmatchKeys: Boolean = True; + gnRespawnItems: Boolean = True; gnSpawnInvul: Integer = 0; gsSDLSampleRate: Integer; gsSDLBufferSize: Integer; @@ -288,6 +290,7 @@ begin gcMonsters := False; gcBotsVS := 'Everybody'; gcDeathmatchKeys := True; + gcRespawnItems := True; gcSpawnInvul := 0; (* section GameplayNetwork *) @@ -303,6 +306,7 @@ begin gnMonsters := False; gnBotsVS := 'Everybody'; gnDeathmatchKeys := True; + gnRespawnItems := True; gnSpawnInvul := 0; (* section MasterServer *) @@ -419,6 +423,7 @@ begin ReadBoolean(gcMonsters, 'Monsters'); ReadString(gcBotsVS, 'BotsVS'); ReadBoolean(gcDeathmatchKeys, 'DeathmatchKeys'); + ReadBoolean(gcRespawnItems, 'RespawnItems'); ReadInteger(gcSpawnInvul, 'SpawnInvul'); with gGameSettings do @@ -449,6 +454,8 @@ begin Options := Options or GAME_OPTION_BOTVSMONSTER; if gcDeathmatchKeys then Options := Options or GAME_OPTION_DMKEYS; + if gcRespawnItems then + Options := Options or GAME_OPTION_RESPAWNITEMS; end; section := 'GameplayNetwork'; @@ -464,6 +471,7 @@ begin ReadBoolean(gnMonsters, 'Monsters'); ReadString(gnBotsVS, 'BotsVS'); ReadBoolean(gnDeathmatchKeys, 'DeathmatchKeys'); + ReadBoolean(gnRespawnItems, 'RespawnItems'); ReadInteger(gnSpawnInvul, 'SpawnInvul'); section := 'MasterServer'; @@ -536,6 +544,7 @@ begin config.WriteBool('GameplayCustom', 'Monsters', gcMonsters); config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS); config.WriteBool('GameplayCustom', 'DeathmatchKeys', gcDeathmatchKeys); + config.WriteBool('GameplayCustom', 'RespawnItems', gcRespawnItems); config.WriteInt ('GameplayCustom', 'SpawnInvul', gcSpawnInvul); config.WriteStr ('GameplayNetwork', 'Map', gnMap); @@ -550,6 +559,7 @@ begin config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters); config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS); config.WriteBool('GameplayNetwork', 'DeathmatchKeys', gnDeathmatchKeys); + config.WriteBool('GameplayNetwork', 'RespawnItems', gnRespawnItems); config.WriteInt ('GameplayNetwork', 'SpawnInvul', gnSpawnInvul); config.WriteStr('MasterServer', 'IP', NetSlistIP); @@ -598,6 +608,7 @@ begin config.WriteBool('GameplayCustom', 'Monsters', gcMonsters); config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS); config.WriteBool('GameplayCustom', 'DeathmatchKeys', gcDeathmatchKeys); + config.WriteBool('GameplayCustom', 'RespawnItems', gcRespawnItems); config.WriteInt ('GameplayCustom', 'SpawnInvul', gcSpawnInvul); config.SaveFile(FileName); @@ -624,6 +635,7 @@ begin config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters); config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS); config.WriteBool('GameplayNetwork', 'DeathmatchKeys', gnDeathmatchKeys); + config.WriteBool('GameplayNetwork', 'RespawnItems', gnRespawnItems); config.WriteInt ('GameplayNetwork', 'SpawnInvul', gnSpawnInvul); config.SaveFile(FileName);