9 protected string m_sTriggerName;
11 [
Attribute(uiwidget: UIWidgets.LocaleEditBox,
desc:
"Text that will be displayed above the countdown number",
category:
"Defend params")]
14 [
Attribute(defvalue:
"-1", UIWidgets.Slider,
desc:
"For how long you have to Defend the objective of the task. Value -1 is for indefinitely.",
params:
"-1 86400 1",
category:
"Defend params")]
15 protected float m_fDefendTime;
17 [
Attribute(defvalue:
"1",
desc:
"When enabled, it will display the text and how much time remains for the Task Defend",
category:
"Defend params")]
18 protected bool m_bDisplayCountdownHUD;
20 [
Attribute(defvalue:
"{47864BB47AB0B1F4}UI/layouts/HUD/CampaignMP/CampaignMainHUD.layout",
category:
"Defend params")]
26 [
Attribute(uiwidget: UIWidgets.Slider,
desc:
"When compared to the number of attackers, minimum of how much of the characters present in the task area must be from defending side to successfully complete the objective on evaluation",
params:
"0 1 0.01", precision: 2,
category:
"Defend params")]
29 [
Attribute(uiwidget: UIWidgets.EditBox,
desc:
"Layer containing attacker forces. Can be more layers, but these layers must include only AI units/groups and nothing else.",
category:
"Defend params")]
32 [
Attribute(
desc:
"When enabled, it will can finish the task earlier than the countdown when all attackers are eliminated",
category:
"Defend params")]
35 [
Attribute(
desc:
"When enabled, evaluation will be delayed and defenders will need to eliminate all attackers in order for the task to be succesfully completed",
category:
"Defend params")]
38 [
Attribute(
desc:
"When enabled, it will display the text to inform players that they have to eliminate all attacker units",
category:
"Defend params")]
41 [
Attribute(uiwidget: UIWidgets.LocaleEditBox,
desc:
"Text that will be displayed to inform players that they have to eliminate all attacker units",
category:
"Defend params")]
48 protected string m_sFormattedCountdownTitle =
string.Format(WidgetManager.Translate(
"<color rgba=\"226, 168, 80, 255\">%1</color>", m_sCountdownTitleText));
90 IEntity foundEntity =
GetGame().GetWorld().FindEntityByName(m_sTriggerName);
94 SCR_ScenarioFrameworkSlotTrigger slotTrigger = SCR_ScenarioFrameworkSlotTrigger.Cast(foundEntity.FindComponent(SCR_ScenarioFrameworkSlotTrigger));
110 Print(
"ScenarioFramework: Task Defend support entity not found in the world, task won't be created!", LogLevel.ERROR);
124 m_eTypeOfTask = SCR_ESFTaskType.DEFEND;
132 SCR_ScenarioFrameworkTaskDefendDefendingFaction defender = SCR_ScenarioFrameworkTaskDefendDefendingFaction.Cast(
m_aFactionSettings[i]);
135 if (defender.GetCountOnlyPlayers())
141 SCR_ScenarioFrameworkTaskDefendAttackingFaction attacker = SCR_ScenarioFrameworkTaskDefendAttackingFaction.Cast(
m_aFactionSettings[i]);
144 if (attacker.GetCountOnlyPlayers())
161 array<SCR_BaseTask> activeTasks = {};
170 if (taskToFind.GetLayerTask() ==
this)
189 int defenderCount = 0;
190 int attackerCount = 0;
195 m_SupportEntity.FinishTask(
m_Task);
200 float defenderRatioEval = defenderCount / attackerCount;
203 m_SupportEntity.FailTask(
m_Task);
209 m_SupportEntity.FinishTask(
m_Task);
217 IEntity attackerLayerEntity;
220 attackerLayerEntity =
GetGame().GetWorld().FindEntityByName(layerName);
221 if (!attackerLayerEntity)
235 if (m_fDefendTime > 0)
250 for (
int i = 0, count =
m_aChildren.Count(); i < count; i++)
256 array<IEntity> spawnedEntities = layerBase.GetSpawnedEntities();
257 for (
int j = 0, countJ = spawnedEntities.Count(); j < countJ; j++)
268 override void RestoreToDefault(
bool includeChildren =
false,
bool reinitAfterRestoration =
false)
283 super.RestoreToDefault(includeChildren, reinitAfterRestoration);
292 override void Init(
SCR_ScenarioFrameworkArea area =
null, SCR_ScenarioFrameworkEActivationType activation = SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT)
306 if (!activationCondition.Init(
GetOwner()))
315 super.Init(area, activation);
342 if (!m_sTriggerName.IsEmpty())
353 super.OnPostInit(owner);
356 SetEventMask(owner, EntityEvent.INIT | EntityEvent.FRAME);
374 ImageWidget leftFlag = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"FlagSideBlue"));
375 ImageWidget rightFlag = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"FlagSideRed"));
376 RichTextWidget leftScore = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(
"ScoreBlue"));
377 RichTextWidget rightScore = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(
"ScoreRed"));
378 RichTextWidget winScore = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(
"TargetScore"));
381 ImageWidget winScoreSideLeft = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"ObjectiveLeft"));
382 ImageWidget winScoreSideRight = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"ObjectiveRight"));
385 leftFlag.SetVisible(
false);
386 rightFlag.SetVisible(
false);
387 leftScore.SetVisible(
false);
388 rightScore.SetVisible(
false);
389 winScore.SetVisible(
false);
390 winScoreSideLeft.SetVisible(
false);
391 winScoreSideRight.SetVisible(
false);
398 if (!m_bDisplayCountdownHUD)
411 taskID =
m_Task.GetTaskID();
449 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
502 if (attackerLayer.GetEnableRepeatedSpawn() && attackerLayer.GetRepeatedSpawnNumber() > 1)
505 array<IEntity> spawnedEntities = attackerLayer.GetSpawnedEntities();
506 SCR_ChimeraCharacter character;
508 foreach (IEntity entity : spawnedEntities)
510 character = SCR_ChimeraCharacter.Cast(entity);
520 damageManager = character.GetDamageManager();
521 if (!damageManager.IsDestroyed())
534 GetOwner().ClearFlags(EntityFlags.ACTIVE);
540 override void EOnFrame(IEntity owner,
float timeSlice)
542 super.EOnFrame(owner, timeSlice);
573 protected FactionKey m_sFactionKey;
575 [
Attribute(defvalue:
"0", UIWidgets.EditBox,
desc:
"When disabled, all units from this faction will be counted with for other Task Defend conditions",
category:
"")]
576 protected bool m_bCountOnlyPlayers;
582 FactionManager factionManager =
GetGame().GetFactionManager();
591 void SetFactionKey(FactionKey factionKey)
598 bool GetCountOnlyPlayers()
605 class SCR_ScenarioFrameworkTaskDefendDefendingFactionTitle : BaseContainerCustomTitle
609 title =
"Defending faction";
617 override bool _WB_GetCustomTitle(BaseContainer source, out
string title)
619 title =
"Attacking faction";