Skip to content

Commit

Permalink
v1.23
Browse files Browse the repository at this point in the history
  • Loading branch information
musurca committed May 14, 2019
1 parent 2aa6d67 commit b312402
Show file tree
Hide file tree
Showing 15 changed files with 104 additions and 46 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Requirements: [CBA_A3](https://github.com/CBATeam/CBA_A3), [ACE3](https://github
**Features:**
* When a player kills a civilian, a new task is generated requiring the player to deliver the body to a member of their family, who lives in a house in the AO (within 20km by default).
* Alternatively, players may attempt to conceal the death by taking the body at least 300m away from a populated center, burying it, and striking off the dead civilian’s name from the grave marker.
* Civilian casualties are announced to everyone on the same side and marked on the map.
* Any corpse in a body bag can now be buried or exhumed (requires an Entrenching Tool).
* Burying any corpse produces a burial mound from which the dead person’s name and age can be read.
* The items carried by the dead are transferred to the body bag, and persist through burial and exhumation.
Expand All @@ -21,7 +22,7 @@ In order to deliver a dead civilian to their family member, you must first place

You can also bury or exhume any body bags if you are carrying an Entrenching Tool.

You can change how your notifications for civilian casualties are displayed in your Addon Settings (listed under "Guilt & Remembrance."). Note that this setting may be overriden by the mission creator or server operator.
You can change how your notifications for civilian casualties are displayed in your Addon Options (listed under "Guilt & Remembrance."). Note that this setting may be overriden by the mission creator or server operator.

**FOR MISSION CREATORS & SERVER OPERATORS:**
This mod is fully signed for multiplayer use, and has been tested on both local and dedicated servers. It must be run on both the client and server.
Expand Down Expand Up @@ -76,6 +77,10 @@ For questions, comments, or bug reports, please contact me directly at nick.musu
CHANGELOG:
---------------------

v1.23 (May 13, 2019):
* civilian casualties now marked on your map (but can be disabled from CBA settings)
* more reliable performance under heavy CPU load / adverse network conditions

v1.22 (May 13, 2019):
* bugfix: now supports Antistasi (as well as other mods/game types where civilians are created on the client-side)

Expand Down
Binary file modified addons/GR/config.bin
Binary file not shown.
5 changes: 3 additions & 2 deletions addons/GR/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CfgFunctions
class initServer { postInit = 1; };
class onUnitKilled {};
class onLocalCivKilled {};
class onClientCivKilled {};
class onClientCivKilled {};
class makeMissionDeliverBody {};
class burybody {};
class exhumebody {};
Expand All @@ -33,7 +33,8 @@ class CfgFunctions
class removeConcealDeathEventHandler {};
class addDeliverBodyEventHandler {};
class removeDeliverBodyEventHandler {};
class MPhint {};
class localNotifyCivDeath {};
class localBodyBagged {};
};
};
};
Expand Down
10 changes: 2 additions & 8 deletions addons/GR/functions/fn_burybody.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ if ((count _dogtagData) == 0) then {
[_player, _target] call ace_dogtags_fnc_takeDogtag;
};

_cargo = objNull;
_cargoId = _target getVariable ["GR_CARGO",0];
if (!(_cargoId isEqualTo 0)) then {
_cargo = _cargoId call BIS_fnc_objectFromNetId;
};
_cargo = _target getVariable ["GR_CARGO",objNull];
if (!(_cargo isEqualTo objNull)) then {
detach _cargo;
_cargo setPos [0,0,0];
Expand All @@ -49,9 +45,7 @@ _grave setPos _posTarget;
_grave setVariable ["CORPSE_ID", _cId];
_grave setVariable ["DOGTAG_DATA", _dogtagData, true];
_grave setVariable ["AGE",_vicAge, true];
if(!(_cargoId isEqualTo 0)) then {
_grave setVariable ["GR_CARGO",_cargoId];
};
_grave setVariable ["GR_CARGO",_cargo];
if (_task != "") then {
_grave setVariable ["GR_HIDEBODY_TASK",_task];
_grave setVariable ["GR_NEXTOFKIN",_nextOfKin];
Expand Down
9 changes: 2 additions & 7 deletions addons/GR/functions/fn_exhumebody.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ _dogtagData = _target getVariable "DOGTAG_DATA";
_vicAge = _target getVariable "AGE";
_task = _target getVariable ["GR_HIDEBODY_TASK",""];
_nextOfKin = _target getVariable ["GR_NEXTOFKIN",objNull];
_cargoId = _target getVariable ["GR_CARGO",0];
_cargo = _target getVariable ["GR_CARGO",objNull];
deleteVehicle _target;

_body = "ACE_bodyBagObject" createVehicle [0,0,0];
Expand All @@ -36,15 +36,10 @@ if (_task != "") then {
_body setVariable ["GR_NEXTOFKIN",_nextOfKin];
};

_cargo = objNull;
if (!(_cargoId isEqualTo 0)) then {
_cargo = _cargoId call BIS_fnc_objectFromNetId;
};
if (_cargo isEqualTo objNull) then {
_cargo = "Supply500" createVehicle [0,0,0];
_cargoId = _cargo call BIS_fnc_netId;
};
_cargo attachTo [_body, [0,0,0.85]];
_body setVariable ["GR_CARGO",_cargoId];
_body setVariable ["GR_CARGO",_cargo];


10 changes: 9 additions & 1 deletion addons/GR/functions/fn_initCBA.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ GR_NOTIFY_HINT=2;
[
"GR_DEATHNOTIFY_STYLE",
"LIST",
"Civilian Death Notification Style",
"Civilian death notification style",
"Guilt & Remembrance",
[[GR_NOTIFY_DIARY,GR_NOTIFY_SIDECHAT,GR_NOTIFY_HINT],["Diary Record Only","Side Chat (lower left)","Hint (top right)"],2]
] call CBA_fnc_AddSetting;

[
"GR_DEATHNOTIFY_MARKER",
"CHECKBOX",
"Mark civilian deaths on map",
"Guilt & Remembrance",
true
] call CBA_fnc_AddSetting;
3 changes: 3 additions & 0 deletions addons/GR/functions/fn_initClient.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ if(!hasInterface) exitWith{};
if (isNil "GR_DEATHNOTIFY_STYLE") then {
GR_DEATHNOTIFY_STYLE=GR_NOTIFY_HINT;
};
if (isNil "GR_DEATHNOTIFY_MARKER") then {
GR_DEATHNOTIFY_MARKER=true;
};

// new ACE actions for body bags and graves
GR_ace_burialAction = ["actionBury","Bury","",{
Expand Down
21 changes: 18 additions & 3 deletions addons/GR/functions/fn_initServer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,26 @@ GR_PLAYER_TASKS = [[],[]] call CBA_fnc_hashCreate;
// trace ID of corpse
["ace_placedInBodyBag", {
params["_target","_bodybag"];
if(!isServer) exitWith{};

_corpseId = _target getVariable "CORPSE_ID";
_bodyTask = _target getVariable ["GR_HIDEBODY_TASK",""];
if(_bodyTask != "") then {
// Tell everyone on side that the body has been bagged
_taskInfo = [GR_TASK_OWNERS,_bodyTask] call CBA_fnc_hashGet;
_taskSide = _taskInfo select 1;
[_corpseId] remoteExec ["GR_fnc_localBodyBagged",_taskSide];
} else
{
// Just tell everyone because we're not sure who shot him
[_corpseId] remoteExec ["GR_fnc_localBodyBagged"];
};

// Set up GR variables
_bodybag setVariable ["CORPSE_ID",_target call BIS_fnc_netId];
_bodybag setVariable ["CORPSE_ID",_corpseId];
_bodybag setVariable ["AGE",_target getVariable ["AGE",0],true]; // only broadcast AGE to clients when in the bodybag
_bodybag setVariable ["GR_NEXTOFKIN",_target getVariable ["GR_NEXTOFKIN",objNull]];
_bodybag setVariable ["GR_HIDEBODY_TASK",_target getVariable ["GR_HIDEBODY_TASK",""]];
_bodybag setVariable ["GR_HIDEBODY_TASK",_bodyTask];

// Transfer inventory
_weaps = weapons _target;
Expand All @@ -55,7 +69,7 @@ GR_PLAYER_TASKS = [[],[]] call CBA_fnc_hashCreate;

_cargo = "Supply500" createVehicle [0,0,0];
_cargo attachTo [_bodybag, [0,0,0.85]];
_bodybag setVariable ["GR_CARGO",_cargo call BIS_fnc_netId];
_bodybag setVariable ["GR_CARGO",_cargo];

[_cargo,_items,_weaps,_mags] spawn {
params["_cargo","_items","_weaps","_mags"];
Expand All @@ -66,6 +80,7 @@ GR_PLAYER_TASKS = [[],[]] call CBA_fnc_hashCreate;
};
}] call CBA_fnc_addEventHandler;

// Add event handler for people killed on server
["CAManBase", "killed",GR_fnc_onUnitKilled] call CBA_fnc_addClassEventHandler;

// Remove GR tasks from a player's responsibility 10 min after disconnect
Expand Down
12 changes: 12 additions & 0 deletions addons/GR/functions/fn_localBodyBagged.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
fn_localBodyBagged.sqf
by @musurca
Callback from server notifying client that a corpse has been bagged.
*/

params["_corpseId"];

deleteMarkerLocal format["GRmrk_%1",_corpseId];
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
fn_MPhint.sqf
fn_localNotifyCivDeath.sqf
by @musurca
Function for printing text notifications from server. Depends on player/mission/server-determined notification style.
Civilian deaths always go into the player's diary record.
*/

params["_killerName","_killedName","_killedAge"];
params["_killerName","_killedName","_killedAge", "_killedPos", "_killedId"];

switch (GR_DEATHNOTIFY_STYLE) do {
case GR_NOTIFY_HINT: {
Expand All @@ -22,6 +22,14 @@ switch (GR_DEATHNOTIFY_STYLE) do {
};
};

if (GR_DEATHNOTIFY_MARKER) then {
_marker = createMarkerLocal [format["GRmrk_%1",_killedId],_killedPos];
_marker setMarkerShapeLocal "ICON";
_marker setMarkerTypeLocal "mil_dot";
_marker setMarkerColorLocal "ColorYellow";
_marker setMarkerAlphaLocal 0.5;
};

// Make diary record of killing
_diaryText= format ["%1 killed %2 (age %3).", _killerName, _killedName, _killedAge];
player createDiaryRecord ["Diary", ["Civilian Deaths", _diaryText]];
13 changes: 6 additions & 7 deletions addons/GR/functions/fn_makeMissionDeliverBody.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@ if (count _bposlist == 0) exitWith { // no place for kin to spawn
_spawnPos = (selectRandom _bposlist);

_nextOfKinGrp = createGroup civilian;
_nextOfKinGrp = [_spawnPos, civilian, [selectRandom GR_CIV_TYPES]] call BIS_fnc_spawnGroup;
sleep 2;
_nextOfKin = (units _nextOfKinGrp) select 0;
_nextOfKin = _nextOfKinGrp createUnit [selectRandom GR_CIV_TYPES, _spawnPos, [],0, "NONE"];
_nextOfKin setPosATL _spawnPos;
_nextOfKin setUnitPos "up";
_nextOfKin allowFleeing 0;
doStop _nextOfKin;

_bigTask = format ["CivDead%1",_nextOfKin call BIS_fnc_netId];
_bigTask = format ["GRtsk_%1",_nextOfKin call BIS_fnc_netId];
[side _killer,_bigTask,[format ["Deliver the body of %1 to his nearest relative.",name _killed],"Deal with Civilian Death","meet"], _nextOfKin,"CREATED",0,false,"meet"] call BIS_fnc_taskCreate;

_nextOfKin setVariable ["GR_DELIVERBODY_TASK",_bigTask];
Expand Down Expand Up @@ -115,13 +113,14 @@ _deathArray pushBack _nextOfKin;
if( ({_x distance _kin <= 20} count allPlayers) > 0 ) then {
_objs = _kin nearObjects ["ACE_bodyBagObject", 5];
if (count _objs > 0) then {
_cId = _kin getVariable ["GR_CORPSE_ID",0];
_cId = _kin getVariable ["GR_CORPSE_ID","0:0"];
_bodyFound=false;
_body = objNull;
{
if ((_x getVariable ["CORPSE_ID",0]) == _cId) exitWith { _body = _x};
if ((_x getVariable ["CORPSE_ID","-1:-1"]) == _cId) exitWith { _body = _x; _bodyFound=true };
} forEach _objs;

if (_body != objNull) then {
if (_bodyFound) then {
_kin lookAt _body;

[_task,"Succeeded",false] call BIS_fnc_taskSetState;
Expand Down
21 changes: 17 additions & 4 deletions addons/GR/functions/fn_onClientCivKilled.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,24 @@ if (!isServer) exitWith {};

params["_killed", "_killer", "_name"];

// Transfer ownership to server immediately
(group _killed) setGroupOwner 2;

// Fix strange name transfer bug
/* Workaround for name bug in MP engine.
(Only last names of civilians created on the client
are given to the server when ownership is transferred.)
*/
_nameTokens = _name splitString " ";
_killed setName [_name, _nameTokens select 0, _nameTokens select 1];

// Call event handler as if civilian was killed on server
[_killed, _killer] call GR_fnc_onUnitKilled;

// Schedule a transfer of ownership to server.
// The short delay prevents strange rag-doll behavior.
[_killed] spawn {
params["_killed"];
sleep 5;
(group _killed) setGroupOwner 2;
sleep 5;
if (isInRemainsCollector _killed) then {
removeFromRemainsCollector [_killed];
};
};
18 changes: 10 additions & 8 deletions addons/GR/functions/fn_onLocalCivKilled.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@

params ["_killed", ["_killer", objNull]];

if ((isNull _killer) || {_killer == _killed}) then {
_killer = _killed getVariable ["ace_medical_lastDamageSource", objNull];
};
if(side (group _killed) == civilian) then {
// Workaround for ACE medical
if ((isNull _killer) || {_killer == _killed}) then {
_killer = _killed getVariable ["ace_medical_lastDamageSource", objNull];
};

// See if it's a vehicle
if ((!isNull _killer) && {!(_killer isKindof "CAManBase")}) then {
_killer = effectiveCommander _killer;
};
// Civilian killed by vehicle?
if ((!isNull _killer) && {!(_killer isKindof "CAManBase")}) then {
_killer = effectiveCommander _killer;
};

if(side (group _killed) == civilian) then {
// Tell the server about killing and start transfer of ownership
[_killed, _killer, name _killed] remoteExecCall ["GR_fnc_onClientCivKilled",2];
};
7 changes: 5 additions & 2 deletions addons/GR/functions/fn_onUnitKilled.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ if ((!isNull _killer) && {!(_killer isKindof "CAManBase")}) then {
if ((side group _killed) == civilian) then {
_vicAge = round random [15,40,79];
_killed setVariable ["AGE",_vicAge];

_killedId = _killed call BIS_fnc_netId;
_killed setVariable ["CORPSE_ID",_killedId];

// Notify the players of the killing
[name _killer, name _killed, _vicAge] remoteExec ["GR_fnc_MPhint", side _killer];
[name _killer, name _killed, _vicAge, position _killed, _killedId] remoteExec ["GR_fnc_localNotifyCivDeath", side _killer];

// Players get an "apology" mission
if (isPlayer _killer) then {
if( (random 100) < GR_MISSION_CHANCE ) then {
[_killer, _killed] spawn GR_fnc_makeMissionDeliverBody;
[_killer, _killed] call GR_fnc_makeMissionDeliverBody;
} else {
// Call custom event upon civilian murder by player anyway
{
Expand Down
2 changes: 1 addition & 1 deletion mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ overview = "Civilian deaths, reparations, and war crimes. Deliver the bodies of
author = "@musurca";
overviewText = "GR";
overviewPicture = "img\logomain.paa";
overviewFootnote = "v122";
overviewFootnote = "v123";

0 comments on commit b312402

Please sign in to comment.