From 46f1e30638b53f4ec91d018d7e79a9b9f5268eac Mon Sep 17 00:00:00 2001 From: Martin Taibr Date: Mon, 5 Feb 2018 15:02:48 +0100 Subject: [PATCH] option to spawn quad and shield at the same time --- balance-mario.cfg | 1 + balance-nexuiz25.cfg | 1 + balance-overkill.cfg | 1 + balance-samual.cfg | 1 + balance-xdf.cfg | 1 + balance-xonotic.cfg | 1 + balance-xpm.cfg | 1 + qcsrc/common/t_items.qc | 24 +++++++++++++++++++++--- qcsrc/common/t_items.qh | 3 --- 9 files changed, 28 insertions(+), 6 deletions(-) diff --git a/balance-mario.cfg b/balance-mario.cfg index 28100182e..0bd65a308 100644 --- a/balance-mario.cfg +++ b/balance-mario.cfg @@ -101,6 +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_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 37099c122..cf13c2089 100644 --- a/balance-nexuiz25.cfg +++ b/balance-nexuiz25.cfg @@ -101,6 +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_respawntimejitter_short 0 set g_pickup_respawntimejitter_medium 0 set g_pickup_respawntimejitter_long 0 diff --git a/balance-overkill.cfg b/balance-overkill.cfg index 3a321ce53..eb1fd6b6e 100644 --- a/balance-overkill.cfg +++ b/balance-overkill.cfg @@ -101,6 +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_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 48c68d81b..bc71c896a 100644 --- a/balance-samual.cfg +++ b/balance-samual.cfg @@ -101,6 +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_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 562506283..227dcec3f 100644 --- a/balance-xdf.cfg +++ b/balance-xdf.cfg @@ -101,6 +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_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 32924a72d..8a053573d 100644 --- a/balance-xonotic.cfg +++ b/balance-xonotic.cfg @@ -101,6 +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_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 6901eda28..3f698423c 100644 --- a/balance-xpm.cfg +++ b/balance-xpm.cfg @@ -101,6 +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_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 e13df065a..6b10b332a 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -626,6 +626,7 @@ AUTOCVAR(g_pickup_respawntime_scaling_reciprocal, float, 0.0, "Multiply respawn AUTOCVAR(g_pickup_respawntime_scaling_offset, float, 0.0, "Multiply respawn time by `reciprocal / (p + offset) + linear` where `p` is the current number of players, takes effect with 2 or more players present, `offset` offsets the curve left or right - the results are not intuitive and I recommend plotting the respawn time and the number of items per player to see what's happening"); AUTOCVAR(g_pickup_respawntime_scaling_linear, float, 1.0, "Multiply respawn time by `reciprocal / (p + offset) + linear` where `p` is the current number of players, takes effect with 2 or more players present, `linear` can be used to simply scale the respawn time linearly"); +/// Adjust respawn time according to the number of players. float adjust_respawntime(float normal_respawntime) { float r = autocvar_g_pickup_respawntime_scaling_reciprocal; float o = autocvar_g_pickup_respawntime_scaling_offset; @@ -660,17 +661,34 @@ void Item_ScheduleRespawn(entity e) //LOG_INFOF("item %s will respawn in %f", e.classname, adjusted_respawntime); // range: adjusted_respawntime - respawntimejitter .. adjusted_respawntime + respawntimejitter - float actual_time = adjusted_respawntime + crandom() * e.respawntimejitter; - Item_ScheduleRespawnIn(e, actual_time); + float respawn_in = adjusted_respawntime + crandom() * e.respawntimejitter; + Item_ScheduleRespawnIn(e, respawn_in); } else // if respawntime is -1, this item does not respawn 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"); + void Item_ScheduleInitialRespawn(entity e) { Item_Show(e, 0); - Item_ScheduleRespawnIn(e, max(0, game_starttime - time) + ((e.respawntimestart) ? e.respawntimestart : ITEM_RESPAWNTIME_INITIAL(e))); + + float spawn_in; + if (autocvar_g_pickup_respawntime_initial_random) + { + // 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); + } + else + { + // range: respawntime .. respawntime + respawntimejitter + spawn_in = e.respawntime + random() * e.respawntimejitter; + } + + Item_ScheduleRespawnIn(e, max(0, game_starttime - time) + ((e.respawntimestart) ? e.respawntimestart : spawn_in)); } void GiveRandomWeapons(entity receiver, int num_weapons, string weapon_names, diff --git a/qcsrc/common/t_items.qh b/qcsrc/common/t_items.qh index d2f44c61d..315a10037 100644 --- a/qcsrc/common/t_items.qh +++ b/qcsrc/common/t_items.qh @@ -57,9 +57,6 @@ bool have_pickup_item(entity this); const float ITEM_RESPAWN_TICKS = 10; -#define ITEM_RESPAWNTIME_INITIAL(i) (ITEM_RESPAWN_TICKS + random() * ((i).respawntime + (i).respawntimejitter - ITEM_RESPAWN_TICKS)) - // range: 10 .. respawntime + respawntimejitter - .float max_armorvalue; .float pickup_anyway; -- 2.39.2