From 9085a81c6b9fcef8e9b1fe85e0473bea93e209f7 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Mon, 22 May 2023 12:57:46 +0200 Subject: [PATCH] add supply event to battle royale, drops random items from the sky --- gamemodes-server.cfg | 1 + qcsrc/common/gamemodes/gamemode/br/_mod.inc | 3 ++ qcsrc/common/gamemodes/gamemode/br/_mod.qh | 3 ++ qcsrc/common/gamemodes/gamemode/br/sv_br.qc | 11 +++++ qcsrc/common/gamemodes/gamemode/br/sv_br.qh | 1 + .../common/gamemodes/gamemode/br/sv_events.qc | 11 +++++ .../common/gamemodes/gamemode/br/sv_events.qh | 49 +++++++++++++++++++ 7 files changed, 79 insertions(+) create mode 100644 qcsrc/common/gamemodes/gamemode/br/sv_events.qc create mode 100644 qcsrc/common/gamemodes/gamemode/br/sv_events.qh diff --git a/gamemodes-server.cfg b/gamemodes-server.cfg index 6fa607dc4..28d56d348 100644 --- a/gamemodes-server.cfg +++ b/gamemodes-server.cfg @@ -611,3 +611,4 @@ set g_br_ring_center_factor 0.25 "factor by which the ring can deviate from the set g_br_ring_fadedistance 0.5 "value multiplied by the current ring radius defines the distance at which the ring slowly becomes visible until it reaches g_br_ring_alpha when standing right in front of it" set g_br_ring_fadedistance_min 2000 "minimum value generated by g_br_ring_fadedistance" set g_br_ring_exitvehicle 0 "players can't use vehicles outside of the ring" +set g_br_supply_interval 30 "seconds between each supply drop or 0 to disable" diff --git a/qcsrc/common/gamemodes/gamemode/br/_mod.inc b/qcsrc/common/gamemodes/gamemode/br/_mod.inc index 41d489e46..4b1bb7966 100644 --- a/qcsrc/common/gamemodes/gamemode/br/_mod.inc +++ b/qcsrc/common/gamemodes/gamemode/br/_mod.inc @@ -16,6 +16,9 @@ #ifdef SVQC #include #endif +#ifdef SVQC + #include +#endif #ifdef CSQC #include #endif diff --git a/qcsrc/common/gamemodes/gamemode/br/_mod.qh b/qcsrc/common/gamemodes/gamemode/br/_mod.qh index 2f1f2fe4b..badfe2877 100644 --- a/qcsrc/common/gamemodes/gamemode/br/_mod.qh +++ b/qcsrc/common/gamemodes/gamemode/br/_mod.qh @@ -16,6 +16,9 @@ #ifdef SVQC #include #endif +#ifdef SVQC + #include +#endif #ifdef CSQC #include #endif diff --git a/qcsrc/common/gamemodes/gamemode/br/sv_br.qc b/qcsrc/common/gamemodes/gamemode/br/sv_br.qc index a4b211a3d..f14f707c0 100644 --- a/qcsrc/common/gamemodes/gamemode/br/sv_br.qc +++ b/qcsrc/common/gamemodes/gamemode/br/sv_br.qc @@ -1011,6 +1011,17 @@ MUTATOR_HOOKFUNCTION(br, PlayerSpawn) br_Start(); } +MUTATOR_HOOKFUNCTION(br, SV_StartFrame) +{ + static float supply_time = 0; + + if(autocvar_g_br_supply_interval > 0 && time - supply_time >= autocvar_g_br_supply_interval) + { + supply_time = time; + spawn_supply(); + } +} + float br_CalculatePlayerDropAngle(entity this) { if(this.velocity.z < 0) diff --git a/qcsrc/common/gamemodes/gamemode/br/sv_br.qh b/qcsrc/common/gamemodes/gamemode/br/sv_br.qh index 8ec22c1ab..daf6acec6 100644 --- a/qcsrc/common/gamemodes/gamemode/br/sv_br.qh +++ b/qcsrc/common/gamemodes/gamemode/br/sv_br.qh @@ -38,3 +38,4 @@ float autocvar_g_br_bleedlinear = 1; int autocvar_g_br_squad_size = 3; int autocvar_g_br_minplayers = 2; bool autocvar_g_br_ring_exitvehicle = false; +float autocvar_g_br_supply_interval = 30; diff --git a/qcsrc/common/gamemodes/gamemode/br/sv_events.qc b/qcsrc/common/gamemodes/gamemode/br/sv_events.qc new file mode 100644 index 000000000..f2e8af81a --- /dev/null +++ b/qcsrc/common/gamemodes/gamemode/br/sv_events.qc @@ -0,0 +1,11 @@ +#include "sv_events.qh" + +void spawn_supply() +{ + string item_class = RandomItems_GetRandomItemClassName("br_supply"); + entity this = Item_Create(item_class, '0 0 0', false); + + MoveToRandomLocationWithinBounds(this, world.mins, world.maxs, DPCONTENTS_SOLID, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 2500, 0, 0, false); + tracebox(this.origin, this.mins, this.maxs, this.origin + '0 0 65536', MOVE_NORMAL, this); + setorigin(this, trace_endpos); +} diff --git a/qcsrc/common/gamemodes/gamemode/br/sv_events.qh b/qcsrc/common/gamemodes/gamemode/br/sv_events.qh new file mode 100644 index 000000000..9d0339c29 --- /dev/null +++ b/qcsrc/common/gamemodes/gamemode/br/sv_events.qh @@ -0,0 +1,49 @@ +#pragma once + +void spawn_supply(); + +noref float autocvar_g_br_supply_health_probability = 0; +noref float autocvar_g_br_supply_armor_probability = 0; +noref float autocvar_g_br_supply_resource_probability = 0; +noref float autocvar_g_br_supply_weapon_probability = 1; +noref float autocvar_g_br_supply_powerup_probability = 0; + +noref float autocvar_g_br_supply_item_health_small_probability = 0; +noref float autocvar_g_br_supply_item_health_medium_probability = 0; +noref float autocvar_g_br_supply_item_health_big_probability = 0; +noref float autocvar_g_br_supply_item_health_mega_probability = 0; + +noref float autocvar_g_br_supply_item_armor_small_probability = 0; +noref float autocvar_g_br_supply_item_armor_medium_probability = 0; +noref float autocvar_g_br_supply_item_armor_big_probability = 0; +noref float autocvar_g_br_supply_item_armor_mega_probability = 0; + +noref float autocvar_g_br_supply_item_bullets_probability = 0; +noref float autocvar_g_br_supply_item_cells_probability = 0; +noref float autocvar_g_br_supply_item_fuel_probability = 0; +noref float autocvar_g_br_supply_item_fuel_regen_probability = 0; +noref float autocvar_g_br_supply_item_invisibility_probability = 0; +noref float autocvar_g_br_supply_item_jetpack_probability = 0; +noref float autocvar_g_br_supply_item_plasma_probability = 0; +noref float autocvar_g_br_supply_item_rockets_probability = 0; +noref float autocvar_g_br_supply_item_shells_probability = 0; +noref float autocvar_g_br_supply_item_shield_probability = 0; +noref float autocvar_g_br_supply_item_speed_probability = 0; +noref float autocvar_g_br_supply_item_strength_probability = 0; + +noref float autocvar_g_br_supply_weapon_arc_probability = 0; +noref float autocvar_g_br_supply_weapon_blaster_probability = 0; +noref float autocvar_g_br_supply_weapon_crylink_probability = 0.1; +noref float autocvar_g_br_supply_weapon_devastator_probability = 0.1; +noref float autocvar_g_br_supply_weapon_electro_probability = 0.1; +noref float autocvar_g_br_supply_weapon_fireball_probability = 0; +noref float autocvar_g_br_supply_weapon_hagar_probability = 0; +noref float autocvar_g_br_supply_weapon_hook_probability = 0; +noref float autocvar_g_br_supply_weapon_machinegun_probability = 0.1; +noref float autocvar_g_br_supply_weapon_mortar_probability = 0.1; +noref float autocvar_g_br_supply_weapon_porto_probability = 0; +noref float autocvar_g_br_supply_weapon_shockwave_probability = 0; +noref float autocvar_g_br_supply_weapon_shotgun_probability = 0.1; +noref float autocvar_g_br_supply_weapon_tuba_probability = 0; +noref float autocvar_g_br_supply_weapon_vaporizer_probability = 0; +noref float autocvar_g_br_supply_weapon_vortex_probability = 0.1; -- 2.39.2