X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fall.qh;h=24ea41c645bb124cfd735b35dd7ba8f33c295283;hb=d01c567581179df7cc68bcdc8dce58efad911bc4;hp=e84afe9402a5acc34a2a8d696d2f9b0a421ef480;hpb=85d1187251eae197d44f2b39a4a0e6fe96b56f9d;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index e84afe940..0af475900 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -1,12 +1,11 @@ -#ifndef WEAPONS_ALL_H -#define WEAPONS_ALL_H +#pragma once -#include "../command/all.qh" -#include "../stats.qh" +#include +#include #include "config.qh" -// weapon sets -typedef vector WepSet; +#include "weapon.qh" + #ifdef SVQC void WriteWepSet(float dest, WepSet w); #endif @@ -17,29 +16,27 @@ WepSet WepSet_GetFromStat_InMap(); WepSet ReadWepSet(); #endif -#include "weapon.qh" - -#ifndef MENUQC +#ifdef GAMEQC #include "calculations.qh" -#include "../models/all.qh" +#include "projectiles.qh" +#include #endif -#include "../util.qh" - -#ifdef SVQC -#include "../../server/bot/aim.qh" -#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, LAMBDA(it.m_pickup = NEW(WeaponPickup, it))); } +STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, it.m_pickup = NEW(WeaponPickup, it)); } + +#ifdef SVQC +#include +#endif .WepSet m_wepset; #define WEPSET(id) (WEP_##id.m_wepset) #define WepSet_FromWeapon(it) ((it).m_wepset) WepSet _WepSet_FromWeapon(int i); -STATIC_INIT(WepSets) { FOREACH(Weapons, true, LAMBDA(it.m_wepset = _WepSet_FromWeapon(it.m_id))); } GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt") // WEAPONTODO: make this work with other progs than just server { @@ -67,17 +64,17 @@ GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt") // WEAPON if(wep_config_file >= 0) { Dump_Weapon_Settings(); - LOG_INFO(sprintf("Dumping weapons... File located in ^2data/data/%s^7.\n", filename)); + LOG_INFOF("Dumping weapons... File located in ^2data/data/%s^7.", filename); fclose(wep_config_file); wep_config_file = -1; wep_config_alsoprint = -1; } else { - LOG_INFO(sprintf("^1Error: ^7Could not open file '%s'!\n", filename)); + LOG_INFOF("^1Error: ^7Could not open file '%s'!", filename); } #else - LOG_INFO(_("Weapons dump command only works with sv_cmd.\n")); + LOG_INFO(_("Weapons dump command only works with sv_cmd.")); #endif return; } @@ -85,10 +82,10 @@ GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt") // WEAPON default: case CMD_REQUEST_USAGE: { - LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpweapons [filename]")); - LOG_INFO(" Where 'filename' is the file to write (default is weapons_dump.cfg),\n"); - LOG_INFO(" if supplied with '-' output to console as well as default,\n"); - LOG_INFO(" if left blank, it will only write to default.\n"); + 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."); return; } } @@ -96,7 +93,7 @@ GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt") // WEAPON #ifdef SVQC entity W_PROP_reloader; -float autocvar_w_prop_interval = 0; +float autocvar_w_prop_interval = 5; .void(Weapon this, int) wr_net; void W_PROP_reload(int chan, entity to) { @@ -108,19 +105,20 @@ void W_PROP_reload(int chan, entity to) if (f) f(it, chan); }); } -void W_PROP_think() +void W_PROP_think(entity this) { W_PROP_reload(MSG_ALL, NULL); } STATIC_INIT_LATE(W_PROP_reloader) { - entity e = W_PROP_reloader = new(W_PROP_reloader); - make_pure(e); - WITH(entity, self, e, (e.think = W_PROP_think)()); + entity e = W_PROP_reloader = new_pure(W_PROP_reloader); + setthink(e, W_PROP_think); + W_PROP_think(e); } #endif -#define REGISTER_WEAPON(...) EVAL(OVERLOAD(REGISTER_WEAPON, __VA_ARGS__)) +#define REGISTER_WEAPON(...) EVAL_REGISTER_WEAPON(OVERLOAD(REGISTER_WEAPON, __VA_ARGS__)) +#define EVAL_REGISTER_WEAPON(...) __VA_ARGS__ #define REGISTER_WEAPON_2(id, inst) REGISTER(Weapons, WEP, id, m_id, inst) /** TODO: deprecated - remove */ #define REGISTER_WEAPON_3(id, sname, inst) \ @@ -144,10 +142,12 @@ X(weaponreplace, string) X(weaponstartoverride, float) X(weaponstart, float) X(weaponthrowable, float) +#ifdef SVQC X(reload_ammo, float) .float reloading_ammo = reload_ammo; X(reload_time, float) .float reloading_time = reload_time; +#endif #undef X @@ -206,8 +206,7 @@ X(reload_time, float) noref entity b = this.baseline; \ if (!b) \ { \ - b = this.baseline = new(baseline); \ - make_pure(b); \ + b = this.baseline = new_pure(baseline); \ b.baseline_target = this; \ } #ifdef SVQC @@ -300,22 +299,22 @@ REGISTRY_CHECK(Weapons) STATIC_INIT(register_weapons_done) { - FOREACH(Weapons, true, LAMBDA( - it.m_id = i; - WepSet set = it.m_wepset; + string inaccessible = ""; + 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; - it.weapon = it.m_id; it.weapons = set; if (it == WEP_Null) continue; int imp = WEP_IMPULSE_BEGIN + it.m_id - 1; if (imp <= WEP_IMPULSE_END) localcmd(sprintf("alias weapon_%s \"impulse %d\"\n", it.netname, imp)); else - LOG_TRACEF("Impulse limit exceeded, weapon will not be directly accessible: %s\n", it.netname); - )); + inaccessible = strcat(inaccessible, "\n", it.netname); + }); + if (inaccessible) LOG_TRACEF("Impulse limit exceeded, weapon(s) will not be directly accessible: %s", inaccessible); #ifdef CSQC - FOREACH(Weapons, true, LAMBDA(it.wr_init(it))); + FOREACH(Weapons, true, it.wr_init(it)); #endif weaponorder_byid = ""; for (int i = Weapons_MAX - 1; i >= 1; --i) @@ -324,11 +323,18 @@ STATIC_INIT(register_weapons_done) weaponorder_byid = strzone(substring(weaponorder_byid, 1, -1)); } -#ifndef MENUQC +#ifdef GAMEQC .entity weaponchild; .entity exteriorweaponentity; -.vector weaponentity_glowmod; +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; + return g; +} + +.int m_gunalign; //.int weapon; // current weapon .string weaponname; // name of .weapon @@ -353,8 +359,13 @@ ENUMCLASS_END(WFRAME) .WFRAME wframe; -vector shotorg_adjust_values(vector vecs, bool y_is_right, bool visual, int algn); -void CL_WeaponEntity_SetModel(entity this, string name); +#ifdef SVQC + #define G_SHOOTFROMFIXEDORIGIN autocvar_g_shootfromfixedorigin +#elif defined(CSQC) + string autocvar_cl_shootfromfixedorigin; + #define G_SHOOTFROMFIXEDORIGIN autocvar_cl_shootfromfixedorigin #endif +vector shotorg_adjust_values(vector vecs, bool y_is_right, bool visual, int algn); +void CL_WeaponEntity_SetModel(entity this, string name, bool _anim); #endif