Forum Jump :

Author Message


Posts: 89
Rank:


Level: Member

Country: in
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2016-02-28 10:41        
     
Hello i have created a script for a group of vehicles to be under player control via addaction.
In this script you can halt/move AI convoy, change speed of AI convoy ,change formation ,move to new position by mapclick.
The vehicle formation is AI led convoy of vehicles.
This script can be used to control AI led convoy while it is moving through waypoints on map placed by map editor.

First place a column of vehicles on map which could be tanks , apcs or trucks.
Make the lead vehicle of column as AI leader.
In AI lead vehicle init- bravoOne = group this; or any other name.
If the vehicle formation has different groupname simply change groupname in formations.sqf
Convoygrp = bravoOne; to one specified.

select one of the vehicles in column as controlled by player.

In player's ai driven vehicle init-
Formcommands = this addaction ["Open commands","formcommands.sqf",true,1,false,true,"","_this in _target"];

place these other sqf's in mission folder.

formcommands.sqf
_Vehicle = _this select 0;

hint "Change convoy formation or speed through scroll menu!";

sleep 1;

MovePos = _Vehicle addaction ["Move To Position","formations.sqf",["Move To"],1,false,true,"","_this in _target"];
FormLine = _Vehicle addaction ["Form LINE","formations.sqf",["form line"],1,false,true,"","_this in _target"];
FormColumn = _vehicle addaction ["Form COLUMN","formations.sqf",["form column"],1,false,true,"","_this in _target"];
MoveSlow = _Vehicle addaction ["Slow speed","formations.sqf",["Move Slow"],1,false,true,"","_this in _target"];
MediumSpeed = _Vehicle addaction ["Medium speed","formations.sqf",["Move Medium"],1,false,true,"","_this in _target"];
MoveFast = _Vehicle addaction ["Full Speed","formations.sqf",["Move Fast"],1,false,true,"","_this in _target"];
Haltconvoy = _Vehicle addaction ["Halt convoy","formations.sqf",["Stop formation"],1,false,true,"","_this in _target"];
MoveConvoy = _Vehicle addaction ["Move convoy","formations.sqf",["Move Formation"],1,false,true,"","_this in _target"];
closeCommands = _vehicle addaction ["Close Commands","formations.sqf",["close commands"],1,false,true,"","_this in _target"];

sleep 1;
_vehicle removeaction formcommands;

exit;

formations.sqf
_vehicle = _this select 0;
_changeFormations = (_this select 3) select 0;

sleep 1;
Convoygrp = bravoOne;//Name of vehicle group formation.

sleep 1;
switch (_changeFormations) do {

case "Move To":
{
sleep 1;
titleText ["Click on map position to move convoy on map!","plain down"];
sleep 0.1;
mapclick = true;
onMapSingleClick "leader Convoygrp move _pos;mapclick = false;
onMapSingleClick ''; true;";
waitUntil {!mapClick};

sleep 1;
leader convoyGrp sidechat "Roger that!, moving to new position!";

};
case "form line":
{
leader convoyGrp sidechat "Form line!";
Convoygrp setformation "LINE";
};

case "form column":
{
leader convoyGrp sidechat "Form column!";
Convoygrp setformation "COLUMN";
};

case "Move Slow":
{
leader convoyGrp sidechat "Move at slow speed!";
Convoygrp setspeedMode "LIMITED";
_vehicle setspeedMode "LIMITED";
};

case "Move Medium":
{
leader convoyGrp sidechat "Move at medium speed!";
Convoygrp setspeedMode "NORMAL";
_vehicle setspeedMode "NORMAL";
};

case "Move Fast":
{
leader convoyGrp sidechat "Move at Full speed!";
Convoygrp setspeedMode "FULL";
_vehicle setspeedMode "FULL";
};

case "Stop formation":
{
leader convoyGrp sidechat "Stop!";
{doStop _x} forEach units convoyGrp;
};

case "Move Formation":
{
leader convoyGrp sidechat "Continue to waypoint!";
{_x doFollow leader convoyGrp} forEach units convoyGrp;
};

case "close commands":
{
hintsilent "command menu closed!";
_vehicle removeaction MovePos;
_vehicle removeaction formLine;
_vehicle removeaction formColumn;
_vehicle removeaction MoveSlow;
_vehicle removeaction MediumSpeed;
_vehicle removeaction MoveFast;
_vehicle removeaction Haltconvoy;
_vehicle removeaction MoveConvoy;
_vehicle removeaction closecommands;

Formcommands = _vehicle addaction ["Open commands","formcommands.sqf",true,1,false,true,"","_this in _target"];

};
};

To open command menu select "open commands" addaction.
To close command menu select "close commands" addaction.

This is 2nd version of convoy formation script in which player is leader of formation.
For this First place a column of vehicles on map which could be tanks , apcs or trucks.
Make the lead vehicle of column as PLAYER as leader.

If the vehicle formation has different groupname simply change groupname in formations.sqf
Convoygrp = bravoOne; to one specified.

In players vehicle Init -
Formcommands = this addaction ["Open commands","formcommands.sqf",true,1,false,true,"","_this in _target"];bravoOne= group this;

Next place formcommands.sqf and formations.sqf in mission folder.
formcommands.sqf
_Vehicle = _this select 0;
hint "Change convoy formation/speed/halt/move through scroll menu!";

sleep 1;

FormLine = _Vehicle addaction ["Form LINE","formations.sqf",["form line"],1,false,true,"","_this in _target"];

FormColumn = _vehicle addaction ["Form COLUMN","formations.sqf",["form column"],1,false,true,"","_this in _target"];

MoveSlow = _Vehicle addaction ["Slow speed","formations.sqf",["Move Slow"],1,false,true,"","_this in _target"];

MediumSpeed = _Vehicle addaction ["Medium speed","formations.sqf",["Move Medium"],1,false,true,"","_this in _target"];

MoveFast = _Vehicle addaction ["Full Speed","formations.sqf",["Move Fast"],1,false,true,"","_this in _target"];

Haltconvoy = _Vehicle addaction ["Halt convoy","formations.sqf",["Stop formation"],1,false,true,"","_this in _target"];

MoveConvoy = _Vehicle addaction ["Move convoy","formations.sqf",["Move Formation"],1,false,true,"","_this in _target"];

closeCommands = _vehicle addaction ["Close Commands","formations.sqf",["close commands"],1,false,true,"","_this in _target"];

sleep 1;
_vehicle removeaction formcommands;

exit;


Formations.sqf
_vehicle = _this select 0;
_changeFormations = (_this select 3) select 0;

sleep 1;
Convoygrp = bravoOne;//Name of vehicle group formation.
Convoygrp setCombatMode "RED";
Convoygrp setBehaviour "COMBAT";

sleep 1;
switch (_changeFormations) do {


case "form line":
{
leader convoyGrp sidechat "Form line!";
Convoygrp setformation "LINE";
};

case "form column":
{
leader convoyGrp sidechat "Form column!";
Convoygrp setformation "COLUMN";
};

case "Move Slow":
{
leader convoyGrp sidechat "Move at slow speed!";
Convoygrp setspeedMode "LIMITED";
_vehicle setspeedMode "LIMITED";
};

case "Move Medium":
{
leader convoyGrp sidechat "Move at medium speed!";
Convoygrp setspeedMode "NORMAL";
_vehicle setspeedMode "NORMAL";
};

case "Move Fast":
{
leader convoyGrp sidechat "Move at Full speed!";
Convoygrp setspeedMode "FULL";
_vehicle setspeedMode "FULL";
};

case "Stop formation":
{
leader convoyGrp sidechat "Stop!";
{doStop _x} forEach units convoyGrp;
driver _vehicle disableAI "MOVE";
};

case "Move Formation":
{
leader convoyGrp sidechat "Continue to waypoint!";
{_x doFollow leader convoyGrp} forEach units convoyGrp;
driver _vehicle enableAI "MOVE";
};

case "close commands":
{
hintsilent "command menu closed!";
_vehicle removeaction formLine;
_vehicle removeaction formColumn;
_vehicle removeaction MoveSlow;
_vehicle removeaction MediumSpeed;
_vehicle removeaction MoveFast;
_vehicle removeaction Haltconvoy;
_vehicle removeaction MoveConvoy;
_vehicle removeaction closecommands;

Formcommands = _vehicle addaction ["Open commands","formcommands.sqf",true,1,false,true,"","_this in _target"];

};
};

To open command menu select "open commands" addaction.
To close command menu select "close commands" addaction.

This post was edited by warbird (2016-08-05 16:27, ago)