2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2016-10-12 22:35:24 +00:00
|
|
|
/*
|
|
|
|
* Author: jaynus / nou
|
|
|
|
* Change a projectile's direction, maintaing speed
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Projectile <OBJECT>
|
|
|
|
* 1: Direction (unit vector) <ARRAY>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [missile, [0,1,0]] call ace_missileguidance_fnc_changeMissileDirection;
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-10-12 22:35:24 +00:00
|
|
|
params ["_projectile", "_v"];
|
2016-05-30 16:37:03 +00:00
|
|
|
|
2016-10-12 22:35:24 +00:00
|
|
|
private _l = sqrt ((_v select 0) ^ 2 + (_v select 1) ^ 2);
|
|
|
|
private _r = -(_v select 2) / _l;
|
2016-05-30 16:37:03 +00:00
|
|
|
|
|
|
|
_projectile setVectorDirAndUp [ _v, [(_v select 0) * _r,(_v select 1) * _r, _l] ];
|
2016-10-12 22:35:24 +00:00
|
|
|
_projectile setVelocity (_v vectorMultiply (vectorMagnitude (velocity _projectile)));
|