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_MortarShootAction.c
Go to the documentation of this file.
1
class
SCR_MortarShootAction
:
SCR_ScriptedUserAction
2
{
3
[
Attribute
(
"0"
,
desc
:
"If action should be performed from the left side of the mortar"
)]
4
protected
bool
m_bPerformFromTheLeftSide
;
5
6
[
Attribute
(
"0"
,
desc
:
"Check if turret is empty to ensure that loader will not clip into the gunner of the mortar"
)]
7
protected
bool
m_bCheckIfTurretIsEmpty
;
8
9
protected
BaseMagazineWell
m_MortarMagWell
;
10
protected
SCR_MortarMuzzleComponent
m_MortarMuzzleComponent
;
11
protected
SCR_MortarShellGadgetComponent
m_ShellComp
;
12
protected
ChimeraCharacter
m_Loader
;
13
protected
float
m_fFuzeTime
= -1;
14
15
protected
const
LocalizedString
WRONG_SHELL_TYPE
=
"#AR-UserAction_WrongShellType"
;
16
protected
const
LocalizedString
ALREADY_LOADED
=
"#AR-UserAction_AlreadyLoaded"
;
17
protected
const
LocalizedString
FIRE_WITH_MANUAL_FUZE
=
"#AR-UserAction_MortarFire_ManualFuze"
;
18
protected
const
LocalizedString
FIRE_WITH_AUTOMATIC_FUZE
=
"#AR-UserAction_MortarFire_AutomaticFuze"
;
19
protected
const
LocalizedString
AREA_OBSTRUCTED
=
"#AR-UserAction_SeatObstructed"
;
20
21
//------------------------------------------------------------------------------------------------
22
override
void
Init
(
IEntity
pOwnerEntity,
GenericComponent
pManagerComponent)
23
{
24
m_MortarMuzzleComponent
= SCR_MortarMuzzleComponent.Cast(pOwnerEntity.
FindComponent
(SCR_MortarMuzzleComponent));
25
if
(
m_MortarMuzzleComponent
)
26
m_MortarMagWell
=
m_MortarMuzzleComponent
.GetMagazineWell();
27
}
28
29
//------------------------------------------------------------------------------------------------
30
override
bool
CanBeShownScript
(
IEntity
user)
31
{
32
if
(!
m_MortarMuzzleComponent
&& !
m_MortarMagWell
)
33
return
false
;
34
35
ChimeraCharacter
character
=
ChimeraCharacter
.Cast(user);
36
if
(!
character
)
37
return
false
;
38
39
CharacterControllerComponent controllerComponent =
character
.GetCharacterController();
40
if
(!controllerComponent || !controllerComponent.CanPlayItemGesture())
41
return
false
;
42
43
m_ShellComp
=
GetHeldShellGadgetComp
(
character
);
44
if
(!
m_ShellComp
||
m_ShellComp
.IsLoaded())
45
return
false
;
46
47
return
super.CanBeShownScript(user);
48
}
49
50
//------------------------------------------------------------------------------------------------
51
override
bool
CanBePerformedScript
(
IEntity
user)
52
{
53
ChimeraCharacter
character
=
ChimeraCharacter
.Cast(user);
54
if
(!
character
)
55
return
false
;
56
57
CharacterControllerComponent controllerComponent =
character
.GetCharacterController();
58
if
(!controllerComponent || !controllerComponent.CanPlayItemGesture())
59
return
false
;
60
61
IEntity
shell = controllerComponent.GetAttachedGadgetAtLeftHandSlot();
62
if
(!shell)
63
return
false
;
64
65
MagazineComponent
shellMagazine =
MagazineComponent
.Cast(shell.
FindComponent
(
MagazineComponent
));
66
if
(!shellMagazine || !shellMagazine.GetMagazineWell() || shellMagazine.GetMagazineWell().Type() !=
m_MortarMagWell
.Type())
67
{
68
SetCannotPerformReason
(
WRONG_SHELL_TYPE
);
69
return
false
;
70
}
71
72
if
(
m_MortarMuzzleComponent
.GetAmmoCount() >= 1 ||
m_MortarMuzzleComponent
.IsBeingLoaded())
73
{
74
SetCannotPerformReason
(
ALREADY_LOADED
);
75
return
false
;
76
}
77
78
if
(
m_bCheckIfTurretIsEmpty
)
79
{
80
SCR_BaseCompartmentManagerComponent compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(
GetOwner
().FindComponent(SCR_BaseCompartmentManagerComponent));
81
if
(compartmentManager && compartmentManager.AnyCompartmentsOccupiedOrLocked())
82
{
83
SetCannotPerformReason
(
AREA_OBSTRUCTED
);
84
return
false
;
85
}
86
}
87
88
SetCannotPerformReason
(
string
.Empty);
89
return
true
;
90
}
91
92
//------------------------------------------------------------------------------------------------
93
override
void
PerformAction
(
IEntity
pOwnerEntity,
IEntity
pUserEntity)
94
{
95
if
(
m_MortarMuzzleComponent
.GetAmmoCount() >=
m_MortarMuzzleComponent
.GetMaxAmmoCount())
96
return
;
97
98
if
(
SCR_PlayerController
.
GetLocalControlledEntity
() == pUserEntity ||
SCR_CharacterHelper
.IsAPlayer(pUserEntity))
99
return
;
//filter out all players as this method is intended only for AI
100
101
ChimeraCharacter
character
=
ChimeraCharacter
.Cast(pUserEntity);
102
if
(!
character
)
103
return
;
104
105
if
(!
m_ShellComp
)
106
{
107
CharacterControllerComponent controllerComponent =
character
.GetCharacterController();
108
if
(!controllerComponent || !controllerComponent.IsGadgetInHands())
109
return
;
110
111
IEntity
shell = controllerComponent.GetAttachedGadgetAtLeftHandSlot();
112
m_ShellComp
= SCR_MortarShellGadgetComponent.Cast(shell.
FindComponent
(SCR_MortarShellGadgetComponent));
113
if
(!
m_ShellComp
)
114
return
;
115
}
116
117
m_MortarMuzzleComponent
.LoadShell(
m_ShellComp
,
character
, fromLeftSide:
m_bPerformFromTheLeftSide
);
118
}
119
120
//------------------------------------------------------------------------------------------------
121
protected
SCR_MortarShellGadgetComponent
GetHeldShellGadgetComp
(notnull
ChimeraCharacter
character
)
122
{
123
CharacterControllerComponent controllerComponent =
character
.GetCharacterController();
124
if
(!controllerComponent || !controllerComponent.IsGadgetInHands())
125
return
null;
126
127
IEntity
shell = controllerComponent.GetAttachedGadgetAtLeftHandSlot();
128
if
(!shell)
129
return
null;
130
131
return
SCR_MortarShellGadgetComponent.Cast(shell.
FindComponent
(SCR_MortarShellGadgetComponent));
132
}
133
134
//------------------------------------------------------------------------------------------------
135
override
bool
GetActionNameScript
(out
string
outName)
136
{
137
if
(!
m_ShellComp
|| !
m_ShellComp
.IsUsingTimeFuze() || !
GetCannotPerformReason
().
IsEmpty
())
138
return
false
;
139
140
UIInfo
actionInfo =
GetUIInfo
();
141
if
(!actionInfo)
142
return
false
;
143
144
ChimeraCharacter
character
=
ChimeraCharacter
.Cast(
SCR_PlayerController
.
GetLocalControlledEntity
());
145
if
(!
character
)
146
return
false
;
147
148
SCR_ShellConfig
timeFuzeConfig =
m_ShellComp
.GetSavedConfig(
character
);
149
if
(!timeFuzeConfig || !timeFuzeConfig.
IsUsingManualTime
())
150
{
151
float
elevation =
m_MortarMuzzleComponent
.GetMuzzleElevation();
152
float
timeToDetonation =
m_ShellComp
.GetTimeToDetonation(elevation,
false
);
153
string
fuzeTime =
WidgetManager
.Translate(
UIConstants
.VALUE_UNIT_SECONDS, timeToDetonation.ToString(-1, 1));
154
outName =
WidgetManager
.Translate(
FIRE_WITH_AUTOMATIC_FUZE
, fuzeTime);
155
}
156
else
157
{
158
string
fuzeTime =
WidgetManager
.Translate(
UIConstants
.VALUE_UNIT_SECONDS, timeFuzeConfig.
GetSavedTime
().ToString(-1, 1));
159
outName =
WidgetManager
.Translate(
FIRE_WITH_MANUAL_FUZE
, fuzeTime);
160
}
161
162
return
true
;
163
}
164
165
//------------------------------------------------------------------------------------------------
166
override
void
OnActionStart
(
IEntity
pUserEntity)
167
{
168
m_Loader
=
ChimeraCharacter
.Cast(pUserEntity);
169
}
170
171
//------------------------------------------------------------------------------------------------
172
override
protected
bool
OnSaveActionData
(ScriptBitWriter writer)
173
{
174
if
(!
m_ShellComp
)
175
return
false
;
176
177
ChimeraCharacter
character
=
ChimeraCharacter
.Cast(
SCR_PlayerController
.
GetLocalControlledEntity
());
178
if
(!
character
)
179
return
false
;
180
181
float
fuzeTime = -1;
182
SCR_ShellConfig
timeFuzeConfig =
m_ShellComp
.GetSavedConfig(
character
);
183
if
(timeFuzeConfig && timeFuzeConfig.
IsUsingManualTime
())
184
fuzeTime = timeFuzeConfig.
GetSavedTime
();
185
186
writer.WriteFloat(fuzeTime);
187
188
return
super.OnSaveActionData(writer);
189
}
190
191
//------------------------------------------------------------------------------------------------
192
override
protected
bool
OnLoadActionData
(
ScriptBitReader
reader)
193
{
194
float
fuzeTime;
195
reader.ReadFloat(fuzeTime);
196
bool
loaded = super.OnLoadActionData(reader);
197
198
if
(!
m_Loader
)
199
return
false
;
200
201
if
(
m_MortarMuzzleComponent
.GetAmmoCount() >=
m_MortarMuzzleComponent
.GetMaxAmmoCount())
202
return
false
;
203
204
m_ShellComp
=
GetHeldShellGadgetComp
(
m_Loader
);
205
if
(!
m_ShellComp
)
206
return
false
;
207
208
m_MortarMuzzleComponent
.LoadShell(
m_ShellComp
,
m_Loader
, fuzeTime,
m_bPerformFromTheLeftSide
);
209
210
return
loaded;
211
}
212
}
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
BaseMagazineWell
Definition
BaseMagazineWell.c:13
BaseUserAction::SetCannotPerformReason
void SetCannotPerformReason(string reason)
Definition
BaseUserAction.c:21
BaseUserAction::GetOwner
proto external IEntity GetOwner()
Returns the parent entity of this action.
BaseUserAction::GetCannotPerformReason
string GetCannotPerformReason()
Definition
BaseUserAction.c:28
BaseUserAction::GetUIInfo
proto external UIInfo GetUIInfo()
Returns the UIInfo set for this user action or null if none.
ChimeraCharacter
Definition
ChimeraCharacter.c:13
GenericComponent
Definition
GenericComponent.c:13
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
LocalizedString
Definition
LocalizedString.c:22
MagazineComponent
Definition
MagazineComponent.c:13
SCR_CharacterHelper
Definition
SCR_CharacterHelper.c:2
SCR_MortarShootAction
Definition
SCR_MortarShootAction.c:2
SCR_MortarShootAction::OnActionStart
override void OnActionStart(IEntity pUserEntity)
Definition
SCR_MortarShootAction.c:166
SCR_MortarShootAction::AREA_OBSTRUCTED
const LocalizedString AREA_OBSTRUCTED
Definition
SCR_MortarShootAction.c:19
SCR_MortarShootAction::FIRE_WITH_MANUAL_FUZE
const LocalizedString FIRE_WITH_MANUAL_FUZE
Definition
SCR_MortarShootAction.c:17
SCR_MortarShootAction::m_ShellComp
SCR_MortarShellGadgetComponent m_ShellComp
Definition
SCR_MortarShootAction.c:11
SCR_MortarShootAction::Init
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
Definition
SCR_MortarShootAction.c:22
SCR_MortarShootAction::CanBePerformedScript
override bool CanBePerformedScript(IEntity user)
Definition
SCR_MortarShootAction.c:51
SCR_MortarShootAction::m_bPerformFromTheLeftSide
bool m_bPerformFromTheLeftSide
Definition
SCR_MortarShootAction.c:4
SCR_MortarShootAction::WRONG_SHELL_TYPE
const LocalizedString WRONG_SHELL_TYPE
Definition
SCR_MortarShootAction.c:15
SCR_MortarShootAction::m_bCheckIfTurretIsEmpty
bool m_bCheckIfTurretIsEmpty
Definition
SCR_MortarShootAction.c:7
SCR_MortarShootAction::GetHeldShellGadgetComp
SCR_MortarShellGadgetComponent GetHeldShellGadgetComp(notnull ChimeraCharacter character)
Definition
SCR_MortarShootAction.c:121
SCR_MortarShootAction::FIRE_WITH_AUTOMATIC_FUZE
const LocalizedString FIRE_WITH_AUTOMATIC_FUZE
Definition
SCR_MortarShootAction.c:18
SCR_MortarShootAction::m_MortarMuzzleComponent
SCR_MortarMuzzleComponent m_MortarMuzzleComponent
Definition
SCR_MortarShootAction.c:10
SCR_MortarShootAction::ALREADY_LOADED
const LocalizedString ALREADY_LOADED
Definition
SCR_MortarShootAction.c:16
SCR_MortarShootAction::PerformAction
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
Definition
SCR_MortarShootAction.c:93
SCR_MortarShootAction::m_Loader
ChimeraCharacter m_Loader
Definition
SCR_MortarShootAction.c:12
SCR_MortarShootAction::GetActionNameScript
override bool GetActionNameScript(out string outName)
Definition
SCR_MortarShootAction.c:135
SCR_MortarShootAction::OnSaveActionData
bool OnSaveActionData(ScriptBitWriter writer)
Definition
SCR_MortarShootAction.c:172
SCR_MortarShootAction::m_fFuzeTime
float m_fFuzeTime
Definition
SCR_MortarShootAction.c:13
SCR_MortarShootAction::OnLoadActionData
bool OnLoadActionData(ScriptBitReader reader)
Definition
SCR_MortarShootAction.c:192
SCR_MortarShootAction::CanBeShownScript
override bool CanBeShownScript(IEntity user)
Definition
SCR_MortarShootAction.c:30
SCR_MortarShootAction::m_MortarMagWell
BaseMagazineWell m_MortarMagWell
Definition
SCR_MortarShootAction.c:9
SCR_PlayerController
Definition
SCR_PlayerController.c:31
SCR_PlayerController::GetLocalControlledEntity
static IEntity GetLocalControlledEntity()
Definition
SCR_PlayerController.c:495
SCR_ScriptedUserAction
A scripted action class having optional logic to check if vehicle is valid.
Definition
SCR_ScriptedUserAction.c:6
SCR_ScriptedUserAction::character
ChimeraCharacter character
Definition
SCR_ScriptedUserAction.c:35
SCR_ShellConfig
Definition
SCR_ShellConfig.c:2
SCR_ShellConfig::IsUsingManualTime
bool IsUsingManualTime()
Definition
SCR_ShellConfig.c:31
SCR_ShellConfig::GetSavedTime
float GetSavedTime()
Definition
SCR_ShellConfig.c:17
ScriptBitReader
Definition
EnNetwork.c:199
UIConstants
Definition
Constants.c:151
UIInfo
UIInfo - allows to define UI elements.
Definition
UIInfo.c:14
WidgetManager
Definition
WidgetManager.c:16
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
IsEmpty
proto native bool IsEmpty()
scripts
Game
UserActions
SCR_MortarShootAction.c
Generated by
1.17.0