1[
EntityEditorProps(
category:
"GameScripted/GameMode/CaptureAndHold", description:
"Area that awards score points when captured.")]
15 [
Attribute(
"#AR-CAH-Area_Symbol_A",
UIWidgets.EditBox,
"Single character used for visualizing this area.",
category:
"CaptureAndHold")]
18 [
Attribute(
"0 0 0",
UIWidgets.EditBox,
"Center of the objective in local space.",
category:
"CaptureAndHold",
params:
"inf inf 0 purposeCoords spaceEntity")]
28 int m_iScorePerTickContested;
30 [
Attribute(
"0.5",
UIWidgets.Slider,
"Percent of players needed (compared to max players) to start contesting.",
params:
"0 1 0.01",
category:
"CaptureAndHold")]
31 float m_fContestingRatio;
73 super.RplLoad(reader);
75 int factionIndex = -1;
76 reader.ReadInt(factionIndex);
79 if (factionIndex != -1)
80 contestingFaction =
GetGame().GetFactionManager().GetFactionByIndex(factionIndex);
93 protected override bool RplSave(ScriptBitWriter writer)
95 super.RplSave(writer);
97 int factionIndex = -1;
101 writer.WriteInt(factionIndex);
119 FactionManager factionManager =
GetGame().GetFactionManager();
122 if (previousFactionIndex != -1)
123 previousFaction = factionManager.GetFactionByIndex(previousFactionIndex);
126 if (newFactionIndex != -1)
127 newFaction = factionManager.GetFactionByIndex(newFactionIndex);
143 return m_iScorePerTick;
150 return m_sAreaSymbol;
157 return m_vObjectiveCenter;
164 return CoordToParent(m_vObjectiveCenter);
192 SCR_CaptureAndHoldManager parentManager = SCR_CaptureAndHoldManager.GetAreaManager();
195 Print(
"CaptureAndHoldArea cannot find SCR_CaptureAndHoldManager! Functionality might be limited!",
LogLevel.WARNING);
199 parentManager.RegisterArea(
this);
202 m_MapDescriptor = SCR_MapDescriptorComponent.Cast(FindComponent(SCR_MapDescriptorComponent));
211 Print(
"CaptureAndHoldArea cannot find SCR_BaseScoringSystemComponent! Points will not be awarded!",
LogLevel.WARNING);
228 props.SetIconSize(0.65, 0.65, 0.65);
229 props.SetTextSize(32, 32, 32);
231 props.SetFrontColor(
Color.White);
232 props.SetTextColor(
Color.White);
233 props.SetTextOffsetX(-10);
234 props.SetTextOffsetY(-16.5);
235 props.Activate(
true);
236 props.SetFont(
"{EABA4FE9D014CCEF}UI/Fonts/RobotoCondensed/RobotoCondensed_Bold.fnt");
237 item.SetProps(props);
240 item.SetPos(xyz[0], xyz[2]);
241 item.SetVisible(
true);
252 Color color =
Color.FromRGBA(249, 210, 103, 255);
253 bool friendly =
false;
258 float val01 =
Math.Sin( GetWorld().GetWorldTime() * 0.01 ) * 0.5 + 0.5;
267 MapItem mapItem = target.Item();
275 props.SetFrontColor(color);
276 props.SetTextColor(color);
278 props.Activate(
true);
279 mapItem.SetProps(props);
286 super.OnFrame(owner, timeSlice);
309 m_fTickTime += timeSlice;
310 while (m_fTickTime >= m_fTickRate)
312 m_fTickTime -= m_fTickRate;
344 scoringSystem.AddFactionObjective(owningFaction, awardedScore);
347 array<SCR_ChimeraCharacter> occupants = {};
349 for (
int i = 0; i < count; ++i)
351 int playerId =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(occupants[i]);
357 scoringSystem.AddObjective(playerId, awardedScore,
false);
368 FactionManager factionManager =
GetGame().GetFactionManager();
369 int previousIndex = factionManager.GetFactionIndex(previousFaction);
372 newIndex = factionManager.GetFactionIndex(newFaction);
382 Faction owningFaction = super.EvaluateOwnerFaction();
392 SCR_CaptureAndHoldManager manager = SCR_CaptureAndHoldManager.GetAreaManager();
393 if (manager && manager.GetIsAreaFactionPersistent())
417 if (faction == owningFaction)
422 if (occupantCount > contestingCount)
424 contestingCount = occupantCount;
425 contestingFaction = faction;
430 float minContestingCount = m_fContestingRatio * ownerCount;
431 if ((
float)contestingCount >= minContestingCount)
443 return owningFaction;
454 Faction faction = character.GetFaction();
459 return indexOf != -1;
478 super.OnOwningFactionChanged(previousFaction, newFaction);
491 SCR_CaptureAndHoldManager parentManager = SCR_CaptureAndHoldManager.GetAreaManager();
495 parentManager.UnregisterArea(
this);
ArmaReforgerScripted GetGame()
ScriptInvokerBase< CaptureAreaTickEventDelegate > CaptureAreaTickEvent
func CaptureAreaTickEventDelegate
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
SCR_BaseScoringSystemComponent GetScoringSystemComponent()
CaptureAreaTickEvent GetOnTickInvoker()
Returns invoker that is invoked when this area ticks (awards score).
override bool RplSave(ScriptBitWriter writer)
void ~SCR_CaptureAndHoldArea()
Unregisters self from parent manager.
event void OnContestingFactionChanged(Faction previousFaction, Faction newFaction)
ref CaptureAreaTickEvent m_OnTickEvent
Callback for when a tick event is raised by this area.
void UpdateMapDescriptor(SCR_MapDescriptorComponent target)
bool IsMajor()
Returns true if this area is marked as a major objective.
override void OnOwningFactionChanged(Faction previousFaction, Faction newFaction)
LocalizedString GetAreaSymbol()
Returns the short "symbolic" one-character name of this area.
vector GetWorldObjectiveCenter()
Returns objective center in world space.
SCR_BaseGameMode GetGameMode()
Utility method - returns current scripted game mode.
void Rpc_SetContestingFaction_BC(int previousFactionIndex, int newFactionIndex)
SCR_MapDescriptorComponent m_MapDescriptor
Attached map descriptor component used for visualization (if any) or null if none.
bool IsCharacterInside(SCR_ChimeraCharacter character)
override Faction EvaluateOwnerFaction()
Handles owning and contesting changes based on defined parameters.
override void OnFrame(IEntity owner, float timeSlice)
Updates the area and awards points if held.
void SetContestingFactionInternal(Faction previousFaction, Faction newFaction)
Sets internal owner faction and raises corresponding callback.
void InitializeMapDescriptor(SCR_MapDescriptorComponent target)
SCR_BaseScoringSystemComponent GetScoringSystemComponent()
Returns scoring system attached to current gamemode (if any) or null otherwise.
override void OnInit(IEntity owner)
Initialize this area and register it to parent manager.
Faction GetContestingFaction()
Returns the faction that currently owns the area or null if none.
bool IsContested()
Returns true if this area is being contested.
Faction m_ContestingFaction
The faction that currently attacking/contesting this point in relation to the owner faction.
override bool RplLoad(ScriptBitReader reader)
Called when Item is initialized from replication stream. Carries the data from Master.
vector GetLocalObjectiveCenter()
Returns objective center in local space relative to the area.
int GetScorePerTick()
Returns score awarded per area tick.
void DoSetContestingFaction(Faction previousFaction, Faction newFaction)
RplComponent m_pRplComponent
Replication component of this entity.
ref map< Faction, ref array< SCR_ChimeraCharacter > > m_mOccupants
Faction GetOwningFaction()
Returns the faction that currently owns the area or null if none.
int GetOccupantsCount(Faction faction)
int GetOccupants(Faction faction, notnull array< SCR_ChimeraCharacter > outCharacters)
Faction m_pOwnerFaction
The faction that currently owns this area.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.