Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ScoringSystemComponent.c
Go to the documentation of this file.
2 {
3 }
4 
6 class IScoringAction
7 {
8  [Attribute("0", UIWidgets.ComboBox, "Scoring mode", "", ParamEnumArray.FromEnum(EScoringActionMode) )]
9  protected EScoringActionMode m_eScoringMode;
10 
11  //------------------------------------------------------------------------------------------------
15  void OnPlayerScoreChanged(int playerId, SCR_BaseScoringSystemComponent scoring);
16 
17  //------------------------------------------------------------------------------------------------
21  void OnFactionScoreChanged(Faction faction, SCR_BaseScoringSystemComponent scoring);
22 }
23 
26 {
30 }
31 
34 class EndGameAction : IScoringAction
35 {
36  [Attribute("100", UIWidgets.EditBox, "Scoring limit", "")]
37  protected int m_iScoreLimit;
38 
39  //------------------------------------------------------------------------------------------------
41  int GetScoreLimit()
42  {
43  return m_iScoreLimit;
44  }
45 
46  //------------------------------------------------------------------------------------------------
47  protected void Execute(SCR_GameModeEndData endData)
48  {
50  if (!gameMode.IsRunning())
51  return;
52 
53  gameMode.EndGameMode(endData);
54  }
55 
56  //------------------------------------------------------------------------------------------------
57  override void OnPlayerScoreChanged(int playerId, SCR_BaseScoringSystemComponent scoring)
58  {
59  if (m_eScoringMode != EScoringActionMode.SLM_Player && m_eScoringMode != EScoringActionMode.SLM_Any)
60  return;
61 
62  int score = scoring.GetPlayerScore(playerId);
63  if (score < m_iScoreLimit)
64  return;
65 
66  SCR_GameModeEndData endData = SCR_GameModeEndData.CreateSimple(EGameOverTypes.ENDREASON_SCORELIMIT, winnerId: playerId);
67  Execute(endData);
68  }
69 
70  //------------------------------------------------------------------------------------------------
71  override void OnFactionScoreChanged(Faction faction, SCR_BaseScoringSystemComponent scoring)
72  {
73  if (m_eScoringMode != EScoringActionMode.SLM_Faction && m_eScoringMode != EScoringActionMode.SLM_Any)
74  return;
75 
76  int score = scoring.GetFactionScore(faction);
77  if (score < m_iScoreLimit)
78  return;
79 
80  int factionIndex = GetGame().GetFactionManager().GetFactionIndex(faction);
81  SCR_GameModeEndData endData = SCR_GameModeEndData.CreateSimple(EGameOverTypes.ENDREASON_SCORELIMIT, winnerFactionId: factionIndex);
82  Execute(endData);
83  }
84 }
85 
87 class SCR_ScoringSystemComponent : SCR_BaseScoringSystemComponent
88 {
89  //Score multipliers
90  [Attribute("1", UIWidgets.EditBox, "Kill score multiplier", category: "Scoring: Multipliers")]
91  protected int m_iKillScoreMultiplier;
92 
93  [Attribute("-1", UIWidgets.EditBox, "Teamkill score multiplier", category: "Scoring: Multipliers")]
94  protected int m_iTeamKillScoreMultiplier;
95 
96  [Attribute("0", UIWidgets.EditBox, "Death score multiplier", category: "Scoring: Multipliers")]
97  protected int m_iDeathScoreMultiplier;
98 
99  [Attribute("-1", UIWidgets.EditBox, "Suicide score multiplier", category: "Scoring: Multipliers")]
100  protected int m_iSuicideScoreMultiplier;
101 
102  [Attribute("1", UIWidgets.EditBox, "Objective score multiplier", category: "Scoring: Multipliers")]
103  protected int m_iObjectiveScoreMultiplier;
104 
105  [Attribute("", UIWidgets.Object, "List of actions executed when score changes.", category: "Scoring: Actions")]
106  protected ref array<ref IScoringAction> m_aActions;
107 
108  //------------------------------------------------------------------------------------------------
110  override int GetScoreLimit()
111  {
112  foreach (IScoringAction scoringAction : m_aActions)
113  {
114  EndGameAction possibleAction = EndGameAction.Cast(scoringAction);
115  if (possibleAction)
116  return possibleAction.GetScoreLimit();
117  }
118 
119  return super.GetScoreLimit();
120  }
121 
122  //------------------------------------------------------------------------------------------------
123  protected override int CalculateScore(SCR_ScoreInfo info)
124  {
125  int score = info.m_iKills * m_iKillScoreMultiplier +
126  info.m_iTeamKills * m_iTeamKillScoreMultiplier +
127  info.m_iDeaths * m_iDeathScoreMultiplier +
128  info.m_iSuicides * m_iSuicideScoreMultiplier +
129  info.m_iObjectives * m_iObjectiveScoreMultiplier;
130 
131  if (score < 0)
132  return 0;
133 
134  return score;
135  }
136 
137  //------------------------------------------------------------------------------------------------
139  protected override void OnPlayerKilled(int playerId, IEntity playerEntity, IEntity killerEntity, notnull Instigator killer)
140  {
141  super.OnPlayerKilled(playerId, playerEntity, killerEntity, killer);
142 
143  // Add death no matter what
144  AddDeath(playerId);
145 
146  if (killer.GetInstigatorType() != InstigatorType.INSTIGATOR_PLAYER)
147  return;
148 
149  int killerId = killer.GetInstigatorPlayerID();
150 
151  // Suicide?
152  if (playerId == killerId)
153  {
154  AddSuicide(playerId);
155  return;
156  }
157 
158  SCR_ChimeraCharacter playerEntityChar = SCR_ChimeraCharacter.Cast(playerEntity);
159  if (!playerEntityChar)
160  return;
161 
162  // We have to resolve who and what faction they belong to
163  SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
164  if (!factionManager)
165  return;
166 
167  Faction factionKiller = Faction.Cast(factionManager.GetPlayerFaction(killerId));
168  if (!factionKiller)
169  return;
170 
171  if (factionKiller.IsFactionFriendly(playerEntityChar.GetFaction()))
172  AddTeamKill(killerId);
173  else
174  AddKill(killerId);
175  }
176 
177  //------------------------------------------------------------------------------------------------
178  protected override void OnGameModeEnd(SCR_GameModeEndData data)
179  {
180  super.OnGameModeEnd(data);
181  }
182 
183  //------------------------------------------------------------------------------------------------
185  protected override void OnPlayerScoreChanged(int playerId, SCR_ScoreInfo scoreInfo)
186  {
187  super.OnPlayerScoreChanged(playerId, scoreInfo);
188 
189  foreach (IScoringAction action : m_aActions)
190  {
191  action.OnPlayerScoreChanged(playerId, this);
192  }
193  }
194 
195  //------------------------------------------------------------------------------------------------
197  protected override void OnFactionScoreChanged(Faction faction, SCR_ScoreInfo scoreInfo)
198  {
199  super.OnFactionScoreChanged(faction, scoreInfo);
200 
201  foreach (IScoringAction action : m_aActions)
202  {
203  action.OnFactionScoreChanged(faction, this);
204  }
205  }
206 }
SCR_BaseGameMode
Definition: SCR_BaseGameMode.c:137
InstigatorType
InstigatorType
Definition: InstigatorType.c:12
SCR_ScoringSystemComponentClass
Definition: SCR_ScoringSystemComponent.c:1
m_aActions
ref SCR_SortedArray< SCR_BaseEditorAction > m_aActions
Definition: SCR_BaseActionsEditorComponent.c:8
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_BaseScoringSystemComponent
Definition: SCR_BaseScoringSystemComponent.c:26
SLM_Any
@ SLM_Any
Definition: SCR_ScoringSystemComponent.c:29
BaseContainerProps
SCR_ScoringSystemComponentClass SCR_BaseScoringSystemComponentClass BaseContainerProps()] class IScoringAction
Definition: SCR_ScoringSystemComponent.c:5
Instigator
Definition: Instigator.c:6
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
EGameOverTypes
EGameOverTypes
Definition: EGameOverTypes.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
OnPlayerKilled
void OnPlayerKilled(int playerId, IEntity playerEntity, IEntity killerEntity, notnull Instigator killer)
Definition: SCR_CampaignFeedbackComponent.c:513
SCR_GameModeEndData
Definition: SCR_GameModeEndData.c:4
Execute
bool Execute(notnull SCR_AIGroupUtilityComponent groupUtility, vector targetPosition, SCR_AIActivitySmokeCoverFeatureProperties smokeCoverProperties, notnull array< AIAgent > avoidAgents, notnull array< AIAgent > excludeAgents, SCR_AIActivityBase contextActivity)
Definition: SCR_AIActivitySmokeCoverFeature.c:199
EScoringActionMode
EScoringActionMode
Action type.
Definition: SCR_ScoringSystemComponent.c:25
SLM_Faction
@ SLM_Faction
Definition: SCR_ScoringSystemComponent.c:28
SCR_BaseScoringSystemComponentClass
Definition: SCR_BaseScoringSystemComponent.c:1
SCR_ScoreInfo
Definition: SCR_ScoreInfo.c:6
Faction
Definition: Faction.c:12
data
Get all prefabs that have the spawner data
Definition: SCR_EntityCatalogManagerComponent.c:305
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition: SCR_FactionManager.c:461
SLM_Player
@ SLM_Player
Definition: SCR_ScoringSystemComponent.c:27
OnGameModeEnd
protected override void OnGameModeEnd(SCR_GameModeEndData data)
Definition: SCR_DataCollectorComponent.c:49
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180