tModLoader Official tModLoader Help Thread

Sorry ^^

Thanks :D
[doublepost=1459688352,1459688041][/doublepost]Last question, I am unsure how to make crafting recipe, so far I am using dirt but I want to use 30 diamonds, how do I do that >.< '' ?

EDIT :
The projectile ID thing is set to the spectre staff homing cast, but in game it doesn't home, how can I fix that ?
 
Sorry ^^

Thanks :D
[doublepost=1459688352,1459688041][/doublepost]Last question, I am unsure how to make crafting recipe, so far I am using dirt but I want to use 30 diamonds, how do I do that >.< '' ?

EDIT :
The projectile ID thing is set to the spectre staff homing cast, but in game it doesn't home, how can I fix that ?
recipe.AddIngredient(ItemID.Diamond, 30);
 
Not sure if this will work, but try item.holdStyle = 1; in your SetDefaults function.

Make sure useStyle is set to 5. If that doesn't work, please post the entire code.
Thanks!I can hold the weapon now,but it hovers in the air. how can I change the weapon's position.
 
HoldoutOffset has a return type of Vector2, so you will need to return a Vector2 within the method.

Also, if you're using a virtual method from the base class, change virtual to override, otherwise it won't work.
Code:
public override Vector2 HoldoutOffset()
{
  Vector2 offset = new Vector2(8,0);
  // 8, 0 is something I just made up on the spot, just experiment with these numbers until you find something that works.
  return offset;
}

Thanks!I can hold the weapon now,but it hovers in the air. how can I change the weapon's position.

I think can work to you aswell :)
 
I think can work to you aswell :)
Well, I had an error here . It said it must return a “Microsoft.Xna.Framework.Vector2?”. Here is my code

using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace whatever.Items.weapons
{
public class ShotGunII : ModItem
{
public override void SetDefaults()
{
item.name = "ShotGun-II";
item.damage = 50;
item.ranged = true;
item.width = 40;
item.height = 20;
item.toolTip = "This is a refined shotgun.";
item.useTime = 28;
item.useAnimation = 28;
item.useStyle = 5;
item.noMelee = true; //so the item's animation doesn't do damage
item.knockBack = 7;
item.value = 10000;
item.rare = 2;
item.useSound = 14;
item.autoReuse = false;
item.shoot = 10; //idk why but all the guns in the vanilla source have this
item.shootSpeed = 14f;
item.useAmmo = ProjectileID.Bullet;
item.holdStyle = 1;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Shotgun ,1);
recipe.AddIngredient(ItemID.IllegalGunParts ,1);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}


public static Vector2[] randomSpread(float speedX, float speedY, int angle, int num)
{
var posArray = new Vector2[num];
float spread = (float)(angle * 0.0174532925);
float baseSpeed = (float)System.Math.Sqrt(speedX * speedX + speedY * speedY);
double baseAngle = System.Math.Atan2(speedX, speedY);
double randomAngle;
for (int i = 0; i < num; ++i)
{
randomAngle = baseAngle + (Main.rand.NextFloat() - 0.5f) * spread;
posArray = new Vector2(baseSpeed * (float)System.Math.Sin(randomAngle), baseSpeed * (float)System.Math.Cos(randomAngle));
}
return (Vector2[])posArray;
}

public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Vector2[] speeds = randomSpread(speedX,speedY,8,6);
for (int i = 0; i < 5; ++i)
{
Projectile.NewProjectile(position.X, position.Y, speeds.X, speeds.Y, type, damage, knockBack, player.whoAmI);
}

return false;
}

public override void UseStyle(Player player)
{
player.itemLocation.X -= 5f * player.direction;
player.itemLocation.Y += 4f * player.gravDir;
}

public override Vector2 HoldoutOffset()
{
Vector2 offset = new Vector2(8,0);
// 8, 0 is something I just made up on the spot, just experiment with these numbers until you find something that works.
return offset;
}



}
}
 
Well, I had an error here . It said it must return a “Microsoft.Xna.Framework.Vector2?”. Here is my code

using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace whatever.Items.weapons
{
public class ShotGunII : ModItem
{
public override void SetDefaults()
{
item.name = "ShotGun-II";
item.damage = 50;
item.ranged = true;
item.width = 40;
item.height = 20;
item.toolTip = "This is a refined shotgun.";
item.useTime = 28;
item.useAnimation = 28;
item.useStyle = 5;
item.noMelee = true; //so the item's animation doesn't do damage
item.knockBack = 7;
item.value = 10000;
item.rare = 2;
item.useSound = 14;
item.autoReuse = false;
item.shoot = 10; //idk why but all the guns in the vanilla source have this
item.shootSpeed = 14f;
item.useAmmo = ProjectileID.Bullet;
item.holdStyle = 1;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Shotgun ,1);
recipe.AddIngredient(ItemID.IllegalGunParts ,1);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}


public static Vector2[] randomSpread(float speedX, float speedY, int angle, int num)
{
var posArray = new Vector2[num];
float spread = (float)(angle * 0.0174532925);
float baseSpeed = (float)System.Math.Sqrt(speedX * speedX + speedY * speedY);
double baseAngle = System.Math.Atan2(speedX, speedY);
double randomAngle;
for (int i = 0; i < num; ++i)
{
randomAngle = baseAngle + (Main.rand.NextFloat() - 0.5f) * spread;
posArray = new Vector2(baseSpeed * (float)System.Math.Sin(randomAngle), baseSpeed * (float)System.Math.Cos(randomAngle));
}
return (Vector2[])posArray;
}

public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Vector2[] speeds = randomSpread(speedX,speedY,8,6);
for (int i = 0; i < 5; ++i)
{
Projectile.NewProjectile(position.X, position.Y, speeds.X, speeds.Y, type, damage, knockBack, player.whoAmI);
}

return false;
}

public override void UseStyle(Player player)
{
player.itemLocation.X -= 5f * player.direction;
player.itemLocation.Y += 4f * player.gravDir;
}

public override Vector2 HoldoutOffset()
{
Vector2 offset = new Vector2(8,0);
// 8, 0 is something I just made up on the spot, just experiment with these numbers until you find something that works.
return offset;
}



}
}
Sorry i forgot one thing, is: public override Vector2? HoldoutOffset()
 
Ok, nevermind for homing projecile, found jopojelly homing projectile code and integrated it in my projectile code, now I have 3 questions, how can I remove the eater of world corruption effect, how can I make the homing happen faster, and lastly, how to make the projectile glow ?
Btw thanks a lot for that code Jopo :D
 

Attachments

  • HyperTerraria.zip
    3.9 KB · Views: 132
No problem. ;)

P.S Guys i have a little problem as i asked in another thread, i have a problem with projectile frames.. it seems like the frameCounter don't work
using System;
using System.IO;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;

namespace Items.Projectiles
{
public class Siege : ModProjectile
{
public static Texture2D mainTex;
public override void SetDefaults()
{

projectile.name = "Siege";
projectile.width = 10;
projectile.height = 10;
projectile.timeLeft = 300;
projectile.penetrate = 2;
projectile.hostile = false;
projectile.friendly = true;
projectile.magic = true;
projectile.tileCollide = true;
projectile.ignoreWater = true;
projectile.alpha = 0;
aiType = -1;
}

public override void AI() // Sprite animation and Projectile gravity "AI"
{
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
projectile.frameCounter++;
if (projectile.frameCounter > 2)
{
projectile.frame++;
projectile.frameCounter = 0;
}
if (projectile.frame >= 2)
{
projectile.frame = 0;
return;
}

}

}
}
Obviously the projectile contains 2 frame but it didn't change..

Thank you.
 
No problem. ;)

P.S Guys i have a little problem as i asked in another thread, i have a problem with projectile frames.. it seems like the frameCounter don't work
using System;
using System.IO;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;

namespace Items.Projectiles
{
public class Siege : ModProjectile
{
public static Texture2D mainTex;
public override void SetDefaults()
{

projectile.name = "Siege";
projectile.width = 10;
projectile.height = 10;
projectile.timeLeft = 300;
projectile.penetrate = 2;
projectile.hostile = false;
projectile.friendly = true;
projectile.magic = true;
projectile.tileCollide = true;
projectile.ignoreWater = true;
projectile.alpha = 0;
aiType = -1;
}

public override void AI() // Sprite animation and Projectile gravity "AI"
{
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
projectile.frameCounter++;
if (projectile.frameCounter > 2)
{
projectile.frame++;
projectile.frameCounter = 0;
}
if (projectile.frame >= 2)
{
projectile.frame = 0;
return;
}

}

}
}
Obviously the projectile contains 2 frame but it didn't change..

Thank you.
In the SetDefaults function of your projectile, you'll have to define how many animation frames there are in your spritesheet:
Code:
Main.projFrames[projectile.type] = 3; // Means there are 3 animation frames.
 
Sorry i forgot one thing, is: public override Vector2? HoldoutOffset()
_:)з」∠)_here is another issue.The gun's position is not symmetrical, meaning I can adjust on one side while on the another side the gun still hovers like I showed in the pictures.Do you know how to deal with this ? Thanks a lot. 2345截图20160403223419.jpg 2345截图20160403223352.jpg
 
Can i have the code?
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace whatever.Items.weapons
{
    public class ShotGunII : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "ShotGun-II";
            item.damage = 50;
            item.ranged = true;
            item.width = 40;
            item.height = 20;
            item.toolTip = "This is a refined shotgun.";
            item.useTime = 28;
            item.useAnimation = 28;
            item.useStyle = 5;
            item.noMelee = true; //so the item's animation doesn't do damage
            item.knockBack = 7;
            item.value = 10000;
            item.rare = 2;
            item.useSound = 14;
            item.autoReuse = false;
            item.shoot = 10; //idk why but all the guns in the vanilla source have this
            item.shootSpeed = 14f;
            item.useAmmo = ProjectileID.Bullet;
            item.holdStyle = 1;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.Shotgun ,1);
            recipe.AddIngredient(ItemID.IllegalGunParts ,1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
       
       
        public static Vector2[] randomSpread(float speedX, float speedY, int angle, int num)
        {
            var posArray = new Vector2[num];
            float spread = (float)(angle * 0.0174532925);
            float baseSpeed = (float)System.Math.Sqrt(speedX * speedX + speedY * speedY);
            double baseAngle = System.Math.Atan2(speedX, speedY);
            double randomAngle;
            for (int i = 0; i < num; ++i)
            {
                randomAngle = baseAngle + (Main.rand.NextFloat() - 0.5f) * spread;
                posArray[i] = new Vector2(baseSpeed * (float)System.Math.Sin(randomAngle), baseSpeed * (float)System.Math.Cos(randomAngle));
            }
            return (Vector2[])posArray;
        }
       
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        { 
           Vector2[] speeds = randomSpread(speedX,speedY,8,6);
           for (int i = 0; i < 5; ++i)
         {
           Projectile.NewProjectile(position.X, position.Y, speeds[i].X, speeds[i].Y, type, damage, knockBack, player.whoAmI);
         }

         return false;
        }
       
        public override void UseStyle(Player player)
        {
           player.itemLocation.X -= 5f * player.direction;
           player.itemLocation.Y += 4f * player.gravDir;
        }
       
        public override Vector2? HoldoutOffset(Player player)
        {
           Vector2 offset = new Vector2(8,0);
           // 8, 0 is something I just made up on the spot, just experiment with these numbers until you find something that works.
           return offset;
        }
       
       
       
    }
}
 
@Eldrazi : Do you know how to tinker the code of the homing projectile ( named Aura ) so it aims faster ? I tried some stuff but cannot make it work, atm it takes about a sec before aiming at an enemy and then going after him :/
Posted mod src above ^
 
@Eldrazi : Do you know how to tinker the code of the homing projectile ( named Aura ) so it aims faster ? I tried some stuff but cannot make it work, atm it takes about a sec before aiming at an enemy and then going after him :/
Posted mod src above ^
Could you post the code here?
I'm on my mobile, so can't really do anything with .zip files :p
 
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace whatever.Items.weapons
{
    public class ShotGunII : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "ShotGun-II";
            item.damage = 50;
            item.ranged = true;
            item.width = 40;
            item.height = 20;
            item.toolTip = "This is a refined shotgun.";
            item.useTime = 28;
            item.useAnimation = 28;
            item.useStyle = 5;
            item.noMelee = true; //so the item's animation doesn't do damage
            item.knockBack = 7;
            item.value = 10000;
            item.rare = 2;
            item.useSound = 14;
            item.autoReuse = false;
            item.shoot = 10; //idk why but all the guns in the vanilla source have this
            item.shootSpeed = 14f;
            item.useAmmo = ProjectileID.Bullet;
            item.holdStyle = 1;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.Shotgun ,1);
            recipe.AddIngredient(ItemID.IllegalGunParts ,1);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
     
     
        public static Vector2[] randomSpread(float speedX, float speedY, int angle, int num)
        {
            var posArray = new Vector2[num];
            float spread = (float)(angle * 0.0174532925);
            float baseSpeed = (float)System.Math.Sqrt(speedX * speedX + speedY * speedY);
            double baseAngle = System.Math.Atan2(speedX, speedY);
            double randomAngle;
            for (int i = 0; i < num; ++i)
            {
                randomAngle = baseAngle + (Main.rand.NextFloat() - 0.5f) * spread;
                posArray[i] = new Vector2(baseSpeed * (float)System.Math.Sin(randomAngle), baseSpeed * (float)System.Math.Cos(randomAngle));
            }
            return (Vector2[])posArray;
        }
     
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
           Vector2[] speeds = randomSpread(speedX,speedY,8,6);
           for (int i = 0; i < 5; ++i)
         {
           Projectile.NewProjectile(position.X, position.Y, speeds[i].X, speeds[i].Y, type, damage, knockBack, player.whoAmI);
         }

         return false;
        }
     
        public override void UseStyle(Player player)
        {
           player.itemLocation.X -= 5f * player.direction;
           player.itemLocation.Y += 4f * player.gravDir;
        }
     
        public override Vector2? HoldoutOffset(Player player)
        {
           Vector2 offset = new Vector2(8,0);
           // 8, 0 is something I just made up on the spot, just experiment with these numbers until you find something that works.
           return offset;
        }
     
     
     
    }
}
Remove the public override void UseStyle with much of probability is for this thing.
public override void UseStyle(Player player)
{
player.itemLocation.X -= 5f * player.direction;
player.itemLocation.Y += 4f * player.gravDir;
}
 
kk

Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;

namespace HyperTerraria.Projectiles
{
    public class Aura : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.name = "Aura";
            projectile.width = 16;
            projectile.height = 16;
            projectile.friendly = true;
            projectile.magic = true;
            projectile.penetrate = 1;
            projectile.timeLeft = 50;
            /*ProjectileID.Sets.Homing[ModProjectile] = true;
            */
            projectile.tileCollide = false;
            projectile.ignoreWater = true;
            projectile.aiStyle = 340;

        }
  public override bool PreAI()
       
        //    return base.PreAI();
        //}

        //public override void AI()
        //{
            {
            if (projectile.alpha > 0)
            {
                projectile.alpha -= 50;
            }
            else
            {
                projectile.extraUpdates = 0;
            }
            if (projectile.alpha < 0)
            {
                projectile.alpha = 0;
            }
            projectile.rotation = (float)System.Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) - 1.57f;
            projectile.frameCounter++;
            if (projectile.frameCounter >= 6)
            {
                projectile.frame++;
                projectile.frameCounter = 0;
            }
            if (projectile.frame >= 2)
            {
                projectile.frame = 0;
            }
            for (int num363 = 0; num363 < 3; num363++)
            {
                float num364 = projectile.velocity.X / 3f * (float)num363;
                float num365 = projectile.velocity.Y / 3f * (float)num363;
                int num366 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 184, 0f, 0f, 0, default(Color), 1f);
                Main.dust[num366].position.X = projectile.Center.X - num364;
                Main.dust[num366].position.Y = projectile.Center.Y - num365;
                Main.dust[num366].velocity *= 0f;
                Main.dust[num366].scale = 0.5f;
            }

            float num367 = projectile.position.X;
            float num368 = projectile.position.Y;
            float num369 = 100000f;
            bool flag10 = false;
            projectile.ai[0] += 1f;
            if (projectile.ai[0] > 30f)
            {
                projectile.ai[0] = 30f;
                for (int num370 = 0; num370 < 200; num370++)
                {
                    if (Main.npc[num370].CanBeChasedBy(projectile, false) && (!Main.npc[num370].wet /*|| projectile.type == 307*/))
                    {
                        float num371 = Main.npc[num370].position.X + (float)(Main.npc[num370].width / 2);
                        float num372 = Main.npc[num370].position.Y + (float)(Main.npc[num370].height / 2);
                        float num373 = System.Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num371) + System.Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num372);
                        if (num373 < 800f && num373 < num369 && Collision.CanHit(projectile.position, projectile.width, projectile.height, Main.npc[num370].position, Main.npc[num370].width, Main.npc[num370].height))
                        {
                            num369 = num373;
                            num367 = num371;
                            num368 = num372;
                            flag10 = true;
                        }
                    }
                }
            }
            if (!flag10)
            {
                num367 = projectile.position.X + (float)(projectile.width / 2) + projectile.velocity.X * 100f;
                num368 = projectile.position.Y + (float)(projectile.height / 2) + projectile.velocity.Y * 100f;
            }
            else /*if (projectile.type == 307)*/
            {
                projectile.friendly = true;
            }
            float num374 = 6f;
            float num375 = 0.1f;

            num374 = 9f;
            num375 = 0.2f;

            Vector2 vector27 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f);
            float num376 = num367 - vector27.X;
            float num377 = num368 - vector27.Y;
            float num378 = (float)System.Math.Sqrt((double)(num376 * num376 + num377 * num377));
            num378 = num374 / num378;
            num376 *= num378;
            num377 *= num378;
            if (projectile.velocity.X < num376)
            {
                projectile.velocity.X = projectile.velocity.X + num375;
                if (projectile.velocity.X < 0f && num376 > 0f)
                {
                    projectile.velocity.X = projectile.velocity.X + num375 * 2f;
                }
            }
            else if (projectile.velocity.X > num376)
            {
                projectile.velocity.X = projectile.velocity.X - num375;
                if (projectile.velocity.X > 0f && num376 < 0f)
                {
                    projectile.velocity.X = projectile.velocity.X - num375 * 2f;
                }
            }
            if (projectile.velocity.Y < num377)
            {
                projectile.velocity.Y = projectile.velocity.Y + num375;
                if (projectile.velocity.Y < 0f && num377 > 0f)
                {
                    projectile.velocity.Y = projectile.velocity.Y + num375 * 2f;
                    return false;
                }
            }
            else if (projectile.velocity.Y > num377)
            {
                projectile.velocity.Y = projectile.velocity.Y - num375;
                if (projectile.velocity.Y > 0f && num377 < 0f)
                {
                    projectile.velocity.Y = projectile.velocity.Y - num375 * 2f;
                    return false;
                }
            }

            return false;
        }
    }
   
}
 
kk

Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;

namespace HyperTerraria.Projectiles
{
    public class Aura : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.name = "Aura";
            projectile.width = 16;
            projectile.height = 16;
            projectile.friendly = true;
            projectile.magic = true;
            projectile.penetrate = 1;
            projectile.timeLeft = 50;
            /*ProjectileID.Sets.Homing[ModProjectile] = true;
            */
            projectile.tileCollide = false;
            projectile.ignoreWater = true;
            projectile.aiStyle = 340;

        }
  public override bool PreAI()
      
        //    return base.PreAI();
        //}

        //public override void AI()
        //{
            {
            if (projectile.alpha > 0)
            {
                projectile.alpha -= 50;
            }
            else
            {
                projectile.extraUpdates = 0;
            }
            if (projectile.alpha < 0)
            {
                projectile.alpha = 0;
            }
            projectile.rotation = (float)System.Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) - 1.57f;
            projectile.frameCounter++;
            if (projectile.frameCounter >= 6)
            {
                projectile.frame++;
                projectile.frameCounter = 0;
            }
            if (projectile.frame >= 2)
            {
                projectile.frame = 0;
            }
            for (int num363 = 0; num363 < 3; num363++)
            {
                float num364 = projectile.velocity.X / 3f * (float)num363;
                float num365 = projectile.velocity.Y / 3f * (float)num363;
                int num366 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 184, 0f, 0f, 0, default(Color), 1f);
                Main.dust[num366].position.X = projectile.Center.X - num364;
                Main.dust[num366].position.Y = projectile.Center.Y - num365;
                Main.dust[num366].velocity *= 0f;
                Main.dust[num366].scale = 0.5f;
            }

            float num367 = projectile.position.X;
            float num368 = projectile.position.Y;
            float num369 = 100000f;
            bool flag10 = false;
            projectile.ai[0] += 1f;
            if (projectile.ai[0] > 30f)
            {
                projectile.ai[0] = 30f;
                for (int num370 = 0; num370 < 200; num370++)
                {
                    if (Main.npc[num370].CanBeChasedBy(projectile, false) && (!Main.npc[num370].wet /*|| projectile.type == 307*/))
                    {
                        float num371 = Main.npc[num370].position.X + (float)(Main.npc[num370].width / 2);
                        float num372 = Main.npc[num370].position.Y + (float)(Main.npc[num370].height / 2);
                        float num373 = System.Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num371) + System.Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num372);
                        if (num373 < 800f && num373 < num369 && Collision.CanHit(projectile.position, projectile.width, projectile.height, Main.npc[num370].position, Main.npc[num370].width, Main.npc[num370].height))
                        {
                            num369 = num373;
                            num367 = num371;
                            num368 = num372;
                            flag10 = true;
                        }
                    }
                }
            }
            if (!flag10)
            {
                num367 = projectile.position.X + (float)(projectile.width / 2) + projectile.velocity.X * 100f;
                num368 = projectile.position.Y + (float)(projectile.height / 2) + projectile.velocity.Y * 100f;
            }
            else /*if (projectile.type == 307)*/
            {
                projectile.friendly = true;
            }
            float num374 = 6f;
            float num375 = 0.1f;

            num374 = 9f;
            num375 = 0.2f;

            Vector2 vector27 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f);
            float num376 = num367 - vector27.X;
            float num377 = num368 - vector27.Y;
            float num378 = (float)System.Math.Sqrt((double)(num376 * num376 + num377 * num377));
            num378 = num374 / num378;
            num376 *= num378;
            num377 *= num378;
            if (projectile.velocity.X < num376)
            {
                projectile.velocity.X = projectile.velocity.X + num375;
                if (projectile.velocity.X < 0f && num376 > 0f)
                {
                    projectile.velocity.X = projectile.velocity.X + num375 * 2f;
                }
            }
            else if (projectile.velocity.X > num376)
            {
                projectile.velocity.X = projectile.velocity.X - num375;
                if (projectile.velocity.X > 0f && num376 < 0f)
                {
                    projectile.velocity.X = projectile.velocity.X - num375 * 2f;
                }
            }
            if (projectile.velocity.Y < num377)
            {
                projectile.velocity.Y = projectile.velocity.Y + num375;
                if (projectile.velocity.Y < 0f && num377 > 0f)
                {
                    projectile.velocity.Y = projectile.velocity.Y + num375 * 2f;
                    return false;
                }
            }
            else if (projectile.velocity.Y > num377)
            {
                projectile.velocity.Y = projectile.velocity.Y - num375;
                if (projectile.velocity.Y > 0f && num377 < 0f)
                {
                    projectile.velocity.Y = projectile.velocity.Y - num375 * 2f;
                    return false;
                }
            }

            return false;
        }
    }
  
}
The following code is causing the small cooldown on following:
Code:
projectile.ai[0] += 1f;
if (projectile.ai[0] > 30f)
{
    projectile.ai[0] = 30f;
Quickest solution: remove the if statement.
 
Back
Top Bottom