Advertisement
Guest User

playerinput

a guest
Sep 9th, 2018
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 75.39 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. class CPlayerInput
  10. {
  11. private saved var actionLocks : array<array<SInputActionLock>>;
  12.  
  13. private var totalCameraPresetChange : float; default totalCameraPresetChange = 0.0f;
  14. private var potAction : SInputAction;
  15. private var potPress : bool;
  16. private var debugBlockSourceName : name; default debugBlockSourceName = 'PLAYER';
  17. private var holdFastMenuInvoked : bool; default holdFastMenuInvoked = false;
  18. private var potionUpperHeld, potionLowerHeld : bool;
  19. private var potionModeHold : bool;
  20.  
  21. default potionModeHold = true;
  22.  
  23. public function Initialize(isFromLoad : bool, optional previousInput : CPlayerInput)
  24. {
  25. var missingLocksCount, i : int;
  26. var dummy : array<SInputActionLock>;
  27.  
  28. if(previousInput)
  29. {
  30. actionLocks = previousInput.actionLocks;
  31. }
  32. else
  33. {
  34. if(!isFromLoad)
  35. {
  36. actionLocks.Grow(EnumGetMax('EInputActionBlock')+1);
  37. }
  38. else
  39. {
  40. missingLocksCount = EnumGetMax('EInputActionBlock') + 1 - actionLocks.Size();
  41. for ( i = 0; i < missingLocksCount; i += 1 )
  42. {
  43. actionLocks.PushBack( dummy );
  44. }
  45. }
  46. }
  47.  
  48. theInput.RegisterListener( this, 'OnCommSprint', 'Sprint' );
  49. theInput.RegisterListener( this, 'OnCommSprintToggle', 'SprintToggle' );
  50. theInput.RegisterListener( this, 'OnCommWalkToggle', 'WalkToggle' );
  51. theInput.RegisterListener( this, 'OnCommGuard', 'Guard' );
  52. //---=== modFriendlyMeditation ===---
  53. theInput.RegisterListener( this, 'OnHoldToMeditate', 'HoldToMeditate' );
  54. theInput.RegisterListener( this, 'OnMeditationFastForward', 'MeditationFastForward' );
  55. theInput.RegisterListener( this, 'OnToggleSpawnCampFire', 'ToggleSpawnCampFire' );
  56. //---=== modFriendlyMeditation ===---
  57.  
  58.  
  59. theInput.RegisterListener( this, 'OnCommSpawnHorse', 'SpawnHorse' );
  60.  
  61.  
  62.  
  63. theInput.RegisterListener( this, 'OnCommDrinkPotion1', 'DrinkPotion1' );
  64. theInput.RegisterListener( this, 'OnCommDrinkPotion2', 'DrinkPotion2' );
  65. theInput.RegisterListener( this, 'OnCommDrinkPotion3', 'DrinkPotion3' );
  66. theInput.RegisterListener( this, 'OnCommDrinkPotion4', 'DrinkPotion4' );
  67. theInput.RegisterListener( this, 'OnCommDrinkpotionUpperHeld', 'DrinkPotionUpperHold' );
  68. theInput.RegisterListener( this, 'OnCommDrinkpotionLowerHeld', 'DrinkPotionLowerHold' );
  69.  
  70.  
  71. theInput.RegisterListener( this, 'OnCommSteelSword', 'SteelSword' );
  72. theInput.RegisterListener( this, 'OnCommSilverSword', 'SilverSword' );
  73. theInput.RegisterListener( this, 'OnCommSheatheAny', 'SwordSheathe' );
  74. theInput.RegisterListener( this, 'OnCommSheatheSilver', 'SwordSheatheSilver' );
  75. theInput.RegisterListener( this, 'OnCommSheatheSteel', 'SwordSheatheSteel' );
  76.  
  77. theInput.RegisterListener( this, 'OnToggleSigns', 'ToggleSigns' );
  78. theInput.RegisterListener( this, 'OnSelectSign', 'SelectAard' );
  79. theInput.RegisterListener( this, 'OnSelectSign', 'SelectYrden' );
  80. theInput.RegisterListener( this, 'OnSelectSign', 'SelectIgni' );
  81. theInput.RegisterListener( this, 'OnSelectSign', 'SelectQuen' );
  82. theInput.RegisterListener( this, 'OnSelectSign', 'SelectAxii' );
  83.  
  84.  
  85.  
  86. theInput.RegisterListener( this, 'OnCommDeckEditor', 'PanelGwintDeckEditor' );
  87. theInput.RegisterListener( this, 'OnCommMenuHub', 'HubMenu' );
  88. theInput.RegisterListener( this, 'OnCommPanelInv', 'PanelInv' );
  89. theInput.RegisterListener( this, 'OnCommHoldFastMenu', 'HoldFastMenu' );
  90. theInput.RegisterListener( this, 'OnCommPanelChar', 'PanelChar' );
  91. theInput.RegisterListener( this, 'OnCommPanelMed', 'PanelMed' );
  92. theInput.RegisterListener( this, 'OnCommPanelMap', 'PanelMap' );
  93. theInput.RegisterListener( this, 'OnCommPanelMapPC', 'PanelMapPC' );
  94. theInput.RegisterListener( this, 'OnCommPanelJour', 'PanelJour' );
  95. theInput.RegisterListener( this, 'OnCommPanelAlch', 'PanelAlch' );
  96. theInput.RegisterListener( this, 'OnCommPanelGlossary', 'PanelGlossary' );
  97. theInput.RegisterListener( this, 'OnCommPanelBestiary', 'PanelBestiary' );
  98. theInput.RegisterListener( this, 'OnCommPanelMeditation', 'PanelMeditation' );
  99. theInput.RegisterListener( this, 'OnCommPanelCrafting', 'PanelCrafting' );
  100. theInput.RegisterListener( this, 'OnShowControlsHelp', 'ControlsHelp' );
  101. theInput.RegisterListener( this, 'OnCommPanelUIResize', 'PanelUIResize' );
  102.  
  103. theInput.RegisterListener( this, 'OnCastSign', 'CastSign' );
  104. theInput.RegisterListener( this, 'OnExpFocus', 'Focus' );
  105. theInput.RegisterListener( this, 'OnExpMedallion', 'Medallion' );
  106.  
  107.  
  108. theInput.RegisterListener( this, 'OnBoatDismount', 'BoatDismount' );
  109.  
  110. theInput.RegisterListener( this, 'OnDiving', 'DiveDown' );
  111. theInput.RegisterListener( this, 'OnDiving', 'DiveUp' );
  112. theInput.RegisterListener( this, 'OnDivingDodge', 'DiveDodge' );
  113.  
  114.  
  115. theInput.RegisterListener( this, 'OnCbtSpecialAttackWithAlternateLight', 'SpecialAttackWithAlternateLight' );
  116. theInput.RegisterListener( this, 'OnCbtSpecialAttackWithAlternateHeavy', 'SpecialAttackWithAlternateHeavy' );
  117. theInput.RegisterListener( this, 'OnCbtAttackWithAlternateLight', 'AttackWithAlternateLight' );
  118. theInput.RegisterListener( this, 'OnCbtAttackWithAlternateHeavy', 'AttackWithAlternateHeavy' );
  119.  
  120. theInput.RegisterListener( this, 'OnCbtAttackLight', 'AttackLight' );
  121. theInput.RegisterListener( this, 'OnCbtAttackHeavy', 'AttackHeavy' );
  122. theInput.RegisterListener( this, 'OnCbtSpecialAttackLight', 'SpecialAttackLight' );
  123. theInput.RegisterListener( this, 'OnCbtSpecialAttackHeavy', 'SpecialAttackHeavy' );
  124. theInput.RegisterListener( this, 'OnCbtDodge', 'Dodge' );
  125. theInput.RegisterListener( this, 'OnCbtRoll', 'CbtRoll' );
  126. theInput.RegisterListener( this, 'OnMovementDoubleTap', 'MovementDoubleTapW' );
  127. theInput.RegisterListener( this, 'OnMovementDoubleTap', 'MovementDoubleTapS' );
  128. theInput.RegisterListener( this, 'OnMovementDoubleTap', 'MovementDoubleTapA' );
  129. theInput.RegisterListener( this, 'OnMovementDoubleTap', 'MovementDoubleTapD' );
  130. theInput.RegisterListener( this, 'OnCbtLockAndGuard', 'LockAndGuard' );
  131. theInput.RegisterListener( this, 'OnCbtCameraLockOrSpawnHorse', 'CameraLockOrSpawnHorse' );
  132. theInput.RegisterListener( this, 'OnCbtCameraLock', 'CameraLock' );
  133. theInput.RegisterListener( this, 'OnCbtComboDigitLeft', 'ComboDigitLeft' );
  134. theInput.RegisterListener( this, 'OnCbtComboDigitRight', 'ComboDigitRight' );
  135.  
  136.  
  137.  
  138. theInput.RegisterListener( this, 'OnCbtCiriSpecialAttack', 'CiriSpecialAttack' );
  139. theInput.RegisterListener( this, 'OnCbtCiriAttackHeavy', 'CiriAttackHeavy' );
  140. theInput.RegisterListener( this, 'OnCbtCiriSpecialAttackHeavy', 'CiriSpecialAttackHeavy' );
  141. theInput.RegisterListener( this, 'OnCbtCiriDodge', 'CiriDodge' );
  142. theInput.RegisterListener( this, 'OnCbtCiriDash', 'CiriDash' );
  143.  
  144.  
  145. theInput.RegisterListener( this, 'OnCbtThrowItem', 'ThrowItem' );
  146. theInput.RegisterListener( this, 'OnCbtThrowItemHold', 'ThrowItemHold' );
  147. theInput.RegisterListener( this, 'OnCbtThrowCastAbort', 'ThrowCastAbort' );
  148.  
  149.  
  150. theInput.RegisterListener( this, 'OnCiriDrawWeapon', 'CiriDrawWeapon' );
  151. theInput.RegisterListener( this, 'OnCiriDrawWeapon', 'CiriDrawWeaponAlternative' );
  152. theInput.RegisterListener( this, 'OnCiriHolsterWeapon', 'CiriHolsterWeapon' );
  153.  
  154.  
  155. if( !theGame.IsFinalBuild() )
  156. {
  157. theInput.RegisterListener( this, 'OnDbgSpeedUp', 'Debug_SpeedUp' );
  158. theInput.RegisterListener( this, 'OnDbgHit', 'Debug_Hit' );
  159. theInput.RegisterListener( this, 'OnDbgKillTarget', 'Debug_KillTarget' );
  160. theInput.RegisterListener( this, 'OnDbgKillAll', 'Debug_KillAllEnemies' );
  161. theInput.RegisterListener( this, 'OnDbgKillAllTargetingPlayer', 'Debug_KillAllTargetingPlayer' );
  162. theInput.RegisterListener( this, 'OnCommPanelFakeHud', 'PanelFakeHud' );
  163. theInput.RegisterListener( this, 'OnDbgTeleportToPin', 'Debug_TeleportToPin' );
  164. }
  165.  
  166.  
  167. theInput.RegisterListener( this, 'OnChangeCameraPreset', 'CameraPreset' );
  168. theInput.RegisterListener( this, 'OnChangeCameraPresetByMouseWheel', 'CameraPresetByMouseWheel' );
  169. theInput.RegisterListener( this, 'OnMeditationAbort', 'MeditationAbort');
  170.  
  171. theInput.RegisterListener( this, 'OnFastMenu', 'FastMenu' );
  172. theInput.RegisterListener( this, 'OnIngameMenu', 'IngameMenu' );
  173.  
  174. theInput.RegisterListener( this, 'OnToggleHud', 'ToggleHud' );
  175. }
  176.  
  177.  
  178. function Destroy()
  179. {
  180. }
  181.  
  182.  
  183.  
  184.  
  185.  
  186. public function FindActionLockIndex(action : EInputActionBlock, sourceName : name) : int
  187. {
  188. var i : int;
  189.  
  190. for(i=0; i<actionLocks[action].Size(); i+=1)
  191. if(actionLocks[action][i].sourceName == sourceName)
  192. return i;
  193.  
  194. return -1;
  195. }
  196.  
  197.  
  198. public function BlockAction(action : EInputActionBlock, sourceName : name, lock : bool, optional keepOnSpawn : bool, optional onSpawnedNullPointerHackFix : CPlayer, optional isFromQuest : bool, optional isFromPlace : bool)
  199. {
  200. var index : int;
  201. var isLocked, wasLocked : bool;
  202. var actionLock : SInputActionLock;
  203.  
  204. if (action == EIAB_HighlightObjective)
  205. {
  206. index = FindActionLockIndex(action, sourceName);
  207. }
  208.  
  209. index = FindActionLockIndex(action, sourceName);
  210.  
  211. wasLocked = (actionLocks[action].Size() > 0);
  212.  
  213. if(lock)
  214. {
  215. if(index != -1)
  216. return;
  217.  
  218. actionLock.sourceName = sourceName;
  219.  
  220. if( action == EIAB_CameraLock )
  221. {
  222. actionLock.removedOnSpawn = true;
  223. }
  224. else
  225. {
  226. actionLock.removedOnSpawn = !keepOnSpawn;
  227. }
  228. actionLock.isFromQuest = isFromQuest;
  229. actionLock.isFromPlace = isFromPlace;
  230.  
  231. actionLocks[action].PushBack(actionLock);
  232. }
  233. else
  234. {
  235. if(index == -1)
  236. return;
  237.  
  238. actionLocks[action].Erase(index);
  239. }
  240.  
  241. isLocked = (actionLocks[action].Size() > 0);
  242. if(isLocked != wasLocked)
  243. OnActionLockChanged(action, isLocked, sourceName, onSpawnedNullPointerHackFix);
  244. }
  245.  
  246.  
  247. public final function TutorialForceUnblockRadial() : array<SInputActionLock>
  248. {
  249. var ret : array<SInputActionLock>;
  250.  
  251. ret = actionLocks[EIAB_RadialMenu];
  252.  
  253. actionLocks[EIAB_RadialMenu].Clear();
  254.  
  255. thePlayer.SetBIsInputAllowed(true, '');
  256.  
  257. BlockAction( EIAB_Signs, 'ToxicGasTutorial', true, true, NULL, false);
  258.  
  259. return ret;
  260. }
  261.  
  262.  
  263. public final function TutorialForceRestoreRadialLocks(radialLocks : array<SInputActionLock>)
  264. {
  265. actionLocks[EIAB_RadialMenu] = radialLocks;
  266. thePlayer.UnblockAction(EIAB_Signs, 'ToxicGasTutorial' );
  267. }
  268.  
  269. private function OnActionLockChanged(action : EInputActionBlock, locked : bool, optional sourceName : name, optional onSpawnedNullPointerHackFix : CPlayer)
  270. {
  271. var player : CPlayer;
  272. var lockType : EPlayerInteractionLock;
  273. var hud : CR4ScriptedHud;
  274. var guiManager : CR4GuiManager;
  275. var rootMenu : CR4MenuBase;
  276.  
  277.  
  278. if( sourceName == debugBlockSourceName )
  279. {
  280.  
  281. sourceName = sourceName;
  282. }
  283.  
  284.  
  285. if(action == EIAB_FastTravel)
  286. {
  287. theGame.GetCommonMapManager().EnableFastTravelling(!locked);
  288. }
  289. else if(action == EIAB_Interactions)
  290. {
  291.  
  292. if(sourceName == 'InsideCombatAction')
  293. lockType = PIL_CombatAction;
  294. else
  295. lockType = PIL_Default;
  296.  
  297. if(!thePlayer)
  298. player = onSpawnedNullPointerHackFix;
  299. else
  300. player = thePlayer;
  301.  
  302. if(player)
  303. {
  304. if(locked)
  305. player.LockButtonInteractions(lockType);
  306. else
  307. player.UnlockButtonInteractions(lockType);
  308. }
  309.  
  310.  
  311. hud = (CR4ScriptedHud)theGame.GetHud();
  312. if ( hud )
  313. {
  314. hud.ForceInteractionUpdate();
  315. }
  316. }
  317. else if(action == EIAB_Movement && locked && thePlayer)
  318. {
  319.  
  320. if(thePlayer.IsUsingVehicle() && thePlayer.GetCurrentStateName() == 'HorseRiding')
  321. {
  322. ((CActor)thePlayer.GetUsedVehicle()).GetMovingAgentComponent().ResetMoveRequests();
  323. thePlayer.GetUsedVehicle().SetBehaviorVariable( '2idle', 1);
  324.  
  325. thePlayer.SetBehaviorVariable( 'speed', 0);
  326. thePlayer.SetBehaviorVariable( '2idle', 1);
  327. }
  328. else if(!thePlayer.IsInAir())
  329. {
  330. thePlayer.RaiseForceEvent( 'Idle' );
  331. }
  332. }
  333. else if (action == EIAB_DismountVehicle)
  334. {
  335. guiManager = theGame.GetGuiManager();
  336.  
  337. if (guiManager)
  338. {
  339. guiManager.UpdateDismountAvailable(locked);
  340. }
  341. }
  342. else if (action == EIAB_OpenPreparation || action == EIAB_OpenMap || action == EIAB_OpenInventory ||
  343. action == EIAB_OpenJournal || action == EIAB_OpenCharacterPanel || action == EIAB_OpenGlossary ||
  344. action == EIAB_OpenAlchemy || action == EIAB_MeditationWaiting || action == EIAB_OpenMeditation)
  345. {
  346. guiManager = theGame.GetGuiManager();
  347.  
  348. if (guiManager && guiManager.IsAnyMenu())
  349. {
  350. rootMenu = (CR4MenuBase)guiManager.GetRootMenu();
  351.  
  352. if (rootMenu)
  353. {
  354. rootMenu.ActionBlockStateChange(action, locked);
  355. }
  356. }
  357. }
  358. }
  359.  
  360. public function BlockAllActions(sourceName : name, lock : bool, optional exceptions : array<EInputActionBlock>, optional saveLock : bool, optional onSpawnedNullPointerHackFix : CPlayer, optional isFromQuest : bool, optional isFromPlace : bool)
  361. {
  362. var i, size : int;
  363.  
  364. size = EnumGetMax('EInputActionBlock')+1;
  365. for(i=0; i<size; i+=1)
  366. {
  367. if ( exceptions.Contains(i) || i == EIAB_CameraLock )
  368. continue;
  369.  
  370. BlockAction(i, sourceName, lock, saveLock, onSpawnedNullPointerHackFix, isFromQuest, isFromPlace);
  371. }
  372. }
  373.  
  374.  
  375. public final function BlockAllQuestActions(sourceName : name, lock : bool)
  376. {
  377. var action, j, size : int;
  378. var isLocked, wasLocked : bool;
  379. var exceptions : array< EInputActionBlock >;
  380.  
  381. if(lock)
  382. {
  383.  
  384. exceptions.PushBack( EIAB_FastTravelGlobal );
  385. BlockAllActions(sourceName, lock, exceptions, true, , true);
  386. }
  387. else
  388. {
  389.  
  390. size = EnumGetMax('EInputActionBlock')+1;
  391. for(action=0; action<size; action+=1)
  392. {
  393. wasLocked = (actionLocks[action].Size() > 0);
  394.  
  395. for(j=0; j<actionLocks[action].Size();)
  396. {
  397. if(actionLocks[action][j].isFromQuest)
  398. {
  399. actionLocks[action].EraseFast(j);
  400. }
  401. else
  402. {
  403. j += 1;
  404. }
  405. }
  406.  
  407. isLocked = (actionLocks[action].Size() > 0);
  408. if(wasLocked != isLocked)
  409. OnActionLockChanged(action, isLocked);
  410. }
  411. }
  412. }
  413.  
  414.  
  415. public function BlockAllUIQuestActions(sourceName : name, lock : bool)
  416. {
  417. var i, j, action, size : int;
  418. var uiActions : array<int>;
  419. var wasLocked, isLocked : bool;
  420.  
  421. if( lock )
  422. {
  423. BlockAction(EIAB_OpenInventory, sourceName, true, true, NULL, false);
  424. BlockAction(EIAB_MeditationWaiting, sourceName, true, true, NULL, false);
  425. BlockAction(EIAB_OpenMeditation, sourceName, true, true, NULL, false);
  426. BlockAction(EIAB_FastTravel, sourceName, true, true, NULL, false);
  427. BlockAction(EIAB_OpenMap, sourceName, true, true, NULL, false);
  428. BlockAction(EIAB_OpenCharacterPanel, sourceName, true, true, NULL, false);
  429. BlockAction(EIAB_OpenJournal, sourceName, true, true, NULL, false);
  430. BlockAction(EIAB_OpenAlchemy, sourceName, true, true, NULL, false);
  431. }
  432. else
  433. {
  434.  
  435. uiActions.Resize(8);
  436. uiActions[0] = EIAB_OpenInventory;
  437. uiActions[1] = EIAB_MeditationWaiting;
  438. uiActions[2] = EIAB_OpenMeditation;
  439. uiActions[3] = EIAB_FastTravel;
  440. uiActions[4] = EIAB_OpenMap;
  441. uiActions[5] = EIAB_OpenCharacterPanel;
  442. uiActions[6] = EIAB_OpenJournal;
  443. uiActions[7] = EIAB_OpenAlchemy;
  444.  
  445. size = uiActions.Size();
  446. for(i=0; i<size; i+=1)
  447. {
  448. action = uiActions[i];
  449.  
  450. wasLocked = (actionLocks[action].Size() > 0);
  451.  
  452. for(j=0; j<actionLocks[action].Size();)
  453. {
  454. if(actionLocks[action][j].isFromQuest)
  455. {
  456. actionLocks[action].EraseFast(j);
  457. }
  458. else
  459. {
  460. j += 1;
  461. }
  462. }
  463.  
  464. isLocked = (actionLocks[action].Size() > 0);
  465. if(wasLocked != isLocked)
  466. OnActionLockChanged(action, isLocked);
  467. }
  468. }
  469. }
  470.  
  471.  
  472. public function ForceUnlockAllInputActions(alsoQuestLocks : bool)
  473. {
  474. var i, j : int;
  475.  
  476. for(i=0; i<=EnumGetMax('EInputActionBlock'); i+=1)
  477. {
  478. if(alsoQuestLocks)
  479. {
  480. actionLocks[i].Clear();
  481. OnActionLockChanged(i, false);
  482. }
  483. else
  484. {
  485. for(j=actionLocks[i].Size()-1; j>=0; j-=1)
  486. {
  487. if(actionLocks[i][j].removedOnSpawn)
  488. actionLocks[i].Erase(j);
  489. }
  490.  
  491. if(actionLocks[i].Size() == 0)
  492. OnActionLockChanged(i, false);
  493. }
  494. }
  495. }
  496.  
  497. public function RemoveLocksOnSpawn()
  498. {
  499. var i, j : int;
  500.  
  501. for(i=0; i<actionLocks.Size(); i+=1)
  502. {
  503. for(j=actionLocks[i].Size()-1; j>=0; j-=1)
  504. {
  505. if(actionLocks[i][j].removedOnSpawn || i == EIAB_CameraLock)
  506. {
  507. actionLocks[i].Erase(j);
  508. }
  509. }
  510. }
  511. }
  512.  
  513. public function GetActionLocks(action : EInputActionBlock) : array< SInputActionLock >
  514. {
  515. return actionLocks[action];
  516. }
  517.  
  518. public function GetAllActionLocks() : array< array< SInputActionLock > >
  519. {
  520. return actionLocks;
  521. }
  522.  
  523. public function IsActionAllowed(action : EInputActionBlock) : bool
  524. {
  525. var actionAllowed : bool;
  526. actionAllowed = (actionLocks[action].Size() == 0);
  527. return actionAllowed;
  528. }
  529.  
  530. public function IsActionBlockedBy( action : EInputActionBlock, sourceName : name ) : bool
  531. {
  532. return FindActionLockIndex( action, sourceName ) != -1;
  533. }
  534.  
  535. public final function GetActionBlockedHudLockType(action : EInputActionBlock) : name
  536. {
  537. var i : int;
  538.  
  539. if(action == EIAB_Undefined)
  540. return '';
  541.  
  542. for(i=0; i<actionLocks[action].Size(); i+=1)
  543. {
  544. if(actionLocks[action][i].isFromPlace)
  545. return 'place';
  546. }
  547.  
  548. if(actionLocks[action].Size() > 0)
  549. return 'time';
  550.  
  551. return '';
  552. }
  553.  
  554.  
  555.  
  556. private var accelerateTimestamp : float;
  557. private var triedDoubleTap : bool;
  558. event OnCommSprint( action : SInputAction )
  559. {
  560. if( IsPressed( action ) )
  561. {
  562. //ImmersiveMotion++
  563.  
  564. if( accelerateTimestamp + DOUBLE_TAP_WINDOW >= theGame.GetEngineTimeAsSeconds() )
  565. {
  566. triedDoubleTap = true;
  567. }
  568. else
  569. {
  570. triedDoubleTap = false;
  571. }
  572.  
  573. if( triedDoubleTap )
  574. thePlayer.SetSprintSpeed(1.5);
  575. else
  576. thePlayer.SetSprintSpeed(1.0);
  577.  
  578. //ImmersiveMotion--
  579.  
  580. thePlayer.SetSprintActionPressed(true);
  581.  
  582. if ( thePlayer.rangedWeapon )
  583. thePlayer.rangedWeapon.OnSprintHolster();
  584. }
  585.  
  586. accelerateTimestamp = theGame.GetEngineTimeAsSeconds(); //ImmersiveMotion
  587. }
  588.  
  589. event OnCommSprintToggle( action : SInputAction )
  590. {
  591. if( IsPressed(action) )
  592. {
  593. if ( thePlayer.GetIsSprintToggled() )
  594. thePlayer.SetSprintToggle( false );
  595. else
  596. thePlayer.SetSprintToggle( true );
  597. }
  598. }
  599.  
  600. event OnCommWalkToggle( action : SInputAction )
  601. {
  602. if( IsPressed(action) && !thePlayer.GetIsSprinting() && !thePlayer.modifyPlayerSpeed )
  603. {
  604. if ( thePlayer.GetIsWalkToggled() )
  605. thePlayer.SetWalkToggle( false );
  606. else
  607. thePlayer.SetWalkToggle( true );
  608. }
  609. }
  610.  
  611.  
  612. event OnCommGuard( action : SInputAction )
  613. {
  614. if(thePlayer.IsCiri() && !GetCiriPlayer().HasSword())
  615. return false;
  616.  
  617. if ( !thePlayer.IsInsideInteraction() )
  618. {
  619. if ( IsActionAllowed(EIAB_Parry) )
  620. {
  621. if( IsReleased(action) && thePlayer.GetCurrentStateName() == 'CombatFists' )
  622. thePlayer.OnGuardedReleased();
  623.  
  624. if( IsPressed(action) )
  625. {
  626. thePlayer.AddCounterTimeStamp(theGame.GetEngineTime());
  627. thePlayer.SetGuarded(true);
  628. thePlayer.OnPerformGuard();
  629. }
  630. else if( IsReleased(action) )
  631. {
  632. thePlayer.SetGuarded(false);
  633. }
  634. }
  635. else
  636. {
  637. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Parry);
  638. }
  639. }
  640. }
  641.  
  642.  
  643.  
  644.  
  645.  
  646. private var pressTimestamp : float;
  647. private const var DOUBLE_TAP_WINDOW : float;
  648. default DOUBLE_TAP_WINDOW = 0.4;
  649.  
  650. event OnCommSpawnHorse( action : SInputAction )
  651. {
  652. var doubleTap : bool;
  653.  
  654. if( IsPressed( action ) )
  655. {
  656. if( pressTimestamp + DOUBLE_TAP_WINDOW >= theGame.GetEngineTimeAsSeconds() )
  657. {
  658. doubleTap = true;
  659. }
  660. else
  661. {
  662. doubleTap = false;
  663. }
  664.  
  665. if( IsActionAllowed( EIAB_CallHorse ) && !thePlayer.IsInInterior() && !thePlayer.IsInAir() )
  666. {
  667.  
  668. if( doubleTap || theInput.LastUsedPCInput() )
  669. {
  670. if ( thePlayer.IsHoldingItemInLHand () )
  671. {
  672. thePlayer.OnUseSelectedItem(true);
  673. thePlayer.SetPlayerActionToRestore ( PATR_CallHorse );
  674. }
  675. else
  676. {
  677. theGame.OnSpawnPlayerHorse();
  678. }
  679. }
  680. }
  681. else
  682. {
  683. if( thePlayer.IsInInterior() )
  684. thePlayer.DisplayActionDisallowedHudMessage( EIAB_Undefined, false, true );
  685. else
  686. thePlayer.DisplayActionDisallowedHudMessage( EIAB_CallHorse );
  687. }
  688.  
  689. pressTimestamp = theGame.GetEngineTimeAsSeconds();
  690.  
  691. return true;
  692. }
  693.  
  694. return false;
  695. }
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702. event OnCommMenuHub( action : SInputAction )
  703. {
  704. if(IsReleased(action))
  705. {
  706. PushMenuHub();
  707. }
  708. }
  709.  
  710. final function PushMenuHub()
  711. {
  712. if ( theGame.IsBlackscreenOrFading() )
  713. {
  714. return;
  715. }
  716. theGame.RequestMenu('CommonMenu');
  717. }
  718.  
  719.  
  720.  
  721. event OnCommPanelChar( action : SInputAction )
  722. {
  723. if(IsReleased(action))
  724. {
  725. PushCharacterScreen();
  726. }
  727. }
  728. final function PushCharacterScreen()
  729. {
  730. if ( theGame.IsBlackscreenOrFading() )
  731. {
  732. return;
  733. }
  734.  
  735. if( IsActionAllowed(EIAB_OpenCharacterPanel) )
  736. {
  737. theGame.RequestMenuWithBackground( 'CharacterMenu', 'CommonMenu' );
  738. }
  739. else
  740. {
  741. thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenCharacterPanel);
  742. }
  743. }
  744.  
  745.  
  746. event OnCommPanelInv( action : SInputAction )
  747. {
  748. if (IsReleased(action))
  749. {
  750. PushInventoryScreen();
  751. }
  752. }
  753.  
  754. final function PushInventoryScreen()
  755. {
  756. if ( theGame.IsBlackscreenOrFading() )
  757. {
  758. return;
  759. }
  760. if( IsActionAllowed(EIAB_OpenInventory) )
  761. {
  762. theGame.RequestMenuWithBackground( 'InventoryMenu', 'CommonMenu' );
  763. }
  764. else
  765. {
  766. thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenInventory);
  767. }
  768. }
  769.  
  770.  
  771. event OnCommDeckEditor( action : SInputAction )
  772. {
  773. if( IsReleased(action) )
  774. {
  775. if ( theGame.IsBlackscreenOrFading() )
  776. {
  777. return false;
  778. }
  779. if (theGame.GetGwintManager().GetHasDoneTutorial() || theGame.GetGwintManager().HasLootedCard())
  780. {
  781. if( IsActionAllowed(EIAB_OpenGwint) )
  782. {
  783. theGame.RequestMenu( 'DeckBuilder' );
  784. }
  785. else
  786. {
  787. thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenGwint);
  788. }
  789. }
  790. }
  791. }
  792.  
  793.  
  794. event OnCommPanelMed( action : SInputAction )
  795. {
  796. if( IsReleased(action) )
  797. {
  798. if( IsActionAllowed(EIAB_MeditationWaiting) )
  799. {
  800. GetWitcherPlayer().Meditate();
  801. }
  802. else
  803. {
  804. thePlayer.DisplayActionDisallowedHudMessage(EIAB_MeditationWaiting);
  805. }
  806. }
  807. }
  808.  
  809. event OnCommPanelMapPC( action : SInputAction )
  810. {
  811. if( IsReleased(action) )
  812. {
  813. PushMapScreen();
  814. }
  815. }
  816.  
  817. event OnCommPanelMap( action : SInputAction )
  818. {
  819. if( IsPressed(action) )
  820. {
  821. PushMapScreen();
  822. }
  823. }
  824. final function PushMapScreen()
  825. {
  826. if ( theGame.IsBlackscreenOrFading() )
  827. {
  828. return;
  829. }
  830. if( IsActionAllowed(EIAB_OpenMap) )
  831. {
  832. theGame.RequestMenuWithBackground( 'MapMenu', 'CommonMenu' );
  833. }
  834. else
  835. {
  836. thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenMap);
  837. }
  838. }
  839.  
  840.  
  841. event OnCommPanelJour( action : SInputAction )
  842. {
  843. if( IsReleased(action) )
  844. {
  845. PushJournalScreen();
  846. }
  847. }
  848. final function PushJournalScreen()
  849. {
  850. if ( theGame.IsBlackscreenOrFading() )
  851. {
  852. return;
  853. }
  854. if( IsActionAllowed(EIAB_OpenJournal) )
  855. {
  856.  
  857. theGame.RequestMenuWithBackground( 'JournalQuestMenu', 'CommonMenu' );
  858. }
  859. else
  860. {
  861. thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenJournal);
  862. }
  863. }
  864.  
  865. //---=== modFriendlyMeditation ===---
  866. event OnToggleSpawnCampFire( action : SInputAction )
  867. {
  868. if( IsPressed( action ) && GetWitcherPlayer() )
  869. {
  870. GetFMeditationConfig().SetSpawnCampFire( !GetFMeditationConfig().SpawnCampFire() );
  871. if( !GetFMeditationConfig().BeSilent() )
  872. {
  873. if( GetFMeditationConfig().SpawnCampFire() )
  874. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "fmedSpawnCampFireOn" ) );
  875. else
  876. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "fmedSpawnCampFireOff" ) );
  877. }
  878. }
  879. }
  880.  
  881. event OnMeditationFastForward( action : SInputAction )
  882. {
  883. var witcher : W3PlayerWitcher = GetWitcherPlayer();
  884.  
  885. if( !thePlayer.IsCiri() && witcher )
  886. {
  887. if( witcher.GetIsPlayerMeditatingInBed() )
  888. {
  889. }
  890. else if( IsPressed( action ) && witcher.IsSkippingTime() )
  891. {
  892. witcher.MeditationEndFastforward();
  893. }
  894. else if( IsReleased( action ) && witcher.IsSkippingTime() )
  895. {
  896. witcher.MeditationEndFastforward();
  897. }
  898. else if( IsPressed( action ) && witcher.IsMeditating() )
  899. {
  900. witcher.MeditationStartFastforward();
  901. }
  902. }
  903. }
  904.  
  905. private var inFriendlyMeditation : bool; default inFriendlyMeditation = false;
  906.  
  907. event OnHoldToMeditate( action : SInputAction )
  908. {
  909. var witcher : W3PlayerWitcher = GetWitcherPlayer();
  910. var asToggle : bool;
  911.  
  912. asToggle = GetFMeditationConfig().HotkeyAsToggle() || GetFMeditationConfig().HotkeyManualFastforward();
  913.  
  914. if( IsPressed(action) && witcher )
  915. {
  916. inFriendlyMeditation = true;
  917. if( /*asToggle &&*/ (witcher.IsMeditating() || witcher.IsSkippingTime()) )
  918. {
  919. witcher.ModEndMeditation();
  920. }
  921. else
  922. {
  923. witcher.ModStartMeditation();
  924. }
  925. }
  926. if( IsReleased( action ) && witcher && !asToggle )
  927. {
  928. witcher.ModEndMeditation();
  929. }
  930. }
  931.  
  932. event OnCommPanelMeditation( action : SInputAction )
  933. {
  934. if( IsPressed(action) )
  935. {
  936. inFriendlyMeditation = false;
  937. }
  938. if( !inFriendlyMeditation && IsReleased( action ) )
  939. {
  940. PushMeditationScreen();
  941. }
  942. }
  943. //---=== modFriendlyMeditation ===---
  944.  
  945. final function PushMeditationScreen()
  946. {
  947. var imInstalled : bool; //Immersive Meditation
  948.  
  949. if ( theGame.IsBlackscreenOrFading() )
  950. {
  951. return;
  952. }
  953. if( IsActionAllowed(EIAB_OpenMeditation) )
  954. {
  955. //Immersive Meditation++
  956.  
  957. if( StringToFloat( theGame.GetInGameConfigWrapper().GetVarValue('ImmersiveCamPositionsMeditation', 'medRotSpeed') ) >= 0.1 )
  958. imInstalled = true;
  959.  
  960. if( imInstalled )
  961. ((CMeditationUI)thePlayer.getMeditation()).NewMeditate();
  962. else
  963. theGame.RequestMenuWithBackground( 'MeditationClockMenu', 'CommonMenu' );
  964.  
  965. //Immersive Meditation--
  966. }
  967. else
  968. {
  969. thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenMeditation);
  970. }
  971. }
  972.  
  973. event OnCommPanelCrafting( action : SInputAction )
  974. {
  975. if( IsReleased(action) )
  976. {
  977. PushCraftingScreen();
  978. }
  979. }
  980.  
  981. final function PushCraftingScreen()
  982. {
  983. if ( theGame.IsBlackscreenOrFading() )
  984. {
  985. return;
  986. }
  987.  
  988. theGame.RequestMenuWithBackground( 'CraftingMenu', 'CommonMenu' );
  989. }
  990.  
  991.  
  992. event OnCommPanelBestiary( action : SInputAction )
  993. {
  994. if( IsReleased(action) )
  995. {
  996. PushBestiaryScreen();
  997. }
  998. }
  999.  
  1000. final function PushBestiaryScreen()
  1001. {
  1002. if ( theGame.IsBlackscreenOrFading() )
  1003. {
  1004. return;
  1005. }
  1006. if( IsActionAllowed(EIAB_OpenGlossary) )
  1007. {
  1008. theGame.RequestMenuWithBackground( 'GlossaryBestiaryMenu', 'CommonMenu' );
  1009. }
  1010. else
  1011. {
  1012. thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenGlossary);
  1013. }
  1014. }
  1015.  
  1016. event OnCommPanelAlch( action : SInputAction )
  1017. {
  1018. if( IsReleased(action) )
  1019. {
  1020. PushAlchemyScreen();
  1021. }
  1022. }
  1023. final function PushAlchemyScreen()
  1024. {
  1025. if ( theGame.IsBlackscreenOrFading() )
  1026. {
  1027. return;
  1028. }
  1029. if( IsActionAllowed(EIAB_OpenAlchemy) )
  1030. {
  1031. theGame.RequestMenuWithBackground( 'AlchemyMenu', 'CommonMenu' );
  1032. }
  1033. else
  1034. {
  1035. thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenAlchemy);
  1036. }
  1037. }
  1038.  
  1039. event OnCommPanelGlossary( action : SInputAction )
  1040. {
  1041. if( IsReleased(action) )
  1042. {
  1043. PushGlossaryScreen();
  1044. }
  1045. }
  1046. final function PushGlossaryScreen()
  1047. {
  1048. if ( theGame.IsBlackscreenOrFading() )
  1049. {
  1050. return;
  1051. }
  1052. if( IsActionAllowed(EIAB_OpenGlossary) )
  1053. {
  1054. theGame.RequestMenuWithBackground( 'GlossaryEncyclopediaMenu', 'CommonMenu' );
  1055. }
  1056. else
  1057. {
  1058. thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenGlossary);
  1059. }
  1060. }
  1061.  
  1062. event OnShowControlsHelp( action : SInputAction )
  1063. {
  1064. if( IsReleased(action) )
  1065. {
  1066. if ( theGame.IsBlackscreenOrFading() )
  1067. {
  1068. return false;
  1069. }
  1070.  
  1071.  
  1072. }
  1073. }
  1074.  
  1075. event OnCommPanelUIResize( action : SInputAction )
  1076. {
  1077. if( IsReleased(action) )
  1078. {
  1079. if ( theGame.IsBlackscreenOrFading() )
  1080. {
  1081. return false;
  1082. }
  1083. theGame.RequestMenu( 'RescaleMenu' );
  1084. }
  1085. }
  1086.  
  1087. event OnCommPanelFakeHud( action : SInputAction )
  1088. {
  1089. if( IsReleased(action) )
  1090. {
  1091. if ( theGame.IsBlackscreenOrFading() )
  1092. {
  1093. return false;
  1094. }
  1095.  
  1096. }
  1097. }
  1098.  
  1099.  
  1100.  
  1101.  
  1102. private var processedSwordHold : bool;
  1103.  
  1104. event OnCommSteelSword( action : SInputAction )
  1105. {
  1106. var duringCastSign : bool;
  1107.  
  1108. if(IsPressed(action))
  1109. processedSwordHold = false;
  1110.  
  1111. if ( theInput.LastUsedGamepad() && theInput.IsActionPressed('Alternate') )
  1112. {
  1113. return false;
  1114. }
  1115.  
  1116. if ( IsReleased(action) || ( IsPressed(action) && (thePlayer.GetCurrentMeleeWeaponType() == PW_None || thePlayer.GetCurrentMeleeWeaponType() == PW_Fists) ) )
  1117. {
  1118. if( !processedSwordHold )
  1119. {
  1120. if ( IsActionAllowed(EIAB_DrawWeapon) && thePlayer.GetBIsInputAllowed() && thePlayer.GetWeaponHolster().IsMeleeWeaponReady() )
  1121. {
  1122. thePlayer.PushCombatActionOnBuffer( EBAT_Draw_Steel, BS_Pressed );
  1123. if ( thePlayer.GetBIsCombatActionAllowed() )
  1124. thePlayer.ProcessCombatActionBuffer();
  1125. }
  1126. processedSwordHold = true;
  1127. }
  1128. }
  1129. }
  1130.  
  1131. event OnCommSilverSword( action : SInputAction )
  1132. {
  1133. var duringCastSign : bool;
  1134.  
  1135. if( IsPressed(action) )
  1136. processedSwordHold = false;
  1137.  
  1138. if ( theInput.LastUsedGamepad() && theInput.IsActionPressed('Alternate') )
  1139. {
  1140. return false;
  1141. }
  1142.  
  1143. if ( IsReleased(action) || ( IsPressed(action) && (thePlayer.GetCurrentMeleeWeaponType() == PW_None || thePlayer.GetCurrentMeleeWeaponType() == PW_Fists) ) )
  1144. {
  1145. if( !processedSwordHold )
  1146. {
  1147. if ( IsActionAllowed(EIAB_DrawWeapon) && thePlayer.GetBIsInputAllowed() && thePlayer.GetWeaponHolster().IsMeleeWeaponReady() )
  1148. {
  1149. thePlayer.PushCombatActionOnBuffer( EBAT_Draw_Silver, BS_Pressed );
  1150. if ( thePlayer.GetBIsCombatActionAllowed() || duringCastSign )
  1151. thePlayer.ProcessCombatActionBuffer();
  1152. }
  1153. processedSwordHold = true;
  1154. }
  1155.  
  1156. }
  1157. }
  1158.  
  1159. event OnCommSheatheAny( action : SInputAction )
  1160. {
  1161. var duringCastSign : bool;
  1162.  
  1163. if( IsPressed( action ) )
  1164. {
  1165. if ( thePlayer.GetBIsInputAllowed() && thePlayer.GetWeaponHolster().IsMeleeWeaponReady() )
  1166. {
  1167. thePlayer.PushCombatActionOnBuffer( EBAT_Sheathe_Sword, BS_Pressed );
  1168. if ( thePlayer.GetBIsCombatActionAllowed() || duringCastSign )
  1169. {
  1170. thePlayer.ProcessCombatActionBuffer();
  1171. }
  1172. }
  1173. processedSwordHold = true;
  1174. }
  1175. }
  1176.  
  1177. event OnCommSheatheSteel( action : SInputAction )
  1178. {
  1179. if( IsPressed( action ) && thePlayer.IsWeaponHeld( 'steelsword' ) && !processedSwordHold)
  1180. {
  1181. OnCommSheatheAny(action);
  1182. }
  1183. }
  1184.  
  1185. event OnCommSheatheSilver( action : SInputAction )
  1186. {
  1187. if( IsPressed( action ) && thePlayer.IsWeaponHeld( 'silversword' ) && !processedSwordHold)
  1188. {
  1189. OnCommSheatheAny(action);
  1190. }
  1191. }
  1192.  
  1193. event OnCommDrinkPot( action : SInputAction )
  1194. {
  1195. if(IsPressed(action))
  1196. {
  1197. if(!potPress)
  1198. {
  1199. potPress = true;
  1200. potAction = action;
  1201. thePlayer.AddTimer('PotDrinkTimer', 0.3);
  1202. }
  1203. else
  1204. {
  1205. PotDrinkTimer(true);
  1206. thePlayer.RemoveTimer('PotDrinkTimer');
  1207. }
  1208. }
  1209. }
  1210.  
  1211. public function PotDrinkTimer(isDoubleTapped : bool)
  1212. {
  1213. thePlayer.RemoveTimer('PotDrinkTimer');
  1214. potPress = false;
  1215.  
  1216. if(isDoubleTapped)
  1217. OnCommDrinkPotion2(potAction);
  1218. else
  1219. OnCommDrinkPotion1(potAction);
  1220. }
  1221.  
  1222.  
  1223.  
  1224.  
  1225. event OnCbtComboDigitLeft( action : SInputAction )
  1226. {
  1227. if ( theInput.IsActionPressed('Alternate') )
  1228. {
  1229. OnTogglePreviousSign(action);
  1230. }
  1231. }
  1232.  
  1233. event OnCbtComboDigitRight( action : SInputAction )
  1234. {
  1235. if ( theInput.IsActionPressed('Alternate') )
  1236. {
  1237. OnToggleNextSign(action);
  1238. }
  1239. }
  1240.  
  1241.  
  1242. event OnSelectSign(action : SInputAction)
  1243. {
  1244. if( IsPressed( action ) )
  1245. {
  1246. switch( action.aName )
  1247. {
  1248. case 'SelectAard' :
  1249. GetWitcherPlayer().SetEquippedSign(ST_Aard);
  1250. break;
  1251. case 'SelectYrden' :
  1252. GetWitcherPlayer().SetEquippedSign(ST_Yrden);
  1253. break;
  1254. case 'SelectIgni' :
  1255. GetWitcherPlayer().SetEquippedSign(ST_Igni);
  1256. break;
  1257. case 'SelectQuen' :
  1258. GetWitcherPlayer().SetEquippedSign(ST_Quen);
  1259. break;
  1260. case 'SelectAxii' :
  1261. GetWitcherPlayer().SetEquippedSign(ST_Axii);
  1262. break;
  1263. default :
  1264. break;
  1265. }
  1266. }
  1267. }
  1268.  
  1269. event OnToggleSigns( action : SInputAction )
  1270. {
  1271. var tolerance : float;
  1272. tolerance = 2.5f;
  1273.  
  1274. if( action.value < -tolerance )
  1275. {
  1276. GetWitcherPlayer().TogglePreviousSign();
  1277. }
  1278. else if( action.value > tolerance )
  1279. {
  1280. GetWitcherPlayer().ToggleNextSign();
  1281. }
  1282. }
  1283. event OnToggleNextSign( action : SInputAction )
  1284. {
  1285. if( IsPressed( action ) )
  1286. {
  1287. GetWitcherPlayer().ToggleNextSign();
  1288. }
  1289. }
  1290. event OnTogglePreviousSign( action : SInputAction )
  1291. {
  1292. if( IsPressed( action ) )
  1293. {
  1294. GetWitcherPlayer().TogglePreviousSign();
  1295. }
  1296. }
  1297.  
  1298. event OnToggleItem( action : SInputAction )
  1299. {
  1300. if( !IsActionAllowed( EIAB_QuickSlots ) )
  1301. {
  1302. thePlayer.DisplayActionDisallowedHudMessage(EIAB_QuickSlots);
  1303. return false;
  1304. }
  1305.  
  1306. if( IsReleased( action ) )
  1307. {
  1308. if( theInput.GetLastActivationTime( action.aName ) < 0.3 )
  1309. GetWitcherPlayer().ToggleNextItem();
  1310. }
  1311. }
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317. event OnCommDrinkpotionUpperHeld( action : SInputAction )
  1318. {
  1319. if(!potionModeHold)
  1320. return false;
  1321.  
  1322.  
  1323. if(thePlayer.IsCiri())
  1324. return false;
  1325.  
  1326. if(IsReleased(action))
  1327. return false;
  1328.  
  1329. potionUpperHeld = true;
  1330. GetWitcherPlayer().FlipSelectedPotion(true);
  1331. }
  1332.  
  1333. event OnCommDrinkpotionLowerHeld( action : SInputAction )
  1334. {
  1335. if(!potionModeHold)
  1336. return false;
  1337.  
  1338.  
  1339. if(thePlayer.IsCiri())
  1340. return false;
  1341.  
  1342. if(IsReleased(action))
  1343. return false;
  1344.  
  1345. potionLowerHeld = true;
  1346. GetWitcherPlayer().FlipSelectedPotion(false);
  1347. }
  1348.  
  1349. public final function SetPotionSelectionMode(b : bool)
  1350. {
  1351. potionModeHold = b;
  1352. }
  1353.  
  1354. private final function DrinkPotion(action : SInputAction, upperSlot : bool) : bool
  1355. {
  1356. var witcher : W3PlayerWitcher;
  1357.  
  1358. if ( potionModeHold && IsReleased(action) )
  1359. {
  1360. if(!potionUpperHeld && !potionLowerHeld)
  1361. {
  1362. GetWitcherPlayer().OnPotionDrinkInput(upperSlot);
  1363. }
  1364.  
  1365. if(upperSlot)
  1366. potionUpperHeld = false;
  1367. else
  1368. potionLowerHeld = false;
  1369. }
  1370. else if(!potionModeHold && IsPressed(action))
  1371. {
  1372. witcher = GetWitcherPlayer();
  1373. if(!witcher.IsPotionDoubleTapRunning())
  1374. {
  1375. witcher.SetPotionDoubleTapRunning(true, upperSlot);
  1376. return true;
  1377. }
  1378. else
  1379. {
  1380. witcher.SetPotionDoubleTapRunning(false);
  1381. witcher.FlipSelectedPotion(upperSlot);
  1382. return true;
  1383. }
  1384. }
  1385.  
  1386. return false;
  1387. }
  1388.  
  1389.  
  1390. event OnCommDrinkPotion1( action : SInputAction )
  1391. {
  1392.  
  1393. if(thePlayer.IsCiri())
  1394. return false;
  1395.  
  1396. if( !IsActionAllowed( EIAB_QuickSlots ) )
  1397. {
  1398. thePlayer.DisplayActionDisallowedHudMessage(EIAB_QuickSlots);
  1399. return false;
  1400. }
  1401.  
  1402. if ( theInput.LastUsedGamepad() )
  1403. {
  1404. return DrinkPotion(action, true);
  1405. }
  1406. else
  1407. if ( IsReleased(action) )
  1408. {
  1409. GetWitcherPlayer().OnPotionDrinkKeyboardsInput(EES_Potion1);
  1410. return true;
  1411. }
  1412.  
  1413. return false;
  1414. }
  1415.  
  1416.  
  1417. event OnCommDrinkPotion2( action : SInputAction )
  1418. {
  1419. var witcher : W3PlayerWitcher;
  1420.  
  1421.  
  1422. if(thePlayer.IsCiri())
  1423. return false;
  1424.  
  1425. if( !IsActionAllowed( EIAB_QuickSlots ) )
  1426. {
  1427. thePlayer.DisplayActionDisallowedHudMessage(EIAB_QuickSlots);
  1428. return false;
  1429. }
  1430.  
  1431. if ( theInput.LastUsedGamepad() )
  1432. {
  1433. return DrinkPotion(action, false);
  1434. }
  1435. else
  1436. if ( IsReleased(action) )
  1437. {
  1438. GetWitcherPlayer().OnPotionDrinkKeyboardsInput(EES_Potion2);
  1439. return true;
  1440. }
  1441.  
  1442. return false;
  1443. }
  1444.  
  1445.  
  1446. event OnCommDrinkPotion3( action : SInputAction )
  1447. {
  1448.  
  1449. if(thePlayer.IsCiri())
  1450. return false;
  1451.  
  1452. if( !IsActionAllowed( EIAB_QuickSlots ) )
  1453. {
  1454. thePlayer.DisplayActionDisallowedHudMessage(EIAB_QuickSlots);
  1455. return false;
  1456. }
  1457.  
  1458. if ( IsReleased(action) )
  1459. {
  1460. GetWitcherPlayer().OnPotionDrinkKeyboardsInput(EES_Potion3);
  1461. return true;
  1462. }
  1463.  
  1464. return false;
  1465. }
  1466.  
  1467.  
  1468. event OnCommDrinkPotion4( action : SInputAction )
  1469. {
  1470. var witcher : W3PlayerWitcher;
  1471.  
  1472.  
  1473. if(thePlayer.IsCiri())
  1474. return false;
  1475.  
  1476. if( !IsActionAllowed( EIAB_QuickSlots ) )
  1477. {
  1478. thePlayer.DisplayActionDisallowedHudMessage(EIAB_QuickSlots);
  1479. return false;
  1480. }
  1481.  
  1482. if ( IsReleased(action) )
  1483. {
  1484. GetWitcherPlayer().OnPotionDrinkKeyboardsInput(EES_Potion4);
  1485. return true;
  1486. }
  1487.  
  1488. return false;
  1489. }
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495. event OnDiving( action : SInputAction )
  1496. {
  1497. if ( IsPressed(action) && IsActionAllowed(EIAB_Dive) )
  1498. {
  1499. if ( action.aName == 'DiveDown' )
  1500. {
  1501. if ( thePlayer.OnAllowedDiveDown() )
  1502. {
  1503. if ( !thePlayer.OnCheckDiving() )
  1504. thePlayer.OnDive();
  1505.  
  1506. if ( thePlayer.bLAxisReleased )
  1507. thePlayer.SetBehaviorVariable( 'divePitch',-1.0);
  1508. else
  1509. thePlayer.SetBehaviorVariable( 'divePitch', -0.9);
  1510. thePlayer.OnDiveInput(-1.f);
  1511.  
  1512. if ( thePlayer.rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  1513. {
  1514. thePlayer.OnRangedForceHolster( true, false );
  1515. thePlayer.OnFullyBlendedIdle();
  1516. }
  1517. }
  1518. }
  1519. else if ( action.aName == 'DiveUp' )
  1520. {
  1521. if ( thePlayer.bLAxisReleased )
  1522. thePlayer.SetBehaviorVariable( 'divePitch',1.0);
  1523. else
  1524. thePlayer.SetBehaviorVariable( 'divePitch', 0.9);
  1525.  
  1526. if ( thePlayer.rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  1527. {
  1528. thePlayer.OnRangedForceHolster( true, false );
  1529. thePlayer.OnFullyBlendedIdle();
  1530. }
  1531.  
  1532. thePlayer.OnDiveInput(1.f);
  1533. }
  1534. }
  1535. else if ( IsReleased(action) )
  1536. {
  1537. thePlayer.SetBehaviorVariable( 'divePitch',0.0);
  1538. thePlayer.OnDiveInput(0.f);
  1539. }
  1540. else if ( IsPressed(action) && !IsActionAllowed(EIAB_Dive) )
  1541. {
  1542. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Dive);
  1543. }
  1544. }
  1545.  
  1546. event OnDivingDodge( action : SInputAction )
  1547. {
  1548. var isDodgeAllowed : bool;
  1549.  
  1550. if( IsPressed(action) )
  1551. {
  1552. isDodgeAllowed = IsActionAllowed(EIAB_Dodge);
  1553. if( isDodgeAllowed && IsActionAllowed(EIAB_Dive) )
  1554. {
  1555. if ( thePlayer.OnCheckDiving() && thePlayer.GetBIsInputAllowed() )
  1556. {
  1557. thePlayer.PushCombatActionOnBuffer( EBAT_Dodge, BS_Pressed );
  1558. if ( thePlayer.GetBIsCombatActionAllowed() )
  1559. thePlayer.ProcessCombatActionBuffer();
  1560. }
  1561. }
  1562. else
  1563. {
  1564. if(!isDodgeAllowed)
  1565. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Dodge);
  1566. else
  1567. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Dive);
  1568. }
  1569. }
  1570. }
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576. event OnExpFistFightLight( action : SInputAction )
  1577. {
  1578. var fistsAllowed : bool;
  1579.  
  1580. if( IsPressed(action) )
  1581. {
  1582. fistsAllowed = IsActionAllowed(EIAB_Fists);
  1583. if( fistsAllowed && IsActionAllowed(EIAB_LightAttacks) )
  1584. {
  1585.  
  1586. thePlayer.SetupCombatAction( EBAT_LightAttack, BS_Pressed );
  1587. }
  1588. else
  1589. {
  1590. if(!fistsAllowed)
  1591. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Fists);
  1592. else
  1593. thePlayer.DisplayActionDisallowedHudMessage(EIAB_LightAttacks);
  1594. }
  1595. }
  1596. }
  1597.  
  1598. event OnExpFistFightHeavy( action : SInputAction )
  1599. {
  1600. var fistsAllowed : bool;
  1601.  
  1602. if( IsPressed(action) )
  1603. {
  1604. fistsAllowed = IsActionAllowed(EIAB_Fists);
  1605. if( fistsAllowed && IsActionAllowed(EIAB_HeavyAttacks) )
  1606. {
  1607.  
  1608. thePlayer.SetupCombatAction( EBAT_HeavyAttack, BS_Pressed );
  1609. }
  1610. else
  1611. {
  1612. if(!fistsAllowed)
  1613. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Fists);
  1614. else
  1615. thePlayer.DisplayActionDisallowedHudMessage(EIAB_HeavyAttacks);
  1616. }
  1617. }
  1618. }
  1619.  
  1620.  
  1621.  
  1622. event OnExpFocus( action : SInputAction )
  1623. {
  1624. if(IsActionAllowed(EIAB_ExplorationFocus))
  1625. {
  1626. if( IsPressed( action ) )
  1627. {
  1628.  
  1629. if( thePlayer.GoToCombatIfNeeded() )
  1630. {
  1631. OnCommGuard( action );
  1632. return false;
  1633. }
  1634. theGame.GetFocusModeController().Activate();
  1635.  
  1636. }
  1637. else if( IsReleased( action ) )
  1638. {
  1639. theGame.GetFocusModeController().Deactivate();
  1640. }
  1641. }
  1642. else
  1643. {
  1644. thePlayer.DisplayActionDisallowedHudMessage(EIAB_ExplorationFocus);
  1645. theGame.GetFocusModeController().Deactivate();
  1646. }
  1647. }
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653. private function ShouldSwitchAttackType():bool
  1654. {
  1655. var outKeys : array<EInputKey>;
  1656.  
  1657. if ( theInput.LastUsedPCInput() )
  1658. {
  1659. theInput.GetPCKeysForAction('PCAlternate',outKeys);
  1660. if ( outKeys.Size() > 0 )
  1661. {
  1662. if ( theInput.IsActionPressed('PCAlternate') )
  1663. {
  1664. return true;
  1665. }
  1666. }
  1667. }
  1668. return false;
  1669. }
  1670.  
  1671. event OnCbtAttackWithAlternateLight( action : SInputAction )
  1672. {
  1673. CbtAttackPC( action, false);
  1674. }
  1675.  
  1676. event OnCbtAttackWithAlternateHeavy( action : SInputAction )
  1677. {
  1678. CbtAttackPC( action, true);
  1679. }
  1680.  
  1681. function CbtAttackPC( action : SInputAction, isHeavy : bool )
  1682. {
  1683. var switchAttackType : bool;
  1684.  
  1685. switchAttackType = ShouldSwitchAttackType();
  1686.  
  1687. if ( !theInput.LastUsedPCInput() )
  1688. {
  1689. return;
  1690. }
  1691.  
  1692. if ( thePlayer.IsCiri() )
  1693. {
  1694. if ( switchAttackType != isHeavy)
  1695. {
  1696. OnCbtCiriAttackHeavy(action);
  1697. }
  1698. else
  1699. {
  1700. OnCbtAttackLight(action);
  1701. }
  1702. }
  1703. else
  1704. {
  1705. if ( switchAttackType != isHeavy)
  1706. {
  1707. OnCbtAttackHeavy(action);
  1708. }
  1709. else
  1710. {
  1711. OnCbtAttackLight(action);
  1712. }
  1713. }
  1714. }
  1715.  
  1716. event OnCbtAttackLight( action : SInputAction )
  1717. {
  1718. var allowed, checkedFists : bool;
  1719.  
  1720. if( IsPressed(action) )
  1721. {
  1722. if( IsActionAllowed(EIAB_LightAttacks) )
  1723. {
  1724. if (thePlayer.GetBIsInputAllowed())
  1725. {
  1726. allowed = false;
  1727.  
  1728. if( thePlayer.GetCurrentMeleeWeaponType() == PW_Fists || thePlayer.GetCurrentMeleeWeaponType() == PW_None )
  1729. {
  1730. checkedFists = true;
  1731. if(IsActionAllowed(EIAB_Fists))
  1732. allowed = true;
  1733. }
  1734. else if(IsActionAllowed(EIAB_SwordAttack))
  1735. {
  1736. checkedFists = false;
  1737. allowed = true;
  1738. }
  1739.  
  1740. if(allowed)
  1741. {
  1742. thePlayer.SetupCombatAction( EBAT_LightAttack, BS_Pressed );
  1743. }
  1744. else
  1745. {
  1746. if(checkedFists)
  1747. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Fists);
  1748. else
  1749. thePlayer.DisplayActionDisallowedHudMessage(EIAB_SwordAttack);
  1750. }
  1751. }
  1752. }
  1753. else if ( !IsActionBlockedBy(EIAB_LightAttacks,'interaction') )
  1754. {
  1755. thePlayer.DisplayActionDisallowedHudMessage(EIAB_LightAttacks);
  1756. }
  1757. }
  1758. }
  1759.  
  1760. event OnCbtAttackHeavy( action : SInputAction )
  1761. {
  1762. var allowed, checkedSword : bool;
  1763. var outKeys : array<EInputKey>;
  1764.  
  1765. if ( thePlayer.GetBIsInputAllowed() )
  1766. {
  1767. if( IsActionAllowed(EIAB_HeavyAttacks) )
  1768. {
  1769. allowed = false;
  1770.  
  1771. if( thePlayer.GetCurrentMeleeWeaponType() == PW_Fists || thePlayer.GetCurrentMeleeWeaponType() == PW_None )
  1772. {
  1773. checkedSword = false;
  1774. if(IsActionAllowed(EIAB_Fists))
  1775. allowed = true;
  1776. }
  1777. else if(IsActionAllowed(EIAB_SwordAttack))
  1778. {
  1779. checkedSword = true;
  1780. allowed = true;
  1781. }
  1782.  
  1783. if(allowed)
  1784. {
  1785. if ( ( thePlayer.GetCurrentMeleeWeaponType() == PW_Fists || thePlayer.GetCurrentMeleeWeaponType() == PW_None ) && IsPressed(action) )
  1786. {
  1787. thePlayer.SetupCombatAction( EBAT_HeavyAttack, BS_Released );
  1788. }
  1789. else
  1790. {
  1791. if( IsReleased(action) && theInput.GetLastActivationTime( action.aName ) < 0.2 )
  1792. {
  1793. thePlayer.SetupCombatAction( EBAT_HeavyAttack, BS_Released );
  1794. }
  1795. }
  1796. }
  1797. else
  1798. {
  1799. if(checkedSword)
  1800. thePlayer.DisplayActionDisallowedHudMessage(EIAB_SwordAttack);
  1801. else
  1802. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Fists);
  1803. }
  1804. }
  1805. else if ( !IsActionBlockedBy(EIAB_HeavyAttacks,'interaction') )
  1806. {
  1807. thePlayer.DisplayActionDisallowedHudMessage(EIAB_HeavyAttacks);
  1808. }
  1809. }
  1810. }
  1811.  
  1812. private function CheckFinisherInput() : bool
  1813. {
  1814. var enemyInCone : CActor;
  1815. var npc : CNewNPC;
  1816. var interactionTarget : CInteractionComponent;
  1817.  
  1818. var isDeadlySwordHeld : bool;
  1819.  
  1820. interactionTarget = theGame.GetInteractionsManager().GetActiveInteraction();
  1821. if ( interactionTarget && interactionTarget.GetName() == "Finish" )
  1822. {
  1823. npc = (CNewNPC)( interactionTarget.GetEntity() );
  1824.  
  1825. isDeadlySwordHeld = thePlayer.IsDeadlySwordHeld();
  1826. if( ( theInput.GetActionValue( 'AttackHeavy' ) == 1.f || theInput.GetActionValue( 'AttackLight' ) == 1.f )
  1827. && isDeadlySwordHeld )
  1828. {
  1829. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_FinisherInput) );
  1830. npc.SignalGameplayEvent('Finisher');
  1831.  
  1832. }
  1833. else if ( !isDeadlySwordHeld )
  1834. {
  1835. if ( thePlayer.IsWeaponHeld( 'fist' ))
  1836. thePlayer.SetBehaviorVariable( 'combatTauntType', 1.f );
  1837. else
  1838. thePlayer.SetBehaviorVariable( 'combatTauntType', 0.f );
  1839.  
  1840. thePlayer.RaiseEvent( 'CombatTaunt' );
  1841. }
  1842.  
  1843. return true;
  1844.  
  1845. }
  1846. return false;
  1847. }
  1848.  
  1849. private function IsPlayerAbleToPerformSpecialAttack() : bool
  1850. {
  1851. if( ( thePlayer.GetCurrentStateName() == 'Exploration' ) && !( thePlayer.IsWeaponHeld( 'silversword' ) || thePlayer.IsWeaponHeld( 'steelsword' ) ) )
  1852. {
  1853. return false;
  1854. }
  1855. return true;
  1856. }
  1857.  
  1858. event OnCbtSpecialAttackWithAlternateLight( action : SInputAction )
  1859. {
  1860. CbSpecialAttackPC( action, false);
  1861. }
  1862.  
  1863. event OnCbtSpecialAttackWithAlternateHeavy( action : SInputAction )
  1864. {
  1865. CbSpecialAttackPC( action, true);
  1866. }
  1867.  
  1868. function CbSpecialAttackPC( action : SInputAction, isHeavy : bool )
  1869. {
  1870. var switchAttackType : bool;
  1871.  
  1872. switchAttackType = ShouldSwitchAttackType();
  1873.  
  1874. if ( !theInput.LastUsedPCInput() )
  1875. {
  1876. return;
  1877. }
  1878.  
  1879. if ( IsPressed(action) )
  1880. {
  1881. if ( thePlayer.IsCiri() )
  1882. {
  1883.  
  1884. OnCbtCiriSpecialAttackHeavy(action);
  1885. }
  1886. else
  1887. {
  1888. if (switchAttackType != isHeavy)
  1889. {
  1890. OnCbtSpecialAttackHeavy(action);
  1891. }
  1892. else
  1893. {
  1894. OnCbtSpecialAttackLight(action);
  1895. }
  1896. }
  1897. }
  1898. else if ( IsReleased( action ) )
  1899. {
  1900. if ( thePlayer.IsCiri() )
  1901. {
  1902. OnCbtCiriSpecialAttackHeavy(action);
  1903. }
  1904. else
  1905. {
  1906.  
  1907. OnCbtSpecialAttackHeavy(action);
  1908. OnCbtSpecialAttackLight(action);
  1909. }
  1910. }
  1911. }
  1912.  
  1913. event OnCbtSpecialAttackLight( action : SInputAction )
  1914. {
  1915. if ( IsReleased( action ) )
  1916. {
  1917. thePlayer.CancelHoldAttacks();
  1918. return true;
  1919. }
  1920.  
  1921. if ( !IsPlayerAbleToPerformSpecialAttack() )
  1922. return false;
  1923.  
  1924. if( !IsActionAllowed(EIAB_LightAttacks) )
  1925. {
  1926. thePlayer.DisplayActionDisallowedHudMessage(EIAB_LightAttacks);
  1927. return false;
  1928. }
  1929. if(!IsActionAllowed(EIAB_SpecialAttackLight) )
  1930. {
  1931. thePlayer.DisplayActionDisallowedHudMessage(EIAB_SpecialAttackLight);
  1932. return false;
  1933. }
  1934.  
  1935. if( IsPressed(action) && thePlayer.CanUseSkill(S_Sword_s01) )
  1936. {
  1937. thePlayer.PrepareToAttack();
  1938. thePlayer.SetPlayedSpecialAttackMissingResourceSound(false);
  1939. thePlayer.AddTimer( 'IsSpecialLightAttackInputHeld', 0.00001, true );
  1940. }
  1941. }
  1942.  
  1943. event OnCbtSpecialAttackHeavy( action : SInputAction )
  1944. {
  1945. if ( IsReleased( action ) )
  1946. {
  1947. thePlayer.CancelHoldAttacks();
  1948. return true;
  1949. }
  1950.  
  1951. if ( !IsPlayerAbleToPerformSpecialAttack() )
  1952. return false;
  1953.  
  1954. if( !IsActionAllowed(EIAB_HeavyAttacks))
  1955. {
  1956. thePlayer.DisplayActionDisallowedHudMessage(EIAB_HeavyAttacks);
  1957. return false;
  1958. }
  1959. if(!IsActionAllowed(EIAB_SpecialAttackHeavy))
  1960. {
  1961. thePlayer.DisplayActionDisallowedHudMessage(EIAB_SpecialAttackHeavy);
  1962. return false;
  1963. }
  1964.  
  1965. if( IsPressed(action) && thePlayer.CanUseSkill(S_Sword_s02) )
  1966. {
  1967. thePlayer.PrepareToAttack();
  1968. thePlayer.SetPlayedSpecialAttackMissingResourceSound(false);
  1969. thePlayer.AddTimer( 'IsSpecialHeavyAttackInputHeld', 0.00001, true );
  1970. }
  1971. else if ( IsPressed(action) )
  1972. {
  1973. if ( theInput.IsActionPressed('AttackHeavy') )
  1974. theInput.ForceDeactivateAction('AttackHeavy');
  1975. else if ( theInput.IsActionPressed('AttackWithAlternateHeavy') )
  1976. theInput.ForceDeactivateAction('AttackWithAlternateHeavy');
  1977. }
  1978. }
  1979.  
  1980.  
  1981. event OnCbtCiriSpecialAttack( action : SInputAction )
  1982. {
  1983. if( !GetCiriPlayer().HasSword() )
  1984. return false;
  1985.  
  1986. if( thePlayer.GetBIsInputAllowed() && thePlayer.GetBIsCombatActionAllowed() && IsPressed(action) )
  1987. {
  1988. if ( thePlayer.HasAbility('CiriBlink') && ((W3ReplacerCiri)thePlayer).HasStaminaForSpecialAction(true) )
  1989. thePlayer.PrepareToAttack();
  1990. thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_SpecialAttack, BS_Pressed );
  1991. thePlayer.ProcessCombatActionBuffer();
  1992. }
  1993. else if ( IsReleased( action ) && thePlayer.GetCombatAction() == EBAT_Ciri_SpecialAttack && thePlayer.GetBehaviorVariable( 'isPerformingSpecialAttack' ) != 0 )
  1994. {
  1995. thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_SpecialAttack, BS_Released );
  1996. thePlayer.ProcessCombatActionBuffer();
  1997. }
  1998. }
  1999.  
  2000.  
  2001. event OnCbtCiriAttackHeavy( action : SInputAction )
  2002. {
  2003. var specialAttackAction : SInputAction;
  2004.  
  2005. if( !GetCiriPlayer().HasSword() )
  2006. return false;
  2007.  
  2008. specialAttackAction = theInput.GetAction('CiriSpecialAttackHeavy');
  2009.  
  2010. if( thePlayer.GetBIsInputAllowed() && IsReleased(action) && thePlayer.GetBehaviorVariable( 'isPerformingSpecialAttack' ) == 0 )
  2011. {
  2012. if( IsActionAllowed(EIAB_HeavyAttacks) && IsActionAllowed(EIAB_SwordAttack) )
  2013. {
  2014. if ( thePlayer.GetCurrentMeleeWeaponType() == PW_Steel )
  2015. {
  2016. thePlayer.PrepareToAttack();
  2017. thePlayer.SetupCombatAction( EBAT_HeavyAttack, BS_Released );
  2018. if ( thePlayer.GetBIsCombatActionAllowed() )
  2019. thePlayer.ProcessCombatActionBuffer();
  2020. }
  2021. }
  2022. else if ( !IsActionBlockedBy(EIAB_HeavyAttacks,'interaction') )
  2023. {
  2024. thePlayer.DisplayActionDisallowedHudMessage(EIAB_LightAttacks);
  2025. }
  2026. }
  2027. }
  2028.  
  2029.  
  2030. event OnCbtCiriSpecialAttackHeavy( action : SInputAction )
  2031. {
  2032. if( !GetCiriPlayer().HasSword() )
  2033. return false;
  2034.  
  2035. if( thePlayer.GetBIsInputAllowed() && thePlayer.GetBIsCombatActionAllowed() && IsPressed(action) )
  2036. {
  2037. theInput.ForceDeactivateAction('AttackWithAlternateHeavy');
  2038. thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_SpecialAttack_Heavy, BS_Pressed );
  2039. thePlayer.ProcessCombatActionBuffer();
  2040. }
  2041. else if ( IsReleased( action ) && thePlayer.GetCombatAction() == EBAT_Ciri_SpecialAttack_Heavy && thePlayer.GetBehaviorVariable( 'isPerformingSpecialAttack' ) != 0 )
  2042. {
  2043. theInput.ForceDeactivateAction('CiriAttackHeavy');
  2044. theInput.ForceDeactivateAction('AttackWithAlternateHeavy');
  2045. thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_SpecialAttack_Heavy, BS_Released );
  2046. thePlayer.ProcessCombatActionBuffer();
  2047. }
  2048. }
  2049.  
  2050. event OnCbtCiriDodge( action : SInputAction )
  2051. {
  2052. if( IsActionAllowed(EIAB_Dodge) && IsPressed(action) && thePlayer.IsAlive() )
  2053. {
  2054. if ( thePlayer.IsInCombatAction() && thePlayer.GetCombatAction() == EBAT_Ciri_SpecialAttack && thePlayer.GetBehaviorVariable( 'isCompletingSpecialAttack' ) <= 0 )
  2055. {
  2056. thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_Dodge, BS_Pressed );
  2057. thePlayer.ProcessCombatActionBuffer();
  2058. }
  2059. else if ( thePlayer.GetBIsInputAllowed() )
  2060. {
  2061. thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_Dodge, BS_Pressed );
  2062. if ( thePlayer.GetBIsCombatActionAllowed() )
  2063. thePlayer.ProcessCombatActionBuffer();
  2064. }
  2065. else
  2066. {
  2067. if ( thePlayer.IsInCombatAction() && thePlayer.GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
  2068. {
  2069. if ( thePlayer.CanPlayHitAnim() && thePlayer.IsThreatened() )
  2070. {
  2071. thePlayer.CriticalEffectAnimationInterrupted("CiriDodge");
  2072. thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_Dodge, BS_Pressed );
  2073. thePlayer.ProcessCombatActionBuffer();
  2074. }
  2075. else
  2076. thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_Dodge, BS_Pressed );
  2077. }
  2078. }
  2079. }
  2080. else if ( !IsActionAllowed(EIAB_Dodge) )
  2081. {
  2082. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Dodge);
  2083. }
  2084. }
  2085.  
  2086. event OnCbtCiriDash( action : SInputAction )
  2087. {
  2088. if ( theInput.LastUsedGamepad() && IsPressed( action ) )
  2089. {
  2090. thePlayer.StartDodgeTimer();
  2091. }
  2092. else if( IsActionAllowed(EIAB_Dodge) && thePlayer.IsAlive() )
  2093. {
  2094. if ( theInput.LastUsedGamepad() )
  2095. {
  2096. if ( !(thePlayer.IsDodgeTimerRunning() && !thePlayer.IsInsideInteraction() && IsReleased(action)) )
  2097. return false;
  2098. }
  2099.  
  2100. if ( thePlayer.IsInCombatAction() && thePlayer.GetCombatAction() == EBAT_Ciri_SpecialAttack && thePlayer.GetBehaviorVariable( 'isCompletingSpecialAttack' ) <= 0 )
  2101. {
  2102. thePlayer.PushCombatActionOnBuffer( EBAT_Roll, BS_Released );
  2103. thePlayer.ProcessCombatActionBuffer();
  2104. }
  2105. else if ( thePlayer.GetBIsInputAllowed() )
  2106. {
  2107. thePlayer.PushCombatActionOnBuffer( EBAT_Roll, BS_Released );
  2108. if ( thePlayer.GetBIsCombatActionAllowed() )
  2109. thePlayer.ProcessCombatActionBuffer();
  2110. }
  2111. else
  2112. {
  2113. if ( thePlayer.IsInCombatAction() && thePlayer.GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
  2114. {
  2115. if ( thePlayer.CanPlayHitAnim() && thePlayer.IsThreatened() )
  2116. {
  2117. thePlayer.CriticalEffectAnimationInterrupted("CiriDodge");
  2118. thePlayer.PushCombatActionOnBuffer( EBAT_Roll, BS_Released );
  2119. thePlayer.ProcessCombatActionBuffer();
  2120. }
  2121. else
  2122. thePlayer.PushCombatActionOnBuffer( EBAT_Roll, BS_Released );
  2123. }
  2124. }
  2125. }
  2126. else if ( !IsActionAllowed(EIAB_Dodge) )
  2127. {
  2128. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Dodge);
  2129. }
  2130. }
  2131.  
  2132. event OnCbtDodge( action : SInputAction )
  2133. {
  2134. if ( IsPressed(action) )
  2135. thePlayer.EvadePressed(EBAT_Dodge);
  2136. }
  2137.  
  2138. event OnCbtRoll( action : SInputAction )
  2139. {
  2140. if ( theInput.LastUsedPCInput() )
  2141. {
  2142. if ( IsPressed( action ) )
  2143. {
  2144. thePlayer.EvadePressed(EBAT_Roll);
  2145. }
  2146. }
  2147. else
  2148. {
  2149. if ( IsPressed( action ) )
  2150. {
  2151. thePlayer.StartDodgeTimer();
  2152. }
  2153. else if ( IsReleased( action ) )
  2154. {
  2155. if ( thePlayer.IsDodgeTimerRunning() )
  2156. {
  2157. thePlayer.StopDodgeTimer();
  2158. if ( !thePlayer.IsInsideInteraction() )
  2159. thePlayer.EvadePressed(EBAT_Roll);
  2160. }
  2161.  
  2162. }
  2163. }
  2164. }
  2165.  
  2166.  
  2167. var lastMovementDoubleTapName : name;
  2168.  
  2169. event OnMovementDoubleTap( action : SInputAction )
  2170. {
  2171. if ( IsPressed( action ) )
  2172. {
  2173. if ( !thePlayer.IsDodgeTimerRunning() || action.aName != lastMovementDoubleTapName )
  2174. {
  2175. thePlayer.StartDodgeTimer();
  2176. lastMovementDoubleTapName = action.aName;
  2177. }
  2178. else
  2179. {
  2180. thePlayer.StopDodgeTimer();
  2181.  
  2182. thePlayer.EvadePressed(EBAT_Dodge);
  2183. }
  2184.  
  2185. }
  2186. }
  2187.  
  2188. event OnCastSign( action : SInputAction )
  2189. {
  2190. var signSkill : ESkill;
  2191.  
  2192. if( !thePlayer.GetBIsInputAllowed() )
  2193. {
  2194. return false;
  2195. }
  2196.  
  2197. if( IsPressed(action) )
  2198. {
  2199. if( !IsActionAllowed(EIAB_Signs) )
  2200. {
  2201. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Signs);
  2202. return false;
  2203. }
  2204. if ( thePlayer.IsHoldingItemInLHand() && thePlayer.IsUsableItemLBlocked() )
  2205. {
  2206. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Undefined, false, false, true);
  2207. return false;
  2208. }
  2209. signSkill = SignEnumToSkillEnum( thePlayer.GetEquippedSign() );
  2210. if( signSkill != S_SUndefined )
  2211. {
  2212. if(!thePlayer.CanUseSkill(signSkill))
  2213. {
  2214. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Signs, false, false, true);
  2215. return false;
  2216. }
  2217.  
  2218. if( thePlayer.HasStaminaToUseSkill( signSkill, false ) )
  2219. {
  2220. if( GetInvalidUniqueId() != thePlayer.inv.GetItemFromSlot( 'l_weapon' ) && !thePlayer.IsUsableItemLBlocked())
  2221. {
  2222.  
  2223.  
  2224.  
  2225. }
  2226.  
  2227. thePlayer.SetupCombatAction( EBAT_CastSign, BS_Pressed );
  2228. }
  2229. else
  2230. {
  2231. thePlayer.SoundEvent("gui_no_stamina");
  2232. }
  2233. }
  2234. }
  2235. }
  2236.  
  2237.  
  2238.  
  2239.  
  2240. event OnThrowBomb(action : SInputAction)
  2241. {
  2242. var selectedItemId : SItemUniqueId;
  2243.  
  2244. selectedItemId = thePlayer.GetSelectedItemId();
  2245. if(!thePlayer.inv.IsItemBomb(selectedItemId))
  2246. return false;
  2247.  
  2248. if( thePlayer.inv.SingletonItemGetAmmo(selectedItemId) == 0 )
  2249. {
  2250.  
  2251. if(IsPressed(action))
  2252. {
  2253. thePlayer.SoundEvent( "gui_ingame_low_stamina_warning" );
  2254. }
  2255.  
  2256. return false;
  2257. }
  2258.  
  2259. if ( IsReleased(action) )
  2260. {
  2261. if ( thePlayer.IsThrowHold() )
  2262. {
  2263. if ( thePlayer.playerAiming.GetAimedTarget() )
  2264. {
  2265. if ( thePlayer.AllowAttack( thePlayer.playerAiming.GetAimedTarget(), EBAT_ItemUse ) )
  2266. {
  2267. thePlayer.PushCombatActionOnBuffer( EBAT_ItemUse, BS_Released );
  2268. thePlayer.ProcessCombatActionBuffer();
  2269. }
  2270. else
  2271. thePlayer.BombThrowAbort();
  2272. }
  2273. else
  2274. {
  2275. thePlayer.PushCombatActionOnBuffer( EBAT_ItemUse, BS_Released );
  2276. thePlayer.ProcessCombatActionBuffer();
  2277. }
  2278.  
  2279. thePlayer.SetThrowHold( false );
  2280.  
  2281. return true;
  2282.  
  2283. }
  2284. else
  2285. {
  2286. if(!IsActionAllowed(EIAB_ThrowBomb))
  2287. {
  2288. thePlayer.DisplayActionDisallowedHudMessage(EIAB_ThrowBomb);
  2289. return false;
  2290. }
  2291.  
  2292. if ( thePlayer.IsHoldingItemInLHand() && !thePlayer.IsUsableItemLBlocked() )
  2293. {
  2294. thePlayer.SetPlayerActionToRestore ( PATR_ThrowBomb );
  2295. thePlayer.OnUseSelectedItem( true );
  2296. return true;
  2297. }
  2298. if(thePlayer.CanSetupCombatAction_Throw() && theInput.GetLastActivationTime( action.aName ) < 0.3f )
  2299. {
  2300.  
  2301. thePlayer.SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  2302. return true;
  2303. }
  2304.  
  2305. thePlayer.SetupCombatAction( EBAT_ItemUse, BS_Released );
  2306. return true;
  2307. }
  2308. }
  2309.  
  2310. return false;
  2311. }
  2312.  
  2313. event OnThrowBombHold(action : SInputAction)
  2314. {
  2315. var locks : array<SInputActionLock>;
  2316. var ind : int;
  2317.  
  2318. var selectedItemId : SItemUniqueId;
  2319.  
  2320. selectedItemId = thePlayer.GetSelectedItemId();
  2321. if(!thePlayer.inv.IsItemBomb(selectedItemId))
  2322. return false;
  2323.  
  2324. if( thePlayer.inv.SingletonItemGetAmmo(selectedItemId) == 0 )
  2325. {
  2326.  
  2327. if(IsPressed(action))
  2328. {
  2329. thePlayer.SoundEvent( "gui_ingame_low_stamina_warning" );
  2330. }
  2331.  
  2332. return false;
  2333. }
  2334.  
  2335. if( IsPressed(action) )
  2336. {
  2337. if(!IsActionAllowed(EIAB_ThrowBomb))
  2338. {
  2339. thePlayer.DisplayActionDisallowedHudMessage(EIAB_ThrowBomb);
  2340. return false;
  2341. }
  2342. else if(GetWitcherPlayer().GetBombDelay(GetWitcherPlayer().GetItemSlot(selectedItemId)) > 0 )
  2343. {
  2344.  
  2345. return false;
  2346. }
  2347. if ( thePlayer.IsHoldingItemInLHand() && !thePlayer.IsUsableItemLBlocked() )
  2348. {
  2349. thePlayer.SetPlayerActionToRestore ( PATR_ThrowBomb );
  2350. thePlayer.OnUseSelectedItem( true );
  2351. return true;
  2352. }
  2353. if(thePlayer.CanSetupCombatAction_Throw() && theInput.GetLastActivationTime( action.aName ) < 0.3f )
  2354. {
  2355. if( thePlayer.GetBIsCombatActionAllowed() )
  2356. {
  2357. thePlayer.PushCombatActionOnBuffer( EBAT_ItemUse, BS_Pressed );
  2358. thePlayer.ProcessCombatActionBuffer();
  2359. }
  2360. }
  2361.  
  2362.  
  2363.  
  2364. locks = GetActionLocks(EIAB_ThrowBomb);
  2365. ind = FindActionLockIndex(EIAB_ThrowBomb, 'BombThrow');
  2366. if(ind >= 0)
  2367. locks.Erase(ind);
  2368.  
  2369. if(locks.Size() != 0)
  2370. return false;
  2371.  
  2372. thePlayer.SetThrowHold( true );
  2373. return true;
  2374. }
  2375.  
  2376. return false;
  2377. }
  2378.  
  2379. event OnThrowBombAbort(action : SInputAction)
  2380. {
  2381. if( IsPressed(action) )
  2382. {
  2383. thePlayer.BombThrowAbort();
  2384. }
  2385. }
  2386.  
  2387.  
  2388.  
  2389.  
  2390.  
  2391. event OnCbtThrowItem( action : SInputAction )
  2392. {
  2393. var isUsableItem, isCrossbow, isBomb, ret : bool;
  2394. var itemId : SItemUniqueId;
  2395.  
  2396.  
  2397. if(thePlayer.IsInAir() || thePlayer.GetWeaponHolster().IsOnTheMiddleOfHolstering())
  2398. return false;
  2399.  
  2400. if( thePlayer.IsSwimming() && !thePlayer.OnCheckDiving() && thePlayer.GetCurrentStateName() != 'AimThrow' )
  2401. return false;
  2402.  
  2403. itemId = thePlayer.GetSelectedItemId();
  2404.  
  2405. if(!thePlayer.inv.IsIdValid(itemId))
  2406. return false;
  2407.  
  2408. isCrossbow = thePlayer.inv.IsItemCrossbow(itemId);
  2409. if(!isCrossbow)
  2410. {
  2411. isBomb = thePlayer.inv.IsItemBomb(itemId);
  2412. if(!isBomb)
  2413. {
  2414. isUsableItem = true;
  2415. }
  2416. }
  2417.  
  2418.  
  2419.  
  2420.  
  2421. if( isCrossbow )
  2422. {
  2423. if ( IsActionAllowed(EIAB_Crossbow) )
  2424. {
  2425. if( IsPressed(action))
  2426. {
  2427. if ( thePlayer.IsHoldingItemInLHand() && !thePlayer.IsUsableItemLBlocked() )
  2428. {
  2429.  
  2430.  
  2431. thePlayer.SetPlayerActionToRestore ( PATR_Crossbow );
  2432. thePlayer.OnUseSelectedItem( true );
  2433. ret = true;
  2434. }
  2435. else if ( thePlayer.GetBIsInputAllowed() && !thePlayer.IsCurrentlyUsingItemL() )
  2436. {
  2437. thePlayer.SetIsAimingCrossbow( true );
  2438. thePlayer.SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  2439.  
  2440.  
  2441. ret = true;
  2442. }
  2443. }
  2444. else
  2445. {
  2446.  
  2447. if ( thePlayer.GetIsAimingCrossbow() && !thePlayer.IsCurrentlyUsingItemL() )
  2448. {
  2449. thePlayer.SetupCombatAction( EBAT_ItemUse, BS_Released );
  2450.  
  2451.  
  2452. thePlayer.SetIsAimingCrossbow( false );
  2453. ret = true;
  2454. }
  2455. }
  2456. }
  2457. else
  2458. {
  2459. if ( !thePlayer.IsInShallowWater() )
  2460. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Crossbow);
  2461. }
  2462.  
  2463. if ( IsPressed(action) )
  2464. thePlayer.AddTimer( 'IsItemUseInputHeld', 0.00001, true );
  2465. else
  2466. thePlayer.RemoveTimer('IsItemUseInputHeld');
  2467.  
  2468. return ret;
  2469. }
  2470. else if(isBomb)
  2471. {
  2472. return OnThrowBomb(action);
  2473. }
  2474. else if(isUsableItem && !thePlayer.IsSwimming() )
  2475. {
  2476. if( IsActionAllowed(EIAB_UsableItem) )
  2477. {
  2478. if(IsPressed(action) && thePlayer.HasStaminaToUseAction(ESAT_UsableItem))
  2479. {
  2480. thePlayer.SetPlayerActionToRestore ( PATR_Default );
  2481. thePlayer.OnUseSelectedItem();
  2482. return true;
  2483. }
  2484.  
  2485. }
  2486. else
  2487. {
  2488. thePlayer.DisplayActionDisallowedHudMessage(EIAB_UsableItem);
  2489. }
  2490. }
  2491.  
  2492. return false;
  2493. }
  2494.  
  2495. event OnCbtThrowItemHold( action : SInputAction )
  2496. {
  2497. var isBomb, isCrossbow, isUsableItem : bool;
  2498. var itemId : SItemUniqueId;
  2499.  
  2500.  
  2501. if(thePlayer.IsInAir() || thePlayer.GetWeaponHolster().IsOnTheMiddleOfHolstering() )
  2502. return false;
  2503.  
  2504. if( thePlayer.IsSwimming() && !thePlayer.OnCheckDiving() && thePlayer.GetCurrentStateName() != 'AimThrow' )
  2505. return false;
  2506.  
  2507. itemId = thePlayer.GetSelectedItemId();
  2508.  
  2509. if(!thePlayer.inv.IsIdValid(itemId))
  2510. return false;
  2511.  
  2512. isCrossbow = thePlayer.inv.IsItemCrossbow(itemId);
  2513. if(!isCrossbow)
  2514. {
  2515. isBomb = thePlayer.inv.IsItemBomb(itemId);
  2516. if(isBomb)
  2517. {
  2518. return OnThrowBombHold(action);
  2519. }
  2520. else
  2521. {
  2522. isUsableItem = true;
  2523. }
  2524. }
  2525.  
  2526.  
  2527. if(IsPressed(action))
  2528. {
  2529. if( isCrossbow && !IsActionAllowed(EIAB_Crossbow) )
  2530. {
  2531. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Crossbow);
  2532. return false;
  2533. }
  2534.  
  2535. if( isUsableItem)
  2536. {
  2537. if(!IsActionAllowed(EIAB_UsableItem))
  2538. {
  2539. thePlayer.DisplayActionDisallowedHudMessage(EIAB_UsableItem);
  2540. return false;
  2541. }
  2542. else if(thePlayer.IsSwimming())
  2543. {
  2544. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Undefined, false, false, true);
  2545. return false;
  2546. }
  2547. }
  2548. }
  2549.  
  2550. if( IsPressed(action) )
  2551. {
  2552. thePlayer.SetThrowHold( true );
  2553. return true;
  2554. }
  2555. else if( IsReleased(action) && thePlayer.IsThrowHold())
  2556. {
  2557.  
  2558.  
  2559. thePlayer.SetupCombatAction( EBAT_ItemUse, BS_Released );
  2560. thePlayer.SetThrowHold( false );
  2561. return true;
  2562. }
  2563.  
  2564. return false;
  2565. }
  2566.  
  2567. event OnCbtThrowCastAbort( action : SInputAction )
  2568. {
  2569. var player : W3PlayerWitcher;
  2570. var throwStage : EThrowStage;
  2571.  
  2572. if(thePlayer.inv.IsItemBomb(thePlayer.GetSelectedItemId()))
  2573. {
  2574. return OnThrowBombAbort(action);
  2575. }
  2576.  
  2577. if( IsPressed(action) )
  2578. {
  2579. player = GetWitcherPlayer();
  2580. if(player)
  2581. {
  2582. if( player.IsCastingSign() )
  2583. {
  2584. player.CastSignAbort();
  2585. }
  2586. else
  2587. {
  2588. if ( thePlayer.inv.IsItemCrossbow( thePlayer.inv.GetItemFromSlot( 'l_weapon' ) ) )
  2589. {
  2590. thePlayer.OnRangedForceHolster();
  2591. }
  2592. else
  2593. {
  2594. throwStage = (int)thePlayer.GetBehaviorVariable( 'throwStage', (int)TS_Stop);
  2595.  
  2596. if(throwStage == TS_Start || throwStage == TS_Loop)
  2597. player.ThrowingAbort();
  2598. }
  2599. }
  2600. }
  2601. }
  2602. }
  2603.  
  2604. event OnCbtSelectLockTarget( inputVector : Vector )
  2605. {
  2606. var newLockTarget : CActor;
  2607. var inputHeading : float;
  2608. var target : CActor;
  2609.  
  2610. inputVector.Y = inputVector.Y * -1.f;
  2611. inputHeading = VecHeading( inputVector );
  2612.  
  2613. newLockTarget = thePlayer.GetScreenSpaceLockTarget( thePlayer.GetDisplayTarget(), 180.f, 1.f, inputHeading );
  2614.  
  2615. if ( newLockTarget )
  2616. thePlayer.ProcessLockTarget( newLockTarget );
  2617.  
  2618. target = thePlayer.GetTarget();
  2619. if ( target )
  2620. {
  2621. thePlayer.SetSlideTarget( target );
  2622.  
  2623. }
  2624. }
  2625.  
  2626. event OnCbtLockAndGuard( action : SInputAction )
  2627. {
  2628. if(thePlayer.IsCiri() && !GetCiriPlayer().HasSword())
  2629. return false;
  2630.  
  2631.  
  2632. if( IsReleased(action) )
  2633. {
  2634. thePlayer.SetGuarded(false);
  2635. thePlayer.OnGuardedReleased();
  2636. }
  2637.  
  2638. if( (thePlayer.IsWeaponHeld('fists') || thePlayer.GetCurrentStateName() == 'CombatFists') && !IsActionAllowed(EIAB_Fists))
  2639. {
  2640. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Fists);
  2641. return false;
  2642. }
  2643.  
  2644. if( IsPressed(action) )
  2645. {
  2646. if( !IsActionAllowed(EIAB_Parry) )
  2647. {
  2648. if ( IsActionBlockedBy(EIAB_Parry,'UsableItem') )
  2649. {
  2650. thePlayer.DisplayActionDisallowedHudMessage(EIAB_Parry);
  2651. }
  2652. return true;
  2653. }
  2654.  
  2655. if ( thePlayer.GetCurrentStateName() == 'Exploration' )
  2656. thePlayer.GoToCombatIfNeeded();
  2657.  
  2658. if ( thePlayer.bLAxisReleased )
  2659. thePlayer.ResetRawPlayerHeading();
  2660.  
  2661. if ( thePlayer.rangedWeapon && thePlayer.rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  2662. thePlayer.OnRangedForceHolster( true, true );
  2663.  
  2664. thePlayer.AddCounterTimeStamp(theGame.GetEngineTime());
  2665. thePlayer.SetGuarded(true);
  2666. thePlayer.OnPerformGuard();
  2667. }
  2668. }
  2669.  
  2670. event OnCbtCameraLockOrSpawnHorse( action : SInputAction )
  2671. {
  2672. if ( OnCbtCameraLock(action) )
  2673. return true;
  2674.  
  2675. if ( OnCommSpawnHorse(action) )
  2676. return true;
  2677.  
  2678. return false;
  2679. }
  2680.  
  2681. event OnCbtCameraLock( action : SInputAction )
  2682. {
  2683. if( IsPressed(action) )
  2684. {
  2685. if ( thePlayer.IsThreatened() || thePlayer.IsActorLockedToTarget() )
  2686. {
  2687. if( !IsActionAllowed(EIAB_CameraLock))
  2688. {
  2689. return false;
  2690. }
  2691. else if ( !thePlayer.IsHardLockEnabled() && thePlayer.GetDisplayTarget() && (CActor)( thePlayer.GetDisplayTarget() ) && IsActionAllowed(EIAB_HardLock))
  2692. {
  2693. if ( thePlayer.bLAxisReleased )
  2694. thePlayer.ResetRawPlayerHeading();
  2695.  
  2696. thePlayer.HardLockToTarget( true );
  2697. }
  2698. else
  2699. {
  2700. thePlayer.HardLockToTarget( false );
  2701. }
  2702. return true;
  2703. }
  2704. }
  2705. return false;
  2706. }
  2707.  
  2708. event OnChangeCameraPreset( action : SInputAction )
  2709. {
  2710. if( IsPressed(action) )
  2711. {
  2712. ((CCustomCamera)theCamera.GetTopmostCameraObject()).NextPreset();
  2713. }
  2714. }
  2715.  
  2716. event OnChangeCameraPresetByMouseWheel( action : SInputAction )
  2717. {
  2718. var tolerance : float;
  2719. tolerance = 10.0f;
  2720.  
  2721. if( ( action.value * totalCameraPresetChange ) < 0.0f )
  2722. {
  2723. totalCameraPresetChange = 0.0f;
  2724. }
  2725.  
  2726. totalCameraPresetChange += action.value;
  2727. if( totalCameraPresetChange < -tolerance )
  2728. {
  2729. ((CCustomCamera)theCamera.GetTopmostCameraObject()).PrevPreset();
  2730. totalCameraPresetChange = 0.0f;
  2731. }
  2732. else if( totalCameraPresetChange > tolerance )
  2733. {
  2734. ((CCustomCamera)theCamera.GetTopmostCameraObject()).NextPreset();
  2735. totalCameraPresetChange = 0.0f;
  2736. }
  2737. }
  2738.  
  2739. event OnMeditationAbort(action : SInputAction)
  2740. {
  2741. //---=== modFriendlyMeditation ===---
  2742. //var med : W3PlayerWitcherStateMeditation;
  2743. //
  2744. //if (!theGame.GetGuiManager().IsAnyMenu())
  2745. //{
  2746. // med = (W3PlayerWitcherStateMeditation)GetWitcherPlayer().GetCurrentState();
  2747. // if(med)
  2748. // {
  2749. //
  2750. //
  2751. // med.StopRequested(false);
  2752. // }
  2753. //}
  2754. var witcher : W3PlayerWitcher = GetWitcherPlayer();
  2755.  
  2756. //Immersive Meditation++
  2757.  
  2758. var imInstalled : bool;
  2759.  
  2760. if( StringToFloat( theGame.GetInGameConfigWrapper().GetVarValue('ImmersiveCamPositionsMeditation', 'medRotSpeed') ) >= 0.1 )
  2761. imInstalled = true;
  2762.  
  2763. if( ((CMeditationUI)thePlayer.getMeditation()).getMedMenuBool() && imInstalled )
  2764. {
  2765. ((CMeditationUI)thePlayer.getMeditation()).NewMeditate();
  2766. }
  2767.  
  2768. //Immersive Meditation--
  2769.  
  2770. {
  2771. witcher.ModEndMeditation();
  2772. if (!theGame.GetGuiManager().IsAnyMenu())
  2773. {
  2774. med = (W3PlayerWitcherStateMeditation)GetWitcherPlayer().GetCurrentState();
  2775. if(med)
  2776. {
  2777.  
  2778.  
  2779. med.StopRequested(false);
  2780. }
  2781. }
  2782. //---=== modFriendlyMeditation ===---
  2783. }
  2784.  
  2785. public final function ClearLocksForNGP()
  2786. {
  2787. var i : int;
  2788.  
  2789. for(i=actionLocks.Size()-1; i>=0; i-=1)
  2790. {
  2791. OnActionLockChanged(i, false);
  2792. actionLocks[i].Clear();
  2793. }
  2794. }
  2795.  
  2796.  
  2797.  
  2798.  
  2799.  
  2800. public function Dbg_UnlockAllActions()
  2801. {
  2802. var i : int;
  2803.  
  2804. if( theGame.IsFinalBuild() )
  2805. {
  2806. return;
  2807. }
  2808.  
  2809. for(i=actionLocks.Size()-1; i>=0; i-=1)
  2810. {
  2811. OnActionLockChanged(i, false);
  2812. }
  2813. actionLocks.Clear();
  2814. }
  2815.  
  2816. event OnDbgSpeedUp( action : SInputAction )
  2817. {
  2818. if( theGame.IsFinalBuild() )
  2819. {
  2820. return false;
  2821. }
  2822.  
  2823. if(IsPressed(action))
  2824. {
  2825. theGame.SetTimeScale(4, theGame.GetTimescaleSource(ETS_DebugInput), theGame.GetTimescalePriority(ETS_DebugInput));
  2826. }
  2827. else if(IsReleased(action))
  2828. {
  2829. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_DebugInput) );
  2830. }
  2831. }
  2832.  
  2833. event OnDbgHit( action : SInputAction )
  2834. {
  2835. if( theGame.IsFinalBuild() )
  2836. {
  2837. return false;
  2838. }
  2839.  
  2840. if(IsReleased(action))
  2841. {
  2842. thePlayer.SetBehaviorVariable( 'HitReactionDirection',(int)EHRD_Back);
  2843. thePlayer.SetBehaviorVariable( 'isAttackReflected', 0 );
  2844. thePlayer.SetBehaviorVariable( 'HitReactionType', (int)EHRT_Heavy);
  2845. thePlayer.SetBehaviorVariable( 'HitReactionWeapon', 0);
  2846. thePlayer.SetBehaviorVariable( 'HitSwingDirection',(int)ASD_LeftRight);
  2847. thePlayer.SetBehaviorVariable( 'HitSwingType',(int)AST_Horizontal);
  2848.  
  2849. thePlayer.RaiseForceEvent( 'Hit' );
  2850. thePlayer.OnRangedForceHolster( true );
  2851. GetWitcherPlayer().SetCustomRotation( 'Hit', thePlayer.GetHeading()+180, 1080.f, 0.1f, false );
  2852. thePlayer.CriticalEffectAnimationInterrupted("OnDbgHit");
  2853. }
  2854. }
  2855.  
  2856. event OnDbgKillTarget( action : SInputAction )
  2857. {
  2858. var target : CActor;
  2859.  
  2860. if( theGame.IsFinalBuild() )
  2861. {
  2862. return false;
  2863. }
  2864.  
  2865. target = thePlayer.GetTarget();
  2866.  
  2867. if( target && IsReleased(action) )
  2868. {
  2869. target.Kill( 'Debug' );
  2870. }
  2871. }
  2872.  
  2873. event OnDbgKillAll( action : SInputAction )
  2874. {
  2875. if( theGame.IsFinalBuild() )
  2876. {
  2877. return false;
  2878. }
  2879.  
  2880. if(IsReleased(action))
  2881. thePlayer.DebugKillAll();
  2882. }
  2883.  
  2884.  
  2885. event OnDbgKillAllTargetingPlayer( action : SInputAction )
  2886. {
  2887. var i : int;
  2888. var all : array<CActor>;
  2889.  
  2890. if( theGame.IsFinalBuild() )
  2891. {
  2892. return false;
  2893. }
  2894.  
  2895. if(IsPressed(action))
  2896. {
  2897. all = GetActorsInRange(thePlayer, 10000, 10000, '', true);
  2898. for(i=0; i<all.Size(); i+=1)
  2899. {
  2900. if(all[i] != thePlayer && all[i].GetTarget() == thePlayer)
  2901. all[i].Kill( 'Debug' );
  2902. }
  2903. }
  2904. }
  2905.  
  2906. event OnDbgTeleportToPin( action : SInputAction )
  2907. {
  2908. if( theGame.IsFinalBuild() )
  2909. {
  2910. return false;
  2911. }
  2912.  
  2913. if(IsReleased(action))
  2914. thePlayer.DebugTeleportToPin();
  2915. }
  2916.  
  2917.  
  2918.  
  2919. event OnBoatDismount( action : SInputAction )
  2920. {
  2921. var boatComp : CBoatComponent;
  2922. var stopAction : SInputAction;
  2923.  
  2924. stopAction = theInput.GetAction('GI_Decelerate');
  2925.  
  2926. if( IsReleased(action) && ( theInput.LastUsedPCInput() || ( stopAction.value < 0.7 && stopAction.lastFrameValue < 0.7 ) ) )
  2927. {
  2928. if( thePlayer.IsActionAllowed( EIAB_DismountVehicle ) )
  2929. {
  2930. boatComp = (CBoatComponent)thePlayer.GetUsedVehicle().GetComponentByClassName( 'CBoatComponent' );
  2931. boatComp.IssueCommandToDismount( DT_normal );
  2932. }
  2933. else
  2934. {
  2935. thePlayer.DisplayActionDisallowedHudMessage(EIAB_DismountVehicle);
  2936. }
  2937. }
  2938. }
  2939.  
  2940.  
  2941.  
  2942.  
  2943.  
  2944. event OnCiriDrawWeapon( action : SInputAction )
  2945. {
  2946. var duringCastSign : bool;
  2947.  
  2948.  
  2949. if ( IsReleased(action) || ( IsPressed(action) && (thePlayer.GetCurrentMeleeWeaponType() == PW_None || thePlayer.GetCurrentMeleeWeaponType() == PW_Fists) ) )
  2950. {
  2951. if ( thePlayer.GetBIsInputAllowed() && thePlayer.GetBIsCombatActionAllowed() )
  2952. {
  2953. if (thePlayer.GetCurrentMeleeWeaponType() == PW_Steel && !thePlayer.IsThreatened() )
  2954. thePlayer.OnEquipMeleeWeapon( PW_None, false );
  2955. else
  2956. thePlayer.OnEquipMeleeWeapon( PW_Steel, false );
  2957. }
  2958. }
  2959. else if(IsReleased(action) || ( IsPressed(action) && (thePlayer.GetCurrentMeleeWeaponType() == PW_Steel || thePlayer.GetCurrentMeleeWeaponType() == PW_Silver) ) )
  2960. {
  2961. CiriSheatheWeapon();
  2962. }
  2963. }
  2964.  
  2965. event OnCiriHolsterWeapon( action : SInputAction )
  2966. {
  2967. var currWeaponType : EPlayerWeapon;
  2968.  
  2969. if(IsPressed( action ))
  2970. {
  2971. currWeaponType = thePlayer.GetCurrentMeleeWeaponType();
  2972.  
  2973. if(currWeaponType == PW_Steel || currWeaponType == PW_Silver)
  2974. {
  2975. CiriSheatheWeapon();
  2976. }
  2977. }
  2978. }
  2979.  
  2980. private final function CiriSheatheWeapon()
  2981. {
  2982. if ( thePlayer.GetBIsInputAllowed() && thePlayer.GetBIsCombatActionAllowed() && !thePlayer.IsThreatened() )
  2983. {
  2984. thePlayer.OnEquipMeleeWeapon( PW_None, false );
  2985. }
  2986. }
  2987.  
  2988.  
  2989.  
  2990.  
  2991. event OnCommHoldFastMenu( action : SInputAction )
  2992. {
  2993. if(IsPressed(action))
  2994. {
  2995. holdFastMenuInvoked = true;
  2996. PushInventoryScreen();
  2997. }
  2998. }
  2999.  
  3000. event OnFastMenu( action : SInputAction )
  3001. {
  3002. if( IsReleased(action) )
  3003. {
  3004. if(holdFastMenuInvoked)
  3005. {
  3006. holdFastMenuInvoked = false;
  3007. return false;
  3008. }
  3009.  
  3010. if ( theGame.IsBlackscreenOrFading() )
  3011. {
  3012. return false;
  3013. }
  3014.  
  3015. if (theGame.GetGuiManager().IsAnyMenu())
  3016. {
  3017. return false;
  3018. }
  3019.  
  3020. if( IsActionAllowed( EIAB_OpenFastMenu ) )
  3021. {
  3022. theGame.SetMenuToOpen( '' );
  3023. theGame.RequestMenu('CommonMenu' );
  3024. }
  3025. else
  3026. {
  3027. thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenFastMenu);
  3028. }
  3029. }
  3030. }
  3031.  
  3032. event OnIngameMenu( action : SInputAction )
  3033. {
  3034. //Immersive Meditation++
  3035. var passedSecondsInGameTime : float;
  3036. var passedSecondsInRealTime : float;
  3037. var imInstalled : bool;
  3038. //Immersive Meditation--
  3039.  
  3040. var openedPanel : name;
  3041.  
  3042. openedPanel = theGame.GetMenuToOpen();
  3043.  
  3044. //Immersive Meditation++
  3045. if( StringToFloat( theGame.GetInGameConfigWrapper().GetVarValue('ImmersiveCamPositionsMeditation', 'medRotSpeed') ) >= 0.1 )
  3046. imInstalled = true;
  3047.  
  3048. if ( IsReleased(action) )
  3049. {
  3050. if( ((CMeditationUI)thePlayer.getMeditation()).getMedMenuBool() && imInstalled )
  3051. {
  3052. ((CMeditationUI)thePlayer.getMeditation()).NewMeditate();
  3053. passedSecondsInGameTime = GameTimeToSeconds(theGame.GetGameTime() - ((CMeditationUI)thePlayer.getMeditation()).getWaitStartTime());
  3054. passedSecondsInRealTime = ConvertGameSecondsToRealTimeSeconds(passedSecondsInGameTime);
  3055. if (passedSecondsInRealTime > 7.0)
  3056. {
  3057. ((W3Campfire)((CMeditationUI)thePlayer.getMeditation()).GetCampFire()).AddTimer('UnLight',1.7,false);
  3058. }
  3059. else
  3060. {
  3061. ((W3Campfire)((CMeditationUI)thePlayer.getMeditation()).GetCampFire()).AddTimer('UnLight',(8.7-passedSecondsInRealTime),false);
  3062. }
  3063. }
  3064. //Immersive Meditation--
  3065. else if( IsReleased(action) && openedPanel != 'GlossaryTutorialsMenu' && !theGame.GetGuiManager().IsAnyMenu() ) // #B very ugly :P
  3066. {
  3067. if ( theGame.IsBlackscreenOrFading() )
  3068. return false;
  3069.  
  3070. theGame.SetMenuToOpen( '' );
  3071. theGame.RequestMenu('CommonIngameMenu' );
  3072. }
  3073. }
  3074. }
  3075.  
  3076. event OnToggleHud( action : SInputAction )
  3077. {
  3078. var hud : CR4ScriptedHud;
  3079. if ( IsReleased(action) )
  3080. {
  3081. hud = (CR4ScriptedHud)theGame.GetHud();
  3082. if ( hud )
  3083. {
  3084. hud.ToggleHudByUser();
  3085. }
  3086. }
  3087. }
  3088.  
  3089. public final function Debug_ClearAllActionLocks(optional action : EInputActionBlock, optional all : bool)
  3090. {
  3091. var i : int;
  3092.  
  3093. if(all)
  3094. {
  3095. Dbg_UnlockAllActions();
  3096. }
  3097. else
  3098. {
  3099. OnActionLockChanged(action, false);
  3100. actionLocks[action].Clear();
  3101. }
  3102. }
  3103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement