ACE3/addons/laser/functions/fnc_handleLaserTargetCreation.sqf
Dedmen Miller e2ac18a05d [WIP] Fix script errors reporting wrong line numbers (#6407)
* advanced_ballistics

* advanced_fatigue

* advanced_throwing

* ai

* aircraft

* arsenal

* atragmx

* attach

* backpacks

* ballistics

* captives

* cargo

* chemlights

* common

* concertina_wire

* cookoff

* dagr

* disarming

* disposable

* dogtags

* dragging

* explosives

* fastroping

* fcs

* finger

* frag

* gestures

* gforces

* goggles

* grenades

* gunbag

* hearing

* hitreactions

* huntir

* interact_menu

* interaction

* inventory

* kestrel4500

* laser

* laserpointer

* logistics_uavbattery

* logistics_wirecutter

* magazinerepack

* map

* map_gestures

* maptools

* markers

* medical

* medical_ai

* medical_blood

* medical_menu

* microdagr

* minedetector

* missileguidance

* missionmodules

* mk6mortar

* modules

* movement

* nametags

* nightvision

* nlaw

* optics

* optionsmenu

* overheating

* overpressure

* parachute

* pylons

* quickmount

* rangecard

* rearm

* recoil

* refuel

* reload

* reloadlaunchers

* repair

* respawn

* safemode

* sandbag

* scopes

* slideshow

* spectator

* spottingscope

* switchunits

* tacticalladder

* tagging

* trenches

* tripod

* ui

* vector

* vehiclelock

* vehicles

* viewdistance

* weaponselect

* weather

* winddeflection

* yardage450

* zeus

* arsenal defines.hpp

* optionals

* DEBUG_MODE_FULL 1

* DEBUG_MODE_FULL 2

* Manual fixes

* Add SQF Validator check for #include after block comment

* explosives fnc_openTimerUI

* fix uniqueItems
2018-09-17 14:19:29 -05:00

65 lines
2.5 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: esteldunedain
* Associates a newly created laser target to it's owner
*
* Argument:
* 0: Vanilla Laser (base type LaserTarget) <OBJECT>
*
* Return Value:
* None
*
* Example:
* [laserTarget player] call ace_laser_fnc_handleLaserTargetCreation;
*
* Public: No
*/
TRACE_1("params",_this);
[{
params ["_targetObject"];
// Only handle locally created lasers
if(!(local _targetObject)) exitWith {TRACE_1("not local",_targetObject);};
private _owners = allUnits select {(lasertarget _x) == _targetObject};
if (count _owners == 1) exitWith {
TRACE_2("Laser target owner [allUnits]", _targetObject, _owners select 0);
[_targetObject, _owners select 0] call FUNC(addLaserTarget);
};
_owners = vehicles select {(lasertarget _x) == _targetObject};
if (count _owners == 1) exitWith {
TRACE_2("Laser target owner [vehicles]", _targetObject, _owners select 0);
[_targetObject, _owners select 0] call FUNC(addLaserTarget);
};
// Vehicle based laser designators won't be linked via laserTarget if the turret has "primaryGunner = 0"
// This backup method just checks the player's vic - which should be reasonably safe as we know the laserTarget is local
private _foundSource = false;
private _vehicle = vehicle ACE_player;
TRACE_2("",_vehicle,typeOf _vehicle);
if ((alive ACE_player) && {_vehicle != ACE_player}) then {
private _turretPath = if (ACE_player == (driver _vehicle)) then {[-1]} else {ACE_player call CBA_fnc_turretPath};
TRACE_1("",_turretPath);
if (!(_turretPath isEqualTo [])) then {
private _currentWeapon = _vehicle currentWeaponTurret _turretPath;
TRACE_1("",_currentWeapon);
if ((getNumber (configFile >> "CfgWeapons" >> _currentWeapon >> "laser")) == 1) then {
#ifdef DEBUG_MODE_FULL
private _turretConfig = [_vehicle, _turretPath] call CBA_fnc_getTurret;
private _primaryGunner = getNumber (_turretConfig >> "primaryGunner");
TRACE_1("",_primaryGunner);
#endif
TRACE_2("Laser target owner [backup method]",_targetObject,_vehicle);
[_targetObject, _vehicle] call FUNC(addLaserTarget);
_foundSource = true;
};
};
};
if (!_foundSource) then {
WARNING_1("Laser target doesn't have owner", _targetObject);
};
}, _this] call CBA_fnc_execNextFrame;