tModLoader How do I make a weapon grant a buff on use?

MPDamageCap

Terrarian
I am having trouble making a beam weapon that grants a buff whenever it is being used. I tried adding this

override bool UseItem(Item item, Player player)
{
player.AddBuff(mod.BuffType("TestBuff"), 6000, false);
}

But I get a "no suitable method found to override". I'm not great at coding so I really don't know why this wouldn't work.
 
I would like to hear more about this, because I am trying to do the same thing. that link gave me a 404 though, so could you please give some other assistance?
 
Thanks! It's been a while, but I still needed this information so I appreciate it.
 
Help
I tried everything, but my weapon still doesn't give a buff.
Here's the weapon code:
1614359443419.png

And here's the buff code:
1614359465208.png

PLEASE HELP I CAN'T FIND ANYTHING
 
you need to have a bool that provides the buff information. don't put it in your weapon defaults.
 
Hey, so I want to make my weapon grant me a buff on hit that increases my weapon use speed. I know how to create buffs, but stuff like player.useTime *= 0.8f; doesn’t work.
Also is OnHitPlayer when you hit an enemy player, or is it when you hit an npc and you run the code within?
 
Back
Top Bottom