private static void HandleAoeDamage(GameSession session, PacketReader packet) { List <IFieldObject <Mob> > mobs = new List <IFieldObject <Mob> >(); long skillSN = packet.ReadLong(); int unkValue = packet.ReadInt(); int playerObjectId = packet.ReadInt(); CoordF coords = packet.Read <CoordF>(); CoordF coords2 = packet.Read <CoordF>(); CoordF coords3 = packet.Read <CoordF>(); packet.ReadByte(); byte count = packet.ReadByte(); packet.ReadInt(); for (int i = 0; i < count; i++) { int entity = packet.ReadInt(); mobs.Add(session.FieldManager.State.Mobs.GetValueOrDefault(entity)); packet.ReadByte(); if (mobs[i] != null) { mobs[i].Value.UpdateStats(session.FieldPlayer.Value.SkillCast.GetDamage()); session.Send(StatPacket.UpdateMobStats(mobs[i])); } } session.Send(SkillDamagePacket.ApplyDamage(session.FieldPlayer, skillSN, unkValue, coords, mobs)); }
public override void Damage(DamageHandler damage, GameSession session) { base.Damage(damage, session); session.FieldManager.BroadcastPacket(StatPacket.UpdateMobStats(this)); if (IsDead) { HandleMobKill(session, this); } }
private static void HandleAoeDamage(GameSession session, PacketReader packet) { List <(IFieldObject <Mob>, DamageHandler)> mobs = new List <(IFieldObject <Mob>, DamageHandler)>(); long skillSN = packet.ReadLong(); int unkValue = packet.ReadInt(); int playerObjectId = packet.ReadInt(); CoordF coords = packet.Read <CoordF>(); CoordF coords2 = packet.Read <CoordF>(); CoordF coords3 = packet.Read <CoordF>(); packet.ReadByte(); byte count = packet.ReadByte(); packet.ReadInt(); bool isCrit = DamageHandler.RollCrit(session.Player.Stats[PlayerStatId.CritRate].Current); for (int i = 0; i < count; i++) { int entity = packet.ReadInt(); packet.ReadByte(); IFieldObject <Mob> mob = session.FieldManager.State.Mobs.GetValueOrDefault(entity); if (mob != null) { DamageHandler damage = DamageHandler.CalculateDamage(session.FieldPlayer.Value.SkillCast, session.FieldPlayer.Value, mob.Value, isCrit); mob.Value.Damage(damage.Damage); session.Send(StatPacket.UpdateMobStats(mob)); if (mob.Value.IsDead) { HandleMobKill(session, mob); } if (mob.Value.Id == 29000128) // Temp fix for tutorial barrier { session.Send("4F 00 03 E8 03 00 00 00 00 00 00 00 00 00 00 00 00 80 3F".ToByteArray()); session.Send("4F 00 03 D0 07 00 00 00 00 00 00 00 00 00 00 00 00 80 3F".ToByteArray()); session.Send("4F 00 08 01 04 01 00 00".ToByteArray()); } mobs.Add((mob, damage)); } } session.Send(SkillDamagePacket.ApplyDamage(skillSN, unkValue, coords, session.FieldPlayer, mobs)); }
private static void HandleAoeDamage(GameSession session, PacketReader packet) { List <IFieldObject <Mob> > mobs = new List <IFieldObject <Mob> >(); long skillSN = packet.ReadLong(); int unkValue = packet.ReadInt(); int playerObjectId = packet.ReadInt(); CoordF coords = packet.Read <CoordF>(); CoordF coords2 = packet.Read <CoordF>(); CoordF coords3 = packet.Read <CoordF>(); packet.ReadByte(); byte count = packet.ReadByte(); packet.ReadInt(); for (int i = 0; i < count; i++) { int entity = packet.ReadInt(); mobs.Add(session.FieldManager.State.Mobs.GetValueOrDefault(entity)); packet.ReadByte(); if (mobs[i] != null) { mobs[i].Value.UpdateStats(session.FieldPlayer.Value.SkillCast.GetDamage()); session.Send(StatPacket.UpdateMobStats(mobs[i])); // TODO: There needs to be a more centralized way to give rewards from killing mobs... // TODO: Add trophy, exp, meso and item drops if (mobs[i].Value.IsDead) { QuestHelper.UpdateQuest(session, mobs[i].Value.Id.ToString(), "npc"); } if (mobs[i].Value.Id == 29000128) // Temp fix for tutorial barrier { session.Send("4F 00 03 E8 03 00 00 00 00 00 00 00 00 00 00 00 00 80 3F".ToByteArray()); session.Send("4F 00 03 D0 07 00 00 00 00 00 00 00 00 00 00 00 00 80 3F".ToByteArray()); session.Send("4F 00 08 01 04 01 00 00".ToByteArray()); } } } session.Send(SkillDamagePacket.ApplyDamage(session.FieldPlayer, skillSN, unkValue, coords, mobs)); }
private void HandleAoeDamage(GameSession session, PacketReader packet) { List <IFieldObject <Mob> > mobs = new List <IFieldObject <Mob> >(); long skillUid = packet.ReadLong(); int someValue = packet.ReadInt(); int playerObjectId = packet.ReadInt(); CoordF coords = packet.Read <CoordF>(); CoordF coords2 = packet.Read <CoordF>(); CoordF coords3 = packet.Read <CoordF>(); packet.ReadByte(); byte count = packet.ReadByte(); packet.ReadInt(); for (int i = 0; i < count; i++) { mobs.Add(session.FieldManager.State.Mobs.GetValueOrDefault(packet.ReadInt())); packet.ReadByte(); session.Send(StatPacket.UpdateMobStats(mobs[i])); } session.Send(SkillDamagePacket.ApplyDamage(session.FieldPlayer, skillUid, someValue, coords, mobs)); }
private static void HandleDamage(GameSession session, PacketReader packet) { List <(IFieldObject <Mob>, DamageHandler)> mobs = new List <(IFieldObject <Mob>, DamageHandler)>(); long skillSN = packet.ReadLong(); int attackCounter = packet.ReadInt(); int playerObjectId = packet.ReadInt(); CoordF position = packet.Read <CoordF>(); CoordF impactPos = packet.Read <CoordF>(); CoordF rotation = packet.Read <CoordF>(); int attackPoint = packet.ReadByte(); byte count = packet.ReadByte(); packet.ReadInt(); bool isCrit = DamageHandler.RollCrit(session.Player.Stats[PlayerStatId.CritRate].Current); for (int i = 0; i < count; i++) { int entity = packet.ReadInt(); packet.ReadByte(); IFieldObject <Mob> mob = session.FieldManager.State.Mobs.GetValueOrDefault(entity); if (mob == null) { continue; } DamageHandler damage = DamageHandler.CalculateDamage(session.FieldPlayer.Value.SkillCast, session.FieldPlayer.Value, mob.Value, isCrit); mob.Value.Damage(damage.Damage); session.Send(StatPacket.UpdateMobStats(mob)); if (mob.Value.IsDead) { HandleMobKill(session, mob); } mobs.Add((mob, damage)); // TODO: Check if the skill is a debuff for an entity SkillCast skillCast = session.FieldPlayer.Value.SkillCast; if (skillCast.IsDebuffElement() || skillCast.IsDebuffToEntity() || skillCast.IsDebuffElement()) { Status status = new Status(session.FieldPlayer.Value.SkillCast, mob.ObjectId, session.FieldPlayer.ObjectId, 1); StatusHandler.Handle(session, status); } } // TODO: Verify if its the player or an ally if (session.FieldPlayer.Value.SkillCast.IsHeal()) { Status status = new Status(session.FieldPlayer.Value.SkillCast, session.FieldPlayer.ObjectId, session.FieldPlayer.ObjectId, 1); StatusHandler.Handle(session, status); // TODO: Heal based on stats session.FieldManager.BroadcastPacket(SkillDamagePacket.Heal(status, 50)); session.FieldPlayer.Value.Stats.Increase(PlayerStatId.Hp, 50); session.Send(StatPacket.UpdateStats(session.FieldPlayer, PlayerStatId.Hp)); } else { session.FieldManager.BroadcastPacket(SkillDamagePacket.Damage(skillSN, attackCounter, position, rotation, session.FieldPlayer, mobs)); } }
private static void HandleDamage(GameSession session, PacketReader packet) { long skillSN = packet.ReadLong(); int attackCounter = packet.ReadInt(); int playerObjectId = packet.ReadInt(); CoordF position = packet.Read <CoordF>(); CoordF impactPos = packet.Read <CoordF>(); CoordF rotation = packet.Read <CoordF>(); int attackPoint = packet.ReadByte(); byte count = packet.ReadByte(); packet.ReadInt(); IFieldActor <Player> fieldPlayer = session.Player.FieldPlayer; bool isCrit = DamageHandler.RollCrit(session.Player.Stats[StatId.CritRate].Total); // TODO: Check if skillSN matches server's current skill for the player // TODO: Verify if its the player or an ally if (fieldPlayer.SkillCast.IsHeal()) { Status status = new(fieldPlayer.SkillCast, fieldPlayer.ObjectId, fieldPlayer.ObjectId, 1); StatusHandler.Handle(session, status); // TODO: Heal based on stats session.FieldManager.BroadcastPacket(SkillDamagePacket.Heal(status, 50)); fieldPlayer.Stats[StatId.Hp].Increase(50); session.Send(StatPacket.UpdateStats(fieldPlayer, StatId.Hp)); } else { List <DamageHandler> damages = new(); for (int i = 0; i < count; i++) { int entityId = packet.ReadInt(); packet.ReadByte(); IFieldActor <NpcMetadata> mob = session.FieldManager.State.Mobs.GetValueOrDefault(entityId); if (mob == null) { continue; } DamageHandler damage = DamageHandler.CalculateDamage(fieldPlayer.SkillCast, fieldPlayer, mob, isCrit); mob.Damage(damage); // TODO: Move logic to Damage() session.FieldManager.BroadcastPacket(StatPacket.UpdateMobStats(mob)); if (mob.IsDead) { HandleMobKill(session, mob); } damages.Add(damage); // TODO: Check if the skill is a debuff for an entity SkillCast skillCast = fieldPlayer.SkillCast; if (skillCast.IsDebuffElement() || skillCast.IsDebuffToEntity() || skillCast.IsDebuffElement()) { Status status = new(fieldPlayer.SkillCast, mob.ObjectId, fieldPlayer.ObjectId, 1); StatusHandler.Handle(session, status); } } session.FieldManager.BroadcastPacket(SkillDamagePacket.Damage(skillSN, attackCounter, position, rotation, fieldPlayer, damages)); } }