#ifdef SVQC
.float strength_finished; // NOTE: this field is used only by map entities, it does not directly apply the strength stat
.float invincible_finished; // ditto
+ .float buffs_finished; // ditts
-#define spawnfunc_body(item) \
- if (!Item_IsDefinitionAllowed(item)) \
+#define SPAWNFUNC_BODY(item) \
+ if (item && Item_IsDefinitionAllowed(item)) \
+ StartItem(this, item); \
+ else \
{ \
startitem_failed = true; \
delete(this); \
void buff_Init(entity ent);
void buff_Init_Compat(entity ent, entity replacement);
#define BUFF_SPAWNFUNC(e, b, t) spawnfunc(item_buff_##e) { \
- STAT(BUFFS, this) = b.m_itemid; \
+ this.buffdef = b; \
- this.team = t; \
+ if(teamplay) \
+ this.team_forced = t; \
buff_Init(this); \
}
#define BUFF_SPAWNFUNCS(e, b) \
{
if(autocvar_g_buffs_waypoint_distance <= 0) return;
- entity buff = buff_FirstFromFlags(STAT(BUFFS, e));
+ entity buff = e.buffdef;
- entity wp = WaypointSprite_Spawn(WP_Buff, 0, autocvar_g_buffs_waypoint_distance, e, '0 0 1' * e.maxs.z, NULL, e.team, e, buff_waypoint, true, RADARICON_Buff);
+ entity wp = WaypointSprite_Spawn(WP_Buff, 0, autocvar_g_buffs_waypoint_distance, e, '0 0 1' * e.maxs.z, NULL, e.team_forced, e, buff_waypoint, true, RADARICON_Buff);
wp.wp_extra = buff.m_id;
WaypointSprite_UpdateTeamRadar(e.buff_waypoint, RADARICON_Buff, e.glowmod);
e.buff_waypoint.waypointsprite_visible_for_player = buff_Waypoint_visible_for_player;
if(!IS_PLAYER(toucher))
return; // incase mutator changed toucher
- if((this.team && DIFF_TEAM(toucher, this))
+ if((this.team_forced && toucher.team != this.team_forced)
|| (STAT(FROZEN, toucher))
|| (toucher.vehicle)
+ || (!this.buffdef) // TODO: error out or maybe reset type if this occurs?
|| (time < PS(toucher).buff_shield)
)
{
bool buff_Customize(entity this, entity client)
{
entity player = WaypointSprite_getviewentity(client);
- if(!this.buff_active || (this.team_forced && player.team != this.team_forced))
- if((!this.buff_active || !this.buffdef) || (this.team && DIFF_TEAM(player, this)))
++ if((!this.buff_active || !this.buffdef) || (this.team_forced && player.team != this.team_forced))
{
this.alpha = 0.3;
if(this.effects & EF_FULLBRIGHT) { this.effects &= ~(EF_FULLBRIGHT); }
{
if(!cvar("g_buffs")) { delete(this); return; }
- entity buff = buff_FirstFromFlags(STAT(BUFFS, this));
- if(!teamplay && this.team) { this.team = 0; }
-
+ entity buff = this.buffdef;
- if(!STAT(BUFFS, this) || !buff_Available(buff))
+ if(!buff || !buff_Available(buff))
buff_NewType(this);
this.classname = "item_buff";
void buff_Init_Compat(entity ent, entity replacement)
{
- if (ent.spawnflags & 2)
- ent.team = NUM_TEAM_1;
- else if (ent.spawnflags & 4)
- ent.team = NUM_TEAM_2;
+ if (teamplay)
+ {
+ if (ent.spawnflags & 2)
+ ent.team_forced = NUM_TEAM_1;
+ else if (ent.spawnflags & 4)
+ ent.team_forced = NUM_TEAM_2;
+ }
- STAT(BUFFS, ent) = replacement.m_itemid;
+ ent.buffdef = replacement;
buff_Init(ent);
}
.float buff_effect_delay;
// buff definitions
-.float buff_active;
+.bool buff_active;
.float buff_activetime;
-.float buff_activetime_updated;
+.bool buff_activetime_updated;
.entity buff_waypoint;
- .int oldbuffs; // for updating effects
+ .entity oldbuffs; // for updating effects
.float buff_shield; // delay for players to keep them from spamming buff pickups
.entity buff_model; // controls effects (TODO: make csqc)
{
IL_EACH(g_items, it.targetname == this.target,
{
- if (it.classname == "weapon_devastator") {
- SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(devastator, ammo)); // WEAPONTODO
- this.netname = cons(this.netname, "devastator");
- }
- else if (it.classname == "weapon_vortex") {
- SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(vortex, ammo)); // WEAPONTODO
- this.netname = cons(this.netname, "vortex");
- }
- else if (it.classname == "weapon_electro") {
- SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(electro, ammo)); // WEAPONTODO
- this.netname = cons(this.netname, "electro");
- }
- else if (it.classname == "weapon_hagar") {
- SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(hagar, ammo)); // WEAPONTODO
- this.netname = cons(this.netname, "hagar");
- }
- else if (it.classname == "weapon_crylink") {
- SetResourceExplicit(this, RES_CELLS, GetResource(this, RES_CELLS) + it.count * WEP_CVAR_PRI(crylink, ammo)); // WEAPONTODO
- this.netname = cons(this.netname, "crylink");
- }
- else if (it.classname == "weapon_mortar") {
- SetResourceExplicit(this, RES_ROCKETS, GetResource(this, RES_ROCKETS) + it.count * WEP_CVAR_PRI(mortar, ammo)); // WEAPONTODO
- this.netname = cons(this.netname, "mortar");
- }
- else if (it.classname == "weapon_shotgun") {
- SetResourceExplicit(this, RES_SHELLS, GetResource(this, RES_SHELLS) + it.count * WEP_CVAR_PRI(shotgun, ammo)); // WEAPONTODO
- this.netname = cons(this.netname, "shotgun");
- }
- 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));
+ entity buff = it.buffdef;
this.netname = cons(this.netname, buff.netname);
- STAT(BUFF_TIME, this) += it.count;
- this.buffs_finished = it.count;
++ this.buffs_finished += it.count;
+ }
+ 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.health)
+ this.health += it.health;
+ else if (it.armorvalue)
+ this.armorvalue += it.armorvalue;
+
+ this.netname = cons(this.netname, it.netname);
}
//remove(it); // removing ents in init functions causes havoc, workaround:
bool lockteams;
+.int team_forced; // can be a team number to force a team, or 0 for default action, or -1 for forced spectator
+
// ========================== Global teams API ================================
+ void Team_InitTeams();
+
/// \brief Returns the global team entity at the given index.
/// \param[in] index Index of the team.
/// \return Global team entity at the given index.