]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/defs.qh
e8b7ce5f9f3501b219043531a2ec21e930e9633c
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / defs.qh
1 #ifndef SERVER_DEFS_H
2 #define SERVER_DEFS_H
3
4 #if defined(CSQC)
5 #elif defined(MENUQC)
6 #elif defined(SVQC)
7         #include "../common/util-pre.qh"
8     #include "sys-pre.qh"
9     #include "../dpdefs/progsdefs.qh"
10     #include "../dpdefs/dpextensions.qh"
11     #include "sys-post.qh"
12     #include "../warpzonelib/anglestransform.qh"
13     #include "../warpzonelib/mathlib.qh"
14     #include "../warpzonelib/common.qh"
15     #include "../warpzonelib/util_server.qh"
16     #include "../warpzonelib/server.qh"
17     #include "../common/constants.qh"
18     #include "../common/stats.qh"
19     #include "../common/teams.qh"
20     #include "../common/util.qh"
21     #include "../common/nades.qh"
22     #include "../common/buffs.qh"
23     #include "../common/test.qh"
24     #include "../common/counting.qh"
25     #include "../common/urllib.qh"
26     #include "../common/command/markup.qh"
27     #include "../common/command/rpn.qh"
28     #include "../common/command/generic.qh"
29     #include "../common/command/shared_defs.qh"
30     #include "../common/net_notice.qh"
31     #include "../common/animdecide.qh"
32     #include "../common/monsters/monsters.qh"
33     #include "../common/monsters/sv_monsters.qh"
34     #include "../common/monsters/spawn.qh"
35     #include "../common/weapons/config.qh"
36     #include "../common/weapons/weapons.qh"
37     #include "weapons/accuracy.qh"
38     #include "weapons/common.qh"
39     #include "weapons/csqcprojectile.qh"
40     #include "weapons/hitplot.qh"
41     #include "weapons/selection.qh"
42     #include "weapons/spawning.qh"
43     #include "weapons/throwing.qh"
44     #include "weapons/tracing.qh"
45     #include "weapons/weaponstats.qh"
46     #include "weapons/weaponsystem.qh"
47     #include "t_items.qh"
48     #include "autocvars.qh"
49     #include "constants.qh"
50 #endif
51
52 #define INDEPENDENT_ATTACK_FINISHED
53
54 noref float require_spawnfunc_prefix; // if this float exists, only functions with spawnfunc_ name prefix qualify as spawn functions
55
56 #define BUTTON_ATCK       button0
57 #define BUTTON_JUMP       button2
58 #define BUTTON_ATCK2      button3
59 #define BUTTON_ZOOM       button4
60 #define BUTTON_CROUCH     button5
61 #define BUTTON_HOOK       button6
62 #define BUTTON_INFO       button7
63 #define BUTTON_CHAT       buttonchat
64 #define BUTTON_USE        buttonuse
65 #define BUTTON_DRAG       button8
66 #define BUTTON_ZOOMSCRIPT button9
67 #define BUTTON_JETPACK    button10
68
69 // Globals
70
71 float g_cloaked, g_footsteps, g_grappling_hook, g_instagib;
72 float g_warmup_limit;
73 float g_warmup_allguns;
74 float g_warmup_allow_timeout;
75 float warmup_stage;
76 float g_pickup_respawntime_weapon;
77 float g_pickup_respawntime_superweapon;
78 float g_pickup_respawntime_ammo;
79 float g_pickup_respawntime_short;
80 float g_pickup_respawntime_medium;
81 float g_pickup_respawntime_long;
82 float g_pickup_respawntime_powerup;
83 float g_pickup_respawntimejitter_weapon;
84 float g_pickup_respawntimejitter_superweapon;
85 float g_pickup_respawntimejitter_ammo;
86 float g_pickup_respawntimejitter_short;
87 float g_pickup_respawntimejitter_medium;
88 float g_pickup_respawntimejitter_long;
89 float g_pickup_respawntimejitter_powerup;
90 float g_jetpack;
91
92 float sv_clones;
93 float sv_foginterval;
94
95 entity  activator;
96
97 float player_count;
98 float currentbots;
99 float bots_would_leave;
100
101 void UpdateFrags(entity player, float f);
102 .float totalfrags;
103
104 float team1_score, team2_score, team3_score, team4_score;
105
106 float maxclients;
107
108 // flag set on worldspawn so that the code knows if it is dedicated or not
109 float server_is_dedicated;
110
111 // Fields
112
113 .void(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) event_damage;
114
115 //.string       wad;
116 //.string       map;
117
118 //.float        worldtype;
119 .float  delay;
120 .float  wait;
121 .float  lip;
122 //.float        light_lev;
123 .float  speed;
124 //.float        style;
125 //.float        skill;
126 .float  sounds;
127 .string  platmovetype;
128 .float platmovetype_start, platmovetype_end;
129
130 .string killtarget;
131
132 .vector pos1, pos2;
133 .vector mangle;
134
135 .float  pain_finished;                  //Added by Supajoe
136 .float  pain_frame;                     //"
137 .float  crouch; // Crouching or not?
138
139 .float  strength_finished;
140 .float  invincible_finished;
141 .float  superweapons_finished;
142
143 .vector         finaldest, finalangle;          //plat.qc stuff
144 .void()         think1;
145 .float state;
146 .float          t_length, t_width;
147
148 .vector destvec;                // for rain
149 .vector destvec2;               // for train
150 .float cnt;             // for rain
151 .float count;
152 //.float cnt2;
153
154 .float play_time;
155 .float respawn_flags;
156 .float respawn_time;
157 .float respawn_time_max;
158 .float death_time;
159 .float fade_time;
160 .float fade_rate;
161
162 // player animation state
163 .float animstate_startframe;
164 .float animstate_numframes;
165 .float animstate_framerate;
166 .float animstate_starttime;
167 .float animstate_endtime;
168 .float animstate_override;
169 .float animstate_looping;
170
171 // weapon animation vectors:
172 .vector anim_fire1;
173 .vector anim_fire2;
174 .vector anim_idle;
175 .vector anim_reload;
176
177 void() player_setupanimsformodel;
178 void setanim(entity e, vector anim, float looping, float override, float restart);
179
180 .string mdl;
181
182 .string playermodel;
183 .string playerskin;
184
185 .float species;
186
187 .float  respawntime;
188 .float  respawntimejitter;
189 //.float        chasecam;
190
191 .float  damageforcescale;
192 const float MIN_DAMAGEEXTRARADIUS = 2;
193 const float MAX_DAMAGEEXTRARADIUS = 16;
194 .float damageextraradius;
195
196 //.float          gravity;
197
198 .float          dmg;
199
200 // for railgun damage (hitting multiple enemies)
201 .float railgunhit;
202 .float railgunhitsolidbackup;
203 .vector railgunhitloc;
204
205 .float          air_finished;
206 .float          dmgtime;
207
208 .float          killcount;
209 .float damage_dealt, typehitsound;
210
211 .float watersound_finished;
212 .float iscreature;
213 .float damagedbycontents;
214 .float damagedbytriggers;
215 .float pushable;
216 .float teleportable;
217 .vector oldvelocity;
218
219 .float pauseregen_finished;
220 .float pauserothealth_finished;
221 .float pauserotarmor_finished;
222 .float pauserotfuel_finished;
223 .string item_pickupsound;
224
225 // definitions for weaponsystem
226 // more WEAPONTODO: move these to their proper files
227 .entity weaponentity;
228 .entity exteriorweaponentity;
229 .vector weaponentity_glowmod;
230
231 //.float weapon; // current weapon
232 .float switchweapon; // weapon requested to switch to
233 .float switchingweapon; // weapon currently being switched to (is copied from switchweapon once switch is possible)
234 .string weaponname; // name of .weapon
235
236 // WEAPONTODO
237 .float autoswitch;
238 //float WEP_ACTION(float wpn, float wrequest);
239 float client_hasweapon(entity cl, float wpn, float andammo, float complain);
240 void w_clear();
241 void w_ready();
242 // VorteX: standalone think for weapons, so normal think on weaponentity can be reserved by weaponflashes (which needs update even player dies)
243 .float weapon_nextthink;
244 .void() weapon_think;
245
246
247 // weapon states (self.weaponentity.state)
248 const float WS_CLEAR                    = 0; // no weapon selected
249 const float WS_RAISE                    = 1; // raise frame
250 const float WS_DROP                             = 2; // deselecting frame
251 const float WS_INUSE                    = 3; // fire state
252 const float WS_READY                    = 4; // idle frame
253
254 // there is 2 weapon tics that can run in one server frame
255 const float W_TICSPERFRAME = 2;
256
257 void weapon_defaultspawnfunc(float wpn);
258
259 .vector dest1, dest2;
260
261 float gameover;
262 float intermission_running;
263 float intermission_exittime;
264 float alreadychangedlevel;
265
266 // Keys player is holding
267 .float itemkeys;
268 // message delay for func_door locked by keys and key locks
269 // this field is used on player entities
270 .float key_door_messagetime;
271
272
273 .float version;
274
275 //swamp
276 .float in_swamp;              // bool
277 .entity swampslug;            // Uses this to release from swamp ("untouch" fix)
278
279 // footstep interval
280 .float nextstep;
281
282 float blockSpectators; //if set, new or existing spectators or observers will be removed unless they become a player within g_maxplayers_spectator_blocktime seconds
283 .float spectatortime; //point in time since the client is spectating or observing
284 void checkSpectatorBlock();
285
286 float game_completion_ratio; // 0 at start, 1 near end
287 .float winning;
288 .float jointime; // time of joining
289 .float alivetime; // time of being alive
290 .float motd_actived_time; // used for both motd and campaign_message
291
292 float nJoinAllowed(entity ignore);
293
294 .float spawnshieldtime;
295 .float item_spawnshieldtime;
296
297 .entity flagcarried;
298
299 .float playerid;
300 float playerid_last;
301 .float noalign;         // if set to 1, the item or spawnpoint won't be dropped to the floor
302
303 .vector spawnorigin;
304
305 .vector death_origin;
306 .vector killer_origin;
307
308 float default_player_alpha;
309 float default_weapon_alpha;
310
311 .float() customizeentityforclient;
312 .float cvar_cl_handicap;
313 .float cvar_cl_clippedspectating;
314 .float cvar_cl_autoscreenshot;
315 .float cvar_cl_jetpack_jump;
316 .float cvar_cl_movement_track_canjump;
317 .float cvar_cl_newusekeysupported;
318
319 .string cvar_g_xonoticversion;
320 .string cvar_cl_weaponpriority;
321 .string cvar_cl_weaponpriorities[10];
322 .float cvar_cl_gunalign;
323 .float cvar_cl_noantilag;
324
325 .string weaponorder_byimpulse;
326
327 .float cvar_cl_allow_uid2name;
328 .float cvar_cl_allow_uidtracking;
329 .string stored_netname;
330
331 .float version_nagtime;
332
333 const float NUM_JUMPPADSUSED = 3;
334 .float jumppadcount;
335 .entity jumppadsused[NUM_JUMPPADSUSED];
336
337 string gamemode_name;
338
339 float startitem_failed;
340
341 string W_Apply_Weaponreplace(string in);
342
343 void FixIntermissionClient(entity e);
344 void FixClientCvars(entity e);
345
346 // WEAPONTODO: remove this
347 WepSet weaponsInMap;
348
349 .float respawn_countdown; // next number to count
350
351 float bot_waypoints_for_items;
352
353 .float attack_finished_for[WEP_MAXCOUNT];
354 .float attack_finished_single;
355 #ifdef INDEPENDENT_ATTACK_FINISHED
356 #define ATTACK_FINISHED_FOR(ent,w) ((ent).(attack_finished_for[(w) - WEP_FIRST]))
357 #else
358 #define ATTACK_FINISHED_FOR(ent,w) ((ent).attack_finished_single)
359 #endif
360 #define ATTACK_FINISHED(ent) ATTACK_FINISHED_FOR(ent,(ent).weapon)
361
362 // assault game mode: Which team is attacking in this round?
363 float assault_attacker_team;
364
365 // speedrun: when 1, player auto teleports back when capture timeout happens
366 .float speedrunning;
367
368 // database
369 float ServerProgsDB;
370 float TemporaryDB;
371
372 .float team_saved;
373
374 float some_spawn_has_been_used;
375 float have_team_spawns; // 0 = no team spawns requested, -1 = team spawns requested but none found, 1 = team spawns requested and found
376 float have_team_spawns_forteam[17]; // 0 = this team has no spawns, 1 = this team has spawns; team 0 is the "no-team"
377
378 // set when showing a kill countdown
379 .entity killindicator;
380 .float killindicator_teamchange;
381
382 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force);
383
384 float lockteams;
385
386 .float parm_idlesince;
387 float sv_maxidle;
388 float sv_maxidle_spectatorsareidle;
389
390 float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end);
391
392 float next_pingtime;
393
394 .float Version;
395 .float SendFlags;
396 .float(entity to, float sendflags) SendEntity;
397
398 // player sounds, voice messages
399 // TODO implemented fall and falling
400 #define ALLPLAYERSOUNDS \
401                 _VOICEMSG(death) \
402                 _VOICEMSG(drown) \
403                 _VOICEMSG(fall) \
404                 _VOICEMSG(falling) \
405                 _VOICEMSG(gasp) \
406                 _VOICEMSG(jump) \
407                 _VOICEMSG(pain100) \
408                 _VOICEMSG(pain25) \
409                 _VOICEMSG(pain50) \
410                 _VOICEMSG(pain75)
411
412 #define ALLVOICEMSGS \
413                 _VOICEMSG(attack) \
414                 _VOICEMSG(attackinfive) \
415                 _VOICEMSG(coverme) \
416                 _VOICEMSG(defend) \
417                 _VOICEMSG(freelance) \
418                 _VOICEMSG(incoming) \
419                 _VOICEMSG(meet) \
420                 _VOICEMSG(needhelp) \
421                 _VOICEMSG(seenflag) \
422                 _VOICEMSG(taunt) \
423                 _VOICEMSG(teamshoot)
424
425 #define _VOICEMSG(m) .string playersound_##m;
426 ALLPLAYERSOUNDS
427 ALLVOICEMSGS
428 #undef _VOICEMSG
429
430 // reserved sound names for the future (some models lack sounds for them):
431 //              _VOICEMSG(flagcarriertakingdamage) \
432 //              _VOICEMSG(getflag) \
433 // reserved sound names for the future (ALL models lack sounds for them):
434 //              _VOICEMSG(affirmative) \
435 //              _VOICEMSG(attacking) \
436 //              _VOICEMSG(defending) \
437 //              _VOICEMSG(roaming) \
438 //              _VOICEMSG(onmyway) \
439 //              _VOICEMSG(droppedflag) \
440 //              _VOICEMSG(negative) \
441 //              _VOICEMSG(seenenemy) \
442
443 string globalsound_fall;
444 string globalsound_metalfall;
445 string globalsound_step;
446 string globalsound_metalstep;
447
448 const float VOICETYPE_PLAYERSOUND = 10;
449 const float VOICETYPE_TEAMRADIO = 11;
450 const float VOICETYPE_LASTATTACKER = 12;
451 const float VOICETYPE_LASTATTACKER_ONLY = 13;
452 const float VOICETYPE_AUTOTAUNT = 14;
453 const float VOICETYPE_TAUNT = 15;
454
455 void PrecachePlayerSounds(string f);
456 void PrecacheGlobalSound(string samplestring);
457 void UpdatePlayerSounds();
458 void ClearPlayerSounds();
459 void PlayerSound(.string samplefield, float channel, float voicetype);
460 void GlobalSound(string samplestring, float channel, float voicetype);
461 void FakeGlobalSound(string samplestring, float channel, float voicetype);
462 void VoiceMessage(string type, string message);
463 float GetPlayerSoundSampleField_notFound;
464 .string GetVoiceMessageSampleField(string type);
465
466 // autotaunt system
467 .float cvar_cl_autotaunt;
468 .float cvar_cl_voice_directional;
469 .float cvar_cl_voice_directional_taunt_attenuation;
470
471 .float version_mismatch;
472
473 float independent_players;
474 #define INDEPENDENT_PLAYERS (autocvar__independent_players ? (autocvar__independent_players > 0) : independent_players)
475 #define IS_INDEPENDENT_PLAYER(e) ((e).solid == SOLID_TRIGGER)
476 #define MAKE_INDEPENDENT_PLAYER(e) (((e).solid = SOLID_TRIGGER) + ((e).frags = FRAGS_PLAYER_NONSOLID))
477 // we're using + here instead of , because fteqcc sucks
478
479 string clientstuff;
480 .float phase;
481 .float pressedkeys;
482
483 .float porto_forbidden;
484
485 .string fog;
486
487 string cvar_changes;
488 string cvar_purechanges;
489 float cvar_purechanges_count;
490
491 float game_starttime; //point in time when the countdown to game start is over
492 float round_starttime; //point in time when the countdown to round start is over
493 .float stat_game_starttime;
494 .float stat_round_starttime;
495
496 .float stat_sv_airaccel_qw;
497 .float stat_sv_airstrafeaccel_qw;
498 .float stat_sv_airspeedlimit_nonqw;
499 .float stat_sv_maxspeed;
500
501 void W_Porto_Remove (entity p);
502
503 .int projectiledeathtype;
504
505 .string message2;
506
507 .float stat_allow_oldvortexbeam;
508
509 // reset to 0 on weapon switch
510 // may be useful to all weapons
511 .float bulletcounter;
512
513 void target_voicescript_next(entity pl);
514 void target_voicescript_clear(entity pl);
515
516 .string target2;
517 .string target3;
518 .string target4;
519 .string curvetarget;
520 .float target_random;
521 .float trigger_reverse;
522
523 // Nexball
524 .entity ballcarried; // Also used for keepaway
525 .float metertime;
526 float g_nexball_meter_period;
527
528 void SUB_DontUseTargets();
529 void SUB_UseTargets();
530
531 .void() reset; // if set, an entity is reset using this
532 .void() reset2; // if set, an entity is reset using this (after calling ALL the reset functions for other entities)
533
534 void ClientData_Touch(entity e);
535
536 //vector debug_shotorg; // if non-zero, overrides the shot origin of all weapons
537
538 .float wasplayer;
539
540 float servertime, serverprevtime, serverframetime;
541
542 .float ammo_fuel;
543
544 .vector prevorigin;
545
546 //flood fields
547 .float nickspamtime; // time of last nick change
548 .float nickspamcount;
549 .float floodcontrol_chat;
550 .float floodcontrol_chatteam;
551 .float floodcontrol_chattell;
552 .float floodcontrol_voice;
553 .float floodcontrol_voiceteam;
554
555 .float stat_shotorg; // networked stat for trueaim HUD
556
557 string matchid;
558
559 .float last_pickup;
560
561 .float hit_time;
562 .float typehit_time;
563
564 .float damage_dealt_total; 
565
566 .float stat_leadlimit;
567
568 float radar_showennemies;
569
570 #ifdef PROFILING
571 float client_cefc_accumulator;
572 float client_cefc_accumulatortime;
573 #endif
574
575 .float weapon_load[WEP_MAXCOUNT];
576 .float ammo_none; // used by the reloading system, must always be 0
577 .float clip_load;
578 .float old_clip_load;
579 .float clip_size;
580
581 .entity lastrocket;
582 .float minelayer_mines;
583 .float vortex_charge;
584 .float vortex_charge_rottime;
585 .float vortex_chargepool_ammo;
586 .float hagar_load;
587
588 .float grab; // 0 = can't grab, 1 = owner can grab, 2 = owner and team mates can grab, 3 = anyone can grab
589
590 #define PROJECTILE_MAKETRIGGER(e) (e).solid = SOLID_CORPSE; (e).dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE
591 // when doing this, hagar can go through clones
592 // #define PROJECTILE_MAKETRIGGER(e) (e).solid = SOLID_BBOX
593
594 .float spectatee_status;
595 .float zoomstate;
596 .float restriction;
597
598 .entity clientdata;
599 .entity personal;
600
601 string deathmessage;
602
603 .float just_joined;
604
605 .float cvar_cl_weaponimpulsemode;
606 .float selectweapon; // last selected weapon of the player
607
608 .float ballistics_density; // wall piercing factor, larger = bullet can pass through more
609
610 const float ACTIVE_NOT          = 0;
611 const float ACTIVE_ACTIVE       = 1;
612 const float ACTIVE_IDLE         = 2;
613 const float ACTIVE_BUSY         = 2;
614 const float ACTIVE_TOGGLE       = 3;
615 .float active;
616 .void (float act_state) setactive;
617 .entity realowner;
618
619 //float serverflags;
620
621 .float team_forced; // can be a team number to force a team, or 0 for default action, or -1 for forced spectator
622
623 .float player_blocked;
624 .float weapon_blocked; // weapon use disabled
625
626 .float frozen; // for freeze attacks
627 .float revive_progress;
628 .float revival_time; // time at which player was last revived
629 .float revive_speed; // NOTE: multiplier (anything above 1 is instaheal)
630 .entity iceblock;
631 .entity frozen_by; // for ice fields
632
633 .entity muzzle_flash;
634 .float misc_bulletcounter;      // replaces uzi & hlac bullet counter.
635
636 .float stat_respawn_time; // shows respawn time, and is negative when awaiting respawn
637
638 void PlayerUseKey();
639
640 typedef vector(entity player, entity spot, vector current) spawn_evalfunc_t;
641 .spawn_evalfunc_t spawn_evalfunc;
642
643 .entity conveyor;
644
645 string modname;
646
647 .float missile_flags;
648 const int MIF_SPLASH = 2;
649 const int MIF_ARC = 4;
650 const int MIF_PROXY = 8;
651 const int MIF_GUIDED_MANUAL = 16;
652 const int MIF_GUIDED_HEAT = 32;
653 const int MIF_GUIDED_LASER = 64;
654 const int MIF_GUIDED_AI = 128;
655 const int MIF_GUIDED_TAG = 128;
656 #define MIF_GUIDED_ALL (MIF_GUIDED_MANUAL | MIF_GUIDED_HEAT | MIF_GUIDED_LASER | MIF_GUIDED_AI | MIF_GUIDED_TAG)
657 #define MIF_GUIDED_TRACKING (MIF_GUIDED_HEAT | MIF_GUIDED_LASER | MIF_GUIDED_AI | MIF_GUIDED_TAG)
658 #define MIF_GUIDED_CONFUSABLE (MIF_GUIDED_HEAT | MIF_GUIDED_AI)
659
660 #define MISSILE_IS_CONFUSABLE(m) ((m.missile_flags & MIF_GUIDED_CONFUSABLE) ? true : false)
661 #define MISSILE_IS_GUIDED(m) ((m.missile_flags & MIF_GUIDED_ALL) ? true : false)
662 #define MISSILE_IS_TRACKING(m) ((m.missile_flags & MIF_GUIDED_TRACKING) ? true : false)
663
664
665 ////
666
667 .entity player_stats;
668 //.float playerid;
669 .string playernick;
670 .float elos;
671 .float ranks;
672 #endif