From 7ae4bec46516926910d8c30c6d00d2cc7d812d66 Mon Sep 17 00:00:00 2001 From: TimePath Date: Mon, 28 Sep 2015 12:44:57 +1000 Subject: [PATCH] Weapons: require explicit pickup model --- qcsrc/common/weapons/all.qh | 23 ++++++++++++++--------- qcsrc/common/weapons/weapon/arc.qc | 1 + qcsrc/common/weapons/weapon/blaster.qc | 1 + qcsrc/common/weapons/weapon/crylink.qc | 1 + qcsrc/common/weapons/weapon/devastator.qc | 1 + qcsrc/common/weapons/weapon/electro.qc | 1 + qcsrc/common/weapons/weapon/fireball.qc | 1 + qcsrc/common/weapons/weapon/hagar.qc | 1 + qcsrc/common/weapons/weapon/hlac.qc | 1 + qcsrc/common/weapons/weapon/hmg.qc | 1 + qcsrc/common/weapons/weapon/hook.qc | 1 + qcsrc/common/weapons/weapon/machinegun.qc | 1 + qcsrc/common/weapons/weapon/minelayer.qc | 1 + qcsrc/common/weapons/weapon/mortar.qc | 1 + qcsrc/common/weapons/weapon/porto.qc | 4 +++- qcsrc/common/weapons/weapon/rifle.qc | 1 + qcsrc/common/weapons/weapon/rpc.qc | 1 + qcsrc/common/weapons/weapon/seeker.qc | 1 + qcsrc/common/weapons/weapon/shockwave.qc | 1 + qcsrc/common/weapons/weapon/shotgun.qc | 1 + qcsrc/common/weapons/weapon/tuba.qc | 1 + qcsrc/common/weapons/weapon/vaporizer.qc | 1 + qcsrc/common/weapons/weapon/vortex.qc | 1 + qcsrc/server/weapons/spawning.qc | 2 +- 24 files changed, 39 insertions(+), 11 deletions(-) diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index 1b7cc7272..7bd56ede5 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -3,12 +3,15 @@ #ifndef MENUQC #include "calculations.qh" +#include "../models/models.qh" #endif #include "../util.qh" + #ifdef SVQC #include "../../server/bot/aim.qh" #endif + const int MAX_SHOT_DISTANCE = 32768; // weapon pickup ratings for bot logic @@ -96,6 +99,7 @@ void WepSet_AddStat(); void WepSet_AddStat_InMap(); void WriteWepSet(float dest, WepSet w); #endif + #ifdef CSQC WepSet WepSet_GetFromStat(); WepSet WepSet_GetFromStat_InMap(); @@ -208,8 +212,8 @@ CLASS(Weapon, Object) ATTRIB(Weapon, wpmodel, string, ""); /** M: modelname : name of model (without g_ v_ or h_ prefixes) */ ATTRIB(Weapon, mdl, string, ""); - /** A: modelname : full path to g_ model */ - ATTRIB(Weapon, model, string, ""); + /** M: model MDL_id_ITEM */ + ATTRIB(Weapon, m_model, entity, NULL); /** M: simplemdl : simpleitems weapon model/image */ ATTRIB(Weapon, w_simplemdl, string, "foobar"); /** M: crosshair : per-weapon crosshair: "CrosshairImage Size" */ @@ -235,6 +239,7 @@ CLASS(Weapon, Object) float pickupbasevalue, vector clr, string modelname, + entity m, string simplemdl, string crosshair, string wepimg, @@ -249,7 +254,7 @@ CLASS(Weapon, Object) this.bot_pickupbasevalue = pickupbasevalue; this.wpcolor = clr; this.mdl = modelname; - this.model = strzone(W_Model(strcat("g_", modelname, ".md3"))); + this.m_model = m; this.w_simplemdl = strzone(simplemdl); // simpleitems weapon model/image this.w_crosshair = strzone(car(crosshair)); string s = cdr(crosshair); @@ -288,16 +293,16 @@ entity dummy_weapon_info; } \ REGISTER_INIT(WEP, id) -#define _REGISTER_WEAPON(id, function, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname) \ - REGISTER_WEAPON_2(id, NEW(Weapon, function, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname)) +#define _REGISTER_WEAPON(id, function, ammotype, impulse, flags, rating, color, modelname, mdl, simplemdl, crosshair, wepimg, refname, wepname) \ + REGISTER_WEAPON_2(id, NEW(Weapon, function, ammotype, impulse, flags, rating, color, modelname, mdl, simplemdl, crosshair, wepimg, refname, wepname)) #ifndef MENUQC - #define REGISTER_WEAPON_13(id, function, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname) \ + #define REGISTER_WEAPON_14(id, function, ammotype, impulse, flags, rating, color, modelname, mdl, simplemdl, crosshair, wepimg, refname, wepname) \ bool function(entity this, int); \ - _REGISTER_WEAPON(id, function, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname) + _REGISTER_WEAPON(id, function, ammotype, impulse, flags, rating, color, modelname, mdl, simplemdl, crosshair, wepimg, refname, wepname) #else - #define REGISTER_WEAPON_13(id, function, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname) \ - _REGISTER_WEAPON(id, w_new, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname) + #define REGISTER_WEAPON_14(id, function, ammotype, impulse, flags, rating, color, modelname, mdl, simplemdl, crosshair, wepimg, refname, wepname) \ + _REGISTER_WEAPON(id, w_new, ammotype, impulse, flags, rating, color, modelname, NULL, simplemdl, crosshair, wepimg, refname, wepname) #endif #include "all.inc" diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 4de781468..1a0b42de5 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_HIGH, /* color */ '1 1 1', /* modelname */ "arc", +/* model */ MDL_ARC_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairhlac 0.7", /* wepimg */ "weaponarc", diff --git a/qcsrc/common/weapons/weapon/blaster.qc b/qcsrc/common/weapons/weapon/blaster.qc index b71ec598d..ae000e32c 100644 --- a/qcsrc/common/weapons/weapon/blaster.qc +++ b/qcsrc/common/weapons/weapon/blaster.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ 0, /* color */ '1 0.5 0.5', /* modelname */ "laser", +/* model */ MDL_BLASTER_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairlaser 0.5", /* wepimg */ "weaponlaser", diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 1120a1846..d6fefed7b 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '1 0.5 1', /* modelname */ "crylink", +/* model */ MDL_CRYLINK_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshaircrylink 0.5", /* wepimg */ "weaponcrylink", diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index 410dd246b..1faae844f 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_HIGH, /* color */ '1 1 0', /* modelname */ "rl", +/* model */ MDL_DEVASTATOR_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairrocketlauncher 0.7", /* wepimg */ "weaponrocketlauncher", diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index d0e300cc5..f08ad101f 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '0 0.5 1', /* modelname */ "electro", +/* model */ MDL_ELECTRO_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairelectro 0.6", /* wepimg */ "weaponelectro", diff --git a/qcsrc/common/weapons/weapon/fireball.qc b/qcsrc/common/weapons/weapon/fireball.qc index 89e421f72..0cc765f95 100644 --- a/qcsrc/common/weapons/weapon/fireball.qc +++ b/qcsrc/common/weapons/weapon/fireball.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '1 0.5 0', /* modelname */ "fireball", +/* model */ MDL_FIREBALL_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairfireball", /* wepimg */ "weaponfireball", diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index 84d733586..7f6b01008 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '1 1 0.5', /* modelname */ "hagar", +/* model */ MDL_HAGAR_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairhagar 0.8", /* wepimg */ "weaponhagar", diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index 1f69bb5ce..c3e9668ad 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '0 1 0', /* modelname */ "hlac", +/* model */ MDL_HLAC_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairhlac 0.6", /* wepimg */ "weaponhlac", diff --git a/qcsrc/common/weapons/weapon/hmg.qc b/qcsrc/common/weapons/weapon/hmg.qc index beeac392b..baf9647eb 100644 --- a/qcsrc/common/weapons/weapon/hmg.qc +++ b/qcsrc/common/weapons/weapon/hmg.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_HIGH, /* color */ '0.5 0.5 0', /* modelname */ "ok_hmg", +/* model */ MDL_HMG_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairuzi 0.6", /* wepimg */ "weaponhmg", diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index 65327f9c2..52ce4da71 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ 0, /* color */ '0 0.5 0', /* modelname */ "hookgun", +/* model */ MDL_HOOK_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairhook 0.5", /* wepimg */ "weaponhook", diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index be1781a94..338710609 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '1 1 0', /* modelname */ "uzi", +/* model */ MDL_MACHINEGUN_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairuzi 0.6", /* wepimg */ "weaponuzi", diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index ce2ea7d35..759361420 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_HIGH, /* color */ '0.75 1 0', /* modelname */ "minelayer", +/* model */ MDL_MINELAYER_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairminelayer 0.9", /* wepimg */ "weaponminelayer", diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index 77cb46020..4c276d1ca 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '1 0 0', /* modelname */ "gl", +/* model */ MDL_MORTAR_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairgrenadelauncher 0.7", /* wepimg */ "weapongrenadelauncher", diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index 7e8b28218..6b6e6252a 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -6,7 +6,9 @@ CLASS(PortoLaunch, Weapon) /* rating */ ATTRIB(PortoLaunch, bot_pickupbasevalue, float, 0); /* color */ ATTRIB(PortoLaunch, wpcolor, vector, '0.5 0.5 0.5'); /* modelname */ ATTRIB(PortoLaunch, mdl, string, "porto"); -/* model */ ATTRIB(PortoLaunch, model, string, strzone(W_Model(strcat("g_", this.mdl, ".md3")))); +#ifndef MENUQC +/* model */ ATTRIB(PortoLaunch, m_model, Model, MDL_PORTO_ITEM); +#endif /* simplemdl */ ATTRIB(PortoLaunch, w_simplemdl, string, "foobar"); /* crosshair */ ATTRIB(PortoLaunch, w_crosshair, string, "gfx/crosshairporto"); /* crosshair */ ATTRIB(PortoLaunch, w_crosshair_size, float, 0.6); diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index a6f264951..ef37d80ba 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '0.5 1 0', /* modelname */ "campingrifle", +/* model */ MDL_RIFLE_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairrifle 0.6", /* wepimg */ "weaponrifle", diff --git a/qcsrc/common/weapons/weapon/rpc.qc b/qcsrc/common/weapons/weapon/rpc.qc index a91280874..37e5c3cc4 100644 --- a/qcsrc/common/weapons/weapon/rpc.qc +++ b/qcsrc/common/weapons/weapon/rpc.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_HIGH, /* color */ '0.5 0.5 0', /* modelname */ "ok_rl", +/* model */ MDL_RPC_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairrocketlauncher 0.7", /* wepimg */ "weaponrpc", diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index a81b460d5..0ebbf0b90 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '0.5 1 0', /* modelname */ "seeker", +/* model */ MDL_SEEKER_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairseeker 0.8", /* wepimg */ "weaponseeker", diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index ec91b17b3..cc0da9418 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qc +++ b/qcsrc/common/weapons/weapon/shockwave.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_LOW, /* color */ '0.5 0.25 0', /* modelname */ "shotgun", +/* model */ MDL_SHOCKWAVE_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairshotgun 0.7", /* wepimg */ "weaponshotgun", diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 1de326384..b02022354 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_LOW, /* color */ '0.5 0.25 0', /* modelname */ "shotgun", +/* model */ MDL_SHOTGUN_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairshotgun 0.65", /* wepimg */ "weaponshotgun", diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index 2d88f3d2c..72276a646 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_MID, /* color */ '0 1 0', /* modelname */ "tuba", +/* model */ MDL_TUBA_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairtuba", /* wepimg */ "weapontuba", diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index 8bf5f06ee..c3dfad4af 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_HIGH, /* color */ '0.5 1 1', /* modelname */ "minstanex", +/* model */ MDL_VAPORIZER_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairminstanex 0.6", /* wepimg */ "weaponminstanex", diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 6f2b7012e..6e2f7418d 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -8,6 +8,7 @@ REGISTER_WEAPON( /* rating */ BOT_PICKUP_RATING_HIGH, /* color */ '0.5 1 1', /* modelname */ "nex", +/* model */ MDL_VORTEX_ITEM, /* simplemdl */ "foobar", /* crosshair */ "gfx/crosshairnex 0.65", /* wepimg */ "weaponnex", diff --git a/qcsrc/server/weapons/spawning.qc b/qcsrc/server/weapons/spawning.qc index 4fb84744c..7079ee0c0 100644 --- a/qcsrc/server/weapons/spawning.qc +++ b/qcsrc/server/weapons/spawning.qc @@ -177,7 +177,7 @@ void weapon_defaultspawnfunc(float wpn) if(self.team) f |= FL_NO_WEAPON_STAY; - StartItem(e.model, string_null, self.respawntime, self.respawntimejitter, e.message, 0, e.weapon, f, weapon_pickupevalfunc, e.bot_pickupbasevalue); + StartItem(strzone(e.m_model.model_str()), string_null, self.respawntime, self.respawntimejitter, e.message, 0, e.weapon, f, weapon_pickupevalfunc, e.bot_pickupbasevalue); self.item_pickupsound_ent = SND_WEAPONPICKUP; #if 0 // WEAPONTODO if (self.modelindex) // don't precache if self was removed -- 2.39.2