Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProjectileTracking - Stop tracking stationary objects #985

Merged
merged 1 commit into from
Sep 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions addons/diagnostic/fnc_projectileTracking_trackProjectile.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ params ["_args", "_handle"];
_args params ["_projectile", "_index", "_initialProjectileData"];

if (!isNull _projectile) then {
private _speed = vectorMagnitude velocity _projectile;
if (_speed < 0.1) then { // If projectile is slowed down, stop tracking after this run
[_handle] call CBA_fnc_removePerFrameHandler;
};

private _data = [];
private _bulletData = [];
Expand All @@ -39,13 +43,9 @@ if (!isNull _projectile) then {
} else {
_bulletData = [_initialProjectileData];
_data = [_handle, _bulletData];
GVAR(projectileData) set [_index, _data];
};

_bulletData pushBack [(getPos _projectile), vectorMagnitude (velocity _projectile)];

_data set [1, _bulletData];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you delete this line intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
    _bulletData = _data select 1;
} else {
    _data = [_handle, _bulletData];
};

_data set [1, _bulletData];

either way _bulletData is going to already be set in _data


GVAR(projectileData) set [_index, _data];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here? outside of the if block?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not needed, because only commands that modify the array are used. Previously the function set a sub array, and a sub sub array to exactly what they were before.

_bulletData pushBack [(getPos _projectile), _speed];

} else {
[_handle] call CBA_fnc_removePerFrameHandler;
Expand Down