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_RemoveCasualtyUserAction.c
Go to the documentation of this file.
1
class
SCR_RemoveCasualtyUserAction
:
SCR_CompartmentUserAction
2
{
3
const
string
m_sCannotPerformHostile =
"#AR-UserAction_SeatHostile"
;
4
const
string
m_sCannotPerformObstructed =
"#AR-UserAction_SeatObstructed"
;
5
6
[
Attribute
(
desc
:
"If true, the action will be only shown if player is inside a vehicle"
)]
7
protected
bool
m_bInteriorOnly
;
8
9
[
Attribute
(
desc
:
"If true, the action will be only shown if player is not inside a vehicle"
)]
10
protected
bool
m_bExteriorOnly
;
11
12
//------------------------------------------------------------------------------------------------
13
override
void
PerformAction
(
IEntity
pOwnerEntity,
IEntity
pUserEntity)
14
{
15
if
(!pOwnerEntity)
16
return
;
17
18
BaseCompartmentSlot
compartment = GetCompartmentSlot();
19
if
(!compartment)
20
return
;
21
22
ChimeraCharacter
casualty =
ChimeraCharacter
.Cast(compartment.GetOccupant());
23
if
(!casualty)
24
return
;
25
26
ChimeraCharacter
user =
ChimeraCharacter
.Cast(pUserEntity);
27
if
(!user)
28
return
;
29
30
SCR_CharacterControllerComponent
controller =
SCR_CharacterControllerComponent
.Cast(user.GetCharacterController());
31
if
(controller && controller.
IsLoitering
())
32
return
;
33
34
CompartmentAccessComponent userCompartmentAccess = user.GetCompartmentAccessComponent();
35
CompartmentAccessComponent casualtyCompartmentAccess = casualty.GetCompartmentAccessComponent();
36
if
(casualtyCompartmentAccess && userCompartmentAccess)
37
{
38
int
doorIdx =
GetRelevantDoorIndex
(pUserEntity);
39
casualtyCompartmentAccess.KickFromVehicle(doorIdx);
40
}
41
42
if
(compartment.IsPiloting())
// even a dead driver applies brakes to the car using the engine, so when we remove the driver from the compartment
43
{
// we pull the handbrake to make it less confusing during gameplay
44
CarControllerComponent
car =
CarControllerComponent
.Cast(compartment.GetController());
45
if
(car)
46
car.SetPersistentHandBrake(
true
)
47
}
48
49
super.PerformAction(pOwnerEntity, pUserEntity);
50
}
51
52
//------------------------------------------------------------------------------------------------
53
override
bool
CanBePerformedScript
(
IEntity
user)
54
{
55
BaseCompartmentSlot
compartment = GetCompartmentSlot();
56
if
(!compartment)
57
return
false
;
58
59
SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(user);
60
if
(!character)
61
return
false
;
62
63
SCR_CharacterControllerComponent
controller =
SCR_CharacterControllerComponent
.Cast(character.GetCharacterController());
64
if
(controller && controller.
IsLoitering
())
65
return
false
;
66
67
CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
68
if
(!compartmentAccess)
69
return
false
;
70
71
// Restrict removing casualty from another compartment in case the section does not match
72
BaseCompartmentSlot
characterCompartment = compartmentAccess.GetCompartment();
73
if
(characterCompartment && characterCompartment.
GetCompartmentSection
() != compartment.
GetCompartmentSection
())
74
return
false
;
75
76
IEntity
owner = compartment.GetOwner();
77
Vehicle
vehicle =
Vehicle
.Cast(owner.
GetRootParent
());
78
if
(vehicle)
79
{
80
Faction
characterFaction = character.GetFaction();
81
Faction
vehicleFaction = vehicle.GetFaction();
82
83
if
(characterFaction && vehicleFaction && characterFaction.IsFactionEnemy(vehicleFaction))
84
{
85
bool
isActive =
true
;
86
SCR_VehicleFactionAffiliationComponent
vehicleAffiliation = vehicle.GetFactionAffiliation();
87
if
(vehicleAffiliation)
88
isActive = vehicleAffiliation.
IsVehicleActive
();
89
90
if
(isActive)
91
{
92
SetCannotPerformReason
(m_sCannotPerformHostile);
93
return
false
;
94
}
95
}
96
}
97
98
BaseCompartmentManagerComponent
managerComponent = compartment.GetManager();
99
if
(!managerComponent)
100
return
false
;
101
102
// Make sure vehicle can be enter via provided door, if not, set reason.
103
if
(!character.IsInVehicle() && !compartmentAccess.CanGetInVehicleViaDoor(owner, managerComponent,
GetRelevantDoorIndex
(user)))
104
{
105
SetCannotPerformReason
(m_sCannotPerformObstructed);
106
return
false
;
107
}
108
109
return
true
;
110
}
111
112
//------------------------------------------------------------------------------------------------
113
override
bool
CanBeShownScript
(
IEntity
user)
114
{
115
BaseCompartmentSlot
compartment = GetCompartmentSlot();
116
if
(!compartment)
117
return
false
;
118
119
ChimeraCharacter
character =
ChimeraCharacter
.Cast(user);
120
if
(!character)
121
return
false
;
122
123
CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
124
if
(!compartmentAccess)
125
return
false
;
126
127
if
(compartmentAccess.IsGettingIn() || compartmentAccess.IsGettingOut())
128
return
false
;
129
130
// Restrict removing casualty from another compartment in case the section does not match
131
BaseCompartmentSlot
characterCompartment = compartmentAccess.GetCompartment();
132
if
(characterCompartment && characterCompartment.
GetCompartmentSection
() != compartment.
GetCompartmentSection
())
133
return
false
;
134
135
ChimeraCharacter
casualty =
ChimeraCharacter
.Cast(compartment.GetOccupant());
136
if
(!casualty)
137
return
false
;
138
139
CharacterControllerComponent controller = casualty.GetCharacterController();
140
if
(!controller)
141
return
false
;
142
143
if
(
m_bInteriorOnly
&& !SCR_InteractionHandlerComponent.CanBeShownInVehicle(character,
this
, interiorOnly:
m_bInteriorOnly
))
144
return
false
;
145
146
if
(
m_bExteriorOnly
&& character.IsInVehicle())
147
return
false
;
148
149
return
controller.GetLifeState() !=
ECharacterLifeState
.ALIVE;
150
}
151
152
//------------------------------------------------------------------------------------------------
153
override
bool
HasLocalEffectOnlyScript
()
154
{
155
return
false
;
156
}
157
}
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
BaseCompartmentManagerComponent
Definition
BaseCompartmentManagerComponent.c:13
BaseCompartmentSlot
Definition
BaseCompartmentSlot.c:2
BaseCompartmentSlot::GetCompartmentSection
int GetCompartmentSection()
Switching seats is allowed only between compartments with matching area.
Definition
BaseCompartmentSlot.c:65
BaseUserAction::SetCannotPerformReason
void SetCannotPerformReason(string reason)
Definition
BaseUserAction.c:21
CarControllerComponent
Definition
CarControllerComponent.c:13
ChimeraCharacter
Definition
ChimeraCharacter.c:13
Faction
Definition
Faction.c:13
IEntity
Definition
IEntity.c:13
IEntity::GetRootParent
proto external IEntity GetRootParent()
SCR_CharacterControllerComponent
Definition
SCR_CharacterControllerComponent.c:36
SCR_CharacterControllerComponent::IsLoitering
bool IsLoitering()
Definition
SCR_CharacterControllerComponent.c:1649
SCR_CompartmentUserAction
Definition
SCR_CompartmentUserAction.c:2
SCR_CompartmentUserAction::GetRelevantDoorIndex
int GetRelevantDoorIndex(IEntity caller)
Definition
SCR_CompartmentUserAction.c:46
SCR_RemoveCasualtyUserAction
Definition
SCR_RemoveCasualtyUserAction.c:2
SCR_RemoveCasualtyUserAction::CanBePerformedScript
override bool CanBePerformedScript(IEntity user)
Definition
SCR_RemoveCasualtyUserAction.c:53
SCR_RemoveCasualtyUserAction::HasLocalEffectOnlyScript
override bool HasLocalEffectOnlyScript()
Definition
SCR_RemoveCasualtyUserAction.c:153
SCR_RemoveCasualtyUserAction::CanBeShownScript
override bool CanBeShownScript(IEntity user)
Definition
SCR_RemoveCasualtyUserAction.c:113
SCR_RemoveCasualtyUserAction::m_bExteriorOnly
bool m_bExteriorOnly
Definition
SCR_RemoveCasualtyUserAction.c:10
SCR_RemoveCasualtyUserAction::m_bInteriorOnly
bool m_bInteriorOnly
Definition
SCR_RemoveCasualtyUserAction.c:7
SCR_RemoveCasualtyUserAction::PerformAction
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
Definition
SCR_RemoveCasualtyUserAction.c:13
SCR_VehicleFactionAffiliationComponent
Definition
SCR_VehicleFactionAffiliationComponent.c:7
SCR_VehicleFactionAffiliationComponent::IsVehicleActive
bool IsVehicleActive()
Check if there are any conscious and alive occupants among the occupants.
Definition
SCR_VehicleFactionAffiliationComponent.c:26
Vehicle
enum EPhysicsLayerPresets Vehicle
Definition
gameLib.c:24
ECharacterLifeState
ECharacterLifeState
Definition
ECharacterLifeState.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
UserActions
SCR_RemoveCasualtyUserAction.c
Generated by
1.17.0