Jump to content
Sign in to follow this  
Rommel

RMM Core Functions

Recommended Posts

Description:

These functions are some of most used generalised functions that I have produced for ArmA 2, and despite sharing them with others, they are used in my upcoming scripts.

They will be loaded into memory, and that is the end of it, there are no running scripts in this pack, they are simply functions for use by the mission maker / programmer.

Contents (mission folder):

init.sqf

mission.sqm

RMM_core.sqf

functions\f_doActionArgument.sqf

functions\f_getAlive.sqf

functions\f_getDirection.sqf

functions\f_getDistance.sqf

functions\f_getForecast.sqf

functions\f_getGroup.sqf

functions\f_getNearest.sqf

functions\f_getNearestBuilding.sqf

functions\f_getPosition.sqf

Usage:

functions\f_doActionArgument.sqf

Parameters: object addAction ["Action name", "functions\f_doActionArgument.sqf", {code}];
Example: this addaction ["Ask to Follow", "functions\f_doActionArgument.sqf", {[_target] joinSilent (group _caller)}];
Local Variables: _target, _caller

Relevant BIKI: http://community.bistudio.com/wiki/addAction

functions\f_getAlive.sqf

Description: A function used to find out who is alive in an array, being a group or an array.
Parameters: Units Array, Group or Unit
Example: (Units player) call RMM_f_getAlive
Returns: Array of alive units or Alive Unit

functions\f_getDirection.sqf

Description: A function used to find out the direction of a unit, group, or between two positions.
Parameters: Array containing two of [Object, Location, Group or Position]
Example: [[0,0,0], group player] call RMM_f_getDirection;
Returns: Number - Direction in degrees

functions\f_getDistance.sqf

Description: A function used to find out the distance between two positions.
Parameters: Array containing two of [Object, Location, Group or Position]
Example: _distance = [Player, [0,0,0]] call RMM_f_getDistance
Returns: Number - Distance in meters

functions\f_getForecast.sqf

Description: Function that returns a string containing the weather forecast
Example: _string = call RMM_f_getForecast
Returns: String - Weather Forecast

functions\f_getGroup.sqf

Description: A function used to find out the group of an object
Example1: _group = player call RMM_f_getGroup
Example2: _group = (group player) call RMM_f_getGroup
Returns: Group

functions\f_getNearest.sqf

Description: A function used to find out the nearest entity parsed in an array to a position. Compares the distance between entity's in the parsed array.
Parameters: Array with [[Object, Location, Group or Position], [Array of [Objects, Locations, Groups and or Positions]] or [[Object, Location, Group or Position], [Array of [Objects, Locations, Groups and or Positions], Distance]
Example: _nearestVeh = [player, vehicles] call RMM_f_getNearest
Example2: _nearestGroup = [[0,0,0], allGroups] call RMM_f_getNearest
Returns: Nearest given entity or List of entities within given distance

functions\f_getNearestBuilding.sqf

Description: A function used to find out the nearest building and appropriate building positions available
Parameters: Object
Example:_array = player call RMM_f_getNearestBuilding
Returns: Array with [building object, building positions (count)]

functions\f_getPosition.sqf

Description: A function used to position of an entity
Parameters: [Object, Location, Group or Position]
Example: _position = (group player) call RMM_f_getPosition
Returns: Position - [X,Y,Z]

Dependencies:

None

Installation:

Simple installation; copy and paste the functions folder (and its contents) into your mission directory.

copy and paste the RMM_Core.sqf file into your mission directory.

Either copy the line out of the init.sqf or paste the following line somewhere to execute the RMM_Core.sqf.

execvm "RMM_Core.sqf";

Compatibility Issues:

None known

Bug Report:

If you find anything, just post here or send me an email to rommel@australianarmedforces.org

... or forever hold your peace.

Author: Rommel

Date: 02/12/2009 (thats 12/02/2009 for the yanks)

Revision: 1.03

------------- DOWNLOAD -------------

Size: 4KB

Type: 7zip | .7z

Unpacker: www.7-zip.org

Mirrors:

http://www.4shared.com/file/163868701/e0f6de78/RMM_CoreChernarus.html

Edited by Rommel

Share this post


Link to post
Share on other sites

Updated to v1.03

103 Changed: RMM_Initdone can now be used to determine successful completion of RMM_Core execution.

102 Fixed: Function RMM_f_getPosition zero divisor error

101 Improved: Variable names

Share this post


Link to post
Share on other sites

Can someone please give me an example as to where to paste "execvm "RMM_Core.sqf";". The instructions say to paste it anywhere, but that didn't work when I tried that method. Thanks.

Share this post


Link to post
Share on other sites

A good place would be init.sqf.

This script is executed once the mission is started. It has to be located in the mission's root (where mission.sqm is).

Share this post


Link to post
Share on other sites

All these are now in CBA, this is now deprecated and there are huge improvements on them in CBA.

If you don't use CBA, then... well just use it, it is the best addon for ArmA2, and gives enormous functionality to addon/mission makers.

And to re-iterate a common association, CBA != ACE, and has no physical content as such, only fixes and functions.

:rolleyes:

EDIT: If you *must* have no addons, ie for a public server, then I could make a mission side variant of them again with the new functionality.

EDIT2: I am planning on making some interesting releases (in the form of addons, due to limited functionality of scripting, and the stacks on effect that occurs in mission folders...) for mission makers very soon, aimed at Arrowhead but obviously functional in A2 (ideally A2 1.06 however).

Edited by Rommel

Share this post


Link to post
Share on other sites

Ah great. Thanks for the reply.

I do use ACE, but was unaware that this functionality existed in it. I noticed a great improvement in game play while running ACE but did not know it went into the mission making side.

Suppose my problem would be, even now that I am aware of it, I wouldn't know how to implement it on my own. As at this point I can only implement scripts others have written, and toy with parameters.

Thanks again.

Share this post


Link to post
Share on other sites

That shed some light for me, and I saw some stuff I'm familiar with.

Thanks Rommel, your the man.

Share this post


Link to post
Share on other sites

Something that I use a lot, and is missing, is a normalize function. Now, I'm pretty sure I found one somewhere in either CBA or vanilla functions at some point, but I have lost it now. Maybe an error message should be logged/shown if limits are the same, dunno. With bad input, you get error message and unmodified output, but no script error. Should clamping be enabled by default like I do? Up to you, but I have never had the need to normalize anything without clamping the result myself. Here is what I use in case you want to implement it:

fn_Normalize = {
/*'
Examples:
[15] call fn_Normalize gives an error message, but returns input value.
[15, 1, 9] call fn_Normalize gives 1, since clamping is by default on.
[15, 1, 9, true] call fn_Normalize gives 1, obviously same as above.
[15, 1, 9, false] fn_Normalize gives 1.75 when clamping is turned off.

Practical example:
[_sunelevation, -14, -1] call fn_Normalize will scale the suns angle from -14° to -1° into
a 0-1 value which can be used to control a night post effect. If clamping was turned off,
you could get values the post effect system could not handle well. With clamping on, even
if the sun goes 50° below the horizon, you will get 0 as output instead of a negative value.
'*/
private ["_normalized","_min","_max","_failsafe","_clamp","_s"];
_normalized = _this select 0;
if (count _this < 3) exitWith {
	_s = format ["fn_normalize requires three parameters, only %1 given", count _this];
	hint _s;
	diag_log _s;
	_normalized
};
_min = _this select 1;
_max = _this select 2;
_clamp = if (count _this > 3) then {_this select 3} else {true};	//Optional parameter, default true. If false, answer may be outside 0-1 range.
_failsafe = if (_min == _max) then {0.0001} else {_min - _max};		//Avoids division by zero errors in the event of equal inputs.
_normalized= 1 - ((_normalized - _min) * (1 / _failsafe) +1);		//Scales the input parameter to 0-1.
if (_clamp) then {_normalized = _normalized max 0 min 1};		//And clamps outside values if not actively set to false.
_normalized
};

Edited by CarlGustaffa

Share this post


Link to post
Share on other sites

I don't understand the point of a few of these functions. Why create a function for distance when such functionality is already built into the game?

Share this post


Link to post
Share on other sites

Having created CBA_fnc_getDistance myself (previously RMM_fnc_getDistance), its use can seem abstract at best. Especially since the code is in pseudo form (it is even a 1 line function):

A distance B

What is it then? Well it is the following:

(ARG(0) call CBA_fnc_getPos) distance (ARG(1) call CBA_fnc_getPos)

Meaning? Well here is an example of some of the parameters

[player,"respawn_west"]

[player,[0,0,0]]

[player,group player]

[player,trigger1]

[player,task1]

Meaning, any two parameters of the types: marker, position, group, task, location, trigger etc.

Unlike the BIS native function.

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
Sign in to follow this  

×