Omega_Nightfueled

Untitled

Sep 8th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using Microsoft.Xna.Framework;
  5. using Terraria.ModLoader;
  6. using Terraria;
  7. using Terraria.ID;
  8. using Terraria.DataStructures;
  9. using Terraria.Utilities;
  10. using Microsoft.Xna.Framework.Graphics;
  11.  
  12. namespace Flail.Projectiles
  13. {
  14. public class ThornBall : ModProjectile
  15. {
  16. public override void SetDefaults()
  17. {
  18. projectile.width = 35;
  19. projectile.height = 35;
  20. projectile.friendly = true;
  21. projectile.penetrate = -1; // Penetrates NPCs infinitely.
  22. projectile.melee = true; // Deals melee dmg.
  23. projectile.aiStyle = 3; // Set the aiStyle to that of a flail.
  24. projectile.extraUpdates = 1;
  25. aiType = ProjectileID.Flairon;
  26. }
  27. public override void OnHitNPC(NPC target, int damage, float knockBack, bool crit) {
  28. target.AddBuff (BuffID.Poisoned, 120, false);
  29. }
  30. public override void AI() {
  31. Vector2 vel1 = new Vector2(90, 90);
  32. vel1 *= 50f;
  33. Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, vel1.X, vel1.Y, ProjectileID.HornetStinger, projectile.damage, 0, Main.myPlayer);
  34. }
  35.  
  36. // Now this is where the chain magic happens. You don't have to try to figure this whole thing out.
  37. // Just make sure that you edit the first line (which starts with 'Texture2D texture') correctly.
  38. public override bool PreDraw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Color lightColor)
  39. {
  40. // So set the correct path here to load the chain texture. 'YourModName' is of course the name of your mod.
  41. // Then into the Projectiles folder and take the texture that is called 'CustomFlailBall_Chain'.
  42. Texture2D texture = ModContent.GetTexture("Flail/Projectiles/VINE");
  43.  
  44. Vector2 position = projectile.Center;
  45. Vector2 mountedCenter = Main.player[projectile.owner].MountedCenter;
  46. Microsoft.Xna.Framework.Rectangle? sourceRectangle = new Microsoft.Xna.Framework.Rectangle?();
  47. Vector2 origin = new Vector2((float)texture.Width * 0.5f, (float)texture.Height * 0.5f);
  48. float num1 = (float)texture.Height;
  49. Vector2 vector2_4 = mountedCenter - position;
  50. float rotation = (float)Math.Atan2((double)vector2_4.Y, (double)vector2_4.X) - 1.57f;
  51. bool flag = true;
  52. if (float.IsNaN(position.X) && float.IsNaN(position.Y))
  53. flag = false;
  54. if (float.IsNaN(vector2_4.X) && float.IsNaN(vector2_4.Y))
  55. flag = false;
  56. while (flag)
  57. {
  58. if ((double)vector2_4.Length() < (double)num1 + 1.0)
  59. {
  60. flag = false;
  61. }
  62. else
  63. {
  64. Vector2 vector2_1 = vector2_4;
  65. vector2_1.Normalize();
  66. position += vector2_1 * num1;
  67. vector2_4 = mountedCenter - position;
  68. Microsoft.Xna.Framework.Color color2 = Lighting.GetColor((int)position.X / 16, (int)((double)position.Y / 16.0));
  69. color2 = projectile.GetAlpha(color2);
  70. Main.spriteBatch.Draw(texture, position - Main.screenPosition, sourceRectangle, color2, rotation, origin, 1f, SpriteEffects.None, 0.0f);
  71. }
  72. }
  73.  
  74. return true;
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment