Skip to content

Commit 4be382e

Browse files
authored
Merge pull request #662 from longtimegamer/fixes-laser-guided-bomb-force-fire-rpg
fixes for laser guided bomb, extra overwatch group, some faction fixes
2 parents d741669 + 530bb76 commit 4be382e

File tree

6 files changed

+309
-234
lines changed

6 files changed

+309
-234
lines changed

co30_Domination.Altis/cfgfunctions.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ class cfgFunctions {
382382
addc(moduleCAS_eachframeAI);
383383
addc(moduleCASAI);
384384
addc(moduleCAS_guidedmissile);
385+
addc(moduleCAS_guidedmissile2);
385386
addc(mando_chute);
386387
addc(sandstorm);
387388
addc(weather_winter);

co30_Domination.Altis/init/fn_preinit.sqf

Lines changed: 89 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2908,85 +2908,83 @@ if (d_with_airdrop == 2) then {
29082908

29092909
d_chem_objs_ar = [];
29102910

2911-
if (d_enable_civs == 1) then {
2912-
//
2913-
//civilian vehicles
2914-
//
2915-
d_civVehiclesWeightedCityWealthHigh = [
2916-
"C_Offroad_01_F", 1,
2917-
"C_Hatchback_01_F", 1,
2918-
"C_Truck_02_covered_F", 0.25,
2919-
"C_Van_01_box_F", 0.25,
2920-
"C_Van_02_transport_F", 0.25,
2921-
"C_Offroad_02_unarmed_F", 0.5,
2922-
"C_SUV_01_F", 0.5,
2923-
"C_IDAP_Van_medevac_02_F", 0.25
2924-
];
2925-
2926-
d_civVehiclesWeightedCityWealthLow = [
2927-
"C_Offroad_01_F", 1,
2928-
"C_Truck_02_covered_F", 0.25,
2929-
"C_Truck_02_transport_F", 0.25,
2930-
"C_Van_01_box_F", 0.25,
2931-
"C_Van_02_transport_F", 0.25,
2932-
"C_IDAP_Van_medevac_02_F", 0.25
2933-
];
2934-
2935-
d_civVehiclesWeightedRural = [
2936-
"C_Offroad_01_F", 1,
2937-
"C_Truck_02_covered_F", 0.25,
2938-
"C_Truck_02_transport_F", 0.25,
2939-
"C_Van_01_box_F", 0.10,
2940-
"C_Offroad_02_unarmed_F", 1,
2941-
"C_Tractor_01_F", 0.10,
2942-
"C_van_01_box_f", 0.10,
2943-
"C_Truck_02_fuel_f", 0.10,
2944-
"C_idap_truck_02_water_f", 0.10,
2945-
"C_van_01_transport_f", 0.25
2946-
];
2947-
2948-
d_civVehiclesWeightedRuralCup = [
2949-
"CUP_C_pickup_unarmed_civ", 1,
2950-
"CUP_C_Datsun", 1,
2951-
"CUP_C_V3S_Covered_TKC", 1,
2952-
"CUP_B_hilux_unarmed_blu_g_f", 1,
2953-
"CUP_I_suv_ion", 0.25,
2954-
"C_Tractor_01_F", 0.10,
2955-
"CUP_C_tractor_old_civ", 0.10
2956-
];
2957-
2958-
d_civVehiclesWeightedRuralCupRemote = [
2959-
"CUP_C_Datsun", 1,
2960-
"CUP_C_Datsun_4seat", 1,
2961-
"CUP_C_V3S_Covered_TKC", 0.5,
2962-
"C_Tractor_01_F", 0.25
2963-
];
2964-
2965-
d_civVehiclesWeightedCityWealthLowCup =+ d_civVehiclesWeightedCityWealthLow;
2966-
d_civVehiclesWeightedCityWealthLowCup =+ [
2967-
"CUP_C_lada_white_civ", 1,
2968-
"CUP_C_lada_red_civ", 1,
2969-
"CUP_C_skoda_white_civ", 1,
2970-
"CUP_C_skoda_green_civ", 1,
2971-
"CUP_C_skoda_blue_civ", 1,
2972-
"CUP_C_skoda_red_civ", 1,
2973-
"CUP_C_ikarus_chernarus", 0.25,
2974-
"CUP_C_bus_city_crciv", 0.25,
2975-
"CUP_B_S1203_Ambulance_CR", 0.25
2976-
];
2977-
2978-
d_civVehiclesWeightedCityWealthLowCFP =+ d_civVehiclesWeightedCityWealthLowCup;
2979-
d_civVehiclesWeightedCityWealthLowCFP =+ [
2980-
"CFP_c_me_datsun_pickup_covered_01", 1,
2981-
"CFP_C_datsun_plain", 1,
2982-
"CFP_C_afg_skoda_105_L_01", 1,
2983-
"CFP_C_asia_praga_v3s_01", 1,
2984-
"CFP_B_caf_ural_01", 1,
2985-
"CFP_I_ssarmy_skoda_1203_01", 1,
2986-
"CFP_B_afgpolice_offroad_01", 0.25,
2987-
"CFP_B_uaz_01", 1
2988-
];
2989-
};
2911+
//
2912+
//civilian vehicles
2913+
//
2914+
d_civVehiclesWeightedCityWealthHigh = [
2915+
"C_Offroad_01_F", 1,
2916+
"C_Hatchback_01_F", 1,
2917+
"C_Truck_02_covered_F", 0.25,
2918+
"C_Van_01_box_F", 0.25,
2919+
"C_Van_02_transport_F", 0.25,
2920+
"C_Offroad_02_unarmed_F", 0.5,
2921+
"C_SUV_01_F", 0.5,
2922+
"C_IDAP_Van_medevac_02_F", 0.25
2923+
];
2924+
2925+
d_civVehiclesWeightedCityWealthLow = [
2926+
"C_Offroad_01_F", 1,
2927+
"C_Truck_02_covered_F", 0.25,
2928+
"C_Truck_02_transport_F", 0.25,
2929+
"C_Van_01_box_F", 0.25,
2930+
"C_Van_02_transport_F", 0.25,
2931+
"C_IDAP_Van_medevac_02_F", 0.25
2932+
];
2933+
2934+
d_civVehiclesWeightedRural = [
2935+
"C_Offroad_01_F", 1,
2936+
"C_Truck_02_covered_F", 0.25,
2937+
"C_Truck_02_transport_F", 0.25,
2938+
"C_Van_01_box_F", 0.10,
2939+
"C_Offroad_02_unarmed_F", 1,
2940+
"C_Tractor_01_F", 0.10,
2941+
"C_van_01_box_f", 0.10,
2942+
"C_Truck_02_fuel_f", 0.10,
2943+
"C_idap_truck_02_water_f", 0.10,
2944+
"C_van_01_transport_f", 0.25
2945+
];
2946+
2947+
d_civVehiclesWeightedRuralCup = [
2948+
"CUP_C_pickup_unarmed_civ", 1,
2949+
"CUP_C_Datsun", 1,
2950+
"CUP_C_V3S_Covered_TKC", 1,
2951+
"CUP_B_hilux_unarmed_blu_g_f", 1,
2952+
"CUP_I_suv_ion", 0.25,
2953+
"C_Tractor_01_F", 0.10,
2954+
"CUP_C_tractor_old_civ", 0.10
2955+
];
2956+
2957+
d_civVehiclesWeightedRuralCupRemote = [
2958+
"CUP_C_Datsun", 1,
2959+
"CUP_C_Datsun_4seat", 1,
2960+
"CUP_C_V3S_Covered_TKC", 0.5,
2961+
"C_Tractor_01_F", 0.25
2962+
];
2963+
2964+
d_civVehiclesWeightedCityWealthLowCup =+ d_civVehiclesWeightedCityWealthLow;
2965+
d_civVehiclesWeightedCityWealthLowCup =+ [
2966+
"CUP_C_lada_white_civ", 1,
2967+
"CUP_C_lada_red_civ", 1,
2968+
"CUP_C_skoda_white_civ", 1,
2969+
"CUP_C_skoda_green_civ", 1,
2970+
"CUP_C_skoda_blue_civ", 1,
2971+
"CUP_C_skoda_red_civ", 1,
2972+
"CUP_C_ikarus_chernarus", 0.25,
2973+
"CUP_C_bus_city_crciv", 0.25,
2974+
"CUP_B_S1203_Ambulance_CR", 0.25
2975+
];
2976+
2977+
d_civVehiclesWeightedCityWealthLowCFP =+ d_civVehiclesWeightedCityWealthLowCup;
2978+
d_civVehiclesWeightedCityWealthLowCFP =+ [
2979+
"CFP_c_me_datsun_pickup_covered_01", 1,
2980+
"CFP_C_datsun_plain", 1,
2981+
"CFP_C_afg_skoda_105_L_01", 1,
2982+
"CFP_C_asia_praga_v3s_01", 1,
2983+
"CFP_B_caf_ural_01", 1,
2984+
"CFP_I_ssarmy_skoda_1203_01", 1,
2985+
"CFP_B_afgpolice_offroad_01", 0.25,
2986+
"CFP_B_uaz_01", 1
2987+
];
29902988

29912989
private _civVehiclesWeightedRuralLivonia = [
29922990
"C_Offroad_01_F", 0.30,
@@ -3456,8 +3454,11 @@ if (d_with_airdrop == 2) then {
34563454
"CFP_C_ME_Civ_1_01", 1,
34573455
"CFP_C_ME_Civ_2_01", 1
34583456
];
3459-
3460-
3457+
3458+
3459+
// default
3460+
d_civ_vehicles_weighted = d_civVehiclesWeightedCityWealthHigh;
3461+
34613462
#ifdef __ALTIS__
34623463
d_civ_vehicles_weighted = d_civVehiclesWeightedCityWealthHigh;
34633464
d_civ_faces = _mixedFaces;
@@ -4067,7 +4068,7 @@ if (d_enemy_factions > 0) then {
40674068
["EAST","RWR_ru_winter","RWR_ru_infantry_winter","RWR_group_inf_teamat"] call d_fnc_GetConfigGroup
40684069
];
40694070
d_specops_E = [["EAST","RWR_ru_winter","RWR_ru_infantry_winter","RWR_group_inf_groupmg"] call d_fnc_GetConfigGroup];
4070-
d_sniper_E = [["EAST","RWR_ru_winter","RWR_ru_infantry_winter","RWR_group_inf_teamdm"] call d_fnc_GetConfigGroup];
4071+
// d_sniper_E = [["EAST","RWR_ru_winter","RWR_ru_infantry_winter","RWR_group_inf_teamdm"] call d_fnc_GetConfigGroup]; // RWR sniper team is mostly non-snipers... just use default snipers
40714072
};
40724073
case 8: {
40734074
// 3CB - African Desert Civilian Militia (ADG)
@@ -4291,20 +4292,22 @@ switch (d_guerrilla_factions) do {
42914292
["I_CUPARMYASIA_T72_01", "I_CUPARMYASIA_BTR_60PB_01"]
42924293
];
42934294
};
4294-
// ION PMC
4295+
// ION PMC and AT
42954296
case 5: {
42964297
d_faction_independent_array = [
42974298
[
4298-
["Indep","CUP_I_PMC_ION","Infantry","CUP_I_PMC_ION_Security_Detail"] call d_fnc_GetConfigGroup
4299+
["Indep","CUP_I_PMC_ION","Infantry","CUP_I_PMC_ION_Security_Detail"] call d_fnc_GetConfigGroup,
4300+
["Indep","IND_F","Infantry","HAF_InfTeam_AT"] call d_fnc_GetConfigGroup
42994301
],
43004302
["CUP_I_MATV_GMG_ION", "CUP_I_BTR80A_ION"]
43014303
];
43024304
};
4303-
// ION PMC Arctic
4305+
// ION PMC Arctic and AT
43044306
case 6: {
43054307
d_faction_independent_array = [
43064308
[
4307-
["Indep","CUP_I_PMC_ION","WinterInfantry","CUP_I_PMC_Winter_ION_Security_Detail"] call d_fnc_GetConfigGroup
4309+
["Indep","CUP_I_PMC_ION","WinterInfantry","CUP_I_PMC_Winter_ION_Security_Detail"] call d_fnc_GetConfigGroup,
4310+
["Indep","IND_F","Infantry","HAF_InfTeam_AT"] call d_fnc_GetConfigGroup
43084311
],
43094312
["CUP_I_MATV_GMG_ION", "CUP_I_nM1025_Mk19_ION_WIN"]
43104313
];

co30_Domination.Altis/scripts/fn_force_fire_rpg.sqf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ params ["_u", "_target"];
33

44
// in Arma 3, it isn't possible to reliably force a unit to fire a secondaryWeapon (RPG)
55
// instead a) force the unit to use the weapon and point it at the target
6-
// and then b) use d_fnc_moduleCAS_guidedmissile to create the missile in flight
6+
// and then b) use d_fnc_moduleCAS_guidedmissile2 to create the missile in flight
77
// note the greater randomPos deviation when further away from the target, just a messy first attempt and probably needs to be tuned
88

99
_u setVariable ["d_is_force_shooting", true, true];
@@ -61,7 +61,7 @@ private _secWeaponMag = (secondaryWeaponMagazine _u) select 0;
6161
private _ammo = getText (configFile>>"CfgMagazines" >> _secWeaponMag >> "ammo");
6262

6363
// fire the rocket
64-
[_targetpos, _missile_start_pos, _ammo, 0, _u, _projectileVelocity, 10, true] call d_fnc_moduleCAS_guidedmissile;
64+
[_targetpos, _missile_start_pos, _ammo, 0, _u, _projectileVelocity, 10, true] call d_fnc_moduleCAS_guidedmissile2;
6565

6666
// restore the primary weapon and primary weapon magazines removed earlier, ignore handgun and grenades for now
6767
_u addMagazines [(_prim_weapon_ammo_mag_arr select 0), 5];

co30_Domination.Altis/scripts/fn_moduleCAS_guidedmissile.sqf

Lines changed: 42 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,76 +10,66 @@ nul=[laserTarget player, getPos startLocation, "M_Scalpel_AT", 500] execVM "guid
1010
*/
1111

1212
//initializing parameters
13-
params ["_target", "_startPos", "_missileType", "_missileHeight", "_instigator", ["_missileSpeed", 1300], ["_perSecondsChecks", 100], ["_minimalGuidance", false]];
13+
params ["_target", "_startPos", "_missileType", "_missileHeight", "_instigator"];
1414
__TRACE_1("","_this")
1515

1616
//defining parameters
1717
//the faster the target, the more checks it will need 100 is good for fast moving targets such as aircrafts
18-
//private _perSecondsChecks = 100;
18+
private _perSecondsChecks = 100;
1919
//actual speed of a AIM-54 Phoenix AA missile // Hmmm I don't think so, appears to be ~4680 km/h which is ~1300 m/s -Longtime
2020
//private _missileSpeed = 6174;
21-
//_minimalGuidance - launch along target vector but do not guide, self detonate if missile goes too far past the target or at 920m or at 3 seconds of flight
22-
23-
private _guideTheShot = {
24-
_shotHasBeenGuided = true;
25-
_missile setDir (_missile getDir _targetPos);
26-
if (_dirVer isEqualType 0) then {// asin can return something like -1.#IND if the value isn't correct (asin 2 for example)
27-
_dirVer = _dirVer * -1;
28-
__TRACE_2("","_missile","_dirVer")
29-
[_missile, _dirVer, 0] call BIS_fnc_setPitchBank;
30-
};
31-
_missile setVelocity [_velocityX, _velocityY, _velocityZ];
32-
};
33-
34-
private _targetPos = [];
35-
if (_target isEqualType []) then {
36-
_targetPos = _target;
37-
} else {
38-
_targetPos = getPosASL _target;
39-
};
21+
private _missileSpeed = 1300;
4022

4123
//if no target is found -> exit
42-
if (_targetPos isEqualTo []) exitWith {hintSilent "No Target Found!"};
24+
if (_target isEqualTo []) exitWith {hintSilent "No Target Found!"};
4325

44-
if (_missileHeight > 0) then {
45-
//create missile and setting pos
46-
_startPos set [2, _missileHeight];
47-
};
26+
//create missile and setting pos
27+
_startPos set [2, _missileHeight];
4828

4929
//creating missile
5030
private _missile = _missileType createVehicle _startPos;
5131
_missile setShotParents [_instigator, _instigator];
52-
private _shotHasBeenGuided = false;
53-
private _startTime = time;
54-
private _initialDistanceToTarget = _missile distance _targetPos;
55-
private _distanceSelfDetonate = 700;
56-
__TRACE_3("","_missile","getPos _missile","_missile distance _targetPos")
32+
__TRACE_3("","_missile","getPos _missile","_missile distance _target")
33+
34+
// todo - orient the missile to point toward the target?
5735

36+
private _startTime = time;
37+
private _maxFlightTime = 10; // in seconds
5838

59-
while { alive _missile && { _targetPos distance _missile > 9 }} do {
60-
private _dirVer = asin ((((getPosASL _missile) # 2) - (_targetPos # 2)) / (_targetPos distance _missile));
61-
__TRACE_1("","_dirVer")
62-
_flyingTime = (_targetPos distance _missile) / _missileSpeed;
63-
private "_velocityX";
64-
private "_velocityY";
65-
private "_velocityZ";
66-
_velocityX = ((_targetPos select 0) - ((getPosASL _missile) select 0)) / _flyingTime;
67-
_velocityY = ((_targetPos select 1) - ((getPosASL _missile) select 1)) / _flyingTime;
68-
_velocityZ = ((_targetPos select 2) - ((getPosASL _missile) select 2)) / _flyingTime;
69-
if (_minimalGuidance) then {
70-
if (!_shotHasBeenGuided) then {
71-
// minimal guidance, only guide once
72-
[] call _guideTheShot;
39+
//ajusting missile pos while flying
40+
while {alive _missile && {_missile distance2D _target > 1 && { time - _startTime < _maxFlightTime }}} do {
41+
//__TRACE_2("flying","_missile","_missile distance2D _target")
42+
//if (_missile distance _target > (_missileSpeed / 10)) then {
43+
if (_missile distance _target > 5) then {
44+
_missile setDir (_missile getDir _target);
45+
private _dirVer = if (_target isEqualType []) then {
46+
asin ((((getPosASL _missile) # 2) - (_target # 2)) / (_target distance _missile));
47+
} else {
48+
asin ((((getPosASL _missile) # 2) - ((getPosASL _target) # 2)) / (_target distance _missile));
7349
};
74-
if (_missile distance _startPos > _distanceSelfDetonate || { time - _startTime > 3 }) then {
75-
// self detonate
76-
_missile setDamage 1;
50+
__TRACE_1("","_dirVer")
51+
if (_dirVer isEqualType 0) then {// asin can return something like -1.#IND if the value isn't correct (asin 2 for example)
52+
_dirVer = _dirVer * -1;
53+
__TRACE_2("","_missile","_dirVer")
54+
[_missile, _dirVer, 0] call BIS_fnc_setPitchBank;
7755
};
78-
} else {
79-
[] call _guideTheShot;
56+
_flyingTime = (_target distance _missile) / _missileSpeed;
57+
private "_velocityX";
58+
private "_velocityY";
59+
private "_velocityZ";
60+
if (_target isEqualType []) then {
61+
_velocityX = ((_target select 0) - ((getPosASL _missile) select 0)) / _flyingTime;
62+
_velocityY = ((_target select 1) - ((getPosASL _missile) select 1)) / _flyingTime;
63+
_velocityZ = ((_target select 2) - ((getPosASL _missile) select 2)) / _flyingTime;
64+
} else {
65+
_velocityX = (((getPosASL _target) select 0) - ((getPosASL _missile) select 0)) / _flyingTime;
66+
_velocityY = (((getPosASL _target) select 1) - ((getPosASL _missile) select 1)) / _flyingTime;
67+
_velocityZ = (((getPosASL _target) select 2) - ((getPosASL _missile) select 2)) / _flyingTime;
68+
};
69+
_missile setVelocity [_velocityX, _velocityY, _velocityZ];
70+
71+
sleep (1/ _perSecondsChecks);
8072
};
81-
82-
sleep (1/ _perSecondsChecks);
8373
};
8474
__TRACE_1("","alive _missile")
8575
if (!alive _missile) then {

0 commit comments

Comments
 (0)