7 [
Attribute(
"{E6FC4537B53EA00B}Configs/Campaign/XPRewards.conf",
params:
"conf class=SCR_XPRewardList")]
8 private ResourceName m_sXPRewardsConfig;
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;
13 [
Attribute(
"1800", UIWidgets.EditBox,
"If suicide is committed more than once in this time (seconds), a penalty is issued.",
params:
"0 inf 1")]
21 protected static const float TRANSPORT_POINTS_TO_XP_RATIO = 0.01;
22 protected static const float TRANSPORT_HELI_MULTIPLIER = 0.25;
23 protected static const int TRANSPORT_XP_PAYOFF_THRESHOLD = 15;
25 protected ref array<ref SCR_XPRewardInfo> m_aXPRewardList = {};
34 super.OnPlayerSpawned(playerId, controlledEntity);
40 if (compartmentAccessComponent)
44 PlayerController pc =
GetGame().GetPlayerManager().GetPlayerController(playerId);
49 SCR_PlayerXPHandlerComponent compXP = SCR_PlayerXPHandlerComponent.Cast(pc.FindComponent(SCR_PlayerXPHandlerComponent));
52 compXP.UpdatePlayerRank(
false);
58 super.OnPlayerDisconnected(playerId, cause, timeout);
66 super.OnPlayerKilled(playerId, playerEntity, killerEntity, killer);
71 if (playerId == killer.GetInstigatorPlayerID())
74 PlayerController pc =
GetGame().GetPlayerManager().GetPlayerController(playerId);
78 SCR_PlayerXPHandlerComponent compXP = SCR_PlayerXPHandlerComponent.Cast(pc.FindComponent(SCR_PlayerXPHandlerComponent));
81 compXP.OnPlayerKilled();
87 if (!compartmentAccessComponent)
96 super.OnControllableDestroyed(entity, killerEntity, killer);
99 if (killer.GetInstigatorType() !=
InstigatorType.INSTIGATOR_PLAYER)
102 int killerId = killer.GetInstigatorPlayerID();
103 int playerId =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(entity);
105 SCR_ChimeraCharacter entityChar = SCR_ChimeraCharacter.Cast(entity);
113 Faction factionKiller =
Faction.Cast(factionManager.GetPlayerFaction(killerId));
117 if (factionKiller.IsFactionFriendly(entityChar.GetFaction()))
119 if (killerId != playerId)
124 SCR_ChimeraCharacter instigatorChar = SCR_ChimeraCharacter.Cast(killerEntity);
126 if (!instigatorChar || !instigatorChar.IsInVehicle())
134 protected void OnCompartmentLeft(IEntity targetEntity, BaseCompartmentManagerComponent manager,
int mgrID,
int slotID,
bool move)
136 BaseCompartmentSlot compartment = manager.FindCompartment(slotID, mgrID);
141 int playerId =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(compartment.GetOccupant());
158 SCR_ChimeraCharacter player = SCR_ChimeraCharacter.Cast(
GetGame().GetPlayerManager().GetPlayerControlledEntity(playerId));
159 IEntity vehicle = CompartmentAccessComponent.GetVehicleIn(player);
163 VehicleHelicopterSimulation heliSim = VehicleHelicopterSimulation.Cast(vehicle.FindComponent(VehicleHelicopterSimulation));
167 amount *= TRANSPORT_HELI_MULTIPLIER;
175 if (newValue * TRANSPORT_POINTS_TO_XP_RATIO >= TRANSPORT_XP_PAYOFF_THRESHOLD)
184 #ifdef NO_SUICIDE_PENALTY
187 PlayerController pc =
GetGame().GetPlayerManager().GetPlayerController(playerId);
192 SCR_PlayerXPHandlerComponent compXPPlayer = SCR_PlayerXPHandlerComponent.Cast(pc.FindComponent(SCR_PlayerXPHandlerComponent));
203 float curTime =
GetGame().GetWorld().GetWorldTime();
204 float penaltyTimestamp = compXPPlayer.GetSuicidePenaltyTimestamp();
207 if (curTime > penaltyTimestamp)
212 int playerXPWithPenalty = compXPPlayer.GetPlayerXP() + penalty;
215 if (fm.IsRankRenegade(newRank))
229 PlayerController controller =
GetGame().GetPlayerManager().GetPlayerController(playerId);
242 RplComponent rplComponent = RplComponent.Cast(
GetOwner().FindComponent(RplComponent));
244 return rplComponent && rplComponent.IsProxy();
254 void AwardXP(
int playerId,
SCR_EXPRewards rewardID,
float multiplier = 1.0,
bool volunteer =
false,
int customXP = 0)
259 PlayerController playerController =
GetGame().GetPlayerManager().GetPlayerController(playerId);
261 if (playerController)
262 AwardXP(playerController, rewardID, multiplier, volunteer, customXP);
272 void AwardXP(notnull PlayerController controller,
SCR_EXPRewards rewardID,
float multiplier = 1.0,
bool volunteer =
false,
int customXP = 0)
277 SCR_PlayerXPHandlerComponent comp = SCR_PlayerXPHandlerComponent.Cast(controller.FindComponent(SCR_PlayerXPHandlerComponent));
282 comp.AddPlayerXP(rewardID, multiplier, volunteer, customXP);
285 if (rewardID ==
SCR_EXPRewards.VETERANCY || m_iVeterancyXPAwardThreshold == 0 || customXP != 0)
288 int singleLifeXP = comp.GetPlayerXPSinceLastSpawn();
289 float veterancyAwards = Math.Floor(singleLifeXP / m_iVeterancyXPAwardThreshold);
291 if (veterancyAwards < 1)
294 int leftoverXP = singleLifeXP % m_iVeterancyXPAwardThreshold;
295 comp.SetPlayerXPSinceLastSpawn(leftoverXP);
316 int rewardsCnt = m_aXPRewardList.Count();
318 for (
int i = 0; i < rewardsCnt; i++)
320 if (m_aXPRewardList[i].GetRewardID() == reward)
321 return m_aXPRewardList[i].GetRewardXP();
341 int rewardsCnt = m_aXPRewardList.Count();
343 for (
int i = 0; i < rewardsCnt; i++)
345 if (m_aXPRewardList[i].GetRewardID() == reward)
346 return m_aXPRewardList[i].GetRewardName();
358 int rewardsCnt = m_aXPRewardList.Count();
360 for (
int i = 0; i < rewardsCnt; i++)
362 if (m_aXPRewardList[i].GetRewardID() == reward)
363 return m_aXPRewardList[i].AllowNotification();
390 Resource container = BaseContainerTools.LoadContainer(m_sXPRewardsConfig);
392 list.GetRewardList(m_aXPRewardList);