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

Bullet Maker's skills #307

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/Shared/Network/NormalOp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static class Zone
public const int Cutscene = 0x6B;
public const int SetSkillSpeed = 0x77;
public const int SetHitDelay = 0x78;
public const int UpdateNormalAttackSkill = 0x87;
public const int SpinObject = 0x8A;
public const int Unknown_A1 = 0xA1;
public const int LeapJump = 0xC2;
Expand Down
23 changes: 22 additions & 1 deletion src/ZoneServer/Buffs/Buff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Melia.Shared.Game.Const;
using Melia.Zone.Buffs.Base;
using Melia.Zone.World.Actors;
using Melia.Zone.World.Actors.CombatEntities.Components;
using Yggdrasil.Scheduling;
using Yggdrasil.Util;

Expand Down Expand Up @@ -168,7 +169,8 @@ public int OverbuffCounter
/// <param name="target"></param>
/// <param name="caster"></param>
/// <param name="skillId">Id of the skill associated with this buff.</param>
public Buff(BuffId buffId, float numArg1, float numArg2, TimeSpan duration, TimeSpan runTime, ICombatEntity target, ICombatEntity caster, SkillId skillId)
/// <param name="overBuffCount">OverBuff count, the quantity of stacking buffs</param>
public Buff(BuffId buffId, float numArg1, float numArg2, TimeSpan duration, TimeSpan runTime, ICombatEntity target, ICombatEntity caster, SkillId skillId, int overBuffCount = 1)
{
this.Id = buffId;
this.NumArg1 = numArg1;
Expand Down Expand Up @@ -209,6 +211,8 @@ public Buff(BuffId buffId, float numArg1, float numArg2, TimeSpan duration, Time

if (this.HasUpdateTime)
this.NextUpdateTime = DateTime.Now.Add(this.UpdateTime);

this.OverbuffCounter = overBuffCount;
}

/// <summary>
Expand All @@ -220,6 +224,15 @@ public void IncreaseOverbuff()
this.OverbuffCounter++;
}

/// <summary>
/// Update overbuff counter for a given value, capped to the buff's max overbuff
/// value.
/// </summary>
public void UpdateOverbuff(int value)
{
this.OverbuffCounter += value;
}

/// <summary>
/// Extends the buff's duration and executes the buff handler's start
/// behavior. Does not add the buff to the actor.
Expand Down Expand Up @@ -251,6 +264,14 @@ internal void End()
this.Handler?.OnEnd(this);
}

/// <summary>
/// Removes/Ends the Buff
/// </summary>
internal void Stop()
{
this.Target.Components.Get<BuffComponent>()?.Stop(this.Id);
}

/// <summary>
/// Updates the buff and handles effects that happen while the buff
/// is active.
Expand Down
39 changes: 39 additions & 0 deletions src/ZoneServer/Buffs/Handlers/Common/Freeze.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using Melia.Shared.Game.Const;
using Melia.Zone.Buffs.Base;
using Melia.Zone.Network;
using Melia.Zone.World.Actors.CombatEntities.Components;

namespace Melia.Zone.Buffs.Handlers.Common
{
/// <summary>
/// Handler for Freeze, which applies hold on the target
/// </summary>
[BuffHandler(BuffId.Freeze)]
public class Freeze : BuffHandler
{
/// <summary>
/// Starts buff
/// </summary>
/// <param name="buff"></param>
public override void OnStart(Buff buff)
{
var target = buff.Target;

if (target.Components.TryGet<MovementComponent>(out var movementComponent))
movementComponent.ApplyHold();
}

/// <summary>
/// Ends the buff
/// </summary>
/// <param name="buff"></param>
public override void OnEnd(Buff buff)
{
var target = buff.Target;

if (target.Components.TryGet<MovementComponent>(out var movementComponent))
movementComponent.ReleaseHold();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Melia.Shared.Game.Const;
using Melia.Zone.Buffs.Base;
using Melia.Zone.Network;
using Melia.Zone.World.Actors.Characters;

namespace Melia.Zone.Buffs.Handlers.Scouts.BulletMaker
{
/// <summary>
/// Handle for the Double Gun Stance Buff, enables movement while attacking
/// </summary>
[BuffHandler(BuffId.DoubleGunStance_Buff)]
public class DoubleGunStance_Buff : BuffHandler
{
public override void OnStart(Buff buff)
{
AddPropertyModifier(buff, buff.Target, PropertyName.MovingShot_BM, this.GetMovingShotBonus(buff));

buff.Target.Properties.Invalidate(PropertyName.MovingShotable);

if (buff.Target is Character character)
Send.ZC_MOVE_SPEED(character);
}

public override void OnEnd(Buff buff)
{
RemovePropertyModifier(buff, buff.Target, PropertyName.MovingShot_BM);

buff.Target.Properties.Invalidate(PropertyName.MovingShotable);

if (buff.Target is Character character)
Send.ZC_MOVE_SPEED(character);
}

private float GetMovingShotBonus(Buff buff)
{
return 0.8f;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
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.BulletMaker
{
/// <summary>
/// Handle for the FreezeBullet Cold Debuff, which freezes the enemy for 2 seconds upon reaching 4 stacks
/// </summary>
[BuffHandler(BuffId.FreezeBullet_Cold_Debuff)]
public class FreezeBullet_Cold_Debuff : BuffHandler
{
public override void OnStart(Buff buff)
{
if (!buff.Vars.GetBool("Slow_FreezeBullet_Cold_Debuff"))
{
var reduceMspd = buff.Target.Properties.GetFloat(PropertyName.MSPD) * 0.5f;

AddPropertyModifier(buff, buff.Target, PropertyName.MSPD_BM, -reduceMspd);
Send.ZC_MSPD(buff.Target);

buff.Vars.SetBool("Slow_FreezeBullet_Cold_Debuff", true);
}

if (buff.OverbuffCounter >= 4)
{
buff.Target.StartBuff(BuffId.Freeze, 0f, 0f, TimeSpan.FromSeconds(2), buff.Caster);
buff.Stop();
}
}

public override void OnEnd(Buff buff)
{
RemovePropertyModifier(buff, buff.Target, PropertyName.MSPD_BM);
Send.ZC_MSPD(buff.Target);
buff.Vars.SetBool("Slow_FreezeBullet_Cold_Debuff", false);
}
}
}
22 changes: 22 additions & 0 deletions src/ZoneServer/Buffs/Handlers/Scouts/BulletMaker/Tase_Debuff.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Melia.Shared.Game.Const;
using Melia.Zone.Buffs.Base;

namespace Melia.Zone.Buffs.Handlers.Scouts.BulletMaker
{
/// <summary>
/// Handle for the Tase Debuff, which makes the target receive additional Lightning Property damage when hit
/// </summary>
[BuffHandler(BuffId.Tase_Debuff)]
public class Tase_Debuff : BuffHandler
{
public override void OnStart(Buff buff)
{
// @TODO: Reduce the Lightning property resistance of the target
}

public override void OnEnd(Buff buff)
{
// @TODO: Increase the Lightning property resistance of the target
}
}
}
31 changes: 31 additions & 0 deletions src/ZoneServer/Network/Send.Normal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,37 @@ public static void UpdateCollection(Character character, int collectionId, int i

character.Connection.Send(packet);
}

/// <summary>
/// Updates the character normal attack stance attack
/// </summary>
/// <param name="entity"></param>
/// <param name="skillId"></param>
public static void UpdateNormalAttackSkill(ICombatEntity entity, SkillId skillId)
{
var packet = new Packet(Op.ZC_NORMAL);
packet.PutInt(NormalOp.Zone.UpdateNormalAttackSkill);

packet.PutInt(entity.Handle);
packet.PutInt((int)skillId);

entity.Map.Broadcast(packet, entity);
}

/// <summary>
/// Purpose unknown. Seems to enable smooth movement while normal attacking.
/// </summary>
/// <param name="entity"></param>
public static void Skill_45(ICombatEntity entity)
{
var packet = new Packet(Op.ZC_NORMAL);
packet.PutInt(NormalOp.Zone.Skill_45);

packet.PutInt(entity.Handle);
packet.PutByte(0);

entity.Map.Broadcast(packet, entity);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Melia.Zone.Network;
using Melia.Zone.Skills;
using Melia.Zone.World.Actors.Monsters;

namespace Melia.Zone.Pads.Handlers.Scout.Ardito
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Melia.Shared.Game.Const;
using Melia.Zone.Network;
using Melia.Zone.World.Actors;
using Melia.Zone.World.Actors.Monsters;

namespace Melia.Zone.Pads.Handlers.Scout.Ardito
{
/// <summary>
/// Handler for the Bullet Marker Freeze Bullet pad, creates and disables the effect
/// </summary>
[PadHandler(PadName.Bulletmarker_FreezeBullet)]
public class Bulletmarker_FreezeBullet : 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)
{
var pad = args.Trigger;
var creator = args.Creator;

Send.ZC_NORMAL.PadUpdate(creator, pad, PadName.Bulletmarker_FreezeBullet, 0, 72.30239f, 50, true);
}

/// <summary>
/// Called when the pad is destroyed.
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
public void Destroyed(object sender, PadTriggerArgs args)
{
var pad = args.Trigger;
var creator = args.Creator;

if (creator.TryGetSkill(SkillId.Bulletmarker_FreezeBullet, out var freezeSkill))
{
freezeSkill.Vars.SetBool("Pad_" + PadName.Bulletmarker_FreezeBullet, false);
}

Send.ZC_NORMAL.PadUpdate(creator, pad, PadName.Bulletmarker_FreezeBullet, 0, 72.30239f, 50, false);
}
}
}
Loading