• 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 [Tutorial] Projectile Guide and Implementation

blushiemagic

Retinazer
tModLoader
Is there a way to make a tiny plantera that fights for you?
Are you talking about a summoned minion? Yes, but then minion projectiles are way more complicated than other projectiles (not to mentioned that you'd have to program your own AI for it). I've made a tutorial on summon weapons somewhere, and also another one on AI (although it's for NPCs).
 

Sin Costan

Eye of Cthulhu
@bluemagic123 thanks a lot with animating projectiles, it was quite simple after looking at your code in your Endgame Extension mod. Also, I found a great use for your Custom Dust tutorial, making custom Heat Ray projectiles. I might be using some of your tutorial to add to the projectile tutorial... if you don't mind of course. :passionate:
 
He means that you must replace "MPT" with your mod's internal name.
help when i load a world this error shows up

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item( key)
at TAPI.PlayerLayer.<.cctor>b__a(TAPI.PlayerLayer layer, Terraria.Player drawPlayer, Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
at TAPI.PlayerLayer+Action.OnDraw(Terraria.Player drawPlayer, Microsoft.Xna.Framework.Graphics.SpriteBatch sb)
at TAPI.PlayerLayer.Draw(Terraria.Player drawPlayer, Microsoft.Xna.Framework.Graphics.SpriteBatch sb)
at Terraria.Main.DrawPlayer(Terraria.Player drawPlayer, Microsoft.Xna.Framework.Vector2 Position, System.Single rotation, Microsoft.Xna.Framework.Vector2 rotationOrigin, System.Single shadow = 0)
at Terraria.Main.Draw(Microsoft.Xna.Framework.GameTime gameTime)

please help
 

Sin Costan

Eye of Cthulhu
Later on this week, gonna add more stuff to the tutorial! Maybe even today, who knows?

- Animated Projectiles!
- Custom Heat Ray!
- Powder?

EDIT: Possibly change the layout of the Tutorial...
 
Last edited:

Theo

Official Terrarian
Later on this week, gonna add more stuff to the tutorial! Maybe even today, who knows?

- Animated Projectiles!
- Custom Heat Ray!
- Powder?

EDIT: Possibly change the layout of the Tutorial...
Yes! More stuff! Also, make sure you add a thrown projectile (grenade, etc) tutorial.
 

samufinland

Terrarian
Later on this week, gonna add more stuff to the tutorial! Maybe even today, who knows?

- Animated Projectiles!
- Custom Heat Ray!
- Powder?

EDIT: Possibly change the layout of the Tutorial...
Hey, can you tell me how to create a basic thrown weapon with animation?(or even without)
 

Sin Costan

Eye of Cthulhu
I'm not sure how to add a cool-down to my projectile, is there anyway to do that?

Hmm, what do you mean by cool-down, like it delays firing of all kinds for a while or just the projectile? If it were case A, then you would just need to add into your item's .json

Code:
"reuseDelay": 10, //10 ticks until you can use any item again

If it were case B, then I would suggest making the item produce a buff that lasts for a certain amount of time in which you add an if statement to CanUseItem() or PreShoot() to your item .cs file. Sorta something like this.

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

using TAPI;
using Terraria;

namespace InternalModName.Items
{
    public class ModItemName : ModItem
    {
        public override bool CanUse(Player player)
        {
            if (player.HasBuff(BuffDef.byName["InternalModName:CoolDownBuff"])  //If the player has the cooldown buff, the item won't be used.
            {
                return false;
            }
            else //If player doesn't, item is used.
            {
                return true;
            }
        }
        public override bool? UseItem(Player player)
        {
            if(!player.HasBuff(BuffDef.byName["InternalModName:CoolDownBuff"]) //If player doesn't have cooldown buff, add the cooldown buff for 5 seconds
            {
                  player.AddBuff(BuffDef.byName["InternalModName:CoolDownBuff"], 300, false);
            }
            return true;
        }
    }
}

This probably isn't the greatest way to go about it, but it should work.
 

Boffin

Brain of Cthulhu
How did I not notice that reuseDelay was a thing :|

When I get on my computer I'll have a go at both, thanks :D
 

Sin Costan

Eye of Cthulhu
Ok, I updated the MPT.zip once again. It now includes

Guide Ray - Custom Heat Ray with Custom Dust (Custom Dust Tutorial by @bluemagic123 )
*notes:
- I'm probably gonna update MPT.zip again soon so that it includes a commented template of making a custom heat ray projectile with vanilla dust
- Guide Ray is absolutely awesome (Fires custom dust that are Guide Gore and Guide Voodoo Doll)
Flame Blast Arrow - Custom Arrow (that can be used by any bow) that makes an animated projectile, the Flame Blast (Thanks for the help @bluemagic123 )
Flame Blaster - Item that converts general arrows into Flame Blast projectile
Cursed Inferno Powder - Custom Vile Powder that causes Cursed Flame when dust touches enemies (Some of the code by @berberborscing )
 

samufinland

Terrarian
Do you happen to know how to make a gun that uses ammo but gives something else (like a gun that splits out the empty shells of the bullets and they can be collected)
 
please help! I made a sword and it wont work ! I get this error when I build my mod

Terraria 1.2.4.1, tAPI Builder r14a

========================================

LitJson.JsonException: ModInfo Error: Invalid character 'F' in input string ---> LitJson.JsonException: Invalid character 'F' in input string
at LitJson.Lexer.NextToken()
at LitJson.JsonReader.ReadToken()
at LitJson.JsonReader.Read()
at LitJson.JsonMapper.ReadValue(WrapperFactory factory, JsonReader reader)
at LitJson.JsonMapper.ToObject(String json)
at tAPI_Builder.MainWindow.<>c__DisplayClass8.<BtnBuild_Click>b__0()
--- End of inner exception stack trace ---
at tAPI_Builder.MainWindow.<>c__DisplayClass8.<BtnBuild_Click>b__0()

and here's my code

{
"displayName": "King Slimes Sword",
"size": [32,32],
"value": [0,2,50,99],
"rare": 6,
"tooltip": "A sword for King Slime!",
"useStyle": 1,
"useAnimation": 16,
"useTime": 16,
"damage": 34,
"knockback": 7,
"useSound": 1,
"autoReuse": true,
"melee": true,
"recipes":
[{
"items": { "Gel": 200, "Gold Bar": 15, "Gold Crown": 1 },
"tiles": [ "Anvil" ],
"creates": 1
},
{
"items": { "Gel": 200, "Gold Bar": 15, "Platinum Crown": 1 },
"tiles": [ "Anvil" ],
"creates": 1
}]
}

please help!
 
Can you post the contents of your ModInfo.json file? This is saying you have a random capital F in there.
{
"internalName": "WM",
"displayName": " Wepon Mod",
"author: "Felix",
"info": "This mod adds Random Weapons like mage weapons, ranged weapons, melee weapons and even summoner stuff!!",
"version": "0.0.0"
}
 

Boffin

Brain of Cthulhu
{
"internalName": "WM",
"displayName": " Wepon Mod",
"author: "Felix",
"info": "This mod adds Random Weapons like mage weapons, ranged weapons, melee weapons and even summoner stuff!!",
"version": "0.0.0"
}

On the line "author: "Felix", you missed the speech mark after author. It should be "author": "Felix",
 
Top Bottom