Advertisement
Guest User

Untitled

a guest
Aug 19th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.17 KB | None | 0 0
  1. /***********************************************************************/
  2. /** © 2015 CD PROJEKT S.A. All rights reserved.
  3. /** THE WITCHER® is a trademark of CD PROJEKT S. A.
  4. /** The Witcher game is based on the prose of Andrzej Sapkowski.
  5. /***********************************************************************/
  6. enum EFloatingValueType
  7. {
  8. EFVT_None,
  9. EFVT_Critical,
  10. EFVT_Block,
  11. EFVT_InstantDeath,
  12. EFVT_DoT,
  13. EFVT_Heal,
  14. EFVT_Buff
  15. }
  16.  
  17. class CR4HudModuleEnemyFocus extends CR4HudModuleBase
  18.  
  19. //modEnemyHud ----------------------------------------------------------------------------
  20. private var m_staminaBar : CScriptedFlashFunction;
  21. private var m_TextField : CScriptedFlashFunction;
  22. private var m_Icon : CScriptedFlashFunction;
  23. private var m_Mutation : CScriptedFlashFunction;
  24. private var m_staminaBarY : CScriptedFlashFunction;
  25. private var m_yPos : CScriptedFlashFunction;
  26.  
  27. private var healthColorInt : int;
  28. private var staminaBool : int;
  29. private var iconBool : bool;
  30. private var mutationBool : bool;
  31. private var levelBool : bool;
  32. private var dodgeBool : bool;
  33. private var targetBool : bool;
  34. private var skullBool : bool;
  35.  
  36. private var wasContainer : bool;
  37.  
  38. private var htmlSize : int;
  39. private var ypos : int;
  40.  
  41. private var currentAttitude : EAIAttitude;
  42. private var lastTarget : CNewNPC;
  43. private var lastNotActor : CGameplayEntity;
  44.  
  45. private var ingameConfigWrapper : CInGameConfigWrapper;
  46. //modEnemyHud ----------------------------------------------------------------------------
  47. private var healthColorInt : int;
  48. private var staminaBool : int;
  49. private var iconBool : bool;
  50. private var mutationBool : bool;
  51. private var levelBool : bool;
  52. private var dodgeBool : bool;
  53. private var targetBool : bool;
  54. private var skullBool : bool;
  55.  
  56. private var wasContainer : bool;
  57.  
  58. private var htmlSize : int;
  59. private var ypos : int;
  60.  
  61. private var currentAttitude : EAIAttitude;
  62. private var lastTarget : CNewNPC;
  63. private var lastNotActor : CGameplayEntity;
  64.  
  65. private var ingameConfigWrapper : CInGameConfigWrapper;
  66. //modEnemyHud ----------------------------------------------------------------------------
  67.  
  68.  
  69.  
  70. private var m_fxSetEnemyName : CScriptedFlashFunction;
  71. private var m_fxSetEnemyLevel : CScriptedFlashFunction;
  72. private var m_fxSetAttitude : CScriptedFlashFunction;
  73. private var m_fxSetEnemyHealth : CScriptedFlashFunction;
  74. private var m_fxSetEnemyStamina : CScriptedFlashFunction;
  75. private var m_fxSetEssenceBarVisibility : CScriptedFlashFunction;
  76. private var m_fxSetStaminaVisibility : CScriptedFlashFunction;
  77. private var m_fxSetNPCQuestIcon : CScriptedFlashFunction;
  78. private var m_fxSetDodgeFeedback : CScriptedFlashFunction;
  79. private var m_fxSetBossOrDead : CScriptedFlashFunction;
  80. private var m_fxSetShowHardLock : CScriptedFlashFunction;
  81. private var m_fxSetDamageText : CScriptedFlashFunction;
  82. private var m_fxHideDamageText : CScriptedFlashFunction;
  83. private var m_fxSetGeneralVisibility : CScriptedFlashFunction;
  84. private var m_fxSetMutationEightVisibility : CScriptedFlashFunction;
  85.  
  86. private var m_mcNPCFocus : CScriptedFlashSprite;
  87.  
  88. private var m_lastTarget : CGameplayEntity;
  89. private var m_lastTargetAttitude : EAIAttitude;
  90. private var m_lastHealthPercentage : int;
  91. private var m_wasAxiied : bool;
  92. private var m_lastStaminaPercentage : int;
  93. private var m_nameInterval : float;
  94. private var m_lastEnemyDifferenceLevel : string;
  95. private var m_lastEnemyLevelString : string;
  96. private var m_lastDodgeFeedbackTarget : CActor;
  97. private var m_lastEnemyName : string;
  98. private var m_lastUseMutation8Icon : bool;
  99.  
  100.  
  101.  
  102. event OnConfigUI()
  103. {
  104. var flashModule : CScriptedFlashSprite;
  105. var hud : CR4ScriptedHud;
  106.  
  107. m_anchorName = "ScaleOnly";
  108.  
  109. flashModule = GetModuleFlash();
  110.  
  111. m_fxSetEnemyName = flashModule.GetMemberFlashFunction( "setEnemyName" );
  112. m_fxSetEnemyLevel = flashModule.GetMemberFlashFunction( "setEnemyLevel" );
  113. m_fxSetAttitude = flashModule.GetMemberFlashFunction( "setAttitude" );
  114. m_fxSetEnemyHealth = flashModule.GetMemberFlashFunction( "setEnemyHealth" );
  115. m_fxSetEnemyStamina = flashModule.GetMemberFlashFunction( "setEnemyStamina" );
  116. m_fxSetEssenceBarVisibility = flashModule.GetMemberFlashFunction( "setEssenceBarVisibility" );
  117. m_fxSetStaminaVisibility = flashModule.GetMemberFlashFunction( "setStaminaVisibility" );
  118. m_fxSetNPCQuestIcon = flashModule.GetMemberFlashFunction( "setNPCQuestIcon" );
  119. m_fxSetDodgeFeedback = flashModule.GetMemberFlashFunction( "setDodgeFeedback" );
  120. m_fxSetDamageText = flashModule.GetMemberFlashFunction( "setDamageText" );
  121. m_fxHideDamageText = flashModule.GetMemberFlashFunction( "hideDamageText" );
  122. m_fxSetBossOrDead = flashModule.GetMemberFlashFunction( "SetBossOrDead" );
  123. m_fxSetShowHardLock = flashModule.GetMemberFlashFunction( "setShowHardLock" );
  124. m_fxSetGeneralVisibility = flashModule.GetMemberFlashFunction( "SetGeneralVisibility" );
  125. m_fxSetMutationEightVisibility = flashModule.GetMemberFlashFunction( "displayMutationEight" );
  126. m_mcNPCFocus = flashModule.GetChildFlashSprite( "mcNPCFocus" );
  127.  
  128. super.OnConfigUI();
  129.  
  130. m_fxSetEnemyName.InvokeSelfOneArg( FlashArgString( "" ) );
  131. m_fxSetEnemyStamina.InvokeSelfOneArg(FlashArgInt(0));
  132.  
  133.  
  134. hud = (CR4ScriptedHud)theGame.GetHud();
  135.  
  136. if (hud)
  137. {
  138. hud.UpdateHudConfig('EnemyFocusModule', true);
  139. }
  140.  
  141.  
  142.  
  143.  
  144. //modEnemyHud ----------------------------------------------------------------------------
  145. m_staminaBarY = m_mcNPCFocus.GetMemberFlashFunction( "setStaminaBarY" );
  146. m_TextField = m_mcNPCFocus.GetMemberFlashFunction( "setTextField" );
  147. m_Icon = m_mcNPCFocus.GetMemberFlashFunction( "setIcon" );
  148. m_Mutation = m_mcNPCFocus.GetMemberFlashFunction( "setMutation" );
  149. m_yPos = m_mcNPCFocus.GetMemberFlashFunction( "setTextY" );
  150.  
  151. ingameConfigWrapper = theGame.GetInGameConfigWrapper();
  152.  
  153.  
  154. healthColorInt = StringToInt(ingameConfigWrapper.GetVarValue('EnemyHUD', 'HealthColor'));
  155. staminaBool = StringToInt(ingameConfigWrapper.GetVarValue('EnemyHUD', 'Stamina'));
  156. levelBool = ingameConfigWrapper.GetVarValue('EnemyHUD', 'Level'); //x
  157. dodgeBool = ingameConfigWrapper.GetVarValue('EnemyHUD', 'Dodge'); //x
  158. iconBool = ingameConfigWrapper.GetVarValue('EnemyHUD', 'Icon'); //x
  159. mutationBool = ingameConfigWrapper.GetVarValue('EnemyHUD', 'Mutation'); //x
  160. targetBool = ingameConfigWrapper.GetVarValue('EnemyHUD', 'Focus'); //x
  161. skullBool = ingameConfigWrapper.GetVarValue('EnemyHUD', 'Skull'); //x
  162. htmlSize = StringToInt(ingameConfigWrapper.GetVarValue('EnemyHUD', 'FontSize')); //x
  163. ypos = StringToInt(ingameConfigWrapper.GetVarValue('EnemyHUD', 'YPos')); //x
  164. //modEnemyHud ----------------------------------------------------------------------------
  165. }
  166.  
  167.  
  168. private function GetAttitudeOfTargetActor( target : CGameplayEntity ) : EAIAttitude
  169. {
  170. var targetActor : CActor;
  171.  
  172. targetActor = ( CActor )target;
  173. if ( targetActor )
  174. {
  175. return targetActor.GetAttitude( thePlayer );
  176. }
  177. return AIA_Neutral;
  178. }
  179.  
  180.  
  181. public function SetDodgeFeedback( target : CActor ) :void
  182. {
  183. //modEnemyHud ----------------------------------------------------------------------------
  184. if(dodgeBool){
  185. m_fxSetDodgeFeedback.InvokeSelfOneArg( FlashArgBool( !( !target ) ) );
  186. m_lastDodgeFeedbackTarget = target;
  187. }
  188. }
  189.  
  190.  
  191. public function DisplayMutationEight( value : bool ) :void
  192. {
  193. m_fxSetMutationEightVisibility.InvokeSelfOneArg( FlashArgBool ( value ) );
  194. }
  195.  
  196.  
  197. public function SetGeneralVisibility( showEnemyFocus : bool, showName : bool )
  198. {
  199. m_fxSetGeneralVisibility.InvokeSelfTwoArgs( FlashArgBool( showEnemyFocus ), FlashArgBool( showName ) );
  200. }
  201.  
  202.  
  203.  
  204. public function ShowDamageType(valueType : EFloatingValueType, value : float, optional stringParam : string)
  205. {
  206. var label:string;
  207. var color:float;
  208. var hud:CR4ScriptedHud;
  209.  
  210.  
  211. if(valueType != EFVT_InstantDeath && valueType != EFVT_Buff && value == 0.f)
  212. return;
  213.  
  214. hud = (CR4ScriptedHud)theGame.GetHud();
  215. if ( !hud.AreEnabledEnemyHitEffects() )
  216. {
  217. return;
  218. }
  219.  
  220. switch (valueType)
  221. {
  222. case EFVT_Critical:
  223. label = GetLocStringByKeyExt("attribute_name_critical_hit_damage");
  224. color = 0xFDFFC2;
  225. break;
  226. case EFVT_InstantDeath:
  227. label = GetLocStringByKeyExt("effect_instant_death");
  228. color = 0xFFC2C2;
  229. break;
  230. case EFVT_Block:
  231. label = GetLocStringByKeyExt("");
  232. color = 0xFC5B5B;
  233. break;
  234. case EFVT_DoT:
  235. label = GetLocStringByKeyExt("");
  236. color = 0xFF0000;
  237. break;
  238. case EFVT_Heal:
  239. label = GetLocStringByKeyExt("");
  240. color = 0x00FF00;
  241. break;
  242. case EFVT_Buff:
  243. label = GetLocStringByKeyExt(stringParam);
  244. color = 0xFFF0F0;
  245. break;
  246. default:
  247. label = GetLocStringByKeyExt("");
  248. color = 0xFFF0F0;
  249. break;
  250. }
  251. SetDamageText(label, CeilF(value), color);
  252. }
  253.  
  254.  
  255.  
  256. private function SetDamageText(label:string, value:int, color:float) : void
  257. {
  258. m_fxSetDamageText.InvokeSelfThreeArgs( FlashArgString(label), FlashArgNumber(value), FlashArgNumber(color) );
  259. }
  260. public function HideDamageText()
  261. {
  262. m_fxHideDamageText.InvokeSelf();
  263. }
  264.  
  265.  
  266.  
  267.  
  268. event OnTick( timeDelta : float )
  269. {
  270. var l_target : CNewNPC;
  271. var l_targetNonActor : CGameplayEntity;
  272. var l_isHuman : bool;
  273. var l_isDifferentTarget : bool;
  274. var l_wasAxiied : bool;
  275. var l_currentHealthPercentage : int;
  276. var l_currentStaminaPercentage : int;
  277. var l_currentTargetAttitude : EAIAttitude;
  278. var l_currentEnemyDifferenceLevel : string;
  279. var l_currentEnemyLevelString : string;
  280. var l_targetScreenPos : Vector;
  281. var l_dodgeFeedbackTarget : CActor;
  282. var l_isBoss : bool;
  283. var screenMargin : float = 0.025;
  284. var marginLeftTop : Vector;
  285. var marginRightBottom : Vector;
  286. var hud : CR4ScriptedHud;
  287. var extraOffset : int;
  288. var herbTag : name;
  289. var herbEntity : W3Herb;
  290. var definitionManager : CDefinitionsManagerAccessor;
  291. var useMutation8Icon : bool;
  292.  
  293.  
  294. l_targetNonActor = thePlayer.GetDisplayTarget();
  295. l_target = (CNewNPC)l_targetNonActor;
  296. l_dodgeFeedbackTarget = thePlayer.GetDodgeFeedbackTarget();
  297.  
  298. hud = (CR4ScriptedHud)theGame.GetHud();
  299.  
  300.  
  301.  
  302. //modEnemyHud ----------------------------------------------------------------------------
  303. healthColorInt = StringToInt(ingameConfigWrapper.GetVarValue('EnemyHUD', 'HealthColor'));
  304. staminaBool = StringToInt(ingameConfigWrapper.GetVarValue('EnemyHUD', 'Stamina'));
  305. levelBool = ingameConfigWrapper.GetVarValue('EnemyHUD', 'Level'); //x
  306. dodgeBool = ingameConfigWrapper.GetVarValue('EnemyHUD', 'Dodge'); //x
  307. iconBool = ingameConfigWrapper.GetVarValue('EnemyHUD', 'Icon'); //x
  308. mutationBool = ingameConfigWrapper.GetVarValue('EnemyHUD', 'Mutation'); //x
  309. targetBool = ingameConfigWrapper.GetVarValue('EnemyHUD', 'Focus'); //x
  310. skullBool = ingameConfigWrapper.GetVarValue('EnemyHUD', 'Skull'); //x
  311.  
  312. wasContainer = false;
  313. if(!l_target){
  314. if(l_targetNonActor){
  315. wasContainer = true;
  316. }
  317. }
  318.  
  319. if( theInput.GetActionValue('EnemyHudLevel') ){
  320. levelBool = true;
  321. skullBool = true;
  322. }
  323. //modEnemyHud ----------------------------------------------------------------------------
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332. if ( l_target )
  333. {
  334. if ( !l_target.IsUsingTooltip())
  335. {
  336. l_target = NULL;
  337. }
  338. }
  339. if ( l_target )
  340. {
  341.  
  342.  
  343. if ( l_target.HasTag( 'HideHealthBarModule' ) )
  344. {
  345. if ( l_target.HasTag( 'NotBoss' ) )
  346. {
  347. l_target = NULL;
  348. }
  349. else
  350. l_isBoss = true;
  351. }
  352. else
  353. {
  354.  
  355. if ( (CHeartMiniboss)l_target )
  356. {
  357. l_target = NULL;
  358. }
  359. }
  360. }
  361.  
  362. if ( l_target )
  363. {
  364.  
  365. l_isHuman = l_target.IsHuman();
  366. l_isDifferentTarget = ( l_target != m_lastTarget );
  367. l_wasAxiied = ( l_target.GetAttitudeGroup() == 'npc_charmed' );
  368.  
  369.  
  370.  
  371.  
  372. if(l_isDifferentTarget && l_target && !l_target.IsInCombat() && IsRequiredAttitudeBetween(thePlayer, l_target, true))
  373. {
  374. l_target.RecalcLevel();
  375. }
  376.  
  377.  
  378. if ( l_isDifferentTarget )
  379. {
  380. m_fxSetBossOrDead.InvokeSelfOneArg( FlashArgBool( l_isBoss || !l_target.IsAlive() ) );
  381.  
  382.  
  383. HideDamageText();
  384.  
  385.  
  386. m_fxSetStaminaVisibility.InvokeSelfOneArg( FlashArgBool( l_isHuman ) );
  387.  
  388. //modEnemyHud ----------------------------------------------------------------------------
  389. if(l_target.UsesEssence())
  390. {
  391. if(healthColorInt == 0 || healthColorInt == 3 )
  392. m_fxSetEssenceBarVisibility.InvokeSelfOneArg( FlashArgBool( true ) );
  393. else
  394. m_fxSetEssenceBarVisibility.InvokeSelfOneArg( FlashArgBool( false ) );
  395. }
  396. else
  397. {
  398. if(healthColorInt == 0 || healthColorInt == 2 )
  399. m_fxSetEssenceBarVisibility.InvokeSelfOneArg( FlashArgBool( false ) );
  400. else
  401. m_fxSetEssenceBarVisibility.InvokeSelfOneArg( FlashArgBool( true ) );
  402. }
  403.  
  404. //m_fxSetEssenceBarVisibility.InvokeSelfOneArg( FlashArgBool( l_target.UsesEssence()) );
  405. //modEnemyHud ----------------------------------------------------------------------------
  406.  
  407.  
  408. UpdateQuestIcon( l_target );
  409. SetDodgeFeedback( NULL );
  410.  
  411. ShowElement( true );
  412.  
  413. m_lastTarget = l_target;
  414. }
  415.  
  416.  
  417.  
  418. l_currentTargetAttitude = l_target.GetAttitude( thePlayer );
  419. if ( l_currentTargetAttitude != AIA_Hostile )
  420. {
  421.  
  422. if ( l_target.IsVIP() )
  423. {
  424. l_currentTargetAttitude = 4;
  425. }
  426. }
  427.  
  428. //modEnemyHud ----------------------------------------------------------------------------
  429. currentAttitude = l_currentTargetAttitude;
  430. lastTarget = l_target;
  431. //modEnemyHud ----------------------------------------------------------------------------
  432.  
  433. if ( l_isDifferentTarget || m_lastTargetAttitude != l_currentTargetAttitude || m_wasAxiied != l_wasAxiied )
  434. {
  435. m_lastTargetAttitude = l_currentTargetAttitude;
  436. m_wasAxiied = l_wasAxiied;
  437. if( m_wasAxiied )
  438. {
  439. m_fxSetAttitude.InvokeSelfOneArg( FlashArgInt( 3 ) );
  440. }
  441. else
  442. {
  443. m_fxSetAttitude.InvokeSelfOneArg( FlashArgInt( l_currentTargetAttitude ) );
  444. }
  445. }
  446.  
  447.  
  448. if ( m_lastDodgeFeedbackTarget != l_dodgeFeedbackTarget )
  449. {
  450. if ( l_currentTargetAttitude == AIA_Hostile )
  451. {
  452. SetDodgeFeedback( l_dodgeFeedbackTarget );
  453. }
  454. else
  455. {
  456. SetDodgeFeedback( NULL );
  457. }
  458. m_lastDodgeFeedbackTarget = l_dodgeFeedbackTarget;
  459. }
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. m_nameInterval -= timeDelta;
  467. if ( l_isDifferentTarget || m_nameInterval < 0 )
  468. {
  469. m_nameInterval = 0.25;
  470.  
  471. UpdateName( l_target.GetDisplayName() );
  472. }
  473.  
  474.  
  475. l_currentHealthPercentage = CeilF( 100 * l_target.GetHealthPercents() );
  476. if ( m_lastHealthPercentage != l_currentHealthPercentage )
  477. {
  478. m_lastHealthPercentage = l_currentHealthPercentage;
  479. m_fxSetEnemyHealth.InvokeSelfOneArg( FlashArgInt( l_currentHealthPercentage ) );
  480.  
  481. }
  482.  
  483.  
  484. l_currentStaminaPercentage = CeilF( 100 * l_target.GetStaminaPercents() );
  485. if ( m_lastStaminaPercentage != l_currentStaminaPercentage )
  486. {
  487. m_lastStaminaPercentage = l_currentStaminaPercentage;
  488. m_fxSetEnemyStamina.InvokeSelfOneArg( FlashArgInt( l_currentStaminaPercentage ) );
  489. }
  490.  
  491.  
  492. l_currentEnemyDifferenceLevel = l_target.GetExperienceDifferenceLevelName( l_currentEnemyLevelString );
  493. if ( l_isDifferentTarget ||
  494. m_lastEnemyDifferenceLevel != l_currentEnemyDifferenceLevel ||
  495. m_lastEnemyLevelString != l_currentEnemyLevelString )
  496. {
  497. m_lastEnemyDifferenceLevel = l_currentEnemyDifferenceLevel;
  498. m_lastEnemyLevelString = l_currentEnemyLevelString;
  499.  
  500. //modEnemyHud -----------------------------------------------------------------------
  501. if(levelBool){
  502. if(skullBool){
  503. m_fxSetEnemyLevel.InvokeSelfTwoArgs( FlashArgString( l_currentEnemyDifferenceLevel ), FlashArgString( l_currentEnemyLevelString ) );
  504. }else{
  505. if(l_currentEnemyDifferenceLevel == "deadlyLevel")
  506. {
  507. m_fxSetEnemyLevel.InvokeSelfTwoArgs( FlashArgString( "none" ), FlashArgString( "" ) );
  508. }
  509. else if(l_currentEnemyDifferenceLevel == "highLevel")
  510. {
  511. m_fxSetEnemyLevel.InvokeSelfTwoArgs( FlashArgString( "normalLevel" ), FlashArgString( l_currentEnemyLevelString ) );
  512. }
  513. else
  514. {
  515. m_fxSetEnemyLevel.InvokeSelfTwoArgs( FlashArgString( l_currentEnemyDifferenceLevel ), FlashArgString( l_currentEnemyLevelString ) );
  516. }
  517. }
  518. }else if(skullBool){
  519. if(l_currentEnemyDifferenceLevel == "deadlyLevel")
  520. {
  521. m_fxSetEnemyLevel.InvokeSelfTwoArgs( FlashArgString( l_currentEnemyDifferenceLevel ), FlashArgString( "" ) );
  522. }
  523. else if(l_currentEnemyDifferenceLevel == "highLevel")
  524. {
  525. m_fxSetEnemyLevel.InvokeSelfTwoArgs( FlashArgString( l_currentEnemyDifferenceLevel ), FlashArgString( "" ) );
  526. }
  527. else
  528. {
  529. m_fxSetEnemyLevel.InvokeSelfTwoArgs( FlashArgString( "none" ), FlashArgString( "" ) );
  530. }
  531. }else{
  532. m_fxSetEnemyLevel.InvokeSelfTwoArgs( FlashArgString( "none" ), FlashArgString( "" ) );
  533. }
  534. //modEnemyHud -----------------------------------------------------------------------
  535. }
  536.  
  537.  
  538. useMutation8Icon = GetWitcherPlayer().IsMutationActive( EPMT_Mutation8 ) && !l_target.IsImmuneToMutation8Finisher();
  539. if ( m_lastUseMutation8Icon != useMutation8Icon )
  540. {
  541. m_lastUseMutation8Icon = useMutation8Icon;
  542. DisplayMutationEight( useMutation8Icon );
  543. }
  544.  
  545.  
  546. if ( GetBaseScreenPosition( l_targetScreenPos, l_target ) )
  547. {
  548. l_targetScreenPos.Y -= 45;
  549.  
  550. marginLeftTop = hud.GetScaleformPoint( screenMargin, screenMargin );
  551. marginRightBottom = hud.GetScaleformPoint( 1 - screenMargin, 1 - screenMargin );
  552.  
  553. if ( l_targetScreenPos.X < marginLeftTop.X )
  554. {
  555. l_targetScreenPos.X = marginLeftTop.X;
  556. }
  557. else if ( l_targetScreenPos.X > marginRightBottom.X )
  558. {
  559. l_targetScreenPos.X = marginRightBottom.X;
  560. }
  561.  
  562. if ( l_targetScreenPos.Y < marginLeftTop.Y )
  563. {
  564. l_targetScreenPos.Y = marginLeftTop.Y;
  565. }
  566. else if ( l_targetScreenPos.Y > marginRightBottom.Y )
  567. {
  568. l_targetScreenPos.Y = marginRightBottom.Y;
  569. }
  570. //HPAS
  571. if ( l_target.GetAttitude( thePlayer ) == AIA_Hostile && ! l_isBoss && isEnemyOn() && isModOn() )
  572. {
  573. l_targetScreenPos.X = mHPAS_Pos.Enemy('X');
  574. l_targetScreenPos.Y = mHPAS_Pos.Enemy('Y');
  575. }
  576. //HPAS
  577. m_mcNPCFocus.SetVisible( true );
  578.  
  579. //modEnemyHud ----------------------------------------------------------------------------
  580. if(l_currentTargetAttitude == AIA_Hostile || l_target.GetAttitudeGroup() == 'npc_charmed'){
  581. m_mcNPCFocus.SetPosition( l_targetScreenPos.X, l_targetScreenPos.Y );
  582. }else{
  583. m_mcNPCFocus.SetPosition( l_targetScreenPos.X, l_targetScreenPos.Y + 33 );
  584. }
  585. //modEnemyHud -----------------------------------------------------------------------
  586. }
  587. else
  588. {
  589. m_mcNPCFocus.SetVisible( false );
  590. }
  591. }
  592. else if ( l_targetNonActor )
  593. {
  594.  
  595. l_isDifferentTarget = ( l_targetNonActor != m_lastTarget );
  596.  
  597.  
  598. if ( l_isDifferentTarget )
  599. {
  600.  
  601. m_fxSetStaminaVisibility.InvokeSelfOneArg( FlashArgBool( false ) );
  602. m_fxSetEssenceBarVisibility.InvokeSelfOneArg( FlashArgBool( false ) );
  603. UpdateQuestIcon( (CNewNPC)l_targetNonActor );
  604. SetDodgeFeedback( NULL );
  605.  
  606. ShowElement( true );
  607.  
  608. m_fxSetAttitude.InvokeSelfOneArg( FlashArgInt( 0 ) );
  609. m_fxSetEnemyLevel.InvokeSelfTwoArgs( FlashArgString( "none" ), FlashArgString( "" ) );
  610.  
  611.  
  612. m_lastTarget = l_targetNonActor;
  613. m_lastTargetAttitude = GetAttitudeOfTargetActor( m_lastTarget );
  614. m_lastHealthPercentage = -1;
  615. m_lastStaminaPercentage = -1;
  616. m_lastEnemyDifferenceLevel = "none";
  617. m_lastEnemyLevelString = "";
  618. }
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626. herbEntity = (W3Herb)l_targetNonActor;
  627. if ( herbEntity )
  628. {
  629. extraOffset = 140;
  630. m_nameInterval -= timeDelta;
  631. if ( l_isDifferentTarget || m_nameInterval < 0 )
  632. {
  633. m_nameInterval = 0.25;
  634.  
  635. herbEntity.GetStaticMapPinTag( herbTag );
  636. if ( herbTag )
  637. {
  638. definitionManager = theGame.GetDefinitionsManager();
  639. if ( definitionManager )
  640. {
  641. UpdateName( GetLocStringByKeyExt( definitionManager.GetItemLocalisationKeyName( herbTag ) ) );
  642. }
  643. }
  644. else
  645. {
  646. UpdateName( "" );
  647. }
  648. }
  649. }
  650. else
  651. {
  652. if ( l_isDifferentTarget )
  653. {
  654. UpdateName( "" );
  655. }
  656. }
  657.  
  658.  
  659. useMutation8Icon = false;
  660. if ( m_lastUseMutation8Icon != useMutation8Icon )
  661. {
  662. DisplayMutationEight( useMutation8Icon );
  663. m_lastUseMutation8Icon = useMutation8Icon;
  664. }
  665.  
  666.  
  667. if ( GetBaseScreenPosition( l_targetScreenPos, l_targetNonActor ) )
  668. {
  669. l_targetScreenPos.Y -= 10;
  670. l_targetScreenPos.Y -= extraOffset;
  671.  
  672. marginLeftTop = hud.GetScaleformPoint( screenMargin, screenMargin );
  673. marginRightBottom = hud.GetScaleformPoint( 1 - screenMargin, 1 - screenMargin );
  674.  
  675. if ( l_targetScreenPos.X < marginLeftTop.X )
  676. {
  677. l_targetScreenPos.X = marginLeftTop.X;
  678. }
  679. else if ( l_targetScreenPos.X > marginRightBottom.X )
  680. {
  681. l_targetScreenPos.X = marginRightBottom.X;
  682. }
  683.  
  684. if ( l_targetScreenPos.Y < marginLeftTop.Y )
  685. {
  686. l_targetScreenPos.Y = marginLeftTop.Y;
  687. }
  688. else if ( l_targetScreenPos.Y > marginRightBottom.Y )
  689. {
  690. l_targetScreenPos.Y = marginRightBottom.Y;
  691. }
  692.  
  693. m_mcNPCFocus.SetVisible( true );
  694. m_mcNPCFocus.SetPosition( l_targetScreenPos.X - 10, l_targetScreenPos.Y + 53 );
  695. }
  696. else
  697. {
  698. m_mcNPCFocus.SetVisible( false );
  699. }
  700. }
  701. else if ( m_lastTarget )
  702. {
  703. m_lastTarget = NULL;
  704. m_mcNPCFocus.SetVisible( false );
  705. SetDodgeFeedback( NULL );
  706. ShowElement( false );
  707. }
  708. else
  709. {
  710.  
  711. if ( m_mcNPCFocus.GetVisible() )
  712. {
  713. m_mcNPCFocus.SetVisible( false );
  714. ShowElement( false );
  715. }
  716. }
  717.  
  718.  
  719.  
  720. //modEnemyHud ----------------------------------------------------------------------------
  721. if(staminaBool == 1 || (staminaBool == 2 && l_isHuman) )
  722. {
  723. m_staminaBarY.InvokeSelfOneArg( FlashArgInt( 43 ) );
  724. }
  725. else
  726. {
  727. m_staminaBarY.InvokeSelfOneArg( FlashArgInt( -9000 ) );
  728. }
  729. //modEnemyHud ----------------------------------------------------------------------------
  730. }
  731.  
  732. public function UpdateName( enemyName : string )
  733. //modEnemyHud ----------------------------------------------------------------------------
  734. var htmlColor : string;
  735. var ingameConfigWrappe : CInGameConfigWrapper;
  736. var humanFriend, humanHostile, monsterFriend, monsterHostile, axiiHuman, axiiMonster, animal, herb : bool;
  737. var target : CGameplayEntity;
  738. var targetActor : CActor;
  739. //modEnemyHud ----------------------------------------------------------------------------
  740.  
  741.  
  742. if ( m_lastEnemyName != enemyName )
  743. {
  744. m_lastEnemyName = enemyName;
  745.  
  746.  
  747. //modEnemyHud ----------------------------------------------------------------------------
  748. ingameConfigWrappe = theGame.GetInGameConfigWrapper();
  749. htmlSize = StringToInt(ingameConfigWrappe.GetVarValue('EnemyHUD', 'FontSize')); //x
  750. ypos = StringToInt(ingameConfigWrappe.GetVarValue('EnemyHUD', 'YPos')); //x
  751.  
  752.  
  753. humanFriend = ingameConfigWrappe.GetVarValue('EnemyHUD', 'NameFriendlyHuman');
  754. humanHostile = ingameConfigWrappe.GetVarValue('EnemyHUD', 'NameHostileHuman');
  755. monsterFriend = ingameConfigWrappe.GetVarValue('EnemyHUD', 'NameFriendlyMonster');
  756. monsterHostile = ingameConfigWrappe.GetVarValue('EnemyHUD', 'NameHostileMonster');
  757. axiiHuman = ingameConfigWrappe.GetVarValue('EnemyHUD', 'NameAxiiHuman');
  758. axiiMonster = ingameConfigWrappe.GetVarValue('EnemyHUD', 'NameAxiiMonster');
  759. animal = ingameConfigWrappe.GetVarValue('EnemyHUD', 'NameAnimal');
  760. herb = ingameConfigWrappe.GetVarValue('EnemyHUD', 'NameHerbs');
  761.  
  762.  
  763. target = thePlayer.GetDisplayTarget();
  764. targetActor = ((CActor)target);
  765.  
  766. if(targetActor)
  767. {
  768. if(targetActor.IsAnimal() && !animal)
  769. {
  770. m_lastEnemyName = "";
  771. }
  772. else if(targetActor.IsHuman())
  773. {
  774. if( targetActor.GetAttitudeGroup() == 'npc_charmed' ) // human axii
  775. {
  776. if(!axiiHuman)
  777. {
  778. m_lastEnemyName = "";
  779. }
  780. else if(targetActor.IsHuman())
  781. {
  782. if( targetActor.GetAttitudeGroup() == 'npc_charmed' ) // human axii
  783. {
  784. if(!axiiHuman)
  785. {
  786. m_lastEnemyName = "";
  787. }
  788. }
  789. else if(currentAttitude == 2) // human enemy
  790. {
  791. if(!humanHostile)
  792. {
  793. m_lastEnemyName = "";
  794. }
  795. }
  796. else // human friendly
  797. {
  798. if(!humanFriend)
  799. {
  800. m_lastEnemyName = "";
  801. }
  802. }
  803. }
  804. else if(targetActor.IsMonster())
  805. {
  806. if( targetActor.GetAttitudeGroup() == 'npc_charmed' ) // human axii
  807. {
  808. if(!axiiMonster)
  809. {
  810. m_lastEnemyName = "";
  811. }
  812. }
  813. else if(currentAttitude == 2) // human enemy
  814. {
  815. if(!monsterHostile)
  816. {
  817. m_lastEnemyName = "";
  818. }
  819. }
  820. else // human friendly
  821. {
  822. if(!monsterFriend)
  823. {
  824. m_lastEnemyName = "";
  825. }
  826. }
  827. }
  828. }
  829. else if(((W3Herb)target))
  830. {
  831. if(!herb)
  832. {
  833. m_lastEnemyName = "";
  834. }
  835. }
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842. htmlColor = GetColors();
  843. m_lastEnemyName = "<FONT SIZE='" + htmlSize + "' COLOR='" + htmlColor +"'>" + m_lastEnemyName + "</FONT>";
  844.  
  845.  
  846.  
  847. m_yPos.InvokeSelfOneArg( FlashArgInt( ypos ) );
  848. m_TextField.InvokeSelfOneArg( FlashArgString( m_lastEnemyName ) );
  849. //modEnemyHud ----------------------------------------------------------------------------
  850. }
  851. }
  852.  
  853. //modEnemyHud ----------------------------------------------------------------------------
  854. function GetColors() : string
  855. {
  856. var htmlColor, s : string;
  857. var red, green, blue : int;
  858. var ingameConfigWrapp : CInGameConfigWrapper;
  859.  
  860. ingameConfigWrapp = theGame.GetInGameConfigWrapper();
  861.  
  862.  
  863. if(wasContainer){
  864. red = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDContainer', 'Red' ));
  865. green = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDContainer', 'Green' ));
  866. blue = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDContainer', 'Blue' ));
  867. }
  868. else{
  869. switch(currentAttitude){
  870. case 0:
  871. red = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDNeutral', 'Red' ));
  872. green = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDNeutral', 'Green' ));
  873. blue = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDNeutral', 'Blue' ));
  874. break;
  875. case 1:
  876. red = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDFriendly', 'Red' ));
  877. green = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDFriendly', 'Green' ));
  878. blue = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDFriendly', 'Blue' ));
  879. break;
  880. case 2:
  881. if(lastTarget.IsHuman())
  882. {
  883. red = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDHostile', 'Red' ));
  884. green = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDHostile', 'Green' ));
  885. blue = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDHostile', 'Blue' ));
  886. }
  887. else if(lastTarget.UsesEssence())
  888. {
  889. red = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDHostile', 'RedSilv' ));
  890. green = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDHostile', 'GreenSilv' ));
  891. blue = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDHostile', 'BlueSilv' ));
  892. }
  893. else
  894. {
  895. red = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDHostile', 'RedSt' ));
  896. green = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDHostile', 'GreenSt' ));
  897. blue = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDHostile', 'BlueSt' ));
  898. }
  899. break;
  900. case 3:
  901. red = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDAxii', 'Red' ));
  902. green = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDAxii', 'Green' ));
  903. blue = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDAxii', 'Blue' ));
  904. break;
  905. case 4:
  906. red = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDVIP', 'Red' ));
  907. green = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDVIP', 'Green' ));
  908. blue = StringToInt(ingameConfigWrapp.GetVarValue( 'EnemyHUDVIP', 'Blue' ));
  909. break;
  910. }
  911. }
  912.  
  913.  
  914. htmlColor = "#";
  915.  
  916. s = ToHex(red);
  917. htmlColor = htmlColor + s;
  918.  
  919. s = ToHex(green);
  920. htmlColor = htmlColor + s;
  921.  
  922. s = ToHex(blue);
  923. htmlColor = htmlColor + s;
  924.  
  925. return htmlColor;
  926. }
  927.  
  928. private function ToHex( n : int) : string
  929. {
  930. var r, x : int;
  931. var str : string;
  932.  
  933. if (n == 0){
  934. str += "00";
  935. }else{
  936. r = FloorF(n / 16);
  937.  
  938. switch (r)
  939. {
  940. case 10:
  941. str += "a";
  942. break;
  943. case 11:
  944. str += "b";
  945. break;
  946. case 12:
  947. str += "c";
  948. break;
  949. case 13:
  950. str += "d";
  951. break;
  952. case 14:
  953. str += "e";
  954. break;
  955. case 15:
  956. str += "f";
  957. break;
  958. default:
  959. str += IntToString(r);
  960. break;
  961. }
  962.  
  963. x = n;
  964. n = FloorF(n / 16);
  965. n = x-(n*16);
  966.  
  967. switch (n)
  968. {
  969. case 10:
  970. str += "a";
  971. break;
  972. case 11:
  973. str += "b";
  974. break;
  975. case 12:
  976. str += "c";
  977. break;
  978. case 13:
  979. str += "d";
  980. break;
  981. case 14:
  982. str += "e";
  983. break;
  984. case 15:
  985. str += "f";
  986. break;
  987. default:
  988. str += IntToString(n);
  989. break;
  990. }
  991. }
  992.  
  993. return str;
  994. }
  995. //modEnemyHud ----------------------------------------------------------------------------
  996.  
  997.  
  998.  
  999.  
  1000. public function SetShowHardLock( set : bool )
  1001. {
  1002. //modEnemyHud ----------------------------------------------------------------------------
  1003. if(targetBool){
  1004. m_fxSetShowHardLock.InvokeSelfOneArg( FlashArgBool( set ) );
  1005. }
  1006.  
  1007. }
  1008.  
  1009. protected function UpdateScale( scale : float, flashModule : CScriptedFlashSprite ) : bool
  1010. {
  1011. return false;
  1012. }
  1013.  
  1014. private function UpdateQuestIcon( target : CNewNPC )
  1015. {
  1016. var mapPinInstances : array< SCommonMapPinInstance >;
  1017. var commonMapManager : CCommonMapManager;
  1018. var currentPin : SCommonMapPinInstance;
  1019. var targetTags : array< name >;
  1020. var i : int;
  1021. var questIcon : string;
  1022. var mapPinType : name;
  1023.  
  1024. questIcon = "none";
  1025.  
  1026. if ( target )
  1027. {
  1028. targetTags = target.GetTags();
  1029.  
  1030. if (targetTags.Size() > 0)
  1031. {
  1032. commonMapManager = theGame.GetCommonMapManager();
  1033.  
  1034. mapPinType = commonMapManager.GetMapPinTypeByTag( targetTags[0] );
  1035. switch ( mapPinType )
  1036. {
  1037. case 'QuestReturn':
  1038. questIcon = "QuestReturn";
  1039. break;
  1040. case 'QuestGiverStory':
  1041. questIcon = "QuestGiverStory";
  1042. break;
  1043. case 'QuestGiverChapter':
  1044. questIcon = "QuestGiverChapter";
  1045. break;
  1046. case 'QuestGiverSide':
  1047. case 'QuestAvailable':
  1048. case 'QuestAvailableHoS':
  1049. case 'QuestAvailableBaW':
  1050. questIcon = "QuestGiverSide";
  1051. break;
  1052. case 'MonsterQuest':
  1053. questIcon = "MonsterQuest";
  1054. break;
  1055. case 'TreasureQuest':
  1056. questIcon = "TreasureQuest";
  1057. break;
  1058. }
  1059. }
  1060. }
  1061.  
  1062.  
  1063. //modEnemyHud ----------------------------------------------------------------------------
  1064. if(iconBool){
  1065. m_Icon.InvokeSelfOneArg( FlashArgBool( true ) );
  1066. }else{
  1067. m_Icon.InvokeSelfOneArg( FlashArgBool( false ) );
  1068. }
  1069.  
  1070. m_fxSetNPCQuestIcon.InvokeSelfOneArg( FlashArgString( questIcon ) );
  1071. }
  1072. }
  1073.  
  1074. exec function dodgeFeedback()
  1075. {
  1076. var npc : CNewNPC;
  1077.  
  1078. npc = (CNewNPC)thePlayer.GetDisplayTarget();
  1079. if ( npc )
  1080. {
  1081. thePlayer.SetDodgeFeedbackTarget( npc );
  1082. }
  1083. }
  1084.  
  1085. exec function hardlock( set : bool )
  1086. {
  1087. var hud : CR4ScriptedHud;
  1088. var module : CR4HudModuleEnemyFocus;
  1089.  
  1090. hud = (CR4ScriptedHud)theGame.GetHud();
  1091. module = (CR4HudModuleEnemyFocus)hud.GetHudModule("EnemyFocusModule");
  1092. module.SetShowHardLock( set );
  1093. }
  1094.  
  1095.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement