Editor Codes

From 39th Battalion Wiki
Jump to navigation Jump to search


Index

Here you will find an expanding collection of codes that are useful for getting stuff done in the initialisation of mission objects.

Open/Close gate/door, trigger

  • Sliding gate
  1. Name gate (e.g. gate_1)
  2. Create trigger around or near gate
  3. Trigger activation:
gate_1 animate ["Door_1_Move", 1]; gate_1 animate ["Door_2_Move", 1];
  1. Trigger deactivation:
gate_1 animate ["Door_1_Move", 0]; gate_1 animate ["Door_2_Move", 0];
  • Swinging type gate/door
  1. Create trigger around or near gate
  2. Name gate (e.g. gate_2)
  3. Trigger activation:
gate_2 animate ["Door_1_Rot", 1];
  1. Trigger deactivation:
gate_2 animate ["Door_1_Rot", 0];

Notes: 1. 0 = close, 1 = open

Remove terrain objects, trigger

  1. Create trigger
  2. Trigger activation:
{
  _x hideObject true
} forEach (nearestTerrainObjects [position thisTrigger,[],((triggerArea thisTrigger select 0) + (triggerArea thisTrigger select 1)) /  2,false]);

Notes: 1. Will remove ALL terrain objects within trigger, however editor placed objects are ignored

Remove dead bodies from Garbage collection

In some instances, you would like to populate a FOB or checkpoint with dead bodies and have them stay during the mission to add atmosphere of something that went horribly wrong, without being deleted by the garbage collection system.

You can do this by name all the variables of units to be used as dead bodies body1, body2, etc. Open init.sqf and enter/modify the following:

removeFromRemainsCollector [body1, body2];
_killme = [body1, body2];
{_x setDamage 1} foreach _killme;

Note: Only line 1 and 2 are edited with unit names. Line 3 is just a loop to damage all under variable _killme

Animations by PLP, AI, script

Is the ‘one foot forward, weapon at rest’ position of AI looking a bit tired? Apply an animation to make NPC’s look more dynamic and alive.

  1. Ensure PLP_calmSoldier3.sqf is in script folder of mission
  2. Place NPC (non player character)
  3. In NPC init:
_nil = [0,"1",2,"3"] execVM "scripts\PLP_calmSoldier3.sqf"
  • Where:
  1. is NPC name.
  2. is animation type.
  3. is whether animation is “smoothly” adapted by NPC (not all animations support this being “TRUE”).
  4. is Gear State (best to leave as “ASIS”. Read as ‘as is’).
  • For example:
_nil = [this,"STAND",false,"ASIS"] execVM "scripts\PLP_calmSoldier3.sqf"

Notes:

  1. Animation types are available in the PLP_calmSoldier3.sqf file.
  2. This script is still being developed, but it seems to be more MP compatible than BIS animation functions.
  3. NPC will automatically react to combat.

Delete vehicle and crew, trigger

To relieve the server of computing the actions of live but unnecessary NPC vehicles, you may opt to remove the vehicle and crew by deleting it.

  1. Create trigger
  2. Trigger activation:
{{deleteVehicle _x} forEach crew _x + [vehicle _x]} forEach thisList;
  1. Force the vehicle via waypoint to pass through the trigger

Notes:

  1. The command does not prejudice; it will delete whatever enters it

IED detonation, trigger

IED named objects in the editor unfortunately have no way to detonate by themselves and as such remain an inert prop. The good thing is that any object, not just IED’s can be made to produce an explosion.

  1. Place down IED prop, or other object that is to explode
  2. Name IED (e.g. ied_1)
  3. Create trigger
  4. Trigger activation:
bomb="M_Mo_82mm_AT_LG" createVehicle (getPos ied_1); deletevehicle ied_1;

Notes:

  1. In the example, "M_Mo_82mm_AT_LG" is the classname of a laser guided 82mm Mortar munition that is used to reproduce an IED explosive effect.
  2. The munition type can be changed to something less or more significant depending on the desired outcome, for example “Bo_GBU12_LGB” is the effect of a GBU-12 Laser Guided Bomb.
  3. More ammunition class names can be found here. Testing is encouraged as

Texture, attach to object

A property called hidden selections exists in certain objects and as such a custom texture can be applied to them.

  • Create the image
  1. Most objects (not all) where textures can be applied, e.g. an existing sign or TV are the size ratio of 2:1 (2 wide x 1 high)
  2. Texture can only be JPG or PAA image format
  • Store image in img folder of mission
  • In init of object to be textured:
this setObjectTexture [0, "img\texture.paa"];

Notes:

  • For flags use;

this setFlagTexture "img\texture.paa";

Addaction, Interactable Object/Person

Adds the ability to interact with an AI and get them to give the player specific mission details

  1. In the init of AI place what you see below
this addAction[“INTERACTION TITLE (e.g. SPEAK TO MAYOR)”, {hintc "WHAT THE MAYOR WILL SAY"},nil,1.5,true,true,"","true",4,false,"",""];

NOTE: The “What the mayor will say” part can be as long as it needs to be, but is best done outside of arma so spelling can be checked and any errors corrected. https://community.bistudio.com/wiki/addAction

Interactable Intel

Adds intel to the map screen that any player on the server can read. It can be in written, visual (custom intel image) or a mixture of both on the map screen.

  1. Add this to the init of the intel object
if (isServer) then { this setVariable ["RscAttributeDiaryRecord_texture","img\INTEL.jpg", true]; [this,"RscAttributeDiaryRecord",["INTEL NAME","WHAT INTEL WILL SAY",""]] call bis_fnc_setServerVariable; this setVariable ["recipients", west, true]; };

ACE, make object carryable

  1. In init of object to be carryable
[this, true, [0,0,1], 0] call ace_dragging_fnc_setCarryable;
  • Where:
  1. [0,0,1] is x,y,z location of object relative to player
  2. , 0] is object rotation in degrees relative to player

ACE, make object loadable

  1. In Editor, locate and place ACE Module, Make Object Loadable
  2. Sync module with object(s) that require to be loadable into ACE Cargo

Waypoint, AI wait until trigger fired

In some instances, it may not be feasible or possible to sync a waypoint to a trigger for activation. This command in the waypoint will wait until a remote trigger has been activated.

  1. Create and name trigger, e.g. trigger_1
  2. In waypoint activation:
triggerActivated trigger_1
  1. NPC will wait at waypoint until trigger elsewhere is activated

Markers, create by Trigger or AddAction

During game, markers can be created not only by players but also by triggers, for example making task generation or information delivery more automated.

  • Create Marker by Trigger
  1. Create trigger
  2. In activation:
taskname = createMarker ["marker_name", [X,Y]]; "marker_name" setMarkerType "mil_box"; "marker_name" setMarkerColor "colorBLUFOR"; "marker_name" setMarkerText "WP1";
  • Where
  1. taskname is unique variable name for this entire task
  2. “marker_name” is unique name given to specific marker
  3. [X,Y] are the coordinates on the map the marker will appear
  4. setMarkerType, setMarkerColor are attributes to customise the marker
  5. setMarkerText is the label for the marker that will be seen in map
  • Create Marker by object AddAction
  1. Place and name object, e.g, Laptop called laptop_1
  2. In init of Laptop:
laptop_1 addAction ["Onscreen Prompt", {
   private _mrk = createMarker ["marker_name", [10000, 10000]];
   _mrk setMarkerType "mil_box";
   _mrk setMarkerColor "colorBLUFOR";
   _mrk setMarkerText "WP1";
}];
  1. Where "Onscreen Prompt" is a custom on screen message shown to players indicating an AddAction is available
  2. All other parameters are the same as by trigger, above.

Notes:

  1. Configuration choices for setMarkerType, setMarkerColor are available via their hyperlink.

Arsenal, attach to object

To create an unrestricted Arsenal on an object.

  1. Place object (e.g. barrel)
  2. In object init:
["AmmoboxInit",[this,true]] call BIS_fnc_arsenal;

Teleport, trigger

Creates a simple one way transport system, between an entry trigger and an exit.

  • Create and name “exit” trigger, e.g. range
  • Create “entry” trigger
  1. Side to activate, e.g. BLUFOR
  2. Set repeatable
  3. Entry trigger Condition:
player in thisList
  1. Entry trigger On Activation:
this setPosATL (getPos range);

Object, attach to object

One or more objects, for example a weapon turret can be attached to other objects, like a truck becoming one synchronised entity.

  1. Create and name host object, e.g. a Ural and truck_1
  2. Create and name the object to be attached, e.g. a HMG turret and gun_1
  3. In object to be attached (turret) init:
gun_1 attachTo [truck_1,[0,0,1]];
  • Where [0,0,1] is x,y,z coordinates measured in metres relative to the host object (i.e.Ural). These values need to be adjusted in order to move the turret to your preferred location on the truck.

Ammunition, unlimited

Gives ability to turrets to have unlimited ammunition.

  1. Place turret or vehicle
  2. In turret or vehicle init:
this addEventHandler ["Fired",{(_this select 0) setVehicleAmmo 1;}]

Side alliance, trigger

Ability to set or change side 1 alliance to side 2.

  1. Place trigger
  2. In On Activation:
side1 setFriend [side2 , value]
  • Where side 1 is side to have an active behaviour change
  • side 2 is passive recipient of side 1 change
  • value will be:
  1. 0 = false
  2. 1 = true
  3. For example:
CIVILIAN setFriend [WEST , 1]
  • Says that Resistance (or Guerrilla) will be friendly with Opfor.

Notes:

  • Faction names:
  1. Blufor = WEST
  2. Opfor = EAST
  3. Guerilla = RESISTANCE
  4. Civilians = CIVILIAN
  • Be aware that this command only sets the friendliness of one side. If you want to have both sides attacking each other, you have to set both.
  • It is possible to make a side hostile towards itself. For example:
west setFriend [west, 0]

Radio Command restricting, trigger

Do you have radio trigger(s) that you only want activated by a particular player?

  1. Name player, e.g. curator
  2. In radio trigger Condition:
this && player == curator

Say3D

Sounds can be configured to broadcast within a certain range of an object or NPC. This function requires that a 16-bit OGG audio file already exist and the sound’s class variables have been set up in description.ext.

  1. Sample description.ext entry
class CfgSounds
{
   sounds[] = {};
   
   class mortar                            < classname of sound
   {
       name = "mortarsiren";               < name used in init fields
       sound[]={sound\siren.ogg, db+10,1}; < audio file/path, decibels, pitch
       titles[] = {0, ""};                 < only if subtitles will accompany
   };
};
  • In object’s init field, the classname of the sound is used with say3D
this say3D ["mortar", 300, 1];
  • Where
  1. this is an object where sound will originate
  2. “mortar” is classname of sound to be played
  3. 300 is range in metres from object sound should be heard
  4. 1 is pitch

Notes:

  • Sound looping. A sound will normally reach the end of its track length and stop. In order to force a track to loop, follow these steps:
  1. Create new soundLoop.sqf file in root of mission folder, and within:
_soundObject = _this select 0;
_trackLength = 30;              <edit
_delay = 0;                     <edit
while{True} do
{
 _soundObject say3D "generator";
 sleep _trackLength + _delay;
};
  • Where:
  1. _trackLength = is the length of the track played before restarting
  2. _delay = delay between track restarts
  • In object init field (sound source)
_nul = [this] execVM "soundLoop.sqf";

2. YouTube tutorial: https://www.youtube.com/watch?v=23gtR0tQhBQ

ACE Vanilla Damage Fix

In some unusual circumstances the vanilla medical system will apply itself to player injuries and ACE Medical is unable to recognise and hence no treatment avenues are available. The following code adds an option to the ACE self interaction menu in order to fully heal a player who may be afflicted. Copy and paste the following code into the initplayerlocal.sqf to initialise:

// ACE Vanilla damage fix
VanillaDamageFix = ['VanillaDamageFix','Fix Vanilla Damage',,{player setDamage 0},{_target == player},{}] call   ace_interact_menu_fnc_createAction;
[typeof player, 1, ["ACE_SelfActions"], VanillaDamageFix] call ace_interact_menu_fnc_addActionToClass;

SkipIntro

In some cases you will need to disable the intro.sqf from running when a player JIPs, if you are calling scripts within the Intro.sqf i.e. spawning a vehicle to a set position and setting its damage level to 1. Will result in the same action being executed for JIP resulting duplications and ruining the mission atmosphere.

Add the following code to the first line of the init.sqf

if (isServer) then {
 0 spawn {
    sleep 30;
    <scriptname> = true;
    publicVariable "SkipIntro";
 };
};

Add the following code to your script file intro.sqf as the 1st line.

if (!isNil "SkipIntro") exitWith {};

Searchlight, Action On

The following code, applied to a mounted Searchlight turret will switch On the Searchlight when the AI does not.

  1. Add the following code to the init box of the Searchlight:
this action ["lightOn", this];

setCaptive, trigger

Change a player’s status to civilian (setCaptive) when they are inside a trigger.

  • Place trigger
  • Set parameters
  1. Type: None
  2. Activation: Any Player
  3. Activation Type: Present
  4. Repeatable: On
  5. Condition:
player in thisList
  • On Activation:
player setcaptive true;
  • On Deactivation:
player setcaptive false;

Respawn in waves

Change the respawn values in the description.ext

From

respawnDelay = 99999;
respawnTemplates[] = {"ace_spectator"};

To

respawnDelay = 10;
respawnTemplates[] = {"ace_spectator","wave"};

Creating a Hold Enter to perform action

Adds an action to an object which requires the user to hold a key to perform the action can be used for such things like search fo intel or trigger a bomb, you will need to enter your code to execute for desired effect in the code execution on completion section.

Enter the code into the init section of any object or unit.

Example in mission using a HintC

 [
  Satphone,
  "Insert USB Hack Device",
  "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
  "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
  "_this distance _target < 3",
  "_caller distance _target < 3",
  {},
  {},
  {hintC "The device displays a bearing indicator 211 and remote station is connected, before the screen fades to black and becomes unresponsive." },
  {},
  [],
  12,
  0,
  true,
  false
 ] 
remoteExec ["BIS_fnc_holdActionAdd", 0, Satphone];

Addaction, move object to x,y,z

Although Addaction is covered elsewhere, this is documenting a way to use Addaction to move an object to new x,y,z coords.

this addAction ["My Action", "my script.sqf", [],1,false,true,"","_this distance _target < 2"];

Where:

  1. “My Action” = Name to display on action menu (String)
  2. “My script.sqf” = Commands or scripts to be run
  3. [] = Space to include arguments passed to script (optional)
  4. 1 = Priority of where it'll appear on the action menu list (Number)
  5. false = Display on center of the screen? True or False Boolean
  6. true = Close the action menu when used? True or False Boolean
  7. “” = Shortcut key (String, Optional)
  8. "_this distance _target < 2" = Condition (string, in this case distance to Addaction)

Example:

this addaction ["Launch Boat","boat_1 setpos  [16525.865,12485.36,0]; _this#0 removeAction _this#2",[],1,true,true,"","_this distance _target <2"]

Open vehicle door

Some doors on vehicles have an animation ability to be opened or closed on command. For instance you might want a door to be opened on game start to give the impression that it has just been exited for immersion.

  1. Identify classname of vehicle, e.g. C_IDAP_Van_02_vehicle_F
  2. Open Config Viewer (Eden/Tools/Config Viewer)
  3. Browse to and expand cfgVehicles
  4. Browse to and expand vehicle classname, in this case C_IDAP_Van_02_vehicle_F
  5. Browse to and expand UserActions
  6. Choose desired animation, for example Sidedoor_Open
  7. In right window frame, look for statement =
  8. Copy line (CTRL + C)
  9. Close Config Viewer (ESC)
  10. Paste line into init of vehicle
  11. Edit line so that only inside of quotes remains. That is:

From:

statement = "this animateDoor ['Door_3_source', 1]";

To:

this animateDoor ['Door_3_source', 1];

Note: Some vehicles have only limited animation options or none at all