Archive for category ArmA 3
Arma 3 Black Fade-In Intro
Posted by kylania in ArmA 3, Script Examples on June 25, 2016
Rip on the BIS forums had asked about a black fade in intro for his new mission. There’s countless ways of doing this but thanks to a hint from polpox I discovered that the new Bootcamp mission has introduced a function that makes a nice looking “infoText” effect. So I took some samples from the various ways I’ve done this before and came up with this.
Save the code as missionIntro.sqf. You can then call it from initPlayerLocal.sqf. There’s quite a few options you can set each with it’s own default. One “gotcha” is that if you don’t put anything in for any of the three first parameters the text typing effect will display %1, so if you want those blank put a space as in the examples.
missionIntro.sqf:
/* Author: kylania Description: Fade in from black intro, with a quote and Arma 3 style SitRep Date/Time/Mission credits. Run via execVM from playerInitLocal.sqf Parameter(s): 0: STRING - Name of the mission. SemiBold font under date during sitrep typing effect. Default: "An Arma 3 mission" 1: STRING - Author of the mission. Displayed under the mission name in medium font. Use a " " for nothing. Default: "by a Community Author" 2: STRING - Version of the mission. Displayed under the mission author in a medium font. Use a " " for nothing. Default: "Version 1.0" 3: STRING - Quote for center screen display on black screen. Default: "Not so long ago, not so far away...\n\n-A quote" 4: NUMBER - Duration of quote display. Default: 9 Returns: Nothing. Examples: ["Jungle Trek", "By Rip", "Version 1", '"A cat is a lion in a jungle of small bushes."\n\n-Indian proverb'] execVM "missionIntro.sqf"; ["A Mission", " ", " ", "", 0] execVM "missionIntro.sqf"; */ // Start with a silent black screen. titleCut ["", "BLACK FADED", 999]; 0 fadeSound 0; // Spawn text effects. _this spawn { params[ ["_missionName", "An Arma 3 mission"], ["_missionAuthor", "by a Community Author"], ["_missionVersion", "Version 1.0"], ["_quote", "Not so long ago, not so far away...\n\n-A quote"], ["_duration", 9] ]; // Starting quote as volume fades in. titleText [_quote,"PLAIN"]; titleFadeOut _duration; _duration fadeSound 1; sleep (_duration - 2); // New "sitrep style" text in bottom right corner, typed out over time. [ [_missionName,"font = 'PuristaSemiBold'"], ["","<br/>"], [_missionAuthor,"font = 'PuristaMedium'"], ["","<br/>"], [_missionVersion,"font = 'PuristaLight'"] ] execVM "\a3\missions_f_bootcamp\Campaign\Functions\GUI\fn_SITREP.sqf"; // Fade from black, to blur, to clear as text types. sleep 3; "dynamicBlur" ppEffectEnable true; "dynamicBlur" ppEffectAdjust [6]; "dynamicBlur" ppEffectCommit 0; "dynamicBlur" ppEffectAdjust [0.0]; "dynamicBlur" ppEffectCommit 5; titleCut ["", "BLACK IN", 5]; };
Gather Data addAction
Here’s a method for collecting “data” to complete a task in ArmA 3 using some new commands which make this process so much easier than in ArmA 2. This assumes that you have set a task called getDataTask either via scripting or by placing down a CreateTask module.
First place your object. By default we’ll only remove the addAction from the object once the data is collected however the script also supports an option to delete the object. Use of the new remoteExec command means that this is multiplayer compatible without lots of tricks or extra code!
object’s init field:
this addAction ["Gather Data", "data.sqf", ["getDataTask"]];
This will add an action to the object allowing the player to use the item to gather data from it. “getDataTask” is the name of the task we’ll complete. data.sqf is the script which will run.
data.sqf:
// this addAction ["Gather Data", "data.sqf", ["getDataTask"]]; // ["getDataTask", true] to optionally delete object. // Grab input. params ["_object", "_caller", "_id", "_args"]; // Grab arguments, task name String and optional Boolean to delete object. _taskID = _args param [0]; _deleteObject = _args param[1, false]; // Remove addAction from object. [_object, _id] remoteExec ["removeAction", 0, true]; // Have Base call out who found the intel. [[side _caller, "base"], format["%1 gathered the data!", name _caller]] remoteExec ["sideChat", 0, true]; // Succeed the task. [_taskID, "Succeeded", true] remoteExec ["BIS_fnc_taskSetState", 0, true]; // If optional delete flag set, remove the object where it's local. if (_deleteObject) then { _object remoteExec ["deleteVehicle", _object]; };
The first two lines are comments showing how to use the script. To optionally delete the object change the arguments array to include the true statement as shown on the second line.
The input section is where we capture all the input from the addAction command and shows the use of the new (from v1.48) params and param commands. Here’s a comparison of the ArmA 2 vs ArmA 3 versions of this code:
ArmA 2:
private ["_object", "_caller", "_id", "_args", "_taskID", "_deleteObject"]; _object = _this select 0; _caller = _this select 1; _id = _this select 2; _args = _this select 3; _taskID = _args select 0; _deleteObject = if (count _args > 1) then {_args select 1} else {false};
ArmA 3:
params ["_object", "_caller", "_id", "_args"]; _taskID = _args param [0]; _deleteObject = _args param[1, false];
I love how much more compact the new code is!
One of the main problems with using addAction is that it’s effects are local, meaning things you did in the script would only apply to the player who activated the addAction. This meant that to remove an action you had to find a way to remove it on all players which was often headache causing. With the introduction of remoteExec commands with ArmA 3 version 1.50 it’s now very simple to do just that!
For the rest of the script all the commands will be executed via remoteExec to make sure all players execute the commands even though they were run from a local addAction. Here’s a comparison of how the remoteExec command works:
Previously you’d have to run this on all clients:
_object removeAction _id;
Now the 0 on the right side means this will be run on all clients.
[_object, _id] remoteExec ["removeAction", 0, true];
Later on we use another feature of the remoteExec to delete an object where it’s local, again letting a local addAction control something nonlocal.
// Notice the 0 from before is replaced with an object, so only runs where _object is local _object remoteExec ["deleteVehicle", _object];
In the script we also use some commands to make the “base” of whichever side found the items call out the name of the player who found it and use the BIS_fnc_setTaskState function to display a notification of the task succeeding and marking it as completed.
There’s been a ton of great new commands for ArmA 3 which really makes things a lot easier to code.