Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.11 KB | None | 0 0
  1. using System;
  2. using Microsoft.Xna.Framework;
  3.  
  4. using Terraria;
  5. using Terraria.ID;
  6. using Terraria.ModLoader;
  7.  
  8. namespace MyMod
  9. {
  10.     public class CactusDagger : ModProjectile
  11.     {
  12.         public override void SetDefaults()
  13.         {
  14.             projectile.name = "Cactus Dagger";
  15.             projectile.width = 12;
  16.             projectile.height = 12;
  17.             projectile.penetrate = 2;
  18.             projectile.friendly = true;
  19.             projectile.thrown = true;
  20.         }
  21.  
  22.         public override bool PreAI()
  23.         {
  24.             if (projectile.ai[0] == 0)
  25.             {
  26.                 projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.03f * (float)projectile.direction;
  27.                 projectile.localAI[1] += 1f;
  28.                 if (projectile.localAI[1] >= 20f)
  29.                 {
  30.                     projectile.velocity.Y = projectile.velocity.Y + 0.4f;
  31.                     projectile.velocity.X = projectile.velocity.X * 0.97f;
  32.                 }
  33.                 else
  34.                 {
  35.                     projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
  36.                 }
  37.  
  38.                 if (projectile.velocity.Y > 16f)
  39.                 {
  40.                     projectile.velocity.Y = 16f;
  41.                 }
  42.             }
  43.             if (projectile.ai[0] == 1f)
  44.             {
  45.                 projectile.ignoreWater = true;
  46.                 projectile.tileCollide = false;
  47.                 int num996 = 15;
  48.                 bool flag52 = false;
  49.                 bool flag53 = false;
  50.                 projectile.localAI[0] += 1f;
  51.                 if (projectile.localAI[0] % 30f == 0f)
  52.                 {
  53.                     flag53 = true;
  54.                 }
  55.                 int num997 = (int)projectile.ai[1];
  56.                 if (projectile.localAI[0] >= (float)(60 * num996))
  57.                 {
  58.                     flag52 = true;
  59.                 }
  60.                 else if (num997 < 0 || num997 >= 200)
  61.                 {
  62.                     flag52 = true;
  63.                 }
  64.                 else if (Main.npc[num997].active && !Main.npc[num997].dontTakeDamage)
  65.                 {
  66.                     projectile.Center = Main.npc[num997].Center - projectile.velocity * 2f;
  67.                     projectile.gfxOffY = Main.npc[num997].gfxOffY;
  68.                     if (flag53)
  69.                     {
  70.                         Main.npc[num997].HitEffect(0, 1.0);
  71.                     }
  72.                 }
  73.                 else
  74.                 {
  75.                     flag52 = true;
  76.                 }
  77.                 if (flag52)
  78.                 {
  79.                     projectile.Kill();
  80.                 }
  81.             }
  82.  
  83.             return false;
  84.         }
  85.  
  86.         public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
  87.         {
  88.             projectile.ai[0] = 1f;
  89.             projectile.ai[1] = (float)target.whoAmI;
  90.             target.AddBuff(169, 900, false);
  91.             projectile.velocity = (target.Center - projectile.Center) * 0.75f;
  92.             projectile.netUpdate = true;
  93.             projectile.damage = 0;
  94.             int num31 = 6;
  95.             Point[] array2 = new Point[num31];
  96.             int num32 = 0;
  97.  
  98.             for (int n = 0; n < 1000; n++)
  99.             {
  100.                 if (n != projectile.whoAmI && Main.projectile[n].active && Main.projectile[n].owner == Main.myPlayer && Main.projectile[n].type == projectile.type && Main.projectile[n].ai[0] == 1f && Main.projectile[n].ai[1] == target.whoAmI)
  101.                 {
  102.                     array2[num32++] = new Point(n, Main.projectile[n].timeLeft);
  103.                     if (num32 >= array2.Length)
  104.                     {
  105.                         break;
  106.                     }
  107.                 }
  108.             }
  109.             if (num32 >= array2.Length)
  110.             {
  111.                 int num33 = 0;
  112.                 for (int num34 = 1; num34 < array2.Length; num34++)
  113.                 {
  114.                     if (array2[num34].Y < array2[num33].Y)
  115.                     {
  116.                         num33 = num34;
  117.                     }
  118.                 }
  119.                 Main.projectile[array2[num33].X].Kill();
  120.             }
  121.         }
  122.  
  123.         public override void Kill(int timeLeft)
  124.         {
  125.             Main.PlaySound(0, (int)projectile.position.X, (int)projectile.position.Y, 1);
  126.             Vector2 vector8 = projectile.position;
  127.             Vector2 oldVelocity = projectile.oldVelocity;
  128.             oldVelocity.Normalize();
  129.             vector8 += oldVelocity * 16f;
  130.             for (int num255 = 0; num255 < 20; num255++)
  131.             {
  132.                 int num256 = Dust.NewDust(vector8, projectile.width, projectile.height, 81, 0f, 0f, 0, default(Color), 1f);
  133.                 Main.dust[num256].position = (Main.dust[num256].position + projectile.Center) / 2f;
  134.                 Main.dust[num256].velocity += projectile.oldVelocity * 0.4f;
  135.                 Main.dust[num256].velocity *= 0.5f;
  136.                 Main.dust[num256].noGravity = true;
  137.                 vector8 -= oldVelocity * 8f;
  138.             }
  139.         }
  140.     }
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement