Skip to content

Commit

Permalink
Merge pull request #1583 from Vdauphin/Add-Explosive
Browse files Browse the repository at this point in the history
Add: Persistent explosive
  • Loading branch information
Vdauphin authored Feb 20, 2024
2 parents 495984e + 035958a commit 22e5915
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 4 deletions.
4 changes: 4 additions & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/def/mission.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ if (isServer) then {
btc_delay_unit = 0.2;
btc_delay_vehicle = 0.3;
btc_delay_exec = 0.1;

//Explosives
btc_explosives = [];
btc_explosives_objectSide = createVehicle ["CBA_NamespaceDummy", [-1000, -1000, 0], [], 0, "NONE"];
};

//Civ
Expand Down
1 change: 1 addition & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/delete.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ profileNamespace setVariable [format ["btc_hm_%1_respawnTickets", _name], nil];
profileNamespace setVariable [format ["btc_hm_%1_deadBodyPlayers", _name], nil];
profileNamespace setVariable [format ["btc_hm_%1_slotsSerialized", _name], nil];
profileNamespace setVariable [format ["btc_hm_%1_markers", _name], nil];
profileNamespace setVariable [format ["btc_hm_%1_explosives", _name], nil];
profileNamespace setVariable [format ["btc_hm_%1_db", _name], nil];

saveProfileNamespace;
Expand Down
18 changes: 18 additions & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/load.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,24 @@ private _slots_serialized = +(profileNamespace getVariable [format ["btc_hm_%1_s
}, _slots_serialized] call CBA_fnc_execNextFrame; // Need to wait for vehicle creation
btc_slots_serialized = _slots_serialized;

//Explosives
private _explosives = +(profileNamespace getVariable [format ["btc_hm_%1_explosives", _name], []]);
btc_explosives = _explosives apply {
_x params ["_explosiveType", "_dir", "_pitch", "_pos", "_side"];
private _explosive = createVehicle [_explosiveType, _pos, [], 0, "CAN_COLLIDE"];
_explosive setPosATL _pos;
[_explosive, _dir, _pitch] call ACE_Explosives_fnc_setPosition;
_explosive setVariable ["btc_side", _side];
if (_side isEqualTo btc_player_side) then {
_explosive setShotParents [btc_explosives_objectSide, objNull];
};
[
_explosive,
_dir,
_pitch
];
};

//Player Markers
private _markers_properties = +(profileNamespace getVariable [format ["btc_hm_%1_markers", _name], []]);
{
Expand Down
24 changes: 24 additions & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/db/save.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,30 @@ private _markers_properties = _player_markers apply {
};
profileNamespace setVariable [format ["btc_hm_%1_markers", _name], +_markers_properties];

//Explosives
private _explosives = [];
{
_x params ["_explosive", "_dir", "_pitch"];
if (isNull _explosive) then {continue};
_explosives pushBack [
typeOf _explosive,
_dir,
_pitch,
getPosATL _explosive,
_explosive getVariable ["btc_side", sideEmpty]
]
} forEach btc_explosives;
{
_explosives pushBack [
typeOf _x,
getDir _x,
0,
getPosATL _x,
_x getVariable ["btc_side", side group ((getShotParents _x) select 0)]
]
} forEach (allMines select {_x isKindOf "APERSMineDispenser_Mine_Ammo"});
profileNamespace setVariable [format ["btc_hm_%1_explosives", _name], +_explosives];

//End
profileNamespace setVariable [format ["btc_hm_%1_db", _name], true];
saveProfileNamespace;
Expand Down
6 changes: 6 additions & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/eh/server.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,9 @@ if (btc_p_respawn_ticketsAtStart >= 0) then {
[_obj, 50] call ace_cargo_fnc_setSpace;
}, true, [], true] call CBA_fnc_addClassEventHandler;
} forEach ["CUP_MTVR_Base", "Truck_01_base_F"];

["ace_explosives_place", {
params ["_explosive", "_dir", "_pitch", "_unit"];
_explosive setVariable ["btc_side", side group _unit];
btc_explosives pushBack _this;
}] call CBA_fnc_addEventHandler;
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ if (random 100 > btc_info_intel_chance) then {
_unit setVariable ["intel", true];
};

if (isPlayer _instigator) then {
if (
isPlayer _instigator ||
_killer isEqualTo btc_explosives_objectSide ||
isPlayer _killer
) then {
private _repValue = btc_rep_bonus_mil_killed;
if (isNull _instigator && isPlayer _killer) then {
_instigator = _killer;
};
if (
_unit getVariable ["ace_captives_isHandcuffed", false] ||
_unit getVariable ["ace_captives_isSurrendering", false]
Expand Down
13 changes: 11 additions & 2 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/rep/hd.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Parameters:
_unit - Object to destroy. [Object]
_part - Not use. [String]
_dam - Amount of damage get by the object. [Number]
_injurer - Not use. [Object]
_injurer - The source unit that caused the damage. [Object]
_ammo - Type of ammo use to make damage. [String]
_hitIndex - Hit part index of the hit point, -1 otherwise. [Number]
_instigator - Person who pulled the trigger. [Object]
Expand Down Expand Up @@ -38,7 +38,13 @@ params [
["_instigator", objNull, [objNull]]
];

if (!isPlayer _instigator || {_dam <= 0.05}) exitWith {_dam};
if (_dam <= 0.05) exitWith {_dam};
if (
!isPlayer _instigator &&
_injurer isNotEqualTo btc_explosives_objectSide &&
!isPlayer _injurer
) exitWith {_dam};

private _isAgent = isAgent teamMember _unit;
if (
!_isAgent && {
Expand All @@ -52,6 +58,9 @@ if !(isServer) exitWith {
_dam
};

if (isNull _instigator && isPlayer _injurer) then {
_instigator = _injurer;
};
[
[btc_rep_malus_civ_hd, btc_rep_malus_animal_hd] select _isAgent,
_instigator
Expand Down
9 changes: 8 additions & 1 deletion =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/rep/killed.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ if (
{!isAgent teamMember _unit}
) exitWith {};

if (isPlayer _instigator) then {
if (
isPlayer _instigator ||
_killer isEqualTo btc_explosives_objectSide ||
isPlayer _killer
) then {
private _isAgent = isAgent teamMember _unit;
if (isNull _instigator && isPlayer _killer) then {
_instigator = _killer;
};
[
[btc_rep_malus_civ_killed, btc_rep_malus_animal_killed] select _isAgent,
_instigator
Expand Down

0 comments on commit 22e5915

Please sign in to comment.