7 #include "../common/util-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"
48 #include "autocvars.qh"
49 #include "constants.qh"
52 #define INDEPENDENT_ATTACK_FINISHED
54 noref float require_spawnfunc_prefix; // if this float exists, only functions with spawnfunc_ name prefix qualify as spawn functions
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
71 float g_cloaked, g_footsteps, g_grappling_hook, g_instagib;
73 float g_warmup_allguns;
74 float g_warmup_allow_timeout;
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;
99 float bots_would_leave;
101 void UpdateFrags(entity player, float f);
104 float team1_score, team2_score, team3_score, team4_score;
108 // flag set on worldspawn so that the code knows if it is dedicated or not
109 float server_is_dedicated;
113 .void(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) event_damage;
127 .string platmovetype;
128 .float platmovetype_start, platmovetype_end;
135 .float pain_finished; //Added by Supajoe
136 .float pain_frame; //"
137 .float crouch; // Crouching or not?
139 .float strength_finished;
140 .float invincible_finished;
141 .float superweapons_finished;
143 .vector finaldest, finalangle; //plat.qc stuff
146 .float t_length, t_width;
148 .vector destvec; // for rain
149 .vector destvec2; // for train
150 .float cnt; // for rain
155 .float respawn_flags;
157 .float respawn_time_max;
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;
171 // weapon animation vectors:
177 void() player_setupanimsformodel;
178 void setanim(entity e, vector anim, float looping, float override, float restart);
188 .float respawntimejitter;
191 .float damageforcescale;
192 const float MIN_DAMAGEEXTRARADIUS = 2;
193 const float MAX_DAMAGEEXTRARADIUS = 16;
194 .float damageextraradius;
200 // for railgun damage (hitting multiple enemies)
202 .float railgunhitsolidbackup;
203 .vector railgunhitloc;
209 .float damage_dealt, typehitsound;
211 .float watersound_finished;
213 .float damagedbycontents;
214 .float damagedbytriggers;
219 .float pauseregen_finished;
220 .float pauserothealth_finished;
221 .float pauserotarmor_finished;
222 .float pauserotfuel_finished;
223 .string item_pickupsound;
225 // definitions for weaponsystem
226 // more WEAPONTODO: move these to their proper files
227 .entity weaponentity;
228 .entity exteriorweaponentity;
229 .vector weaponentity_glowmod;
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
238 //float WEP_ACTION(float wpn, float wrequest);
239 float client_hasweapon(entity cl, float wpn, float andammo, float complain);
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;
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
254 // there is 2 weapon tics that can run in one server frame
255 const float W_TICSPERFRAME = 2;
257 void weapon_defaultspawnfunc(float wpn);
259 .vector dest1, dest2;
262 float intermission_running;
263 float intermission_exittime;
264 float alreadychangedlevel;
266 // Keys player is holding
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;
276 .float in_swamp; // bool
277 .entity swampslug; // Uses this to release from swamp ("untouch" fix)
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();
286 float game_completion_ratio; // 0 at start, 1 near end
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
292 float nJoinAllowed(entity ignore);
294 .float spawnshieldtime;
295 .float item_spawnshieldtime;
301 .float noalign; // if set to 1, the item or spawnpoint won't be dropped to the floor
305 .vector death_origin;
306 .vector killer_origin;
308 float default_player_alpha;
309 float default_weapon_alpha;
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;
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;
325 .string weaponorder_byimpulse;
327 .float cvar_cl_allow_uid2name;
328 .float cvar_cl_allow_uidtracking;
329 .string stored_netname;
331 .float version_nagtime;
333 const float NUM_JUMPPADSUSED = 3;
335 .entity jumppadsused[NUM_JUMPPADSUSED];
337 string gamemode_name;
339 float startitem_failed;
341 string W_Apply_Weaponreplace(string in);
343 void FixIntermissionClient(entity e);
344 void FixClientCvars(entity e);
346 // WEAPONTODO: remove this
349 .float respawn_countdown; // next number to count
351 float bot_waypoints_for_items;
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]))
358 #define ATTACK_FINISHED_FOR(ent,w) ((ent).attack_finished_single)
360 #define ATTACK_FINISHED(ent) ATTACK_FINISHED_FOR(ent,(ent).weapon)
362 // assault game mode: Which team is attacking in this round?
363 float assault_attacker_team;
365 // speedrun: when 1, player auto teleports back when capture timeout happens
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"
378 // set when showing a kill countdown
379 .entity killindicator;
380 .float killindicator_teamchange;
382 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force);
386 .float parm_idlesince;
388 float sv_maxidle_spectatorsareidle;
390 float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end);
396 .float(entity to, float sendflags) SendEntity;
398 // player sounds, voice messages
399 // TODO implemented fall and falling
400 #define ALLPLAYERSOUNDS \
412 #define ALLVOICEMSGS \
414 _VOICEMSG(attackinfive) \
417 _VOICEMSG(freelance) \
418 _VOICEMSG(incoming) \
420 _VOICEMSG(needhelp) \
421 _VOICEMSG(seenflag) \
425 #define _VOICEMSG(m) .string playersound_##m;
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) \
443 string globalsound_fall;
444 string globalsound_metalfall;
445 string globalsound_step;
446 string globalsound_metalstep;
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;
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);
467 .float cvar_cl_autotaunt;
468 .float cvar_cl_voice_directional;
469 .float cvar_cl_voice_directional_taunt_attenuation;
471 .float version_mismatch;
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
483 .float porto_forbidden;
488 string cvar_purechanges;
489 float cvar_purechanges_count;
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;
496 .float stat_sv_airaccel_qw;
497 .float stat_sv_airstrafeaccel_qw;
498 .float stat_sv_airspeedlimit_nonqw;
499 .float stat_sv_maxspeed;
501 void W_Porto_Remove (entity p);
503 .int projectiledeathtype;
507 .float stat_allow_oldvortexbeam;
509 // reset to 0 on weapon switch
510 // may be useful to all weapons
511 .float bulletcounter;
513 void target_voicescript_next(entity pl);
514 void target_voicescript_clear(entity pl);
520 .float target_random;
521 .float trigger_reverse;
524 .entity ballcarried; // Also used for keepaway
526 float g_nexball_meter_period;
528 void SUB_DontUseTargets();
529 void SUB_UseTargets();
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)
534 void ClientData_Touch(entity e);
536 //vector debug_shotorg; // if non-zero, overrides the shot origin of all weapons
540 float servertime, serverprevtime, serverframetime;
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;
555 .float stat_shotorg; // networked stat for trueaim HUD
564 .float damage_dealt_total;
566 .float stat_leadlimit;
568 float radar_showennemies;
571 float client_cefc_accumulator;
572 float client_cefc_accumulatortime;
575 .float weapon_load[WEP_MAXCOUNT];
576 .float ammo_none; // used by the reloading system, must always be 0
578 .float old_clip_load;
582 .float minelayer_mines;
583 .float vortex_charge;
584 .float vortex_charge_rottime;
585 .float vortex_chargepool_ammo;
588 .float grab; // 0 = can't grab, 1 = owner can grab, 2 = owner and team mates can grab, 3 = anyone can grab
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
594 .float spectatee_status;
605 .float cvar_cl_weaponimpulsemode;
606 .float selectweapon; // last selected weapon of the player
608 .float ballistics_density; // wall piercing factor, larger = bullet can pass through more
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;
616 .void (float act_state) setactive;
621 .float team_forced; // can be a team number to force a team, or 0 for default action, or -1 for forced spectator
623 .float player_blocked;
624 .float weapon_blocked; // weapon use disabled
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)
631 .entity frozen_by; // for ice fields
633 .entity muzzle_flash;
634 .float misc_bulletcounter; // replaces uzi & hlac bullet counter.
636 .float stat_respawn_time; // shows respawn time, and is negative when awaiting respawn
640 typedef vector(entity player, entity spot, vector current) spawn_evalfunc_t;
641 .spawn_evalfunc_t spawn_evalfunc;
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)
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)
667 .entity player_stats;