Files
DayZ-Epoch/dayz_code/compile/player_crossbowBolt.sqf
Aaron Clark 76e9a0582e 0.1
2012-11-04 20:28:50 -06:00

53 lines
1.7 KiB
Plaintext

private["_unit","_ammo","_audible","_distance","_listTalk","_weapon","_projectile","_vUp","_endPos","_dir","_height","_bolt","_hitArray","_hitObject","_hitSelection","_config","_hitMemoryPt","_variation","_val","_doLoop","_countr"];
_unit = _this select 0;
_weapon = _this select 1;
_ammo = _this select 4;
_projectile = _this select 6;
_projectile = nearestObject [_unit, _ammo];
_vUp = vectorUp _projectile;
_endPos = getPosATL _projectile;
_dir = 0;
while {alive _projectile} do {
_endPos = getPosATL _projectile;
_vUp = vectorUp _projectile;
sleep 0.01;
};
_distance = _unit distance _endPos;
_height = _endPos select 2;
_doLoop = true;
_countr = 0;
if (_height < 100) then {
_bolt = createVehicle ["BoltSteelF", _endPos, [], 0, "CAN_COLLIDE"];
_bolt setPosATL _endPos;
_bolt setDir (getDir _unit);
_bolt setVectorUp _vUp;
_hitArray = _unit getVariable["firedHit",[]];
while {_doLoop} do {
_hitArray = _unit getVariable["firedHit",[]];
if (count _hitArray > 0) then {_doLoop = false};
if (_countr > 50) then {_doLoop = false};
_countr = _countr + 1;
sleep 0.1;
};
if (count _hitArray > 0) then {
_hitObject = _hitArray select 0;
_hitSelection = _hitArray select 1;
_config = configFile >> "cfgBody" >> _hitSelection;
_hitMemoryPt = getText(_config >> "memoryPoint");
_variation = getNumber(_config >> "variation");
_val = [((random (_variation * 2)) - _variation),((random (_variation * 2)) - _variation),((random (_variation * 2)) - _variation)];
_bolt attachTo [_hitObject,_val,_hitMemoryPt];
_dir = ([_hitObject,_unit] call BIS_fnc_relativeDirTo) + 180;
_bolt setDir (_dir);
_bolt setPos (getPos _bolt);
_unit setVariable["firedHit",[]];
_unit setVariable["firedDamage",0,true];
};
};