Synopsis:
A library to provide functions that will add typical Fighting Fantasy combats to an adventure.
Description:
While the basic rules for Fighting Fantasy combats are pretty straightforward there are many variations of those basic rules – most typically variations on how to handle combat against multiple opponents as well as a host of other differences.
This library attempts to address many of the easier to handle variations of the basic FF combat rules (as well as the core rules naturally) as possible.
Requirements:
- Include Hosted Libraries: FFLib, GeneralLib
Usage:
All combat functions use the $combat variable. This is a list with a number of sub-lists, however for the most typical purpose the subscript $combat[7] is most useful. This holds the status of the current combat (i.e. most recently evaluated call to a combat routine on a page) and if you – probably do – wish to know whether the Hero has lost or won the combat yet, can be tested for the following values:
- ‘outstanding’ = combat has yet to commence (this might apply to the second combat on a page while the first has yet to finish)
- ‘precombat’ = combat has been commenced but no actions taken yet
- ‘fighting’ = combat is ongoing
- ‘escaping’ = Hero is in process of escaping the combat (test luck option to reduce damage on escaping may still apply)
- ‘escaped’ = This combat was succesfully escaped by the Hero
- ‘won’ = The Hero won this combat
- ‘lost’ = The Hero lost this combat (not necessarily fatal, possible Withdrawal Damage limit reached by Hero)
- ‘survived’ = The maximum number of Rounds has been reached and the combat is over.
So typically, you might say in an ABML reference:
<script script=”&combat_1on1(123,1,1,’Orc’,8,7);”></script>
<if condition=”$combat[7] eq ‘won’; ” reval=”yes”>The Orc lies dead at your feet. <tt ref=”321″>Turn to 321</tt></if>
<if condition=”$combat[7] eq ‘escaped’; ” reval=”yes”>You run off back up the corridor <tt ref=”234″>Turn to 234</tt></if>
Which would only show up the Turn To 123 link if the Hero wins the combat, or Turn To 234 if the Hero escapes.
Functions:
- combat_1on1($pageID, $combatID, $escape, @enemies)
Reserves: permanent variable: $combat
Requires: permanent variables: $skill, $stamina
Optional: permanent variables: $luck, $damage_taken_modifier
Example: &combat_1on1(123,1,1,’Orc’,7,6,’Goblin’,5,7);
Performs a standard sequential combat against the list of enemies supplied in the @enemies parameter (i.e. fight them one at a time).
The parameter $pageID is generally meant to be the name of the reference/page the combat is on though it may be any value the writer cares.
The parameter $combatID is meant to uniquely identify the combat within the context of $pageID, e.g. a page may have more than one combat on it. The combination of $pageID and $combatID should uniquely identify the combat. This paramater MUST be a non-zero value.
The parameter $escape may be either 0 for escaping not allowed, 1 for escaping allowed, or 2 for escaping allowe but the enemy will automatically hit the character as they escape.
The @enemies list details all the enemies to fight, in this case they must be supplied as ‘enemyname1′,skill value, stamina value, ‘enemyname2′ skill value…. etc. there is no limit on the number of enemies you may supply. In the example given the first enemy is an Orc with Skill 7 and Stamina 6, and the second enemy is a Goblin with Skill 5 and Stamina 7.
This function is simply a convenient wrapper for &combat_full (see later) and is unlikely to change its definition so can safely be used in an Include context.
- &combat_multi($pageID, $combatID, $escape, @enemies)
Reserves: permanent variable: $combat
Requires: permanent variables: $skill, $stamina
Optional: permanent variables: $luck, $damage_taken_modifier
Example:&combat_multi(131,1,1,’Orc’,7,6,’Goblin’,5,7);
All parameters are identical to &combat_1on1, the only difference is how combats against multiple enemies is handled. Rather than fighting in sequence, all enemies get to attack the character at the same time, and the reader selects the enemy they wish the character to attack. Succesful ‘fights’ against an enemy that has not been selected for attack simply counts as the character making a succesful parry/dodge against that attack (unsuccesful obviously means the enemy hit the character). The combat round against the selected opponent is executed in the normal way. This is the most typical variant system for multiple opponent combats I have seen in Fighting Fantasy.
This function is simply a convenient wrapper for &combat_full (see later) and is unlikely to change its definition so can safely be used in an Include context.
- &combat_full($pageID, $combatID, $inskill, $skillname, $instamina, $staminaname, $isfatal, $escape, $useluck, $rounds, $damagelow, $damagehigh, $withdrawal_damage, $i_rolls, $m_attacks, $s_enemy, @enemies)
Reserves: permanent variable: $combat
Requires: Nothing
Optional: permanent variables: $luck, $damage_taken_modifier, $stamina
Example: &combat_full(123, 1, $skill, ‘Skill’, $stamina, ‘Stamina’, 1, 2, 1, 0, 2, 2, 2, 1,1, 1,’Orc’,7,6,’2,2,0,Goblin’,5,7,2,2,0);
Warning: If you must use this function copy and paste it into your library. This function is extremely likely to change.
Parameters:
$pageID – see &combat_1on1
$combatID - see &combat_1on1
$inskill – the value to use for Heros Skill
$skillname – the name to use for Skill
$instamina – the value to use for Heros Stamina
$staminaname – the name to use for Stamina
$isfatal – Boolean, 1 means the function will generate an enforced ABML bookend tag upon the Hero falling to 0 Stamina, 0 means the combat will simply end allowing the writer to make other clauses.
$escape – see &combat_1on1
$useluck – 0=No luck used, 1=standard luck combat rules, 2=testluck only to increase damage done by Hero attacks, 3=testluck only to reduce damage done by enemies on Hero
$rounds – Combat will ceasse after the number of rounds supplied to this parameter, or until lost/won if set to 0
$damagelow – The lower point in the range of damage the Hero will cause on a succesful hit
$damagehigh – the higher point in the range of damage the Hero will cause on a succesful hit
i.e. to vary Heros damage set $damagelow to 1 and $damagehigh to 5 and Hero wil cause from 1 to 5 damage randomly determined on each hit
$withdrawal_damage – Set to the value that when reached in Stamina the Hero will withdraw from combat (deemed as having ‘lost’ the combat)
$i_rolls – when fighting multiple opponents simultaneously setting this to 1 will make the Hero roll seperate attack dice against each enemy, setting to 0 means one attack roll will be used to fight all enemies in a round.
$m_attacks – when fighting multiple opponents determines if the combat is executed sequentially (0) or in multiple context (1) against enemies (i.e. they all get to attack every round).
$s_enemy – when fighting multiple opponents in multiple context (see $m_attacks) determines whether the Hero gets to select his enemy to attack each round (1), or whether Hero must attack sequntially (0)
@enemies – enemy details list (extended) of the form: name, skill, stamina,damage_low,damage_high,withdrawal_damage
Too many possible variations to explain really, I just hope the parameter list makes sense!
One further detail deserves mentioning. While parameter $staminaname may be anything, if you set it to ‘Stamina’ &combat_full will adjust the (presumably permanent global) variable $stamina accordingly. If you wish it to alter any other variable instead of $stamina you will have to create a wrapper function which examines the value of $combat[19] after the call to &combat_full, e.g. $car_armour=$combat[19]; This subscript holds the current value of what is supplied as the $instamina parameter. The upshot of all this is that you can rename your skill/stamina stats anything you like as long as it needs the same FF combat rules (and in fact you can have a Car and a Hero with seperate stats in your adventure which both ultimately use this function, directly with the Hero, and through a simple renaming wrapper for the Car),
Note: I should simplify this by making &combat_full return $combat[19] negating the need for a wrapper since it currently returns nothing.