Commit Graph

236 Commits

Author SHA1 Message Date
Zack Middleton 51e9aa2df0 Fix hit accuracy stats for lightning gun and shotgun kills
If a lightning bolt killed a player or the first shotgun pellet that
hit a player killed them, the shot was not counted as accurate.

Check if shot player is alive for hit accuracy before dealing damage.
2017-09-29 18:54:57 -05:00
Zack Middleton c3e64d3806 Make bots only use q3tourney6 crusher to kill their enemy
Only use the crusher for killing the bot's enemy. This doesn't
affect 1v1 very much but prevents the whole team of bots in CTF
from suddenly shooting at the crusher button. Entering the crusher
bounds was basically instant death.
2017-08-28 21:46:58 -05:00
Zack Middleton ad1d0e616e Make bots use crusher on other q3tourney6 maps
Make bots activate crusher on q3tourney6_ctf and mpq3tourney6.

Check if player is inside the crush bounds instead of below the
crusher. There is a jumppad the goes under it in mpq3tourney6.
2017-08-28 21:46:57 -05:00
Zack Middleton e793c0c37c Fix crash when pmove_msec is 0
When pmove_fixed is set to 1, setting pmove_msec to 0 would crash.
2017-08-19 01:42:38 -05:00
Zack Middleton 9736e7ff91 Fix compiling Cmd_CallTeamVote_f 2017-08-09 19:19:59 -05:00
Zack Middleton 3f267728c3 Remove newlines from chat messages in Game VM
This has no affect due to ioquake3 engine already removing command
separators (which includes newlines) in Cmd_Args_Sanitize().
2017-08-09 18:41:26 -05:00
Zack Middleton f0b74a27c9 Check for all command separators in callTeamVote
Make callTeamVote check for all command separators like in callVote.
It's not exploitable as the only vote option (leader) always uses an
integer argument.

Also the ioquake3 engine remove command separators from client game
commands in Cmd_Args_Sanitize().
2017-08-09 18:37:18 -05:00
Zack Middleton 0bce5463f7 Add spawnflags to QUAKED for trigger_multiple 2017-08-09 17:47:33 -05:00
Zack Middleton c05fbe554e Make warmup in Team Deathmatch wait for players to join both teams
Reported by Cyrax.
2017-07-31 15:24:15 -05:00
Zack Middleton 39716745f9 Silence g_util.c warning about set but not read variable
Probably caused by my commit on June 2 2017.

  commit 4006358492
  Fix spawn/freed entity logic (specifically harvester skulls)
2017-07-28 17:36:20 -05:00
Zack Middleton 5f2e4a03c5 Add score bonus for defending the flag carrier in 1 Flag CTF
Set flag_pw to neutral flag instead of using CTF value for red or
blue flag so that flag carrier is detected correctly.
2017-07-14 19:06:43 -05:00
Zack Middleton 13831f9569 Restore not giving defense score bonus to flag carrier
The Team Arena code for giving defense bonus for fragging player
who recently damaged a skull carrier unintentionally applied to
the flag carrier.

The skull carrier case would of been handled by the flag carrier
block above it. However, Harvest mode doesn't call
Team_CheckHurtCarrier() so the skull carrier defense bonus does
not work.

This restores the pre-Team Arena behavior of not giving defense
score bonus to flag carrier.
2017-07-14 19:06:43 -05:00
Zack Middleton c8db6c55e5 Fix score bonus for defending the flag carrier in CTF
Fix copy-paste error in the original Quake 3 code. The wrong values
are used for v1 and v2. v2 was previously set to distance of attacker
to flag base; which should be handled already.

The game now gives defense score bonus to player when they frag an
enemy near their team's flag carrier while the player is more than
1000 units from the flag carrier.

This may also fix not giving defense bonus when near carrier due to
checking if carrier and enemy (instead of attacker) are in PVS.

Found by @Razish.
2017-07-14 19:06:43 -05:00
Zack Middleton b984dd4a23 Add range check for bot skill in addbot command
Adding a bot with skill of 0 doesn't show icon on hud.
2017-06-29 19:43:37 -05:00
Zack Middleton cabc32362c Don't pick duplicate random bots until all bot types are added
Don't add the same bot to multiple teams until there are as many
bots on the server as there are bot types.

Previously each team would have unique bots until all bot types
were added to the team but other teams may have the same bot. Now
there will not be any duplicate bots until there are more bots than
bot types.

Now Quake 3 (32 bot types) in 16 vs 16 bot CTF will not contain
duplicate bot types. (You have to increase memory in code/game/
g_mem.c in order to add 32 bots though.)

I had to change G_AddRandomBot() to use 'addbot random' or else the
same bot could be added to red and blue teams. The bot was selected
and stored in console command buffer so game doesn't know not to
select the bot again.
2017-06-29 19:41:17 -05:00
Zack Middleton 0999aff28d Fix duplicate (delayed) random bots being choosen
Count delayed bots when looking for least used bot infos for deciding
which bot to add.
2017-06-29 19:41:17 -05:00
Zack Middleton d8f2ff7a4b Check delayed bot's team when counting bots for bot_minplayers
note: This requires my previous commit that added teampref userinfo
so that bots choose correct team in ClientConnect.
2017-06-29 19:41:17 -05:00
Zack Middleton 7c601da651 Fix not adding random bot when all bot info are in use on team
If there are two bot infos in scripts/bots.txt then each team can
only add two random bots via bot_minplayers or addbot random.

Pick random bot info from least used bot infos instead of only ones
that are used by zero players. That way a random bot can always be
added to the game.

This rarely affected Quake 3 since there is 32 bot infos. It could
easily affect new games though.
2017-06-29 19:41:16 -05:00
Zack Middleton d0d1fe1b7c Fix bot_minplayers passing delay as team to addbot in non-team gametypes 2017-06-29 19:41:16 -05:00
Zack Middleton 51649695a5 Fix random bot not looking for bots by funname
Quake 3's Anarki bot has a 'funname' with colors in it.
This commit fixes Anarki not being detected as in use.
2017-06-29 19:41:16 -05:00
Zack Middleton 23a331c9f8 Make 'addbot random' command select a random bot info
It reuses the random bot selection code for bot_minplayers cvar.
2017-06-29 19:41:16 -05:00
Zack Middleton 007e250e11 Split G_AddRandomBot into multiple functions 2017-06-29 17:52:06 -05:00
Zack Middleton 03336dd0bf Allow spectators to use noclip cheat 2017-06-24 20:27:24 -05:00
Zack Middleton f19efb77c8 Fix Team Arena team base models not dropping to floor
Team Arena's Overload gametype has red and blue team Obelisk base
objects. It uses separate entities for visual and damage. Only the
damageable entity was dropped to floor. Leaving model floating off
the ground.

Team Arena's Harvester base has the same problem. Model entity
floats in air but trigger entity drops to floor.

Drop all Team Arena team base models to floor. Fixes CTF, 1Flag,
Overload, and Harvester base models.
2017-06-24 20:15:02 -05:00
Zack Middleton f7c3276fe8 Fix g_teamAutoJoin and g_teamForceBalance
There are various issues caused by not knowing the initial team for
the local client and bots when they connect. This is can be reproduced
by starting a team game from the main menu.

When g_teamAutoJoin is enabled, bots and local client join a random
team at connect and then execute their team command a few frames
later. This may result in the player being killed if they specify a
different team. In Team Arena's Harvester mode this causes harvester
skulls to be spawned at the beginning of the game.

When g_teamForceBalance is enabled, the local client and bots may not
be able to join their desired team. This may result in them being
spectators. If g_teamAutoJoin is also enabled they may be left on
the opposite (red/blue) team they were meant to join.

There is a hack for including bot's team in their player info string
(used by cgame for which team skin to use) before the bot joins
their desired team. Bots aren't guaranteed to join their desired team
(as may happen when both g_teamAutoJoin and g_teamForceBalance are
enabled) so clients may see them as being on the wrong team!

----

Add teampref userinfo option for team preference. If teampref is set
it will be used for attempting to join the team immediately at connect.

Bots now join team at connect using teampref userinfo. So remove
the hack for setting bot's team in player info string before the bot
joins the team.

To avoid the client sending teampref userinfo to all network servers,
the local client uses a g_localTeamPref cvar. The g_localTeamPref
cvar is cleared after it's used so it doesn't get used when starting
another server later. Another reason not to use a teampref userinfo
cvar is there isn't a reliable way to clear it in CGame/UI which are
likely loaded from baseq3 pk3.

Make it so g_teamAutoJoin doesn't affect clients who specify
teampref. If teampref is invalid, the client will join a random team
like g_teamAutoJoin.

Don't apply g_teamForceBalance to the local client or bots. Otherwise
they may be left as spectators when starting team game from menu.

The start server menus use team command and g_localTeamPref to set
the human player's team. This way it's compatible with vanilla Q3
game VMs and the new setting team at connect feature.
2017-06-22 21:56:20 -05:00
Tobias Kuehnhammer 8956ab41dd Fix notarget cheat
Bots no longer target players in 'no target mode'.
2017-06-07 21:27:33 -05:00
Zack Middleton c99281a0da Make bots stop attacking player after disconnect
Bots did not notice player disconnected, so they kept attacking
the last known position.

Checking if entity is valid in BotEntityVisible might fix other
similar issues too.
2017-06-07 21:11:52 -05:00
Zack Middleton 8a6c9d1038 Remove unneeded 'angles' variables/clearing in ai_dmq3.c 2017-06-07 21:06:28 -05:00
Zack Middleton 730b917059 Fix comment in BotAIPredictObstacles 2017-06-07 20:53:35 -05:00
Zack Middleton 5b9302a7ef Don't start game entity loops at index 1 2017-06-07 20:32:57 -05:00
Zack Middleton 71512bb1fd Show client's name in callvote clientkick vote display message
Make callvote always kick by client num so player can't rename to
avoid being kicked. Don't allow calling a vote to kick host or
non-existent players.
2017-06-07 20:24:10 -05:00
Zack Middleton eeb28dc1d0 Fix score info being dropped by server
Server drops reliable command string if it's length is more than 1022.
2017-06-07 19:55:36 -05:00
Zack Middleton 91acf8a681 Don't build score info for bots, they don't parse it 2017-06-07 19:54:34 -05:00
Zack Middleton b511b8f2f6 Fix Coverity warning that endVelocity is uninitialized 2017-06-07 19:51:32 -05:00
Zack Middleton 6e340f9a5b Don't use uninitialized ps from BotAI_GetClientState
If BotAI_GetPlayerState returns qfalse, ps is untouched and in
some cases means uninitialized. So don't use it if not valid.
2017-06-07 19:02:20 -05:00
Zack Middleton 74aa4268b2 Stop caching sv_maxclients in bot code 2017-06-07 19:00:28 -05:00
Zack Middleton 1066214548 Fix "brought in 1 skulls" Harvester message
Use correct singular/plural form of skulls for Harvester's brought in
skulls message.

Reported by Tobias.
2017-06-02 22:11:52 -05:00
Zack Middleton 4006358492 Fix spawn/freed entity logic (specifically harvester skulls)
- Actually use the second 'force' pass in G_Spawn when out of
available slots.
- Make G_EntitiesFree return qtrue if we can open a new slot.
(Only used when spawning Harvester skulls.)

Fixes not spawning Harvester skulls when there are no 'open freed
slots', but we have other slots available to open.
2017-06-02 22:11:52 -05:00
Zack Middleton 4227d97958 Make Team Arena win logic handle more game types/blue team
The Team Arena menu uses red team for single player but q3_ui
(and mods could) use blue. Also handle all the game types, not
just the ones used by Team Arena. Fixes FFA and Team DM.
2017-06-02 22:07:27 -05:00
Zack Middleton 4506ebd5d7 Fix joining team when starting local team play server
AKA fix joining team in Team Arena single player. Though it also
affects starting Q3 skirmish in team dm or ctf modes.
2017-06-02 21:07:30 -05:00
Zack Middleton 2c225a5a2b Merge pull request #199 from UniQP/typos
Fix some typos in comments
2017-05-24 13:41:15 -05:00
Zack Middleton 729766150f Don't start a vote after vote passed for map change
Processing a callvote command after a vote passed to change maps but
has not been executed yet will result in 1) map change immediately
happening 2) after new map loads players have vote HUD messages but
Game VM doesn't have a vote in progress. The phantom vote status will
only be removed if players start a new vote or run vid_restart.

The underlying issue is that a second callvote sets vote config
strings but a map change is executed before they are sent to clients.
Resulting in clients getting "cs" reliable commands with the config
string changes _after_ the map change. Out of sync config strings.

Even if the underlying issue was fixed, the second vote would be lost.
So it's best to not force a map change to happen immediately anyway.

Reported by Tobias Kuehnhammer.
2017-04-12 18:29:17 -05:00
Simon McVittie 2ab109b772 Avoid 'register' declarations
gcc 6 with -Wall -Wextra warns:

code/botlib/l_precomp.c: In function ‘PC_NameHash’:
code/botlib/l_precomp.c:551:2: warning: ‘register’ is not at beginning of declaration [-Wold-style-declaration]
  int register hash, i;
  ^~~

Modern compilers either ignore the register storage class when
generating code, or generate better code without it, so just remove
most of them.

The remaining uses are in third-party bundled libraries (libjpeg, zlib),
and in a PowerPC-specific inline function consisting of inline
assembler (because I'm not 100% confident that it doesn't have
some practical use there).
2016-11-01 16:37:38 +00:00
Simon McVittie 9c76b546e3 Pick up date from SOURCE_DATE_EPOCH, for reproducible builds
The goal of reproducible builds is that a rebuild of the same source
code with the same compiler, libraries, etc. should result in the same
binaries. SOURCE_DATE_EPOCH provides a standard way for build systems
to fill in the date of the latest source change, typically from a git
commit or from metadata like the debian/changelog in Debian packages.

This does not change anything if SOURCE_DATE_EPOCH is not defined;
the intention is that a larger build system like a Debian package
will define it.

Please see https://reproducible-builds.org/ for more information about
reproducible builds.
2016-09-22 09:02:20 +01:00
Thomas Köppe 3c8da8ca07 [game/ai_main.c] Use floating-point fabs() for floating-point values 2016-08-23 19:36:27 +01:00
Sebastian Buchwald 5eae6de2f4 Fix some typos in comments 2016-07-26 14:43:41 +02:00
Zack Middleton 4474297af8 Fix bot team order to kill last player it killed
Bot's lastkilledplayer was set to -1 after carrying out an ordered kill.
Later in BotChat_Random() the PlayerName function was passed -1 which
caused a "Error: PlayerName: playernum out of range" message.

I think the reason it was set to negative one is so that if the bot is
ordered to kill the player again, the bot will not say it's done and
drop the goal. Though, if the bot killed the player based on it's own
decision, it will just say it's done and drop the goal (bug?).

Let's check the time of the last kill to see if it happened since the
team order was received instead of setting lastkilledplayer to -1
after completing the team ordered kill. This fixes bot dropping goal
if target player was the last player they killed and the PlayerName
out of range error.
2016-07-11 05:20:36 -05:00
Zack Middleton 274fa898b1 Fix typo of empty in ai_main.c 2016-06-27 21:13:27 -05:00
Tobias Kuehnhammer 49ab0cc05e Fix (unused) watertype checks in PM_WaterMove 2015-07-30 19:33:28 -05:00
Zack Middleton 2292bf5bb2 Save bot accompany distance across map change or restart
If a bot is accompanying someone before map change or restart, the bot would
continue accompanying them but press up against them and orbit around them.
This is caused by the bot's formation distance being 0.

Save the formation distance so they maintain proper distance and do not
orbit around the player.
2015-04-30 17:19:00 -05:00