Jump to content
Sign in to follow this  
bartkusa

What do Location and Game Logic units do?

Recommended Posts

I noticed that there are "Game Logic" objects and "Location" objects, like "Camp" and "Airport" in the editor.

What are they used for? The Biki isn't very helpful.

Share this post


Link to post
Share on other sites

I'm not sure it can be more specific... As the page says, its an extended type of marker. Location is used to specify parts of the world which are then searchable in a script. Sort of like an inventory.

Game logic I would describe as a variable space (if you place them in the editor, its server side). Like the way many mission designers use invisible H.

Share this post


Link to post
Share on other sites
I'm not sure it can be more specific... As the page says, its an extended type of marker. Location is used to specify parts of the world which are then searchable in a script. Sort of like an inventory.

Game logic I would describe as a variable space (if you place them in the editor, its server side). Like the way many mission designers use invisible H.

Thanks for explaining what they are, but sometimes that isn't enough to make someone learn. For example, imagine you took a dummy like me and I asked:

:confused:: "What is this 'rifle' thing?"

:D: "Well, uhhh, it accelerates tiny metal rocks until it gets to the end of this metal tube, and sends them flying through the air."

:confused:: "That's great and all, but why would I want to do that?"

:D: "Tiny, fast-moving rocks are pretty good at killing animals you want to eat, and people who don't like you."

:confused:: "... Ohh, I get it!"

How would I use them? Can you give me an example? Are there any side effects I should be aware of?

Like, what if I start putting "Open field" and "Airport" locations in forests across Chernarus? Could it interfere with AI pathing?

Share this post


Link to post
Share on other sites

Location => for modules.

Share this post


Link to post
Share on other sites
How would I use them? Can you give me an example? Are there any side effects I should be aware of?

Like, what if I start putting "Open field" and "Airport" locations in forests across Chernarus? Could it interfere with AI pathing?

If the locations are used by scripts, then sure it might be a problem. Or it might improve the script ;)

The wiki has a good example of locations:

_nearestCity = nearestLocation [getPos player, "nameCity"]

_myNewCity = createLocation ["nameCity", position, sizeX, sizeY]

_myNewCity setText "Awesome Ville"

So if you could for example make a new city on the map, set a location to it with and it would be detectable by scripts using nearestLocation.

For game logics, there's like a gazillion examples. But lets say you've placed a logic called "server" on the map, I would say that you could for example do this:

Serverside script:

server setVariable ["scoreWest", _scoreWest, true]

Clientside script:

_scoreWest = server getVariable "scoreWest"

I'm sure you can use game logics for ALOT more advanced things, but that's all the use I've found ;)

Edited by Murklor

Share this post


Link to post
Share on other sites

For game logics, there's like a gazillion examples. But lets say you've placed a logic called "server" on the map, I would say that you could for example do this:

Serverside script:

server setVariable ["scoreWest", _scoreWest, true]

Clientside script:

_scoreWest = server getVariable "scoreWest"

I'm sure you can use game logics for ALOT more advanced things, but that's all the use I've found ;)

I'm still getting my head around script-locality, so this is a cool invention. Thanks!

Share this post


Link to post
Share on other sites

Not to be an ass, but knowing how something works should be enough. If you want to simply copy what people are already doing with it, then just look at their existing work.

Someone figures out a mixture to make gun powder. People like it because it goes boom, and maybe they make some rudimentary bombs.

Somebody else figures out how to cast iron, and they make some structures.

An interested person whose thinking of weapons, uses existing work to create a cannon, which is manyfold more useful.

I am not saying people shouldn't share information, but you learn more and sometimes end up with better results when you do your own experimentation. If you get stuck you can ask for help, and helping you will be easier because you can show what you currently have and where you are stuck rather than starting at square one.

Share this post


Link to post
Share on other sites
Not to be an ass, but knowing how something works should be enough. If you want to simply copy what people are already doing with it, then just look at their existing work.

Not to be an ass, but you're an ass. I never asked for scripts; I just want to know how people took some of the tools in the editor and made them useful, and if there are any caveats I should be aware of.

I've used Location markers in some of my own missions to great effect. I placed some Open Space locations on the map and used "getNearest openSpace" to move AAA as close as possible to a randomly-designated point without obscuring their vision with trees. Now I'm using them to generate directed graphs.

However, I'm using them without understanding them totally. That means I might not use them to their fullest potential, and it also means I might use them in inappropriate ways.

What I'm interested in is hidden features of Locations and Game Logics. One person elsewhere told me Game Logics could be given AND and OR waypoints, and move between waypoints, once their current WP is satisfied. That's insanely useful and can replace a lot of hand-scripting.

What I'm worried about is if my Location-based shenanigans (mentioned above) would interfere with AI pathfinding, or maybe the Ambient Combat Module. I'm worried ambient civilians might start congregating in hidden places far from towns, like 18th-century witches' covens.

vvv yesssss. Even knowing how Game Logics worked, I never would've thought to use them for radio conversations. vvv

Edited by bartkusa

Share this post


Link to post
Share on other sites

Well, hereunder an old OFPEC tutorial about GL, WP and triggers. Very useful IMHO.

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.

Share this post


Link to post
Share on other sites

I could easily be an ass, but I was trying not to be.

I never said there was something wrong with your question, however, it you don't ask specific questions, you can't complain when people give you simple answers.

If you use the built-in location classes, they will be used by BIS modules, just like if you put them in there when making the map. So, it would probably be best to add the correct type of class when adding new locations or use custom classes. Also, unless you added many new locations, someone who knows the map might get curious when they see a new location and would be able to find your artillery. However, you could set the side of the location so they would only be visible to one side.

Although, it's a nice example, using triggers with game logics for simple things like radio conversations wouldn't be ideal performance-wise. Triggers would be checking for their conditions too frequently even if the triggers were set to occur only once.

Share this post


Link to post
Share on other sites
Although, it's a nice example, using triggers with game logics for simple things like radio conversations wouldn't be ideal performance-wise. Triggers would be checking for their conditions too frequently even if the triggers were set to occur only once.

It was only an example to explain what GL can do, as requested by the OP.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×