Advertisement
Guest User

Untitled

a guest
Mar 16th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 75.37 KB | None | 0 0
  1. /***********************************************************************/
  2. /** © 2015 CD PROJEKT S.A. All rights reserved.
  3. /** THE WITCHER® is a trademark of CD PROJEKT S. A.
  4. /** The Witcher game is based on the prose of Andrzej Sapkowski.
  5. /***********************************************************************/
  6.  
  7.  
  8.  
  9.  
  10. enum ECustomCameraType
  11. {
  12. CCT_None,
  13. CCT_CustomController,
  14. CCT_RotatedToTarget_OverShoulder,
  15. CCT_RotatedToTarget_Medium,
  16. }
  17.  
  18. enum ECustomCameraController
  19. {
  20. CCC_NoTarget,
  21. CCC_Target_Interior,
  22. CCC_Target,
  23. }
  24.  
  25. struct SCustomCameraParams
  26. {
  27. var source : CActor;
  28. var useCustomCamera : bool;
  29. var cameraParams : SMultiValue;
  30. }
  31.  
  32. struct SCustomOrientationParams
  33. {
  34. var source : CActor;
  35. var customOrientationTarget : EOrientationTarget;
  36. }
  37.  
  38. state Combat in CR4Player extends ExtendedMovable
  39. {
  40. protected var comboDefinition : CComboDefinition;
  41. public var comboPlayer : CComboPlayer;
  42.  
  43. protected var updatePosition : bool;
  44.  
  45. private var bIsSwitchingDirection : bool;
  46. protected var currentWeapon : EPlayerWeapon;
  47.  
  48. private var comboAttackA_Id : int;
  49. private var comboAttackA_Target : CGameplayEntity;
  50. private var comboAttackA_Sliding : bool;
  51.  
  52. private var comboAttackB_Id : int;
  53. private var comboAttackB_Target : CGameplayEntity;
  54. private var comboAttackB_Sliding : bool;
  55.  
  56. private var comboAspectName : name;
  57.  
  58. private var enemiesInRange : array<CActor>;
  59. private var positionWeightsDest : array<float>;
  60. private var positionWeights : array<float>;
  61. private var positionVelocity : array<float>;
  62. private var positionWeightDamper : SpringDamper;
  63.  
  64. private var dodgeDirection : EPlayerEvadeDirection;
  65.  
  66. default comboAttackA_Id = -1;
  67. default comboAttackB_Id = -1;
  68.  
  69. private var zoomOutForApproachingAttacker : bool;
  70.  
  71. private var slideDistanceOffset : float;
  72.  
  73. default slideDistanceOffset = 0.1f;
  74.  
  75. protected var startupAction : EInitialAction;
  76. protected var startupBuff : CBaseGameplayEffect;
  77. protected var isInCriticalState : bool;
  78.  
  79.  
  80. private var realCombat : bool;
  81. private var lastVitality : float;
  82.  
  83. private var timeToCheckCombatEndCur : float;
  84. private var timeToCheckCombatEndMax : float; default timeToCheckCombatEndMax = 0.5f;
  85.  
  86.  
  87. private var timeToExitCombatFromSprinting : float; default timeToExitCombatFromSprinting = 2.0f;
  88.  
  89. public function SetupState( initialAction : EInitialAction, optional initialBuff : CBaseGameplayEffect )
  90. {
  91. startupAction = initialAction;
  92. startupBuff = initialBuff;
  93. }
  94.  
  95.  
  96.  
  97.  
  98. event OnEnterState( prevStateName : name )
  99. {
  100. var i : int;
  101.  
  102. parent.AddAnimEventCallback('AllowInput', 'OnAnimEvent_AllowInput');
  103. parent.AddAnimEventCallback('AllowRoll', 'OnAnimEvent_AllowRoll');
  104. parent.AddAnimEventCallback('ForceAttack', 'OnAnimEvent_ForceAttack');
  105. parent.AddAnimEventCallback('PunchHand_Left', 'OnAnimEvent_PunchHand');
  106. parent.AddAnimEventCallback('PunchHand_Right', 'OnAnimEvent_PunchHand');
  107.  
  108. super.OnEnterState(prevStateName);
  109.  
  110.  
  111.  
  112. parent.AddTimer( 'CombatComboUpdate', 0, true, false, TICK_PrePhysics );
  113. parent.AddTimer( 'CombatEndCheck', 0.1f, true );
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120. parent.SetBehaviorMimicVariable( 'gameplayMimicsMode', (float)(int)PGMM_Combat );
  121.  
  122. CombatInit();
  123.  
  124. theTelemetry.LogWithName(TE_STATE_COMBAT);
  125.  
  126. StatsInit();
  127. }
  128.  
  129. function StatsInit()
  130. {
  131. realCombat = thePlayer.IsInCombat();
  132. lastVitality = thePlayer.GetStat(BCS_Vitality);
  133. }
  134.  
  135. event OnLeaveState( nextStateName : name )
  136. {
  137. var skillAbilityName : name;
  138.  
  139.  
  140. super.OnLeaveState(nextStateName);
  141.  
  142. parent.RemoveTimer( 'CombatComboUpdate' );
  143. parent.RemoveTimer( 'CombatEndCheck' );
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150. if ( nextStateName != 'AimThrow' )
  151. OnCombatActionEndComplete();
  152.  
  153.  
  154.  
  155. if ( nextStateName != 'CombatFocusMode_SelectSpot' )
  156. {
  157. if ( comboPlayer )
  158. {
  159. comboPlayer.Deinit();
  160. }
  161. }
  162.  
  163.  
  164.  
  165.  
  166.  
  167. parent.SetInteractionPriority( IP_Prio_0 );
  168.  
  169. CleanUpComboStuff();
  170.  
  171.  
  172. skillAbilityName = SkillEnumToName(S_Alchemy_s17);
  173. while(thePlayer.HasAbility(skillAbilityName))
  174. thePlayer.RemoveAbility(skillAbilityName);
  175. }
  176.  
  177. event OnStateCanGoToCombat()
  178. {
  179. return true;
  180. }
  181.  
  182.  
  183. entry function CombatInit()
  184. {
  185. var camera : CCustomCamera = theGame.GetGameCamera();
  186.  
  187. camera.ChangePivotPositionController( 'Default' );
  188.  
  189.  
  190.  
  191. parent.AddTimer( 'CombatLoop', 0, true );
  192.  
  193. }
  194.  
  195. timer function CombatLoop( timeDelta : float , id : int)
  196. {
  197. ProcessPlayerOrientation();
  198. ProcessPlayerCombatStance();
  199.  
  200. parent.GetVisualDebug().AddArrow( 'heading3', parent.GetWorldPosition(), parent.GetWorldPosition() + VecFromHeading( parent.cachedRawPlayerHeading ), 1.f, 0.2f, 0.2f, true, Color(255,0,255), true );
  201.  
  202.  
  203. UpdateIsInAir();
  204.  
  205. StatsUpdate();
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214. }
  215.  
  216. private function UpdateIsInAir()
  217. {
  218. var mac : CMovingPhysicalAgentComponent;
  219. var isInGround : bool;
  220.  
  221.  
  222.  
  223. if( thePlayer.IsRagdolled() )
  224. {
  225. return;
  226. }
  227.  
  228. mac = ( CMovingPhysicalAgentComponent ) thePlayer.GetMovingAgentComponent();
  229. if( mac )
  230. {
  231. isInGround = mac.IsOnGround();
  232. thePlayer.SetIsInAir( !isInGround );
  233. }
  234. }
  235.  
  236. function StatsUpdate()
  237. {
  238. var curVitality : float;
  239.  
  240. curVitality = thePlayer.GetStat(BCS_Vitality);
  241. lastVitality = curVitality;
  242. }
  243.  
  244. timer function CombatEndCheck( timeDelta : float , id : int)
  245. {
  246.  
  247. if( !parent.IsInCombat() )
  248. {
  249. if( timeToCheckCombatEndCur < 0.0f )
  250. {
  251. // W3EE - Begin
  252. if( !parent.IsGuarded() )
  253. {
  254. parent.GoToExplorationIfNeeded();
  255. }
  256. // W3EE - End
  257. }
  258. else
  259. {
  260. timeToCheckCombatEndCur -= timeDelta;
  261. }
  262. }
  263. else
  264. {
  265. timeToCheckCombatEndCur = timeToCheckCombatEndMax;
  266. }
  267. }
  268.  
  269. public function ResetTimeToEndCombat()
  270. {
  271. timeToCheckCombatEndCur = timeToCheckCombatEndMax;
  272. }
  273.  
  274. event OnCombatActionEnd()
  275. {
  276. virtual_parent.OnCombatActionEnd();
  277.  
  278. }
  279.  
  280.  
  281. var cFMCameraZoomIsEnabled : bool;
  282.  
  283. event OnCFMCameraZoomFail()
  284. {
  285. CFMCameraZoomFail();
  286. }
  287.  
  288. entry function CFMCameraZoomFail()
  289. {
  290. var camera : CCustomCamera = theGame.GetGameCamera();
  291. var animation : SCameraAnimationDefinition;
  292.  
  293. animation.animation = 'camera_combat_focus_fail';
  294. animation.priority = CAP_Highest;
  295. animation.blendIn = 0.1f;
  296. animation.blendOut = 0.1f;
  297. animation.weight = 1.f;
  298. animation.speed = 1.0f;
  299. animation.loop = false;
  300. animation.additive = true;
  301. animation.reset = true;
  302.  
  303. camera.PlayAnimation( animation );
  304. }
  305.  
  306. event OnGameCameraTick( out moveData : SCameraMovementData, dt : float )
  307. {
  308.  
  309.  
  310. if( super.OnGameCameraTick( moveData, dt ) )
  311. {
  312. return true;
  313. }
  314. if( thePlayer.IsFistFightMinigameEnabled() )
  315. {
  316. theGame.GetGameCamera().ChangePivotRotationController( 'Exploration' );
  317. theGame.GetGameCamera().ChangePivotDistanceController( 'Default' );
  318. theGame.GetGameCamera().ChangePivotPositionController( 'Default' );
  319.  
  320. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  321. moveData.pivotDistanceController = theGame.GetGameCamera().GetActivePivotDistanceController();
  322. moveData.pivotPositionController = theGame.GetGameCamera().GetActivePivotPositionController();
  323.  
  324. moveData.pivotPositionController.SetDesiredPosition( thePlayer.GetWorldPosition() );
  325. moveData.pivotRotationController.SetDesiredPitch( -10.0f );
  326. moveData.pivotRotationController.maxPitch = 50.0;
  327. moveData.pivotDistanceController.SetDesiredDistance( 3.5f );
  328. moveData.pivotPositionController.offsetZ = 1.3f;
  329.  
  330. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( 1.0f, 2.0f, 0), 0.3f, dt );
  331. moveData.pivotRotationController.SetDesiredHeading( VecHeading( parent.GetDisplayTarget().GetWorldPosition() - parent.GetWorldPosition() ) + 60.0f, 0.5f );
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339. }
  340. else if ( thePlayer.GetFlyingBossCamera() )
  341. {
  342. theGame.GetGameCamera().SetManualRotationVerTimeout( 99999 );
  343. }
  344.  
  345. if ( parent.IsThreatened() || parent.GetPlayerMode().GetForceCombatMode() )
  346. {
  347. theGame.GetGameCamera().ChangePivotDistanceController( 'ScriptedCombat' );
  348.  
  349. moveData.pivotDistanceController = theGame.GetGameCamera().GetActivePivotDistanceController();
  350.  
  351. }
  352.  
  353. return false;
  354. }
  355.  
  356.  
  357. event OnGameCameraPostTick( out moveData : SCameraMovementData, dt : float )
  358. {
  359. var enemies : array<CActor> = parent.GetMoveTargets();
  360. var buff : CBaseGameplayEffect;
  361. var targetCapsuleHeight : float;
  362. var offset : float;
  363. var playerToTargetVector : Vector;
  364.  
  365.  
  366.  
  367. if( parent.movementLockType == PMLT_NoRun && !GetWitcherPlayer().HasBuff( EET_Mutation11Immortal ) )
  368. {
  369. //ImmersiveCam++
  370. if( parent.ic.comLock )
  371. {
  372. UpdateCameraLockedCombat( moveData, dt );
  373. return true;
  374. }
  375. //ImmersiveCam--
  376. else if ( enemies.Size() == 1 )
  377. {
  378. if ( parent.IsCombatMusicEnabled() || parent.GetPlayerMode().GetForceCombatMode() )
  379. UpdateCameraInterior( moveData, dt );
  380. else
  381. parent.UpdateCameraInterior( moveData, dt );
  382.  
  383. return true;
  384. }
  385. else if ( !parent.IsCombatMusicEnabled() && !parent.IsInCombatAction() )
  386. {
  387. parent.UpdateCameraInterior( moveData, dt );
  388. return true;
  389. }
  390. }
  391.  
  392. buff = parent.GetCurrentlyAnimatedCS();
  393. if ( ( ( parent.IsInCombatAction() || buff ) && ( !parent.IsInCombat() || !( parent.moveTarget && parent.moveTarget.IsAlive() && parent.IsThreat( parent.moveTarget ) ) ) )
  394. || ( parent.GetPlayerCombatStance() == PCS_AlertFar && !thePlayer.GetFlyingBossCamera() ) )
  395. parent.UpdateCameraCombatActionButNotInCombat( moveData, dt );
  396.  
  397. if ( !parent.IsInCombatAction() )
  398. virtual_parent.UpdateCameraSprint( moveData, dt );
  399.  
  400. if ( virtual_parent.UpdateCameraForSpecialAttack( moveData, dt ) )
  401. return true;
  402.  
  403. if ( ( parent.IsCameraLockedToTarget() ) && !cameraChanneledSignEnabled )
  404. {
  405. UpdateCameraInterior( moveData, dt );
  406. return true;
  407. }
  408. // ImmersiveCam++
  409. else if( parent.ic.comLock )
  410. {
  411. UpdateCameraLockedCombat( moveData, dt );
  412. return true;
  413. }
  414. //ImmersiveCam--
  415. if ( parent.GetPlayerCombatStance() == PCS_AlertNear )
  416. {
  417. if ( enemies.Size() <= 1 && parent.moveTarget)
  418. {
  419. targetCapsuleHeight = ( (CMovingPhysicalAgentComponent)parent.moveTarget.GetMovingAgentComponent() ).GetCapsuleHeight();
  420. if ( targetCapsuleHeight > 2.f )
  421. {
  422. playerToTargetVector = parent.moveTarget.GetWorldPosition() - parent.GetWorldPosition();
  423. offset = ( 2 - ( targetCapsuleHeight + playerToTargetVector.Z ) )/(-2);
  424. offset = ClampF( offset, 0.f, 1.f );
  425. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( moveData.cameraLocalSpaceOffset.X, moveData.cameraLocalSpaceOffset.Y, moveData.cameraLocalSpaceOffset.Z + offset ), 1.f, dt );
  426. }
  427. }
  428. }
  429.  
  430. super.OnGameCameraPostTick( moveData, dt );
  431. }
  432.  
  433. //ImmersiveCam++
  434. protected function UpdateCameraLockedCombat( out moveData : SCameraMovementData, timeDelta : float )
  435. {
  436. theGame.GetGameCamera().ChangePivotRotationController( 'CombatInterior' );
  437. theGame.GetGameCamera().ChangePivotDistanceController( 'Default' );
  438. theGame.GetGameCamera().ChangePivotPositionController( 'Default' );
  439.  
  440. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  441. moveData.pivotDistanceController = theGame.GetGameCamera().GetActivePivotDistanceController();
  442. moveData.pivotPositionController = theGame.GetGameCamera().GetActivePivotPositionController();
  443.  
  444. moveData.pivotPositionController.SetDesiredPosition( parent.GetWorldPosition(), interiorCameraDesiredPositionMult);
  445. moveData.pivotDistanceController.SetDesiredDistance( 3.30f );
  446.  
  447. moveData.pivotPositionController.offsetZ = 1.50f;
  448. }
  449. //ImmersiveCam--
  450.  
  451. private function ProcessPlayerOrientation()
  452. {
  453. var newOrientationTarget : EOrientationTarget;
  454. var customOrientationInfo : SCustomOrientationInfo;
  455. var customOrientationTarget : EOrientationTarget;
  456.  
  457. if ( parent.GetCustomOrientationTarget( customOrientationInfo ) )
  458. customOrientationTarget = customOrientationInfo.orientationTarget;
  459. else
  460. customOrientationTarget = OT_None;
  461.  
  462. if ( parent.moveTarget )
  463. {
  464. if ( parent.moveTarget.GetGameplayVisibility() )
  465. newOrientationTarget = OT_Actor;
  466. else if ( parent.playerMoveType > PMT_Idle )
  467. newOrientationTarget = OT_Camera;
  468. else
  469. newOrientationTarget = OT_Player;
  470. }
  471. else if ( parent.IsCastingSign() && !parent.IsInCombat() )
  472. newOrientationTarget = OT_CameraOffset;
  473.  
  474.  
  475. else
  476. newOrientationTarget = OT_Player;
  477.  
  478.  
  479.  
  480.  
  481. if ( parent.IsGuarded() )
  482. {
  483. if( parent.moveTarget )
  484. {
  485. if ( VecDistance( parent.moveTarget.GetWorldPosition(), parent.GetWorldPosition() ) > parent.findMoveTargetDist )
  486. newOrientationTarget = OT_Camera;
  487. }
  488. else if ( !parent.delayOrientationChange )
  489. newOrientationTarget = OT_Camera;
  490. }
  491.  
  492.  
  493.  
  494.  
  495. if ( parent.IsThrowingItemWithAim() )
  496. newOrientationTarget = OT_CameraOffset;
  497.  
  498. if ( customOrientationTarget != OT_None )
  499. newOrientationTarget = customOrientationTarget;
  500.  
  501. if ( parent.delayOrientationChange )
  502. newOrientationTarget = parent.GetOrientationTarget();
  503.  
  504. if ( newOrientationTarget != parent.GetOrientationTarget() )
  505. parent.SetOrientationTarget( newOrientationTarget );
  506. }
  507.  
  508. protected function ProcessPlayerCombatStance()
  509. {
  510. var targetCapsuleHeight : float;
  511. var stance : EPlayerCombatStance;
  512. var playerToTargetVector : Vector;
  513. var playerToTargetDist : float;
  514. var wasVisibleInCam : bool;
  515. var moveTargetNPC : CNewNPC;
  516.  
  517.  
  518. if( GetWitcherPlayer() && GetWitcherPlayer().HasBuff( EET_Mutation11Buff ) )
  519. {
  520. return;
  521. }
  522.  
  523. parent.findMoveTargetDistMin = 10.f;
  524. moveTargetNPC = (CNewNPC)(parent.moveTarget);
  525. if ( virtual_parent.GetPlayerCombatStance() == PCS_AlertNear || virtual_parent.GetPlayerCombatStance() == PCS_AlertFar )
  526. parent.findMoveTargetDist = parent.findMoveTargetDistMax;
  527. else
  528. parent.findMoveTargetDist = parent.findMoveTargetDistMin;
  529.  
  530. if ( parent.moveTarget
  531. && moveTargetNPC.GetCurrentStance() != NS_Fly
  532.  
  533. && parent.enableStrafe
  534. && parent.IsThreat( parent.moveTarget )
  535. && parent.IsEnemyVisible( parent.moveTarget ) )
  536. {
  537. playerToTargetVector = parent.moveTarget.GetNearestPointInPersonalSpace( parent.GetWorldPosition() ) - parent.GetWorldPosition();
  538. playerToTargetDist = VecLength( playerToTargetVector );
  539. if ( playerToTargetDist <= parent.findMoveTargetDist )
  540. {
  541. stance = PCS_AlertNear;
  542. }
  543. else
  544. {
  545. if ( parent.findMoveTargetDist <= parent.findMoveTargetDistMin )
  546. {
  547. targetCapsuleHeight = ( (CMovingPhysicalAgentComponent)parent.moveTarget.GetMovingAgentComponent() ).GetCapsuleHeight();
  548. if ( targetCapsuleHeight > 2.f )
  549. {
  550. parent.findMoveTargetDistMin = 15.f;
  551. parent.findMoveTargetDist = parent.findMoveTargetDistMin;
  552.  
  553. if ( playerToTargetDist <= parent.findMoveTargetDist )
  554. {
  555. stance = PCS_AlertNear;
  556. }
  557. else
  558. {
  559. stance = PCS_AlertFar;
  560. }
  561. }
  562. else
  563. {
  564. stance = PCS_AlertFar;
  565. }
  566. }
  567. else
  568. {
  569. stance = PCS_AlertNear;
  570. }
  571. }
  572. }
  573. else if ( moveTargetNPC && moveTargetNPC.GetCurrentStance() == NS_Fly )
  574. {
  575. if ( AbsF( playerToTargetVector.Z ) < 25 && VecLength2D( playerToTargetVector ) < parent.findMoveTargetDist * 2.f )
  576. {
  577. stance = PCS_AlertNear;
  578. }
  579. else
  580. {
  581. stance = PCS_AlertFar;
  582. }
  583. }
  584. else if ( parent.IsCastingSign() && !parent.IsInCombat() )
  585. stance = PCS_Normal;
  586. else
  587. stance = virtual_parent.GetPlayerCombatStance();
  588.  
  589.  
  590.  
  591.  
  592. if ( !parent.IsEnemyVisible( parent.moveTarget ) )
  593. {
  594. if ( virtual_parent.GetPlayerCombatStance() == PCS_AlertNear || parent.IsInCombat() )
  595. {
  596. stance = PCS_AlertFar;
  597. }
  598. }
  599.  
  600.  
  601. if ( thePlayer.GetFlyingBossCamera() )
  602. {
  603. stance = PCS_AlertNear;
  604. }
  605.  
  606. if ( parent.IsGuarded() )
  607. stance = PCS_Guarded;
  608. else if ( stance == PCS_Guarded )
  609. {
  610. stance = PCS_AlertFar;
  611. //BlockWhenYouWant++
  612. else if ( !parent.IsThreatened() )
  613. stance = PCS_Normal;
  614.  
  615. else if( FactsQuerySum("force_stance_normal") > 0 )
  616. {
  617. stance = PCS_Normal;
  618. }
  619. //BlockWhenYouWant--
  620.  
  621. // W3EE - Begin
  622. if( !Options().CombatState() )
  623. stance = PCS_Normal;
  624. // W3EE - End
  625.  
  626. if ( virtual_parent.GetPlayerCombatStance() == PCS_AlertNear && stance != PCS_AlertNear && stance != PCS_Guarded )
  627. {
  628. if ( !parent.IsEnemyVisible( parent.moveTarget ) && playerToTargetDist <= parent.findMoveTargetDist )
  629. DisableCombatStance( 5.f, stance );
  630. else
  631. SetStance( stance );
  632. }
  633. else
  634. SetStance( stance );
  635. }
  636.  
  637. var cachedStance : EPlayerCombatStance;
  638. var disableCombatStanceTimer : bool;
  639. protected function DisableCombatStance( timeDelta : float, stance : EPlayerCombatStance )
  640. {
  641. cachedStance = stance;
  642. if ( !disableCombatStanceTimer )
  643. {
  644. disableCombatStanceTimer = true;
  645. parent.AddTimer( 'DisableCombatStanceTimer', timeDelta );
  646. }
  647. }
  648.  
  649. private timer function DisableCombatStanceTimer( timeDelta : float , id : int)
  650. {
  651. SetStance( cachedStance );
  652. }
  653.  
  654. protected function SetStance( stance : EPlayerCombatStance )
  655. {
  656. parent.RemoveTimer( 'DisableCombatStanceTimer' );
  657. disableCombatStanceTimer = false;
  658.  
  659.  
  660. virtual_parent.SetPlayerCombatStance( stance );
  661.  
  662. if ( stance == PCS_AlertNear || stance == PCS_Guarded )
  663. {
  664. parent.RestoreOriginalInteractionPriority();
  665. parent.SetScriptMoveTarget( parent.moveTarget );
  666. }
  667. else
  668. {
  669. parent.SetInteractionPriority( IP_Prio_0 );
  670. parent.SetScriptMoveTarget( NULL );
  671. }
  672. }
  673.  
  674.  
  675.  
  676. event OnAnimEvent_AllowInput( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  677. {
  678. if (!parent.GetBIsCombatActionAllowed() && !parent.IsActorLockedToTarget() )
  679. {
  680. if ( animEventType == AET_DurationStart )
  681. {
  682. parent.EnableFindTarget( true );
  683. }
  684. }
  685. virtual_parent.OnAnimEvent_AllowInput(animEventName,animEventType,animInfo);
  686. }
  687.  
  688. event OnAnimEvent_AllowRoll( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  689. {
  690. if ( animEventType == AET_DurationEnd )
  691. {
  692. parent.bIsRollAllowed = false;
  693. }
  694. }
  695.  
  696. event OnAnimEvent_ForceAttack( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  697. {
  698. parent.RemoveTimer( 'ProcessAttackTimer' );
  699. ProcessAttack( cachedPlayerAttackType, true );
  700. }
  701.  
  702. event OnAnimEvent_PunchHand( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  703. {
  704. if ( animEventName == 'PunchHand_Left' )
  705. {
  706. parent.SetBehaviorVariable( 'punchHand', 0.0f );
  707. }
  708. else if ( animEventName == 'PunchHand_Right' )
  709. {
  710. parent.SetBehaviorVariable( 'punchHand', 1.0f );
  711. }
  712. }
  713.  
  714.  
  715. event OnPreAttackEvent(animEventName : name, animEventType : EAnimationEventType, data : CPreAttackEventData, animInfo : SAnimationEventAnimInfo )
  716. {
  717. var res : bool;
  718. var weaponEntity : CItemEntity;
  719. var aerondight : W3Effect_Aerondight;
  720. var weaponId : SItemUniqueId;
  721.  
  722. // W3EE - Begin
  723. if( Combat().SeveranceRunewordRangeExtension() )
  724. {
  725. if( data.attackName == 'attack_heavy_special' )
  726. {
  727. data.rangeName = 'runeword2_heavy';
  728. weaponEntity = thePlayer.inv.GetItemEntityUnsafe(thePlayer.inv.GetItemFromSlot(data.weaponSlot));
  729. weaponEntity.PlayEffectSingle('heavy_trail_extended_fx');
  730. }
  731. else if( data.attackName == 'attack_light_special' )
  732. {
  733. data.rangeName = 'runeword2_light';
  734. weaponEntity = thePlayer.inv.GetItemEntityUnsafe(thePlayer.inv.GetItemFromSlot(data.weaponSlot));
  735. weaponEntity.PlayEffectSingle('light_trail_extended_fx');
  736. }
  737. }
  738. else if( parent.HasAbility( 'Runeword 11 _Stats', true ) && (W3PlayerWitcher)parent )
  739. {
  740. weaponEntity = thePlayer.inv.GetItemEntityUnsafe(thePlayer.inv.GetItemFromSlot(data.weaponSlot));
  741. weaponEntity.PlayEffect('bereavement_trail');
  742. }
  743. else if( (parent.HasAbility( 'Runeword 10 _Stats', true ) || parent.HasAbility( 'Runeword 4 _Stats', true )) && (W3PlayerWitcher)parent )
  744. {
  745. weaponEntity = thePlayer.inv.GetItemEntityUnsafe(thePlayer.inv.GetItemFromSlot(data.weaponSlot));
  746. weaponEntity.PlayEffectSingle('runeword1_fire_trail');
  747. }
  748. /*
  749. else if(parent.HasAbility('Runeword 1 _Stats', true) && (W3PlayerWitcher)parent && GetWitcherPlayer().GetRunewordInfusionType() == ST_Igni)
  750. {
  751. weaponEntity = thePlayer.inv.GetItemEntityUnsafe(thePlayer.inv.GetItemFromSlot(data.weaponSlot));
  752. weaponEntity.PlayEffectSingle('runeword1_fire_trail');
  753. }
  754. */
  755. // W3EE - End
  756. else if( parent.HasBuff( EET_Aerondight ) )
  757. {
  758. weaponId = thePlayer.inv.GetCurrentlyHeldSword();
  759. if( thePlayer.inv.ItemHasTag( weaponId, 'Aerondight' ) )
  760. {
  761. aerondight = (W3Effect_Aerondight)thePlayer.GetBuff( EET_Aerondight );
  762.  
  763. if( aerondight.IsFullyCharged() )
  764. {
  765. weaponEntity.PlayEffectSingle( 'aerondight_special_trail' );
  766. }
  767. }
  768. }
  769.  
  770. res = virtual_parent.OnPreAttackEvent( animEventName, animEventType, data, animInfo );
  771.  
  772. if ( animEventType == AET_DurationEnd && parent.HasHitTarget() )
  773. {
  774. comboPlayer.PlayHit();
  775. }
  776. return res;
  777. }
  778.  
  779. event OnPerformGuard()
  780. {
  781. OnInterruptAttack();
  782.  
  783.  
  784.  
  785. }
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792. event OnPerformEvade( playerEvadeType : EPlayerEvadeType )
  793. {
  794. if ( playerEvadeType == PET_Dodge )
  795. {
  796. parent.bIsRollAllowed = true;
  797. PerformEvade( PET_Dodge, false);
  798. }
  799. else if ( playerEvadeType == PET_Roll )
  800. {
  801. PerformEvade( PET_Dodge, true);
  802. }
  803.  
  804.  
  805. }
  806.  
  807. var evadeTarget : CActor;
  808. var wasLockedToTarget : bool;
  809. var angle : float;
  810. var cachedDodgeDirection : EPlayerEvadeDirection;
  811. var prevRawLeftJoyRot : float ;
  812. var evadeTargetPos : Vector;
  813. var cachedRawDodgeHeading : float;
  814. var turnInPlaceBeforeDodge : bool;
  815. entry function PerformEvade( playerEvadeType : EPlayerEvadeType, isRolling : bool )
  816. {
  817. // ImmersiveCam++
  818. var ic : icControl;
  819. // ImmersiveCam--
  820.  
  821. var rawDodgeHeading : float;
  822. var predictedDodgePos : Vector;
  823. var lineWidth : float;
  824. var noCreatureOnLine : bool;
  825.  
  826. var tracePosFrom : Vector;
  827. var playerToTargetRot : EulerAngles;
  828. var predictedDodgePosNormal : Vector;
  829. var dodgeNum : float;
  830. var randNum : int;
  831. var randMax : int;
  832. var i : int;
  833. var submergeDepth : float;
  834.  
  835. var dodgeLength : float;
  836. var intersectPoint : Vector;
  837. var intersectLength : float;
  838. var playerToPoint : float;
  839.  
  840. var moveTargets : array<CActor>;
  841. var playerToTargetAngleDiff : float;
  842. var playerToRawAngleDiff : float;
  843. var playerToCamAngleDiff : float;
  844.  
  845. var targetCapsuleRadius : float;
  846. var perkStats : SAbilityAttributeValue;
  847.  
  848. // ImmersiveCam++
  849. ic = thePlayer.ic;
  850. // ImmersiveCam--
  851.  
  852. parent.ResetUninterruptedHitsCount();
  853. parent.SetIsCurrentlyDodging(true, isRolling);
  854.  
  855. parent.RemoveTimer( 'UpdateDodgeInfoTimer' );
  856.  
  857. // ImmersiveCam++
  858. if ( ic.critSloMoCam )
  859. ic.Init(,,isRolling, evadeTarget);
  860. // ImmersiveCam--
  861. if ( parent.IsHardLockEnabled() && parent.GetTarget() )
  862. evadeTarget = parent.GetTarget();
  863. else
  864. {
  865. parent.FindMoveTarget();
  866. evadeTarget = parent.moveTarget;
  867. }
  868.  
  869.  
  870.  
  871.  
  872. if ( isRolling )
  873. {
  874. dodgeLength = 6.5f;
  875. }
  876. else
  877. {
  878. if ( parent.GetCurrentStateName() == 'CombatFists' )
  879. dodgeLength = 3.f;
  880. else
  881. dodgeLength = 3.5f;
  882. }
  883.  
  884. intersectLength = dodgeLength * 0.75;
  885.  
  886. evadeTargetPos = evadeTarget.PredictWorldPosition( 0.4f );
  887.  
  888. dodgeDirection = GetEvadeDirection( playerEvadeType );
  889. rawDodgeHeading = GetRawDodgeHeading();
  890. parent.evadeHeading = rawDodgeHeading;
  891.  
  892.  
  893. predictedDodgePos = VecFromHeading( rawDodgeHeading ) * dodgeLength + parent.GetWorldPosition();
  894. parent.GetVisualDebug().AddSphere('predictedDodgePos', 0.25, predictedDodgePos, true, Color(0,128,256), 5.0f );
  895. parent.GetVisualDebug().AddSphere('evadeTargetPos', 0.25, evadeTargetPos, true, Color(255,255,0), 5.0f );
  896. parent.GetVisualDebug().AddArrow( 'DodgeVector', parent.GetWorldPosition(), predictedDodgePos, 1.f, 0.2f, 0.2f, true, Color(0,128,256), true, 5.f );
  897.  
  898. turnInPlaceBeforeDodge = false;
  899.  
  900.  
  901. if ( evadeTarget )
  902. {
  903. intersectPoint = VecFromHeading( rawDodgeHeading ) * VecDot( VecFromHeading( rawDodgeHeading ), evadeTargetPos - parent.GetWorldPosition() ) + parent.GetWorldPosition();
  904. parent.GetVisualDebug().AddArrow( 'DodgeVector', parent.GetWorldPosition(), VecFromHeading( rawDodgeHeading ) * intersectLength + parent.GetWorldPosition(), 1.f, 0.2f, 0.2f, true, Color(0,128,256), true, 5.f );
  905. parent.GetVisualDebug().AddArrow( 'DodgeVector2', intersectPoint, evadeTargetPos, 1.f, 0.2f, 0.2f, true, Color(0,128,256), true, 5.f );
  906. moveTargets = parent.GetMoveTargets();
  907.  
  908. playerToTargetAngleDiff = AbsF( AngleDistance( parent.GetHeading(), VecHeading( evadeTargetPos - parent.GetWorldPosition() ) ) );
  909. playerToRawAngleDiff = AbsF( AngleDistance( rawDodgeHeading, parent.GetHeading() ) );
  910.  
  911. if ( parent.playerMoveType == PMT_Run || ( parent.playerMoveType > PMT_Run && parent.GetSprintingTime() > 0.12 ) )
  912. {
  913. if ( playerToRawAngleDiff < 90 )
  914. {
  915. dodgeDirection = PED_Forward;
  916. }
  917. else
  918. {
  919. dodgeDirection = PED_Back;
  920. turnInPlaceBeforeDodge = true;
  921. }
  922. }
  923. else
  924. {
  925.  
  926. if ( playerToTargetAngleDiff > 90 )
  927. {
  928.  
  929. if ( playerToRawAngleDiff < 90 )
  930. {
  931. dodgeDirection = PED_Forward;
  932. turnInPlaceBeforeDodge = true;
  933. }
  934. else
  935. {
  936.  
  937. if ( VecLength( intersectPoint - parent.GetWorldPosition() ) < intersectLength )
  938. {
  939. if ( theGame.TestNoCreaturesOnLine( parent.GetWorldPosition(), predictedDodgePos, 0.1, parent, NULL, true ) )
  940.  
  941. {
  942. dodgeDirection = PED_Back;
  943. }
  944. else
  945. {
  946. dodgeDirection = PED_Back;
  947. turnInPlaceBeforeDodge = true;
  948. }
  949. }
  950. else
  951. {
  952. dodgeDirection = PED_Back;
  953. turnInPlaceBeforeDodge = true;
  954. }
  955. }
  956. }
  957. else
  958. {
  959.  
  960. if ( playerToRawAngleDiff < 90 )
  961. {
  962.  
  963. if ( VecLength( intersectPoint - parent.GetWorldPosition() ) < intersectLength )
  964. {
  965. if ( theGame.TestNoCreaturesOnLine( parent.GetWorldPosition(), predictedDodgePos, 0.1, parent, NULL, true ) )
  966.  
  967. {
  968. dodgeDirection = PED_Forward;
  969. turnInPlaceBeforeDodge = true;
  970. }
  971. else
  972. dodgeDirection = PED_Forward;
  973. }
  974. else
  975. dodgeDirection = PED_Forward;
  976. }
  977. else
  978. {
  979.  
  980. if ( VecLength( intersectPoint - parent.GetWorldPosition() ) < intersectLength && AbsF( AngleDistance( VecHeading( intersectPoint - parent.GetWorldPosition() ), rawDodgeHeading ) ) < 10.f )
  981. {
  982. if ( theGame.TestNoCreaturesOnLine( parent.GetWorldPosition(), predictedDodgePos, 0.1, parent, NULL, true ) )
  983.  
  984. {
  985. dodgeDirection = PED_Back;
  986. }
  987. else
  988. {
  989. dodgeDirection = PED_Back;
  990. turnInPlaceBeforeDodge = true;
  991. }
  992. }
  993. else
  994. {
  995. dodgeDirection = PED_Back;
  996. }
  997. }
  998. }
  999. targetCapsuleRadius = ( (CMovingPhysicalAgentComponent)evadeTarget.GetMovingAgentComponent() ).GetCapsuleRadius();
  1000. if ( parent.IsHardLockEnabled() && targetCapsuleRadius > 0.8f )
  1001. {
  1002. playerToCamAngleDiff = AbsF( AngleDistance( parent.GetHeading(), VecHeading( theCamera.GetCameraDirection() ) ) );
  1003. if ( playerToCamAngleDiff > 0 && playerToCamAngleDiff < 110 )
  1004. {
  1005.  
  1006. if ( playerToRawAngleDiff < 90 )
  1007. {
  1008. dodgeDirection = PED_Forward;
  1009. turnInPlaceBeforeDodge = false;
  1010. }
  1011. }
  1012.  
  1013. if ( playerToCamAngleDiff > 60 && playerToCamAngleDiff < 135 )
  1014. {
  1015.  
  1016. if ( playerToRawAngleDiff > 120 )
  1017. {
  1018. dodgeDirection = PED_Back;
  1019. turnInPlaceBeforeDodge = true;
  1020. }
  1021. }
  1022. }
  1023. }
  1024. }
  1025.  
  1026. if(!SkipStaminaDodgeEvadeCost())
  1027. {
  1028. if(isRolling)
  1029. parent.DrainStamina(ESAT_Roll);
  1030. else
  1031. parent.DrainStamina(ESAT_Dodge);
  1032. }
  1033.  
  1034. // W3EE - Begin
  1035. /*if( parent.CanUseSkill(S_Perk_21) )
  1036. {
  1037. if( isRolling )
  1038. {
  1039. GetWitcherPlayer().GainAdrenalineFromPerk21( 'roll' );
  1040. }
  1041. else
  1042. {
  1043. GetWitcherPlayer().GainAdrenalineFromPerk21( 'dodge' );
  1044. }
  1045. }*/
  1046. // W3EE - End
  1047.  
  1048. if ( dodgeDirection == PED_Forward )
  1049. {
  1050. if ( evadeTarget )
  1051. {
  1052. evadeTarget.SignalGameplayEventParamInt('Time2Dodge', (int)EDT_Fear );
  1053.  
  1054. if ( wasLockedToTarget )
  1055. parent.SetUnpushableTarget( evadeTarget );
  1056. }
  1057. }
  1058.  
  1059. if ( !theGame.GetWorld().StaticTrace( predictedDodgePos + Vector(0,0,5), predictedDodgePos + Vector(0,0,-5) , predictedDodgePos, predictedDodgePosNormal ) )
  1060. playerToTargetRot.Pitch = 0.f;
  1061. else
  1062. playerToTargetRot = VecToRotation( predictedDodgePos - parent.GetWorldPosition() );
  1063.  
  1064. submergeDepth = ((CMovingPhysicalAgentComponent)parent.GetMovingAgentComponent()).GetSubmergeDepth();
  1065.  
  1066. FillDodgePlaylists( isRolling );
  1067.  
  1068. if ( !parent.GetWeaponHolster().IsMeleeWeaponReady() )
  1069. {
  1070. dodgeNum = 0;
  1071. }
  1072. else if ( !turnInPlaceBeforeDodge )
  1073. {
  1074. if ( dodgeDirection == PED_Back )
  1075. {
  1076. parent.SetBehaviorVariable( 'dodgeNum', dodgePlaylistBck[ dodgePlaylistBck.Size() - 1 ] );
  1077. dodgePlaylistBck.EraseFast( dodgePlaylistBck.Size() - 1 );
  1078. }
  1079. else
  1080. {
  1081. parent.SetBehaviorVariable( 'dodgeNum', dodgePlaylistFwd[ dodgePlaylistFwd.Size() - 1 ] );
  1082. dodgePlaylistFwd.EraseFast( dodgePlaylistFwd.Size() - 1 );
  1083. }
  1084. }
  1085. else
  1086. {
  1087. if ( dodgeDirection == PED_Forward )
  1088. {
  1089. parent.SetBehaviorVariable( 'dodgeNum', dodgePlaylistFlipFwd[ dodgePlaylistFlipFwd.Size() - 1 ] );
  1090. dodgePlaylistFlipFwd.EraseFast( dodgePlaylistFlipFwd.Size() - 1 );
  1091. }
  1092. }
  1093.  
  1094.  
  1095.  
  1096. parent.SetBehaviorVariable( 'combatActionType', (int)CAT_Dodge );
  1097. parent.SetBehaviorVariable( 'playerEvadeDirection', (int)( dodgeDirection ) ) ;
  1098. parent.SetBehaviorVariable( 'turnInPlaceBeforeDodge', 0.f ) ;
  1099. parent.SetBehaviorVariable( 'isRolling', (int)isRolling ) ;
  1100.  
  1101. // W3EE - Begin
  1102. if ( turnInPlaceBeforeDodge )
  1103. parent.SetBehaviorVariable( 'turnInPlaceBeforeDodge', 1.f ) ;
  1104. // W3EE - End
  1105.  
  1106. if ( parent.RaiseForceEvent( 'CombatAction' ) )
  1107. virtual_parent.OnCombatActionStart();
  1108.  
  1109. parent.SetCustomRotation( 'Dodge', GetDodgeHeading( playerEvadeType ), 0.0f, 0.1f, false );
  1110.  
  1111. if ( turnInPlaceBeforeDodge )
  1112. Sleep( 0.4f );
  1113. else
  1114. Sleep( 0.3f );
  1115.  
  1116.  
  1117. if ( parent.bLAxisReleased )
  1118. cachedRawDodgeHeading = rawDodgeHeading;
  1119. else
  1120. cachedRawDodgeHeading = GetRawDodgeHeading();
  1121.  
  1122.  
  1123. parent.SetCustomRotation( 'Dodge', GetDodgeHeadingForMovementHeading( cachedRawDodgeHeading ), 90.0f, 0.0f, false );
  1124.  
  1125. parent.BindMovementAdjustmentToEvent( 'Dodge', 'Dodge' );
  1126. parent.AddTimer( 'UpdateDodgeInfoTimer', 0, true );
  1127.  
  1128. parent.WaitForBehaviorNodeDeactivation( 'DodgeComplete', 0.7f );
  1129. parent.RemoveTimer( 'UpdateDodgeInfoTimer' );
  1130.  
  1131.  
  1132. parent.SetIsCurrentlyDodging(false);
  1133.  
  1134. }
  1135.  
  1136.  
  1137. var dodgePlaylistFwd : array<float>;
  1138. var dodgePlaylistFlipFwd : array<float>;
  1139. var dodgePlaylistBck : array<float>;
  1140. private function FillDodgePlaylists( isRolling : bool )
  1141. {
  1142. var linearSequence : array<float>;
  1143. var i, rand, numOfAnims : int;
  1144.  
  1145. if ( dodgePlaylistFwd.Size() <= 0 )
  1146. dodgePlaylistFwd = CreatePlaylist(2);
  1147.  
  1148. if ( dodgePlaylistFlipFwd.Size() <= 0 )
  1149. dodgePlaylistFlipFwd = CreatePlaylist(2);
  1150.  
  1151. if ( dodgePlaylistBck.Size() <= 0 )
  1152. dodgePlaylistBck = CreatePlaylist(3);
  1153. }
  1154.  
  1155. private function CreatePlaylist( numOfAnims : int ) : array<float>
  1156. {
  1157. var linearSequence : array<float>;
  1158. var i, rand : int;
  1159. var playList : array<float>;
  1160.  
  1161. linearSequence.Clear();
  1162. for ( i = 0; i < numOfAnims; i += 1 )
  1163. {
  1164. linearSequence.PushBack(i);
  1165. }
  1166.  
  1167. for ( i = 0; i < numOfAnims; i += 1 )
  1168. {
  1169. rand = RandRange( linearSequence.Size(), 0 );
  1170. playList.PushBack( linearSequence[ rand ] );
  1171. linearSequence.Erase( rand );
  1172. }
  1173.  
  1174. return playList;
  1175. }
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183. private function SkipStaminaDodgeEvadeCost() : bool
  1184. {
  1185. var targetNPC : CNewNPC;
  1186.  
  1187. targetNPC = (CNewNPC)parent.GetTarget();
  1188. if( targetNPC )
  1189. {
  1190.  
  1191. if( targetNPC.IsAttacking() && parent.CanUseSkill(S_Sword_s09) )
  1192. {
  1193. return true;
  1194. }
  1195. }
  1196.  
  1197. return false;
  1198. }
  1199.  
  1200.  
  1201.  
  1202. protected function GetEvadeDirection( playerEvadeType : EPlayerEvadeType ) : EPlayerEvadeDirection
  1203. {
  1204. var rawToHeadingAngleDiff : float;
  1205. var evadeDirection : EPlayerEvadeDirection;
  1206. var unusedActor : CActor;
  1207. var inputToleranceFwd : float;
  1208. var inputToleranceBck : float;
  1209. var checkedHeading : Vector;
  1210. var moveTargets : array<CActor>;
  1211.  
  1212. var tempAngleDiff : float;
  1213.  
  1214. moveTargets = parent.GetMoveTargets();
  1215. inputToleranceFwd = 45.f;
  1216. inputToleranceBck = 135.f;
  1217.  
  1218. if ( playerEvadeType == PET_Dodge )
  1219. {
  1220. checkedHeading = VecFromHeading( parent.GetCombatActionHeading() );
  1221.  
  1222. if ( parent.GetPlayerCombatStance() == PCS_AlertNear || parent.GetPlayerCombatStance() == PCS_Guarded )
  1223. {
  1224. inputToleranceFwd = 90.f;
  1225. inputToleranceBck = 90.f;
  1226. rawToHeadingAngleDiff = AngleDistance( VecHeading( evadeTarget.GetWorldPosition() - parent.GetWorldPosition() ), parent.GetCombatActionHeading() );
  1227. }
  1228. else
  1229. rawToHeadingAngleDiff = AngleDistance( parent.GetHeading(), parent.GetCombatActionHeading() );
  1230. }
  1231. else if ( playerEvadeType == PET_Pirouette )
  1232. {
  1233. if ( wasLockedToTarget )
  1234. {
  1235. inputToleranceFwd = 30.f;
  1236. inputToleranceBck = 30.f;
  1237. rawToHeadingAngleDiff = AngleDistance( VecHeading( evadeTargetPos - parent.GetWorldPosition() ), parent.GetCombatActionHeading() );
  1238. }
  1239. else
  1240. rawToHeadingAngleDiff = AngleDistance( parent.GetHeading(), parent.GetCombatActionHeading() );
  1241. }
  1242. else
  1243. rawToHeadingAngleDiff = AngleDistance( parent.GetHeading(), parent.GetCombatActionHeading() );
  1244.  
  1245. if ( parent.lAxisReleasedAfterCounterNoCA )
  1246. evadeDirection = PED_Back;
  1247. else if( parent.GetIsSprinting() )
  1248. evadeDirection = PED_Forward;
  1249. else if( rawToHeadingAngleDiff >= ( -1 * inputToleranceFwd ) && rawToHeadingAngleDiff < inputToleranceFwd )
  1250. evadeDirection = PED_Forward;
  1251. else if( rawToHeadingAngleDiff >= inputToleranceFwd && rawToHeadingAngleDiff < ( 180 - inputToleranceBck ) )
  1252. evadeDirection = PED_Right;
  1253. else if( rawToHeadingAngleDiff >= ( -180 + inputToleranceBck ) && rawToHeadingAngleDiff < ( -1 * inputToleranceFwd ) )
  1254. evadeDirection = PED_Left;
  1255. else
  1256. evadeDirection = PED_Back;
  1257.  
  1258.  
  1259. return evadeDirection;
  1260. }
  1261.  
  1262. function GetRawDodgeHeading() : float
  1263. {
  1264. var heading : float;
  1265.  
  1266. if ( wasLockedToTarget )
  1267. {
  1268. if ( dodgeDirection == PED_Forward )
  1269. heading = VecHeading( evadeTargetPos - parent.GetWorldPosition() );
  1270. else if ( dodgeDirection == PED_Left )
  1271. heading = VecHeading( evadeTargetPos - parent.GetWorldPosition() ) + 90;
  1272. else if ( dodgeDirection == PED_Right )
  1273. heading = VecHeading( evadeTargetPos - parent.GetWorldPosition() ) - 90;
  1274. else
  1275. heading = VecHeading( evadeTargetPos - parent.GetWorldPosition() ) - 180;
  1276. }
  1277. else
  1278. {
  1279.  
  1280. if ( parent.lAxisReleasedAfterCounterNoCA )
  1281. heading = parent.GetHeading() + 180;
  1282. else
  1283. heading = parent.rawPlayerHeading;
  1284.  
  1285. if ( parent.lAxisReleasedAfterCounterNoCA && evadeTarget )
  1286. heading = VecHeading( parent.GetWorldPosition() - evadeTarget.GetWorldPosition() );
  1287. }
  1288.  
  1289. parent.GetVisualDebug().AddArrow( 'Dodge', parent.GetWorldPosition(), parent.GetWorldPosition() + VecFromHeading( heading )*3, 1.f, 0.2f, 0.2f, true, Color(256,128,128), true, 5.f );
  1290.  
  1291. return heading;
  1292. }
  1293.  
  1294. function GetDodgeHeading( playerEvadeType : EPlayerEvadeType ) : float
  1295. {
  1296. var unusedActor : CActor;
  1297. var rawDodgeHeading : float;
  1298. var dodgeHeading : float;
  1299.  
  1300. rawDodgeHeading = GetRawDodgeHeading();
  1301.  
  1302. if ( dodgeDirection == PED_Forward )
  1303. dodgeHeading = rawDodgeHeading;
  1304. else if ( dodgeDirection == PED_Right )
  1305. dodgeHeading = rawDodgeHeading + 90;
  1306. else if ( dodgeDirection == PED_Left )
  1307. dodgeHeading = rawDodgeHeading - 90;
  1308. else
  1309. dodgeHeading = rawDodgeHeading + 180;
  1310.  
  1311. return dodgeHeading;
  1312. }
  1313.  
  1314. timer function UpdateDodgeInfoTimer( time : float , id : int)
  1315. {
  1316. if ( wasLockedToTarget && evadeTarget )
  1317. {
  1318. parent.UpdateCustomRotationHeading( 'Dodge', VecHeading( evadeTargetPos - parent.GetWorldPosition() ) );
  1319. parent.UpdateCustomLockMovementHeading( 'DodgeMovement', GetRawDodgeHeading() );
  1320. }
  1321. else
  1322. {
  1323. if ( !parent.bLAxisReleased )
  1324. cachedRawDodgeHeading = GetRawDodgeHeading();
  1325.  
  1326. parent.UpdateCustomRotationHeading( 'Dodge', GetDodgeHeadingForMovementHeading( cachedRawDodgeHeading ) );
  1327. }
  1328. }
  1329.  
  1330.  
  1331. function GetDodgeHeadingForMovementHeading( movementHeading : float) : float
  1332. {
  1333. var heading : float;
  1334.  
  1335. if ( evadeTarget && parent.bLAxisReleased )
  1336. heading = parent.GetHeading();
  1337.  
  1338. if ( dodgeDirection == PED_Forward )
  1339. heading = movementHeading;
  1340. else if ( dodgeDirection == PED_Right )
  1341. heading = movementHeading + 90;
  1342. else if ( dodgeDirection == PED_Left )
  1343. heading = movementHeading - 90;
  1344. else
  1345. heading = movementHeading + 180;
  1346.  
  1347. if ( turnInPlaceBeforeDodge )
  1348. return heading + 180;
  1349.  
  1350. return heading;
  1351. }
  1352.  
  1353. timer function UpdateRollInfoTimer( time : float , id : int)
  1354. {
  1355. var playerToTargetDist : float;
  1356. var evadeTargetSpeed : float;
  1357.  
  1358. if ( wasLockedToTarget && evadeTarget )
  1359. {
  1360. parent.UpdateCustomRotationHeading( 'Roll', GetRawDodgeHeading() );
  1361. parent.UpdateCustomLockMovementHeading( 'RollMovement', GetRawDodgeHeading() );
  1362. }
  1363. else
  1364. {
  1365. if ( !parent.bLAxisReleased )
  1366. parent.UpdateCustomRotationHeading( 'Roll', parent.rawPlayerHeading );
  1367. else
  1368. parent.UpdateCustomRotationHeading( 'Roll', VecHeading( parent.GetHeadingVector() ) );
  1369. }
  1370.  
  1371. parent.GetVisualDebug().AddArrow( 'dodgeInitialHeading', parent.GetWorldPosition(), parent.GetWorldPosition() + VecFromHeading( parent.rawPlayerHeading )*3, 1.f, 0.2f, 0.2f, true, Color(256,128,256), true, 5.f );
  1372. }
  1373.  
  1374. protected function GetLandingEvadeDirection( landAt : Vector, evadingHeading : float ) : EPlayerEvadeDirection
  1375. {
  1376. var playerToTargetHeading : float;
  1377. var headingDiff : float;
  1378. var changeDirection : EPlayerEvadeDirection;
  1379. var dontChangeAngle : float;
  1380. var currentDodgeFwdHeading : float;
  1381.  
  1382. dontChangeAngle = 180;
  1383.  
  1384.  
  1385. playerToTargetHeading = VecHeading( evadeTargetPos - landAt );
  1386. currentDodgeFwdHeading = GetDodgeHeadingForMovementHeading( evadingHeading );
  1387.  
  1388. headingDiff = AngleDistance( playerToTargetHeading, currentDodgeFwdHeading );
  1389.  
  1390.  
  1391. if( headingDiff >= -dontChangeAngle && headingDiff < dontChangeAngle )
  1392. changeDirection = PED_Forward;
  1393. else if( headingDiff >= dontChangeAngle )
  1394. changeDirection = PED_Right;
  1395. else
  1396. changeDirection = PED_Left;
  1397.  
  1398. if( changeDirection == PED_Forward)
  1399. {
  1400. return dodgeDirection;
  1401. }
  1402.  
  1403. if( changeDirection == PED_Right)
  1404. {
  1405. switch( dodgeDirection )
  1406. {
  1407. case PED_Forward: return PED_Right;
  1408. case PED_Right: return PED_Back;
  1409. case PED_Back: return PED_Left;
  1410. case PED_Left: return PED_Forward;
  1411. }
  1412. }
  1413. if( changeDirection == PED_Left)
  1414. {
  1415. switch( dodgeDirection )
  1416. {
  1417. case PED_Forward: return PED_Left;
  1418. case PED_Right: return PED_Forward;
  1419. case PED_Back: return PED_Right;
  1420. case PED_Left: return PED_Back;
  1421. }
  1422. }
  1423. return dodgeDirection;
  1424. }
  1425.  
  1426.  
  1427.  
  1428.  
  1429. private final function CleanUpComboStuff()
  1430. {
  1431. comboAttackA_Id = -1;
  1432. comboAttackB_Id = -1;
  1433.  
  1434. comboAttackA_Target = NULL;
  1435. comboAttackB_Target = NULL;
  1436.  
  1437. comboAttackA_Sliding = false;
  1438. comboAttackB_Sliding = false;
  1439.  
  1440. comboAspectName = '';
  1441. }
  1442.  
  1443. private final function CacheComboAttack( attackId : int, slideTarget : CGameplayEntity, sliding : bool, aspectName : name )
  1444. {
  1445. comboAttackB_Id = comboAttackA_Id;
  1446. comboAttackB_Target = comboAttackA_Target;
  1447. comboAttackB_Sliding = comboAttackA_Sliding;
  1448.  
  1449. comboAttackA_Id = attackId;
  1450. comboAttackA_Target = slideTarget;
  1451. comboAttackA_Sliding = sliding;
  1452.  
  1453. comboAspectName = aspectName;
  1454. }
  1455.  
  1456. // W3EE - Begin
  1457. var W3EEComboDef : W3EEComboDefinition;
  1458. public final function BuildComboWitcher( attackType : name, fistAnim : bool )
  1459. {
  1460. if( !W3EEComboDef )
  1461. {
  1462. W3EEComboDef = new W3EEComboDefinition in this;
  1463. W3EEComboDef.Init();
  1464. }
  1465.  
  1466. if( W3EEComboDef.GetIsActive() )
  1467. {
  1468. W3EEComboDef.Update(attackType, fistAnim);
  1469. comboDefinition = W3EEComboDef.GetComboDefinition();
  1470.  
  1471. comboPlayer = new CComboPlayer in this;
  1472. if ( !comboPlayer.Build( comboDefinition, parent ) )
  1473. {
  1474. LogChannel( 'ComboNode', "Error: BuildCombo" );
  1475. }
  1476. comboPlayer.SetDurationBlend( 0.2f );
  1477.  
  1478. CleanUpComboStuff();
  1479. comboPlayer.Init();
  1480. }
  1481. else
  1482. {
  1483. BuildComboPlayer();
  1484. }
  1485. }
  1486. // W3EE - End
  1487.  
  1488. public final function BuildComboPlayer()
  1489. {
  1490. if ( !comboPlayer )
  1491. {
  1492. BuildCombo();
  1493. }
  1494.  
  1495. if ( comboPlayer )
  1496. {
  1497. comboPlayer.Init();
  1498. }
  1499. }
  1500.  
  1501. private final function BuildCombo()
  1502. {
  1503.  
  1504. comboDefinition = new CComboDefinition in this;
  1505.  
  1506.  
  1507. OnCreateAttackAspects();
  1508.  
  1509.  
  1510. comboPlayer = new CComboPlayer in this;
  1511. if ( !comboPlayer.Build( comboDefinition, parent ) )
  1512. {
  1513. LogChannel( 'ComboNode', "Error: BuildCombo" );
  1514. }
  1515.  
  1516.  
  1517. comboPlayer.SetDurationBlend( 0.2f );
  1518.  
  1519.  
  1520. CleanUpComboStuff();
  1521. }
  1522.  
  1523. event OnCreateAttackAspects(){}
  1524.  
  1525. event OnPerformAttack( playerAttackType : name )
  1526. {
  1527. var actor : CActor;
  1528. var finish : CComponent;
  1529. var playerToTargetHeading : float;
  1530. var shouldFaceTarget : bool;
  1531. var aiStorageObject : IScriptable;
  1532. var newTarget : CActor;
  1533.  
  1534.  
  1535. if ( parent.DisableManualCameraControlStackHasSource('Finisher') )
  1536. return false;
  1537.  
  1538. if ( !thePlayer.IsCombatMusicEnabled()
  1539. && !thePlayer.CanAttackWhenNotInCombat( EBAT_LightAttack, false, newTarget ) )
  1540. {
  1541. if ( parent.IsInCombatActionFriendly() )
  1542. {
  1543. return false;
  1544. }
  1545.  
  1546. actor = (CActor)(parent.slideTarget);
  1547.  
  1548. shouldFaceTarget = true;
  1549.  
  1550. if ( shouldFaceTarget )
  1551. parent.SetBehaviorVariable( 'playerToTargetDistForOverlay', VecDistance( parent.GetWorldPosition(), actor.GetNearestPointInPersonalSpace( parent.GetWorldPosition() ) ) );
  1552. else
  1553. parent.SetBehaviorVariable( 'playerToTargetDistForOverlay', 50.f );
  1554.  
  1555. aiStorageObject = actor.GetScriptStorageObject('ReactionData');
  1556. if ( virtual_parent.DisplayCannotAttackMessage( actor ) )
  1557. {
  1558. return false;
  1559. }
  1560. else
  1561. {
  1562. if ( parent.RaiseAttackFriendlyEvent( actor ) )
  1563. {
  1564. return true;
  1565. }
  1566.  
  1567. return false;
  1568. }
  1569. }
  1570. else
  1571. {
  1572. if ( parent.IsInCombatActionFriendly() )
  1573. {
  1574. parent.RaiseEvent('CombatActionFriendlyEnd');
  1575. }
  1576.  
  1577. parent.SendAttackReactionEvent();
  1578. ProcessAttackApproach( playerAttackType );
  1579. parent.ObtainTicketFromCombatTarget('TICKET_Melee',10000);
  1580. parent.ObtainTicketFromCombatTarget('TICKET_Range',10000);
  1581. parent.RemoveTimer('FreeTickets');
  1582. }
  1583. }
  1584.  
  1585. private function IsInCombatAction_Attack(): bool
  1586. {
  1587. return parent.IsInCombatAction_Attack();
  1588. }
  1589.  
  1590. var cachedPlayerAttackType : name;
  1591. var farAttackMinDist : float;
  1592. var previousSlideTarget : CGameplayEntity;
  1593. var finisherDist : float;
  1594. var isOnHighSlope : bool;
  1595. entry function ProcessAttackApproach( playerAttackType : name )
  1596. {
  1597. var playerToTargetDist : float;
  1598. var playerToTargetVec : Vector;
  1599. var actor : CActor;
  1600. var npc : CNewNPC;
  1601.  
  1602. var isDeadlySwordHeld : bool;
  1603.  
  1604. actor = (CActor)parent.slideTarget;
  1605. npc = (CNewNPC)parent.slideTarget;
  1606.  
  1607. FactsAdd("ach_attack", 1, 4 );
  1608. theGame.GetGamerProfile().CheckLearningTheRopes();
  1609. if ( actor && ( !npc || npc.GetCurrentStance() != NS_Fly ) )
  1610. {
  1611. finisherDist = 1.5f;
  1612.  
  1613. actor.IsAttacked( true );
  1614.  
  1615. if ( actor.GetComponent("Finish").IsEnabled() && ( parent.GetCurrentStateName() == 'CombatSteel' || parent.GetCurrentStateName() == 'CombatSilver' ) )
  1616. parent.OnForceTicketUpdate();
  1617.  
  1618. playerToTargetDist = GetPlayerToTargetDistance( true, 1.f );
  1619.  
  1620. playerToTargetVec = parent.GetWorldPosition() - actor.GetWorldPosition();
  1621. if ( AbsF( playerToTargetVec.Z ) > 1.f )
  1622. isOnHighSlope = true;
  1623. else
  1624. isOnHighSlope = false;
  1625.  
  1626. if ( parent.GetCurrentStateName() == 'CombatFists' )
  1627. farAttackMinDist = 3.f;
  1628. else
  1629. farAttackMinDist = 4.f;
  1630.  
  1631. if ( actor.GetComponent("Finish").IsEnabled()
  1632. && playerToTargetDist < GetMaxAttackDist() + 1.f
  1633. && ( parent.GetCurrentStateName() == 'CombatSteel' || parent.GetCurrentStateName() == 'CombatSilver' ) )
  1634. {
  1635. isDeadlySwordHeld = parent.IsDeadlySwordHeld();
  1636.  
  1637. if ( playerToTargetDist < finisherDist || !isDeadlySwordHeld )
  1638. ProcessAttack( playerAttackType, false );
  1639. else
  1640. {
  1641. if ( parent.IsInCombatAction() && parent.GetBehaviorVariable( 'combatActionType' ) == 8 )
  1642. {
  1643. if ( previousSlideTarget != actor )
  1644. EnableAttackApproach( playerAttackType );
  1645. }
  1646. else
  1647. EnableAttackApproach( playerAttackType );
  1648. }
  1649. }
  1650. else
  1651. {
  1652. if ( parent.approachAttack == 0 )
  1653. {
  1654. if ( playerToTargetDist > farAttackMinDist && playerToTargetDist < parent.softLockDist )
  1655. {
  1656. if ( parent.IsInCombatAction() && parent.GetBehaviorVariable( 'combatActionType' ) == 8 )
  1657. {
  1658. if ( previousSlideTarget != actor )
  1659. EnableAttackApproach( playerAttackType );
  1660. }
  1661. else
  1662. EnableAttackApproach( playerAttackType );
  1663. }
  1664. else
  1665. ProcessAttack( playerAttackType, false );
  1666. }
  1667. else
  1668. ProcessAttack( playerAttackType, false );
  1669. }
  1670.  
  1671. }
  1672.  
  1673. else
  1674. {
  1675. ProcessAttack( playerAttackType, false );
  1676. }
  1677. }
  1678.  
  1679. entry function EnableAttackApproach( playerAttackType : name )
  1680. {
  1681. var playerToTargetHeading : float;
  1682.  
  1683. previousSlideTarget = parent.slideTarget;
  1684. playerToTargetHeading = VecHeading( parent.slideTarget.GetWorldPosition() - parent.GetWorldPosition() );
  1685.  
  1686. if ( parent.RaiseForceEvent( 'CombatAction' ) )
  1687. virtual_parent.OnCombatActionStart();
  1688.  
  1689. parent.SetBehaviorVariable( 'combatActionType', 8 );
  1690. parent.SetCustomRotation( 'PreAttack_Rotation', playerToTargetHeading, 0.0f, 0.2f, false );
  1691. parent.CustomLockMovement( 'PreAttack_Movement', playerToTargetHeading );
  1692. parent.BindMovementAdjustmentToEvent( 'PreAttack_Movement', 'PreAttack_Movement' );
  1693. cachedPlayerAttackType = playerAttackType;
  1694.  
  1695. parent.SetBehaviorVariable( 'approachDirectionWS', playerToTargetHeading );
  1696. parent.SetBehaviorVariable( 'approachDirectionLS', AngleDistance( parent.GetHeading(), playerToTargetHeading )/180 );
  1697.  
  1698. parent.AddTimer( 'ProcessAttackTimer', 0.1f, true );
  1699.  
  1700. }
  1701.  
  1702. var prevPlayerToTargetDist : float;
  1703.  
  1704. var wasDecreasing : bool;
  1705. timer function ProcessAttackTimer( time : float , id : int)
  1706. {
  1707. var slideDistance : float;
  1708. var playerToTargetDist : float;
  1709. var playerToTargetHeading : float;
  1710.  
  1711. playerToTargetDist = GetPlayerToTargetDistance( true, 1.f );
  1712. playerToTargetHeading = VecHeading( parent.slideTarget.GetWorldPosition() - parent.GetWorldPosition() );
  1713. parent.SetBehaviorVariable( 'approachDirectionWS', playerToTargetHeading );
  1714. parent.SetBehaviorVariable( 'approachDirectionLS', AngleDistance( parent.GetHeading(), playerToTargetHeading )/180 );
  1715.  
  1716. parent.UpdateCustomLockMovementHeading( 'PreAttack_Movement', playerToTargetHeading );
  1717. parent.UpdateCustomRotationHeading( 'PreAttack_Movement', playerToTargetHeading );
  1718.  
  1719. if ( !parent.slideTarget )
  1720. ProcessAttack( cachedPlayerAttackType, true );
  1721. else if ( parent.slideTarget.GetComponent("Finish").IsEnabled() )
  1722. {
  1723. playerToTargetDist = GetPlayerToTargetDistance( false, 1.f );
  1724. if ( playerToTargetDist < finisherDist )
  1725. ProcessAttack( cachedPlayerAttackType, true );
  1726. }
  1727. else if ( isOnHighSlope )
  1728. {
  1729. if ( playerToTargetDist < 2.f )
  1730. ProcessAttack( cachedPlayerAttackType, true );
  1731. }
  1732. else if ( playerToTargetDist < farAttackMinDist )
  1733. ProcessAttack( cachedPlayerAttackType, true );
  1734.  
  1735. if ( playerToTargetDist < prevPlayerToTargetDist )
  1736. wasDecreasing = true;
  1737. else if ( wasDecreasing && playerToTargetDist > prevPlayerToTargetDist )
  1738. {
  1739. wasDecreasing = false;
  1740. ProcessAttack( cachedPlayerAttackType, true );
  1741. }
  1742.  
  1743. prevPlayerToTargetDist = playerToTargetDist;
  1744. }
  1745.  
  1746. timer function AttackTimerEnd( time : float , id : int)
  1747. {
  1748. var slideTargetNPC : CNewNPC;
  1749.  
  1750. slideTargetNPC = (CNewNPC)( parent.slideTarget );
  1751. if ( !slideTargetNPC || !slideTargetNPC.IsInFinisherAnim() || !parent.isInFinisher )
  1752. {
  1753. parent.SetSlideTarget( parent.GetCombatActionTarget( EBAT_LightAttack ) );
  1754. ProcessAttack( cachedPlayerAttackType, true );
  1755. }
  1756. }
  1757.  
  1758. var enableSoftLock : bool;
  1759. entry function ProcessAttack( playerAttackType : name, performApproachAttack : bool )
  1760. {
  1761. var temp1 : name;
  1762. var temp2, temp3, temp4 : bool;
  1763. var playerToTargetVec : Vector;
  1764. var playerToTargetRot : EulerAngles;
  1765. var targetCapsuleHeight : float;
  1766. var attackTarget : CActor;
  1767. var tempPos1 : Vector;
  1768. var tempPos2 : Vector;
  1769. var noSlideTargetPos : Vector;
  1770. var noSlideTargetNormal : Vector;
  1771. var temp : CActor;
  1772. var npc, npcAttackTarget : CNewNPC;
  1773. var witcher : W3PlayerWitcher;
  1774. var i : int;
  1775. var isDeadlySwordHeld : bool;
  1776. var comp : CComponent;
  1777. var compEnabled : bool;
  1778. var useNormalAttack : bool;
  1779.  
  1780. parent.RemoveTimer( 'ProcessAttackTimer' );
  1781. parent.RemoveTimer( 'AttackTimerEnd' );
  1782. npc = (CNewNPC)parent.slideTarget;
  1783.  
  1784. if(npc)
  1785. {
  1786. comp = npc.GetComponent("Finish");
  1787. compEnabled = comp.IsEnabled();
  1788. }
  1789. isDeadlySwordHeld = parent.IsDeadlySwordHeld();
  1790. if ( npc
  1791. && compEnabled
  1792. && ( VecDistance( parent.GetWorldPosition(), npc.GetNearestPointInBothPersonalSpaces( parent.GetWorldPosition() ) ) < 1.5f || !isDeadlySwordHeld ) )
  1793. {
  1794. if ( !isDeadlySwordHeld )
  1795. {
  1796. if ( parent.IsWeaponHeld( 'fist' ))
  1797. parent.SetBehaviorVariable( 'combatTauntType', 1.f );
  1798. else
  1799. parent.SetBehaviorVariable( 'combatTauntType', 0.f );
  1800.  
  1801. if ( parent.RaiseEvent( 'CombatTaunt' ) )
  1802. parent.PlayBattleCry( 'BattleCryTaunt', 1.f, true, true );
  1803.  
  1804.  
  1805.  
  1806. }
  1807. else if ( parent.IsWeaponHeld( 'steelsword' ) || parent.IsWeaponHeld( 'silversword' ) )
  1808. {
  1809. if ( !theGame.GetWorld().NavigationLineTest( parent.GetWorldPosition(), npc.GetWorldPosition(), 0.4f ) )
  1810. {
  1811. useNormalAttack = true;
  1812. comp.SetEnabled( false );
  1813. }
  1814. else if ( !parent.isInFinisher )
  1815. {
  1816. npc.SignalGameplayEvent( 'Finisher' );
  1817. parent.AddTimer( 'AttackTimerEnd', 0.2f );
  1818. }
  1819. }
  1820. else
  1821. {
  1822.  
  1823. parent.SetBehaviorVariable( 'combatTauntType', 0.f );
  1824.  
  1825. if ( parent.RaiseEvent( 'CombatTaunt' ) )
  1826. parent.PlayBattleCry( 'BattleCryTaunt', 1.f, true, true );
  1827.  
  1828.  
  1829.  
  1830. }
  1831. }
  1832. else
  1833. useNormalAttack = true;
  1834.  
  1835. if ( useNormalAttack )
  1836. {
  1837. parent.GetMovingAgentComponent().GetMovementAdjustor().CancelAll();
  1838.  
  1839. //W3EE - Begin
  1840. witcher = (W3PlayerWitcher)parent;
  1841. if( witcher )
  1842. {
  1843. BuildComboWitcher(playerAttackType, parent.GetCurrentStateName() == 'CombatFists');
  1844. }
  1845. else
  1846. if ( !comboPlayer )
  1847. {
  1848. BuildComboPlayer();
  1849.  
  1850.  
  1851. }
  1852.  
  1853.  
  1854. enableSoftLock = Options().LockOn() || parent.IsHardLockEnabled();
  1855.  
  1856. // enableSoftLock = true;
  1857. //W3EE - End
  1858.  
  1859. if ( parent.IsInCombat()
  1860. && thePlayer.IsSprintActionPressed()
  1861. && !parent.bLAxisReleased
  1862. && !parent.IsActorLockedToTarget()
  1863. && parent.GetForceDisableUpdatePosition() )
  1864. enableSoftLock = false;
  1865.  
  1866. updatePosition = true;
  1867. if ( !enableSoftLock )
  1868. updatePosition = false;
  1869.  
  1870. attackTarget = (CActor)parent.slideTarget;
  1871. npcAttackTarget = (CNewNPC)attackTarget;
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877. if(attackTarget)
  1878. {
  1879. attackTarget.SetUnpushableTarget( parent );
  1880. parent.SetUnpushableTarget(attackTarget);
  1881. }
  1882. parent.SetBehaviorVariable( 'combatActionType', (int)CAT_Attack );
  1883.  
  1884. if ( parent.slideTarget )
  1885. playerToTargetVec = parent.slideTarget.GetWorldPosition() - parent.GetWorldPosition();
  1886. else
  1887. {
  1888. tempPos1 = parent.GetWorldPosition() + parent.GetHeadingVector() * 4;
  1889. tempPos1.Z += 10.f;
  1890. tempPos2 = tempPos1;
  1891. tempPos2.Z -= 20.f;
  1892. theGame.GetWorld().StaticTrace( tempPos1, tempPos2, noSlideTargetPos, noSlideTargetNormal );
  1893. playerToTargetVec = parent.GetWorldPosition() - noSlideTargetPos;
  1894. }
  1895.  
  1896.  
  1897. if( playerAttackType == theGame.params.ATTACK_NAME_LIGHT )
  1898. {
  1899. if (npc)
  1900. npc.SignalGameplayEventParamInt('Time2DodgeFast', (int)EDT_Attack_Light );
  1901.  
  1902. if ( parent.GetCurrentStateName() == 'CombatFists' )
  1903. {
  1904. // W3EE - Begin
  1905. if( W3EEComboDef.GetIsActive() )
  1906. {
  1907. comboPlayer.PlayAttack('AttackFistFast');
  1908. }
  1909. else
  1910. {
  1911. if ( parent.slideTarget )
  1912. {
  1913. if ( !attackTarget || !parent.IsThreat(attackTarget) )
  1914. comboPlayer.PlayAttack( 'AttackLightNoTarget' );
  1915. else
  1916. {
  1917.  
  1918. comboPlayer.PlayAttack( 'AttackLight' );
  1919. }
  1920. }
  1921. else
  1922. comboPlayer.PlayAttack( 'AttackLightNoTarget' );
  1923. }
  1924. // W3EE - End
  1925. }
  1926. else
  1927. {
  1928. // W3EE - Begin
  1929. if( W3EEComboDef.GetIsActive() )
  1930. {
  1931. if( Combat().IsUsingBattleAxe() || Combat().IsUsingBattleMace() )
  1932. comboPlayer.PlayAttack('AttackBattleAxeFast');
  1933. else
  1934. if( Combat().IsUsingSecondaryWeapon() )
  1935. comboPlayer.PlayAttack('AttackLightSecondary');
  1936. else
  1937. comboPlayer.PlayAttack('AttackLightReal');
  1938. }
  1939. else
  1940. {
  1941. if ( npc && npc.IsUsingHorse() )
  1942. comboPlayer.PlayAttack('AttackLightVsRider');
  1943. else if ( !parent.IsInShallowWater() && npc && ( npc.GetCurrentStance() == NS_Fly || npc.IsInAir() ) )
  1944. {
  1945. if ( playerToTargetVec.Z >= 0.f )
  1946. comboPlayer.PlayAttack( 'AttackLightFlying' );
  1947. else
  1948. comboPlayer.PlayAttack( 'AttackLightSlopeDown' );
  1949. }
  1950. else
  1951. {
  1952. if (attackTarget)
  1953. targetCapsuleHeight = ((CMovingPhysicalAgentComponent)attackTarget.GetMovingAgentComponent()).GetCapsuleHeight();
  1954. else
  1955. targetCapsuleHeight = 0;
  1956.  
  1957. playerToTargetRot = VecToRotation( playerToTargetVec );
  1958.  
  1959. if ( ( playerToTargetVec.Z > 0.4f && AbsF( playerToTargetRot.Pitch ) > 12.f ) || parent.IsInShallowWater() )
  1960. comboPlayer.PlayAttack( 'AttackLightSlopeUp' );
  1961. else if ( playerToTargetVec.Z < -0.35f && AbsF( playerToTargetRot.Pitch ) > 12.f )
  1962. comboPlayer.PlayAttack( 'AttackLightSlopeDown' );
  1963.  
  1964. else if ( !parent.slideTarget )
  1965. comboPlayer.PlayAttack( 'AttackLight' );
  1966. else if ( targetCapsuleHeight < 1.5 )
  1967. comboPlayer.PlayAttack( 'AttackLightCapsuleShort' );
  1968. else
  1969. comboPlayer.PlayAttack( 'AttackLight' );
  1970. }
  1971. }
  1972. // W3EE - End
  1973. }
  1974.  
  1975. virtual_parent.OnCombatActionStart();
  1976. }
  1977. else if ( playerAttackType == theGame.params.ATTACK_NAME_HEAVY )
  1978. {
  1979.  
  1980. thePlayer.PlayBattleCry( 'BattleCryAttack', 0.1f );
  1981.  
  1982. if ( parent.GetCurrentStateName() == 'CombatFists' )
  1983. {
  1984. // W3EE - Begin
  1985. if( W3EEComboDef.GetIsActive() )
  1986. {
  1987. comboPlayer.PlayAttack('AttackFistHeavy');
  1988. }
  1989. else
  1990. {
  1991. if ( parent.slideTarget )
  1992. {
  1993. if ( !attackTarget || !parent.IsThreat(attackTarget) )
  1994. comboPlayer.PlayAttack( 'AttackHeavyNoTarget' );
  1995. else
  1996. {
  1997.  
  1998. comboPlayer.PlayAttack( 'AttackHeavy' );
  1999. }
  2000. }
  2001. else
  2002. comboPlayer.PlayAttack( 'AttackHeavyNoTarget' );
  2003. }
  2004. // W3EE - End
  2005. }
  2006. else
  2007. {
  2008. // W3EE - Begin
  2009. if( W3EEComboDef.GetIsActive() )
  2010. {
  2011. if( Combat().IsUsingBattleAxe() || Combat().IsUsingBattleMace() )
  2012. comboPlayer.PlayAttack('AttackBattleAxeHeavy');
  2013. else
  2014. comboPlayer.PlayAttack('AttackHeavyReal');
  2015. }
  2016. else
  2017. {
  2018. if ( npc && npc.IsUsingHorse() )
  2019. comboPlayer.PlayAttack('AttackHeavyVsRider');
  2020. else if ( parent.slideTarget )
  2021. {
  2022. if(npc && ( npc.GetCurrentStance() == NS_Fly || npc.IsInAir() ) )
  2023. comboPlayer.PlayAttack( 'AttackHeavyFlying' );
  2024.  
  2025. else
  2026. comboPlayer.PlayAttack( 'AttackHeavy' );
  2027. }
  2028. else
  2029. {
  2030.  
  2031. comboPlayer.PlayAttack( 'AttackHeavy' );
  2032. }
  2033. }
  2034. // W3EE - End
  2035.  
  2036. //witcher = (W3PlayerWitcher)parent;
  2037. if(witcher)
  2038. {
  2039. witcher.ToggleSpecialAttackHeavyAllowed(true);
  2040. parent.AddTimer( 'SpecialAttackHeavyAllowedTimer', 0.2 );
  2041. }
  2042. }
  2043.  
  2044. virtual_parent.OnCombatActionStart();
  2045. }
  2046. else
  2047. LogChannel( 'PlayerAttackType', "playerAttackType does not exist!" );
  2048. }
  2049. }
  2050.  
  2051. timer function SpecialAttackHeavyAllowedTimer( time : float , id : int)
  2052. {
  2053. ((W3PlayerWitcher)parent).ToggleSpecialAttackHeavyAllowed(false);
  2054. }
  2055.  
  2056. event OnInterruptAttack()
  2057. {
  2058. parent.RaiseEvent( 'AttackInterrupt' );
  2059. }
  2060.  
  2061.  
  2062. var wasInCloseCombat : bool;
  2063.  
  2064. function OnComboAttackCallback( out callbackInfo : SComboAttackCallbackInfo )
  2065. {
  2066. var angle : float;
  2067. var playerHeading : float;
  2068. var playerToTargetHeading : float;
  2069. var playerToTargetAngleDiff : float;
  2070. var playerToTargetDist : float;
  2071. var farAttackMinDist : float;
  2072. var mediumAttackMinDist : float;
  2073. var enableCloseCombatRadius : bool;
  2074. var isHumanoid : bool;
  2075. var maxAttackDist : float;
  2076. var actorTarget : CActor;
  2077. var isLightAttack : bool;
  2078. var attackTarget : CGameplayEntity;
  2079. var playerToTargetVec : Vector;
  2080. var attackTargetActor : CActor;
  2081.  
  2082. LogChannel( 'ComboNode', "inGlobalAttackCounter = " + callbackInfo.inGlobalAttackCounter + ", inStringAttackCounter = " + callbackInfo.inStringAttackCounter );
  2083.  
  2084.  
  2085. callbackInfo.outShouldRotate = true;
  2086.  
  2087. if ( callbackInfo.inAspectName == 'AttackLight'
  2088. || callbackInfo.inAspectName == 'AttackLightNoTarget'
  2089. || callbackInfo.inAspectName == 'AttackLightCapsuleShort'
  2090. || callbackInfo.inAspectName == 'AttackLightFlying'
  2091. || callbackInfo.inAspectName == 'AttackLightSlopeDown'
  2092. || callbackInfo.inAspectName == 'AttackLightSlopeUp'
  2093. || callbackInfo.inAspectName == 'AttackLightVsRider'
  2094. || callbackInfo.inAspectName == 'AttackLightFar'
  2095. // W3EE - Begin
  2096. || callbackInfo.inAspectName == 'AttackLightReal'
  2097. || callbackInfo.inAspectName == 'AttackFistFast'
  2098. || callbackInfo.inAspectName == 'AttackLightSecondary'
  2099. || callbackInfo.inAspectName == 'AttackBattleAxeFast'
  2100. )
  2101. // W3EE - End
  2102. {
  2103. isLightAttack = true;
  2104. }
  2105. else
  2106. isLightAttack = false;
  2107.  
  2108. playerToTargetVec = parent.slideTarget.GetWorldPosition() - parent.GetWorldPosition();
  2109.  
  2110. if ( parent.slideTarget &&
  2111. enableSoftLock &&
  2112. ( !( (CNewNPC)parent.slideTarget )
  2113. || ( ( (CActor)parent.slideTarget ).GetGameplayVisibility()
  2114.  
  2115. && ( ( (CNewNPC)(parent.slideTarget) ).GetCurrentStance() != NS_Fly || playerToTargetVec.Z < 2.5f || parent.IsActorLockedToTarget() ) ) ) )
  2116. {
  2117. attackTarget = parent.slideTarget;
  2118.  
  2119.  
  2120.  
  2121.  
  2122. if ( parent.HasAbility('NoTransOnHitCheat') )
  2123. {
  2124. parent.SetHitReactTransScale( 0.0f );
  2125. }
  2126. else if ( parent.HasAbility('NoCloseCombatCheat') )
  2127. {
  2128. parent.SetHitReactTransScale( 1.f );
  2129. }
  2130. else
  2131. {
  2132. if ( isLightAttack && callbackInfo.inStringAttackCounter >= 2 && !( (CActor)parent.slideTarget ).IsGuarded() && !wasInCloseCombat )
  2133. parent.SetHitReactTransScale( 0.5f );
  2134. else
  2135. parent.SetHitReactTransScale( 1.f );
  2136. }
  2137.  
  2138. playerToTargetDist = GetPlayerToTargetDistance( true, parent.GetHitReactTransScale(), 0.2f );
  2139.  
  2140. if ( !parent.GetBIsCombatActionAllowed() )
  2141. {
  2142. if ( playerToTargetDist > parent.softLockDist )
  2143. {
  2144. parent.EnableFindTarget( true );
  2145. parent.SetSlideTarget( parent.GetTarget() );
  2146. playerToTargetDist = GetPlayerToTargetDistance( true, parent.GetHitReactTransScale(), 0.2f );
  2147. }
  2148. }
  2149.  
  2150. attackTargetActor = (CActor)parent.slideTarget;
  2151. attackTargetActor.IsAttacked( true );
  2152.  
  2153. if ( parent.GetPlayerCombatStance() == PCS_AlertNear || parent.GetPlayerCombatStance() == PCS_Guarded )
  2154. callbackInfo.outRotateToEnemyAngle = VecHeading( parent.slideTarget.GetWorldPosition() - parent.GetWorldPosition() );
  2155. else
  2156. callbackInfo.outRotateToEnemyAngle = parent.GetCombatActionHeading();
  2157.  
  2158. if ( (CActor)parent.slideTarget )
  2159. callbackInfo.outSlideToPosition = ( (CActor)parent.slideTarget ).GetNearestPointInBothPersonalSpaces( parent.GetWorldPosition() );
  2160. else
  2161. callbackInfo.outSlideToPosition = parent.slideTarget.GetWorldPosition();
  2162.  
  2163. playerToTargetAngleDiff = AngleDistance( callbackInfo.outRotateToEnemyAngle, parent.GetHeading() );
  2164.  
  2165. callbackInfo.outShouldTranslate = false;
  2166.  
  2167. if ( parent.GetCurrentStateName() == 'CombatFists' )
  2168. {
  2169. farAttackMinDist = 2.f;
  2170. mediumAttackMinDist = 0.75f;
  2171. }
  2172. else
  2173. {
  2174. farAttackMinDist = 2.5f;
  2175. mediumAttackMinDist = 1.25f;
  2176. }
  2177.  
  2178. enableCloseCombatRadius = false;
  2179.  
  2180. actorTarget = ( CActor ) parent.slideTarget;
  2181. if ( actorTarget && CalculateAttributeValue( actorTarget.GetAttributeValue( 'humanoid' ) ) > 0.f )
  2182. isHumanoid = true;
  2183. else
  2184. isHumanoid = false;
  2185.  
  2186. // W3EE - Begin
  2187. if ( playerToTargetDist > parent.softLockDist )
  2188. callbackInfo.outDistance = ADIST_Small;
  2189. else if ( playerToTargetDist > 4.6f )
  2190. callbackInfo.outDistance = ADIST_Large;
  2191. else if ( playerToTargetDist > farAttackMinDist )
  2192. callbackInfo.outDistance = ADIST_Medium;
  2193. else if ( playerToTargetDist > mediumAttackMinDist )
  2194. callbackInfo.outDistance = ADIST_Small;
  2195. else
  2196. callbackInfo.outDistance = ADIST_Small;
  2197.  
  2198. if ( parent.slideTarget && (CActor)parent.slideTarget )
  2199. {
  2200. if ( ( (CActor)( parent.slideTarget ) ).IsCurrentlyDodging() )
  2201. callbackInfo.outDistance = ADIST_Small;
  2202.  
  2203. if ( GetAttitudeBetween( parent, parent.slideTarget ) != AIA_Hostile )
  2204. callbackInfo.outDistance = ADIST_Small;
  2205. }
  2206.  
  2207. if ( callbackInfo.inAspectName == 'AttackNeutral' )
  2208. {
  2209. if ( playerToTargetDist > 1.f || parent.HasAbility('NoCloseCombatCheat') )
  2210. callbackInfo.outDistance = ADIST_Small;
  2211. else
  2212. callbackInfo.outDistance = ADIST_Small;
  2213. }
  2214.  
  2215.  
  2216.  
  2217. if ( callbackInfo.outDistance != ADIST_Small || callbackInfo.inAspectName == 'AttackHeavy' )
  2218. wasInCloseCombat = false;
  2219. else
  2220. wasInCloseCombat = true;
  2221. // W3EE - End
  2222.  
  2223. }
  2224. else
  2225. {
  2226. callbackInfo.outShouldTranslate = false;
  2227. callbackInfo.outSlideToPosition = parent.GetWorldPosition() + VecFromHeading( parent.GetCombatActionHeading() );
  2228.  
  2229. callbackInfo.outRotateToEnemyAngle = parent.GetCombatActionHeading();
  2230.  
  2231. playerToTargetAngleDiff = AngleDistance( callbackInfo.outRotateToEnemyAngle , VecHeading( parent.GetHeadingVector() ) );
  2232.  
  2233. //W3EE - Begin
  2234. // (Omnidirectional)
  2235. /*if( theInput.IsActionPressed('DistanceModifier') || ( theInput.LastUsedGamepad() && theInput.GetActionValue( 'GI_AxisLeftY' ) >= Options().GetPadDistanceLong() ) || ( theInput.LastUsedGamepad() && theInput.GetActionValue( 'GI_AxisLeftY' ) <= Options().GetPadDistanceLong() * -1.f ) || ( theInput.LastUsedGamepad() && theInput.GetActionValue( 'GI_AxisLeftX' ) >= Options().GetPadDistanceLong() ) || ( theInput.LastUsedGamepad() && theInput.GetActionValue( 'GI_AxisLeftX' ) <= Options().GetPadDistanceLong() * -1.f ) )
  2236. callbackInfo.outDistance = ADIST_Large;
  2237. else
  2238. if( theInput.IsActionPressed('DistanceModifierMed') || ( theInput.LastUsedGamepad() && theInput.GetActionValue( 'GI_AxisLeftY' ) >= Options().GetPadDistanceMedium() ) || ( theInput.LastUsedGamepad() && theInput.GetActionValue( 'GI_AxisLeftY' ) <= Options().GetPadDistanceMedium() * -1.f ) || ( theInput.LastUsedGamepad() && theInput.GetActionValue( 'GI_AxisLeftX' ) >= Options().GetPadDistanceMedium() ) || ( theInput.LastUsedGamepad() && theInput.GetActionValue( 'GI_AxisLeftX' ) <= Options().GetPadDistanceMedium() * -1.f ) )
  2239. callbackInfo.outDistance = ADIST_Medium;
  2240. else
  2241. callbackInfo.outDistance = ADIST_Small;*/
  2242.  
  2243. // (Forward Only)
  2244. if( theInput.IsActionPressed('DistanceModifier') || ( theInput.LastUsedGamepad() && theInput.GetActionValue('GI_AxisLeftY') >= Options().GetPadDistanceLong() ) )
  2245. callbackInfo.outDistance = ADIST_Large;
  2246. else
  2247. if( theInput.IsActionPressed('DistanceModifierMed') || ( theInput.LastUsedGamepad() && theInput.GetActionValue('GI_AxisLeftY') >= Options().GetPadDistanceMedium() ) )
  2248. callbackInfo.outDistance = ADIST_Medium;
  2249. else
  2250. callbackInfo.outDistance = ADIST_Small;
  2251. //W3EE - End
  2252. }
  2253.  
  2254. if ( playerToTargetAngleDiff < -135.f )
  2255. callbackInfo.outDirection = AD_Back;
  2256. else if ( playerToTargetAngleDiff < -45.f )
  2257. callbackInfo.outDirection = AD_Right;
  2258. else if ( playerToTargetAngleDiff > 135.f )
  2259. callbackInfo.outDirection = AD_Back;
  2260. else if ( playerToTargetAngleDiff > 45.f )
  2261. callbackInfo.outDirection = AD_Left;
  2262. else
  2263. callbackInfo.outDirection = AD_Front;
  2264.  
  2265.  
  2266. if ( callbackInfo.inStringAttackCounter == 0 || callbackInfo.inGlobalAttackCounter == 0 )
  2267. parent.SetBIsFirstAttackInCombo(true);
  2268. else if ( callbackInfo.inStringAttackCounter >= 2 )
  2269. parent.SetBIsFirstAttackInCombo(false);
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276. if ( callbackInfo.inAspectName == 'AttackNeutral' )
  2277. callbackInfo.outDirection = AD_Front;
  2278.  
  2279. if ( callbackInfo.inAspectName == 'AttackNeutral' )
  2280. callbackInfo.outAttackType = ComboAT_Normal;
  2281. else if( ( callbackInfo.inStringAttackCounter == 0 || AbsF(playerToTargetAngleDiff) >= 45.f || playerToTargetDist > farAttackMinDist || !parent.slideTarget ) )
  2282. {
  2283. callbackInfo.outAttackType = ComboAT_Directional;
  2284. callbackInfo.outShouldTranslate = true;
  2285. }
  2286. else
  2287. callbackInfo.outAttackType = ComboAT_Normal;
  2288.  
  2289. if ( callbackInfo.outShouldTranslate )
  2290. {
  2291. MarkSlidePosition( callbackInfo.outSlideToPosition );
  2292. }
  2293.  
  2294. if ( parent.GetBehaviorVariable( 'combatIdleStance' ) > 0.8 )
  2295. callbackInfo.outLeftString = false;
  2296. else
  2297. callbackInfo.outLeftString = true;
  2298.  
  2299. // W3EE - Begin
  2300. if( !isLightAttack && callbackInfo.outDistance == ADIST_Medium )
  2301. GetWitcherPlayer().SetAnimSpeed(0.9f);
  2302.  
  2303. if( callbackInfo.outDirection != AD_Front && callbackInfo.outDistance != ADIST_Small )
  2304. W3EEComboDef.SetStanceSwitched(false);
  2305.  
  2306. if ( callbackInfo.inAspectName == 'AttackHeavy' || callbackInfo.inAspectName == 'AttackHeavyReal' || callbackInfo.inAspectName == 'AttackLightSecondary' || callbackInfo.inAspectName == 'AttackBattleAxeFast' || callbackInfo.inAspectName == 'AttackBattleAxeHeavy' || W3EEComboDef.ShouldSwitchIdleAnim(callbackInfo.inAspectName == 'AttackLightReal' && callbackInfo.outDistance == ADIST_Small && callbackInfo.outDirection == AD_Front) )
  2307. // W3EE - End
  2308. parent.SetBehaviorVariable( 'playerAttackType', (int)PAT_Heavy );
  2309. else
  2310. {
  2311. parent.SetBehaviorVariable( 'playerAttackType', (int)PAT_Light );
  2312. }
  2313.  
  2314. parent.EnableCloseCombatCharacterRadius( enableCloseCombatRadius );
  2315. CacheComboAttack( callbackInfo.inAttackId, attackTarget, callbackInfo.outShouldTranslate, callbackInfo.inAspectName );
  2316. }
  2317.  
  2318. private function GetMaxAttackDist() : float
  2319. {
  2320. var maxAttackDist : float;
  2321.  
  2322. if ( parent.approachAttack == 0 )
  2323. maxAttackDist = 0.f;
  2324. else if ( parent.approachAttack == 2 )
  2325. maxAttackDist = 7.f;
  2326. else
  2327. maxAttackDist = 4.f;
  2328.  
  2329. return maxAttackDist;
  2330. }
  2331.  
  2332. private function GetPlayerToTargetDistance( getPredictedDistance : bool, translationScale : float, optional customTime : float ) : float
  2333. {
  2334. var predictionTime : float;
  2335. var targetCapsuleRadius : float;
  2336. var nearestPoint : Vector;
  2337. var nearestPointNoPredict : Vector;
  2338. var predictedPos : Vector;
  2339. var currentPos : Vector;
  2340. var scaledCurrToPredictedVector : Vector;
  2341. var capsuleOffsetVec : Vector;
  2342. var dist : float;
  2343. var distPredict : float;
  2344. var slideTargetNPC : CNewNPC;
  2345.  
  2346. if ( (CActor)(parent.slideTarget) )
  2347. targetCapsuleRadius = ((CMovingPhysicalAgentComponent)( (CActor)(parent.slideTarget) ).GetMovingAgentComponent()).GetCapsuleRadius();
  2348.  
  2349. if ( customTime > 0.f )
  2350. predictionTime = customTime;
  2351. else
  2352. predictionTime = 0.8f;
  2353.  
  2354. if ( getPredictedDistance && ( (CActor)(parent.slideTarget) ) && !parent.slideTarget.IsRagdolled() )
  2355. {
  2356. currentPos = parent.slideTarget.GetWorldPosition();
  2357. predictedPos = ( (CActor)(parent.slideTarget) ).PredictWorldPosition( predictionTime );
  2358. scaledCurrToPredictedVector = ( predictedPos - currentPos ) * translationScale;
  2359. predictedPos = currentPos + scaledCurrToPredictedVector;
  2360. capsuleOffsetVec = targetCapsuleRadius * VecNormalize( parent.GetWorldPosition() - parent.slideTarget.GetWorldPosition() );
  2361. nearestPoint = predictedPos + capsuleOffsetVec;
  2362. }
  2363. else
  2364. nearestPoint = parent.slideTarget.GetWorldPosition() + targetCapsuleRadius * VecNormalize( parent.GetWorldPosition() - parent.slideTarget.GetWorldPosition() );
  2365.  
  2366. nearestPointNoPredict = parent.slideTarget.GetWorldPosition() + capsuleOffsetVec;
  2367. distPredict = VecDistance( parent.GetWorldPosition(), nearestPoint );
  2368. dist = VecDistance( parent.GetWorldPosition(), nearestPointNoPredict );
  2369.  
  2370. if ( distPredict > dist )
  2371. {
  2372. parent.GetVisualDebug().AddSphere('playerToTargetDist', 0.25, nearestPoint, true, Color(128,128,128), 3.0f );
  2373. return distPredict;
  2374. }
  2375. else
  2376. {
  2377. slideTargetNPC = (CNewNPC)( parent.slideTarget );
  2378. if ( slideTargetNPC && slideTargetNPC.IsAttacking() && slideTargetNPC.GetTarget() == parent )
  2379. {
  2380. parent.GetVisualDebug().AddSphere('playerToTargetDist', 0.25, nearestPoint, true, Color(128,128,128), 3.0f );
  2381. return distPredict;
  2382. }
  2383. else
  2384. {
  2385. parent.GetVisualDebug().AddSphere('playerToTargetDist', 0.25, nearestPointNoPredict, true, Color(128,128,128), 3.0f );
  2386. return dist;
  2387. }
  2388. }
  2389. }
  2390.  
  2391. timer function CombatComboUpdate( timeDelta : float , id : int)
  2392. {
  2393. var stateName : name;
  2394.  
  2395. InteralCombatComboUpdate( timeDelta );
  2396.  
  2397. if( thePlayer.IsInCombatAction_Attack() && !thePlayer.IsInCombatActionFriendly() )
  2398. {
  2399. thePlayer.ProcessWeaponCollision();
  2400. }
  2401. }
  2402.  
  2403.  
  2404. protected final function InteralCombatComboUpdate( timeDelta : float )
  2405. {
  2406. var slidePosition : Vector;
  2407. var slideRotationVector : Vector;
  2408. var slideRotation : float;
  2409. var targetNearestPoint : Vector;
  2410. var playerToTargetDist : float;
  2411. var playerRadius : float;
  2412.  
  2413. var heading : float;
  2414.  
  2415. if ( comboAttackA_Target )
  2416. {
  2417.  
  2418. if ( (CActor)comboAttackA_Target )
  2419. playerToTargetDist = VecDistance( parent.GetWorldPosition(), ( (CActor)comboAttackA_Target ).GetNearestPointInBothPersonalSpaces( parent.GetWorldPosition() ) );
  2420. else
  2421. playerToTargetDist = VecDistance( parent.GetWorldPosition(), comboAttackA_Target.GetWorldPosition() );
  2422.  
  2423. if ( !((CActor)comboAttackA_Target).GetGameplayVisibility() )
  2424. updatePosition = false;
  2425.  
  2426. if ( ( parent.GetOrientationTarget() == OT_Camera || parent.GetOrientationTarget() == OT_CameraOffset ) && playerToTargetDist > 1.5f )
  2427. updatePosition = false;
  2428.  
  2429.  
  2430.  
  2431.  
  2432. if ( parent.moveTarget && !parent.IsThreat( parent.moveTarget ) && comboAttackA_Target )
  2433. {
  2434. if ( VecDistance( comboAttackA_Target.GetWorldPosition(), parent.GetWorldPosition() ) > parent.interactDist
  2435. || AbsF( AngleDistance( parent.GetCombatActionHeading(), VecHeading( comboAttackA_Target.GetWorldPosition() - parent.GetWorldPosition() ) ) ) > 90.f )
  2436. updatePosition = false;
  2437. }
  2438.  
  2439. if ( updatePosition && comboAttackA_Id != -1 )
  2440. {
  2441. if ( (CActor)comboAttackA_Target )
  2442. targetNearestPoint = ( (CActor)comboAttackA_Target ).GetNearestPointInPersonalSpace( parent.GetWorldPosition() ) ;
  2443. else
  2444. targetNearestPoint = comboAttackA_Target.GetWorldPosition();
  2445. playerRadius = ((CMovingPhysicalAgentComponent)(parent).GetMovingAgentComponent()).GetCapsuleRadius();
  2446. slidePosition = playerRadius * VecNormalize( parent.GetWorldPosition() - comboAttackA_Target.GetWorldPosition() ) + targetNearestPoint;
  2447. slideRotationVector = comboAttackA_Target.GetWorldPosition() - parent.GetWorldPosition();
  2448. slideRotation = VecHeading( slideRotationVector );
  2449. comboPlayer.UpdateTarget( comboAttackA_Id, slidePosition, slideRotation, true, true );
  2450.  
  2451. if ( comboAttackA_Sliding )
  2452. {
  2453. MarkSlidePosition( slidePosition );
  2454. }
  2455. }
  2456.  
  2457. if ( !updatePosition && comboAttackA_Id != -1 )
  2458. comboPlayer.UpdateTarget( comboAttackA_Id, parent.GetWorldPosition() + VecFromHeading( parent.GetCombatActionHeading() ), parent.GetCombatActionHeading(), true, true );
  2459. }
  2460. else if ( comboAttackA_Id != -1 && parent.IsInCombatAction() && parent.GetBehaviorVariable( 'combatActionType' ) == 0.f )
  2461. {
  2462. comboPlayer.UpdateTarget( comboAttackA_Id, parent.GetWorldPosition() + VecFromHeading( parent.GetCombatActionHeading() ), parent.GetCombatActionHeading(), true, true );
  2463.  
  2464. }
  2465.  
  2466. if(comboPlayer)
  2467. comboPlayer.Update( timeDelta );
  2468. }
  2469.  
  2470. private final function MarkSlidePosition( position : Vector )
  2471. {
  2472. parent.GetVisualDebug().AddSphere('slidePos', 0.5f, position, true, Color(255,0,255), 5.0f );
  2473. }
  2474.  
  2475. public final function ResetComboPlayerAndGoToIdle()
  2476. {
  2477. comboPlayer.Deinit();
  2478. parent.GetRootAnimatedComponent().RaiseBehaviorForceEvent( 'ToIdle' );
  2479. }
  2480.  
  2481. private var ticketRequests : array<int>;
  2482. private var ticketNames : array<name>;
  2483.  
  2484. private function BlockAllCombatTickets( block : bool )
  2485. {
  2486. var combatData : CCombatDataComponent;
  2487. var tmpTicketRequest : int;
  2488. var i : int;
  2489.  
  2490. combatData = parent.GetCombatDataComponent();
  2491.  
  2492. if ( ticketNames.Size() <= 0 )
  2493. InitTicketNames();
  2494.  
  2495. ReleaseTicketRequests();
  2496.  
  2497. if ( block )
  2498. {
  2499. for ( i=0; i<ticketNames.Size(); i+=1 )
  2500. {
  2501. tmpTicketRequest = combatData.TicketSourceOverrideRequest( ticketNames[i], 0, 10000000.0 );
  2502. ticketRequests.PushBack(tmpTicketRequest);
  2503. }
  2504. ForceTicketUpdate();
  2505. }
  2506. }
  2507.  
  2508. private function ReleaseTicketRequests()
  2509. {
  2510. var i : int;
  2511. var combatData : CCombatDataComponent;
  2512.  
  2513. combatData = parent.GetCombatDataComponent();
  2514.  
  2515. for ( i=0; i<ticketRequests.Size(); i+=1 )
  2516. {
  2517. combatData.TicketSourceClearRequest( ticketNames[i], ticketRequests[i] );
  2518. }
  2519. ticketRequests.Clear();
  2520. }
  2521.  
  2522. private function ForceTicketUpdate()
  2523. {
  2524. var i : int;
  2525. var combatData : CCombatDataComponent;
  2526.  
  2527. combatData = parent.GetCombatDataComponent();
  2528.  
  2529. for ( i=0; i<ticketRequests.Size(); i+=1 )
  2530. {
  2531. combatData.ForceTicketImmediateImportanceUpdate( ticketNames[i]);
  2532. }
  2533. }
  2534.  
  2535. private function InitTicketNames()
  2536. {
  2537. ticketNames.PushBack('TICKET_Melee');
  2538. ticketNames.PushBack('TICKET_Range');
  2539. ticketNames.PushBack('TICKET_Special');
  2540. ticketNames.PushBack('TICKET_Charge');
  2541. }
  2542.  
  2543. event OnBlockAllCombatTickets( block : bool )
  2544. {
  2545. BlockAllCombatTickets( block );
  2546. }
  2547.  
  2548. event OnForceTicketUpdate()
  2549. {
  2550. ForceTicketUpdate();
  2551. }
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557. event OnCombatActionEndComplete()
  2558. {
  2559. parent.EnableCloseCombatCharacterRadius( false );
  2560. parent.OnCombatActionEndComplete();
  2561. parent.SetBIsFirstAttackInCombo(false);
  2562. }
  2563. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement