Advertisement
Guest User

Error [mod0000_mergedfiles]game\gui\hud\modules\hudmodulebuf

a guest
Dec 18th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 KB | None | 0 0
  1. /*
  2. Copyright © CD Projekt RED 2015
  3. */
  4.  
  5. class CR4HudModuleBuffs extends CR4HudModuleBase
  6. {
  7. private var _currentEffects : array <CBaseGameplayEffect>;
  8. private var _previousEffects : array <CBaseGameplayEffect>;
  9.  
  10. private var m_fxSetPercentSFF : CScriptedFlashFunction;
  11. private var m_flashValueStorage : CScriptedFlashValueStorage;
  12. private var iCurrentEffectsSize : int; default iCurrentEffectsSize = 0;
  13. private var bDisplayBuffs : bool; default bDisplayBuffs = true;
  14.  
  15.  
  16.  
  17.  
  18. event OnConfigUI()
  19. {
  20. var flashModule : CScriptedFlashSprite;
  21. var hud : CR4ScriptedHud;
  22.  
  23. m_anchorName = "mcAnchorBuffs";
  24. m_flashValueStorage = GetModuleFlashValueStorage();
  25. super.OnConfigUI();
  26.  
  27. flashModule = GetModuleFlash();
  28. m_fxSetPercentSFF = flashModule.GetMemberFlashFunction( "setPercent" );
  29.  
  30. hud = (CR4ScriptedHud)theGame.GetHud();
  31. if (hud)
  32. {
  33. hud.UpdateHudConfig('BuffsModule', true);
  34. }
  35. }
  36.  
  37. event OnTick( timeDelta : float )
  38. {
  39. var effectsSize : int;
  40. var effectArray : array< CBaseGameplayEffect >;
  41. var i : int;
  42. var offset : int;
  43. var duration : float;
  44. var initialDuration : float;
  45.  
  46. if ( !CanTick( timeDelta ) )
  47. return true;
  48.  
  49. _previousEffects = _currentEffects;
  50. _currentEffects.Clear();
  51.  
  52. if( bDisplayBuffs && GetEnabled() )
  53. {
  54. offset = 0;
  55.  
  56. effectArray = thePlayer.GetCurrentEffects();
  57. effectsSize = effectArray.Size();
  58.  
  59. for ( i = 0; i < effectsSize; i += 1 )
  60. {
  61. // modCustomLocalizationFix++
  62. if(effectArray[i].ShowOnHUD() && effectArray[i].GetEffectNameLocalisationKey() != "" )
  63. // modCustomLocalizationFix--
  64. initialDuration = effectArray[i].GetInitialDuration();
  65. m_runword5Applied = true;
  66. if( initialDuration < 1.0 )
  67. {
  68. initialDuration = 1;
  69. duration = 1;
  70. }
  71. else
  72. {
  73. duration = effectArray[i].GetDurationLeft();
  74. if(duration < 0.f)
  75. duration = 0.f;
  76. }
  77.  
  78. if(_currentEffects.Size() < i+1-offset)
  79. {
  80. _currentEffects.PushBack(effectArray[i]);
  81. m_fxSetPercentSFF.InvokeSelfThreeArgs( FlashArgNumber(i-offset),FlashArgNumber( duration ), FlashArgNumber( initialDuration ) );
  82. }
  83. else if( effectArray[i].GetEffectType() == _currentEffects[i-offset].GetEffectType() )
  84. {
  85. m_fxSetPercentSFF.InvokeSelfThreeArgs( FlashArgNumber(i-offset),FlashArgNumber( duration ), FlashArgNumber( initialDuration ) );
  86. }
  87. else
  88. {
  89. LogChannel('HUDBuffs',i+" something wrong");
  90. }
  91. }
  92. else
  93. {
  94. offset += 1;
  95.  
  96. }
  97. }
  98. }
  99.  
  100.  
  101. if ( _currentEffects.Size() == 0 && _previousEffects.Size() == 0 )
  102. return true;
  103.  
  104.  
  105. if ( buffListHasChanged(_currentEffects, _previousEffects) )
  106. UpdateBuffs();
  107.  
  108. }
  109.  
  110.  
  111. private function buffListHasChanged( currentEffects : array<CBaseGameplayEffect>, previousEffects : array<CBaseGameplayEffect> ) : bool
  112. {
  113. var i : int;
  114. var currentSize : int = currentEffects.Size();
  115. var previousSize : int = previousEffects.Size();
  116.  
  117.  
  118. if( currentSize != previousSize )
  119. return true;
  120. else
  121. {
  122.  
  123. for( i = 0; i < currentSize; i+=1 )
  124. {
  125. if ( currentEffects[i] != previousEffects[i] )
  126. return true;
  127. }
  128.  
  129.  
  130. return false;
  131. }
  132. }
  133.  
  134. function UpdateBuffs()
  135. {
  136. var l_flashObject : CScriptedFlashObject;
  137. var l_flashArray : CScriptedFlashArray;
  138. var i : int;
  139.  
  140. l_flashArray = GetModuleFlashValueStorage()().CreateTempFlashArray();
  141. for(i = 0; i < Min(12,_currentEffects.Size()); i += 1)
  142. {
  143. // modCustomLocalizationFix++
  144. if(_currentEffects[i].ShowOnHUD() && _currentEffects[i].GetEffectNameLocalisationKey() != "" )
  145. // modCustomLocalizationFix--
  146. if(_currentEffects[i].IsNegative())
  147. // modCustomLocalizationFix--
  148. l_flashObject = m_flashValueStorage.CreateTempFlashObject();
  149. l_flashObject.SetMemberFlashBool("isVisible",_currentEffects[i].ShowOnHUD());
  150. l_flashObject.SetMemberFlashString("iconName",_currentEffects[i].GetIcon());
  151. l_flashObject.SetMemberFlashString("title",GetLocStringByKeyExt(_currentEffects[i].GetEffectNameLocalisationKey()));
  152. l_flashObject.SetMemberFlashBool("isPositive",_currentEffects[i].IsPositive());
  153. l_flashObject.SetMemberFlashNumber("duration",_currentEffects[i].GetDurationLeft() );
  154. l_flashObject.SetMemberFlashNumber("initialDuration", _currentEffects[i].GetInitialDuration());
  155. l_flashArray.PushBackFlashObject(l_flashObject);
  156. }
  157. }
  158.  
  159. m_flashValueStorage.SetFlashArray( "hud.buffs", l_flashArray );
  160.  
  161.  
  162. protected function UpdateScale( scale : float, flashModule : CScriptedFlashSprite ) : bool
  163. {
  164. return true;
  165. }
  166.  
  167. protected function UpdatePosition(anchorX:float, anchorY:float) : void
  168. {
  169. var l_flashModule : CScriptedFlashSprite;
  170. var tempX : float;
  171. var tempY : float;
  172.  
  173. l_flashModule = GetModuleFlash();
  174.  
  175.  
  176.  
  177.  
  178. tempX = anchorX + (660.0 * (1.0 - theGame.GetUIHorizontalFrameScale()));
  179. tempY = anchorY + (645.0 * (1.0 - theGame.GetUIVerticalFrameScale()));
  180.  
  181. l_flashModule.SetX( tempX );
  182. l_flashModule.SetY( tempY );
  183. }
  184.  
  185. event OnBuffsDisplay( value : bool )
  186. {
  187. bDisplayBuffs = value;
  188. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement