Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using Microsoft.Xna.Framework;
- using Terraria.ModLoader;
- using Terraria;
- using Terraria.ID;
- using Terraria.DataStructures;
- using Terraria.Utilities;
- using Microsoft.Xna.Framework.Graphics;
- namespace Flail.Projectiles
- {
- public class ThornBall : ModProjectile
- {
- public override void SetDefaults()
- {
- projectile.width = 35;
- projectile.height = 35;
- projectile.friendly = true;
- projectile.penetrate = -1; // Penetrates NPCs infinitely.
- projectile.melee = true; // Deals melee dmg.
- projectile.aiStyle = 3; // Set the aiStyle to that of a flail.
- projectile.extraUpdates = 1;
- aiType = ProjectileID.Flairon;
- }
- public override void OnHitNPC(NPC target, int damage, float knockBack, bool crit) {
- target.AddBuff (BuffID.Poisoned, 120, false);
- }
- public override void AI() {
- Vector2 vel1 = new Vector2(90, 90);
- vel1 *= 50f;
- Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, vel1.X, vel1.Y, ProjectileID.HornetStinger, projectile.damage, 0, Main.myPlayer);
- }
- // Now this is where the chain magic happens. You don't have to try to figure this whole thing out.
- // Just make sure that you edit the first line (which starts with 'Texture2D texture') correctly.
- public override bool PreDraw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Color lightColor)
- {
- // So set the correct path here to load the chain texture. 'YourModName' is of course the name of your mod.
- // Then into the Projectiles folder and take the texture that is called 'CustomFlailBall_Chain'.
- Texture2D texture = ModContent.GetTexture("Flail/Projectiles/VINE");
- Vector2 position = projectile.Center;
- Vector2 mountedCenter = Main.player[projectile.owner].MountedCenter;
- Microsoft.Xna.Framework.Rectangle? sourceRectangle = new Microsoft.Xna.Framework.Rectangle?();
- Vector2 origin = new Vector2((float)texture.Width * 0.5f, (float)texture.Height * 0.5f);
- float num1 = (float)texture.Height;
- Vector2 vector2_4 = mountedCenter - position;
- float rotation = (float)Math.Atan2((double)vector2_4.Y, (double)vector2_4.X) - 1.57f;
- bool flag = true;
- if (float.IsNaN(position.X) && float.IsNaN(position.Y))
- flag = false;
- if (float.IsNaN(vector2_4.X) && float.IsNaN(vector2_4.Y))
- flag = false;
- while (flag)
- {
- if ((double)vector2_4.Length() < (double)num1 + 1.0)
- {
- flag = false;
- }
- else
- {
- Vector2 vector2_1 = vector2_4;
- vector2_1.Normalize();
- position += vector2_1 * num1;
- vector2_4 = mountedCenter - position;
- Microsoft.Xna.Framework.Color color2 = Lighting.GetColor((int)position.X / 16, (int)((double)position.Y / 16.0));
- color2 = projectile.GetAlpha(color2);
- Main.spriteBatch.Draw(texture, position - Main.screenPosition, sourceRectangle, color2, rotation, origin, 1f, SpriteEffects.None, 0.0f);
- }
- }
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment