mirror of
https://github.com/Defent/DMS_Exile.git
synced 2024-08-30 16:52:12 +00:00
78aa0f8667
#### November 14, 2015 (8:30 PM CST-America): * **NEW CONFIG VALUES:** DMS_AllowStaticReinforcements DMS_MarkerText_ShowAICount_Static DMS_PredefinedMissionLocations_WEIGHTED DMS_AIKill_DistanceBonusMinDistance DMS_AIKill_DistanceBonusCoefficient * You can now manually disable Static Mission AI reinforcements using "DMS_AllowStaticReinforcements" * You can now choose whether or not to show AI count for map markers for both Static and Dynamic missions separately. * DMS will now check to see if the config.sqf didn't load properly, and for the presence of RyanZombies. * You can now make predefined locations weighted. * Some optimization + code clarity. * Added ```taviana_config.sqf``` (identical to ```tavi_config.sqf```) for the latest version of Taviana. * **saltflats mission**: * The AI will now initially spawn randomly across the compound. This should help with the issue of some AI spawning outside of the compound. * Added more static guns: 4 around the flagpole (5 meters north, south, east, and west). One on top of the tower in each corner, and another on the top of the concrete water tower. * When an AI group is offloaded to a client and he gets out of range AND no other viable client is found, the AI locality should now revert to the server (it used to just stay with the original client). * Added extra measures to prevent the creation of 2 markers with the same name. * fn_FillCrate.sqf: * Fixed the issue where DMS would complain about incorrect parameters when using custom code to generate loot. * DMS now has debug logging to tell you exactly what it spawns in the crate when using a crate case or custom code. * "DMS_PredefinedMissionLocations" itself will now be shuffled when finding a position. This should make the generated positions even more random. * Added new Group Reinforcement Types: "armed_vehicle_replace" and "static_gunner" * Potentially resolved the issue with launchers not being deleted from AI bodies when they're killed sometimes. * **fn_PlayerAwardOnAIKill.sqf**: Created a separate function to handle poptabs/respect of a player when he/she kills an AI. * Added a "distance bonus" for respect when killing AI. * Added logging for player rewards on AI kills. * DMS now lets Exile's body cleanup handle dead AIs. * Fixed the issue where DMS would spawn static missions even when "DMS_StaticMission" is set to false. * fn_SetAILocality.sqf now returns true/false if it does/doesn't find an owner. * New function "fn_SpawnAIGroup_MultiPos.sqf". Almost identical to SpawnAIGroup, except it spawns each AI along a list of locations. * **Removed the pre-packed PBO. Too many people were having issues with their PBO tool removing the prefix and repacking it would result in DMS not working.**
169 lines
5.3 KiB
Plaintext
169 lines
5.3 KiB
Plaintext
/*
|
|
DMS_fnc_PlayerAwardOnAIKill
|
|
Created by eraser1
|
|
|
|
Gives (or removes) a player's respect/poptabs for killing an AI.
|
|
|
|
Usage:
|
|
[
|
|
_playerObj,
|
|
_unit,
|
|
_AISide,
|
|
_AIType,
|
|
_roadKilled
|
|
] call DMS_fnc_PlayerAwardOnAIKill;
|
|
|
|
Returns nothing
|
|
*/
|
|
|
|
private ["_playerUID", "_playerObj", "_moneyChange", "_AISide", "_AIType", "_repChange", "_roadKilled", "_unitMoney", "_unit", "_unitRespect", "_playerMoney", "_playerRespect", "_msgType", "_msgParams"];
|
|
|
|
if !(params
|
|
[
|
|
["_playerObj", objNull, [objNull] ],
|
|
["_unit", objNull, [objNull] ],
|
|
["_AISide", "", [""] ],
|
|
["_AIType", "", [""] ],
|
|
["_roadKilled", false, [false] ]
|
|
])
|
|
exitWith
|
|
{
|
|
diag_log format ["DMS ERROR :: Calling DMS_fnc_PlayerAwardOnAIKill with invalid parameters: %1",_this];
|
|
};
|
|
|
|
|
|
_playerUID = getPlayerUID _playerObj;
|
|
|
|
if ((!isNull _playerObj) && {(_playerUID != "") && {_playerObj isKindOf "Exile_Unit_Player"}}) then
|
|
{
|
|
_moneyChange = missionNamespace getVariable [format ["DMS_%1_%2_MoneyGain",_AISide,_AIType],0];
|
|
_repChange = missionNamespace getVariable [format ["DMS_%1_%2_RepGain",_AISide,_AIType],0];
|
|
|
|
if (_roadKilled && {DMS_Diff_RepOrTabs_on_roadkill}) then
|
|
{
|
|
_moneyChange = missionNamespace getVariable [format ["DMS_%1_%2_RoadkillMoney",_AISide,_AIType],0];
|
|
_repChange = missionNamespace getVariable [format ["DMS_%1_%2_RoadkillRep",_AISide,_AIType],0];
|
|
};
|
|
|
|
// Check for individually defined AI money/respect.
|
|
_unitMoney = _unit getVariable ["DMS_AI_Money",""];
|
|
_unitRespect = _unit getVariable ["DMS_AI_Respect",""];
|
|
|
|
if !(_unitMoney isEqualTo "") then
|
|
{
|
|
_moneyChange = _unitMoney;
|
|
};
|
|
|
|
if !(_unitRespect isEqualTo "") then
|
|
{
|
|
_repChange = _unitRespect;
|
|
};
|
|
|
|
|
|
if ((_moneyChange!=0) || (_repChange!=0)) then
|
|
{
|
|
_playerMoney = _playerObj getVariable ["ExileMoney", 0];
|
|
_playerRespect = _playerObj getVariable ["ExileScore", 0];
|
|
|
|
if (DMS_DEBUG) then
|
|
{
|
|
format ["PlayerAwardOnAIKill :: Attempting to give %1 (%2) %3 poptabs and %4 respect. Player currently has %5 tabs and %6 respect.", name _playerObj, _playerUID, _moneyChange, _repChange, _playerMoney, _playerRespect] call DMS_fnc_DebugLog;
|
|
};
|
|
|
|
if (_moneyChange!=0) then
|
|
{
|
|
private ["_msgType", "_msgParams"];
|
|
|
|
// Set client's money
|
|
// I also make sure that they don't get negative poptabs
|
|
_playerMoney = (_playerMoney + _moneyChange) max 0;
|
|
_playerObj setVariable ["ExileMoney",_playerMoney];
|
|
|
|
_msgType = "moneyReceivedRequest";
|
|
_msgParams = [str _playerMoney, format ["killing a %1 AI",_AIType]];
|
|
|
|
if (_moneyChange<0) then
|
|
{
|
|
// Change message for players when they're actually LOSING poptabs
|
|
_msgType = "notificationRequest";
|
|
_msgParams = ["Whoops",[format ["Lost %1 poptabs from running over a %2 AI!",abs _moneyChange,_AIType]]];
|
|
|
|
// With the error message the money value won't be updated on the client, so I just directly PVC the value.
|
|
ExileClientPlayerMoney = _playerMoney;
|
|
(owner _playerObj) publicVariableClient "ExileClientPlayerMoney";
|
|
ExileClientPlayerMoney = nil;
|
|
};
|
|
|
|
if (DMS_Show_Kill_Poptabs_Notification) then
|
|
{
|
|
// Send notification and update client's money stats
|
|
[_playerObj, _msgType, _msgParams] call ExileServer_system_network_send_to;
|
|
}
|
|
else
|
|
{
|
|
// Player's money will already be updated for negative values, so let's not create unnecessary network traffic by sending another PVC
|
|
if (_moneyChange>0) then
|
|
{
|
|
ExileClientPlayerMoney = _playerMoney;
|
|
(owner _playerObj) publicVariableClient "ExileClientPlayerMoney";
|
|
ExileClientPlayerMoney = nil;
|
|
};
|
|
};
|
|
};
|
|
|
|
if (_repChange!=0) then
|
|
{
|
|
_attributes = [[format ["%1 AI KILL",toUpper _AIType],_repChange]];
|
|
|
|
if (DMS_AIKill_DistanceBonusCoefficient>0) then
|
|
{
|
|
_distance = floor (_unit distance _playerObj);
|
|
|
|
if (_distance>DMS_AIKill_DistanceBonusMinDistance) then
|
|
{
|
|
_distanceBonus = floor (_distance * DMS_AIKill_DistanceBonusCoefficient);
|
|
_attributes pushBack [format ["%1m RANGE BONUS",_distance], _distanceBonus];
|
|
|
|
_repChange = _repChange + _distanceBonus;
|
|
};
|
|
};
|
|
|
|
// Set client's respect
|
|
_playerRespect = _playerRespect + _repChange;
|
|
_playerObj setVariable ["ExileScore",_playerRespect];
|
|
|
|
if (DMS_Show_Kill_Respect_Notification) then
|
|
{
|
|
// Send frag message
|
|
[_playerObj, "showFragRequest", [_attributes]] call ExileServer_system_network_send_to;
|
|
};
|
|
|
|
// Send updated respect value to client
|
|
ExileClientPlayerScore = _playerRespect;
|
|
(owner _playerObj) publicVariableClient "ExileClientPlayerScore";
|
|
ExileClientPlayerScore = nil;
|
|
};
|
|
|
|
if (DMS_DEBUG) then
|
|
{
|
|
format ["PlayerAwardOnAIKill :: %1 (%2) awarded %3 poptabs and %4 respect for killing %5. Player's money is now %6, and respect is now %7. Roadkill: %8", name _playerObj, _playerUID, _moneyChange, _repChange, _unit, _playerMoney, _playerRespect, _roadKilled] call DMS_fnc_DebugLog;
|
|
};
|
|
|
|
// Update client database entry
|
|
format["setAccountMoneyAndRespect:%1:%2:%3", _playerMoney, _playerRespect, _playerUID] call ExileServer_system_database_query_fireAndForget;
|
|
}
|
|
else
|
|
{
|
|
if (DMS_DEBUG) then
|
|
{
|
|
format ["PlayerAwardOnAIKill :: %1 (%2) was not awarded any poptabs or respect.", name _playerObj, _playerUID] call DMS_fnc_DebugLog;
|
|
};
|
|
};
|
|
}
|
|
else
|
|
{
|
|
if (DMS_DEBUG) then
|
|
{
|
|
format ["PlayerAwardOnAIKill :: No reward for non-player _playerObj: %1",_playerObj] call DMS_fnc_DebugLog;
|
|
};
|
|
}; |