From: Martin Taibr Date: Tue, 6 Feb 2018 20:02:09 +0000 (+0100) Subject: shared random for powerups X-Git-Tag: xonotic-v0.8.5~2341^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=088f49dac75e47b7a9dff3639ec702025ee8d984;p=xonotic%2Fxonotic-data.pk3dir.git shared random for powerups --- diff --git a/balance-mario.cfg b/balance-mario.cfg index 0bd65a308..111a27474 100644 --- a/balance-mario.cfg +++ b/balance-mario.cfg @@ -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 diff --git a/balance-nexuiz25.cfg b/balance-nexuiz25.cfg index cf13c2089..d5365d284 100644 --- a/balance-nexuiz25.cfg +++ b/balance-nexuiz25.cfg @@ -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 diff --git a/balance-samual.cfg b/balance-samual.cfg index bc71c896a..653881a68 100644 --- a/balance-samual.cfg +++ b/balance-samual.cfg @@ -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 diff --git a/balance-xdf.cfg b/balance-xdf.cfg index 227dcec3f..952abd9bc 100644 --- a/balance-xdf.cfg +++ b/balance-xdf.cfg @@ -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 diff --git a/balance-xonotic.cfg b/balance-xonotic.cfg index 8a053573d..2b9d38ca9 100644 --- a/balance-xonotic.cfg +++ b/balance-xonotic.cfg @@ -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 diff --git a/balance-xpm.cfg b/balance-xpm.cfg index 3f698423c..76d75bfbe 100644 --- a/balance-xpm.cfg +++ b/balance-xpm.cfg @@ -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 diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 6b10b332a..b52ad7b64 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -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));