Advertisement
Guest User

Untitled

a guest
Jan 13th, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.73 KB | None | 0 0
  1. EmeraldAiBehaviour.cs
  2.  
  3. Lines 15-55 (before Start()):
  4. public bool ManualControl = false;
  5.         [HideInInspector]
  6.         public EmeraldAISystem EmeraldComponent;
  7.         float BlockTimer;
  8.         bool BackupDelayActive;
  9.         float BackupDistance;
  10.         bool SearchDelayActive = false;
  11.         int StartingDetectionRadius;
  12.         private bool SupportAbilityInvoked = false;
  13.         private bool SummonAbilityInvoked = false;
  14.         private bool OffensiceAbilityInvoked = false;
  15.         private int AbilityInvokedIndex;
  16.  
  17.         public void InvokeOffensiveAbility(AbilityType abilityType, int AbilityIndex)
  18.         {
  19.             switch (abilityType)
  20.             {
  21.                 case AbilityType.Support:
  22.                     SupportAbilityInvoked = true;
  23.                     break;
  24.                 case AbilityType.Summon:
  25.                     SummonAbilityInvoked = true;
  26.                     break;
  27.                 case AbilityType.Offensive:
  28.                     OffensiceAbilityInvoked = true;
  29.                     break;
  30.                 default:
  31.                     break;
  32.             }
  33.            
  34.             AbilityInvokedIndex = AbilityIndex;
  35.         }
  36.  
  37.         public enum AbilityType
  38.         {
  39.             Support,
  40.             Summon,
  41.             Offensive,
  42.         }
  43.  
  44. Lines 788 and on:
  45.  
  46. if (EmeraldComponent.EnableBothWeaponTypes == EmeraldAISystem.YesOrNo.No && EmeraldComponent.WeaponTypeRef == EmeraldAISystem.WeaponType.Ranged ||
  47.                                 EmeraldComponent.EnableBothWeaponTypes == EmeraldAISystem.YesOrNo.Yes && EmeraldComponent.WeaponTypeRef == EmeraldAISystem.WeaponType.Ranged)
  48.                             {
  49.                                 float AbilityOddsRoll = Random.Range(0f, 1f);
  50.                                 AbilityOddsRoll = AbilityOddsRoll * 100;
  51.  
  52.                                 if (ManualControl
  53.                                     && SupportAbilityInvoked
  54.                                     || !ManualControl
  55.                                     &&!EmeraldComponent.m_AbilityPicked
  56.                                     && EmeraldComponent.SupportAbilities.Count > 0
  57.                                     && !EmeraldComponent.HealingCooldownActive
  58.                                     && ((float)EmeraldComponent.CurrentHealth / EmeraldComponent.StartingHealth*100) < EmeraldComponent.HealthPercentageToHeal)
  59.                                 {
  60.                                     EmeraldAICombatManager.GenerateSupportAbility(EmeraldComponent);
  61.                                     EmeraldComponent.AIAnimator.SetInteger("Attack Index", EmeraldComponent.CurrentAnimationIndex + 1);
  62.                                     EmeraldComponent.AIAnimator.SetTrigger("Attack");
  63.                                     EmeraldComponent.m_AbilityPicked = true;
  64.                                     SupportAbilityInvoked = false;
  65.                                 }
  66.                                 else if (ManualControl
  67.                                          && SummonAbilityInvoked
  68.                                          || !ManualControl
  69.                                          && !EmeraldComponent.m_AbilityPicked
  70.                                          && EmeraldComponent.TotalSummonedAI < EmeraldComponent.MaxAllowedSummonedAI
  71.                                          && EmeraldComponent.SummoningAbilities.Count > 0)
  72.                                 {
  73.                                     EmeraldAICombatManager.GenerateSummoningAbility(EmeraldComponent);
  74.                                     EmeraldComponent.AIAnimator.SetInteger("Attack Index", EmeraldComponent.CurrentAnimationIndex + 1);
  75.                                     EmeraldComponent.AIAnimator.SetTrigger("Attack");
  76.                                     EmeraldComponent.m_AbilityPicked = true;
  77.                                     SummonAbilityInvoked = false;
  78.                                 }
  79.                                 else if (!EmeraldComponent.m_AbilityPicked && EmeraldComponent.OffensiveAbilities.Count > 0)                            
  80.                                 {                                    
  81.                                     if (!EmeraldComponent.EmeraldDetectionComponent.m_LookAtInProgress && EmeraldComponent.UseHeadLookRef == EmeraldAISystem.YesOrNo.Yes ||
  82.                                         EmeraldComponent.UseHeadLookRef == EmeraldAISystem.YesOrNo.No)
  83.                                     {
  84.                                         if (ManualControl)
  85.                                         {
  86.                                             if (OffensiceAbilityInvoked)
  87.                                             {
  88.                                                 EmeraldAICombatManager.GenerateOffensiveAbility(EmeraldComponent, AbilityInvokedIndex);
  89.                                             }
  90.                                             else
  91.                                             {
  92.                                                 EmeraldAICombatManager.GenerateOffensiveAbility(EmeraldComponent, 0);
  93.                                             }
  94.                                         }
  95.                                         else
  96.                                         {
  97.                                             EmeraldAICombatManager.GenerateOffensiveAbility(EmeraldComponent);
  98.                                         }
  99.                                         EmeraldComponent.m_InitialTargetPosition = EmeraldComponent.CurrentTarget.position;
  100.                                         EmeraldComponent.AIAnimator.SetInteger("Attack Index", EmeraldComponent.CurrentAnimationIndex+1);
  101.                                         EmeraldComponent.AIAnimator.SetTrigger("Attack");
  102.                                         EmeraldComponent.m_AbilityPicked = true;
  103.                                     }
  104.                                     else
  105.                                     {
  106.                                         //If our AI is in the process of rotating with the look at feature, return.
  107.                                         return;
  108.                                     }
  109.                                 }
  110.                             }
  111.  
  112. EmeraldAiCombatManager.cs:
  113. somewhere inside add method:
  114.     public static void GenerateOffensiveAbility(EmeraldAISystem EmeraldComponent, int AbilityIndex)
  115.     {
  116.         if (EmeraldComponent.OffensiveAbilities.Count > 0
  117.             && AbilityIndex <= EmeraldComponent.OffensiveAbilities.Count)
  118.         {
  119.             EmeraldComponent.m_EmeraldAIAbility = EmeraldComponent.OffensiveAbilities[AbilityIndex].OffensiveAbility;
  120.             EmeraldComponent.CurrentAnimationIndex = EmeraldComponent.OffensiveAbilities[AbilityIndex].AbilityAnimaition;
  121.         }
  122.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement