]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Support count field on weapon pickups, fix 0 ammo with target_give and no count set...
authorbones_was_here <bones_was_here@xa.org.au>
Tue, 25 Aug 2020 23:14:35 +0000 (09:14 +1000)
committerbones_was_here <bones_was_here@xa.org.au>
Tue, 25 Aug 2020 23:14:35 +0000 (09:14 +1000)
qcsrc/server/compat/quake3.qc
qcsrc/server/weapons/spawning.qc

index a68cc8a339c987a3822617b78b5458e900164531..5a9d31d86231235fcf7180ec5bbd2f97c704f8db 100644 (file)
@@ -201,35 +201,35 @@ void target_give_init(entity this)
        IL_EACH(g_items, it.targetname == this.target,
        {
                if (it.classname == "weapon_devastator") {
-                       SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
+                       this.ammo_rockets = it.ammo_rockets;
                        this.netname = cons(this.netname, "devastator");
                }
                else if (it.classname == "weapon_vortex") {
-                       SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
+                       this.ammo_cells = it.ammo_cells;
                        this.netname = cons(this.netname, "vortex");
                }
                else if (it.classname == "weapon_electro") {
-                       SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
+                       this.ammo_cells = it.ammo_cells;
                        this.netname = cons(this.netname, "electro");
                }
                else if (it.classname == "weapon_hagar") {
-                       SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
+                       this.ammo_rockets = it.ammo_rockets;
                        this.netname = cons(this.netname, "hagar");
                }
                else if (it.classname == "weapon_crylink") {
-                       SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
+                       this.ammo_cells = it.ammo_cells;
                        this.netname = cons(this.netname, "crylink");
                }
                else if (it.classname == "weapon_mortar") {
-                       SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
+                       this.ammo_rockets = it.ammo_rockets;
                        this.netname = cons(this.netname, "mortar");
                }
                else if (it.classname == "weapon_shotgun") {
-                       SetResourceExplicit(this, RES_SHELLS, GetResource(this, RES_SHELLS) + it.count * WEP_CVAR_PRI(shotgun, ammo)); // WEAPONTODO
+                       this.ammo_shells = it.ammo_shells;
                        this.netname = cons(this.netname, "shotgun");
                }
                else if (it.classname == "weapon_machinegun") {
-                       SetResourceExplicit(this, RES_BULLETS, GetResource(this, RES_BULLETS) + it.count * WEP_CVAR(machinegun, burst_ammo)); // WEAPONTODO
+                       this.ammo_nails = it.ammo_nails;
                        this.netname = cons(this.netname, "machinegun");
                }
                else if (it.classname == "item_armor_mega")
index 63bc865e29dc47bf7404474dc9234365f08999bd..8ade74aa40da69efb610d8c84c4a6a1e5e552835 100644 (file)
@@ -109,15 +109,35 @@ void weapon_defaultspawnfunc(entity this, Weapon wpn)
        // if we don't already have ammo, give us some ammo
        if ((wpn.ammo_type != RES_NONE) && !GetResource(this, wpn.ammo_type))
        {
-               switch (wpn.ammo_type)
+               int ammo = 0;
+               if (this.count > 0)
                {
-                       case RES_SHELLS:  SetResource(this, wpn.ammo_type, cvar("g_pickup_shells_weapon"));  break;
-                       case RES_BULLETS: SetResource(this, wpn.ammo_type, cvar("g_pickup_nails_weapon"));   break;
-                       case RES_ROCKETS: SetResource(this, wpn.ammo_type, cvar("g_pickup_rockets_weapon")); break;
-                       case RES_CELLS:   SetResource(this, wpn.ammo_type, cvar("g_pickup_cells_weapon"));   break;
-                       case RES_PLASMA:  SetResource(this, wpn.ammo_type, cvar("g_pickup_plasma_weapon"));  break;
-                       case RES_FUEL:    SetResource(this, wpn.ammo_type, cvar("g_pickup_fuel_weapon"));    break;
+                       switch (wpn.netname)
+                       {
+                               case "arc":        ammo = cvar("g_balance_arc_beam_ammo");              break;
+                               case "devastator": ammo = cvar("g_balance_devastator_ammo");            break;
+                               case "machinegun": ammo = cvar("g_balance_machinegun_sustained_ammo");  break;
+                               case "minelayer":  ammo = cvar("g_balance_minelayer_ammo");             break;
+                               case "seeker":     ammo = cvar("g_balance_seeker_tag_ammo");            break;
+                               default:           ammo = cvar(strcat("g_balance_", wpn.netname, "_primary_ammo"));
+                       }
+
+                       ammo *= this.count;
                }
+               else
+               {
+                       switch (wpn.ammo_type)
+                       {
+                               case RES_SHELLS:  ammo = cvar("g_pickup_shells_weapon");  break;
+                               case RES_BULLETS: ammo = cvar("g_pickup_nails_weapon");   break;
+                               case RES_ROCKETS: ammo = cvar("g_pickup_rockets_weapon"); break;
+                               case RES_CELLS:   ammo = cvar("g_pickup_cells_weapon");   break;
+                               case RES_PLASMA:  ammo = cvar("g_pickup_plasma_weapon");  break;
+                               case RES_FUEL:    ammo = cvar("g_pickup_fuel_weapon");    break;
+                       }
+               }
+
+               SetResource(this, wpn.ammo_type, ammo);
        }
 
        #if 0 // WEAPONTODO