djcev.com

//

Git Repos / fte_dogmode / qc / items / powerups.qc

Last update to this file was on 2025-03-30 at 19:29.

Show powerups.qc

//==============================================================================
// items/powerups.qc -- POWERUPS
//==============================================================================

//======================================================================
// forward declarations
//======================================================================

// base_item_powerup
#ifdef SSQC
// BASE_ITEM_POWERUP_RESPAWNDELAY(idx)
// BASE_ITEM_POWERUP_ADD(pl, idx)
void(entity grabber, entity power) base_item_powerup_grab;
void(entity attacker, float item_index) base_item_powerup_fire;
void() base_item_powerup_touch;
entity(entity src, vector org, vector vel, float fl, void(entity) init_fn)
spawn_base_item_powerup;
void(string key, string value) base_item_powerup_init_field;
#endif
#if defined(CSQC) || defined(SSQC)
void(entity e) base_item_powerup_init;
#endif
#ifdef SSQC
strip void() base_item_powerup;
#endif

// item_artifact_envirosuit
#ifdef CSQC
void(float isnew) item_artifact_envirosuit_netreceive;
#endif
#ifdef SSQC
entity(entity src, vector org, vector vel, float fl)
spawn_item_artifact_envirosuit;
#endif
#if defined(CSQC) || defined(SSQC)
void(entity e) item_artifact_envirosuit_init;
#endif
#ifdef SSQC
void() item_artifact_envirosuit;
#endif

// item_artifact_invisibility
#ifdef CSQC
void(float isnew) item_artifact_invisibility_netreceive;
#endif
#ifdef SSQC
entity(entity src, vector org, vector vel, float fl)
spawn_item_artifact_invisibility;
#endif
#if defined(CSQC) || defined(SSQC)
void(entity e) item_artifact_invisibility_init;
#endif
#ifdef SSQC
void() item_artifact_invisibility;
#endif

// item_artifact_invulnerability
#ifdef CSQC
void(float isnew) item_artifact_invulnerability_netreceive;
#endif
#ifdef SSQC
entity(entity src, vector org, vector vel, float fl)
spawn_item_artifact_invulnerability;
#endif
#if defined(CSQC) || defined(SSQC)
void(entity e) item_artifact_invulnerability_init;
#endif
#ifdef SSQC
void() item_artifact_invulnerability;
#endif

// item_artifact_super_damage
#ifdef CSQC
void(float isnew) item_artifact_super_damage_netreceive;
#endif
#ifdef SSQC
entity(entity src, vector org, vector vel, float fl)
spawn_item_artifact_super_damage;
#endif
#if defined(CSQC) || defined(SSQC)
void(entity e) item_artifact_super_damage_init;
#endif
#ifdef SSQC
void() item_artifact_super_damage;
#endif

//------------------------------------------------------------------------------

//----------------------------------------------------------------------
// class base_item_powerup: base_item
// {
#ifdef SSQC
//--------------------------------------------------------------
#define BASE_ITEM_POWERUP_RESPAWNDELAY(idx) \
{ \
local float delay_sp = 0; \
local float delay_dm = 0; \
if (deathmatch) \
{ \
if (idx == ITEM_SEQ_ARTIFACT_INVISIBILITY || \
idx == ITEM_SEQ_ARTIFACT_INVULNERABILITY) \
{ \
delay_dm = time + 60 * 5; \
} \
else \
{ \
delay_dm = time + 60; \
} \
} \
else \
{ \
if (idx == ITEM_SEQ_ARTIFACT_INVISIBILITY || \
idx == ITEM_SEQ_ARTIFACT_INVULNERABILITY) \
{ \
delay_sp = 300; \
} \
else \
{ \
delay_sp = 60; \
} \
} \
}

//--------------------------------------------------------------
#define BASE_ITEM_POWERUP_ADD(pl, idx) \
{ \
/* do the apropriate action */ \
if (idx == ITEM_SEQ_ARTIFACT_ENVIROSUIT) \
{ \
pl.items |= IT_SUIT; \
pl.rad_time = 1; \
pl.radsuit_finished = time + 30; \
} \
else if (idx == ITEM_SEQ_ARTIFACT_INVISIBILITY) \
{ \
pl.items |= IT_INVISIBILITY; \
pl.invisible_time = 1; \
pl.invisible_finished = time + 30; \
} \
else if (idx == ITEM_SEQ_ARTIFACT_INVULNERABILITY) \
{ \
pl.items |= IT_INVULNERABILITY; \
pl.invincible_time = 1; \
pl.invincible_finished = time + 30; \
} \
else if (idx == ITEM_SEQ_ARTIFACT_QUAD) \
{ \
pl.items |= IT_QUAD; \
pl.super_time = 1; \
pl.super_damage_finished = time + 30; \
} \
}

//--------------------------------------------------------------
void(entity grabber, entity power) base_item_powerup_grab =
{
BASE_ITEM_INVENTORY_ADD (power, grabber)

// don't re-grab / immediately throw the item -- CEV
if (grabber.button6)
grabber.flags |= FL_THROW_HELD;

// let the player know -- CEV
sprint (grabber, sprintf("%s grabbed the %s\n",
grabber.netname, power.netname));

// let the client (CSQC) know -- CEV
if (grabber.classtype == CT_PLAYER && grabber.SendEntity)
grabber.SendFlags |= NETFLAG_PLAYER_WEAPON;

// fire all targets / killtargets
local entity stemp = self;
local entity otemp = other;
other = grabber;
self = power;
activator = other;
sub_usetargets ();
self = stemp;
other = otemp;

// either remove the item or set up for respawning -- CEV
power.mdl = power.model;
BASE_ITEM_POWERUP_RESPAWNDELAY (power.weapon)
BASE_ITEM_CHECKREMOVE (power, delay_sp, delay_dm)
};

//--------------------------------------------------------------
void(entity attacker, float item_index) base_item_powerup_fire =
{
// add the item -- CEV
BASE_ITEM_POWERUP_ADD (attacker, item_index)

// now remove the powerup from the inventory -- CEV
BASE_ITEM_INVENTORY_REMOVE (attacker)

// make sure the client knows -- CEV
if (attacker.classtype == CT_PLAYER && attacker.SendEntity)
attacker.SendFlags |= NETFLAG_PLAYER_ITEMS |
NETFLAG_PLAYER_WEAPON;

// and make sure the player knows -- CEV
local item_info_t item = item_info[item_index];
BASE_ITEM_PICKUPMESSAGE (attacker, item, CHAN_ITEM_POWERUP)
};

//--------------------------------------------------------------
void() base_item_powerup_touch =
{
// thrown item check -- CEV
if (base_item_touch_projectile())
return;

if (sub_checkvalidtouch(other) == FALSE)
return;

// don't touch() if the player isn't holding a weapon -- CEV
BASE_ENTITY_WEAPONLOOKUP (other)
if (item_index < ITEM_SEQ_W_START||item_index > ITEM_SEQ_W_END)
{
if (item_index == ITEM_SEQ_HANDS && other.button6 &&
!(other.flags & FL_THROW_HELD))
{
// self.attack_finished = time + 0.5;
base_item_powerup_grab (other, self);
return;
}
else
{
return;
}
}

// add the item -- CEV
BASE_ITEM_POWERUP_RESPAWNDELAY (self.weapon)
BASE_ITEM_POWERUP_ADD (other, self.weapon)

local item_info_t item = item_info[self.weapon];
BASE_ITEM_PICKUPMESSAGE (other, item, CHAN_ITEM_POWERUP)

// fire all targets / killtargets
activator = other;
sub_usetargets ();

// either remove the item or set up for respawning -- CEV
self.mdl = self.model;
BASE_ITEM_CHECKREMOVE (self, delay_sp, delay_dm)
};

//--------------------------------------------------------------
entity(entity src, vector org, vector vel, float fl,
void(entity) init_fn) spawn_base_item_powerup =
{
local entity e = spawn ();
e.owner = src;
e.spawnflags = fl;
e.origin = org;
e.velocity = vel;
init_fn (e);
return e;
};

//--------------------------------------------------------------
void(string key, string value) base_item_powerup_init_field =
{
base_item_init_field (key, value);
};
#endif

#if defined(CSQC) || defined(SSQC)
//--------------------------------------------------------------
void(entity e) base_item_powerup_init =
{
e.classgroup |= CG_ITEM_POWERUP;


local item_info_t item = item_info[e.weapon];

#ifdef CSQC
setmodelindex (e, e.modelindex);
e.modelflags |= MF_ROTATE;
#endif

#ifdef SSQC
precache_model (item.world_model);
precache_sound (item.pickup_sound);
setmodel (e, item.world_model);
e.touch = base_item_powerup_touch;
#endif

e.noise = item.pickup_sound;

if (e.netname == __NULL__ || e.netname == "")
e.netname = item.name;

base_item_init (e);
};
#endif

#ifdef SSQC
//--------------------------------------------------------------
strip void() base_item_powerup =
{
base_item_powerup_init (self);
};
#endif
// };

/*QUAKED item_artifact_envirosuit (0 .5 .8) (-16 -16 -24) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/suit.mdl"); }
Biosuit
Player takes no damage from water or slime for 30 seconds
*/
//----------------------------------------------------------------------
// class item_artifact_envirosuit: base_item_powerup
// {
#ifdef CSQC
//--------------------------------------------------------------
void(float isnew) item_artifact_envirosuit_netreceive =
{
// creates a number of variables, including netflags -- CEV
BASE_ITEM_NETRECEIVE (item_artifact_envirosuit_init)
};
#endif

#ifdef SSQC
//--------------------------------------------------------------
entity(entity src, vector org, vector vel, float fl)
spawn_item_artifact_envirosuit =
{
return spawn_base_item_powerup (src, org, vel, fl,
item_artifact_envirosuit_init);
};
#endif

#if defined(CSQC) || defined(SSQC)
//--------------------------------------------------------------
void(entity e) item_artifact_envirosuit_init =
{
e.classname = "item_artifact_envirosuit";
e.classtype = CT_ITEM_ENVIROSUIT;

#ifdef SSQC
// base_item_powerup_init will cache suit.wav -- CEV
precache_sound ("items/suit2.wav");

e.weapon = ITEM_SEQ_ARTIFACT_ENVIROSUIT;
e.items = IT_SUIT;

// t_fog fix for custom models dumptruck_ds
if !(e.particles_offset)
e.particles_offset = '0 0 32';
#endif

e.pos1 = '-16 -16 -24';
e.pos2 = '16 16 32';

// StartItem
base_item_powerup_init (e);
};
#endif

#ifdef SSQC
//--------------------------------------------------------------
void() item_artifact_envirosuit =
{
// remap spawnflags, inhibit spawn, remap fields -- CEV
BASE_ITEM_PREINIT (base_item_powerup_init_field)

item_artifact_envirosuit_init (self);
};
#endif
// };

/*QUAKED item_artifact_invisibility (0 .5 .8) (-16 -16 -24) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/invisibl.mdl"); }
Ring of Shadows
Player is invisible for 30 seconds
*/
//----------------------------------------------------------------------
// class item_artifact_invisibility: base_item_powerup
// {
#ifdef CSQC
//--------------------------------------------------------------
void(float isnew) item_artifact_invisibility_netreceive =
{
// creates a number of variables, including netflags -- CEV
BASE_ITEM_NETRECEIVE (item_artifact_invisibility_init)
};
#endif

#ifdef SSQC
//--------------------------------------------------------------
entity(entity src, vector org, vector vel, float fl)
spawn_item_artifact_invisibility =
{
return spawn_base_item_powerup (src, org, vel, fl,
item_artifact_invisibility_init);
};
#endif

#if defined(CSQC) || defined(SSQC)
//--------------------------------------------------------------
void(entity e) item_artifact_invisibility_init =
{
e.classname = "item_artifact_invisibility";
e.classtype = CT_ITEM_INVISIBILITY;

#ifdef SSQC
precache_sound ("items/inv2.wav");
precache_sound ("items/inv3.wav");

e.weapon = ITEM_SEQ_ARTIFACT_INVISIBILITY;
e.items = IT_INVISIBILITY;

// t_fog fix for custom models dumptruck_ds
if !(e.particles_offset)
e.particles_offset = '0 0 0';
#endif

e.pos1 = '-16 -16 -24';
e.pos2 = '16 16 32';

// StartItem
base_item_powerup_init (e);
};
#endif

#ifdef SSQC
//--------------------------------------------------------------
void() item_artifact_invisibility =
{
// remap spawnflags, inhibit spawn, remap fields -- CEV
BASE_ITEM_PREINIT (base_item_powerup_init_field)

item_artifact_invisibility_init (self);
};
#endif
// };

/*QUAKED item_artifact_invulnerability (0 .5 .8) (-16 -16 -24) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/invulner.mdl"); }
Pentagram of Protection
Player is invulnerable for 30 seconds
*/
//----------------------------------------------------------------------
// class item_artifact_invulnerability: base_item_powerup
// {
#ifdef CSQC
//--------------------------------------------------------------
void(float isnew) item_artifact_invulnerability_netreceive =
{
// creates a number of variables, including netflags -- CEV
BASE_ITEM_NETRECEIVE (item_artifact_invulnerability_init)
};
#endif

#ifdef SSQC
//--------------------------------------------------------------
entity(entity src, vector org, vector vel, float fl)
spawn_item_artifact_invulnerability =
{
return spawn_base_item_powerup (src, org, vel, fl,
item_artifact_invulnerability_init);
};
#endif

#if defined(CSQC) || defined(SSQC)
//--------------------------------------------------------------
void(entity e) item_artifact_invulnerability_init =
{
e.classname = "item_artifact_invulnerability";
e.classtype = CT_ITEM_INVULNERABILITY;

#ifdef SSQC
// called in client.qc -- dumptruck_ds
precache_sound ("items/protect2.wav");
// called in combat.qc -- dumptruck_ds
precache_sound ("items/protect3.wav");

e.weapon = ITEM_SEQ_ARTIFACT_INVULNERABILITY;
e.items = IT_INVULNERABILITY;

// t_fog fix for custom models dumptruck_ds
if !(e.particles_offset)
e.particles_offset = '0 0 16';
#endif

e.pos1 = '-16 -16 -24';
e.pos2 = '16 16 32';

// StartItem
base_item_powerup_init (e);
};
#endif

#ifdef SSQC
//--------------------------------------------------------------
void() item_artifact_invulnerability =
{
// remap spawnflags, inhibit spawn, remap fields -- CEV
BASE_ITEM_PREINIT (base_item_powerup_init_field)

item_artifact_invulnerability_init (self);
};
#endif
// };

/*QUAKED item_artifact_super_damage (0 .5 .8) (-16 -16 -24) (16 16 32) X X X X X SPAWN_SILENT TRIGGER_SPAWNED SUSPENDED_IN_AIR NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER RESPAWN_WITH_DM_EFFECTS NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
{ model("progs/quaddama.mdl"); }
Quad Damage
Player does 4x damage for 30 seconds
*/
//----------------------------------------------------------------------
// class item_artifact_super_damage: base_item_powerup
// {
#ifdef CSQC
//--------------------------------------------------------------
void(float isnew) item_artifact_super_damage_netreceive =
{
// creates a number of variables, including netflags -- CEV
BASE_ITEM_NETRECEIVE (item_artifact_super_damage_init)
};
#endif

#ifdef SSQC
//--------------------------------------------------------------
entity(entity src, vector org, vector vel, float fl)
spawn_item_artifact_super_damage =
{
return spawn_base_item_powerup (src, org, vel, fl,
item_artifact_super_damage_init);
};
#endif

#if defined(CSQC) || defined(SSQC)
//--------------------------------------------------------------
void(entity e) item_artifact_super_damage_init =
{
e.classname = "item_artifact_super_damage";
e.classtype = CT_ITEM_QUAD;

#ifdef SSQC
// base_item_powerup_init will cache damage.wav -- CEV
precache_sound ("items/damage3.wav");

e.weapon = ITEM_SEQ_ARTIFACT_QUAD;
e.items = IT_QUAD;

// t_fog fix for custom models dumptruck_ds
if !(e.particles_offset)
e.particles_offset = '0 0 16';
#endif

e.pos1 = '-16 -16 -24';
e.pos2 = '16 16 32';

// StartItem
base_item_powerup_init (e);
};
#endif

#ifdef SSQC
//--------------------------------------------------------------
void() item_artifact_super_damage =
{
// remap spawnflags, inhibit spawn, remap fields -- CEV
BASE_ITEM_PREINIT (base_item_powerup_init_field)

item_artifact_super_damage_init (self);
};
#endif
// };

Return to the top of this page or return to the overview of this repo.

Log powerups.qc

Return to the top of this page or return to the overview of this repo.