From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Tue, 23 May 2023 13:04:11 +0000 (+0200) Subject: improve drop from sky logic for drop events in battle royale X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b9c385d6dd9e5bde32d275164d98d7c9335f5b11;p=xonotic%2Fxonotic-data.pk3dir.git improve drop from sky logic for drop events in battle royale --- diff --git a/qcsrc/common/gamemodes/gamemode/br/sv_events.qc b/qcsrc/common/gamemodes/gamemode/br/sv_events.qc index 6c7f6a2d8..766b12d7d 100644 --- a/qcsrc/common/gamemodes/gamemode/br/sv_events.qc +++ b/qcsrc/common/gamemodes/gamemode/br/sv_events.qc @@ -1,6 +1,6 @@ #include "sv_events.qh" -void drop_from_sky(entity this); +bool drop_from_sky(entity this); void spawn_supply() { @@ -8,7 +8,11 @@ void spawn_supply() entity this = Item_CreateLoot(item_class, '0 0 0', '0 0 0', 999999999); this.reset = SUB_Remove; - drop_from_sky(this); + if(!drop_from_sky(this)) + { + delete(this); + LOG_WARN("supply drop failed"); + } } void spawn_vehicle() @@ -20,22 +24,35 @@ void spawn_vehicle() vehicles_spawn(this); this.reset = SUB_Remove; - drop_from_sky(this); + if(!drop_from_sky(this)) + { + delete(this); + LOG_WARN("vehicle drop failed"); + } } // TODO: ensure spawn is within ring -void drop_from_sky(entity this) +bool drop_from_sky(entity this) { + bool move_success = false; + for(int i = 0; i < 100; ++i) { - MoveToRandomLocationWithinBounds(this, world.mins, world.maxs, DPCONTENTS_SOLID, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 10, 0, 0, false); + if(!MoveToRandomLocationWithinBounds(this, world.mins, world.maxs, DPCONTENTS_SOLID, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 100, 0, 0, false)) + continue; + + move_success = true; + tracebox(this.origin, this.mins, this.maxs, this.origin + '0 0 65536', MOVE_NORMAL, this); if(!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)) continue; setorigin(this, trace_endpos); - return; + return true; } - LOG_WARN("drop from sky not possible, spawning on floor"); + if(move_success) + LOG_WARN("drop from sky not possible, spawning on floor"); + + return move_success; }