Skip to content

Commit

Permalink
Merge pull request #698 from Sparker95/development
Browse files Browse the repository at this point in the history
Version 0.49
  • Loading branch information
Sparker95 authored Aug 10, 2020
2 parents ab2cba8 + 19ca2d8 commit fca4458
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 20 deletions.
16 changes: 10 additions & 6 deletions src/AI/Commander/AICommander.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,22 @@
#define ENEMY_CLUSTER_EFF_MAX [30, 7, 6, 2, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999]

// Max amount of simultaneous actions
#define CMDR_MAX_TAKE_OUTPOST_ACTIONS 3
#define CMDR_MAX_TAKE_OUTPOST_ACTIONS 2
#define CMDR_MAX_REINFORCE_ACTIONS 3
#define CMDR_MAX_SUPPLY_ACTIONS 3
#define CMDR_MAX_SUPPLY_ACTIONS 6
#define CMDR_MAX_OFFICER_ASSIGNMENT_ACTIONS 3
//#define CMDR_MAX_ATTACK_ACTIONS 100 QRFs are unlimited
// QRF actions
#define CMDR_MAX_ATTACK_ACTIONS 4
#define CMDR_MAX_PATROL_ACTIONS 6
#define CMDR_MAX_CONSTRUCT_ACTIONS 3
#define CMDR_MAX_CONSTRUCT_ACTIONS 2

// Max amount of units at airfields
#define CMDR_MAX_INF_AIRFIELD 80
#define CMDR_MAX_VEH_AIRFIELD 25

// Max amount of ground vehicles which can be imported at each external reinforcement
#define CMDR_MAX_GROUND_VEH_EACH_EXTERNAL_REINFORCEMENT 5

#ifdef OOP_ASSERT
#define ASSERT_CLUSTER_ACTUAL_OR_NULL(actual) \
ASSERT_MSG(actual isEqualType [], QUOTE(actual) + " is invalid type. It should be an array."); \
Expand Down Expand Up @@ -182,5 +186,5 @@
// This maps activity=value like: 25=~0.5, 100=1, 1000=~2
#define __ACTIVITY_FUNCTION(rawActivity) (log (0.09 * MAP_LINEAR_SET_POINT(vin_diff_global, 0.2, 1, 3) * (rawActivity) + 1))

// https://www.desmos.com/calculator/yxhaqijv19
#define __DAMAGE_FUNCTION(rawDamage, campaignProgress) (exp(-0.2 * (1 - sqrt(0.9 * MAP_GAMMA(vin_diff_global, campaignProgress))) * (rawDamage)) - 0.1)
// https://www.desmos.com/calculator/vgvrm8x3un
#define __DAMAGE_FUNCTION(rawDamage, campaignProgress) (exp(-0.5 * (1 - sqrt(0.9 * MAP_GAMMA(vin_diff_global, campaignProgress))) * (rawDamage - 8)) - 0.1)
7 changes: 6 additions & 1 deletion src/AI/Commander/AICommander.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,11 @@ http://patorjk.com/software/taag/#p=display&f=Univers&t=CMDR%20AI
params [P_THISOBJECT, P_OOP_OBJECT("_worldNow"), P_OOP_OBJECT("_worldFuture")];
private _side = T_GETV("side");

// Limit amount of concurrent actions
private _activeActions = T_GETV("activeActions");
pr _count = {GET_OBJECT_CLASS(_x) == "QRFCmdrAction"} count _activeActions;
if (_count >= CMDR_MAX_ATTACK_ACTIONS) exitWith {[]};

private _srcGarrisons = CALLM0(_worldNow, "getAliveGarrisons") select {
// Must be on our side and not involved in another action
(GETV(_x, "side") == _side) and
Expand Down Expand Up @@ -3027,7 +3032,7 @@ http://patorjk.com/software/taag/#p=display&f=Univers&t=CMDR%20AI
_loc,
_generalGarrisons # 0,
CALLSM1("Location", "getCapacityInfForType", LOCATION_TYPE_AIRPORT) - _nInf,
_nVehMax - _nVeh
(_nVehMax - _nVeh) min CMDR_MAX_GROUND_VEH_EACH_EXTERNAL_REINFORCEMENT
]
} else {
[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ CLASS("ConstructLocationCmdrAction", "CmdrAction")
#ifndef RELEASE_BUILD
private _delay = random 2;
#else
private _delay = 50 * log (0.1 * _detachEffStrength + 1) * (1 + 2 * log (0.0003 * _dist + 1)) * 0.1 + 2 + (random 15 + 30);
private _delay = 75 * log (0.1 * _detachEffStrength + 1) * (1 + 2 * log (0.0003 * _dist + 1)) * 0.1 + 2 + (random 30 + 30);
#endif

// Shouldn't need to cap it, the functions above should always return something reasonable, if they don't then fix them!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ CLASS("TakeLocationCmdrAction", "TakeOrJoinCmdrAction")
#ifndef RELEASE_BUILD
private _delay = random 2;
#else
private _delay = 50 * log (0.1 * _detachEffStrength + 1) * (1 + 2 * log (0.0003 * _dist + 1)) * 0.1 + 2 + (random 15 + 30);
private _delay = 75 * log (0.1 * _detachEffStrength + 1) * (1 + 2 * log (0.0003 * _dist + 1)) * 0.1 + 2 + (random 30 + 30);
#endif

// Shouldn't need to cap it, the functions above should always return something reasonable, if they don't then fix them!
Expand Down
4 changes: 2 additions & 2 deletions src/AI/Commander/CmdrStrategy/CmdrStrategy.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ CLASS("CmdrStrategy", ["RefCounted" ARG "Storable"])
P_OOP_OBJECT("_tgtCluster"),
P_ARRAY("_detachEff")];
private _tgtClusterPos = GETV(_tgtCluster, "pos");
private _adjustedDamage = CALLM2(_worldNow, "getDamageScore", _tgtClusterPos, 1000);
private _adjustedDamage = CALLM2(_worldNow, "getDamageScore", _tgtClusterPos, 2500);
APPLY_SCORE_STRATEGY(_defaultScore, _adjustedDamage)
ENDMETHOD;

Expand Down Expand Up @@ -381,7 +381,7 @@ CLASS("CmdrStrategy", ["RefCounted" ARG "Storable"])
P_OOP_OBJECT("_tgtLoc"),
P_ARRAY("_detachEff")];
private _tgtPos = GETV(_tgtLoc, "pos");
private _adjustedDamage = CALLM2(_worldNow, "getDamageScore", _tgtPos, 1000);
private _adjustedDamage = CALLM2(_worldNow, "getDamageScore", _tgtPos, 2500);
APPLY_SCORE_STRATEGY(_defaultScore, _adjustedDamage)
ENDMETHOD;

Expand Down
24 changes: 20 additions & 4 deletions src/GameManager/GameManager.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ CLASS("GameManager", "MessageReceiverEx")
ENDMETHOD;

vin_fnc_autoLoadMsg = {
diag_log _this;
diag_log ("[Vindicta Autoload] " + _this);
["autoloadwarning", [format ["<t size='4' color='#FF7733'>%1</t><br/><t size='2' color='#FFFFFF'>%2</t>", LOCS("Vindicta_GameManager", "Autoload"), _this], "PLAIN", -1, true, true]] remoteExec ["cutText", ON_ALL, false];
["autoloadwarning", 10] remoteExec ["cutFadeOut", ON_ALL, false];
};
Expand All @@ -543,6 +543,12 @@ CLASS("GameManager", "MessageReceiverEx")
LOC("Autoload_NoSaves") call vin_fnc_autoLoadMsg;
};

// log
diag_log "[Vindicta Autoload] All saved games:";
{
diag_log format [" %1", _x];
} forEach _recordNamesAndHeaders;

// Check all headers for loadability
pr _checkResult = T_CALLM1("checkAllHeadersForLoading", _recordNamesAndHeaders);

Expand All @@ -554,6 +560,12 @@ CLASS("GameManager", "MessageReceiverEx")
!(INCOMPATIBLE_WORLD_NAME in _x#1)
};

// Log
diag_log "[Vindicta Autoload] Saved games compatible for load:";
{
diag_log format [" %1", _x];
} forEach _dataForLoad;

if(count _dataForLoad == 0) exitWith {
LOC("Autoload_NoSavesForMap") call vin_fnc_autoLoadMsg;
};
Expand All @@ -562,6 +574,8 @@ CLASS("GameManager", "MessageReceiverEx")

_dataForLoad#0 params ["_recordName", "_errors"];

diag_log format ["[Vindicta Autoload] Selected saved game: %1", _recordName];

if(INCOMPATIBLE_SAVE_VERSION in _errors) exitWith {
LOC("Autoload_Version") call vin_fnc_autoLoadMsg;
};
Expand All @@ -584,17 +598,19 @@ CLASS("GameManager", "MessageReceiverEx")
private _autoLoadTime = PROCESS_TIME + 30;
while { !IS_ADMIN_ON_DEDI && _autoLoadTime > PROCESS_TIME } do {
sleep 0.5;
format [LOC("Autoload_CountDown"), _autoLoadTime - PROCESS_TIME] call vin_fnc_autoLoadMsg;
format [LOC("Autoload_CountDown"), ceil (_autoLoadTime - PROCESS_TIME)] call vin_fnc_autoLoadMsg;
};

if(!IS_ADMIN_ON_DEDI) then {
T_CALLM2("postMethodAsync", "loadGame", [_recordName]);
pr _args = [_recordName, T_GETV("storageClassName")];
T_CALLM2("postMethodAsync", "loadGame", _args);
} else {
LOC("Autoload_AdminAbort") call vin_fnc_autoLoadMsg;
};
};
} else {
T_CALLM2("postMethodAsync", "loadGame", [_recordName]);
pr _args = [_recordName, T_GETV("storageClassName")];
T_CALLM2("postMethodAsync", "loadGame", _args);
};

#undef LOC_SCOPE
Expand Down
2 changes: 1 addition & 1 deletion src/GameMode/CivilWar/CivilWarGameMode.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ CLASS("CivilWarGameMode", "GameModeBase")
// _casualtiesRatio - value in range 0..1. Max when a certain amount of casualties was reached.
pr _casualtiesRatio = 0;
pr _casualties = T_GETV("casualties");
_casualtiesRatio = _casualties / 400;
_casualtiesRatio = _casualties / 750;
_casualtiesRatio = CLAMP(_casualtiesRatio, 0.0, 1.0);

// Final aggression:
Expand Down
2 changes: 1 addition & 1 deletion src/UI/InGameMenu/InGameMenuTabGameModeInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ CLASS("InGameMenuTabGameModeInit", "DialogTabBase")
private _foundForbiddenCharacter = false;
(toArray _forbidden) findIf {
private _xStr = toString [_x];
private _id = _string find _xStr;
private _id = _campaignName find _xStr;
if (_id != -1) exitWith { _foundForbiddenCharacter = true; true; };
false;
};
Expand Down
7 changes: 4 additions & 3 deletions src/Unit/Unit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -1188,15 +1188,16 @@ CLASS("Unit", ["Storable" ARG "GOAP_Agent"])
pr _nCargo = CALLM0(_gar, "countCargoUnits");

// Some number which scales the amount of items in this box
pr _nGuns = 1.3 * _nInf * _lootScaling / ((_nVeh + _nCargo) max 1);
pr __n = _nInf * _lootScaling / ((_nVeh + _nCargo) max 1);
pr _nGuns = 0.8 * __n;

// Modifier for cargo boxes
if (_catID == T_CARGO) then {
_nGuns = _nGuns * 3;
_nGuns = 6 * __n;
};

// Add weapons and magazines
pr _arr = [[T_INV_primary, _nGuns, 10], [T_INV_secondary, 0.4*_nGuns, 5], [T_INV_handgun, 0.1*_nGuns, 3]]; // [_subcatID, num. attempts]
pr _arr = [[T_INV_primary, 1.5*_nGuns, 10], [T_INV_secondary, 0.3*_nGuns, 5], [T_INV_handgun, 0.1*_nGuns, 3]]; // [_subcatID, num. attempts]
{
_x params ["_subcatID", "_n", "_nMagsPerGun"];
if (count (_tInv#_subcatID) > 0) then { // If there are any weapons in this subcategory
Expand Down

0 comments on commit fca4458

Please sign in to comment.