Pattern script

From Blood Wiki
(Difference between revisions)
Jump to: navigation, search
Line 2: Line 2:
  
 
== Introduction ==
 
== Introduction ==
Pattern scripts is special kind of expressions that returns 1 or 0 used to determine availability of some functionality or event. This scripts can check for very wide range of conditions (gametime, special parms of entities, [[Infoportions | infoportions]] etc.).
+
Pattern scripts is special kind of expressions that returns 1 or 0. Script can check and combine wide range of conditions (gametime, special parms of entities, [[Infoportions | infoportions]] etc.). Patters script are used for enemy appearance, gamemodel damage masks, trigger touchability and other events which only need to control availability of some action.
  
Usage examples:
+
=== Script input ===
 +
* Pattern - script string
 +
* Script owner - entity that owns pattern comparison
 +
* Script activator - entity that launched comparison event
  
* Enemy appearance (some enemies are only active at night, some only at day etc.)
+
=== Script rules ===
* Gamemodels damage masks (checks if could be damaged by certain weapon)
+
* Instructions are case sensative
* Checking if trigger could be touched
+
* Operators (excluding ''()'') should be separated by space or tab.
 +
* Null script always returns 1
  
 
Basic syntax:
 
Basic syntax:
Line 20: Line 24:
 
   // this script check if it's fullmoon night or raining  
 
   // this script check if it's fullmoon night or raining  
 
   (night & fullmoon) | raining
 
   (night & fullmoon) | raining
 
=== Script input ===
 
* Pattern - script string
 
* Script owner - entity that owns pattern comparison
 
* Script activator - entity that launched comparison event
 
  
 
== Operators ==
 
== Operators ==

Revision as of 00:28, 18 July 2012

Template:Article unfinished

Contents

Introduction

Pattern scripts is special kind of expressions that returns 1 or 0. Script can check and combine wide range of conditions (gametime, special parms of entities, infoportions etc.). Patters script are used for enemy appearance, gamemodel damage masks, trigger touchability and other events which only need to control availability of some action.

Script input

  • Pattern - script string
  • Script owner - entity that owns pattern comparison
  • Script activator - entity that launched comparison event

Script rules

  • Instructions are case sensative
  • Operators (excluding ()) should be separated by space or tab.
  • Null script always returns 1

Basic syntax:

 // this script check if its a night or if there is an enemy within 300 units
 night | enemy<300>.found
 // this scripts check if gametime is between 12 and 14 hours
 hour =><= 12 14
 // this script check if it's fullmoon night or raining 
 (night & fullmoon) | raining

Operators

Link expressions together.

Operator Example Description
Logical operators (only applicable between expressions)
( ) (expression) Expression
& x & y Logical 'And'. Must be always separated by space.
| x | y Logical 'Or'. Must be always separated by space.
not x & not y Logical Not. Must be always separated by space.
Comparison operators (must be always separated by space)
= x = y Equal
!= x != y Not equal
> x > y Greater
>= x >= y Greater or equal
< x < y Lesser
<= x <= y Lesser or equal
>< x >< start end x > start And x < end
=>< x =>< start end x >= start And x < end
><= x ><= start end x > start And x <= end
=><= x =><= start end x >= start And x <= end

Functions

Set of functions is determined by pattern implementation. There is two pattern implementations as of yet.

GenericPattern

This is generic appearance pattern. It used on enemies appearance, zone appearance.

Operator Description
true Always returns 1
false Always returns 0
self.field Checks one of the field of script owner. Fields could be:
  • found - entity exists.
  • touchable - entity is touchable trigger or zone.
  • fired - trigger is deactivated. This is only applicable to: trigger_once, trigger_redirect, trigger_multi.
  • solved - puzzle trigger is solved. This is only applicable to: trigger_puzzle.
  • killed - entity was killed (deadflag is set).
  • dist x operator - check distance to activator.
  • deadtime x operator - check time enemy being dead.
enemy.field Check field of script owner enemy. See fields list above.
target<name>.field Find entity by targetname (return first match). See fields list above.
enemy<radius>.field Find enemy of script owner within given radius. See fields list above.
sid<name>.field Find entity by SaveId. See fields list above.

GamemodelHitPattern

Used on misc_gamemodel when model is hit.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox