]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Remove weapon-specific code from target_give_init and support count field on powerup...
authorbones_was_here <bones_was_here@xa.org.au>
Wed, 26 Aug 2020 04:27:02 +0000 (14:27 +1000)
committerbones_was_here <bones_was_here@xa.org.au>
Wed, 26 Aug 2020 04:27:02 +0000 (14:27 +1000)
qcsrc/common/items/item/powerup.qh
qcsrc/server/compat/quake3.qc

index bf4727a79fdba674faedc71be9c98414754914a2..921cc0b2f2c23e85610ae4c0f14d1202f6ee16ba 100644 (file)
@@ -14,6 +14,7 @@ CLASS(Powerup, Pickup)
     ATTRIB(Powerup, m_itemflags, int, FL_POWERUP);
     ATTRIB(Powerup, m_respawntime, float(), GET(g_pickup_respawntime_powerup));
     ATTRIB(Powerup, m_respawntimejitter, float(), GET(g_pickup_respawntimejitter_powerup));
+    ATTRIB(Powerup, count, float);
 #endif
 ENDCLASS(Powerup)
 
@@ -27,7 +28,7 @@ float autocvar_g_balance_powerup_strength_time;
 void powerup_strength_init(Pickup this, entity item)
 {
     if(!item.strength_finished)
-        item.strength_finished = autocvar_g_balance_powerup_strength_time;
+        item.strength_finished = (item.count) ? item.count : autocvar_g_balance_powerup_strength_time;
 }
 #endif
 REGISTER_ITEM(Strength, Powerup) {
@@ -65,7 +66,7 @@ float autocvar_g_balance_powerup_invincible_time;
 void powerup_shield_init(Pickup this, entity item)
 {
     if(!item.invincible_finished)
-        item.invincible_finished = autocvar_g_balance_powerup_invincible_time;
+        item.invincible_finished = (item.count) ? item.count : autocvar_g_balance_powerup_invincible_time;
 }
 #endif
 REGISTER_ITEM(Shield, Powerup) {
index 5a9d31d86231235fcf7180ec5bbd2f97c704f8db..392d96f71be7d85271041fcee7ecc0705c8b6af0 100644 (file)
@@ -200,54 +200,32 @@ void target_give_init(entity this)
 {
        IL_EACH(g_items, it.targetname == this.target,
        {
-               if (it.classname == "weapon_devastator") {
-                       this.ammo_rockets = it.ammo_rockets;
-                       this.netname = cons(this.netname, "devastator");
-               }
-               else if (it.classname == "weapon_vortex") {
-                       this.ammo_cells = it.ammo_cells;
-                       this.netname = cons(this.netname, "vortex");
-               }
-               else if (it.classname == "weapon_electro") {
-                       this.ammo_cells = it.ammo_cells;
-                       this.netname = cons(this.netname, "electro");
-               }
-               else if (it.classname == "weapon_hagar") {
-                       this.ammo_rockets = it.ammo_rockets;
-                       this.netname = cons(this.netname, "hagar");
-               }
-               else if (it.classname == "weapon_crylink") {
-                       this.ammo_cells = it.ammo_cells;
-                       this.netname = cons(this.netname, "crylink");
-               }
-               else if (it.classname == "weapon_mortar") {
-                       this.ammo_rockets = it.ammo_rockets;
-                       this.netname = cons(this.netname, "mortar");
-               }
-               else if (it.classname == "weapon_shotgun") {
-                       this.ammo_shells = it.ammo_shells;
-                       this.netname = cons(this.netname, "shotgun");
-               }
-               else if (it.classname == "weapon_machinegun") {
-                       this.ammo_nails = it.ammo_nails;
-                       this.netname = cons(this.netname, "machinegun");
-               }
-               else if (it.classname == "item_armor_mega")
-                       SetResourceExplicit(this, RES_ARMOR, 100);
-               else if (it.classname == "item_health_mega")
-                       SetResourceExplicit(this, RES_HEALTH, 200);
-               else if (it.classname == "item_buff") {
+               if (it.classname == "item_buff")
+               {
                        entity buff = buff_FirstFromFlags(STAT(BUFFS, it));
                        this.netname = cons(this.netname, buff.netname);
                        STAT(BUFF_TIME, this) = it.count;
                }
-               else if (it.classname == "item_shield") {
-                       this.invincible_finished = it.count;
-                       this.netname = cons(this.netname, "invincible");
-               }
-               else if (it.classname == "item_strength") {
-                       this.strength_finished = it.count;
-                       this.netname = cons(this.netname, "strength");
+               else
+               {
+                       if (it.ammo_rockets)
+                               this.ammo_rockets = it.ammo_rockets;
+                       else if (it.ammo_cells)
+                               this.ammo_cells = it.ammo_cells;
+                       else if (it.ammo_shells)
+                               this.ammo_shells = it.ammo_shells;
+                       else if (it.ammo_nails)
+                               this.ammo_nails = it.ammo_nails;
+                       else if (it.invincible_finished)
+                               this.invincible_finished = it.invincible_finished;
+                       else if (it.strength_finished)
+                               this.strength_finished = it.strength_finished;
+                       else if (it.classname == "item_armor_mega")
+                               SetResourceExplicit(this, RES_ARMOR, 100);
+                       else if (it.classname == "item_health_mega")
+                               SetResourceExplicit(this, RES_HEALTH, 200);
+
+                       this.netname = cons(this.netname, it.netname);
                }
 
                //remove(it); // removing ents in init functions causes havoc, workaround: