Use ModifyWeaponDamage hook
Hi, I'm barely starting on modding, and I wanted a weapon (4 sided dice that acts like spiky ball) that deals a random amount of damage. Is there any way you can help me? I also tried using virtual int Terraria.Utilities.UnifiedRandom.Next (int maxValue), but im not very proficient in c#, so i would really appreciate it if you could help me
This is my code
using LetsGoGambling.Content.Items.DamageClasses;
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Utilities;
using Humanizer;
virtual void LetsGoGambling.Content.ModifyWeaponDamage ( Player player,
ref StatModifier damage
)
namespace LetsGoGambling.Content.Items.Weapons // Item location
{
public class WoodenD4 : ModItem // Item name
{
public override void SetDefaults()
{
Item.shoot = ModContent.ProjectileType<Projectiles.WoodenD4Projectile>(); // Item spawns projectile
Item.DamageType = ModContent.GetInstance<Luckydamage>(); // Custom damage type
Item.width = 27; // Sprite lenght
Item.height = 39; // Sprite height
Item.useStyle = ItemUseStyleID.Swing; // The way the character uses the item
Use Style IDs
Item.useTime = 10; //Item frames of use
Item.useAnimation = 10; // Item animation
Item.autoReuse = true; // Item automatic or do you have to click again to use it
Item.damage = 1;
Item.knockBack = 1;
// Item.mana = 5; // ExampleDamageClass weapons should get magic and melee prefixes, but since this weapon doesn't have a mana cost all magic prefixes except Deranged can't be applied.
Item.crit = 6; //
Item.value = Item.buyPrice(0, 0, 0, 1); // Item price
Item.rare = ItemRarityID.White; // Item rarity
Rarity
Item.UseSound = SoundID.Item1; // Sound when used
Item.shootSpeed = 6; // Item projectile velocity
Item.noMelee = true; // Item not dealing damage while held, we don’t hit mobs in the head with a gun
}
public override void AddRecipes() { CreateRecipe().AddIngredient(ItemID.Wood, 8).AddTile(TileID.Anvils).Register(); }
}
}