BIS fnc initVehicle: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Second half of the code actually also never worked. So removed completly)
(Page filling)
Line 1: Line 1:
{{Function|= Comments
{{Function|= Comments
____________________________________________________________________________________________
____________________________________________________________________________________________


| arma3 |= Game name
| arma3 |Game name=


|1.42|= Game version
|1.42|Game version=
____________________________________________________________________________________________


| <pre>/*
|arg= local |Argument=
Author: Julien `Tom_48_97` VIDA


Description:
|eff= global |Effect=
This function aims to simplify the way to customise 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.
____________________________________________________________________________________________
 
Important note: Unless it explicitly mentioned (example case 10), the function will restore the initial state of every animation sources of the given object.


Additional information:
| This function changes the textures, animation sources and/or mass of a given vehicle.<br />
OPREP - http://dev.arma3.com/post/oprep-vehicle-customization
The use of '''BIS_fnc_initVehicle_customization''' variable in a vehicle's init field is possible (see '''Example 4''')
Community Wiki - https://community.bistudio.com/wiki/Vehicle_Customization_%28VhC%29
{{Informative|Unless explicitly mentioned (see '''Example 3'''), the function will restore the initial state of every animation sources of the given object.}}


Parameter(s):
'''Additional information:'''
0: vehicle to customize
* [http://dev.arma3.com/post/oprep-vehicle-customization OPREP]
1: Variant (textures)
* [[Vehicle_Customization_(VhC)]]
BOOL - true to restore default texture source ; false to skip texture source change
<!--
VOID - Nil to skip the texture source change
=========================
ARRAY - Array of texture sources with their given probability: ["textureSource1", 0.5, "textureSource2", 0.5]
The following are examples from function's header
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:
BOOL - True if success, otherwise, false
Examples:
1) Do nothing because default VAR texture and VAR animation are "false"
1) Do nothing because default VAR texture and VAR animation are "false"
result = [this] call bis_fnc_initVehicle;
result = [this] call bis_fnc_initVehicle;
Line 77: Line 59:
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)
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;
result = [this, true, true, true] call bis_fnc_initVehicle;
-->
|Description=
____________________________________________________________________________________________


*/
| [vehicle, variant, animations, mass] call [[BIS_fnc_unitHeadgear]] |Syntax=
</pre> |= Description
 
____________________________________________________________________________________________
|p1= vehicle: [[Object]] - vehicle to customize |Parameter 1=
 
|p2= variant: (Optional, default [[false]])
* [[Boolean]] - [[true]] to restore default texture source, [[false]] to skip texture source change
* [[Array]] - Array of texture sources with their probability, to format {{Inline code|["textureSource1", 0.5, "textureSource2", 0.5]}}
* [[String]] - Variant class name - from the <tt>[[configFile]] >> [[CfgVehicles]]</tt> or from the <tt>[[missionConfigFile]] >> [[Description.ext#CfgVehicleTemplates|CfgVehicleTemplates]]</tt>
* [[Number]] - index of the texture source (same as the old system) |Parameter 2=


| <!-- [unitName, [], []] call BIS_fnc_unitHeadgear; --> |= Syntax
|p3= animations: (Optional, default [[false]])
* [[Boolean]] - [[true]] to restore init phase of every animation sources
* [[Array]] - Array of animation sources with their probability, to format {{Inline code|["animationSource1", 0.5, "animationSource2", 0.5]}}<br />'''NOTE:''' if the first element is wrong, it will skip the rest of the animation sources
* [[String]] - variant class name - from the <tt>[[configFile]] >> [[CfgVehicles]]</tt> or from the <tt>[[missionConfigFile]] >> [[Description.ext#CfgVehicleTemplates|CfgVehicleTemplates]]</tt>
|Parameter 3=


|p1= |= Parameter 1
|p4= 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
|Parameter 4=


| |= Return value
| [[Boolean]] - function success or not |Return value=
____________________________________________________________________________________________
____________________________________________________________________________________________


|x1= <code>result = [this, "", []] [[call]] [[BIS_fnc_initVehicle]];</code> |=  
|x1= <code>result = <nowiki>[</nowiki>[[this]], "", []] [[call]] [[BIS_fnc_initVehicle]];</code> |Example 1=  


|x2= <code>result = [this, ["MyTextureSource1", 0.5, "MyTextureSource2", 0.6], []] [[call]] [[BIS_fnc_initVehicle]];</code> |=  
|x2= <code>result = <nowiki>[</nowiki>[[this]], ["MyTextureSource1", 0.5, "MyTextureSource2", 0.6], []] [[call]] [[BIS_fnc_initVehicle]];</code> |Example 2=


|x3= <code>result = [this, [[nil]], ["MyAnimationSource1", 0.5, "MyAnimationSource2", 0.7]] [[call]] [[BIS_fnc_initVehicle]];</code> |=  
|x3= <code>result = <nowiki>[</nowiki>[[this]], [[nil]], ["MyAnimationSource1", 0.5, "MyAnimationSource2", 0.7]] [[call]] [[BIS_fnc_initVehicle]];</code> |Example 3=
 
|x4= <code>[[this]] [[setVariable]] ["'''BIS_fnc_initVehicle_customization'''", [[false]], [[false]], [[false]]]; {{codecomment|// set in an init field}}</code> |Example 4=
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[Vehicle Customization (VhC)]], [[Description.ext#CfgVehicleTemplates|CfgVehicleTemplates]], [[Description.ext#disableRandomization|disableRandomization]] |= See also
| [[Vehicle Customization (VhC)]], [[Description.ext#CfgVehicleTemplates|CfgVehicleTemplates]], [[Description.ext#disableRandomization|disableRandomization]] |See also=
 
}}
}}



Revision as of 01:05, 27 May 2018

Hover & click on the images for description

Description

Description:
This function changes the textures, animation sources and/or mass of a given vehicle.
The use of BIS_fnc_initVehicle_customization variable in a vehicle's init field is possible (see Example 4)
Unless explicitly mentioned (see Example 3), the function will restore the initial state of every animation sources of the given object.

Additional information:

Execution:
call
Groups:
Uncategorised

Syntax

Syntax:
[vehicle, variant, animations, mass] call BIS_fnc_unitHeadgear
Parameters:
vehicle: Object - vehicle to customize
variant: (Optional, default false)
animations: (Optional, default false)
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:
this setVariable ["BIS_fnc_initVehicle_customization", false, false, false]; // set in an init field

Additional Information

See also:
Vehicle Customization (VhC)CfgVehicleTemplatesdisableRandomization

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

Notes

Bottom Section