]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/spawning.qc
Add weaponthrowable property to weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / spawning.qc
index 30b7b0bebcd9f9b7102e4ba837c77e1c3c94591b..409dbfe07e09345d362075c4fe5036af0face583 100644 (file)
@@ -1,16 +1,27 @@
 string W_Apply_Weaponreplace(string in)
 {
        float n = tokenize_console(in);
-       string out = "";
-       float i;
+       string out = "", s, replacement;
+       float i, j;
+       entity e;
        for(i = 0; i < n; ++i)
        {
-               string s = argv(i);
-               string r = cvar_string(strcat("g_weaponreplace_", s));
-               if(r == "")
+               replacement = "";
+               s = argv(i);
+               
+               for(j = WEP_FIRST; j <= WEP_LAST; ++j)
+               {
+                       e = get_weaponinfo(j);
+                       if(e.netname == s)
+                       {
+                               replacement = e.weaponreplace;
+                       }
+               }
+
+               if(replacement == "")
                        out = strcat(out, " ", s);
-               else if(r != "0")
-                       out = strcat(out, " ", r);
+               else if(replacement != "0")
+                       out = strcat(out, " ", replacement);
        }
        return substring(out, 1, -1);
 }
@@ -19,7 +30,6 @@ void weapon_defaultspawnfunc(float wpn)
 {
        entity e;
        float t;
-       var .float ammofield;
        string s;
        entity oldself;
        float i, j;
@@ -104,7 +114,7 @@ void weapon_defaultspawnfunc(float wpn)
 
        if(!self.respawntime)
        {
-               if(WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
+               if(e.weapons & WEPSET_SUPERWEAPONS)
                {
                        self.respawntime = g_pickup_respawntime_superweapon;
                        self.respawntimejitter = g_pickup_respawntimejitter_superweapon;
@@ -116,22 +126,37 @@ void weapon_defaultspawnfunc(float wpn)
                }
        }
 
-       if(WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
+       if(e.weapons & WEPSET_SUPERWEAPONS)
                if(!self.superweapons_finished)
                        self.superweapons_finished = autocvar_g_balance_superweapons_time;
 
+       // if we don't already have ammo, give us some ammo
+       if(!self.(e.ammo_field))
+       {
+               switch(e.ammo_field)
+               {
+                       case ammo_shells:  self.ammo_shells  = cvar("g_pickup_shells_weapon");  break;
+                       case ammo_nails:   self.ammo_nails   = cvar("g_pickup_nails_weapon");   break;
+                       case ammo_rockets: self.ammo_rockets = cvar("g_pickup_rockets_weapon"); break;
+                       case ammo_cells:   self.ammo_cells   = cvar("g_pickup_cells_weapon");   break;
+                       case ammo_fuel:    self.ammo_fuel    = cvar("g_pickup_fuel_weapon");    break;
+               }
+       }
+
+       #if 0
        if(e.items)
        {
                for(i = 0, j = 1; i < 24; ++i, j *= 2)
                {
                        if(e.items & j)
                        {
-                               ammofield = Item_CounterField(j);
-                               if(!self.ammofield)
-                                       self.ammofield = cvar(strcat("g_pickup_", Item_CounterFieldName(j), "_weapon"));
+                               ammotype = Item_CounterField(j);
+                               if(!self.ammotype)
+                                       self.ammotype = cvar(strcat("g_pickup_", Item_CounterFieldName(j), "_weapon"));
                        }
                }
        }
+       #endif
 
        // pickup anyway
        if(g_pickup_weapons_anyway)
@@ -140,7 +165,7 @@ void weapon_defaultspawnfunc(float wpn)
        f = FL_WEAPON;
 
        // no weapon-stay on superweapons
-       if(WEPSET_CONTAINS_ANY_EA(e, WEPBIT_SUPERWEAPONS))
+       if(e.weapons & WEPSET_SUPERWEAPONS)
                f |= FL_NO_WEAPON_STAY;
 
        // weapon stay isn't supported for teamed weapons