-
Notifications
You must be signed in to change notification settings - Fork 17
/
world.qc
529 lines (442 loc) · 15 KB
/
world.qc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
void() main =
{
dprint ("main function\n");
// these are just commands to the prog compiler to copy these files
precache_file ("progs.dat");
precache_file ("gfx.wad");
precache_file ("quake.rc");
precache_file ("default.cfg");
precache_file ("end1.bin");
precache_file2 ("end2.bin");
precache_file ("demo1.dem");
precache_file ("demo2.dem");
precache_file ("demo3.dem");
//
// these are all of the lumps from the cached.ls files
//
precache_file ("gfx/palette.lmp");
precache_file ("gfx/colormap.lmp");
precache_file2 ("gfx/pop.lmp");
precache_file ("gfx/complete.lmp");
precache_file ("gfx/inter.lmp");
precache_file ("gfx/ranking.lmp");
precache_file ("gfx/vidmodes.lmp");
precache_file ("gfx/finale.lmp");
precache_file ("gfx/conback.lmp");
precache_file ("gfx/qplaque.lmp");
precache_file ("gfx/menudot1.lmp");
precache_file ("gfx/menudot2.lmp");
precache_file ("gfx/menudot3.lmp");
precache_file ("gfx/menudot4.lmp");
precache_file ("gfx/menudot5.lmp");
precache_file ("gfx/menudot6.lmp");
precache_file ("gfx/menuplyr.lmp");
precache_file ("gfx/bigbox.lmp");
precache_file ("gfx/dim_modm.lmp");
precache_file ("gfx/dim_drct.lmp");
precache_file ("gfx/dim_ipx.lmp");
precache_file ("gfx/dim_tcp.lmp");
precache_file ("gfx/dim_mult.lmp");
precache_file ("gfx/mainmenu.lmp");
precache_file ("gfx/box_tl.lmp");
precache_file ("gfx/box_tm.lmp");
precache_file ("gfx/box_tr.lmp");
precache_file ("gfx/box_ml.lmp");
precache_file ("gfx/box_mm.lmp");
precache_file ("gfx/box_mm2.lmp");
precache_file ("gfx/box_mr.lmp");
precache_file ("gfx/box_bl.lmp");
precache_file ("gfx/box_bm.lmp");
precache_file ("gfx/box_br.lmp");
precache_file ("gfx/sp_menu.lmp");
precache_file ("gfx/ttl_sgl.lmp");
precache_file ("gfx/ttl_main.lmp");
precache_file ("gfx/ttl_cstm.lmp");
precache_file ("gfx/mp_menu.lmp");
precache_file ("gfx/netmen1.lmp");
precache_file ("gfx/netmen2.lmp");
precache_file ("gfx/netmen3.lmp");
precache_file ("gfx/netmen4.lmp");
precache_file ("gfx/netmen5.lmp");
precache_file ("gfx/sell.lmp");
precache_file ("gfx/help0.lmp");
precache_file ("gfx/help1.lmp");
precache_file ("gfx/help2.lmp");
precache_file ("gfx/help3.lmp");
precache_file ("gfx/help4.lmp");
precache_file ("gfx/help5.lmp");
precache_file ("gfx/pause.lmp");
precache_file ("gfx/loading.lmp");
precache_file ("gfx/p_option.lmp");
precache_file ("gfx/p_load.lmp");
precache_file ("gfx/p_save.lmp");
precache_file ("gfx/p_multi.lmp");
// sounds loaded by C code
precache_sound ("misc/menu1.wav");
precache_sound ("misc/menu2.wav");
precache_sound ("misc/menu3.wav");
precache_sound ("ambience/water1.wav");
precache_sound ("ambience/wind2.wav");
// shareware
precache_file ("maps/start.bsp");
precache_file ("maps/e1m1.bsp");
precache_file ("maps/e1m2.bsp");
precache_file ("maps/e1m3.bsp");
precache_file ("maps/e1m4.bsp");
precache_file ("maps/e1m5.bsp");
precache_file ("maps/e1m6.bsp");
precache_file ("maps/e1m7.bsp");
precache_file ("maps/e1m8.bsp");
// registered
precache_file2 ("gfx/pop.lmp");
precache_file2 ("maps/e2m1.bsp");
precache_file2 ("maps/e2m2.bsp");
precache_file2 ("maps/e2m3.bsp");
precache_file2 ("maps/e2m4.bsp");
precache_file2 ("maps/e2m5.bsp");
precache_file2 ("maps/e2m6.bsp");
precache_file2 ("maps/e2m7.bsp");
precache_file2 ("maps/e3m1.bsp");
precache_file2 ("maps/e3m2.bsp");
precache_file2 ("maps/e3m3.bsp");
precache_file2 ("maps/e3m4.bsp");
precache_file2 ("maps/e3m5.bsp");
precache_file2 ("maps/e3m6.bsp");
precache_file2 ("maps/e3m7.bsp");
precache_file2 ("maps/e4m1.bsp");
precache_file2 ("maps/e4m2.bsp");
precache_file2 ("maps/e4m3.bsp");
precache_file2 ("maps/e4m4.bsp");
precache_file2 ("maps/e4m5.bsp");
precache_file2 ("maps/e4m6.bsp");
precache_file2 ("maps/e4m7.bsp");
precache_file2 ("maps/e4m8.bsp");
precache_file2 ("maps/end.bsp");
precache_file2 ("maps/dm1.bsp");
precache_file2 ("maps/dm2.bsp");
precache_file2 ("maps/dm3.bsp");
precache_file2 ("maps/dm4.bsp");
precache_file2 ("maps/dm5.bsp");
precache_file2 ("maps/dm6.bsp");
}
//=======================
/*QUAKED worldspawn (0 0 0) ?
Keys:
"light" default light level
"message" sets the title of the map
"sounds" CD track to play
"wad" which graphics wads to use. semicolon delineated, no spaces
"worldtype" style of keys to spawn
0 = medieval
1 = metal
2 = base
"gravity" how fast your dreams come crashing down
"_sunlight" "#"
"_sun_mangle" "# # 0" yaw pitch roll. pitch is 90 to -90 degrees up to down.
"_sunlight_color" "# # #"
"_dirt" use dirtmapping
"_dirtdepth" length of dirt rays, default 128.
"_dirtscale" Scale factor used in dirt calculations, default 1 (higher is darker)
"_dirtgain" Exponent used in dirt calculation, default 1 (lower is darker)
*/
/*FGD
@SolidClass color(240 240 240) = worldspawn : "World entity"
[
message(string) : "Map name"
worldtype(choices) : "Key Style" : 0 =
[
0 : "Medieval"
1 : "Runemetal"
2 : "Base"
]
fog(string) : "Set fog via engine (D R G B)"
fog_density(string) : "Set fog density via mod"
fog_color(string) : "Set fog color via mod (R G B)"
sounds(integer) : "CD track to play" : 0
light(integer) : "Ambient light"
gravity(integer) : "Gravity"
sky(string) : "Skybox"
_skyfog(string) : "Sky fog strength"
_wateralpha(string) : "Water alpha"
_lavaalpha(string) : "Lava alpha" : "1.0"
_telealpha(string) : "Tele alpha" : "1.0"
_sunlight(integer) : "Sunlight"
_sun_mangle(string) : "Sun mangle (Yaw pitch roll)"
_sunlight_color(string) : "Sun color"
_dirt(integer) : "use dirtmapping" : 0
_dirtdepth(integer) : "length of dirt rays" : 128
_dirtscale(string) : "Scale factor used in dirt calculations, higher is darker" : "1.0"
_dirtgain(string) : "Exponent used in dirt calculation, lower is darker" : "1.0"
]
*/
//=======================
void() worldspawn =
{
lastspawn = world;
startingserverflags = serverflags;
InitBodyQueue ();
InitLightStyles(); // moved to lights.qc
if (!self.gravity)
{
if (mapname == "e1m8")
{
self.gravity = 100;
}
else
{
self.gravity = 800;
}
}
cvar_set("sv_gravity", ftos(self.gravity));
// learn to map petersen i hate u
if (mapname == "e4m5") sandyMadeThis = TRUE;
// make sure these are set for spawnfuncs, which happen before the first startframe()
teamplay = cvar("teamplay");
skill = cvar("skill");
self.light_lev = 0; // shut up FTEQCC warning
fog_fixKeys(); // -1 -> 0 switch, if world has fog values
keyType = "Key"; // default if there are no keys placed in the map
if (cvar("pr_checkextension"))
{
if (checkextension("QUAKE_EX"))
{
// do absolutely nothing in the rerelease
isKex = TRUE;
}
#ifndef NO_CSQC
else
{
isCSQC = TRUE;
/*
// globalstat is inconsistently implemented (ironwail) because the "EXT_CSQC"
// extension is actually undefined and meaningless
if (checkextension("EXT_CSQC"))
{
globalstat(STAT_CLIENTS, 2, "clients");
globalstat(STAT_CLIENTDATA, 2, "clientsAliveMask"); // client death status monitor
}
else
*/
clientstat(STAT_KEYCOUNTS, 2, worldtype); // multiple keys on hud
clientstat(STAT_CLIENTDATA, 2, clientdata); // shitty client death status monitor
clientstat(STAT_TINTAMOUNT, 2, tint); // backdoor v_cshift
clientstat(STAT_TINTCOLOR_R, 2, tint_color_x);
clientstat(STAT_TINTCOLOR_G, 2, tint_color_y);
clientstat(STAT_TINTCOLOR_B, 2, tint_color_z);
}
#endif
}
cdtrack = &world.sounds; // absolute madness. see void() target_music_use
// the area based ambient sounds MUST be the first precache_sounds
// player precaches
W_Precache (); // get weapon precaches
precache_sound ("misc/null.wav");
// sounds used from C physics code
precache_sound ("demon/dland2.wav"); // landing thud
precache_sound ("misc/h2ohit1.wav"); // landing splash
// player sounds
precache_sound ("items/itembk2.wav"); // item respawn sound
precache_sound ("player/plyrjmp8.wav"); // player jump
precache_sound ("player/land.wav"); // player landing
precache_sound ("player/land2.wav"); // player hurt landing
precache_sound ("player/drown1.wav"); // drowning pain
precache_sound ("player/drown2.wav"); // drowning pain
precache_sound ("player/gasp1.wav"); // gasping for air
precache_sound ("player/gasp2.wav"); // taking breath
precache_sound ("player/h2odeath.wav"); // drowning death
precache_sound ("misc/talk.wav"); // talk
precache_sound ("player/teledth1.wav"); // telefrag
precache_sound ("misc/r_tele1.wav"); // teleport sounds
precache_sound ("misc/r_tele2.wav");
precache_sound ("misc/r_tele3.wav");
precache_sound ("misc/r_tele4.wav");
precache_sound ("misc/r_tele5.wav");
// iw -- fix powerup cheat sounds
// sounds used by cheats
precache_sound ("items/suit2.wav"); // suit (finish)
precache_sound ("items/protect2.wav"); // pent (finish)
precache_sound ("items/protect3.wav"); // pent (protect)
precache_sound ("items/inv2.wav"); // ring (finish)
precache_sound ("items/inv3.wav"); // ring (idle)
precache_sound ("items/damage2.wav"); // quad (finish)
precache_sound ("items/damage3.wav"); // quad (attack)
// iw -- END
// items
precache_sound ("weapons/lock4.wav"); // ammo pick up
precache_sound ("weapons/pkup.wav"); // weapon up
precache_sound ("items/armor1.wav"); // armor up
precache_sound3("items/pack.wav"); // backpacks can play either of these
precache_sound3("items/patch.wav");
// player gib sounds
precache_sound ("player/gib.wav"); // player gib sound
precache_sound ("player/udeath.wav"); // player gib sound
precache_sound ("player/tornoff2.wav"); // gib sound
// player pain sounds
precache_sound ("player/pain1.wav");
precache_sound ("player/pain2.wav");
precache_sound ("player/pain3.wav");
precache_sound ("player/pain4.wav");
precache_sound ("player/pain5.wav");
precache_sound ("player/pain6.wav");
// player death sounds
precache_sound ("player/death1.wav");
precache_sound ("player/death2.wav");
precache_sound ("player/death3.wav");
precache_sound ("player/death4.wav");
precache_sound ("player/death5.wav");
// liquids
precache_sound ("player/h2ojump.wav"); // player jumping into water
precache_sound ("player/slimbrn2.wav"); // player enter slime
precache_sound ("player/inh2o.wav"); // player enter water
precache_sound ("player/inlava.wav"); // player enter lava
precache_sound ("misc/outwater.wav"); // leaving water sound
precache_sound ("misc/w_under.wav"); // copper: diving water sound
precache_sound ("misc/w_under2.wav"); // copper: diving water sound
precache_sound ("player/lburn1.wav"); // lava burn
precache_sound ("player/lburn2.wav"); // lava burn
precache_sound ("misc/water1.wav"); // swimming
precache_sound ("misc/water2.wav"); // swimming
precache_model ("progs/player.mdl");
precache_model ("progs/eyes.mdl");
precache_model ("progs/h_player.mdl");
precache_model ("progs/gib1.mdl");
precache_model ("progs/gib2.mdl");
precache_model ("progs/gib3.mdl");
precache_model ("progs/s_bubble.spr"); // drowning bubbles
precache_model ("progs/s_explod.spr"); // sprite explosion
precache_model ("progs/s_explo2.spr"); // sprite weak explosion
precache_model ("progs/bolt.mdl"); // for lightning gun
precache_model ("progs/bolt2.mdl"); // for lightning gun
precache_model ("progs/bolt3.mdl"); // for boss shock
precache_model ("progs/lavaball.mdl"); // for testing
precache_model ("progs/missile.mdl");
precache_model ("progs/grenade.mdl");
precache_model ("progs/spike.mdl");
//precache_model ("progs/s_spike.mdl");
precache_model ("progs/backpack.mdl");
precache_model ("progs/zom_gib.mdl");
}
void() StartFrame =
{
teamplay = cvar("teamplay");
if (initCleanup)
{
initCleanup -= 1;
if (skill_str != string_null)
{
dprint("restoring skill from save\n");
cvar_set("skill",skill_str);
}
}
else if (!gamestarted && framecount > 2)
{
if (framecount != 3)
initCleanup += 2;
gamestarted = TRUE;
}
float sk = cvar("skill");
entity skbtn;
if (sk != skill)
{
skill = sk;
skbtn = skill_head;
while (skbtn)
{
self = skbtn;
dprint("activating skillbutton from startframe\n");
skillbutton_activate();
skbtn = skbtn.owner;
}
self = world;
}
framecount++;
//cvar_set("registered",ftos(framecount));
#ifndef NO_CSQC
// assemble two bytes out of client count and a bitmask of who's dead to send to
// players for display on the hud and scoreboard
if (coop || deathmatch)
{
entity e = nextent(world);
float p = 16;
float clientDataMask;
clientDataMask = clients & 15;
while (e.flags & FL_CLIENT)
{
if (e.health > 0 && e.deadflag != DEAD_DEAD)
clientDataMask |= p;
p *= 2;
e = nextent(e);
}
// globalstat() isn't reliable in quake ports that implement completely random
// assortments of csqc extensions, but somehow clientstat() is implemented in
// every engine that implements any csqc, so we have to copy the number to every
// player and send it as a client stat instead. so it goes.
e = nextent(world);
while (e.flags & FL_CLIENT)
{
e.clientdata = clientDataMask;
e = nextent(e);
}
}
#endif
/*
'activator' should be a parameter of *_use(), but it's a global. so it goes.
this can lead to lots of hard-to-repro bugs in cases where 'activator' isn't set
properly, since it just happens to be set to the player anyway *most* of the time.
for this reason I enforce a global ban on activator ever being 'world' (via a
gameplay-ending error() in SUB_UseTargets) and nulling it out every single frame.
stale or incorrectly set activators are thus smoked out immediately, and not six
months from now the first time a monster touches a door field at a critical but
impossible to reproduce moment.
*/
activator = world;
}
/*
==============================================================================
BODY QUE[UE ~ ed.]
==============================================================================
*/
void() bodyqueue =
{ // just here so spawn functions don't complain after the world creates bodyqueues
}
void() InitBodyQueue =
{
entity bq;
bq = spawn();
bq.classname = "bodyqueue";
bq.owner = bq;
bodyqueue_head = bq;
float i = 0;
while (i < 5)
{
bq = spawn();
bq.classname = "bodyqueue";
bq.owner = bodyqueue_head.owner;
bodyqueue_head.owner = bq;
i++;
}
/*
bodyqueue_head.owner = spawn();
bodyqueue_head.owner.classname = "bodyqueue";
bodyqueue_head.owner.owner = spawn();
bodyqueue_head.owner.owner.classname = "bodyqueue";
bodyqueue_head.owner.owner.owner = spawn();
bodyqueue_head.owner.owner.owner.classname = "bodyqueue";
bodyqueue_head.owner.owner.owner.owner = bodyqueue_head;*/
}
// make a body queue entry for the given ent so the ent can be
// respawned elsewhere
void(entity ent) CopyToBodyQueue =
{
bodyqueue_head.angles = ent.angles;
bodyqueue_head.model = ent.model;
bodyqueue_head.modelindex = ent.modelindex;
bodyqueue_head.frame = ent.frame;
bodyqueue_head.colormap = ent.colormap;
bodyqueue_head.movetype = ent.movetype;
bodyqueue_head.velocity = ent.velocity;
bodyqueue_head.flags = 0;
setorigin (bodyqueue_head, ent.origin);
setsize (bodyqueue_head, ent.mins, ent.maxs);
bodyqueue_head = bodyqueue_head.owner;
}