Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CharacterCommandHandler.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/Character", description: "Scripted character command handler", icon: HYBRID_COMPONENT_ICON)]
5
6class SCR_CharacterCommandHandlerComponent : CharacterCommandHandlerComponent
7{
8 //------------------------------------------------------------------------------------------------
9 override bool HandleMelee(CharacterInputContext pInputCtx, float pDt, int pCurrentCommandID)
10 {
11 if (pInputCtx.GetMeleeAttack())
12 {
13 m_MeleeComponent.PerformAttack();
14 GetCommandModifier_Melee().Attack();
15 pInputCtx.SetMeleeAttack(false);
16 return true;
17 }
18
21
22 return GetCommandModifier_Melee().IsMeleeAttackTag();
23 }
24
25 //------------------------------------------------------------------------------------------------
26 override event int SelectMeleeAnimationType()
27 {
28 return m_MeleeComponent.HasBayonet();
29 }
30
31 //------------------------------------------------------------------------------------------------
40
41 //------------------------------------------------------------------------------------------------
42 override void OnCommandActivate(int pCmdId)
43 {
45 m_OnCommandActivate.Invoke(pCmdId);
46
47 super.OnCommandActivate(pCmdId);
48 }
49
50 //------------------------------------------------------------------------------------------------
53 {
54 if (IsLoitering())
55 return;
56
57 SCR_CharacterControllerComponent scrCharCtrl = SCR_CharacterControllerComponent.Cast(GetControllerComponent());
58 if (!scrCharCtrl)
59 return;
60
61 m_CmdLoiter = new SCR_CharacterCommandLoiter(m_CharacterAnimComp, m_OwnerEntity, GetControllerComponent().GetInputContext(), scrCharCtrl.GetScrInputContext(), m_ScrStaticTable, this, customAnimData);
62 m_CharacterAnimComp.SetCurrentCommand(m_CmdLoiter);
63 }
64
65 //------------------------------------------------------------------------------------------------
67 {
68 AnimPhysCommandScripted currentCmdScripted = m_CharacterAnimComp.GetCommandScripted();
69 if (!currentCmdScripted)
70 return null;
71
72 return SCR_CharacterCommandLoiter.Cast(currentCmdScripted);
73 }
74
75 //------------------------------------------------------------------------------------------------
78 //terminateFast should be true when we are going into alerted or combat state.
79 void StopLoitering(bool terminateFast)
80 {
81 if (m_CmdLoiter)
82 m_CmdLoiter.StopLoitering(terminateFast);
83
84 Rpc(Rpc_StopLoiter_S, false);
85 }
86
87 //------------------------------------------------------------------------------------------------
90 [RplRpc(RplChannel.Reliable, RplRcver.Server)]
91 void Rpc_StopLoiter_S(bool terminateFast)
92 {
93 if (m_CmdLoiter)
94 m_CmdLoiter.StopLoitering(terminateFast);
95 }
96
97 //------------------------------------------------------------------------------------------------
102
103 //------------------------------------------------------------------------------------------------
104 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast, RplCondition.NoOwner)]
106 {
107 auto loiterCommand = GetLoiterCommand();
108 if (!loiterCommand)
109 return;
110
111 loiterCommand.FinishLoiter();
112 }
113
114 //------------------------------------------------------------------------------------------------
119
120 //------------------------------------------------------------------------------------------------
124 {
125 return GetLoiterCommand() != null;
126 }
127 //------------------------------------------------------------------------------------------------
128 private void StartLoiteringRpl(SCR_ScriptedCharacterInputContext inputCtx)
129 {
131 StartCommandLoitering(inputCtx.m_CustomAnimData);
132 }
133
134 //------------------------------------------------------------------------------------------------
135 protected override bool OnRplSave(ScriptBitWriter writer)
136 {
137 if (!m_CmdLoiter || !IsLoitering() || !m_CmdLoiter.GetScriptedInputContext())
138 {
139 writer.WriteBool(false);
140 return true;
141 }
142
143 writer.WriteBool(true);
144
145 SCR_ScriptedCharacterInputContext inputCtx = m_CmdLoiter.GetScriptedInputContext();
146 inputCtx.OnRplSave(writer);
147
148 return true;
149 }
150
151 //------------------------------------------------------------------------------------------------
152 protected override bool OnRplLoad(ScriptBitReader reader)
153 {
154 bool hasLoiterData;
155 reader.ReadBool(hasLoiterData);
156 if (!hasLoiterData)
157 return true;
158
160 inputCtx.OnRplLoad(reader);
161
163 StartLoiteringRpl(inputCtx);
164 else
165 m_delayedLoiteringContext = inputCtx;
166
167 return true;
168 }
169
170 //------------------------------------------------------------------------------------------------
171 override protected void OnInit(IEntity owner)
172 {
173 super.OnInit(owner);
174
176 m_OwnerEntity = ChimeraCharacter.Cast(owner);
179 m_WeaponManager = BaseWeaponManagerComponent.Cast(m_OwnerEntity.FindComponent(BaseWeaponManagerComponent));
183 {
184 StartLoiteringRpl(m_delayedLoiteringContext);
186 }
187
189 Print("Failed to bind scripted static table (see class SCR_ScriptedCommandsStaticTable). This can be caused by missing animation commands, tags, or events in the animation graph.");
190 }
191
197 protected BaseWeaponManagerComponent m_WeaponManager;
201
203}
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_AIUtilityComponentClass m_OwnerEntity
ref SCR_ScriptedCommandsStaticTable m_ScrStaticTable
SCR_CharacterCommandLoiter GetLoiterCommand()
void BroadCastLoiterFinish()
void RPC_FinishLoitering_BCNO()
BaseWeaponManagerComponent m_WeaponManager
ref SCR_ScriptedCharacterInputContext m_delayedLoiteringContext
ScriptInvokerInt GetOnCommandActivate()
SCR_ScriptedCommandsStaticTable GetScriptedStaticTable()
void StartCommandLoitering(SCR_LoiterCustomAnimData customAnimData)
CharacterAnimationComponent m_CharacterAnimComp
SCR_MeleeComponent m_MeleeComponent
SCR_CharacterControllerComponent m_CharacterControllerComp
ref CharacterMovementState m_MovementState
ref ScriptInvokerInt m_OnCommandActivate
ref SCR_CharacterCommandLoiter m_CmdLoiter
void Rpc_StopLoiter_S(bool terminateFast)
enum ELoiterCommandState SCR_CharacterCommandLoiter(BaseAnimPhysComponent pAnimPhysComponent, ChimeraCharacter pCharacter, CharacterInputContext pBaseInputCtx, SCR_ScriptedCharacterInputContext pScrInputCtx, SCR_ScriptedCommandsStaticTable pStaticTable, SCR_CharacterCommandHandlerComponent pScrCommandHandler, SCR_LoiterCustomAnimData customAnimData)
void StopLoitering(bool terminateFast)
ScriptInvokerBase< ScriptInvokerIntMethod > ScriptInvokerInt
event bool HandleMelee(CharacterInputContext pInputCtx, float pDt, int pCurrentCommandID)
SCR_ScriptedCharacterInputContext GetScrInputContext()
void SetScrInputContext(SCR_ScriptedCharacterInputContext ctx)
void Update(float timeSlice)
Event methods.
HYBRID_COMPONENT_ICON
Default icon for all components written in script that don't inherit ScriptComponent.
override void OnCommandActivate(int pCmdId)
proto external CharacterInputContext GetInputContext()
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplCondition
Conditional replication rule. Fine grained selection of receivers.
RplRcver
Definition RplRcver.c:59
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14