Jtgibson/Tips – User

From Bohemia Interactive Community
Jump to navigation Jump to search

This is just a repository of useful information I've dug up in my occasional gorilla-like bashing on the keyboard and hooting. (I try not to throw feces. I am, after all, civilised.)

I found some of this information in an old file I had been sitting on for a while and never got around to putting up anywhere. Since I've more or less given up on a personal website these days -- all it was good for was having my former employer spy on me -- I'll just throw it up as a biki subpage instead. =)

"Some input after EndOfFile"

This error in the Addon Builder occurs if you are missing the brackets when declaring an array in a configuration (and the award for most cryptic and least accurate error message goes to...). class CfgPatches { class JTACEBloodOverlay { name = "ACE - Restore Blood Overlay"; requiredVersion = 0.1; requiredAddons = {"ace_medical"}; author = "JT"; units[] = {}; weapons[] = {}; }; };

versus:

class CfgPatches { class JTACEBloodOverlay { name = "ACE - Restore Blood Overlay"; requiredVersion = 0.1; requiredAddons[] = {"ace_medical"}; author = "JT"; units[] = {}; weapons[] = {}; }; };

How to determine if a plugin is installed

Attempt to load a known class that would be provided by that plugin, and then test isClass to see if the class is valid. If not, the plugin is not installed.

	_isMyClassActive = isClass (configFile / "CfgPatches" / "MyClass");

It can sometimes be beneficial when creating a script-only addon to create a dummy module that allows scripters to test for its existence.

Get object/point under crosshairs

There are several useful functions for this:

cursorTarget returns the object you see the unit info text for. For instance, if you are holding your crosshairs over a friendly and it identifies them as "Rifleman", they are your cursortarget. What's interesting is that this behaviour carries over to lockable weapons, so as long as you have a target locked on your HUD (and can therefore still see their HUD info, e.g., "MSE-3 Marid"), they will remain your cursortarget even if no longer pointing directly at them.

cursorObject was added in Arma 3 v1.56 to address this problem. It always yields the objects directly under your crosshairs.

screenToWorld is also incredibly handy -- whatever screen coordinates you pass in (from 0 to 1 on the horizontal and from 0 to 1 on the vertical) will translate into a specific point on the map. Unless, of course, you're pointing off into space. You get nothing! Get out of my factory!

De-simulate an object (reduce memory footprint/"virtualise")

Three steps can be taken to desimulate an object. All in combination provide the optimal solution:

	//Move object 50 metres underground
	_this setPosATL [(_this getPos select 0), (_this getPos select 1), (_this getPos select 2)-50];

	//Hide object from server
	hideObjectGlobal _this;

	//Disable simulation to reduce/eliminate network traffic
	_this enableSimulation false;

A de-simulated object should be stored in a variable or otherwise tracked, as otherwise it is difficult to locate by script.

ACE3

ACE3 Cargo: Add virtual cargo

To create a new virtual object, simply add its classname to the object's "ACE_cargo_loaded" array:

	_array = _this getVariable ["ACE_cargo_loaded", []];
	_array pushBack "ACE_Wheel"; //Add the virtual class "wheel" onto the end of the array
	
	_array pushBack "ACE_Wheel"; //Add two more wheels
	_array pushBack "ACE_Wheel";

This is far more efficient than using the ACE3 cargo attachment module, which actually creates "real" objects and then attaches them invisibly to the unit.

If putting into a vehicle's init script, you cannot use local variables, so will have to use an external function instead.

ACE3 Cargo: Iterating and deleting

The cargo module in ACE is somewhat complicated because objects in cargo can either exist as true objects -- which are hidden and attached to the object -- or as virtual objects -- which exist only as a classname and are spawned when created. The advantage of having true objects as cargo is that their properties (damage, contents, etc.) are preserved, while virtual objects are very efficient for the engine (only a few bytes to store a prototypical object).

All of the objects are stored in the object's "ACE_cargo_loaded" array, so iterating through this list will reveal all of the objects contained as cargo.

If the object is not the same type as objNull, you know it is a virtual object and can be removed from the array to delete. If the object IS equivalent to objNull, it must be removed from the array and then destroyed with deleteVehicle.