]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapons.qc
Merge branch 'master' into Mario/overkill
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapons.qc
index a5134d7b52a62f4243693e2df9588a5c1e0f3b32..e45a901c3c62a2e13e3344a669d908c0bd8e507d 100644 (file)
@@ -84,25 +84,33 @@ void register_weapon(
        float pickupbasevalue,
        vector clr,
        string modelname,
-       string shortname,
-       string wname)
+       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.netname = shortname;
-       e.message = wname;
        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.spawnflags = weapontype;
-       e.model2 = strzone(strcat("wpn-", ftos(id)));
-       e.impulse = i;
-       e.bot_pickupbasevalue = pickupbasevalue;
-       e.ammo_field = ammotype;
+       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;
 
        #ifndef MENUQC
        func(WR_INIT);
@@ -121,14 +129,18 @@ void register_weapons_done()
        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.model2 = "";
        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 = "";
+
        float i;
        weaponorder_byid = "";
        for(i = WEP_MAXCOUNT; i >= 1; --i)
@@ -161,6 +173,20 @@ string W_NameWeaponOrder_MapFunc(string s)
        }
        return s;
 }
+
+string W_UndeprecateName(string s)
+{
+       switch ( s )
+       {
+               case "nex"            : return "vortex";
+               case "rocketlauncher" : return "devastator"; 
+               case "laser"          : return "blaster";
+               case "minstanex"      : return "vaporizer";
+               case "grenadelauncher": return "mortar";
+               case "uzi"            : return "machinegun";
+               default               : return s;
+       }
+}
 string W_NameWeaponOrder(string order)
 {
        return mapPriorityList(order, W_NameWeaponOrder_MapFunc);
@@ -170,6 +196,7 @@ string W_NumberWeaponOrder_MapFunc(string s)
        float i;
        if(s == "0" || stof(s))
                return s;
+       s = W_UndeprecateName(s);
        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
                if(s == get_weaponinfo(i).netname)
                        return ftos(i);
@@ -249,9 +276,18 @@ void W_RandomWeapons(entity e, float n)
        e.weapons = result;
 }
 
-string W_Name(float weaponid) // WEAPONTODO: make into a macro
+string GetAmmoPicture(.float ammotype)
 {
-       return (get_weaponinfo(weaponid)).message;
+       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";
+               default: return ""; // wtf, no ammo type?
+       }
 }
 
 #ifdef CSQC
@@ -263,24 +299,12 @@ string W_Name(float weaponid) // WEAPONTODO: make into a macro
                case 1: return ammo_nails;
                case 2: return ammo_rockets;
                case 3: return ammo_cells;
-               case 4: return ammo_fuel;
+               case 4: return ammo_plasma;
+               case 5: return ammo_fuel;
                default: return ammo_none;
        }
 }
 
-string GetAmmoPicture(.float ammotype)
-{
-       switch(ammotype)
-       {
-               case ammo_shells:  return "ammo_shells";
-               case ammo_nails:   return "ammo_nails";
-               case ammo_rockets: return "ammo_rockets";
-               case ammo_cells:   return "ammo_cells";
-               case ammo_fuel:    return "ammo_fuel";
-               default: return ""; // wtf, no ammo type?
-       }
-}
-
 float GetAmmoStat(.float ammotype)
 {
        switch(ammotype)
@@ -289,6 +313,7 @@ float GetAmmoStat(.float ammotype)
                case ammo_nails: return STAT_NAILS;
                case ammo_rockets: return STAT_ROCKETS;
                case ammo_cells: return STAT_CELLS;
+               case ammo_plasma: return STAT_PLASMA;
                case ammo_fuel: return STAT_FUEL;
                default: return -1;
        }