Title    : Frogbot physics
Filename : frogphys00.zip
Version  : Beta 0.0
Date     : 7 Jan 1998
Author   : Robert Field
Email    : frog@powerup.com.au
Credits  : id software

Build time: stuffing around on and off for a couple of weeks
	(mixed in between other parts of the Frogbot bot patch,
	which hasn't been released yet)


Type of Mod
-----------
Quake C  : yes
Sound    : yes, require the Pak0.pak file to blank out monster splashing
		and landing sounds
MDL      : no  


Format of QuakeC
----------------
.qc files     : yes
progs.dat     : yes


Description of the Modification
-------------------------------

The code of this mod is a subset of the Frogbot mod I am currently developing.
Essentially I have made MOVETYPE_WALK (ie. player physics model) out of
MOVETYPE_STEP (ie. monster physics model). This mod provides a player
physics model for people who wish to develop a bot for Quake (see
Copyright and Distribution Permissions below). The Frogbot is controlled
by arrow keys and jump and fire buttons just like a player uses. To my
knowledge the Frogbot virtually behaves exactly like a player (see
Technical details below).

To operate the bot use the following commands:
(I suggest you bind them to keys)

addbot - add a bot
botjump - make bot jump (push second time to release jump button)
botfire - make bot fire (push second time to stop firing)
botrj - make bot jump and fire simultaneously (push second time to stop)

botN - bot movement
botS
botE
botW
botNE
botNW
botSE
botSW
botstop - stops bot motion and mouse movement

botup - bot mouse movement
botdown
botleft
botright

botlook - toggles botlook mode. When in this mode all bots look in the
	same direction to the listen server player, and type in the same
	impulse keys to that player.

becomebot - become a bot
becomeplayer - become a player

framerate - toggles framerate display. The first number is smoothed
	framerate over the previous second. The second number corresponds
	to the number you get after running timedemo.


How to Install the Modification
-------------------------------

Create a directory called frogphys as a subdirectory in your Quake
directory and copy the Pak0.pak file included in this
archive to the frogphys directory. To play, type quake -listen 16
-game frogphys from the Quake directory. Don't forget the -listen 16.
Deathmatch 1, 2, and 3 are available while any other deathmatch gives
deathmatch 3.


Technical Details
-----------------
So how can I be sure that the physics in this mod replicate those of a
player? I painstakingly reverse-engineered the Quake MOVETYPE_WALK
physics model using bprint statements of things like self.origin,
self.velocity, self.flags, self.waterlevel, self.watertype, self.v_angle,
self.angles, self.teleport_time.
For example, you make the player face a certain direction and push
forward and record self.velocity for each frame. Then you derive an
initial acceleration formula. Then you make a player run forward, and
then push another arrow (easiest to do this by pausing first).
Physics related with water were the most difficult. There are subtleties
like gravity is calculated after PlayerPrethink when self.waterlevel >= 2,
but before PlayerPrethink otherwise. Also, the exact relation between
self.teleport_time and self.flags & FL_WATERJUMP had me confused for a
while (Set self.teleport_time = 0 at the end of PlayerPreThink and observer
getting out of water for a player). Also, the exact way waterlevel is
calculated took a while to work out.

So where in my mod does the bot not have exactly the same physics as a
player (ie. to all decimal places)?
There is a minor discrepancy with the bots walking up stairs, but I
doubt my implementation could be improved upon. The stepping
implementation is very safe with regard to clipping issues. As an
exercise get 15 Frogbots to run up the stairs and slopes in dm6 together. On
earlier implementations I had problems with the bots getting stuck through
each other and on walls, plus also falling through walls, when they stepped
in closed proximity.
In Quake, a player runs around as though he has sandpaper on his front, but
silk on his sides and back. This is due to some weird formula which the guys
at id used when a player is facing a wall (ie. within the 180 or so degree arc)
and tries to move into the wall. You don't feel wall friction when not
facing a wall. BTW, in Quake a player can move faster than sv_maxspeed
by looking along a wall and pushing the diagonal arrow key into the wall.
(Also, in an open space, it is possible to run faster than sv_maxspeed
if you push forward and rapidly toggle the side arrow keys. This is
because Quake only limits speed in the direction you are trying to
accelerate.)
My solution to the friction problem at this stage is to remove the
forward wall friction for players so they don't feel disadvantaged.


Things to try with the Frogbot (to visually test the physics)
-------------------------------------------------------------

Try running the bots on all the steps and slopes in dm6. Watch him slide down
the dm6 tube like a player. Make him run up the steep slope in the dm6
mega health room. Make him do the dm6 tube jump. Make him rocket jump.
Make him get out of the lava in the dm4 megahealth room by jumping.
Test out his swimming and getting out of water in dm3, by first using
the jump button, and then just by making him look up (the botlook
function is useful for setting the bots direction). Try out the teleporters.
Shoot the Frogbots with some rockets at their feet. Make the bots get
the quad in dm4 (in at least 3 ways). Put a bot with the rocket launcher at
the base of the steps near the double shotgun in dm4. Make him fire the rocket
at a wall and watch his momentum carry him up the steps. Get the yellow armor
in e1m2. Anything else that a player can do.


Author Information
------------------

This is my first publicly distributed quakeC patch.
I have written the "Game Choice Server" quakeworld mod which has been
used on a local dialup quake server to enable dial-in clients to vote
on things like map, powerups, etc (majority wins).
I will be doing a Graduate Diploma in Information Technology at QUT
(Brisbane, Australia) this year.
I am 25 years old.
I don't have my own web site because I've been too slack, and busy with
other things.


Copyright and Distribution Permissions
--------------------------------------

The modifications included in this archive are Copyright 1998, Robert Field.
The original QuakeC source is Copyright 1996, id software.

Authors MAY use these modifications as a basis for other publicly
available work, on condition that they acknowledge that they are using
my work by retaining the sprint statement "This mod uses the Frogbot physics
code, which was developed by Robert Field.". In addition, I require that
any publicly available work using my code include the QuakeC source of
their code, unless I grant otherwise.

You may distribute this Quake modification in any electronic format as long as
all the files in this archive remain intact and unmodified and are distributed
together.


Disclaimer
----------

Software under this agreement is under no kind of warranty. Software
under this agreement is provided as is, and isn't guaranteed in any way
by the mod author. Use this software at your own risk. 


Note for Authors using this mod
-------------------------------

Though a bot based on this mod can't cheat with regards to player physics,
it is recommended that the following be adhered to:
Use pitchaccel and yawaccel to change the bots viewing direction. Don't
change real_pitch and real_yaw directly, because the bot will look like
a machine.
Don't rapidly change arrow or mouse inputs (eg. to achieve faster bot
running speed, or a killer aim).
A real player's fingers and reflexes aren't that fast.
As a point of interest, the Frogbot mod which I will be releasing at a
later stage (when it's done) has an average of 5 thinks per second.
