Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
counter.qc File Reference
#include "counter.qh"
Include dependency graph for counter.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void counter_reset (entity this)
void counter_use (entity this, entity actor, entity trigger)
 spawnfunc (trigger_counter)

Function Documentation

◆ counter_reset()

void counter_reset ( entity this)

Definition at line 66 of file counter.qc.

67{
68 setthink(this, func_null);
69 this.nextthink = 0;
70 this.counter_cnt = 0;
71 this.active = ACTIVE_ACTIVE;
72
73 // remove any per-player counters
74 IL_EACH(g_counters, it.owner == this,
75 {
76 delete(it);
77 });
78}
float counter_cnt
Definition counter.qh:6
IntrusiveList g_counters
Definition counter.qh:8
float nextthink
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
#define IL_EACH(this, cond, body)
var void func_null()
#define setthink(e, f)

References active, ACTIVE_ACTIVE, counter_cnt, entity(), func_null(), g_counters, IL_EACH, nextthink, and setthink.

Referenced by counter_use(), and spawnfunc().

◆ counter_use()

void counter_use ( entity this,
entity actor,
entity trigger )

Definition at line 4 of file counter.qc.

5{
6 if(this.active != ACTIVE_ACTIVE)
7 return;
8
9 entity store = this;
11 {
12 if(!IS_PLAYER(actor))
13 return;
14 entity mycounter = NULL;
15 IL_EACH(g_counters, it.realowner == actor && it.owner == this,
16 {
17 mycounter = it;
18 break;
19 });
20 if(!mycounter)
21 {
22 mycounter = new_pure(counter);
23 IL_PUSH(g_counters, mycounter);
24 mycounter.owner = this;
25 mycounter.realowner = actor;
26 mycounter.counter_cnt = 0;
27 // NOTE: will be deleted when the player respawns or match resets
28 }
29 store = mycounter;
30 }
31
32 store.counter_cnt += 1;
33 if (store.counter_cnt > this.count)
34 return;
35
36 bool doactivate = (this.spawnflags & COUNTER_FIRE_AT_COUNT);
37
38 if (store.counter_cnt == this.count)
39 {
40 if(IS_PLAYER(actor) && !(this.spawnflags & SPAWNFLAG_NOMESSAGE))
41 Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COMPLETED);
42
43 doactivate = true;
44
45 if(this.respawntime)
46 {
47 setthink(store, counter_reset);
48 store.nextthink = time + this.respawntime;
49 }
50 }
51 else
52 {
53 if(IS_PLAYER(actor) && !(this.spawnflags & SPAWNFLAG_NOMESSAGE))
54 {
55 if((this.count - store.counter_cnt) >= 4)
56 Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COUNTER);
57 else
58 Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_SEQUENCE_COUNTER_FEWMORE, this.count - store.counter_cnt);
59 }
60 }
61
62 if(doactivate)
63 SUB_UseTargets(this, actor, trigger);
64}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float count
Definition powerups.qc:22
int spawnflags
Definition ammo.qh:15
#define IS_PLAYER(s)
Definition player.qh:243
void counter_reset(entity this)
Definition counter.qc:66
const int COUNTER_FIRE_AT_COUNT
Definition counter.qh:12
const int COUNTER_PER_PLAYER
Definition counter.qh:13
float time
const int SPAWNFLAG_NOMESSAGE
Definition defs.qh:16
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
void SUB_UseTargets(entity this, entity actor, entity trigger)
Definition triggers.qc:344
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:67
#define NULL
Definition post.qh:14
float respawntime
Definition items.qh:30

References active, ACTIVE_ACTIVE, count, COUNTER_FIRE_AT_COUNT, COUNTER_PER_PLAYER, counter_reset(), entity(), g_counters, IL_EACH, IL_PUSH(), IS_PLAYER, new_pure, NULL, respawntime, Send_Notification(), setthink, SPAWNFLAG_NOMESSAGE, spawnflags, SUB_UseTargets(), and time.

Referenced by spawnfunc().

◆ spawnfunc()

spawnfunc ( trigger_counter )

Definition at line 90 of file counter.qc.

91{
92 if (!this.count)
93 this.count = 2;
94
95 this.counter_cnt = 0;
96 this.use = counter_use;
97 this.reset = counter_reset;
98 this.active = ACTIVE_ACTIVE;
99}
void counter_use(entity this, entity actor, entity trigger)
Definition counter.qc:4
#define use

References active, ACTIVE_ACTIVE, count, counter_cnt, counter_reset(), counter_use(), and use.