BIS fnc animateFlag: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Some wiki formatting)
 
(42 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{RV|type=function


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


| arma3dev |= Game name
|gr1= Object Manipulation


|1.67|= Game version
|arg= global
____________________________________________________________________________________________


| Smoothly animates given flag from current position on the flag pole to the given position. The function is global, MP and JIP compatible, persistent and will syncronise flags across the network. When flag animation is done, the scripted event handler "FlagAnimationDone" is called. To add scripted event handler to the flag use: <br><br><tt>_eh <nowiki>=</nowiki> [<yourflag>, "FlagAnimationDone", <yourcode>] call [[BIS_fnc_addScriptedEventHandler]];</tt><br><br>
|eff= global
'''NOTE''': Never put call to this function into object init field |= Description
____________________________________________________________________________________________


| [flag, phase, instant] call [[BIS_fnc_animateFlag]] |= Syntax
|descr= Smoothly animates given flag from current position on the flag pole to the given position. When flag animation is done, the {{Link|Arma 3: Scripted Event Handlers|scripted event handler}} {{Link|Arma 3: Scripted Event Handlers#BIS_fnc_animateFlag|"FlagAnimationDone"}} is called.


|p1= flag: [[Object]] - [[flag]] object of the type "FlagCarrier" |= Parameter 1
|mp= The effect is global, MP compatible and its effect is persistent.
|p2= phase: [[Number]] - desired animation phase 0...1 (0 - bottom of the flag pole, 1 - top of the flag pole) |= Parameter 2
|p3= instant (Optional):
* [[Boolean]] - when [[true]], animation is instant ("FlagAnimationDone" EH is not called in this case). Default: [[false]]
* [[Number]] - animation duration multiplier |= Parameter 3


| [[Nothing]] |= Return value
|s1= [flag, phase, instant] call [[BIS_fnc_animateFlag]]
____________________________________________________________________________________________


|x1= <code>[flag1, 0] [[call]] [[BIS_fnc_animateFlag]];</code> |=
|p1= flag: [[Object]] - [[flag]] object of the type "FlagCarrier"
____________________________________________________________________________________________


|[[flag]], [[flagOwner]], [[setFlagOwner]], [[setFlagSide]], [[setFlagTexture]], [[flagSide]], [[flagTexture]], [[setFlagAnimationPhase]], [[flagAnimationPhase]], [[Flag Textures]] |= See also
|p2= phase: [[Number]] - desired animation phase 0..1 (0 - bottom of the flag pole, 1 - top of the flag pole)


|p3= instant (Optional, default [[false]]):
* [[Boolean]] - when [[true]], animation is instant ("FlagAnimationDone" EH is not called in this case)
* [[Number]] - animation duration multiplier
|r1= [[Nothing]]
|x1= <sqf>[flag1, 0] call BIS_fnc_animateFlag;</sqf>
|x2= <sqf>
// Adding the "FlagAnimationDone" EH
private _eh = [<yourflag>, "FlagAnimationDone", { /* your code */ }] call BIS_fnc_addScriptedEventHandler;
</sqf>
|seealso= [[flag]] [[flagOwner]] [[setFlagOwner]] [[setFlagSide]] [[setFlagTexture]] [[flagSide]] [[flagTexture]] [[setFlagAnimationPhase]] [[flagAnimationPhase]] [[Arma 3: Flag Textures]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= Killzone_Kid
<!-- Note Section BEGIN -->
|timestamp= 20161212200200
|text= Flag Demo (https://www.youtube.com/watch?v=sJtQfRML0cc)
<sqf>
fnc_addFlagAction =
{
_this addAction
[
"Pull The Cord",
{
player playAction "PutDown";
sleep 0.5;
[_this select 0, flagAnimationPhase (_this select 0) + 0.2, 0.2] call BIS_fnc_animateFlag;
_this select 0 removeAction (_this select 2);
},
"",
10,
true,
true,
"",
"_this distance2D _target < 2"
];
};


<!-- Note Section END -->
private _flag = createVehicle ["Flag_BI_F", player getRelPos [10, 0], [], 0, "CAN_COLLIDE"];
</dl>
[_flag, 0, true] call BIS_fnc_animateFlag;
_flag call fnc_addFlagAction;


<h3 style="display:none">Bottom Section</h3>
[
[[Category:Function Group: Network|{{uc:netId}}]]
_flag,
[[Category:Functions|{{uc:netId}}]]
"FlagAnimationDone",
[[Category:{{Name|arma3}}: Functions|{{uc:netId}}]]
{
 
if (_this select 1 > 0.9) exitWith
<!-- CONTINUE Notes -->
{
<dl class="command_description">
[_this select 0, "FlagAnimationDone"] call BIS_fnc_removeAllScriptedEventHandlers;
<dd class="notedate">Posted on December 12, 2016 - 20:02 (UTC)</dd>
removeAllActions (_this select 0);
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
};
<dd class="note">wip
_this select 0 call fnc_addFlagAction;
</dd>
}
</dl>
]
<!-- DISCONTINUE Notes -->
call BIS_fnc_addScriptedEventHandler;
</sqf>
}}

Latest revision as of 22:39, 30 May 2024

Hover & click on the images for description

Description

Description:
Smoothly animates given flag from current position on the flag pole to the given position. When flag animation is done, the scripted event handler "FlagAnimationDone" is called.
Execution:
call
Multiplayer:
The effect is global, MP compatible and its effect is persistent.
Groups:
Object Manipulation

Syntax

Syntax:
[flag, phase, instant] call BIS_fnc_animateFlag
Parameters:
flag: Object - flag object of the type "FlagCarrier"
phase: Number - desired animation phase 0..1 (0 - bottom of the flag pole, 1 - top of the flag pole)
instant (Optional, default false):
  • Boolean - when true, animation is instant ("FlagAnimationDone" EH is not called in this case)
  • Number - animation duration multiplier
Return Value:
Nothing

Examples

Example 1:
[flag1, 0] call BIS_fnc_animateFlag;
Example 2:
// Adding the "FlagAnimationDone" EH private _eh = [<yourflag>, "FlagAnimationDone", { /* your code */ }] call BIS_fnc_addScriptedEventHandler;

Additional Information

See also:
flag flagOwner setFlagOwner setFlagSide setFlagTexture flagSide flagTexture setFlagAnimationPhase flagAnimationPhase Arma 3: Flag Textures

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
Killzone_Kid - c
Posted on Dec 12, 2016 - 20:02 (UTC)
Flag Demo (https://www.youtube.com/watch?v=sJtQfRML0cc)
fnc_addFlagAction = { _this addAction [ "Pull The Cord", { player playAction "PutDown"; sleep 0.5; [_this select 0, flagAnimationPhase (_this select 0) + 0.2, 0.2] call BIS_fnc_animateFlag; _this select 0 removeAction (_this select 2); }, "", 10, true, true, "", "_this distance2D _target < 2" ]; }; private _flag = createVehicle ["Flag_BI_F", player getRelPos [10, 0], [], 0, "CAN_COLLIDE"]; [_flag, 0, true] call BIS_fnc_animateFlag; _flag call fnc_addFlagAction; [ _flag, "FlagAnimationDone", { if (_this select 1 > 0.9) exitWith { [_this select 0, "FlagAnimationDone"] call BIS_fnc_removeAllScriptedEventHandlers; removeAllActions (_this select 0); }; _this select 0 call fnc_addFlagAction; } ] call BIS_fnc_addScriptedEventHandler;