X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fitems.qc;h=1282d428af96e139049298a6bd2630cf9437d5e8;hb=6c4aca14b76d71f2ebabb059cd1ee30f6cb7c790;hp=37ffb25e7c3cff3b49e3581dc69a179048483212;hpb=5b6650aacd624aa8a1153ee4322fb40a94eb3cb9;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/items.qc b/qcsrc/common/items.qc index 37ffb25e7..1282d428a 100644 --- a/qcsrc/common/items.qc +++ b/qcsrc/common/items.qc @@ -1,5 +1,5 @@ // WEAPON PLUGIN SYSTEM -entity weapon_info[24]; +entity weapon_info[WEP_MAXCOUNT]; entity dummy_weapon_info; void register_weapon(float id, float(float) func, float ammotype, float i, float weapontype, float pickupbasevalue, string modelname, string shortname, string wname) @@ -8,7 +8,7 @@ void register_weapon(float id, float(float) func, float ammotype, float i, float weapon_info[id - 1] = e = spawn(); e.classname = "weapon_info"; e.weapon = id; - e.weapons = power2of(id - WEP_FIRST); + WEPSET_COPY_EW(e, id); e.netname = shortname; e.message = wname; e.items = ammotype; @@ -19,6 +19,18 @@ void register_weapon(float id, float(float) func, float ammotype, float i, float e.model2 = strzone(strcat("wpn-", e.mdl)); e.impulse = i; e.bot_pickupbasevalue = pickupbasevalue; + if(ammotype & IT_SHELLS) + e.ammo_field = ammo_shells; + else if(ammotype & IT_NAILS) + e.ammo_field = ammo_nails; + else if(ammotype & IT_ROCKETS) + e.ammo_field = ammo_rockets; + else if(ammotype & IT_CELLS) + e.ammo_field = ammo_cells; + else if(ammotype & IT_FUEL) + e.ammo_field = ammo_fuel; + else + e.ammo_field = ammo_batteries; } float w_null(float dummy) { @@ -29,7 +41,7 @@ void register_weapons_done() dummy_weapon_info = spawn(); dummy_weapon_info.classname = "weapon_info"; dummy_weapon_info.weapon = 0; // you can recognize dummies by this - dummy_weapon_info.weapons = 0; // you can recognize dummies by this too + WEPSET_CLEAR_E(dummy_weapon_info); dummy_weapon_info.netname = ""; dummy_weapon_info.message = "@!#%'n Tuba"; dummy_weapon_info.items = 0; @@ -43,7 +55,7 @@ void register_weapons_done() float i; weaponorder_byid = ""; - for(i = 24; i >= 1; --i) + for(i = WEP_MAXCOUNT; i >= 1; --i) if(weapon_info[i-1]) weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i)); weaponorder_byid = strzone(substring(weaponorder_byid, 1, strlen(weaponorder_byid) - 1)); @@ -142,3 +154,21 @@ string W_FixWeaponOrder_ForceComplete(string order) return W_FixWeaponOrder(order, 1); } +void W_RandomWeapons(entity e, float n) +{ + float i, j; + WEPSET_DECLARE_A(remaining); + WEPSET_DECLARE_A(result); + WEPSET_COPY_AE(remaining, e); + WEPSET_CLEAR_A(result); + for(i = 0; i < n; ++i) + { + RandomSelection_Init(); + for(j = WEP_FIRST; j <= WEP_LAST; ++j) + if(WEPSET_CONTAINS_AW(remaining, j)) + RandomSelection_Add(world, j, string_null, 1, 1); + WEPSET_OR_AW(result, RandomSelection_chosen_float); + WEPSET_ANDNOT_AW(remaining, RandomSelection_chosen_float); + } + WEPSET_COPY_EA(e, result); +}