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

Go to the source code of this file.

Functions

void BGMScript_InitEntity (entity e)
 classfield (BGMScript) .float just_toggled
float doBGMScript (entity e)

Variables

float autocvar_bgmvolume
float bgmtime

Function Documentation

◆ BGMScript_InitEntity()

void BGMScript_InitEntity ( entity e)

Definition at line 116 of file bgmscript.qc.

117{
118 float l;
119 string m;
120 if(e.bgmscript != "")
121 {
124
125 float i;
126
127 m = strcat(e.bgmscript, " ");
128 l = strlen(m);
129
130 e.bgmscriptline0 = -1;
131 for(i = 0; i < bgmscriptbufsize; ++i)
132 {
133 if(substring(bufstr_get(bgmscriptbuf, i), 0, l) == m)
134 break;
135 }
136 e.bgmscriptline = e.bgmscriptline0 = i;
137 if(i >= bgmscriptbufsize)
138 {
139 LOG_INFOF("ERROR: bgmscript does not define %s", e.bgmscript);
140 strfree(e.bgmscript);
141 }
142 }
143}
float bgmscriptbufsize
Definition bgmscript.qc:9
float bgmscriptbuf
Definition bgmscript.qc:8
float bgmscriptbufloaded
Definition bgmscript.qc:10
void BGMScript_Init()
Definition bgmscript.qc:97
#define strlen
#define LOG_INFOF(...)
Definition log.qh:66
string substring(string s, float start, float length)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define strfree(this)
Definition string.qh:59

References BGMScript_Init(), bgmscriptbuf, bgmscriptbufloaded, bgmscriptbufsize, entity(), LOG_INFOF, strcat(), strfree, strlen, and substring().

◆ classfield()

classfield ( BGMScript )

◆ doBGMScript()

float doBGMScript ( entity e)

Definition at line 173 of file bgmscript.qc.

174{
175 float amp, vel;
176
177 if(e.bgmscript == "")
178 return 1;
179
180 if(autocvar_bgmvolume <= 0)
181 return -1;
182
183 e.just_toggled = false;
184
185 if(bgmtime < 0)
186 return -1;
187
188 if(bgmtime < e.bgmscripttime)
189 {
190 amp = GetCurrentAmplitude(e, e.bgmscripttime - e.bgmscriptstatetime + drawframetime);
191
192 e.bgmscriptline = e.bgmscriptline0;
193 e.bgmscripttime = bgmtime;
194
195 // treat this as a stop event for all notes, to prevent sticking keys
196 e.bgmscriptstate = false;
197 e.bgmscriptvolume = 1;
198 e.bgmscriptstatetime = bgmtime - GetTimeForAmplitude(e, amp);
199 }
200
201 // find the CURRENT line
202 for (;;)
203 {
204 tokenize_console(bufstr_get(bgmscriptbuf, e.bgmscriptline));
205 if(stof(argv(1)) >= bgmtime || argv(0) != e.bgmscript)
206 {
207 e.bgmscripttime = bgmtime;
208 return GetCurrentAmplitude(e, bgmtime - e.bgmscriptstatetime);
209 }
210 else if(bgmtime >= stof(argv(1)))
211 {
212 e.bgmscriptline += 1;
213 e.bgmscripttime = stof(argv(1));
214
215 amp = GetCurrentAmplitude(e, e.bgmscripttime - e.bgmscriptstatetime);
216
217 // time code reached!
218 vel = stof(argv(2));
219 if(vel > 0)
220 {
221 e.just_toggled = e.bgmscriptstate = true;
222 e.bgmscriptvolume = vel;
223 }
224 else
225 e.just_toggled = e.bgmscriptstate = false;
226
227 e.bgmscriptstatetime = e.bgmscripttime - GetTimeForAmplitude(e, amp);
228 }
229 }
230}
float GetCurrentAmplitude(entity e, float trel)
Definition bgmscript.qc:145
float GetTimeForAmplitude(entity e, float amp)
Definition bgmscript.qc:159
float bgmtime
Definition bgmscript.qh:9
float autocvar_bgmvolume
Definition bgmscript.qh:5
float drawframetime
Definition main.qh:108
#define tokenize_console
float stof(string val,...)
string argv(float n)

References argv(), autocvar_bgmvolume, bgmscriptbuf, bgmtime, drawframetime, entity(), GetCurrentAmplitude(), GetTimeForAmplitude(), stof(), and tokenize_console.

Variable Documentation

◆ autocvar_bgmvolume

float autocvar_bgmvolume

Definition at line 5 of file bgmscript.qh.

Referenced by doBGMScript().

◆ bgmtime

float bgmtime

Definition at line 9 of file bgmscript.qh.

Referenced by doBGMScript().