]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
refactor of battle royale events and new vehicle drop event
authorJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Tue, 23 May 2023 11:57:20 +0000 (13:57 +0200)
committerJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Tue, 23 May 2023 11:57:20 +0000 (13:57 +0200)
gamemodes-server.cfg
qcsrc/common/gamemodes/gamemode/br/sv_br.qc
qcsrc/common/gamemodes/gamemode/br/sv_br.qh
qcsrc/common/gamemodes/gamemode/br/sv_events.qc
qcsrc/common/gamemodes/gamemode/br/sv_events.qh
qcsrc/common/vehicles/sv_vehicles.qc

index 28d56d34856d32e0806607bc84be96f57f6eb74b..06717d27ba2cfcb2baca2d2f232a965c2561acbc 100644 (file)
@@ -612,3 +612,4 @@ set g_br_ring_fadedistance 0.5 "value multiplied by the current ring radius defi
 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"
+set g_br_vehicle_interval 0 "seconds between each vehicle drop or 0 to disable"
index 2b449739cf4770c94d3e3557abf23df12cee09d0..2e0085cc4d40f71703132ab7e4c4582a408a4d50 100644 (file)
@@ -28,6 +28,8 @@ const float br_drop_time_secs = 1;
 const float drop_speed_vertical_max = 0.9;
 const float drop_distance_disconnect = 32;
 const float drop_speed_crash = 0.9;
+float br_event_supply_time;
+float br_event_vehicle_time;
 bool br_started = false;
 .bool br_ring_warned;
 .float br_drop_time;
@@ -1013,13 +1015,20 @@ MUTATOR_HOOKFUNCTION(br, PlayerSpawn)
 
 MUTATOR_HOOKFUNCTION(br, SV_StartFrame)
 {
-    static float supply_time = 0;
+    if(!br_started)
+        return false;
 
-    if(autocvar_g_br_supply_interval > 0 && time - supply_time >= autocvar_g_br_supply_interval)
+    if(autocvar_g_br_supply_interval > 0 && time - br_event_supply_time >= autocvar_g_br_supply_interval)
     {
-        supply_time = time;
+        br_event_supply_time = time;
         spawn_supply();
     }
+
+    if(autocvar_g_br_vehicle_interval > 0 && time - br_event_vehicle_time >= autocvar_g_br_vehicle_interval)
+    {
+        br_event_vehicle_time = time;
+        spawn_vehicle();
+    }
 }
 
 float br_CalculatePlayerDropAngle(entity this)
@@ -1274,6 +1283,7 @@ void br_Start(){
             it.br_force_drop_distance = min_distance + random() * max(dropship_path_length - (min_distance + dropship_speed * br_drop_time_secs), 0);
     });
 
+    br_event_supply_time = br_event_vehicle_time = time;
     round_handler.cnt = 0; // emulate round handler round start
 }
 
index daf6acec66121e53bfd381109625e4e7d1f2f5e8..f38de2765a7cc01631e5c802f9bb59570d8bb2e1 100644 (file)
@@ -39,3 +39,4 @@ 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;
+float autocvar_g_br_vehicle_interval = 0;
index f2e8af81aafc61f99916a40c4334edbea107f5b3..6c7f6a2d839dc9607416ff2f7d56012266fb2ae3 100644 (file)
@@ -1,11 +1,41 @@
 #include "sv_events.qh"
 
+void drop_from_sky(entity this);
+
 void spawn_supply()
 {
     string item_class = RandomItems_GetRandomItemClassName("br_supply");
-    entity this = Item_Create(item_class, '0 0 0', false);
+    entity this = Item_CreateLoot(item_class, '0 0 0', '0 0 0', 999999999);
+    this.reset = SUB_Remove;
+
+    drop_from_sky(this);
+}
+
+void spawn_vehicle()
+{
+    entity this = spawn();
+    this.br_vehicle_drop = true;
+    if(!vehicle_initialize(this, VEH_SPIDERBOT, true)) { delete(this); return; }
+    this.pos2.y = random() * 360;
+    vehicles_spawn(this);
+    this.reset = SUB_Remove;
+
+    drop_from_sky(this);
+}
+
+// TODO: ensure spawn is within ring
+void drop_from_sky(entity this)
+{
+    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);
+        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;
+    }
 
-    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);
+    LOG_WARN("drop from sky not possible, spawning on floor");
 }
index 9d0339c29e2e9eba99bb661954dca954f28aff56..82bf71ee1e03545755d8d9553cca5161429debf2 100644 (file)
@@ -1,6 +1,9 @@
 #pragma once
 
 void spawn_supply();
+void spawn_vehicle();
+
+.bool br_vehicle_drop;
 
 noref float autocvar_g_br_supply_health_probability = 0;
 noref float autocvar_g_br_supply_armor_probability = 0;
index 6cc3fdafd8d18d9f3214fc767568b18ca2e7b8fb..6c8af6234e5157fdd3d240a4461772c4b0d92fb2 100644 (file)
@@ -509,6 +509,9 @@ void vehicles_showwp(entity this)
 
 void vehicles_setreturn(entity veh)
 {
+       if(veh.br_vehicle_drop)
+               return;
+
        vehicles_clearreturn(veh);
 
        entity ret = new(vehicle_return);
@@ -1160,7 +1163,8 @@ void vehicles_spawn(entity this)
        this.angles = this.pos2;
        setorigin(this, this.pos1);
        // Show it
-       Send_Effect(EFFECT_TELEPORT, this.origin + '0 0 64', '0 0 0', 1);
+       if(!this.br_vehicle_drop)
+               Send_Effect(EFFECT_TELEPORT, this.origin + '0 0 64', '0 0 0', 1);
 
        if(this.vehicle_controller)
                this.team = this.vehicle_controller.team;