From fffe446358d32241d22808b5b2e28de931ebd1cf Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Tue, 22 Oct 2013 17:13:31 +0200 Subject: [PATCH] Better nudge system; be more verbose for now. --- qcsrc/server/item_ammo.qc | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/qcsrc/server/item_ammo.qc b/qcsrc/server/item_ammo.qc index 954a5c039..306f74172 100644 --- a/qcsrc/server/item_ammo.qc +++ b/qcsrc/server/item_ammo.qc @@ -1,7 +1,8 @@ typedef void(float id, float itemtype, void() spawnfunc) item_ammo_acceptor; // TODO define them in the balance configs -float autocvar_g_balance_ammodistribution_nudgevalue = 0; +float autocvar_g_balance_ammodistribution_nudgefactor_min = 0.7; +float autocvar_g_balance_ammodistribution_nudgefactor_max = 1.4; float autocvar_g_balance_ammodistribution_inner_exponent = -1; float autocvar_g_balance_ammodistribution_outer_exponent = 2; float autocvar_g_balance_ammodistribution_outer_nonmatch_exponent = -2; @@ -154,7 +155,14 @@ void item_ammo_pick() n_mincount += item_ammo_mincount[i]; } for (i = 0; i < ITEM_AMMO_COUNT; ++i) - item_ammo_count[i] = item_ammo_mincount[i] + max(0, ceil(item_ammo_count[i] * (n_a - n_mincount) / n_count + autocvar_g_balance_ammodistribution_nudgevalue)); + { + float c_i = item_ammo_count[i]; + float m_i = item_ammo_mincount[i]; + item_ammo_count[i] = m_i + max(0, ceil(c_i * (n_a - n_mincount) / n_count * autocvar_g_balance_ammodistribution_nudgefactor_max)); + // Obviously >= + item_ammo_mincount[i] = m_i + max(0, floor(c_i * (n_a - n_mincount) / n_count * autocvar_g_balance_ammodistribution_nudgefactor_min)); + dprint(sprintf("Item %s distribution: at least %d, at most %d, distribution input %d %f\n", Item_CounterFieldName(item_ammo_type(i)), item_ammo_mincount[i], item_ammo_count[i], m_i, c_i)); + } // Find the weights and priorities. for (a = ammolist; a; a = a.chain) @@ -234,7 +242,7 @@ void item_ammo_pick() // Assign the selected item type to the selected item. a.item_ammo_chosen_type = i; - print(sprintf("%v (%v): %s -> %s\n", a.origin, a.item_ammo_origin, a.save_classname, Item_CounterFieldName(item_ammo_type(i)))); + dprint(sprintf("%v (%v): %s -> %s\n", a.origin, a.item_ammo_origin, a.save_classname, Item_CounterFieldName(item_ammo_type(i)))); // Decrease the count of remaining items. if (item_ammo_mincount[i] > 0) @@ -244,6 +252,17 @@ void item_ammo_pick() --n_a; } + for (i = 0; i < ITEM_AMMO_COUNT; ++i) + { + if (item_ammo_count[i] - item_ammo_mincount[i] >= 2) + { + if (item_ammo_mincount[i] == 0) + print(sprintf("WARNING: map might not have enough item_ammo near %s weapons\n", Item_CounterFieldName(item_ammo_type(i)))); + if (item_ammo_count[i] == 0) + print(sprintf("WARNING: map might have too many item_ammo near %s weapons\n", Item_CounterFieldName(item_ammo_type(i)))); + } + } + // SPAWN SPAWN SPAWN for (a = ammolist; a; a = a.chain) { -- 2.39.2