Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
pendulum.qc
Go to the documentation of this file.
1#include "pendulum.qh"
2#ifdef SVQC
3.float freq;
5{
6 float v;
7 this.nextthink = time + 0.1;
8
9 if (!(this.owner.active == ACTIVE_ACTIVE))
10 {
11 this.owner.avelocity_x = 0;
12 return;
13 }
14
15 // calculate sinewave using makevectors
16 makevectors((this.nextthink * this.owner.freq + this.owner.phase) * '0 360 0');
17 v = this.owner.speed * v_forward_y + this.cnt;
18 if(this.owner.classname == "func_pendulum") // don't brake stuff if the func_bobbing was killtarget'ed
19 {
20 // * 10 so it will arrive in 0.1 sec
21 this.owner.avelocity_z = (remainder(v - this.owner.angles_z, 360)) * 10;
22 }
23}
24
25spawnfunc(func_pendulum)
26{
27 entity controller;
28 if (this.noise != "")
29 {
32 }
33
34 this.active = ACTIVE_ACTIVE;
35
36 // keys: angle, speed, phase, noise, freq
37
38 if(!this.speed)
39 this.speed = 30;
40 // not initializing this.dmg to 2, to allow damageless pendulum
41
42 if(this.dmg && (this.message == ""))
43 this.message = " was squished";
44 if(this.dmg && (this.message2 == ""))
45 this.message2 = "was squished by";
46 if(this.dmg && (!this.dmgtime))
47 this.dmgtime = 0.25;
48 this.dmgtime2 = time;
49
51
52 this.avelocity_z = 0.0000001;
53 if (!InitMovingBrushTrigger(this))
54 return;
55
56 if(!this.freq)
57 {
58 // find pendulum length (same formula as Q3A)
59 this.freq = 1 / (M_PI * 2) * sqrt(autocvar_sv_gravity / (3 * max(8, fabs(this.mins_z))));
60 }
61
62 // copy initial angle
63 this.cnt = this.angles_z;
64
65 // wait for targets to spawn
66 controller = new_pure(func_pendulum_controller);
67 controller.owner = this;
68 controller.nextthink = time + 1;
70 this.nextthink = this.ltime + 999999999;
71 setthink(this, SUB_NullThink); // for PushMove
72
73 //this.effects |= EF_LOWPRECISION;
74
75 // TODO make a reset function for this one
76}
77#endif
float dmg
Definition breakable.qc:12
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float cnt
Definition powerups.qc:24
string message
Definition powerups.qc:19
entity owner
Definition main.qh:87
#define autocvar_sv_gravity
Definition stats.qh:421
float time
float nextthink
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
float speed
Definition dynlight.qc:9
float remainder(float e, float f)
Definition mathlib.qc:212
#define M_PI
Definition mathlib.qh:108
float sqrt(float f)
string precache_sound(string sample)
float fabs(float f)
float MSG_INIT
Definition menudefs.qc:58
float max(float f,...)
float ltime
Definition net.qc:10
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:67
float freq
Definition pendulum.qc:3
void func_pendulum_controller_think(entity this)
Definition pendulum.qc:4
void generic_plat_blocked(entity this, entity blocker)
Definition platforms.qc:3
float dmgtime
Definition platforms.qh:7
float dmgtime2
Definition platforms.qh:8
#define makevectors
Definition post.qh:21
#define setthink(e, f)
#define setblocked(e, f)
const int CH_TRIGGER_SINGLE
Definition sound.qh:13
const float VOL_BASE
Definition sound.qh:36
const float ATTEN_IDLE
Definition sound.qh:32
void soundto(int _dest, entity e, int chan, string samp, float vol, float _atten, float _pitch)
Definition all.qc:74
#define spawnfunc(id)
Definition spawnfunc.qh:96
bool InitMovingBrushTrigger(entity this)
Definition subs.qc:577
void SUB_NullThink(entity this)
Definition subs.qc:3
string noise
Definition subs.qh:83
string message2
Definition triggers.qh:19