public static bool CanAttack(Game.Entity attacker, Game.Entity attacked, Database.SpellInformation spell, bool melee) { if (spell != null) if (spell.CanKill && attacker.EntityFlag == EntityFlag.Player && ServerBase.Constants.PKForbiddenMaps.Contains(attacker.Owner.Map.ID) && attacked.EntityFlag == EntityFlag.Player) return false; if (attacker.EntityFlag == EntityFlag.Player) if (attacker.Owner.WatchingGroup != null) return false; if (attacked == null) return false; if (attacked.Dead) { attacker.AttackPacket = null; return false; } if (attacked.EntityFlag == EntityFlag.Monster) { if (attacked.Companion) { if (ServerBase.Constants.PKForbiddenMaps.Contains(attacker.Owner.Map.ID)) { if (attacked.Owner == attacker.Owner) return false; if (attacker.PKMode != Conquer_Online_Server.Game.Enums.PKMode.PK && attacker.PKMode != Conquer_Online_Server.Game.Enums.PKMode.Team) return false; else { attacker.AddFlag(Network.GamePackets.Update.Flags.FlashingName); attacker.FlashingNameStamp = Time32.Now; attacker.FlashingNameTime = 10; return true; } } } if (attacked.Name.Contains("Guard")) { if (attacker.PKMode != Conquer_Online_Server.Game.Enums.PKMode.PK && attacker.PKMode != Conquer_Online_Server.Game.Enums.PKMode.Team) return false; else { attacker.AddFlag(Network.GamePackets.Update.Flags.FlashingName); attacker.FlashingNameStamp = Time32.Now; attacker.FlashingNameTime = 10; return true; } } else return true; } else { if (attacked.EntityFlag == EntityFlag.Player) if (!attacked.Owner.Attackable) return false; if (attacker.EntityFlag == EntityFlag.Player) if (attacker.Owner.WatchingGroup == null) if (attacked.EntityFlag == EntityFlag.Player) if (attacked.Owner.WatchingGroup != null) return false; if (spell != null) if (spell.OnlyGround) if (attacked.ContainsFlag(Update.Flags.Fly)) return false; if (melee && attacked.ContainsFlag(Update.Flags.Fly)) return false; if (ServerBase.Constants.PKForbiddenMaps.Contains(attacker.Owner.Map.ID)) { if (attacker.PKMode == Conquer_Online_Server.Game.Enums.PKMode.PK || attacker.PKMode == Conquer_Online_Server.Game.Enums.PKMode.Team || (spell != null && spell.CanKill)) { attacker.Owner.Send(ServerBase.Constants.PKForbidden); attacker.AttackPacket = null; } return false; } if (attacker.PKMode == Conquer_Online_Server.Game.Enums.PKMode.Capture) { if (attacked.ContainsFlag(Update.Flags.FlashingName) || attacked.PKPoints > 99) { return true; } } if (attacker.PKMode == Conquer_Online_Server.Game.Enums.PKMode.Team) { if (attacker.Owner.Team != null) if (attacker.Owner.Team.IsTeammate(attacked.UID)) { attacker.AttackPacket = null; return false; } if (attacker.Owner.Guild != null) { if (attacker.GuildID != 0) { if (attacked.GuildID != 0) { if (attacker.GuildID == attacked.GuildID) { attacker.AttackPacket = null; return false; } } } } if (attacker.ClanId != 0) { if (attacker.ClanId != 0) { if (attacked.ClanId != 0) { if (attacker.ClanId == attacked.ClanId) { attacker.AttackPacket = null; return false; } } } } if (attacker.Owner.Friends.ContainsKey(attacked.UID)) { attacker.AttackPacket = null; return false; } if (attacker.Owner.Guild != null) { if (attacker.GuildID != 0) { if (attacked.GuildID != 0) { if (attacker.Owner.Guild.Ally.ContainsKey(attacked.GuildID)) { attacker.AttackPacket = null; return false; } } } } if (attacker.ClanId != 0) { if (attacked.ClanId != 0) { if (attacker.GetClan.Allies.ContainsKey(attacked.ClanId)) { attacker.AttackPacket = null; return false; } } } } if (spell != null) if (spell.OnlyGround) if (attacked.ContainsFlag(Update.Flags.Fly)) return false; if (spell != null) if (!spell.CanKill) { if (spell != null && !spell.CanKill && attacker.PKMode == Conquer_Online_Server.Game.Enums.PKMode.Capture) { return false; } if (spell != null && !spell.CanKill && attacker.Owner.Map.ID >= 10000) { attacker.AddFlag(Network.GamePackets.Update.Flags.Normal); return true; } else { attacker.AddFlag(Network.GamePackets.Update.Flags.FlashingName); attacker.FlashingNameStamp = Time32.Now; attacker.FlashingNameTime = 10; return true; } } if (attacker.PKMode != Conquer_Online_Server.Game.Enums.PKMode.PK && attacker.PKMode != Conquer_Online_Server.Game.Enums.PKMode.Team && attacked.PKPoints < 99) { attacker.AttackPacket = null; return false; } else { if (!attacked.ContainsFlag(Update.Flags.FlashingName) || !attacked.ContainsFlag(Update.Flags.BlackName)) { if (ServerBase.Constants.PKFreeMaps.Contains(attacker.Owner.Map.BaseID)) return true; attacker.AddFlag(Network.GamePackets.Update.Flags.FlashingName); attacker.FlashingNameStamp = Time32.Now; attacker.FlashingNameTime = 10; } } return true; } }
public static bool CanAttack(Game.Entity attacker, Game.Entity attacked, Database.SpellInformation spell, bool melee) { if (attacker.EntityFlag == EntityFlag.Player) { if (attacked.EntityFlag == EntityFlag.Player) { if (attacker.MapID == 2060) { if (attacked.Owner.CaptureB && attacker.Owner.CaptureB) { return false; } if (attacked.Owner.CaptureW && attacker.Owner.CaptureW) { return false; } if (attacked.Owner.CaptureBL && attacker.Owner.CaptureBL) { return false; } if (attacked.Owner.CaptureR && attacker.Owner.CaptureR) { return false; } } } } if (attacker.EntityFlag == EntityFlag.Player) { if (attacked.EntityFlag == EntityFlag.Monster) { if (attacked.MonsterInfo.Name == "StigGuard") { return false; } } } if (attacker.EntityFlag == EntityFlag.Monster) { if (attacked.EntityFlag == EntityFlag.Monster) { if (attacked.MonsterInfo.Name == "StigGuard") { return false; } } } if (attacker.EntityFlag == EntityFlag.Player) { if (attacked.EntityFlag == EntityFlag.Monster) { if (attacked.MonsterInfo.Name == "RevGuard") { return false; } } } if (attacker.EntityFlag == EntityFlag.Monster) { if (attacked.EntityFlag == EntityFlag.Monster) { if (attacked.MonsterInfo.Name == "RevGuard") { return false; } } } if (spell != null) if (spell.CanKill == 1 && attacker.EntityFlag == EntityFlag.Player && ServerBase.Constants.PKForbiddenMaps.Contains(attacker.Owner.Map.ID) && attacked.EntityFlag == EntityFlag.Player) return false; if (attacker.EntityFlag == EntityFlag.Player) if (attacker.Owner.WatchingGroup != null) return false; if (attacked == null) return false; if (attacked.Dead) { attacker.AttackPacket = null; return false; } if (attacked.EntityFlag == EntityFlag.Monster) { if (attacked.Companion) { if (ServerBase.Constants.PKForbiddenMaps.Contains(attacker.Owner.Map.ID)) { if (attacked.Owner == attacker.Owner) return false; if (attacker.PKMode != PhoenixProject.Game.Enums.PKMode.PK && attacker.PKMode != PhoenixProject.Game.Enums.PKMode.Team) return false; else { attacker.AddFlag(Network.GamePackets.Update.Flags.FlashingName); attacker.FlashingNameStamp = Time32.Now; attacker.FlashingNameTime = 10; return true; } } } if (attacked.Name.Contains("Guard")) { if (attacker.PKMode != PhoenixProject.Game.Enums.PKMode.PK && attacker.PKMode != PhoenixProject.Game.Enums.PKMode.Team) return false; else { attacker.AddFlag(Network.GamePackets.Update.Flags.FlashingName); attacker.FlashingNameStamp = Time32.Now; attacker.FlashingNameTime = 10; return true; } } else return true; } else { if (attacked.EntityFlag == EntityFlag.Player) if (!attacked.Owner.Attackable) return false; if (attacker.EntityFlag == EntityFlag.Player) if (attacker.Owner.WatchingGroup == null) if (attacked.EntityFlag == EntityFlag.Player) if (attacked.Owner.WatchingGroup != null) return false; if (spell != null) { if (spell.ID != 8001) { if (spell.OnlyGround == 1) if (attacked.ContainsFlag(Update.Flags.Fly)) return false; if (melee && attacked.ContainsFlag(Update.Flags.Fly)) return false; } } if (spell != null) { if (spell.ID == 6010) { if (attacked.ContainsFlag(Update.Flags.Fly)) return false; } } if (spell != null) { if (spell.ID == 10381) { if (attacked.ContainsFlag(Update.Flags.Fly)) return false; } } if (spell != null) { if (spell.ID == 6000) { if (attacked.ContainsFlag(Update.Flags.Fly)) return false; } } if (spell != null) { if (spell.ID == 5030) { if (attacked.ContainsFlag(Update.Flags.Fly)) return false; } } if (spell == null) { if (attacked.ContainsFlag(Update.Flags.Fly)) return false; } if (attacked.ContainsFlag(Network.GamePackets.Update.Flags2.IceBlock)) { return false; } if (attacked.Owner.Account.State == PhoenixProject.Database.AccountTable.AccountState.GameMaster) { return false; } if (attacked.Owner.Account.State == PhoenixProject.Database.AccountTable.AccountState.ProjectManager) { return false; } if (attacked.Owner.Account.State == PhoenixProject.Database.AccountTable.AccountState.GameHelper) { return false; } if (ServerBase.Constants.PKForbiddenMaps.Contains(attacker.Owner.Map.ID)) { if (attacker.PKMode == PhoenixProject.Game.Enums.PKMode.PK || attacker.PKMode == PhoenixProject.Game.Enums.PKMode.Team || (spell != null && spell.CanKill == 1)) { attacker.Owner.Send(ServerBase.Constants.PKForbidden); attacker.AttackPacket = null; } return false; } if (attacker.MapID >= 1000000) { if (attacker.PKMode == PhoenixProject.Game.Enums.PKMode.PK || attacker.PKMode == PhoenixProject.Game.Enums.PKMode.Team || (spell != null && spell.CanKill == 1)) { attacker.Owner.Send(ServerBase.Constants.PKForbidden); attacker.AttackPacket = null; } return false; } if (attacker.PKMode == PhoenixProject.Game.Enums.PKMode.Capture) { if (attacked.ContainsFlag(Update.Flags.FlashingName) || attacked.PKPoints > 99) { return true; } } if (attacker.PKMode == PhoenixProject.Game.Enums.PKMode.Revenge) { if (attacker.Owner.Enemy.ContainsKey(attacked.UID)) { return true; } } if (attacker.PKMode == PhoenixProject.Game.Enums.PKMode.Peace) { if (attacker.PKMode == PhoenixProject.Game.Enums.PKMode.Peace) { return false; } } if (attacker.Name == attacked.Name) { if (attacker.Name == attacked.Name) { return false; } } if (attacker.PKMode == PhoenixProject.Game.Enums.PKMode.Team) { if (attacker.Owner.Team != null) if (attacker.Owner.Team.IsTeammate(attacked.UID)) { attacker.AttackPacket = null; return false; } if (attacker.Owner.Guild != null) { if (attacker.GuildID != 0) { if (attacked.GuildID != 0) { if (attacker.GuildID == attacked.GuildID) { attacker.AttackPacket = null; return false; } } } } if (attacker.ClanId != 0) { if (attacker.ClanId != 0) { if (attacked.ClanId != 0) { if (attacker.ClanId == attacked.ClanId) { attacker.AttackPacket = null; return false; } } } } if (attacker.Owner.Friends.ContainsKey(attacked.UID)) { attacker.AttackPacket = null; return false; } if (attacker.Owner.Guild != null) { if (attacker.GuildID != 0) { if (attacked.GuildID != 0) { if (attacker.Owner.Guild.Ally.ContainsKey(attacked.GuildID)) { attacker.AttackPacket = null; return false; } } } } if (attacked.UID == attacker.UID) return false; if (attacker.Myclan != null) { if (attacker.ClanId != 0) { if (attacked.ClanId != 0) { if (attacker.Myclan.Allies.ContainsKey(attacked.ClanId)) { attacker.AttackPacket = null; return false; } } } } } if (spell != null) if (spell.OnlyGround == 1) if (attacked.ContainsFlag(Update.Flags.Fly)) return false; if (spell != null) if (spell.CanKill == 0) return true; if (attacker.PKMode != PhoenixProject.Game.Enums.PKMode.PK && attacker.PKMode != PhoenixProject.Game.Enums.PKMode.Team && attacked.PKPoints < 99) { attacker.AttackPacket = null; return false; } else { if (!attacked.ContainsFlag(Update.Flags.FlashingName)) { if (!attacked.ContainsFlag(Update.Flags.BlackName)) { if (ServerBase.Constants.PKFreeMaps.Contains(attacker.MapID)) return true; if (ServerBase.Constants.Damage1Map.Contains(attacker.MapID)) return true; if (attacker.Owner.Map.BaseID == 700) return true; attacker.AddFlag(Network.GamePackets.Update.Flags.FlashingName); attacker.FlashingNameStamp = Time32.Now; attacker.FlashingNameTime = 10; } } } return true; } }