#define EFFECT(istrail, name, realname) \
REGISTER(RegisterEffects, EFFECT, Effects, name, m_id, Create_Effect_Entity(realname, istrail));
-void RegisterEffects_First()
-{
- #ifdef SVQC
- #define dedi (server_is_dedicated ? "a dedicated " : "")
- #else
- #define dedi ""
- #endif
-
- LOG_TRACEF("Beginning effect initialization on %s%s program...\n", dedi, PROGNAME);
- #undef dedi
-}
-
-void RegisterEffects_Done()
-{
- LOG_TRACE("Effects initialization successful!\n");
-}
-
-// NOW we actually activate the declarations
-ACCUMULATE_FUNCTION(RegisterEffects, RegisterEffects_First)
EFFECT(0, Null, string_null)
#include "all.inc"
-ACCUMULATE_FUNCTION(RegisterEffects, RegisterEffects_Done)
#endif
{
WriteByte(MSG_ENTITY, ENT_CLIENT_INVENTORY);
entity e = self.owner;
- if (IS_SPEC(e)) e = e.enemy;
+ if (/*IS_SPEC(e)*/ (e.classname == "spectator")) e = e.enemy;
Inventory data = e.inventory;
Inventory_Write(data);
return true;
void Inventory_new(entity e)
{
Inventory inv = new(Inventory), bak = new(Inventory);
- inv.classname = "inventory", bak.classname = "inventory";
+ inv.classname = bak.classname = "inventory";
inv.inventory = bak;
inv.drawonlytoclient = e;
Net_LinkEntity((inv.owner = e).inventory = inv, false, 0, Inventory_Send);
#ifndef MENUQC
MODEL(ArmorSmall_ITEM, Item_Model("item_armor_small.md3"));
+SOUND(ArmorSmall, "misc/armor1.wav");
#endif
REGISTER_ITEM(ArmorSmall, Armor) {
#ifndef MENUQC
this.m_model = MDL_ArmorSmall_ITEM;
+ this.m_sound = SND_ArmorSmall;
#endif
- this.m_sound = "misc/armor1.wav";
this.m_name = "5 Armor";
this.m_icon = "armor";
#ifdef SVQC
#ifndef MENUQC
MODEL(ArmorMedium_ITEM, Item_Model("item_armor_medium.md3"));
+SOUND(ArmorMedium, "misc/armor10.wav");
#endif
REGISTER_ITEM(ArmorMedium, Armor) {
#ifndef MENUQC
this.m_model = MDL_ArmorMedium_ITEM;
+ this.m_sound = SND_ArmorMedium;
#endif
- this.m_sound = "misc/armor10.wav";
this.m_name = "25 Armor";
this.m_icon = "armor";
#ifdef SVQC
#ifndef MENUQC
MODEL(ArmorLarge_ITEM, Item_Model("item_armor_big.md3"));
+SOUND(ArmorLarge, "misc/armor17_5.wav");
#endif
REGISTER_ITEM(ArmorLarge, Armor) {
#ifndef MENUQC
this.m_model = MDL_ArmorLarge_ITEM;
+ this.m_sound = SND_ArmorLarge;
#endif
- this.m_sound = "misc/armor17_5.wav";
this.m_name = "50 Armor";
this.m_icon = "armor";
this.m_color = '0 1 0';
#ifndef MENUQC
MODEL(ArmorMega_ITEM, Item_Model("item_armor_large.md3"));
+SOUND(ArmorMega, "misc/armor25.wav");
#endif
REGISTER_ITEM(ArmorMega, Armor) {
#ifndef MENUQC
this.m_model = MDL_ArmorMega_ITEM;
+ this.m_sound = SND_ArmorMega;
#endif
- this.m_sound = "misc/armor25.wav";
this.m_name = "100 Armor";
this.m_icon = "item_large_armor";
this.m_color = '0 1 0';
#ifndef MENUQC
MODEL(HealthSmall_ITEM, Item_Model("g_h1.md3"));
+SOUND(HealthSmall, "misc/minihealth.ogg");
#endif
REGISTER_ITEM(HealthSmall, Health) {
#ifndef MENUQC
this.m_model = MDL_HealthSmall_ITEM;
+ this.m_sound = SND_HealthSmall;
#endif
- this.m_sound = "misc/minihealth.wav";
this.m_name = "5 Health";
this.m_icon = "health";
#ifdef SVQC
#ifndef MENUQC
MODEL(HealthMedium_ITEM, Item_Model("g_h25.md3"));
+SOUND(HealthMedium, "misc/mediumhealth.ogg");
#endif
REGISTER_ITEM(HealthMedium, Health) {
#ifndef MENUQC
this.m_model = MDL_HealthMedium_ITEM;
+ this.m_sound = SND_HealthMedium;
#endif
- this.m_sound = "misc/mediumhealth.wav";
this.m_name = "25 Health";
this.m_icon = "health";
#ifdef SVQC
#ifndef MENUQC
MODEL(HealthLarge_ITEM, Item_Model("g_h50.md3"));
+SOUND(HealthLarge, "misc/mediumhealth.ogg");
#endif
REGISTER_ITEM(HealthLarge, Health) {
#ifndef MENUQC
this.m_model = MDL_HealthLarge_ITEM;
+ this.m_sound = SND_HealthLarge;
#endif
- this.m_sound = "misc/mediumhealth.wav";
this.m_name = "50 Health";
this.m_icon = "health";
this.m_color = '1 0 0';
#ifndef MENUQC
MODEL(HealthMega_ITEM, Item_Model("g_h100.md3"));
+SOUND(HealthMega, "misc/megahealth.ogg");
#endif
REGISTER_ITEM(HealthMega, Health) {
#ifndef MENUQC
this.m_model = MDL_HealthMega_ITEM;
+ this.m_sound = SND_HealthMega;
#endif
- this.m_sound = "misc/megahealth.wav";
this.m_name = "100 Health";
this.m_icon = "item_mega_health";
this.m_color = '1 0 0';
CLASS(Pickup, GameItem)
#ifndef MENUQC
ATTRIB(Pickup, m_model, Model, NULL)
+ ATTRIB(Pickup, m_sound, Sound, SND_ITEMPICKUP)
#endif
- ATTRIB(Pickup, m_sound, string, "misc/itempickup.wav")
ATTRIB(Pickup, m_name, string, string_null)
METHOD(Pickup, show, void(entity this));
void Pickup_show(entity this) { LOG_INFOF("%s: %s\n", etos(this), this.m_name); }
ATTRIB(Pickup, m_botvalue, int, 0)
ATTRIB(Pickup, m_itemflags, int, 0)
ATTRIB(Pickup, m_itemid, int, 0)
+ float generic_pickupevalfunc(entity player, entity item);
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)
- METHOD(Pickup, giveTo, bool(entity this, entity item, entity player));
- bool Pickup_giveTo(entity this, entity item, entity player) { return Item_GiveTo(item, player); }
+ float Item_GiveTo(entity item, entity player);
+ METHOD(Pickup, giveTo, bool(entity this, entity item, entity player))
+ { return Item_GiveTo(item, player); }
bool ITEM_HANDLE(Pickup, entity this, entity item, entity player);
#endif
ENDCLASS(Pickup)
-#ifdef SVQC
-// For g_pickup_respawntime
-#include "../../../server/defs.qh"
-// Getters to dynamically retrieve the values of g_pickup_respawntime*
-GETTER(float, g_pickup_respawntime_weapon)
-GETTER(float, g_pickup_respawntime_superweapon)
-GETTER(float, g_pickup_respawntime_ammo)
-GETTER(float, g_pickup_respawntime_short)
-GETTER(float, g_pickup_respawntime_medium)
-GETTER(float, g_pickup_respawntime_long)
-GETTER(float, g_pickup_respawntime_powerup)
-GETTER(float, g_pickup_respawntimejitter_weapon)
-GETTER(float, g_pickup_respawntimejitter_superweapon)
-GETTER(float, g_pickup_respawntimejitter_ammo)
-GETTER(float, g_pickup_respawntimejitter_short)
-GETTER(float, g_pickup_respawntimejitter_medium)
-GETTER(float, g_pickup_respawntimejitter_long)
-GETTER(float, g_pickup_respawntimejitter_powerup)
-
-#endif
-
#endif
#ifndef MENUQC
MODEL(Strength_ITEM, Item_Model("g_strength.md3"));
+SOUND(Strength, "misc/powerup.ogg");
#endif
REGISTER_ITEM(Strength, Powerup) {
#ifndef MENUQC
this.m_model = MDL_Strength_ITEM;
+ this.m_sound = SND_Strength;
#endif
- this.m_sound = "misc/powerup.wav";
this.m_name = "Strength Powerup";
this.m_icon = "strength";
this.m_color = '0 0 1';
#ifndef MENUQC
MODEL(Shield_ITEM, Item_Model("g_invincible.md3"));
+SOUND(Shield, "misc/powerup_shield.ogg");
#endif
REGISTER_ITEM(Shield, Powerup) {
#ifndef MENUQC
this.m_model = MDL_Shield_ITEM;
+ this.m_sound = SND_Shield;
#endif
- this.m_sound = "misc/powerup_shield.wav";
this.m_name = "Shield";
this.m_icon = "shield";
this.m_color = '1 0 1';
#ifndef MENUQC
MODEL(VaporizerCells_ITEM, Item_Model("a_cells.md3"));
+SOUND(VaporizerCells, "misc/itempickup.ogg");
#endif
REGISTER_ITEM(VaporizerCells, Ammo) {
#ifndef MENUQC
this.m_model = MDL_VaporizerCells_ITEM;
+ this.m_sound = SND_VaporizerCells;
#endif
- this.m_sound = "misc/itempickup.wav";
this.m_name = "Vaporizer Ammo";
this.m_icon = "ammo_supercells";
#ifdef SVQC
#ifndef MENUQC
MODEL(ExtraLife_ITEM, Item_Model("g_h100.md3"));
+SOUND(ExtraLife, "misc/megahealth.ogg");
#endif
REGISTER_ITEM(ExtraLife, Powerup) {
#ifndef MENUQC
this.m_model = MDL_ExtraLife_ITEM;
+ this.m_sound = SND_ExtraLife;
#endif
- this.m_sound = "misc/megahealth.wav";
this.m_name = "Extra life";
this.m_icon = "item_mega_health";
this.m_color = '1 0 0';
#ifndef MENUQC
MODEL(Invisibility_ITEM, Item_Model("g_strength.md3"));
+SOUND(Invisibility, "misc/powerup.ogg");
#endif
REGISTER_ITEM(Invisibility, Powerup) {
#ifndef MENUQC
this.m_model = MDL_Invisibility_ITEM;
+ this.m_sound = SND_Invisibility;
#endif
- this.m_sound = "misc/powerup.wav";
this.m_name = "Invisibility";
this.m_icon = "strength";
this.m_color = '0 0 1';
#ifndef MENUQC
MODEL(Speed_ITEM, Item_Model("g_invincible.md3"));
+SOUND(Speed, "misc/powerup_shield.ogg");
#endif
REGISTER_ITEM(Speed, Powerup) {
#ifndef MENUQC
this.m_model = MDL_Speed_ITEM;
+ this.m_sound = SND_Speed;
#endif
- this.m_sound = "misc/powerup_shield.wav";
this.m_name = "Speed";
this.m_icon = "shield";
this.m_color = '1 0 1';
REGISTRY(Weapons, 72) // Increase as needed. Can be up to 72.
REGISTER_REGISTRY(RegisterWeapons)
+STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, LAMBDA(it.m_pickup = NEW(WeaponPickup, it))); }
entity get_weaponinfo(int id);
/** M: wepname : human readable name */
ATTRIB(Weapon, message, string, "AOL CD Thrower");
+ ATTRIB(Weapon, m_pickup, entity, NULL);
+
/** (SERVER) setup weapon data */
METHOD(Weapon, wr_setup, void(Weapon this)) {}
/** (SERVER) logic to run every frame */
}
ENDCLASS(Weapon)
+#include "../items/all.qh"
+CLASS(WeaponPickup, Pickup)
+#ifndef MENUQC
+ ATTRIB(WeaponPickup, m_sound, Sound, SND_WEAPONPICKUP)
+#endif
+#ifdef SVQC
+ float weapon_pickupevalfunc(entity player, entity item);
+ ATTRIB(WeaponPickup, m_pickupevalfunc, float(entity player, entity item), weapon_pickupevalfunc)
+#endif
+ CONSTRUCTOR(WeaponPickup, Weapon w) {
+ CONSTRUCT(WeaponPickup);
+#ifndef MENUQC
+ this.m_model = w.m_model;
+#endif
+#ifdef SVQC
+ this.m_botvalue = w.bot_pickupbasevalue;
+#endif
+ }
+ENDCLASS(WeaponPickup)
+
CLASS(OffhandWeapon, Object)
METHOD(OffhandWeapon, offhand_think, void(OffhandWeapon this, entity player, bool key_pressed)) {}
ENDCLASS(OffhandWeapon)
#define GET(name) name##get
#define GETTER(type, name) type GET(name)() { return name; }
-
+#define PROPERTY(type, name) type name; GETTER(type, name)
#define LAMBDA(...) { __VA_ARGS__ ; }
// Can't wrap with do-while as block may contain continue or break
class(cname) .type name[cnt];
#define ENDCLASS(cname) \
- [[last]] INIT(cname) { return this; }
+ INIT(cname) { return this; }
#define SUPER(cname) (cname##_vtbl.vtblbase)
#define super (this.vtblbase.vtblbase)
#ifndef SERVER_ALL_H
#define SERVER_ALL_H
+#include "../common/effects/all.qh"
+#include "../common/models/all.qh"
+#include "../common/sounds/all.qh"
+
#include "autocvars.qh"
#include "constants.qh"
#include "defs.qh"
#include "miscfunctions.qh"
-
-#include "../common/effects/all.qh"
-#include "../common/models/all.qh"
-#include "../common/sounds/all.qh"
-
#endif
float g_warmup_allguns;
float g_warmup_allow_timeout;
float warmup_stage;
-float g_pickup_respawntime_weapon;
-float g_pickup_respawntime_superweapon;
-float g_pickup_respawntime_ammo;
-float g_pickup_respawntime_short;
-float g_pickup_respawntime_medium;
-float g_pickup_respawntime_long;
-float g_pickup_respawntime_powerup;
-float g_pickup_respawntimejitter_weapon;
-float g_pickup_respawntimejitter_superweapon;
-float g_pickup_respawntimejitter_ammo;
-float g_pickup_respawntimejitter_short;
-float g_pickup_respawntimejitter_medium;
-float g_pickup_respawntimejitter_long;
-float g_pickup_respawntimejitter_powerup;
+PROPERTY(float, g_pickup_respawntime_weapon)
+PROPERTY(float, g_pickup_respawntime_superweapon)
+PROPERTY(float, g_pickup_respawntime_ammo)
+PROPERTY(float, g_pickup_respawntime_short)
+PROPERTY(float, g_pickup_respawntime_medium)
+PROPERTY(float, g_pickup_respawntime_long)
+PROPERTY(float, g_pickup_respawntime_powerup)
+PROPERTY(float, g_pickup_respawntimejitter_weapon)
+PROPERTY(float, g_pickup_respawntimejitter_superweapon)
+PROPERTY(float, g_pickup_respawntimejitter_ammo)
+PROPERTY(float, g_pickup_respawntimejitter_short)
+PROPERTY(float, g_pickup_respawntimejitter_medium)
+PROPERTY(float, g_pickup_respawntimejitter_long)
+PROPERTY(float, g_pickup_respawntimejitter_powerup)
float g_jetpack;
float sv_clones;
// string overrides entity
.string item_pickupsound;
.entity item_pickupsound_ent;
+.entity item_model_ent;
// definitions for weaponsystem
// more WEAPONTODO: move these to their proper files
RemoveItem();
}
-void _StartItem(entity this, string itemmodel, string pickupsound, float defaultrespawntime, float defaultrespawntimejitter, string itemname, float itemid, float weaponid, float itemflags, float(entity player, entity item) pickupevalfunc, float pickupbasevalue)
+void _StartItem(entity this, entity def, float defaultrespawntime, float defaultrespawntimejitter, string itemname, float itemid, float weaponid, float itemflags)
{
- startitem_failed = false;
-
- if(this.model == "")
- this.model = itemmodel;
+ Model itemmodel = def.m_model;
+ Sound pickupsound = def.m_sound;
+ float(entity player, entity item) pickupevalfunc = def.m_pickupevalfunc;
+ float pickupbasevalue = def.m_botvalue;
- if(this.model == "")
- {
- error(strcat("^1Tried to spawn ", itemname, " with no model!\n"));
- return;
- }
+ startitem_failed = false;
- if(this.item_pickupsound == "")
- this.item_pickupsound = pickupsound;
+ this.item_model_ent = itemmodel;
+ this.item_pickupsound_ent = pickupsound;
if(!this.respawntime) // both need to be set
{
this.bot_pickup = true;
this.bot_pickupevalfunc = pickupevalfunc;
this.bot_pickupbasevalue = pickupbasevalue;
- this.mdl = this.model;
+ this.mdl = this.model ? this.model : strzone(this.item_model_ent.model_str());
this.netname = itemname;
this.touch = Item_Touch;
setmodel(this, MDL_Null); // precision set below
}
}
-void StartItem(entity this, entity a)
+void StartItem(entity this, GameItem def)
{
- this.itemdef = a;
_StartItem(
this,
- strzone(a.m_model.model_str()), // itemmodel
- a.m_sound, // pickupsound
- a.m_respawntime(), // defaultrespawntime
- a.m_respawntimejitter(), // defaultrespawntimejitter
- a.m_name, // itemname
- a.m_itemid, // itemid
+ this.itemdef = def,
+ def.m_respawntime(), // defaultrespawntime
+ def.m_respawntimejitter(), // defaultrespawntimejitter
+ def.m_name, // itemname
+ def.m_itemid, // itemid
0, // weaponid
- a.m_itemflags, // itemflags
- a.m_pickupevalfunc, // pickupevalfunc
- a.m_botvalue // pickupbasevalue
+ def.m_itemflags // itemflags
);
}
.float is_item;
.entity itemdef;
-void _StartItem(entity this, string itemmodel, string pickupsound, float defaultrespawntime, float defaultrespawntimejitter, string itemname, float itemid, float weaponid, float itemflags, float(entity player, entity item) pickupevalfunc, float pickupbasevalue);
+void _StartItem(entity this, entity def, float defaultrespawntime, float defaultrespawntimejitter, string itemname, float itemid, float weaponid, float itemflags);
void target_items_use (void);
if (this.team)
f |= FL_NO_WEAPON_STAY;
+ GameItem def = e.m_pickup;
_StartItem(
this,
- strzone(e.m_model.model_str()), // itemmodel
- string_null, // pickupsound
+ this.itemdef = def,
this.respawntime, // defaultrespawntime
this.respawntimejitter, // defaultrespawntimejitter
e.message, // itemname
0, // itemid
e.weapon, // weaponid
- f, // itemflags
- weapon_pickupevalfunc, // pickupevalfunc
- e.bot_pickupbasevalue // pickupbasevalue
+ f // itemflags
);
- this.item_pickupsound_ent = SND_WEAPONPICKUP;
#if 0 // WEAPONTODO
if (this.modelindex) { // don't precache if this was removed
e.wr_init(e);