Terraria Mod Creation (C#)


IT Manager / Video Game Modding and Development
Jun 4, 2019
Allen, Texas, United States
So I'm currently in development of a Terraria mod using tModLoader's system and I thought for any of you that play Modded Terraria, you may be interested.

It's a mod that pretty much adds everything imaginable. Guns, Swords, Pets, etc... My entire mod is crafted from scratch coded and put together using C# (C-Sharp). It has a custom crafting system implimented into every games code so if you get stuck on how to craft a gun, just look inside of the code for the specific gun, and look at the recipie on the bottom and it will tell you.

=Legend for all the code in case you want to know what everything means (Sorry everything is offset)=

ItemID.*** = The item it needs and the amount it needs to craft it.
TileID.*** = The station you stand next to to make the item. So if it says MythrilAnvil, you stand next to it to enable crafting for that item.
item.damage = 44; = How much damage per shot it does.
item.crit = 3; = Percentage of the Critical Strike chance.
item.ranged = true; = False means the gun is not ranged and is melee. It will not do ranged damage. True is for Guns, bows, and magic.
item.width = 90; = The width of the item.
item.height = 40; = The height of the item.
item.useAnimation = 16; = If the item has an animation, this is how long it takes to perform. Usually matches useTime variable.
item.useTime = 16; = How fast the item attacks, shoots, etc. Usually matches useAnimation variable.
item.reuseDelay = 0; = The delay of the useTime and useAnimation variables.
item.useStyle = 5; =
1- General swing/throw. Stuff like swords.
2- Eating/Using. Stuff like potions, food, healing items.
3- Stabbing. Shortswords
4- Holding up. Life crystals, summon items, etc.
5- Holding out. Guns, Spells, Drills, Chainsaws, Flails, and spears.
item.noMelee = true; = Enables if it's a Melee (Sword) or not.
item.knockBack = 5.00f; = How much knockback the weapon produces.
item.value = 195000; = Value of the items. 10000:1000:10:1 ratio = Copper:Silver:Gold:platinum coins
item.rare = 4; = Rarity of the item. Each number is a specific rarity that can be found on the Terraria WiKi.
item.UseSound = SoundID.Item40; = Self explanitory. What sound the item makes when it's used.
item.autoReuse = true; = If you can hold it down to attack or not. If not, it's manual attack.
item.shoot = 10; = Left as 10.
item.shootSpeed = 20f; = Left as 20f
item.scale = 0.85f; = Left as 0.85f
item.useAmmo = AmmoID.Bullet; = What it uses to shoot. Bullets, Mana, Health?

Currently, it only has 10 guns from realistic to fictional.

This is the code just one gun takes.

I'll be posting progress, and any issues I have just in case any of you know C#. Thanks, bye!

P.S. If any of you would like to try it out, I placed a Google Drive link to the download. Extract the compressed folder to: C:\Users\*USER*\Documents\My Games\Terraria\ModLoader\Mod Sources. When you enter your game, click 'Mod Sources', and click 'Build and Run'. What that does is it turns the file into a .tmod file so tModLoader can run it. Also, feel free to look at my code if you would like to understand what everything does, or want to learn yourself. I'd be happy to teach y'all if you want to learn it! :)

Download: Here (Google Drive link)
Download 2: Here (Gofile link)
Download 3 (Will expire in 30 days as of 6/7/19): Here (Uploadfiles link)
Last edited: