• For issues you find with the Switch and Console releases, please follow this link and give as much detail as possible. This is the speediest way to get info to Pipeworks and get a hotfix in the works.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Begin your search for Journey's End information here and here. Please report bugs and issues for Journey's End here.
  • For issues you find with the Mobile 1.4 update, please follow this link and give as much detail as possible. This is the speediest way to get info to DR Studios to look at your issue. Also, some troubleshooting hints here.

Standalone [1.3] tModLoader - A Modding API

Hek

Eye of Cthulhu
Could you show your item code (probably once more)? :)
It is a little bit messed up
Code:
using Terraria.ModLoader;
using Terraria.ID;
using Microsoft.Xna.Framework.Graphics;


namespace Terranova.Projectiles
{
    public class prjMokbiShuriken : ModProjectile
    {
        private Player player = new Player();

        private int timeLeftIndicator;
      

        public override void SetDefaults()
        {
            projectile.name = "mokbiShuriken";
            projectile.width = 22;
            projectile.height = 22;
            projectile.friendly = true;
            projectile.magic = false;
            projectile.penetrate = 2;
            projectile.extraUpdates = 1;
            projectile.hide = false;
          
           // projectile.aiStyle = ProjectileID.Shuriken;
          
            timeLeftIndicator = 1000;
            player = Main.player[projectile.owner];
        }
        public override bool PreAI()
        {
            if (projectile.timeLeft > timeLeftIndicator)
                projectile.timeLeft = timeLeftIndicator;
            return true;
        }
        public override void AI()
        {
            projectile.rotation += 1;
            projectile.velocity.Y = projectile.ai[0];
            projectile.velocity.X = 2.5f;

        }
        public override bool OnTileCollide(Vector2 oldVelocity)
        {
            projectile.penetrate--;
            if (projectile.penetrate <= 0)
            {
                projectile.Kill();
            }
          
              
                Main.PlaySound(3, (int)projectile.position.X, (int)projectile.position.Y, 4);


                return false;
          
        }
        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            if(projectile.penetrate == 0)
            {
                projectile.Kill();
            }
            else
            {
                projectile.penetrate--;
                projectile.ai[1] += 0.1f;
                projectile.velocity *= 0.75f;
            }       
            base.OnHitNPC(target, damage, knockback, crit);
        }
    }
}
 

Eldrazi

Eater of Worlds
It is a little bit messed up
Code:
using Terraria.ModLoader;
using Terraria.ID;
using Microsoft.Xna.Framework.Graphics;


namespace Terranova.Projectiles
{
    public class prjMokbiShuriken : ModProjectile
    {
        private Player player = new Player();

        private int timeLeftIndicator;
     

        public override void SetDefaults()
        {
            projectile.name = "mokbiShuriken";
            projectile.width = 22;
            projectile.height = 22;
            projectile.friendly = true;
            projectile.magic = false;
            projectile.penetrate = 2;
            projectile.extraUpdates = 1;
            projectile.hide = false;
         
           // projectile.aiStyle = ProjectileID.Shuriken;
         
            timeLeftIndicator = 1000;
            player = Main.player[projectile.owner];
        }
        public override bool PreAI()
        {
            if (projectile.timeLeft > timeLeftIndicator)
                projectile.timeLeft = timeLeftIndicator;
            return true;
        }
        public override void AI()
        {
            projectile.rotation += 1;
            projectile.velocity.Y = projectile.ai[0];
            projectile.velocity.X = 2.5f;

        }
        public override bool OnTileCollide(Vector2 oldVelocity)
        {
            projectile.penetrate--;
            if (projectile.penetrate <= 0)
            {
                projectile.Kill();
            }
         
             
                Main.PlaySound(3, (int)projectile.position.X, (int)projectile.position.Y, 4);


                return false;
         
        }
        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            if(projectile.penetrate == 0)
            {
                projectile.Kill();
            }
            else
            {
                projectile.penetrate--;
                projectile.ai[1] += 0.1f;
                projectile.velocity *= 0.75f;
            }      
            base.OnHitNPC(target, damage, knockback, crit);
        }
    }
}
Ah, I'm not looking for your projectile code. I need your item code instead.
 

Hek

Eye of Cthulhu
Ah, I'm not looking for your projectile code. I need your item code instead.
Code:
using Terraria.ModLoader;
using Terranova;
using Terranova.Items;

namespace Terranova.Items.Weapons
{
    class MokbiShuriken : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Mokbi Shuriken";
            item.width = 22;
            item.height = 22;
            item.useStyle = 1;
            item.useTime = 1;
            item.useAnimation = 4;
            item.reuseDelay = 20;
            item.autoReuse = true;
            item.shootSpeed = 1.5f;
            item.shoot = mod.ProjectileType("prjMokbiShuriken");
            item.damage = 10;
            item.width = 18;
            item.height = 20;
            item.maxStack = 999;
            item.consumable = true;
            item.useSound = 1;
            item.noUseGraphic = true;
            item.noMelee = true;
            item.value = 15;
            item.thrown = true;

        }

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

    }
}
 

Eldrazi

Eater of Worlds
Code:
using Terraria.ModLoader;
using Terranova;
using Terranova.Items;

namespace Terranova.Items.Weapons
{
    class MokbiShuriken : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Mokbi Shuriken";
            item.width = 22;
            item.height = 22;
            item.useStyle = 1;
            item.useTime = 1;
            item.useAnimation = 4;
            item.reuseDelay = 20;
            item.autoReuse = true;
            item.shootSpeed = 1.5f;
            item.shoot = mod.ProjectileType("prjMokbiShuriken");
            item.damage = 10;
            item.width = 18;
            item.height = 20;
            item.maxStack = 999;
            item.consumable = true;
            item.useSound = 1;
            item.noUseGraphic = true;
            item.noMelee = true;
            item.value = 15;
            item.thrown = true;

        }

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

    }
}
Allright hang on, what exactly is the problem here?
Does the player face the correctdirection but does the projectile not do the same?
 
  • Like
Reactions: Hek

Hek

Eye of Cthulhu
Allright hang on, what exactly is the problem here?
Does the player face the correctdirection but does the projectile not do the same?
There are plenty of of problems, first of all it just changes the player direction of throwing, next comes all the direction and velocity changes. I just would like to make something like the original shuriken just adjust some things like speed, penetration and direction
 

Eldrazi

Eater of Worlds
There are plenty of of problems, first of all it just changes the player direction of throwing, next comes all the direction and velocity changes. I just would like to make something like the original shuriken just adjust some things like speed, penetration and direction
Whelp, it's not really that strange the projectile persists with a certain velocity. Below is your AI code:
Code:
public override void AI()
{
    projectile.rotation += 1;
    projectile.velocity.Y = projectile.ai[0];
    projectile.velocity.X = 2.5f;
}
In here you're hardcoding the X value of the projectiles velocity to 2.5, because of which your projectile will keep moving to the right.
 
  • Like
Reactions: Hek

Hek

Eye of Cthulhu
Whelp, it's not really that strange the projectile persists with a certain velocity. Below is your AI code:
Code:
public override void AI()
{
    projectile.rotation += 1;
    projectile.velocity.Y = projectile.ai[0];
    projectile.velocity.X = 2.5f;
}
In here you're hardcoding the X value of the projectiles velocity to 2.5, because of which your projectile will keep moving to the right.
So how to fix it? and btw: is there any thread explaining all projectile.* types?
 

Eldrazi

Eater of Worlds
So how to fix it? and btw: is there any thread explaining all projectile.* types?
To fix it just remove those lines hardcoding the velocity of your projectile.
If you want a shuriken like AI, just use the following:
Code:
public override void AI()
{
    projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.03f * (float)projectile.direction;   
   
    projectile.ai[0] += 1f;
    if (projectile.ai[0] >= 20f)
    {
        projectile.velocity.Y = projectile.velocity.Y + 0.4f;
        projectile.velocity.X = projectile.velocity.X * 0.97f;
    }
}
If you want to change anything regarding the velocity in there: the code should speak for itself.
As for your second question: no, not that I know of. Just take the trial and error route to get your answers.
 
  • Like
Reactions: Hek

Hek

Eye of Cthulhu
To fix it just remove those lines hardcoding the velocity of your projectile.
If you want a shuriken like AI, just use the following:
Code:
public override void AI()
{
    projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.03f * (float)projectile.direction;  
  
    projectile.ai[0] += 1f;
    if (projectile.ai[0] >= 20f)
    {
        projectile.velocity.Y = projectile.velocity.Y + 0.4f;
        projectile.velocity.X = projectile.velocity.X * 0.97f;
    }
}
If you want to change anything regarding the velocity in there: the code should speak for itself.
As for your second question: no, not that I know of. Just take the trial and error route to get your answers.
Did you just copy this from anywhere ? Or did you do this just right now? Because I would never have the idea of using Math.Abs and "(float)projectile.direction"
 

Eldrazi

Eater of Worlds
Did you just copy this from anywhere ? Or did you do this just right now? Because I would never have the idea of using Math.Abs and "(float)projectile.direction"
Math.Abs gets the absolute value of the given value/variable, meaning the value will always be positive, so that in this case the velocity only determines the speed at which the projectile rotates and direction determines the direction it's rotating towards.
 
  • Like
Reactions: Hek

Hek

Eye of Cthulhu
Math.Abs gets the absolute value of the given value/variable, meaning the value will always be positive, so that in this case the velocity only determines the speed at which the projectile rotates and direction determines the direction it's rotating towards.
And how to adjust/fix this, so it flies further ? As already mentioned, when it comes to projectiles, im still lacking understanding.

picture can not load (here)
 

Eldrazi

Eater of Worlds
And how to adjust/fix this, so it flies further ? As already mentioned, when it comes to projectiles, im still lacking understanding.
The image is not working for me, but if you want the projectile to fly longer before it drops, you'll want to change the value that is checked here
if (projectile.ai[0] >= 20f)
Changing 20 to a higher value will result in more time before the drop.
 
  • Like
Reactions: Hek

Hek

Eye of Cthulhu
The image is not working for me, but if you want the projectile to fly longer before it drops, you'll want to change the value that is checked here
if (projectile.ai[0] >= 20f)
Changing 20 to a higher value will result in more time before the drop.
Okay thanks, last question, how to change the flying speed before the shuriken drops right from the beginning?
 

Eldrazi

Eater of Worlds
Yepp thanks. Im working right now at stopping the rotation at the max point, and starting it again while dropping like the original shuriken
If it's allright, that should already be happening using the AI I gave you earlier?
 
Top Bottom