37 [
Attribute(defvalue:
"10", uiwidget: UIWidgets.EditBox,
params:
"1 inf 0.1",
desc:
"Maximum duration it takes for character to drown\n[s]")]
38 protected float m_fDrowningDuration;
41 protected SCR_CharacterCameraHandlerComponent m_CameraHandler;
43 protected bool m_bOverrideActions =
true;
44 protected bool m_bInspectionFocus;
45 protected bool m_bCharacterIsDrowning;
46 protected float m_fDrowningTime;
58 ref ScriptInvoker<IEntity, bool, bool> m_OnGadgetStateChangedInvoker =
new ScriptInvoker<IEntity, bool, bool>();
59 ref ScriptInvoker<IEntity, bool> m_OnGadgetFocusStateChangedInvoker =
new ScriptInvoker<IEntity, bool>();
66 protected ref ScriptInvoker<AnimationEventID, AnimationEventID, int, float, float> m_OnAnimationEvent;
70 private static bool s_bDiagRegistered;
71 private static bool m_bEnableDebugUI;
72 private CharacterAnimationComponent m_AnimComponent;
73 private Widget m_wDebugRootWidget;
93 if (!character || character.IsInVehicleADS())
107 override void OnConsciousnessChanged(
bool conscious)
112 AIControlComponent aiControl = AIControlComponent.Cast(
GetOwner().FindComponent(AIControlComponent));
113 if (!aiControl || !aiControl.IsAIActivated())
116 IEntity currentWeapon;
118 if (wpnMan && wpnMan.GetCurrentWeapon())
119 currentWeapon = wpnMan.GetCurrentWeapon().GetOwner();
123 bool dropGrenade =
false;
127 EWeaponType wt = wpnMan.GetCurrentWeapon().GetWeaponType();
132 if ((triggerComp && triggerComp.WasTriggered()) || (handler && handler.IsThrowingAction()))
139 handler.DropLiveGrenadeFromHand(
false);
147 ScriptInvoker GetOnAnimationEvent()
149 if (!m_OnAnimationEvent)
150 m_OnAnimationEvent =
new ScriptInvoker();
152 return m_OnAnimationEvent;
156 override void OnGadgetStateChanged(IEntity gadget,
bool isInHand,
bool isOnGround)
158 m_OnGadgetStateChangedInvoker.Invoke(gadget, isInHand, isOnGround);
162 override void OnGadgetFocusStateChanged(IEntity gadget,
bool isFocused)
164 m_OnGadgetFocusStateChangedInvoker.Invoke(gadget, isFocused);
170 m_OnItemUseBeganInvoker.Invoke(itemUseParams.GetEntity(), itemUseParams);
176 m_OnItemUseEndedInvoker.Invoke(itemUseParams.GetEntity(), successful, itemUseParams);
178 m_OnItemUseFinishedInvoker.Invoke(itemUseParams.GetEntity(), successful, itemUseParams);
182 protected override void OnAnimationEvent(AnimationEventID animEventType, AnimationEventID animUserString,
int intParam,
float timeFromStart,
float timeToEnd)
184 if (m_OnAnimationEvent)
185 m_OnAnimationEvent.Invoke(animEventType, animUserString, intParam, timeFromStart, timeToEnd);
190 override void OnMeleeDamage(
bool started)
199 return m_OnPlayerDeath;
206 return m_OnPlayerDeathWithParam;
210 override void OnDeath(IEntity instigatorEntity, notnull
Instigator instigator)
212 m_OnPlayerDeath.Invoke();
213 m_OnPlayerDeathWithParam.Invoke(
this, instigatorEntity, instigator);
217 pc.m_bRetain3PV =
true;
222 garbageSystem.Insert(character);
228 m_OnLifeStateChanged.Invoke(previousLifeState, newLifeState);
234 IEntity vehicle = CompartmentAccessComponent.GetVehicleIn(
char);
239 if (!vehicleFactionAff)
242 vehicleFactionAff.UpdateOccupantsCount();
246 override bool GetCanMeleeAttack()
269 override bool GetCanEquipGadget(IEntity gadget)
272 if (handler.IsLoitering() || GetScrInputContext().m_iLoiteringType != -1)
281 override bool OnPerformAction()
283 return m_bOverrideActions;
287 override void OnInit(IEntity owner)
296 m_CameraHandler = SCR_CharacterCameraHandlerComponent.Cast(character.FindComponent(SCR_CharacterCameraHandlerComponent));
299 if (!m_AnimComponent)
300 m_AnimComponent = CharacterAnimationComponent.Cast(character.FindComponent(CharacterAnimationComponent));
307 protected override void OnApplyControls(IEntity owner,
float timeSlice)
309 if (GetScrInputContext().m_iLoiteringType >= 0)
312 if (!handler.IsLoitering())
314 if (TryStartLoiteringInternal())
321 protected override void UpdateDrowning(
float timeSlice, vector waterLevel)
327 CompartmentAccessComponent accesComp =
char.GetCompartmentAccessComponent();
328 bool isInWatertightCompartment = accesComp && accesComp.GetCompartment() && accesComp.GetCompartment().GetIsWaterTight();
330 float drowningTimeStartFX = 4;
331 if (waterLevel[2] > 0 && !isInWatertightCompartment)
333 if (m_fDrowningTime < drowningTimeStartFX && (m_fDrowningTime + timeSlice) > drowningTimeStartFX)
335 m_OnPlayerDrowning.Invoke(m_fDrowningDuration, drowningTimeStartFX);
336 m_bCharacterIsDrowning =
true;
339 m_fDrowningTime += timeSlice;
343 if (m_fDrowningTime != 0)
345 m_OnPlayerStopDrowning.Invoke();
346 m_bCharacterIsDrowning =
false;
354 if (!damageMan || !damageMan.GetResilienceHitZone())
357 if (m_fDrowningTime > m_fDrowningDuration)
360 damageMan.Kill(
Instigator.CreateInstigator(
char));
366 float GetDrowningTime()
368 return m_fDrowningTime;
373 bool IsCharacterDrowning()
375 return m_bCharacterIsDrowning;
379 override bool ShouldAligningAdjustAimingAngles()
381 return IsAligningBeforeLoiter();
386 bool IsAligningBeforeLoiter()
388 return GetScrInputContext().m_iLoiteringType != -1 && GetScrInputContext().m_bLoiteringShouldAlignCharacter &&
GetAnimationComponent().GetHeadingComponent().IsAligning();
393 override bool SCR_GetDisableMovementControls()
399 if (GetScrInputContext().m_iLoiteringType > 0)
401 bool isAligningBeforeLoiter = IsAligningBeforeLoiter();
402 bool isHolsteringBeforeLoiter = GetScrInputContext().m_iLoiteringShouldHolsterWeapon &&
IsChangingItem();
404 if (isAligningBeforeLoiter || isHolsteringBeforeLoiter)
408 return handler.IsLoitering();
412 override void SCR_OnDisabledJumpAction()
418 if (handler.IsLoitering())
419 StopLoitering(
false);
421 if (IsAligningBeforeLoiter())
424 if (headingComponent)
426 headingComponent.ResetAligning();
427 GetScrInputContext().m_iLoiteringType = -1;
437 override void OnDiag(IEntity owner,
float timeslice)
440 if (!character ||
IsDead())
446 bool diagTransform = DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_CHARACTER_TRANSFORMATION);
450 if (bIsLocalCharacter && diagTransform)
452 DbgUI.Begin(
"Character Transformation");
453 const string CHAR_POS =
"X:\t%1\nY:\t%2\nZ:\t%3";
454 const string CHAR_ROT =
"PITCH:\t%1\nYAW:\t%2\nROLL:\t%3";
455 const string CHAR_SCALE =
"%1";
456 const string CHAR_AIM =
"X:\t%1\nY:\t%2\nZ:\t%3";
457 vector pos = character.GetOrigin();
458 vector rot = character.GetYawPitchRoll();
459 float scale = character.GetScale();
461 string strPosition =
string.Format(CHAR_POS, pos[0].ToString(), pos[1].ToString(), pos[2].ToString());
462 string strRotation =
string.Format(CHAR_ROT, rot[1].ToString(), rot[0].ToString(), rot[2].ToString());
463 string strScale =
string.Format(CHAR_SCALE, scale.ToString());
464 string strAiming =
string.Format(CHAR_AIM, aimRot[0].ToString(), aimRot[1].ToString(), aimRot[2].ToString());
465 DbgUI.Text(
"POSITION:\n" + strPosition);
466 DbgUI.Text(
"ROTATION:\n" + strRotation);
467 DbgUI.Text(
"SCALE:" + strScale);
468 DbgUI.Text(
"AIMING ANGLES:\n" + strAiming);
470 if (DbgUI.Button(
"Print plaintext to console"))
471 Print(
"TransformInfo:\nPOSITION:\n" + strPosition +
"\nROTATION:\n" + strRotation +
"\nSCALE:" + strScale +
"\nAIMING ANGLES:\n" + strAiming, LogLevel.NORMAL);
477 m_bEnableDebugUI = bIsLocalCharacter && DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_CHARACTER_MENU);
478 if (m_bEnableDebugUI && !m_wDebugRootWidget)
480 else if (!m_bEnableDebugUI && m_wDebugRootWidget)
483 if (m_bEnableDebugUI)
488 private void ReloadDebugUI()
490 if (m_wDebugRootWidget)
497 private void DeleteDebugUI()
499 m_wDebugRootWidget.RemoveFromHierarchy();
500 m_wDebugRootWidget =
null;
504 private void UpdateInputCircles()
506 if (!m_wDebugRootWidget || !m_AnimComponent)
509 Widget wInput = m_wDebugRootWidget.FindAnyWidget(
"Input");
513 WorkspaceWidget workspaceWidget =
GetGame().GetWorkspace();
515 float topSpeed = m_AnimComponent.GetTopSpeed(-1,
false);
517 TextWidget wMaxSpeed = TextWidget.Cast(wInput.FindAnyWidget(
"MaxSpeed"));
520 float speed = Math.Ceil(topSpeed * 10) * 0.1;
521 wMaxSpeed.SetText(speed.ToString() +
"m/s");
524 float ringSize = FrameSlot.GetSizeX(wInput);
525 float degSizeDivider = topSpeed * ringSize;
526 if (degSizeDivider > 0)
527 for (
int spd = 0; spd < 3; spd++)
541 color = ARGB(255, 150, 255, 150);
544 color = ARGB(255, 200, 200, 150);
547 color = ARGB(255, 255, 150, 150);
549 for (
int deg = 0; deg < 360; deg++)
552 float inputForward = velInput[2];
553 float inputRight = velInput[0];
555 float degSize = m_AnimComponent.GetMaxSpeed(inputForward, inputRight, spdType) / degSizeDivider;
559 float degOff = (ringSize - degSize) * 0.5;
561 string iRingname =
"iRing_" + spd.ToString() +
"_" + deg.ToString();
563 ImageWidget wImg = ImageWidget.Cast(wInput.FindAnyWidget(iRingname));
566 wImg = ImageWidget.Cast(workspaceWidget.CreateWidget(WidgetType.ImageWidgetTypeID, WidgetFlags.BLEND | WidgetFlags.VISIBLE | WidgetFlags.STRETCH | WidgetFlags.NOWRAP, Color.FromInt(color), spd + 2, wInput));
567 wImg.LoadImageTexture(0,
"{90DF4F065D08EF4E}UI/Textures/HUD_obsolete/character/input_360ringslice.edds");
568 wImg.SetRotation(deg);
569 wImg.SetName(iRingname);
572 FrameSlot.SetAnchorMax(wImg, 0, 0);
573 FrameSlot.SetAnchorMin(wImg, 0, 0);
574 FrameSlot.SetSize(wImg, degSize, degSize);
575 FrameSlot.SetPos(wImg, degOff, degOff);
581 private void CreateDebugUI()
583 m_wDebugRootWidget =
GetGame().GetWorkspace().CreateWidgets(
"{C70DA11469BBAF67}UI/layouts/Debug/HUD_Debug_Character.layout",
null);
584 UpdateInputCircles();
588 private void UpdateDebugBoolWidget(
string textWidgetName,
bool isTrue,
float time = 0)
590 TextWidget wTxt = TextWidget.Cast(m_wDebugRootWidget.FindAnyWidget(textWidgetName));
594 time = Math.Ceil(time * 10) * 0.1;
597 wTxt.SetColorInt(ARGB(255, 160, 210, 255));
599 wTxt.SetText(
"YES (" + time.ToString() +
")");
605 wTxt.SetColorInt(ARGB(255, 255, 160, 160));
607 wTxt.SetText(
"NO (" + time.ToString() +
")");
614 private void UpdateDebugUI()
622 UpdateInputCircles();
627 topSpeed = m_AnimComponent.GetTopSpeed(-1,
false);
629 Widget wCenter = m_wDebugRootWidget.FindAnyWidget(
"Center");
630 Widget wCenter2 = m_wDebugRootWidget.FindAnyWidget(
"Center2");
631 Widget wCenter3 = m_wDebugRootWidget.FindAnyWidget(
"Center3");
634 if (movementInput != vector.Zero)
636 float inputLength = movementInput.Length();
638 movementInput *= 1 / inputLength;
641 if (wCenter && wCenter2 && wCenter3 && topSpeed > 0)
643 float inputForward = movementInput[0];
644 float inputRight = movementInput[2];
646 float moveScale = maxSpeed / topSpeed;
647 float x = movementInput[0] * moveScale * 0.5 + 0.5;
648 float y = -movementInput[2] * moveScale * 0.5 + 0.5;
649 FrameSlot.SetAnchorMin(wCenter, x, y);
650 FrameSlot.SetAnchorMax(wCenter, x, y);
652 vector moveLocal = m_AnimComponent.GetInertiaSpeed();
653 x = (moveLocal[0] / topSpeed) * 0.5 + 0.5;
654 y = (-moveLocal[2] / topSpeed) * 0.5 + 0.5;
655 FrameSlot.SetAnchorMin(wCenter2, x, y);
656 FrameSlot.SetAnchorMax(wCenter2, x, y);
658 moveLocal = character.VectorToLocal(
GetVelocity());
659 x = (moveLocal[0] / topSpeed) * 0.5 + 0.5;
660 y = (-moveLocal[2] / topSpeed) * 0.5 + 0.5;
661 FrameSlot.SetAnchorMin(wCenter3, x, y);
662 FrameSlot.SetAnchorMax(wCenter3, x, y);
665 TextWidget wSpeed = TextWidget.Cast(m_wDebugRootWidget.FindAnyWidget(
"Speed"));
666 TextWidget wSpeed2 = TextWidget.Cast(m_wDebugRootWidget.FindAnyWidget(
"Speed2"));
667 if (wSpeed && wSpeed2)
669 float speed = Math.Ceil(m_AnimComponent.GetInertiaSpeed().Length() * 10) * 0.1;
670 wSpeed.SetText(speed.ToString() +
"m/s");
672 speed = Math.Ceil(
GetVelocity().Length() * 10) * 0.1;
673 wSpeed2.SetText(speed.ToString() +
"m/s");
676 TextWidget wAdjustedSpeed = TextWidget.Cast(m_wDebugRootWidget.FindAnyWidget(
"AdjustedSpeed"));
680 TextWidget wAdjustedStance = TextWidget.Cast(m_wDebugRootWidget.FindAnyWidget(
"AdjustedStance"));
691 TextWidget wMovementAngle = TextWidget.Cast(m_wDebugRootWidget.FindAnyWidget(
"MovementAngle"));
692 CharacterCommandHandlerComponent handler = m_AnimComponent.GetCommandHandler();
693 if (!wMovementAngle || !handler)
699 float currAngle = moveCmd.GetMovementSlopeAngle();
700 wMovementAngle.SetText(currAngle.ToString() +
"deg");
710 override void OnPrepareControls(IEntity owner, ActionManager am,
float dt,
bool player)
714 ChimeraCharacter character = ChimeraCharacter.Cast(owner);
715 CompartmentAccessComponent compAccess = character.GetCompartmentAccessComponent();
717 BaseCompartmentSlot compartment = compAccess.GetCompartment();
721 if (action && action.CanBePerformed(
GetOwner()))
723 action.PerformAction(compartment.GetOwner(),
GetOwner());
737 ChimeraCharacter character = ChimeraCharacter.Cast(owner);
738 CompartmentAccessComponent compAccess = character.GetCompartmentAccessComponent();
740 BaseCompartmentSlot compartment = compAccess.GetCompartment();
744 if (action && action.CanBePerformed(
GetOwner()))
746 action.PerformAction(compartment.GetOwner(),
GetOwner());
750 if (!action && compAccess.CanGetOutVehicle())
752 compAccess.GetOutVehicle(-1,
false);
759 float value = am.GetActionValue(
"CharacterRoll");
763 else if (value > 0.5)
769 else if (rollValue != 0)
782 if (System.IsCLIParam(
"CharacterDebugUI"))
783 m_bEnableDebugUI =
true;
785 if (!s_bDiagRegistered)
787 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_CHARACTER_MENU,
"",
"Enable Debug UI",
"Character");
788 DiagMenu.SetValue(
SCR_DebugMenuID.DEBUGUI_CHARACTER_MENU, m_bEnableDebugUI);
789 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_CHARACTER_NOBANKING,
"",
"Disable Banking",
"Character");
790 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_CHARACTER_TRANSFORMATION,
"",
"Enable transform info",
"Character");
791 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_CHARACTER_RECOIL_CAMERASHAKE_DISABLE,
"",
"Disable recoil cam shake",
"Character");
792 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_CHARACTER_ADDITIONAL_CAMERASHAKE_DISABLE,
"",
"Disable additional cam shake",
"Character");
793 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_CHARACTER_CAMERASHAKE_TEST_WINDOW,
"",
"Show shake diag",
"Character");
794 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_WEAPONS_ALLOW_INSPECTION_LOOKAT,
"",
"Inspection LookAt",
"Character");
795 s_bDiagRegistered =
true;
805 if (m_wDebugRootWidget)
814 void SetNextSightsFOVInfo(
int direction = 1,
bool allowCycling =
false)
824 if (!variableFovInfo)
828 variableFovInfo.SetNext(allowCycling);
830 variableFovInfo.SetPrevious(allowCycling);
839 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(
GetOwner());
843 TurretComponent turretComponent = TurretComponent.Cast(turret.FindComponent(TurretComponent));
845 turretComponent.SwitchNextSights();
847 turretComponent.SwitchPrevSights();
857 if (!weaponComponent)
861 weaponComponent.SwitchNextSights();
863 weaponComponent.SwitchPrevSights();
875 if (!weaponComponent)
878 BaseSightsComponent sightsComponent = weaponComponent.GetSights();
879 if (!sightsComponent)
882 return sightsComponent.GetFOVInfo();
891 GetGame().GetInputManager().AddActionListener(
"CharacterUnequipItem", EActionTrigger.DOWN, ActionUnequipItem);
892 GetGame().GetInputManager().AddActionListener(
"CharacterDropItem", EActionTrigger.DOWN, ActionDropItem);
893 GetGame().GetInputManager().AddActionListener(
"CharacterWeaponLowReady", EActionTrigger.DOWN, ActionWeaponLowReady);
894 GetGame().GetInputManager().AddActionListener(
"CharacterWeaponRaised", EActionTrigger.DOWN, ActionWeaponRaised);
895 GetGame().GetInputManager().AddActionListener(
"CharacterWeaponBipod", EActionTrigger.DOWN, ActionWeaponBipod);
899 GetGame().GetInputManager().AddActionListener(
"SwitchCameraType", EActionTrigger.DOWN,
m_CameraHandler.OnCameraSwitchPressed);
903 GetGame().GetInputManager().RemoveActionListener(
"CharacterUnequipItem", EActionTrigger.DOWN, ActionUnequipItem);
904 GetGame().GetInputManager().RemoveActionListener(
"CharacterDropItem", EActionTrigger.DOWN, ActionDropItem);
905 GetGame().GetInputManager().RemoveActionListener(
"CharacterWeaponLowReady", EActionTrigger.DOWN, ActionWeaponLowReady);
906 GetGame().GetInputManager().RemoveActionListener(
"CharacterWeaponRaised", EActionTrigger.DOWN, ActionWeaponRaised);
907 GetGame().GetInputManager().RemoveActionListener(
"CharacterWeaponBipod", EActionTrigger.DOWN, ActionWeaponBipod);
911 GetGame().GetInputManager().RemoveActionListener(
"SwitchCameraType", EActionTrigger.DOWN,
m_CameraHandler.OnCameraSwitchPressed);
914 m_OnControlledByPlayer.Invoke(owner, controlled);
917 SCR_CharacterInventoryStorageComponent pCharInvComponent = SCR_CharacterInventoryStorageComponent.Cast(owner.FindComponent(SCR_CharacterInventoryStorageComponent));
918 if (pCharInvComponent)
919 pCharInvComponent.InitAsPlayer(owner, controlled);
926 void ActionUnequipItem(
float value = 0.0, EActionTrigger trigger = 0)
928 SCR_InventoryStorageManagerComponent storageManager = SCR_InventoryStorageManagerComponent.Cast(
GetInventoryStorageManager());
932 SCR_CharacterInventoryStorageComponent storage = storageManager.GetCharacterStorage();
934 storage.UnequipCurrentItem();
941 void ActionDropItem(
float value = 0.0, EActionTrigger trigger = 0)
943 SCR_InventoryStorageManagerComponent storageManager = SCR_InventoryStorageManagerComponent.Cast(
GetInventoryStorageManager());
947 SCR_CharacterInventoryStorageComponent storage = storageManager.GetCharacterStorage();
949 storage.DropCurrentItem();
956 void ActionWeaponLowReady(
float value = 0.0, EActionTrigger trigger = 0)
972 void ActionWeaponRaised(
float value = 0.0, EActionTrigger trigger = 0)
985 void ActionWeaponBipod(
float value = 0.0, EActionTrigger trigger = 0)
992 if (!weapon || !weapon.HasBipod())
998 weapon.SetBipod(!weapon.GetBipod());
1002 protected override void OnInspectionModeChanged(
bool newState)
1004 m_bInspectionFocus = newState;
1007 protected int m_iTargetContext;
1010 protected override float GetInspectTargetLookAt(out vector targetAngles)
1013 if (!DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_WEAPONS_ALLOW_INSPECTION_LOOKAT))
1020 if (Debug.KeyState(KeyCode.KC_ADD))
1023 Debug.ClearKey(KeyCode.KC_ADD);
1024 m_bInspectionFocus =
true;
1027 if (Debug.KeyState(KeyCode.KC_SUBTRACT))
1030 Debug.ClearKey(KeyCode.KC_SUBTRACT);
1031 m_bInspectionFocus =
true;
1034 if (!m_bInspectionFocus)
1038 const float threshold = 0.001;
1039 if (Math.AbsFloat(aimChange[0]) > threshold || Math.AbsFloat(aimChange[1]) > threshold)
1041 m_bInspectionFocus =
false;
1049 SCR_InteractionHandlerComponent handler = SCR_InteractionHandlerComponent.Cast(
GetGame().
GetPlayerController().FindComponent(SCR_InteractionHandlerComponent));
1054 array<UserActionContext> contexts = {};
1056 array<IEntity> ents = handler.GetManualOverrideList(
null, tmp);
1057 ActionsManagerComponent ac;
1058 array<UserActionContext> buff;
1060 array<BaseUserAction> actions;
1061 foreach (IEntity e : ents)
1063 ac = ActionsManagerComponent.Cast(e.FindComponent(ActionsManagerComponent));
1068 int bc = ac.GetContextList(buff);
1069 for (
int i = 0; i < bc; ++i)
1072 if (ctx.GetActionsCount() == 0)
1076 int actionsCount = ctx.GetActionsList(actions);
1081 contexts.Insert(ctx);
1088 int nonEmptyCount = contexts.Count();
1089 m_iTargetContext = Math.Repeat(m_iTargetContext, nonEmptyCount);
1091 if (nonEmptyCount == 0)
1094 ctx = contexts[m_iTargetContext];
1095 vector contextPos = ctx.GetOrigin();
1098 vector targetDirection = contextPos -
GetCharacter().EyePosition();
1099 vector localTargetDirection =
GetCharacter().VectorToLocal( targetDirection );
1100 localTargetDirection.Normalize();
1102 float lookYaw = Math.Sin(localTargetDirection[0]) * Math.RAD2DEG;
1103 float lookPitch = Math.Sin(localTargetDirection[1]) * Math.RAD2DEG;
1108 targetAngles = Vector(lookYaw, lookPitch, 0) * Math.DEG2RAD;
1110 return 4.30 * Math.RAD2DEG ;
1117 return m_pScrInputContext;
1127 void StartLoitering(
int loiteringType,
bool holsterWeapon,
bool allowRootMotion,
bool alignToPosition, vector targetPosition[4] = {
"1 0 0",
"0 1 0",
"0 0 1",
"0 0 0" })
1136 if (scrCmdHandler.IsLoitering())
1139 m_pScrInputContext.m_iLoiteringType = loiteringType;
1140 m_pScrInputContext.m_iLoiteringShouldHolsterWeapon = holsterWeapon;
1141 m_pScrInputContext.m_bLoiteringShouldAlignCharacter = alignToPosition;
1142 m_pScrInputContext.m_mLoiteringPosition = targetPosition;
1143 m_pScrInputContext.m_bLoiteringRootMotion = allowRootMotion;
1148 if (alignToPosition)
1149 AlignToPositionFromCurrentPosition(targetPosition);
1151 TryStartLoiteringInternal();
1155 protected bool AlignToPositionFromCurrentPosition(vector targetPosition[4],
float toleranceXZ = 0.01,
float toleranceY = 0.01)
1160 vector currentTransform[4];
1163 if (headingComponent)
1164 headingComponent.AlignPosDirWS(currentTransform[3], currentTransform[2], targetPosition[3], targetPosition[2]);
1166 return vector.DistanceSqXZ(currentTransform[3], targetPosition[3]) < (toleranceXZ * toleranceXZ)
1167 && Math.AbsFloat(currentTransform[3][2] - targetPosition[3][2]) < toleranceY;
1171 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
1172 protected void Rpc_StartLoitering_S(
int loiteringType,
bool holsterWeapon,
bool allowRootMotion,
bool alignToPosition, vector targetPosition[4])
1174 m_pScrInputContext.m_iLoiteringType = loiteringType;
1175 m_pScrInputContext.m_iLoiteringShouldHolsterWeapon = holsterWeapon;
1176 m_pScrInputContext.m_bLoiteringShouldAlignCharacter = alignToPosition;
1177 m_pScrInputContext.m_mLoiteringPosition = targetPosition;
1178 m_pScrInputContext.m_bLoiteringRootMotion = allowRootMotion;
1181 scrCmdHandler.StartCommandLoitering();
1185 protected bool TryStartLoiteringInternal()
1197 if (headingComponent && headingComponent.IsAligning())
1199 if (AlignToPositionFromCurrentPosition(GetScrInputContext().m_mLoiteringPosition, 0.02, 0.3))
1204 scrCmdHandler.StartCommandLoitering();
1207 Rpc(Rpc_StartLoitering_S,
1208 m_pScrInputContext.m_iLoiteringType,
1209 m_pScrInputContext.m_iLoiteringShouldHolsterWeapon,
1210 m_pScrInputContext.m_bLoiteringRootMotion,
1211 m_pScrInputContext.m_bLoiteringShouldAlignCharacter,
1212 m_pScrInputContext.m_mLoiteringPosition);
1220 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
1221 void RPC_StopLoitering_S(
bool terminateFast)
1224 Print(
"Called RPC_StopLoitering_S on a proxy.", LogLevel.ERROR);
1227 scrCmdHandler.StopLoitering(terminateFast);
1234 void StopLoitering(
bool terminateFast)
1240 scrCmdHandler.StopLoitering(terminateFast);
1243 Rpc(RPC_StopLoitering_S, terminateFast);
1253 return handler.IsLoitering();
1257 enum ECharacterGestures
1260 POINT_WITH_FINGER = 1