Title    : Kasuha's DeathMatch Camera
Version  : 1.7
Filename : kascam17.zip
Date     : 25 May 1997
Author   : Karel Suhajda aka KASUHA
Email    : suhajda@serverpha.czcom.cz

Note     : this patch is based on DMCAM and QCAM patches
           I also dug something in Threewave CTF

Note II  : forgive my english, actually I am czech :-)

Type of Mod
-----------
Progs.dat: yes
Sound    : no
MDL      : no
BSP      : no
QC       : YES!!!

Time spent: about 50 hours

--------------------------------------------------------------------------------
* Credits

- Id software for Quake
- Rogier R. Mulhuijzen for DMCAM and its sources
- Paul Jordan for QCAM and its sources
- Threewave CTF authors for CTF sources
- The NecroRaisers clan for betatesting
- All you who send me suggestions and help :-)

--------------------------------------------------------------------------------
* Introduction

I have seen some demos done using DMCAM and QCAM and I got the idea to do it
a better way.

--------------------------------------------------------------------------------
* Installation

Put the progs.dat in a sub-dir of the server's quake-directory (kascam for
example).

--------------------------------------------------------------------------------
* How to use the patch

Start up the server with -game <kascam's dir>. If you called the dir "kascam"
you would type:

quake -game kascam

Next, change the name of the client you want to use as the camera into
"CamClient". When that client connects it is automaticaly turned into the
camera. It is a good idea to run the camera on a listen server.
You can also turn normal player to camera using "IMPULSE 250" without
renaming.
If you don't want to see CamClient in results table, change its name to ""

There is only one camera allowed at one time.

--------------------------------------------------------------------------------
* How it works

The player turns to camera-man when his name is "CamClient" during connect or
when he types "impulse 250" on console. Only one camera is available.

The camera has eight working modes - five automatic and three manual.

o IDLE mode: camera flies randomly in the current room. This mode is used only
  when there is no live player in the level.
  When there appears any live player, camera enters the next mode:

o FLYBY mode: generates in the vicinity of targeted player and
  looks on him until he escapes round a corner or until he is too far
  away. Then a new camera is generated. When a player is near the camera
  (up to 200) and he is facing away, camera enters the next mode:

o FOLLOW mode: follows targeted player everywhere he goes. When the player
  disappears (thru a teleport or under/off water), camera switches to FLYBY.

o FIXED mode: used automatically from FLYBY mode when there is enough players
  visible at the same time. Tries to see as many players as possible, doesn't
  concentrate on single player. When here is less than two players visible
  for more than three seconds, camera searches for a new target. If this mode
  is entered automatically, it lasts no more than 15 seconds.

o DEATH mode: selected automatically when targeted player turns dead. Tracks
  dead body or head and focuses on it. Reports player's name and frag count.
  This mode is not manually selectible.

o HAND mode: camera is unmovable but you can look around using controls.

o FLY mode: 'flying' camera - can't go thru walls. Moves slowly.

o NOCLIP mode: figure yourself.


When a player is targeted, camera shows also his status - weapons, ammo, armor,
health, keys. It doesn't show items which change the view color (biosuit,
pentagram, ring, quad).

Camera reports a new "victim" by its name and frag count. This is reported
to camera only. You can turn it off.

When the camera selects a player, it pursuits him 60 seconds or until death
if it comes sooner :-) Camera swaps FLYBY/FOLLOW mode or can swap to FIXED
mode when there are many players visible. Camera goes to DEATH mode when its
target die.

The selected player is always a live player. Selecting criteria is randomly
selected from following possibilities:
20% most frags
20% most health (max damage player can bear, counting current health and armor)
60% random selection

The CamClient can also control the camera:

IMPULSE 100: Select automatically a new target.
IMPULSE 1xx: Select xx-th player in order they connected. Starts in FLYBY.
             (CamClient is not a player)
             Doesn't switch to a new target if it is dead or dying.
IMPULSE 18x: Store current camera position to memory x (0 to 9).
IMPULSE 19x: Restore camera position from memory x. Works only in
             non-automatic modes.
IMPULSE 200: Force FLYBY mode on current target (may immediately turn to
             FOLLOW) When no target is selected camera chooses a player
             nearest to the screen centre. When here is nobody visible
             nothing happens.
IMPULSE 201: Force FOLLOW mode on current target.
             When no target is selected camera chooses a player nearest to the
             screen centre. When here is nobody visible nothing happens.
IMPULSE 202: Force HAND mode. Also moves camera to the point it is aiming at
             (not if in FLYBY or FIXED mode).
             You can move camera in HAND mode using IMPULSE 202.
IMPULSE 203: Force FLY mode.
IMPULSE 204: Force NOCLIP mode.
IMPULSE 205: Force FIXED mode.
IMPULSE 210: Turn "NOW TAKING" and "R.I.P." messages off/on.
IMPULSE 211: Reports current camera position. Somebody wanted it...
IMPULSE 250: Turn to camera if here is no camera.

NOTE: Described IMPULSEs excluding IMPULSE 250 work for camera only.
      IMPULSE 250 works for non-cameras only.
      Standard impulses work for non-cameras only.

------------------------------------------------------------------------------
* Known bugs

- Camera may not have any good spot points in FOLLOW/FLYBY. Then it behaves
  like IDLE though a target is selected. This is *very* unlikely to happen.
- Camera sometimes loses contact with its target on a lift in FLYBY mode.
- Camera doesn't move to intermission spot during intermission.

I am not sure if these can be considered 'bugs'. I call it 'minor problems' ;-)

A real bug:
- Sometimes camera does "automatic centerview". Don't know why it happens.
  A workaround: enter both "+LOOKUP" and "+LOOKDOWN" at the console.
  This may interfere with manual modes.
  Really don't know how to remove this :-(

------------------------------------------------------------------------------
* short FAQ

Q: Can I use KasCam on single computer?
A: No. Well, you can, but you'll have nothing to take. KasCam is one player
   converted to camera so on single computer you'll have nobody to do any
   action. You can only make demo of monsters walking thru corridors :-)

Q: Can I use KasCam take my single-player game?
A: Yes, but you need two computers. One to play on and one for camera. You can
   start in coop and then turn the second player to camera.

Q: How can I remove CamClient from score table?
A: Change its name to "". You can do it both before or after starting the
   camera. If you do it before starting camera, you have to use IMPULSE 250
   to start the camera.

------------------------------------------------------------------------------
* Copyright and Distribution Permissions (I like these from DMCAM so here goes:)

Authors MAY use these modifications as a basis for other
publically available work, after all, I did.

You may distribute this Quake modification in any free electronic format
as long as this description file remains intact and unmodified and is
retained along with all of the files in the archive.

You may not publish or distribute this Quake modification in a non-free
form without the permission of the author.
This file contains my notes to QC programmers which intend to use KasCam
in their own QC patches

-------------------------------------------------------------------------------
QCNOTES.TXT

VERSION 1.7 WARNING: hooking points have changed again!!! You HAVE TO revise
them if you upgrade your patch from previous version. Three changes there.

VERSION 1.6 WARNING: hooking points have changed again! Well, it was my fault
that I didn't change them properly in 1.5 :-(

VERSION 1.5 WARNING: hooking points have changed! If you update your patch
using KasCam 1.0 you have to review all hooking points. I have cleaned DEFS.QC
also - it is just original now.

The only thing I used from DMCAM and QCAM is hooking method and some
initialization. Everything else is brand new.

CTF was digged for multi-string CENTERPRINT. It is nice, check it out :-)

The camera AI is in KASCAM.QC. Hooking points are in CLIENT.QC, WEAPONS.QC
and WORLD.QC marked by 'KasCam' keyword. PROGS.SRC is also changed. I decided
to include all QC's, however.

Marked areas can not be always simply removed. They may contain some original
functional code. Keywords only mark places that are 'messed with'.

I made comments every time I wasn't sure what I am really doing. So it is
possible that the most important parts are not commented at all... Sorry.

V1.06 sources were used. I also removed all the bugs known to me ('cells' bug
and 'fishes' bug). These changes are not marked.

I wanted to keep hooking points at the lowest possible count. So the "copy
status" sequence is performed every frame. I didn't notice any slowdown.

I don't know how to set "looking angle" more accurately than in 256 steps
per full circle resulting in "skipping" view. It seems that resulting demos
sometimes don't have this problem though.

There are problems with traceline function. trace_endpos ends in void space
sometimes so this point has also to be tested using pointcontents :-(

Water, sky, teleports and lava are a serious problem - they don't stop
traceline. If anybody knows how to find contents change (binary division is
not interesting method)...

I don't know how to make reports 'only for camera'. sprint(self,...) function
did serious problems so I used bprint.
