How do i make my weapons shoot projectiles?

Add an

Code:
item.shoot = mod.ProjectileType("ProjektileName");
item.shootSpeed = SpeedOfProjektilef;

Example

Sword

Code:
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();

        }
    }
}

Projektile (Preojektile File Must be in "Projektiles" Folder)

Code:
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;
        }
    }
}


I Hope it helps
 
Do i put it in the Mod Sources folder it just seems to be reading my
Projectiles folder as a mod:eek:


You Need to Put the Projektiles Folder in the Same Folder like you Items Folder

iVwVVqM.png
 
It's telling me this... c:\Users\Brown\Documents\My Games\Terraria\ModLoader\Mod Sources\TestBlade\Projectiles\GreatFire.cs(25,42) : error CS0103: The name 'Math' does not exist in the current context :confused:
 
It's telling me this... c:\Users\Brown\Documents\My Games\Terraria\ModLoader\Mod Sources\TestBlade\Projectiles\GreatFire.cs(25,42) : error CS0103: The name 'Math' does not exist in the current context :confused:
Can you send a Screenshot and the Code?
evvt i only Reply in 12 Hour again Because i go Sleep in 5 min C:
 
Last edited:
It's telling me this... c:\Users\Brown\Documents\My Games\Terraria\ModLoader\Mod Sources\TestBlade\Projectiles\GreatFire.cs(25,42) : error CS0103: The name 'Math' does not exist in the current context :confused:
You'll need to include the correct namespace to be able to use the Math class and functions. Add the following line to the rest of your using statements:
Code:
using System;
 
What line would i put it in? If you don't mind showing me.

using Terraria.ID;
using Terraria.ModLoader;

namespace TestBlade.Projectiles
{

public class GreatFire : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "Great Fire";
projectile.width = 64;
projectile.height = 64;
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;
}
}
 
What line would i put it in? If you don't mind showing me.

using Terraria.ID;
using Terraria.ModLoader;

namespace TestBlade.Projectiles
{

public class GreatFire : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "Great Fire";
projectile.width = 64;
projectile.height = 64;
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;
}
}
Well, where do you see similar code? Especially notice the Add the following line to the rest of your using statements part.
 
Well, where do you see similar code? Especially notice the Add the following line to the rest of your using statements part.

I could not get it right i'm not that great when it comes to using Cs it would be nice of you just to show me were it goes so when i do this again i don't make the same mistake over and over again. I have been trying tho.
 
I could not get it right i'm not that great when it comes to using Cs it would be nice of you just to show me were it goes so when i do this again i don't make the same mistake over and over again. I have been trying tho.
Aaaaall the way at the top, with the rest of the using statements.
 
OOOOOOOOooohhhhhhhh :D I feel so dumb but it's so funny when you pointed it out as i was looking a the bottom rather then the top :kingslime:
[doublepost=1461757909,1461757384][/doublepost]Hmmm it seem to fire more when i jump and less when i'm on the ground.
 
OOOOOOOOooohhhhhhhh :D I feel so dumb but it's so funny when you pointed it out as i was looking a the bottom rather then the top :kingslime:
[doublepost=1461757909,1461757384][/doublepost]Hmmm it seem to fire more when i jump and less when i'm on the ground.
?? Xcuse me? ;)
 
It's funny to see as if i walk the light will show as if it was shot but if i jump the
Projectile comes out `:confused: It's how do you say out of this world :kingslime:
 
It's funny to see as if i walk the light will show as if it was shot but if i jump the
Projectile comes out `:confused: It's how do you say out of this world :kingslime:
I got The it to that Projektiles dont Spawn near Ground
I Just maked them go trough Walls
just make

Code:
item.tileCollide = True;
to

Code:
item.tileCollide = false;
 
So that's why `:D still i like the idea it's just i could not find out how to fix it if i wanted it to do it when i did not jump!
Thank you vary much but i must ask since you maybe able to help. As a side note do you know how to add debuffs on weapons? `:)
 
So that's why `:D still i like the idea it's just i could not find out how to fix it if i wanted it to do it when i did not jump!
Thank you vary much but i must ask since you maybe able to help. As a side note do you know how to add debuffs on weapons? `:)
Currently no C:
Im too not a great Modder :D

I search a little bit trough Example mod and evvt i find Something C:
 
Back
Top Bottom