Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_VotingFactionCommanderRelieve.c
Go to the documentation of this file.
1
[
BaseContainerProps
(configRoot:
true
),
SCR_BaseContainerCustomTitleEnum
(
EVotingType
,
"m_Type"
)]
2
class
SCR_VotingFactionCommanderRelieve
:
SCR_VotingReferendum
3
{
4
//------------------------------------------------------------------------------------------------
5
override
bool
IsAvailable(
int
value,
bool
isOngoing)
6
{
7
SCR_GameModeCampaign
campaignGameMode =
SCR_GameModeCampaign
.Cast(
GetGame
().
GetGameMode
());
8
if
(!campaignGameMode || !campaignGameMode.GetCommanderRoleEnabled())
9
return
false
;
10
11
SCR_FactionManager
fManager =
SCR_FactionManager
.Cast(
GetGame
().GetFactionManager());
12
if
(!fManager)
13
return
false
;
14
15
Faction
playerFaction = fManager.GetPlayerFaction(value);
16
if
(!playerFaction)
17
return
false
;
18
19
SCR_Faction
playerFactionLocal =
SCR_Faction
.Cast(fManager.GetLocalPlayerFaction());
20
if
(!playerFactionLocal || playerFactionLocal != playerFaction)
21
return
false
;
22
23
return
value == playerFactionLocal.
GetCommanderId
();
24
}
25
26
//------------------------------------------------------------------------------------------------
27
override
int
GetPlayerCount
()
28
{
29
int
playerCount;
30
SCR_FactionManager
factionManager =
SCR_FactionManager
.Cast(
GetGame
().GetFactionManager());
31
32
Faction
targetFaction;
33
34
if
(factionManager)
35
targetFaction = factionManager.GetPlayerFaction(
m_iValue
);
36
37
//--- Count only players on the same faction as target of the vote
38
//--- e.g., with 50% vote limit, only half of BLUFOR players will have to vote, not half of all players
39
40
Faction
playerFaction;
41
array<int> players = {};
42
43
for
(
int
i = 0, count =
GetGame
().GetPlayerManager().
GetPlayers
(players); i < count; i++)
44
{
45
playerFaction = factionManager.GetPlayerFaction(players[i]);
46
47
if
(targetFaction == playerFaction)
48
playerCount++;
49
}
50
51
//--- Limit to prevent instant completion in a session with less than limited participants
52
return
Math
.Max(playerCount,
m_iMinVotes
);
53
}
54
55
//------------------------------------------------------------------------------------------------
56
override
bool
CanSendNotification(
int
value)
57
{
58
SCR_FactionManager
fManager =
SCR_FactionManager
.Cast(
GetGame
().GetFactionManager());
59
if
(!fManager)
60
return
false
;
61
62
return
fManager.GetPlayerFaction(value) == fManager.GetLocalPlayerFaction();
63
}
64
65
//------------------------------------------------------------------------------------------------
66
override
void
OnVotingEnd(
int
value =
DEFAULT_VALUE
,
int
winner =
DEFAULT_VALUE
)
67
{
68
if
(winner ==
DEFAULT_VALUE
)
69
return
;
70
71
if
(
Replication
.IsClient())
72
return
;
73
74
SCR_Faction
faction =
SCR_Faction
.Cast(
SCR_FactionManager
.SGetPlayerFaction(winner));
75
if
(!faction || faction.
GetCommanderId
() != winner)
76
return
;
77
78
SCR_FactionCommanderHandlerComponent component = SCR_FactionCommanderHandlerComponent.GetInstance();
79
if
(!component)
80
return
;
81
82
component.SetFactionCommander(
SCR_Faction
.Cast(
SCR_FactionManager
.SGetPlayerFaction(winner)),
SCR_Faction
.
AI_COMMANDER_ID
);
83
}
84
}
EVotingType
EVotingType
Definition
EVotingType.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition
SCR_BaseGameModeComponent.c:15
SCR_BaseContainerCustomTitleEnum
class SCR_CampaignHintStorage SCR_BaseContainerCustomTitleEnum(EHint, "m_eHintId")
Definition
SCR_CampaignHintStorage.c:22
GetPlayers
int GetPlayers(out notnull array< int > outPlayers)
Definition
SCR_DataCollectorComponent.c:255
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition
SCR_FactionManager.c:498
SCR_GameModeCampaign
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
Definition
SCR_GameModeCampaign.c:1812
Faction
Definition
Faction.c:13
Math
Definition
Math.c:13
Replication
Main replication API.
Definition
Replication.c:14
SCR_Faction
Definition
SCR_Faction.c:6
SCR_Faction::AI_COMMANDER_ID
static const int AI_COMMANDER_ID
Definition
SCR_Faction.c:126
SCR_Faction::GetCommanderId
int GetCommanderId()
Definition
SCR_Faction.c:899
SCR_VotingBase::DEFAULT_VALUE
static const int DEFAULT_VALUE
Definition
SCR_VotingBase.c:49
SCR_VotingBase::GetPlayerCount
int GetPlayerCount()
Definition
SCR_VotingBase.c:400
SCR_VotingBase::m_iMinVotes
int m_iMinVotes
Definition
SCR_VotingBase.c:26
SCR_VotingFactionCommanderRelieve
Definition
SCR_VotingFactionCommanderRelieve.c:3
SCR_VotingReferendum
Definition
SCR_VotingBase.c:464
SCR_VotingReferendum::m_iValue
int m_iValue
Definition
SCR_VotingBase.c:466
scripts
Game
FactionCommander
SCR_VotingFactionCommanderRelieve.c
Generated by
1.17.0