Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the rest of Assassin's Skills and Abilities #334

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Melia.Shared.Game.Const;
using Melia.Zone.Buffs.Base;
using Melia.Zone.Network;
using Melia.Zone.World.Actors;
using Melia.Zone.World.Actors.Characters;

namespace Melia.Zone.Buffs.Handlers.Scouts.Assassin
{
/// <summary>
/// Handler for Assassin Target debuff, which can only
/// be applied to a single target and needs to clean
/// itself up when it ends
/// </summary>
[BuffHandler(BuffId.Assassin_Target_Debuff)]
internal class Assassin_Target_Debuff : BuffHandler
{
/// <summary>
/// Remove the variable from the caster when the buff ends,
/// assuming this entity is still the target
/// </summary>
/// <param name="buff"></param>
public override void OnEnd(Buff buff)
{
var targetHandle = buff.Target.Handle;
var caster = buff.Caster;
if (caster is Character character && character != null && character.Variables.Temp.TryGetInt("Melia.AssassinationTarget", out var assassinationTarget) && assassinationTarget == targetHandle)
character.Variables.Temp.Remove("Melia.AssassinationTarget");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Melia.Shared.Game.Const;
using Melia.Zone.Buffs.Base;
using Melia.Zone.Network;
using Melia.Zone.World.Actors;

namespace Melia.Zone.Buffs.Handlers.Scouts.Assassin
{
/// <summary>
/// Handler for Hallucination Smoke Buff, which raises crit rate
/// </summary>
/// <remarks>
/// NumArg1: Skill Level
/// NumArg2: Unused
/// </remarks>
[BuffHandler(BuffId.HallucinationSmoke_Buff)]
internal class HallucinationSmoke_Buff : BuffHandler
{
// Official bonus rate is unknown
private const float CRTHRBonus = 0.2f;

/// <summary>
/// Starts buff, increasing Crit Rate
/// </summary>
/// <param name="buff"></param>
public override void OnActivate(Buff buff, ActivationType activationType)
{
var CRTHRbuff = buff.Target.Properties.GetFloat(PropertyName.CRTHR) * CRTHRBonus;

AddPropertyModifier(buff, buff.Target, PropertyName.CRTHR_BM, CRTHRbuff);
}

/// <summary>
/// Ends the buff, resetting crit rate
/// </summary>
/// <param name="buff"></param>
public override void OnEnd(Buff buff)
{
RemovePropertyModifier(buff, buff.Target, PropertyName.CRTHR_BM);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Melia.Shared.Game.Const;
using Melia.Zone.Buffs.Base;
using Melia.Zone.Network;
using Melia.Zone.World.Actors;

namespace Melia.Zone.Buffs.Handlers.Scouts.Assassin
{
/// <summary>
/// Handler for Hallucination Smoke Debuff, which reduces
/// Accuracy and Evasion
/// </summary>
/// <remarks>
/// NumArg1: Skill Level
/// NumArg2: Damage to take when buff ends
/// </remarks>
[BuffHandler(BuffId.HallucinationSmoke_Debuff)]
internal class HallucinationSmoke_Debuff : BuffHandler
{
private const float DRPenaltyRate = 0.2f;
private const float HRPenaltyRate = 0.2f;

/// <summary>
/// Starts buff, reducing Hit and Dodge Rate
/// </summary>
/// <param name="buff"></param>
public override void OnActivate(Buff buff, ActivationType activationType)
{
var reduceDR = buff.Target.Properties.GetFloat(PropertyName.DR) * DRPenaltyRate;
var reduceHR = buff.Target.Properties.GetFloat(PropertyName.HR) * HRPenaltyRate;

AddPropertyModifier(buff, buff.Target, PropertyName.DR_BM, -reduceDR);
AddPropertyModifier(buff, buff.Target, PropertyName.HR_BM, -reduceHR);
}

/// <summary>
/// Ends the buff, resetting hit and dodge rate, and
/// potentially dealing damage
/// </summary>
/// <param name="buff"></param>
public override void OnEnd(Buff buff)
{
RemovePropertyModifier(buff, buff.Target, PropertyName.DR_BM);
RemovePropertyModifier(buff, buff.Target, PropertyName.HR_BM);

if (buff.NumArg2 > 0 && !buff.Target.IsDead)
{
var attacker = buff.Caster;
var target = buff.Target;
var damage = buff.NumArg2;

target.TakeSimpleHit(damage, attacker, SkillId.None);
}
}
}
}
33 changes: 33 additions & 0 deletions src/ZoneServer/Buffs/Handlers/Scouts/Assassin/Hasisas_Buff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ namespace Melia.Zone.Buffs.Handlers.Scouts.Assassin
/// <summary>
/// Handle for the Hasisas Buff, which increases the target's Attack speed and Crit damage
/// </summary>
/// <remarks>
/// NumArg1: Skill Level
/// NumArg2: 1 if the evasion bonus is applied
/// </remarks>
[BuffHandler(BuffId.Hasisas_Buff)]
public class Hasisas_Buff : BuffHandler
{
private const float AspdBonusBase = 155;
private const float AspdBonusPerLevel = 20;
private const float CritBonusBase = 3f;
private const float CritBonusPerLevel = 1.5f;
private const float DRBonusBase = 0.2f;
private const float HpLossRate = 0.01f;

public override void OnActivate(Buff buff, ActivationType activationType)
Expand All @@ -23,12 +28,22 @@ public override void OnActivate(Buff buff, ActivationType activationType)

AddPropertyModifier(buff, buff.Target, PropertyName.ASPD_BM, aspdBonus);
AddPropertyModifier(buff, buff.Target, PropertyName.CRTATK_BM, critBonus);

buff.Vars.SetInt("Hasisas.TickCounter", 0);

if (buff.NumArg2 > 0)
{
var drBonus = buff.Target.Properties.GetFloat(PropertyName.DR) * DRBonusBase;

AddPropertyModifier(buff, buff.Target, PropertyName.DR_BM, drBonus);
}
}

public override void OnEnd(Buff buff)
{
RemovePropertyModifier(buff, buff.Target, PropertyName.ASPD_BM);
RemovePropertyModifier(buff, buff.Target, PropertyName.CRTATK_BM);
RemovePropertyModifier(buff, buff.Target, PropertyName.DR_BM);
}

public override void WhileActive(Buff buff)
Expand All @@ -46,6 +61,24 @@ private void ReduceHp(Buff buff)
if (Feature.IsEnabled("HasisasNoHpLoss"))
return;

// Assassin2 increases the number of ticks before you take
// damage. This is done using a counter in a buff variable.
// The tick limit is set when applying the buff
var tickCounter = buff.Vars.GetInt("Hasisas.TickCounter");
tickCounter++;

if (tickCounter > buff.Vars.GetInt("Hasisas.TickLimit"))
{
// reset the counter and continue
buff.Vars.SetInt("Hasisas.TickCounter", 0);
}
else
{
// update the counter and return
buff.Vars.SetInt("Hasisas.TickCounter", tickCounter);
return;
}

// The description stats an HP loss of 1% per 10 seconds,
// which matches the buff's update time. Should a user
// change it, the description would no longer be accurate,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Melia.Shared.Game.Const;
using Melia.Zone.Buffs.Base;
using Melia.Zone.Network;
using Melia.Zone.World.Actors;

namespace Melia.Zone.Buffs.Handlers.Scouts.Assassin
{
/// <summary>
/// Handler for Piercing Heart Buff, which raises crit rate
/// </summary>
/// <remarks>
/// NumArg1: Skill Level
/// NumArg2: Unused
/// </remarks>
[BuffHandler(BuffId.PiercingHeart_Buff)]
internal class PiercingHeart_Buff : BuffHandler
{
// Official bonus rate is unknown
private const float CRTHRBonus = 0.5f;

/// <summary>
/// Starts buff, increasing Crit Rate
/// </summary>
/// <param name="buff"></param>
public override void OnActivate(Buff buff, ActivationType activationType)
{
var CRTHRbuff = buff.Target.Properties.GetFloat(PropertyName.CRTHR) * CRTHRBonus;

AddPropertyModifier(buff, buff.Target, PropertyName.CRTHR_BM, CRTHRbuff);
}

/// <summary>
/// Ends the buff, resetting crit rate
/// </summary>
/// <param name="buff"></param>
public override void OnEnd(Buff buff)
{
RemovePropertyModifier(buff, buff.Target, PropertyName.CRTHR_BM);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using Melia.Shared.Game.Const;
using Melia.Zone.Buffs.Base;
using Melia.Zone.World.Actors;

namespace Melia.Zone.Buffs.Handlers.Scout.Assassin
{
/// <summary>
/// Handle for the Piercing Heart debuff, which prevents healing
/// </summary>
[BuffHandler(BuffId.PiercingHeart_Debuff)]
public class PiercingHeart_Debuff : BuffHandler
{
/// <summary>
/// Eliminates all healing if the entity has the piercing heart debuff.
/// </summary>
/// <param name="entity"></param>
/// <param name="hpAmount"></param>
/// <returns></returns>
public static bool TryApply(ICombatEntity entity, ref float hpAmount)
{
if (!entity.TryGetBuff(BuffId.PiercingHeart_Debuff, out var buff))
return false;

hpAmount = 0;

return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Threading.Tasks;
using Melia.Shared.Game.Const;
using Melia.Shared.World;
using Melia.Zone.Network;
using Melia.Zone.World.Actors;
using Melia.Zone.World.Actors.Characters;
using Melia.Zone.World.Actors.CombatEntities.Components;
using Melia.Zone.World.Actors.Monsters;
using Melia.Zone.World.Actors.Pads;
using Yggdrasil.Logging;

namespace Melia.Zone.Pads.Handlers.Scout.Assassin
{
/// <summary>
/// Handler for the Assassin HallucinationSmoke pad,
/// which displays a smoke cloud
/// </summary>
[PadHandler(PadName.Assassin_HallucinationSmoke)]
public class Assassin_HallucinationSmoke : ICreatePadHandler, IDestroyPadHandler
{
/// <summary>
/// Called when the pad is created.
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
public void Created(object sender, PadTriggerArgs args)
{
Send.ZC_NORMAL.PadUpdate(args.Creator, args.Trigger, PadName.Assassin_HallucinationSmoke, -0.7853982f, 0, 30, true);
}

/// <summary>
/// Called when the pad is destroyed.
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
public void Destroyed(object sender, PadTriggerArgs args)
{
Send.ZC_NORMAL.PadUpdate(args.Creator, args.Trigger, PadName.Assassin_HallucinationSmoke, 0, 145.8735f, 30, false);
}
}
}
8 changes: 8 additions & 0 deletions src/ZoneServer/Skills/Combat/SkillModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ public class SkillModifier
/// </remarks>
public float DamageMultiplier { get; set; } = 1;

/// <summary>
/// Gets or sets the Crit Rate multiplier
/// </summary>
/// <remarks>
/// This is applied before anything else that modifies crit rate
/// </remarks>
public float CritRateMultiplier { get; set; } = 1;

/// <summary>
/// Gets or sets the minimum critical chance.
/// </summary>
Expand Down
Loading