#include "item.qc"
#include "item/ammo.qc"
+#include "item/armor.qc"
#include "item/buff.qc"
+#include "item/health.qc"
#include "ammo.qh"
#include "../../../server/t_items.qh"
-#define REGISTER_AMMO(id, model, sound, name, itemid, basevalue) \
-REGISTER_ITEM(id, Ammo, LAMBDA({ \
- this.ammoModel = model; \
- this.ammoSound = sound; \
- this.ammoName = name; \
- this.ammoId = itemid; \
- this.ammoQuantity = basevalue; \
+#define REGISTER_AMMO(id, model, sound, name, itemid, botvalue) \
+REGISTER_ITEM(id, Ammo, LAMBDA({ \
+ this.m_model = model; \
+ this.m_sound = sound; \
+ this.m_respawntime = SPAWNTIME_AMMO; \
+ this.m_respawntimejitter = SPAWNTIME_AMMO; \
+ this.m_name = name; \
+ this.m_itemid = itemid; \
+ this.m_botvalue = botvalue; \
}))
-REGISTER_AMMO(Bullets,
- "models/items/a_bullets.mdl",
- "misc/itempickup.wav",
- "bullets",
- IT_NAILS,
- 2000
+REGISTER_AMMO(Bullets
+ , "models/items/a_bullets.mdl"
+ , "misc/itempickup.wav"
+ , "bullets"
+ , IT_NAILS
+ , 2000
)
-REGISTER_AMMO(Cells,
- "models/items/a_cells.md3",
- "misc/itempickup.wav",
- "cells",
- IT_ROCKETS,
- 2000
+REGISTER_AMMO(Cells
+ , "models/items/a_cells.md3"
+ , "misc/itempickup.wav"
+ , "cells"
+ , IT_ROCKETS
+ , 2000
)
-REGISTER_AMMO(Plasma,
- "models/items/a_cells.md3",
- "misc/itempickup.wav",
- "plasma",
- IT_ROCKETS,
- 2000
+REGISTER_AMMO(Plasma
+ , "models/items/a_cells.md3"
+ , "misc/itempickup.wav"
+ , "plasma"
+ , IT_ROCKETS
+ , 2000
)
-REGISTER_AMMO(Rockets,
- "models/items/a_rockets.md3",
- "misc/itempickup.wav",
- "rockets",
- IT_ROCKETS,
- 3000
+REGISTER_AMMO(Rockets
+ , "models/items/a_rockets.md3"
+ , "misc/itempickup.wav"
+ , "rockets"
+ , IT_ROCKETS
+ , 3000
)
-REGISTER_AMMO(Shells,
- "models/items/a_shells.md3",
- "misc/itempickup.wav",
- "shells",
- IT_SHELLS,
- 500
+REGISTER_AMMO(Shells
+ , "models/items/a_shells.md3"
+ , "misc/itempickup.wav"
+ , "shells"
+ , IT_SHELLS
+ , 500
)
-
-bool Ammo_respondTo(entity this, int request)
-{
- switch (request) {
- default: return false;
- case ITEM_SIGNAL(Default):
- print(strcat(this.ammoName, " responding\n"));
- return true;
- }
-}
#ifndef AMMO_H
#define AMMO_H
-#include "../item.qh"
-CLASS(Ammo, GameItem)
- METHOD(Ammo, respondTo, bool(entity, int))
- ATTRIB(Ammo, ammoModel, string, string_null)
- ATTRIB(Ammo, ammoSound, string, string_null)
- ATTRIB(Ammo, ammoName, string, string_null)
- ATTRIB(Ammo, ammoId, int, 0)
- ATTRIB(Ammo, ammoQuantity, int, 0)
+#include "pickup.qh"
+CLASS(Ammo, Pickup)
ENDCLASS(Ammo)
#endif
--- /dev/null
+#include "armor.qh"
+#include "../../../server/t_items.qh"
+
+#define REGISTER_ARMOR(id, model, sound, resp, name, itemid, botvalue) \
+REGISTER_ITEM(id, Armor, LAMBDA({ \
+ this.m_model = model; \
+ this.m_sound = sound; \
+ this.m_respawntime = resp; \
+ this.m_respawntimejitter = resp; \
+ this.m_name = name; \
+ this.m_itemid = itemid; \
+ this.m_botvalue = botvalue; \
+}))
+
+REGISTER_ARMOR(ArmorSmall
+ , "models/items/item_armor_small.md3"
+ , "misc/armor1.wav"
+ , SPAWNTIME_SHORT
+ , "5 Armor"
+ , IT_ARMOR_SHARD
+ , BOT_PICKUP_RATING_LOW
+)
+
+REGISTER_ARMOR(ArmorMedium
+ , "models/items/item_armor_medium.md3"
+ , "misc/armor10.wav"
+ , SPAWNTIME_MEDIUM
+ , "25 Armor"
+ , IT_ARMOR
+ , BOT_PICKUP_RATING_MID
+)
+
+REGISTER_ARMOR(ArmorBig
+ , "models/items/item_armor_big.md3"
+ , "misc/armor17_5.wav"
+ , SPAWNTIME_LONG
+ , "50 Armor"
+ , IT_ARMOR
+ , 20000 // FIXME: higher than BOT_PICKUP_RATING_HIGH?
+)
+
+REGISTER_ARMOR(ArmorLarge
+ , "models/items/item_armor_large.md3"
+ , "misc/armor25.wav"
+ , SPAWNTIME_LONG
+ , "100 Armor"
+ , IT_ARMOR
+ , BOT_PICKUP_RATING_HIGH
+)
--- /dev/null
+#ifndef ARMOR_H
+#define ARMOR_H
+#include "pickup.qh"
+CLASS(Armor, Pickup)
+ENDCLASS(Armor)
+#endif
--- /dev/null
+#include "health.qh"
+#include "../../../server/t_items.qh"
+
+#define REGISTER_HEALTH(id, model, sound, resp, name, itemid, botvalue) \
+REGISTER_ITEM(id, Health, LAMBDA({ \
+ this.m_model = model; \
+ this.m_sound = sound; \
+ this.m_respawntime = resp; \
+ this.m_respawntimejitter = resp; \
+ this.m_name = name; \
+ this.m_itemid = itemid; \
+ this.m_botvalue = botvalue; \
+}))
+
+REGISTER_HEALTH(HealthSmall
+ , "models/items/g_h1.md3"
+ , "misc/minihealth.wav"
+ , SPAWNTIME_SHORT
+ , "5 Health"
+ , IT_5HP
+ , BOT_PICKUP_RATING_LOW
+)
+
+REGISTER_HEALTH(HealthMedium
+ , "models/items/g_h25.md3"
+ , "misc/mediumhealth.wav"
+ , SPAWNTIME_SHORT
+ , "25 Health"
+ , IT_25HP
+ , BOT_PICKUP_RATING_MID
+)
+
+REGISTER_HEALTH(HealthLarge
+ , "models/items/g_h50.md3"
+ , "misc/mediumhealth.wav"
+ , SPAWNTIME_MEDIUM
+ , "50 Health"
+ , IT_25HP
+ , BOT_PICKUP_RATING_MID
+)
+
+REGISTER_HEALTH(HealthMega
+ , "models/items/g_h100.md3"
+ , "misc/megahealth.wav"
+ , SPAWNTIME_LONG
+ , "100 Health"
+ , IT_HEALTH
+ , BOT_PICKUP_RATING_HIGH
+)
--- /dev/null
+#ifndef HEALTH_H
+#define HEALTH_H
+#include "pickup.qh"
+CLASS(Health, Pickup)
+ENDCLASS(Health)
+#endif
--- /dev/null
+#ifndef PICKUP_H
+#define PICKUP_H
+#include "../item.qh"
+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_respawntime, int, 0)
+ ATTRIB(Pickup, m_respawntimejitter, int, 0)
+ ATTRIB(Pickup, m_name, string, string_null)
+ ATTRIB(Pickup, m_itemid, int, 0)
+ ATTRIB(Pickup, m_botvalue, int, 0)
+ENDCLASS(Pickup)
+
+#define SPAWNTIMES(_) \
+ _(WEAPON, weapon) \
+ _(AMMO, ammo) \
+ _(SHORT, short) \
+ _(MEDIUM, medium) \
+ _(LONG, long) \
+ /**/
+
+#define SPAWNTIMES_ENUM(id, idlc) SPAWNTIME_##id ,
+enum { SPAWNTIMES(SPAWNTIMES_ENUM) };
+#undef SPAWNTIMES_ENUM
+
+#ifdef SVQC
+#include "../../../server/defs.qh"
+
+#define SPAWNTIMES_MAP(id, idlc) i == SPAWNTIME_##id ? g_pickup_respawntime_##idlc :
+[[inline]] int spawntime(int i) { return SPAWNTIMES(SPAWNTIMES_MAP) 0; }
+#undef SPAWNTIMES_MAP
+
+#define SPAWNTIMES_MAP(id, idlc) i == SPAWNTIME_##id ? g_pickup_respawntimejitter_##idlc :
+[[inline]] int spawntimejitter(int i) { return SPAWNTIMES(SPAWNTIMES_MAP) 0; }
+#undef SPAWNTIMES_MAP
+#endif
+
+bool Pickup_respondTo(entity this, int request)
+{
+ switch (request) {
+ default: return false;
+ case ITEM_SIGNAL(Default):
+ print(strcat(this.m_name, " responding\n"));
+ return true;
+ }
+}
+
+#endif
// Macro to hide this implementation detail
#define NEW(cname) (spawn##cname(NULL, NULL))
-#define CLASS(cname, base) \
-entity spawn##cname(entity this, entity basevtbl) { \
- this = NEW(base); basevtbl = base##_vtbl; \
+#define CLASS(cname, base) \
+entity spawn##cname(entity this, entity basevtbl) { \
+ this = NEW(base); basevtbl = base##_vtbl; \
}
-#define METHOD(cname, name, prototype) \
-prototype cname##_##name; \
-.prototype name; \
-[[accumulate]] entity spawn##cname(entity this, entity basevtbl) { \
- this.name = cname##_##name; \
+#define METHOD(cname, name, prototype) \
+prototype cname##_##name; \
+.prototype name; \
+[[accumulate]] entity spawn##cname(entity this, entity basevtbl) { \
+ this.name = cname##_##name; \
}
-#define ATTRIB(cname, name, type, val) \
-.type name; \
-[[accumulate]] entity spawn##cname(entity this, entity basevtbl) { \
- this.name = val; \
+#define ATTRIB(cname, name, type, val) \
+.type name; \
+[[accumulate]] entity spawn##cname(entity this, entity basevtbl) { \
+ this.name = val; \
}
-#define ATTRIBARRAY(cname, name, type, cnt) \
+#define ATTRIBARRAY(cname, name, type, cnt) \
.type name[cnt];
-#define ENDCLASS(cname) \
-.bool instanceOf##cname; \
-entity cname##_vtbl; \
-[[last]] entity spawn##cname(entity this, entity basevtbl) { \
- this.instanceOf##cname = true; \
- this.classname = #cname; \
- if (!cname##_vtbl) cname##_vtbl = spawnVtbl(this, basevtbl); \
- return this; \
+#define ENDCLASS(cname) \
+.bool instanceOf##cname; \
+entity cname##_vtbl; \
+[[accumulate]] [[last]] entity spawn##cname(entity this, entity basevtbl) { \
+ this.instanceOf##cname = true; \
+ this.classname = #cname; \
+ if (!cname##_vtbl) cname##_vtbl = spawnVtbl(this, basevtbl); \
+ return this; \
}
#define SUPER(cname) (cname##_vtbl.vtblbase)
void StartItemA (entity a)
{
- StartItem(a.ammoModel, a.ammoSound, g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, a.ammoName, a.ammoId, 0, 0, commodity_pickupevalfunc, a.ammoQuantity);
+ StartItem(a.m_model, a.m_sound, spawntime(a.m_respawntime), spawntimejitter(a.m_respawntimejitter), a.m_name, a.m_itemid, 0, 0, commodity_pickupevalfunc, a.m_botvalue);
}
void spawnfunc_item_rockets (void) {
self.max_armorvalue = g_pickup_armorsmall_max;
if(!self.pickup_anyway)
self.pickup_anyway = g_pickup_armorsmall_anyway;
- StartItem ("models/items/item_armor_small.md3", "misc/armor1.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "5 Armor", IT_ARMOR_SHARD, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
+ StartItemA (ITEM_ArmorSmall);
}
void spawnfunc_item_armor_medium (void) {
self.max_armorvalue = g_pickup_armormedium_max;
if(!self.pickup_anyway)
self.pickup_anyway = g_pickup_armormedium_anyway;
- StartItem ("models/items/item_armor_medium.md3", "misc/armor10.wav", g_pickup_respawntime_medium, g_pickup_respawntimejitter_medium, "25 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
+ StartItemA (ITEM_ArmorMedium);
}
void spawnfunc_item_armor_big (void) {
self.max_armorvalue = g_pickup_armorbig_max;
if(!self.pickup_anyway)
self.pickup_anyway = g_pickup_armorbig_anyway;
- StartItem ("models/items/item_armor_big.md3", "misc/armor17_5.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "50 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, 20000);
+ StartItemA (ITEM_ArmorBig);
}
void spawnfunc_item_armor_large (void) {
self.max_armorvalue = g_pickup_armorlarge_max;
if(!self.pickup_anyway)
self.pickup_anyway = g_pickup_armorlarge_anyway;
- StartItem ("models/items/item_armor_large.md3", "misc/armor25.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "100 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
+ StartItemA (ITEM_ArmorLarge);
}
void spawnfunc_item_health_small (void) {
self.health = g_pickup_healthsmall;
if(!self.pickup_anyway)
self.pickup_anyway = g_pickup_healthsmall_anyway;
- StartItem ("models/items/g_h1.md3", "misc/minihealth.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "5 Health", IT_5HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
+ StartItemA (ITEM_HealthSmall);
}
void spawnfunc_item_health_medium (void) {
self.health = g_pickup_healthmedium;
if(!self.pickup_anyway)
self.pickup_anyway = g_pickup_healthmedium_anyway;
- StartItem ("models/items/g_h25.md3", "misc/mediumhealth.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "25 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
+ StartItemA (ITEM_HealthMedium);
}
void spawnfunc_item_health_large (void) {
self.health = g_pickup_healthlarge;
if(!self.pickup_anyway)
self.pickup_anyway = g_pickup_healthlarge_anyway;
- StartItem ("models/items/g_h50.md3", "misc/mediumhealth.wav", g_pickup_respawntime_medium, g_pickup_respawntimejitter_medium, "50 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
+ StartItemA (ITEM_HealthLarge);
}
void spawnfunc_item_health_mega (void) {
- if(!self.max_health)
- self.max_health = g_pickup_healthmega_max;
- if(!self.health)
- self.health = g_pickup_healthmega;
- if(!self.pickup_anyway)
- self.pickup_anyway = g_pickup_healthmega_anyway;
- StartItem ("models/items/g_h100.md3", "misc/megahealth.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "100 Health", IT_HEALTH, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
+ if(!self.max_health)
+ self.max_health = g_pickup_healthmega_max;
+ if(!self.health)
+ self.health = g_pickup_healthmega;
+ if(!self.pickup_anyway)
+ self.pickup_anyway = g_pickup_healthmega_anyway;
+ StartItemA (ITEM_HealthMega);
}
// support old misnamed entities