2[
ComponentEditorProps(
category:
"GameScripted/Commander", description:
"Handles voting and AI decisions for the faction Commander role. Should be attached to gamemode entity.")]
7class SCR_CampaignFactionCommanderHandlerComponent : SCR_FactionCommanderHandlerComponent
9 [
Attribute(
"100",
desc:
"How far from the Establish task will players still be able to build a new base.",
params:
"0 inf 1")]
15 static const string SEIZE_TASK_RELAY_NAME =
"#AR-CampaignTasks_TitleHack-UC";
16 static const string SEIZE_TASK_RELAY_DESC =
"#AR-CampaignTasks_DescriptionReconfigure";
17 static const string SEIZE_TASK_NAME =
"#AR-CampaignTasks_TitleSeize-UC";
18 static const string SEIZE_TASK_DESC =
"#AR-CampaignTasks_DescriptionSeize";
19 static const string SEIZE_TASK_ID =
"%1_SeizeCampaignMilitaryBase_%2";
20 static const ResourceName SEIZE_TASK_PREFAB =
"{1CE0D63C852E747B}Prefabs/Tasks/SeizeCampaignMilitaryBaseTaskEntity.et";
41 if (!m_MinBaseDistanceConfig)
44 return m_MinBaseDistanceConfig.GetMinDistanceFromBase(baseType);
57 if (!campaignFaction || !campaignFaction.IsPlayable())
104 if (!campaignFaction.IsAICommander())
114 if (!militaryBaseSystem)
117 array<SCR_MilitaryBaseComponent> bases = {};
120 array<Faction> factions = {};
121 GetGame().GetFactionManager().GetFactionsList(factions);
126 foreach (SCR_MilitaryBaseComponent
base : bases)
139 if (!campaignFaction || !campaignFaction.IsPlayable() || !campaignFaction.IsAICommander() || !campaignFaction.IsTasksEnabled())
142 if (baseFaction == campaignFaction)
159 if (
GetTaskOnBase(targetBase, faction, SCR_SeizeCampaignMilitaryBaseTaskEntity))
163 if (!groupTaskManager || !groupTaskManager.CanCreateNewTaskWithResourceName(SEIZE_TASK_PREFAB, faction))
166 string taskId =
string.Format(SEIZE_TASK_ID, faction.GetFactionKey(), targetBase.GetCallsign());
172 title = SEIZE_TASK_RELAY_NAME;
173 description = SEIZE_TASK_RELAY_DESC;
177 title = SEIZE_TASK_NAME;
178 description = SEIZE_TASK_DESC;
185 SCR_CampaignMilitaryBaseTaskEntity newTask = SCR_CampaignMilitaryBaseTaskEntity.Cast(taskSystem.CreateTask(
190 targetBase.GetOwner().GetOrigin()
197 newTask.SetMilitaryBaseCallSign(targetBase.GetCallsign());
198 taskSystem.SetTaskOwnership(newTask, SCR_ETaskOwnership.EXECUTOR);
200 taskSystem.AddTaskFaction(newTask, faction.GetFactionKey());
202 groupTaskManager.SetGroupTask(newTask, 0);
208 array<SCR_Task> tasks = {};
212 faction.GetFactionKey(),
219 SCR_CampaignMilitaryBaseTaskEntity campaignMilitaryBaseTask;
223 campaignMilitaryBaseTask = SCR_CampaignMilitaryBaseTaskEntity.Cast(
task);
224 if (!campaignMilitaryBaseTask)
231 base = campaignMilitaryBaseTask.GetMilitaryBase();
235 if (
base == campaignMilitaryBase)
254 SCR_AIGroup playerGroup = groupsManager.GetPlayerGroup(playerId);
282 SCR_XPHandlerComponent xpHandler = SCR_XPHandlerComponent.Cast(
GetGame().
GetGameMode().FindComponent(SCR_XPHandlerComponent));
300 super.OnPlayerRegistered(playerId);
308 super.OnPlayerDisconnected(playerId, cause, timeout);
316 super.OnServerCommanderChanged(newCommanderId, oldCommanderId);
325 super.OnPlayerKilled(instigatorContextData);
327 int playerID = instigatorContextData.GetVictimPlayerID();
333 if (faction.IsPlayerCommander(playerID))
346 PlayerController playerController =
GetGame().GetPlayerManager().GetPlayerController(playerId);
347 if (!playerController)
363 super.EOnInit(owner);
ArmaReforgerScripted GetGame()
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_BaseGameMode GetGameMode()
RplComponent m_RplComponent
int m_iBaseEstablishingRadius
void OnFactionTasksEnabledChanged(Faction faction)
void OnServerCommanderChanged(int newCommanderId, int oldCommanderId)
void AwardCommanderTaskCompletionXP(int commanderId, SCR_EXPRewards rewardId, int XPToAdd)
void RegisterPlayerXPInvokers(int playerId, bool unregister=false)
int GetBaseEstablishingRadius()
void ~SCR_CampaignFactionCommanderHandlerComponent()
void CheckSeizeTasks(notnull SCR_CampaignFaction faction, int playerid)
SCR_Task GetTaskOnBase(notnull SCR_CampaignMilitaryBaseComponent campaignMilitaryBase, notnull Faction faction, typename taskClass)
int GetBaseMinDistance(notnull SCR_CampaignMilitaryBaseComponent base)
void CreateSeizeTask(notnull SCR_CampaignFaction faction, SCR_CampaignMilitaryBaseComponent targetBase, int playerid)
void OnRadioCoverageChanged(notnull SCR_CoverageRadioComponent radio)
void OnCommanderChanged(SCR_Faction faction, int commanderPlayerId)
void OnBaseFactionChanged(notnull SCR_MilitaryBaseComponent base, Faction faction)
void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
Get all prefabs that have the spawner data
OnFactionCommanderChangedInvoker GetOnFactionCommanderChanged()
void SCR_FactionManager(IEntitySource src, IEntity parent)
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
void SCR_GroupTaskManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
ScriptInvokerBase< OnPlayerXPChangedMethod > OnPlayerXPChanged
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void SCR_Task(IEntitySource src, IEntity parent)
Handles voting and AI decisions for the faction Commander role in Conflict. Should be attached to gam...
void SendHQMessage(SCR_ERadioMsg msgType, int baseCallsign=SCR_MilitaryBaseComponent.INVALID_BASE_CALLSIGN, int calledID=SCR_CampaignMilitaryBaseComponent.INVALID_PLAYER_INDEX, bool public=true, int param=SCR_CampaignRadioMsg.INVALID_RADIO_MSG_PARAM)
bool IsValidForSeizeTask()
SCR_ECampaignBaseType GetType()
Returns type of this base.
string GetFormattedBaseNameWithCallsign(Faction faction)
bool IsHQRadioTrafficPossible(notnull SCR_CampaignFaction faction, SCR_ERadioCoverageStatus direction=SCR_ERadioCoverageStatus.RECEIVE)
SCR_CampaignFaction GetCampaignFaction()
Returns the owning faction.
float GetRewardXPAmountFraction()
bool IsXPRewardListed(SCR_EXPRewards rewardId)
Handles voting and AI decisions for the faction Commander role. Should be attached to gamemode entity...
int GetBases(notnull out array< SCR_MilitaryBaseComponent > bases)
OnBaseFactionChangedInvoker GetOnBaseFactionChanged()
static SCR_MilitaryBaseSystem GetInstance()
OnPlayerXPChanged GetOnPlayerXPChanged()
OnCoverageChangedInvoker GetOnCoverageChanged()
static SCR_RadioCoverageSystem GetInstance()
override void EOnInit(IEntity owner)
SCR_FieldOfViewSettings Attribute
override void OnPlayerRegistered(int playerId)
override void OnPlayerDisconnected(int playerId, KickCauseCode cause, int timeout)