X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fall.qh;h=f98152aa8b8b1838245d80de623c8c6346a44bd6;hb=ff2e9a518b256c1cbaad9bc3eb7450f85ca8b80e;hp=26b40084bfe82b4013862d1d6c4fae03621c74ff;hpb=ae458cf44e1264534a20514f2f451c3d06ff135b;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index 26b40084bf..f98152aa8b 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -20,12 +20,12 @@ WepSet ReadWepSet(); #include "calculations.qh" #include "projectiles.qh" #include +#include #endif #include REGISTRY(Weapons, 72) // Increase as needed. Can be up to 72. -#define Weapons_from(i) _Weapons_from(i, WEP_Null) REGISTER_REGISTRY(Weapons) STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, it.m_pickup = NEW(WeaponPickup, it)); } @@ -82,10 +82,10 @@ GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt", false) // default: case CMD_REQUEST_USAGE: { - LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " dumpweapons [filename]"); - LOG_INFO(" Where 'filename' is the file to write (default is weapons_dump.cfg),"); - LOG_INFO(" if supplied with '-' output to console as well as default,"); - LOG_INFO(" if left blank, it will only write to default."); + LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " dumpweapons [filename]"); + LOG_HELP(" Where 'filename' is the file to write (default is weapons_dump.cfg),"); + LOG_HELP(" if supplied with '-' output to console as well as default,"); + LOG_HELP(" if left blank, it will only write to default."); return; } } @@ -126,8 +126,9 @@ STATIC_INIT_LATE(W_PROP_reloader) [[alias("WEP_" #id)]] Weapon _wep_##sname REGISTER_WEAPON(Null, NEW(Weapon)); +REGISTRY_DEFINE_GET(Weapons, WEP_Null) -Weapon Weapons_fromstr(string s) +Weapon Weapon_from_name(string s) { FOREACH(Weapons, it != WEP_Null && it.netname == s, return it); return WEP_Null; @@ -256,7 +257,7 @@ const .float reloading_time = reload_time; .void(Weapon this, int i) wr_net; NET_HANDLE(WeaponUpdate, bool isnew) { - Weapon w = Weapons_from(ReadByte()); + Weapon w = REGISTRY_GET(Weapons, ReadByte()); for (int i; (i = ReadByte()); ) { w.wr_net(w, i); @@ -291,13 +292,14 @@ const .float reloading_time = reload_time; // read cvars from weapon settings +// cvars are created as such: g_balance_wepname_name #define WEP_CVAR(wepname, name) (_wep_##wepname.wepvar_##name) #define WEP_CVAR_PRI(wepname, name) WEP_CVAR(wepname, primary_##name) #define WEP_CVAR_SEC(wepname, name) WEP_CVAR(wepname, secondary_##name) #define WEP_CVAR_BOTH(wepname, isprimary, name) ((isprimary) ? WEP_CVAR_PRI(wepname, name) : WEP_CVAR_SEC(wepname, name)) const int WEP_FIRST = 1; -#define WEP_LAST (Weapons_COUNT - 1) +#define WEP_LAST (REGISTRY_COUNT(Weapons) - 1) WepSet WEPSET_ALL; WepSet WEPSET_SUPERWEAPONS; @@ -308,7 +310,7 @@ WepSet WEPSET_SUPERWEAPONS; // TODO: invert after 0.8.2. Will require moving 'best weapon' impulses #define WEP_IMPULSE_BEGIN 230 -#define WEP_IMPULSE_END bound(WEP_IMPULSE_BEGIN, WEP_IMPULSE_BEGIN + (Weapons_COUNT - 1) - 1, 253) +#define WEP_IMPULSE_END bound(WEP_IMPULSE_BEGIN, WEP_IMPULSE_BEGIN + (REGISTRY_COUNT(Weapons) - 1) - 1, 253) REGISTRY_SORT(Weapons, WEP_HARDCODED_IMPULSES + 1) REGISTRY_CHECK(Weapons) @@ -332,8 +334,8 @@ STATIC_INIT(register_weapons_done) FOREACH(Weapons, true, it.wr_init(it)); #endif weaponorder_byid = ""; - for (int i = Weapons_MAX - 1; i >= 1; --i) - if (Weapons_from(i)) + for (int i = REGISTRY_MAX(Weapons) - 1; i >= 1; --i) + if (REGISTRY_GET(Weapons, i)) weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i)); weaponorder_byid = strzone(substring(weaponorder_byid, 1, -1)); } @@ -356,12 +358,16 @@ vector weaponentity_glowmod(Weapon wep, entity actor, int c, entity wepent) .vector spawnorigin; // for casings +.vector movedir_aligned; // shot origin based on weapon alignment (unaffected by shootfromeye) + // weapon animation vectors: .vector anim_fire1; .vector anim_fire2; .vector anim_idle; .vector anim_reload; +.entity muzzle_flash; + // static frame globals ENUMCLASS(WFRAME) @@ -394,4 +400,8 @@ REPLICATE(cvar_cl_accuracy_data_receive, bool, "cl_accuracy_data_receive"); #ifdef SVQC void wframe_send(entity actor, entity weaponentity, int wepframe, float attackrate, bool restartanim); #endif + +#ifdef SVQC +void W_MuzzleFlash(Weapon thiswep, entity actor, .entity weaponentity, vector shotorg, vector shotdir); +#endif #endif