X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fall.qc;h=e430ec2e78c252dea99cfc5c8fdfcc1a874bce8a;hb=2dbcd3c5a4a458b9e83f3b037ca1d951f73755c3;hp=c236bb47c4d3ef361bc5ac9705e88a78483d1933;hpb=9e84ff8daa3826ef32e2891a7c5224a7cd436d23;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index c236bb47c..e430ec2e7 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) @@ -192,14 +192,11 @@ string W_FixWeaponOrder_ForceComplete(string order) return W_FixWeaponOrder(order, 1); } -void W_RandomWeapons(entity e, float n) +void W_RandomWeapons(entity e, int n) { - int i; - WepSet remaining; - WepSet result; - remaining = e.weapons; - result = '0 0 0'; - for (i = 0; i < n; ++i) + WepSet remaining = e.weapons; + WepSet result = '0 0 0'; + for (int j = 0; j < n; ++j) { RandomSelection_Init(); FOREACH(Weapons, it != WEP_Null, { @@ -213,59 +210,55 @@ void W_RandomWeapons(entity e, float n) e.weapons = 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 RESOURCE_SHELLS: return ITEM_Shells.m_icon; + case RESOURCE_BULLETS: return ITEM_Bullets.m_icon; + case RESOURCE_ROCKETS: return ITEM_Rockets.m_icon; + case RESOURCE_CELLS: return ITEM_Cells.m_icon; + case RESOURCE_PLASMA: return ITEM_Plasma.m_icon; + case RESOURCE_FUEL: return ITEM_JetpackFuel.m_icon; default: return ""; // wtf, no ammo type? } } #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 RESOURCE_SHELLS; + case 1: return RESOURCE_BULLETS; + case 2: return RESOURCE_ROCKETS; + case 3: return RESOURCE_CELLS; + case 4: return RESOURCE_PLASMA; + case 5: return RESOURCE_FUEL; + default: return RESOURCE_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 RESOURCE_SHELLS: return STAT_SHELLS; + case RESOURCE_BULLETS: return STAT_NAILS; + case RESOURCE_ROCKETS: return STAT_ROCKETS; + case RESOURCE_CELLS: return STAT_CELLS; + case RESOURCE_PLASMA: return STAT_PLASMA.m_id; + case RESOURCE_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) @@ -537,7 +530,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) this.owner.stat_shotorg = compressed_shotorg; + this.movedir = decompressShotOrigin(compressed_shotorg); #else this.movedir = decompressShotOrigin(compressed_shotorg); #endif @@ -566,7 +561,10 @@ NET_HANDLE(wframe, bool isNew) int slot = ReadByte(); bool restartanim = ReadByte(); entity wepent = viewmodels[slot]; - anim_set(wepent, a, !restartanim, restartanim, restartanim); + if(a.x == wepent.anim_idle_x) // we don't need to enforce idle animation + wepent.animstate_looping = false; + else + anim_set(wepent, a, !restartanim, restartanim, restartanim); wepent.state = ReadByte(); wepent.weapon_nextthink = ReadFloat(); switch (wepent.state) @@ -643,12 +641,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; } }