Advertisement
Guest User

Script error

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