X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fall.qc;h=fb060df8a71c5ae2b129b55f3e7478a4067ca926;hb=b8880819e333ef558143ae80afcdb339b907a439;hp=763dd6e8de83646cefda1786d8f6b51d3ce1dbaf;hpb=f366b93e1d9e8ebdff81c9277f9958178dcb38d0;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index 763dd6e8d..b8d2428f3 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -26,7 +26,7 @@ #include "../constants.qh" #include "../stats.qh" #include "../teams.qh" - #include "../util.qh" + #include #include "../monsters/_mod.qh" #include "config.qh" #include @@ -50,9 +50,9 @@ #ifdef SVQC #include "config.qc" #endif -#define IMPLEMENTATION -#include "all.inc" -#undef IMPLEMENTATION + +#include "weapon/_mod.inc" + // WEAPON PLUGIN SYSTEM @@ -67,11 +67,11 @@ WepSet _WepSet_FromWeapon(int a) if (a >= 24) { a -= 24; - return '0 0 1' * power2of(a); + return '0 0 1' * (2 ** a); } - return '0 1 0' * power2of(a); + return '0 1 0' * (2 ** a); } - return '1 0 0' * power2of(a); + return '1 0 0' * (2 ** a); } #ifdef SVQC void WriteWepSet(float dst, WepSet w) @@ -123,6 +123,8 @@ string W_UndeprecateName(string s) case "minstanex": return "vaporizer"; case "grenadelauncher": return "mortar"; case "uzi": return "machinegun"; + case "hmg": return "okhmg"; + case "rpc": return "okrpc"; default: return s; } } @@ -192,14 +194,10 @@ string W_FixWeaponOrder_ForceComplete(string order) return W_FixWeaponOrder(order, 1); } -void W_RandomWeapons(entity e, float n) +WepSet W_RandomWeapons(entity e, WepSet remaining, int n) { - int i; - WepSet remaining; - WepSet result; - remaining = e.weapons; - result = '0 0 0'; - for (i = 0; i < n; ++i) + WepSet result = '0 0 0'; + for (int j = 0; j < n; ++j) { RandomSelection_Init(); FOREACH(Weapons, it != WEP_Null, { @@ -210,62 +208,72 @@ void W_RandomWeapons(entity e, float n) result |= WepSet_FromWeapon(w); remaining &= ~WepSet_FromWeapon(w); } - e.weapons = result; + return result; } -string GetAmmoPicture(.int ammotype) +string GetAmmoPicture(int ammotype) { switch (ammotype) { - case ammo_shells: return ITEM_Shells.m_icon; - case ammo_nails: return ITEM_Bullets.m_icon; - case ammo_rockets: return ITEM_Rockets.m_icon; - case ammo_cells: return ITEM_Cells.m_icon; - case ammo_plasma: return ITEM_Plasma.m_icon; - case ammo_fuel: return ITEM_JetpackFuel.m_icon; + case RES_SHELLS: return ITEM_Shells.m_icon; + case RES_BULLETS: return ITEM_Bullets.m_icon; + case RES_ROCKETS: return ITEM_Rockets.m_icon; + case RES_CELLS: return ITEM_Cells.m_icon; + case RES_PLASMA: return ITEM_Plasma.m_icon; + case RES_FUEL: return ITEM_JetpackFuel.m_icon; default: return ""; // wtf, no ammo type? } } +string GetAmmoName(int ammotype) +{ + switch (ammotype) + { + case RES_SHELLS: return ITEM_Shells.m_name; + case RES_BULLETS: return ITEM_Bullets.m_name; + case RES_ROCKETS: return ITEM_Rockets.m_name; + case RES_CELLS: return ITEM_Cells.m_name; + case RES_PLASMA: return ITEM_Plasma.m_name; + case RES_FUEL: return ITEM_JetpackFuel.m_name; + default: return "batteries"; + } +} + #ifdef CSQC - .int GetAmmoFieldFromNum(int i) +int GetAmmoTypeFromNum(int i) +{ + switch (i) { - switch (i) - { - case 0: return ammo_shells; - case 1: return ammo_nails; - case 2: return ammo_rockets; - case 3: return ammo_cells; - case 4: return ammo_plasma; - case 5: return ammo_fuel; - default: return ammo_none; - } + case 0: return RES_SHELLS; + case 1: return RES_BULLETS; + case 2: return RES_ROCKETS; + case 3: return RES_CELLS; + case 4: return RES_PLASMA; + case 5: return RES_FUEL; + default: return RES_NONE; } +} - int GetAmmoStat(.int ammotype) +int GetAmmoStat(int ammotype) +{ + switch (ammotype) { - switch (ammotype) - { - case ammo_shells: return STAT_SHELLS; - case ammo_nails: return STAT_NAILS; - case ammo_rockets: return STAT_ROCKETS; - case ammo_cells: return STAT_CELLS; - case ammo_plasma: return STAT_PLASMA.m_id; - case ammo_fuel: return STAT_FUEL.m_id; - default: return -1; - } + case RES_SHELLS: return STAT_SHELLS; + case RES_BULLETS: return STAT_NAILS; + case RES_ROCKETS: return STAT_ROCKETS; + case RES_CELLS: return STAT_CELLS; + case RES_PLASMA: return STAT_PLASMA.m_id; + case RES_FUEL: return STAT_FUEL.m_id; + default: return -1; } +} #endif string W_Sound(string w_snd) { string output = strcat("weapons/", w_snd); -#ifdef SVQC - MUTATOR_CALLHOOK(WeaponSound, w_snd, output); - return M_ARGV(1, string); -#else - return output; -#endif + MUTATOR_CALLHOOK(WeaponSound, w_snd, output); + return M_ARGV(1, string); } string W_Model(string w_mdl) @@ -300,24 +308,21 @@ vector shotorg_adjustfromclient(vector vecs, float y_is_right, float algn) vector shotorg_adjust_values(vector vecs, bool y_is_right, bool visual, int algn) { -#ifdef SVQC string s; -#endif if (visual) { vecs = shotorg_adjustfromclient(vecs, y_is_right, algn); } -#ifdef SVQC - else if (autocvar_g_shootfromeye) + else if (STAT(SHOOTFROMEYE)) { vecs.y = vecs.z = 0; } - else if (autocvar_g_shootfromcenter) + else if (STAT(SHOOTFROMCENTER)) { vecs.y = 0; vecs.z -= 2; } - else if ((s = autocvar_g_shootfromfixedorigin) != "") + else if ((s = G_SHOOTFROMFIXEDORIGIN) != "") { vector v = stov(s); if (y_is_right) v.y = -v.y; @@ -325,7 +330,6 @@ vector shotorg_adjust_values(vector vecs, bool y_is_right, bool visual, int algn vecs.y = v.y; vecs.z = v.z; } -#endif else // just do the same as top { vecs = shotorg_adjustfromclient(vecs, y_is_right, algn); @@ -391,7 +395,9 @@ void CL_WeaponEntity_SetModel(entity this, string name, bool _anim) { if (name == "") { - this.model = ""; + vector oldmin = this.mins, oldmax = this.maxs; + setmodel(this, MDL_Null); + setsize(this, oldmin, oldmax); if (this.weaponchild) delete(this.weaponchild); this.weaponchild = NULL; this.movedir = '0 0 0'; @@ -523,7 +529,11 @@ void CL_WeaponEntity_SetModel(entity this, string name, bool _anim) if (this.movedir.x >= 0) { - int algn = STAT(GUNALIGN, this.owner); + //int algn = STAT(GUNALIGN, this.owner); + int algn = W_GunAlign(this, STAT(GUNALIGN, this.owner)); + #ifdef SVQC + this.m_gunalign = algn; + #endif vector v = this.movedir; this.movedir = shotorg_adjust(v, false, false, algn); this.view_ofs = shotorg_adjust(v, false, true, algn) - v; @@ -531,7 +541,9 @@ void CL_WeaponEntity_SetModel(entity this, string name, bool _anim) int compressed_shotorg = compressShotOrigin(this.movedir); // make them match perfectly #ifdef SVQC - this.movedir = decompressShotOrigin(this.owner.stat_shotorg = compressed_shotorg); + // null during init + if (this.owner) STAT(SHOTORG, this.owner) = compressed_shotorg; + this.movedir = decompressShotOrigin(compressed_shotorg); #else this.movedir = decompressShotOrigin(compressed_shotorg); #endif @@ -553,25 +565,39 @@ REGISTER_NET_TEMP(wframe) #ifdef CSQC NET_HANDLE(wframe, bool isNew) { - vector a; - a.x = ReadCoord(); - a.y = ReadCoord(); - a.z = ReadCoord(); + int fr = ReadByte(); + float t = ReadFloat(); + int slot = ReadByte(); bool restartanim = ReadByte(); - anim_set(viewmodel, a, !restartanim, restartanim, restartanim); - viewmodel.state = ReadByte(); - viewmodel.weapon_nextthink = ReadFloat(); - viewmodel.alpha = ReadByte() / 255; - switch (viewmodel.state) + entity wepent = viewmodels[slot]; + if(fr == WFRAME_IDLE) + wepent.animstate_looping = false; // we don't need to enforce idle animation + else + { + vector a = '0 0 0'; + switch(fr) + { + case WFRAME_IDLE: a = wepent.anim_idle; break; + case WFRAME_FIRE1: a = wepent.anim_fire1; break; + case WFRAME_FIRE2: a = wepent.anim_fire2; break; + default: + case WFRAME_RELOAD: a = wepent.anim_reload; break; + } + a.z *= t; + anim_set(wepent, a, !restartanim, restartanim, restartanim); + } + wepent.state = ReadByte(); + wepent.weapon_nextthink = ReadFloat(); + switch (wepent.state) { case WS_RAISE: - viewmodel.weapon_switchdelay = activeweapon.switchdelay_raise; + wepent.weapon_switchdelay = wepent.activeweapon.switchdelay_raise; break; case WS_DROP: - viewmodel.weapon_switchdelay = activeweapon.switchdelay_drop; + wepent.weapon_switchdelay = wepent.activeweapon.switchdelay_drop; break; default: - viewmodel.weapon_switchdelay = 0; + wepent.weapon_switchdelay = 0; break; } return true; @@ -579,19 +605,18 @@ NET_HANDLE(wframe, bool isNew) #endif #ifdef SVQC -void wframe_send(entity actor, entity weaponentity, vector a, bool restartanim) +void wframe_send(entity actor, entity weaponentity, int wepframe, float attackrate, bool restartanim) { if (!IS_REAL_CLIENT(actor)) return; int channel = MSG_ONE; msg_entity = actor; WriteHeader(channel, wframe); - WriteCoord(channel, a.x); - WriteCoord(channel, a.y); - WriteCoord(channel, a.z); + WriteByte(channel, wepframe); + WriteFloat(channel, attackrate); + WriteByte(channel, weaponslot(weaponentity.weaponentity_fld)); WriteByte(channel, restartanim); WriteByte(channel, weaponentity.state); WriteFloat(channel, weaponentity.weapon_nextthink); - WriteByte(channel, weaponentity.m_alpha * 255); } #endif @@ -636,12 +661,12 @@ CLIENT_COMMAND(weapon_find, "Show spawn locations of a weapon") } default: { - LOG_INFOF("Incorrect parameters for ^2%s^7\n", "weapon_find"); + LOG_INFOF("Incorrect parameters for ^2%s^7", "weapon_find"); } case CMD_REQUEST_USAGE: { - LOG_INFO("\nUsage:^3 cl_cmd weapon_find weapon\n"); - LOG_INFO(" Where 'weapon' is the lowercase weapon name, 'all' or 'unowned'.\n"); + LOG_INFO("Usage:^3 cl_cmd weapon_find weapon"); + LOG_INFO(" Where 'weapon' is the lowercase weapon name, 'all' or 'unowned'."); return; } }