From 0a8c23fba8d0c4bdff0767098fd848807fe76aac Mon Sep 17 00:00:00 2001 From: LegendaryGuard Date: Thu, 20 Jan 2022 02:55:46 +0100 Subject: [PATCH] Fix crash when player controls vehicles going inside ring, plus when controlling, vehicle damage applied inside ring. Allow setting Battle Royale to play on CTF and Assault maps --- gamemodes-server.cfg | 2 ++ qcsrc/common/gamemodes/gamemode/br/br.qh | 18 ++++++++++++++++++ qcsrc/common/gamemodes/gamemode/br/sv_br.qc | 6 +++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gamemodes-server.cfg b/gamemodes-server.cfg index b3ef1b737..e2b282f42 100644 --- a/gamemodes-server.cfg +++ b/gamemodes-server.cfg @@ -573,6 +573,8 @@ set g_duel_not_dm_maps 0 "when this is set, DM maps will NOT be listed in duel" // battle royale // ====== set g_br 0 "Battle Royale: survive on a shrinking battlefield" +set g_br_not_assault_maps 0 "when this is set, CTF maps will NOT be listed in BR" +set g_br_not_ctf_maps 0 "when this is set, CTF maps will NOT be listed in BR" set g_br_not_dm_maps 0 "when this is set, DM maps will NOT be listed in BR" set g_br_minplayers 2 "minimum players to start the BR match" set g_br_squad_size 3 "maximum squad size" diff --git a/qcsrc/common/gamemodes/gamemode/br/br.qh b/qcsrc/common/gamemodes/gamemode/br/br.qh index 1d34096a7..046f9554e 100644 --- a/qcsrc/common/gamemodes/gamemode/br/br.qh +++ b/qcsrc/common/gamemodes/gamemode/br/br.qh @@ -1,8 +1,12 @@ #pragma once +#include +#include #include #include +bool autocvar_g_br_not_assault_maps = false; +bool autocvar_g_br_not_ctf_maps = false; bool autocvar_g_br_not_dm_maps = false; #ifdef CSQC @@ -31,6 +35,20 @@ CLASS(BattleRoyale, Gametype) } METHOD(BattleRoyale, m_isForcedSupported, bool(Gametype this)) { + if(!autocvar_g_br_not_assault_maps) + { + // if this is unset, all ASSAULT maps support BR too + if(!(MapInfo_Map_supportedGametypes & this.m_flags) && (MapInfo_Map_supportedGametypes & MAPINFO_TYPE_ASSAULT.m_flags)) + return true; // TODO: references another gametype (alternatively, we could check which gamemodes are always enabled and append this if any are supported) + } + + if(!autocvar_g_br_not_ctf_maps) + { + // if this is unset, all CTF maps support BR too + if(!(MapInfo_Map_supportedGametypes & this.m_flags) && (MapInfo_Map_supportedGametypes & MAPINFO_TYPE_CTF.m_flags)) + return true; // TODO: references another gametype (alternatively, we could check which gamemodes are always enabled and append this if any are supported) + } + if(!autocvar_g_br_not_dm_maps) { // if this is unset, all DM maps support BR too diff --git a/qcsrc/common/gamemodes/gamemode/br/sv_br.qc b/qcsrc/common/gamemodes/gamemode/br/sv_br.qc index 3a092a576..70270f671 100644 --- a/qcsrc/common/gamemodes/gamemode/br/sv_br.qc +++ b/qcsrc/common/gamemodes/gamemode/br/sv_br.qc @@ -244,7 +244,11 @@ MUTATOR_HOOKFUNCTION(br, PlayerPreThink, CBC_ORDER_FIRST) player.br_ring_warned = true; Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_BR_RING_WARN); } - player.event_damage(player, ring, ring, ring.strength * frametime, DEATH_RING.m_id, DMG_NOWEP, player.origin, '0 0 0'); // ring damage + + if (player.vehicle) // if a player is controlling vehicles + vehicles_damage(player.vehicle, ring, ring, 10 * ring.strength * frametime, DEATH_RING.m_id, DMG_NOWEP, player.vehicle.origin, '0 0 0'); + + Damage(player, ring, ring, ring.strength * frametime, DEATH_RING.m_id, DMG_NOWEP, player.origin, '0 0 0'); // ring damage } else { -- 2.39.2