Fighting
========

BabbleMUD server.

Author:  Nick Gammon 
          http://www.gammon.com.au/ 

Written: 25th August 2004.

(C) Copyright Nick Gammon 2004. Permission to copy, use, modify, sell and
distribute this document is granted provided this copyright notice appears
in all copies. 


Introduction
------------

Fighting will occur in rounds, each round being broken up into phases. The phases will be sequential for a particular player, but occur independently for each participant (Eg. player A fights player B, A is preparing a spell, B is dodging the last one).


Initial surprise
----------------

When a fight commences either or both parties may be surprised. This "surprise" phase will take a number of seconds, after which that party can commence to attack (or defend).

  * If two players come across each other in a dark room they both may be surprised
  * If one player sneaks up on another (eg. from behind) then only one might be surprised
  * If both see each other and are expecting a fight, neither might be surprised


Attack logic
------------

1. Prepare attack (eg. prepare to cast spell, fit arrow to bow): x seconds
  
   - During preparation phase, attacker will have lowered defence against an incoming attack
   
   - Preparation may fail due to chance, or maybe some effect (eg. 'silence' may prevent spells being cast)
   
   - Preparation may fail due to fright or other lack of initiative
   
   - Player may run away
   
   - Player may choose to block or increase defence at expense of launching attack
   
   - If preparation fails, go to recovery phase (recovery may be shorter for failed preparation compared to successful launch).


2. Launch attack (eg. cast spell, fire arrow)
   
   - Launch may fail due to an attack occuring (on the player) during the preparation phase, eg. they may now be stunned, silenced, asleep etc.

   - If launch fails, go to recovery phase

   - Once launched, the attack is "committed" and cannot be revoked. 
   
   - Some attacks may cause multiple launches (eg. multiple arrows, multiple knives)
   
   - At this stage the attack "costs" something (eg. one less arrow, less spell mana)
   
   - It would be possible for the attacker to die (or be knocked unconscious) at this stage, however the attack is still in progress and is still counted when it reaches its target
   
   
3. Attack now enters "in transit" phase (eg. arrow is in flight) and focus moves to the defender

   - "in transit" would be x seconds
   
   
4. Recovery (eg. recovery from effort involved): x seconds

   - Note that recovery time may be less than 'in transit' time, so it would be possible to launch a second attack before the first one reaches its target


5. Go to 1 to prepare another attack.


Defend
------

Once attack is launched by opponent ...

1. Dodge - during the "in transit" time the defender can attempt to dodge with x% success

2. Arrive or miss - when the "in transit" time elapses the attacking object (eg. arrow) arrives or misses

3. Miss - there will be a chance that the attack may simply miss (eg. badly-aimed arrow)

   - if so, defence phase ends

4. Parry or block - the defender may choose to block or parry with x% success. If effective, or partially effective, this will reduce the percentage of the effect of the attack.

   - if blocking is 100% effective, defence phase ends
 
5. Reflection - some things (eg. spells) may now be reflected back at the caster, effectively turning this into the "in transit" phase in the opposite direction.

   - if reflected, defence phase ends
   
5. Take damage - the defender may react in different ways to different attacks:

   * normal - takes 1.0 times damage caused by attack
   * susceptible - takes 1.5 (or some other figure > 1) times damage
   * resistant - takes 0.5 (or some other figure < 1) times damage
   * immune - takes 0 damage from attack
   * absorption - takes -1.0 (or some other figure <  0) times damage, effectively making the attack heal him
   
  Effectively all of the above can be represented by a single figure - the defence multiplier.
  
6. Other effects (eg. blindness, sleep, paralysis, petrification, poison) may take effect now, and be added to the defender with a timeout. (eg. sleep for 10 seconds).

  - some characters may be immune to the effect(s) (but not necessarily the main attack)
  
7. Check for death etc.

Note: Some attacks may comprise multiple components (eg. physical and magical) in which case each component need to be handled separately).


Summary of variables
====================

Surprise

* Initial surprise time (time between commmencement of fight and ability to attack)

Prepare

* Time to prepare attack
* Factors inhibiting preparation (eg. sleep)
* Chance of successful preparation
* Chance of running away
* Chance of choosing to block
* Reduced defence during preparation phase (eg. inability to dodge or block)

Launch

* Chance of successful launch
* Factors inhibiting launch (eg. stun, sleep, silence)
* Time taken to reach target (in-transit time)
* Power of attack (eg. force of blow, power of spell) - ATTACK RATING
* Accuracy of launch (eg. accuracy with the bow and arrow)
* Number of attacks (eg. fire multiple arrows, throw two knives)
* Cost of launch (eg. mana cost, fatigue, arrows)

Recovery

* Time to recover (time from launch before another attack can be prepared)
* Reduced defence during recovery phase (eg. inability to dodge or block)

Attack reaches target

* Chance of dodging (eg. dodging arrows) - DEXTERITY
* Chance of attack missing
* Amount of parry/block
* Amount of passive defence (eg. armour, defence spell) - DEFENCE RATING
* Multiplier based on susceptible/immune/resistant/absorption
* Other effects (eg. poison, sleep, stun) that may last for a while, if so what they are and for how long

