• Journey's End on PC - Find info here and here. Please report bugs and issues for PC 1.4 and 1.4.1 to Re-Logic here.
  • Journey's End on Mobile - Find info here. Report bugs for Mobile 1.4 to DR Studios at this link and give as much detail as possible.
  • 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.
  • Console and Switch - The latest news can be found here. To report a bug, please use this link.

tAPI [Guide/Resources] - Adding Projectiles to Melee Weapons

Zygomorph

Spazmatism

So what if you're making a large sword, and you want to add a debuff to it? Check out Getting Started With Modding. But there are some things that berberborscing doesn't touch on, regarding items. (Go to http://dev.willhuxtable.com/ids/#buff for a buff list. [Remember something- not many buffs work against enemies. Most likely the only ones you should tinker with are the ones that an existing item uses.])

But what else can you do? Obviously you can add dust, but I myself don't really understand dust and I prefer to stay away from it. So what can we do? Oh yeah, what did 1.2 add that revolutionized melee? Melee projectiles.
So how do you make a sword shoot a projectile?
Let's see.

kdcROYP.png
This goes in the "Items" folder.
Code:
{
"displayName": "Sword of Shootiness", //Name of item in-game
"size": [width, height], //Size of texture file
"maxStack": number, //Weapons are usually 1
"value": [platinum, gold, silver, copper], /*Sell is 1/6 of value */
"rare": number, //Go to http://terraria.gamepedia.com/Rarity
"tooltip": "string", //When you mouse over it
"useStyle": [For a broadsword, usually 1], /*http://goo.gl/AeqNTi */
"useAnimation": number,
"useTime": number, //http://goo.gl/AdE162
"damage": number,
"knockback": number, //1 lowest, 10 highest of normal items
"useSound": [Usually 1 for broadswords], //http://goo.gl/JX9sYi
"autoReuse": bool, //Swings continuously or not
"melee": true, //Melee effects and stuff
"shoot": InternalName:Projectile, /* This is the projectile name that is in the next section! IMPORTANT! */

"recipes":
[{
"items": { "material": number, "material": number },
"tiles": [ "tile", "tile" ],
"creates": number [Usually 1 for weapons]
}]
}


In the "Projectiles" folder.
Code:
{
"displayName": "string", //When you mouse over it
"size": [width, height], //Size of texture
"damage": number, //Independent to sword damage
"knockback": number,
"aiStyle": 27, //http://goo.gl/MjSGyC
"melee": true //Melee damage boosts, etc.
}
kdcROYP.png
Fixed a damage type for the projectile.
Added illuminati(ng) comments to code.
 
Last edited:

Sin Costan

Eye of Cthulhu
So what if you're making a large sword, and you want to add a debuff to it? Check out Getting Started With Modding. But there are some things that berberborscing doesn't touch on, regarding items.

Go to http://dev.willhuxtable.com/ids/#buff for a buff list. Remember something- not many buffs work against enemies. Most likely the only ones you should tinker with are the ones that an existing item uses.

But what else can you do? Obviously you can add dust, but I myself don't really understand dust and I prefer to stay away from it. So what can we do? Oh yeah, what did 1.2 add that revolutionized melee? Melee projectiles.
So how do you make a sword shoot a projectile?
Let's see.

You should know where to put this, the "Items" folder.
Code:
{
"displayName": "Sword of Shootiness",
"size": [width, height],
"maxStack": number,
"value": [platinum, gold, silver, copper],
"rare": number,
"tooltip": "string",
"useStyle": [For a broadsword, usually 1],
"useAnimation": number,
"useTime": number,
"damage": number,
"knockback": number,
"useSound": [Usually 1 for boradswords],
"autoReuse": bool,
"melee": true,
"shoot": InternalName:Projectile,

"recipes":
[{
"items": { "material": number, "material": number },
"tiles": [ "tile", "tile" ],
"creates": [Usually 1 for weapons]
}]
}
In the "Projectiles" folder.
Code:
{
"displayName": "string",
"size": [width, height],
"damage": number,
"knockback": number,
"aiStyle": 27,
"ranged": true
}
Dat middle collumn.
 

Zygomorph

Spazmatism
I made a tutorial on this, but on a different website, but good job, mate; as this seems to be a very common question
Yeah, the sword projectiles changed a lot if stuff. I hope w'ell see it in more mods.
Edit- My mod doesn't even have a sword with a projectile.
IFnj6ci.png
 

Wulf'frid

Terrarian
although, rather than doing ranged, you could probably do something like "noMelee": false, so that the projectile is affected by melee booster (I'm not sure if this actually matters, I did it, and it compiled fine)
 

Zygomorph

Spazmatism
although, rather than doing ranged, you could probably do something like "noMelee": false, so that the projectile is affected by melee booster (I'm not sure if this actually matters, I did it, and it compiled fine)
Ooh I didn't think of that. Nice catch. The projectile should in fact count as ranged damage. I'm going to add some illuminating comments as well.
 

Sin Costan

Eye of Cthulhu
I don't want to crash the party, but you forgot "shootSpeed" in your item's JSON. Also, the "damage" json property doesn't affect the projectile at all.

although, rather than doing ranged, you could probably do something like "noMelee": false, so that the projectile is affected by melee booster (I'm not sure if this actually matters, I did it, and it compiled fine)

Setting "noMelee" to false doesn't really change anything, it's default is false after all. "noMelee" is a property that makes the item texture that is currently used not do damage, which is why all ranged weapons have this to true.

Ooh I didn't think of that. Nice catch. The projectile should in fact count as ranged damage. I'm going to add some illuminating comments as well.

If the projectile's "melee" is set to true, then it should be counted as a melee. If that is not working, you should probably change the projectile's damage directly using the projectile's AI() like this...

Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using TAPI;
using Terraria;

namespace ModInternalName.Projectiles
{   
    public class ProjectileName : ModProjectile
    {
        public override void AI()
        {
            Player player = Main.player[projectile.owner];
            int damage = 10; //Set damage to anything...
            float meleeMult = player.meleeDamage;
            projectile.damage = damage *meleeMult;
        }
    }
}

Of course you can just do all that directly in projectile.damage, but that was separated to show the individual stuff...

But anyways, dat middle collumn. ( ͡° ͜ʖ ͡°)
 
Top Bottom