Home   Help Search Login Register  

Author Topic: RLS Library  (Read 1149 times)

0 Members and 1 Guest are viewing this topic.

Offline Denisko-Redisko

  • Members
  • *
RLS Library
« on: 22 Dec 2009, 02:01:46 »
Hi All!
I want to share a library of functions that I use in their scripts.
For the most part, it functions of the quick work with config. I will cite here some of the descriptions, the rest of documentation can be found in the archive with the library.

In our own project, I use macro func and invoke, for the definition and function calls. Also, the functions can be called by the generic name, they all have the prefix rls_func_.

func(ReadSlotPrimary), func(ReadSlotHandGun), func(ReadSlotSecondary),
func(ReadSlotHandGunMag), func(ReadSlotMag), func(ReadSlotGoggle), func(ReadSlotHardMounted),
func(ReadSlotItem)

syntax:
Code: [Select]
(string vehicleClassName) invoke(ReadSlot<SlotName>)Returns the number of (respectively) slots available vehicleClassName.

func(ReadModes)
syntax:
Code: [Select]
(string weaponClassName) invoke(ReadModes)
(config weaponClassEntryPoint) invoke(ReadModes)
Returns an array of entry points into the "modes". Array of config.

func(ReadMuzzles)
syntax:
Code: [Select]
(string weaponClassName) invoke(ReadMuzzles)
(config weaponClassEntryPoint) invoke(ReadMuzzles)
Returns an array of entry points into weapons' muzzles. Array of config.
Example of func(ReadModes) and func(ReadMuzzles):
Code: [Select]
// correct reading of the properties of weapons (it real value of dispersion)
hint str getNumber (
    ((primaryWeapon player invoke(ReadMuzzles) select 0) invoke(ReadModes) select 0) >> "dispersion"
);

// the most accurate of all available muzzles
_dispersion = 1e40; // 1.#INF
{
    {
        _dispersion = _dispersion min getNumber (_x >> "dispersion")
    } foreach (_x invoke(ReadModes))
} foreach (primaryWeapon player invoke(ReadMuzzles));
hint str _dispersion;
func(ReadAnyMagazines)
syntax:
Code: [Select]
(string weaponClassName) invoke(ReadAnyMagazines)Return all compatibles magazines. Array of string.
Example:
Code: [Select]
"m16a4" invoke(ReadAnyMagazines);
result:
[
    "30Rnd_556x45_Stanag", "30Rnd_556x45_StanagSD", "20Rnd_556x45_Stanag",
    "30Rnd_556x45_G36", "100Rnd_556x45_BetaCMag", "30Rnd_556x45_G36SD"
]

func(IsMagazineSD)
syntax:
Code: [Select]
(string MagazineName) invoke(IsMagazineSD)Returns true if the magazine uses noiseless ammo.

func(FilterWeaponSDSense)
syntax:
Code: [Select]
(string weaponClassName) invoke(FilterWeaponSDSense)
(array of string listOfWeaponClassNames) invoke(FilterWeaponSDSense)
(object unit) invoke(FilterWeaponSDSense)
(otherType value) invoke(FilterWeaponSDSense)
Returns are compatible magazines in the form of an array:
Code: [Select]
[                                                             // weaponlist
    [weapon classname,                                        // pair: weapon & muzzlelist
        [                                                     // muzzlelist
            [muzzle configEntry,                              // pair: muzzle & ammolist
                [                                             // ammolist
                    [magazine configEntry, ammo configEntry],
                    [magazine configEntry, ammo configEntry]
                ]
            ]
        ]
    ],
    [weapon classname,
        [
            [muzzle configEntry,
                [
                    [magazine configEntry, ammo configEntry],
                    [magazine configEntry, ammo configEntry]
                ]
            ]
        ]
    ]
]
Note: If the unit, there will be a used list of weapons used by the unit.
Note: If the "other type value", there will be a used list of all weapons, that presented in game.
Note: SD-sensitive, suppressed ammo are returned only for weapons (muzzles) of a small flash, and vice versa - for such guns are returned only suppressed ammo.

func(IsWeaponSD)
syntax:
Code: [Select]
(string weaponClassName) invoke(IsWeaponSD)
(array of string listOfWeaponClassNames) invoke(IsWeaponSD)
(object soldier) invoke(IsWeaponSD)
Returns true if the weapon has a small flash and uses a noiseless ammo.
Note: If the soldier, there will be a used list of weapons used by the soldier.
Example:
Code: [Select]
// true if is the primary weapon with the suppressor
primaryWeapon player invoke(IsWeaponSD)
// true if player has weapon with the suppressor
weapons player invoke(IsWeaponSD)

func(FilterWeapon)
syntax:
Code: [Select]
[
    string weaponClassName or
    array of string listOfWeaponClassNames or
    object soldier or
    otherType value,
    {
        declarative query
    }
] invoke(FilterWeapon)
Filter an array of weapons custom filters (for more, see. "en.funcFilterWeapon.readme.html")
First and foremost this function is base for such functions as: func(FilterWeaponSD), func(FilterATGun), func(FilterAAGun)
Example:
Code: [Select]
>>>> search all weapon with ammo with simulation == shotRocket
[player, { _ammoFilter = {
    getText ( _ammo >> "simulation" ) == "shotRocket"
}}] invoke(FilterWeapon)
>>>> result:
[ // weapon list
    ["SMAW", // weapon classname
        [ // muzzle list
            [/CfgWeapons/SMAW", // muzzle
                [ // ammolist, list of pairs: magazine configEntry & ammo configEntry
                    [/CfgMagazines/SMAW_HEAA, /CfgAmmo/R_SMAW_HEAA],
                    [/CfgMagazines/SMAW_HEDP, /CfgAmmo/R_SMAW_HEDP]
                ]
            ]
        ]
    ]
]

func(FilterWeaponSD)
syntax:
Code: [Select]
(string weaponClassName) invoke(FilterWeaponSD)
(array of string listOfWeaponClassNames) invoke(FilterWeaponSD)
(object soldier) invoke(FilterWeaponSD)
(otherType value) invoke(FilterWeaponSD)
Search (in listOfWeaponClassNames) SD weapons (has a small flash and uses a noiseless ammo), search result is returned as an array of formats.
Note: If the soldier, there will be a used list of weapons used by the soldier.
Note: If the "other type value", there will be a used list of all weapons, that presented in game.
Example:
Code: [Select]
player invoke(FilterWeaponSD)
>>>> result
[
    ["M9SD",
        [
            [/CfgWeapons/M9SD,
                [
                    [/CfgMagazines/15Rnd_9x19_M9SD, /CfgAmmo/B_9x19_SD]
                ]
            ]
        ]
    ],
    ["M4A1_AIM_SD_camo",
        [
            [/CfgWeapons/M4A1_AIM_SD_camo,
                [
                    [/CfgMagazines/30Rnd_556x45_StanagSD, /CfgAmmo/B_556x45_SD],
                    [/CfgMagazines/30Rnd_556x45_G36SD, /CfgAmmo/B_556x45_SD]
                ]
            ]
        ]
    ]
]
// get all sd-weapons from game config
0 invoke(FilterWeaponSD)

func(FilterATGun)
syntax:
Code: [Select]
(string WeaponClassNames) invoke(FilterATGun)
(array of string listOfWeaponClassNames) invoke(FilterATGun)
(object soldier) invoke(FilterATGun)
(otherType value) invoke(FilterATGun)
Search (in listOfWeaponClassNames) weapons capable of hitting a tank. Output format is similar to the output format of the function FilterWeaponSD.
Note: If the soldier, there will be a used list of weapons used by the soldier.
Note: If the "other type value", there will be a used list of all weapons, that presented in game.

func(FilterAAGun)
syntax:
Code: [Select]
(string WeaponClassNames) invoke(FilterAAGun)
(array of string listOfWeaponClassNames) invoke(FilterAAGun)
(object unit) invoke(FilterAAGun)
(otherType value) invoke(FilterAAGun)
Search (in listOfWeaponClassNames) weapons homing (irLock). Output format is similar to the output format of the function FilterWeaponSD.
Note: If the soldier, there will be a used list of weapons used by the soldier.
Note: If the "other type value", there will be a used list of all weapons, that presented in game.

func(FilterFirearm)
syntax:
Code: [Select]
(string WeaponClassNames) invoke(FilterFirearm)
(array of string listOfWeaponClassNames) invoke(FilterFirearm)
(object unit) invoke(FilterFirearm)
(otherType value) invoke(FilterFirearm)
Search (in listOfWeaponClassNames) firearm weapons (weapons firing shotBullets). Output format is similar to the output format of the function FilterWeaponSD.
Note: If the soldier, there will be a used list of weapons used by the soldier.
Note: If the "other type value", there will be a used list of all weapons, that presented in game.

func(ReadActions)
syntax:
Code: [Select]
[string unitClassName, string targetAnimation] invoke(ReadActions)Return the entrypoint to class Actions (configFile >> _unitClassNameMoves >> "Actions") for specified unitClassName and his targetAnimation.
Example:
Code: [Select]
player playMove ([typeOf player, animationState player] invoke(ReadActions) >> "reloadMagazine")
// is the same as that:
player playAction "reloadMagazine"

func(ReadAnimType)
syntax:
Code: [Select]
(object soldier) invoke(ReadAnimType)Returns the type of the current animation. One of the following:
Code: [Select]
"ManPosDead", "ManPosStand", "ManPosCombat", "ManPosCrouch", "ManPosLying", "ManPosHandGunStand", "ManPosHandGunCrouch", "ManPosHandGunLying", "ManPosNoWeapon", "ManPosLyingNoWeapon", "ManPosWeapon", "ManPosNoWeapon", "ManPosStand", "ManPosSwimming",
"ManPosBinoc", "ManPosBinocLying", "ManPosBinocStand"

func(ReadUpDegree)
syntax:
Code: [Select]
(object soldier) invoke(ReadUpDegree)Returns the value of the property UpDegree (AI Animation State) of the animation for the specified unit. Number type.

func(MapGrep)
syntax:
Code: [Select]
[array list, code filter] invoke(MapGrep)
[config class, code condition] invoke(MapGrep)
Returns an array for those elements for which the condition evaluates to notNil. Example:
Code: [Select]
// Returns all classnames of cars.
[configFile >> "CfgVehicles", {
    if( getText(_x >> "simulation") == "car" ) then { configName _x }
}] invoke(MapGrep)

// names of players' soldiers
[ units player, { name _x } ] invoke(MapGrep)

// positions of all cars requiring repairs:
[allUnits, {
    if( _x isKindOf "Car" && ! canMove _x ) then { getPosASL2 _x }
}] invoke(MapGrep)
sorry for my english