BIS fnc initVehicle: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Text replacement - "[[Arma 3: Vehicle Customization" to "[[Arma 3: Vehicle Customisation")
 
(51 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= arma3
____________________________________________________________________________________________
|version1= 1.42


| arma3 |= Game name
|arg= local


|1.42|= Game version
|eff= global
____________________________________________________________________________________________


| <pre>/*
|gr1= Vehicles
Author: Julien `Tom_48_97` VIDA


Description:
|descr= This function changes the textures, animation sources and/or mass of a given vehicle.<br>
This function aims to simplify the way to customize vehicles. It can change the textures and/or the animation sources of a given object. Usage of this function is explained in the below examples.
Unless explicitly mentioned , the function will restore the initial state of every animation sources of the given object (see {{Link|#Example 3}}).


Important note: Unless it explicitly mentionned (example case 10), the function will restore the initial state of every animation sources of the given object.
|s1= [vehicle, variant, animations, mass] call [[BIS_fnc_initVehicle]]


Additional information:
|p1= vehicle: [[Object]] - vehicle to customize
OPREP - http://dev.arma3.com/post/oprep-vehicle-customization
Community Wiki - https://community.bistudio.com/wiki/Vehicle_Customization_%28VhC%29


Parameter(s):
|p2= variant: (Optional, default [[false]])
0: vehicle to customize
* [[Boolean]] - [[true]] to restore default texture source, [[false]] to skip texture source change
1: Variant (textures)
* [[Array]] - texture sources with their probability in format <sqf inline>["textureSource1", 0.5, "textureSource2", 0.5]</sqf>
BOOL - true to restore default texture source ; false to skip texture source change
* [[String]] - variant class name - from <sqf inline>configFile >> "CfgVehicles"</sqf> or <sqf inline>missionConfigFile >> "CfgVehicleTemplates"</sqf> (see [[Description.ext#CfgVehicleTemplates|CfgVehicleTemplates]])
VOID - Nil to skip the texture source change
* [[Number]] - index of the texture source (same as the old system)
ARRAY - Array of texture sources with their given probability: ["textureSource1", 0.5, "textureSource2", 0.5]
STRING - Variant class name(from the configFile >> cfgVehicles or from the missionConfigfile >> cfgVehicleTemplate)
SCALAR - index of the texture source (same as the old system)
2: Animations
BOOL - true to restore init phase of every animation sources
VOID - Nil to skip change of the animation sources
ARRAY - Array of animation sources and probability: ["AnimationSource1", 0.5, "animationSource2", 0.5]. Note, if the first element is false, it will skip the reset of the animation sources
STRING - Variant class name(from the configFile >> cfgVehicles or from the missionConfigfile >> cfgVehicleTemplate)
3: Mass
BOOL - true to set the default mass, false to disable the mass change
SCALAR - Mass to add or remove the vehicle


Returns:
|p3= animations: (Optional, default [[false]])
BOOL - True if success, otherwise, false
* [[Boolean]] - [[true]] to restore init phase of every animation sources
* [[Array]] - animation sources with their probability in format <sqf inline>["animationSource1", 0.5, "animationSource2", 0.5]</sqf>{{Feature|important|
If the first element is wrong, it will skip the rest of the animation sources!}}
* [[String]] - variant class name - from <sqf inline>configFile >> "CfgVehicles"</sqf> or <sqf inline>missionConfigFile >> "CfgVehicleTemplates"</sqf> (see [[Description.ext#CfgVehicleTemplates|CfgVehicleTemplates]])


Examples:
|p4= mass: (Optional, default [[false]])
1) Do nothing because default VAR texture and VAR animation are "false"
* [[Boolean]] - [[true]] to set the default mass, [[false]] to disable the mass change
result = [this] call bis_fnc_initVehicle;
* [[Number]] - mass to remove/add to the vehicle


2) Restore default texture and animation sources (reset)
|r1= [[Boolean]] - function success or not
result = [this, true, true] call bis_fnc_initVehicle;


3) Randomize everything according to the config file
|x1= <sqf>result = [this, "", []] call BIS_fnc_initVehicle;</sqf>
result = [this, "", []] call bis_fnc_initVehicle; //<-- Prefered
result = [this, "", ""] call bis_fnc_initVehicle;


4) Skip everything
|x2= <sqf>result = [this, ["MyTextureSource1", 0.5, "MyTextureSource2", 0.6], []] call BIS_fnc_initVehicle;</sqf>
result = [this, nil, nil] call bis_fnc_initVehicle; //<-- Prefered
result = [this, false, false] call bis_fnc_initVehicle;


5) Apply the given texture and ignore the animations
|x3= <sqf>result = [this, nil, ["MyAnimationSource1", 0.5, "MyAnimationSource2", 0.7]] call BIS_fnc_initVehicle;</sqf>
Priority is given to [missionConfigFile, "CfgVehicleTemplates"]
result = [this, "TemplateName", nil] call bis_fnc_initVehicle;


6) random weighted on the given texture sources and their probability, then randomize the animation sources according to the config file
|x4= <sqf>
result = [this, ["MyTextureSource1", 0.5, "MyTextureSource2", 0.6], []] call bis_fnc_initVehicle;
// randomise camo net options with 50% probability
[vehicle player, false, ["showcamonethull", 0.5, "showcamonetturret", 0.5, "showcamonetcannon", 0.5, "showslathull", 0.5]] call BIS_fnc_initVehicle;
</sqf>


7) MyAnimationSource1 phase has a 50% chance to be set to 1 and MyAnimationSource2 has a 70% chance to be set to 1
|x6= <sqf>
result = [this, nil, ["MyAnimationSource1", 0.5, "MyAnimationSource2", 0.7]] call bis_fnc_initVehicle;
// force show all camo net options. Use animationNames to get all available animation sources. Vehicles that don't support certain animations are simply ignored.
 
[vehicle player, false, ["showcamonethull", 1, "showcamonetturret", 1, "showcamonetcannon", 1, "showslathull", 1]] call BIS_fnc_initVehicle;
8) MyAnimationSource1 phase will be 1 whereas MyAnimationSource2 will be set to 0
</sqf>
result = [this, nil, ["MyAnimationSource1", 1, "MyAnimationSource2", 0]] call bis_fnc_initVehicle;
 
9) Change animation sources with a given template
result = [this, nil, "MyTemplate"] call bis_fnc_initVehicle;
 
10) Change animation source with a given array of probabilities but skip the reset of all animation sources
// Algo: Skip the change of texture, [don't reste of the animation sources, proceed the given animation sources with their, probabilities], skip the change of mass
result = [this, nil, [false,"MyAnimationSource1", 0.5, "MyAnimationSource2", 0.8], nil] call bis_fnc_initVehicle;
 
11) Restore the vehicle to its default state as defined in the config (texture, animation sources, mass) (For the texture, the first item of the texture list is used)
result = [this, true, true, true] call bis_fnc_initVehicle;
 
*/
</pre> |= Description
____________________________________________________________________________________________
 
| <!-- [unitName, [], []] call BIS_fnc_unitHeadgear; --> |= Syntax
 
|p1=  |= Parameter 1
 
| |= Return value
____________________________________________________________________________________________
 
|x1= <code>result = [this, "", []] call bis_fnc_initVehicle;</code> |=
 
|x2= <code>result = [this, ["MyTextureSource1", 0.5, "MyTextureSource2", 0.6], []] call bis_fnc_initVehicle;</code> |=
 
|x3= <code>result = [this, nil, ["MyAnimationSource1", 0.5, "MyAnimationSource2", 0.7]] call bis_fnc_initVehicle;</code> |=
____________________________________________________________________________________________
 
| [[Vehicle Customization (VhC)]], [[Description.ext#CfgVehicleTemplates|CfgVehicleTemplates]], [[Description.ext#disableRandomization|disableRandomization]] |= See also


|seealso= [[BIS_fnc_saveVehicle]] [[BIS_fnc_loadVehicle]] [[Arma 3: Vehicle Customisation]]
}}
}}
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style="display:none">Bottom Section</h3>
[[Category:Functions|{{uc:initVehicle}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:initVehicle}}]]

Latest revision as of 22:57, 8 April 2024

Hover & click on the images for description

Description

Description:
This function changes the textures, animation sources and/or mass of a given vehicle.
Unless explicitly mentioned , the function will restore the initial state of every animation sources of the given object (see Example 3).
Execution:
call
Groups:
Vehicles

Syntax

Syntax:
[vehicle, variant, animations, mass] call BIS_fnc_initVehicle
Parameters:
vehicle: Object - vehicle to customize
variant: (Optional, default false)
animations: (Optional, default false)
  • Boolean - true to restore init phase of every animation sources
  • Array - animation sources with their probability in format ["animationSource1", 0.5, "animationSource2", 0.5]
    If the first element is wrong, it will skip the rest of the animation sources!
  • String - variant class name - from configFile >> "CfgVehicles" or missionConfigFile >> "CfgVehicleTemplates" (see CfgVehicleTemplates)
mass: (Optional, default false)
  • Boolean - true to set the default mass, false to disable the mass change
  • Number - mass to remove/add to the vehicle
Return Value:
Boolean - function success or not

Examples

Example 1:
result = [this, "", []] call BIS_fnc_initVehicle;
Example 2:
result = [this, ["MyTextureSource1", 0.5, "MyTextureSource2", 0.6], []] call BIS_fnc_initVehicle;
Example 3:
result = [this, nil, ["MyAnimationSource1", 0.5, "MyAnimationSource2", 0.7]] call BIS_fnc_initVehicle;
Example 4:
// randomise camo net options with 50% probability [vehicle player, false, ["showcamonethull", 0.5, "showcamonetturret", 0.5, "showcamonetcannon", 0.5, "showslathull", 0.5]] call BIS_fnc_initVehicle;
Example 6:
// force show all camo net options. Use animationNames to get all available animation sources. Vehicles that don't support certain animations are simply ignored. [vehicle player, false, ["showcamonethull", 1, "showcamonetturret", 1, "showcamonetcannon", 1, "showslathull", 1]] call BIS_fnc_initVehicle;

Additional Information

See also:
BIS_fnc_saveVehicle BIS_fnc_loadVehicle Arma 3: Vehicle Customisation

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note