]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
shared random for powerups
authorMartin Taibr <taibr.martin@gmail.com>
Tue, 6 Feb 2018 20:02:09 +0000 (21:02 +0100)
committerMartin Taibr <taibr.martin@gmail.com>
Tue, 6 Feb 2018 20:02:09 +0000 (21:02 +0100)
balance-mario.cfg
balance-nexuiz25.cfg
balance-samual.cfg
balance-xdf.cfg
balance-xonotic.cfg
balance-xpm.cfg
qcsrc/common/t_items.qc

index 0bd65a308bfda7253a9b5e9368424fe05a3845a7..111a2747408736191046832454e040d31b3f7574 100644 (file)
@@ -101,7 +101,7 @@ set g_pickup_respawntime_powerup 120
 set g_pickup_respawntime_weapon 10
 set g_pickup_respawntime_superweapon 120
 set g_pickup_respawntime_ammo 10
-set g_pickup_respawntime_initial_random 1
+set g_pickup_respawntime_initial_random 2
 set g_pickup_respawntimejitter_short 0
 set g_pickup_respawntimejitter_medium 0
 set g_pickup_respawntimejitter_long 0
index cf13c20896b8cc0a022d388ac56f0292984d5269..d5365d2843b204a4860ffd52bb843107e67781d6 100644 (file)
@@ -101,7 +101,7 @@ set g_pickup_respawntime_powerup 120
 set g_pickup_respawntime_weapon 15
 set g_pickup_respawntime_superweapon 120
 set g_pickup_respawntime_ammo 15
-set g_pickup_respawntime_initial_random 1
+set g_pickup_respawntime_initial_random 2
 set g_pickup_respawntimejitter_short 0
 set g_pickup_respawntimejitter_medium 0
 set g_pickup_respawntimejitter_long 0
index bc71c896ac446bb6677a5c7e996385337ca3ceb3..653881a681e7b40a2ecd9656db8a9b508453181d 100644 (file)
@@ -101,7 +101,7 @@ set g_pickup_respawntime_powerup 120
 set g_pickup_respawntime_weapon 10
 set g_pickup_respawntime_superweapon 120
 set g_pickup_respawntime_ammo 10
-set g_pickup_respawntime_initial_random 1
+set g_pickup_respawntime_initial_random 2
 set g_pickup_respawntimejitter_short 0
 set g_pickup_respawntimejitter_medium 0
 set g_pickup_respawntimejitter_long 0
index 227dcec3f17206b42dcb3b3c31f7ee503770a3fb..952abd9bc72710f7cecb935619ebeed96f4c5d07 100644 (file)
@@ -101,7 +101,7 @@ set g_pickup_respawntime_powerup 0.1
 set g_pickup_respawntime_weapon 0.1
 set g_pickup_respawntime_superweapon 0.1
 set g_pickup_respawntime_ammo 0.1
-set g_pickup_respawntime_initial_random 1
+set g_pickup_respawntime_initial_random 2
 set g_pickup_respawntimejitter_short 0
 set g_pickup_respawntimejitter_medium 0
 set g_pickup_respawntimejitter_long 0
index 8a053573dbf720606a6686f8a7b1a7fe4ec2e2ba..2b9d38ca95fce1fa32a28957f06328a0491f0e9c 100644 (file)
@@ -101,7 +101,7 @@ set g_pickup_respawntime_powerup 120
 set g_pickup_respawntime_weapon 10
 set g_pickup_respawntime_superweapon 120
 set g_pickup_respawntime_ammo 10
-set g_pickup_respawntime_initial_random 0
+set g_pickup_respawntime_initial_random 1
 set g_pickup_respawntimejitter_short 0
 set g_pickup_respawntimejitter_medium 0
 set g_pickup_respawntimejitter_long 0
index 3f698423c76c59a7f5909b16fd4a16296486207e..76d75bfbed9ffdff603450f669eec4fb17b15af2 100644 (file)
@@ -101,7 +101,7 @@ set g_pickup_respawntime_powerup 120
 set g_pickup_respawntime_weapon 10
 set g_pickup_respawntime_superweapon 120
 set g_pickup_respawntime_ammo 10
-set g_pickup_respawntime_initial_random 0
+set g_pickup_respawntime_initial_random 1
 set g_pickup_respawntimejitter_short 0
 set g_pickup_respawntimejitter_medium 0
 set g_pickup_respawntimejitter_long 0
index 6b10b332a9b18879f5fd7b33702274b4fcd58587..b52ad7b641248d9129901c4fa1e0fe81f1d87057 100644 (file)
@@ -668,24 +668,37 @@ void Item_ScheduleRespawn(entity e)
                Item_Show(e, -1);
 }
 
-AUTOCVAR(g_pickup_respawntime_initial_random, bool, 0, "Make the initial respawn time of items between 10 and their normal respawn time");
+AUTOCVAR(g_pickup_respawntime_initial_random, int, 1,
+       "For items that don't start spawned: 0: spawn after their normal respawntime; 1: spawn after `random * respawntime` with the *same* random; 2: same as 1 but each item has separate random");
 
+float shared_random = -1;
 void Item_ScheduleInitialRespawn(entity e)
 {
+       // initializing during declaration causes the compiler to segfault
+       if (shared_random == -1) {
+               shared_random = random();
+       }
+
        Item_Show(e, 0);
 
        float spawn_in;
-       if (autocvar_g_pickup_respawntime_initial_random)
+       if (autocvar_g_pickup_respawntime_initial_random == 0)
+       {
+               // range: respawntime .. respawntime + respawntimejitter
+               spawn_in = e.respawntime + random() * e.respawntimejitter;
+       }
+       else if (autocvar_g_pickup_respawntime_initial_random == 1)
        {
                // range:
                // if respawntime >= ITEM_RESPAWN_TICKS: ITEM_RESPAWN_TICKS .. respawntime + respawntimejitter
                // else: 0 .. ITEM_RESPAWN_TICKS
-               spawn_in = ITEM_RESPAWN_TICKS + random() * (e.respawntime + e.respawntimejitter - ITEM_RESPAWN_TICKS);
+               // this is to prevent powerups spawning unexpectedly without waypoints
+               spawn_in = ITEM_RESPAWN_TICKS + shared_random * (e.respawntime + e.respawntimejitter - ITEM_RESPAWN_TICKS);
        }
        else
        {
-               // range: respawntime .. respawntime + respawntimejitter
-               spawn_in = e.respawntime + random() * e.respawntimejitter;
+               // range: same as 1
+               spawn_in = ITEM_RESPAWN_TICKS + random() * (e.respawntime + e.respawntimejitter - ITEM_RESPAWN_TICKS);
        }
 
        Item_ScheduleRespawnIn(e, max(0, game_starttime - time) + ((e.respawntimestart) ? e.respawntimestart : spawn_in));