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

Go to the source code of this file.

Functions

void multivibrator_reset (entity this)
void multivibrator_send (entity this)
void multivibrator_send_think (entity this)
void multivibrator_toggle (entity this, entity actor, entity trigger)
 spawnfunc (trigger_multivibrator)

Function Documentation

◆ multivibrator_reset()

void multivibrator_reset ( entity this)

Definition at line 44 of file multivibrator.qc.

45{
46 if(!(this.spawnflags & START_ENABLED))
47 this.nextthink = 0; // wait for a trigger event
48 else
49 this.nextthink = max(1, time);
50}
int spawnflags
Definition ammo.qh:15
float time
float nextthink
const int START_ENABLED
Definition defs.qh:6
float max(float f,...)

References entity(), max(), nextthink, spawnflags, START_ENABLED, and time.

Referenced by spawnfunc().

◆ multivibrator_send()

void multivibrator_send ( entity this)

Definition at line 3 of file multivibrator.qc.

4{
5 float newstate;
6 float cyclestart;
7
8 cyclestart = floor((time + this.phase) / (this.wait + this.respawntime)) * (this.wait + this.respawntime) - this.phase;
9
10 newstate = (time < cyclestart + this.wait);
11
12 if(this.state != newstate)
13 SUB_UseTargets(this, this, NULL);
14 this.state = newstate;
15
16 if(this.state)
17 this.nextthink = cyclestart + this.wait + 0.01;
18 else
19 this.nextthink = cyclestart + this.wait + this.respawntime + 0.01;
20}
float wait
Definition items.qc:17
int state
void SUB_UseTargets(entity this, entity actor, entity trigger)
Definition triggers.qc:344
float floor(float f)
float phase
Definition platforms.qh:10
#define NULL
Definition post.qh:14
float respawntime
Definition items.qh:30

References entity(), floor(), nextthink, NULL, phase, respawntime, state, SUB_UseTargets(), time, and wait.

Referenced by multivibrator_send_think(), and multivibrator_toggle().

◆ multivibrator_send_think()

void multivibrator_send_think ( entity this)

Definition at line 22 of file multivibrator.qc.

23{
25}
void multivibrator_send(entity this)

References entity(), and multivibrator_send().

Referenced by spawnfunc().

◆ multivibrator_toggle()

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

Definition at line 27 of file multivibrator.qc.

28{
29 if(this.nextthink == 0)
30 {
32 }
33 else
34 {
35 if(this.state)
36 {
37 SUB_UseTargets(this, actor, trigger);
38 this.state = 0;
39 }
40 this.nextthink = 0;
41 }
42}

References entity(), multivibrator_send(), nextthink, state, and SUB_UseTargets().

Referenced by spawnfunc().

◆ spawnfunc()

spawnfunc ( trigger_multivibrator )

Definition at line 63 of file multivibrator.qc.

64{
65 if(!this.wait)
66 this.wait = 1;
67 if(!this.respawntime)
68 this.respawntime = this.wait;
69
70 this.state = 0;
73 this.nextthink = max(1, time);
74
75 if(this.targetname && this.targetname != "")
77}
#define use
void multivibrator_reset(entity this)
void multivibrator_toggle(entity this, entity actor, entity trigger)
void multivibrator_send_think(entity this)
#define setthink(e, f)
string targetname
Definition triggers.qh:56

References max(), multivibrator_reset(), multivibrator_send_think(), multivibrator_toggle(), nextthink, respawntime, setthink, state, targetname, time, use, and wait.