tModLoader Projectile help

Repeatedmars

Terrarian
Im newer to modding so i dont know very much but im making a sword and im trying to make it shoot a projectile that spins like the true nights edge projectile can anyone tell me how.
 
if you want it to shoot a projectile then you'll need to add a projectile into the code and make it shoot it, you can start by adding the 2 things below into your SetDefaults() area.

item.shoot = mod.ProjectileType("ProjectileName");
item.shootSpeed = SpeedOfProjectilef;

make sure you have a projectile it can shoot in your projectiles folder aswell.
An example would be:

using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;

namespace SwordOfCthulhu.Items.Weapons
{
public class SwordOfCthulhu : ModItem
{
public override void SetDefaults()
{
item.name = "Sword Of Cthulhu";
item.damage = 500;
item.melee = true;
item.width = 58;
item.height = 66;
item.toolTip = "You feel celestial Power! ";
item.useTime = 8;
item.useAnimation = 8;
item.useStyle = 1;
item.knockBack = 6;
item.value = 100;
item.rare = 10;
item.useSound = 1;
item.autoReuse = true;
item.useTurn = true;
item.shoot = mod.ProjectileType("SwordOfCthulhuBeam");
item.shootSpeed = 12f;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.TerraBlade, 1);
recipe.AddIngredient(ItemID.Meowmere, 1);
recipe.AddIngredient(ItemID.StarWrath, 1);
recipe.AddIngredient(ItemID.LunarBar, 25);
recipe.AddTile(TileID.LunarCraftingStation);
recipe.SetResult(this);
recipe.AddRecipe();

}
}
}

Then you would need a projectile, like this:

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

namespace SwordOfCthulhu.Projectiles
{

public class SwordOfCthulhuBeam : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "Sword Of Cthulhu Beam";
projectile.width = 30;
projectile.height = 58;
projectile.friendly = true;
projectile.melee = true;
projectile.tileCollide = true;
projectile.penetrate = 30;
projectile.timeLeft = 200;
projectile.light = 0.75f;
projectile.extraUpdates = 1;
projectile.ignoreWater = true;
}
public override void AI()
{
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
}
}
}
 
Back
Top Bottom