SailEvent
From Original War Support Wiki
SAIL Events -> SailEvent
Description
This event occurs when function "RaiseSailEvent" is executed.
Exported Values
SailEvent(value);
value - a value given to "SailEvent" by function "RaiseSailEvent".
Usage
"SailEvent" works like other events except the value it 'gives' through its parameter is the same as the input for function "RaiseSailEvent". Additionally you can choose yourself when the event should occur - that is when you use function "RaiseSailEvent". This function has one parameter corresponding to the one value event "SailEvent" 'gives'.
Important: Apparently you can only export integers to "SailEvent". If you use a list as the parameter in "RaiseSailEvent" then it is automatically converted to the corresponding integer in "SailEvent".
Example:
Every 0$5 do
var show_hidden_bunker;
begin
show_hidden_bunker = LoadVariable('03_bunker_found',false);
InGameOn;
Wait(0$2);
RaiseSailEvent(show_hidden_bunker);
SayRadio(Dennis, 'A2-Den-1');
InGameOff;
end
On SailEvent(reveal_bunker) do
begin
Wait(0$3);
CenterOnXY(12, 33);
if reveal_bunker then
begin
Wait(0$4);
CenterOnXY(56, 34);
end;
end;
Here the character "Dennis" speaks while the camera focuses on hex [12, 33]. If the player did something in a former mission then hex [56, 34] is also revealed.
This is almost the same as using an "every" with a very low update time, a "marked" and a global variable. The difference is that "SailEvent" is triggered instantly (like every other event) and the "every" is triggered only almost instantly. Furthermore you don't have to use a global variable when using "SailEvent" because the value is exported directly to the event.
The example above rewritten:
Export show_hidden_bunker;
Every 0$5 do
begin
show_hidden_bunker = LoadVariable('03_bunker_found',false);
Disable(01);
InGameOn;
Wait(0$2);
Enable(01);
SayRadio(Dennis, 'A2-Den-1');
InGameOff;
end
Every 0$0.1 marked 01 do
begin
Wait(0$3);
CenterOnXY(12, 33);
if show_hidden_bunker then
begin
Wait(0$4);
CenterOnXY(56, 34);
end;
end;
You can define SailEvent only once, but there is a way to use it for various situations thanks to its parameter and "case" command
Example for multiple usage:
Every 0$0.5 trigger IsIdle(Donaldson) and IsIdle(JMM) do
begin
... //some unimportatnt code
RaiseSailEvent(Frank); //Call SailEvent with param Frank
end;
Every 0$0.5 trigger IsPlaced(Nota) do
begin
... //some unimportatnt code
ComMoveXY(Nota,56,1);
AddComSailEvent(Nota,Nota); //unit Nota call Sailevent with param Nota after he reach coords 56,1
... //other unimportant code
end;
Here is source for SailEvent function:
on SailEvent(param) do
var a;
begin
case param of
Frank: //when param of SailEvent = Frank do this code
begin
PlaceUnitXY(Frank,12,1,false);
ComMoveXY(Frank,17,9);
AddComMoveXY(Frank,16,18);
AddComMoveXY(Frank,24,31);
if (IsPlaced(JMM)) then AddComMoveUnit(Frank,JMM);
AddComFree(Frank);
end;
Nota: //when param of SailEvent = Nota do this code
begin
RemoveUnit(Nota);
SetAttitude(7,2,att_enemy,true);
RaiseSailEvent(listOfEnemyUnits); //you can call other SailEvent with other param from SailEvent :D
end;
listOfEnemyUnits: //when param of SailEvent = listOfEnemyUnits do this code
begin
enable(2);
for a in listOfEnemyUnits do
PlaceUnitArea(a,arabianAttack,false);
ComMoveXY(listOfEnemyUnits,69,27);
AddComAgressiveMove(listOfEnemyUnits,62,51);
end;
end;
end;




