8 protected int m_iCharacterID;
11 protected bool m_bDeathAnimation;
14 protected bool m_bRootMotion;
17 protected string m_sPositionToEntity;
20 protected bool m_bDisablePhysics;
23 protected int m_iDefaultEmotion;
26 protected bool m_bProximityLook;
29 protected float m_fProximityLookRadius;
32 protected float m_fProximityLookWidth;
35 protected bool m_bProximityTalk;
38 protected float m_fProximityTalkRadius;
41 protected bool m_bProximityTalkOnlyOnce;
44 protected int m_iProximityTalkDefaultStage;
47 protected int m_iTalkVariants;
50 protected bool m_bRandomTalkVariant;
53 protected bool m_bStopTalkWhenOutOfProximity;
55 protected bool m_bStoppingTalk;
56 protected bool m_bProximityTalkEnabled =
true;
58 protected int m_iPermanentNarrativeStage;
59 protected int m_iActualTalkVariant = 1;
60 protected int m_iPlayerBoneId;
62 protected float m_fLookAtIntensity;
63 protected float m_fDistanceToPlayer;
65 protected vector m_vLook[4];
66 protected vector m_vLookEnd[4];
67 protected vector m_vLookAxis;
68 protected vector m_vPlayerHead[4];
69 protected vector m_vPlayerPosition[4];
70 protected vector m_vPlayerHeadPosition;
72 protected IEntity m_EntityInHand;
74 protected IEntity entityToAttachTo;
93 void PlayAnimation(
bool in =
false,
string command =
"CMD_NarrativeStage",
int animId = 0)
95 if (!m_CharacterAnimation)
103 customAnimData.m_CustomCommand = commandId;
105 SCR_CharacterCommandHandlerComponent scrCmdHandler = SCR_CharacterCommandHandlerComponent.Cast(m_CharacterAnimation.GetCommandHandler());
106 scrCmdHandler.StartCommand_Move();
108 vector targetPosition[4] = {
"1 0 0",
"0 1 0",
"0 0 1",
"0 0 0" };
110 bool alignToPosition =
false;
112 if (m_sPositionToEntity !=
"")
114 entityToAttachTo =
GetGame().
GetWorld().FindEntityByName(m_sPositionToEntity);
115 if (entityToAttachTo)
118 alignToPosition =
true;
127 m_CharacterAnimation.CallCommand4I(commandId, 0, animId, 0, 0, 0);
129 m_CharacterAnimation.CallCommand(commandId, animId, 0);
132 if (m_iActualTalkVariant < m_iTalkVariants)
133 m_iActualTalkVariant++;
135 m_iActualTalkVariant = 1;
137 if (m_bRandomTalkVariant)
138 m_iActualTalkVariant = Math.RandomInt(1, m_iTalkVariants + 1);
143 m_CharacterAnimation.SetVariableInt(variableId, m_iActualTalkVariant);
146 m_CharacterAnimation.SetVariableInt(m_EmotionId, m_iDefaultEmotion);
152 m_iPermanentNarrativeStage = stage;
153 m_bProximityTalkEnabled =
true;
164 m_Player.GetTransform(m_vPlayerPosition);
165 m_fDistanceToPlayer =
vector.Distance(m_vPlayerPosition[3], owner.
GetOrigin());
167 if (m_fDistanceToPlayer > m_fProximityTalkRadius)
169 if (m_fDistanceToPlayer < m_fProximityLookRadius)
171 else if (m_fDistanceToPlayer < 50)
177 m_bStoppingTalk =
true;
180 if (!m_bProximityTalkOnlyOnce)
181 m_bProximityTalkEnabled =
true;
185 m_bStoppingTalk =
false;
187 if (m_bProximityTalk && m_bProximityTalkEnabled)
189 if (!m_bProximityTalkOnlyOnce)
191 PlayAnimation(
true,
"CMD_NarrativeStage", m_iPermanentNarrativeStage);
192 m_bProximityTalkEnabled =
false;
196 PlayAnimation(
true,
"CMD_NarrativeStage", m_iPermanentNarrativeStage);
197 m_bProximityTalkEnabled =
false;
204 m_bStoppingTalk =
true;
211 m_fLookAtIntensity =
Math.Clamp(m_fLookAtIntensity, 0.01, 0.99);
213 if (m_LookAtVariable)
214 m_CharacterAnimation.SetVariableFloat(m_LookAtVariable, 1 / (1 +
Math.Pow(m_fLookAtIntensity / (1 - m_fLookAtIntensity), -2)));
218 m_fLookAtIntensity -= timeSlice * 1.3;
223 if (m_PointOfViewStart)
224 m_PointOfViewStart.GetWorldTransform(m_vLook);
226 if (m_PointOfViewEnd)
227 m_PointOfViewEnd.GetWorldTransform(m_vLookEnd);
229 m_vLookAxis =
vector.Direction(m_vLook[3], m_vLookEnd[3]);
230 m_vLookAxis.Normalize();
232 if (
Math3D.IntersectionSphereCone(m_vPlayerPosition[3], 1, m_vLook[3], m_vLookAxis, m_fProximityLookWidth))
235 m_iPlayerBoneId = playerAnimation.GetBoneIndex(
"Head");
236 playerAnimation.GetBoneMatrix(m_iPlayerBoneId, m_vPlayerHead);
238 Math3D.MatrixMultiply4(m_vPlayerPosition, m_vPlayerHead, m_vPlayerHead);
241 m_CharacterAnimation.SetIKTarget(
"HeadLook",
"HeadLook", m_vPlayerHeadPosition, {0, 0, 0});
243 m_fLookAtIntensity += timeSlice * 1.3;
248 m_fLookAtIntensity -= timeSlice * 1.3;
269 m_iPermanentNarrativeStage = m_iProximityTalkDefaultStage;
276 if (m_bDisablePhysics)
279 if (m_bProximityLook)
286 m_PointOfViewStart =
m_SlotManager.GetSlotByName(
"PointOfViewStart");
287 m_PointOfViewEnd =
m_SlotManager.GetSlotByName(
"PointOfViewEnd");
292 if (m_CharacterAnimation)
294 m_LookAtVariable = m_CharacterAnimation.BindVariableFloat(
"NarrativeLookAtIntensity");
295 m_EmotionId = m_CharacterAnimation.BindVariableInt(
"emotion");
317 m_CommSoundComp.TerminateAll();
320 GetGame().GetCallqueue().CallLater(
PlayAnimation, 1000,
false,
true,
"CMD_Narrative", m_iCharacterID);
326 SCR_TutorialGamemodeComponent tutorialGamemodeComponent = SCR_TutorialGamemodeComponent.GetInstance();
328 if (!tutorialGamemodeComponent)
331 SCR_ETutorialCourses actualCourse = tutorialGamemodeComponent.GetActiveConfig().GetCourseType();
339 array<EntitySlotInfo> npcSlotInfos = {};
347 if (slotInfo.GetAttachedEntity())
348 slotInfo.DetachEntity(
false);
352 if (m_bDeathAnimation)
358 CharacterControllerComponent controller = CharacterControllerComponent.Cast(
GetOwner().
FindComponent(CharacterControllerComponent));
361 controller.ForceDeath();
370 if (eventName ==
"TutorialVoice")
373 m_CommSoundComp.SoundEventPriority(
GameAnimationUtils.GetEventString(animUserString), intParam,
true);
375 else if (eventName ==
"PropDetach")
385 m_EntityInHand = slotInfo.GetAttachedEntity();
386 slotInfo.DetachEntity(
true);
390 else if (eventName ==
"PropAttach")
398 if (telephoneSlot && m_EntityInHand)
399 telephoneSlot.AttachEntity(m_EntityInHand);
ArmaReforgerScripted GetGame()
DamageManagerComponent m_DamageManager
ChimeraCharacter m_Player
SCR_CharacterBloodHitZone OnDamage
Resilience - incapacitation or death, depending on game mode settings.
SCR_CharacterControllerComponent m_CharController
bool LookAtPlayer(IEntity owner, float timeSlice, bool lookAway=false)
void SetPermanentNarrativeStage(int stage)
bool IsActualCourseFreeRoam()
SCR_SlotServiceComponentClass m_SlotManager
Service with basic slot handling functionalities.
Adds ability to attach an object to a slot.
proto external int SetEventMask(notnull IEntity owner, int mask)
proto external GenericComponent FindComponent(typename typeName)
proto external Managed FindComponent(typename typeName)
proto external vector GetOrigin()
proto external BaseWorld GetWorld()
proto external void GetTransform(out vector mat[])
proto external vector CoordToLocal(vector coord)
void StartLoitering(IEntity loiterEntity, int loiteringType, bool holsterWeapon, bool allowRootMotion, bool alignToPosition, vector targetPosition[4]={ "1 0 0", "0 1 0", "0 0 1", "0 0 0" }, bool disableInput=false, SCR_LoiterCustomAnimData customAnimData=SCR_LoiterCustomAnimData.Default)
proto external GenericEntity GetOwner()
Get owner entity.
void EOnFixedFrame(IEntity owner, float timeSlice)
void EOnInit(IEntity owner)
event void OnAnimationEvent(AnimationEventID animEventType, AnimationEventID animUserString, int intParam, float timeFromStart, float timeToEnd)
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.