Pattern script

From Blood Wiki
(Difference between revisions)
Jump to: navigation, search
m
 
(61 intermediate revisions by one user not shown)
Line 1: Line 1:
{{article unfinished}}
+
{{TOCRIGHT}}
 +
==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 | infoportions]] etc.). Pattern script are used for enemy appearance, gamemodel damage masks, trigger touchability and other events which only need to control availability of some action.
  
= Introduction =
+
===Script input===
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 - script string
 
+
* Script owner - entity that owns script
Usage examples:
+
* Script activator - entity that launched comparison event
 
+
* Enemy appearance (some enemies are only active at night, some only at day etc.)
+
* Gamemodels damage masks (checks if could be damaged by certain weapon)
+
* Checking if trigger could be touched
+
  
 +
===Script rules===
 +
* Instructions are case sensative
 +
* Operators (excluding ''('' and '')'') should be separated with space or tab.
 +
* Null script always returns 1
  
 
Basic syntax:
 
Basic syntax:
Line 22: Line 24:
 
   (night & fullmoon) | raining
 
   (night & fullmoon) | raining
  
 
+
==Operators==
= Expression operators =
+
{| width=800 border=1 cellspacing=0 cellpadding=5 style="border-collapse: collapse"
 
+
! width=10% | Operator
Link expressions together.
+
! width=20% | Example
 
+
! width=70% | Description
{| border=1 cellspacing=0 cellpadding=5 style="border-collapse: collapse"
+
|-
! bgcolor=#EEDFDF | #
+
| colspan=3 class=shadow | Logical operators (only applicable between expressions)
! bgcolor=#EEDFDF | Operator
+
! bgcolor=#EEDFDF | Example
+
! bgcolor=#EEDFDF | Description
+
 
|-
 
|-
| align=center | 1
 
 
| align=center | '''( )'''
 
| align=center | '''( )'''
| align=center | '''(''' ''expression'' ''')'''  
+
| align=center | '''('''''expression''''')'''  
 
| Expression
 
| Expression
 
|-
 
|-
| align=center | 2
 
 
| align=center | '''&'''
 
| align=center | '''&'''
 
| align=center | x '''&''' y
 
| align=center | x '''&''' y
| Logical 'And'
+
| Logical 'And'.
 
|-
 
|-
| align=center | 3
 
 
| align=center | '''|'''
 
| align=center | '''|'''
 
| align=center | x '''|''' y
 
| align=center | x '''|''' y
| Logical 'Or'
+
| Logical 'Or'.
 +
|-
 +
| align=center | '''not'''
 +
| align=center | x & '''not''' y
 +
| Logical Not.
 +
|-
 +
| colspan=3 class=shadow | Comparison operators
 
|-
 
|-
| align=center | 4
 
 
| align=center | '''='''
 
| align=center | '''='''
 
| align=center | x '''=''' y
 
| align=center | x '''=''' y
 
| Equal
 
| Equal
 
|-
 
|-
| align=center | 5
 
 
| align=center | '''!='''
 
| align=center | '''!='''
 
| align=center | x '''!=''' y  
 
| align=center | x '''!=''' y  
 
| Not equal
 
| Not equal
 
|-
 
|-
| align=center | 6
 
 
| align=center | '''>'''
 
| align=center | '''>'''
 
| align=center | x '''>''' y  
 
| align=center | x '''>''' y  
 
| Greater
 
| Greater
 
|-
 
|-
| align=center | 7
 
 
| align=center | '''>='''
 
| align=center | '''>='''
 
| align=center | x '''>=''' y
 
| align=center | x '''>=''' y
 
| Greater or equal
 
| Greater or equal
 
|-
 
|-
| align=center | 8
 
 
| align=center | '''<'''
 
| align=center | '''<'''
 
| align=center | x '''<''' y
 
| align=center | x '''<''' y
 
| Lesser
 
| Lesser
 
|-
 
|-
| align=center | 9
 
 
| align=center | '''<='''
 
| align=center | '''<='''
 
| align=center | x '''<=''' y
 
| align=center | x '''<=''' y
 
| Lesser or equal
 
| Lesser or equal
 
|-
 
|-
| align=center | 10
 
| align=center | '''not'''
 
| align=center | x & '''not''' y
 
| Logical Not
 
|-
 
| align=center | 11
 
 
| align=center | '''><'''
 
| align=center | '''><'''
 
| align=center | x '''><''' start end
 
| align=center | x '''><''' start end
 
| x > start And x < end
 
| x > start And x < end
 
|-
 
|-
| align=center | 12
 
 
| align=center | '''=><'''
 
| align=center | '''=><'''
 
| align=center | x '''=><''' start end
 
| align=center | x '''=><''' start end
 
| x >= start And x < end
 
| x >= start And x < end
 
|-
 
|-
| align=center | 13
 
 
| align=center | '''><='''
 
| align=center | '''><='''
 
| align=center | x '''><=''' start end
 
| align=center | x '''><=''' start end
 
| x > start And x <= end
 
| x > start And x <= end
 
|-
 
|-
| align=center | 14
 
 
| align=center | '''=><='''
 
| align=center | '''=><='''
 
| align=center | x '''=><=''' start end
 
| align=center | x '''=><=''' start end
Line 104: Line 91:
 
|}
 
|}
  
= Functions =
+
==Functions==
  
 
Set of functions is determined by pattern implementation. There is two pattern implementations as of yet.
 
Set of functions is determined by pattern implementation. There is two pattern implementations as of yet.
  
=== GenericPattern ===
+
===GenericPattern===
  
 
This is generic appearance pattern. It used on enemies appearance, [[Zones | zone appearance]].
 
This is generic appearance pattern. It used on enemies appearance, [[Zones | zone appearance]].
  
{| width=800 border=1 cellspacing=0 cellpadding=5 style="border-collapse: collapse"
+
'''true'''
! width=25% bgcolor=#EEDFDF | Operator
+
:Always yes
! width=75% bgcolor=#EEDFDF | 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.
+
* 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.
+
|-
+
| '''target<'''''name'''''>'''.''field''
+
|
+
|-
+
| '''enemy<'''''radius'''''>'''.''field''
+
|
+
|-
+
| '''sid<'''''name'''''>'''.''field''
+
|
+
|}
+
  
=== GamemodelHitPattern ===
+
'''false'''
 +
:Always no
  
Used on [[misc_gamemodel]] when model is hit.
+
'''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
  
{{hidden begin | GamemodelHitPattern functions}}
+
'''enemy'''.''field''
{| width=800 border=1 cellspacing=0 cellpadding=5 style="border-collapse: collapse"
+
:Check field of script owner enemy. See fields list above.
! width=25% bgcolor=#EEDFDF | Operator
+
 
! width=75% bgcolor=#EEDFDF | Description
+
'''target<'''''name'''''>'''.''field''
|-
+
:Find entity by targetname (return first match). See fields list above.
| '''true'''
+
 
| Always returns 1
+
'''enemy<'''''radius'''''>'''.''field''
|-
+
:Find enemy of script owner within given radius. See fields list above.
| '''false'''
+
 
| Always returns 0
+
'''sid<'''''name'''''>'''.''field''
|-
+
:Find entity by [[SaveId]]. See fields list above.
| '''pushonly'''
+
 
| System word. Allows to push object but not destroy. This should be the first operator in expression if used.
+
'''player'''
|-
+
:Script activator is player.
| '''tag_''tagname'''''
+
 
| Returns 1 if model tag closest to hit position matches this tag. Otherwise 0.
+
'''monster'''
|-
+
:Script activator is [[Radiant/Glossary | NPC]].
| '''''number''%'''
+
 
| Randomly returns 1 with this chance percentage. Typical values are 25%, 50%, 90% etc.
+
'''posessed'''
|-
+
:Script activator is  [[Radiant/Glossary | NPC]] posessed by player.
| '''''damagetype'''''
+
 
| Check if weapon have this damage type. Damagetype should be one of following constants:
+
'''info''' ''infoportion''
* slash - sword
+
:Activator has this [[Infoportions | infoportion]]
* crush - mace
+
 
* crushblow - mace special hit
+
'''infovalue''' ''infoportion'' ''operator''
* hack - axe
+
:Infoportion value comparison (false is always returned is there is no such infoportion).
* impale - throwing knifes, arrows
+
 
* teeth - animals
+
'''morning'''
* claw - animals, wolf form
+
:[[Gametime]] hour is within 5.00 - 9.59.
* water - water damage
+
 
* energy - energy bolts, magic missiles
+
'''day'''
* spikes - spike zones
+
:Gametime hour is within 10.00 - 18.59.
* flame - fire, flame sword
+
 
* flaying - flay artefact
+
'''evening'''
* imploding - implode artefact
+
:Gametime hour is within 19.00 - 22.59.
* soulreaver - soul reaver magic attack
+
 
|}
+
'''night'''
{{hidden end}}
+
:Gametime hour is within 23.00 - 4.59.
 +
 
 +
'''hour''' x ''operator''
 +
:Gametime hour is within some bounds.
 +
 
 +
'''time''' x ''operator''
 +
:Gametime check using string gametime representation. All operators are supported.
 +
 
 +
'''daytime''' x ''operator''
 +
:Gametime check using float gametime representation (daytime).
 +
 
 +
'''moontime''' x ''operator''
 +
:Gametime check using float gametime representation (moontime).
 +
 
 +
'''fullmoon'''
 +
:Moon is on full state (note that moon can be on full state at day).
 +
 
 +
'''newmoon'''
 +
:Moon is on null state.
 +
 
 +
'''raining'''
 +
:Check if it is raining or snow.
 +
 
 +
===GamemodelHitPattern===
 +
 
 +
'''true'''
 +
:Always yes
 +
 
 +
'''false'''
 +
:Always no
 +
 
 +
'''pushonly'''
 +
:System word. Allows to push object but not destroy. This should be the first operator in expression if used.
 +
 
 +
'''tag_''tagname'''''
 +
:Returns true if model tag closest to hit position matches this tag. Otherwise 0.
 +
 
 +
'''''number''%'''
 +
:Randomly returns true with this chance percentage. Typical values are 25%, 50%, 90% etc.
 +
 
 +
'''''damagetype'''''
 +
:Weapon that was used to hit model have this damage type. Damagetype should be one of following constants:
 +
:* '''slash''' - sword
 +
:* '''crush''' - mace
 +
:* '''crushblow''' - mace special hit
 +
:* '''hack''' - axe
 +
:* '''impale''' - throwing knifes, arrows
 +
:* '''teeth''' - animals
 +
:* '''claw''' - animals, wolf form
 +
:* '''water''' - water damage
 +
:* '''energy''' - energy bolts, magic missiles
 +
:* '''spikes''' - spike zones
 +
:* '''flame''' - fire, flame sword
 +
:* '''flaying''' - flay artefact
 +
:* '''imploding''' - implode artefact
 +
:* '''soulreaver''' - soul reaver magic attack
 +
 
 +
==See also==
 +
* [[Trigger event]]

Latest revision as of 04:21, 23 November 2012

Contents

[edit] 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.). Pattern script are used for enemy appearance, gamemodel damage masks, trigger touchability and other events which only need to control availability of some action.

[edit] Script input

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

[edit] Script rules

  • Instructions are case sensative
  • Operators (excluding ( and )) should be separated with 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

[edit] Operators

Operator Example Description
Logical operators (only applicable between expressions)
( ) (expression) Expression
& x & y Logical 'And'.
| x | y Logical 'Or'.
not x & not y Logical Not.
Comparison operators
= 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

[edit] Functions

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

[edit] GenericPattern

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

true

Always yes

false

Always no

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.

player

Script activator is player.

monster

Script activator is NPC.

posessed

Script activator is NPC posessed by player.

info infoportion

Activator has this infoportion

infovalue infoportion operator

Infoportion value comparison (false is always returned is there is no such infoportion).

morning

Gametime hour is within 5.00 - 9.59.

day

Gametime hour is within 10.00 - 18.59.

evening

Gametime hour is within 19.00 - 22.59.

night

Gametime hour is within 23.00 - 4.59.

hour x operator

Gametime hour is within some bounds.

time x operator

Gametime check using string gametime representation. All operators are supported.

daytime x operator

Gametime check using float gametime representation (daytime).

moontime x operator

Gametime check using float gametime representation (moontime).

fullmoon

Moon is on full state (note that moon can be on full state at day).

newmoon

Moon is on null state.

raining

Check if it is raining or snow.

[edit] GamemodelHitPattern

true

Always yes

false

Always no

pushonly

System word. Allows to push object but not destroy. This should be the first operator in expression if used.

tag_tagname

Returns true if model tag closest to hit position matches this tag. Otherwise 0.

number%

Randomly returns true with this chance percentage. Typical values are 25%, 50%, 90% etc.

damagetype

Weapon that was used to hit model have this damage type. Damagetype should be one of following constants:
  • slash - sword
  • crush - mace
  • crushblow - mace special hit
  • hack - axe
  • impale - throwing knifes, arrows
  • teeth - animals
  • claw - animals, wolf form
  • water - water damage
  • energy - energy bolts, magic missiles
  • spikes - spike zones
  • flame - fire, flame sword
  • flaying - flay artefact
  • imploding - implode artefact
  • soulreaver - soul reaver magic attack

[edit] See also

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox