BattleForge Wiki
Register
Advertisement

Conditions and Actions[]


Conditions and Actions have to be inside an Event-Block.

Conditions and Actions

Conditions & Actions






Conditions[]


The following are a few conditions from the Battleforge Script Engine and their meanings.
1. SquadIsAlive { Tag = "squad01" }
2. EntityIsInRange { Tag = "entity01", TargetTag = "tree01", Range = 17}
3. MapTimerIsElapsed {Name = "mt_Timer01", Seconds = 10, Minutes = 0},


  1. Checks if the squad called "squad01" (the tag has been set in the editor) is alive at the moment.
  2. Checks if an entity called "entity01" is within range of 17 meters to the object "tree01".
  3. Checks if 10 seconds have passed since the MapTimer "mt_Timer01" was started.


A word of warning:
Events with an empty conditions block are executed immediately. This is especially bad in combination with "OnEvent" - events, meaning that the actions of that event would be executed non-stop. Performance would suffer badly.

Multiple conditions and boolean operators in the conditions block
Having more than one condition
Just as there can be more than one action per block, there may be multiple conditions as well. Those multiple conditions can be combined in a number of ways. A few examples are:
"Are both (or all) conditions true?"
That is called "AND" in boolean logic. It could as well be rephrased to "Is at least ONE condition false?"
"Is at least ONE condition true?"
That is called "OR" in boolean logic. It could as well be rephrased to "Are not all conditions false?"
"Is only one of two conditions true?"
That is called an "XOR", or "exclusive or", in boolean logic. It could as well be rephrased to "Are not both conditions true or false?"

Boolean

Boolean








Boolean2

Boolean














The negations of AND, OR and XOR are also available, which are NotAND, NotOR and XAND.
You can use AND, OR, NotOR and NotAND for 2-n conditions.
You can use XOR and XAND for 2 conditions.

In EA Phenomic's script system you can also use ALL, ANY, NONE and NotANY (instead of AND, OR, NotAND and XOR). Those are interesting when it comes to the quantor checks EA Phenomic will use in some conditions.

Player Conditions[]

Now that the hunt is on, let's run a check that makes the players fail, should one of them not hunt the orcs fast enough.


PlayerTimerIsElapsed {Player = "ANY", Name = "pt_TimeSinceOrcDied", Seconds = 0, Minutes = 1},


That condition will become true, should any of the players ever pass the one-minute-mark.

Quantifier Checks[]

So now that we have accomplished scripting the orc hunt mission, let's tighten things up a bit. We could reduce the time slot in which a kill has to happen to 20 seconds, but in the same turn make the players fail only if ALL players have exceeded the 20 seconds at the same time. This can be done by simply changing the quantor in the condition as follows:


PlayerTimerIsElapsed {Player = "ALL", Name = "pt_TimeSinceOrcDied", Seconds = 20, Minutes = 0},


That's the beauty of having quantors.

Actions[]


The following are a few actions from the Battleforge Script Engine and their meanings.
1. SquadSpawn {TargetTag = "tree01", Team = "tm_Player1", SquadId = 168},
2. MapTimerStart {Name = "mt_Timer"},
3. SquadVanish {Tag = "berserker"},

  1. This action spawns a squad at the object "tree01". The squad belongs to Player1 and has the ID "168" in the editor/BEE. The IDs can be checked in the BEE or the editor (BEE is preferable).
  1. Starts a MapTimer called "mt_Timer".
  1. This causes the squad, in that case with the scripttag "berserker", to vanish, meaning it dies without playing the usual death animation.

There can be more than one action in an action block.

Player Actions[]

Let's say we want each of four players to kill an orc every minute to prove his skill. Should they be unable to do that, they would suffer the consequences.
We can do that easily with the help of player variables.
Instead of starting and tracking four timers separately, we can do so with just a few Player script commands.
The following piece of script starts a timer for all players.


PlayerTimerStart {Player = "ALL", Name = "pt_TimeSinceOrcDied"},


Now that the timer has been started for each player, we could simply check who has killed one of his orcs recently, and restart the respective timer (we will ignore the fact that the players could in theory help out each other for now).

back.

Advertisement