Scrigroup - Documente si articole

     

HomeDocumenteUploadResurseAlte limbi doc
AccessAdobe photoshopAlgoritmiAutocadBaze de dateCC sharp
CalculatoareCorel drawDot netExcelFox proFrontpageHardware
HtmlInternetJavaLinuxMatlabMs dosPascal
PhpPower pointRetele calculatoareSqlTutorialsWebdesignWindows
WordXml


Basic Concepts - Triggers

c



+ Font mai mare | - Font mai mic



Basic Concepts

Triggers

Mission events (such as unit spawning, activating mission tasks, tactical enemy AI controlling, etc.) are ruled by the script that consists of the triggers. A trigger is a group of commands that get the execution when some conditions are fired (for example, units reach the specified region, a key player's unit get dead).



An example of a trigger:

[ArtSupport_Ger_Army]

QuestActivate ( 'ArtSupport' , 240000 )

ArtSupportChangeState ( 2 , ENABLE )

RunTrigger ( 'Check_ArtSupport_Ger_Army' )

PingShow ( 'Ping_02' , 2 , POINT , 'Point_02' )

Halt

Commands in the trigger are executed till the Halt statement is encountered. If the trigger executes all its commands and the Halt statement is not encountered, it continues execution right from the beginning and performs the loop infinitely until any other external trigger calls DestroyTrigger or DestroyTriggetInstance procedure or the mission completes.

Several triggers may work in parallel: the first trigger executes several commands, then it implicitly switches the execution to the second one (etc), and then back to the game engine. If the Delay statement is encountered, the execution of the current trigger is interrupted for a given period of time and is switched to either another trigger or the game engine.

Comment 1: It is highly recommended to call Delay statement from time to time to prevent any performance issues related to the mission script.

Comment 2: Some trigger procedures cannot be processed immediately (e.g., RunCommand takes some time to execute, because the unit must think of a given order for some time and then carry it out). In this case after the procedure you should call Delay and after a proper period of time accomplish all the related checks.

Separating Characters

When writing triggers, the following separating characters are used

" " ( " " ) " all the separating characters use the same layout space+character+space

Comments

If a string begins with the commenting characters: "COMMENT ", " ", " " then such operator is considered to be commented out and is not executed. Also, the commenting characters can be followed by a string, which cannot be interpreted as an operator

Unit Types

The following classification is used as unit types in triggers

<UnitType>:

ALL    - all units

ARMOREDCAR - armored vehicles

ARTILLERY    - artillery

CAR    - vehicles

FLAK    - anti-aircraft guns

FORTIFICATION    - concrete / wooden pillboxes

HMG    - heavy machine-guns

HUMAN    - people

SPG    - self-propelled guns

TANKS    - tanks

Set

Setting and initializing a variable

Syntax:

SET <VariableName> <VariableName2> || <Value> || <String> || <Function>

<Variable> - variable to be set to a value.

<Value> - value to be set to the variable.

<String> - string to be set to the variable.

<Function> - function returning the value of the type of the variable <Variable>.

Example:

[Trigger]

Set @num = 2

The local variable num is set to the number 2

Halt

[Trigger]

Set @num = "human"

The local variable num is set to the string "human"

Halt

[Trigger]

Set @num = GetNUnits ( ARMY , 1 , HUMAN )

The local variable num is set to the value returned by the function GetNUnits

Halt

IF

Conditional operator

Syntax (option 1):

IF <ConditionA> THEN

<Statement2>

ELSE

<Statement3>

ENDIF

Syntax (option 2):

IF ( <ConditionA> THEN

<Statement2>

ENDIF

<ConditionA> - condition

Syntax:

<Condition01>

where <ConditionXX> represents

<Variable> ">" || "<" || "<=" || ">=" || " " || " "<Variable2> || <Value> || <String>

Example:

[Trigger]

if ( @@num_human1 > @@num_human2 AND @@num_tanks2 = 0 ) then

MissionWin ( )

Halt

else

Delay )

endif

[Trigger_01]

if ( @@num_human1 > @@num_human2 AND @@num_tanks2 = 0 ) then

MissionFail ( )

Halt

endif

LABEL

Sets a jump label

Syntax:

LABEL <Label>

<Label> - name of the label.

Example:

[Trigger]

LABEL Label_01

.

Halt

GOTO

Unconditional jump operator

Syntax:

GOTO <Label>

<Label> - name of the label to be jumped to within one trigger

Example:

[Trigger]

.

LABEL Label_01

GOTO Label_01

Halt

Delay

Delay in operator execution

Syntax (option 1):

Delay ( <Int>

<Int> - duration of the delay in milliseconds

Syntax (option 2):

Delay ( <DelayMin> , <DelayMax>

<DelayMin> - minimum duration of the in milliseconds

<DelayMax> - maximum duration of the delay in milliseconds

Example:

[Trigger]

Delay ( 1000 ) // This trigger has a 1-second delay

Halt

[Trigger_01]

Delay ( 1000 , 2000 )

// This trigger has a delay of 1 to 2 seconds

Halt

Halt

Ends the operation of the trigger, in which it is called

Syntax:

Halt

Example:

[Trigger]

Delay ( 1000 )

Halt // The trigger's operation is ended after 1 second



Politica de confidentialitate | Termeni si conditii de utilizare



DISTRIBUIE DOCUMENTUL

Comentarii


Vizualizari: 892
Importanta: rank

Comenteaza documentul:

Te rugam sa te autentifici sau sa iti faci cont pentru a putea comenta

Creaza cont nou

Termeni si conditii de utilizare | Contact
© SCRIGROUP 2024 . All rights reserved