I am trying to understand the best way of passing EH data to scripts.
A question first, what is the better way of detecting if shots are fired at a specific unit?
I was trying something like this.
wepFired = this AddEventHandler ["Fired", {this exec "Fired.sqf"}];
Fired.sqf ( Fictional at the moment )
UnitDat = _this;
_Unit = UnitDat select 0;
_Weap = UnitDat select 1;
_WAmo = UnitDat select 3;
// ----------------------------------------------------------------- Get Position of Shooter ---------
_UnitPos = Position _Unit;
_UnitPosx = _UnitPos select 0;
_UnitPosy = _UnitPos select 1;
// ----------------------------------------------------------------- Get Shooters Target, Shooters Range, and Skill -------------
_UnitTar = GetTarget _Unit;
_UnitRng = ( _Unit GetDistance _UnitTar );
_UnitSkl = GetSkill _Unit;
// ----------------------------------------------------------------- Determine if under fire ------------------------------
if (_UnitTar == Gn1) then { isUndFir = True } Else { isUndFir = False};
Hint str _WAmo;
I am trying to gain the following data,
The shooters Target
The shooters rang from its target
The shooters Skill
The shooters weapon
At the moment I am using a “wepFired = this AddEventGandler ["Fired}; {this exec "Fired.sqf"}];” in the shooters Init box right now, but I would like to have it in a trigger, so that any enemy that are in the trigger zone will be assigned that event handler so when they fire this data is gained.
I will also be placing a pause in there so that not every shot is registered after the first.