X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=qcsrc%2Fcommon%2Fweapons%2Fall.qc;h=b972cfdec4adfa1a74a6d7ef24b4c6c7dc6b9498;hb=1af8ea71282d19f66c96622815c68943eaa36aba;hp=72c92471a9c537435aaeb29ed20072303c7700a3;hpb=f1a11cabe78baaaa067fe22bbdf2ca1546d1e8fc;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index 72c92471a..b972cfdec 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -9,7 +9,6 @@ #include "../constants.qh" #include "../stats.qh" #include "../../warpzonelib/anglestransform.qh" - #include "../../warpzonelib/mathlib.qh" #include "../../warpzonelib/common.qh" #include "../../warpzonelib/client.qh" #include "../util.qh" @@ -25,7 +24,6 @@ #include "../../dpdefs/progsdefs.qh" #include "../../dpdefs/dpextensions.qh" #include "../../warpzonelib/anglestransform.qh" - #include "../../warpzonelib/mathlib.qh" #include "../../warpzonelib/common.qh" #include "../../warpzonelib/util_server.qh" #include "../../warpzonelib/server.qh" @@ -54,11 +52,11 @@ #ifndef MENUQC #include "calculations.qc" #endif +#define IMPLEMENTATION #include "all.inc" +#undef IMPLEMENTATION // WEAPON PLUGIN SYSTEM -entity weapon_info[WEP_MAXCOUNT]; -entity dummy_weapon_info; #if WEP_MAXCOUNT > 72 # error Kein Weltraum links auf dem Gerät @@ -149,77 +147,13 @@ WepSet ReadWepSet() } #endif -void register_weapon( - int id, - WepSet bit, - bool(int) func, - .int ammotype, - int i, - int weapontype, - float pickupbasevalue, - vector clr, - string modelname, - string simplemdl, - string crosshair, - string wepimg, - string refname, - string wepname) -{ - entity e; - weapon_info[id - 1] = e = spawn(); - e.classname = "weapon_info"; - e.weapon = id; - e.weapons = bit; - e.weapon_func = func; - e.ammo_field = ammotype; - e.impulse = i; - e.spawnflags = weapontype; - e.bot_pickupbasevalue = pickupbasevalue; - e.wpcolor = clr; - e.wpmodel = strzone(strcat("wpn-", ftos(id))); - e.mdl = modelname; - e.model = strzone(strcat("models/weapons/g_", modelname, ".md3")); - e.w_simplemdl = strzone(simplemdl); // simpleitems weapon model/image - e.w_crosshair = strzone(car(crosshair)); - string s = cdr(crosshair); - e.w_crosshair_size = ((s != "") ? stof(s) : 1); // so that we can scale the crosshair from code (for compat) - e.model2 = strzone(wepimg); - e.netname = refname; - e.message = wepname; - - #ifdef CSQC - func(WR_INIT); - #endif -} -bool w_null(int dummy) -{ - return 0; -} void register_weapons_done() { - dummy_weapon_info = spawn(); - dummy_weapon_info.classname = "weapon_info"; - dummy_weapon_info.weapon = 0; // you can recognize dummies by this - dummy_weapon_info.weapons = '0 0 0'; - dummy_weapon_info.netname = ""; - dummy_weapon_info.message = "AOL CD Thrower"; - dummy_weapon_info.weapon_func = w_null; - dummy_weapon_info.wpmodel = ""; - dummy_weapon_info.mdl = ""; - dummy_weapon_info.model = ""; - dummy_weapon_info.spawnflags = 0; - dummy_weapon_info.impulse = -1; - dummy_weapon_info.bot_pickupbasevalue = 0; - dummy_weapon_info.ammo_field = ammo_none; - - dummy_weapon_info.w_crosshair = "gfx/crosshair1"; - dummy_weapon_info.w_crosshair_size = 1; - dummy_weapon_info.model2 = ""; + dummy_weapon_info = NEW(Weapon); - int i; weaponorder_byid = ""; - for(i = WEP_MAXCOUNT; i >= 1; --i) - if(weapon_info[i-1]) + for (int i = WEP_MAXCOUNT - 1; i >= 0; --i) + if (weapon_info[i]) weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i)); weaponorder_byid = strzone(substring(weaponorder_byid, 1, strlen(weaponorder_byid) - 1)); } @@ -353,14 +287,14 @@ void W_RandomWeapons(entity e, float n) string GetAmmoPicture(.int ammotype) { - switch(ammotype) + switch (ammotype) { - case ammo_shells: return "ammo_shells"; - case ammo_nails: return "ammo_bullets"; - case ammo_rockets: return "ammo_rockets"; - case ammo_cells: return "ammo_cells"; - case ammo_plasma: return "ammo_cells"; - case ammo_fuel: return "ammo_fuel"; + 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; default: return ""; // wtf, no ammo type? } } @@ -394,4 +328,36 @@ int GetAmmoStat(.int ammotype) } } #endif + +string W_Sound(string w_snd) +{ + #define extensions(X) X(wav) X(ogg) + #define tryext(ext) { if (fexists(strcat("sound/", output = strcat("weapons/", w_snd, "."#ext)))) break; } + string output; + do { + extensions(tryext); + #undef tryext + #undef extensions + output = strcat("weapons/", w_snd); + } while (0); + +#ifdef SVQC + MUTATOR_CALLHOOK(WeaponSound, w_snd, output); + return weapon_sound_output; +#else + return output; +#endif +} + +string W_Model(string w_mdl) +{ + string output = strcat("models/weapons/", w_mdl); +#ifdef SVQC + MUTATOR_CALLHOOK(WeaponModel, w_mdl, output); + return weapon_model_output; +#else + return output; +#endif +} + #endif