Right Click Functionality

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.
 
Screenshot 2024-06-02 091025.png
Screenshot 2024-06-02 091036.png
Screenshot 2024-06-02 091042.png

1. Left Click 2. Right click / interact 3.Left click again....
 
In CanUseItem, you are setting all the defaults to something on right click, but you are not setting them back for left click.
 
In CanUseItem, you are setting all the defaults to something on right click, but you are not setting them back for left click.
is there a way to disable shooting a projectile?
 
IIRC you can set shoot to ProjectileID.None
 
Back
Top Bottom