Facebook
From BIG OZI, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 73
  1. using Microsoft.Xna.Framework;
  2. using Terraria;
  3. using Terraria.ID;
  4.  
  5. namespace JoJoStands.Projectiles.PlayerStands.SilverChariot
  6. {
  7.     public class SilverChariotStandT2 : StandClass
  8.     {
  9.         public override void SetStaticDefaults()
  10.         {
  11.             Main.projPet[projectile.type] = true;
  12.             Main.projFrames[projectile.type] = 10;
  13.         }
  14.         public bool parryFrames = false;
  15.         public override float maxDistance => 98f;
  16.         public override int punchDamage => 46;
  17.         public override int punchTime => 7;
  18.         public override int halfStandHeight => 37;
  19.         public override float fistWhoAmI => 10f;
  20.         public override int standType => 1;
  21.         public override int standOffset => +30;
  22.  
  23.         public int updateTimer = 0;
  24.  
  25.         public override void AI()
  26.         {
  27.             SelectAnimation();
  28.             UpdateStandInfo();
  29.             updateTimer++;
  30.             if (shootCount > 0)
  31.             {
  32.                 shootCount--;
  33.             }
  34.             Player player = Main.player[projectile.owner];
  35.             MyPlayer modPlayer = player.GetModPlayer<MyPlayer>();
  36.             projectile.frameCounter++;
  37.             if (modPlayer.StandOut)
  38.             {
  39.                 projectile.timeLeft = 2;
  40.             }
  41.             if (updateTimer >= 90)      //an automatic netUpdate so that if something goes wrong it'll at least fix in about a second
  42.             {
  43.                 updateTimer = 0;
  44.                 projectile.netUpdate = true;
  45.             }
  46.             if (!modPlayer.StandAutoMode)
  47.             {
  48.                 if (Main.mouseLeft && projectile.owner == Main.myPlayer)
  49.                 {
  50.                     Punch();
  51.                 }
  52.                 else
  53.                 {
  54.                     if (player.whoAmI == Main.myPlayer)
  55.                         attackFrames = false;
  56.                 }
  57.                 if (Main.mouseRight && !player.HasBuff(mod.BuffType("AbilityCooldown")) && projectile.owner == Main.myPlayer)
  58.                 {
  59.                     secondaryAbilityFrames = true;
  60.                     Main.mouseLeft = false;
  61.                     projectile.netUpdate = true;
  62.                     GoInFront();
  63.                     Rectangle parryRectangle = new Rectangle((int)projectile.Center.X + (4 * projectile.direction), (int)projectile.Center.Y, 16, 54);
  64.                     for (int p = 0; p < Main.maxProjectiles; p++)
  65.                     {
  66.                         Projectile otherProj = Main.projectile[p];
  67.                         if (otherProj.active)
  68.                         {
  69.                             if (parryRectangle.Intersects(otherProj.Hitbox) && otherProj.type != projectile.type && !otherProj.friendly)
  70.                             {
  71.                                 parryFrames = true;
  72.                                 otherProj.owner = projectile.owner;
  73.                                 otherProj.velocity *= -1;
  74.                                 otherProj.hostile = false;
  75.                                 otherProj.friendly = true;
  76.                                 player.AddBuff(mod.BuffType("AbilityCooldown"), 60 * 10);
  77.                             }
  78.                         }
  79.                     }
  80.                     for (int n = 0; n < Main.maxNPCs; n++)
  81.                     {
  82.                         NPC npc = Main.npc[n];
  83.                         if (npc.active)
  84.                         {
  85.                             if (!npc.townNPC && !npc.friendly && !npc.immortal && !npc.hide && parryRectangle.Intersects(npc.Hitbox))
  86.                             {
  87.                                 npc.StrikeNPC(npc.damage * 2, 6f, player.direction);
  88.                                 secondaryAbilityFrames = false;
  89.                                 parryFrames = true;
  90.                                 player.AddBuff(mod.BuffType("AbilityCooldown"), 60 * 5);
  91.                             }
  92.                         }
  93.                     }
  94.                 }
  95.                 if (!Main.mouseRight)
  96.                 {
  97.                     secondaryAbilityFrames = false;
  98.                 }
  99.                 if (!attackFrames && !Main.mouseRight && !parryFrames)
  100.                 {
  101.                     StayBehind();
  102.                 }
  103.             }
  104.             if (modPlayer.StandAutoMode)
  105.             {
  106.                 BasicPunchAI();
  107.             }
  108.         }
  109.  
  110.         public override void SelectAnimation()
  111.         {
  112.             if (attackFrames)
  113.             {
  114.                 normalFrames = false;
  115.                 parryFrames = false;
  116.                 PlayAnimation("Attack");
  117.             }
  118.             if (normalFrames)
  119.             {
  120.                 attackFrames = false;
  121.                 parryFrames = false;
  122.                 PlayAnimation("Idle");
  123.             }
  124.             if (secondaryAbilityFrames)
  125.             {
  126.                 normalFrames = false;
  127.                 attackFrames = false;
  128.                 parryFrames = false;
  129.                 PlayAnimation("Secondary");
  130.             }
  131.             if (parryFrames)
  132.             {
  133.                 normalFrames = false;
  134.                 attackFrames = false;
  135.                 PlayAnimation("Parry");
  136.             }
  137.             if (Main.player[projectile.owner].GetModPlayer<MyPlayer>().poseMode)
  138.             {
  139.                 normalFrames = false;
  140.                 attackFrames = false;
  141.                 parryFrames = false;
  142.                 PlayAnimation("Pose");
  143.             }
  144.         }
  145.  
  146.         public override void PlayAnimation(string animationName)
  147.         {
  148.             if (Main.netMode != NetmodeID.Server)
  149.                 standTexture = mod.GetTexture("Projectiles/PlayerStands/SilverChariot/SilverChariot_" + animationName);
  150.  
  151.             if (animationName == "Idle")
  152.             {
  153.                 AnimationStates(animationName, 4, 30, true);
  154.             }
  155.             if (animationName == "Attack")
  156.             {
  157.                 AnimationStates(animationName, 5, newPunchTime, true);
  158.             }
  159.             if (animationName == "Secondary")
  160.             {
  161.                 AnimationStates(animationName, 1, 1, true);
  162.             }
  163.             if (animationName == "Parry")
  164.             {
  165.                 AnimationStates(animationName, 8, 10, false);
  166.             }
  167.             if (animationName == "Pose")
  168.             {
  169.                 AnimationStates(animationName, 1, 10, true);
  170.             }
  171.         }
  172.     }
  173. }