melia
melia copied to clipboard
Buff System
Applying and removing (de)buffs, which are used in combination with skills, such as Heal. Need to be able to affect characters and monsters, run for a certain amount of time, and then get removed.
Currently being worked on in a branch by @SalmanTKhan.
I believe we need to discuss how exactly we'll implement the behavior of buffs. Originally, I figured the buff information would surely be stored in the IES files, in columns like PATK, MSPD, etc, and that the server would use those to modify the properties when a buff is activated or deactivated. After looking at the data more closely, however, I don't see a comprehensive list of stats and modifiers. Whether this data is server-only or they actually coded every single buff, we're lacking a list we could use. That means we'll either have to code them or add modifiers to the buff data.
Looking at how complicated the buffs can get, I believe it would be easier to code them, since they can be quite involved. There are quite a few that have special conditions and work differently in different situations. Describing this with JSON seems bothersome. Instead, I'd propose we create buff handlers similar to skill handlers, with Activate
and Deactivate
methods, so we can code the behavior of the buffs. It's a lot of buffs... but that would give us a lot of freedom for customizing them, since we could make them do anything.
I've written something similar for another server, for "conditions", which were very similar to buffs. The condition handlers had OnStart
, OnEnd
, and WhileActive
methods, to add the property modifiers, remove them, and potentially do something while the buff is active.
[ConditionScript(ConditionId.Berserk)]
public class BerserkConditionScript : ConditionScript
{
public override void OnStart(Character character, Condition condition)
{
character.Parameters.Modifiers.Add("Condition.Berserk", new MultiplyModifier(ModifierType.AttackMin, 2));
character.Parameters.Modifiers.Add("Condition.Berserk", new MultiplyModifier(ModifierType.AttackMax, 2));
character.Locks.AddSkillLock(SkillId.Defense);
}
public override void OnEnd(Character character, Condition condition)
{
character.Parameters.Modifiers.Remove("Condition.Berserk");
character.Locks.RemoveSkillLock(SkillId.Defense);
}
}
[ConditionScript(ConditionId.DeadlyPoison)]
public class DeadlyPoisonConditionScript : ConditionScript
{
public override void OnStart(Character character, Condition condition)
{
character.Regens.Add("Condition.DeadlyPoison", new Regen(ParameterType.Life, -10));
character.SyncParameters();
}
public override void OnEnd(Character character, Condition condition)
{
character.Regens.Remove("Condition.DeadlyPoison");
character.SyncParameters();
}
public override void WhileActive(Character character, Condition condition, TimeSpan elapsed)
{
if (character.Parameters.Life <= 0)
character.Kill();
}
}
The basic functionality has been implemented, but we aren't saving the buffs yet, which I'm sure some of them need. Others will need to be stopped on logout, which currently happens for all buffs. We will consider this issue completed once the basic functionality of applying buffs and disabling them when necessary is fully implemented.