Km_Null
Terrarian
So...
I found myself making mods for terraria and have encountered an error, I've tried to make a weapon with similar functions as the sky dragons fury (two different attacks on two key binds) however, whenever right click is hit, anything that was set to right click only, now appears on left click, here's the code (used an example test mod);
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
using Terraria.Audio;
using System.Collections.Generic;
using Terraria.DataStructures;
using DualWepTEst.Projectile;
namespace DualWepTEst.Content.Items
{
public class DualWep : ModItem
{
public override bool AltFunctionUse(Player player)
{
return true;
}
public override bool CanUseItem(Player player)
{
Item.useTurn = true;
if (player.altFunctionUse == 0) //Only use value 2 for right-click functionality
{
Item.useTime = 20;
Item.useAnimation = 20;
Item.autoReuse = true;
Item.DamageType = DamageClass.Melee;
Item.damage = 50;
Item.knockBack = 6;
Item.crit = 6;
return true;
}
else {
Item.shoot = ModContent.ProjectileType<TestProjectile>();
Item.autoReuse = false;
return true;
}
}
public override void SetDefaults()
{
Item.useStyle = ItemUseStyleID.Swing;
Item.width = 26;
Item.height = 42;
Item.value = Item.buyPrice(gold: 5);
Item.rare = ItemRarityID.Pink;
Item.UseSound = SoundID.Item1;
}
public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.AddTile(TileID.WorkBenches);
recipe.Register();
}
}
}
I have no idea why it doesn't work, but I hope someone will.
I found myself making mods for terraria and have encountered an error, I've tried to make a weapon with similar functions as the sky dragons fury (two different attacks on two key binds) however, whenever right click is hit, anything that was set to right click only, now appears on left click, here's the code (used an example test mod);
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
using Terraria.Audio;
using System.Collections.Generic;
using Terraria.DataStructures;
using DualWepTEst.Projectile;
namespace DualWepTEst.Content.Items
{
public class DualWep : ModItem
{
public override bool AltFunctionUse(Player player)
{
return true;
}
public override bool CanUseItem(Player player)
{
Item.useTurn = true;
if (player.altFunctionUse == 0) //Only use value 2 for right-click functionality
{
Item.useTime = 20;
Item.useAnimation = 20;
Item.autoReuse = true;
Item.DamageType = DamageClass.Melee;
Item.damage = 50;
Item.knockBack = 6;
Item.crit = 6;
return true;
}
else {
Item.shoot = ModContent.ProjectileType<TestProjectile>();
Item.autoReuse = false;
return true;
}
}
public override void SetDefaults()
{
Item.useStyle = ItemUseStyleID.Swing;
Item.width = 26;
Item.height = 42;
Item.value = Item.buyPrice(gold: 5);
Item.rare = ItemRarityID.Pink;
Item.UseSound = SoundID.Item1;
}
public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.AddTile(TileID.WorkBenches);
recipe.Register();
}
}
}
I have no idea why it doesn't work, but I hope someone will.