public int[] GetBuff(CardType type, byte subtype) { int value1 = 0; int value2 = 0; foreach (BCard entry in StaticBcards.Concat(SkillBcards) .Where(s => s != null && s.Type.Equals((byte)type) && s.SubType.Equals(subtype))) { value1 += entry.IsLevelScaled ? entry.IsLevelDivided ? Level / entry.FirstData : entry.FirstData * Level : entry.FirstData; value2 += entry.SecondData; } foreach (Buff.Buff buff in Buffs) { foreach (BCard entry in buff.Card.BCards.Where(s => s.Type.Equals((byte)type) && s.SubType.Equals(subtype) && (s.CastType != 1 || s.CastType == 1 && buff.Start.AddMilliseconds(buff.Card.Delay * 100) < DateTime.Now))) { value1 += entry.IsLevelScaled ? entry.IsLevelDivided ? buff.Level / entry.FirstData : entry.FirstData * buff.Level : entry.FirstData; value2 += entry.SecondData; } } return(new[] { value1, value2 }); }
public bool HasBuff(CardType type, byte subtype, bool removeWeaponEffects = false) { if (removeWeaponEffects) { return(Buffs.Any(buff => buff.Card.BCards.Any(b => b.Type == (byte)type && b.SubType == subtype && (b.CastType != 1 || b.CastType == 1 && buff.Start.AddMilliseconds(buff.Card.Delay * 100) < DateTime.Now)))); } return(Buffs.Any(buff => buff.Card.BCards.Any(b => b.Type == (byte)type && b.SubType == subtype && (b.CastType != 1 || b.CastType == 1 && buff.Start.AddMilliseconds(buff.Card.Delay * 100) < DateTime.Now))) || StaticBcards.Any(s => s.Type.Equals((byte)type) && s.SubType.Equals(subtype))); }
private void TargetHit2(IBattleEntity target, TargetHitType hitType, Skill skill, int damage, int hitmode, short?skillEffect = null, short?mapX = null, short?mapY = null, ComboDTO skillCombo = null, bool showTargetAnimation = false, bool isPvp = false, bool isRange = false) { target.GetDamage(target.BattleEntity.IsReflecting ? 0 : target.DealtDamage, Entity, !(Session is MapMonster mon && mon.IsInvicible)); string str = $"su {(byte)Entity.SessionType()} {Entity.GetId()} {(byte)target.SessionType()} {target.GetId()} {skill?.SkillVNum ?? 0} {skill?.Cooldown ?? 0}"; switch (hitType) { case TargetHitType.SingleTargetHit: str += $" {skill?.AttackAnimation ?? 11} {skill?.Effect ?? skillEffect ?? 0} {Entity.GetPos().X} {Entity.GetPos().Y} {(target.CurrentHp > 0 ? 1 : 0)} {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {(target.BattleEntity.IsReflecting ? 0 : target.DealtDamage)} {hitmode} {skill?.SkillType - 1 ?? 0}"; break; case TargetHitType.SingleTargetHitCombo: str += $" {skillCombo?.Animation ?? 0} {skillCombo?.Effect ?? 0} {Entity.GetPos().X} {Entity.GetPos().Y} {(target.CurrentHp > 0 ? 1 : 0)} {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {(target.BattleEntity.IsReflecting ? 0 : target.DealtDamage)} {hitmode} {skill.SkillType - 1}"; break; case TargetHitType.SingleAOETargetHit: switch (hitmode) { case 1: hitmode = 4; break; case 3: hitmode = 6; break; default: hitmode = 5; break; } if (showTargetAnimation) { Entity.MapInstance.Broadcast( $" {skill?.AttackAnimation ?? 0} {skill?.Effect ?? 0} 0 0 {(target.CurrentHp > 0 ? 1 : 0)} {(int)(target.CurrentHp / (double)target.MaxHp * 100)} 0 0 {skill.SkillType - 1}"); } str += $" {skill?.AttackAnimation ?? 0} {skill?.Effect ?? 0} {Entity.GetPos().X} {Entity.GetPos().Y} {(target.CurrentHp > 0 ? 1 : 0)} {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {(target.BattleEntity.IsReflecting ? 0 : target.DealtDamage)} {hitmode} {skill.SkillType - 1}"; break; case TargetHitType.AOETargetHit: switch (hitmode) { case 1: hitmode = 4; break; case 3: hitmode = 6; break; default: hitmode = 5; break; } str += $" {skill?.AttackAnimation ?? 0} {skill?.Effect ?? 0} {Entity.GetPos().X} {Entity.GetPos().Y} {(target.CurrentHp > 0 ? 1 : 0)} {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {(target.BattleEntity.IsReflecting ? 0 : target.DealtDamage)} {hitmode} {skill.SkillType - 1}"; break; case TargetHitType.ZoneHit: str += $" {skill?.AttackAnimation ?? 0} {skillEffect ?? 0} {mapX ?? Entity.GetPos().X} {mapY ?? Entity.GetPos().Y} {(target.CurrentHp > 0 ? 1 : 0)} {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {(target.BattleEntity.IsReflecting ? 0 : target.DealtDamage)} 5 {skill.SkillType - 1}"; break; case TargetHitType.SpecialZoneHit: str += $" {skill?.AttackAnimation ?? 0} {skillEffect ?? 0} {Entity.GetPos().X} {Entity.GetPos().Y} {(target.CurrentHp > 0 ? 1 : 0)} {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {(target.BattleEntity.IsReflecting ? 0 : target.DealtDamage)} 0 {skill.SkillType - 1}"; break; } Entity.MapInstance.Broadcast(str); bool isBoss = false; if (Entity.GetSession() is Character character) { character.LastSkillUse = DateTime.Now; RemoveBuff(85); // Hideout } else if (Entity.GetSession() is Mate mate) { mate.LastSkillUse = DateTime.Now; } if (target.GetSession() is MapMonster monster) { if (monster.Target == null) { monster.LastSkill = DateTime.Now; } monster.Target = Entity; isBoss = monster.IsBoss; if (isBoss) { Entity.MapInstance?.Broadcast(monster.GenerateBoss()); } monster.DamageList.AddOrUpdate(Entity, damage, (key, oldValue) => oldValue + damage); } if (!isBoss && skill != null && hitmode != 1) { if ((target.BattleEntity.CostumeHatBcards == null || !target.BattleEntity.CostumeHatBcards.Any()) && target is Character targetCharacter) { var hat = targetCharacter.Inventory.LoadBySlotAndType <WearableInstance>((byte)EquipmentType.CostumeHat, InventoryType.Wear); hat?.Item.BCards.ForEach(s => target.BattleEntity.CostumeHatBcards.Add(s)); } if ((target.BattleEntity.CostumeSuitBcards == null || !target.BattleEntity.CostumeSuitBcards.Any()) && target is Character targetCharacter2) { var costume = targetCharacter2.Inventory.LoadBySlotAndType <WearableInstance>((byte)EquipmentType.CostumeHat, InventoryType.Wear); costume?.Item.BCards.ForEach(s => target.BattleEntity.CostumeSuitBcards.Add(s)); } foreach (BCard bcard in target.BattleEntity.CostumeSuitBcards.Where(s => s != null)) { switch ((CardType)bcard.Type) { case CardType.Buff: var b = new Buff.Buff(bcard.SecondData); switch (b.Card?.BuffType) { case BuffType.Bad: bcard.ApplyBCards(Entity, Entity); break; case BuffType.Good: case BuffType.Neutral: bcard.ApplyBCards(target, Entity); break; } break; } } foreach (BCard bcard in target.BattleEntity.CostumeSuitBcards.Where(s => s != null)) { switch ((CardType)bcard.Type) { case CardType.Buff: var b = new Buff.Buff(bcard.SecondData); switch (b.Card?.BuffType) { case BuffType.Bad: bcard.ApplyBCards(Entity, Entity); break; case BuffType.Good: case BuffType.Neutral: bcard.ApplyBCards(target, Entity); break; } break; } } foreach (BCard bc in StaticBcards.Where(s => s != null)) { switch ((CardType)bc.Type) { case CardType.Buff: var b = new Buff.Buff(bc.SecondData); switch (b.Card?.BuffType) { case BuffType.Bad: bc.ApplyBCards(target, Entity); break; case BuffType.Good: case BuffType.Neutral: bc.ApplyBCards(Entity, Entity); break; } break; } } foreach (BCard bcard in skill.BCards.Where(b => b != null)) { switch ((CardType)bcard.Type) { case CardType.Buff: var b = new Buff.Buff(bcard.SecondData); switch (b.Card?.BuffType) { case BuffType.Bad: bcard.ApplyBCards(target, Entity); break; case BuffType.Good: case BuffType.Neutral: bcard.ApplyBCards(Entity, Entity); break; } break; case CardType.HealingBurningAndCasting: switch ((AdditionalTypes.HealingBurningAndCasting)bcard.SubType) { case AdditionalTypes.HealingBurningAndCasting.RestoreHP: case AdditionalTypes.HealingBurningAndCasting.RestoreHPWhenCasting: bcard.ApplyBCards(Entity, Entity); break; default: bcard.ApplyBCards(target, Entity); break; } break; case CardType.MeditationSkill: bcard.ApplyBCards(Entity); break; default: bcard.ApplyBCards(target, Entity); break; } } } if (skill == null || skill.Range <= 0 && skill.TargetRange <= 0 || isRange || !(Entity.GetSession() is MapMonster)) { return; } foreach (IBattleEntity entitiesInRange in Entity.MapInstance ?.GetBattleEntitiesInRange(Entity.GetPos(), skill.TargetRange) .Where(e => e != target && e.IsTargetable(Entity.SessionType()))) { TargetHit2(entitiesInRange, TargetHitType.SingleTargetHit, skill, damage, hitmode, isRange: true); } }