private static void Process_Delete_Npc(Player client, string[] command) { if (client.Account.Permission < PlayerPermission.GM) { return; } uint id; if (command.Length > 1 && uint.TryParse(command[1], out id)) { var npc = Database.ServerDatabase.Context.Npcs.GetById(id); if (npc != null) { Database.ServerDatabase.Context.Npcs.Remove(npc); foreach (var map in Managers.MapManager.ActiveMaps.Values) { if (map.Objects.ContainsKey(npc.UID)) { Space.ILocatableObject x; map.Objects.TryRemove(npc.UID, out x); if (x != null) { foreach (var player in map.QueryPlayers(x)) { player.Send(GeneralActionPacket.Create(id, DataAction.RemoveEntity, 0, 0)); } } } } } } }
public override void Run(Game_Server.Player _client, ushort _linkback) { Responses = new List <NpcDialogPacket>(); AddAvatar(); switch (_linkback) { case 0: AddText("The fate brings lover together. I hope that all can get married and live happily with their lover. What can I do for you?"); AddOption("I would like to get married please.", 1); AddOption("Just passing by.", 255); break; case 1: if (_client.Spouse == "None") { _client.Send(GeneralActionPacket.Create(_client.UID, Enum.DataAction.OpenCustom, 1067)); } else { AddText("I am sorry i cannot allow more than one marriage..."); AddOption("I see", 255); } break; } AddFinish(); Send(); }
//Gets us a new location and handles all map insertion. public void Respawn() { base.sentDeath = false; Mode = MonsterMode.Idle; DiedAt = 0; SpawnPacket.StatusEffects = 0; ClientEffects.Clear(); Direction = (byte)Common.Random.Next(9); //Pull a new location for us that fits within spawn grounds var loc = new Point(Common.Random.Next(Owner.TopLeft.X, Owner.BottomRight.X), Common.Random.Next(Owner.TopLeft.Y, Owner.BottomRight.Y)); var loop = 0; while (!Map.IsValidMonsterLocation(loc)) { loop++; loc = new Point(Common.Random.Next(Owner.TopLeft.X, Owner.BottomRight.X), Common.Random.Next(Owner.TopLeft.Y, Owner.BottomRight.Y)); if (loop > 100) { Console.WriteLine("Error assigning monster spawn! Monster will not be revived"); break; } } if (!Map.IsValidMonsterLocation(loc)) { return; } LastMove = LastAttack = Common.Clock + Common.MS_PER_SECOND + 3; X = (ushort)loc.X; Y = (ushort)loc.Y; Life = MaximumLife; Map.Insert(this); UpdateSurroundings(true); foreach (var id in VisibleObjects.Keys) { if (id > 1000000) { IsActive = true; break; } } if (IsActive) { Owner.IsActive = true; } SendToScreen(GeneralActionPacket.Create(UID, DataAction.SpawnEffect, X, Y)); Common.MapService.AddFlag(MapID, X, Y, TinyMap.TileFlag.Monster); Owner.AliveMembers.TryAdd(UID, this); if (!Alive) { Console.WriteLine("Revived a monster that is still dead! {0}", UID); } }
private static void Process_Popup(Player client, string[] command) { if (client.Account.Permission < PlayerPermission.GM) return; try { var packet = GeneralActionPacket.Create(client.UID, DataAction.OpenWindow, ushort.Parse(command[1]), ushort.Parse(command[2])); client.Send(packet); } catch (Exception p) { Console.WriteLine(p); } }
public new void Faded() { Common.MapService.RemoveFlag(MapID, X, Y, TinyMap.TileFlag.Monster); var packet = GeneralActionPacket.Create(UID, DataAction.RemoveEntity, 0, 0); foreach (var p in Map.QueryPlayers(this)) { if (p.VisibleObjects.ContainsKey(UID)) { uint x; p.Send(packet); p.VisibleObjects.TryRemove(UID, out x); } } }
public void Jump(Entity To) { Point newloc = NextLocation(To); var pack = GeneralActionPacket.Create(UID, DataAction.Jump, (ushort)newloc.X, (ushort)newloc.Y); pack.Data2Low = X; pack.Data2High = Y; X = (ushort)newloc.X; Y = (ushort)newloc.Y; LastMove = Common.Clock; SendToScreen(pack); }
private static void Process_Data(Player client, string[] command) { if (client.Account.Permission < PlayerPermission.GM) return; try { var packet = new GeneralActionPacket(); packet.UID = client.UID; packet.Data2Low = client.X; packet.Data2High = client.Y; packet.Data1 = uint.Parse(command[2]); packet.Action = (DataAction)uint.Parse(command[1]); client.Send(packet); } catch (Exception p) { Console.WriteLine(p); } }
public void Faded() { Monster m; Owner.DeadMembers.Enqueue(this); Owner.DyingMembers.TryRemove(UID, out m); Common.MapService.RemoveFlag(MapID, X, Y, TinyMap.TileFlag.Monster); var packet = GeneralActionPacket.Create(UID, DataAction.RemoveEntity, 0, 0); foreach (var p in Map.QueryPlayers(this)) { if (p.VisibleObjects.ContainsKey(UID)) { uint x; p.Send(packet); p.VisibleObjects.TryRemove(UID, out x); } if (VisibleObjects.ContainsKey(p.UID)) { uint x; VisibleObjects.TryRemove(p.UID, out x); } } }
private void Follow() { if (!IsInVisualField(PetOwner)) { Pet.Map = PetOwner.Map; var dir = Calculations.GetDirection(Pet.Location, PetOwner.Location); Point tryMove = new Point(Common.Random.Next(PetOwner.X - 15, PetOwner.X + 15), Common.Random.Next(PetOwner.Y - 15, PetOwner.Y + 15)); if (!Common.MapService.Valid((ushort)Pet.Map.ID, (ushort)tryMove.X, (ushort)tryMove.Y)) { Pet.X = PetOwner.X; Pet.Y = PetOwner.Y; } else { Pet.X = (ushort)tryMove.X; Pet.Y = (ushort)tryMove.Y; } Pet.Direction = PetOwner.Direction; Pet.UpdateSurroundings(true); var packet = GeneralActionPacket.Create(Pet.UID, Enum.DataAction.Jump, PetOwner.X, PetOwner.Y); Pet.SendToScreen(packet, true); } }
public PetAI(Entity owner, Monster Entity, int ThinkSpeed, int MoveSpeed, int AtkSpeed, int ViewRange, int MoveRange, int AtkRange) { this.owner = owner; this.Pet = Entity; this.Pet.SendToScreen(GeneralActionPacket.Create(Pet.UID, Enum.DataAction.SpawnEffect, 0), true); this.ThinkSpeed = ThinkSpeed; this.MoveSpeed = MoveSpeed; this.AtkSpeed = AtkSpeed + 1000; this.ViewRange = ViewRange; if (this.ViewRange > 15) { this.ViewRange = 15; } this.MoveRange = MoveRange; this.AtkRange = AtkRange; this.LastAttack = DateTime.Now; this.LastMoveTick = Environment.TickCount; this.LastAwakeTick = Environment.TickCount; this.MotorSystem = new System.Timers.Timer(10000); this.MotorSystem.Elapsed += new ElapsedEventHandler(MotorSystem_TakingDecision); this.MotorSystem.Interval = 500; this.MotorSystem.Enabled = true; }
public override void Run(Game_Server.Player _client, ushort _linkback) { _client.Send(GeneralActionPacket.Create(_client.UID, Enum.DataAction.OpenWindow, 4)); }
public void Popup(ushort _type) { client.Send(GeneralActionPacket.Create(client.UID, DataAction.OpenWindow, _type)); }
public override void Run(Game_Server.Player _client, ushort _linkback) { Responses = new List <NpcDialogPacket>(); AddAvatar(); switch (_linkback) { case 0: AddText("A good set of equipment can help you a lot in future battles.Is there something I can do for you?"); AddOption("Enchant HP to my gears.", 1); //AddOption("Composing Upgrade.", 2); AddOption("Nothing right now, thanks.", 255); break; case 1: _client.Send(GeneralActionPacket.Create(_client.UID, Enum.DataAction.OpenCustom, 1091)); break; /*case 2: * AddText("There are two ways of composing from +1 to +9 with +n stones or +n items and from +9 to +12 with DragonBalls."); * AddText("Whitch one would you want?"); * AddOption("Compose +1 to +9.", 3); * AddOption("Compose +9 to +12.", 4); * AddOption("How does composing +9 to +12 works?", 5); * AddOption("Thanks.", 255); * * break; * case 3: * _client.Send(GeneralActionPacket.Create(_client.UID, Enum.DataAction.OpenWindow, 1)); * break; * case 4: * AddText("What a glorious day! I belive it's the best weather to refine equipment in. Do you need my help with anything?"); * AddOption("Compose +9 Equipment to +10.", 6); * AddOption("Compose +10 Equipment to +11.", 7); * AddOption("Compose +11 Equipment to +12.", 8); * AddOption("Nothing right now, thanks.", 255); * break; * case 5: * AddText("If you have any +9 items, you may use DragonBalls to refine it and upgrade its bonus level up to +12."); * AddOption("Are there any limits to equipment refining?", 9); * AddOption("How many DragonBalls would I need?", 17); * break; * case 9: * AddText("When your level reaches 130, I can help you upgrade the bonus level of your equiment and weapons."); * AddText("However, there are limitations.Only right-Handed weapons can be refined. Whereas, there are no limits to equipment refining."); * AddOption("Thanks. I never knew.", 255); * break; * case 17: * AddText("12 DragonBalls are required for refining +9 items to +10, "); * AddText("25 DragonBalls are required for refining +10 items to +11, "); * AddText("4 DBScrolls are required for refining +11 items to +12,"); * AddOption("Got it, thanks.", 255); * break; * #region +9 to +10 * * case 6: * AddText("Choose the equipment you want to upgrade from +9 to +10 from the list below. "); * AddOption("Helmet/Earrings/TaoCap ", 11); * AddOption("Ring/Bracelet ", 16); * AddOption("Necklace/Bag ", 12); * AddOption("Boots ", 18); * AddOption("Armor ", 13); * AddOption("Shield ", 15); * AddOption("Weapon ", 14); * AddOption("I changed my mind. ", 255); * * break; * case 11: * case 12: * case 13: * case 14: * case 15: * case 16: * case 18: * { * var equipment = _client.Equipment.GetItemBySlot((Enum.ItemLocation)(_linkback % 10)); * if (equipment == null) * AddText("There must be some mistake.... You must be wearing the items in order to refine it!"); * else if (equipment.Plus != 9) * AddText("It seems that your items is not +9, in this case i can not help you."); * else if (!_client.HasItem(1088000, 12)) * AddText("There must be some mistake. You do not have the 12 DragonBalls required to refine this item!"); * else * { * for (var i = 0; i < 12; i++) * _client.DeleteItem(1088000); * equipment.Plus++; * _client.Send(ItemInformationPacket.Create(equipment)); * AddText("It is done! Please enjoy your new equipment."); * Managers.PlayerManager.SendToServer(new TalkPacket(ChatType.GM, _client.Name + " upgraded his " + equipment.BaseItem.Name + " to +10 . Congratulations!")); * _client.Save(); * * } * AddOption("Nevermind", 255); * break; * } #endregion * #region +10 to +11 * case 7: * AddText("Choose the equipment you want to upgrade from +10 to +11 from the list below. "); * AddOption("Helmet/Earrings/TaoCap ", 21); * AddOption("Ring/Bracelet ", 26); * AddOption("Necklace/Bag ", 22); * AddOption("Boots ", 28); * AddOption("Armor ", 23); * AddOption("Shield ", 25); * AddOption("Weapon ", 24); * AddOption("I changed my mind. ", 255); * * break; * case 21: * case 22: * case 23: * case 24: * case 25: * case 26: * case 28: * { * var equipment = _client.Equipment.GetItemBySlot((Enum.ItemLocation)(_linkback % 20)); * if (equipment == null) * AddText("There must be some mistake.... You must be wearing the items in order to refine it!"); * else if (equipment.Plus != 10) * AddText("It seems that your items is not +10, in this case I can not help you."); * else if (!_client.HasItem(1088000, 25)) * AddText("There must be some mistake. You do not have the 25 DragonBalls required to refine this item!"); * else * { * for (var i = 0; i < 25; i++) * _client.DeleteItem(1088000); * equipment.Plus++; * _client.Send(ItemInformationPacket.Create(equipment)); * AddText("It is done! Please enjoy your new equipment."); * Managers.PlayerManager.SendToServer(new TalkPacket(ChatType.GM, _client.Name + " upgraded his " + equipment.BaseItem.Name + " to +11 . Congratulations!")); * _client.Save(); * * } * AddOption("Nevermind", 255); * break; * } #endregion * #region +11 to +12 * * * case 8: * AddText("Choose the equipment you want to upgrade from +11 to +12 from the list below. "); * AddOption("Helmet/Earrings/TaoCap ", 31); * AddOption("Ring/Bracelet ", 36); * AddOption("Necklace/Bag ", 32); * AddOption("Boots ", 38); * AddOption("Armor ", 33); * AddOption("Shield ", 35); * AddOption("Weapon ", 34); * AddOption("I changed my mind. ", 255); * * break; * case 31: * case 32: * case 33: * case 34: * case 35: * case 36: * case 38: * { * var equipment = _client.Equipment.GetItemBySlot((Enum.ItemLocation)(_linkback % 30)); * if (equipment == null) * AddText("There must be some mistake.... You must be wearing the items in order to refine it!"); * else if (equipment.Plus != 11) * AddText("It seems that your items is not +11, in this case I can not help you."); * else if (!_client.HasItem(720028, 4)) * AddText("There must be some mistake. You do not have the 4 DBScrolls required to refine this item!"); * else * { * for (var i = 0; i < 4; i++) * _client.DeleteItem(720028); * equipment.Plus++; * _client.Send(ItemInformationPacket.Create(equipment)); * AddText("It is done! Please enjoy your new equipment."); * Managers.PlayerManager.SendToServer(new TalkPacket(ChatType.GM, _client.Name + " upgraded his " + equipment.BaseItem.Name + " to +12 . Congratulations!")); * _client.Save(); * * } * AddOption("Nevermind", 255); * break; * } #endregion*/ } AddFinish(); Send(); }
public static void Process_GeneralActionPacket(Player client, GeneralActionPacket packet) { switch (packet.Action) { #region ChangeDirection case DataAction.ChangeDirection: client.Direction = (byte)(packet.Data4 % 8); client.SendToScreen(packet); break; #endregion #region ChangePKMode case DataAction.ChangePKMode: client.PKMode = (PKMode)packet.Data1; client.Send(packet); break; #endregion #region ChangeAction case DataAction.ChangeAction: var action = (ActionType)packet.Data1; // if (client.Action != action) { client.Action = action; client.SendToScreen(packet); if (action == ActionType.Sit || action == ActionType.Lie) { client.LastSitAt = Common.Clock; } } break; #endregion #region Hotkeys case DataAction.Hotkeys: client.Send(packet); break; #endregion #region Set Location case DataAction.SetLocation: { packet.Data1 = (ushort)client.Character.Map; packet.Data3Low = (ushort)client.Character.X; packet.Data3High = (ushort)client.Character.Y; client.Send(packet); break; } #endregion #region GetSurroundings case DataAction.GetSurroundings: MapManager.AddPlayer(client, client.Character.Map); break; #endregion #region Jump case DataAction.Jump: client.HandleJump(packet); break; #endregion #region Default default: Console.WriteLine("Unhandled MsgActionPacket type {0} from player {1}", packet.Action, client.Character.Name); break; #endregion } }