Created
August 12, 2023 23:39
-
-
Save jdrews/c5fc3a8dbefd3fd61766551548671e4e to your computer and use it in GitHub Desktop.
Terraria Mod Sword
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Xna.Framework; | |
using Terraria; | |
using Terraria.ID; | |
using Terraria.ModLoader; | |
namespace DrewsSword.Items | |
{ | |
public class DrewSword : ModItem | |
{ | |
// The Display Name and Tooltip of this item can be edited in the Localization/en-US_Mods.DrewsSword.hjson file. | |
public override void SetDefaults() | |
{ | |
Item.damage = 100; | |
Item.DamageType = DamageClass.Melee; | |
Item.width = 40; | |
Item.height = 40; | |
Item.useTime = 10; | |
Item.useAnimation = 10; | |
Item.useStyle = 1; | |
Item.knockBack = 6; | |
Item.value = 10000; | |
Item.rare = 2; | |
Item.UseSound = SoundID.Item1; | |
Item.autoReuse = true; | |
} | |
public override void AddRecipes() | |
{ | |
Recipe recipe = CreateRecipe(); | |
recipe.AddIngredient(ItemID.DirtBlock, 10); | |
recipe.AddTile(TileID.WorkBenches); | |
recipe.Register(); | |
} | |
public override void MeleeEffects(Player player, Rectangle hitbox) | |
{ | |
if (Main.rand.NextBool(3)) | |
{ | |
// Emit dusts when the sword is swung | |
Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 74); | |
} | |
} | |
public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) | |
{ | |
// Inflict the OnFire debuff for 1 second onto any NPC/Monster that this hits. | |
// 60 frames = 1 second | |
target.AddBuff(BuffID.OnFire, 60); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A few useful links for the above
https://github.com/tModLoader/tModLoader/wiki/Basic-tModLoader-Modding-Guide
https://terraria.fandom.com/wiki/Dust_IDs
https://github.com/tModLoader/tModLoader/blob/1.4.4/ExampleMod/Content/Items/Weapons/ExampleSword.cs