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

Go to the source code of this file.

Functions

 spawnfunc (trigger_impulse)
void trigger_impulse_link (entity this)
bool trigger_impulse_send (entity this, entity to, int sf)
void trigger_impulse_touch_accel (entity this, entity toucher)
void trigger_impulse_touch_directional (entity this, entity toucher)
void trigger_impulse_touch_radial (entity this, entity toucher)

Function Documentation

◆ spawnfunc()

spawnfunc ( trigger_impulse )

Definition at line 174 of file impulse.qc.

175{
176 this.active = ACTIVE_ACTIVE;
179
180 if(this.radius)
181 {
182 if(!this.strength)
183 {
185 }
186 setorigin(this, this.origin);
187 setsize(this, '-1 -1 -1' * this.radius,'1 1 1' * this.radius);
189 }
190 else
191 {
192 if(this.target)
193 {
194 if(!this.strength)
195 {
197 }
199 }
200 else
201 {
202 if(!this.strength)
203 {
205 }
208 }
209 }
210
212}
void trigger_impulse_touch_directional(entity this, entity toucher)
Definition impulse.qc:3
void trigger_impulse_link(entity this)
Definition impulse.qc:169
void trigger_impulse_touch_accel(entity this, entity toucher)
Definition impulse.qc:59
void trigger_impulse_touch_radial(entity this, entity toucher)
Definition impulse.qc:91
float strength
Definition impulse.qh:13
const float IMPULSE_DEFAULT_RADIAL_STRENGTH
Definition impulse.qh:22
float radius
Definition impulse.qh:11
const float IMPULSE_DEFAULT_DIRECTIONAL_STRENGTH
Definition impulse.qh:23
float autocvar_g_triggerimpulse_directional_multiplier
Definition impulse.qh:6
float autocvar_g_triggerimpulse_radial_multiplier
Definition impulse.qh:7
const float IMPULSE_DEFAULT_ACCEL_STRENGTH
Definition impulse.qh:24
float autocvar_g_triggerimpulse_accel_power
Definition impulse.qh:5
float autocvar_g_triggerimpulse_accel_multiplier
Definition impulse.qh:4
float effects
const float EF_NODEPTHTEST
vector origin
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
#define BITSET_ASSIGN(a, b)
Definition common.qh:104
#define settouch(e, f)
Definition self.qh:73
string target
Definition triggers.qh:55
void WarpZoneLib_ExactTrigger_Init(entity this, bool unsetmodel)

References active, ACTIVE_ACTIVE, autocvar_g_triggerimpulse_accel_multiplier, autocvar_g_triggerimpulse_accel_power, autocvar_g_triggerimpulse_directional_multiplier, autocvar_g_triggerimpulse_radial_multiplier, BITSET_ASSIGN, EF_NODEPTHTEST, effects, IMPULSE_DEFAULT_ACCEL_STRENGTH, IMPULSE_DEFAULT_DIRECTIONAL_STRENGTH, IMPULSE_DEFAULT_RADIAL_STRENGTH, origin, radius, settouch, strength, target, trigger_impulse_link(), trigger_impulse_touch_accel(), trigger_impulse_touch_directional(), trigger_impulse_touch_radial(), and WarpZoneLib_ExactTrigger_Init().

◆ trigger_impulse_link()

void trigger_impulse_link ( entity this)

Definition at line 169 of file impulse.qc.

170{
172}
bool trigger_impulse_send(entity this, entity to, int sf)
Definition impulse.qc:154
void trigger_link(entity this, bool(entity this, entity to, int sendflags) sendfunc)
Definition triggers.qc:104

References entity(), trigger_impulse_send(), and trigger_link().

Referenced by spawnfunc().

◆ trigger_impulse_send()

bool trigger_impulse_send ( entity this,
entity to,
int sf )

Definition at line 154 of file impulse.qc.

155{
156 WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_IMPULSE);
157
163
164 trigger_common_write(this, true);
165
166 return true;
167}
int spawnflags
Definition ammo.qh:15
int falloff
Definition impulse.qh:12
const int MSG_ENTITY
Definition net.qh:115
#define WriteHeader(to, id)
Definition net.qh:221
void WriteCoord(float data, float dest, float desto)
void WriteByte(float data, float dest, float desto)
void trigger_common_write(entity this, bool withtarget)
Definition triggers.qc:110

References active, entity(), falloff, MSG_ENTITY, radius, spawnflags, strength, trigger_common_write(), WriteByte(), WriteCoord(), and WriteHeader.

Referenced by trigger_impulse_link().

◆ trigger_impulse_touch_accel()

void trigger_impulse_touch_accel ( entity this,
entity toucher )

Definition at line 59 of file impulse.qc.

60{
61 float pushdeltatime;
62
63 if (this.active != ACTIVE_ACTIVE)
64 return;
65
66 if (!isPushable(toucher))
67 return;
68
70
71 pushdeltatime = time - toucher.lastpushtime;
72 if (pushdeltatime > IMPULSE_MAX_PUSHDELTATIME)
73 {
74 pushdeltatime = 0;
75 }
76 toucher.lastpushtime = time;
77 if(!pushdeltatime)
78 {
79 return;
80 }
81
82 // div0: ticrate independent, 1 = identity (not 20)
83 toucher.velocity = toucher.velocity * (this.strength ** pushdeltatime);
84
85#ifdef SVQC
87#endif
88}
const float IMPULSE_MAX_PUSHDELTATIME
Definition impulse.qh:26
float time
void UpdateCSQCProjectile(entity e)
#define EXACTTRIGGER_TOUCH(e, t)
Definition common.qh:115
entity entity toucher
Definition self.qh:72
bool isPushable(entity e)
Definition triggers.qc:3

References active, ACTIVE_ACTIVE, entity(), EXACTTRIGGER_TOUCH, IMPULSE_MAX_PUSHDELTATIME, isPushable(), strength, time, toucher, and UpdateCSQCProjectile().

Referenced by spawnfunc().

◆ trigger_impulse_touch_directional()

void trigger_impulse_touch_directional ( entity this,
entity toucher )

Definition at line 3 of file impulse.qc.

4{
5 entity targ;
6 float pushdeltatime;
7 float str;
8
9 if (this.active != ACTIVE_ACTIVE)
10 return;
11
12 if (!isPushable(toucher))
13 return;
14
16
17 targ = find(NULL, targetname, this.target);
18 if(!targ)
19 {
20 objerror(this, "trigger_force without a (valid) .target!\n");
21 delete(this);
22 return;
23 }
24
25 // falloff is not supported because radius is always 0 in directional mode
26 str = this.strength;
27
28 pushdeltatime = time - toucher.lastpushtime;
29 if (pushdeltatime > IMPULSE_MAX_PUSHDELTATIME)
30 {
31 pushdeltatime = 0;
32 }
33 toucher.lastpushtime = time;
34 if(!pushdeltatime)
35 {
36 return;
37 }
38
40 {
41 float addspeed = str - toucher.velocity * normalize(targ.origin - this.origin);
42 if (addspeed > 0)
43 {
44 float accelspeed = min(IMPULSE_DIRECTIONAL_MAX_ACCEL_FACTOR * pushdeltatime * str, addspeed);
45 toucher.velocity += accelspeed * normalize(targ.origin - this.origin);
46 }
47 }
48 else
49 toucher.velocity = toucher.velocity + normalize(targ.origin - this.origin) * str * pushdeltatime;
50
52
53#ifdef SVQC
55#endif
56}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
const int IMPULSE_DIRECTIONAL_SPEEDTARGET
Definition impulse.qh:20
const float IMPULSE_DIRECTIONAL_MAX_ACCEL_FACTOR
Definition impulse.qh:28
entity find(entity start,.string field, string match)
float min(float f,...)
vector normalize(vector v)
#define UNSET_ONGROUND(s)
Definition movetypes.qh:18
#define NULL
Definition post.qh:14
#define objerror
Definition pre.qh:8
string targetname
Definition triggers.qh:56

References active, ACTIVE_ACTIVE, entity(), EXACTTRIGGER_TOUCH, find(), IMPULSE_DIRECTIONAL_MAX_ACCEL_FACTOR, IMPULSE_DIRECTIONAL_SPEEDTARGET, IMPULSE_MAX_PUSHDELTATIME, isPushable(), min(), normalize(), NULL, objerror, spawnflags, strength, target, targetname, time, toucher, UNSET_ONGROUND, and UpdateCSQCProjectile().

Referenced by spawnfunc().

◆ trigger_impulse_touch_radial()

void trigger_impulse_touch_radial ( entity this,
entity toucher )

Definition at line 91 of file impulse.qc.

92{
93 float pushdeltatime;
94 float str;
95
96 if (this.active != ACTIVE_ACTIVE)
97 return;
98
99 if (!isPushable(toucher))
100 return;
101
103
104 pushdeltatime = time - toucher.lastpushtime;
105 if (pushdeltatime > IMPULSE_MAX_PUSHDELTATIME)
106 {
107 pushdeltatime = 0;
108 }
109 toucher.lastpushtime = time;
110 if(!pushdeltatime)
111 {
112 return;
113 }
114
115 setsize(this, '-1 -1 -1' * this.radius,'1 1 1' * this.radius);
116
117 str = min(this.radius, vlen(this.origin - toucher.origin));
118
119 if(this.falloff == FALLOFF_LINEAR)
120 str = (1 - str / this.radius) * this.strength; // 1 in the inside
121 else if(this.falloff == FALLOFF_LINEAR_INV)
122 str = (str / this.radius) * this.strength; // 0 in the inside
123 else
124 str = this.strength;
125
126 toucher.velocity = toucher.velocity + normalize(toucher.origin - this.origin) * str * pushdeltatime;
127
128#ifdef SVQC
130#endif
131}
const int FALLOFF_LINEAR
Definition impulse.qh:17
const int FALLOFF_LINEAR_INV
Definition impulse.qh:18
float vlen(vector v)

References active, ACTIVE_ACTIVE, entity(), EXACTTRIGGER_TOUCH, falloff, FALLOFF_LINEAR, FALLOFF_LINEAR_INV, IMPULSE_MAX_PUSHDELTATIME, isPushable(), min(), normalize(), origin, radius, strength, time, toucher, UpdateCSQCProjectile(), and vlen().

Referenced by spawnfunc().