From: Mario Date: Fri, 14 Feb 2025 16:18:20 +0000 (+1000) Subject: Store weapon impulse numbers in a field, exclude special attacks and ball stealer X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fe8cd148d8ec48ca8ebc69daaf556a95da5d06aa;p=xonotic%2Fxonotic-data.pk3dir.git Store weapon impulse numbers in a field, exclude special attacks and ball stealer --- diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index 46d5eab17f..765017feee 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -46,6 +46,8 @@ STATIC_INIT(WeaponPickup) #define WepSet_FromWeapon(it) ((it).m_wepset) WepSet _WepSet_FromWeapon(int i); +.int m_impulse; + #define DEFAULT_FILENAME "weapons_dump.cfg" // NOTE: dumpeffectinfo, dumpnotifs, dumpturrets and dumpweapons use similar code GENERIC_COMMAND(dumpweapons, "Dump all turrets into " DEFAULT_FILENAME, false) // WEAPONTODO: make this work with other progs than just server @@ -142,6 +144,12 @@ Weapon Weapon_from_name(string s) return WEP_Null; } +Weapon Weapon_from_impulse(int imp) +{ + FOREACH(Weapons, it != WEP_Null && it.m_impulse == imp, return it); + return WEP_Null; +} + #ifdef GAMEQC @@ -329,16 +337,20 @@ REGISTRY_CHECK(Weapons) STATIC_INIT(register_weapons_done) { string inaccessible = ""; + int imp = WEP_IMPULSE_BEGIN; FOREACH(Weapons, true, { WepSet set = it.m_wepset = _WepSet_FromWeapon(it.m_id = i); WEPSET_ALL |= set; if (it.spawnflags & WEP_FLAG_SUPERWEAPON) WEPSET_SUPERWEAPONS |= set; if (it == WEP_Null) continue; - int imp = WEP_IMPULSE_BEGIN + it.m_id - 1; + if ((it.spawnflags & WEP_FLAG_SPECIALATTACK) || (it.spawnflags & WEP_TYPE_OTHER)) continue; + + it.m_impulse = imp; if (imp <= WEP_IMPULSE_END) localcmd(sprintf("alias weapon_%s \"impulse %d\"\n", it.netname, imp)); else inaccessible = strcat(inaccessible, "\n", it.netname); + ++imp; }); if (inaccessible != "" && autocvar_developer > 0) LOG_TRACEF("Impulse limit exceeded, weapon(s) will not be directly accessible: %s", inaccessible); #ifdef CSQC diff --git a/qcsrc/server/impulse.qc b/qcsrc/server/impulse.qc index b9f9d7766f..91863cc6f0 100644 --- a/qcsrc/server/impulse.qc +++ b/qcsrc/server/impulse.qc @@ -158,7 +158,7 @@ void weapon_byid_handle(entity this, int number, int imp) for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { .entity weaponentity = weaponentities[slot]; - W_SwitchWeapon_TryOthers(this, REGISTRY_GET(Weapons, WEP_FIRST + number), weaponentity); + W_SwitchWeapon_TryOthers(this, Weapon_from_impulse(imp), weaponentity); if(autocvar_g_weaponswitch_debug != 1) break; }