Skip to content

Commit

Permalink
fix calc intersect
Browse files Browse the repository at this point in the history
  • Loading branch information
tbox1911 committed Oct 13, 2024
1 parent be7b759 commit a3b0949
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ R3F_LOG_FNCT_3D_tirer_position_degagee_sol = {
"_rayon_degage",
"_pos_centre",
"_rayon_max",
["_nb_tirages_max", 30],
["_nb_tirages_max", 50],
["_eau_autorise", false]
];
private ["_nb_tirages", "_objets_genants", "_position_degagee", "_rayon_curr", "_angle_curr", "_intersect"];
Expand Down Expand Up @@ -575,9 +575,10 @@ R3F_LOG_FNCT_3D_tirer_position_degagee_sol = {
} forEach ([_position_degagee, _rayon_degage] call R3F_LOG_FNCT_3D_get_objets_genants_rayon);

// Verifier intersec avec building / rocks
private _maxpos = ATLtoASL (_position_degagee vectorAdd [0,0,30]);
if (lineIntersects [ATLtoASL _position_degagee, _maxpos]) then { _intersect = true };

private _minpos = ATLtoASL (_position_degagee vectorAdd [0,0,0.5]);
private _maxpos = (_minpos vectorAdd [0,0,30]);
if (lineIntersects [_minpos, _maxpos]) then { _intersect = true };
if (count (nearestTerrainObjects [_position_degagee, ["ROCK", "TREE"], 20]) > 0) then { _intersect = true };
(_intersect && _nb_tirages < _nb_tirages_max)
}
},
Expand Down
49 changes: 25 additions & 24 deletions core.liberation/scripts/shared/functions/F_fixPosUnit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,37 @@ if (speed vehicle _unit > 1) exitWith {};
if (_unit getVariable ["GRLIB_in_building", false]) exitWith {};

private _spawnpos = getPosATL _unit;
private _curalt = _spawnpos select 2;
private _minalt = 5;
private _maxalt = 60;

if (_curalt >= _maxalt) exitWith {};
if (surfaceIsWater _spawnpos) exitWith {};

private _maxalt = 30;
private _forest_type = ["forest", "wood"];
private _typepos = tolower (surfaceType getPosWorld _unit);
private _forest = count (_forest_type select { (_typepos find _x) > -1 });
_forest = _forest + count (nearestTerrainObjects [_unit, ["Tree","Small Tree"], 6]);
if (_forest > 0) then { _minalt = 3 };
if (_forest > 0) then { _maxalt = 3 };

private _obstacle = count (nearestTerrainObjects [_unit, ["House","Building"], 10]);
if (_obstacle > 0) then { _minalt = 2.3 };

private _minpos = ATLtoASL (_spawnpos vectorAdd [0,0,_minalt]);
private _maxpos = ATLtoASL (_spawnpos vectorAdd [0,0,_maxalt]);

if (lineIntersects [ATLtoASL _spawnpos, _minpos, _unit]) then {
_unit allowDamage false;
while { (lineIntersects [ATLtoASL _spawnpos, _maxpos, _unit]) && _curalt < _maxalt } do {
_curalt = _curalt + 0.5;
_spawnpos set [2, _curalt];
sleep 0.1;
};
_unit setPosATL _spawnpos;
_unit switchMove "AmovPercMwlkSrasWrflDf";
_unit playMoveNow "AmovPercMwlkSrasWrflDf";
sleep 3;
_unit setHitPointDamage ["hitLegs", 0];
_unit allowDamage true;
if (_obstacle > 0) then { _maxalt = 2.3 };

private _obstacle_rock = count (nearestTerrainObjects [_spawnpos, ["ROCK"], 20]);
if (_obstacle_rock > 0) then {_maxalt = 60 };

private _spawnpos = ATLtoASL (_spawnpos vectorAdd [0,0,0.5]);
private _maxpos = (_spawnpos vectorAdd [0,0,_maxalt]);
if !(lineIntersects [_spawnpos, _maxpos, _unit]) exitWith {};

private _curalt = _spawnpos select 2;
while { (lineIntersects [_spawnpos, _maxpos, _unit]) && _curalt < _maxalt } do {
_curalt = _curalt + 0.5;
_spawnpos set [2, _curalt];
sleep 0.05;
};

_unit allowDamage false;
_unit setPosASL _spawnpos;
sleep 3;
_unit switchMove "AmovPercMwlkSrasWrflDf";
_unit playMoveNow "AmovPercMwlkSrasWrflDf";
sleep 3;
_unit setHitPointDamage ["hitLegs", 0];
_unit allowDamage true;
2 changes: 1 addition & 1 deletion core.liberation/scripts/shared/functions/F_forceCrew.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private _grp = createGroup [_side, true];
sleep 0.1;
} forEach _vehicle_roles;

(units _grp) joinSilent _grp;
(crew _vehicle) joinSilent _grp;
(units _grp) allowGetIn true;
(units _grp) orderGetIn true;
(_grp) addVehicle _vehicle;
Expand Down

0 comments on commit a3b0949

Please sign in to comment.