How can I clear a certain buff from player? #3137
Replies: 5 comments 30 replies
-
|
Plugin can only apply buffs, not remove them. |
Beta Was this translation helpful? Give feedback.
-
|
You can't end the buff. (you could if ssc was enabled using a non documented packet). Your best option here is to apply the buff each few ticks with a duration of a second and then stop applying it. |
Beta Was this translation helpful? Give feedback.
-
|
There is a |
Beta Was this translation helpful? Give feedback.
-
|
Has your issue been resolved? @ALEX2014-git |
Beta Was this translation helpful? Give feedback.
-
|
The final solution that I used is a proposed idea to instead apply effect constantly and rely on it's timer to end instead of clearing it manually. Thanks everyone for discussion! public class Mod
{
///other methods here, such as mod ctor and initialization, afk flag is set and revoked via chat command
public override void Initialize()
{
On.Terraria.Player.Update += Player_Update;
}
private void Player_Update(On.Terraria.Player.orig_Update orig, Player self, int i)
{
orig(self, i);
if (self.GetCustomData().isAFK)
{
if (self.GetCustomData().afkDebuffCooldown <= 0)
{
TShock.Players[self.whoAmI].SetBuff(BuffID.Webbed, 30);
self.GetCustomData().afkDebuffCooldown = 25;
}
self.GetCustomData().afkDebuffCooldown--;
}
}
}
public static class PlayerCWT
{
static ConditionalWeakTable<Player, Data> table = new ConditionalWeakTable<Player, Data>();
public static Data GetCustomData(this Player self) => table.GetOrCreateValue(self);
public class Data
{
public bool isAFK;
public int afkDebuffCooldown;
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to clear a certain buff from player inside my command method.
Currently I have this code that successfully applies debuff for default duration of a minute.
This works, when executed targeted players gets webbed for 1 minute.
But then I want to be able to prematurely end it.
I tried this commands
None can do the trick. Buff will never get cleared or sets up to 1 tick.
How can I achieve my desired action?
I'm new to Terraria Modding, never used tModLoader, but I have experience of Unity modding and C# native hooks.
(Also, on a side note, when I tried to use
It didn't do anything, I assume this has to do with networking stuff, but I'm curios how can I use
Terrariamethods via TShock plugin and can I even?)Beta Was this translation helpful? Give feedback.
All reactions