From 1e8a03349941343726e0ab7fc2dc77b612c26968 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 27 Jan 2017 11:58:34 +1000 Subject: [PATCH] Add a property for item's default pickup_anyway value --- qcsrc/common/items/item/ammo.qh | 5 +++++ qcsrc/common/items/item/armor.qh | 16 ++++++++++++++++ qcsrc/common/items/item/health.qh | 16 ++++++++++++++++ qcsrc/common/items/item/pickup.qh | 1 + qcsrc/common/t_items.qc | 31 +++---------------------------- qcsrc/server/miscfunctions.qh | 9 --------- 6 files changed, 41 insertions(+), 37 deletions(-) diff --git a/qcsrc/common/items/item/ammo.qh b/qcsrc/common/items/item/ammo.qh index f240578b3..d7c3e9408 100644 --- a/qcsrc/common/items/item/ammo.qh +++ b/qcsrc/common/items/item/ammo.qh @@ -1,11 +1,16 @@ #pragma once #include "pickup.qh" +#ifdef SVQC +PROPERTY(float, g_pickup_ammo_anyway); +#endif + CLASS(Ammo, Pickup) #ifdef SVQC ATTRIB(Ammo, m_pickupevalfunc, float(entity player, entity item), ammo_pickupevalfunc); ATTRIB(Ammo, m_respawntime, float(), GET(g_pickup_respawntime_ammo)); ATTRIB(Ammo, m_respawntimejitter, float(), GET(g_pickup_respawntimejitter_ammo)); + ATTRIB(Ammo, m_pickupanyway, float(), GET(g_pickup_ammo_anyway)); #endif ENDCLASS(Ammo) diff --git a/qcsrc/common/items/item/armor.qh b/qcsrc/common/items/item/armor.qh index 9fcd07634..f153bf06e 100644 --- a/qcsrc/common/items/item/armor.qh +++ b/qcsrc/common/items/item/armor.qh @@ -18,6 +18,9 @@ ENDCLASS(Armor) MODEL(ArmorSmall_ITEM, Item_Model("item_armor_small.md3")); SOUND(ArmorSmall, Item_Sound("armor1")); #endif +#ifdef SVQC +PROPERTY(float, g_pickup_armorsmall_anyway); +#endif REGISTER_ITEM(ArmorSmall, Armor) { #ifdef GAMEQC @@ -30,6 +33,7 @@ REGISTER_ITEM(ArmorSmall, Armor) { this.m_itemid = IT_ARMOR_SHARD; this.m_respawntime = GET(g_pickup_respawntime_short); this.m_respawntimejitter = GET(g_pickup_respawntimejitter_short); + this.m_pickupanyway = GET(g_pickup_armorsmall_anyway); #endif } @@ -37,6 +41,9 @@ REGISTER_ITEM(ArmorSmall, Armor) { MODEL(ArmorMedium_ITEM, Item_Model("item_armor_medium.md3")); SOUND(ArmorMedium, Item_Sound("armor10")); #endif +#ifdef SVQC +PROPERTY(float, g_pickup_armormedium_anyway); +#endif REGISTER_ITEM(ArmorMedium, Armor) { #ifdef GAMEQC @@ -49,6 +56,7 @@ REGISTER_ITEM(ArmorMedium, Armor) { this.m_itemid = IT_ARMOR; this.m_respawntime = GET(g_pickup_respawntime_medium); this.m_respawntimejitter = GET(g_pickup_respawntimejitter_medium); + this.m_pickupanyway = GET(g_pickup_armormedium_anyway); #endif } @@ -56,6 +64,9 @@ REGISTER_ITEM(ArmorMedium, Armor) { MODEL(ArmorBig_ITEM, Item_Model("item_armor_big.md3")); SOUND(ArmorBig, Item_Sound("armor17_5")); #endif +#ifdef SVQC +PROPERTY(float, g_pickup_armorbig_anyway); +#endif REGISTER_ITEM(ArmorBig, Armor) { #ifdef GAMEQC @@ -70,6 +81,7 @@ REGISTER_ITEM(ArmorBig, Armor) { this.m_itemid = IT_ARMOR; this.m_respawntime = GET(g_pickup_respawntime_long); this.m_respawntimejitter = GET(g_pickup_respawntimejitter_long); + this.m_pickupanyway = GET(g_pickup_armorbig_anyway); #endif } @@ -77,6 +89,9 @@ REGISTER_ITEM(ArmorBig, Armor) { MODEL(ArmorMega_ITEM, Item_Model("item_armor_large.md3")); SOUND(ArmorMega, Item_Sound("armor25")); #endif +#ifdef SVQC +PROPERTY(float, g_pickup_armormega_anyway); +#endif REGISTER_ITEM(ArmorMega, Armor) { #ifdef GAMEQC @@ -93,5 +108,6 @@ REGISTER_ITEM(ArmorMega, Armor) { this.m_itemid = IT_ARMOR; this.m_respawntime = GET(g_pickup_respawntime_long); this.m_respawntimejitter = GET(g_pickup_respawntimejitter_long); + this.m_pickupanyway = GET(g_pickup_armormega_anyway); #endif } diff --git a/qcsrc/common/items/item/health.qh b/qcsrc/common/items/item/health.qh index e32d0ebbd..1fc544a40 100644 --- a/qcsrc/common/items/item/health.qh +++ b/qcsrc/common/items/item/health.qh @@ -18,6 +18,9 @@ ENDCLASS(Health) MODEL(HealthSmall_ITEM, Item_Model("g_h1.md3")); SOUND(HealthSmall, Item_Sound("minihealth")); #endif +#ifdef SVQC +PROPERTY(float, g_pickup_healthsmall_anyway); +#endif REGISTER_ITEM(HealthSmall, Health) { #ifdef GAMEQC @@ -30,6 +33,7 @@ REGISTER_ITEM(HealthSmall, Health) { this.m_itemid = IT_5HP; this.m_respawntime = GET(g_pickup_respawntime_short); this.m_respawntimejitter = GET(g_pickup_respawntimejitter_short); + this.m_pickupanyway = GET(g_pickup_healthsmall_anyway); #endif } @@ -37,6 +41,9 @@ REGISTER_ITEM(HealthSmall, Health) { MODEL(HealthMedium_ITEM, Item_Model("g_h25.md3")); SOUND(HealthMedium, Item_Sound("mediumhealth")); #endif +#ifdef SVQC +PROPERTY(float, g_pickup_healthmedium_anyway); +#endif REGISTER_ITEM(HealthMedium, Health) { #ifdef GAMEQC @@ -49,6 +56,7 @@ REGISTER_ITEM(HealthMedium, Health) { this.m_itemid = IT_25HP; this.m_respawntime = GET(g_pickup_respawntime_short); this.m_respawntimejitter = GET(g_pickup_respawntimejitter_short); + this.m_pickupanyway = GET(g_pickup_healthmedium_anyway); #endif } @@ -56,6 +64,9 @@ REGISTER_ITEM(HealthMedium, Health) { MODEL(HealthBig_ITEM, Item_Model("g_h50.md3")); SOUND(HealthBig, Item_Sound("mediumhealth")); #endif +#ifdef SVQC +PROPERTY(float, g_pickup_healthbig_anyway); +#endif REGISTER_ITEM(HealthBig, Health) { #ifdef GAMEQC @@ -70,6 +81,7 @@ REGISTER_ITEM(HealthBig, Health) { this.m_itemid = IT_25HP; this.m_respawntime = GET(g_pickup_respawntime_medium); this.m_respawntimejitter = GET(g_pickup_respawntimejitter_medium); + this.m_pickupanyway = GET(g_pickup_healthbig_anyway); #endif } @@ -77,6 +89,9 @@ REGISTER_ITEM(HealthBig, Health) { MODEL(HealthMega_ITEM, Item_Model("g_h100.md3")); SOUND(HealthMega, Item_Sound("megahealth")); #endif +#ifdef SVQC +PROPERTY(float, g_pickup_healthmega_anyway); +#endif REGISTER_ITEM(HealthMega, Health) { #ifdef GAMEQC @@ -93,5 +108,6 @@ REGISTER_ITEM(HealthMega, Health) { this.m_itemid = IT_HEALTH; this.m_respawntime = GET(g_pickup_respawntime_long); this.m_respawntimejitter = GET(g_pickup_respawntimejitter_long); + this.m_pickupanyway = GET(g_pickup_healthmega_anyway); #endif } diff --git a/qcsrc/common/items/item/pickup.qh b/qcsrc/common/items/item/pickup.qh index af83fb9c8..26771e68d 100644 --- a/qcsrc/common/items/item/pickup.qh +++ b/qcsrc/common/items/item/pickup.qh @@ -42,6 +42,7 @@ CLASS(Pickup, GameItem) ATTRIB(Pickup, m_pickupevalfunc, float(entity player, entity item), generic_pickupevalfunc); ATTRIB(Pickup, m_respawntime, float()); ATTRIB(Pickup, m_respawntimejitter, float()); + ATTRIB(Pickup, m_pickupanyway, float()); float Item_GiveTo(entity item, entity player); METHOD(Pickup, giveTo, bool(Pickup this, entity item, entity player)) { diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 852a92814..9aab742d0 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -1083,6 +1083,9 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default this.respawntimejitter = defaultrespawntimejitter; } + if(!this.pickup_anyway && def.m_pickupanyway) + this.pickup_anyway = def.m_pickupanyway(); + int itemid = def.m_itemid; this.items = itemid; int weaponid = def.instanceOfWeaponPickup ? def.m_weapon.m_id : 0; @@ -1282,8 +1285,6 @@ spawnfunc(item_rockets) { if(!this.ammo_rockets) this.ammo_rockets = g_pickup_rockets; - if(!this.pickup_anyway) - this.pickup_anyway = g_pickup_ammo_anyway; StartItem(this, ITEM_Rockets); } @@ -1301,8 +1302,6 @@ spawnfunc(item_bullets) if(!this.ammo_nails) this.ammo_nails = g_pickup_nails; - if(!this.pickup_anyway) - this.pickup_anyway = g_pickup_ammo_anyway; StartItem(this, ITEM_Bullets); } @@ -1310,8 +1309,6 @@ spawnfunc(item_cells) { if(!this.ammo_cells) this.ammo_cells = g_pickup_cells; - if(!this.pickup_anyway) - this.pickup_anyway = g_pickup_ammo_anyway; StartItem(this, ITEM_Cells); } @@ -1319,8 +1316,6 @@ spawnfunc(item_plasma) { if(!this.ammo_plasma) this.ammo_plasma = g_pickup_plasma; - if(!this.pickup_anyway) - this.pickup_anyway = g_pickup_ammo_anyway; StartItem(this, ITEM_Plasma); } @@ -1338,8 +1333,6 @@ spawnfunc(item_shells) if(!this.ammo_shells) this.ammo_shells = g_pickup_shells; - if(!this.pickup_anyway) - this.pickup_anyway = g_pickup_ammo_anyway; StartItem(this, ITEM_Shells); } @@ -1349,8 +1342,6 @@ spawnfunc(item_armor_small) this.armorvalue = g_pickup_armorsmall; if(!this.max_armorvalue) this.max_armorvalue = g_pickup_armorsmall_max; - if(!this.pickup_anyway) - this.pickup_anyway = g_pickup_armorsmall_anyway; StartItem(this, ITEM_ArmorSmall); } @@ -1360,8 +1351,6 @@ spawnfunc(item_armor_medium) this.armorvalue = g_pickup_armormedium; if(!this.max_armorvalue) this.max_armorvalue = g_pickup_armormedium_max; - if(!this.pickup_anyway) - this.pickup_anyway = g_pickup_armormedium_anyway; StartItem(this, ITEM_ArmorMedium); } @@ -1371,8 +1360,6 @@ spawnfunc(item_armor_big) this.armorvalue = g_pickup_armorbig; if(!this.max_armorvalue) this.max_armorvalue = g_pickup_armorbig_max; - if(!this.pickup_anyway) - this.pickup_anyway = g_pickup_armorbig_anyway; StartItem(this, ITEM_ArmorBig); } @@ -1382,8 +1369,6 @@ spawnfunc(item_armor_mega) this.armorvalue = g_pickup_armormega; if(!this.max_armorvalue) this.max_armorvalue = g_pickup_armormega_max; - if(!this.pickup_anyway) - this.pickup_anyway = g_pickup_armormega_anyway; StartItem(this, ITEM_ArmorMega); } @@ -1393,8 +1378,6 @@ spawnfunc(item_health_small) this.max_health = g_pickup_healthsmall_max; if(!this.health) this.health = g_pickup_healthsmall; - if(!this.pickup_anyway) - this.pickup_anyway = g_pickup_healthsmall_anyway; StartItem(this, ITEM_HealthSmall); } @@ -1404,8 +1387,6 @@ spawnfunc(item_health_medium) this.max_health = g_pickup_healthmedium_max; if(!this.health) this.health = g_pickup_healthmedium; - if(!this.pickup_anyway) - this.pickup_anyway = g_pickup_healthmedium_anyway; StartItem(this, ITEM_HealthMedium); } @@ -1415,8 +1396,6 @@ spawnfunc(item_health_big) this.max_health = g_pickup_healthbig_max; if(!this.health) this.health = g_pickup_healthbig; - if(!this.pickup_anyway) - this.pickup_anyway = g_pickup_healthbig_anyway; StartItem(this, ITEM_HealthBig); } @@ -1426,8 +1405,6 @@ spawnfunc(item_health_mega) this.max_health = g_pickup_healthmega_max; if(!this.health) this.health = g_pickup_healthmega; - if(!this.pickup_anyway) - this.pickup_anyway = g_pickup_healthmega_anyway; StartItem(this, ITEM_HealthMega); } @@ -1591,8 +1568,6 @@ spawnfunc(item_fuel) { if(!this.ammo_fuel) this.ammo_fuel = g_pickup_fuel; - if(!this.pickup_anyway) - this.pickup_anyway = g_pickup_ammo_anyway; StartItem(this, ITEM_JetpackFuel); } diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index eb0f3a910..b6eab56bb 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -175,29 +175,20 @@ float g_pickup_fuel_jetpack; float g_pickup_fuel_max; float g_pickup_armorsmall; float g_pickup_armorsmall_max; -float g_pickup_armorsmall_anyway; float g_pickup_armormedium; float g_pickup_armormedium_max; -float g_pickup_armormedium_anyway; float g_pickup_armorbig; float g_pickup_armorbig_max; -float g_pickup_armorbig_anyway; float g_pickup_armormega; float g_pickup_armormega_max; -float g_pickup_armormega_anyway; float g_pickup_healthsmall; float g_pickup_healthsmall_max; -float g_pickup_healthsmall_anyway; float g_pickup_healthmedium; float g_pickup_healthmedium_max; -float g_pickup_healthmedium_anyway; float g_pickup_healthbig; float g_pickup_healthbig_max; -float g_pickup_healthbig_anyway; float g_pickup_healthmega; float g_pickup_healthmega_max; -float g_pickup_healthmega_anyway; -float g_pickup_ammo_anyway; float g_pickup_weapons_anyway; float g_weaponarena; WepSet g_weaponarena_weapons; -- 2.39.2