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

Go to the source code of this file.

Functions

void multi_eventdamage (entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
void multi_reset (entity this)
void multi_touch (entity this, entity toucher)
void multi_trigger (entity this)
void multi_use (entity this, entity actor, entity trigger)
void multi_wait (entity this)
 spawnfunc (trigger_multiple)
 spawnfunc (trigger_once)

Function Documentation

◆ multi_eventdamage()

void multi_eventdamage ( entity this,
entity inflictor,
entity attacker,
float damage,
int deathtype,
.entity weaponentity,
vector hitloc,
vector force )

Definition at line 105 of file multi.qc.

106{
107 if(!this.takedamage)
108 return;
109 if(this.spawnflags & NOSPLASH)
110 if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
111 return;
112 if(this.team)
113 if(((this.spawnflags & INVERT_TEAMS) == 0) == (this.team != attacker.team))
114 return;
115 TakeResource(this, RES_HEALTH, damage);
116 if (GetResource(this, RES_HEALTH) <= 0)
117 {
118 this.enemy = attacker;
119 this.goalentity = inflictor;
120 multi_trigger(this);
121 }
122}
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
void TakeResource(entity receiver, Resource res_type, float amount)
Takes an entity some resource.
int team
Definition main.qh:188
int spawnflags
Definition ammo.qh:15
#define DEATH_ISSPECIAL(t)
Definition all.qh:39
const int HITTYPE_SPLASH
Definition all.qh:30
const int INVERT_TEAMS
Definition defs.qh:10
const int NOSPLASH
Definition defs.qh:12
entity goalentity
Definition viewloc.qh:16
void multi_trigger(entity this)
Definition multi.qc:20
float takedamage
Definition subs.qh:78
entity enemy
Definition sv_ctf.qh:153

References DEATH_ISSPECIAL, enemy, entity(), GetResource(), goalentity, HITTYPE_SPLASH, INVERT_TEAMS, multi_trigger(), NOSPLASH, spawnflags, takedamage, TakeResource(), team, and vector.

Referenced by spawnfunc().

◆ multi_reset()

void multi_reset ( entity this)

Definition at line 124 of file multi.qc.

125{
126 if ( !(this.spawnflags & SPAWNFLAG_NOTOUCH) )
127 settouch(this, multi_touch);
128 if (this.max_health)
129 {
130 SetResourceExplicit(this, RES_HEALTH, this.max_health);
131 this.takedamage = DAMAGE_YES;
132 this.solid = SOLID_BBOX;
133 }
134 setthink(this, func_null);
135 this.nextthink = 0;
136 this.team = this.team_saved;
137 this.use = multi_use;
138}
float max_health
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
const float SOLID_BBOX
float nextthink
#define use
const int SPAWNFLAG_NOTOUCH
Definition defs.qh:17
solid
Definition ent_cs.qc:165
void multi_use(entity this, entity actor, entity trigger)
Definition multi.qc:59
void multi_touch(entity this, entity toucher)
Definition multi.qc:66
var void func_null()
#define setthink(e, f)
#define settouch(e, f)
Definition self.qh:73
int team_saved
Definition vote.qh:70
const int DAMAGE_YES
Definition subs.qh:80

References DAMAGE_YES, entity(), func_null(), max_health, multi_touch(), multi_use(), nextthink, SetResourceExplicit(), setthink, settouch, solid, SOLID_BBOX, SPAWNFLAG_NOTOUCH, spawnflags, takedamage, team, team_saved, and use.

Referenced by spawnfunc().

◆ multi_touch()

void multi_touch ( entity this,
entity toucher )

Definition at line 66 of file multi.qc.

67{
68 if(!(this.spawnflags & ALL_ENTITIES) && !toucher.iscreature)
69 {
70 return;
71 }
72
73 if(this.team)
74 {
75 if(((this.spawnflags & INVERT_TEAMS) == 0) == (this.team != toucher.team))
76 {
77 return;
78 }
79 }
80
81 // if the trigger has an angles field, check player's facing direction
82 if (this.movedir != '0 0 0')
83 {
84 makevectors (toucher.angles);
85 if (v_forward * this.movedir < 0)
86 return; // not facing the right way
87 }
88
89 // if the trigger has pressed keys, check that the player is pressing those keys
90 if(this.pressedkeys && IS_PLAYER(toucher)) // only for players
91 {
92 if(!(CS(toucher).pressedkeys & this.pressedkeys))
93 {
94 return;
95 }
96 }
97
99
100 this.enemy = toucher;
101 this.goalentity = toucher;
102 multi_trigger(this);
103}
#define IS_PLAYER(s)
Definition player.qh:243
vector v_forward
const int ALL_ENTITIES
Definition defs.qh:8
#define EXACTTRIGGER_TOUCH(e, t)
Definition common.qh:115
vector movedir
Definition viewloc.qh:18
#define makevectors
Definition post.qh:21
entity entity toucher
Definition self.qh:72
ClientState CS(Client this)
Definition state.qh:47
int pressedkeys

References ALL_ENTITIES, CS(), enemy, entity(), EXACTTRIGGER_TOUCH, goalentity, INVERT_TEAMS, IS_PLAYER, makevectors, movedir, multi_trigger(), pressedkeys, spawnflags, team, toucher, and v_forward.

Referenced by multi_reset(), and spawnfunc().

◆ multi_trigger()

void multi_trigger ( entity this)

Definition at line 20 of file multi.qc.

21{
22 if (this.nextthink > time)
23 {
24 return; // allready been triggered
25 }
26
27 if((this.spawnflags & ONLY_PLAYERS) && !IS_PLAYER(this.enemy))
28 {
29 return; // only players
30 }
31
32 if (this.noise && this.noise != "")
33 {
35 }
36
37 // don't trigger again until reset
38 this.takedamage = DAMAGE_NO;
39
40 SUB_UseTargets(this, this.enemy, this.goalentity);
41
42 if (this.wait > 0)
43 {
44 setthink(this, multi_wait);
45 this.nextthink = time + this.wait;
46 }
47 else if (this.wait == 0)
48 {
49 multi_wait(this); // waiting finished
50 }
51 else
52 { // we can't just delete(this) here, because this is a touch function
53 // called while C code is looping through area links...
54 settouch(this, func_null);
55 this.use = func_null;
56 }
57}
float wait
Definition items.qc:17
float time
const int ONLY_PLAYERS
Definition defs.qh:13
void SUB_UseTargets(entity this, entity actor, entity trigger)
Definition triggers.qc:344
void multi_wait(entity this)
Definition multi.qc:6
const int CH_TRIGGER
Definition sound.qh:12
const float VOL_BASE
Definition sound.qh:36
#define _sound(e, c, s, v, a)
Definition sound.qh:43
const float ATTEN_NORM
Definition sound.qh:30
string noise
Definition subs.qh:83
const int DAMAGE_NO
Definition subs.qh:79

References _sound, ATTEN_NORM, CH_TRIGGER, DAMAGE_NO, enemy, entity(), func_null(), goalentity, IS_PLAYER, multi_wait(), nextthink, noise, ONLY_PLAYERS, setthink, settouch, spawnflags, SUB_UseTargets(), takedamage, time, use, VOL_BASE, and wait.

Referenced by multi_eventdamage(), multi_touch(), and multi_use().

◆ multi_use()

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

Definition at line 59 of file multi.qc.

60{
61 this.goalentity = trigger;
62 this.enemy = actor;
63 multi_trigger(this);
64}

References enemy, entity(), goalentity, and multi_trigger().

Referenced by multi_reset(), and spawnfunc().

◆ multi_wait()

void multi_wait ( entity this)

Definition at line 6 of file multi.qc.

7{
8 if (this.max_health)
9 {
10 SetResourceExplicit(this, RES_HEALTH, this.max_health);
12 this.solid = SOLID_BBOX;
13 }
14}

References DAMAGE_YES, entity(), max_health, SetResourceExplicit(), solid, SOLID_BBOX, and takedamage.

Referenced by multi_trigger().

◆ spawnfunc() [1/2]

spawnfunc ( trigger_multiple )

Definition at line 153 of file multi.qc.

154{
155 this.reset = multi_reset;
156 if (this.sounds == 1)
157 this.noise = "misc/secret.wav";
158 else if (this.sounds == 2)
159 this.noise = strzone(SND(TALK));
160 else if (this.sounds == 3)
161 this.noise = "misc/trigger1.wav";
162
163 if(this.noise && this.noise != "")
164 precache_sound(this.noise);
165
166 if (!this.wait)
167 this.wait = 0.2;
168 else if(this.wait < -1)
169 this.wait = 0;
170 this.use = multi_use;
171
172 if(this.wait == -1 && (q3compat & Q3COMPAT_DEFI))
173 this.wait = 0.1; // compatibility for q3df: "instant" return
174
176
177 this.team_saved = this.team;
178 IL_PUSH(g_saved_team, this);
179
180 if (GetResource(this, RES_HEALTH))
181 {
182 if (this.spawnflags & SPAWNFLAG_NOTOUCH)
183 objerror (this, "health and notouch don't make sense\n");
184 this.canteamdamage = true;
185 this.max_health = GetResource(this, RES_HEALTH);
186 this.event_damage = multi_eventdamage;
187 this.takedamage = DAMAGE_YES;
188 this.solid = SOLID_BBOX;
189 setorigin(this, this.origin); // make sure it links into the world
190 }
191 else
192 {
193 if ( !(this.spawnflags & SPAWNFLAG_NOTOUCH) )
194 {
195 settouch(this, multi_touch);
196 setorigin(this, this.origin); // make sure it links into the world
197 }
198 }
199}
vector origin
bool canteamdamage
Definition damage.qh:65
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define EXACTTRIGGER_INIT
Definition common.qh:116
string precache_sound(string sample)
string strzone(string s)
void multi_reset(entity this)
Definition multi.qc:124
void multi_eventdamage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition multi.qc:105
#define objerror
Definition pre.qh:8
q3compat
Definition quake3.qc:59
#define Q3COMPAT_DEFI
Definition quake3.qh:5
IntrusiveList g_saved_team
Definition vote.qh:79
#define SND(id)
Definition all.qh:35
float sounds
Definition subs.qh:42

References canteamdamage, DAMAGE_YES, EXACTTRIGGER_INIT, g_saved_team, GetResource(), IL_PUSH(), max_health, multi_eventdamage(), multi_reset(), multi_touch(), multi_use(), noise, objerror, origin, precache_sound(), q3compat, Q3COMPAT_DEFI, settouch, SND, solid, SOLID_BBOX, sounds, SPAWNFLAG_NOTOUCH, spawnflags, strzone(), takedamage, team, team_saved, use, and wait.

◆ spawnfunc() [2/2]

spawnfunc ( trigger_once )

Definition at line 215 of file multi.qc.

216{
217 this.wait = -1;
218 spawnfunc_trigger_multiple(this);
219}

References wait.