Guest User

Untitled

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