shoelid
Terrarian
Hey! New to modding, and I'm posting here with the hope that somebody can help me with my code. I want my weapon to give the player a buff when they right click with it. The issue is that once the player right clicks with the sword, item.buffType is assigned to the entire item. From that point forward, both the left and right clicks assign the buff. How do I unassign item.buffType for the left click functionality? or maybe there's a better way to go about this?
Here's the relevant code:
C#:public override bool CanUseItem(Player player){ //right click functionality if (player.altFunctionUse == 2){ item.UseSound = SoundID.Item100;//placeholder item.useStyle = ItemUseStyleID.HoldingUp; item.useTime = 10;//placeholder item.useAnimation = 10;//placeholder item.noMelee = true; item.buffType = ModContent.BuffType<GhostbladeBuff>(); item.buffTime = 360; } else { item.UseSound = SoundID.Item1; item.useStyle = ItemUseStyleID.SwingThrow; item.useTime = 10; item.useAnimation = 25; item.noMelee = false; } return base.CanUseItem(player); }
UPDATE: I've since resolved this issue on my own. Instead of using
item.buffType = ModContent.BuffType<GhostbladeBuff>();
, I'm using item.buffType = mod.BuffType"GhostbladeBuff"
. This allows me to use item.buffType = mod.BuffType"";
to unassign the buff, fixing my issue.