Advertisement
Guest User

Untitled

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