This is Many
Retinazer
wait have you got C# installed on your computer?I seem to have done something wrong... in the C# file for my item, it has 23 errors, 12 of which are this: Predefined type 'System.Int32' is not defined or imported (CS0518)
wait have you got C# installed on your computer?I seem to have done something wrong... in the C# file for my item, it has 23 errors, 12 of which are this: Predefined type 'System.Int32' is not defined or imported (CS0518)
apparently as it turns out, it just installed .net 8.0.4. But also gives an errorwait have you got C# installed on your computer?
try following this guideapparently as it turns out, it just installed .net 8.0.4. But also gives an error View attachment 466737
I believe that error is what is causing the other errors to appear, but when I checked the mod within tModLoader, it actually worked as an item with no function (currently)
Could you attach an image of this. Because whenever I replace the 0 with Vector2.Zero it throws an error. So I am kind of confused..."Velocity X and Velocity Y of the dust, I set to 0 to prevent dust from moving"
It is moving because I forgot that it is vector
To prevent it from moving, replace 0 with Vector2.Zero
Sorry, my mistake. I changed that messageCould you attach an image of this. Because whenever I replace the 0 with Vector2.Zero it throws an error. So I am kind of confused...
Yes, example mod has some examples of animated tilesCan i make my item a placeable block? For example the silver ore(i think) you used as an example to be placeable and mineable?
Update: i created a sprite and animated it? Can i do that? (sorry for bad quality)
About f, it means that value is float" Item<span>.</span>knockBack <span>=</span> <span>6f</span><span>;</span>"
Sorry, I'm unfamiliarized with C#. Is the "f" required for every knockback value? (Kind of a stupid question but I'd like to know if it is required, and if not, what "f" changes)
EDIT: I believe I understand now. Does "f" indicate that the character in front of it is NOT a variable?
Note: Is there anything in the tutorial that tells us how to make a crafting recipe for our material (in my case, Rusted Scrap Metal)?
Right here for anyone who wants it:
public override void AddRecipes()
{
CreateRecipe()
.AddIngredient(ItemID.RustedScrapMetal, 12)
.AddIngredient(ItemID.IronBar, 2)
.AddTile(TileID.Anvils)
.Register();
}
though, I would like to add something. I can't seem to figure out what exactly works as "near water" in the recipes. Would it be Waterfall or Water_drip? Both don't seem right.
Ah, sorryAbout f, it means that value is float
About recipe, read tutorial properly
Abiut crafting condition, look up in visual studio, I believe there is something like .AddCondition(conditionid or whatever)
Dude, that is straight up explained in the tutorialHeya! Is there anything in this tutorial that mentions how to make a crafting recipe for my item?
For example, I'm wanting to make it so that I can make my Mod Item (RustedScrapMetal) by using an Iron Bar near water.
Introduction
Hi everyone! This tutorial will be about creating a simple item (material) and a sword.
Perhaps I'm exaggerating a little, starting with 2 objects at once, but for those who read the previous tutorial and, as advised there, learned C#, this won't be difficult.
And one very important anon - we will now make mod for 1.4.4, not for 1.4.3!!!
Let's go!
What are we going to study in this tutorial:
- How to create simple item
- How to create a sword that can poison enemy
How to create simple item
This item will be the material for all subsequent items that we will create.
First draw the sprite. The size of most materials in Terraria doesn't exceed 40x40px.
You can use any raster graphics editor, from Paint.net to Photoshop.
I'm using PikoPixel (only able on macOS) and Piskel.
So, create an item sprite. My will be 22x24px.
IMPORTANT: Default Terraria pixel is 2x2px in every graphics editor.
View attachment 414236
How it looks in game
View attachment 414237
Second, create a .cs file for your material code.
Put it here - ModSources/YourModName/Content/Items/Materials. It's optional but most of mods uses this path.
And then, put this code in it (// are explanations):
It isn't hard, is it?C#:// What libraries we use in the code using Terraria.ID; using Terraria.ModLoader; using Terraria.Localization; using Terraria.GameContent.Creative; namespace SteelMod.Content.Items.Materials // Where your code located { public class SteelShard : ModItem // Your item name (SteelShard) and type (ModItem) { public override void SetStaticDefaults() { CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 100; // How many items need for research in Journey Mode } public override void SetDefaults() { Item.width = 22; // Width of an item sprite Item.height = 24; // Height of an item sprite Item.maxStack = 9999; // How many items can be in one inventory slot Item.value = 100; // Item sell price in copper coins Item.rare = ItemRarityID.Blue; // The color of item's name in game. Check https://terraria.wiki.gg/wiki/Rarity } } }
Your first item is ready, congrats!
How to create a sword that can poison enemy
Sword is the simpliest weapon you can make, so we'll increase "risk and reward" - we will add poison effect to enemies we hit.
Also, we will emit poison themed dust when the sword is swing for better effect.
For the primary sword we need this code:
Oof, sweaty. But this is just a generic sword that swings and deals 50 melee damage.C#:using SteelMod.Content.Items.Materials; // Using our Materials folder using Terraria; using Terraria.GameContent.Creative; using Terraria.ID; using Terraria.ModLoader; namespace SteelMod.Content.Items.Weapons.Melee // Where is your code locates { public class SteelSword : ModItem { public override void SetStaticDefaults() { CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1; // How many items need for research in Journey Mode } public override void SetDefaults() { // Visual properties Item.width = 40; // Width of an item sprite Item.height = 40; // Height of an item sprite Item.scale = 1f; // Multiplicator of item size, for example is you set this to 2f our sword will be biger twice. IMPORTANT: If you are using numbers with floating point, write "f" in their end, like 1.5f, 3.14f, 2.1278495f etc. Item.rare = ItemRarityID.Blue; // The color of item's name in game. Check https://terraria.wiki.gg/wiki/Rarity // Combat properties Item.damage = 50; // Item damage Item.DamageType = DamageClass.Melee; // What type of damage item is deals, Melee, Ranged, Magic, Summon, Generic (takes bonuses from all damage multipliers), Default (doesn't take bonuses from any damage multipliers) // useTime and useAnimation often use the same value, but we'll see examples where they don't use the same values Item.useTime = 20; // How long the swing lasts in ticks (60 ticks = 1 second) Item.useAnimation = 20; // How long the swing animation lasts in ticks (60 ticks = 1 second) Item.knockBack = 6f; // How far the sword punches enemies, 20 is maximal value Item.autoReuse = true; // Can the item auto swing by holding the attack button // Other properties Item.value = 10000; // Item sell price in copper coins Item.useStyle = ItemUseStyleID.Swing; // This is how you're holding the weapon, visit https://terraria.wiki.gg/wiki/Use_Style_IDs for list of possible use styles Item.UseSound = SoundID.Item1; // What sound is played when using the item, all sounds can be found here - https://terraria.wiki.gg/wiki/Sound_IDs } // Creating item craft public override void AddRecipes() { Recipe recipe = CreateRecipe(); recipe.AddIngredient<SteelShard>(7); // We are using custom material for the craft, 7 Steel Shards recipe.AddIngredient(ItemID.Wood, 3); // Also, we are using vanilla material to craft, 3 Wood recipe.AddTile(TileID.Anvils); // Crafting station we need for craft, WorkBenches, Anvils etc. You can find them here - https://terraria.wiki.gg/wiki/Tile_IDs recipe.Register(); } } }
View attachment 414260
View attachment 414261
But we want to add some visuals (Dust) and combat advantages (Poison)
For Dust you need one more library:
C#:using Microsoft.Xna.Framework; // Using another one library
And some additional code:
Also, we want to add poison effect to this sword, so we need this code:C#:public override void MeleeEffects(Player player, Rectangle hitbox) { if (Main.rand.NextBool(3)) // With 1/3 chance per tick (60 ticks = 1 second)... { // ...spawning dust Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), // Position to spawn hitbox.Width, hitbox.Height, // Width and Height DustID.Poisoned, // Dust type. Check https://terraria.wiki.gg/wiki/Dust_IDs 0, 0, // Speed X and Speed Y of dust, it have some randomization 125); // Dust transparency, 0 - full visibility, 255 - full transparency } }
Full code of poisoning sword looks like that:C#:// What is happening on hitting living entity public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { if (Main.rand.NextBool(4)) // 1/4 chance, or 25% in other words { target.AddBuff(BuffID.Poisoned, // Adding Poisoned to target 300); // for 5 seconds (60 ticks = 1 second) } }
C#:using Microsoft.Xna.Framework; // Using another one library using SteelMod.Content.Items.Materials; // Using our Materials folder using Terraria; using Terraria.GameContent.Creative; using Terraria.ID; using Terraria.ModLoader; namespace SteelMod.Content.Items.Weapons.Melee // Where is your code locates { public class PoisonedSteelSword : ModItem { public override void SetStaticDefaults() { CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1; // How many items need for research in Journey Mode } public override void SetDefaults() { // Visual properties Item.width = 40; // Width of an item sprite Item.height = 40; // Height of an item sprite Item.scale = 1f; // Multiplicator of item size, for example is you set this to 2f our sword will be biger twice. IMPORTANT: If you are using numbers with floating point, write "f" in their end, like 1.5f, 3.14f, 2.1278495f etc. Item.rare = ItemRarityID.Blue; // The color of item's name in game. See https://terraria.wiki.gg/wiki/Rarity // Combat properties Item.damage = 50; // Item damage Item.DamageType = DamageClass.Melee; // What type of damage item is deals, Melee, Ranged, Magic, Summon, Generic (takes bonuses from all damage multipliers), Default (doesn't take bonuses from any damage multipliers) // useTime and useAnimation often use the same value, but we'll see examples where they don't use the same values Item.useTime = 20; // How long the swing lasts in ticks (60 ticks = 1 second) Item.useAnimation = 20; // How long the swing animation lasts in ticks (60 ticks = 1 second) Item.knockBack = 6f; // How far the sword punches enemies, 20 is maximal value Item.autoReuse = true; // Can the item auto swing by holding the attack button // Other properties Item.value = 10000; // Item sell price in copper coins Item.useStyle = ItemUseStyleID.Swing; // This is how you're holding the weapon, visit https://terraria.wiki.gg/wiki/Use_Style_IDs for list of possible use styles Item.UseSound = SoundID.Item1; // What sound is played when using the item, all sounds can be found here - https://terraria.wiki.gg/wiki/Sound_IDs } public override void MeleeEffects(Player player, Rectangle hitbox) { if (Main.rand.NextBool(3)) // Tik başına 1/3 şansla (60 tik = 1 saniye)... { // ...toz üreten Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), // Oluşturulacak pozisyon hitbox.Width, hitbox.Height, // Genişlik ve Yükseklik DustID.Poisoned, // Toz türü. https://terraria.wiki.gg/wiki/Dust_IDs adresini kontrol edin 0, 0, // Tozun Hızı X ve Hızı Y, bir miktar rastgeleliğe sahiptir 125); // Toz şeffaflığı, 0 - tam görünürlük, 255 - tam şeffaflık } } // Canlı bir varlığa çarpma durumunda neler oluyor? public override void OnHitNPC(Oyuncu oyuncu, NPC hedef, NPC.HitInfo hit, int damageDone) { if (Main.rand.NextBool(4)) // 1/4 şans veya başka bir deyişle %25 { target.AddBuff(BuffID.Poisoned, // Hedefe Poisoned ekleniyor 300); // 5 saniye boyunca (60 tik = 1 saniye) } } // Öğe zanaatı oluşturma genel geçersiz kılma void AddRecipes() { Tarif tarif = CreateRecipe(); recipe.AddIngredient<SteelShard>(7); // El sanatları için özel malzeme kullanıyoruz, 7 Çelik Parçası recipe.AddIngredient(ItemID.Wood, 3); // Ayrıca, 3 Wood üretmek için vanilya malzemesi kullanıyoruz recipe.AddIngredient(ItemID.JungleSpores, 5); // Craft'a bazı Jungle Spores ekledim recipe.AddTile(TileID.Anvils); // Craft için ihtiyacımız olan Crafting istasyonu, WorkBenches, Anvils vb. Bunları burada bulabilirsiniz - https://terraria.wiki.gg/wiki/Tile_IDs tarif.Kayıt(); } } }[/KOD] Evet, sonunda bu da bitti! [ATTACH type="full" alt="Ekran Görüntüsü 2023-07-13 22.41.34.png"]414266[/ATTACH] [SIZE=6][B]Bitiş[/B][/SIZE] [SIZE=4]Bu eğitimi okuyan herkese teşekkürler! Umarım yeni bir şeyler öğrenmişsinizdir. Ayrıca, bu kadar uzun bir eğitim beklediğim için özür dilerim. Herhangi bir sorunuz varsa sorun! Bir sonraki derste görüşmek üzere![/SIZE] [SIZE=6][COLOR=rgb(173, 173, 173)][SIZE=4][URL='https://forums.terraria.org/index.php?threads/modding-tutorial-1-basics.118751/']Önceki Eğitim[/URL] / [/SIZE][/COLOR][/SIZE][SIZE=6][SIZE=4][URL='https://forums.terraria.org/index.php?threads/modding-tutorial-3-some-more-weapons.135285/']Sonraki [/URL][/SIZE][SIZE=5][SIZE=4][URL='https://forums.terraria.org/index.php?threads/modding-tutorial-3-some-more-weapons.135285/']Eğitim[/URL][/SIZE][/SIZE][/SIZE][/CENTER] [/QUOTE]
just use notepad and name it <item name>.cs that's what I doI don't exactly know how to make a .CS fine sense I'm on windows 10, also do I need to use something like a website to make the .CS file?