Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_XPHandlerComponent.c
Go to the documentation of this file.
2{
3}
4
5class SCR_XPHandlerComponent : SCR_BaseGameModeComponent
6{
7 [Attribute("{E6FC4537B53EA00B}Configs/Campaign/XPRewards.conf", params: "conf class=SCR_XPRewardList")]
8 private ResourceName m_sXPRewardsConfig;
9
10 [Attribute("300", UIWidgets.EditBox, "How many XP a player needs to gain in a single life to get the Veterancy award. 0 = disabled.", params: "0 inf 1")]
11 protected int m_iVeterancyXPAwardThreshold;
12
13 [Attribute("1800", UIWidgets.EditBox, "If suicide is committed more than once in this time (seconds), a penalty is issued.", params: "0 inf 1")]
14 protected int m_iSuicidePenaltyCooldown;
15
16 [Attribute("0.1", UIWidgets.EditBox, "Fraction of the vehicle cost to be awarded as XP to player destroying it", params: "0 inf 1")]
17 protected float m_fEnemyVehicleDestroyXPMultiplier;
18
19 [Attribute("180", UIWidgets.EditBox, "Player is being rewarded xp for survival each time this amount of seconds pass since spawning", params: "0 inf 1")]
20 protected int m_iSurvivalRewardCooldown;
21
22 [Attribute("60", UIWidgets.EditBox, "Maximum amount of survival reward cycles with xp rewards being scaled", params: "0 inf 1")]
23 protected int m_iSurvivalScaleMaxCycleAmount;
24
25 [Attribute("1", UIWidgets.EditBox, "Ratio of XP awarded to supplies spent in repair action (ratio of 0.5: 10 supplies spent on repair rewards 5 XP", params: "0 inf 1")]
26 protected float m_fVehicleRepairXPMultiplier;
27
28 static protected bool s_bXpSystemEnabled;
29
30 //static const int SKILL_LEVEL_MAX = 10;
31 //static const int SKILL_LEVEL_XP_COST = 1000; // how much XP is needed for new level
32
33 //static const float SKILL_LEVEL_XP_BONUS = 0.1;
34
35 protected static const float TRANSPORT_POINTS_TO_XP_RATIO = 0.01;
36 protected static const float TRANSPORT_HELI_MULTIPLIER = 0.25;
37 protected static const int TRANSPORT_XP_PAYOFF_THRESHOLD = 15;
38
39 protected ref array<ref SCR_XPRewardInfo> m_aXPRewardList = {};
40
42
43 protected ref array<SCR_CampaignMilitaryBaseComponent> m_aBasesBeingSeized = {};
44 protected float m_fBaseSeizingCheckTimer;
45
46 protected float m_fXpMultiplier = 1;
47
48 protected const int BASE_SEIZING_CHECK_INTERVAL = 5;
49 protected const int RELAY_SEIZING_RADIUS = 50;
50
51 //------------------------------------------------------------------------------------------------
53 static bool IsXpSystemEnabled()
54 {
55 return s_bXpSystemEnabled;
56 }
57
58 //------------------------------------------------------------------------------------------------
60 {
61 return m_iSurvivalRewardCooldown;
62 }
63
64 //------------------------------------------------------------------------------------------------
66 {
67 return m_iSurvivalScaleMaxCycleAmount;
68 }
69
70 //------------------------------------------------------------------------------------------------
72 {
74 if (!seizeXPRewardInfo)
75 return 0;
76
77 return seizeXPRewardInfo.GetSeizeProgressionTimer();
78 }
79
80 //------------------------------------------------------------------------------------------------
81 int GetSeizeBaseProgressionXP(string baseFactionKey)
82 {
84 if (!seizeXPRewardInfo)
85 return 0;
86
87 return seizeXPRewardInfo.GetSeizeProgressionXpReward(baseFactionKey);
88 }
89
90 //------------------------------------------------------------------------------------------------
91 override void OnPlayerSpawnFinalize_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, SCR_SpawnData data, IEntity entity)
92 {
93 super.OnPlayerSpawnFinalize_S(requestComponent, handlerComponent, data, entity);
94
95 if (!requestComponent || !entity)
96 return;
97
98 if (!IsProxy())
99 {
101
102 if (compartmentAccessComponent)
103 compartmentAccessComponent.GetOnCompartmentLeft().Insert(OnCompartmentLeft);
104 }
105
106 PlayerController pc = requestComponent.GetPlayerController();
107 if (!pc)
108 return;
109
111 if (compXP)
112 {
113 compXP.UpdatePlayerRank(false);
115 }
116 }
117
118 //------------------------------------------------------------------------------------------------
119 override void OnPlayerDisconnected(int playerId, KickCauseCode cause, int timeout)
120 {
121 super.OnPlayerDisconnected(playerId, cause, timeout);
122
123 m_mPlayerTransportPoints.Remove(playerId);
124 }
125
126 //------------------------------------------------------------------------------------------------
127 override void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
128 {
129 super.OnPlayerKilled(instigatorContextData);
130
131 if (IsProxy())
132 return;
133
134 int playerID = instigatorContextData.GetVictimPlayerID();
135
136 //~ If player killed self (Admins and GM are not punished)
137 if (instigatorContextData.HasAnyVictimKillerRelation(SCR_ECharacterDeathStatusRelations.SUICIDE))
138 ProcessSuicide(playerID);
139
140 PlayerController pc = GetGame().GetPlayerManager().GetPlayerController(playerID);
141
142 if (pc)
143 {
145
146 if (compXP)
147 {
148 compXP.OnPlayerKilled();
150 }
151 }
152
153 AwardTransportXP(playerID);
154
155 SCR_CompartmentAccessComponent compartmentAccessComponent = SCR_CompartmentAccessComponent.Cast(instigatorContextData.GetVictimEntity().FindComponent(SCR_CompartmentAccessComponent));
156 if (!compartmentAccessComponent)
157 return;
158
159 compartmentAccessComponent.GetOnCompartmentLeft().Remove(OnCompartmentLeft);
160 }
161
162 //------------------------------------------------------------------------------------------------
163 override void OnControllableDestroyed(notnull SCR_InstigatorContextData instigatorContextData)
164 {
165 super.OnControllableDestroyed(instigatorContextData);
166
167 IEntity victim = instigatorContextData.GetVictimEntity();
168 if (!victim)
169 return;
170
171 // Vehicle destroyed, award XP for enemy vehicle destroy
172 if (victim.IsInherited(Vehicle))
173 OnVehicleDestroyed(instigatorContextData);
174
175 // Character killed, award XP for killing a character
176 if (ChimeraCharacter.Cast(victim))
177 OnCharacterKilled(instigatorContextData);
178 }
179
180 //------------------------------------------------------------------------------------------------
181 protected void OnVehicleDestroyed(notnull SCR_InstigatorContextData instigatorContextData)
182 {
183 if (instigatorContextData.GetInstigator().GetInstigatorType() != InstigatorType.INSTIGATOR_PLAYER)
184 return;
185
186 Vehicle vehicle = Vehicle.Cast(instigatorContextData.GetVictimEntity());
187 if (!vehicle)
188 return;
189
190 int playerID = instigatorContextData.GetInstigator().GetInstigatorPlayerID();
191 if (playerID == 0)
192 return;
193
194 Faction playerFaction = SCR_FactionManager.SGetPlayerFaction(playerID);
195 if (!playerFaction)
196 return;
197
198 Faction vehicleFaction = vehicle.GetFaction();
199
200 // If vehicle does not have any affiliated faction, use it's default faction
201 if (!vehicleFaction)
202 vehicleFaction = vehicle.GetDefaultFaction();
203
204 // Continue only if destroyed vehicle's faction is not friendly to player's faction
205 if (!vehicleFaction || playerFaction.IsFactionFriendly(vehicleFaction))
206 return;
207
209 if (!editableEntityComponent)
210 return;
211
212 array<ref SCR_EntityBudgetValue> budgets = {};
213 editableEntityComponent.GetEntityBudgetCost(budgets, vehicle);
214
215 int xpToAward;
216 foreach (SCR_EntityBudgetValue budget : budgets)
217 {
218 // We only care about the supply cost in Conflict
219 if (budget.GetBudgetType() != EEditableEntityBudget.CAMPAIGN)
220 continue;
221
222 // XP Reward should be a fraction of the cost of the vehicle
223 xpToAward = budget.GetBudgetValue() * m_fEnemyVehicleDestroyXPMultiplier;
224 AwardXP(playerID, SCR_EXPRewards.ENEMY_VEHICLE_DESTRUCTION, xpToAward);
225
226 return;
227 }
228 }
229
230 //------------------------------------------------------------------------------------------------
231 protected void OnCharacterKilled(notnull SCR_InstigatorContextData instigatorContextData)
232 {
233 // Handle XP for kills of players
234 if (instigatorContextData.GetInstigator().GetInstigatorType() != InstigatorType.INSTIGATOR_PLAYER)
235 return;
236
237 SCR_ECharacterControlType killerControlType = instigatorContextData.GetKillerCharacterControlType();
238 int killerId = instigatorContextData.GetKillerPlayerID();
239
240 //~ Punish for teamkilling if teamkill punishment is enabled. GM and Admin are never punished
241 if (instigatorContextData.HasAnyVictimKillerRelation(SCR_ECharacterDeathStatusRelations.KILLED_BY_FRIENDLY_PLAYER))
242 {
243 if (instigatorContextData.DoesPlayerKillCountAsTeamKill())
244 AwardXP(killerId, SCR_EXPRewards.FRIENDLY_KILL);
245
246 return;
247 }
248 //~ Killed by Enemy player
249 if (instigatorContextData.HasAnyVictimKillerRelation(SCR_ECharacterDeathStatusRelations.KILLED_BY_ENEMY_PLAYER))
250 {
251 //~ Possessed AI will not get any XP to hide that the GM is possessing
252 if (killerControlType == SCR_ECharacterControlType.POSSESSED_AI)
253 return;
254
255 //~ The kill was illegal so punish the player instead
256 if (instigatorContextData.IsEnemyKillPunished(SCR_EDisguisedKillingPunishment.WARCRIME | SCR_EDisguisedKillingPunishment.XP_LOSS, true, true))
257 {
258 AwardXP(killerId, SCR_EXPRewards.WARCRIME);
259 return;
260 }
261 else if (instigatorContextData.IsEnemyKillPunished(SCR_EDisguisedKillingPunishment.XP_LOSS, true))
262 {
263 AwardXP(killerId, SCR_EXPRewards.KILLING_WHILE_DISGUISED);
264 return;
265 }
266
267 //~ Killer gets bigger XP reward for killing enemy commander
268 int victimID = instigatorContextData.GetVictimPlayerID();
269 SCR_Faction victimFaction = SCR_Faction.Cast(SCR_FactionManager.SGetPlayerFaction(victimID));
270 if (victimFaction && victimFaction.GetCommanderId() == victimID)
271 {
272 AwardXP(killerId, SCR_EXPRewards.ENEMY_COMMANDER_KILL);
273 return;
274 }
275
276 //~ Check if player is in vehicle
277 //~ TODO: This logic is incomplete. If the player places a mine then gets into a vehicle and kills a enemy with the mine they will get the vehicle XP
278 SCR_ChimeraCharacter instigatorChar = SCR_ChimeraCharacter.Cast(instigatorContextData.GetKillerEntity());
279 if (instigatorChar && instigatorChar.IsInVehicle())
280 AwardXP(killerId, SCR_EXPRewards.ENEMY_KILL_VEH);
281 //~ Character not in vehicle so give normal reward
282 else
283 AwardXP(killerId, SCR_EXPRewards.ENEMY_KILL);
284
285 return;
286 }
287 }
288
289 //------------------------------------------------------------------------------------------------
290 protected void OnCompartmentLeft(IEntity targetEntity, BaseCompartmentManagerComponent manager, int mgrID, int slotID, bool move)
291 {
292 BaseCompartmentSlot compartment = manager.FindCompartment(slotID, mgrID);
293
294 if (!compartment)
295 return;
296
297 int playerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(compartment.GetOccupant());
298
299 if (playerId == 0)
300 return;
301
302 AwardTransportXP(playerId);
303 }
304
305 //------------------------------------------------------------------------------------------------
306 protected void OnStatPointsAdded(int playerId, SCR_EDataStats stat, float amount, bool temp)
307 {
308 if (!temp)
309 return;
310
311 if (stat == SCR_EDataStats.POINTS_AS_DRIVER_OF_PLAYERS)
312 OnDrivingStatPointsAdded(playerId, amount);
313 else if (IsHealingFriendlyStatPoint(stat))
314 OnHealingStatPointsAdded(playerId);
315 }
316
317 //------------------------------------------------------------------------------------------------
318 protected void OnDrivingStatPointsAdded(int playerId, float amount)
319 {
320 SCR_ChimeraCharacter player = SCR_ChimeraCharacter.Cast(GetGame().GetPlayerManager().GetPlayerControlledEntity(playerId));
321 IEntity vehicle = CompartmentAccessComponent.GetVehicleIn(player);
322
323 if (vehicle)
324 {
326
327 // Award lower XP per distance travelled in a helicopter
328 if (heliSim)
329 amount *= TRANSPORT_HELI_MULTIPLIER;
330 }
331
332 int newValue = m_mPlayerTransportPoints.Get(playerId) + amount;
333 m_mPlayerTransportPoints.Set(playerId, newValue);
334
335 if (newValue * TRANSPORT_POINTS_TO_XP_RATIO >= TRANSPORT_XP_PAYOFF_THRESHOLD)
336 AwardTransportXP(playerId);
337 }
338
339 //------------------------------------------------------------------------------------------------
340 protected void OnHealingStatPointsAdded(int playerId)
341 {
342 AwardXP(playerId, SCR_EXPRewards.MEDICAL_ASSISTANCE);
343 }
344
345 //------------------------------------------------------------------------------------------------
349 {
350 return stat == SCR_EDataStats.MORPHINE_FRIENDLIES
351 || stat == SCR_EDataStats.BANDAGE_FRIENDLIES
352 || stat == SCR_EDataStats.SALINE_FRIENDLIES;
353 }
354
355 //------------------------------------------------------------------------------------------------
362 protected void OnSupportStationExecuted(SCR_BaseSupportStationComponent supportStation, ESupportStationType supportStationType, IEntity actionTarget, IEntity actionUser, SCR_BaseUseSupportStationAction action)
363 {
364 // Vehicle repaired
365 if (supportStationType == ESupportStationType.REPAIR)
366 OnVehicleRepaired(supportStation, supportStationType, actionTarget, actionUser, action);
367
368 // Character healed
369 if (supportStationType == ESupportStationType.HEAL)
370 OnCharacterHealed(supportStation, supportStationType, actionTarget, actionUser, action);
371 }
372
373 //------------------------------------------------------------------------------------------------
380 protected void OnVehicleRepaired(SCR_BaseSupportStationComponent supportStation, ESupportStationType supportStationType, IEntity actionTarget, IEntity actionUser, SCR_BaseUseSupportStationAction action)
381 {
382 // Only player as a user is counted
383 int userPlayerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(actionUser);
384 if (userPlayerId == 0 || !action)
385 return;
386
387 // Amount of awarded XP depends on cost of the repair action
388 int xpToAward = action.GetSupportStationSuppliesOnUse() * m_fVehicleRepairXPMultiplier;
389 if (xpToAward == 0)
390 return;
391
392 AwardXP(userPlayerId, SCR_EXPRewards.SUPPORT_REPAIR_VEHICLE, xpToAward);
393 }
394
395 //------------------------------------------------------------------------------------------------
402 protected void OnCharacterHealed(SCR_BaseSupportStationComponent supportStation, ESupportStationType supportStationType, IEntity actionTarget, IEntity actionUser, SCR_BaseUseSupportStationAction action)
403 {
404 // Only player as a user is counted
405 int userPlayerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(actionUser);
406 if (userPlayerId == 0 || !action)
407 return;
408
409 // Only healing other characters is counted
410 int targetPlayerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(actionTarget);
411 if (targetPlayerId == userPlayerId)
412 return;
413
414 AwardXP(userPlayerId, SCR_EXPRewards.MEDICAL_ASSISTANCE);
415 }
416
417 //------------------------------------------------------------------------------------------------
419 {
420 SCR_SeizeXpRewardInfo seizeXPRewardInfo = SCR_SeizeXpRewardInfo.Cast(GetXpRewardInfo(SCR_EXPRewards.BASE_SEIZED));
421 if (!seizeXPRewardInfo)
422 return;
423
424 SCR_ECampaignBaseType baseType = baseComponent.GetType();
425 SCR_ECampaignSeizingBaseType seizingBaseType;
426
427 if (baseComponent.IsControlPoint())
428 seizingBaseType = SCR_ECampaignSeizingBaseType.CONTROL_POINT;
429 else if (baseType == SCR_ECampaignBaseType.SOURCE_BASE)
430 seizingBaseType = SCR_ECampaignSeizingBaseType.SOURCE_BASE;
431 else if (baseType == SCR_ECampaignBaseType.BASE)
432 seizingBaseType = SCR_ECampaignSeizingBaseType.FOB;
433
434 int xpReward = seizeXPRewardInfo.GetSeizeCompletionXpReward(seizingBaseType);
435
436 int radius;
437 vector baseOrigin = baseComponent.GetOwner().GetOrigin();
438 Faction baseFaction = baseComponent.GetFaction();
439
440 if (baseType == SCR_ECampaignBaseType.RELAY)
441 radius = RELAY_SEIZING_RADIUS;
442 else
443 radius = baseComponent.GetRadius();
444
445 PlayerManager playerManager = GetGame().GetPlayerManager();
446 array<int> players = {};
447 playerManager.GetPlayers(players);
448 SCR_ChimeraCharacter playerEntity;
449
450 foreach (int playerId : players)
451 {
452 playerEntity = SCR_ChimeraCharacter.Cast(playerManager.GetPlayerControlledEntity(playerId));
453
454 if (!playerEntity || playerEntity.GetFactionKey() != baseFaction.GetFactionKey())
455 continue;
456
457 if (vector.DistanceSq(playerEntity.GetOrigin(), baseOrigin) >= radius * radius)
458 continue;
459
460 if (baseType == SCR_ECampaignBaseType.RELAY)
461 AwardXP(playerId, SCR_EXPRewards.RELAY_RECONFIGURED, 1);
462 else
463 AwardXP(playerId, SCR_EXPRewards.BASE_SEIZED, 1, false, xpReward);
464 }
465 }
466
467 //------------------------------------------------------------------------------------------------
468 void OnBaseAttackStarted(notnull SCR_CampaignMilitaryBaseComponent base, Faction defendingFaction, Faction attackingFaction)
469 {
470 if (m_aBasesBeingSeized.Contains(base))
471 return;
472
474 }
475
476 //------------------------------------------------------------------------------------------------
478 {
479 if (!m_aBasesBeingSeized.Contains(base))
480 return;
481
482 m_aBasesBeingSeized.RemoveItem(base);
483
484 PlayerManager playerManager = GetGame().GetPlayerManager();
485 array<int> players = {};
486 playerManager.GetPlayers(players);
487 PlayerController playerController;
488 SCR_PlayerXPHandlerComponent playerXpHandlerComponent;
489
490 foreach (int playerId : players)
491 {
492 playerController = GetGame().GetPlayerManager().GetPlayerController(playerId);
493 if (!playerController)
494 continue;
495
496 playerXpHandlerComponent = SCR_PlayerXPHandlerComponent.Cast(playerController.FindComponent(SCR_PlayerXPHandlerComponent));
497 if (!playerXpHandlerComponent)
498 continue;
499
500 playerXpHandlerComponent.StopSeizingProgressReward(base);
501 }
502 }
503
504 //------------------------------------------------------------------------------------------------
512
513 //------------------------------------------------------------------------------------------------
515 {
516 Faction baseFaction = base.GetFaction();
517 if (!baseFaction)
518 return;
519
520 PlayerManager playerManager = GetGame().GetPlayerManager();
521 array<int> players = {};
522 playerManager.GetPlayers(players);
523 vector baseOrigin = base.GetOwner().GetOrigin();
524 int radius = base.GetRadius();
525
526 SCR_ChimeraCharacter playerEntity;
527 PlayerController playerController;
528 SCR_PlayerXPHandlerComponent playerXpHandlerComponent;
529
530 foreach (int playerId : players)
531 {
532 playerEntity = SCR_ChimeraCharacter.Cast(playerManager.GetPlayerControlledEntity(playerId));
533
534 if (!playerEntity || playerEntity.GetFactionKey() == baseFaction.GetFactionKey())
535 continue;
536
537 playerController = GetGame().GetPlayerManager().GetPlayerController(playerId);
538 if (!playerController)
539 continue;
540
541 playerXpHandlerComponent = SCR_PlayerXPHandlerComponent.Cast(playerController.FindComponent(SCR_PlayerXPHandlerComponent));
542 if (!playerXpHandlerComponent)
543 continue;
544
545 if (vector.DistanceSq(playerEntity.GetOrigin(), baseOrigin) < radius * radius)
546 playerXpHandlerComponent.StartSeizingProgressReward(base);
547 else
548 playerXpHandlerComponent.StopSeizingProgressReward(base);
549 }
550 }
551
552 //------------------------------------------------------------------------------------------------
555 void ProcessSuicide(int playerId)
556 {
557#ifdef NO_SUICIDE_PENALTY
558 return;
559#endif
560 PlayerController pc = GetGame().GetPlayerManager().GetPlayerController(playerId);
561 if (!pc)
562 return;
563
565 if (!compXPPlayer)
566 return;
567
568 SCR_FactionManager fm = SCR_FactionManager.Cast(GetGame().GetFactionManager());
569 if (!fm)
570 return;
571
572 SCR_RankContainer ranks = fm.GetFactionRanks(playerId);
573
574 // Check for cooldown on the penalty
575 float curTime = GetGame().GetWorld().GetWorldTime();
576 float penaltyTimestamp = compXPPlayer.GetSuicidePenaltyTimestamp();
577 compXPPlayer.SetSuicidePenaltyTimestamp(curTime + (m_iSuicidePenaltyCooldown * 1000.0));
578 if (curTime > penaltyTimestamp)
579 return;
580
581 // Don't make player renegade just by suiciding
582 int penalty = GetXPRewardAmount(SCR_EXPRewards.SUICIDE);
583 int playerXPWithPenalty = compXPPlayer.GetPlayerXP() + penalty;
584 SCR_ECharacterRank newRank = ranks.GetRankByXP(playerXPWithPenalty);
585 if (ranks.IsRankRenegade(newRank))
586 return;
587
588 AwardXP(pc.GetPlayerId(), SCR_EXPRewards.SUICIDE);
589 }
590
591 //------------------------------------------------------------------------------------------------
592 protected void AwardTransportXP(int playerId)
593 {
594 float toAward = m_mPlayerTransportPoints.Get(playerId) * TRANSPORT_POINTS_TO_XP_RATIO;
595
596 if (toAward <= 0)
597 return;
598
599 PlayerController controller = GetGame().GetPlayerManager().GetPlayerController(playerId);
600
601 if (!controller)
602 return;
603
604 m_mPlayerTransportPoints.Set(playerId, 0);
605
606 AwardXP(controller, SCR_EXPRewards.TASK_TRANSPORT, toAward);
607 }
608
609 //------------------------------------------------------------------------------------------------
610 protected bool IsProxy()
611 {
612 RplComponent rplComponent = RplComponent.Cast(GetOwner().FindComponent(RplComponent));
613
614 return rplComponent && rplComponent.IsProxy();
615 }
616
617 //------------------------------------------------------------------------------------------------
624 void AwardXP(int playerId, SCR_EXPRewards rewardID, float multiplier = 1.0, bool volunteer = false, int customXP = 0)
625 {
626 if (IsProxy())
627 return;
628
629 PlayerController playerController = GetGame().GetPlayerManager().GetPlayerController(playerId);
630
631 if (playerController)
632 AwardXP(playerController, rewardID, multiplier, volunteer, customXP);
633 }
634
635 //------------------------------------------------------------------------------------------------
642 void AwardXP(notnull PlayerController controller, SCR_EXPRewards rewardID, float multiplier = 1.0, bool volunteer = false, int customXP = 0)
643 {
644 if (IsProxy())
645 return;
646
648
649 if (!comp)
650 return;
651
652 comp.AddPlayerXP(rewardID, multiplier, volunteer, customXP);
653
654 // Do not handle veterancy award if it's being processed already or disabled
655 if (rewardID == SCR_EXPRewards.VETERANCY || m_iVeterancyXPAwardThreshold == 0 || customXP != 0)
656 return;
657
658 int singleLifeXP = comp.GetPlayerXPSinceLastSpawn();
659 float veterancyAwards = Math.Floor(singleLifeXP / m_iVeterancyXPAwardThreshold);
660
661 if (veterancyAwards < 1)
662 return;
663
664 int leftoverXP = singleLifeXP % m_iVeterancyXPAwardThreshold;
665 comp.SetPlayerXPSinceLastSpawn(leftoverXP);
666
667 // Award veterancy bonus with a delay so the UI isn't overwritten immediately
668 GetGame().GetCallqueue().CallLater(VeterancyAward, 2000, false, controller, veterancyAwards);
669 }
670
671 //------------------------------------------------------------------------------------------------
675 void VeterancyAward(notnull PlayerController controller, float multiplier)
676 {
677 AwardXP(controller, SCR_EXPRewards.VETERANCY, multiplier);
678 }
679
680 //------------------------------------------------------------------------------------------------
682 {
683 foreach (SCR_XPRewardInfo info : m_aXPRewardList)
684 {
685 if (info.GetRewardID() == reward)
686 return info;
687 }
688
689 return null;
690 }
691
692 //------------------------------------------------------------------------------------------------
697 {
698 int rewardsCnt = m_aXPRewardList.Count();
699
700 for (int i = 0; i < rewardsCnt; i++)
701 {
702 if (m_aXPRewardList[i].GetRewardID() == reward)
703 return m_aXPRewardList[i].GetRewardXP();
704 }
705
706 return 0;
707 }
708
709 //------------------------------------------------------------------------------------------------
713 {
714 return m_fXpMultiplier;
715 }
716
717 //------------------------------------------------------------------------------------------------
722 {
723 int rewardsCnt = m_aXPRewardList.Count();
724
725 for (int i = 0; i < rewardsCnt; i++)
726 {
727 if (m_aXPRewardList[i].GetRewardID() == reward)
728 return m_aXPRewardList[i].GetRewardName();
729 }
730
731 return "";
732 }
733
734 //------------------------------------------------------------------------------------------------
739 {
740 int rewardsCnt = m_aXPRewardList.Count();
741
742 for (int i = 0; i < rewardsCnt; i++)
743 {
744 if (m_aXPRewardList[i].GetRewardID() == reward)
745 return m_aXPRewardList[i].AllowNotification();
746 }
747
748 return false;
749 }
750
751 //------------------------------------------------------------------------------------------------
755// EProfileSkillID GetXPRewardSkill(SCR_EXPRewards reward)
756// {
757// int rewardsCnt = m_aXPRewardList.Count();
758//
759// for (int i = 0; i < rewardsCnt; i++)
760// {
761// if (m_aXPRewardList[i].GetRewardID() == reward)
762// return m_aXPRewardList[i].GetRewardSkill();
763// }
764//
765// return EProfileSkillID.GLOBAL;
766// }
767
768 //------------------------------------------------------------------------------------------------
769 protected override void EOnFrame(IEntity owner, float timeSlice)
770 {
771 m_fBaseSeizingCheckTimer += timeSlice;
772
774 {
777 }
778 }
779
780 //------------------------------------------------------------------------------------------------
781 override void OnPostInit(IEntity owner)
782 {
783 //Parse & register XP reward list
784 Resource container = BaseContainerTools.LoadContainer(m_sXPRewardsConfig);
785 SCR_XPRewardList list = SCR_XPRewardList.Cast(BaseContainerTools.CreateInstanceFromContainer(container.GetResource().ToBaseContainer()));
786 list.GetRewardList(m_aXPRewardList);
787
788 SCR_MissionHeader header = SCR_MissionHeader.Cast(GetGame().GetMissionHeader());
789
790 if (header)
791 m_fXpMultiplier = header.m_fXpMultiplier;
792
794
796 if (supportStationManager)
797 {
799 }
800
803
804 SetEventMask(GetOwner(), EntityEvent.FRAME);
805
806 s_bXpSystemEnabled = true;
807 }
808
809 //------------------------------------------------------------------------------------------------
811 {
813 if (supportStationManager)
814 {
816 }
817
820
821 s_bXpSystemEnabled = false;
822 }
823}
824
EEditableEntityBudget
ESupportStationType
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum SCR_EAICombatMoveRequestState UNDEFINED
void OnCompartmentLeft(AIAgent agent, IEntity targetEntity, BaseCompartmentManagerComponent manager, int mgrID, int slotID, bool move)
void OnVehicleDestroyed(IEntity vehicle)
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
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
void SCR_FactionManager(IEntitySource src, IEntity parent)
int m_iSuicidePenaltyCooldown
void OnControllableDestroyed(IEntity entity, IEntity killerEntity, Instigator instigator, notnull SCR_InstigatorContextData instigatorContextData)
SCR_EDataStats
override void EOnFrame(IEntity owner, float timeSlice)
override void OnPlayerSpawnFinalize_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, SCR_SpawnData data, IEntity entity)
bool AllowNotification(SCR_EXPRewards reward)
void OnBaseSeized(SCR_CampaignMilitaryBaseComponent baseComponent)
void ~SCR_XPHandlerComponent()
int GetSeizeBaseProgressionXP(string baseFactionKey)
void ProcessSuicide(int playerId)
ref map< int, float > m_mPlayerTransportPoints
string GetXPRewardName(SCR_EXPRewards reward)
int GetXPRewardAmount(SCR_EXPRewards reward)
int GetSeizeBaseProgressionRewardTimer()
@ PICKUP_TASK_COMPLETED
@ VALUABLE_INTEL_HANDIN_SMALL
@ ATTACK_TASK_COMPLETED
@ CLEAR_TASK_COMPLETED
@ DISMANTLE_BASE_COMPLETED
@ REPAIR_TASK_COMPLETED
@ COMMANDER_TASK_COMPLETED
@ REARM_TASK_COMPLETED
@ RECON_TASK_COMPLETED
@ RELAY_RECONFIGURED
@ FIRE_SUPPORT_TASK_COMPLETED
@ ENEMY_COMMANDER_KILL
@ VALUABLE_INTEL_HANDIN_MEDIUM
@ HOLD_TASK_COMPLETED
@ ATTACK_TASK_FAILED
@ KILLING_WHILE_DISGUISED
@ SUPPORT_REPAIR_VEHICLE
@ ENEMY_VEHICLE_DESTRUCTION
@ FREE_ROAM_BUILDING_BUILT
@ REINFORCE_TASK_COMPLETED
@ ESTABLISH_BASE_COMPLETED
@ VALUABLE_INTEL_HANDIN_LARGE
@ MEDICAL_ASSISTANCE
@ SEIZE_TASK_COMPLETED
@ SUPPLIES_DELIVERED
bool IsHealingFriendlyStatPoint(SCR_EDataStats stat)
void OnCharacterHealed(SCR_BaseSupportStationComponent supportStation, ESupportStationType supportStationType, IEntity actionTarget, IEntity actionUser, SCR_BaseUseSupportStationAction action)
void OnBaseAttackEnded(notnull SCR_CampaignMilitaryBaseComponent base)
ref array< SCR_CampaignMilitaryBaseComponent > m_aBasesBeingSeized
const int RELAY_SEIZING_RADIUS
const int BASE_SEIZING_CHECK_INTERVAL
void OnBaseAttackStarted(notnull SCR_CampaignMilitaryBaseComponent base, Faction defendingFaction, Faction attackingFaction)
void OnCharacterKilled(notnull SCR_InstigatorContextData instigatorContextData)
SCR_XPRewardInfo GetXpRewardInfo(SCR_EXPRewards reward)
float GetXPMultiplier()
int GetSurvivalRewardCooldown()
void AwardTransportXP(int playerId)
void OnSupportStationExecuted(SCR_BaseSupportStationComponent supportStation, ESupportStationType supportStationType, IEntity actionTarget, IEntity actionUser, SCR_BaseUseSupportStationAction action)
void OnVehicleRepaired(SCR_BaseSupportStationComponent supportStation, ESupportStationType supportStationType, IEntity actionTarget, IEntity actionUser, SCR_BaseUseSupportStationAction action)
void EvaluateAllAttackedBasesAttackers()
float m_fXpMultiplier
void VeterancyAward(notnull PlayerController controller, float multiplier)
float m_fBaseSeizingCheckTimer
void EvaluateBaseAttackers(SCR_CampaignMilitaryBaseComponent base)
void OnHealingStatPointsAdded(int playerId)
int GetSurvivalScaleMaxCycleAmount()
void OnStatPointsAdded(int playerId, SCR_EDataStats stat, float amount, bool temp)
void OnDrivingStatPointsAdded(int playerId, float amount)
proto external Managed FindComponent(typename typeName)
Definition Math.c:13
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
SCR_ECampaignBaseType GetType()
Returns type of this base.
static OnBaseStateChangedInvoker GetOnBaseUnderAttack()
ScriptInvoker GetOnCompartmentLeft(bool createNew=true)
static SCR_EditableEntityComponent GetEditableEntity(IEntity owner)
bool GetEntityBudgetCost(out notnull array< ref SCR_EntityBudgetValue > outBudgets, IEntity owner=null)
int GetCommanderId()
static ref ScriptInvoker s_OnStatAdded
int GetPlayerXPSinceLastSpawn()
Getter for player XP accumulated since last respawn.
void StartSeizingProgressReward(notnull SCR_CampaignMilitaryBaseComponent base)
void StopSeizingProgressReward(notnull SCR_CampaignMilitaryBaseComponent base)
void AddPlayerXP(SCR_EXPRewards rewardID, float multiplier=1.0, bool volunteer=false, int addDirectly=0)
bool IsRankRenegade(SCR_ECharacterRank rankID)
SCR_ECharacterRank GetRankByXP(int XP)
int GetSeizeCompletionXpReward(SCR_ECampaignSeizingBaseType baseType)
int GetSeizeProgressionXpReward(string factionKey)
ScriptInvokerBase< SupportStation_OnSupportStationExecuted > GetOnSupportStationExecutedSuccessfully()
static SCR_SupportStationManagerComponent GetInstance()
Config template for XP rewards.
void GetRewardList(out notnull array< ref SCR_XPRewardInfo > rewardList)
Definition Types.c:486
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
IEntity GetOwner()
Owner entity of the fuel tank.
InstigatorType
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14
override void OnPlayerDisconnected(int playerId, KickCauseCode cause, int timeout)