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_BaseWeaponAction.c
Go to the documentation of this file.
1
class
SCR_BaseWeaponAction
:
SCR_InventoryAction
2
{
3
const
string
PRIMARY_WEAPON_TYPE =
"primary"
;
4
const
string
SECONDARY_WEAPON_TYPE =
"secondary"
;
5
const
string
GRENADE_WEAPON_TYPE =
"grenade"
;
6
7
protected
bool
m_bIsSwappingWeapons
=
false
;
8
protected
string
m_sWeaponToSwapName
=
""
;
9
protected
BaseWeaponComponent
m_pWeaponOnGroundComponent
;
10
protected
ref array<WeaponSlotComponent>
m_aWeaponSlots
= {};
11
protected
string
m_sWeaponOnGroundType
=
""
;
12
protected
int
m_iSameTypeSlotsCount
= 0;
13
14
//------------------------------------------------------------------------------------------------
15
// Returns true if the equip or equip holster action can be perfomed. Also modifies the text depending on the conditions
16
bool
CanEquipOrReplaceWeapon
(
IEntity
userEntity )
17
{
18
ChimeraCharacter
user =
ChimeraCharacter
.Cast( userEntity );
19
if
( !user )
20
return
false
;
21
22
BaseWeaponManagerComponent weaponManager = user.GetCharacterController().GetWeaponManagerComponent();
23
if
( !weaponManager )
24
return
false
;
25
26
m_iSameTypeSlotsCount
= 0;
27
m_bIsSwappingWeapons
=
false
;
28
m_sWeaponToSwapName
=
""
;
29
30
// Eventually the equip actions will be removed for the grenades as whole
31
if
(
m_sWeaponOnGroundType
== GRENADE_WEAPON_TYPE )
32
return
true
;
33
34
m_aWeaponSlots
.Clear();
35
weaponManager.GetWeaponsSlots(
m_aWeaponSlots
);
36
37
string
weaponSlotType;
38
39
// If there is an empty slot of the same type as the weapon on the ground we are able to equip the weapon without replacing anything
40
foreach
(
WeaponSlotComponent
weaponSlot:
m_aWeaponSlots
)
41
{
42
weaponSlotType = weaponSlot.GetWeaponSlotType();
43
44
if
( weaponSlotType !=
m_sWeaponOnGroundType
&& !CharacterHandWeaponSlotComponent.Cast(weaponSlot) )
45
continue
;
46
47
m_iSameTypeSlotsCount
++;
48
49
if
( !weaponSlot.GetWeaponEntity() )
50
return
true
;
51
}
52
53
BaseWeaponComponent
weaponToSwap =
GetWeaponToSwap
( weaponManager );
54
55
if
( !weaponToSwap )
56
return
false
;
57
58
m_bIsSwappingWeapons
=
true
;
59
60
UIInfo
weaponToSwapUIInfo = weaponToSwap.GetUIInfo();
61
62
// If the component is missing configuration we can fall back on the weapon slot name.
63
if
( weaponToSwapUIInfo )
64
{
65
string
weaponToSwapName = weaponToSwapUIInfo.GetName();
66
67
if
( !weaponToSwapName.IsEmpty() )
68
m_sWeaponToSwapName
= weaponToSwapName;
69
}
70
else
71
m_sWeaponToSwapName
=
m_sWeaponOnGroundType
;
72
73
return
true
;
74
}
75
76
//------------------------------------------------------------------------------------------------
77
// Gets all the variables that are constant for the entire duration.
78
override
void
Init
(
IEntity
pOwnerEntity,
GenericComponent
pManagerComponent)
79
{
80
super.Init(pOwnerEntity, pManagerComponent);
81
82
if
( !m_Item )
83
{
84
Print
(
"Pick up/equip UserAction is attached to an object which is not an item"
,
LogLevel
.WARNING );
85
return
;
86
}
87
88
m_pWeaponOnGroundComponent
=
BaseWeaponComponent
.Cast( m_Item.GetOwner().FindComponent(
BaseWeaponComponent
) );
89
90
if
( !
m_pWeaponOnGroundComponent
)
91
return
;
92
m_sWeaponOnGroundType
=
m_pWeaponOnGroundComponent
.GetWeaponSlotType();
93
}
94
95
96
//------------------------------------------------------------------------------------------------
97
// Returns the weapon that will be swapped.
98
BaseWeaponComponent
GetWeaponToSwap
( notnull BaseWeaponManagerComponent weaponManager )
99
{
100
BaseWeaponComponent
currentWeapon = weaponManager.GetCurrentWeapon();
101
102
// The equipped weapon will be swapped, if it's the same type as the one on the ground.
103
if
(currentWeapon)
104
{
105
if
( currentWeapon.GetWeaponSlotType() ==
m_sWeaponOnGroundType
)
106
return
currentWeapon;
107
}
108
109
BaseWeaponComponent
weaponToSwap;
110
string
weaponSlotType;
111
112
// First compatible slot will be used if the equipped weapon doesn't match.
113
foreach
(
WeaponSlotComponent
weaponSlot:
m_aWeaponSlots
)
114
{
115
weaponSlotType = weaponSlot.GetWeaponSlotType();
116
117
if
( weaponSlotType ==
m_sWeaponOnGroundType
)
118
{
119
weaponToSwap =
BaseWeaponComponent
.Cast( weaponSlot.GetWeaponEntity().FindComponent(
BaseWeaponComponent
) );
120
if
( weaponToSwap )
121
return
weaponToSwap;
122
}
123
}
124
125
return
null;
126
}
127
};
BaseWeaponComponent
Definition
BaseWeaponComponent.c:13
ChimeraCharacter
Definition
ChimeraCharacter.c:13
GenericComponent
Definition
GenericComponent.c:13
IEntity
Definition
IEntity.c:13
SCR_BaseWeaponAction
Definition
SCR_BaseWeaponAction.c:2
SCR_BaseWeaponAction::CanEquipOrReplaceWeapon
bool CanEquipOrReplaceWeapon(IEntity userEntity)
Definition
SCR_BaseWeaponAction.c:16
SCR_BaseWeaponAction::GetWeaponToSwap
BaseWeaponComponent GetWeaponToSwap(notnull BaseWeaponManagerComponent weaponManager)
Definition
SCR_BaseWeaponAction.c:98
SCR_BaseWeaponAction::m_pWeaponOnGroundComponent
BaseWeaponComponent m_pWeaponOnGroundComponent
Definition
SCR_BaseWeaponAction.c:9
SCR_BaseWeaponAction::m_sWeaponToSwapName
string m_sWeaponToSwapName
Definition
SCR_BaseWeaponAction.c:8
SCR_BaseWeaponAction::m_sWeaponOnGroundType
string m_sWeaponOnGroundType
Definition
SCR_BaseWeaponAction.c:11
SCR_BaseWeaponAction::m_iSameTypeSlotsCount
int m_iSameTypeSlotsCount
Definition
SCR_BaseWeaponAction.c:12
SCR_BaseWeaponAction::m_aWeaponSlots
ref array< WeaponSlotComponent > m_aWeaponSlots
Definition
SCR_BaseWeaponAction.c:10
SCR_BaseWeaponAction::m_bIsSwappingWeapons
bool m_bIsSwappingWeapons
Definition
SCR_BaseWeaponAction.c:7
SCR_BaseWeaponAction::Init
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
Definition
SCR_BaseWeaponAction.c:78
SCR_InventoryAction
modded version for to be used with the inventory 2.0
Definition
SCR_InventoryAction.c:4
UIInfo
UIInfo - allows to define UI elements.
Definition
UIInfo.c:14
WeaponSlotComponent
Definition
WeaponSlotComponent.c:13
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
scripts
Game
UserActions
SCR_BaseWeaponAction.c
Generated by
1.17.0