fix glowmod of weapon entity (no longer assign it to world, make code more consistent)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / defs.qh
1 #define INDEPENDENT_ATTACK_FINISHED
2
3 float require_spawnfunc_prefix; // if this float exists, only functions with spawnfunc_ name prefix qualify as spawn functions
4
5 #define BUTTON_ATCK   button0
6 #define BUTTON_JUMP   button2
7 #define BUTTON_ATCK2  button3
8 #define BUTTON_ZOOM   button4
9 #define BUTTON_CROUCH button5
10 #define BUTTON_HOOK   button6
11 #define BUTTON_INFO   button7
12 #define BUTTON_CHAT   buttonchat
13 #define BUTTON_USE    buttonuse
14 #define BUTTON_DRAG   button8
15
16 // Globals
17
18 float ctf_score_value(string parameter);
19
20 float g_dm, g_domination, g_ctf, g_tdm, g_keyhunt, g_onslaught, g_assault, g_arena, g_ca, g_lms, g_runematch, g_race, g_nexball, g_cts, g_freezetag, g_keepaway;
21 float g_cloaked, g_footsteps, g_jump_grunt, g_grappling_hook, g_midair, g_minstagib, g_pinata, g_norecoil, g_minstagib_invis_alpha, g_bloodloss;
22 float g_warmup_limit;
23 float g_warmup_allguns;
24 float g_warmup_allow_timeout;
25 float g_ctf_win_mode;
26 float g_ctf_ignore_frags;
27 float g_ctf_reverse;
28 float g_race_qualifying;
29 float inWarmupStage;
30 float g_pickup_respawntime_weapon;
31 float g_pickup_respawntime_ammo;
32 float g_pickup_respawntime_short;
33 float g_pickup_respawntime_medium;
34 float g_pickup_respawntime_long;
35 float g_pickup_respawntime_powerup;
36 float g_pickup_respawntimejitter_weapon;
37 float g_pickup_respawntimejitter_ammo;
38 float g_pickup_respawntimejitter_short;
39 float g_pickup_respawntimejitter_medium;
40 float g_pickup_respawntimejitter_long;
41 float g_pickup_respawntimejitter_powerup;
42 float g_jetpack;
43
44 float sv_clones;
45 float sv_gentle;
46 float sv_foginterval;
47
48 entity  activator;
49
50 float player_count;
51 float currentbots;
52 float bots_would_leave;
53 float lms_lowest_lives;
54 float lms_next_place;
55 float LMS_NewPlayerLives();
56
57 void UpdateFrags(entity player, float f);
58 .float totalfrags;
59
60 float team1_score, team2_score, team3_score, team4_score;
61
62 float maxclients;
63
64 // Fields
65
66 .void(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) event_damage;
67
68 //.string       wad;
69 //.string       map;
70
71 //.float        worldtype;
72 .float  delay;
73 .float  wait;
74 .float  lip;
75 //.float        light_lev;
76 .float  speed;
77 //.float        style;
78 //.float        skill;
79 .float  sounds;
80
81 .string killtarget;
82
83 .vector pos1, pos2;
84 .vector mangle;
85
86 .float cvar_cl_hitsound;
87
88 .float  pain_finished;                  //Added by Supajoe
89 .float  pain_frame;                     //"
90 .float  statdraintime;                  // record the one-second intervals between draining health and armour when they're over 100
91 .float  crouch; // Crouching or not?
92
93 .float  strength_finished;
94 //.float        speed_finished;
95 .float  invincible_finished;
96 //.float        slowmo_finished;
97
98 .vector         finaldest, finalangle;          //plat.qc stuff
99 .void()         think1;
100 .float state;
101 .float          t_length, t_width;
102
103 .vector destvec;                // for rain
104 .float cnt;             // for rain
105 .float count;
106 //.float cnt2;
107
108 .float play_time;
109 .float death_time;
110 .float dead_frame;
111 .float fade_time;
112 .float fade_rate;
113
114 // player animation state
115 .float animstate_startframe;
116 .float animstate_numframes;
117 .float animstate_framerate;
118 .float animstate_starttime;
119 .float animstate_endtime;
120 .float animstate_override;
121 .float animstate_looping;
122
123 // player animation data for this model
124 // each vector is as follows:
125 // _x = startframe
126 // _y = numframes
127 // _z = framerate
128 .vector anim_die1; // player dies
129 .vector anim_die2; // player dies differently
130 .vector anim_draw; // player pulls out a weapon
131 .vector anim_duck; // player crouches (from idle to duckidle)
132 .vector anim_duckwalk; // player walking while crouching
133 .vector anim_duckjump; // player jumping from a crouch
134 .vector anim_duckidle; // player idling while crouching
135 .vector anim_idle; // player standing
136 .vector anim_jump; // player jump
137 .vector anim_pain1; // player flinches from pain
138 .vector anim_pain2; // player flinches from pain, differently
139 .vector anim_shoot; // player shoots
140 .vector anim_taunt; // player taunts others (FIXME: no code references this)
141 .vector anim_run; // player running forward
142 .vector anim_runbackwards; // player running backward
143 .vector anim_strafeleft; // player shuffling left quickly
144 .vector anim_straferight; // player shuffling right quickly
145 .vector anim_dead1; // player dead (must be identical to last frame of die1)
146 .vector anim_dead2; // player dead (must be identical to last frame of die2)
147 .vector anim_forwardright; // player running forward and right
148 .vector anim_forwardleft; // player running forward and left
149 .vector anim_backright; // player running backward and right
150 .vector anim_backleft; // player running back and left
151
152 // weapon animation vectors:
153 .vector anim_fire1;
154 .vector anim_fire2;
155 .vector anim_idle;
156 .vector anim_reload;
157
158 void() player_setupanimsformodel;
159 void setanim(entity e, vector anim, float looping, float override, float restart);
160
161 .string mdl;
162
163 .string playermodel;
164 .string playerskin;
165
166 .float species;
167
168 .float  respawntime;
169 .float  respawntimejitter;
170 //.float        chasecam;
171
172 .float  damageforcescale;
173
174 //.float          gravity;
175
176 .float          dmg;
177
178 // for railgun damage (hitting multiple enemies)
179 .float railgunhit;
180 .float railgunhitsolidbackup;
181 .vector railgunhitloc;
182
183 .float          air_finished;
184 .float          dmgtime;
185
186 .float          killcount;
187 .float hitsound, typehitsound;
188
189 .float watersound_finished;
190 .float iscreature;
191 .vector oldvelocity;
192
193 .float pauseregen_finished;
194 .float pauserothealth_finished;
195 .float pauserotarmor_finished;
196 .float pauserotfuel_finished;
197 .string item_pickupsound;
198
199 // definitions for weaponsystem
200
201 .entity weaponentity;
202 .entity exteriorweaponentity;
203 .vector weaponentity_glowmod;
204 .float switchweapon;
205 .float autoswitch;
206 float weapon_action(float wpn, float wrequest);
207 float client_hasweapon(entity cl, float wpn, float andammo, float complain);
208 void w_clear();
209 void w_ready();
210 // VorteX: standalone think for weapons, so normal think on weaponentity can be reserved by weaponflashes (which needs update even player dies)
211 .float weapon_nextthink;
212 .void() weapon_think;
213
214 //float PLAYER_WEAPONSELECTION_DELAY = );
215 float   PLAYER_WEAPONSELECTION_SPEED = 18;
216 vector  PLAYER_WEAPONSELECTION_RANGE = '0 20 -40';
217
218 // weapon states (self.weaponentity.state)
219 float WS_CLEAR                  = 0; // no weapon selected
220 float WS_RAISE                  = 1; // raise frame
221 float WS_DROP                   = 2; // deselecting frame
222 float WS_INUSE                  = 3; // fire state
223 float WS_READY                  = 4; // idle frame
224
225 // there is 2 weapon tics that can run in one server frame
226 #define W_TICSPERFRAME 2
227
228 void weapon_defaultspawnfunc(float wpn);
229
230 string w_deathtypestring;
231
232 void(entity client, string s) centerprint_builtin = #73;
233 .vector dest1, dest2;
234
235 float gameover;
236 float intermission_running;
237 float intermission_exittime;
238 float alreadychangedlevel;
239
240
241 .float runes;
242
243
244 .float welcomemessage_time;
245 .float version;
246
247 // minstagib vars
248 .float jump_interval;    // laser refire
249
250 //swamp
251 .float in_swamp;              // bool
252 .entity swampslug;            // Uses this to release from swamp ("untouch" fix)
253
254 // footstep interval
255 .float nextstep;
256
257 .float ready;
258 #define RESTART_COUNTDOWN 10
259 float restart_mapalreadyrestarted; //bool, indicates whether reset_map() was already executed
260 entity restartTimer;
261 void restartTimer_Think();
262 float blockSpectators; //if set, new or existing spectators or observers will be removed unless they become a player within g_maxplayers_spectator_blocktime seconds
263 .float spectatortime; //point in time since the client is spectating or observing
264 void checkSpectatorBlock();
265
266 .float winning;
267 .float jointime; // time of joining
268 .float alivetime; // time of being alive
269
270 float isJoinAllowed();
271 #define PREVENT_JOIN_TEXT "^1You may not join the game at this time.\n\nThe player limit reached maximum capacity."
272
273 //sv_timeout: pauses the game by setting the gamespeed to a really low value (see TIMEOUT_SLOWMO_VALUE)
274 #define TIMEOUT_SLOWMO_VALUE 0.0001
275 float sys_frametime; // gets initialised in worlspawn, saves the value from autocvar_sys_ticrate
276 float remainingTimeoutTime; // contains the time in seconds that the active timeout has left
277 float remainingLeadTime; // contains the number of seconds left of the leadtime (before the timeout starts)
278 float timeoutStatus; // (values: 0, 1, 2) contains whether a timeout is not active (0), was called but still at leadtime (1) or is active (2)
279 .float allowedTimeouts; // contains the number of allowed timeouts for each player
280 entity timeoutInitiator; // contains the entity of the player who started the last timeout
281 float orig_slowmo; // contains the value of autocvar_slowmo so that, after timeout finished, it isn't set to slowmo 1 necessarily
282 .vector lastV_angle; //used when pausing the game in order to force the player to keep his old view angle fixed
283 entity timeoutHandler; //responsible for centerprinting the timeout countdowns and playing sounds
284 void timeoutHandler_Think();
285 void evaluateTimeout();
286 void evaluateTimein();
287 string getTimeoutText(float addOneSecond);
288
289 .float spawnshieldtime;
290
291 .float lms_nextcheck;
292 .float lms_traveled_distance;
293
294 .entity flagcarried;
295
296 .entity lastrocket;
297
298 .float playerid;
299 float playerid_last;
300 .float noalign;         // if set to 1, the item or spawnpoint won't be dropped to the floor
301
302 .vector spawnorigin;
303
304 .vector death_origin;
305 .vector killer_origin;
306
307 float default_player_alpha;
308 float default_weapon_alpha;
309
310 .float() customizeentityforclient;
311 .float cvar_cl_handicap;
312 .float cvar_cl_playerdetailreduction;
313 .float cvar_scr_centertime;
314 .float cvar_cl_shownames;
315 .string cvar_g_xonoticversion;
316 .string cvar_cl_weaponpriority;
317 .string cvar_cl_weaponpriorities[10];
318 #ifdef ALLOW_FORCEMODELS
319 .float cvar_cl_forceplayermodels;
320 .float cvar_cl_forceplayermodelsfromxonotic;
321 float sv_clforceplayermodels;
322 #endif
323 float sv_loddistance1;
324 float sv_loddistance2;
325 .float cvar_cl_gunalign;
326 .float cvar_cl_noantilag;
327
328 .string weaponorder_byimpulse;
329
330 .float cvar_cl_allow_uid2name;
331 .string stored_netname;
332
333 void Announce(string snd);
334 void AnnounceTo(entity e, string snd);
335
336 .float version_nagtime;
337
338 .float modelindex_lod0;
339 .float modelindex_lod0_from_xonotic;
340 .float skinindex;
341 .float modelindex_lod1;
342 .float modelindex_lod2;
343
344 #define NUM_JUMPPADSUSED 3
345 .float jumppadcount;
346 .entity jumppadsused[NUM_JUMPPADSUSED];
347
348 string gamemode_name;
349 float teams_matter;
350
351 float startitem_failed;
352
353 void DropFlag(entity flag, entity penalty_receiver, entity attacker);
354 void DropBall(entity ball, vector org, vector vel);
355 void DropAllRunes(entity pl);
356
357
358 typedef .float floatfield;
359 floatfield Item_CounterField(float it);
360
361 float W_AmmoItemCode(float wpn);
362 float W_WeaponBit(float wpn);
363 string W_Name(float weaponid);
364
365 void UpdateSelectedPlayer();
366 void ClearSelectedPlayer();
367 .entity selected_player;
368 .entity last_selected_player;
369 .float selected_player_time; // when this player has been selected
370 .float selected_player_count; // how long this player has been directly pointed to
371 .float selected_player_display_needs_update; // are regular updates necessary? (health)
372 .float selected_player_display_timeout; // when the selection will time out
373
374 void FixIntermissionClient(entity e);
375 void FixClientCvars(entity e);
376
377 float weaponsInMap;
378
379 void centerprint_atprio(entity e, float prio, string s);
380 void centerprint_expire(entity e, float prio);
381 void centerprint(entity e, string s);
382
383 .float respawn_countdown; // next number to count
384
385 float bot_waypoints_for_items;
386
387 .float attack_finished_for[WEP_MAXCOUNT];
388 .float attack_finished_single;
389 #ifdef INDEPENDENT_ATTACK_FINISHED
390 #define ATTACK_FINISHED_FOR(ent,w) ((ent).(attack_finished_for[(w) - WEP_FIRST]))
391 #else
392 #define ATTACK_FINISHED_FOR(ent,w) ((ent).attack_finished_single)
393 #endif
394 #define ATTACK_FINISHED(ent) ATTACK_FINISHED_FOR(ent,(ent).weapon)
395
396 // assault game mode: Which team is attacking in this round?
397 float assault_attacker_team;
398
399 // speedrun: when 1, player auto teleports back when capture timeout happens
400 .float speedrunning;
401
402 // Q3 support
403 .float notteam;
404 .float notsingle;
405 .float notfree;
406 .float notq3a;
407 float q3acompat_machineshotgunswap;
408
409 // database
410 float ServerProgsDB;
411 float TemporaryDB;
412
413 .float team_saved;
414
415 float some_spawn_has_been_used;
416 float have_team_spawns; // 0 = no team spawns requested, -1 = team spawns requested but none found, 1 = team spawns requested and found
417
418 // set when showing a kill countdown
419 .entity killindicator;
420 .float killindicator_teamchange;
421
422 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force);
423
424 float lockteams;
425
426 .float parm_idlesince;
427 float sv_maxidle;
428 float sv_maxidle_spectatorsareidle;
429
430 float sv_pogostick;
431 float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end);
432
433 float next_pingtime;
434
435 .float Version;
436 .float SendFlags;
437 .float(entity to, float sendflags) SendEntity;
438
439 // player sounds, voice messages
440 // TODO implemented fall and falling
441 #define ALLPLAYERSOUNDS \
442                 _VOICEMSG(death) \
443                 _VOICEMSG(fall) \
444                 _VOICEMSG(drown) \
445                 _VOICEMSG(gasp) \
446                 _VOICEMSG(jump) \
447                 _VOICEMSG(pain25) \
448                 _VOICEMSG(pain50) \
449                 _VOICEMSG(pain75) \
450                 _VOICEMSG(pain100)
451 #define ALLVOICEMSGS \
452                 _VOICEMSG(attack) \
453                 _VOICEMSG(attackinfive) \
454                 _VOICEMSG(meet) \
455                 _VOICEMSG(seenflag) \
456                 _VOICEMSG(taunt) \
457                 _VOICEMSG(teamshoot)
458
459 #define _VOICEMSG(m) .string playersound_##m;
460 ALLPLAYERSOUNDS
461 ALLVOICEMSGS
462 #undef _VOICEMSG
463
464 // reserved sound names for the future (models lack sounds for them):
465 //              _VOICEMSG(affirmative) \
466 //              _VOICEMSG(attacking) \
467 //              _VOICEMSG(defending) \
468 //              _VOICEMSG(roaming) \
469 //              _VOICEMSG(onmyway) \
470 //              _VOICEMSG(droppedflag) \
471 //              _VOICEMSG(flagcarriertakingdamage) \
472 //              _VOICEMSG(negative) \
473 //              _VOICEMSG(seenenemy) \
474 //              _VOICEMSG(fall) \
475 //              _VOICEMSG(getflag) \
476 //              _VOICEMSG(incoming) \
477 //              _VOICEMSG(coverme) \
478 //              _VOICEMSG(needhelp) \
479 //              _VOICEMSG(defend) \
480 //              _VOICEMSG(freelance) \
481 //              _VOICEMSG(falling) \
482
483 string globalsound_fall;
484 string globalsound_metalfall;
485 string globalsound_step;
486 string globalsound_metalstep;
487
488 #define VOICETYPE_PLAYERSOUND 10
489 #define VOICETYPE_TEAMRADIO 11
490 #define VOICETYPE_LASTATTACKER 12
491 #define VOICETYPE_LASTATTACKER_ONLY 13
492 #define VOICETYPE_AUTOTAUNT 14
493 #define VOICETYPE_TAUNT 15
494
495 void PrecachePlayerSounds(string f);
496 void PrecacheGlobalSound(string samplestring);
497 void UpdatePlayerSounds();
498 void ClearPlayerSounds();
499 void PlayerSound(.string samplefield, float channel, float voicetype);
500 void GlobalSound(string samplestring, float channel, float voicetype);
501 void FakeGlobalSound(string samplestring, float channel, float voicetype);
502 void VoiceMessage(string type, string message);
503 float GetPlayerSoundSampleField_notFound;
504 .string GetVoiceMessageSampleField(string type)
505
506 // autotaunt system
507 .float cvar_cl_autotaunt;
508 .float cvar_cl_voice_directional;
509 .float cvar_cl_voice_directional_taunt_attenuation;
510
511 .float version_mismatch;
512
513 float independent_players;
514 #define IS_INDEPENDENT_PLAYER(e) ((e).solid == SOLID_TRIGGER)
515 #define MAKE_INDEPENDENT_PLAYER(e) (((e).solid = SOLID_TRIGGER) + ((e).frags = FRAGS_PLAYER_NONSOLID))
516 // we're using + here instead of , because fteqcc sucks
517
518 string clientstuff;
519 .float phase;
520 .float weapons;
521 .float pressedkeys;
522
523 .float porto_forbidden;
524
525 .string fog;
526
527 string cvar_changes;
528 string cvar_purechanges;
529 float cvar_purechanges_count;
530
531 float game_starttime; //point in time when the countdown is over
532 .float stat_game_starttime;
533
534 .float stat_sv_airaccel_qw;
535 .float stat_sv_airstrafeaccel_qw;
536 .float stat_sv_airspeedlimit_nonqw;
537 .float stat_sv_maxspeed;
538
539 void W_Porto_Remove (entity p);
540
541 .float projectiledeathtype;
542
543 .string message2;
544
545 vector railgun_start, railgun_end; // filled by FireRailgunBullet, used by damage code for head shot
546 .float stat_allow_oldnexbeam;
547
548 // reset to 0 on weapon switch
549 // may be useful to all weapons
550 .float bulletcounter;
551
552 void target_voicescript_next(entity pl);
553 void target_voicescript_clear(entity pl);
554
555 .string target2;
556 .string target3;
557 .string target4;
558 .float trigger_reverse;
559
560 // Nexball 
561 .entity ballcarried; // Also used for keepaway
562 .float metertime;
563 float g_nexball_meter_period;
564
565 void SUB_DontUseTargets();
566 void SUB_UseTargets();
567
568 .void() reset; // if set, an entity is reset using this
569 .void() reset2; // if set, an entity is reset using this (after calling ALL the reset functions for other entities)
570
571 void ClientData_Touch(entity e);
572
573 vector debug_shotorg; // if non-zero, overrides the shot origin of all weapons
574
575 // the QC VM sucks
576 #define BITXOR(v,b)        ((v) + (b) - 2 * ((v) & (b)))
577 #define BITXOR_ASSIGN(v,b) ((v) += ((b) - 2 * ((v) & (b))))
578
579 .float wasplayer;
580
581 float servertime, serverprevtime, serverframetime;
582
583 .entity soundentity;
584
585 .float ammo_fuel;
586
587 .vector prevorigin;
588
589 //flood fields
590 .float nickspamtime; // time of last nick change
591 .float nickspamcount;
592 .float floodcontrol_chat;
593 .float floodcontrol_chatteam;
594 .float floodcontrol_chattell;
595 .float floodcontrol_voice;
596 .float floodcontrol_voiceteam;
597
598 .float stat_shotorg; // networked stat for trueaim HUD
599
600 string matchid;
601 .float hitplotfh;
602 .string noise4;
603
604 .float last_pickup;
605
606 .float stat_leadlimit;
607
608 float radar_showennemies;
609
610 #ifdef PROFILING
611 float client_cefc_accumulator;
612 float client_cefc_accumulatortime;
613 #endif
614
615 .float campingrifle_bulletcounter;
616
617 #define PROJECTILE_MAKETRIGGER(e) (e).solid = SOLID_CORPSE; (e).dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE
618 // when doing this, hagar can go through clones
619 // #define PROJECTILE_MAKETRIGGER(e) (e).solid = SOLID_BBOX
620
621 .float spectatee_status;
622 .float zoomstate;
623 .float bloodloss_timer;
624 .float restriction;
625
626 .entity clientdata;
627 .entity personal;
628
629 string deathmessage;
630
631 .float just_joined;
632
633 .float cvar_cl_accuracy_data_share;
634 .float cvar_cl_accuracy_data_receive;
635
636 .float cvar_cl_weaponimpulsemode;
637 .float selectweapon; // last selected weapon of the player
638
639 .float ballistics_density; // wall piercing factor, larger = bullet can pass through more
640
641 #define ACTIVE_NOT              0
642 #define ACTIVE_ACTIVE   1
643 #define ACTIVE_IDLE     2
644 #define ACTIVE_BUSY     2
645 #define ACTIVE_TOGGLE   3
646 .float active;
647 .float (float act_state) setactive;
648 .entity realowner;
649
650 .float nex_charge;
651 .float nex_charge_rottime;
652 .float nex_chargepool_ammo;
653
654 float allowed_to_spawn; // boolean variable used by the clan arena code to determine if a player can spawn (after the round has ended)
655
656 float serverflags;
657
658 .float team_forced; // can be a team number to force a team, or 0 for default action, or -1 for forced spectator
659
660 .float freezetag_frozen;
661 .float freezetag_beginrevive_time;
662 .float freezetag_revive_progress;