Jump to content
ww2weasel

Get more ai vehicles to assist you in mission.

Recommended Posts

This for the newbs out there unfamiliar with scripting.

For Mission Editors only.

Ok - say you want to have vehicles as support during your mission.

1st create the amount of vehicles that will be in the game for player to use. Give each vehicle a name - so it can be referenced by trigger later. Also give 1 move waypoint with an open fire, limited & aware waypoint. <You can move waypoint of the unit - so the unit follows it's waypoint.>

To use this simple technique.

Take one of the vehicles you would like to start off with.

Say that vehicle's name is tank1.

Now that you have selected the vehicle.

create a variable name. If your not going to script but use a trigger, then use a Global name - as this will work in MP as well.

Global name for example: Next_Vehicle

In a trigger set to condition true; in activation line put: Next_Vehicle = tank1;publicVariable "Next_Vehicle";

then tank1 is now available to your group and will be referenced as the variable Next_Vehicle <The two names are synonymous>.

You may use other triggers to move the tank - but when you setup the other triggers be careful to use the variable name - Next_Vehicle.

So for every trigger or script - you would be referencing Next_Vehicle not tank1.

ok, it's important for you to understand this concept. Reread the paragraph above in case you're not grasping what's happening. :confused:

ok applying this technique for your missions other vehicles...

if tank1 is killed:

in a trigger put in condition line: Next_Vehicle==tank1 && !alive Next_Vehicle

in activation field put: Next_Vehicle=tank2;publicVariable "Next_Vehicle";

if tank2 is killed:

in a trigger put in condition line: Next_Vehicle==tank2 && !alive Next_Vehicle

in activation field put: Next_Vehicle=tank3;publicVariable "Next_Vehicle";

etc... Repeat as many times as you want another vehicle in the mission.

So now you have multiple vehicles helping out - but 1 at a time. :yay:

Now all the other triggers setup for Next_Vehicle - will continue to run substituting the new vehicle in as if nothing has happened.

example of getting Ai vehicle to move via triggers or commands in script:

[Next_Vehicle, 1] setWPPos getMarkerPos "MarkerOne"

[Next_Vehicle, 1] setWPPos getPos player

The best possible use for this technique would be to use onmapsingleclick command so a player can call in their vehicle via radio Alpha when they need support. When they call next_vehicle using Radio Alpha, they would open up the map view in editor if not there already - by pressing the letter "M" and clicking on the map where they would like their vehicle to go and lend support. :eek:

EXAMPLE onmapsingleclick :j:

Using the command onmapsingleclick - you would need to setup in this case Radio Alpha. I included a script and a few references from Mission .sqm to show you how to setup. I grabbed the 1st script with onmapsingleclick I could find in my scripts folder.

All you really need to do is setup RAdio Alpha - but I kept explaining in case someone wanted to do more with many radio's.

Mission.sqm info:

In each radio - you would need to setup up like so. Also included trigger info from mission.sqm to help you understand how to set Radio Alpha thru Radio Juliet

Radio Alpha -

Condition=disablerad1 && (side player == east)

Activ=onMapSingleClick {[_pos,""g_1"",ssg1a,leader ssg1,disablerad1,ssg1,1,Alpha] exec "onclickUnitsE.sqs"

Below mission.sqm for added info.

class Item3

{

position[]={4083.924316,17.258379,5649.841309};

a=5.000000;

b=5.000000;

angle=-198.276993;

rectangular=1;

activationBy="ALPHA";

repeating=1;

age="UNKNOWN";

expCond="disablerad1 && (side player == east)";

expActiv="onMapSingleClick {[_pos,""g_1"",ssg1a,leader ssg1,disablerad1,ssg1,1,Alpha] exec ""onclickUnitsE.sqs""};";

class Effects

{

};

};

Radio's Bravo - thru Radio India not listed due to space considerations.....

Radio Juliet-

Condition=disablerad10 && (side player == east)

Activ=onMapSingleClick {[_pos,""g_10"",ssg10a,leader ssg10,disablerad10,ssg10,10,Juliet] exec "onclickUnitsE.sqs"

class Item13

{

position[]={4039.412598,17.436346,5646.117676};

a=5.000000;

b=5.000000;

angle=-198.276993;

rectangular=1;

activationBy="JULIET";

repeating=1;

age="UNKNOWN";

expCond="disablerad10 && (side player == east)";

expActiv="onMapSingleClick {[_pos,""g_10"",ssg10a,leader ssg10,disablerad10,ssg10,10,Juliet] exec ""onclickUnitsE.sqs""};";

class Effects

{

};

};

It's important to set all radios as enabled, this will set a logic switch for the scripts. Also this will set a message as text to read on the relevant radio channel.<Alpha thru Juliet>:

Create a trigger set it to true.

In activation line type:disablerad1=true;disablerad2=true;disablerad3=true;disablerad4=true;disablerad5=true;disablerad6=true;disablerad7=true;disablerad8=true;disablerad9=true;disablerad10=true;1 setRadioMsg "Infantry";2 setRadioMsg "MG Team 1";3 setRadioMsg "HQ.";4 setRadioMsg "MG Team 2";5 setRadioMsg "Heavy Weapons";6 setRadioMsg "Grenadiers";7 setRadioMsg "Medics";8 setRadioMsg "Sniper";9 setRadioMsg "Flamethrower";10 setRadioMsg "RPG Team";

class Item7

{

position[]={4072.394531,17.316566,5634.857910};

a=5.000000;

b=5.000000;

angle=-198.276993;

rectangular=1;

age="UNKNOWN";

expCond="true";

expActiv="disablerad1=true;disablerad2=true;disablerad3=true;disablerad4=true;disablerad5=true;disablerad6=true;disablerad7=true;disablerad8=true;disablerad9=true;disablerad10=true;1 setRadioMsg ""Infantry"";2 setRadioMsg ""MG Team 1"";3 setRadioMsg ""HQ."";4 setRadioMsg ""MG Team 2"";5 setRadioMsg ""Heavy Weapons"";6 setRadioMsg ""Grenadiers"";7 setRadioMsg ""Medics"";8 setRadioMsg ""Sniper"";9 setRadioMsg ""Flamethrower"";10 setRadioMsg ""RPG Team"";";

class Effects

{

};

};

Here is an example script calling up to 10 squads via radio. In this case you could just make it one.

;-----------------------------------------------------------------------------------------------------

;A WH40K script by WW2Weasel

;

;This script to move AI Vehicles around by using Alpha Radio for example.

;

;[position of click on map,marker,group array,leader group,group,disablerad#] exec "somescriptname.sqs"

;

;Example: onMapSingleClick {[_pos,"rus_1",rkk1a,leader rkk1,rkk1,1] exec "onclickunits.sqs"}

;

;Define the above variables to your mission required variables prior to using script.

;

;This script takes into consideration someone already knows how to define array & group for squad.

;

;Here is an example of defining array group for squad. Change numbers incrementally for other squads. In leaders init line type: rkk1=group this;rkk1a=units rkk1;

;

;Feel free to edit as you like; no permission is necessary.

;-----------------------------------------------------------------------------------------------------

?!(side player == east) : exit

onMapSingleClick {}

_pos = _this select 0

_marker = _this select 1

_grouparray = _this select 2

_leadergroup = _this select 3

_disablerad = _this select 4

_group = _this select 5

_numb = _this select 6

?(("not alive _x" count units _group) == count units _group):_disablerad=false;_numb setRadioMsg "NULL";_marker setMarkerType "Marker",_marker setMarkerColor "ColorRed",exit

?local player:_marker setMarkerType "Arrow"

?local player:_marker setMarkerColor "ColorGreen"

~5

[_group,1] setWPPos _pos

_marker setMarkerPos _pos

{_x doMove getWPPos [_group, 1]}forEach _grouparray

_leadergroup sideChat "On the way"

;_ncallsign = Format ["%1 moving out!",_callsign]

?local player:_marker setMarkerColor "ColorRed"

?local player:_marker setMarkerType "Warning"

~5

?local player:_marker setMarkerColor "ColorBlack"

?local player:_marker setMarkerType "Unknown"

~25

?_numb==1:disablerad1=true,publicVariable "disablerad1",1 setRadioMsg "Infantry"

?_numb==2:disablerad2=true,publicVariable "disablerad2",2 setRadioMsg "MG Team 1"

?_numb==3:disablerad3=true,publicVariable "disablerad3",3 setRadioMsg "HQ."

?_numb==4:disablerad4=true,publicVariable "disablerad4",4 setRadioMsg "MG Team 2"

?_numb==5:disablerad5=true,publicVariable "disablerad5",5 setRadioMsg "Heavy Weapons"

?_numb==6:disablerad6=true,publicVariable "disablerad6",6 setRadioMsg "Grenadiers"

?_numb==7:disablerad7=true,publicVariable "disablerad7",7 setRadioMsg "Medics"

?_numb==8:disablerad8=true,publicVariable "disablerad8",8 setRadioMsg "Sniper"

?_numb==9:disablerad9=true,publicVariable "disablerad9",9 setRadioMsg "Flamethrower"

?_numb==10:disablerad10=true,publicVariable "disablerad10",10 setRadioMsg "RPG Team"

exit

Edited by WW2Weasel

Share this post


Link to post
Share on other sites

hi,

Nice script.

I see that you use local player for the marker changes stuff which is a very good thing to save performance in MP, you should also use local player for the sideChat since chat stuffs are always local to the player, it's not big deal but every little performance save in MP are always welcome :).

Moreover, for all the setWPPos, getWPPos, setMarkerPos you should use local server condition something like:

if (local server) then {[_group,1] setWPPos _pos; _marker setMarkerPos _pos; {_x doMove getWPPos [_group, 1]}forEach _grouparray}

don't forget to put a game logic named server somewhere on the map.

This method save performance but most important, only one reference computer (the server) calculate all the position stuffs, like that it's more reliable in MP.

I suggest you to upload a demo with few missionettes to show every possibilities of support. It is always clearer for people to have a look in the editor. Keep it up the good work.

cya.

Nikiller.

Share this post


Link to post
Share on other sites
you should also use local player for the sideChat since chat stuffs are always local to the player, it's not big deal but every little performance save in MP are always welcome .

Hmmm, ya an oversight.

if (local server) then {[_group,1] setWPPos _pos; _marker setMarkerPos _pos; {_x doMove getWPPos [_group, 1]}forEach _grouparray}

k

don't forget to put a game logic named server somewhere on the map.

Ya, always try to drop one in, when I do missions.

I suggest you to upload a demo with few missionettes to show every possibilities of support. It is always clearer for people to have a look in the editor. Keep it up the good work.

Might be awhile, most of the missions I have are in WH40k format. Time is something I'm in short supply of.

I did have a WW2 mission - that the above script mission was about. 3 peeps in mp had 1 tank, 1 halftrack w/Infantry, 1 jeep w/mg each - as planned support order. Played out well - Had been playing it out in Lan mode mostly.

Edited by WW2Weasel

Share this post


Link to post
Share on other sites

hmmm - found an interesting development.

Ever get a moment when something you entered in a trigger then tested as good. Doesn't work when you make changes in another trigger.

You might scratch your head and wonder what the hell is going on...

Then a couple days go by and your head has an awful patchwork quilt look too it as you have pulled out your hair trying to quell the fury that the editor has released in you.

Well - sometimes it's a very simple solution - but you must realize first what the problem is before you can fix it.

The example I just experienced - I will show you and explain why it happened.

The triggers in order of creation below:

1st trigger:

Condition: true

Activation: New_Vehicle=tank1;publicVariable "New_Vehicle"

2nd trigger:

Condition: New_Vehicle==tank1 && !alive tank1

Activation: New_Vehicle=tank2;publicVariable "New_Vehicle"

3rd trigger:

Condition: New_Vehicle==tank2 && !alive tank2

Activation: New_Vehicle=apc;publicVariable "New_Vehicle";

4th trigger:

Condition: true

Activation: New_Vehicle doMove getMarkerPos "demo";

End result is tanks roll out and as they get killed another takes it place. So it all worked well.

Now the problem develops.....

I needed to add a movement event to get the other 2 replacement units to move on target marker.

So I got lazy and did it with triggers rather than a script.

As a result of this decision - I was laying the seeds for failure to get the mission to do what I wanted.

I will show you what I did - this resulted in the apparent failure of trigger 4 to work.

1st trigger:

Condition: true

Activation: New_Vehicle=tank1;publicVariable "New_Vehicle";New_Vehicle doMove getMarkerPos "demo";

2nd trigger:

Condition: New_Vehicle==tank1 && !alive tank1

Activation: New_Vehicle=tank2;publicVariable "New_Vehicle";New_Vehicle doMove getMarkerPos "demo";

3rd trigger:

Condition: New_Vehicle==tank2 && !alive tank2

Activation: New_Vehicle=apc;publicVariable "New_Vehicle";New_Vehicle doMove getMarkerPos "demo";

ok triggers 2 & 3 are ok - but trigger 1 is where the mistake happened - I went back into trigger 1 and deleted - New_Vehicle doMove getMarkerPos "demo"; I already had trigger 4 setup - and decided to keep trigger 4. So I Saved it then went to see the results in editor.

I was astonished to see tank1 no longer moving. Hmmm - thought what the hell is up with this.

Double checked everything and was at a dead end. So I thought ok - so what did I just change? I added the move to marker command.

Ok so the thought process now is to troubleshoot the whole process. All 4 triggers are set to execute at start of mission with no time delay.

Ok - I made changes to 3 of 4 triggers.... hmmm ok.

With my experience in the computer field - my next thought is fifo <first in first out>.

As I pondered this - it's when the solution came to me.

Each time you put a save on the trigger it shuffles the fifo order. So technically - the last trigger created is logically the first trigger to be processed as the three other triggers are considered to be newer than the 4th trigger.

To test out my thesis... I "contol X" <cut> the trigger out of editor the "Control V" <paste> the trigger back into editor. Thereby reshuffling the fifo once again.

Low and behold - problem resolved - Problem was also fixable by giving it a 1 second delay - either approach worked.

So to summarize - if something you had in a trigger was just working and now it doesn't -

Keep in mind the <fifo> effect. As in this case the problem was I was telling the Variable Next_Vehicle to move before the variable Next_Vehicle was set to tank1.

It's just one of those nasty unforseen problems that frustrate OFP editors.

Edited by WW2Weasel

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

×