Skip to content

Commit

Permalink
Merge pull request #796 from Sparker95/development
Browse files Browse the repository at this point in the history
Version 0.55
  • Loading branch information
Sparker95 authored May 13, 2021
2 parents 222ff1c + 62c4b95 commit 3b96b73
Show file tree
Hide file tree
Showing 82 changed files with 280,852 additions and 30,466 deletions.
12,336 changes: 12,336 additions & 0 deletions MarkupMission_VN.VR/mission.sqm

Large diffs are not rendered by default.

24,662 changes: 24,662 additions & 0 deletions Vindicta.cam_lao_nam/mission.sqm

Large diffs are not rendered by default.

64,230 changes: 51,463 additions & 12,767 deletions Vindicta.cup_chernarus_A3/mission.sqm

Large diffs are not rendered by default.

87,605 changes: 87,605 additions & 0 deletions Vindicta.eden/mission.sqm

Large diffs are not rendered by default.

72,685 changes: 72,685 additions & 0 deletions Vindicta.lingor3/mission.sqm

Large diffs are not rendered by default.

47,109 changes: 29,550 additions & 17,559 deletions Vindicta.psyfx_pht/mission.sqm

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion configs/minorVersion.hpp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
54
55
3 changes: 3 additions & 0 deletions src/AI/AI/AI_GOAP.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ CLASS("AI_GOAP", "AI")
// Because it changes after goal is processed first time
pr __currentGoalParameters = _currentGoalParameters select {_x#0 != TAG_INSTANT};
pr __goalParameters = _goalParameters select {_x#0 != TAG_INSTANT};
OOP_INFO_1(" current goal params: %1", __currentGoalParameters);
OOP_INFO_1(" new goal parameters: %1", __goalParameters);
OOP_INFO_1(" equal: %1", __currentGoalParameters isEqualTo __goalParameters);
__currentGoalParameters isEqualTo __goalParameters;
}
) then {
Expand Down
125 changes: 94 additions & 31 deletions src/AI/Commander/AICommander.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,13 @@ CLASS("AICommander", "AI")
// Otherwise try to find any garrisons there
pr _isFriendly = false;
pr _garFriendly = CALLM1(_loc, "getGarrisons", T_GETV("side")) select {_x in T_GETV("garrisons")};
pr _gar = if (count _garFriendly != 0) then {
pr _garrisons = if (count _garFriendly != 0) then {
_isFriendly = true;
_garFriendly#0
_garFriendly;
} else {
pr _allGars = CALLM0(_loc, "getGarrisons");
if (count _allGars != 0) then { _allGars#0 } else { "" };
pr _args = [0, [GARRISON_TYPE_GENERAL, GARRISON_TYPE_ANTIAIR, GARRISON_TYPE_AIR]];
pr _allGars = CALLM(_loc, "getGarrisons", _args);
_allGars;
};

pr _value = NEW("IntelLocation", []);
Expand Down Expand Up @@ -618,36 +619,46 @@ CLASS("AICommander", "AI")

// Set side
if (_updateLevel >= CLD_UPDATE_LEVEL_SIDE) then {
if (!IS_NULL_OBJECT(_gar)) then {
if (count _garrisons > 0) then {
pr _gar = _garrisons#0;
SETV(_value, "side", CALLM0(_gar, "getSide"));
} else {
SETV(_value, "side", CLD_SIDE_UNKNOWN);
};
} else {
SETV(_value, "side", CLD_SIDE_UNKNOWN);
};

// Set efficiency
if (!_isFriendly) then {
// Set these fields if it's enemy location
if (_updateLevel >= CLD_UPDATE_LEVEL_UNITS) then {
if (!IS_NULL_OBJECT(_gar)) then {
pr _comp = CALLM0(_gar, "getCompositionNumbers");
pr _eff = CALLM0(_gar, "getEfficiencyTotal");
SETV(_value, "unitData", _comp);
SETV(_value, "efficiency", _eff);
} else {
SETV(_value, "unitData", +T_comp_null);
SETV(_value, "efficiency", +T_eff_null);
};
} else {
SETV(_value, "unitData", []);
SETV(_value, "efficiency", +T_eff_null);
};
} else {

if (_isFriendly) then {
// For friendly locations it makes no sense
SETV(_value, "unitData", +T_comp_null);
SETV(_value, "efficiency", +T_eff_null);
} else {
if (count _garrisons != 0) then {
// Calculate the sum of all compositions
pr _compSum = +T_comp_null; // Filled with 0
pr _effSum = +T_eff_null;
{ // forEach _garrisons;
pr _gar = _x;

// Set these fields if it's enemy location
if (_updateLevel >= CLD_UPDATE_LEVEL_UNITS) then {
pr _comp = CALLM0(_gar, "getCompositionNumbers");
pr _eff = CALLM0(_gar, "getEfficiencyTotal");
[_compSum, _comp] call comp_fnc_addAccumulate;
[_effSum, _eff] call eff_fnc_acc_add;
} else {
SETV(_value, "unitData", []);
SETV(_value, "efficiency", +T_eff_null);
};
} forEach _garrisons;

SETV(_value, "unitData", _compSum);
SETV(_value, "efficiency", _effSum);
} else {
SETV(_value, "unitData", +T_comp_null);
SETV(_value, "efficiency", +T_eff_null);
};
};

// Set ref to location object
Expand Down Expand Up @@ -2176,7 +2187,7 @@ http://patorjk.com/software/taag/#p=display&f=Univers&t=CMDR%20AI
}
) or {
// Consider all air garrisons
GETV(_x, "type") == GARRISON_TYPE_AIR
GETV(_x, "type") in [ GARRISON_TYPE_AIR, GARRISON_TYPE_ANTIAIR]
}
};

Expand Down Expand Up @@ -2882,7 +2893,7 @@ http://patorjk.com/software/taag/#p=display&f=Univers&t=CMDR%20AI

OOP_INFO_1(" More infantry required: %1", _infMoreRequired);

private _squadTypes = [T_GROUP_inf_assault_squad, T_GROUP_inf_rifle_squad];
private _squadTypes = [T_GROUP_inf_assault_squad, T_GROUP_inf_rifle_squad, T_GROUP_inf_weapons_squad];
OOP_INFO_1(" Trying to add %1 more infantry...", _infMoreRequired);

// Try to add recruits
Expand Down Expand Up @@ -3016,7 +3027,7 @@ http://patorjk.com/software/taag/#p=display&f=Univers&t=CMDR%20AI
#ifdef REINFORCEMENT_TESTING
if(isNil "gDebugReinfProgress") then { gDebugReinfProgress = 0; };
private _progress = gDebugReinfProgress;
gDebugReinfProgress = gDebugReinfProgress + 0.1;
gDebugReinfProgress = (gDebugReinfProgress + 0.1) min 1;
systemChat format ["Reinforcing %1 now at %2 progress", _side, _progress];
#else
private _progress = CALLM0(gGameMode, "getAggression"); // 0..1
Expand Down Expand Up @@ -3078,6 +3089,56 @@ http://patorjk.com/software/taag/#p=display&f=Univers&t=CMDR%20AI
} select {
!(_x isEqualTo [])
};

// Locations that we can reinforce with AA units
private _antiAirReinfInfo = _reinfLocations apply {
private _loc = GETV(_x, "actual");
private _AAGarrisons = CALLM2(_loc, "getGarrisons", _side, GARRISON_TYPE_ANTIAIR);

// Create AA garrison if it doesn't exist
private _AAGar = if(count _AAGarrisons == 0) then {
private _templateName = CALLM2(gGameMode, "getTemplateName", _side, "military");
private _args = [GARRISON_TYPE_ANTIAIR, _side, [], "military", _templateName];
private _gar = NEW("Garrison", _args);
CALLM2(_gar, "postMethodSync", "setLocation", [_loc]);
CALLM0(_gar, "activateCmdrThread");
_gar
} else {
_AAGarrisons # 0
};

private _nAA = 0;
// We want to include all garrisons that consider this location home, not just the one at the location currently
// (i.e. QRFs, attacks, convoys etc, that may return again) - just in case we decide to move the SPAA later
{
_nAA = _nAA + CALLM1(_x, "countUnits", [[T_VEH ARG T_VEH_SPAA]]);
} forEach CALLM2(_loc, "getHomeGarrisons", _side, GARRISON_TYPE_ANTIAIR);
private _locType = CALLM0(_loc, "getType");

private _locName = CALLM0(_loc, "getName");

private _nAASpace = CALLM1(_loc, "getCapacityAAForType", _locType);
private _nAAMax = ceil (_nAASpace * VEHICLE_STOCK_FN(_progressScaled, 1) * 1.3);

OOP_INFO_MSG("%1: Reinforcing %2 space %3 max %4 current num %5", [_AAGar ARG _locName ARG _nAASpace ARG _nAAMax ARG _nAA]);

[
_AAGar,
(CLAMP(_nAAMax, 0, _nAASpace) - _nAA) min 1
]
};

// Add AA
if (_progressScaled > 0.4 && ([_t, T_VEH, T_VEH_SPAA, 0] call t_fnc_isValid)) then {
{
_x params ["_AAGarrison", "_nAARequired"];
for "_i" from 0 to _nAARequired - 1 do {
private _type = T_VEH_SPAA;
private _newGroup = CALLM2(_AAGarrison, "postMethodAsync", "createAddVehGroup", [_side ARG T_VEH ARG _type ARG -1]);
OOP_INFO_MSG("%1: Created AA group %2", [_AAGarrison ARG _newGroup]);
};
} forEach _antiAirReinfInfo;
};

// Locations that we can reinforce with air units
private _airReinfInfo = _reinfLocations select {
Expand Down Expand Up @@ -3115,16 +3176,17 @@ http://patorjk.com/software/taag/#p=display&f=Univers&t=CMDR%20AI
private _nPlaneMax = ceil (_nPlaneSpace * VEHICLE_STOCK_FN(_progressScaled, 1) * 1.3);
[
_airGarr,
(CLAMP(_nHeliMax, 0, _nHeliSpace) - _nHeli) min 1,
(CLAMP(_nPlaneMax, 0, _nPlaneSpace) - _nPlane) min 1
(CLAMP(_nHeliMax, 0, _nHeliSpace) - _nHeli),
(CLAMP(_nPlaneMax, 0, _nPlaneSpace) - _nPlane)
]
};

// Add air
if (_progressScaled > 0.3 && ([_t, T_VEH, T_VEH_heli_attack, 0] call t_fnc_isValid)) then {
{
_x params ["_airGar", "_nHelisRequired", "_mPlanesRequired"];
for "_i" from 0 to _nHelisRequired - 1 do {
scopeName "loopAirfields";
_x params ["_airGar", "_nHelisRequired", "_nPlanesRequired"];
if (_nHelisRequired > 0) then {
private _type = T_VEH_heli_attack;
// selectRandomWeighted [
// T_VEH_heli_light, 1,
Expand All @@ -3133,6 +3195,7 @@ http://patorjk.com/software/taag/#p=display&f=Univers&t=CMDR%20AI
// ];
private _newGroup = CALLM2(_airGar, "postMethodAsync", "createAddVehGroup", [_side ARG T_VEH ARG _type ARG -1]);
OOP_INFO_MSG("%1: Created heli group %2", [_airGar ARG _newGroup]);
breakOut "loopAirfields"; // Add only one helicopter per whole reinforcement
};
} forEach _airReinfInfo;
};
Expand Down
38 changes: 30 additions & 8 deletions src/AI/Commander/CmdrAction/Actions/QRFCmdrAction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,7 @@ CLASS("QRFCmdrAction", "AttackCmdrAction")
private _srcGarrComp = GETV(_srcGarr, "composition");
private _srcType = GETV(_srcGarr, "type");

#ifdef OOP_INFO
if (_srcType == GARRISON_TYPE_AIR) then {
OOP_INFO_0(" Garrison type: air");
} else {
OOP_INFO_0(" Garrison type: ground");
};
#endif
OOP_INFO_1(" Garrison type: %1", _srcType);

ASSERT_OBJECT(_srcGarr);

Expand Down Expand Up @@ -183,6 +177,7 @@ CLASS("QRFCmdrAction", "AttackCmdrAction")
};

// Ground counterattack must calculate distance from simplified terrain grid
case GARRISON_TYPE_ANTIAIR;
case GARRISON_TYPE_GENERAL: {
private _distanceOverGround = CALLM2(gStrategicNavGrid, "calculateGroundDistance", _srcGarrPos, _tgtClusterPos);
_distanceOverGround;
Expand All @@ -199,6 +194,21 @@ CLASS("QRFCmdrAction", "AttackCmdrAction")
_needTransport = true;
};

// If this is an AA garrison, it must only fight against pure air targets
// Only some infantry is allowed to compensate for crew of the helicopter
if (_srcType == GARRISON_TYPE_ANTIAIR &&
{_enemyEff#T_EFF_medium>0 || _enemyEff#T_EFF_armor>0}) exitWith {
OOP_DEBUG_MSG(" Target cluster has non-air units, src garrison is anti-air", []);
T_CALLM1("setScore", ZERO_SCORE);
};

// If this is an AA garrison, ensure there are some air targets
if (_srcType == GARRISON_TYPE_ANTIAIR &&
{_enemyEff#T_EFF_air == 0}) exitWith {
OOP_DEBUG_MSG(" Target cluster no air units, src garrison is anti-air", []);
T_CALLM1("setScore", ZERO_SCORE);
};

// Try to allocate units
private _allocArgs = [];
private _allocResult = switch _srcType do {
Expand All @@ -225,6 +235,18 @@ CLASS("QRFCmdrAction", "AttackCmdrAction")
_transportWhitelistMask, _transportBlacklistMask];
CALLSM("GarrisonModel", "allocateUnits", _allocArgs)
};

FIX_LINE_NUMBERS()
case GARRISON_TYPE_ANTIAIR: {
private _payloadWhitelistMask = T_comp_antiair_mask;
private _payloadBlacklistMask = T_comp_static_mask; // Don't take static weapons under any conditions
private _transportWhitelistMask = T_comp_ground_or_infantry_mask; // Take ground units, take any infantry to satisfy crew requirements
private _transportBlacklistMask = [];
_allocArgs = [_enemyEff, _allocationFlags, _srcGarrComp, _srcGarrEff,
_payloadWhitelistMask, _payloadBlacklistMask,
_transportWhitelistMask, _transportBlacklistMask];
CALLSM("GarrisonModel", "allocateUnits", _allocArgs)
};
default { [] };
};

Expand All @@ -246,7 +268,7 @@ CLASS("QRFCmdrAction", "AttackCmdrAction")
};
*/
if (count ([_effRemaining, _srcDesiredEff] call eff_fnc_validateCrew) > 0 ) exitWith { // We must have enough crew to operate vehicles ...
OOP_DEBUG_1("Remaining crew requirement not satisfied: %1", _effRemaining);
OOP_DEBUG_1(" Remaining crew requirement not satisfied: %1", _effRemaining);
T_CALLM1("setScore", ZERO_SCORE);
};

Expand Down
2 changes: 1 addition & 1 deletion src/AI/Commander/Model/LocationModel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ CLASS("LocationModel", "ModelBase")

private _world = T_GETV("world");

private _garrisonActuals = CALLM2(_actual, "getGarrisons", 0, [GARRISON_TYPE_GENERAL ARG GARRISON_TYPE_AIR]);
private _garrisonActuals = CALLM2(_actual, "getGarrisons", 0, [GARRISON_TYPE_GENERAL ARG GARRISON_TYPE_AIR ARG GARRISON_TYPE_ANTIAIR]);
private _garrisonIds = [];
{
private _garrison = CALLM1(_world, "findGarrisonByActual", _x);
Expand Down
30 changes: 18 additions & 12 deletions src/AI/Garrison/ActionGarrisonRelax.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ CLASS("ActionGarrisonRelax", "ActionGarrisonBehaviour")

// Give goals to groups
pr _gar = GETV(T_GETV("AI"), "agent");
pr _garType = CALLM0(_gar, "getType");
pr _loc = CALLM0(_gar, "getLocation");
pr _buildings = if (_loc != NULL_OBJECT) then {+CALLM0(_loc, "getOpenBuildings")} else {[]}; // Buildings into which groups will be ordered to move
// Sort buildings by their height (or maybe there is a better criteria, but higher is better, right?)
Expand Down Expand Up @@ -118,21 +119,26 @@ CLASS("ActionGarrisonRelax", "ActionGarrisonBehaviour")
};

case GROUP_TYPE_VEH: {
if (!_atLocation) then {
// Get into vehicles when not at a location
_args = ["GoalGroupGetInVehiclesAsCrew", 0, [[TAG_ONLY_COMBAT_VEHICLES, true]] + _extraParams, _AI]; // Occupy only combat vehicles
if (_garType == GARRISON_TYPE_ANTIAIR) then {
// Anti air crew always chills in their tank
_args = ["GoalGroupGetInVehiclesAsCrew", 0, [[TAG_ONLY_COMBAT_VEHICLES, true]] + _extraParams, _AI];
} else {
// Crew of vehicle groups stays around their vehicle
pr _vehUnits = CALLM0(_group, "getVehicleUnits");
pr _goalParams = if (count _vehUnits > 0) then {
pr _vehUnit = selectRandom _vehUnits;
pr _pos = CALLM0(_vehUnit, "getPos");
// Relax within 50 meters of the vehicle
[[TAG_POS, _pos], [TAG_MOVE_RADIUS, 50]]
if (!_atLocation) then {
// Get into vehicles when not at a location
_args = ["GoalGroupGetInVehiclesAsCrew", 0, [[TAG_ONLY_COMBAT_VEHICLES, true]] + _extraParams, _AI]; // Occupy only combat vehicles
} else {
[]
// Crew of vehicle groups stays around their vehicle
pr _vehUnits = CALLM0(_group, "getVehicleUnits");
pr _goalParams = if (count _vehUnits > 0) then {
pr _vehUnit = selectRandom _vehUnits;
pr _pos = CALLM0(_vehUnit, "getPos");
// Relax within 50 meters of the vehicle
[[TAG_POS, _pos], [TAG_MOVE_RADIUS, 50]]
} else {
[]
};
_args = ["GoalGroupRelax", 0, _goalParams + _extraParams, _AI]; // They will patrol next to their vehicles
};
_args = ["GoalGroupRelax", 0, _goalParams + _extraParams, _AI]; // They will patrol next to their vehicles
};
};
};
Expand Down
4 changes: 3 additions & 1 deletion src/ClientSideChecks/PlayerMonitor.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,11 @@ CLASS("PlayerMonitor", "MessageReceiverEx") ;
OOP_INFO_1("CURRENT LOCATIONS: %1", T_GETV("currentLocations"));

// Check if player is trying to fly an aircraft
/*
private _veh = vehicle player;
if (_veh isKindOf "Air") then {
//pr _unit = GET_UNIT_FROM_OBJECT_HANDLE(_veh);
if ( /*!IS_NULL_OBJECT(_veh) &&*/ (isEngineOn _veh)) then {
if ( (isEngineOn _veh)) then {
pr _phrasesCantFly = [
localize "STR_PM_P_NO_PILOTING_1",
localize "STR_PM_P_NO_PILOTING_2",
Expand All @@ -249,6 +250,7 @@ CLASS("PlayerMonitor", "MessageReceiverEx") ;
};
};
};
*/

T_SETV("prevPos", getPosASL _unit);
ENDMETHOD;
Expand Down
1 change: 1 addition & 0 deletions src/GameMode/CivilWar/CivilWarCityData.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ CLASS("CivilWarCityData", "CivilWarLocationData")
params [P_THISOBJECT, P_NUMBER("_value")];
pr _population = T_GETV("population");
pr _mult = (_population/1000)^(-0.75); // https://www.desmos.com/calculator/mkpvvijqze
_mult = _mult min 1.55; //10 soldiers for 100 influence at base 0.07 per kill
_value = _value * _mult;
OOP_INFO_3("addInfluenceScaled: %1, multiplier: %2, population: %3", _value, _mult, _population);
T_CALLM1("addInfluence", _value);
Expand Down
12 changes: 9 additions & 3 deletions src/GameMode/CivilWar/CivilWarGameMode.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,18 @@ CLASS("CivilWarGameMode", "GameModeBase")
pr _locs = CALLSM0("Location", "getAll") select { CALLM0(_x, "getType") in _locTypes; };
pr _nCapturedLocs = 0;
pr _nCapturedAirports = 0;
pr _commanderAI = CALLSM("AICommander", "getAICommander", [ENEMY_SIDE]);
{
pr _garrisons = CALLM1(_x, "getGarrisons", FRIENDLY_SIDE);
if (count _garrisons > 0) then {
_nCapturedLocs = _nCapturedLocs + 1;
if (CALLM0(_x, "getType") == LOCATION_TYPE_AIRPORT) then {
_nCapturedAirports = _nCapturedAirports + 1;
// Also check if commander knows anything about this location
// He might not know about player-built places like camps
pr _intel = CALLM1(_commanderAI, "getIntelAboutLocation", _x);
if (!IS_NULL_OBJECT(_intel)) then {
_nCapturedLocs = _nCapturedLocs + 1;
if (CALLM0(_x, "getType") == LOCATION_TYPE_AIRPORT) then {
_nCapturedAirports = _nCapturedAirports + 1;
};
};
};
} forEach _locs;
Expand Down
Loading

0 comments on commit 3b96b73

Please sign in to comment.