Advertisement
Hird194

Unexpected end of file found after '{' at line 49

Oct 23rd, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.35 KB | None | 0 0
  1. /*
  2. Copyright © CD Projekt RED 2015
  3. */
  4.  
  5.  
  6.  
  7.  
  8.  
  9. //---=== modFriendlyMeditation ===---
  10. //reworked
  11. state Meditation in W3PlayerWitcher extends MeditationBase
  12. {
  13. private var meditationIdle, startedFastforward : bool;
  14. private var noSaveLock : int;
  15.  
  16. public function StartFastforward()
  17. {
  18. if( meditationIdle && !startedFastforward )
  19. {
  20. startedFastforward = true;
  21. if( virtual_parent.GetCurrentStateName() != 'MeditationWaiting' )
  22. virtual_parent.PushState( 'MeditationWaiting' );
  23. }
  24. }
  25.  
  26. public function EndFastforward()
  27. {
  28. if( startedFastforward )
  29. {
  30. startedFastforward = false;
  31. if( virtual_parent.GetCurrentStateName() == 'MeditationWaiting' )
  32. virtual_parent.PopState();
  33. }
  34. }
  35.  
  36. public function IsMeditationIdle() : bool
  37. {
  38. return meditationIdle;
  39. }
  40.  
  41. private function SetMeditationIdle()
  42. {
  43. meditationIdle = true;
  44. if ( !GetFMeditationConfig().HotkeyManualFastforward() || virtual_parent.GetMeditationStartedByClock() )
  45. StartFastforward();
  46. }
  47.  
  48. event OnBehaviorGraphNotification( notificationName : name, stateName : name )
  49. {
  50. if ( virtual_parent.GetPlayerAction() == PEA_Meditation )
  51. {
  52. if( notificationName == 'OnPlayerActionStartFinished' && !meditationIdle )
  53.  
  54. virtual_parent.SetBehaviorVariable('MeditateWithIgnite', 0);
  55. actionSuccess = virtual_parent.PlayerStartAction(PEA_Meditation);
  56.  
  57. virtual_parent.SetBehaviorVariable('MeditateWithIgnite', 0);
  58. actionSuccess = virtual_parent.PlayerStartAction(PEA_Meditation);
  59. SetMeditationIdle();
  60. }
  61. else
  62. {
  63. actionSuccess = true;
  64. else
  65. {
  66. actionSuccess = true;
  67. }
  68.  
  69. parent.OnBehaviorGraphNotification( notificationName, stateName );
  70.  
  71.  
  72.  
  73. event OnEnterState( prevStateName : name )
  74. {
  75. super.OnEnterState( prevStateName );
  76.  
  77. //theGame.witcherLog.AddMessage("Entering Meditation: " + prevStateName);
  78.  
  79. if( virtual_parent.GetBehaviorVariable('MeditateAbort') > 0 )
  80. {
  81. virtual_parent.ModEndMeditation();
  82. }
  83. else if(prevStateName != 'MeditationWaiting')
  84. {
  85. virtual_parent.SetBehaviorVariable( 'MeditateWithIgnite', 0 );
  86. virtual_parent.SetBehaviorVariable( 'HasCampfire', 0 );
  87. meditationIdle = false;
  88. BlockGameplayActions( true );
  89. theGame.CreateNoSaveLock( "Meditation", noSaveLock );
  90. HideItemsInHands();
  91. InternalBeginMeditation();
  92. thePlayer.RemoveTimer( 'MeditationModulesOffTimer' );
  93. thePlayer.AddTimer( 'MeditationModulesOnTimer', 0.1, false ); //FHUD compatibility
  94. }
  95. }
  96.  
  97. event OnLeaveState( nextStateName : name )
  98. {
  99. //theGame.witcherLog.AddMessage("Exiting Meditation: " + nextStateName);
  100.  
  101. if(nextStateName != 'MeditationWaiting')
  102. {
  103. meditationIdle = false;
  104. BlockGameplayActions( false );
  105. theGame.ReleaseNoSaveLock( noSaveLock );
  106. InternalEndMeditation();
  107. thePlayer.RemoveTimer( 'MeditationModulesOnTimer' );
  108. thePlayer.AddTimer( 'MeditationModulesOffTimer', 0.1, false ); //FHUD compatibility
  109. FactsAdd( 'MeditationWaitFinished', 1, 1 );
  110. }
  111.  
  112. super.OnLeaveState( nextStateName );
  113. }
  114.  
  115. event OnPlayerTickTimer( deltaTime : float )
  116. {
  117. super.OnPlayerTickTimer( deltaTime );
  118.  
  119. if ( virtual_parent.GetPlayerAction() != PEA_Meditation && virtual_parent.GetPlayerAction() != PEA_GoToSleep )
  120. {
  121. virtual_parent.ModEndMeditation();
  122. }
  123. }
  124.  
  125. private function InternalBeginMeditation()
  126. {
  127. startedFastforward = false;
  128. if ( virtual_parent.GetIsPlayerMeditatingInBed() )
  129. {
  130. virtual_parent.SetBehaviorVariable( 'MeditateWithIgnite', 0 );
  131. virtual_parent.SetBehaviorVariable( 'HasCampfire', 0 );
  132. SetMeditationIdle();
  133. }
  134. else
  135. {
  136. if ( virtual_parent.fMeditationConfig.SpawnCampFire() )
  137. {
  138. if ( virtual_parent.fmedCanSpawnCampfire )
  139. {
  140. if ( !virtual_parent.spawnedCampFire || VecDistanceSquared2D(virtual_parent.spawnedCampFire.GetWorldPosition(), thePlayer.GetWorldPosition()) > 9.f )
  141. {
  142. virtual_parent.SetBehaviorVariable( 'MeditateWithIgnite', 1 );
  143. thePlayer.AddTimer( 'SpawnCampFireTimer', 4.5, false );
  144. }
  145. }
  146. else // spawning was turned off by Preparations
  147. {
  148. thePlayer.AddTimer( 'CampFireErrorMessageTimer', 0.1, false );
  149. }
  150. }
  151. virtual_parent.SetBehaviorVariable( 'HasCampfire', 0 );
  152. virtual_parent.PlayerStartAction( PEA_Meditation );
  153. }
  154. }
  155.  
  156. timer function SpawnCampFireTimer(dt : float, id : int)
  157. {
  158. var campFire : CLightEntitySimple;
  159. var template : CEntityTemplate;
  160. var commonMenuRef : CR4CommonMenu;
  161. var commonMenuRef : CR4CommonMenu;
  162. var pos : Vector;
  163. var l_bed : W3WitcherBed;
  164. var z : float;
  165. var rot : EulerAngles;
  166.  
  167. template = (CEntityTemplate)LoadResource( "environment\decorations\light_sources\campfire\campfire_01.w2ent", true);
  168. pos = thePlayer.GetWorldPosition() + VecFromHeading( thePlayer.GetHeading() ) * Vector(0.8, 0.8, 0);
  169. if( theGame.GetWorld().NavigationComputeZ( pos, pos.Z - 128, pos.Z + 128, z ) )
  170. {
  171. pos.Z = z;
  172. }
  173. if( theGame.GetWorld().PhysicsCorrectZ( pos, z ) )
  174. {
  175. pos.Z = z;
  176. }
  177. rot = thePlayer.GetWorldRotation();
  178. virtual_parent.spawnedCampFire = (W3Campfire)theGame.CreateEntity(template, pos, rot);
  179. virtual_parent.spawnedCampFire.ToggleFire( true );
  180. thePlayer.AddTimer( 'CampFireResourcesTimer', 0.1, false ); //Preparations compatibility
  181. }
  182.  
  183. private function InternalEndMeditation()
  184.  
  185. l_bed = (W3WitcherBed)theGame.GetEntityByTag( 'witcherBed' );
  186. {
  187. var wbed : W3WitcherBed;
  188. if( !l_bed.GetWasUsed() )
  189. thePlayer.RemoveTimer( 'SpawnCampFireTimer' );
  190. wbed = (W3WitcherBed)theGame.GetEntityByTag( 'witcherBed' );
  191. if ( wbed.GetWasUsed() )
  192. virtual_parent.PlayerStopAction(PEA_Meditation);
  193. virtual_parent.PlayerStopAction(PEA_Meditation);
  194. GetWitcherPlayer().ManageSleeping();
  195. wbed.SetWasUsed( false );
  196. else
  197. if ( startedFastforward )
  198. virtual_parent.PlayerStopAction( PEA_GoToSleep );
  199. EndFastforward();
  200. if ( virtual_parent.spawnedCampFire && !GetFMeditationConfig().DoNotDespawnCampFire() )
  201. l_bed.SetWasUsed( false );
  202. virtual_parent.SetBehaviorVariable( 'HasCampfire', 1 );
  203. thePlayer.AddTimer( 'DeSpawnCampFireTimer', 1.5, false );
  204. if ( virtual_parent.GetPlayerAction() == PEA_Meditation )
  205. {
  206. virtual_parent.PlayerStopAction( PEA_Meditation );
  207. }
  208. }
  209.  
  210. private function HideItemsInHands()
  211. {
  212. if ( virtual_parent.GetCurrentMeleeWeaponType() != PW_None )
  213. {
  214. virtual_parent.OnEquipMeleeWeapon( PW_None, true, true );
  215. }
  216. if ( virtual_parent.IsHoldingItemInLHand() )
  217. {
  218. virtual_parent.HideUsableItem( true );
  219. }
  220. if ( virtual_parent.rangedWeapon )
  221. {
  222. virtual_parent.OnRangedForceHolster( true, true, false );
  223. }
  224. }
  225.  
  226. function BlockGameplayActions( lock : bool )
  227. {
  228. var exceptions : array< EInputActionBlock >;
  229.  
  230. exceptions.PushBack( EIAB_OpenMeditation );
  231. exceptions.PushBack( EIAB_MeditationWaiting );
  232. exceptions.PushBack( EIAB_OpenFastMenu );
  233. exceptions.PushBack( EIAB_OpenInventory );
  234. exceptions.PushBack( EIAB_OpenAlchemy );
  235. exceptions.PushBack( EIAB_OpenCharacterPanel );
  236. exceptions.PushBack( EIAB_OpenJournal );
  237. exceptions.PushBack( EIAB_OpenMap );
  238. exceptions.PushBack( EIAB_OpenGlossary );
  239. exceptions.PushBack( EIAB_RadialMenu );
  240.  
  241. if ( lock )
  242. {
  243. thePlayer.BlockAllActions( 'Meditation', true, exceptions );
  244. }
  245. else
  246. {
  247. thePlayer.BlockAllActions( 'Meditation', false);
  248. }
  249. }
  250. }
  251. //---=== modFriendlyMeditation ===---
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement