DMS_Exile/@ExileServer/addons/a3_dms/scripts/OnKilled.sqf

139 lines
3.4 KiB
Plaintext
Raw Normal View History

/*
DMS_OnKilled
Created by eraser1 and Defent
Influenced by WAI
Usage:
[
[
_killedUnit,
_killer
],
_side, // "bandit" only for now
_type // not currently used
] call DMS_OnKilled;
*/
private ["_unit", "_player", "_playerObj", "_side", "_type", "_launcher", "_rockets", "_money", "_respect", "_moneyGain", "_repGain"];
2015-08-31 05:08:30 +00:00
if (DMS_DEBUG) then
{
diag_log format ["DMS_DEBUG OnKilled :: Logging AI death with parameters: %1",_this];
};
2015-08-29 19:58:46 +00:00
_unit = _this select 0 select 0;
_player = _this select 0 select 1;
_side = _this select 1;
_type = _this select 2;
_launcher = secondaryWeapon _unit;
2015-09-02 17:01:33 +00:00
_playerObj = objNull;
if (isPlayer _player) then
{
_playerObj = _player;
if (DMS_ai_share_info) then
{
{
if (((position _x) distance (position _unit)) <= DMS_ai_share_info_distance ) then {
_x reveal [_player, 4.0];
};
} count allUnits;
};
}
else
{
2015-09-02 17:01:33 +00:00
// Remove this due to reports of issues
/*
_playerObj = gunner _player;
if (isNull _playerObj) then
{
_playerObj = driver _player;
2015-08-29 19:58:46 +00:00
};
2015-09-02 17:01:33 +00:00
*/
2015-08-29 19:58:46 +00:00
if ((DMS_clear_AI_body && {(random 100) <= DMS_clear_AI_body_chance}) || {DMS_remove_roadkill && {(random 100) <= DMS_remove_roadkill_chance}}) then
{
removeAllWeapons _unit;
removeAllAssignedItems _unit;
removeAllItemsWithMagazines _unit;
removeUniform _unit;
removeVest _unit;
removeBackpack _unit;
};
};
2015-08-29 19:58:46 +00:00
if(DMS_ai_remove_launchers && {_launcher != ""}) then
{
_rockets = _launcher call DMS_selectMagazine;
_unit removeWeapon _launcher;
{
if(_x == _rockets) then {
_unit removeMagazine _x;
2015-08-29 19:58:46 +00:00
};
false;
} count magazines _unit;
};
2015-08-29 19:58:46 +00:00
if(DMS_RemoveNVG) then
{
_unit unlinkItem "NVGoggles";
};
2015-08-29 19:58:46 +00:00
2015-08-31 20:44:15 +00:00
// credit: https://github.com/SMVampire/VEMF/
if (((count (units group _unit)) > 1) && {(leader group _unit) == _unit}) then
{
_grpUnits = units group _unit;
_grpUnits = _grpUnits - [_unit];
(group _unit) selectLeader (_grpUnits call BIS_fnc_selectRandom);
};
2015-08-29 19:58:46 +00:00
if ((!isNull _playerObj) && {(getPlayerUID _playerObj) != ""}) then
{
_moneyGain = missionNamespace getVariable [format ["DMS_%1MoneyGainOnKill",_side],0];
_repGain = missionNamespace getVariable [format ["DMS_%1RepGainOnKill",_side],0];
2015-08-29 19:58:46 +00:00
if ((_moneyGain>0) || (_repGain>0)) then
{
_money = _playerObj getVariable ["ExileMoney", 0];
_respect = _playerObj getVariable ["ExileScore", 0];
if (_moneyGain>0) then
{
// Set client's money
_money = _money + _moneyGain;
_playerObj setVariable ["ExileMoney",_money];
// Send notification and update client's money stats
// Somebody done fucked up so you don't see the sender for the money sending ;)
2015-08-31 21:39:31 +00:00
[_playerObj, "moneyReceivedRequest", [str _money, "killing AI"]] call ExileServer_system_network_send_to;
2015-08-29 19:58:46 +00:00
};
if (_repGain>0) then
{
// Set client's respect
_respect = _respect + _repGain;
_playerObj setVariable ["ExileScore",_respect];
2015-08-29 19:58:46 +00:00
// Send frag message
[_playerObj, "showFragRequest", [ [["AI KILL",_repGain]] ] ] call ExileServer_system_network_send_to;
2015-08-29 19:58:46 +00:00
// Send updated respect value to client
ExileClientPlayerScore = _respect;
(owner _playerObj) publicVariableClient "ExileClientPlayerScore";
ExileClientPlayerScore = nil;
2015-08-29 19:58:46 +00:00
};
// Update client database entry
format["setAccountMoneyAndRespect:%1:%2:%3", _money, _respect, (getPlayerUID _playerObj)] call ExileServer_system_database_query_fireAndForget;
2015-08-29 19:58:46 +00:00
};
};
2015-08-29 19:58:46 +00:00
DMS_CleanUpList pushBack [_unit,diag_tickTime,DMS_CompletedMissionCleanupTime];