2001-12-31 16:16:59 +00:00
//-----------------------------------------------------------------------------
//
// $Id$
//
//-----------------------------------------------------------------------------
//
2001-12-31 16:28:42 +00:00
// $Log$
2007-02-03 15:02:21 +00:00
// Revision 1.196 2007/02/03 15:02:21 jbravo
// Renamed RQ3 to Reaction, Dropped loading of various baseq3 media, disabled the follow command, fixed grenades killing teammates and some cleanups
//
2005-09-13 03:32:03 +00:00
// Revision 1.195 2005/09/13 03:32:03 jbravo
// added a Youve started bandaging message at the right time.
//
2005-09-13 03:11:08 +00:00
// Revision 1.194 2005/09/13 03:11:08 jbravo
// Dead players cant use unzoom or weapon commands
//
2005-09-13 02:33:17 +00:00
// Revision 1.193 2005/09/13 02:33:17 jbravo
// Adding new callvote gametype:map
//
2005-09-07 20:27:42 +00:00
// Revision 1.192 2005/09/07 20:27:41 makro
// Entity attachment trees
//
2005-02-15 16:33:39 +00:00
// Revision 1.191 2005/02/15 16:33:39 makro
// Tons of updates (entity tree attachment system, UI vectors)
//
2004-01-26 21:26:09 +00:00
// Revision 1.190 2004/01/26 21:26:08 makro
// no message
//
2003-09-16 23:25:32 +00:00
// Revision 1.189 2003/09/16 23:25:32 makro
// trigger_multiple - new spawnflag, 3 new keys
//
2003-04-26 22:33:07 +00:00
// Revision 1.188 2003/04/26 22:33:06 jbravo
// Wratted all calls to G_FreeEnt() to avoid crashing and provide debugging
//
2003-04-19 15:27:31 +00:00
// Revision 1.187 2003/04/19 15:27:30 jbravo
// Backing out of most of unlagged. Only optimized prediction and smooth clients
// remains.
//
2003-04-09 20:57:21 +00:00
// Revision 1.186 2003/04/09 20:57:21 jbravo
// DM team none was missing a suicide.
//
2003-04-09 02:00:43 +00:00
// Revision 1.185 2003/04/09 02:00:43 jbravo
// Fixed team none in DM and some final cleanups for the 3.0 release
//
2003-03-30 00:36:03 +00:00
// Revision 1.184 2003/03/30 00:36:03 jbravo
// Grenadebug when dropping bandolier
//
2003-03-29 18:53:41 +00:00
// Revision 1.183 2003/03/29 18:53:41 jbravo
// Fixed ammo bug when dropping bandolier. Added color to more errormessages
//
2003-03-28 13:10:36 +00:00
// Revision 1.182 2003/03/28 13:10:36 jbravo
// *** empty log message ***
//
2003-03-28 13:05:18 +00:00
// Revision 1.181 2003/03/28 13:05:18 jbravo
// No nickchanging to avoid getting votekicked.
//
2003-03-28 10:36:03 +00:00
// Revision 1.180 2003/03/28 10:36:02 jbravo
// Tweaking the replacement system a bit. Reactionmale now the default model
//
2003-03-10 07:07:58 +00:00
// Revision 1.179 2003/03/10 07:07:58 jbravo
// Small unlagged fixes and voting delay added.
//
2003-03-09 21:30:39 +00:00
// Revision 1.178 2003/03/09 21:30:38 jbravo
// Adding unlagged. Still needs work.
//
2003-02-27 03:58:35 +00:00
// Revision 1.177 2003/02/27 03:58:35 jbravo
// Fixed the FF system after adding TDM broke it. Added color to error messages
//
2002-11-13 00:50:38 +00:00
// Revision 1.176 2002/11/13 00:50:38 jbravo
// Fixed item dropping, specmode selection on death and helmet probs.
//
2002-10-30 20:04:34 +00:00
// Revision 1.175 2002/10/30 20:04:34 jbravo
// Adding helmet
//
2002-10-26 22:03:43 +00:00
// Revision 1.174 2002/10/26 22:03:43 jbravo
// Made TeamDM work RQ3 style.
//
2002-10-26 18:29:17 +00:00
// Revision 1.173 2002/10/26 18:29:17 jbravo
// Added allweap and allitem funtionality.
//
2002-10-26 00:37:18 +00:00
// Revision 1.172 2002/10/26 00:37:18 jbravo
// New multiple item code and added PB support to the UI
//
2002-10-21 21:00:39 +00:00
// Revision 1.171 2002/10/21 21:00:39 slicer
// New MM features and bug fixes
//
2002-09-30 01:32:30 +00:00
// Revision 1.170 2002/09/30 01:32:30 jbravo
// Fixing the vote and callvote cmd's so dead players in CTB can use them.
//
2002-09-29 16:06:45 +00:00
// Revision 1.169 2002/09/29 16:06:44 jbravo
// Work done at the HPWorld expo
//
2002-09-24 05:06:17 +00:00
// Revision 1.168 2002/09/24 05:06:17 blaze
// fixed spectating so ref\'s can now use all the chasecam modes.
//
2002-09-07 22:40:01 +00:00
// Revision 1.167 2002/09/07 22:40:01 jbravo
// Added a scaling ctb respawn system. Fixed a bug that allowed players to
// spawn before their team respawn with the team command.
//
2002-09-04 00:16:17 +00:00
// Revision 1.166 2002/09/04 00:16:17 makro
// Fixed 'unselectable grenade shown in the inventory if you switch weapons
// after pulling the pin' bug
//
2002-08-27 04:53:46 +00:00
// Revision 1.165 2002/08/27 04:53:46 niceass
// one more woops
//
2002-08-27 04:50:54 +00:00
// Revision 1.164 2002/08/27 04:50:54 niceass
// woops
//
2002-08-27 04:48:13 +00:00
// Revision 1.163 2002/08/27 04:48:13 niceass
// ref say added
//
2002-08-24 07:58:49 +00:00
// Revision 1.162 2002/08/24 07:58:49 niceass
// moved sanitizestring to g_util
//
2002-08-23 14:25:05 +00:00
// Revision 1.161 2002/08/23 14:25:05 slicer
// Added a new Referee System with multiple ref support
//
2002-08-21 07:00:07 +00:00
// Revision 1.160 2002/08/21 07:00:07 jbravo
// Added CTB respawn queue and fixed game <-> cgame synch problem in CTB
//
2002-08-17 01:56:31 +00:00
// Revision 1.159 2002/08/17 01:56:31 jbravo
// % vars now only work in say_team mode.
//
2002-08-13 16:59:16 +00:00
// Revision 1.158 2002/08/13 16:59:16 makro
// Fixed per-client callvote limit; added a new cvar - g_RQ3_maxClientVotes
//
2002-08-07 20:49:21 +00:00
// Revision 1.157 2002/08/07 20:49:21 slicer
// Adapted Vote system to Matchmode
//
2002-07-16 04:08:28 +00:00
// Revision 1.156 2002/07/16 04:08:28 niceass
// temporary hack solution for map rotation and ctb
//
2002-07-11 04:31:07 +00:00
// Revision 1.155 2002/07/11 04:31:07 niceass
// removed team leaders in all gametypes and changed some text from centerprint to console print
//
2002-07-09 05:41:48 +00:00
// Revision 1.154 2002/07/09 05:41:48 niceass
// scoreboard fix
//
2002-07-09 03:24:00 +00:00
// Revision 1.153 2002/07/09 03:24:00 niceass
// fixed team talk
//
2002-07-08 04:25:02 +00:00
// Revision 1.152 2002/07/08 04:25:02 niceass
// changes to who can be seen dead. removed deaths
//
2002-07-07 23:54:57 +00:00
// Revision 1.151 2002/07/07 23:54:57 jbravo
// Say and Say_team now resets the idle timer
//
2002-07-04 04:20:41 +00:00
// Revision 1.150 2002/07/04 04:20:41 jbravo
// Fixed my weaponchange cancel in the Use cmd, and fixed the bug where players
// that where in eye spectating someone moved on to another player instantly on death.
//
2002-07-02 20:22:35 +00:00
// Revision 1.149 2002/07/02 20:22:35 jbravo
// Changed the files to use the right ui.
//
2002-07-02 19:15:17 +00:00
// Revision 1.148 2002/07/02 19:15:17 jbravo
// Drop weapon with akimbos now behaves like AQ, plus no suicides during LCA
//
2002-06-29 04:15:15 +00:00
// Revision 1.147 2002/06/29 04:15:15 jbravo
// CTF is now CTB. no weapons while the case is in hand other than pistol or knife
//
2002-06-28 21:41:12 +00:00
// Revision 1.146 2002/06/28 21:41:12 jbravo
// Gawd damn buglet
//
2002-06-24 05:51:51 +00:00
// Revision 1.145 2002/06/24 05:51:51 jbravo
// CTF mode is now semi working
//
2002-06-23 23:32:29 +00:00
// Revision 1.144 2002/06/23 23:32:29 jbravo
// Fixed logging of clients IP addresses.
//
2002-06-23 21:44:08 +00:00
// Revision 1.143 2002/06/23 21:44:08 jbravo
// Fixed shots fired stats for non TP modes and some cleanups
//
2002-06-23 19:27:52 +00:00
// Revision 1.142 2002/06/23 19:27:18 niceass
// bandage bug fix
//
2002-06-23 15:22:53 +00:00
// Revision 1.141 2002/06/23 15:22:53 slicer
// Future 2.1 Matchmode Features - PART II
//
2002-06-23 03:04:09 +00:00
// Revision 1.140 2002/06/23 03:04:09 assimon
// Added suport for callvote map <map> and ref map <map>.
//
2002-06-21 00:05:55 +00:00
// Revision 1.139 2002/06/21 00:05:55 slicer
// Spectators can now use say_team to communicate among each others, DM and TP
//
2002-06-20 22:32:43 +00:00
// Revision 1.138 2002/06/20 22:32:43 jbravo
// Added last damaged player and fixed a test2 model problem (atrimum my ass :)
// Changed g_RQ3_printOwnObits to g_RQ3_showOwnKills and it also controls $K
//
2002-06-20 21:06:07 +00:00
// Revision 1.137 2002/06/20 21:06:07 freud
// Added playing of lens.wav when using the unzoom command
//
2002-06-20 18:40:17 +00:00
// Revision 1.136 2002/06/20 18:40:17 slicer
// Future 2.1 Matchmode Features - PART I
//
2002-06-20 02:27:30 +00:00
// Revision 1.135 2002/06/20 02:27:30 jbravo
// Now the scoreboard doesnt show whos alive and whos not when you are alive
//
2002-06-19 18:18:09 +00:00
// Revision 1.134 2002/06/19 18:18:09 jbravo
// Small cleanups for compiler warnings
//
2002-06-18 09:23:23 +00:00
// Revision 1.133 2002/06/18 09:23:23 niceass
// small callvote upgrade
//
2002-06-18 03:57:38 +00:00
// Revision 1.132 2002/06/18 03:57:38 jbravo
// Committing for aasimon. Callvote nextmap removed and replaced with cyclemap for .ini
//
2002-06-17 16:57:39 +00:00
// Revision 1.131 2002/06/17 16:57:39 jbravo
// Items can now be dropped during bandaging
//
2002-06-17 03:22:58 +00:00
// Revision 1.130 2002/06/17 03:22:58 jbravo
// Base voting system is now fixed.
//
2002-06-16 20:06:15 +00:00
// Revision 1.129 2002/06/16 20:06:14 jbravo
// Reindented all the source files with "indent -kr -ut -i8 -l120 -lc120 -sob -bad -bap"
//
2002-06-13 17:01:30 +00:00
// Revision 1.128 2002/06/13 17:01:30 slicer
// Radio Gender changes according to model gender
//
2002-06-12 22:32:24 +00:00
// Revision 1.127 2002/06/12 22:32:24 slicer
// Even better way to improve the Cvar Anti-Cheat System
//
2002-06-10 23:32:03 +00:00
// Revision 1.126 2002/06/10 23:32:03 slicer
// Tweaked the weapon queuing
//
2002-06-10 19:10:59 +00:00
// Revision 1.125 2002/06/10 19:10:59 jbravo
// Voting system fixed for TP
//
2002-06-10 19:04:21 +00:00
// Revision 1.124 2002/06/10 19:04:21 slicer
// Passing RefID trought scoreboard, forgot to add
//
2002-06-10 03:26:04 +00:00
// Revision 1.123 2002/06/10 03:26:04 jbravo
// Fixed two small errors
//
2002-06-09 18:58:40 +00:00
// Revision 1.122 2002/06/09 18:58:00 makro
// no message
//
2002-06-07 19:07:08 +00:00
// Revision 1.121 2002/06/07 19:07:08 slicer
// removed cvars for teamXready, replaced by level.teamXready
//
2002-06-05 23:53:05 +00:00
// Revision 1.120 2002/06/05 23:53:05 jbravo
// Color fixes for player names
//
2002-06-05 04:57:50 +00:00
// Revision 1.119 2002/06/05 04:57:50 niceass
// "team" command fix
//
2002-06-03 19:21:16 +00:00
// Revision 1.118 2002/06/03 19:21:16 niceass
// matchmode scoreboard changes. untested
//
2002-06-03 05:56:04 +00:00
// Revision 1.117 2002/06/03 05:56:04 jbravo
// server used say for cmds issued during intermission
//
2002-06-03 00:49:07 +00:00
// Revision 1.116 2002/06/03 00:46:08 niceass
// match scoreboard changes
//
2002-06-02 00:13:39 +00:00
// Revision 1.115 2002/06/02 00:13:39 makro
// Spectators can vote in TP, not just call a vote
//
2002-05-31 18:17:10 +00:00
// Revision 1.114 2002/05/31 18:17:10 makro
// Bot stuff. Added a server command that prints a line to a client
// and everyone who is spectating him
//
2002-05-21 04:58:28 +00:00
// Revision 1.113 2002/05/21 04:58:28 blaze
// kicked the reload bugs ass!
//
2002-05-19 17:50:33 +00:00
// Revision 1.112 2002/05/19 17:50:33 jbravo
// Team fixes for DM
//
2002-05-15 12:46:32 +00:00
// Revision 1.111 2002/05/15 12:46:32 makro
// Small func_static change.Give ammo should now give grenades/knives
//
2002-05-12 19:15:47 +00:00
// Revision 1.110 2002/05/12 19:15:47 jbravo
// Added playerlist, did some cleanup on votes.
//
2002-05-12 16:10:19 +00:00
// Revision 1.109 2002/05/12 16:10:19 jbravo
// Added unignore
//
2002-05-12 12:15:05 +00:00
// Revision 1.108 2002/05/12 12:15:05 slicer
// Added Referee command for captains
//
2002-05-11 19:52:09 +00:00
// Revision 1.107 2002/05/11 19:52:09 slicer
// Added sub and captain to the scoreboard function
//
2002-05-10 08:10:18 +00:00
// Revision 1.106 2002/05/10 08:10:18 jbravo
// Fixed a bug in the Obit system and a give (weapons or all) bug
//
2002-05-10 04:06:27 +00:00
// Revision 1.105 2002/05/10 04:06:27 jbravo
// Added Ignore
//
2002-05-06 00:35:49 +00:00
// Revision 1.104 2002/05/06 00:35:49 jbravo
// Small fixes to misc stuff
//
2002-05-05 15:51:16 +00:00
// Revision 1.103 2002/05/05 15:51:16 slicer
// Captain and subs get saved on map_restarts ( moved to "sess" )
//
2002-05-04 16:19:02 +00:00
// Revision 1.102 2002/05/04 16:19:02 jbravo
// Fixing the stuff cmd to work on dedicated servers.
//
2002-05-01 18:44:36 +00:00
// Revision 1.101 2002/05/01 18:44:36 jbravo
// Added a stuff command. Needed for misc things. See bottum of cmd_use in
// g_teamplay.c
//
2002-04-30 11:54:37 +00:00
// Revision 1.100 2002/04/30 11:54:37 makro
// Bots rule ! Also, added clips to give all. Maybe some other things
//
2002-04-30 01:23:05 +00:00
// Revision 1.99 2002/04/30 01:23:05 jbravo
// Changed the server logging to be more like a normal AQ server. Cleaned
// all colors from the logs.
//
2002-04-28 11:03:46 +00:00
// Revision 1.98 2002/04/28 11:03:46 slicer
// Added "teammodel" for Matchmode, Referee "pause" command
//
2002-04-26 03:39:34 +00:00
// Revision 1.97 2002/04/26 03:39:34 jbravo
// added tkok, fixed players always leaving zcam modes when player thats
// beeing tracked dies
//
2002-04-23 06:03:05 +00:00
// Revision 1.96 2002/04/23 06:03:05 niceass
// scoreboard stuff
//
2002-04-18 16:13:23 +00:00
// Revision 1.95 2002/04/18 16:13:23 jbravo
// Scoreboard now shows green for live players and white for dead.
// Time should not get reset on deaths any more.
//
2002-04-14 12:55:03 +00:00
// Revision 1.94 2002/04/14 12:55:03 jbravo
// Cleaned up cmd_reload while hunting for the m3 reload bug
//
2002-04-13 15:37:54 +00:00
// Revision 1.93 2002/04/13 15:37:53 jbravo
// limchasecam has been redone with new spec system
//
2002-04-07 12:57:36 +00:00
// Revision 1.92 2002/04/07 12:57:36 slicer
// Small fix on Matchmode Captain system
2002-04-07 12:49:53 +00:00
//
2002-04-07 03:22:48 +00:00
// Revision 1.90 2002/04/07 03:22:48 jbravo
// Tweaks and crashbug fixes
//
2002-04-05 18:53:26 +00:00
// Revision 1.89 2002/04/05 18:53:26 jbravo
// Warning fixes
//
2002-04-01 22:23:14 +00:00
// Revision 1.88 2002/04/01 22:23:14 slicer
// Added "weapon" command buffering | Solved Gren Mode Bug
//
2002-03-31 23:41:45 +00:00
// Revision 1.87 2002/03/31 23:41:45 jbravo
// Added the use command
//
2002-03-31 03:31:24 +00:00
// Revision 1.86 2002/03/31 03:31:24 jbravo
// Compiler warning cleanups
//
2002-03-30 23:20:10 +00:00
// Revision 1.85 2002/03/30 23:20:10 jbravo
// Added damage in scoreboard.
//
2002-03-30 21:51:42 +00:00
// Revision 1.84 2002/03/30 21:51:42 jbravo
// Removed all those ifdefs for zcam.
//
2002-03-30 02:29:43 +00:00
// Revision 1.83 2002/03/30 02:29:43 jbravo
// Lots of spectator code updates. Removed debugshit, added some color.
//
2002-03-26 11:32:05 +00:00
// Revision 1.82 2002/03/26 11:32:05 jbravo
// Remember specstate between rounds.
//
2002-03-23 05:17:43 +00:00
// Revision 1.81 2002/03/23 05:17:42 jbravo
// Major cleanup of game -> cgame communication with LCA vars.
//
2002-03-21 19:22:12 +00:00
// Revision 1.80 2002/03/21 19:22:12 jbravo
// Bando now adds extra ammo to the special weaps, and when its dropped it goes
// away again.
//
2002-03-18 19:19:08 +00:00
// Revision 1.79 2002/03/18 19:18:39 slicer
// Fixed bandage bugs ( i hope )
//
2002-03-18 13:39:24 +00:00
// Revision 1.78 2002/03/18 13:39:24 jbravo
// Spectators in TP can now use callvote
//
2002-03-18 13:32:53 +00:00
// Revision 1.77 2002/03/18 13:32:53 jbravo
// Fixed the fraglines for sniper head kills and twekaed bandaging a bit for
// testing
//
2002-03-18 04:37:10 +00:00
// Revision 1.76 2002/03/18 04:37:10 jbravo
// Removing locations from teamtalk on dead players.
//
2002-03-18 01:22:35 +00:00
// Revision 1.75 2002/03/18 01:22:35 slicer
// bandage bleedtick back to original
//
2002-03-17 15:18:55 +00:00
// Revision 1.74 2002/03/17 15:18:55 jbravo
// Added 2 checks to debugshit
//
2002-03-17 13:41:28 +00:00
// Revision 1.73 2002/03/17 13:41:28 jbravo
// Added a debug cmd to print out stuff when bugs occor
//
2002-03-17 00:40:23 +00:00
// Revision 1.72 2002/03/17 00:40:23 jbravo
// Adding variable team names. g_RQ3_team1name and g_RQ3_team2name. Fixed
// Slicers fraglimit check.
//
2002-03-14 23:54:12 +00:00
// Revision 1.71 2002/03/14 23:54:12 jbravo
// Added a variable system from AQ. Works the same except it uses $ for %
//
2002-03-14 02:24:39 +00:00
// Revision 1.70 2002/03/14 02:24:39 jbravo
// Adding radio :)
//
2002-03-13 18:41:18 +00:00
// Revision 1.69 2002/03/13 18:40:52 slicer
// Adjusted some of elder's unzoom code for the new sniper system ( server side )
//
2002-03-07 19:46:47 +00:00
// Revision 1.68 2002/03/07 19:46:47 jbravo
// No dropping weapons or items if bandaging
//
2002-03-07 00:00:54 +00:00
// Revision 1.67 2002/03/07 00:00:54 assimon
// Added a skeleton referee suport, with some functional commands (map_restart and kick)
//
2002-03-03 21:46:26 +00:00
// Revision 1.66 2002/03/03 21:46:26 blaze
// weapon stats, done, beta test for bugs
//
2002-03-03 02:04:15 +00:00
// Revision 1.65 2002/03/03 02:04:14 jbravo
// Zcam tewaking
//
2002-03-02 14:54:24 +00:00
// Revision 1.64 2002/03/02 14:54:24 jbravo
// Added the skin and model names to the name of the player thats being
// followed, as in AQ
//
2002-03-01 20:22:31 +00:00
// Revision 1.63 2002/03/01 20:22:31 jbravo
// Fixed a small booboo with the teamcounts
//
2002-03-01 20:02:34 +00:00
// Revision 1.62 2002/03/01 20:02:34 jbravo
// Added ui_RQ3_teamCount1, ui_RQ3_teamCount2 and ui_RQ3_numSpectators for
// makro
//
2002-02-28 05:42:31 +00:00
// Revision 1.61 2002/02/28 05:42:31 blaze
// weapons stats on server side
//
2002-02-27 01:54:29 +00:00
// Revision 1.60 2002/02/27 01:54:29 jbravo
// More spectatorfixes and finally stopped all fallingdamage anims and
// sounds during LCA.
//
2002-02-26 21:59:10 +00:00
// Revision 1.59 2002/02/26 21:59:10 jbravo
// Fixed death on switching teams while dead
//
2002-02-26 04:59:10 +00:00
// Revision 1.58 2002/02/26 04:59:10 jbravo
// Fixed teamswitching and team broadcasting
//
2002-02-26 03:46:53 +00:00
// Revision 1.57 2002/02/26 03:46:53 jbravo
// Range can now be set on grenades.
//
2002-02-26 01:10:19 +00:00
// Revision 1.56 2002/02/26 01:10:19 jbravo
// Dead people cant speak to the living any more.
//
2002-02-25 19:41:53 +00:00
// Revision 1.55 2002/02/25 19:41:53 jbravo
// Fixed the use ESC and join menu to join teams when dead players are
// spectating in TP mode.
// Tuned the autorespawn system a bit. Now dead ppl. are dead for a very
// small time before they are made into spectators.
//
2002-02-25 17:54:57 +00:00
// Revision 1.54 2002/02/25 17:54:57 jbravo
// Added [DEAD] tags infront of players names where appropriate and made
// the server log conversation like AQ does.
//
2002-02-23 18:07:46 +00:00
// Revision 1.53 2002/02/23 18:07:18 slicer
// Changed Sniper code and Cam code
//
2002-02-22 02:13:13 +00:00
// Revision 1.52 2002/02/22 02:13:13 jbravo
// Fixed a few bugs and did some cleanups
//
2002-02-10 22:02:06 +00:00
// Revision 1.51 2002/02/10 22:02:06 niceass
// took some debug info out
//
2002-02-10 08:16:12 +00:00
// Revision 1.50 2002/02/10 08:16:12 niceass
// added deaths to the scoreboard
//
2002-02-09 00:10:12 +00:00
// Revision 1.49 2002/02/09 00:10:12 jbravo
// Fixed spectator follow and free and updated zcam to 1.04 and added the
// missing zcam files.
//
2002-02-05 23:42:06 +00:00
// Revision 1.48 2002/02/05 23:41:27 slicer
// More on matchmode..
//
2002-02-04 00:11:12 +00:00
// Revision 1.47 2002/02/04 00:10:49 slicer
// Matchmode: Teams Ready/Not Ready goes by cvar MM_team1/2
2002-02-02 20:39:09 +00:00
//
2002-02-02 16:34:02 +00:00
// Revision 1.43 2002/02/02 16:34:02 slicer
// Matchmode..
//
2002-01-31 02:53:28 +00:00
// Revision 1.42 2002/01/31 02:53:28 blaze
// err, make that playerstats command
//
2002-01-31 02:52:49 +00:00
// Revision 1.41 2002/01/31 02:52:49 blaze
// some basic work on the trains/elevators
//
2002-01-31 02:25:31 +00:00
// Revision 1.40 2002/01/31 02:25:31 jbravo
// Adding limchasecam.
//
2002-01-11 20:20:58 +00:00
// Revision 1.39 2002/01/11 20:20:58 jbravo
// Adding TP to main branch
//
2002-01-11 19:48:33 +00:00
// Revision 1.38 2002/01/11 19:48:30 jbravo
// Formatted the source in non DOS format.
//
2001-12-31 16:28:42 +00:00
// Revision 1.37 2001/12/31 16:28:42 jbravo
// I made a Booboo with the Log tag.
//
2001-12-31 16:16:59 +00:00
//
//-----------------------------------------------------------------------------
2001-05-06 20:50:27 +00:00
// Copyright (C) 1999-2000 Id Software, Inc.
//
# include "g_local.h"
2001-12-17 15:08:34 +00:00
# include "zcam.h"
2001-05-06 20:50:27 +00:00
//Blaze: was there a extra ../ here?
2009-06-28 05:31:14 +00:00
# include "../ui/menudef.h" // for the voice chats
2001-05-06 20:50:27 +00:00
//Blaze for door code
2002-06-16 20:06:15 +00:00
void Use_BinaryMover ( gentity_t * ent , gentity_t * other , gentity_t * activator ) ;
2003-03-28 13:05:18 +00:00
// JBravo: for kicking code
gentity_t * getEntByName ( char * name ) ;
2002-06-16 20:06:15 +00:00
2001-05-06 20:50:27 +00:00
/*
= = = = = = = = = = = = = = = = = =
DeathmatchScoreboardMessage
= = = = = = = = = = = = = = = = = =
2002-06-16 20:06:15 +00:00
*/
void DeathmatchScoreboardMessage ( gentity_t * ent )
{
char entry [ 1024 ] , string [ 1400 ] ;
int stringlength , i , j ;
gclient_t * cl ;
int numSorted , scoreFlags , accuracy ;
int alive ;
2001-05-06 20:50:27 +00:00
// send the latest information on all clients
string [ 0 ] = 0 ;
stringlength = 0 ;
scoreFlags = 0 ;
numSorted = level . numConnectedClients ;
2002-06-16 20:06:15 +00:00
for ( i = 0 ; i < numSorted ; i + + ) {
int ping ;
2001-05-06 20:50:27 +00:00
cl = & level . clients [ level . sortedClients [ i ] ] ;
2002-04-18 16:13:23 +00:00
if ( cl - > pers . connected = = CON_CONNECTING ) {
2001-05-06 20:50:27 +00:00
ping = - 1 ;
} else {
2003-04-19 15:27:31 +00:00
ping = cl - > ps . ping < 999 ? cl - > ps . ping : 999 ;
//ping = cl->pers.realPing < 999 ? cl->pers.realPing : 999;
2001-05-06 20:50:27 +00:00
}
2002-04-18 16:13:23 +00:00
if ( cl - > accuracy_shots ) {
2001-05-06 20:50:27 +00:00
accuracy = cl - > accuracy_hits * 100 / cl - > accuracy_shots ;
2002-04-18 16:13:23 +00:00
} else {
2001-05-06 20:50:27 +00:00
accuracy = 0 ;
}
2002-04-18 16:13:23 +00:00
2002-06-03 19:21:16 +00:00
// NiceAss: No one can see who is dead or alive in matchmode when alive.
// But if you are dead, you can see who is dead/alive on your team.
alive = cl - > sess . sessionTeam ! = TEAM_SPECTATOR ;
2002-07-08 04:25:02 +00:00
if ( g_gametype . integer > = GT_TEAM & & level . team_round_going ) {
if ( ent - > client - > sess . sessionTeam ! = TEAM_SPECTATOR )
alive = qtrue ;
if ( g_RQ3_matchmode . integer & & ent - > client - > sess . sessionTeam = = TEAM_SPECTATOR & &
ent - > client - > sess . savedTeam ! = cl - > sess . savedTeam )
alive = qtrue ;
}
2002-09-24 05:06:17 +00:00
//Blaze: Prit out some Debug info
if ( & g_entities [ level . sortedClients [ i ] ] = = NULL ) G_Printf ( " Ln 1399 \n " ) ;
2002-08-24 07:58:49 +00:00
2002-08-23 14:25:05 +00:00
Com_sprintf ( entry , sizeof ( entry ) , " %i %i %i %i %i %i %i %i %i %i %i %i " ,
2002-07-08 04:25:02 +00:00
level . sortedClients [ i ] ,
cl - > ps . persistant [ PERS_SCORE ] ,
ping ,
( level . time - cl - > pers . enterTime ) / 60000 ,
scoreFlags ,
g_entities [ level . sortedClients [ i ] ] . s . powerups ,
accuracy ,
cl - > ps . persistant [ PERS_DAMAGE_DELT ] , // JBravo: Added for scoreboard
alive , // JBravo: Added for TP scoreboard
cl - > sess . captain , // Slicer: Added for Matchmode Scoreboard
2002-08-23 14:25:05 +00:00
cl - > sess . sub , // Slicer: Added for Matchmode Scoreboard
cl - > sess . referee
2002-07-08 04:25:02 +00:00
) ;
2001-11-15 07:06:33 +00:00
2001-05-06 20:50:27 +00:00
j = strlen ( entry ) ;
2012-03-13 22:52:39 +00:00
if ( stringlength + j > = sizeof ( string ) )
2001-05-06 20:50:27 +00:00
break ;
2002-06-16 20:06:15 +00:00
strcpy ( string + stringlength , entry ) ;
2001-05-06 20:50:27 +00:00
stringlength + = j ;
}
2002-08-24 07:58:49 +00:00
2002-10-21 21:00:39 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " scores %i %i %i %i %i %i %i%s " , i ,
2002-06-16 20:06:15 +00:00
level . teamScores [ TEAM_RED ] , level . teamScores [ TEAM_BLUE ] ,
level . team1ready , level . team2ready ,
2002-10-21 21:00:39 +00:00
( int ) level . matchTime , level . refAmmount ? level . refStatus : - 1 , string ) ) ;
2001-05-06 20:50:27 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
Cmd_Score_f
Request current scoreboard information
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_Score_f ( gentity_t * ent )
{
DeathmatchScoreboardMessage ( ent ) ;
2001-05-06 20:50:27 +00:00
}
2002-02-28 05:42:31 +00:00
/*
= = = = = = = = = = = = = = = = = =
Cmd_WeaponStats_f
Request current weaponstats information
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_WeaponStats_f ( gentity_t * ent )
2002-02-28 05:42:31 +00:00
{
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities ,
va ( " wstats %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i " ,
ent - > client - > pers . records [ REC_KNIFETHROWSHOTS ] ,
ent - > client - > pers . records [ REC_KNIFETHROWHITS ] ,
ent - > client - > pers . records [ REC_KNIFESLASHSHOTS ] ,
ent - > client - > pers . records [ REC_KNIFESLASHHITS ] ,
ent - > client - > pers . records [ REC_MK23SHOTS ] , ent - > client - > pers . records [ REC_MK23HITS ] ,
ent - > client - > pers . records [ REC_M3SHOTS ] , ent - > client - > pers . records [ REC_M3HITS ] ,
ent - > client - > pers . records [ REC_MP5SHOTS ] , ent - > client - > pers . records [ REC_MP5HITS ] ,
ent - > client - > pers . records [ REC_M4SHOTS ] , ent - > client - > pers . records [ REC_M4HITS ] ,
ent - > client - > pers . records [ REC_SSG3000SHOTS ] ,
ent - > client - > pers . records [ REC_SSG3000HITS ] ,
ent - > client - > pers . records [ REC_HANDCANNONSHOTS ] ,
ent - > client - > pers . records [ REC_HANDCANNONHITS ] ,
ent - > client - > pers . records [ REC_AKIMBOSHOTS ] , ent - > client - > pers . records [ REC_AKIMBOHITS ] ,
ent - > client - > pers . records [ REC_GRENADESHOTS ] ,
ent - > client - > pers . records [ REC_GRENADEHITS ] , ent - > client - > pers . records [ REC_KICKHITS ] ,
ent - > client - > pers . records [ REC_KILLS ] , ent - > client - > pers . records [ REC_TEAMKILLS ] ,
ent - > client - > pers . records [ REC_SUICIDES ] ) ) ;
trap_SendServerCommand ( ent - g_entities ,
2009-07-04 03:37:41 +00:00
va ( " wstats2 %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i " ,
2002-06-16 20:06:15 +00:00
ent - > client - > pers . records [ REC_KNIFETHROWDEATHS ] ,
ent - > client - > pers . records [ REC_KNIFETHROWKILLS ] ,
ent - > client - > pers . records [ REC_KNIFESLASHDEATHS ] ,
ent - > client - > pers . records [ REC_KNIFESLASHKILLS ] ,
ent - > client - > pers . records [ REC_MK23DEATHS ] , ent - > client - > pers . records [ REC_MK23KILLS ] ,
ent - > client - > pers . records [ REC_M3DEATHS ] , ent - > client - > pers . records [ REC_M3KILLS ] ,
ent - > client - > pers . records [ REC_MP5DEATHS ] , ent - > client - > pers . records [ REC_MP5KILLS ] ,
ent - > client - > pers . records [ REC_M4DEATHS ] , ent - > client - > pers . records [ REC_M4KILLS ] ,
ent - > client - > pers . records [ REC_SSG3000DEATHS ] ,
ent - > client - > pers . records [ REC_SSG3000KILLS ] ,
ent - > client - > pers . records [ REC_HANDCANNONDEATHS ] ,
ent - > client - > pers . records [ REC_HANDCANNONKILLS ] ,
ent - > client - > pers . records [ REC_AKIMBODEATHS ] ,
ent - > client - > pers . records [ REC_AKIMBOKILLS ] ,
ent - > client - > pers . records [ REC_GRENADEDEATHS ] ,
ent - > client - > pers . records [ REC_GRENADEKILLS ] ,
ent - > client - > pers . records [ REC_KICKDEATHS ] , ent - > client - > pers . records [ REC_KICKKILLS ] ) ) ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
}
2001-05-06 20:50:27 +00:00
/*
= = = = = = = = = = = = = = = = = =
CheatsOk
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
qboolean CheatsOk ( gentity_t * ent )
{
if ( ! g_cheats . integer ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" ^1Cheats are not enabled on this server. \n \" " ) ) ;
2001-05-06 20:50:27 +00:00
return qfalse ;
}
2002-06-16 20:06:15 +00:00
if ( ent - > health < = 0 ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" ^1You must be alive to use this command. \n \" " ) ) ;
2001-05-06 20:50:27 +00:00
return qfalse ;
}
return qtrue ;
}
/*
= = = = = = = = = = = = = = = = = =
ConcatArgs
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
char * ConcatArgs ( int start )
{
int i , c , tlen ;
static char line [ MAX_STRING_CHARS ] ;
int len ;
char arg [ MAX_STRING_CHARS ] ;
2001-05-06 20:50:27 +00:00
len = 0 ;
c = trap_Argc ( ) ;
2002-06-16 20:06:15 +00:00
for ( i = start ; i < c ; i + + ) {
trap_Argv ( i , arg , sizeof ( arg ) ) ;
tlen = strlen ( arg ) ;
if ( len + tlen > = MAX_STRING_CHARS - 1 ) {
2001-05-06 20:50:27 +00:00
break ;
}
2002-06-16 20:06:15 +00:00
memcpy ( line + len , arg , tlen ) ;
2001-05-06 20:50:27 +00:00
len + = tlen ;
2002-06-16 20:06:15 +00:00
if ( i ! = c - 1 ) {
2001-05-06 20:50:27 +00:00
line [ len ] = ' ' ;
len + + ;
}
}
line [ len ] = 0 ;
return line ;
}
/*
= = = = = = = = = = = = = = = = = =
ClientNumberFromString
Returns a player number for either a number or name string
Returns - 1 if invalid
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
int ClientNumberFromString ( gentity_t * to , char * s )
{
gclient_t * cl ;
int idnum ;
char s2 [ MAX_STRING_CHARS ] ;
char n2 [ MAX_STRING_CHARS ] ;
2001-05-06 20:50:27 +00:00
// numeric values are just slot numbers
if ( s [ 0 ] > = ' 0 ' & & s [ 0 ] < = ' 9 ' ) {
2002-06-16 20:06:15 +00:00
idnum = atoi ( s ) ;
if ( idnum < 0 | | idnum > = level . maxclients ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( to - g_entities , va ( " print \" ^1Bad client slot: %i \n \" " , idnum ) ) ;
2001-05-06 20:50:27 +00:00
return - 1 ;
}
cl = & level . clients [ idnum ] ;
2002-06-16 20:06:15 +00:00
if ( cl - > pers . connected ! = CON_CONNECTED ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( to - g_entities , va ( " print \" ^1Client %i is not active \n \" " , idnum ) ) ;
2001-05-06 20:50:27 +00:00
return - 1 ;
}
return idnum ;
}
// check for a name match
2002-06-16 20:06:15 +00:00
SanitizeString ( s , s2 ) ;
for ( idnum = 0 , cl = level . clients ; idnum < level . maxclients ; idnum + + , cl + + ) {
if ( cl - > pers . connected ! = CON_CONNECTED ) {
2001-05-06 20:50:27 +00:00
continue ;
}
2002-06-16 20:06:15 +00:00
SanitizeString ( cl - > pers . netname , n2 ) ;
if ( ! strcmp ( n2 , s2 ) ) {
2001-05-06 20:50:27 +00:00
return idnum ;
}
}
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( to - g_entities , va ( " print \" ^1User %s is not on the server \n \" " , s ) ) ;
2001-05-06 20:50:27 +00:00
return - 1 ;
}
/*
= = = = = = = = = = = = = = = = = =
Cmd_Give_f
Give items to a client
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_Give_f ( gentity_t * ent )
2001-05-06 20:50:27 +00:00
{
2002-06-16 20:06:15 +00:00
char * name ;
gitem_t * it ;
int i ;
qboolean give_all ;
gentity_t * it_ent ;
trace_t trace ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( ! CheatsOk ( ent ) ) {
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
name = ConcatArgs ( 1 ) ;
2001-05-06 20:50:27 +00:00
if ( Q_stricmp ( name , " all " ) = = 0 )
give_all = qtrue ;
else
give_all = qfalse ;
2002-06-16 20:06:15 +00:00
if ( give_all | | Q_stricmp ( name , " health " ) = = 0 ) {
ent - > health = 100 ; // 100 max health ent->client->ps.stats[STAT_MAX_HEALTH];
2001-05-06 20:50:27 +00:00
if ( ! give_all )
return ;
}
2002-06-16 20:06:15 +00:00
if ( give_all | | Q_stricmp ( name , " weapons " ) = = 0 ) {
2001-06-08 04:47:30 +00:00
//Elder: basically it sets all the STAT_WEAPONS bits to 1 EXCEPT for WP_NONE and
//the initial bit (I don't know what that is)
//http://www.iota-six.freeserve.co.uk/c/bitwise.htm
2002-06-16 20:06:15 +00:00
ent - > client - > ps . stats [ STAT_WEAPONS ] = ( 1 < < WP_NUM_WEAPONS ) - 1 - ( 1 < < WP_NONE ) ;
2002-05-10 08:10:18 +00:00
// JBravo: so we can drop any of these weapons
ent - > client - > uniqueWeapons = 5 ;
ent - > client - > weaponCount [ WP_SSG3000 ] = 1 ;
ent - > client - > weaponCount [ WP_MP5 ] = 1 ;
ent - > client - > weaponCount [ WP_M3 ] = 1 ;
ent - > client - > weaponCount [ WP_M4 ] = 1 ;
ent - > client - > weaponCount [ WP_AKIMBO ] = 1 ;
ent - > client - > weaponCount [ WP_HANDCANNON ] = 1 ;
2004-01-26 21:26:09 +00:00
//Makro - added knives
ent - > client - > weaponCount [ WP_KNIFE ] = 1 ;
2001-05-06 20:50:27 +00:00
if ( ! give_all )
return ;
}
2002-10-26 00:37:18 +00:00
if ( give_all | | Q_stricmp ( name , " items " ) = = 0 ) {
// JBravo: for the new items system
ent - > client - > ps . stats [ STAT_HOLDABLE_ITEM ] = ( 1 < < HI_KEVLAR ) ;
ent - > client - > ps . stats [ STAT_HOLDABLE_ITEM ] | = ( 1 < < HI_LASER ) ;
ent - > client - > ps . stats [ STAT_HOLDABLE_ITEM ] | = ( 1 < < HI_SILENCER ) ;
ent - > client - > ps . stats [ STAT_HOLDABLE_ITEM ] | = ( 1 < < HI_BANDOLIER ) ;
ent - > client - > ps . stats [ STAT_HOLDABLE_ITEM ] | = ( 1 < < HI_SLIPPERS ) ;
2002-10-30 20:04:34 +00:00
if ( g_RQ3_haveHelmet . integer ) {
ent - > client - > ps . stats [ STAT_HOLDABLE_ITEM ] | = ( 1 < < HI_HELMET ) ;
ent - > client - > uniqueItems = 6 ;
} else {
ent - > client - > uniqueItems = 5 ;
}
2002-10-26 00:37:18 +00:00
}
2002-06-16 20:06:15 +00:00
if ( give_all | | Q_stricmp ( name , " ammo " ) = = 0 ) {
for ( i = 0 ; i < MAX_WEAPONS ; i + + ) {
2001-05-06 20:50:27 +00:00
//Blaze: Give right amount of shots to each gun
2004-01-26 21:26:09 +00:00
if ( i = = WP_KNIFE )
ent - > client - > ps . ammo [ i ] = 10 ;
else
ent - > client - > ps . ammo [ i ] = ClipAmountForAmmo ( i ) ;
2002-04-30 11:54:37 +00:00
//Makro - I want clips, dammit !
Add_Ammo ( ent , i , 100 , 1 ) ;
2001-05-06 20:50:27 +00:00
}
2002-05-15 12:46:32 +00:00
//Makro - added grenade + knife
ent - > client - > ps . stats [ STAT_WEAPONS ] | = ( 1 < < WP_GRENADE ) | ( 1 < < WP_KNIFE ) ;
2001-05-06 20:50:27 +00:00
if ( ! give_all )
return ;
}
// spawn a specific item right on the player
2002-06-16 20:06:15 +00:00
if ( ! give_all ) {
it = BG_FindItem ( name ) ;
2001-05-06 20:50:27 +00:00
if ( ! it ) {
return ;
}
it_ent = G_Spawn ( ) ;
2002-06-16 20:06:15 +00:00
VectorCopy ( ent - > r . currentOrigin , it_ent - > s . origin ) ;
2001-05-06 20:50:27 +00:00
it_ent - > classname = it - > classname ;
2002-06-16 20:06:15 +00:00
G_SpawnItem ( it_ent , it ) ;
FinishSpawningItem ( it_ent ) ;
memset ( & trace , 0 , sizeof ( trace ) ) ;
Touch_Item ( it_ent , ent , & trace ) ;
2001-05-06 20:50:27 +00:00
if ( it_ent - > inuse ) {
2011-07-14 18:58:56 +00:00
G_FreeEntity ( it_ent ) ;
2001-05-06 20:50:27 +00:00
}
}
}
2003-04-09 02:00:43 +00:00
/*void RQ3_Cmd_debugshit (gentity_t * ent)
2002-10-26 00:37:18 +00:00
{
G_Printf ( " STAT_HOLDABLE_ITEM is %d, uniqueItems is %d \n " , ent - > client - > ps . stats [ STAT_HOLDABLE_ITEM ] , ent - > client - > uniqueItems ) ;
2003-04-09 02:00:43 +00:00
} */
2001-05-06 20:50:27 +00:00
/*
= = = = = = = = = = = = = = = = = =
Cmd_God_f
Sets client to godmode
argv ( 0 ) god
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_God_f ( gentity_t * ent )
2001-05-06 20:50:27 +00:00
{
2002-06-16 20:06:15 +00:00
char * msg ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( ! CheatsOk ( ent ) ) {
2001-05-06 20:50:27 +00:00
return ;
}
ent - > flags ^ = FL_GODMODE ;
2002-06-16 20:06:15 +00:00
if ( ! ( ent - > flags & FL_GODMODE ) )
2001-05-06 20:50:27 +00:00
msg = " godmode OFF \n " ;
else
msg = " godmode ON \n " ;
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" %s \" " , msg ) ) ;
2001-05-06 20:50:27 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
Cmd_Notarget_f
Sets client to notarget
argv ( 0 ) notarget
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_Notarget_f ( gentity_t * ent )
{
char * msg ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( ! CheatsOk ( ent ) ) {
2001-05-06 20:50:27 +00:00
return ;
}
ent - > flags ^ = FL_NOTARGET ;
2002-06-16 20:06:15 +00:00
if ( ! ( ent - > flags & FL_NOTARGET ) )
2001-05-06 20:50:27 +00:00
msg = " notarget OFF \n " ;
else
msg = " notarget ON \n " ;
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" %s \" " , msg ) ) ;
2001-05-06 20:50:27 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
Cmd_Noclip_f
argv ( 0 ) noclip
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_Noclip_f ( gentity_t * ent )
{
char * msg ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( ! CheatsOk ( ent ) ) {
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( ent - > client - > noclip ) {
2001-05-06 20:50:27 +00:00
msg = " noclip OFF \n " ;
} else {
msg = " noclip ON \n " ;
}
ent - > client - > noclip = ! ent - > client - > noclip ;
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" %s \" " , msg ) ) ;
2001-05-06 20:50:27 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
Cmd_LevelShot_f
This is just to help generate the level pictures
for the menus . It goes to the intermission immediately
and sends over a command to the client to resize the view ,
hide the scoreboard , and take a special screenshot
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_LevelShot_f ( gentity_t * ent )
{
if ( ! CheatsOk ( ent ) ) {
2001-05-06 20:50:27 +00:00
return ;
}
// doesn't work in single player
2002-06-16 20:06:15 +00:00
if ( g_gametype . integer ! = 0 ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1Must be in g_gametype 0 for levelshot \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2011-03-07 03:59:31 +00:00
if ( ! ent - > client - > pers . localClient ) {
trap_SendServerCommand ( ent - g_entities , " print \" The levelshot command must be executed by a local client \n \" " ) ;
return ;
}
2001-05-06 20:50:27 +00:00
BeginIntermission ( ) ;
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , " clientLevelShot " ) ;
2001-05-06 20:50:27 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
2001-08-17 20:48:18 +00:00
Elder : WTF . . . this is the wrong description , but it was
like this in the 1.29 h source
2001-05-06 20:50:27 +00:00
Cmd_LevelShot_f
This is just to help generate the level pictures
for the menus . It goes to the intermission immediately
and sends over a command to the client to resize the view ,
hide the scoreboard , and take a special screenshot
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_TeamTask_f ( gentity_t * ent )
{
2001-05-06 20:50:27 +00:00
char userinfo [ MAX_INFO_STRING ] ;
2002-06-16 20:06:15 +00:00
char arg [ MAX_TOKEN_CHARS ] ;
2001-05-06 20:50:27 +00:00
int task ;
int client = ent - > client - level . clients ;
2002-06-16 20:06:15 +00:00
if ( trap_Argc ( ) ! = 2 ) {
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
trap_Argv ( 1 , arg , sizeof ( arg ) ) ;
task = atoi ( arg ) ;
2001-05-06 20:50:27 +00:00
trap_GetUserinfo ( client , userinfo , sizeof ( userinfo ) ) ;
Info_SetValueForKey ( userinfo , " teamtask " , va ( " %d " , task ) ) ;
trap_SetUserinfo ( client , userinfo ) ;
ClientUserinfoChanged ( client ) ;
}
/*
= = = = = = = = = = = = = = = = =
Cmd_Kill_f
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_Kill_f ( gentity_t * ent )
{
if ( ent - > client - > sess . sessionTeam = = TEAM_SPECTATOR ) {
2001-05-06 20:50:27 +00:00
return ;
}
if ( ent - > health < = 0 ) {
return ;
}
2002-07-02 19:15:17 +00:00
if ( g_gametype . integer = = GT_TEAMPLAY & & level . lights_camera_action ) {
return ;
}
2005-09-07 20:27:42 +00:00
//Makro - lamer protection
//(if you suicide while hit, the attacker still receives his/her/its frag)
if ( g_RQ3_giveMeWhatsMine . integer )
{
if ( ent - > client - > lasthurt_mod ! = 0 )
{
gentity_t * attacker = & g_entities [ ent - > client - > lasthurt_client ] ;
if ( attacker ! = NULL )
{
AddScore ( attacker , ent - > r . currentOrigin , 1 ) ;
trap_SendServerCommand ( - 1 , va ( " %s tried to steal a frag from %s. And failed \n " , ent - > client - > pers . netname ,
attacker - > client - > pers . netname ) ) ;
}
}
}
2001-05-06 20:50:27 +00:00
ent - > flags & = ~ FL_GODMODE ;
ent - > client - > ps . stats [ STAT_HEALTH ] = ent - > health = - 999 ;
2002-06-16 20:06:15 +00:00
player_die ( ent , ent , ent , 100000 , MOD_SUICIDE ) ;
2005-09-07 20:27:42 +00:00
2001-05-06 20:50:27 +00:00
}
/*
= = = = = = = = = = = = = = = = =
2014-05-03 22:47:46 +00:00
BroadcastTeamChange
2001-05-06 20:50:27 +00:00
Let everyone know about a team change
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void BroadcastTeamChange ( gclient_t * client , int oldTeam )
2001-05-06 20:50:27 +00:00
{
2002-01-11 20:20:58 +00:00
// JBravo: change team names if teamplay
2002-10-26 22:03:43 +00:00
if ( g_gametype . integer > = GT_TEAM ) {
2002-02-26 04:59:10 +00:00
if ( client - > sess . savedTeam = = TEAM_RED ) {
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" %s " S_COLOR_WHITE " joined %s. \n \" " ,
client - > pers . netname , g_RQ3_team1name . string ) ) ;
2002-02-26 04:59:10 +00:00
} else if ( client - > sess . savedTeam = = TEAM_BLUE ) {
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" %s " S_COLOR_WHITE " joined %s. \n \" " ,
client - > pers . netname , g_RQ3_team2name . string ) ) ;
2002-02-26 04:59:10 +00:00
} else if ( client - > sess . savedTeam = = TEAM_SPECTATOR & & oldTeam ! = TEAM_SPECTATOR ) {
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" %s " S_COLOR_WHITE " left his team. \n \" " ,
client - > pers . netname ) ) ;
2002-01-11 20:20:58 +00:00
}
2002-02-26 04:59:10 +00:00
} else {
2002-06-16 20:06:15 +00:00
if ( client - > sess . sessionTeam = = TEAM_RED ) {
2002-07-11 04:31:07 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" %s " S_COLOR_WHITE " joined the red team. \n \" " ,
2002-06-16 20:06:15 +00:00
client - > pers . netname ) ) ;
} else if ( client - > sess . sessionTeam = = TEAM_BLUE ) {
2002-07-11 04:31:07 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" %s " S_COLOR_WHITE " joined the blue team. \n \" " ,
2002-06-16 20:06:15 +00:00
client - > pers . netname ) ) ;
} else if ( client - > sess . sessionTeam = = TEAM_SPECTATOR & & oldTeam ! = TEAM_SPECTATOR ) {
2002-07-11 04:31:07 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" %s " S_COLOR_WHITE " joined the spectators. \n \" " ,
2002-06-16 20:06:15 +00:00
client - > pers . netname ) ) ;
} else if ( client - > sess . sessionTeam = = TEAM_FREE ) {
2002-07-11 04:31:07 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" %s " S_COLOR_WHITE " joined the battle. \n \" " ,
2002-06-16 20:06:15 +00:00
client - > pers . netname ) ) ;
2002-01-11 20:20:58 +00:00
}
2001-05-06 20:50:27 +00:00
}
}
/*
= = = = = = = = = = = = = = = = =
SetTeam
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void SetTeam ( gentity_t * ent , char * s )
{
int team , oldTeam , clientNum ;
gclient_t * client ;
spectatorState_t specState = 0 ;
2002-07-11 04:31:07 +00:00
int specClient = 0 , teamsave ;
//int teamLeader;
2001-05-06 20:50:27 +00:00
//
// see what change is requested
//
client = ent - > client ;
clientNum = client - level . clients ;
2002-02-22 02:13:13 +00:00
2002-10-26 22:03:43 +00:00
if ( g_gametype . integer < GT_TEAM ) {
2002-02-22 02:13:13 +00:00
specClient = 0 ;
specState = SPECTATOR_NOT ;
}
2002-06-16 20:06:15 +00:00
if ( ! Q_stricmp ( s , " scoreboard " ) | | ! Q_stricmp ( s , " score " ) ) {
2001-05-06 20:50:27 +00:00
team = TEAM_SPECTATOR ;
specState = SPECTATOR_SCOREBOARD ;
2002-06-16 20:06:15 +00:00
} else if ( ! Q_stricmp ( s , " follow1 " ) ) {
2001-05-06 20:50:27 +00:00
team = TEAM_SPECTATOR ;
specState = SPECTATOR_FOLLOW ;
specClient = - 1 ;
2002-06-16 20:06:15 +00:00
} else if ( ! Q_stricmp ( s , " follow2 " ) ) {
2001-05-06 20:50:27 +00:00
team = TEAM_SPECTATOR ;
specState = SPECTATOR_FOLLOW ;
specClient = - 2 ;
2002-01-11 20:20:58 +00:00
// JBravo: adding aliases none for spectator, 1 for team red and 2 for team blue.
2002-06-16 20:06:15 +00:00
} else if ( ! Q_stricmp ( s , " spectator " ) | | ! Q_stricmp ( s , " s " ) | | ! Q_stricmp ( s , " none " ) ) {
2001-05-06 20:50:27 +00:00
team = TEAM_SPECTATOR ;
specState = SPECTATOR_FREE ;
2002-05-19 17:50:33 +00:00
} else if ( g_gametype . integer > = GT_TEAM ) {
2001-05-06 20:50:27 +00:00
// if running a team game, assign player to one of the teams
2002-10-26 22:03:43 +00:00
if ( g_gametype . integer < GT_TEAM ) {
2002-02-22 02:13:13 +00:00
specState = SPECTATOR_NOT ;
2002-01-11 20:20:58 +00:00
}
2002-06-16 20:06:15 +00:00
if ( ! Q_stricmp ( s , " red " ) | | ! Q_stricmp ( s , " r " ) | | ! Q_stricmp ( s , " 1 " ) ) {
2001-05-06 20:50:27 +00:00
team = TEAM_RED ;
2002-06-16 20:06:15 +00:00
} else if ( ! Q_stricmp ( s , " blue " ) | | ! Q_stricmp ( s , " b " ) | | ! Q_stricmp ( s , " 2 " ) ) {
2001-05-06 20:50:27 +00:00
team = TEAM_BLUE ;
2003-03-28 10:36:03 +00:00
} else if ( ! Q_stricmp ( s , " auto " ) ) {
team = PickTeam ( clientNum ) ;
2001-05-06 20:50:27 +00:00
} else {
// pick the team with the least number of players
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - > client - > ps . clientNum ,
va ( " print \" ^1%s is an illegal team. Putting you on the team with the least number of players. \n \" " , s ) ) ;
2002-06-16 20:06:15 +00:00
team = PickTeam ( clientNum ) ;
2001-05-06 20:50:27 +00:00
}
2002-05-19 17:50:33 +00:00
if ( g_teamForceBalance . integer ) {
2002-06-16 20:06:15 +00:00
int counts [ TEAM_NUM_TEAMS ] ;
2001-05-06 20:50:27 +00:00
2011-03-07 03:59:31 +00:00
counts [ TEAM_BLUE ] = TeamCount ( clientNum , TEAM_BLUE ) ;
counts [ TEAM_RED ] = TeamCount ( clientNum , TEAM_RED ) ;
2001-05-06 20:50:27 +00:00
// We allow a spread of two
2002-05-19 17:50:33 +00:00
if ( team = = TEAM_RED & & counts [ TEAM_RED ] - counts [ TEAM_BLUE ] > 1 ) {
2011-03-07 03:59:31 +00:00
trap_SendServerCommand ( clientNum ,
2002-06-16 20:06:15 +00:00
" cp \" Red team has too many players. \n \" " ) ;
return ; // ignore the request
2001-05-06 20:50:27 +00:00
}
2002-05-19 17:50:33 +00:00
if ( team = = TEAM_BLUE & & counts [ TEAM_BLUE ] - counts [ TEAM_RED ] > 1 ) {
2011-03-07 03:59:31 +00:00
trap_SendServerCommand ( clientNum ,
2002-06-16 20:06:15 +00:00
" cp \" Blue team has too many players. \n \" " ) ;
return ; // ignore the request
2001-05-06 20:50:27 +00:00
}
// It's ok, the team we are switching to has less or same number of players
}
} else {
// force them to spectators if there aren't any spots free
team = TEAM_FREE ;
}
// override decision if limiting the players
2002-05-19 17:50:33 +00:00
if ( ( g_gametype . integer = = GT_TOURNAMENT )
2002-06-16 20:06:15 +00:00
& & level . numNonSpectatorClients > = 2 ) {
2001-05-06 20:50:27 +00:00
team = TEAM_SPECTATOR ;
2002-06-16 20:06:15 +00:00
} else if ( g_maxGameClients . integer > 0 & & level . numNonSpectatorClients > = g_maxGameClients . integer ) {
2001-05-06 20:50:27 +00:00
team = TEAM_SPECTATOR ;
}
//
// decide if we will allow the change
//
2002-01-11 20:20:58 +00:00
// JBravo: we use the savedTeam var because the player meight be dead.
2002-09-29 16:06:45 +00:00
if ( g_gametype . integer > = GT_TEAM ) {
2002-01-11 20:20:58 +00:00
oldTeam = client - > sess . savedTeam ;
} else {
2002-02-22 02:13:13 +00:00
oldTeam = client - > sess . sessionTeam ;
2002-01-11 20:20:58 +00:00
}
2002-05-19 17:50:33 +00:00
if ( team = = oldTeam ) {
2002-01-11 20:20:58 +00:00
return ;
}
// JBravo: we want it to be OK to change from FREE to SPECTATOR without dieing.
2002-05-19 17:50:33 +00:00
if ( g_gametype . integer = = GT_TEAMPLAY & & oldTeam = = TEAM_FREE & & team = = TEAM_SPECTATOR ) {
2001-05-06 20:50:27 +00:00
return ;
}
//
// execute the team change
//
2002-10-21 21:00:39 +00:00
//sLiCeR: Matchmode referee hear all protection
2002-11-13 00:50:38 +00:00
if ( g_gametype . integer > = GT_TEAM & & ( oldTeam = = TEAM_FREE | | oldTeam = = TEAM_SPECTATOR ) & & ( team = = TEAM_RED | | team = = TEAM_BLUE ) )
2002-10-21 21:00:39 +00:00
ent - > client - > sess . refHear = qfalse ;
2001-05-06 20:50:27 +00:00
// if the player was dead leave the body
2002-05-19 17:50:33 +00:00
if ( client - > ps . stats [ STAT_HEALTH ] < = 0 ) {
2001-05-06 20:50:27 +00:00
CopyToBodyQue ( ent ) ;
}
// he starts at 'base'
client - > pers . teamState . state = TEAM_BEGIN ;
2002-01-11 20:20:58 +00:00
// JBravo: if player is changing from FREE or SPECT. there is no need for violence.
2002-02-26 21:59:10 +00:00
if ( client - > sess . sessionTeam ! = TEAM_SPECTATOR & & client - > sess . sessionTeam ! = TEAM_FREE & &
2002-06-16 20:06:15 +00:00
client - > ps . pm_type = = PM_NORMAL ) {
2001-05-06 20:50:27 +00:00
// Kill him (makes sure he loses flags, etc)
ent - > flags & = ~ FL_GODMODE ;
ent - > client - > ps . stats [ STAT_HEALTH ] = ent - > health = 0 ;
2002-06-16 20:06:15 +00:00
player_die ( ent , ent , ent , 100000 , MOD_SUICIDE ) ;
2001-05-06 20:50:27 +00:00
}
2002-07-09 05:41:48 +00:00
2003-04-09 20:57:21 +00:00
// JBravo: DM players switching to spectators should also die.
if ( g_gametype . integer = = GT_FFA & & team = = TEAM_SPECTATOR & & client - > ps . pm_type = = PM_NORMAL ) {
ent - > flags & = ~ FL_GODMODE ;
ent - > client - > ps . stats [ STAT_HEALTH ] = ent - > health = 0 ;
player_die ( ent , ent , ent , 100000 , MOD_SUICIDE ) ;
}
2002-01-11 20:20:58 +00:00
// JBravo: lets set the correct var here.
2002-10-26 22:03:43 +00:00
if ( g_gametype . integer > = GT_TEAM ) {
2002-06-24 05:51:51 +00:00
client - > sess . savedTeam = team ;
client - > ps . persistant [ PERS_SAVEDTEAM ] = team ;
2002-01-11 20:20:58 +00:00
} else {
client - > sess . sessionTeam = team ;
}
2002-02-03 21:23:51 +00:00
//Slicer : Matchmode - If a captain changes team , that team is no longer ready
2002-05-19 17:50:33 +00:00
if ( g_RQ3_matchmode . integer ) {
2002-06-16 20:06:15 +00:00
switch ( ent - > client - > sess . captain ) {
case TEAM_RED :
level . team1ready = qfalse ;
break ;
case TEAM_BLUE :
level . team2ready = qfalse ;
break ;
default :
break ;
2002-02-02 20:39:09 +00:00
}
2002-05-05 15:51:16 +00:00
ent - > client - > sess . captain = TEAM_FREE ;
ent - > client - > sess . sub = TEAM_FREE ;
2002-02-02 20:39:09 +00:00
}
2001-05-06 20:50:27 +00:00
// they go to the end of the line for tournements
2011-07-11 19:05:03 +00:00
if ( team = = TEAM_SPECTATOR & & oldTeam ! = team ) {
2001-05-06 20:50:27 +00:00
client - > sess . spectatorTime = level . time ;
}
2002-02-27 01:54:29 +00:00
// JBravo: not messing with spec system in TP during teamswitches
2002-10-26 22:03:43 +00:00
if ( g_gametype . integer < GT_TEAM ) {
2002-02-27 01:54:29 +00:00
client - > sess . spectatorState = specState ;
client - > sess . spectatorClient = specClient ;
}
2001-05-06 20:50:27 +00:00
client - > sess . teamLeader = qfalse ;
2002-06-16 20:06:15 +00:00
BroadcastTeamChange ( client , oldTeam ) ;
2001-05-06 20:50:27 +00:00
// get and distribute relevent paramters
2002-01-11 20:20:58 +00:00
// JBravo: save sessionTeam and then set it correctly for the call to ClientUserinfoChanged
// so the scoreboard will be correct. Also check for uneven teams.
2002-10-26 22:03:43 +00:00
if ( g_gametype . integer > = GT_TEAM ) {
2002-07-02 19:15:17 +00:00
if ( g_RQ3_matchmode . integer & & g_RQ3_maxplayers . integer > 0 ) {
if ( RQ3TeamCount ( - 1 , client - > sess . savedTeam ) > g_RQ3_maxplayers . integer ) // If it overflows max players
2002-06-23 15:22:53 +00:00
//Make him a sub immeadiatly.
ent - > client - > sess . sub = client - > sess . savedTeam ;
}
2002-06-16 20:06:15 +00:00
CheckForUnevenTeams ( ent ) ;
2002-01-11 20:20:58 +00:00
teamsave = client - > sess . sessionTeam ;
client - > sess . sessionTeam = client - > sess . savedTeam ;
2002-06-16 20:06:15 +00:00
ClientUserinfoChanged ( clientNum ) ;
2002-06-17 03:22:58 +00:00
CalculateRanks ( ) ;
2002-01-11 20:20:58 +00:00
client - > sess . sessionTeam = teamsave ;
2002-07-02 19:15:17 +00:00
ResetKills ( ent ) ;
2002-06-20 22:32:43 +00:00
client - > last_damaged_players [ 0 ] = ' \0 ' ;
2002-06-13 17:01:30 +00:00
//Slicer: Changing radio gender according to models
2002-06-16 20:06:15 +00:00
if ( client - > sess . savedTeam = = TEAM_RED )
2002-06-13 17:01:30 +00:00
client - > radioGender = level . team1gender ;
2002-06-16 20:06:15 +00:00
else if ( client - > sess . savedTeam = = TEAM_BLUE )
2002-06-13 17:01:30 +00:00
client - > radioGender = level . team2gender ;
2002-09-07 22:40:01 +00:00
} else {
2002-06-16 20:06:15 +00:00
ClientUserinfoChanged ( clientNum ) ;
ClientBegin ( clientNum ) ;
2002-01-11 20:20:58 +00:00
}
2002-11-13 00:50:38 +00:00
if ( g_gametype . integer = = GT_CTF | | ( g_gametype . integer = = GT_TEAM & & client - > sess . savedTeam = = TEAM_SPECTATOR ) )
2002-09-29 16:06:45 +00:00
MakeSpectator ( ent ) ;
2002-11-13 00:50:38 +00:00
// JBravo: If the game is in progress, lets spawn players joining.
if ( g_gametype . integer = = GT_TEAM & & level . team_round_going & &
( client - > sess . savedTeam = = TEAM_RED | | client - > sess . savedTeam = = TEAM_BLUE ) ) {
client - > ps . persistant [ PERS_SAVEDTEAM ] = client - > sess . savedTeam ;
client - > ps . persistant [ PERS_TEAM ] = client - > sess . savedTeam ;
client - > sess . sessionTeam = client - > sess . savedTeam ;
respawn ( ent ) ;
}
2001-05-06 20:50:27 +00:00
}
/*
= = = = = = = = = = = = = = = = =
StopFollowing
If the client being followed leaves the game , or you just want to drop
to free floating spectator mode
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void StopFollowing ( gentity_t * ent )
{
vec3_t angle ;
2002-03-23 05:17:43 +00:00
2002-06-16 20:06:15 +00:00
ent - > client - > ps . persistant [ PERS_TEAM ] = TEAM_SPECTATOR ;
2001-11-15 07:06:33 +00:00
ent - > client - > sess . sessionTeam = TEAM_SPECTATOR ;
2001-05-06 20:50:27 +00:00
ent - > client - > sess . spectatorState = SPECTATOR_FREE ;
2002-03-26 11:32:05 +00:00
ent - > client - > specMode = SPECTATOR_FREE ;
2002-05-06 00:35:49 +00:00
// JBravo: clear zcam also
ent - > client - > ps . stats [ STAT_RQ3 ] & = ~ RQ3_ZCAM ;
2002-02-23 18:07:46 +00:00
//Slicer - Removing any zoom bits he might have gainned
Cmd_Unzoom ( ent ) ;
2002-02-09 00:10:12 +00:00
ent - > client - > ps . pm_flags & = ~ PMF_FOLLOW ;
2001-05-06 20:50:27 +00:00
ent - > r . svFlags & = ~ SVF_BOT ;
ent - > client - > ps . clientNum = ent - g_entities ;
2002-03-30 02:29:43 +00:00
angle [ 0 ] = angle [ 1 ] = angle [ 2 ] = 0.0 ;
SetClientViewAngle ( ent , angle ) ;
2001-05-06 20:50:27 +00:00
}
/*
= = = = = = = = = = = = = = = = =
Cmd_Team_f
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_Team_f ( gentity_t * ent )
{
int oldTeam ;
char s [ MAX_TOKEN_CHARS ] ;
2002-01-11 20:20:58 +00:00
2002-06-09 18:58:40 +00:00
//Makro - moved here
2002-09-29 16:06:45 +00:00
if ( g_gametype . integer > = GT_TEAM ) {
2002-06-09 18:58:40 +00:00
oldTeam = ent - > client - > sess . savedTeam ;
} else {
oldTeam = ent - > client - > sess . sessionTeam ;
}
2002-05-19 17:50:33 +00:00
if ( trap_Argc ( ) ! = 2 ) {
2002-01-11 20:20:58 +00:00
// JBravo: lets keep the teamnames right.
2002-09-29 16:06:45 +00:00
if ( g_gametype . integer = = GT_TEAMPLAY | | g_gametype . integer = = GT_TEAM ) {
2002-06-09 18:58:40 +00:00
//oldTeam = ent->client->sess.savedTeam;
2002-05-19 17:50:33 +00:00
switch ( oldTeam ) {
2002-06-05 04:57:50 +00:00
case TEAM_RED :
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" You are a member of %s \n \" " ,
g_RQ3_team1name . string ) ) ;
2002-01-11 20:20:58 +00:00
break ;
2002-06-05 04:57:50 +00:00
case TEAM_BLUE :
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" You are a member of %s \n \" " ,
g_RQ3_team2name . string ) ) ;
2002-05-19 17:50:33 +00:00
break ;
case TEAM_SPECTATOR :
case TEAM_FREE :
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" You have not joined a team. \n \" " ) ;
2002-01-11 20:20:58 +00:00
break ;
}
2002-09-29 16:06:45 +00:00
} else if ( g_gametype . integer = = GT_CTF ) {
switch ( oldTeam ) {
case TEAM_RED :
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" You are a member of the SILVER team. \n \" " ) ) ;
break ;
case TEAM_BLUE :
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" You are a member of the BLACK team. \n \" " ) ) ;
break ;
case TEAM_SPECTATOR :
case TEAM_FREE :
trap_SendServerCommand ( ent - g_entities , " print \" You have not joined a team. \n \" " ) ;
break ;
}
2002-01-11 20:20:58 +00:00
} else {
2002-06-09 18:58:40 +00:00
//oldTeam = ent->client->sess.sessionTeam;
2002-05-19 17:50:33 +00:00
switch ( oldTeam ) {
2002-02-22 02:13:13 +00:00
case TEAM_BLUE :
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" Blue team \n \" " ) ;
2002-02-22 02:13:13 +00:00
break ;
case TEAM_RED :
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" Red team \n \" " ) ;
2002-02-22 02:13:13 +00:00
break ;
case TEAM_FREE :
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" Free team \n \" " ) ;
2002-02-22 02:13:13 +00:00
break ;
case TEAM_SPECTATOR :
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" Spectator team \n \" " ) ;
2002-02-22 02:13:13 +00:00
break ;
}
2002-01-11 20:20:58 +00:00
}
2001-05-06 20:50:27 +00:00
return ;
}
2002-05-19 17:50:33 +00:00
if ( ent - > client - > switchTeamTime > level . time ) {
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities ,
2003-02-27 03:58:35 +00:00
" print \" ^1May not switch teams more than once per 5 seconds. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
}
// if they are playing a tournement game, count as a loss
2002-05-19 17:50:33 +00:00
if ( ( g_gametype . integer = = GT_TOURNAMENT )
2002-06-16 20:06:15 +00:00
& & ent - > client - > sess . sessionTeam = = TEAM_FREE ) {
2001-05-06 20:50:27 +00:00
ent - > client - > sess . losses + + ;
}
2002-06-16 20:06:15 +00:00
trap_Argv ( 1 , s , sizeof ( s ) ) ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
SetTeam ( ent , s ) ;
2001-05-06 20:50:27 +00:00
ent - > client - > switchTeamTime = level . time + 5000 ;
}
/*
= = = = = = = = = = = = = = = = =
Cmd_Follow_f
= = = = = = = = = = = = = = = = =
2007-02-03 15:02:21 +00:00
// JBravo: This cmd is only used for limchasecam cheating
2002-06-16 20:06:15 +00:00
void Cmd_Follow_f ( gentity_t * ent )
{
int i ;
char arg [ MAX_TOKEN_CHARS ] ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( trap_Argc ( ) ! = 2 ) {
if ( ent - > client - > sess . spectatorState = = SPECTATOR_FOLLOW ) {
StopFollowing ( ent ) ;
2001-05-06 20:50:27 +00:00
}
return ;
}
2002-06-16 20:06:15 +00:00
trap_Argv ( 1 , arg , sizeof ( arg ) ) ;
i = ClientNumberFromString ( ent , arg ) ;
if ( i = = - 1 ) {
2001-05-06 20:50:27 +00:00
return ;
}
// can't follow self
2002-06-16 20:06:15 +00:00
if ( & level . clients [ i ] = = ent - > client ) {
2001-05-06 20:50:27 +00:00
return ;
}
// can't follow another spectator
2002-06-16 20:06:15 +00:00
if ( level . clients [ i ] . sess . sessionTeam = = TEAM_SPECTATOR ) {
2001-05-06 20:50:27 +00:00
return ;
}
// if they are playing a tournement game, count as a loss
2002-06-16 20:06:15 +00:00
if ( ( g_gametype . integer = = GT_TOURNAMENT )
& & ent - > client - > sess . sessionTeam = = TEAM_FREE ) {
2001-05-06 20:50:27 +00:00
ent - > client - > sess . losses + + ;
}
// first set them to spectator
2002-06-16 20:06:15 +00:00
if ( ent - > client - > sess . sessionTeam ! = TEAM_SPECTATOR ) {
SetTeam ( ent , " spectator " ) ;
2001-05-06 20:50:27 +00:00
}
ent - > client - > sess . spectatorState = SPECTATOR_FOLLOW ;
2002-03-26 11:32:05 +00:00
ent - > client - > specMode = SPECTATOR_FOLLOW ;
2001-05-06 20:50:27 +00:00
ent - > client - > sess . spectatorClient = i ;
}
2007-02-03 15:02:21 +00:00
*/
2001-05-06 20:50:27 +00:00
/*
= = = = = = = = = = = = = = = = =
Cmd_FollowCycle_f
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_FollowCycle_f ( gentity_t * ent , int dir )
{
int clientnum ;
int original ;
2001-05-06 20:50:27 +00:00
// if they are playing a tournement game, count as a loss
2002-06-16 20:06:15 +00:00
if ( ( g_gametype . integer = = GT_TOURNAMENT )
& & ent - > client - > sess . sessionTeam = = TEAM_FREE ) {
2001-05-06 20:50:27 +00:00
ent - > client - > sess . losses + + ;
}
// first set them to spectator
2002-01-11 20:20:58 +00:00
// JBravo: Unless we are in teamplay. No need to mess with teams.
2002-10-26 22:03:43 +00:00
if ( ent - > client - > sess . spectatorState = = SPECTATOR_NOT & & g_gametype . integer < GT_TEAM ) {
2002-06-16 20:06:15 +00:00
SetTeam ( ent , " spectator " ) ;
2001-05-06 20:50:27 +00:00
}
2002-06-16 20:06:15 +00:00
if ( dir ! = 1 & & dir ! = - 1 ) {
G_Error ( " Cmd_FollowCycle_f: bad dir %i " , dir ) ;
2001-05-06 20:50:27 +00:00
}
clientnum = ent - > client - > sess . spectatorClient ;
original = clientnum ;
do {
clientnum + = dir ;
2002-06-16 20:06:15 +00:00
if ( clientnum > = level . maxclients ) {
2001-05-06 20:50:27 +00:00
clientnum = 0 ;
}
2002-06-16 20:06:15 +00:00
if ( clientnum < 0 ) {
2001-05-06 20:50:27 +00:00
clientnum = level . maxclients - 1 ;
}
// can only follow connected clients
2002-06-16 20:06:15 +00:00
if ( level . clients [ clientnum ] . pers . connected ! = CON_CONNECTED ) {
2001-05-06 20:50:27 +00:00
continue ;
}
// can't follow another spectator
2002-06-16 20:06:15 +00:00
if ( level . clients [ clientnum ] . sess . sessionTeam = = TEAM_SPECTATOR ) {
2001-05-06 20:50:27 +00:00
continue ;
}
2002-01-31 02:25:31 +00:00
// JBravo: limchasecam
2002-10-26 22:03:43 +00:00
if ( g_gametype . integer > = GT_TEAM & & g_RQ3_limchasecam . integer ! = 0 & &
2002-09-24 05:06:17 +00:00
ent - > client - > sess . savedTeam ! = level . clients [ clientnum ] . sess . sessionTeam & & ent - > client - > sess . referee = = 0 ) {
G_Printf ( " SavedTeam = (%d) \n " , ent - > client - > sess . savedTeam ) ;
2002-01-31 02:25:31 +00:00
continue ;
}
2001-05-06 20:50:27 +00:00
// this is good, we can use it
ent - > client - > sess . spectatorClient = clientnum ;
ent - > client - > sess . spectatorState = SPECTATOR_FOLLOW ;
2002-03-26 11:32:05 +00:00
ent - > client - > specMode = SPECTATOR_FOLLOW ;
2001-05-06 20:50:27 +00:00
return ;
2002-06-16 20:06:15 +00:00
} while ( clientnum ! = original ) ;
2001-05-06 20:50:27 +00:00
// leave it where it was
}
/*
= = = = = = = = = = = = = = = = = =
G_Say
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
static void G_SayTo ( gentity_t * ent , gentity_t * other , int mode , int color , const char * name , const char * message )
{
2001-05-06 20:50:27 +00:00
if ( ! other ) {
return ;
}
if ( ! other - > inuse ) {
return ;
}
if ( ! other - > client ) {
return ;
}
2002-06-16 20:06:15 +00:00
if ( other - > client - > pers . connected ! = CON_CONNECTED ) {
2001-08-01 19:52:17 +00:00
return ;
}
2002-10-21 21:00:39 +00:00
if ( mode = = SAY_TEAM & & ! OnSameTeam ( ent , other ) & & ! ent - > client - > sess . refHear ) { //Slicer: This makes referees read say_team stuff if Hear all
2001-05-06 20:50:27 +00:00
return ;
}
// no chatting to players in tournements
2002-06-16 20:06:15 +00:00
if ( ( g_gametype . integer = = GT_TOURNAMENT )
2002-08-27 04:53:46 +00:00
& & other - > client - > sess . sessionTeam = = TEAM_FREE & & ent - > client - > sess . sessionTeam ! = TEAM_FREE & &
mode ! = SAY_REF ) {
2001-05-06 20:50:27 +00:00
return ;
}
2002-05-10 04:06:27 +00:00
// JBravo: is the guy ignored ?
2002-08-27 04:53:46 +00:00
if ( IsInIgnoreList ( other , ent ) & & mode ! = SAY_REF )
2002-05-10 04:06:27 +00:00
return ;
2002-07-09 03:24:00 +00:00
// JBravo: Dead people dont speak to the living... or so Im told.
2002-09-29 16:06:45 +00:00
if ( ! G_PlayerAlive ( ent ) & & G_PlayerAlive ( other ) & &
2002-08-27 04:53:46 +00:00
g_gametype . integer = = GT_TEAMPLAY & & level . team_round_going & & mode ! = SAY_REF )
2002-02-26 01:10:19 +00:00
return ;
2002-07-09 03:24:00 +00:00
2011-03-10 21:18:07 +00:00
trap_SendServerCommand ( other - g_entities , va ( " %s \" %s%c%c%s \n \" " ,
2002-06-16 20:06:15 +00:00
mode = = SAY_TEAM ? " tchat " : " chat " ,
name , Q_COLOR_ESCAPE , color , message ) ) ;
2001-05-06 20:50:27 +00:00
}
# define EC "\x19"
2002-06-16 20:06:15 +00:00
void G_Say ( gentity_t * ent , gentity_t * target , int mode , const char * chatText )
{
int j ;
gentity_t * other ;
int color ;
char name [ 64 ] ;
2001-05-06 20:50:27 +00:00
// don't let text be too long for malicious reasons
2002-06-16 20:06:15 +00:00
char text [ MAX_SAY_TEXT ] ;
char location [ 64 ] ;
int validation ;
2001-08-13 17:26:53 +00:00
// Elder: validate the client
2002-06-16 20:06:15 +00:00
validation = RQ3_ValidateSay ( ent ) ;
2002-07-07 23:54:57 +00:00
ent - > client - > idletime = 0 ;
2001-08-13 17:26:53 +00:00
2002-06-16 20:06:15 +00:00
if ( validation ! = SAY_OK ) {
2001-08-13 17:26:53 +00:00
// Only send one message for the initial offense
2002-06-16 20:06:15 +00:00
if ( ent - > client - > pers . sayMuteTime = = level . time & & ent - > client - > pers . sayModerated = = qfalse ) {
2001-08-17 20:48:18 +00:00
ent - > client - > pers . sayModerated = qtrue ;
2002-06-16 20:06:15 +00:00
if ( validation = = SAY_WARNING ) {
trap_SendServerCommand ( ent - g_entities ,
va
( " print \" Exceeded message limit - ^3WARNING ^7(%i seconds). \n \" " ,
g_RQ3_messageWarnTime . integer ) ) ;
G_LogPrintf ( " Server: %s received a message protect warning (offense %i) \n " ,
ent - > client - > pers . netname , ent - > client - > pers . sayWarnings ) ;
} else if ( validation = = SAY_BAN ) {
2001-08-17 20:48:18 +00:00
// Don't bother printing if kicked
if ( g_RQ3_messageBanTime . integer > 0 )
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities ,
va
( " print \" Exceeded message limit - ^1BAN ^7(%i seconds). \n \" " ,
g_RQ3_messageBanTime . integer ) ) ;
G_LogPrintf ( " Server: %s received a message protect ban (offense %i) \n " ,
ent - > client - > pers . netname , ent - > client - > pers . sayBans ) ;
2001-08-13 17:26:53 +00:00
}
}
return ;
}
2001-05-06 20:50:27 +00:00
2002-06-21 00:05:55 +00:00
// Slicer: DM now has [SPECTATOR]
2002-02-25 17:54:57 +00:00
// JBravo: adding below the [DEAD] tag infront of dead players names.
2002-06-16 20:06:15 +00:00
switch ( mode ) {
2001-05-06 20:50:27 +00:00
default :
case SAY_ALL :
2002-02-25 17:54:57 +00:00
if ( ent - > client - > sess . sessionTeam = = TEAM_SPECTATOR ) {
2002-07-02 19:15:17 +00:00
if ( g_gametype . integer < GT_TEAM ) // DM, SPECTATOR
2002-06-21 00:05:55 +00:00
Com_sprintf ( name , sizeof ( name ) , " [SPECTATOR] %s%c%c " EC " : " , ent - > client - > pers . netname ,
2002-06-16 20:06:15 +00:00
Q_COLOR_ESCAPE , COLOR_WHITE ) ;
2002-06-21 00:05:55 +00:00
else {
2002-07-02 19:15:17 +00:00
if ( ent - > client - > sess . savedTeam = = TEAM_SPECTATOR )
2002-10-21 21:00:39 +00:00
Com_sprintf ( name , sizeof ( name ) , " %s %s%c%c " EC " : " , ent - > client - > sess . referee ? " [REFEREE] " : " [SPECTATOR] " , ent - > client - > pers . netname ,
2002-06-21 00:05:55 +00:00
Q_COLOR_ESCAPE , COLOR_WHITE ) ;
else
2002-10-21 21:00:39 +00:00
Com_sprintf ( name , sizeof ( name ) , " %s %s%c%c " EC " : " , ent - > client - > sess . referee ? " [REFEREE] " : " [DEAD] " , ent - > client - > pers . netname ,
2002-06-21 00:05:55 +00:00
Q_COLOR_ESCAPE , COLOR_WHITE ) ;
}
2002-02-25 17:54:57 +00:00
} else {
2002-06-16 20:06:15 +00:00
Com_sprintf ( name , sizeof ( name ) , " %s%c%c " EC " : " , ent - > client - > pers . netname , Q_COLOR_ESCAPE ,
COLOR_WHITE ) ;
2002-02-25 17:54:57 +00:00
}
2002-08-27 04:50:54 +00:00
color = COLOR_GREEN ;
2001-05-06 20:50:27 +00:00
break ;
case SAY_TEAM :
2002-02-25 17:54:57 +00:00
if ( ent - > client - > sess . sessionTeam = = TEAM_SPECTATOR ) {
2002-06-21 00:05:55 +00:00
if ( g_gametype . integer < GT_TEAM ) // DM, SPECTATOR
Com_sprintf ( name , sizeof ( name ) , EC " [SPECTATOR] (%s%c%c " EC " ) " EC " : " ,
2002-06-16 20:06:15 +00:00
ent - > client - > pers . netname , Q_COLOR_ESCAPE , COLOR_WHITE ) ;
2002-06-21 00:05:55 +00:00
else {
2002-07-02 19:15:17 +00:00
if ( ent - > client - > sess . savedTeam = = TEAM_SPECTATOR )
2002-10-21 21:00:39 +00:00
Com_sprintf ( name , sizeof ( name ) , EC " %s (%s%c%c " EC " ) " EC " : " , ent - > client - > sess . referee ? " [REFEREE] " : " [SPECTATOR] " ,
2002-06-21 00:05:55 +00:00
ent - > client - > pers . netname , Q_COLOR_ESCAPE , COLOR_WHITE ) ;
else
Com_sprintf ( name , sizeof ( name ) , EC " [DEAD] (%s%c%c " EC " ) " EC " : " ,
ent - > client - > pers . netname , Q_COLOR_ESCAPE , COLOR_WHITE ) ;
}
2002-02-25 17:54:57 +00:00
} else {
if ( Team_GetLocationMsg ( ent , location , sizeof ( location ) ) )
2002-06-16 20:06:15 +00:00
Com_sprintf ( name , sizeof ( name ) , EC " (%s%c%c " EC " ) (%s) " EC " : " ,
ent - > client - > pers . netname , Q_COLOR_ESCAPE , COLOR_WHITE , location ) ;
2002-02-25 17:54:57 +00:00
else
2002-06-16 20:06:15 +00:00
Com_sprintf ( name , sizeof ( name ) , EC " (%s%c%c " EC " ) " EC " : " ,
ent - > client - > pers . netname , Q_COLOR_ESCAPE , COLOR_WHITE ) ;
2002-02-25 17:54:57 +00:00
}
2001-05-06 20:50:27 +00:00
color = COLOR_CYAN ;
break ;
case SAY_TELL :
2002-02-25 17:54:57 +00:00
if ( target & & g_gametype . integer = = GT_TEAMPLAY & &
2002-06-16 20:06:15 +00:00
target - > client - > sess . savedTeam = = ent - > client - > sess . savedTeam & &
Team_GetLocationMsg ( ent , location , sizeof ( location ) ) )
Com_sprintf ( name , sizeof ( name ) , EC " [%s%c%c " EC " ] (%s) " EC " : " , ent - > client - > pers . netname ,
Q_COLOR_ESCAPE , COLOR_WHITE , location ) ;
else if ( target & & g_gametype . integer > = GT_TEAM
& & target - > client - > sess . sessionTeam = = ent - > client - > sess . sessionTeam
& & Team_GetLocationMsg ( ent , location , sizeof ( location ) ) )
Com_sprintf ( name , sizeof ( name ) , EC " [%s%c%c " EC " ] (%s) " EC " : " , ent - > client - > pers . netname ,
Q_COLOR_ESCAPE , COLOR_WHITE , location ) ;
2001-05-06 20:50:27 +00:00
else
2002-06-16 20:06:15 +00:00
Com_sprintf ( name , sizeof ( name ) , EC " [%s%c%c " EC " ] " EC " : " , ent - > client - > pers . netname ,
Q_COLOR_ESCAPE , COLOR_WHITE ) ;
2001-05-06 20:50:27 +00:00
color = COLOR_MAGENTA ;
break ;
2002-08-27 04:48:13 +00:00
case SAY_REF :
Com_sprintf ( name , sizeof ( name ) , " [REFEREE] %s%c%c " EC " : " , ent - > client - > pers . netname ,
Q_COLOR_ESCAPE , COLOR_WHITE ) ;
2002-08-27 04:50:54 +00:00
color = COLOR_WHITE ;
2002-08-27 04:48:13 +00:00
break ;
2001-05-06 20:50:27 +00:00
}
2002-03-14 23:54:12 +00:00
// JBravo: Parsing % vars here
2002-08-17 01:56:31 +00:00
if ( ent - > client - > sess . sessionTeam ! = TEAM_SPECTATOR & & mode = = SAY_TEAM ) {
2002-06-16 20:06:15 +00:00
ParseSayText ( ent , ( char * ) chatText ) ;
2002-03-14 23:54:12 +00:00
}
2002-06-16 20:06:15 +00:00
Q_strncpyz ( text , chatText , sizeof ( text ) ) ;
2001-05-06 20:50:27 +00:00
2002-02-26 01:10:19 +00:00
if ( target ) {
G_SayTo ( ent , target , mode , color , name , text ) ;
2001-05-06 20:50:27 +00:00
return ;
}
// echo the text to the console
2002-06-16 20:06:15 +00:00
if ( g_dedicated . integer ) {
G_Printf ( " %s%s \n " , name , text ) ;
2001-05-06 20:50:27 +00:00
}
2002-04-30 01:23:05 +00:00
// JBravo: Log it like AQ does
2002-06-16 20:06:15 +00:00
G_LogPrintf ( " %s%s \n " , name , text ) ;
2002-04-30 01:23:05 +00:00
2001-05-06 20:50:27 +00:00
// send it to all the apropriate clients
for ( j = 0 ; j < level . maxclients ; j + + ) {
2002-09-24 05:06:17 +00:00
//Blaze: Prit out some Debug info
if ( & g_entities [ j ] = = NULL ) G_Printf ( " Ln 1532 \n " ) ;
2001-05-06 20:50:27 +00:00
other = & g_entities [ j ] ;
2002-02-26 01:10:19 +00:00
G_SayTo ( ent , other , mode , color , name , text ) ;
2001-05-06 20:50:27 +00:00
}
}
/*
= = = = = = = = = = = = = = = = = =
2002-07-07 23:54:57 +00:00
Cmd_ay_f
2001-05-06 20:50:27 +00:00
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
static void Cmd_Say_f ( gentity_t * ent , int mode , qboolean arg0 )
{
char * p ;
2002-06-23 15:22:53 +00:00
qboolean normaluser ;
2002-06-16 20:06:15 +00:00
if ( trap_Argc ( ) < 2 & & ! arg0 ) {
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( arg0 ) {
p = ConcatArgs ( 0 ) ;
} else {
p = ConcatArgs ( 1 ) ;
2001-05-06 20:50:27 +00:00
}
2002-06-20 18:40:17 +00:00
//Slicer Matchmode
2002-07-02 19:15:17 +00:00
if ( g_RQ3_matchmode . integer ) {
2002-08-23 14:25:05 +00:00
normaluser = ( ent - > client - > sess . captain = = TEAM_FREE & & ! ent - > client - > sess . referee ) ;
2002-06-23 15:22:53 +00:00
switch ( g_RQ3_forceteamtalk . integer ) {
2002-07-02 19:15:17 +00:00
case 1 : //Only allow say_team when the game hasn't started
if ( level . inGame & & normaluser )
mode = SAY_TEAM ;
break ;
case 2 :
if ( normaluser )
mode = SAY_TEAM ;
break ;
default :
break ;
2002-06-23 15:22:53 +00:00
}
}
2002-06-20 18:40:17 +00:00
2002-06-16 20:06:15 +00:00
G_Say ( ent , NULL , mode , p ) ;
2001-05-06 20:50:27 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
Cmd_Tell_f
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
static void Cmd_Tell_f ( gentity_t * ent )
{
int targetNum ;
gentity_t * target ;
char * p ;
char arg [ MAX_TOKEN_CHARS ] ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( trap_Argc ( ) < 2 ) {
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-21 00:05:55 +00:00
//Slicer : no TELL FOR TP
2002-07-02 19:15:17 +00:00
if ( ! g_gametype . integer < GT_TEAM )
2002-06-21 00:05:55 +00:00
return ;
2002-06-16 20:06:15 +00:00
trap_Argv ( 1 , arg , sizeof ( arg ) ) ;
targetNum = atoi ( arg ) ;
if ( targetNum < 0 | | targetNum > = level . maxclients ) {
2001-05-06 20:50:27 +00:00
return ;
}
2002-09-24 05:06:17 +00:00
//Blaze: Prit out some Debug info
if ( & g_entities [ targetNum ] = = NULL ) G_Printf ( " Ln 1608 \n " ) ;
2001-05-06 20:50:27 +00:00
target = & g_entities [ targetNum ] ;
2002-06-16 20:06:15 +00:00
if ( ! target | | ! target - > inuse | | ! target - > client ) {
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
p = ConcatArgs ( 2 ) ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
G_LogPrintf ( " tell: %s to %s: %s \n " , ent - > client - > pers . netname , target - > client - > pers . netname , p ) ;
G_Say ( ent , target , SAY_TELL , p ) ;
2001-05-06 20:50:27 +00:00
// don't tell to the player self if it was already directed to this player
// also don't send the chat back to a bot
2002-06-16 20:06:15 +00:00
if ( ent ! = target & & ! ( ent - > r . svFlags & SVF_BOT ) ) {
G_Say ( ent , ent , SAY_TELL , p ) ;
}
2001-05-06 20:50:27 +00:00
}
2002-06-16 20:06:15 +00:00
static void G_VoiceTo ( gentity_t * ent , gentity_t * other , int mode , const char * id , qboolean voiceonly )
{
2001-05-06 20:50:27 +00:00
int color ;
char * cmd ;
if ( ! other ) {
return ;
}
if ( ! other - > inuse ) {
return ;
}
if ( ! other - > client ) {
return ;
}
2002-06-16 20:06:15 +00:00
if ( mode = = SAY_TEAM & & ! OnSameTeam ( ent , other ) ) {
2001-05-06 20:50:27 +00:00
return ;
}
// no chatting to players in tournements
2002-06-16 20:06:15 +00:00
if ( ( g_gametype . integer = = GT_TOURNAMENT ) ) {
2001-05-06 20:50:27 +00:00
return ;
}
if ( mode = = SAY_TEAM ) {
color = COLOR_CYAN ;
cmd = " vtchat " ;
2002-06-16 20:06:15 +00:00
} else if ( mode = = SAY_TELL ) {
2001-05-06 20:50:27 +00:00
color = COLOR_MAGENTA ;
cmd = " vtell " ;
2002-06-16 20:06:15 +00:00
} else {
2001-05-06 20:50:27 +00:00
color = COLOR_GREEN ;
cmd = " vchat " ;
}
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( other - g_entities , va ( " %s %d %d %d %s " , cmd , voiceonly , ent - > s . number , color , id ) ) ;
2001-05-06 20:50:27 +00:00
}
2002-06-16 20:06:15 +00:00
void G_Voice ( gentity_t * ent , gentity_t * target , int mode , const char * id , qboolean voiceonly )
{
int j ;
gentity_t * other ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( g_gametype . integer < GT_TEAM & & mode = = SAY_TEAM ) {
2001-05-06 20:50:27 +00:00
mode = SAY_ALL ;
}
2002-06-16 20:06:15 +00:00
if ( target ) {
G_VoiceTo ( ent , target , mode , id , voiceonly ) ;
2001-05-06 20:50:27 +00:00
return ;
}
// echo the text to the console
2002-06-16 20:06:15 +00:00
if ( g_dedicated . integer ) {
G_Printf ( " voice: %s %s \n " , ent - > client - > pers . netname , id ) ;
2001-05-06 20:50:27 +00:00
}
// send it to all the apropriate clients
for ( j = 0 ; j < level . maxclients ; j + + ) {
2002-09-24 05:06:17 +00:00
//Blaze: Prit out some Debug info
if ( & g_entities [ j ] = = NULL ) G_Printf ( " Ln 1682 \n " ) ;
2001-05-06 20:50:27 +00:00
other = & g_entities [ j ] ;
2002-06-16 20:06:15 +00:00
G_VoiceTo ( ent , other , mode , id , voiceonly ) ;
2001-05-06 20:50:27 +00:00
}
}
/*
= = = = = = = = = = = = = = = = = =
Cmd_Voice_f
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
static void Cmd_Voice_f ( gentity_t * ent , int mode , qboolean arg0 , qboolean voiceonly )
{
char * p ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( trap_Argc ( ) < 2 & & ! arg0 ) {
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( arg0 ) {
p = ConcatArgs ( 0 ) ;
} else {
p = ConcatArgs ( 1 ) ;
2001-05-06 20:50:27 +00:00
}
2002-06-16 20:06:15 +00:00
G_Voice ( ent , NULL , mode , p , voiceonly ) ;
2001-05-06 20:50:27 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
Cmd_VoiceTell_f
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
static void Cmd_VoiceTell_f ( gentity_t * ent , qboolean voiceonly )
{
int targetNum ;
gentity_t * target ;
char * id ;
char arg [ MAX_TOKEN_CHARS ] ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( trap_Argc ( ) < 2 ) {
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
trap_Argv ( 1 , arg , sizeof ( arg ) ) ;
targetNum = atoi ( arg ) ;
if ( targetNum < 0 | | targetNum > = level . maxclients ) {
2001-05-06 20:50:27 +00:00
return ;
}
2002-09-24 05:06:17 +00:00
//Blaze: Prit out some Debug info
if ( & g_entities [ targetNum ] = = NULL ) G_Printf ( " Ln 1733 \n " ) ;
2001-05-06 20:50:27 +00:00
target = & g_entities [ targetNum ] ;
2002-06-16 20:06:15 +00:00
if ( ! target | | ! target - > inuse | | ! target - > client ) {
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
id = ConcatArgs ( 2 ) ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
G_LogPrintf ( " vtell: %s to %s: %s \n " , ent - > client - > pers . netname , target - > client - > pers . netname , id ) ;
G_Voice ( ent , target , SAY_TELL , id , voiceonly ) ;
2001-05-06 20:50:27 +00:00
// don't tell to the player self if it was already directed to this player
// also don't send the chat back to a bot
2002-06-16 20:06:15 +00:00
if ( ent ! = target & & ! ( ent - > r . svFlags & SVF_BOT ) ) {
G_Voice ( ent , ent , SAY_TELL , id , voiceonly ) ;
2001-05-06 20:50:27 +00:00
}
}
/*
= = = = = = = = = = = = = = = = = =
Cmd_VoiceTaunt_f
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
static void Cmd_VoiceTaunt_f ( gentity_t * ent )
{
2001-05-06 20:50:27 +00:00
gentity_t * who ;
int i ;
if ( ! ent - > client ) {
return ;
}
// insult someone who just killed you
2002-03-14 23:54:12 +00:00
// JBravo: adding the multiple killed system.
if ( ent - > enemy & & ent - > enemy - > client & & ent - > enemy - > client - > lastkilled_client [ 0 ] = = ent ) {
2001-05-06 20:50:27 +00:00
// i am a dead corpse
if ( ! ( ent - > enemy - > r . svFlags & SVF_BOT ) ) {
2002-06-16 20:06:15 +00:00
G_Voice ( ent , ent - > enemy , SAY_TELL , VOICECHAT_DEATHINSULT , qfalse ) ;
2001-05-06 20:50:27 +00:00
}
if ( ! ( ent - > r . svFlags & SVF_BOT ) ) {
2002-06-16 20:06:15 +00:00
G_Voice ( ent , ent , SAY_TELL , VOICECHAT_DEATHINSULT , qfalse ) ;
2001-05-06 20:50:27 +00:00
}
ent - > enemy = NULL ;
return ;
}
// insult someone you just killed
2002-03-14 23:54:12 +00:00
// JBravo: adding the multiple killed system.
2002-04-07 03:22:48 +00:00
if ( ent - > client - > lastkilled_client [ 0 ] ! = NULL & & ent - > client - > lastkilled_client [ 0 ] - > s . number > = 0 & &
2002-06-16 20:06:15 +00:00
ent - > client - > lastkilled_client [ 0 ] - > s . number ! = ent - > s . number ) {
2002-03-14 23:54:12 +00:00
who = ent - > client - > lastkilled_client [ 0 ] ;
2001-05-06 20:50:27 +00:00
if ( who - > client ) {
// who is the person I just killed
if ( who - > client - > lasthurt_mod = = MOD_GAUNTLET ) {
if ( ! ( who - > r . svFlags & SVF_BOT ) ) {
2002-06-16 20:06:15 +00:00
G_Voice ( ent , who , SAY_TELL , VOICECHAT_KILLGAUNTLET , qfalse ) ; // and I killed them with a gauntlet
2001-05-06 20:50:27 +00:00
}
if ( ! ( ent - > r . svFlags & SVF_BOT ) ) {
2002-06-16 20:06:15 +00:00
G_Voice ( ent , ent , SAY_TELL , VOICECHAT_KILLGAUNTLET , qfalse ) ;
2001-05-06 20:50:27 +00:00
}
} else {
if ( ! ( who - > r . svFlags & SVF_BOT ) ) {
2002-06-16 20:06:15 +00:00
G_Voice ( ent , who , SAY_TELL , VOICECHAT_KILLINSULT , qfalse ) ; // and I killed them with something else
2001-05-06 20:50:27 +00:00
}
if ( ! ( ent - > r . svFlags & SVF_BOT ) ) {
2002-06-16 20:06:15 +00:00
G_Voice ( ent , ent , SAY_TELL , VOICECHAT_KILLINSULT , qfalse ) ;
2001-05-06 20:50:27 +00:00
}
}
2002-03-14 23:54:12 +00:00
// JBravo: adding the multiple killed system.
ent - > client - > lastkilled_client [ 0 ] = NULL ;
2001-05-06 20:50:27 +00:00
return ;
}
}
if ( g_gametype . integer > = GT_TEAM ) {
// praise a team mate who just got a reward
2002-06-16 20:06:15 +00:00
for ( i = 0 ; i < MAX_CLIENTS ; i + + ) {
2001-05-06 20:50:27 +00:00
who = g_entities + i ;
if ( who - > client & & who ! = ent & & who - > client - > sess . sessionTeam = = ent - > client - > sess . sessionTeam ) {
if ( who - > client - > rewardTime > level . time ) {
if ( ! ( who - > r . svFlags & SVF_BOT ) ) {
2002-06-16 20:06:15 +00:00
G_Voice ( ent , who , SAY_TELL , VOICECHAT_PRAISE , qfalse ) ;
2001-05-06 20:50:27 +00:00
}
if ( ! ( ent - > r . svFlags & SVF_BOT ) ) {
2002-06-16 20:06:15 +00:00
G_Voice ( ent , ent , SAY_TELL , VOICECHAT_PRAISE , qfalse ) ;
2001-05-06 20:50:27 +00:00
}
return ;
}
}
}
}
// just say something
2002-06-16 20:06:15 +00:00
G_Voice ( ent , NULL , SAY_ALL , VOICECHAT_TAUNT , qfalse ) ;
2001-05-06 20:50:27 +00:00
}
2002-06-16 20:06:15 +00:00
static char * gc_orders [ ] = {
2001-05-06 20:50:27 +00:00
" hold your position " ,
" hold this position " ,
" come here " ,
" cover me " ,
" guard location " ,
" search and destroy " ,
" report "
} ;
2002-06-16 20:06:15 +00:00
void Cmd_GameCommand_f ( gentity_t * ent )
{
int player ;
int order ;
char str [ MAX_TOKEN_CHARS ] ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
trap_Argv ( 1 , str , sizeof ( str ) ) ;
player = atoi ( str ) ;
trap_Argv ( 2 , str , sizeof ( str ) ) ;
order = atoi ( str ) ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( player < 0 | | player > = MAX_CLIENTS ) {
2001-05-06 20:50:27 +00:00
return ;
}
2011-03-07 03:59:31 +00:00
if ( order < 0 | | order > ARRAY_LEN ( gc_orders ) ) {
2001-05-06 20:50:27 +00:00
return ;
}
2002-09-24 05:06:17 +00:00
//Blaze: Prit out some Debug info
if ( & g_entities [ player ] = = NULL ) G_Printf ( " Ln 1854 \n " ) ;
2002-06-16 20:06:15 +00:00
G_Say ( ent , & g_entities [ player ] , SAY_TELL , gc_orders [ order ] ) ;
G_Say ( ent , ent , SAY_TELL , gc_orders [ order ] ) ;
2001-05-06 20:50:27 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
Cmd_Where_f
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_Where_f ( gentity_t * ent )
{
2012-01-14 00:18:42 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" %s \n \" " , vtos ( ent - > r . currentOrigin ) ) ) ;
2001-05-06 20:50:27 +00:00
}
static const char * gameNames [ ] = {
" Free For All " ,
" Tournament " ,
" Single Player " ,
" Team Deathmatch " ,
2002-01-11 20:20:58 +00:00
// JBravo: duh ;)
" RQ3 teamplay " ,
2002-06-29 04:15:15 +00:00
" Capture the Briefcase " ,
2001-05-06 20:50:27 +00:00
" One Flag CTF " ,
" Overload " ,
" Harvester "
} ;
/*
= = = = = = = = = = = = = = = = = =
Cmd_CallVote_f
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_CallVote_f ( gentity_t * ent )
{
2003-03-28 13:05:18 +00:00
int i , kickNum ;
2003-03-10 07:07:58 +00:00
float delay ;
2002-06-16 20:06:15 +00:00
char arg1 [ MAX_STRING_TOKENS ] ;
char arg2 [ MAX_STRING_TOKENS ] ;
2005-09-13 02:33:17 +00:00
char * v_gametype , * v_map ;
2003-03-28 13:05:18 +00:00
gentity_t * kicked ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( ! g_allowVote . integer ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1Voting not allowed here. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( level . voteTime ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1A vote is already in progress. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2003-03-10 07:07:58 +00:00
// JBravo: delay added after mapchanges
if ( level . time - level . startTime < ( float ) g_RQ3_vote_waittime . integer * 1000 ) {
delay = ( ( ( ( float ) g_RQ3_vote_waittime . integer * 1000 ) + level . startTime ) - level . time ) / 1000 ;
if ( delay < 10.0 )
trap_SendServerCommand ( ent - g_entities , va ( " print \" ^1Voting currently blocked - Please vote again in^2 %1.2f ^1seconds \n \" " ,
delay ) ) ;
else
trap_SendServerCommand ( ent - g_entities , va ( " print \" ^1Voting currently blocked - Please vote again in^2 %2.2f ^1seconds \n \" " ,
delay ) ) ;
return ;
}
2002-08-13 16:59:16 +00:00
//Makro - replaced the constant with a cvar
if ( ent - > client - > pers . voteCount > = g_RQ3_maxClientVotes . integer ) {
//Makro - added cvar info
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" ^1You have called the maximum number of votes (%i). \n \" " , g_RQ3_maxClientVotes . integer ) ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2005-09-13 02:33:17 +00:00
// JBravo: Lets allow spectators to vote in TP
2002-09-30 01:32:30 +00:00
if ( ent - > client - > sess . sessionTeam = = TEAM_SPECTATOR & & g_gametype . integer < GT_TEAM ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1Not allowed to call a vote as spectator. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
2002-08-07 20:49:21 +00:00
}
2005-09-13 02:33:17 +00:00
//Slicer Matchmode
2002-08-07 20:49:21 +00:00
if ( g_RQ3_matchmode . integer & & ent - > client - > sess . captain = = TEAM_FREE ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1Only team Captains can start a vote. \n \" " ) ;
2002-08-07 20:49:21 +00:00
return ;
2001-05-06 20:50:27 +00:00
}
// make sure it is a valid command to vote on
2002-06-16 20:06:15 +00:00
trap_Argv ( 1 , arg1 , sizeof ( arg1 ) ) ;
trap_Argv ( 2 , arg2 , sizeof ( arg2 ) ) ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( strchr ( arg1 , ' ; ' ) | | strchr ( arg2 , ' ; ' ) ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1Invalid vote string. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-08-07 20:49:21 +00:00
if ( ! Q_stricmp ( arg1 , " cyclemap " ) ) {
2010-08-13 14:57:27 +00:00
//TTI - adding "map_restart"
} else if ( ! Q_stricmp ( arg1 , " map_restart " ) ) {
2005-09-07 20:27:42 +00:00
//Makro - adding "timelimit X"
} else if ( ! Q_stricmp ( arg1 , " timelimit " ) ) {
2002-05-12 19:15:47 +00:00
} else if ( ! Q_stricmp ( arg1 , " map " ) ) {
} else if ( ! Q_stricmp ( arg1 , " g_gametype " ) ) {
} else if ( ! Q_stricmp ( arg1 , " kick " ) ) {
} else if ( ! Q_stricmp ( arg1 , " clientkick " ) ) {
2005-09-13 02:33:17 +00:00
// JBravo: adding game, a gametype:map combo
} else if ( ! Q_stricmp ( arg1 , " game " ) ) {
2001-05-06 20:50:27 +00:00
} else {
2002-08-07 20:49:21 +00:00
if ( g_RQ3_matchmode . integer ) {
if ( ! Q_stricmp ( arg1 , " resetmatch " ) ) {
} else if ( ! Q_stricmp ( arg1 , " clearscores " ) ) {
} else {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1Invalid vote command. \n \" " ) ;
2010-08-13 14:57:27 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" Valid vote commands are: cyclemap, map_restart, map <mapname>, g_gametype <n>, game <gametype:map>, kick <player>, clientkick <clientnum>, clearscores, resetmatch and timelimit <minutes>. \n \" " ) ;
2002-08-07 20:49:21 +00:00
return ;
}
2003-03-28 13:05:18 +00:00
} else {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1Invalid vote command. \n \" " ) ;
2002-08-07 20:49:21 +00:00
trap_SendServerCommand ( ent - g_entities ,
2010-08-13 14:57:27 +00:00
" print \" Valid vote commands are: cyclemap, map_restart, map <mapname>, g_gametype <n>, game <gametype:map>, kick <player>, clientkick <clientnum> and timelimit <minutes>. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
2002-08-07 20:49:21 +00:00
}
2001-05-06 20:50:27 +00:00
}
// special case for g_gametype, check for bad values
2002-06-16 20:06:15 +00:00
if ( ! Q_stricmp ( arg1 , " g_gametype " ) ) {
2005-09-13 02:33:17 +00:00
// JBravo: Adding the digit check to catch errors
// JBravo: Im cloning this code in the callvote game section.
// Changes here must be done there also.
2005-09-07 20:27:42 +00:00
//Makro - added short gametype names
2005-09-13 02:33:17 +00:00
if ( is_digit ( arg2 [ 0 ] ) ) {
2005-09-07 20:27:42 +00:00
i = atoi ( arg2 ) ;
2005-09-13 02:33:17 +00:00
} else {
if ( ! Q_stricmp ( arg2 , " dm " ) ) {
i = GT_FFA ;
} else if ( ! Q_stricmp ( arg2 , " tp " ) ) {
i = GT_TEAMPLAY ;
} else if ( ! Q_stricmp ( arg2 , " tdm " ) ) {
i = GT_TEAM ;
} else if ( ! Q_stricmp ( arg2 , " ctb " ) ) {
i = GT_CTF ;
} else {
//if not a preset name, consider it an error
i = 999 ;
}
2005-09-07 20:27:42 +00:00
}
2002-10-26 22:03:43 +00:00
if ( i ! = GT_FFA & & i ! = GT_TEAMPLAY & & i ! = GT_CTF & & i ! = GT_TEAM ) {
2005-09-13 02:33:17 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1Invalid gametype. Valid gametypes are 0(dm), 3(tdm), 4(tp) and 5(ctb). \n \" " ) ;
2002-06-02 00:13:39 +00:00
return ;
2002-05-12 19:15:47 +00:00
}
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
Com_sprintf ( level . voteString , sizeof ( level . voteString ) , " %s %d " , arg1 , i ) ;
Com_sprintf ( level . voteDisplayString , sizeof ( level . voteDisplayString ) , " %s %s " , arg1 , gameNames [ i ] ) ;
} else if ( ! Q_stricmp ( arg1 , " map " ) ) {
2001-05-06 20:50:27 +00:00
// special case for map changes, we want to reset the nextmap setting
// this allows a player to change maps, but not upset the map rotation
2003-03-28 13:05:18 +00:00
if ( ! G_FileExists ( va ( " maps/%s.bsp " , arg2 ) ) ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" ^1The map %s does not exist. \n \" " , arg2 ) ) ;
2002-06-18 09:23:23 +00:00
return ;
}
2002-07-16 04:08:28 +00:00
// NiceAss: Talk to NiceAss before you fix this crappy hack =)
2003-03-28 13:05:18 +00:00
if ( ! G_FileSearch ( va ( " scripts/%s.arena " , arg2 ) , " rq3ctb " ) & & g_gametype . integer = = GT_CTF ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" ^1The map %s does not support CTB. \n \" " , arg2 ) ) ;
2002-07-16 04:08:28 +00:00
return ;
}
2002-06-23 03:04:09 +00:00
Com_sprintf ( level . voteString , sizeof ( level . voteString ) , " %s " , arg1 ) ;
Com_sprintf ( level . voteMap , sizeof ( level . voteMap ) , " %s " , arg2 ) ;
Com_sprintf ( level . voteDisplayString , sizeof ( level . voteDisplayString ) , " %s %s " , level . voteString , level . voteMap ) ;
2005-09-13 02:33:17 +00:00
} else if ( ! Q_stricmp ( arg1 , " game " ) ) {
// JBravo: adding new game vote. Syntax: gametype:map
if ( ! strchr ( arg2 , ' : ' ) ) {
trap_SendServerCommand ( ent - g_entities , " print \" ^1Invalid vote string. Usage: gametype:map \n \" " ) ;
return ;
}
v_gametype = strtok ( arg2 , " : " ) ;
v_map = strtok ( NULL , " : " ) ;
2002-06-23 03:04:09 +00:00
2005-09-13 02:33:17 +00:00
if ( is_digit ( v_gametype [ 0 ] ) ) {
i = atoi ( v_gametype ) ;
} else {
if ( ! Q_stricmp ( v_gametype , " dm " ) ) {
i = GT_FFA ;
} else if ( ! Q_stricmp ( v_gametype , " tp " ) ) {
i = GT_TEAMPLAY ;
} else if ( ! Q_stricmp ( v_gametype , " tdm " ) ) {
i = GT_TEAM ;
} else if ( ! Q_stricmp ( v_gametype , " ctb " ) ) {
i = GT_CTF ;
} else {
//if not a preset name, consider it an error
i = 999 ;
}
}
trap_SendServerCommand ( ent - g_entities , va ( " print \" ^1v_map = %s, v_gametype = %s, i = %d \n \" " , v_map , v_gametype , i ) ) ;
if ( i ! = GT_FFA & & i ! = GT_TEAMPLAY & & i ! = GT_CTF & & i ! = GT_TEAM ) {
trap_SendServerCommand ( ent - g_entities , " print \" ^1Invalid gametype. Valid gametypes are 0(dm), 3(tdm), 4(tp) and 5(ctb). \n \" " ) ;
return ;
}
if ( ! G_FileExists ( va ( " maps/%s.bsp " , v_map ) ) ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" ^1The map %s does not exist. \n \" " , v_map ) ) ;
return ;
}
switch ( i ) {
case GT_FFA :
if ( ! G_FileSearch ( va ( " scripts/%s.arena " , v_map ) , " rq3dm " ) ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" ^1The map %s does not support DM. \n \" " , v_map ) ) ;
return ;
}
break ;
case GT_TEAMPLAY :
if ( ! G_FileSearch ( va ( " scripts/%s.arena " , v_map ) , " rq3tp " ) ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" ^1The map %s does not support TP. \n \" " , v_map ) ) ;
return ;
}
break ;
case GT_TEAM :
if ( ! G_FileSearch ( va ( " scripts/%s.arena " , v_map ) , " rq3tdm " ) ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" ^1The map %s does not support TDM. \n \" " , v_map ) ) ;
return ;
}
break ;
case GT_CTF :
if ( ! G_FileSearch ( va ( " scripts/%s.arena " , v_map ) , " rq3ctb " ) ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" ^1The map %s does not support CTB. \n \" " , v_map ) ) ;
return ;
}
break ;
default :
trap_SendServerCommand ( ent - g_entities , " print \" ^1Invalid gametype. Valid gametypes are 0(dm), 3(tdm), 4(tp) and 5(ctb). \n \" " ) ;
return ;
}
Com_sprintf ( level . voteString , sizeof ( level . voteString ) , " %s " , arg1 ) ;
Com_sprintf ( level . voteMap , sizeof ( level . voteMap ) , " %s " , v_map ) ;
level . voteGametype = i ;
Com_sprintf ( level . voteDisplayString , sizeof ( level . voteDisplayString ) , " %s on %s " , gameNames [ i ] , level . voteMap ) ;
2002-06-18 03:57:38 +00:00
} else if ( ! Q_stricmp ( arg1 , " cyclemap " ) ) {
Com_sprintf ( level . voteString , sizeof ( level . voteString ) , " cyclemap " ) ;
2002-06-16 20:06:15 +00:00
Com_sprintf ( level . voteDisplayString , sizeof ( level . voteDisplayString ) , " %s " , level . voteString ) ;
2003-03-28 13:05:18 +00:00
} else if ( ! Q_strncmp ( arg1 , " kick " , 4 ) ) {
kicked = getEntByName ( arg2 ) ;
if ( kicked & & kicked - > client ) {
kickNum = kicked - > client - level . clients ;
Com_sprintf ( level . voteString , sizeof ( level . voteString ) , " clientkick \" %i \" " , kickNum ) ;
Com_sprintf ( level . voteDisplayString , sizeof ( level . voteDisplayString ) , " %s \" %s \" " , arg1 , arg2 ) ;
} else {
Com_sprintf ( level . voteString , sizeof ( level . voteString ) , " %s \" %s \" " , arg1 , arg2 ) ;
Com_sprintf ( level . voteDisplayString , sizeof ( level . voteDisplayString ) , " %s " , level . voteString ) ;
}
2001-05-06 20:50:27 +00:00
} else {
2002-06-16 20:06:15 +00:00
Com_sprintf ( level . voteString , sizeof ( level . voteString ) , " %s \" %s \" " , arg1 , arg2 ) ;
Com_sprintf ( level . voteDisplayString , sizeof ( level . voteDisplayString ) , " %s " , level . voteString ) ;
2001-05-06 20:50:27 +00:00
}
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( - 1 , va ( " print \" %s^7 called a vote. \n \" " , ent - > client - > pers . netname ) ) ;
2001-05-06 20:50:27 +00:00
2014-05-03 22:47:46 +00:00
// start the voting, the caller automatically votes yes
2001-05-06 20:50:27 +00:00
level . voteTime = level . time ;
level . voteYes = 1 ;
level . voteNo = 0 ;
2002-06-16 20:06:15 +00:00
for ( i = 0 ; i < level . maxclients ; i + + ) {
2001-05-06 20:50:27 +00:00
level . clients [ i ] . ps . eFlags & = ~ EF_VOTED ;
}
ent - > client - > ps . eFlags | = EF_VOTED ;
2002-08-13 16:59:16 +00:00
//Makro - added
ent - > client - > pers . voteCount + + ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
trap_SetConfigstring ( CS_VOTE_TIME , va ( " %i " , level . voteTime ) ) ;
trap_SetConfigstring ( CS_VOTE_STRING , level . voteDisplayString ) ;
trap_SetConfigstring ( CS_VOTE_YES , va ( " %i " , level . voteYes ) ) ;
trap_SetConfigstring ( CS_VOTE_NO , va ( " %i " , level . voteNo ) ) ;
2001-05-06 20:50:27 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
Cmd_Vote_f
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_Vote_f ( gentity_t * ent )
{
char msg [ 64 ] ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( ! level . voteTime ) {
trap_SendServerCommand ( ent - g_entities , " print \" No vote in progress. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( ent - > client - > ps . eFlags & EF_VOTED ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1Vote already cast. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-02 00:13:39 +00:00
//Makro - allow spectators to vote in TP
2002-09-30 01:32:30 +00:00
if ( ent - > client - > sess . sessionTeam = = TEAM_SPECTATOR & & g_gametype . integer < GT_TEAM ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1Not allowed to vote as spectator. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-08-07 20:49:21 +00:00
//Slicer Matchmode
if ( g_RQ3_matchmode . integer & & ent - > client - > sess . captain = = TEAM_FREE ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1Only team Captains vote. \n \" " ) ;
2002-08-07 20:49:21 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" Vote cast. \n \" " ) ;
2001-05-06 20:50:27 +00:00
ent - > client - > ps . eFlags | = EF_VOTED ;
2002-06-16 20:06:15 +00:00
trap_Argv ( 1 , msg , sizeof ( msg ) ) ;
2001-05-06 20:50:27 +00:00
2013-07-21 23:15:13 +00:00
if ( tolower ( msg [ 0 ] ) = = ' y ' | | msg [ 0 ] = = ' 1 ' ) {
2001-05-06 20:50:27 +00:00
level . voteYes + + ;
2002-06-16 20:06:15 +00:00
trap_SetConfigstring ( CS_VOTE_YES , va ( " %i " , level . voteYes ) ) ;
2001-05-06 20:50:27 +00:00
} else {
level . voteNo + + ;
2002-06-16 20:06:15 +00:00
trap_SetConfigstring ( CS_VOTE_NO , va ( " %i " , level . voteNo ) ) ;
2001-05-06 20:50:27 +00:00
}
// a majority will be determined in CheckVote, which will also account
// for players entering or leaving
}
/*
= = = = = = = = = = = = = = = = = =
Cmd_CallTeamVote_f
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_CallTeamVote_f ( gentity_t * ent )
{
int i , team , cs_offset ;
char arg1 [ MAX_STRING_TOKENS ] ;
char arg2 [ MAX_STRING_TOKENS ] ;
2001-05-06 20:50:27 +00:00
2002-06-17 03:22:58 +00:00
// JBravo: not wanted for TP
2002-10-26 22:03:43 +00:00
if ( g_gametype . integer > = GT_TEAM )
2002-06-17 03:22:58 +00:00
return ;
2001-05-06 20:50:27 +00:00
team = ent - > client - > sess . sessionTeam ;
2002-06-16 20:06:15 +00:00
if ( team = = TEAM_RED )
2001-05-06 20:50:27 +00:00
cs_offset = 0 ;
2002-06-16 20:06:15 +00:00
else if ( team = = TEAM_BLUE )
2001-05-06 20:50:27 +00:00
cs_offset = 1 ;
else
return ;
2002-06-16 20:06:15 +00:00
if ( ! g_allowVote . integer ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1Voting not allowed here. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( level . teamVoteTime [ cs_offset ] ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1A team vote is already in progress. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-08-13 16:59:16 +00:00
//Makro - replaced the constant with a cvar
if ( ent - > client - > pers . teamVoteCount > = g_RQ3_maxClientVotes . integer ) {
//Makro - added cvar info
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities ,
2003-02-27 03:58:35 +00:00
va ( " print \" ^1You have called the maximum number of team votes (%i). \n \" " , g_RQ3_maxClientVotes . integer ) ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( ent - > client - > sess . sessionTeam = = TEAM_SPECTATOR ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1Not allowed to call a vote as spectator. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
2002-06-16 20:06:15 +00:00
}
2001-05-06 20:50:27 +00:00
// make sure it is a valid command to vote on
2002-06-16 20:06:15 +00:00
trap_Argv ( 1 , arg1 , sizeof ( arg1 ) ) ;
2001-05-06 20:50:27 +00:00
arg2 [ 0 ] = ' \0 ' ;
2002-06-16 20:06:15 +00:00
for ( i = 2 ; i < trap_Argc ( ) ; i + + ) {
2001-05-06 20:50:27 +00:00
if ( i > 2 )
strcat ( arg2 , " " ) ;
2002-06-16 20:06:15 +00:00
trap_Argv ( i , & arg2 [ strlen ( arg2 ) ] , sizeof ( arg2 ) - strlen ( arg2 ) ) ;
2001-05-06 20:50:27 +00:00
}
2002-06-16 20:06:15 +00:00
if ( strchr ( arg1 , ' ; ' ) | | strchr ( arg2 , ' ; ' ) ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1Invalid vote string. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2001-11-15 07:06:33 +00:00
2002-06-16 20:06:15 +00:00
if ( ! Q_stricmp ( arg1 , " leader " ) ) {
2001-05-06 20:50:27 +00:00
char netname [ MAX_NETNAME ] , leader [ MAX_NETNAME ] ;
2002-06-16 20:06:15 +00:00
if ( ! arg2 [ 0 ] ) {
2001-05-06 20:50:27 +00:00
i = ent - > client - > ps . clientNum ;
2002-06-16 20:06:15 +00:00
} else {
2001-05-06 20:50:27 +00:00
// numeric values are just slot numbers
for ( i = 0 ; i < 3 ; i + + ) {
2002-06-16 20:06:15 +00:00
if ( ! arg2 [ i ] | | arg2 [ i ] < ' 0 ' | | arg2 [ i ] > ' 9 ' )
2001-05-06 20:50:27 +00:00
break ;
}
2002-06-16 20:06:15 +00:00
if ( i > = 3 | | ! arg2 [ i ] ) {
i = atoi ( arg2 ) ;
if ( i < 0 | | i > = level . maxclients ) {
trap_SendServerCommand ( ent - g_entities ,
2003-02-27 03:58:35 +00:00
va ( " print \" ^1Bad client slot: %i \n \" " , i ) ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( ! g_entities [ i ] . inuse ) {
trap_SendServerCommand ( ent - g_entities ,
2003-02-27 03:58:35 +00:00
va ( " print \" ^1Client %i is not active \n \" " , i ) ) ;
2002-06-16 20:06:15 +00:00
return ;
}
} else {
2001-05-06 20:50:27 +00:00
Q_strncpyz ( leader , arg2 , sizeof ( leader ) ) ;
Q_CleanStr ( leader ) ;
2002-06-16 20:06:15 +00:00
for ( i = 0 ; i < level . maxclients ; i + + ) {
if ( level . clients [ i ] . pers . connected = = CON_DISCONNECTED )
2001-05-06 20:50:27 +00:00
continue ;
if ( level . clients [ i ] . sess . sessionTeam ! = team )
continue ;
Q_strncpyz ( netname , level . clients [ i ] . pers . netname , sizeof ( netname ) ) ;
Q_CleanStr ( netname ) ;
2002-06-16 20:06:15 +00:00
if ( ! Q_stricmp ( netname , leader ) ) {
2001-05-06 20:50:27 +00:00
break ;
}
}
2002-06-16 20:06:15 +00:00
if ( i > = level . maxclients ) {
trap_SendServerCommand ( ent - g_entities ,
2003-02-27 03:58:35 +00:00
va ( " print \" ^1%s is not a valid player on your team. \n \" " ,
2002-06-16 20:06:15 +00:00
arg2 ) ) ;
2001-05-06 20:50:27 +00:00
return ;
}
}
}
Com_sprintf ( arg2 , sizeof ( arg2 ) , " %d " , i ) ;
} else {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" ^1Invalid vote string. \n \" " ) ;
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" Team vote commands are: leader <player>. \n \" " ) ;
return ;
}
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
Com_sprintf ( level . teamVoteString [ cs_offset ] , sizeof ( level . teamVoteString [ cs_offset ] ) , " %s %s " , arg1 , arg2 ) ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
for ( i = 0 ; i < level . maxclients ; i + + ) {
if ( level . clients [ i ] . pers . connected = = CON_DISCONNECTED )
2001-05-06 20:50:27 +00:00
continue ;
if ( level . clients [ i ] . sess . sessionTeam = = team )
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( i ,
va ( " print \" %s^7 called a team vote. \n \" " , ent - > client - > pers . netname ) ) ;
2001-05-06 20:50:27 +00:00
}
2014-05-03 22:47:46 +00:00
// start the voting, the caller automatically votes yes
2001-05-06 20:50:27 +00:00
level . teamVoteTime [ cs_offset ] = level . time ;
level . teamVoteYes [ cs_offset ] = 1 ;
level . teamVoteNo [ cs_offset ] = 0 ;
2002-06-16 20:06:15 +00:00
for ( i = 0 ; i < level . maxclients ; i + + ) {
2001-05-06 20:50:27 +00:00
if ( level . clients [ i ] . sess . sessionTeam = = team )
level . clients [ i ] . ps . eFlags & = ~ EF_TEAMVOTED ;
2002-06-16 20:06:15 +00:00
}
2001-05-06 20:50:27 +00:00
ent - > client - > ps . eFlags | = EF_TEAMVOTED ;
2002-08-13 16:59:16 +00:00
//Makro - added
ent - > client - > pers . teamVoteCount + + ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
trap_SetConfigstring ( CS_TEAMVOTE_TIME + cs_offset , va ( " %i " , level . teamVoteTime [ cs_offset ] ) ) ;
trap_SetConfigstring ( CS_TEAMVOTE_STRING + cs_offset , level . teamVoteString [ cs_offset ] ) ;
trap_SetConfigstring ( CS_TEAMVOTE_YES + cs_offset , va ( " %i " , level . teamVoteYes [ cs_offset ] ) ) ;
trap_SetConfigstring ( CS_TEAMVOTE_NO + cs_offset , va ( " %i " , level . teamVoteNo [ cs_offset ] ) ) ;
2001-05-06 20:50:27 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
Cmd_TeamVote_f
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_TeamVote_f ( gentity_t * ent )
{
int team , cs_offset ;
char msg [ 64 ] ;
2001-05-06 20:50:27 +00:00
team = ent - > client - > sess . sessionTeam ;
2002-06-16 20:06:15 +00:00
if ( team = = TEAM_RED )
2001-05-06 20:50:27 +00:00
cs_offset = 0 ;
2002-06-16 20:06:15 +00:00
else if ( team = = TEAM_BLUE )
2001-05-06 20:50:27 +00:00
cs_offset = 1 ;
else
return ;
2002-06-16 20:06:15 +00:00
if ( ! level . teamVoteTime [ cs_offset ] ) {
trap_SendServerCommand ( ent - g_entities , " print \" No team vote in progress. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( ent - > client - > ps . eFlags & EF_TEAMVOTED ) {
trap_SendServerCommand ( ent - g_entities , " print \" Team vote already cast. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( ent - > client - > sess . sessionTeam = = TEAM_SPECTATOR ) {
trap_SendServerCommand ( ent - g_entities , " print \" Not allowed to vote as spectator. \n \" " ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , " print \" Team vote cast. \n \" " ) ;
2001-05-06 20:50:27 +00:00
ent - > client - > ps . eFlags | = EF_TEAMVOTED ;
2002-06-16 20:06:15 +00:00
trap_Argv ( 1 , msg , sizeof ( msg ) ) ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( msg [ 0 ] = = ' y ' | | msg [ 1 ] = = ' Y ' | | msg [ 1 ] = = ' 1 ' ) {
2001-05-06 20:50:27 +00:00
level . teamVoteYes [ cs_offset ] + + ;
2002-06-16 20:06:15 +00:00
trap_SetConfigstring ( CS_TEAMVOTE_YES + cs_offset , va ( " %i " , level . teamVoteYes [ cs_offset ] ) ) ;
2001-05-06 20:50:27 +00:00
} else {
level . teamVoteNo [ cs_offset ] + + ;
2002-06-16 20:06:15 +00:00
trap_SetConfigstring ( CS_TEAMVOTE_NO + cs_offset , va ( " %i " , level . teamVoteNo [ cs_offset ] ) ) ;
}
2001-05-06 20:50:27 +00:00
// a majority will be determined in TeamCheckVote, which will also account
// for players entering or leaving
}
/*
= = = = = = = = = = = = = = = = =
Cmd_SetViewpos_f
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_SetViewpos_f ( gentity_t * ent )
{
vec3_t origin , angles ;
char buffer [ MAX_TOKEN_CHARS ] ;
int i ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( ! g_cheats . integer ) {
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" ^1Cheats are not enabled on this server. \n \" " ) ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( trap_Argc ( ) ! = 5 ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" usage: setviewpos x y z yaw \n \" " ) ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
VectorClear ( angles ) ;
for ( i = 0 ; i < 3 ; i + + ) {
trap_Argv ( i + 1 , buffer , sizeof ( buffer ) ) ;
origin [ i ] = atof ( buffer ) ;
2001-05-06 20:50:27 +00:00
}
2002-06-16 20:06:15 +00:00
trap_Argv ( 4 , buffer , sizeof ( buffer ) ) ;
angles [ YAW ] = atof ( buffer ) ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
TeleportPlayer ( ent , origin , angles ) ;
2001-05-06 20:50:27 +00:00
}
/*
= = = = = = = = = = = = = = = = =
Cmd_Stats_f
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_Stats_f ( gentity_t * ent )
{
2001-05-06 20:50:27 +00:00
}
2002-06-16 20:06:15 +00:00
2001-05-06 20:50:27 +00:00
/*
= = = = = = = = = = = = = = = = =
Cmd_Bandage
Added by Blaze
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_Bandage ( gentity_t * ent )
2001-05-06 20:50:27 +00:00
{
2001-09-11 00:12:29 +00:00
if ( ent - > client - > ps . pm_type = = PM_SPECTATOR )
return ;
2001-06-12 19:29:46 +00:00
//Elder: added so you can't "rebandage"
2002-03-18 19:19:08 +00:00
if ( ent - > client - > ps . weaponstate = = WEAPON_BANDAGING ) {
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" You are already bandaging! \n \" " ) ) ;
2001-06-12 19:29:46 +00:00
return ;
}
2002-03-18 13:32:53 +00:00
if ( ( ent - > client - > ps . stats [ STAT_RQ3 ] & RQ3_BANDAGE_NEED ) = = RQ3_BANDAGE_NEED | |
2002-06-16 20:06:15 +00:00
( ent - > client - > ps . stats [ STAT_RQ3 ] & RQ3_LEGDAMAGE ) = = RQ3_LEGDAMAGE ) {
2001-06-18 01:59:58 +00:00
//Elder: remove zoom bits
2001-07-16 01:40:33 +00:00
Cmd_Unzoom ( ent ) ;
//Elder: drop the primed grenade
//Moved weapon switch to bg_pmove.c
2002-06-16 20:06:15 +00:00
if ( ent - > client - > ps . weapon = = WP_GRENADE & & ent - > client - > ps . weaponstate = = WEAPON_COCKED ) {
2001-07-16 01:40:33 +00:00
FireWeapon ( ent ) ;
ent - > client - > ps . ammo [ WP_GRENADE ] - - ;
2002-09-04 00:16:17 +00:00
//Makro - if this is the last grenade, remove the weapon from the inventory
if ( ent - > client - > ps . ammo [ WP_GRENADE ] < = 0 ) {
ent - > client - > ps . stats [ STAT_WEAPONS ] & = ~ ( 1 < < WP_GRENADE ) ;
}
2001-07-16 01:40:33 +00:00
}
2002-03-18 19:19:08 +00:00
//slicer
ent - > client - > ps . weaponstate = WEAPON_BANDAGING ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( ent - > client - > ps . weapon = = WP_KNIFE
& & ! ( ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & RQ3_KNIFEMODE ) ) {
ent - > client - > ps . generic1 = ( ( ent - > client - > ps . generic1 & ANIM_TOGGLEBIT )
^ ANIM_TOGGLEBIT ) | WP_ANIM_THROWDISARM ;
2002-03-18 13:32:53 +00:00
} else {
2002-06-16 20:06:15 +00:00
ent - > client - > ps . generic1 = ( ( ent - > client - > ps . generic1 & ANIM_TOGGLEBIT )
^ ANIM_TOGGLEBIT ) | WP_ANIM_DISARM ;
2001-10-30 23:26:03 +00:00
}
2001-08-06 19:15:00 +00:00
2001-09-01 16:14:14 +00:00
ent - > client - > ps . weaponTime + = BLEED_BANDAGE_TIME ;
2002-06-16 20:06:15 +00:00
ent - > client - > bleedtick = 4 ;
2005-09-13 03:32:03 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" You've started bandaging. \n \" " ) ) ;
2002-03-18 13:32:53 +00:00
} else {
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" No need to bandage. \n \" " ) ) ;
2001-05-06 20:50:27 +00:00
}
}
/*
= = = = = = = = = = = = = = = = = =
Opendoor Function
Added by Blaze
Checks to see if they are near a door , if so open it
= = = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_OpenDoor ( gentity_t * ent )
2001-05-06 20:50:27 +00:00
{
//Use_BinaryMover( ent->parent, ent, other );
2009-07-04 03:37:41 +00:00
// gentity_t *door = NULL;
2001-07-01 05:11:12 +00:00
2001-09-11 00:12:29 +00:00
//Don't open doors if dead or spectating
if ( ent - > client - > ps . stats [ STAT_HEALTH ] < = 0 | | ent - > client - > ps . pm_type = = PM_SPECTATOR )
2001-07-01 05:11:12 +00:00
return ;
2003-09-16 23:25:32 +00:00
//Makro - doesn't look right to me. Doing it one single time should be enough
/*
2002-06-16 20:06:15 +00:00
while ( ( door = findradius ( door , ent - > r . currentOrigin , 100 ) ) ! = NULL ) {
if ( Q_stricmp ( door - > classname , " func_door_rotating " ) = = 0 ) {
2001-05-06 20:50:27 +00:00
ent - > client - > openDoor = qtrue ;
2001-08-13 17:26:53 +00:00
ent - > client - > openDoorTime = level . time ;
2002-06-16 20:06:15 +00:00
} else if ( Q_stricmp ( door - > classname , " func_door " ) = = 0 ) {
2001-05-06 20:50:27 +00:00
ent - > client - > openDoor = qtrue ;
2001-08-13 17:26:53 +00:00
ent - > client - > openDoorTime = level . time ;
2001-05-06 20:50:27 +00:00
}
}
2003-09-16 23:25:32 +00:00
*/
ent - > client - > openDoor = qtrue ;
ent - > client - > openDoorTime = level . time ;
2001-05-06 20:50:27 +00:00
}
/* Hawkins. Reaction weapon command */
2002-06-16 20:06:15 +00:00
void Cmd_Weapon ( gentity_t * ent )
2001-05-06 20:50:27 +00:00
{
2002-06-16 20:06:15 +00:00
2005-02-15 16:33:39 +00:00
//Makro - this was a few lines below
2005-09-13 03:11:08 +00:00
if ( ! ent | | ! ent - > client | | ent - > client - > ps . pm_type = = PM_SPECTATOR )
2005-02-15 16:33:39 +00:00
return ;
2009-07-01 18:31:03 +00:00
//JBravo: lets make 100% sure no dead people unzoom
if ( ent - > health < = 0 )
return ;
2005-02-15 16:33:39 +00:00
2002-04-01 22:23:14 +00:00
ent - > client - > weapon_attempts - - ;
2002-06-16 20:06:15 +00:00
if ( ent - > client - > weapon_attempts < 0 )
2002-04-01 22:23:14 +00:00
ent - > client - > weapon_attempts = 0 ;
2002-06-16 20:06:15 +00:00
if ( ent - > client - > ps . weaponstate = = WEAPON_BANDAGING ) {
if ( ! ent - > client - > weapon_after_bandage_warned ) {
2002-04-01 22:23:14 +00:00
ent - > client - > weapon_after_bandage_warned = qtrue ;
2002-06-16 20:06:15 +00:00
G_SendClientSpec ( ent ,
va ( " print \" You'll get to your weapon when you are finished bandaging! \n \" " ) ) ;
2002-04-01 22:23:14 +00:00
}
ent - > client - > weapon_attempts + + ;
2001-06-18 01:59:58 +00:00
return ;
}
2002-04-01 22:23:14 +00:00
ent - > client - > weapon_after_bandage_warned = qfalse ;
2002-07-02 19:15:17 +00:00
2002-06-16 20:06:15 +00:00
if ( ent - > client - > ps . weaponstate = = WEAPON_RELOADING | |
ent - > client - > ps . weaponstate = = WEAPON_FIRING | |
ent - > client - > ps . weaponstate = = WEAPON_DROPPING | | ent - > client - > ps . weaponstate = = WEAPON_RAISING ) {
ent - > client - > weapon_attempts + + ;
2001-06-24 02:08:15 +00:00
return ;
2002-04-01 22:23:14 +00:00
}
2001-06-11 23:02:21 +00:00
//Elder: added brackets, and-ops and not-ops instead of logical ops
2002-06-16 20:06:15 +00:00
switch ( ent - > s . weapon ) {
2001-05-06 20:50:27 +00:00
case WP_SSG3000 :
2002-06-16 20:06:15 +00:00
if ( ( ent - > client - > ps . stats [ STAT_RQ3 ] & RQ3_ZOOM_LOW ) = = RQ3_ZOOM_LOW & &
( ent - > client - > ps . stats [ STAT_RQ3 ] & RQ3_ZOOM_MED ) = = RQ3_ZOOM_MED ) {
2001-06-18 01:59:58 +00:00
//Elder: zoom 1x
ent - > client - > ps . stats [ STAT_RQ3 ] & = ~ RQ3_ZOOM_LOW ;
ent - > client - > ps . stats [ STAT_RQ3 ] & = ~ RQ3_ZOOM_MED ;
2002-06-16 20:06:15 +00:00
} else if ( ( ent - > client - > ps . stats [ STAT_RQ3 ] & RQ3_ZOOM_MED ) = = RQ3_ZOOM_MED ) {
2001-06-18 01:59:58 +00:00
//Elder: zoom 6x
ent - > client - > ps . stats [ STAT_RQ3 ] | = RQ3_ZOOM_LOW ;
2002-06-16 20:06:15 +00:00
} else if ( ( ent - > client - > ps . stats [ STAT_RQ3 ] & RQ3_ZOOM_LOW ) = = RQ3_ZOOM_LOW ) {
2001-06-18 01:59:58 +00:00
//Elder: zoom 4x
ent - > client - > ps . stats [ STAT_RQ3 ] | = RQ3_ZOOM_MED ;
ent - > client - > ps . stats [ STAT_RQ3 ] & = ~ RQ3_ZOOM_LOW ;
2002-06-16 20:06:15 +00:00
} else {
2001-06-18 01:59:58 +00:00
//Elder: zoom 2x
ent - > client - > ps . stats [ STAT_RQ3 ] | = RQ3_ZOOM_LOW ;
}
2002-04-01 22:23:14 +00:00
G_Sound ( ent , CHAN_ITEM , G_SoundIndex ( " sound/misc/lens.wav " ) ) ;
2001-05-06 20:50:27 +00:00
break ;
case WP_PISTOL :
// semiauto toggle (increase accuracy)
2002-06-16 20:06:15 +00:00
if ( ( ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & RQ3_MK23MODE ) = = RQ3_MK23MODE ) {
2001-06-11 23:02:21 +00:00
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & = ~ RQ3_MK23MODE ;
2002-06-16 20:06:15 +00:00
G_SendClientSpec ( ent , va ( " print \" Switched to full automatic. \n \" " ) ) ;
} else {
2001-06-11 06:12:32 +00:00
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] | = RQ3_MK23MODE ;
2002-06-16 20:06:15 +00:00
G_SendClientSpec ( ent , va ( " print \" Switched to semi-automatic. \n \" " ) ) ;
2001-06-11 06:12:32 +00:00
}
2002-04-01 22:23:14 +00:00
G_Sound ( ent , CHAN_ITEM , G_SoundIndex ( " sound/misc/click.wav " ) ) ;
2001-05-06 20:50:27 +00:00
break ;
case WP_M4 :
// 3rb/full auto toggle
2002-06-16 20:06:15 +00:00
if ( ( ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & RQ3_M4MODE ) = = RQ3_M4MODE ) {
2001-06-11 23:02:21 +00:00
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & = ~ RQ3_M4MODE ;
2002-06-16 20:06:15 +00:00
G_SendClientSpec ( ent , va ( " print \" Switched to full automatic. \n \" " ) ) ;
} else {
2001-06-11 06:12:32 +00:00
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] | = RQ3_M4MODE ;
2002-06-16 20:06:15 +00:00
G_SendClientSpec ( ent , va ( " print \" Switched to 3 round burst. \n \" " ) ) ;
2001-06-11 06:12:32 +00:00
}
2002-04-01 22:23:14 +00:00
G_Sound ( ent , CHAN_ITEM , G_SoundIndex ( " sound/misc/click.wav " ) ) ;
2001-05-06 20:50:27 +00:00
break ;
case WP_MP5 :
// 3rb/full auto toggle
2002-06-16 20:06:15 +00:00
if ( ( ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & RQ3_MP5MODE ) = = RQ3_MP5MODE ) {
2001-06-11 23:02:21 +00:00
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & = ~ RQ3_MP5MODE ;
2002-06-16 20:06:15 +00:00
G_SendClientSpec ( ent , va ( " print \" Switched to full automatic. \n \" " ) ) ;
} else {
2001-06-11 06:12:32 +00:00
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] | = RQ3_MP5MODE ;
2002-06-16 20:06:15 +00:00
G_SendClientSpec ( ent , va ( " print \" Switched to 3 round burst. \n \" " ) ) ;
2001-06-11 06:12:32 +00:00
}
2002-04-01 22:23:14 +00:00
G_Sound ( ent , CHAN_ITEM , G_SoundIndex ( " sound/misc/click.wav " ) ) ;
2001-05-06 20:50:27 +00:00
break ;
case WP_KNIFE :
2001-12-17 15:08:34 +00:00
// NiceAss: weapon animation/state check before the mode switch.
2002-06-16 20:06:15 +00:00
if ( ent - > client - > ps . weaponstate ! = WEAPON_READY )
break ;
2001-12-17 15:08:34 +00:00
2001-05-06 20:50:27 +00:00
// toggle throwing/slashing
2002-06-16 20:06:15 +00:00
if ( ( ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & RQ3_KNIFEMODE ) = = RQ3_KNIFEMODE ) {
2001-06-10 06:46:06 +00:00
//Elder: added
2001-06-11 23:02:21 +00:00
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & = ~ RQ3_KNIFEMODE ;
2002-06-16 20:06:15 +00:00
G_SendClientSpec ( ent , va ( " print \" Switched to throwing. \n \" " ) ) ;
2001-12-17 15:08:34 +00:00
// Niceass: Animations added
ent - > client - > ps . weaponstate = WEAPON_MODECHANGE ;
ent - > client - > ps . weaponTime = 550 ;
2002-06-16 20:06:15 +00:00
ent - > client - > ps . generic1 =
( ( ent - > client - > ps . generic1 & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | WP_ANIM_EXTRA1 ;
} else {
2001-06-10 06:46:06 +00:00
//Elder: we're gonna use this to flag throw or slash with the knife
2001-06-11 06:12:32 +00:00
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] | = RQ3_KNIFEMODE ;
2002-06-16 20:06:15 +00:00
G_SendClientSpec ( ent , va ( " print \" Switched to slashing. \n \" " ) ) ;
2001-12-17 15:08:34 +00:00
// Niceass: Animations added
ent - > client - > ps . weaponstate = WEAPON_MODECHANGE ;
ent - > client - > ps . weaponTime = 550 ;
2002-06-16 20:06:15 +00:00
ent - > client - > ps . generic1 =
( ( ent - > client - > ps . generic1 & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | WP_ANIM_EXTRA2 ;
2001-06-10 06:46:06 +00:00
}
2001-05-06 20:50:27 +00:00
break ;
case WP_HANDCANNON :
// nothing
break ;
case WP_M3 :
// nothing
break ;
case WP_AKIMBO :
// nothing
break ;
case WP_GRENADE :
2002-02-26 03:46:53 +00:00
// JBravo: Fix for uninitialized grenade mode
if ( ( ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & RQ3_GRENSHORT ) = = 0 & &
2002-06-16 20:06:15 +00:00
( ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & RQ3_GRENMED ) = = 0 ) {
2002-02-26 03:46:53 +00:00
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] | = RQ3_GRENSHORT ;
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & = ~ RQ3_GRENMED ;
}
2001-05-06 20:50:27 +00:00
// short, medium, long throws
2002-06-16 20:06:15 +00:00
if ( ( ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & RQ3_GRENSHORT ) = = RQ3_GRENSHORT & & ( ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & RQ3_GRENMED ) = = RQ3_GRENMED ) { //Going into Short
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] | = RQ3_GRENSHORT ; //Set the short flag
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & = ~ RQ3_GRENMED ; //unset the med flag
2002-05-31 18:17:10 +00:00
G_SendClientSpec ( ent , va ( " print \" Grenade set for short range throw. \n \" " ) ) ;
2002-06-16 20:06:15 +00:00
} else if ( ( ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & RQ3_GRENSHORT ) = = RQ3_GRENSHORT ) { //Going into Med
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & = ~ RQ3_GRENSHORT ; //unset the short flag
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] | = RQ3_GRENMED ; //Set the med flag
2002-05-31 18:17:10 +00:00
G_SendClientSpec ( ent , va ( " print \" Grenade set for medium range throw. \n \" " ) ) ;
2002-06-16 20:06:15 +00:00
} else if ( ( ent - > client - > ps . persistant [ PERS_WEAPONMODES ] & RQ3_GRENMED ) = = RQ3_GRENMED ) { //Going into Long
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] | = RQ3_GRENSHORT ; //Set the short flag
ent - > client - > ps . persistant [ PERS_WEAPONMODES ] | = RQ3_GRENMED ; //Set the med flag
2002-05-31 18:17:10 +00:00
G_SendClientSpec ( ent , va ( " print \" Grenade set for long range throw. \n \" " ) ) ;
2001-06-11 23:02:21 +00:00
}
//Elder: added
else {
G_Printf ( " Cmd_Weapon_f: Received bad grenade toggle \n " ) ;
}
2001-05-06 20:50:27 +00:00
break ;
default :
break ;
}
2002-05-31 18:17:10 +00:00
//Makro - changed all the trap_SendServerCommand prints to G_SendClientSpec prints
//so that players spectating this client get his messages, too
2001-05-06 20:50:27 +00:00
}
2002-06-16 20:06:15 +00:00
2002-04-01 22:23:14 +00:00
//Slicer
2002-06-16 20:06:15 +00:00
void Cmd_New_Weapon ( gentity_t * ent )
{
2001-05-06 20:50:27 +00:00
2002-04-01 22:23:14 +00:00
ent - > client - > weapon_attempts + + ;
2002-06-16 20:06:15 +00:00
if ( ent - > client - > weapon_attempts = = 1 )
Cmd_Weapon ( ent ) ;
2002-04-01 22:23:14 +00:00
}
2001-06-08 04:47:30 +00:00
2001-05-06 20:50:27 +00:00
// Hawkins make sure spread comes back
2002-06-16 20:06:15 +00:00
void Cmd_Unzoom ( gentity_t * ent )
2001-07-16 01:40:33 +00:00
{
2005-02-15 16:33:39 +00:00
//Makro - if the client is dead or spectating, do nothing
2005-09-13 03:11:08 +00:00
if ( ! ent | | ! ent - > client | | ent - > client - > ps . pm_type = = PM_SPECTATOR )
2005-02-15 16:33:39 +00:00
return ;
2002-06-20 21:06:07 +00:00
// Freud, play zooming sounds for unzoom
if ( ent - > client - > ps . stats [ STAT_RQ3 ] & RQ3_ZOOM_LOW | |
ent - > client - > ps . stats [ STAT_RQ3 ] & RQ3_ZOOM_MED )
G_Sound ( ent , CHAN_ITEM , G_SoundIndex ( " sound/misc/lens.wav " ) ) ;
2002-06-16 20:06:15 +00:00
ent - > client - > ps . stats [ STAT_RQ3 ] & = ~ RQ3_ZOOM_LOW ;
ent - > client - > ps . stats [ STAT_RQ3 ] & = ~ RQ3_ZOOM_MED ;
2001-05-06 20:50:27 +00:00
}
2001-06-08 04:47:30 +00:00
2001-05-06 20:50:27 +00:00
/*
= = = = = = = = = = = = = = = = =
2001-07-28 14:12:11 +00:00
Cmd_DropWeapon_f XRAY FMJ
2001-05-06 20:50:27 +00:00
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_DropWeapon_f ( gentity_t * ent )
{
2001-11-15 07:06:33 +00:00
2001-09-11 00:12:29 +00:00
if ( ent - > client - > ps . pm_type = = PM_SPECTATOR )
return ;
2002-03-07 19:46:47 +00:00
// JBravo: no dropping stuff while bandaging. Fix dedicated to GoKu and JesterRace :)
2002-06-16 20:06:15 +00:00
if ( ent - > client - > ps . weaponstate = = WEAPON_BANDAGING ) {
trap_SendServerCommand ( ent - g_entities , va ( " print \" You are too busy bandaging... \n \" " ) ) ;
2002-03-07 19:46:47 +00:00
return ;
}
2001-11-11 07:24:27 +00:00
//Elder: remove zoom bits
2002-03-13 18:41:18 +00:00
Cmd_Unzoom ( ent ) ;
2001-11-11 07:24:27 +00:00
//Throwing away return value here; high precedence weapon drop
2002-06-16 20:06:15 +00:00
ThrowWeapon ( ent , qtrue ) ;
2001-05-06 20:50:27 +00:00
}
2001-07-28 14:12:11 +00:00
/*
= = = = = = = = = = = = = = = = =
Cmd_DropItem_f
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_DropItem_f ( gentity_t * ent )
2001-07-28 14:12:11 +00:00
{
2001-09-11 00:12:29 +00:00
if ( ent - > client - > ps . pm_type = = PM_SPECTATOR )
return ;
2002-03-07 19:46:47 +00:00
// JBravo: no dropping stuff while bandaging. Fix dedicated to GoKu and JesterRace :)
2002-06-17 16:57:39 +00:00
// Turns out they are full of shit... :)
/* if (ent->client->ps.weaponstate == WEAPON_BANDAGING) {
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" You are too busy bandaging... \n \" " ) ) ;
2002-03-07 19:46:47 +00:00
return ;
2002-06-17 16:57:39 +00:00
} */
2002-03-07 19:46:47 +00:00
2002-06-16 20:06:15 +00:00
if ( ent - > client - > ps . stats [ STAT_HOLDABLE_ITEM ] ) {
2001-07-28 14:12:11 +00:00
//Elder: reset item totals if using bandolier
2002-10-26 00:37:18 +00:00
//JBravo: New multiple items code.
if ( ent - > client - > ps . stats [ STAT_HOLDABLE_ITEM ] & ( 1 < < HI_BANDOLIER ) ) {
2002-06-16 20:06:15 +00:00
if ( ent - > client - > numClips [ WP_SSG3000 ] > RQ3_SSG3000_EXTRA_AMMO )
ent - > client - > numClips [ WP_SSG3000 ] = RQ3_SSG3000_EXTRA_AMMO ;
2003-03-29 18:53:41 +00:00
if ( ent - > client - > numClips [ WP_M3 ] > RQ3_M3_MAXCLIP )
ent - > client - > numClips [ WP_M3 ] = RQ3_M3_MAXCLIP ;
if ( ent - > client - > numClips [ WP_HANDCANNON ] > RQ3_M3_MAXCLIP )
ent - > client - > numClips [ WP_HANDCANNON ] = RQ3_M3_MAXCLIP ;
2002-06-16 20:06:15 +00:00
if ( ent - > client - > numClips [ WP_M4 ] > RQ3_M4_EXTRA_AMMO )
ent - > client - > numClips [ WP_M4 ] = RQ3_M4_EXTRA_AMMO ;
if ( ent - > client - > numClips [ WP_MP5 ] > RQ3_MP5_EXTRA_AMMO )
ent - > client - > numClips [ WP_MP5 ] = RQ3_MP5_EXTRA_AMMO ;
2003-03-29 18:53:41 +00:00
if ( ent - > client - > ps . ammo [ WP_KNIFE ] > RQ3_KNIVES_EXTRA_AMMO ) {
ent - > client - > ps . ammo [ WP_KNIFE ] = RQ3_KNIVES_EXTRA_AMMO ;
ent - > client - > weaponCount [ WP_KNIFE ] = RQ3_KNIVES_EXTRA_AMMO ;
}
2002-06-16 20:06:15 +00:00
if ( ent - > client - > numClips [ WP_AKIMBO ] > RQ3_AKIMBO_EXTRA_AMMO )
ent - > client - > numClips [ WP_AKIMBO ] = RQ3_AKIMBO_EXTRA_AMMO ;
2003-03-30 00:36:03 +00:00
if ( ent - > client - > ps . ammo [ WP_GRENADE ] > 2 )
2003-03-29 18:53:41 +00:00
ent - > client - > ps . ammo [ WP_GRENADE ] = 2 ;
2002-06-16 20:06:15 +00:00
if ( ent - > client - > numClips [ WP_PISTOL ] > 1 )
ent - > client - > numClips [ WP_PISTOL ] = 1 ;
if ( ent - > client - > uniqueWeapons > g_RQ3_maxWeapons . integer ) {
Cmd_Unzoom ( ent ) ;
ThrowWeapon ( ent , qtrue ) ;
}
2001-07-28 14:12:11 +00:00
}
2001-08-01 18:28:38 +00:00
//Force laser off
2002-10-26 00:37:18 +00:00
else if ( ent - > client - > ps . stats [ STAT_HOLDABLE_ITEM ] & ( 1 < < HI_LASER ) )
2001-07-28 14:12:11 +00:00
Laser_Gen ( ent , qfalse ) ;
2002-06-16 20:06:15 +00:00
ThrowItem ( ent ) ;
2001-07-28 14:12:11 +00:00
}
}
2002-06-16 20:06:15 +00:00
2001-08-03 22:46:49 +00:00
/*
= = = = = = = = = = = = = = = = =
PlayerStats
= = = = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
void Cmd_PlayerStats_f ( gentity_t * ent )
2001-08-03 22:46:49 +00:00
{
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , va ( " print \" %s^7: \n \" " , ent - > client - > pers . netname ) ) ;
trap_SendServerCommand ( ent - g_entities , va ( " print \" ---------------------------------- \n \" " ) ) ;
trap_SendServerCommand ( ent - g_entities , va ( " print \" | Weapon | Accuracy | Hits/Shots | \n \" " ) ) ;
trap_SendServerCommand ( ent - g_entities , va ( " print \" ---------------------------------- \n \" " ) ) ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" | Knife(T)| %.0f | %.0f/%.0f \n \" " ,
( 100 * ( float ) ent - > client - > pers . records [ REC_KNIFETHROWHITS ] /
( ent - > client - > pers . records [ REC_KNIFETHROWSHOTS ] ? ent - > client - > pers .
records [ REC_KNIFETHROWSHOTS ] : 1 ) ) ,
( float ) ent - > client - > pers . records [ REC_KNIFETHROWHITS ] ,
( float ) ent - > client - > pers . records [ REC_KNIFETHROWSHOTS ] ) ) ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" | MK23 | %.0f | %.0f/%.0f \n \" " ,
( 100 * ( float ) ent - > client - > pers . records [ REC_MK23HITS ] /
( ent - > client - > pers . records [ REC_MK23SHOTS ] ? ent - > client - > pers .
records [ REC_MK23SHOTS ] : 1 ) ) , ( float ) ent - > client - > pers . records [ REC_MK23HITS ] ,
( float ) ent - > client - > pers . records [ REC_MK23SHOTS ] ) ) ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" | Akimbo | %.0f | %.0f/%.0f \n \" " ,
( 100 * ( float ) ent - > client - > pers . records [ REC_AKIMBOHITS ] /
( ent - > client - > pers . records [ REC_AKIMBOSHOTS ] ? ent - > client - > pers .
records [ REC_AKIMBOSHOTS ] : 1 ) ) , ( float ) ent - > client - > pers . records [ REC_AKIMBOHITS ] ,
( float ) ent - > client - > pers . records [ REC_AKIMBOSHOTS ] ) ) ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" | M4 | %.0f | %.0f/%.0f \n \" " ,
( 100 * ( float ) ent - > client - > pers . records [ REC_M4HITS ] /
( ent - > client - > pers . records [ REC_M4SHOTS ] ? ent - > client - > pers .
records [ REC_M4SHOTS ] : 1 ) ) , ( float ) ent - > client - > pers . records [ REC_M4HITS ] ,
( float ) ent - > client - > pers . records [ REC_M4SHOTS ] ) ) ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" | MP5 | %.0f | %.0f/%.0f \n \" " ,
( 100 * ( float ) ent - > client - > pers . records [ REC_MP5HITS ] /
( ent - > client - > pers . records [ REC_MP5SHOTS ] ? ent - > client - > pers .
records [ REC_MP5SHOTS ] : 1 ) ) , ( float ) ent - > client - > pers . records [ REC_MP5HITS ] ,
( float ) ent - > client - > pers . records [ REC_MP5SHOTS ] ) ) ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" | M3 | %.0f | %.0f/%.0f \n \" " ,
( 100 * ( float ) ent - > client - > pers . records [ REC_M3HITS ] /
( ent - > client - > pers . records [ REC_M3SHOTS ] ? ent - > client - > pers .
records [ REC_M3SHOTS ] : 1 ) ) , ( float ) ent - > client - > pers . records [ REC_M3HITS ] ,
( float ) ent - > client - > pers . records [ REC_M3SHOTS ] ) ) ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" | HC | %.0f | %.0f/%.0f \n \" " ,
( 100 * ( float ) ent - > client - > pers . records [ REC_HANDCANNONHITS ] /
( ent - > client - > pers . records [ REC_HANDCANNONSHOTS ] ? ent - > client - > pers .
records [ REC_HANDCANNONSHOTS ] : 1 ) ) ,
( float ) ent - > client - > pers . records [ REC_HANDCANNONHITS ] ,
( float ) ent - > client - > pers . records [ REC_HANDCANNONSHOTS ] ) ) ;
trap_SendServerCommand ( ent - g_entities ,
va ( " print \" | SSG | %.0f | %.0f/%.0f \n \" " ,
( 100 * ( float ) ent - > client - > pers . records [ REC_SSG3000HITS ] /
( ent - > client - > pers . records [ REC_SSG3000SHOTS ] ? ent - > client - > pers .
records [ REC_SSG3000SHOTS ] : 1 ) ) , ( float ) ent - > client - > pers . records [ REC_SSG3000HITS ] ,
( float ) ent - > client - > pers . records [ REC_SSG3000SHOTS ] ) ) ;
trap_SendServerCommand ( ent - g_entities , va ( " print \" ---------------------------------- \n \" " ) ) ;
2001-08-03 22:46:49 +00:00
}
2001-05-06 20:50:27 +00:00
2011-03-30 20:36:00 +00:00
void G_SetSunFlare ( const vec3_t dir , int size , float alpha ) ;
void Cmd_TestSunFlare_f ( gentity_t * ent )
{
vec3_t dir ;
int size = 0 ;
float alpha = 0.f ;
char arg [ 64 ] ;
if ( ! CheatsOk ( ent ) | | ! ent - > client | | ! ent - > client - > pers . localClient )
return ;
if ( trap_Argc ( ) > = 2 )
{
trap_Argv ( 1 , arg , sizeof ( arg ) ) ;
size = atoi ( arg ) ;
}
if ( trap_Argc ( ) > = 3 )
{
trap_Argv ( 2 , arg , sizeof ( arg ) ) ;
alpha = atof ( arg ) ;
}
if ( size < = 0 )
size = 256 ;
if ( alpha < = 0.f )
alpha = 0.75f ;
AngleVectors ( ent - > client - > ps . viewangles , dir , NULL , NULL ) ;
G_SetSunFlare ( dir , size , alpha ) ;
}
2001-05-06 20:50:27 +00:00
/*
= = = = = = = = = = = = = = = = =
ClientCommand
= = = = = = = = = = = = = = = = =
*/
2002-02-02 16:34:02 +00:00
2002-06-16 20:06:15 +00:00
void ClientCommand ( int clientNum )
{
2001-05-06 20:50:27 +00:00
gentity_t * ent ;
2002-06-16 20:06:15 +00:00
char cmd [ MAX_TOKEN_CHARS ] ;
2001-05-06 20:50:27 +00:00
ent = g_entities + clientNum ;
2012-10-04 15:49:55 +00:00
if ( ! ent - > client | | ent - > client - > pers . connected ! = CON_CONNECTED ) {
2001-05-06 20:50:27 +00:00
return ; // not fully in game yet
}
2002-06-16 20:06:15 +00:00
trap_Argv ( 0 , cmd , sizeof ( cmd ) ) ;
2001-05-06 20:50:27 +00:00
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " say " ) = = 0 ) {
Cmd_Say_f ( ent , SAY_ALL , qfalse ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " say_team " ) = = 0 ) {
Cmd_Say_f ( ent , SAY_TEAM , qfalse ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " tell " ) = = 0 ) {
Cmd_Tell_f ( ent ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " vsay " ) = = 0 ) {
Cmd_Voice_f ( ent , SAY_ALL , qfalse , qfalse ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " vsay_team " ) = = 0 ) {
Cmd_Voice_f ( ent , SAY_TEAM , qfalse , qfalse ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " vtell " ) = = 0 ) {
Cmd_VoiceTell_f ( ent , qfalse ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " vosay " ) = = 0 ) {
Cmd_Voice_f ( ent , SAY_ALL , qfalse , qtrue ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " vosay_team " ) = = 0 ) {
Cmd_Voice_f ( ent , SAY_TEAM , qfalse , qtrue ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " votell " ) = = 0 ) {
Cmd_VoiceTell_f ( ent , qtrue ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " vtaunt " ) = = 0 ) {
Cmd_VoiceTaunt_f ( ent ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " score " ) = = 0 ) {
Cmd_Score_f ( ent ) ;
2001-05-06 20:50:27 +00:00
return ;
}
2002-06-16 20:06:15 +00:00
if ( Q_stricmp ( cmd , " wstats " ) = = 0 ) {
Cmd_WeaponStats_f ( ent ) ;
2002-02-28 05:42:31 +00:00
return ;
}
2001-05-06 20:50:27 +00:00
// ignore all other commands when at intermission
if ( level . intermissiontime ) {
2002-06-03 05:56:04 +00:00
// JBravo: this is just simply way out there.
2002-06-16 20:06:15 +00:00
// Cmd_Say_f (ent, qfalse, qtrue);
return ;
}
if ( Q_stricmp ( cmd , " give " ) = = 0 )
Cmd_Give_f ( ent ) ;
else if ( Q_stricmp ( cmd , " god " ) = = 0 )
Cmd_God_f ( ent ) ;
else if ( Q_stricmp ( cmd , " notarget " ) = = 0 )
Cmd_Notarget_f ( ent ) ;
else if ( Q_stricmp ( cmd , " noclip " ) = = 0 )
Cmd_Noclip_f ( ent ) ;
else if ( Q_stricmp ( cmd , " kill " ) = = 0 )
Cmd_Kill_f ( ent ) ;
else if ( Q_stricmp ( cmd , " teamtask " ) = = 0 )
Cmd_TeamTask_f ( ent ) ;
else if ( Q_stricmp ( cmd , " levelshot " ) = = 0 )
Cmd_LevelShot_f ( ent ) ;
2007-02-03 15:02:21 +00:00
// JBravo: no limchasecam cheating...
// else if (Q_stricmp(cmd, "follow") == 0)
// Cmd_Follow_f(ent);
2002-06-16 20:06:15 +00:00
else if ( Q_stricmp ( cmd , " follownext " ) = = 0 )
Cmd_FollowCycle_f ( ent , 1 ) ;
else if ( Q_stricmp ( cmd , " followprev " ) = = 0 )
Cmd_FollowCycle_f ( ent , - 1 ) ;
else if ( Q_stricmp ( cmd , " team " ) = = 0 )
Cmd_Team_f ( ent ) ;
else if ( Q_stricmp ( cmd , " where " ) = = 0 )
Cmd_Where_f ( ent ) ;
else if ( Q_stricmp ( cmd , " callvote " ) = = 0 )
Cmd_CallVote_f ( ent ) ;
else if ( Q_stricmp ( cmd , " vote " ) = = 0 )
Cmd_Vote_f ( ent ) ;
else if ( Q_stricmp ( cmd , " callteamvote " ) = = 0 )
Cmd_CallTeamVote_f ( ent ) ;
else if ( Q_stricmp ( cmd , " teamvote " ) = = 0 )
Cmd_TeamVote_f ( ent ) ;
else if ( Q_stricmp ( cmd , " gc " ) = = 0 )
Cmd_GameCommand_f ( ent ) ;
else if ( Q_stricmp ( cmd , " setviewpos " ) = = 0 )
Cmd_SetViewpos_f ( ent ) ;
else if ( Q_stricmp ( cmd , " stats " ) = = 0 )
Cmd_Stats_f ( ent ) ;
else if ( Q_stricmp ( cmd , " playerlist " ) = = 0 )
Cmd_Playerlist_f ( ent ) ;
2002-02-02 16:34:02 +00:00
//Slicer: matchmode
2002-06-16 20:06:15 +00:00
else if ( Q_stricmp ( cmd , " captain " ) = = 0 )
MM_Captain_f ( ent ) ;
else if ( Q_stricmp ( cmd , " ready " ) = = 0 )
MM_Ready_f ( ent ) ;
else if ( Q_stricmp ( cmd , " sub " ) = = 0 )
MM_Sub_f ( ent ) ;
else if ( Q_stricmp ( cmd , " teamname " ) = = 0 )
2002-04-07 12:49:53 +00:00
MM_TeamName_f ( ent ) ;
2002-06-16 20:06:15 +00:00
else if ( Q_stricmp ( cmd , " teammodel " ) = = 0 )
2002-04-28 11:03:46 +00:00
MM_TeamModel_f ( ent ) ;
2002-06-16 20:06:15 +00:00
else if ( Q_stricmp ( cmd , " referee " ) = = 0 )
2002-05-12 12:15:05 +00:00
MM_Referee_f ( ent ) ;
2002-07-04 04:20:41 +00:00
else if ( Q_stricmp ( cmd , " settings " ) = = 0 )
MM_Settings_f ( ent ) ;
2002-03-07 00:00:54 +00:00
// aasimon: referee for MM
2002-06-16 20:06:15 +00:00
else if ( Q_stricmp ( cmd , " reflogin " ) = = 0 )
Ref_Auth ( ent ) ;
else if ( Q_stricmp ( cmd , " ref " ) = = 0 )
Ref_Command ( ent ) ;
else if ( Q_stricmp ( cmd , " refresign " ) = = 0 )
Ref_Resign ( ent ) ;
2001-05-06 20:50:27 +00:00
// Begin Duffman
2002-06-16 20:06:15 +00:00
else if ( Q_stricmp ( cmd , " reload " ) = = 0 ) {
2001-08-30 09:47:39 +00:00
//Cmd_Reload( ent );
2001-05-06 20:50:27 +00:00
// End Duffman
//Blaze's Open door command
2002-07-02 19:15:17 +00:00
} else if ( Q_stricmp ( cmd , " opendoor " ) = = 0 )
2002-06-16 20:06:15 +00:00
Cmd_OpenDoor ( ent ) ;
2001-05-06 20:50:27 +00:00
//Blaze: Bandage code
2002-06-16 20:06:15 +00:00
else if ( Q_stricmp ( cmd , " bandage " ) = = 0 )
Cmd_Bandage ( ent ) ;
2001-05-06 20:50:27 +00:00
//End Blaze
2001-11-15 07:06:33 +00:00
// Hawkins
2002-06-16 20:06:15 +00:00
else if ( Q_stricmp ( cmd , " weapon " ) = = 0 )
Cmd_New_Weapon ( ent ) ;
else if ( Q_stricmp ( cmd , " unzoom " ) = = 0 )
Cmd_Unzoom ( ent ) ;
2001-05-06 20:50:27 +00:00
// end hawkins
2002-01-11 20:20:58 +00:00
// JBravo: adding the choose and drop commands.
2002-06-16 20:06:15 +00:00
else if ( Q_stricmp ( cmd , " choose " ) = = 0 )
RQ3_Cmd_Choose_f ( ent ) ;
else if ( Q_stricmp ( cmd , " drop " ) = = 0 )
RQ3_Cmd_Drop_f ( ent ) ;
else if ( Q_stricmp ( cmd , " use " ) = = 0 )
RQ3_Cmd_Use_f ( ent ) ;
2002-03-14 02:24:39 +00:00
// JBravo: adding radio
2002-06-16 20:06:15 +00:00
else if ( Q_stricmp ( cmd , " radiogender " ) = = 0 )
RQ3_Cmd_Radiogender_f ( ent ) ;
else if ( Q_stricmp ( cmd , " radio_power " ) = = 0 )
RQ3_Cmd_Radio_power_f ( ent ) ;
else if ( Q_stricmp ( cmd , " radio " ) = = 0 )
RQ3_Cmd_Radio_f ( ent ) ;
else if ( Q_stricmp ( cmd , " dropweapon " ) = = 0 ) // XRAY FMJ
Cmd_DropWeapon_f ( ent ) ;
2002-05-10 04:06:27 +00:00
// JBravo: adding ignore
2002-06-16 20:06:15 +00:00
else if ( Q_stricmp ( cmd , " ignorenum " ) = = 0 )
Cmd_Ignorenum_f ( ent ) ;
2002-06-23 23:32:29 +00:00
else if ( Q_stricmp ( cmd , " unignorenum " ) = = 0 )
Cmd_Ignorenum_f ( ent ) ;
2002-06-16 20:06:15 +00:00
else if ( Q_stricmp ( cmd , " ignore " ) = = 0 )
Cmd_Ignore_f ( ent ) ;
else if ( Q_stricmp ( cmd , " unignore " ) = = 0 )
Cmd_Unignore_f ( ent ) ;
else if ( Q_stricmp ( cmd , " clearignorelist " ) = = 0 )
Cmd_Ignoreclear_f ( ent ) ;
2002-04-26 03:39:34 +00:00
// JBravo: adding tkok
2002-06-16 20:06:15 +00:00
else if ( Q_stricmp ( cmd , " tkok " ) = = 0 )
RQ3_Cmd_TKOk ( ent ) ;
2003-04-09 02:00:43 +00:00
// else if (Q_stricmp(cmd, "debugshit") == 0)
// RQ3_Cmd_debugshit(ent);
2001-07-28 14:12:11 +00:00
//Elder: stuff for dropping items
2002-06-16 20:06:15 +00:00
else if ( Q_stricmp ( cmd , " dropitem " ) = = 0 )
Cmd_DropItem_f ( ent ) ;
else if ( Q_stricmp ( cmd , " camera " ) = = 0 )
camera_cmd ( ent ) ;
2002-07-02 19:15:17 +00:00
else if ( Q_stricmp ( cmd , " playerstats " ) = = 0 )
2002-06-16 20:06:15 +00:00
Cmd_PlayerStats_f ( ent ) ;
2011-03-30 20:36:00 +00:00
else if ( Q_stricmp ( cmd , " testSunFlare " ) = = 0 )
Cmd_TestSunFlare_f ( ent ) ;
2002-07-02 19:15:17 +00:00
else if ( Q_stricmp ( cmd , " SendCheatCvars " ) = = 0 ) {
if ( ! G_SendCheatVars ( clientNum ) )
2002-06-12 22:32:24 +00:00
Com_Printf ( " Error loading cvar cfg \n " ) ;
2002-07-02 19:15:17 +00:00
} else
2003-02-27 03:58:35 +00:00
trap_SendServerCommand ( clientNum , va ( " print \" ^1unknown cmd ^7%s \n \" " , cmd ) ) ;
2001-05-06 20:50:27 +00:00
}
2001-08-13 17:26:53 +00:00
/*
= = = = = = = = = = = = = = =
RQ3_ValidateSay
Added by Elder
Ensure that the client is not spamming because we need
sv_floodProtect off for fast reloads and what - not .
It ' s not perfect ( ideally we ' d cut them off in cgame
but messagemodes by - pass it ) , but at least it prevents
spam from reaching other clients .
= = = = = = = = = = = = = = =
*/
2002-06-16 20:06:15 +00:00
int RQ3_ValidateSay ( gentity_t * ent )
2001-08-13 17:26:53 +00:00
{
2002-07-02 19:15:17 +00:00
int timeCheck , warnTime , banTime ;
int intervalTime , maxWarnings , maxMessages ;
2001-11-15 07:06:33 +00:00
2001-08-17 20:48:18 +00:00
if ( g_RQ3_messageProtect . integer = = 0 )
return SAY_OK ;
// Check for good cvar values and set them to defaults if bad
// We use local vars because the cvars may not update in time for use
// message count
2002-06-16 20:06:15 +00:00
if ( g_RQ3_messageMaxCount . integer < 0 ) {
2001-08-17 20:48:18 +00:00
maxMessages = atoi ( SAY_MAX_NUMBER ) ;
2002-06-16 20:06:15 +00:00
trap_Cvar_Set ( " sv_RQ3_messageMaxCount " , SAY_MAX_NUMBER ) ;
} else
2001-08-17 20:48:18 +00:00
maxMessages = g_RQ3_messageMaxCount . integer ;
// warning time
2002-06-16 20:06:15 +00:00
if ( g_RQ3_messageWarnTime . integer < 0 ) {
2001-08-17 20:48:18 +00:00
warnTime = atoi ( SAY_WARNING_TIME ) ;
2002-06-16 20:06:15 +00:00
trap_Cvar_Set ( " sv_RQ3_messageWarnTime " , SAY_WARNING_TIME ) ;
} else
2001-08-17 20:48:18 +00:00
warnTime = g_RQ3_messageWarnTime . integer ;
// max warnings
2002-06-16 20:06:15 +00:00
if ( g_RQ3_messageMaxWarnings . integer < 0 ) {
2001-08-17 20:48:18 +00:00
maxWarnings = atoi ( SAY_MAX_WARNINGS ) ;
2002-06-16 20:06:15 +00:00
trap_Cvar_Set ( " sv_RQ3_messageMaxWarnings " , SAY_MAX_WARNINGS ) ;
} else
2001-08-17 20:48:18 +00:00
maxWarnings = g_RQ3_messageMaxWarnings . integer ;
2001-08-13 17:26:53 +00:00
2001-08-17 20:48:18 +00:00
// ban time
2002-06-16 20:06:15 +00:00
if ( g_RQ3_messageBanTime . integer < 0 ) {
2001-08-17 20:48:18 +00:00
banTime = atoi ( SAY_BAN_TIME ) ;
2002-06-16 20:06:15 +00:00
trap_Cvar_Set ( " sv_RQ3_messageBanTime " , SAY_BAN_TIME ) ;
} else
2001-08-17 20:48:18 +00:00
banTime = g_RQ3_messageBanTime . integer ;
// interval time
2002-06-16 20:06:15 +00:00
if ( g_RQ3_messageInterval . integer < 0 ) {
2001-08-17 20:48:18 +00:00
intervalTime = atoi ( SAY_PERIOD_TIME ) ;
2002-06-16 20:06:15 +00:00
trap_Cvar_Set ( " sv_RQ3_messageInterval " , SAY_PERIOD_TIME ) ;
} else
2001-08-17 20:48:18 +00:00
intervalTime = g_RQ3_messageInterval . integer ;
// seconds to milliseconds
2002-06-16 20:06:15 +00:00
if ( ent - > client - > pers . sayWarnings ) {
2001-08-17 20:48:18 +00:00
timeCheck = warnTime * 1000 ;
2002-06-16 20:06:15 +00:00
} else {
2001-08-17 20:48:18 +00:00
timeCheck = banTime * 1000 ;
}
2001-08-13 17:26:53 +00:00
// check if already warned/banned
2002-06-16 20:06:15 +00:00
if ( ent - > client - > pers . sayMuteTime & & level . time - ent - > client - > pers . sayMuteTime < timeCheck ) {
2001-08-13 17:26:53 +00:00
if ( ent - > client - > pers . sayWarnings )
return SAY_WARNING ;
else
return SAY_BAN ;
}
// check if a flooder
2002-06-16 20:06:15 +00:00
if ( ent - > client - > pers . sayCount > = maxMessages & & level . time - ent - > client - > pers . sayTime < intervalTime * 1000 ) {
2001-08-13 17:26:53 +00:00
ent - > client - > pers . sayMuteTime = level . time ;
2001-11-15 07:06:33 +00:00
2001-08-13 17:26:53 +00:00
// determine penalty level
2002-06-16 20:06:15 +00:00
if ( ent - > client - > pers . sayWarnings > = maxWarnings ) {
2001-08-13 17:26:53 +00:00
// bans never reset, but warnings do
ent - > client - > pers . sayBans + + ;
ent - > client - > pers . sayWarnings = 0 ;
2001-11-15 07:06:33 +00:00
2001-08-17 20:48:18 +00:00
// kick if no ban time is set
if ( banTime = = 0 )
trap_DropClient ( ent - > s . clientNum , " Dropped due to chat abuse " ) ;
2001-08-13 17:26:53 +00:00
return SAY_BAN ;
2002-06-16 20:06:15 +00:00
} else {
2001-08-13 17:26:53 +00:00
ent - > client - > pers . sayWarnings + + ;
return SAY_WARNING ;
}
}
// regular say check
2002-06-16 20:06:15 +00:00
if ( level . time - ent - > client - > pers . sayTime > intervalTime * 1000 ) {
2001-08-13 17:26:53 +00:00
ent - > client - > pers . sayCount = 0 ;
ent - > client - > pers . sayTime = level . time ;
ent - > client - > pers . sayMuteTime = 0 ;
2001-08-17 20:48:18 +00:00
ent - > client - > pers . sayModerated = qfalse ;
2001-08-13 17:26:53 +00:00
}
ent - > client - > pers . sayCount + + ;
2001-11-15 07:06:33 +00:00
2001-08-13 17:26:53 +00:00
return SAY_OK ;
}
2002-05-31 18:17:10 +00:00
//Makro - this function sends print commands to the client and the ones spectating him
2002-06-16 20:06:15 +00:00
void G_SendClientSpec ( gentity_t * ent , const char * msg )
2002-05-31 18:17:10 +00:00
{
int i ;
2002-06-16 20:06:15 +00:00
if ( ! ent )
return ;
if ( ! ent - > client )
return ;
2002-05-31 18:17:10 +00:00
2002-06-16 20:06:15 +00:00
trap_SendServerCommand ( ent - g_entities , msg ) ;
2002-05-31 18:17:10 +00:00
for ( i = 0 ; i < level . maxclients ; i + + ) {
2002-06-16 20:06:15 +00:00
gclient_t * follower = & level . clients [ i ] ;
2002-05-31 18:17:10 +00:00
//no need to send the message twice
2002-06-16 20:06:15 +00:00
if ( i = = ent - g_entities )
2002-05-31 18:17:10 +00:00
continue ;
if ( follower - > pers . connected ! = CON_CONNECTED )
continue ;
if ( follower - > sess . sessionTeam ! = TEAM_SPECTATOR )
continue ;
if ( follower - > sess . spectatorState ! = SPECTATOR_FOLLOW )
continue ;
//gotcha !
2002-06-16 20:06:15 +00:00
if ( follower - > sess . spectatorClient = = ent - g_entities )
trap_SendServerCommand ( i , msg ) ;
2002-05-31 18:17:10 +00:00
}
}