public static void PvE(Player Attacker, TerrainNPC Target) { try { if (!Attacker.IsAlive()) { Attacker.IsInBattle = false; return; } if (Target == null || !Target.IsAlive()) { Attacker.IsInBattle = false; return; } if (Attacker.Map != Target.Map) { Attacker.IsInBattle = false; return; } if (!MyMath.CanSee(Attacker.X, Attacker.Y, Target.X, Target.Y, (Attacker.AtkRange + 1))) { Attacker.IsInBattle = false; return; } if (Battle.WeaponSkill(Attacker, Target)) { return; } Attacker.LastAttackTick = Environment.TickCount; if (!MyMath.Success(Attacker.Dexterity)) { World.BroadcastMapMsg(Attacker, new MsgInteract(Attacker, Target, 0, (MsgInteract.Action)Attacker.AtkType), true); return; } Int32 Damage = 0; Damage = MyMath.GetDamagePlayer2Environment(Attacker, Target); if (Attacker.Map.Id != 1039) { Attacker.RemoveAtkDura(); } World.BroadcastMapMsg(Attacker, new MsgInteract(Attacker, Target, Damage, MsgInteract.Action.Attack), true); if (Damage >= Target.CurHP) { if (Attacker.XP < 99) { Attacker.XP++; } Target.GetAttacked(Attacker, Target.CurHP); Int32 CurHP = Target.CurHP; World.BroadcastMapMsg(Attacker, new MsgInteract(Attacker, Target, 1, MsgInteract.Action.Kill), true); Target.Die(); if (Target.Type == 21 || Target.Type == 22) { UInt32 Exp = AdjustExp(CurHP, Attacker, Target); Attacker.AddExp(Exp, true); Int32 Bonus = (Int32)(Target.MaxHP * 0.05); UInt32 BonusExp = AdjustExp(Bonus, Attacker, Target); Attacker.AddExp(BonusExp, true); Item RightHand = Attacker.GetItemByPos(4); if (RightHand != null && ((RightHand.Type / 100000) == 4 || (RightHand.Type / 100000) == 5)) { Attacker.AddWeaponSkillExp((UInt16)(RightHand.Type / 1000), Exp); } else if (RightHand == null) { Attacker.AddWeaponSkillExp(0, Exp); } Item LeftHand = Attacker.GetItemByPos(5); if (LeftHand != null && ((LeftHand.Type / 100000) == 4 || (LeftHand.Type / 100000) == 9)) { Attacker.AddWeaponSkillExp((UInt16)(LeftHand.Type / 1000), Exp); } } else if (Target.Type == (Byte)TerrainNPC.NpcType.SynFlag) { if (Attacker.Syndicate != null) { // TODO re-enable donation gain on pole //if (Attacker.Map.InWar) // if (Attacker.Syndicate.Id != Attacker.Map.Holder) // { // Attacker.Money += (UInt32)(Damage / 10000); // Attacker.Send(new MsgUserAttrib(Attacker, Attacker.Money, MsgUserAttrib.AttributeType.Money)); // Syndicate.Member Member = Attacker.Syndicate.GetMemberInfo(Attacker.UniqId); // if (Member != null) // { // Member.Donation += (UInt32)(Damage / 10000); // Attacker.Syndicate.Money += (UInt32)(Damage / 10000); // Attacker.Send(new MsgSynAttrInfo(Attacker.UniqId, Attacker.Syndicate)); // } // } } } } else { Target.CurHP -= Damage; Target.GetAttacked(Attacker, Damage); if (Target.Type == 21 || Target.Type == 22) { UInt32 Exp = AdjustExp(Damage, Attacker, Target); Attacker.AddExp(Exp, true); Item RightHand = Attacker.GetItemByPos(4); if (RightHand != null && ((RightHand.Type / 100000) == 4 || (RightHand.Type / 100000) == 5)) { Attacker.AddWeaponSkillExp((UInt16)(RightHand.Type / 1000), Exp); } else if (RightHand == null) { Attacker.AddWeaponSkillExp(0, Exp); } Item LeftHand = Attacker.GetItemByPos(5); if (LeftHand != null && ((LeftHand.Type / 100000) == 4 || (LeftHand.Type / 100000) == 9)) { Attacker.AddWeaponSkillExp((UInt16)(LeftHand.Type / 1000), Exp); } } else if (Target.Type == (Byte)TerrainNPC.NpcType.SynFlag) { if (Attacker.Syndicate != null) { // TODO re-enable donation gain on pole //if (Attacker.Map.InWar) // if (Attacker.Syndicate.Id != Attacker.Map.Holder) // { // Attacker.Money += (UInt32)(Target.CurHP / 10000); // Attacker.Send(new MsgUserAttrib(Attacker, Attacker.Money, MsgUserAttrib.AttributeType.Money)); // Syndicate.Member Member = Attacker.Syndicate.GetMemberInfo(Attacker.UniqId); // if (Member != null) // { // Member.Donation += (UInt32)(Target.CurHP / 10000); // Attacker.Syndicate.Money += (UInt32)(Target.CurHP / 10000); // Attacker.Send(new MsgSynAttrInfo(Attacker.UniqId, Attacker.Syndicate)); // } // } } } } if (Attacker.Map.Id != 1039) { Battle.WeaponAttribute(Attacker, Target); } } catch (Exception exc) { sLogger.Error(exc); } }
public static void PvM(Player Attacker, Monster Target) { try { if (!Attacker.IsAlive()) { Attacker.IsInBattle = false; return; } if (Target == null || !Target.IsAlive()) { Attacker.IsInBattle = false; return; } if (Attacker.Map != Target.Map) { Attacker.IsInBattle = false; return; } if (!MyMath.CanSee(Attacker.X, Attacker.Y, Target.X, Target.Y, (Attacker.AtkRange + 1))) { Attacker.IsInBattle = false; return; } if (!CanAttack(Attacker, Target)) { Attacker.IsInBattle = false; return; } if (Battle.WeaponSkill(Attacker, Target)) { return; } Attacker.LastAttackTick = Environment.TickCount; if (!MyMath.Success(Attacker.Dexterity)) { World.BroadcastMapMsg(Attacker, new MsgInteract(Attacker, Target, 0, (MsgInteract.Action)Attacker.AtkType), true); return; } Int32 Damage = 0; Damage = MyMath.GetDamagePlayer2Monster(Attacker, Target); if (Attacker.Map.Id != 1039) { Attacker.RemoveAtkDura(); } World.BroadcastMapMsg(Attacker, new MsgInteract(Attacker, Target, Damage, MsgInteract.Action.Attack), true); if ((Byte)(Target.Id / 100) == 9) { Attacker.AttachStatus(Status.Crime, 25000); } if (Damage >= Target.CurHP) { if (Attacker.XP < 99) { Attacker.XP++; } StatusEffect effect; if (Attacker.GetStatus(Status.SuperSpeed, out effect)) { effect.IncreaseDuration(820); ++Attacker.CurKO; } if (Attacker.GetStatus(Status.SuperAtk, out effect)) { effect.IncreaseDuration(820); ++Attacker.CurKO; } Int32 CurHP = Target.CurHP; Target.Die(Attacker.UniqId); if (Attacker.HasStatus(Status.SuperAtk) || Attacker.HasStatus(Status.SuperSpeed)) { World.BroadcastMapMsg(Attacker, new MsgInteract(Attacker, Target, 0xFFFF * (Attacker.CurKO + 1), MsgInteract.Action.Kill), true); } else { World.BroadcastMapMsg(Attacker, new MsgInteract(Attacker, Target, 1, MsgInteract.Action.Kill), true); } UInt32 Exp = AdjustExp(CurHP, Attacker, Target); Attacker.AddExp(Exp, true); Int32 Bonus = (Int32)(Target.MaxHP * 0.05); if (Attacker.Team != null) { Attacker.Team.AwardMemberExp(Attacker, Target, Bonus); } UInt32 BonusExp = AdjustExp(Bonus, Attacker, Target); Attacker.AddExp(BonusExp, true); Attacker.SendSysMsg(StrRes.STR_KILL_EXPERIENCE, BonusExp); Item RightHand = Attacker.GetItemByPos(4); if (RightHand != null && ((RightHand.Type / 100000) == 4 || (RightHand.Type / 100000) == 5)) { Attacker.AddWeaponSkillExp((UInt16)(RightHand.Type / 1000), Exp); } else if (RightHand == null) { Attacker.AddWeaponSkillExp(0, Exp); } Item LeftHand = Attacker.GetItemByPos(5); if (LeftHand != null && ((LeftHand.Type / 100000) == 4 || (LeftHand.Type / 100000) == 9)) { Attacker.AddWeaponSkillExp((UInt16)(LeftHand.Type / 1000), Exp); } } else { Target.CurHP -= Damage; UInt32 Exp = AdjustExp(Damage, Attacker, Target); Attacker.AddExp(Exp, true); Item RightHand = Attacker.GetItemByPos(4); if (RightHand != null && ((RightHand.Type / 100000) == 4 || (RightHand.Type / 100000) == 5)) { Attacker.AddWeaponSkillExp((UInt16)(RightHand.Type / 1000), Exp); } else if (RightHand == null) { Attacker.AddWeaponSkillExp(0, Exp); } Item LeftHand = Attacker.GetItemByPos(5); if (LeftHand != null && ((LeftHand.Type / 100000) == 4 || (LeftHand.Type / 100000) == 9)) { Attacker.AddWeaponSkillExp((UInt16)(LeftHand.Type / 1000), Exp); } } if (Attacker.Map.Id != 1039) { Battle.WeaponAttribute(Attacker, Target); } } catch (Exception exc) { sLogger.Error(exc); } }
public static void PvP(Player Attacker, Player Target) { try { if (!Attacker.IsAlive()) { Attacker.IsInBattle = false; return; } if (Target == null || !Target.IsAlive()) { Attacker.IsInBattle = false; return; } if (Attacker.Map != Target.Map) { Attacker.IsInBattle = false; return; } if (!MyMath.CanSee(Attacker.X, Attacker.Y, Target.X, Target.Y, (Attacker.AtkRange + 1))) { Attacker.IsInBattle = false; return; } if (!CanAttack(Attacker, Target)) { Attacker.IsInBattle = false; return; } if (Battle.WeaponSkill(Attacker, Target)) { return; } if (Attacker.AtkType != 25 && Target.IsFlying()) { Attacker.IsInBattle = false; return; } if (!Attacker.Map.IsPkField() && !Attacker.Map.IsSynMap() && !Attacker.Map.IsPrisonMap()) { if (!Target.IsCriminal()) { Attacker.AttachStatus(Status.Crime, 25000); } } Attacker.LastAttackTick = Environment.TickCount; if (!MyMath.Success(Attacker.Dexterity)) { World.BroadcastMapMsg(Attacker, new MsgInteract(Attacker, Target, 0, (MsgInteract.Action)Attacker.AtkType), true); return; } Int32 Damage = 0; Damage = MyMath.GetDamagePlayer2Player(Attacker, Target); if (Attacker.Map.Id != 1039) { Attacker.RemoveAtkDura(); Target.RemoveDefDura(); } if (!Target.Reflect()) { World.BroadcastMapMsg(Attacker, new MsgInteract(Attacker, Target, Damage, MsgInteract.Action.Attack), true); if (Damage >= Target.CurHP) { Target.Die(Attacker); World.BroadcastMapMsg(Attacker, new MsgInteract(Attacker, Target, 1, MsgInteract.Action.Kill), true); } else { Target.CurHP -= Damage; Target.Send(new MsgUserAttrib(Target, Target.CurHP, MsgUserAttrib.AttributeType.Life)); if (Target.Team != null) { Target.Team.BroadcastMsg(new MsgUserAttrib(Target, Target.CurHP, MsgUserAttrib.AttributeType.Life)); } if (Target.Action == Emotion.SitDown) { Target.Energy /= 2; Target.Send(new MsgUserAttrib(Target, Target.Energy, MsgUserAttrib.AttributeType.Energy)); Target.Action = Emotion.StandBy; World.BroadcastRoomMsg(Target, new MsgAction(Target, (int)Target.Action, MsgAction.Action.Emotion), true); } } } else { if (Damage > 2000) { Damage = 2000; } World.BroadcastMapMsg(Attacker, new MsgInteract(Target, Attacker, Damage, MsgInteract.Action.ReflectWeapon), true); if (Damage >= Attacker.CurHP) { Attacker.Die(null); World.BroadcastMapMsg(Target, new MsgInteract(Target, Attacker, 1, MsgInteract.Action.Kill), true); } else { Attacker.CurHP -= Damage; Attacker.Send(new MsgUserAttrib(Attacker, Attacker.CurHP, MsgUserAttrib.AttributeType.Life)); if (Attacker.Team != null) { Attacker.Team.BroadcastMsg(new MsgUserAttrib(Attacker, Attacker.CurHP, MsgUserAttrib.AttributeType.Life)); } } } if (Attacker.Map.Id != 1039) { Battle.WeaponAttribute(Attacker, Target); } } catch (Exception exc) { sLogger.Error(exc); } }