Combat System
Functions relating to the combat system. You can start and stop fights, and manipulate and inspect their state.
Basics
The basic flow is that you create a new session using the Combat2
function, add some participants, and then start it with the Begin
method.
A newly created session does not contain any participants at all, not even the player character (whom you can add with the global variable Player
). You could, if you want to, forego adding the player to a combat session, and have only AI-controlled participants fight it out.
NPC participants can be created by using the Creature
function, described in the Constructors section.
- (Combat Session) - a new, empty combat session.
- (Combat Session) - active combat, or nil if there is none
- participant (Creature) - the new creature to involve in this fight.
- number - read-only
Participant State
Use these functions to force characters into specific states, or to inspect their current state. This is useful to, for example, force a character to already be swallowed by some predator before the combat starts.
Note that each Combat Session is completely separate and self-contained. A participant could, for example, be grappling with another participant in one session, and be swallowed by that same creature in another session. In other words, combat-related states like grappling, swallowing, stunning and the like are 'forgotten' as soon as the combat session ends. It is up to your scene scripts to figure out how participants have interacted with each other, so that the scene can respond to the combat's outcome appropriately.
Be sure that all Creatures you pass to these functions, are already registered to this combat session using AddParticipant
. If this is not done, the functions will raise an error.
- participant (Creature) - the character to apply the buff to
- buff (PendingBuff) - the new buff to apply
- participant (Creature) - the character to check
- (boolean) - true if grappling, false otherwise
- participant (Creature) - the character to check
- (boolean) - true if swallowed, false otherwise
- participant (Creature) - the character to check
- (boolean) - true if grappling and initiator, false otherwise
- participant (Creature) - the character to check
- (Creature) - the predator who swallowed the input participant, or nil
- participant (Creature) - the character to check
- (Creature) - the grapple partner, or nil
- predator (Creature) - the predator swallowing the prey
- prey (Creature) - the prey being swallowed
- predator (Creature) - the predator swallowing the prey
- prey (Creature) - the prey being swallowed
- instigator (Creature) - the grappling initiator
- target (Creature) - the target being grappled
- a (Creature) - the first grappling partner
- b (Creature) - the second grappling partner
Callbacks
You can use these functions to have the combat system inform you of certain events. For example, you can have a snippet of Lua code run every time a round ends, or whenever someone is swallowed by a predator. This is useful for scripting combat sequences beyond what the vanilla combat system normally allows.
- callback (function(round)) - user callback function
- callback (function(round)) - user callback function
- callback (function) - user callback function
- callback (function(killer, victim)) - user callback function
- callback (function(predator, prey)) - user callback function
- callback (function(predator, prey)) - user callback function
- callback (function(killer, victim)) - user callback function