From ac7f397ceff9390594c5d9d331449192ba07f6f8 Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 12 May 2015 20:09:44 +1000 Subject: [PATCH] Add jetpack Fix incorrect ammo from ammo pickups --- qcsrc/common/items/all.inc | 1 + qcsrc/common/items/item/ammo.qc | 19 +++++----- qcsrc/common/items/item/armor.qc | 12 ++++--- qcsrc/common/items/item/health.qc | 12 ++++--- qcsrc/common/items/item/jetpack.qc | 56 ++++++++++++++++++++++++++++++ qcsrc/common/items/item/pickup.qh | 4 +-- qcsrc/common/items/item/powerup.qc | 4 +++ qcsrc/server/t_items.qc | 6 ++-- 8 files changed, 88 insertions(+), 26 deletions(-) create mode 100644 qcsrc/common/items/item/jetpack.qc diff --git a/qcsrc/common/items/all.inc b/qcsrc/common/items/all.inc index 6e2a6ba8c..5776b7ef2 100644 --- a/qcsrc/common/items/all.inc +++ b/qcsrc/common/items/all.inc @@ -4,4 +4,5 @@ #include "item/armor.qc" #include "item/buff.qc" #include "item/health.qc" +#include "item/jetpack.qc" #include "item/powerup.qc" diff --git a/qcsrc/common/items/item/ammo.qc b/qcsrc/common/items/item/ammo.qc index b6f9abcc6..449905ea5 100644 --- a/qcsrc/common/items/item/ammo.qc +++ b/qcsrc/common/items/item/ammo.qc @@ -1,5 +1,7 @@ #include "ammo.qh" -#include "../../../server/t_items.qh" +#ifdef SVQC + #include "../../../server/t_items.qh" +#endif #define WITH(it) this.m_##it; #define CONFIGURE(...) MAP(WITH, __VA_ARGS__) @@ -15,56 +17,51 @@ DEFINE(Bullets ,IF(ALL, CONFIGURE , model = "models/items/a_bullets.mdl" - , sound = "misc/itempickup.wav" , name = "bullets" - , itemid = IT_NAILS ) ,IF(SV, CONFIGURE , botvalue = 2000 + , itemid = IT_NAILS ) ) DEFINE(Cells ,IF(ALL, CONFIGURE , model = "models/items/a_cells.md3" - , sound = "misc/itempickup.wav" , name = "cells" - , itemid = IT_ROCKETS ) ,IF(SV, CONFIGURE , botvalue = 2000 + , itemid = IT_CELLS ) ) DEFINE(Plasma ,IF(ALL, CONFIGURE , model = "models/items/a_cells.md3" - , sound = "misc/itempickup.wav" , name = "plasma" - , itemid = IT_ROCKETS ) ,IF(SV, CONFIGURE , botvalue = 2000 + , itemid = IT_PLASMA ) ) DEFINE(Rockets ,IF(ALL, CONFIGURE , model = "models/items/a_rockets.md3" - , sound = "misc/itempickup.wav" , name = "rockets" - , itemid = IT_ROCKETS ) ,IF(SV, CONFIGURE , botvalue = 3000 + , itemid = IT_ROCKETS ) ) DEFINE(Shells ,IF(ALL, CONFIGURE , model = "models/items/a_shells.md3" - , sound = "misc/itempickup.wav" , name = "shells" - , itemid = IT_SHELLS ) ,IF(SV, CONFIGURE , botvalue = 500 + , itemid = IT_SHELLS ) ) diff --git a/qcsrc/common/items/item/armor.qc b/qcsrc/common/items/item/armor.qc index a5c52458c..8cbc9cd8a 100644 --- a/qcsrc/common/items/item/armor.qc +++ b/qcsrc/common/items/item/armor.qc @@ -1,5 +1,7 @@ #include "armor.qh" -#include "../../../server/t_items.qh" +#ifdef SVQC + #include "../../../server/t_items.qh" +#endif #define WITH(it) this.m_##it; #define CONFIGURE(...) MAP(WITH, __VA_ARGS__) @@ -10,10 +12,10 @@ DEFINE(ArmorSmall , model = "models/items/item_armor_small.md3" , sound = "misc/armor1.wav" , name = "5 Armor" - , itemid = IT_ARMOR_SHARD ) ,IF(SV, CONFIGURE , botvalue = BOT_PICKUP_RATING_LOW + , itemid = IT_ARMOR_SHARD , respawntime = GET(g_pickup_respawntime_short) , respawntimejitter = GET(g_pickup_respawntimejitter_short) ) @@ -24,10 +26,10 @@ DEFINE(ArmorMedium , model = "models/items/item_armor_medium.md3" , sound = "misc/armor10.wav" , name = "25 Armor" - , itemid = IT_ARMOR ) ,IF(SV, CONFIGURE , botvalue = BOT_PICKUP_RATING_MID + , itemid = IT_ARMOR , respawntime = GET(g_pickup_respawntime_medium) , respawntimejitter = GET(g_pickup_respawntimejitter_medium) ) @@ -38,10 +40,10 @@ DEFINE(ArmorBig , model = "models/items/item_armor_big.md3" , sound = "misc/armor17_5.wav" , name = "50 Armor" - , itemid = IT_ARMOR ) ,IF(SV, CONFIGURE , botvalue = 20000 // FIXME: higher than BOT_PICKUP_RATING_HIGH? + , itemid = IT_ARMOR , respawntime = GET(g_pickup_respawntime_long) , respawntimejitter = GET(g_pickup_respawntimejitter_long) ) @@ -52,10 +54,10 @@ DEFINE(ArmorLarge , model = "models/items/item_armor_large.md3" , sound = "misc/armor25.wav" , name = "100 Armor" - , itemid = IT_ARMOR ) ,IF(SV, CONFIGURE , botvalue = BOT_PICKUP_RATING_HIGH + , itemid = IT_ARMOR , respawntime = GET(g_pickup_respawntime_long) , respawntimejitter = GET(g_pickup_respawntimejitter_long) ) diff --git a/qcsrc/common/items/item/health.qc b/qcsrc/common/items/item/health.qc index 2b4a84bcf..fba35e2a9 100644 --- a/qcsrc/common/items/item/health.qc +++ b/qcsrc/common/items/item/health.qc @@ -1,5 +1,7 @@ #include "health.qh" -#include "../../../server/t_items.qh" +#ifdef SVQC + #include "../../../server/t_items.qh" +#endif #define WITH(it) this.m_##it; #define CONFIGURE(...) MAP(WITH, __VA_ARGS__) @@ -10,10 +12,10 @@ DEFINE(HealthSmall , model = "models/items/g_h1.md3" , sound = "misc/minihealth.wav" , name = "5 Health" - , itemid = IT_5HP ) ,IF(SV, CONFIGURE , botvalue = BOT_PICKUP_RATING_LOW + , itemid = IT_5HP , respawntime = GET(g_pickup_respawntime_short) , respawntimejitter = GET(g_pickup_respawntimejitter_short) ) @@ -24,10 +26,10 @@ DEFINE(HealthMedium , model = "models/items/g_h25.md3" , sound = "misc/mediumhealth.wav" , name = "25 Health" - , itemid = IT_25HP ) ,IF(SV, CONFIGURE , botvalue = BOT_PICKUP_RATING_MID + , itemid = IT_25HP , respawntime = GET(g_pickup_respawntime_short) , respawntimejitter = GET(g_pickup_respawntimejitter_short) ) @@ -38,10 +40,10 @@ DEFINE(HealthLarge , model = "models/items/g_h50.md3" , sound = "misc/mediumhealth.wav" , name = "50 Health" - , itemid = IT_25HP ) ,IF(SV, CONFIGURE , botvalue = BOT_PICKUP_RATING_MID + , itemid = IT_25HP , respawntime = GET(g_pickup_respawntime_medium) , respawntimejitter = GET(g_pickup_respawntimejitter_medium) ) @@ -52,10 +54,10 @@ DEFINE(HealthMega , model = "models/items/g_h100.md3" , sound = "misc/megahealth.wav" , name = "100 Health" - , itemid = IT_HEALTH ) ,IF(SV, CONFIGURE , botvalue = BOT_PICKUP_RATING_HIGH + , itemid = IT_HEALTH , respawntime = GET(g_pickup_respawntime_long) , respawntimejitter = GET(g_pickup_respawntimejitter_long) ) diff --git a/qcsrc/common/items/item/jetpack.qc b/qcsrc/common/items/item/jetpack.qc new file mode 100644 index 000000000..d130b06cf --- /dev/null +++ b/qcsrc/common/items/item/jetpack.qc @@ -0,0 +1,56 @@ +#ifdef SVQC + #include "../../../server/t_items.qh" + #include "../../../server/constants.qh" +#endif + +#define WITH(it) this.m_##it; +#define CONFIGURE(...) MAP(WITH, __VA_ARGS__) +#define DEFINE(id, ...) REGISTER_ITEM(id, Pickup, MAP(IDENTITY, __VA_ARGS__)) + +DEFINE(Jetpack + ,IF(ALL, CONFIGURE + , model = "models/items/g_jetpack.md3" + , name = "Jet pack" + ) + ,IF(SV, CONFIGURE + , botvalue = BOT_PICKUP_RATING_LOW + , itemflags = FL_POWERUP + , itemid = IT_JETPACK + , pickupevalfunc = commodity_pickupevalfunc + , respawntime = GET(g_pickup_respawntime_powerup) + , respawntimejitter = GET(g_pickup_respawntimejitter_powerup) + ) +) + +DEFINE(JetpackFuel + ,IF(ALL, CONFIGURE + , model = "models/items/g_fuel.md3" + , name = "Fuel" + ) + ,IF(SV, CONFIGURE + , botvalue = BOT_PICKUP_RATING_LOW + , itemid = IT_FUEL + , pickupevalfunc = commodity_pickupevalfunc + , respawntime = GET(g_pickup_respawntime_ammo) + , respawntimejitter = GET(g_pickup_respawntimejitter_ammo) + ) +) + +DEFINE(JetpackRegen + ,IF(ALL, CONFIGURE + , model = "models/items/g_fuelregen.md3" + , name = "Fuel regenerator" + ) + ,IF(SV, CONFIGURE + , botvalue = BOT_PICKUP_RATING_LOW + , itemflags = FL_POWERUP + , itemid = IT_FUEL_REGEN + , pickupevalfunc = commodity_pickupevalfunc + , respawntime = GET(g_pickup_respawntime_powerup) + , respawntimejitter = GET(g_pickup_respawntimejitter_powerup) + ) +) + +#undef WITH +#undef CONFIGURE +#undef DEFINE diff --git a/qcsrc/common/items/item/pickup.qh b/qcsrc/common/items/item/pickup.qh index 1bd644a7c..1bcbc3899 100644 --- a/qcsrc/common/items/item/pickup.qh +++ b/qcsrc/common/items/item/pickup.qh @@ -4,12 +4,12 @@ CLASS(Pickup, GameItem) METHOD(Pickup, respondTo, bool(entity, int)) ATTRIB(Pickup, m_model, string, string_null) - ATTRIB(Pickup, m_sound, string, string_null) + ATTRIB(Pickup, m_sound, string, "misc/itempickup.wav") ATTRIB(Pickup, m_name, string, string_null) - ATTRIB(Pickup, m_itemid, int, 0) #ifdef SVQC ATTRIB(Pickup, m_botvalue, int, 0) ATTRIB(Pickup, m_itemflags, int, 0) + ATTRIB(Pickup, m_itemid, int, 0) ATTRIB(Pickup, m_pickupevalfunc, float(entity player, entity item), generic_pickupevalfunc) ATTRIB(Pickup, m_respawntime, float(), func_null) ATTRIB(Pickup, m_respawntimejitter, float(), func_null) diff --git a/qcsrc/common/items/item/powerup.qc b/qcsrc/common/items/item/powerup.qc index 7270664d4..9100e0bb3 100644 --- a/qcsrc/common/items/item/powerup.qc +++ b/qcsrc/common/items/item/powerup.qc @@ -19,6 +19,8 @@ DEFINE(Strength , model = "models/items/g_strength.md3" , sound = "misc/powerup.wav" , name = "Strength Powerup" + ) + ,IF(SV, CONFIGURE , itemid = IT_STRENGTH ) ) @@ -27,6 +29,8 @@ DEFINE(Shield , model = "models/items/g_invincible.md3" , sound = "misc/powerup_shield.wav" , name = "Shield" + ) + ,IF(SV, CONFIGURE , itemid = IT_INVINCIBLE ) ) diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 8a8f74008..4a87edd0e 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -1478,7 +1478,7 @@ void spawnfunc_item_fuel(void) self.ammo_fuel = g_pickup_fuel; if(!self.pickup_anyway) self.pickup_anyway = g_pickup_ammo_anyway; - StartItem ("models/items/g_fuel.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "Fuel", IT_FUEL, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW); + StartItemA (ITEM_JetpackFuel); } void spawnfunc_item_fuel_regen(void) @@ -1488,7 +1488,7 @@ void spawnfunc_item_fuel_regen(void) spawnfunc_item_fuel(); return; } - StartItem ("models/items/g_fuelregen.md3", "misc/itempickup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Fuel regenerator", IT_FUEL_REGEN, 0, FL_POWERUP, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW); + StartItemA (ITEM_JetpackRegen); } void spawnfunc_item_jetpack(void) @@ -1500,7 +1500,7 @@ void spawnfunc_item_jetpack(void) spawnfunc_item_fuel(); return; } - StartItem ("models/items/g_jetpack.md3", "misc/itempickup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Jet pack", IT_JETPACK, 0, FL_POWERUP, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW); + StartItemA (ITEM_Jetpack); } float GiveWeapon(entity e, float wpn, float op, float val) -- 2.39.2