Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScoringSystemComponent.c
Go to the documentation of this file.
2{
3}
4
6class 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
31
34class 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 {
49 SCR_BaseGameMode gameMode = SCR_BaseGameMode.Cast(GetGame().GetGameMode());
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
87class 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(notnull SCR_InstigatorContextData instigatorContextData)
140 {
141 super.OnPlayerKilled(instigatorContextData);
142
143 // Add death no matter what
144 AddDeath(instigatorContextData.GetVictimPlayerID());
145
146 Instigator instigator = instigatorContextData.GetInstigator();
147
148 //~ Killed by AI
149 if (instigator.GetInstigatorType() != InstigatorType.INSTIGATOR_PLAYER)
150 return;
151
152 SCR_ECharacterControlType victimControlType = instigatorContextData.GetVictimCharacterControlType();
153 SCR_ECharacterControlType killerControlType = instigatorContextData.GetKillerCharacterControlType();
154
155 //~ Score for killing self, killing enemy player and killing friendly player
156 //~ Player killed self
157 if (instigatorContextData.HasAnyVictimKillerRelation(SCR_ECharacterDeathStatusRelations.SUICIDE))
158 {
159 //~ Possessed AI do not count the suicide
160 if (victimControlType == SCR_ECharacterControlType.POSSESSED_AI)
161 return;
162
163 AddSuicide(instigatorContextData.GetVictimPlayerID());
164 return;
165 }
166 //~ Killed by enemy player.
167 if (instigatorContextData.HasAnyVictimKillerRelation(SCR_ECharacterDeathStatusRelations.KILLED_BY_ENEMY_PLAYER))
168 {
169 //~ If killer is a possessed player it is not counted
170 if (killerControlType == SCR_ECharacterControlType.POSSESSED_AI)
171 return;
172
173 AddKill(instigator.GetInstigatorPlayerID());
174 return;
175 }
176 //~ Killed by friendly player. Score will still be deducted from friendly kills of admin and GMs
177 if (instigatorContextData.DoesPlayerKillCountAsTeamKill(editorKillsCount: true))
178 {
179 AddTeamKill(instigator.GetInstigatorPlayerID());
180 return;
181 }
182 }
183
184 //------------------------------------------------------------------------------------------------
185 protected override void OnGameModeEnd(SCR_GameModeEndData data)
186 {
187 super.OnGameModeEnd(data);
188 }
189
190 //------------------------------------------------------------------------------------------------
192 protected override void OnPlayerScoreChanged(int playerId, SCR_ScoreInfo scoreInfo)
193 {
194 super.OnPlayerScoreChanged(playerId, scoreInfo);
195
196 foreach (IScoringAction action : m_aActions)
197 {
198 action.OnPlayerScoreChanged(playerId, this);
199 }
200 }
201
202 //------------------------------------------------------------------------------------------------
204 protected override void OnFactionScoreChanged(Faction faction, SCR_ScoreInfo scoreInfo)
205 {
206 super.OnFactionScoreChanged(faction, scoreInfo);
207
208 foreach (IScoringAction action : m_aActions)
209 {
210 action.OnFactionScoreChanged(faction, this);
211 }
212 }
213}
EGameOverTypes
ArmaReforgerScripted GetGame()
Definition game.c:1398
bool Execute(notnull SCR_AIGroupUtilityComponent groupUtility, vector targetPosition, SCR_AIActivitySmokeCoverFeatureProperties smokeCoverProperties, notnull array< AIAgent > avoidAgents, notnull array< AIAgent > excludeAgents, int maxPositionCount=1, SCR_AIActivityBase contextActivity=null)
override void OnGameModeEnd(SCR_GameModeEndData data)
ref SCR_SortedArray< SCR_BaseEditorAction > m_aActions
SCR_BaseGameMode GetGameMode()
void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
SCR_ECharacterControlType
What kind of controller the character or (in some cases vehicle) has, eg: AI, Player,...
Get all prefabs that have the spawner data
Get all prefabs that have the spawner the given labels and are valid in the editor mode param catalogType Type to catalog to get prefabs from param editorMode Editor mode to get valid entries from param faction Faction(Optional)
EScoringActionMode
Action type.
SCR_ScoringSystemComponentClass SCR_BaseScoringSystemComponentClass BaseContainerProps()] class IScoringAction
void EndGameMode(SCR_GameModeEndData endData)
void OnFactionScoreChanged(Faction faction, SCR_ScoreInfo scoreInfo)
void OnPlayerScoreChanged(int playerId, SCR_ScoreInfo scoreInfo)
InstigatorType
SCR_FieldOfViewSettings Attribute