Jump to content
Sign in to follow this  
GenPattonX

how to have units fire/empty their mags only at a direction, not at a target

Recommended Posts

i need to have some soldiers fire at a location/direction, or maybe a target, depending what that might be.

i tried this:

unit1 doTarget unit2; this fire "M16";

i also read that one could place game logic items, then have unit1 fire on the items I've just placed, using the Unit1 DoFire Unit2... i tried this but it didnt work :(

actually how does one use gamelogic?

Share this post


Link to post
Share on other sites
i need to have some soldiers fire at a location/direction, or maybe a target, depending what that might be.

i tried this:

unit1 doTarget unit2; this fire "M16";

i also read that one could place game logic items, then have unit1 fire on the items I've just placed, using the Unit1 DoFire Unit2... i tried this but it didnt work :(

actually how does one use gamelogic?

There are some complicated methods used in some MP missions, but Lester's Invisibile Tagets would be the easiest way.

http://www.mediafire.com/?rzmt7vik144hh22

A game logic is a special type of unit. It is not seen but can be used for trigger activations, perform special functions for scripts and used for cutscenes and talking.

Game Logic Tutorial

by macguba Website

Recommended for OFP version 1.46.

Views: 2020

Recommended for OFP version 1.46

This tutorial is lifted directly from a thread that appeared in the forum in May 03.

http://www.ofpec.com/yabbse/index.php?board=6;action=display;threadid=9923

All I've done is tidy it up. The original question was posed by Ebolaboy and the principal contributors were:-

macguba

Doolittle

Sui

Chris Death

Sefe

Tomb

anon.

LCD

If you have any good hints and tips about GLs please add them as Comments. The attached download is this tutorial in the forum of a text document.

macguba

9 June 04

General stuff

=============

The thing about GLs is that they are a problem solver: if you don't have a problem you don't need one. BIS used them for much of their conversations or events (which seem to be scripted, but are not). In a normal mission you can replace about 50% to 90% of all scrips by game logics.

GLs can do many of the things that an ordinary loon can do. They have their own special kinds of waypoints (see Sefe's tute below) and you can make them:

- ride in vehicles

- follow waypoints

- fire triggers

- be setpossed into mid air

- synched to triggers

- undergo delays

- act as markers

But you can't make units target or shoot a GL.

For MP games, you can make a gamelogic, name it Server and then use it to see who is the server and who are clients.

? not local Server : hint "Client scum!"

You can also use gamelogics to remember where vehicles started:

_logic = "Logic" createVehicle [0, 0, 0]

_logic setPos getPos _vehicle

_logic setDir getDir _vehicle

Then all you need to do is remember the GL object attached to each vehicle so that when you respawn it you just put it at that GL's location and set it to that GL's direction.

Sefe's GL tute

==============

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 its 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 conditions in your mission when you combine three or more game logics.

The other big tute, preserved by Tomb though the author's name has been lost.

=============================================================================

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.

Download gamelogictutorial.zip (5.464 kb).

Downloads: 525

Use this information at your own risk!

This site is not affiliated in anyway with BI Studios or Codemasters

©Copyright 2001 www.ofpec.com. All Rights Reserved.

Donate to OFPEC

Edited by Zulu1

Share this post


Link to post
Share on other sites

im surprized u say its complicated or hard... remember that last cutscene in the resistance campaign where Victor Troska dies? They had several soldiers and some tanks firing at him, but actually i dont think they target the player at all they just seem to fire at a location or direction, u can see the tanks firing too.

So i tried to unpbo the resistance campaign, got the missions into the editor, but something is terribly wrong, i can load every mission fine, but the cutscene missions show the map completelly blank, no units, no triggers, nothing.... did they do that because they don't want us to be able to see how they created the cutscenes and which commands and stuff they used for them? Anyway it seems that in the cutscene where they kill Victor they just used some simple commands.... does anyone know how to open their cutscene missions?

Share this post


Link to post
Share on other sites

Cutscene missions should be in the 'intro' or 'outro' section of the mission in the editor, I'll have a look at it now, because I also don't know how they did it.

Edit: The Resistance campaign's mission.sqm files are encoded, it seems, but the scripts still work it's "init.sqs" from the mission (x12GameOver.Noe)

Edited by Lenyoga

Share this post


Link to post
Share on other sites

one question, to create those scripts, did they do it by hand or they used a in game program? I mean how do u know how a scene looks in game if u are writing in a notepad?

Share this post


Link to post
Share on other sites

No ingame script editor. Alt tab is your friend, and reload the mission (not the game) to see the changes.

Share this post


Link to post
Share on other sites

hi,

i need to have some soldiers fire at a location/direction, or maybe a target, depending what that might be.

i tried this:

unit1 doTarget unit2; this fire "M16";

i also read that one could place game logic items, then have unit1 fire on the items I've just placed, using the Unit1 DoFire Unit2... i tried this but it didnt work :(

actually how does one use gamelogic?

For infantry you will have to setPos an invisible target in front of your soldiers.

You can use this script for tanks: http://forums.bistudio.com/showthread.php?127420-Nikiller-s-scripts-pack&p=2076012#post2076012

cya.

Nikiller.

Share this post


Link to post
Share on other sites
they used a in game program?

Although BI didn't provide that kind of facility,Faguss did write something like that.It requires Fwatch to run.It's the 4th link down,"in-game script editor".

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  

×