X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fall.qh;h=37858af5b6b61fc8b7f9febe6a9d6bcfa60b8af3;hb=0f318cfd5e7b56140cc6a0274e7ec5f258c30157;hp=26b40084bfe82b4013862d1d6c4fae03621c74ff;hpb=fe65404b4515e2f7db18a71c9953f318003b214e;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index 26b40084b..37858af5b 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)); } @@ -38,7 +38,9 @@ STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, it.m_pickup = NEW(WeaponPicku #define WepSet_FromWeapon(it) ((it).m_wepset) WepSet _WepSet_FromWeapon(int i); -GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt", false) // WEAPONTODO: make this work with other progs than just server +#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 { switch(request) { @@ -51,12 +53,12 @@ GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt", false) // if(filename == "") { - filename = "weapons_dump.cfg"; + filename = DEFAULT_FILENAME; wep_config_alsoprint = false; } else if(filename == "-") { - filename = "weapons_dump.cfg"; + filename = DEFAULT_FILENAME; wep_config_alsoprint = true; } wep_config_file = fopen(filename, FILE_WRITE); @@ -74,7 +76,7 @@ GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt", false) // LOG_INFOF("^1Error: ^7Could not open file '%s'!", filename); } #else - LOG_INFO(_("Weapons dump command only works with sv_cmd.")); + LOG_INFO("Weapons dump command only works with sv_cmd."); #endif return; } @@ -82,14 +84,15 @@ 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 []"); + LOG_HELPF(" Where is the file to write (default is %s),", DEFAULT_FILENAME); + LOG_HELP(" if supplied with '-' output to console as well as default,"); + LOG_HELP(" if left blank, it will only write to default."); return; } } } +#undef DEFAULT_FILENAME #ifdef SVQC entity W_PROP_reloader; @@ -126,8 +129,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 +260,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,24 +295,25 @@ 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; #include "all.inc" -// TODO: remove after 0.8.2. Retains impulse number compatibility because 0.8.1 clients don't reload the weapons.cfg +// TODO: remove after 0.8.5. Retains impulse number compatibility because 0.8.1 clients don't reload the weapons.cfg #define WEP_HARDCODED_IMPULSES 20 -// TODO: invert after 0.8.2. Will require moving 'best weapon' impulses +// TODO: invert after 0.8.5. 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) @@ -327,13 +332,13 @@ STATIC_INIT(register_weapons_done) else inaccessible = strcat(inaccessible, "\n", it.netname); }); - if (inaccessible) LOG_TRACEF("Impulse limit exceeded, weapon(s) will not be directly accessible: %s", inaccessible); + if (inaccessible != "" && autocvar_developer > 0) LOG_TRACEF("Impulse limit exceeded, weapon(s) will not be directly accessible: %s", inaccessible); #ifdef CSQC 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)); } @@ -345,7 +350,7 @@ STATIC_INIT(register_weapons_done) vector weaponentity_glowmod(Weapon wep, entity actor, int c, entity wepent) { vector g; - if (!(g = wep.wr_glow(wep, actor, wepent))) g = colormapPaletteColor(c & 0x0F, true) * 2; + if (!(g = wep.wr_glow(wep, actor, wepent))) g = colormapPaletteColor(c & 0x0F, true); return g; } @@ -356,12 +361,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) @@ -375,6 +384,7 @@ ENUMCLASS_END(WFRAME) .WFRAME wframe; #ifdef SVQC + string autocvar_g_shootfromfixedorigin; #define G_SHOOTFROMFIXEDORIGIN autocvar_g_shootfromfixedorigin #elif defined(CSQC) string autocvar_cl_shootfromfixedorigin; @@ -384,14 +394,26 @@ ENUMCLASS_END(WFRAME) vector shotorg_adjust_values(vector vecs, bool y_is_right, bool visual, int algn); void CL_WeaponEntity_SetModel(entity this, string name, bool _anim); +REPLICATE_INIT(int, cvar_cl_gunalign); +REPLICATE_INIT(bool, cvar_cl_weapon_switch_reload); +REPLICATE_INIT(bool, cvar_cl_weapon_switch_fallback_to_impulse); +REPLICATE_INIT(int, cvar_cl_weaponimpulsemode); + +REPLICATE_INIT(string, cvar_cl_weaponpriority); +REPLICATE_INIT(string, cvar_cl_weaponpriorities[10]); + #ifdef CSQC -bool cvar_cl_accuracy_data_share; -REPLICATE(cvar_cl_accuracy_data_share, bool, "cl_accuracy_data_share"); -bool cvar_cl_accuracy_data_receive; -REPLICATE(cvar_cl_accuracy_data_receive, bool, "cl_accuracy_data_receive"); +REPLICATE_INIT(bool, cvar_cl_accuracy_data_share); +REPLICATE_INIT(bool, cvar_cl_accuracy_data_receive); #endif #ifdef SVQC void wframe_send(entity actor, entity weaponentity, int wepframe, float attackrate, bool restartanim); + +void W_MuzzleFlash(Weapon thiswep, entity actor, .entity weaponentity, vector shotorg, vector shotdir); + +string W_FixWeaponOrder_ForceComplete_AndBuildImpulseList(entity this, string wo); +string W_FixWeaponOrder_AllowIncomplete(entity this, string order); #endif + #endif