From: bones_was_here Date: Wed, 26 Aug 2020 04:27:02 +0000 (+1000) Subject: Remove weapon-specific code from target_give_init and support count field on powerup... X-Git-Tag: xonotic-v0.8.5~352^2~42 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d4cd74e6670b4a67f00fbb0208b5bdff5885b46e;p=xonotic%2Fxonotic-data.pk3dir.git Remove weapon-specific code from target_give_init and support count field on powerup pickups --- diff --git a/qcsrc/common/items/item/powerup.qh b/qcsrc/common/items/item/powerup.qh index bf4727a79..921cc0b2f 100644 --- a/qcsrc/common/items/item/powerup.qh +++ b/qcsrc/common/items/item/powerup.qh @@ -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) { diff --git a/qcsrc/server/compat/quake3.qc b/qcsrc/server/compat/quake3.qc index 5a9d31d86..392d96f71 100644 --- a/qcsrc/server/compat/quake3.qc +++ b/qcsrc/server/compat/quake3.qc @@ -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: