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

Go to the source code of this file.

Functions

 spawnfunc (target_voicescript)
void target_voicescript_clear (entity pl)
void target_voicescript_next (entity pl)
void target_voicescript_reset (entity this)
void target_voicescript_use (entity this, entity actor, entity trigger)

Variables

entity voicescript
float voicescript_index
float voicescript_nextthink
float voicescript_voiceend

Function Documentation

◆ spawnfunc()

spawnfunc ( target_voicescript )

Definition at line 89 of file voicescript.qc.

90{
91 // netname: directory of the sound files
92 // message: list of "sound file" duration "sound file" duration, a *, and again a list
93 // foo1 4.1 foo2 4.0 foo3 -3.1 * fool1 1.1 fool2 7.1 fool3 9.1 fool4 3.7
94 // Here, a - in front of the duration means that no delay is to be
95 // added after this message
96 // wait: average time between messages
97 // delay: initial delay before the first message
98
99 float i, n;
101 this.active = ACTIVE_ACTIVE;
102 this.reset = target_voicescript_reset;
103
104 n = tokenize_console(this.message);
105 this.cnt = n / 2;
106 for(i = 0; i+1 < n; i += 2)
107 {
108 if(argv(i) == "*")
109 {
110 this.cnt = i / 2;
111 ++i;
112 }
113 precache_sound(strcat(this.netname, "/", argv(i), ".wav"));
114 }
115}
string netname
Definition powerups.qc:20
float cnt
Definition powerups.qc:24
string message
Definition powerups.qc:19
#define use
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
#define tokenize_console
string precache_sound(string sample)
string argv(float n)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
void target_voicescript_use(entity this, entity actor, entity trigger)
void target_voicescript_reset(entity this)

References active, ACTIVE_ACTIVE, argv(), cnt, message, netname, precache_sound(), strcat(), target_voicescript_reset(), target_voicescript_use(), tokenize_console, and use.

◆ target_voicescript_clear()

void target_voicescript_clear ( entity pl)

Definition at line 8 of file voicescript.qc.

9{
10 pl.voicescript = NULL;
11}
#define NULL
Definition post.qh:14

References entity(), and NULL.

Referenced by PutPlayerInServer().

◆ target_voicescript_next()

void target_voicescript_next ( entity pl)

Definition at line 25 of file voicescript.qc.

26{
27 entity vs;
28 float i, n, dt;
29
30 vs = pl.voicescript;
31 if(!vs)
32 return;
33 if(vs.active != ACTIVE_ACTIVE)
34 {
35 pl.voicescript = NULL;
36 return;
37 }
38 if(vs.message == "")
39 return;
40 if (!IS_PLAYER(pl))
41 return;
42 if(game_stopped)
43 return;
44
45 if(time >= pl.voicescript_voiceend)
46 {
47 if(time >= pl.voicescript_nextthink)
48 {
49 // get the next voice...
50 n = tokenize_console(vs.message);
51
52 if(pl.voicescript_index < vs.cnt)
53 i = pl.voicescript_index * 2;
54 else if(n > vs.cnt * 2)
55 i = ((pl.voicescript_index - vs.cnt) % ((n - vs.cnt * 2 - 1) / 2)) * 2 + vs.cnt * 2 + 1;
56 else
57 i = -1;
58
59 if(i >= 0)
60 {
61 play2(pl, strcat(vs.netname, "/", argv(i), ".wav"));
62 dt = stof(argv(i + 1));
63 if(dt >= 0)
64 {
65 pl.voicescript_voiceend = time + dt;
66 pl.voicescript_nextthink = pl.voicescript_voiceend + vs.wait * (0.5 + random());
67 }
68 else
69 {
70 pl.voicescript_voiceend = time - dt;
71 pl.voicescript_nextthink = pl.voicescript_voiceend;
72 }
73
74 pl.voicescript_index += 1;
75 }
76 else
77 {
78 pl.voicescript = NULL; // stop trying then
79 }
80 }
81 }
82}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define IS_PLAYER(s)
Definition player.qh:243
float game_stopped
Definition stats.qh:81
float time
float stof(string val,...)
float random(void)
void play2(entity e, string filename)
Definition all.qc:116

References ACTIVE_ACTIVE, argv(), entity(), game_stopped, IS_PLAYER, NULL, play2(), random(), stof(), strcat(), time, and tokenize_console.

Referenced by PlayerPreThink().

◆ target_voicescript_reset()

void target_voicescript_reset ( entity this)

Definition at line 84 of file voicescript.qc.

85{
86 this.active = ACTIVE_ACTIVE;
87}

References active, ACTIVE_ACTIVE, and entity().

Referenced by spawnfunc().

◆ target_voicescript_use()

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

Definition at line 13 of file voicescript.qc.

14{
15 if(this.active != ACTIVE_ACTIVE)
16 return;
17 if(actor.voicescript != this)
18 {
19 actor.voicescript = this;
20 actor.voicescript_index = 0;
21 actor.voicescript_nextthink = time + this.delay;
22 }
23}
float delay
Definition items.qc:17

References active, ACTIVE_ACTIVE, delay, entity(), and time.

Referenced by spawnfunc().

Variable Documentation

◆ voicescript

entity voicescript

Definition at line 3 of file voicescript.qc.

◆ voicescript_index

float voicescript_index

Definition at line 4 of file voicescript.qc.

◆ voicescript_nextthink

float voicescript_nextthink

Definition at line 5 of file voicescript.qc.

◆ voicescript_voiceend

float voicescript_voiceend

Definition at line 6 of file voicescript.qc.