djcev.com

//

Git Repos / fte_dogmode / qc / triggers / counter.qc

Last update to this file was on 2025-08-13 at 05:20.

Show counter.qc

//==============================================================================
// trigger_counter
//==============================================================================

//======================================================================
// constants
//======================================================================

#ifdef SSQC
//----------------------------------------------------------------------
// trigger_counter spawnflags -- CEV
//----------------------------------------------------------------------
typedef enumflags
{
SPAWNFLAG_TRIGGER_COUNTER_NOMESSAGE = 1
// SPAWNFLAG_NOT_ON_EASY = 256, // see base_entities.qc -- CEV
// SPAWNFLAG_NOT_ON_NORMAL = 512,
// SPAWNFLAG_NOT_ON_HARD_OR_NIGHTMARE = 1024,
// SPAWNFLAG_NOT_IN_DEATHMATCH = 2048,
// SPAWNFLAG_NOT_IN_COOP = 4096,
// SPAWNFLAG_NOT_IN_SP = 8192,
// SPAWNFLAG_NOT_ON_SKILL2 = 32768, // see base_entities.qc -- CEV
// SPAWNFLAG_NOT_ON_SKILL3 = 65536, // see base_entities.qc -- CEV
// SPAWNFLAG_CENTERPRINTALL = 131072 // see base_entities.qc -- CEV
} trigger_counter_spawnflags;
#endif

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

#ifdef SSQC
// trigger_counter
void() trigger_counter_use;
void(entity e) trigger_counter_init;
void() trigger_counter;
#endif

#ifdef SSQC
// trigger_counter_timed
void() trigger_counter_timed_think;
void() trigger_counter_timed_use;
void(entity e) trigger_counter_timed_init;
void() trigger_counter_timed;
#endif

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

#ifdef SSQC
/*QUAKED trigger_counter (.5 .5 .5) ? nomessage X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

Acts as an intermediary for an action that takes multiple inputs.

If nomessage is not set, t will print "1 more.. " etc when triggered and "sequence complete" when finished.

After the counter has been triggered "count" times (default 2), it will fire all of it's targets and remove itself.
*/
//----------------------------------------------------------------------
// class trigger_counter: base_multiple
// {
//--------------------------------------------------------------
void() trigger_counter_use =
{
if (self.stateflags & STATE_INACTIVE)
return;

self.count -= 1;
if (self.count < 0)
return;

if (self.count)
{
if (activator.classtype == CT_PLAYER &&
(!(self.spawnflags &
SPAWNFLAG_TRIGGER_COUNTER_NOMESSAGE)))
{
if (self.count >= 4)
centerprint (activator,
"There are more to go...");
else if (self.count == 3)
centerprint (activator,
"Only 3 more to go...");
else if (self.count == 2)
centerprint (activator,
"Only 2 more to go...");
else
centerprint (activator,
"Only 1 more to go...");
}
return;
}

if (activator.classtype == CT_PLAYER &&
(!(self.spawnflags &
SPAWNFLAG_TRIGGER_COUNTER_NOMESSAGE)))
{
centerprint (activator, "Sequence completed!");
}

self.enemy = activator;
base_multiple_fire ();
};

//--------------------------------------------------------------
void(entity e) trigger_counter_init =
{
e.classname = "trigger_counter";
e.classtype = CT_TRIGGER_COUNTER;
e.wait = -1;

if (!e.count)
e.count = 2;

e.use = trigger_counter_use;

// might need to be base_mapentity_init -- CEV
base_trigger_init (e);
};

//--------------------------------------------------------------
void() trigger_counter =
{
BASE_TRIGGER_PREINIT (base_trigger_init_field)
trigger_counter_init (self);
};
// };
#endif

#ifdef SSQC
/*QUAKED trigger_counter_timed (.5 .5 .5) ? nomessage message_all
Acts as an intermediary for an action that takes multiple inputs.

If nomessage is not set, t will print "1 more.. " etc when triggered and "sequence complete" when finished.

After the counter has been triggered "count" times (default 2), it will fire all of it's targets and remove itself.
*/
//----------------------------------------------------------------------
// class trigger_counter_timed: base_multiple
// {
//--------------------------------------------------------------
void() trigger_counter_timed_think =
{
self.count = self.cnt;
};

//--------------------------------------------------------------
void() trigger_counter_timed_use =
{
self.count -= 1;

if (self.count < 0)
return;

self.nextthink = time + self.delay;

if (self.count)
{
if (activator.classtype == CT_PLAYER &&
(!(self.spawnflags &
SPAWNFLAG_TRIGGER_COUNTER_NOMESSAGE)))
{
if (self.count >= 4)
centerprint (activator,
"There are more to go...");
else if (self.count == 3)
centerprint (activator,
"Only 3 more to go...");
else if (self.count == 2)
centerprint (activator,
"Only 2 more to go...");
else
centerprint (activator,
"Only 1 more to go...");
}
return;
}

if (activator.classtype == CT_PLAYER && (!(self.spawnflags &
SPAWNFLAG_TRIGGER_COUNTER_NOMESSAGE)))
{
centerprint (activator, "Sequence completed!");
}

self.enemy = activator;
self.delay = 0;
self.nextthink = -1;
self.think = sub_null;
base_multiple_fire ();
base_entity_remove (self);
};

//--------------------------------------------------------------
void(entity e) trigger_counter_timed_init =
{
e.classname = "trigger_counter_timed";
e.classtype = CT_TRIGGER_COUNTER_TIMED;

e.wait = -1;
if (!e.count)
e.count = 2;

if (!e.delay)
e.delay = 2;

e.cnt = e.count;
e.think = trigger_counter_timed_think;
e.use = trigger_counter_timed_use;

// might need to be base_mapentity_init -- CEV
base_trigger_init (e);
};

//--------------------------------------------------------------
void() trigger_counter_timed =
{
BASE_TRIGGER_PREINIT (base_trigger_init_field)
trigger_counter_timed_init (self);
};
// }
#endif

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

Log counter.qc

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