NPCClient math script: Difference between revisions
Jump to navigation
Jump to search
Created page with " == NPC Client == == NPC == {| HP The HP for the NPC | MaxHP | Mana | MaxMana |}" |
|||
(20 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
NPC Client Math scripts are used from the [[Behavior_Operations#Percept_Operation|Percept Operation]] and [[Behaviors_and_Reactions#Reaction|Reaction]] for conditional behavior. The script environment is setup with a NPCClient and a NPC attribute. | |||
== Attributes == | |||
== NPC == | === NPC Client === | ||
The NPCClient has the following properties: | |||
{| | {| | ||
|gameHour | |||
The | |The hour in game time | ||
| | |- | ||
|gameMinute | |||
| | |The minute in game time | ||
|- | |||
| | |gameMonth | ||
|The month in game time | |||
|- | |||
|gameYear | |||
|The year in game time | |||
|- | |||
|} | |} | ||
Example Math Script ('''DiurnalNight'''): | |||
if (NPCClient:gameHour > 22 | NPCClient:gameHour < 6) | |||
{ | |||
Result = 1.0; | |||
} else | |||
{ | |||
Result = 0.0; | |||
}; | |||
=== NPC === | |||
The NPC has the following properties: | |||
{| | |||
|HasTarget | |||
|Return 1.0 if there is a target. If no target 0.0 is returned. The "Target" attribute will be set as well. | |||
|- | |||
|Hate | |||
|The hate for the current target. If no target 0.0 is returned. | |||
|- | |||
|HP | |||
|The HP for the NPC | |||
|- | |||
|InsideTribeHome | |||
|Return 1.0 if inside tribe home, otherwise 0.0. | |||
|- | |||
|InsideRegion | |||
|Return 1.0 if inside region, otherwise 0.0. | |||
|- | |||
|Mana | |||
|The Mana for the NPC | |||
|- | |||
|MaxHP | |||
|The Max HP for the NPC | |||
|- | |||
|MaxMana | |||
|The Max Mana for the NPC | |||
|- | |||
|MaxMStamina | |||
|The Max Mental Stamina for the NPC | |||
|- | |||
|MaxPStamina | |||
|The Max Physical Stamina for the NPC | |||
|- | |||
|MStamina | |||
|The Mental Stamina for the NPC | |||
|- | |||
|PStamina | |||
|The Physical Stamina for the NPC | |||
|- | |||
|} | |||
Example: | |||
Health = NPC:HP/NPC:MaxHP; | |||
Mana = NPC:Mana/NPC:MaxMana; | |||
=== Target === | |||
The Targethas the following properties: | |||
{| | |||
|HP | |||
|The HP for the NPC | |||
|- | |||
|Mana | |||
|The Mana for the NPC | |||
|- | |||
|MaxHP | |||
|The Max HP for the NPC | |||
|- | |||
|MaxMana | |||
|The Max Mana for the NPC | |||
|- | |||
|MaxMStamina | |||
|The Max Mental Stamina for the NPC | |||
|- | |||
|MaxPStamina | |||
|The Max Physical Stamina for the NPC | |||
|- | |||
|MStamina | |||
|The Mental Stamina for the NPC | |||
|- | |||
|PStamina | |||
|The Physical Stamina for the NPC | |||
|- | |||
|} | |||
Example: | |||
if (NPC:HasTarget > 0.0) | |||
{ | |||
TargetHealth = Target:HP/Target:MaxHP; | |||
TargetMana = Target:Mana/Target:MaxMana; | |||
HealthDiff = Target:HP/NPC:HP; | |||
} | |||
== Examples == | |||
=== Perception Operation === | |||
Exampe Script using conditions: | |||
... | |||
<[[Behavior_Operations#Percept_Operation|percept]] condition="DiurnalNight" event="GoToSleep" failed_event="GoToRegion" /> | |||
... | |||
In this [[Behavior_Operations#Percept_Operation|Percept Operation]] example the event GoToSleep is triggered if the DiurnalNight math script return true. | |||
=== Reaction === | |||
Example: | |||
<[[Behaviors_and_Reactions#Reaction|react]] event="damage" condition="DiurnalNight" behavior="NightFight" delta="20" weight="1" /> | |||
In this [[Behaviors_and_Reactions#Reaction|Reaction]] example the damage event will cause a NightFight behavior to be executed if DiurnalNight returns true. |
Latest revision as of 23:42, 17 December 2013
NPC Client Math scripts are used from the Percept Operation and Reaction for conditional behavior. The script environment is setup with a NPCClient and a NPC attribute.
Attributes
NPC Client
The NPCClient has the following properties:
gameHour | The hour in game time |
gameMinute | The minute in game time |
gameMonth | The month in game time |
gameYear | The year in game time |
Example Math Script (DiurnalNight):
if (NPCClient:gameHour > 22 | NPCClient:gameHour < 6) { Result = 1.0; } else { Result = 0.0; };
NPC
The NPC has the following properties:
HasTarget | Return 1.0 if there is a target. If no target 0.0 is returned. The "Target" attribute will be set as well. |
Hate | The hate for the current target. If no target 0.0 is returned. |
HP | The HP for the NPC |
InsideTribeHome | Return 1.0 if inside tribe home, otherwise 0.0. |
InsideRegion | Return 1.0 if inside region, otherwise 0.0. |
Mana | The Mana for the NPC |
MaxHP | The Max HP for the NPC |
MaxMana | The Max Mana for the NPC |
MaxMStamina | The Max Mental Stamina for the NPC |
MaxPStamina | The Max Physical Stamina for the NPC |
MStamina | The Mental Stamina for the NPC |
PStamina | The Physical Stamina for the NPC |
Example:
Health = NPC:HP/NPC:MaxHP; Mana = NPC:Mana/NPC:MaxMana;
Target
The Targethas the following properties:
HP | The HP for the NPC |
Mana | The Mana for the NPC |
MaxHP | The Max HP for the NPC |
MaxMana | The Max Mana for the NPC |
MaxMStamina | The Max Mental Stamina for the NPC |
MaxPStamina | The Max Physical Stamina for the NPC |
MStamina | The Mental Stamina for the NPC |
PStamina | The Physical Stamina for the NPC |
Example:
if (NPC:HasTarget > 0.0) { TargetHealth = Target:HP/Target:MaxHP; TargetMana = Target:Mana/Target:MaxMana; HealthDiff = Target:HP/NPC:HP; }
Examples
Perception Operation
Exampe Script using conditions:
... <percept condition="DiurnalNight" event="GoToSleep" failed_event="GoToRegion" /> ...
In this Percept Operation example the event GoToSleep is triggered if the DiurnalNight math script return true.
Reaction
Example:
<react event="damage" condition="DiurnalNight" behavior="NightFight" delta="20" weight="1" />
In this Reaction example the damage event will cause a NightFight behavior to be executed if DiurnalNight returns true.