public void Build() { AssetTypeId = AssetTypeModule.BATTLESTATION; RemoveVisualModifier(VisualModifierCommand.BATTLESTATION_CONSTRUCTING); //Visuals.Add(new VisualModifierCommand(Id, VisualModifierCommand.BATTLESTATION_DOWNTIME_TIMER, 1800, "", 0, true)); PrepareSatellites(); GameManager.SendCommandToMap(Spacemap.Id, AssetRemoveCommand.write(GetAssetType(), Id)); foreach (var character in Spacemap.Characters.Values) { if (character is Player player) { short relationType = character.Clan.Id != 0 && Clan.Id != 0 ? Clan.GetRelation(character.Clan) : (short)0; player.SendCommand(GetAssetCreateCommand(relationType)); } } BuildTimeInMinutes = 0; InBuildingState = false; }
public bool AddInRangeCharacter(Character character) { try { if (character == null || InRangeCharacters.ContainsKey(character.Id) || character.Destroyed || character.Id == Id || character.Spacemap.Id != Spacemap.Id) { return(false); } var success = InRangeCharacters.TryAdd(character.Id, character); if (success) { InRangeCharacterAdded?.Invoke(this, new CharacterArgs(character)); if (this is Player player) { short relationType = character.Clan.Id != 0 && Clan.Id != 0 ? Clan.GetRelation(character.Clan) : (short)0; if (character is Player) { var otherPlayer = character as Player; player.SendCommand(otherPlayer.GetShipCreateCommand(player, relationType)); if (otherPlayer.Title != "" && !EventManager.JackpotBattle.InEvent(otherPlayer)) { player.SendPacket($"0|n|t|{otherPlayer.Id}|1|{otherPlayer.Title}"); } player.SendPacket(otherPlayer.DroneManager.GetDronesPacket()); player.SendCommand(DroneFormationChangeCommand.write(otherPlayer.Id, DroneManager.GetSelectedFormationId(otherPlayer.Settings.InGameSettings.selectedFormation))); } else if (character is Pet) { var pet = character as Pet; if (pet == player.Pet) { player.SendCommand(PetHeroActivationCommand.write(pet.Owner.Id, pet.Id, 22, 3, pet.Name, (short)pet.Owner.FactionId, pet.Owner.Clan.Id, 15, pet.Owner.Clan.Tag, pet.Position.X, pet.Position.Y, pet.Speed, new class_11d(class_11d.DEFAULT))); } else { player.SendCommand(PetActivationCommand.write(pet.Owner.Id, pet.Id, 22, 3, pet.Name, (short)pet.Owner.FactionId, pet.Owner.Clan.Id, 15, pet.Owner.Clan.Tag, new ClanRelationModule(relationType), pet.Position.X, pet.Position.Y, pet.Speed, false, true, new class_11d(class_11d.DEFAULT))); } } else { player.SendCommand(character.GetShipCreateCommand()); } var timeElapsed = (DateTime.Now - character.MovementStartTime).TotalMilliseconds; player.SendCommand(MoveCommand.write(character.Id, character.Destination.X, character.Destination.Y, (int)(character.MovementTime - timeElapsed))); } } return(success); } catch (Exception e) { Out.WriteLine("AddInRangeCharacter void exception " + e, "Character.cs"); Logger.Log("error_log", $"- [Character.cs] AddInRangeCharacter void exception: {e}"); return(false); } }
public bool AddInRangeCharacter(Character character) { if (character.Spacemap != Spacemap || IsInRangeCharacter(character) || character.Destroyed) { return(false); } if (character == this) { return(false); } var success = InRangeCharacters.TryAdd(character.Id, character); if (success) { InRangeCharacterAdded?.Invoke(this, new CharacterArgs(character)); if (this is Player player) { short relationType = character.Clan != null && Clan != null?Clan.GetRelation(character.Clan) : (short)0; bool sameClan = character.Clan != null && Clan != null ? Clan == character.Clan : false; if (character is Player) { var otherPlayer = character as Player; player.SendCommand(otherPlayer.GetShipCreateCommand(player.RankId == 21 ? true : false, relationType, sameClan, (EventManager.JackpotBattle.Active && player.Spacemap == EventManager.JackpotBattle.Spacemap && otherPlayer.Spacemap == EventManager.JackpotBattle.Spacemap))); player.SendPacket($"0|n|INV|{otherPlayer.Id}|{Convert.ToInt32(otherPlayer.Invisible)}"); if (otherPlayer.Title != "" && !EventManager.JackpotBattle.Active && player.Spacemap != EventManager.JackpotBattle.Spacemap && otherPlayer.Spacemap != EventManager.JackpotBattle.Spacemap) { player.SendPacket($"0|n|t|{otherPlayer.Id}|1|{otherPlayer.Title}"); } player.CheckAbilities(otherPlayer); otherPlayer.DroneManager.UpdateDrones(); player.SendPacket(otherPlayer.DroneManager.GetDronesPacket()); player.SendCommand(DroneFormationChangeCommand.write(otherPlayer.Id, otherPlayer.SettingsManager.SelectedFormation)); } else if (character is Pet) { var pet = character as Pet; if (pet == player.Pet) { player.SendCommand(PetHeroActivationCommand.write(pet.Owner.Id, pet.Id, 22, 3, pet.Name, (short)pet.Owner.FactionId, pet.Owner.GetClanId(), 15, pet.Owner.GetClanTag(), pet.Position.X, pet.Position.Y, pet.Speed)); } else { player.SendCommand(PetActivationCommand.write(pet.Owner.Id, pet.Id, 22, 3, pet.Name, (short)pet.Owner.FactionId, pet.Owner.GetClanId(), 15, pet.Owner.GetClanTag(), new ClanRelationModule(relationType), pet.Position.X, pet.Position.Y, pet.Speed, false, true)); player.SendPacket($"0|n|INV|{pet.Id}|{Convert.ToInt32(pet.Invisible)}"); } } else if (character is Spaceball) { var spaceball = character as Spaceball; player.SendCommand(spaceball.GetShipCreateCommand()); } } } return(success); }
public bool TargetDefinition(Attackable target, bool sendMessage = true, bool isPlayerRocketAttack = false) { if (target == null) { return(false); } short relationType = Clan.Id != 0 && target.Clan.Id != 0 ? Clan.GetRelation(target.Clan) : (short)0; if (this is Player player) { if (relationType != ClanRelationModule.AT_WAR) { var attackable = true; var packet = ""; if (target is Player) { if (!EventManager.JackpotBattle.InEvent(player) && !Duel.InDuel(player)) { if (FactionId == target.FactionId) { packet = "0|A|STD|You can't attack members of your own company!"; } else if (Clan.Id != 0 && target.Clan.Id != 0 && Clan.Id == target.Clan.Id) { packet = "0|A|STD|You can't attack members of your own clan!"; } if (packet != "") { attackable = false; } } if (!attackable) { player.DisableAttack(player.Settings.InGameSettings.selectedLaser); if (sendMessage) { player.SendPacket(packet); } return(false); } } } if (target is Player targetPlayer && targetPlayer.Group != null) { if (player.Group == targetPlayer.Group) { player.DisableAttack(player.Settings.InGameSettings.selectedLaser); if (sendMessage) { player.SendPacket("0|A|STD|You can't attack members of your group!"); } return(false); } } if ((target is Player && (target as Player).Storage.IsInDemilitarizedZone) || (Duel.InDuel(player) && player.Storage.Duel.PeaceArea)) { player.DisableAttack(player.Settings.InGameSettings.selectedLaser); if (peaceAreaCooldown.AddSeconds(10) < DateTime.Now) { if (sendMessage) { player.SendPacket("0|A|STM|peacearea"); if (target is Player) { (target as Player).SendPacket("0|A|STM|peacearea"); } peaceAreaCooldown = DateTime.Now; } } return(false); } if (inAttackCooldown.AddSeconds(10) < DateTime.Now) { if (sendMessage) { player.SendPacket("0|A|STM|oppoatt|%!|" + (target is Player && EventManager.JackpotBattle.InEvent(target as Player) ? EventManager.JackpotBattle.Name : target.Name)); inAttackCooldown = DateTime.Now; } } } else if (this is Satellite) { if (relationType != ClanRelationModule.AT_WAR && (target.FactionId == FactionId || target.Clan.Id == Clan.Id || relationType == ClanRelationModule.ALLIED || relationType == ClanRelationModule.NON_AGGRESSION_PACT)) { return(false); } } var range = this is Player ? (isPlayerRocketAttack ? (this as Player).AttackManager.GetRocketRange() : AttackRange) : this is Satellite ? (this as Satellite).GetRange() : this is Npc ? 450 : AttackRange; if (Position.DistanceTo(target.Position) > range) { if (outOfRangeCooldown.AddSeconds(5) < DateTime.Now) { if (sendMessage) { if (this is Player && !isPlayerRocketAttack) { (this as Player).SendPacket("0|A|STM|outofrange"); } if (target is Player) { (target as Player).SendPacket("0|A|STM|attescape"); } outOfRangeCooldown = DateTime.Now; } } return(false); } return(true); }
public override void Destroy(Character destroyer, DestructionType destructionType) { if (this is Spaceball) { return; } if (MainAttacker != null && MainAttacker is Player) { destroyer = MainAttacker; destructionType = DestructionType.PLAYER; } if (destructionType == DestructionType.PLAYER) { var destroyerPlayer = destroyer as Player; destroyerPlayer.Selected = null; destroyerPlayer.DisableAttack(destroyerPlayer.SettingsManager.SelectedLaser); //if (!(this is Pet) || (this is Pet && (this as Pet).Owner != destroyerPlayer)) int experience = destroyerPlayer.Ship.GetExperienceBoost(Ship.Rewards.Experience); int honor = destroyerPlayer.GetHonorBoost(destroyerPlayer.Ship.GetHonorBoost(Ship.Rewards.Honor)); int uridium = Ship.Rewards.Uridium; var changeType = ChangeType.INCREASE; short relationType = destroyerPlayer.Clan != null && Clan != null?Clan.GetRelation(destroyerPlayer.Clan) : (short)0; if (destroyerPlayer.FactionId == FactionId && relationType != ClanRelationModule.AT_WAR && !(EventManager.JackpotBattle.Active && EventManager.JackpotBattle.Players.ContainsKey(Id))) { changeType = ChangeType.DECREASE; } destroyerPlayer.ChangeData(DataType.EXPERIENCE, experience); destroyerPlayer.ChangeData(DataType.HONOR, honor, changeType); destroyerPlayer.ChangeData(DataType.URIDIUM, uridium, changeType); if (!(this is Pet)) { new CargoBox(AssetTypeModule.BOXTYPE_FROM_SHIP, Position, Spacemap, false, false, destroyerPlayer); } } Destroyed = true; var destroyCommand = ShipDestroyedCommand.write(Id, 0); SendCommandToInRangePlayers(destroyCommand); if (this is Player thisPlayer) { if (EventManager.JackpotBattle.Active && thisPlayer.Spacemap.Id == EventManager.JackpotBattle.Spacemap.Id && EventManager.JackpotBattle.Players.ContainsKey(thisPlayer.Id)) { EventManager.JackpotBattle.Players.TryRemove(thisPlayer.Id, out thisPlayer); GameManager.SendPacketToMap(EventManager.JackpotBattle.Spacemap.Id, "0|LM|ST|SLE|" + EventManager.JackpotBattle.Players.Count); } thisPlayer.SkillManager.DisableAllSkills(); thisPlayer.Pet.Deactivate(true); thisPlayer.CurrentHitPoints = 0; thisPlayer.SendCommand(destroyCommand); thisPlayer.DisableAttack(thisPlayer.SettingsManager.SelectedLaser); thisPlayer.CurrentInRangePortalId = -1; thisPlayer.Storage.InRangeAssets.Clear(); thisPlayer.KillScreen(destroyer, destructionType); } Selected = null; InRangeCharacters.Clear(); VisualModifiers.Clear(); Spacemap.RemoveCharacter(this); if (this is Pet) { (this as Pet).Deactivate(true, true); } }