Home   Help Search Login Register  

Author Topic: Game Logic  (Read 1827 times)

0 Members and 1 Guest are viewing this topic.

EbolaBoy

  • Guest
Game Logic
« on: 28 May 2003, 13:17:43 »
Anyone know a good tutorial that explains game logic and it's uses? I only seem to find small bits and peices.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Game Logic
« Reply #1 on: 28 May 2003, 13:33:34 »
I don't know of one.   The thing about GLs is that they are a problem solver:  if you don't have a problem you don't need one.     However, use the forum and FAQ search functions for tips.

GLs can do many of the things that an ordinary loon can do.   They can ride in vehicles (can they drive?  dunno), follow waypoints and be setpossed into mid air.

If you've found lots of bits and pieces perhaps you could combine them into a tutorial yourself.

If you have a specific problem or there's something about them that you can't figure out, post it here and we'll do our best to help. :)
Plenty of reviewed ArmA missions for you to play

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:Game Logic
« Reply #2 on: 28 May 2003, 18:52:42 »
I make a Game Logic and give it the name Server and then use that to see who is the server and who are clients.
Code: [Select]
?not local Server : hint "Client scum!"I also use Game Logics to remember where vehicles started:
Code: [Select]
_logic = "Logic" createVehicle [0, 0, 0]
_logic setPos getPos _vehicle
_logic setDir getDir _vehicle
Then all I need to do is remember the Logic object attached to each vehicle so that when I respawn it I just put it at that Logic's location and set it to that Logic's direction.

People also use Game Logics with waypoints to do some fancy stuff in missions, though I have no experience with that.

Doolittle

EbolaBoy

  • Guest
Re:Game Logic
« Reply #3 on: 29 May 2003, 04:18:56 »
Thank you gentlemen. I'll play around with them more and see what else I can find. If I collect enough information I'll try and put together a FAQ or tutorial.

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Game Logic
« Reply #4 on: 30 May 2003, 01:07:43 »
Game Logics serve as way more than server side detectors or position markers...

They are a very powerful unit that can be given waypoints, synced to triggers and given delays. BIS used them for much of their conversations or events (which seem to be scripted, but are not ;))

I'm pretty sure Sefe wrote a tutorial on their uses... it should be hanging around the editor's depot somewhere...

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Game Logic
« Reply #5 on: 30 May 2003, 05:11:09 »
As Sui said, game logics are way more than only
server side detectors.

Hell they even can be used instead of scripts (if you don't
like external stuff running in your missions).

And finally - yeah the game logic tutorial by Sefe does
exist and AFAIK it should be called: logic groups (ed depot)

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline Sefe

  • OFPEC Patron
  • Former Staff
  • ****
Re:Game Logic
« Reply #6 on: 30 May 2003, 12:13:44 »
I'm pretty sure Sefe wrote a tutorial on their uses... it should be hanging around the editor's depot somewhere...

I wrote a thread about it in the old hints and tips board which got replaced by the editors depot. I don't know if the entry made it to the editors depot.

BUt indeed, GLs are quite powerful. In a normal mission you can replace about 50% to 90% of all scrips by game logics.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Game Logic
« Reply #7 on: 30 May 2003, 14:02:36 »
Well, the "logic groups" i've mentioned above isn't the
one by Sefe, therefore here are Sefe's words from the
old forum:

Code: [Select]
You may have asked yourself what's the use of the game logic units. Most mission designers use it to get positions on the map (eg. Position = GetPos NameOfTheGameLogic).

But the game logic units have a much higher potential! You can use them to implement complex conditions to your missions without using any scripting. But you have to understand the behaviour of game logics:

1. Game logics have a position and can activate triggers just like any other units. Take a look at the condition box of a trigger. There you will find the option "game logic present". You can also group the game logic and the trigger and set the condition to "vehicle present". In this case the trigger will only be activated by the presense of this game logic.

2. You can define waypoints for a game logic unit. The waypoint type can be AND or OR (unlike the waypoints for a 'regular' unit that can be MOVE, HOLD, SEEK AND DESTROY etc.). I'll come to the waypoint type later. As soon as the mission starts, the game logic will go from waypoint to waypoint. But unlike all other units the game logic will not move to the waypoint but 'jump' immediately to it's position.

3. Like for all other waypoints you can define a condition, a timeout and an OnActivation code for a game logic waypoint. When a game logic reaches a waypoint it will perform these actions (in this order):

Wait until the condition is TRUE

Wait until the timeout is passed

Execute the OnActivation code

Jump to the next waypoint


4. Like all waypoints you can synchronize a game logic waypoint with a trigger. That means that the game logic will not proceed to the next waypoint until the trigger condition is TRUE. Now we'll return to the type of the game logic waypoint (AND or OR). If you synchronize more than one trigger with the waypoint, the behaviour of the trigger will depend on the waypoint type. If it is an AND waypoint, the game logic will only jump to the next waypoint when all triggers are activated. If it is an OR waypoint it will proceed to the next waypoint when any of the triggers is activated.

5. Like all other waypoints you can also synchronize a game logic waypoint with any other waypoint. The game logic and the other unit will not proceed to their next waypoints until both of them have reached the synchronized waypoint. This is absolutely the same behaviour as if you would synchronize two non-game logic units. Of course you can also synchronize two game logic waypoints.

But what is that all good for? I'll give you some examples showing the whole potential of game logic units:

Example 1: Establishing radio conversations

To establish a radio conversation you would probably write a script that would look like this:

Alpha1 SideRadio "Message1"
~5
Bravo1 SideRadio "Message2"
~8
Alpha1 SideRadio "Message3"

Without a script you would do it like this:

You'd create a game logic and four waypoints

You'd synchronize the first WP with the trigger that will start the conversation

In the second WP's OnActivation field you'd write: Alpha1 SideRadio "Message1"

In the third WP's OnActivation field you'd write: Bravo1 SideRadio "Message2". Since this radio message has to be sent five seconds after the first, you'd set the timeout to five seconds

In the fourth WP's OnActivation field you'd write: Alpha1 SideRadio "Message3". You'd set the timeout to eight seconds.


As you can see, we can use the timeout of the game logic WPs to time events without having to call a script. While the timeout is equivalent to the ~-operator, the condition field is equivalent to the @-operator.

You can use this method also to create cutscenes without any scripting. In the attachment you will find an example mission that demonstrates a cutscene (radio Alpha) and a radio conversation (radio Bravo).

Example 2: Combining triggers to complex condtions

Now it's going to be a little more complex. What if you had three triggers. The third trigger should be activated if one of the two other triggers are activated. You could also express it like this:

Trigger3 = Trigger1 OR Trigger2 [do not use this syntax in OFP, it's just to describe the boolean correlation of the triggers]

To achieve that you can use a game logic unit:

Create a game logic and define two waypoints. Place the first waypoint outside the third trigger's area and the second one inside the area.

Set the first waypoint's type to OR.

Synchronize the first and the second trigger with the first (OR) waypoint

Draw a group line [F2] between the game logic and the third trigger. Set the trigger's condition to "vehicle present"


The whole thing will work like this: At the beginning of the mission, the game logic will jump to it's first waypoint. Since it's outside of the third trigger's area, it doesn't activate it. The game logic will wait at this OR-waypoint until either the first or the second trigger will be activated. As soon as this happens, the game logic will jump to it's next waypoint. This waypoint is inside the area of the third trigger and so it will be activated. That will cause exactly the effect we wanted.

Finally, let's get really advanced. This time you have four triggers. The fourth trigger should be activated on this condition:

Trigger4 = (Trigger1 OR Trigger2) AND Trigger3

Let's go to work:

Create a game logic, define two waypoints. The first one must be an AND waypoint. The second waypoint must be inside the area of Trigger4. Group Trigger4 and the game logic and set the trigger condition to "vehicle present". This is all similar to above (except that we now use an AND waypoint).

Synchronize Trigger3 with the first waypoint of the game logic.

Create a second game logic with two waypoints. Set the first waypoint to OR. Synchronize the second waypoint with the first waypoint of the other game logic.

Synchronize Trigger1 and Trigger2 with the first (OR) waypoint of this game logic.


But how the hell does this work?

The second game logic will proceed to it's second waypoint if either Trigger1 or Trigger2 is activated. That's the same as above. You could also say:

GameLogic2ReachedWaypoint = Trigger1 OR Trigger2

The first game logic will reach it's second waypoint and activate Trigger4 when Trigger3 is true and the second game logic has reached it's second waypoint:

Trigger4 = GameLogic2ReachedWaypoint AND Trigger3

If you combine these expressions, you'll get:

Trigger4 = (Trigger1 OR Trigger2) AND Trigger3

Voilà!

You can even create more complex condtions in your mission when you combine three or more game logics.

hope you forgive me Sefe that i kept you from typing that
all again by yourself  ;D

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline Sefe

  • OFPEC Patron
  • Former Staff
  • ****
Re:Game Logic
« Reply #8 on: 31 May 2003, 12:58:52 »
Uh, I didn't know someone kept it.

You'll be the first reciepent of the newly created "Sefe's twaddle conservation medal".

Offline Tomb

  • Contributing Member
  • **
  • in2 Metal? Go 2 my sig
Re:Game Logic
« Reply #9 on: 31 May 2003, 13:46:22 »
 ;D


 :o btw, I found some stuff too, didn't keep the authorName, sorry 'bout that, and some of it may overlap what ole seffy wrote back then, but anyho' - here goes :) :


Code: [Select]
This tutorial explains how to use Logic groups in your missions.

Logic groups allow you to create a sequence of waypoints on the map that are not
tied to a physical group in the game. The logical groups behave like a group in
that it moves from waypoint to waypoint but there is no actual units
displayed in the game.


The demo mission uses these logic groups to drive the following conversations
in the demo mission :
Officer saying wait here and beginning of mission
Officer talking with the patrol
Officer talking to you while in the jeep
Officer talking while you are driving the jeep


The waypoints of these logic groups shadow the movement of the soldiers that are
having the conversation thereby allowing the mission builder to seperate the
conversation from the actual movement of the soldiers.


The following is an example of how a logic group is used in the demo mission.


NOTE : I haven't done much with logic groups yet so some of this might be assumptions.


Example : Officer talking in jeep during demo mission
At the beginning of the demo mission there is a point where the officer and your
character jump into the jeep and the officer proceeds to tell you about the mission
while he is driving. The entire dialog is handled with the LOGIC functionality.


Below is waypoint number 4 for the item11 group (the group consisting of the
officer and your character). This waypoint indicates that the group should get
into the assigned vehicle (in this case the jeep). Notice the synchronization field
set to 8? This indicates that the expActiv field will not be executed until any other
sensors or waypoints with synchronization equal to 8 have been triggered.
More about that in a moment.


class Item3
{
position[]={8110.902832,10.232186,5093.410645};
id=41.000000;
type="GETIN";
combat="AWARE";
expActiv="0 fadeMusic 0.22";
synchronizations[]={8};
class Effects
{
track="05demo";
};
showWP="NEVER";
};



Below is the logic group from the demo mission which is used to execute the dialog
within the jeep. Notice that the side field equals "LOGIC". It only needs a single
vehicle defined in this group and its side field is also set to "LOGIC" and the
vehicle field is set to "Logic". For any logic group you would create you would use
a similar vehicle definition.


The waypoints are where the interesting stuff is. Notice each waypoint has the
type field must be set to "AND".


Take a look at waypoint 0. Notice its synchronization field is set to 8?
This indicates that this logic group will not proceed to waypoint 1 until
waypoint 4 of the group the officer and your player are in has been triggered
(i.e. they both got into the jeep).


Okay, once the officer and your character are in the jeep then waypoint 1 is triggered.
Notice its expCond field is "off in jeep and aP in jeep"? No sense having a dialog if
both participants aren't in the jeep! If the condition is true then the game
waits 4 seconds (based on the values of the timeout fields) and the executes the command
in the expActiv instructing the officer to say something.


Waypoint 2 is then triggered. Again notice its expCond field is
"off in jeep and aP in jeep"? No sense having a dialog if both participants aren't
in the jeep! If the condition is true then the game waits 17 seconds
(based on the values of the timeout fields) and the executes the command in
the expActiv instructing the officer to say something else.


Waypoint 3 is then triggered.
Again notice its expCond field is "off in jeep and aP in jeep"?
No sense having a dialog if both participants aren't in the jeep!
If the condition is true then the command in the expActiv instructing
the officer to say something else is executed. Notice the syncrhonization field
is set to 9? That means the command in the expActiv field won't be executed until
any other sensors or waypoints with synchronization set to 9 are also triggered.
Read below to see the sensor with synchronization set to 9.
class Item23
{
side="LOGIC";
class Vehicles
{
items=1.000000;
class Item0
{
position[]={8058.157715,5.852848,5001.322266};
special="NONE";
id=87.000000;
side="LOGIC";
vehicle="Logic";
leader=1.000000;
lock="LOCKED";
skill=1.000000;
markers[]={};
};
};
class Waypoints
{
items=4.000000;
class Item0
{
position[]={8105.548340,5.450422,5001.322266};
type="AND";
synchronizations[]={8};
class Effects
{
};
showWP="NEVER";
};
class Item1
{
position[]={8143.950684,6.763751,5001.321777};
type="AND";
expCond="off in jeep and aP in jeep";
expActiv="off say ""S02v03""";
synchronizations[]={};
class Effects
{
};
timeoutMin=4.000000;
timeoutMid=4.000000;
timeoutMax=4.000000;
showWP="NEVER";
};
class Item2
{
position[]={8169.280273,7.815929,5001.321777};
type="AND";
expCond="off in jeep and aP in jeep";
expActiv="off say ""S02v50""";
synchronizations[]={};
class Effects
{
};
timeoutMin=17.000000;
timeoutMid=17.000000;
timeoutMax=17.000000;
showWP="NEVER";
};
class Item3
{
position[]={8190.720215,8.735840,5001.470703};
type="AND";
expCond="off in jeep and aP in jeep";
expActiv="off say ""S02v05""";
synchronizations[]={9};
class Effects
{
};
showWP="NEVER";
};
};
};



Below is a sensore defined in the demo mission. It is triggered when vehicle id 41
(i.e. the jeep) has entered an area surrounding position (7609,4807).
It has a synchronization field set to 9 same as the logic groups last waypoint.
This means that the officer will not say string S02v05 (from waypoint 3)
until the jeep has reached this area. The officer and your character (in the jeep)
will cause this sensor to trigger since their fourth waypoint (the one after the
GETIN waypoint) is very close to that position.


class Item19
{
position[]={7609.221191,28.079998,4807.668457};
a=20.000000;
b=20.000000;
activationBy="VEHICLE";
age="UNKNOWN";
idVehicle=41.000000;
text="Dorazili";
class Effects
{
};
synchronizations[]={9};
};


That is how the conversation in the jeep was scripted using LOGIC functionality.


The same thing could have been achieved by having multiple waypoints defined for
the officer and your character group from the time they get into the jeep
(waypoint 3) and the time they reach the village (waypoint 4).
Each of these new waypoints would then have the officer saying one of his
profound statements. By using the logic group though you are not tightly coupling
the actual movement of the jeep with the dialog but rather the dialog is occuring
at certain time intervals during the trip. This allows the mission builder to tweak
the movement path independent of the conversation.
-----------------------------------------------------------------------------------

You may have asked yourself what's the use of the game logic units.
Most mission designers use it to get positions on the map
(eg. Position = GetPos NameOfTheGameLogic).
 
But the game logic units have a much higher potential! You can use them to
implement complex conditions to your missions without using any scripting.
But you have to understand the behaviour of game logics:
 
1. Game logics have a position and can activate triggers just like any other units.
Take a look at the condition box of a trigger. There you will find the option
"game logic present". You can also group the game logic and the trigger and set
the condition to "vehicle present". In this case the trigger will only be activated
by the presense of this game logic.
 
2. You can define waypoints for a game logic unit. The waypoint type can be AND or OR
(unlike the waypoints for a 'regular' unit that can be MOVE, HOLD, SEEK AND DESTROY etc).
I'll come to the waypoint type later. As soon as the mission starts, the game logic will
go from waypoint to waypoint. But unlike all other units the game logic will not move
to the waypoint but 'jump' immediately to it's position.
 
3. Like for all other waypoints you can define a condition, a timeout and an
OnActivation code for a game logic waypoint. When a game logic reaches a waypoint
it will perform these actions (in this order):

Wait until the condition is TRUE

Wait until the timeout is passed

Execute the OnActivation code

Jump to the next waypoint


4. Like all waypoints you can synchronize a game logic waypoint with a trigger.
That means that the game logic will not proceed to the next waypoint until the
trigger condition is TRUE. Now we'll return to the type of the game logic waypoint
(AND or OR). If you synchronize more than one trigger with the waypoint,
the behaviour of the trigger will depend on the waypoint type. If it is an AND waypoint,
the game logic will only jump to the next waypoint when all triggers are activated.
If it is an OR waypoint it will proceed to the next waypoint when any of the triggers
is activated.
 
5. Like all other waypoints you can also synchronize a game logic waypoint with
any other waypoint. The game logic and the other unit will not proceed to their
next waypoints until both of them have reached the synchronized waypoint.
This is absolutely the same behaviour as if you would synchronize
two non-game logic units. Of course you can also synchronize two game logic waypoints.
 
But what is that all good for? I'll give you some examples showing the whole potential
of game logic units:
 
Example 1: Establishing radio conversations
 
To establish a radio conversation you would probably write a script that would
look like this:
 
Alpha1 SideRadio "Message1"
~5
Bravo1 SideRadio "Message2"
~8
Alpha1 SideRadio "Message3"
 
Without a script you would do it like this:

You'd create a game logic and four waypoints

You'd synchronize the first WP with the trigger that will start the conversation

In the second WP's OnActivation field you'd write: Alpha1 SideRadio "Message1"

In the third WP's OnActivation field you'd write: Bravo1 SideRadio "Message2".
Since this radio message has to be sent five seconds after the first, you'd set
the timeout to five seconds

In the fourth WP's OnActivation field you'd write: Alpha1 SideRadio "Message3".
You'd set the timeout to eight seconds.


As you can see, we can use the timeout of the game logic WPs to time events
without having to call a script. While the timeout is equivalent to the ~-operator,
the condition field is equivalent to the @-operator.
 
You can use this method also to create cutscenes without any scripting.
In the attachment you will find an example mission that demonstrates a cutscene
(radio Alpha) and a radio conversation (radio Bravo).
 
Example 2: Combining triggers to complex condtions
 
Now it's going to be a little more complex. What if you had three triggers.
The third trigger should be activated if one of the two other triggers are activated.
You could also express it like this:
 
Trigger3 = Trigger1 OR Trigger2 [do not use this syntax in OFP,
it's just to describe the boolean correlation of the triggers]
 
To achieve that you can use a game logic unit:

Create a game logic and define two waypoints. Place the first waypoint
outside the third trigger's area and the second one inside the area.

Set the first waypoint's type to OR.

Synchronize the first and the second trigger with the first (OR) waypoint

Draw a group line [F2] between the game logic and the third trigger.
Set the trigger's condition to "vehicle present"


The whole thing will work like this: At the beginning of the mission,
the game logic will jump to it's first waypoint. Since it's outside of the
third trigger's area, it doesn't activate it.
The game logic will wait at this OR-waypoint until either the first or
the second trigger will be activated. As soon as this happens,
the game logic will jump to it's next waypoint.
This waypoint is inside the area of the third trigger and so it will be activated.
That will cause exactly the effect we wanted.
 
Finally, let's get really advanced. This time you have four triggers.
The fourth trigger should be activated on this condition:
 
Trigger4 = (Trigger1 OR Trigger2) AND Trigger3
 
Let's go to work:

Create a game logic, define two waypoints. The first one must be an AND waypoint.
The second waypoint must be inside the area of Trigger4. Group Trigger4 and the
game logic and set the trigger condition to "vehicle present".
This is all similar to above (except that we now use an AND waypoint).

Synchronize Trigger3 with the first waypoint of the game logic.

Create a second game logic with two waypoints. Set the first waypoint to OR.
Synchronize the second waypoint with the first waypoint of the other game logic.

Synchronize Trigger1 and Trigger2 with the first (OR) waypoint of this game logic.


But how the hell does this work?
 
The second game logic will proceed to it's second waypoint if either Trigger1 or
Trigger2 is activated. That's the same as above. You could also say:
 
GameLogic2ReachedWaypoint = Trigger1 OR Trigger2
 
The first game logic will reach it's second waypoint and activate Trigger4 when
Trigger3 is true and the second game logic has reached it's second waypoint:
 
Trigger4 = GameLogic2ReachedWaypoint AND Trigger3
 
If you combine these expressions, you'll get:
 
Trigger4 = (Trigger1 OR Trigger2) AND Trigger3
 
Voilà!
 
You can even create more complex condtions in your mission when
you combine three or more game logics.



som'n like that  :P ;D

l8rs  :-*

 Tombs



EbolaBoy

  • Guest
Re:Game Logic
« Reply #10 on: 01 Jun 2003, 14:07:14 »
VERY Helpful gents...much thanks.

barry_the_baldy

  • Guest
Re:Game Logic
« Reply #11 on: 29 Dec 2003, 02:36:25 »
Is there a way to pout a GL in the air so that an artillery piece will shoot at it?

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Game Logic
« Reply #12 on: 29 Dec 2003, 03:09:20 »
u cant make units shot GL

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta