public void ObjectChat(S.ObjectChat p) { if (Players.TryGetValue(p.ObjectID, out PlayerObject player)) { //player.ActionFeed.Add(new QueuedAction { Action = MirAction.Running, Direction = p.Direction, Location = new Vector2(p.Location.X, p.Location.Y) }); GameScene.ChatController.RecieveChat(p.Text, p.Type); } }
public void ObjectChat(S.ObjectChat p) { GameScene.ChatController.ReceiveChat(p.Text, p.Type); if (p.Type != ChatType.Normal) { return; } if (ObjectList.TryGetValue(p.ObjectID, out MapObject ob)) { if (ob is PlayerObject player) { player.ChatLabel.SetText(p.Text); player.ChatTime = Time.time + 5; } } }
public static void ObjectChat(S.ObjectChat p) { gameManager.ObjectChat(p); }
public void Chat(string message) { if (string.IsNullOrEmpty(message)) return; SMain.EnqueueChat(string.Format("{0}: {1}", Name, message)); if (GMLogin) { if (message == GMPassword) { IsGM = true; SMain.Enqueue(string.Format("{0} is now a GM", Name)); ReceiveChat("You have been made a GM", ChatType.System); } else { SMain.Enqueue(string.Format("{0} attempted a GM login", Name)); ReceiveChat("Incorrect login password", ChatType.System); } GMLogin = false; return; } if (Info.ChatBanned) { if (Info.ChatBanExpiryDate > DateTime.Now) { ReceiveChat("You are currently banned from chatting.", ChatType.System); return; } Info.ChatBanned = false; } else { if (ChatTime > Envir.Time) { if (ChatTick >= 5 & !IsGM) { Info.ChatBanned = true; Info.ChatBanExpiryDate = DateTime.Now.AddMinutes(5); ReceiveChat("You have been banned from chatting for 5 minutes.", ChatType.System); return; } ChatTick++; } else ChatTick = 0; ChatTime = Envir.Time + 2000; } string[] parts; message = message.Replace("$pos", Functions.PointToString(CurrentLocation)); Packet p; if (message.StartsWith("/")) { //Private Message message = message.Remove(0, 1); parts = message.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 0) return; PlayerObject player = Envir.GetPlayer(parts[0]); if (player == null) { IntelligentCreatureObject creature = GetCreatureByName(parts[0]); if (creature != null) { creature.ReceiveChat(message.Remove(0, parts[0].Length), ChatType.WhisperIn); return; } ReceiveChat(string.Format("Could not find {0}.", parts[0]), ChatType.System); return; } if (player.Info.Friends.Any(e => e.Info == Info && e.Blocked)) { ReceiveChat("Player is not accepting your messages.", ChatType.System); return; } if (Info.Friends.Any(e => e.Info == player.Info && e.Blocked)) { ReceiveChat("Cannot message player whilst they are on your blacklist.", ChatType.System); return; } ReceiveChat(string.Format("/{0}", message), ChatType.WhisperOut); player.ReceiveChat(string.Format("{0}=>{1}", Name, message.Remove(0, parts[0].Length)), ChatType.WhisperIn); } else if (message.StartsWith("!!")) { if (GroupMembers == null) return; //Group message = String.Format("{0}:{1}", Name, message.Remove(0, 2)); p = new S.ObjectChat { ObjectID = ObjectID, Text = message, Type = ChatType.Group }; for (int i = 0; i < GroupMembers.Count; i++) GroupMembers[i].Enqueue(p); } else if (message.StartsWith("!~")) { if (MyGuild == null) return; //Guild message = message.Remove(0, 2); MyGuild.SendMessage(String.Format("{0}: {1}", Name, message)); } else if (message.StartsWith("!#")) { //Mentor Message message = message.Remove(0, 2); parts = message.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 0) return; if (Info.Mentor == 0) return; CharacterInfo Mentor = Envir.GetCharacterInfo(Info.Mentor); PlayerObject player = Envir.GetPlayer(Mentor.Name); if (player == null) { ReceiveChat(string.Format("{0} isn't online.", Mentor.Name), ChatType.System); return; } ReceiveChat(string.Format("{0}: {1}", Name, message), ChatType.Mentor); player.ReceiveChat(string.Format("{0}: {1}", Name, message), ChatType.Mentor); } else if (message.StartsWith("!")) { //Shout if (Envir.Time < ShoutTime) { ReceiveChat(string.Format("You cannot shout for another {0} seconds.", Math.Ceiling((ShoutTime - Envir.Time) / 1000D)), ChatType.System); return; } if (Level < 8 && (!HasMapShout && !HasServerShout)) { ReceiveChat("You need to be level 8 before you can shout.", ChatType.System); return; } ShoutTime = Envir.Time + 10000; message = String.Format("(!){0}:{1}", Name, message.Remove(0, 1)); if (HasMapShout) { p = new S.Chat { Message = message, Type = ChatType.Shout2 }; HasMapShout = false; for (int i = 0; i < CurrentMap.Players.Count; i++) { CurrentMap.Players[i].Enqueue(p); } return; } else if (HasServerShout) { p = new S.Chat { Message = message, Type = ChatType.Shout3 }; HasServerShout = false; for (int i = 0; i < Envir.Players.Count; i++) { Envir.Players[i].Enqueue(p); } return; } else { p = new S.Chat { Message = message, Type = ChatType.Shout }; //Envir.Broadcast(p); for (int i = 0; i < CurrentMap.Players.Count; i++) { if (!Functions.InRange(CurrentLocation, CurrentMap.Players[i].CurrentLocation, Globals.DataRange * 2)) continue; CurrentMap.Players[i].Enqueue(p); } } } else if (message.StartsWith(":)")) { //Relationship Message message = message.Remove(0, 2); parts = message.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 0) return; if (Info.Married == 0) return; CharacterInfo Lover = Envir.GetCharacterInfo(Info.Married); PlayerObject player = Envir.GetPlayer(Lover.Name); if (player == null) { ReceiveChat(string.Format("{0} isn't online.", Lover.Name), ChatType.System); return; } ReceiveChat(string.Format("{0}: {1}", Name, message), ChatType.Relationship); player.ReceiveChat(string.Format("{0}: {1}", Name, message), ChatType.Relationship); } else if (message.StartsWith("@!")) { if (!IsGM) return; message = String.Format("(*){0}:{1}", Name, message.Remove(0, 2)); p = new S.Chat { Message = message, Type = ChatType.Announcement }; Envir.Broadcast(p); } else if (message.StartsWith("@")) { //Command message = message.Remove(0, 1); parts = message.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 0) return; PlayerObject player; CharacterInfo data; String hintstring; UserItem item; switch (parts[0].ToUpper()) { case "LOGIN": GMLogin = true; ReceiveChat("Please type the GM Password", ChatType.Hint); return; case "KILL": if (!IsGM) return; if (parts.Length >= 2) { player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(string.Format("Could not find {0}", parts[0]), ChatType.System); return; } if (!player.GMNeverDie) player.Die(); } else { if (!CurrentMap.ValidPoint(Front)) return; Cell cell = CurrentMap.GetCell(Front); if (cell == null || cell.Objects == null) return; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; switch (ob.Race) { case ObjectType.Player: case ObjectType.Monster: if (ob.Dead) continue; ob.EXPOwner = this; ob.ExpireTime = Envir.Time + MonsterObject.EXPOwnerDelay; ob.Die(); break; default: continue; } } } return; case "RESTORE": if (!IsGM || parts.Length < 2) return; data = Envir.GetCharacterInfo(parts[1]); if (data == null) { ReceiveChat(string.Format("Player {0} was not found", parts[1]), ChatType.System); return; } if (!data.Deleted) return; data.Deleted = false; ReceiveChat(string.Format("Player {0} has been restored by", data.Name), ChatType.System); SMain.Enqueue(string.Format("Player {0} has been restored by {1}", data.Name, Name)); break; case "CHANGEGENDER": if (!IsGM && !Settings.TestServer) return; data = parts.Length < 2 ? Info : Envir.GetCharacterInfo(parts[1]); if (data == null) return; switch (data.Gender) { case MirGender.Male: data.Gender = MirGender.Female; break; case MirGender.Female: data.Gender = MirGender.Male; break; } ReceiveChat(string.Format("Player {0} has been changed to {1}", data.Name, data.Gender), ChatType.System); SMain.Enqueue(string.Format("Player {0} has been changed to {1} by {2}", data.Name, data.Gender, Name)); if (data.Player != null) data.Player.Connection.LogOut(); break; case "LEVEL": if ((!IsGM && !Settings.TestServer) || parts.Length < 2) return; ushort level; ushort old; if (parts.Length >= 3) { if (!IsGM) return; if (ushort.TryParse(parts[2], out level)) { parts[2] = ushort.MaxValue.ToString(); } if (ushort.TryParse(parts[2], out level)) { if (level == 0) return; player = Envir.GetPlayer(parts[1]); if (player == null) return; old = player.Level; player.Level = level; player.LevelUp(); ReceiveChat(string.Format("Player {0} has been Leveled {1} -> {2}.", player.Name, old, player.Level), ChatType.System); SMain.Enqueue(string.Format("Player {0} has been Leveled {1} -> {2} by {3}", player.Name, old, player.Level, Name)); return; } } else { if (parts[1] == "-1") { parts[1] = ushort.MaxValue.ToString(); } if (ushort.TryParse(parts[1], out level)) { if (level == 0) return; old = Level; Level = level; LevelUp(); ReceiveChat(string.Format("Leveled {0} -> {1}.", old, Level), ChatType.System); SMain.Enqueue(string.Format("Player {0} has been Leveled {1} -> {2} by {3}", Name, old, Level, Name)); return; } } ReceiveChat("Could not level player", ChatType.System); break; case "MAKE": if ((!IsGM && !Settings.TestServer) || parts.Length < 2) return; ItemInfo iInfo = Envir.GetItemInfo(parts[1]); if (iInfo == null) return; uint count = 1; if (parts.Length >= 3 && !uint.TryParse(parts[2], out count)) count = 1; var tempCount = count; while (count > 0) { if (iInfo.StackSize >= count) { item = Envir.CreateDropItem(iInfo); item.Count = count; if (CanGainItem(item, false)) GainItem(item); return; } item = Envir.CreateDropItem(iInfo); item.Count = iInfo.StackSize; count -= iInfo.StackSize; if (!CanGainItem(item, false)) return; GainItem(item); } ReceiveChat(string.Format("{0} x{1} has been created.", iInfo.Name, tempCount), ChatType.System); SMain.Enqueue(string.Format("Player {0} has attempted to Create {1} x{2}", Name, iInfo.Name, tempCount)); break; case "CLEARBAG": if (!IsGM && !Settings.TestServer) return; player = this; if (parts.Length >= 2) player = Envir.GetPlayer(parts[1]); if (player == null) return; for (int i = 0; i < player.Info.Inventory.Length; i++) { item = player.Info.Inventory[i]; if (item == null) continue; player.Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = item.Count }); player.Info.Inventory[i] = null; } player.RefreshStats(); break; case "SUPERMAN": if (!IsGM && !Settings.TestServer) return; GMNeverDie = !GMNeverDie; hintstring = GMNeverDie ? "Invincible Mode." : "Normal Mode."; ReceiveChat(hintstring, ChatType.Hint); UpdateGMBuff(); break; case "GAMEMASTER": if (!IsGM && !Settings.TestServer) return; GMGameMaster = !GMGameMaster; hintstring = GMGameMaster ? "GameMaster Mode." : "Normal Mode."; ReceiveChat(hintstring, ChatType.Hint); UpdateGMBuff(); break; case "OBSERVER": if (!IsGM) return; Observer = !Observer; hintstring = Observer ? "Observer Mode." : "Normal Mode."; ReceiveChat(hintstring, ChatType.Hint); UpdateGMBuff(); break; case "ALLOWGUILD": EnableGuildInvite = !EnableGuildInvite; hintstring = EnableGuildInvite ? "Guild invites enabled." : "Guild invites disabled."; ReceiveChat(hintstring, ChatType.Hint); break; case "RECALL": if (!IsGM) return; if (parts.Length < 2) return; player = Envir.GetPlayer(parts[1]); if (player == null) return; player.Teleport(CurrentMap, Front); break; case "ENABLEGROUPRECALL": EnableGroupRecall = !EnableGroupRecall; hintstring = EnableGroupRecall ? "Group Recall Enabled." : "Group Recall Disabled."; ReceiveChat(hintstring, ChatType.Hint); break; case "GROUPRECALL": if (GroupMembers == null || GroupMembers[0] != this || Dead) return; if (CurrentMap.Info.NoRecall) { ReceiveChat("You cannot recall people on this map", ChatType.System); return; } if (Envir.Time < LastRecallTime) { ReceiveChat(string.Format("You cannot recall for another {0} seconds", (LastRecallTime - Envir.Time) / 1000), ChatType.System); return; } if (ItemSets.Any(set => set.Set == ItemSet.Recall && set.SetComplete)) { LastRecallTime = Envir.Time + 180000; for (var i = 1; i < GroupMembers.Count(); i++) { if (GroupMembers[i].EnableGroupRecall) GroupMembers[i].Teleport(CurrentMap, CurrentLocation); else GroupMembers[i].ReceiveChat("A recall was attempted without your permission", ChatType.System); } } break; case "RECALLMEMBER": if (GroupMembers == null || GroupMembers[0] != this) { ReceiveChat("You are not a group leader.", ChatType.System); return; } if (Dead) { ReceiveChat("You cannot recall when you are dead.", ChatType.System); return; } if (CurrentMap.Info.NoRecall) { ReceiveChat("You cannot recall people on this map", ChatType.System); return; } if (Envir.Time < LastRecallTime) { ReceiveChat(string.Format("You cannot recall for another {0} seconds", (LastRecallTime - Envir.Time) / 1000), ChatType.System); return; } if (ItemSets.Any(set => set.Set == ItemSet.Recall && set.SetComplete)) { if (parts.Length < 2) return; player = Envir.GetPlayer(parts[1]); if (player == null || !IsMember(player) || this == player) { ReceiveChat((string.Format("Player {0} could not be found", parts[1])), ChatType.System); return; } if (!player.EnableGroupRecall) { player.ReceiveChat("A recall was attempted without your permission", ChatType.System); ReceiveChat((string.Format("{0} is blocking grouprecall", player.Name)), ChatType.System); return; } LastRecallTime = Envir.Time + 60000; if (!player.Teleport(CurrentMap, Front)) player.Teleport(CurrentMap, CurrentLocation); } else { ReceiveChat("You cannot recall without a recallset.", ChatType.System); return; } break; case "RECALLLOVER": if (Info.Married == 0) { ReceiveChat("You're not married.", ChatType.System); return; } if (Dead) { ReceiveChat("You can't recall when you are dead.", ChatType.System); return; } if (CurrentMap.Info.NoRecall) { ReceiveChat("You cannot recall people on this map", ChatType.System); return; } if (Info.Equipment[(int)EquipmentSlot.RingL] == null) { ReceiveChat("You need to be wearing a Wedding Ring for recall.", ChatType.System); return; } if (Info.Equipment[(int)EquipmentSlot.RingL].WeddingRing == Info.Married) { CharacterInfo Lover = Envir.GetCharacterInfo(Info.Married); if (Lover == null) return; player = Envir.GetPlayer(Lover.Name); if (player == null) { ReceiveChat((string.Format("{0} is not online.", Lover.Name)), ChatType.System); return; } if (player.Dead) { ReceiveChat("You can't recall a dead player.", ChatType.System); return; } if (player.Info.Equipment[(int)EquipmentSlot.RingL] == null) { player.ReceiveChat((string.Format("You need to wear a Wedding Ring for recall.", Lover.Name)), ChatType.System); ReceiveChat((string.Format("{0} Isn't wearing a Wedding Ring.", Lover.Name)), ChatType.System); return; } if (player.Info.Equipment[(int)EquipmentSlot.RingL].WeddingRing != player.Info.Married) { player.ReceiveChat((string.Format("You need to wear a Wedding Ring on your left finger for recall.", Lover.Name)), ChatType.System); ReceiveChat((string.Format("{0} Isn't wearing a Wedding Ring.", Lover.Name)), ChatType.System); return; } if (!player.AllowLoverRecall) { player.ReceiveChat("A recall was attempted without your permission", ChatType.System); ReceiveChat((string.Format("{0} is blocking Lover Recall.", player.Name)), ChatType.System); return; } if ((Envir.Time < LastRecallTime) && (Envir.Time < player.LastRecallTime)) { ReceiveChat(string.Format("You cannot recall for another {0} seconds", (LastRecallTime - Envir.Time) / 1000), ChatType.System); return; } LastRecallTime = Envir.Time + 60000; player.LastRecallTime = Envir.Time + 60000; if (!player.Teleport(CurrentMap, Front)) player.Teleport(CurrentMap, CurrentLocation); } else { ReceiveChat("You cannot recall your lover without wearing a wedding ring", ChatType.System); return; } break; case "TIME": ReceiveChat(string.Format("The time is : {0}", DateTime.Now.ToString("hh:mm tt")), ChatType.System); break; case "ROLL": int diceNum = Envir.Random.Next(5) + 1; if (GroupMembers == null) { return; } for (int i = 0; i < GroupMembers.Count; i++) { PlayerObject playerSend = GroupMembers[i]; playerSend.ReceiveChat(string.Format("{0} has rolled a {1}", Name, diceNum), ChatType.Group); } break; case "MAP": var mapName = CurrentMap.Info.FileName; var mapTitle = CurrentMap.Info.Title; ReceiveChat((string.Format("You are currently in {0}. Map ID: {1}", mapTitle, mapName)), ChatType.System); break; case "MOVE": if (!IsGM && !HasTeleportRing && !Settings.TestServer) return; if (!IsGM && CurrentMap.Info.NoPosition) { ReceiveChat(("You cannot position move on this map"), ChatType.System); return; } if (Envir.Time < LastTeleportTime) { ReceiveChat(string.Format("You cannot teleport for another {0} seconds", (LastTeleportTime - Envir.Time) / 1000), ChatType.System); return; } int x, y; if (parts.Length <= 2 || !int.TryParse(parts[1], out x) || !int.TryParse(parts[2], out y)) { if (!IsGM) LastTeleportTime = Envir.Time + 10000; TeleportRandom(200, 0); return; } if (!IsGM) LastTeleportTime = Envir.Time + 10000; Teleport(CurrentMap, new Point(x, y)); break; case "MAPMOVE": if ((!IsGM && !Settings.TestServer) || parts.Length < 2) return; var instanceID = 1; x = 0; y = 0; if (parts.Length == 3 || parts.Length == 5) int.TryParse(parts[2], out instanceID); if (instanceID < 1) instanceID = 1; var map = SMain.Envir.GetMapByNameAndInstance(parts[1], instanceID); if (map == null) { ReceiveChat((string.Format("Map {0}:[{1}] could not be found", parts[1], instanceID)), ChatType.System); return; } if (parts.Length == 4 || parts.Length == 5) { int.TryParse(parts[parts.Length - 2], out x); int.TryParse(parts[parts.Length - 1], out y); } switch (parts.Length) { case 2: ReceiveChat(TeleportRandom(200, 0, map) ? (string.Format("Moved to Map {0}", map.Info.FileName)) : (string.Format("Failed movement to Map {0}", map.Info.FileName)), ChatType.System); break; case 3: ReceiveChat(TeleportRandom(200, 0, map) ? (string.Format("Moved to Map {0}:[{1}]", map.Info.FileName, instanceID)) : (string.Format("Failed movement to Map {0}:[{1}]", map.Info.FileName, instanceID)), ChatType.System); break; case 4: ReceiveChat(Teleport(map, new Point(x, y)) ? (string.Format("Moved to Map {0} at {1}:{2}", map.Info.FileName, x, y)) : (string.Format("Failed movement to Map {0} at {1}:{2}", map.Info.FileName, x, y)), ChatType.System); break; case 5: ReceiveChat(Teleport(map, new Point(x, y)) ? (string.Format("Moved to Map {0}:[{1}] at {2}:{3}", map.Info.FileName, instanceID, x, y)) : (string.Format("Failed movement to Map {0}:[{1}] at {2}:{3}", map.Info.FileName, instanceID, x, y)), ChatType.System); break; } break; case "GOTO": if (!IsGM) return; if (parts.Length < 2) return; player = Envir.GetPlayer(parts[1]); if (player == null) return; Teleport(player.CurrentMap, player.CurrentLocation); break; case "MOB": if (!IsGM && !Settings.TestServer) return; if (parts.Length < 2) { ReceiveChat("Not enough parameters to spawn monster", ChatType.System); return; } MonsterInfo mInfo = Envir.GetMonsterInfo(parts[1]); if (mInfo == null) { ReceiveChat((string.Format("Monster {0} does not exist", parts[1])), ChatType.System); return; } count = 1; if (parts.Length >= 3 && IsGM) if (!uint.TryParse(parts[2], out count)) count = 1; for (int i = 0; i < count; i++) { MonsterObject monster = MonsterObject.GetMonster(mInfo); if (monster == null) return; monster.Spawn(CurrentMap, Front); } ReceiveChat((string.Format("Monster {0} x{1} has been spawned.", mInfo.Name, count)), ChatType.System); break; case "RECALLMOB": if ((!IsGM && !Settings.TestServer) || parts.Length < 2) return; MonsterInfo mInfo2 = Envir.GetMonsterInfo(parts[1]); if (mInfo2 == null) return; count = 1; byte petlevel = 0; if (parts.Length > 2) if (!uint.TryParse(parts[2], out count) || count > 50) count = 1; if (parts.Length > 3) if (!byte.TryParse(parts[3], out petlevel) || petlevel > 7) petlevel = 0; if (!IsGM && Pets.Count > 4) return; for (int i = 0; i < count; i++) { MonsterObject monster = MonsterObject.GetMonster(mInfo2); if (monster == null) return; monster.PetLevel = petlevel; monster.Master = this; monster.MaxPetLevel = 7; monster.Direction = Direction; monster.ActionTime = Envir.Time + 1000; monster.Spawn(CurrentMap, Front); Pets.Add(monster); } ReceiveChat((string.Format("Pet {0} x{1} has been recalled.", mInfo2.Name, count)), ChatType.System); break; case "RELOADDROPS": if (!IsGM) return; foreach (var t in Envir.MonsterInfoList) t.LoadDrops(); ReceiveChat("Drops Reloaded.", ChatType.Hint); break; case "RELOADNPCS": if (!IsGM) return; for (int i = 0; i < CurrentMap.NPCs.Count; i++) { CurrentMap.NPCs[i].LoadInfo(true); } DefaultNPC.LoadInfo(true); ReceiveChat("NPCs Reloaded.", ChatType.Hint); break; case "GIVEGOLD": if ((!IsGM && !Settings.TestServer) || parts.Length < 2) return; player = this; if (parts.Length > 2) { if (!IsGM) return; if (!uint.TryParse(parts[2], out count)) return; player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(string.Format("Player {0} was not found.", parts[1]), ChatType.System); return; } } else if (!uint.TryParse(parts[1], out count)) return; if (count + player.Account.Gold >= uint.MaxValue) count = uint.MaxValue - player.Account.Gold; player.GainGold(count); SMain.Enqueue(string.Format("Player {0} has been given {1} gold", player.Name, count)); break; case "GIVEPEARLS": if ((!IsGM && !Settings.TestServer) || parts.Length < 2) return; player = this; if (parts.Length > 2) { if (!IsGM) return; if (!uint.TryParse(parts[2], out count)) return; player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(string.Format("Player {0} was not found.", parts[1]), ChatType.System); return; } } else if (!uint.TryParse(parts[1], out count)) return; if (count + player.Info.PearlCount >= int.MaxValue) count = (uint)(int.MaxValue - player.Info.PearlCount); player.IntelligentCreatureGainPearls((int)count); if (count > 1) SMain.Enqueue(string.Format("Player {0} has been given {1} pearls", player.Name, count)); else SMain.Enqueue(string.Format("Player {0} has been given {1} pearl", player.Name, count)); break; case "GIVECREDIT": if ((!IsGM && !Settings.TestServer) || parts.Length < 2) return; player = this; if (parts.Length > 2) { if (!IsGM) return; if (!uint.TryParse(parts[2], out count)) return; player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(string.Format("Player {0} was not found.", parts[1]), ChatType.System); return; } } else if (!uint.TryParse(parts[1], out count)) return; if (count + player.Account.Credit >= uint.MaxValue) count = uint.MaxValue - player.Account.Credit; player.GainCredit(count); SMain.Enqueue(string.Format("Player {0} has been given {1} credit", player.Name, count)); break; case "GIVESKILL": if ((!IsGM && !Settings.TestServer) || parts.Length < 3) return; byte spellLevel = 0; player = this; Spell skill; if (!Enum.TryParse(parts.Length > 3 ? parts[2] : parts[1], true, out skill)) return; if (skill == Spell.None) return; spellLevel = byte.TryParse(parts.Length > 3 ? parts[3] : parts[2], out spellLevel) ? Math.Min((byte)3, spellLevel) : (byte)0; if (parts.Length > 3) { if (!IsGM) return; player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(string.Format("Player {0} was not found.", parts[1]), ChatType.System); return; } } var magic = new UserMagic(skill) { Level = spellLevel }; if (player.Info.Magics.Any(e => e.Spell == skill)) { player.Info.Magics.FirstOrDefault(e => e.Spell == skill).Level = spellLevel; player.ReceiveChat(string.Format("Spell {0} changed to level {1}", skill.ToString(), spellLevel), ChatType.Hint); return; } else { player.ReceiveChat(string.Format("You have learned {0} at level {1}", skill.ToString(), spellLevel), ChatType.Hint); if (player != this) { ReceiveChat(string.Format("{0} has learned {1} at level {2}", player.Name, skill.ToString(), spellLevel), ChatType.Hint); } player.Info.Magics.Add(magic); } player.Enqueue(magic.GetInfo()); player.RefreshStats(); break; case "FIND": if (!IsGM && !HasProbeNecklace) return; if (Envir.Time < LastProbeTime) { ReceiveChat(string.Format("You cannot search for another {0} seconds", (LastProbeTime - Envir.Time) / 1000), ChatType.System); return; } if (parts.Length < 2) return; player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(parts[1] + " is not online", ChatType.System); return; } if (player.CurrentMap == null) return; if (!IsGM) LastProbeTime = Envir.Time + 180000; ReceiveChat((string.Format("{0} is located at {1} ({2},{3})", player.Name, player.CurrentMap.Info.Title, player.CurrentLocation.X, player.CurrentLocation.Y)), ChatType.System); break; case "LEAVEGUILD": if (MyGuild == null) return; if (MyGuildRank == null) return; MyGuild.DeleteMember(this, Name); break; case "CREATEGUILD": if ((!IsGM && !Settings.TestServer) || parts.Length < 3) return; player = Envir.GetPlayer(parts[1]); if (!IsGM && player != this) return; if (player == null) { ReceiveChat(string.Format("Player {0} was not found.", parts[1]), ChatType.System); return; } if (player.MyGuild != null) { ReceiveChat(string.Format("Player {0} is already in a guild.", parts[1]), ChatType.System); return; } if ((parts[2].Length < 3) || (parts[2].Length > 20)) { ReceiveChat("Guildname is restricted to 3-20 characters.", ChatType.System); return; } GuildObject guild = Envir.GetGuild(parts[2]); if (guild != null) { ReceiveChat(string.Format("Guild {0} already exists.", parts[2]), ChatType.System); return; } player.CanCreateGuild = true; if (player.CreateGuild(parts[2])) ReceiveChat(string.Format("Successfully created guild {0}", parts[2]), ChatType.System); else ReceiveChat("Failed to create guild", ChatType.System); player.CanCreateGuild = false; break; case "ALLOWTRADE": AllowTrade = !AllowTrade; if (AllowTrade) ReceiveChat("You are now allowing trade", ChatType.System); else ReceiveChat("You are no longer allowing trade", ChatType.System); break; case "TRIGGER": if (!IsGM) return; if (parts.Length < 2) return; if (parts.Length >= 3) { player = Envir.GetPlayer(parts[2]); if (player == null) { ReceiveChat(string.Format("Player {0} was not found.", parts[2]), ChatType.System); return; } player.CallDefaultNPC(DefaultNPCType.Trigger, parts[1]); return; } foreach (var pl in Envir.Players) { pl.CallDefaultNPC(DefaultNPCType.Trigger, parts[1]); } break; case "RIDE": if (MountType > -1) { RidingMount = !RidingMount; RefreshMount(); } else ReceiveChat("You haven't a mount...", ChatType.System); ChatTime = 0; break; case "SETFLAG": if (!IsGM && !Settings.TestServer) return; if (parts.Length < 2) return; int tempInt = 0; if (!int.TryParse(parts[1], out tempInt)) return; if (tempInt > Info.Flags.Length - 1) return; Info.Flags[tempInt] = !Info.Flags[tempInt]; for (int f = CurrentMap.NPCs.Count - 1; f >= 0; f--) { if (Functions.InRange(CurrentMap.NPCs[f].CurrentLocation, CurrentLocation, Globals.DataRange)) CurrentMap.NPCs[f].CheckVisible(this); } break; case "LISTFLAGS": if (!IsGM && !Settings.TestServer) return; for (int i = 0; i < Info.Flags.Length; i++) { if (Info.Flags[i] == false) continue; ReceiveChat("Flag " + i, ChatType.Hint); } break; case "CLEARFLAGS": if (!IsGM && !Settings.TestServer) return; player = parts.Length > 1 && IsGM ? Envir.GetPlayer(parts[1]) : this; if (player == null) { ReceiveChat(parts[1] + " is not online", ChatType.System); return; } for (int i = 0; i < player.Info.Flags.Length; i++) { player.Info.Flags[i] = false; } break; case "CLEARMOB": if (!IsGM) return; if (parts.Length > 1) { map = Envir.GetMapByNameAndInstance(parts[1]); if (map == null) return; } else { map = CurrentMap; } foreach (var cell in map.Cells) { if (cell == null || cell.Objects == null) continue; int obCount = cell.Objects.Count(); for (int m = 0; m < obCount; m++) { MapObject ob = cell.Objects[m]; if (ob.Race != ObjectType.Monster) continue; if (ob.Dead) continue; ob.Die(); } } break; case "CHANGECLASS": //@changeclass [Player] [Class] if (!IsGM && !Settings.TestServer) return; data = parts.Length <= 2 || !IsGM ? Info : Envir.GetCharacterInfo(parts[1]); if (data == null) return; MirClass mirClass; if (!Enum.TryParse(parts[parts.Length - 1], true, out mirClass) || data.Class == mirClass) return; data.Class = mirClass; ReceiveChat(string.Format("Player {0} has been changed to {1}", data.Name, data.Class), ChatType.System); SMain.Enqueue(string.Format("Player {0} has been changed to {1} by {2}", data.Name, data.Class, Name)); if (data.Player != null) data.Player.Connection.LogOut(); break; case "DIE": LastHitter = null; Die(); break; case "HAIR": if (!IsGM && !Settings.TestServer) return; if (parts.Length < 2) { Info.Hair = (byte)SMain.Envir.Random.Next(0, 9); } else { byte tempByte = 0; byte.TryParse(parts[1], out tempByte); Info.Hair = tempByte; } break; case "DECO": //TEST CODE if ((!IsGM && !Settings.TestServer) || parts.Length < 2) return; ushort tempShort = 0; ushort.TryParse(parts[1], out tempShort); DecoObject decoOb = new DecoObject { Image = tempShort, CurrentMap = CurrentMap, CurrentLocation = CurrentLocation, }; CurrentMap.AddObject(decoOb); decoOb.Spawned(); Enqueue(decoOb.GetInfo()); break; case "ADJUSTPKPOINT": if ((!IsGM && !Settings.TestServer) || parts.Length < 2) return; if (parts.Length > 2) { if (!IsGM) return; player = Envir.GetPlayer(parts[1]); if (player == null) return; int.TryParse(parts[2], out tempInt); } else { player = this; int.TryParse(parts[1], out tempInt); } player.PKPoints = tempInt; break; case "AWAKENING": { if ((!IsGM && !Settings.TestServer) || parts.Length < 3) return; ItemType type; if (!Enum.TryParse(parts[1], true, out type)) return; AwakeType awakeType; if (!Enum.TryParse(parts[2], true, out awakeType)) return; foreach (UserItem temp in Info.Equipment) { if (temp == null) continue; ItemInfo realItem = Functions.GetRealItem(temp.Info, Info.Level, Info.Class, Envir.ItemInfoList); if (realItem.Type == type) { Awake awake = temp.Awake; bool[] isHit; int result = awake.UpgradeAwake(temp, awakeType, out isHit); switch (result) { case -1: ReceiveChat(string.Format("{0} : Condition Error.", temp.Name), ChatType.System); break; case 0: ReceiveChat(string.Format("{0} : Upgrade Failed.", temp.Name), ChatType.System); break; case 1: ReceiveChat(string.Format("{0} : AWAKE Level {1}, value {2}~{3}.", temp.Name, awake.getAwakeLevel(), awake.getAwakeValue(), awake.getAwakeValue()), ChatType.System); p = new S.RefreshItem { Item = temp }; Enqueue(p); break; default: break; } } } } break; case "REMOVEAWAKENING": { if ((!IsGM && !Settings.TestServer) || parts.Length < 2) return; ItemType type; if (!Enum.TryParse(parts[1], true, out type)) return; foreach (UserItem temp in Info.Equipment) { if (temp == null) continue; ItemInfo realItem = Functions.GetRealItem(temp.Info, Info.Level, Info.Class, Envir.ItemInfoList); if (realItem.Type == type) { Awake awake = temp.Awake; int result = awake.RemoveAwake(); switch (result) { case 0: ReceiveChat(string.Format("{0} : Remove failed Level 0", temp.Name), ChatType.System); break; case 1: ReceiveChat(string.Format("{0} : Remove success. Level {1}", temp.Name, temp.Awake.getAwakeLevel()), ChatType.System); p = new S.RefreshItem { Item = temp }; Enqueue(p); break; default: break; } } } } break; case "STARTWAR": if (!IsGM) return; if (parts.Length < 2) return; GuildObject enemyGuild = Envir.GetGuild(parts[1]); if (MyGuild == null) { ReceiveChat("You are not in a guild.", ChatType.System); } if (MyGuild.Ranks[0] != MyGuildRank) { ReceiveChat("You must be a leader to start a war.", ChatType.System); return; } if (enemyGuild == null) { ReceiveChat(string.Format("Could not find guild {0}.", parts[1]), ChatType.System); return; } if (MyGuild == enemyGuild) { ReceiveChat("Cannot go to war with your own guild.", ChatType.System); return; } if (MyGuild.WarringGuilds.Contains(enemyGuild)) { ReceiveChat("Already at war with this guild.", ChatType.System); return; } if (MyGuild.GoToWar(enemyGuild)) { ReceiveChat(string.Format("You started a war with {0}.", parts[1]), ChatType.System); enemyGuild.SendMessage(string.Format("{0} has started a war", MyGuild.Name), ChatType.System); } break; case "ADDINVENTORY": int openLevel = (int)((Info.Inventory.Length - 46) / 4); uint openGold = (uint)(1000000 + openLevel * 1000000); if (Account.Gold >= openGold) { Account.Gold -= openGold; Enqueue(new S.LoseGold { Gold = openGold }); Enqueue(new S.ResizeInventory { Size = Info.ResizeInventory() }); ReceiveChat("Inventory size increased.", ChatType.System); } else { ReceiveChat("Not enough gold.", ChatType.System); } ChatTime = 0; break; case "INFO": { if (!IsGM && !Settings.TestServer) return; MapObject ob = null; if (parts.Length < 2) { Point target = Functions.PointMove(CurrentLocation, Direction, 1); Cell cell = CurrentMap.GetCell(target); if (cell.Objects == null || cell.Objects.Count < 1) return; ob = cell.Objects[0]; } else { ob = Envir.GetPlayer(parts[1]); } if (ob == null) return; switch (ob.Race) { case ObjectType.Player: PlayerObject plOb = (PlayerObject)ob; ReceiveChat("--Player Info--", ChatType.System2); ReceiveChat(string.Format("Name : {0}, Level : {1}, X : {2}, Y : {3}", plOb.Name, plOb.Level, plOb.CurrentLocation.X, plOb.CurrentLocation.Y), ChatType.System2); break; case ObjectType.Monster: MonsterObject monOb = (MonsterObject)ob; ReceiveChat("--Monster Info--", ChatType.System2); ReceiveChat(string.Format("ID : {0}, Name : {1}", monOb.Info.Index, monOb.Name), ChatType.System2); ReceiveChat(string.Format("Level : {0}, X : {1}, Y : {2}", monOb.Level, monOb.CurrentLocation.X, monOb.CurrentLocation.Y), ChatType.System2); break; case ObjectType.Merchant: NPCObject npcOb = (NPCObject)ob; ReceiveChat("--NPC Info--", ChatType.System2); ReceiveChat(string.Format("ID : {0}, Name : {1}", npcOb.Info.Index, npcOb.Name), ChatType.System2); ReceiveChat(string.Format("X : {0}, Y : {1}", ob.CurrentLocation.X, ob.CurrentLocation.Y), ChatType.System2); ReceiveChat(string.Format("File : {0}", npcOb.Info.FileName), ChatType.System2); break; } } break; case "CLEARQUESTS": if (!IsGM && !Settings.TestServer) return; player = parts.Length > 1 && IsGM ? Envir.GetPlayer(parts[1]) : this; if (player == null) { ReceiveChat(parts[1] + " is not online", ChatType.System); return; } foreach (var quest in player.CurrentQuests) { SendUpdateQuest(quest, QuestState.Remove); } player.CurrentQuests.Clear(); player.CompletedQuests.Clear(); player.GetCompletedQuests(); break; case "SETQUEST": if ((!IsGM && !Settings.TestServer) || parts.Length < 3) return; player = parts.Length > 3 && IsGM ? Envir.GetPlayer(parts[3]) : this; if (player == null) { ReceiveChat(parts[3] + " is not online", ChatType.System); return; } int questid = 0; int questState = 0; int.TryParse(parts[1], out questid); int.TryParse(parts[2], out questState); if (questid < 1) return; var activeQuest = player.CurrentQuests.FirstOrDefault(e => e.Index == questid); //remove from active list if (activeQuest != null) { player.SendUpdateQuest(activeQuest, QuestState.Remove); player.CurrentQuests.Remove(activeQuest); } switch (questState) { case 0: //cancel if (player.CompletedQuests.Contains(questid)) player.CompletedQuests.Remove(questid); break; case 1: //complete if (!player.CompletedQuests.Contains(questid)) player.CompletedQuests.Add(questid); break; } player.GetCompletedQuests(); break; case "TOGGLETRANSFORM": Buff b = Buffs.FirstOrDefault(e => e.Type == BuffType.Transform); if (b == null) return; if (!b.Paused) { PauseBuff(b); } else { UnpauseBuff(b); } RefreshStats(); hintstring = b.Paused ? "Transform Disabled." : "Transform Enabled."; ReceiveChat(hintstring, ChatType.Hint); break; case "CREATEMAPINSTANCE": //TEST CODE if (!IsGM || parts.Length < 2) return; map = SMain.Envir.GetMapByNameAndInstance(parts[1]); if (map == null) { ReceiveChat(string.Format("Map {0} does not exist", parts[1]), ChatType.System); return; } MapInfo mapInfo = map.Info; mapInfo.CreateMap(); ReceiveChat(string.Format("Map instance created for map {0}", mapInfo.FileName), ChatType.System); break; case "STARTCONQUEST": //Needs some work, but does job for now. if ((!IsGM && !Settings.TestServer) || parts.Length < 2) return; int ConquestID; if (parts.Length < 1) { ReceiveChat(string.Format("The Syntax is /StartConquest [ConquestID]"), ChatType.System); return; } if (MyGuild == null) { ReceiveChat(string.Format("You need to be in a guild to start a War"), ChatType.System); return; } else if (!int.TryParse(parts[1], out ConquestID)) return; ConquestObject tempConq = Envir.Conquests.FirstOrDefault(t => t.Info.Index == ConquestID); if (tempConq != null) { tempConq.StartType = ConquestType.Forced; tempConq.WarIsOn = !tempConq.WarIsOn; tempConq.AttackerID = MyGuild.Guildindex; } else return; ReceiveChat(string.Format("{0} War Started.", tempConq.Info.Name), ChatType.System); SMain.Enqueue(string.Format("{0} War Started.", tempConq.Info.Name)); break; case "RESETCONQUEST": //Needs some work, but does job for now. if ((!IsGM && !Settings.TestServer) || parts.Length < 2) return; int ConquestNum; if (parts.Length < 1) { ReceiveChat(string.Format("The Syntax is /ResetConquest [ConquestID]"), ChatType.System); return; } if (MyGuild == null) { ReceiveChat(string.Format("You need to be in a guild to start a War"), ChatType.System); return; } else if (!int.TryParse(parts[1], out ConquestNum)) return; ConquestObject ResetConq = Envir.Conquests.FirstOrDefault(t => t.Info.Index == ConquestNum); if (ResetConq != null && !ResetConq.WarIsOn) { ResetConq.Reset(); } else { ReceiveChat("Conquest not found or War is currently on.", ChatType.System); return; } ReceiveChat(string.Format("{0} has been reset.", ResetConq.Info.Name), ChatType.System); break; case "GATES": string openclose = parts[1]; bool OpenClose; if (MyGuild == null || MyGuild.Conquest == null || !MyGuildRank.Options.HasFlag(RankOptions.CanChangeRank) || MyGuild.Conquest.WarIsOn) { ReceiveChat(string.Format("You don't have access to control any gates at the moment."), ChatType.System); return; } if (openclose == null) return; if (openclose.ToUpper() == "CLOSE") OpenClose = true; else if (openclose.ToUpper() == "OPEN") OpenClose = false; else { ReceiveChat(string.Format("You must type /Gates Open or /Gates Close."), ChatType.System); return; } for (int i = 0; i < MyGuild.Conquest.GateList.Count; i++) if (MyGuild.Conquest.GateList[i].Gate != null && !MyGuild.Conquest.GateList[i].Gate.Dead) if (OpenClose) MyGuild.Conquest.GateList[i].Gate.CloseDoor(); else MyGuild.Conquest.GateList[i].Gate.OpenDoor(); if (OpenClose) ReceiveChat(string.Format("The gates at {0} have been closed.", MyGuild.Conquest.Info.Name), ChatType.System); else ReceiveChat(string.Format("The gates at {0} have been opened.", MyGuild.Conquest.Info.Name), ChatType.System); break; default: break; } foreach (string command in Envir.CustomCommands) { if (string.Compare(parts[0], command, true) != 0) continue; CallDefaultNPC(DefaultNPCType.CustomCommand, parts[0]); } } else { message = String.Format("{0}:{1}", CurrentMap.Info.NoNames ? "?????" : Name, message); p = new S.ObjectChat { ObjectID = ObjectID, Text = message, Type = ChatType.Normal }; Enqueue(p); Broadcast(p); } }
public void Chat(string message) { if (string.IsNullOrEmpty(message)) return; SMain.EnqueueChat(string.Format("{0}: {1}", Name, message)); if (GMLogin) { if (message == GMPassword) { IsGM = true; SMain.Enqueue(string.Format("{0} is now a GM", Name)); ReceiveChat("You have been made a GM", ChatType.System); } else { SMain.Enqueue(string.Format("{0} attempted a GM login", Name)); ReceiveChat("Incorrect login password", ChatType.System); } GMLogin = false; return; } string[] parts; message = message.Replace("$pos", Functions.PointToString(CurrentLocation)); Packet p; if (message.StartsWith("/")) { //Private Message message = message.Remove(0, 1); parts = message.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 0) return; PlayerObject player = Envir.GetPlayer(parts[0]); if (player == null) { ReceiveChat(string.Format("Could not find {0}.", parts[0]), ChatType.System); return; } ReceiveChat(string.Format("/{0}", message), ChatType.WhisperOut); player.ReceiveChat(string.Format("{0}=>{1}", Name, message.Remove(0, parts[0].Length)), ChatType.WhisperIn); } else if (message.StartsWith("!!")) { if (GroupMembers == null) return; //Group message = String.Format("{0}:{1}", Name, message.Remove(0, 2)); p = new S.ObjectChat { ObjectID = ObjectID, Text = message, Type = ChatType.Group }; for (int i = 0; i < GroupMembers.Count; i++) GroupMembers[i].Enqueue(p); } else if (message.StartsWith("!~")) { if (MyGuild == null) return; //Guild message = message.Remove(0, 2); MyGuild.SendMessage(String.Format("{0}: {1}", Name, message)); } else if (message.StartsWith("!")) { //Shout if (Envir.Time < ShoutTime) { ReceiveChat(string.Format("You cannot shout for another {0} seconds.", Math.Ceiling((ShoutTime - Envir.Time) / 1000D)), ChatType.System); return; } if (Level < 2) { ReceiveChat("You need to be level 2 before you can shout.", ChatType.System); return; } ShoutTime = Envir.Time + 10000; message = String.Format("(!){0}:{1}", Name, message.Remove(0, 1)); p = new S.Chat {Message = message, Type = ChatType.Shout}; Envir.Broadcast(p); //for (int i = 0; i < CurrentMap.Players.Count; i++) // CurrentMap.Players[i].Enqueue(p); } else if (message.StartsWith("@!")) { if (!IsGM) return; message = String.Format("(*){0}:{1}", Name, message.Remove(0, 2)); p = new S.Chat {Message = message, Type = ChatType.Announcement}; Envir.Broadcast(p); } else if (message.StartsWith("#")) // GM COMMANDS { message = message.Remove(0, 1); parts = message.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 0) return; PlayerObject player; CharacterInfo data; String hintstring; UserItem item; switch (parts[0].ToUpper()) { case "GMKILL": if (!IsGM) return; if (parts.Length >= 2) { player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(string.Format("Could not find {0}", parts[0]), ChatType.System); return; } if (!player.GMNeverDie) player.Die(); } else { if (!CurrentMap.ValidPoint(Front)) return; Cell cell = CurrentMap.GetCell(Front); if (cell == null || cell.Objects == null) return; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; switch (ob.Race) { case ObjectType.Player: case ObjectType.Monster: if (ob.Dead) continue; ob.EXPOwner = this; ob.ExpireTime = Envir.Time + MonsterObject.EXPOwnerDelay; ob.Die(); break; default: continue; } } } return; case "LOGIN": GMLogin = true; ReceiveChat("Please type the GM Password", ChatType.Hint); return; case "GMRESTORE": if (!IsGM || parts.Length < 2) return; data = Envir.GetCharacterInfo(parts[1]); if (data == null) { ReceiveChat(string.Format("Player {0} was not found", parts[1]), ChatType.System); return; } if (!data.Deleted) return; data.Deleted = false; ReceiveChat(string.Format("Player {0} has been restored by", data.Name), ChatType.System); SMain.Enqueue(string.Format("Player {0} has been restored by {1}", data.Name, Name)); break; case "GMCHANGEGENDER": if (!IsGM) return; data = parts.Length < 2 ? Info : Envir.GetCharacterInfo(parts[1]); if (data == null) return; switch (data.Gender) { case MirGender.Male: data.Gender = MirGender.Female; break; case MirGender.Female: data.Gender = MirGender.Male; break; } ReceiveChat(string.Format("Player {0} has been changed to {1}", data.Name, data.Gender), ChatType.System); SMain.Enqueue(string.Format("Player {0} has been changed to {1} by {2}", data.Name, data.Gender, Name)); if (data.Player != null) data.Player.Connection.LogOut(); break; case "GMLEVEL": if (!IsGM || parts.Length < 2) return; byte level; byte old; if (parts.Length >= 3) { if (byte.TryParse(parts[2], out level)) { if (level == 0) return; player = Envir.GetPlayer(parts[1]); if (player == null) return; old = player.Level; player.Level = level; player.LevelUp(); ReceiveChat(string.Format("Player {0} has been Leveled {1} -> {2}.", player.Name, old, player.Level), ChatType.System); SMain.Enqueue(string.Format("Player {0} has been Leveled {1} -> {2} by {3}", player.Name, old, player.Level, Name)); return; } } else { if (byte.TryParse(parts[1], out level)) { if (level == 0) return; old = Level; Level = level; LevelUp(); ReceiveChat(string.Format("Leveled {0} -> {1}.", old, Level), ChatType.System); SMain.Enqueue(string.Format("Player {0} has been Leveled {1} -> {2} by {3}", Name, old, Level, Name)); return; } } ReceiveChat("Could not level player", ChatType.System); return; case "GMMAKE": if (!IsGM || parts.Length < 2) return; ItemInfo iInfo = Envir.GetItemInfo(parts[1]); if (iInfo == null) return; uint count = 1; if (parts.Length >= 3 && !uint.TryParse(parts[2], out count)) count = 1; var tempCount = count; while (count > 0) { if (iInfo.StackSize >= count) { item = Envir.CreateDropItem(iInfo); item.Count = count; if (CanGainItem(item, false)) GainItem(item); return; } item = Envir.CreateDropItem(iInfo); item.Count = iInfo.StackSize; count -= iInfo.StackSize; if (!CanGainItem(item, false)) return; GainItem(item); } ReceiveChat(string.Format("{0} x{1} has been created.", iInfo.Name, tempCount), ChatType.System); SMain.Enqueue(string.Format("Player {0} has attempted to Create {1} x{2}", Name, iInfo.Name, tempCount)); break; case "GMCLEARBAG": if (!IsGM) return; player = this; if (parts.Length >= 2) player = Envir.GetPlayer(parts[1]); if (player == null) return; for (int i = 0; i < player.Info.Inventory.Length; i++) { item = player.Info.Inventory[i]; if (item == null) continue; player.Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = item.Count }); player.Info.Inventory[i] = null; } break; case "SUPER": case "SUPERMAN": if (!IsGM) return; GMNeverDie = !GMNeverDie; hintstring = GMNeverDie ? "Invincible Mode." : "Normal Mode."; ReceiveChat(hintstring, ChatType.Hint); break; case "GM": case "GAMEMASTER": if (!IsGM) return; GMGameMaster = !GMGameMaster; hintstring = GMGameMaster ? "GameMaster Mode." : "Normal Mode."; ReceiveChat(hintstring, ChatType.Hint); break; case "OBS": case "OBSERVER": if (!IsGM) return; Observer = !Observer; hintstring = Observer ? "Observer Mode." : "Normal Mode."; ReceiveChat(hintstring, ChatType.Hint); break; case "GMRECALL": if (!IsGM) return; if (parts.Length < 2) return; player = Envir.GetPlayer(parts[1]); if (player == null) return; player.Teleport(CurrentMap, Front); break; case "GMGO": if (!IsGM) return; if (parts.Length < 2) return; player = Envir.GetPlayer(parts[1]); if (player == null) return; Teleport(player.CurrentMap, player.CurrentLocation); break; case "GMMOB": if (!IsGM) return; if (parts.Length < 2) { ReceiveChat("Not enough parameters to spawn monster", ChatType.System); return; } MonsterInfo mInfo = Envir.GetMonsterInfo(parts[1]); if (mInfo == null) { ReceiveChat((string.Format("Monster {0} does not exist", parts[1])), ChatType.System); return; } count = 1; if (parts.Length >= 3) if (!uint.TryParse(parts[2], out count) || count > 50) count = 1; for (int i = 0; i < count; i++) { MonsterObject monster = MonsterObject.GetMonster(mInfo); if (monster == null) return; monster.Spawn(CurrentMap, Front); } ReceiveChat((string.Format("Monster {0} x{1} has been spawned.", mInfo.Name, count)), ChatType.System); break; case "GMRECALLMOB": if (!IsGM) return; if (parts.Length < 2) return; MonsterInfo mInfo2 = Envir.GetMonsterInfo(parts[1]); if (mInfo2 == null) return; count = 1; byte petlevel = 0; if (parts.Length > 2) if (!uint.TryParse(parts[2], out count) || count > 50) count = 1; if (parts.Length > 3) if (!byte.TryParse(parts[3], out petlevel) || petlevel > 7) petlevel = 0; for (int i = 0; i < count; i++) { MonsterObject monster = MonsterObject.GetMonster(mInfo2); if (monster == null) return; monster.PetLevel = petlevel; monster.Master = this; monster.MaxPetLevel = 7; monster.Direction = Direction; monster.ActionTime = Envir.Time + 1000; monster.Spawn(CurrentMap, Front); Pets.Add(monster); } ReceiveChat((string.Format("Pet {0} x{1} has been recalled.", mInfo2.Name, count)), ChatType.System); break; case "GMRELOADDROPS": if (!IsGM) return; foreach (var t in Envir.MonsterInfoList) t.LoadDrops(); ReceiveChat("Drops Reloaded.", ChatType.Hint); break; case "GMGIVEGOLD": if (!IsGM) return; if (parts.Length < 2) return; player = this; if (parts.Length > 2) { if (!uint.TryParse(parts[2], out count)) return; player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(string.Format("Player {0} was not found.", parts[1]), ChatType.System); return; } } else if (!uint.TryParse(parts[1], out count)) return; if (count + player.Account.Gold >= uint.MaxValue) count = uint.MaxValue - player.Account.Gold; player.GainGold(count); SMain.Enqueue(string.Format("Player {0} has been given {1} gold", player.Name, count)); break; case "GMKICK": { } break; } } else if (message.StartsWith("@")) { //Command message = message.Remove(0, 1); parts = message.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 0) return; PlayerObject player; // CharacterInfo data; String hintstring; // UserItem item; switch (parts[0].ToUpper()) { case "MAPMOVE": if (!IsGM) return; if (parts.Length < 2) return; var instanceID = 1;int x = 0; int y = 0; if (parts.Length == 3 || parts.Length == 5) int.TryParse(parts[2], out instanceID); if (instanceID < 1) instanceID = 1; var map = SMain.Envir.GetMapByNameAndInstance(parts[1], instanceID); if (map == null) { ReceiveChat((string.Format("Map {0}:[{1}] could not be found", parts[1], instanceID)), ChatType.System); return; } if (parts.Length == 4 || parts.Length == 5) { int.TryParse(parts[parts.Length - 2], out x); int.TryParse(parts[parts.Length - 1], out y); } switch (parts.Length) { case 2: ReceiveChat(TeleportRandom(200, 0, map) ? (string.Format("Moved to Map {0}", map.Info.FileName)) : (string.Format("Failed movement to Map {0}", map.Info.FileName)), ChatType.System); break; case 3: ReceiveChat(TeleportRandom(200, 0, map) ? (string.Format("Moved to Map {0}:[{1}]", map.Info.FileName, instanceID)) : (string.Format("Failed movement to Map {0}:[{1}]", map.Info.FileName, instanceID)), ChatType.System); break; case 4: ReceiveChat(Teleport(map, new Point(x, y)) ? (string.Format("Moved to Map {0} at {1}:{2}", map.Info.FileName, x, y)): (string.Format("Failed movement to Map {0} at {1}:{2}", map.Info.FileName, x, y)), ChatType.System); break; case 5: ReceiveChat(Teleport(map, new Point(x, y)) ? (string.Format("Moved to Map {0}:[{1}] at {2}:{3}", map.Info.FileName, instanceID, x, y)) : (string.Format("Failed movement to Map {0}:[{1}] at {2}:{3}", map.Info.FileName, instanceID, x, y)), ChatType.System); break; } break; case "ALLOWGUILD": EnableGuildInvite = !EnableGuildInvite; hintstring = EnableGuildInvite ? "Guild invites enabled." : "Guild invites disabled."; ReceiveChat(hintstring, ChatType.Hint); break; case "ENABLEGROUPRECALL": EnableGroupRecall = !EnableGroupRecall; hintstring = EnableGroupRecall ? "Group Recall Enabled." : "Group Recall Disabled."; ReceiveChat(hintstring, ChatType.Hint); break; case "GROUPRECALL": if (GroupMembers == null || GroupMembers[0] != this || Dead) return; if (CurrentMap.Info.NoRecall) { ReceiveChat("You cannot recall people on this map", ChatType.System); return; } if (Envir.Time < LastRecallTime) { ReceiveChat(string.Format("You cannot recall for another {0} seconds", (LastRecallTime - Envir.Time) / 1000), ChatType.System); return; } if (ItemSets.Any(set => set.Set == ItemSet.Recall && set.SetComplete)) { LastRecallTime = Envir.Time + 180000; for (var i = 1; i < GroupMembers.Count(); i++) { if (GroupMembers[i].EnableGroupRecall) GroupMembers[i].Teleport(CurrentMap, CurrentLocation); else GroupMembers[i].ReceiveChat("A recall was attempted without your permission", ChatType.System); } } break; case "RECALLMEMBER": if (GroupMembers == null || GroupMembers[0] != this) { ReceiveChat("You are not a group leader.", ChatType.System); return; } if (Dead) { ReceiveChat("You cannot recall when you are dead.", ChatType.System); return; } if (Envir.Time < LastRecallTime) { ReceiveChat(string.Format("You cannot recall for another {0} seconds", (LastRecallTime - Envir.Time) / 1000), ChatType.System); return; } if (ItemSets.Any(set => set.Set == ItemSet.Recall && set.SetComplete)) { if (parts.Length < 2) return; player = Envir.GetPlayer(parts[1]); if (player == null || !IsMember(player) || this == player) { ReceiveChat((string.Format("Player {0} could not be found", parts[1])), ChatType.System); return; } if (!player.EnableGroupRecall) { player.ReceiveChat("A recall was attempted without your permission", ChatType.System); ReceiveChat((string.Format("{0} is blocking grouprecall", player.Name)), ChatType.System); return; } LastRecallTime = Envir.Time + 60000; if (!player.Teleport(CurrentMap, Front)) player.Teleport(CurrentMap, CurrentLocation); } else { ReceiveChat("You cannot recall without a recallset.", ChatType.System); return; } break; case "DATE": ReceiveChat(string.Format("The time is : {0}", DateTime.Now.ToString("hh:mm tt")), ChatType.System); break; case "MAP": var mapName = CurrentMap.Info.FileName; var mapTitle = CurrentMap.Info.Title; ReceiveChat((string.Format("You are currently in {0}. Map ID: {1}", mapTitle, mapName)), ChatType.System); break; case "MOVE": if (!IsGM && !HasTeleportRing) return; if (!IsGM && CurrentMap.Info.NoPosition) { ReceiveChat(("You cannot position move on this map"), ChatType.System); return; } if (Envir.Time < LastTeleportTime) { ReceiveChat(string.Format("You cannot teleport for another {0} seconds", (LastTeleportTime - Envir.Time) / 1000), ChatType.System); return; } // int f = 0, g; if (parts.Length <= 2 || !int.TryParse(parts[1], out x) || !int.TryParse(parts[2], out y)) { if (!IsGM) LastTeleportTime = Envir.Time + 180000; TeleportRandom(200, 0); return; } if (!IsGM) LastTeleportTime = Envir.Time + 180000; Teleport(CurrentMap, new Point(x, y)); break; case "FIND": if (!IsGM && !HasProbeNecklace) return; if (Envir.Time < LastProbeTime) { ReceiveChat(string.Format("You cannot search for another {0} seconds", (LastProbeTime - Envir.Time) / 1000), ChatType.System); return; } if (parts.Length < 2) return; player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(parts[1] + " is not online", ChatType.System); return; } if (player.CurrentMap == null) return; if (!IsGM) LastProbeTime = Envir.Time + 180000; ReceiveChat((string.Format("{0} is located at {1} ({2},{3})", player.Name, player.CurrentMap.Info.Title, player.CurrentLocation.X, player.CurrentLocation.Y)), ChatType.System); break; case "LEAVEGUILD": if (MyGuild == null) return; if (MyGuildRank == null) return; MyGuild.DeleteMember(this, Name); break; case "CREATEGUILD": if (!IsGM) return; if (parts.Length < 3) return; player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(string.Format("Player {0} was not found.", parts[1]), ChatType.System); return; } if (player.MyGuild != null) { ReceiveChat(string.Format("Player {0} is already in a guild.", parts[1]), ChatType.System); return; } if ((parts[2].Length < 3) || (parts[2].Length > 20)) { ReceiveChat("Guildname is restricted to 3-20 characters.", ChatType.System); return; } GuildObject guild = Envir.GetGuild(parts[2]); if (guild != null) { ReceiveChat(string.Format("Guild {0} already exists.", parts[2]), ChatType.System); return; } player.CanCreateGuild = true; if (player.CreateGuild(parts[2])) ReceiveChat(string.Format("Succesfully created guild {0}", parts[2]), ChatType.System); else ReceiveChat("Failed to create guild", ChatType.System); player.CanCreateGuild = false; break; } } else { //FAR - NPC Listener code //if (NPCListener != null && NPCListener.Active) //{ // if (NPCID == NPCListener.NPCID) // { // NPCPage.AddVariable(this, NPCListener.NPCVariable, message); // NPCListener.Active = false; // NPCJumpPage = new NPCJumpPage // { // NPCID = NPCListener.NPCID, // TimePeriod = 0, // NPCGotoPage = "[" + NPCListener.NPCGotoPage + "]" // }; // } // else // { // NPCListener.Active = false; // } //} message = String.Format("{0}:{1}", CurrentMap.Info.NoNames ? "?????" : Name, message); p = new S.ObjectChat { ObjectID = ObjectID, Text = message, Type = ChatType.Normal }; Enqueue(p); Broadcast(p); } }
public void Chat(string message) { if (string.IsNullOrEmpty(message)) return; SMain.EnqueueChat(string.Format("{0}: {1}", Name, message)); if (GMLogin) { if (message == GMPassword) { IsGM = true; SMain.Enqueue(string.Format("{0} is now a GM", Name)); } GMLogin = false; return; } string[] parts; message = message.Replace("$pos", Functions.PointToString(CurrentLocation)); Packet p; if (message.StartsWith("/")) { //Private Message message = message.Remove(0, 1); parts = message.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 0) return; PlayerObject player = Envir.GetPlayer(parts[0]); if (player == null) { ReceiveChat(string.Format("Could not find {0}.", parts[0]), ChatType.System); return; } ReceiveChat(string.Format("/{0}", message), ChatType.WhisperOut); player.ReceiveChat(string.Format("{0}=>{1}", Name, message.Remove(0, parts[0].Length)), ChatType.WhisperIn); } else if (message.StartsWith("!!")) { if (GroupMembers == null) return; //Group message = String.Format("{0}:{1}", Name, message.Remove(0, 2)); p = new S.ObjectChat { ObjectID = ObjectID, Text = message, Type = ChatType.Group }; for (int i = 0; i < GroupMembers.Count; i++) GroupMembers[i].Enqueue(p); } else if (message.StartsWith("!~")) { //Guild //message = message.Remove(0, 2); } else if (message.StartsWith("!")) { //Shout if (Envir.Time < ShoutTime) { ReceiveChat(string.Format("You cannot shout for another {0} seconds.", Math.Ceiling((ShoutTime - Envir.Time) / 1000D)), ChatType.System); return; } if (Level < 2) { ReceiveChat("You need to be level 2 before you can shout.", ChatType.System); return; } ShoutTime = Envir.Time + 10000; message = String.Format("(!){0}:{1}", Name, message.Remove(0, 1)); p = new S.Chat {Message = message, Type = ChatType.Shout}; Envir.Broadcast(p); //for (int i = 0; i < CurrentMap.Players.Count; i++) // CurrentMap.Players[i].Enqueue(p); } else if (message.StartsWith("@!")) { if (!IsGM) return; message = String.Format("(*){0}:{1}", Name, message.Remove(0, 2)); p = new S.Chat {Message = message, Type = ChatType.Announcement}; Envir.Broadcast(p); } else if (message.StartsWith("@")) { //Command message = message.Remove(0, 1); parts = message.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 0) return; PlayerObject player; CharacterInfo data; String hintstring; switch (parts[0].ToUpper()) { case "LOGIN": GMLogin = true; ReceiveChat("Please type the GM Password", ChatType.Hint); return; case "KILL": if (!IsGM) return; if (parts.Length >= 2) { player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(string.Format("Could not find {0}.", parts[0]), ChatType.System); return; } if (!player.GMNeverDie) player.Die(); } else { if (!CurrentMap.ValidPoint(Front)) return; Cell cell = CurrentMap.GetCell(Front); if (cell == null || cell.Objects == null) return; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; switch (ob.Race) { case ObjectType.Player: case ObjectType.Monster: if (ob.Dead) continue; ob.EXPOwner = this; ob.ExpireTime = Envir.Time + MonsterObject.EXPOwnerDelay; ob.Die(); break; default: continue; } } } return; case "RESTORE": if (!IsGM || parts.Length < 2) return; data = Envir.GetCharacterInfo(parts[1]); if (data == null) { ReceiveChat(string.Format("{0} was not found", parts[1]), ChatType.System); return; } if (!data.Deleted) return; data.Deleted = false; SMain.Enqueue(string.Format("Player {0} has been restored by {2}", data.Name, data.Gender, Name)); break; case "CHANGEGENDER": if (!IsGM) return; data = parts.Length < 2 ? Info : Envir.GetCharacterInfo(parts[1]); if (data == null) return; switch (data.Gender) { case MirGender.Male: data.Gender = MirGender.Female; break; case MirGender.Female: data.Gender = MirGender.Male; break; } SMain.Enqueue(string.Format("Player {0} has been changed to {1} by {2}", data.Name, data.Gender, Name)); if (data.Player != null) data.Player.Connection.LogOut(); break; case "LEVEL": if (!IsGM) return; byte level; byte old; if (parts.Length >= 3) { if (byte.TryParse(parts[2], out level)) { if (level == 0) return; player = Envir.GetPlayer(parts[1]); if (player == null) return; old = player.Level; player.Level = level; player.LevelUp(); SMain.Enqueue(string.Format("Player {0} has been Leveled {1} -> {2} by {3}", player.Name, old, player.Level, Name)); } } else { if (byte.TryParse(parts[1], out level)) { if (level == 0) return; old = Level; Level = level; LevelUp(); SMain.Enqueue(string.Format("Player {0} has been Leveled {1} -> {2} by {3}", Name, old, Level, Name)); } } return; case "MAKE": if (!IsGM || parts.Length < 2) return; ItemInfo iInfo = Envir.GetItemInfo(parts[1]); if (iInfo == null) return; uint count = 1; if (parts.Length >= 3 && !uint.TryParse(parts[2], out count)) count = 1; while (count > 0) { UserItem item; if (iInfo.StackSize >= count) { item = Envir.CreateDropItem(iInfo); item.Count = count; SMain.Enqueue(string.Format("Player {0} has attempted to Create {1} x{2}", Name, iInfo.Name, item.Count)); if (CanGainItem(item, false)) GainItem(item); return; } item = Envir.CreateDropItem(iInfo); item.Count = iInfo.StackSize; count -= iInfo.StackSize; SMain.Enqueue(string.Format("Player {0} has attempted to Create {1} x{2}", Name, iInfo.Name, item.Count)); if (!CanGainItem(item, false)) return; GainItem(item); } break; case "CLEARBAG": if (!IsGM) return; player = this; if (parts.Length >= 2) player = Envir.GetPlayer(parts[1]); if (player == null) return; for (int i = 0; i < player.Info.Inventory.Length; i++) { UserItem item = player.Info.Inventory[i]; if (item == null) continue; player.Enqueue(new S.DeleteItem {UniqueID = item.UniqueID, Count = item.Count}); player.Info.Inventory[i] = null; } break; case "SUPERMAN": if (!IsGM) return; GMNeverDie = !GMNeverDie; hintstring = GMNeverDie ? "Invincible Mode." : "Normal Mode."; ReceiveChat(hintstring, ChatType.Hint); break; case "GAMEMASTER": if (!IsGM) return; GMGameMaster = !GMGameMaster; hintstring = GMGameMaster ? "GameMaster Mode." : "Normal Mode."; ReceiveChat(hintstring, ChatType.Hint); break; case "RECALL": if (!IsGM) return; if (parts.Length < 2) return; player = Envir.GetPlayer(parts[1]); if (player == null) return; player.Teleport(CurrentMap, Front); break; case "RECALLMEMBER": if (GroupMembers == null || GroupMembers[0] != this) { ReceiveChat("You are a group leader.", ChatType.System); return; } if (Dead) { ReceiveChat("You cannot recall when you are dead.", ChatType.System); return; } if (parts.Length < 2) return; player = Envir.GetPlayer(parts[1]); if (player == null || !IsMember(player) || this == player) return; if (!player.Teleport(CurrentMap, Front)) player.Teleport(CurrentMap, CurrentLocation); break; case "MOVE": if (!IsGM && !HasTeleportRing) return; int x, y; if (parts.Length <= 2 || !int.TryParse(parts[1], out x) || !int.TryParse(parts[2], out y)) { TeleportRandom(40, 0); return; } Teleport(CurrentMap, new Point(x, y)); break; case "GOTO": if (!IsGM) return; if (parts.Length < 2) return; player = Envir.GetPlayer(parts[1]); if (player == null) return; Teleport(player.CurrentMap, player.CurrentLocation); break; case "MOB": if (!IsGM) return; if (parts.Length < 2) return; MonsterInfo mInfo = Envir.GetMonsterInfo(parts[1]); if (mInfo == null) return; count = 1; if (parts.Length >= 3) if (!uint.TryParse(parts[2], out count) || count > 50) count = 1; for (int i = 0; i < count; i++) { MonsterObject monster = MonsterObject.GetMonster(mInfo); if (monster == null) return; monster.Spawn(CurrentMap, Front); } break; case "RELOADDROPS": for (int i = 0; i < Envir.MonsterInfoList.Count; i++) Envir.MonsterInfoList[i].LoadDrops(); ReceiveChat("Drops Reloaded.", ChatType.Hint); break; } } else { message = String.Format("{0}:{1}", Name, message); p = new S.ObjectChat {ObjectID = ObjectID, Text = message, Type = ChatType.Normal}; Enqueue(p); Broadcast(p); } }
public void ObjectChat(S.ObjectChat p) { GameScene.ChatController.ReceiveChat(p.Text, p.Type); }
public void Chat(string message) { if (string.IsNullOrEmpty(message)) return; SMain.EnqueueChat(string.Format("{0}: {1}", Name, message)); if (GMLogin) { if (message == GMPassword) { IsGM = true; SMain.Enqueue(string.Format("{0} is now a GM", Name)); ReceiveChat("You have been made a GM", ChatType.System); } else { SMain.Enqueue(string.Format("{0} attempted a GM login", Name)); ReceiveChat("Incorrect login password", ChatType.System); } GMLogin = false; return; } if (Info.ChatBanned) { if (Info.ChatBanExpiryDate > DateTime.Now) { ReceiveChat("You are currently banned from chatting.", ChatType.System); return; } Info.ChatBanned = false; } string[] parts; message = message.Replace("$pos", Functions.PointToString(CurrentLocation)); Packet p; if (message.StartsWith("/")) { //Private Message message = message.Remove(0, 1); parts = message.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 0) return; PlayerObject player = Envir.GetPlayer(parts[0]); if (player == null) { ReceiveChat(string.Format("Could not find {0}.", parts[0]), ChatType.System); return; } ReceiveChat(string.Format("/{0}", message), ChatType.WhisperOut); player.ReceiveChat(string.Format("{0}=>{1}", Name, message.Remove(0, parts[0].Length)), ChatType.WhisperIn); } else if (message.StartsWith("!!")) { if (GroupMembers == null) return; //Group message = String.Format("{0}:{1}", Name, message.Remove(0, 2)); p = new S.ObjectChat { ObjectID = ObjectID, Text = message, Type = ChatType.Group }; for (int i = 0; i < GroupMembers.Count; i++) GroupMembers[i].Enqueue(p); } else if (message.StartsWith("!~")) { if (MyGuild == null) return; //Guild message = message.Remove(0, 2); MyGuild.SendMessage(String.Format("{0}: {1}", Name, message)); } else if (message.StartsWith("!")) { //Shout if (Envir.Time < ShoutTime) { ReceiveChat(string.Format("You cannot shout for another {0} seconds.", Math.Ceiling((ShoutTime - Envir.Time) / 1000D)), ChatType.System); return; } if (Level < 7) { ReceiveChat("You need to be level 7 before you can shout.", ChatType.System); return; } ShoutTime = Envir.Time + 10000; message = String.Format("(!){0}:{1}", Name, message.Remove(0, 1)); p = new S.Chat { Message = message, Type = ChatType.Shout }; //Envir.Broadcast(p); for (int i = 0; i < CurrentMap.Players.Count; i++) { if (!Functions.InRange(CurrentLocation, CurrentMap.Players[i].CurrentLocation, Globals.DataRange * 2)) continue; CurrentMap.Players[i].Enqueue(p); } } else if (message.StartsWith("@!")) { if (!IsGM) return; message = String.Format("(*){0}:{1}", Name, message.Remove(0, 2)); p = new S.Chat { Message = message, Type = ChatType.Announcement }; Envir.Broadcast(p); } else if (message.StartsWith("@")) { //Command message = message.Remove(0, 1); parts = message.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 0) return; PlayerObject player; CharacterInfo data; String hintstring; UserItem item; switch (parts[0].ToUpper()) { case "LOGIN": GMLogin = true; ReceiveChat("Please type the GM Password", ChatType.Hint); return; case "KILL": if (!IsGM) return; if (parts.Length >= 2) { player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(string.Format("Could not find {0}", parts[0]), ChatType.System); return; } if (!player.GMNeverDie) player.Die(); } else { if (!CurrentMap.ValidPoint(Front)) return; Cell cell = CurrentMap.GetCell(Front); if (cell == null || cell.Objects == null) return; for (int i = 0; i < cell.Objects.Count; i++) { MapObject ob = cell.Objects[i]; switch (ob.Race) { case ObjectType.Player: case ObjectType.Monster: if (ob.Dead) continue; ob.EXPOwner = this; ob.ExpireTime = Envir.Time + MonsterObject.EXPOwnerDelay; ob.Die(); break; default: continue; } } } return; case "RESTORE": if (!IsGM || parts.Length < 2) return; data = Envir.GetCharacterInfo(parts[1]); if (data == null) { ReceiveChat(string.Format("Player {0} was not found", parts[1]), ChatType.System); return; } if (!data.Deleted) return; data.Deleted = false; ReceiveChat(string.Format("Player {0} has been restored by", data.Name), ChatType.System); SMain.Enqueue(string.Format("Player {0} has been restored by {1}", data.Name, Name)); break; case "CHANGEGENDER": if (!IsGM) return; data = parts.Length < 2 ? Info : Envir.GetCharacterInfo(parts[1]); if (data == null) return; switch (data.Gender) { case MirGender.Male: data.Gender = MirGender.Female; break; case MirGender.Female: data.Gender = MirGender.Male; break; } ReceiveChat(string.Format("Player {0} has been changed to {1}", data.Name, data.Gender), ChatType.System); SMain.Enqueue(string.Format("Player {0} has been changed to {1} by {2}", data.Name, data.Gender, Name)); if (data.Player != null) data.Player.Connection.LogOut(); break; case "LEVEL": if (!IsGM || parts.Length < 2) return; byte level; byte old; if (parts.Length >= 3) { if (byte.TryParse(parts[2], out level)) { if (level == 0) return; player = Envir.GetPlayer(parts[1]); if (player == null) return; old = player.Level; player.Level = level; player.LevelUp(); ReceiveChat(string.Format("Player {0} has been Leveled {1} -> {2}.", player.Name, old, player.Level), ChatType.System); SMain.Enqueue(string.Format("Player {0} has been Leveled {1} -> {2} by {3}", player.Name, old, player.Level, Name)); return; } } else { if (byte.TryParse(parts[1], out level)) { if (level == 0) return; old = Level; Level = level; LevelUp(); ReceiveChat(string.Format("Leveled {0} -> {1}.", old, Level), ChatType.System); SMain.Enqueue(string.Format("Player {0} has been Leveled {1} -> {2} by {3}", Name, old, Level, Name)); return; } } ReceiveChat("Could not level player", ChatType.System); return; case "MAKE": if (!IsGM || parts.Length < 2) return; ItemInfo iInfo = Envir.GetItemInfo(parts[1]); if (iInfo == null) return; uint count = 1; if (parts.Length >= 3 && !uint.TryParse(parts[2], out count)) count = 1; var tempCount = count; while (count > 0) { if (iInfo.StackSize >= count) { item = Envir.CreateDropItem(iInfo); item.Count = count; if (CanGainItem(item, false)) GainItem(item); return; } item = Envir.CreateDropItem(iInfo); item.Count = iInfo.StackSize; count -= iInfo.StackSize; if (!CanGainItem(item, false)) return; GainItem(item); } ReceiveChat(string.Format("{0} x{1} has been created.", iInfo.Name, tempCount), ChatType.System); SMain.Enqueue(string.Format("Player {0} has attempted to Create {1} x{2}", Name, iInfo.Name, tempCount)); break; case "CLEARBAG": if (!IsGM) return; player = this; if (parts.Length >= 2) player = Envir.GetPlayer(parts[1]); if (player == null) return; for (int i = 0; i < player.Info.Inventory.Length; i++) { item = player.Info.Inventory[i]; if (item == null) continue; player.Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = item.Count }); player.Info.Inventory[i] = null; } break; case "SUPERMAN": if (!IsGM) return; GMNeverDie = !GMNeverDie; hintstring = GMNeverDie ? "Invincible Mode." : "Normal Mode."; ReceiveChat(hintstring, ChatType.Hint); break; case "GAMEMASTER": if (!IsGM) return; GMGameMaster = !GMGameMaster; hintstring = GMGameMaster ? "GameMaster Mode." : "Normal Mode."; ReceiveChat(hintstring, ChatType.Hint); break; case "OBSERVER": if (!IsGM) return; Observer = !Observer; hintstring = Observer ? "Observer Mode." : "Normal Mode."; ReceiveChat(hintstring, ChatType.Hint); break; case "ALLOWGUILD": EnableGuildInvite = !EnableGuildInvite; hintstring = EnableGuildInvite ? "Guild invites enabled." : "Guild invites disabled."; ReceiveChat(hintstring, ChatType.Hint); break; case "RECALL": if (!IsGM) return; if (parts.Length < 2) return; player = Envir.GetPlayer(parts[1]); if (player == null) return; player.Teleport(CurrentMap, Front); break; case "ENABLEGROUPRECALL": EnableGroupRecall = !EnableGroupRecall; hintstring = EnableGroupRecall ? "Group Recall Enabled." : "Group Recall Disabled."; ReceiveChat(hintstring, ChatType.Hint); break; case "GROUPRECALL": if (GroupMembers == null || GroupMembers[0] != this || Dead) return; if (CurrentMap.Info.NoRecall) { ReceiveChat("You cannot recall people on this map", ChatType.System); return; } if (Envir.Time < LastRecallTime) { ReceiveChat(string.Format("You cannot recall for another {0} seconds", (LastRecallTime - Envir.Time) / 1000), ChatType.System); return; } if (ItemSets.Any(set => set.Set == ItemSet.Recall && set.SetComplete)) { LastRecallTime = Envir.Time + 180000; for (var i = 1; i < GroupMembers.Count(); i++) { if (GroupMembers[i].EnableGroupRecall) GroupMembers[i].Teleport(CurrentMap, CurrentLocation); else GroupMembers[i].ReceiveChat("A recall was attempted without your permission", ChatType.System); } } break; case "RECALLMEMBER": if (GroupMembers == null || GroupMembers[0] != this) { ReceiveChat("You are not a group leader.", ChatType.System); return; } if (Dead) { ReceiveChat("You cannot recall when you are dead.", ChatType.System); return; } if (Envir.Time < LastRecallTime) { ReceiveChat(string.Format("You cannot recall for another {0} seconds", (LastRecallTime - Envir.Time) / 1000), ChatType.System); return; } if (ItemSets.Any(set => set.Set == ItemSet.Recall && set.SetComplete)) { if (parts.Length < 2) return; player = Envir.GetPlayer(parts[1]); if (player == null || !IsMember(player) || this == player) { ReceiveChat((string.Format("Player {0} could not be found", parts[1])), ChatType.System); return; } if (!player.EnableGroupRecall) { player.ReceiveChat("A recall was attempted without your permission", ChatType.System); ReceiveChat((string.Format("{0} is blocking grouprecall", player.Name)), ChatType.System); return; } LastRecallTime = Envir.Time + 60000; if (!player.Teleport(CurrentMap, Front)) player.Teleport(CurrentMap, CurrentLocation); } else { ReceiveChat("You cannot recall without a recallset.", ChatType.System); return; } break; case "TIME": ReceiveChat(string.Format("The time is : {0}", DateTime.Now.ToString("hh:mm tt")), ChatType.System); break; case "ROLL": int diceNum = Envir.Random.Next(5) + 1; if (GroupMembers == null) { return; } for (int i = 0; i < GroupMembers.Count; i++) { PlayerObject playerSend = GroupMembers[i]; playerSend.ReceiveChat(string.Format("{0} has rolled a {1}", Name, diceNum), ChatType.Group); } break; case "MAP": var mapName = CurrentMap.Info.FileName; var mapTitle = CurrentMap.Info.Title; ReceiveChat((string.Format("You are currently in {0}. Map ID: {1}", mapTitle, mapName)), ChatType.System); break; case "MOVE": if (!IsGM && !HasTeleportRing) return; if (!IsGM && CurrentMap.Info.NoPosition) { ReceiveChat(("You cannot position move on this map"), ChatType.System); return; } if (Envir.Time < LastTeleportTime) { ReceiveChat(string.Format("You cannot teleport for another {0} seconds", (LastTeleportTime - Envir.Time) / 1000), ChatType.System); return; } int x, y; if (parts.Length <= 2 || !int.TryParse(parts[1], out x) || !int.TryParse(parts[2], out y)) { if (!IsGM) LastTeleportTime = Envir.Time + 180000; TeleportRandom(200, 0); return; } if (!IsGM) LastTeleportTime = Envir.Time + 180000; Teleport(CurrentMap, new Point(x, y)); break; case "MAPMOVE": if (!IsGM) return; if (parts.Length < 2) return; var instanceID = 1; x = 0; y = 0; if (parts.Length == 3 || parts.Length == 5) int.TryParse(parts[2], out instanceID); if (instanceID < 1) instanceID = 1; var map = SMain.Envir.GetMapByNameAndInstance(parts[1], instanceID); if (map == null) { ReceiveChat((string.Format("Map {0}:[{1}] could not be found", parts[1], instanceID)), ChatType.System); return; } if (parts.Length == 4 || parts.Length == 5) { int.TryParse(parts[parts.Length - 2], out x); int.TryParse(parts[parts.Length - 1], out y); } switch (parts.Length) { case 2: ReceiveChat(TeleportRandom(200, 0, map) ? (string.Format("Moved to Map {0}", map.Info.FileName)) : (string.Format("Failed movement to Map {0}", map.Info.FileName)), ChatType.System); break; case 3: ReceiveChat(TeleportRandom(200, 0, map) ? (string.Format("Moved to Map {0}:[{1}]", map.Info.FileName, instanceID)) : (string.Format("Failed movement to Map {0}:[{1}]", map.Info.FileName, instanceID)), ChatType.System); break; case 4: ReceiveChat(Teleport(map, new Point(x, y)) ? (string.Format("Moved to Map {0} at {1}:{2}", map.Info.FileName, x, y)) : (string.Format("Failed movement to Map {0} at {1}:{2}", map.Info.FileName, x, y)), ChatType.System); break; case 5: ReceiveChat(Teleport(map, new Point(x, y)) ? (string.Format("Moved to Map {0}:[{1}] at {2}:{3}", map.Info.FileName, instanceID, x, y)) : (string.Format("Failed movement to Map {0}:[{1}] at {2}:{3}", map.Info.FileName, instanceID, x, y)), ChatType.System); break; } break; case "GOTO": if (!IsGM) return; if (parts.Length < 2) return; player = Envir.GetPlayer(parts[1]); if (player == null) return; Teleport(player.CurrentMap, player.CurrentLocation); break; case "MOB": if (!IsGM) return; if (parts.Length < 2) { ReceiveChat("Not enough parameters to spawn monster", ChatType.System); return; } MonsterInfo mInfo = Envir.GetMonsterInfo(parts[1]); if (mInfo == null) { ReceiveChat((string.Format("Monster {0} does not exist", parts[1])), ChatType.System); return; } count = 1; if (parts.Length >= 3) if (!uint.TryParse(parts[2], out count) || count > 50) count = 1; for (int i = 0; i < count; i++) { MonsterObject monster = MonsterObject.GetMonster(mInfo); if (monster == null) return; monster.Spawn(CurrentMap, Front); } ReceiveChat((string.Format("Monster {0} x{1} has been spawned.", mInfo.Name, count)), ChatType.System); break; case "RECALLMOB": if (!IsGM) return; if (parts.Length < 2) return; MonsterInfo mInfo2 = Envir.GetMonsterInfo(parts[1]); if (mInfo2 == null) return; count = 1; byte petlevel = 0; if (parts.Length > 2) if (!uint.TryParse(parts[2], out count) || count > 50) count = 1; if (parts.Length > 3) if (!byte.TryParse(parts[3], out petlevel) || petlevel > 7) petlevel = 0; for (int i = 0; i < count; i++) { MonsterObject monster = MonsterObject.GetMonster(mInfo2); if (monster == null) return; monster.PetLevel = petlevel; monster.Master = this; monster.MaxPetLevel = 7; monster.Direction = Direction; monster.ActionTime = Envir.Time + 1000; monster.Spawn(CurrentMap, Front); Pets.Add(monster); } ReceiveChat((string.Format("Pet {0} x{1} has been recalled.", mInfo2.Name, count)), ChatType.System); break; case "RELOADDROPS": if (!IsGM) return; foreach (var t in Envir.MonsterInfoList) t.LoadDrops(); ReceiveChat("Drops Reloaded.", ChatType.Hint); break; case "RELOADNPCS": if (!IsGM) return; for (int i = 0; i < CurrentMap.NPCs.Count; i++) { CurrentMap.NPCs[i].LoadInfo(true); } DefaultNPC.LoadInfo(true); ReceiveChat("NPCs Reloaded.", ChatType.Hint); break; case "GIVEGOLD": if (!IsGM) return; if (parts.Length < 2) return; player = this; if (parts.Length > 2) { if (!uint.TryParse(parts[2], out count)) return; player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(string.Format("Player {0} was not found.", parts[1]), ChatType.System); return; } } else if (!uint.TryParse(parts[1], out count)) return; if (count + player.Account.Gold >= uint.MaxValue) count = uint.MaxValue - player.Account.Gold; player.GainGold(count); SMain.Enqueue(string.Format("Player {0} has been given {1} gold", player.Name, count)); break; case "GIVESKILL": if (!IsGM) return; if (parts.Length < 3) return; byte spellLevel = 0; player = this; Spell skill; if (!Enum.TryParse(parts.Length > 3 ? parts[2] : parts[1], true, out skill)) return; if (skill == Spell.None) return; spellLevel = byte.TryParse(parts.Length > 3 ? parts[3] : parts[2], out spellLevel) ? Math.Min((byte)3, spellLevel) : (byte)0; if (parts.Length > 3) { player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(string.Format("Player {0} was not found.", parts[1]), ChatType.System); return; } } if (player.Info.Magics.Any(e => e.Spell == skill)) { player.Info.Magics.FirstOrDefault(e => e.Spell == skill).Level = spellLevel; player.ReceiveChat(string.Format("Spell {0} changed to level {1}", skill.ToString(), spellLevel), ChatType.Hint); return; } var magic = new UserMagic(skill) { Level = spellLevel }; player.ReceiveChat(string.Format("You have learned {0} at level {1}", skill.ToString(), spellLevel), ChatType.Hint); if (player != this) { ReceiveChat(string.Format("{0} has learned {1} at level {2}", player.Name, skill.ToString(), spellLevel), ChatType.Hint); } player.Info.Magics.Add(magic); player.Enqueue(magic.GetInfo()); player.RefreshStats(); break; case "FIND": if (!IsGM && !HasProbeNecklace) return; if (Envir.Time < LastProbeTime) { ReceiveChat(string.Format("You cannot search for another {0} seconds", (LastProbeTime - Envir.Time) / 1000), ChatType.System); return; } if (parts.Length < 2) return; player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(parts[1] + " is not online", ChatType.System); return; } if (player.CurrentMap == null) return; if (!IsGM) LastProbeTime = Envir.Time + 180000; ReceiveChat((string.Format("{0} is located at {1} ({2},{3})", player.Name, player.CurrentMap.Info.Title, player.CurrentLocation.X, player.CurrentLocation.Y)), ChatType.System); break; case "LEAVEGUILD": if (MyGuild == null) return; if (MyGuildRank == null) return; MyGuild.DeleteMember(this, Name); break; case "CREATEGUILD": if (!IsGM) return; if (parts.Length < 3) return; player = Envir.GetPlayer(parts[1]); if (player == null) { ReceiveChat(string.Format("Player {0} was not found.", parts[1]), ChatType.System); return; } if (player.MyGuild != null) { ReceiveChat(string.Format("Player {0} is already in a guild.", parts[1]), ChatType.System); return; } if ((parts[2].Length < 3) || (parts[2].Length > 20)) { ReceiveChat("Guildname is restricted to 3-20 characters.", ChatType.System); return; } GuildObject guild = Envir.GetGuild(parts[2]); if (guild != null) { ReceiveChat(string.Format("Guild {0} already exists.", parts[2]), ChatType.System); return; } player.CanCreateGuild = true; if (player.CreateGuild(parts[2])) ReceiveChat(string.Format("Successfully created guild {0}", parts[2]), ChatType.System); else ReceiveChat("Failed to create guild", ChatType.System); player.CanCreateGuild = false; break; case "ALLOWTRADE": AllowTrade = !AllowTrade; if(AllowTrade) ReceiveChat("You are now allowing trade", ChatType.System); else ReceiveChat("You are no longer allowing trade", ChatType.System); break; case "TRIGGER": if (!IsGM) return; if (parts.Length < 2) return; if (parts.Length >= 3) { player = Envir.GetPlayer(parts[2]); if (player == null) { ReceiveChat(string.Format("Player {0} was not found.", parts[2]), ChatType.System); return; } player.CallDefaultNPC(DefaultNPCType.Trigger, parts[1]); return; } foreach (var pl in Envir.Players) { pl.CallDefaultNPC(DefaultNPCType.Trigger, parts[1]); } break; case "RIDE": if (MountType > -1) { RidingMount = !RidingMount; RefreshMount(); } else ReceiveChat("You haven't a mount...", ChatType.System); break; case "CLEARFLAGS": if (!IsGM) return; player = parts.Length > 1 ? Envir.GetPlayer(parts[1]) : this; if (player == null) { ReceiveChat(parts[1] + " is not online", ChatType.System); return; } for (int i = 0; i < player.Info.Flags.Length; i++) { player.Info.Flags[i] = false; } player.GetCompletedQuests(); //player.SendQuestUpdate(); break; case "CHANGECLASS": //@changeclass [Player] [Class] if (!IsGM) return; data = parts.Length <= 2 ? Info : Envir.GetCharacterInfo(parts[1]); if (data == null) return; MirClass mirClass; if (!Enum.TryParse(parts[parts.Length - 1], true, out mirClass) || data.Class == mirClass) return; data.Class = mirClass; ReceiveChat(string.Format("Player {0} has been changed to {1}", data.Name, data.Class), ChatType.System); SMain.Enqueue(string.Format("Player {0} has been changed to {1} by {2}", data.Name, data.Class, Name)); if (data.Player != null) data.Player.Connection.LogOut(); break; case "DIE": LastHitter = null; Die(); break; case "HAIR": if (!IsGM) return; if(parts.Length < 2) Info.Hair = (byte)SMain.Envir.Random.Next(0, 9); else { byte tempByte = 0; byte.TryParse(parts[1], out tempByte); Info.Hair = tempByte; } break; case "DECO": if (!IsGM) return; if (parts.Length < 2) return; ushort tempShort = 0; ushort.TryParse(parts[1], out tempShort); DecoObject decoOb = new DecoObject { Image = tempShort, CurrentMap = CurrentMap, CurrentLocation = CurrentLocation, }; CurrentMap.AddObject(decoOb); decoOb.Spawned(); Enqueue(decoOb.GetInfo()); break; case "ADJUSTPKPOINT": if (!IsGM) return; if (parts.Length < 2) return; int tempInt; if(parts.Length > 2) { player = Envir.GetPlayer(parts[1]); if (player == null) return; int.TryParse(parts[2], out tempInt); } else { player = this; int.TryParse(parts[1], out tempInt); } player.PKPoints = tempInt; break; case "AWAKENING": { if (!IsGM) return; if (parts.Length < 3) return; ItemType type; if (!Enum.TryParse(parts[1], true, out type)) return; AwakeType awakeType; if (!Enum.TryParse(parts[2], true, out awakeType)) return; foreach (UserItem temp in Info.Equipment) { if (temp == null) continue; ItemInfo realItem = Functions.GetRealItem(temp.Info, Info.Level, Info.Class, Envir.ItemInfoList); if (realItem.Type == type) { Awake awake = temp.Awake; bool[] isHit; int result = awake.UpgradeAwake(temp, awakeType, out isHit); switch (result) { case -1: ReceiveChat(string.Format("{0} : Condition Error.", temp.Name), ChatType.System); break; case 0: ReceiveChat(string.Format("{0} : Upgrade Failed.", temp.Name), ChatType.System); break; case 1: ReceiveChat(string.Format("{0} : AWAKE Level {1}, value {2}~{3}.", temp.Name, awake.getAwakeLevel(), awake.getAwakeValue(), awake.getAwakeValue()), ChatType.System); p = new S.RefreshItem { Item = temp }; Enqueue(p); break; default: break; } } } } break; case "REMOVEAWAKENING": { if (!IsGM) return; if (parts.Length < 2) return; ItemType type; if (!Enum.TryParse(parts[1], true, out type)) return; foreach (UserItem temp in Info.Equipment) { if (temp == null) continue; ItemInfo realItem = Functions.GetRealItem(temp.Info, Info.Level, Info.Class, Envir.ItemInfoList); if (realItem.Type == type) { Awake awake = temp.Awake; int result = awake.RemoveAwake(); switch (result) { case 0: ReceiveChat(string.Format("{0} : Remove failed Level 0", temp.Name), ChatType.System); break; case 1: ReceiveChat(string.Format("{0} : Remove success. Level {1}", temp.Name, temp.Awake.getAwakeLevel()), ChatType.System); p = new S.RefreshItem { Item = temp }; Enqueue(p); break; default: break; } } } } break; case "STARTWAR": if (!IsGM) return; if (parts.Length < 2) return; GuildObject enemyGuild = Envir.GetGuild(parts[1]); if(MyGuild == null) { ReceiveChat("You are not in a guild.", ChatType.System); } if (MyGuild.Ranks[0] != MyGuildRank) { ReceiveChat("You must be a leader to start a war.", ChatType.System); return; } if(enemyGuild == null) { ReceiveChat(string.Format("Could not find guild {0}.", parts[1]), ChatType.System); return; } if(MyGuild == enemyGuild) { ReceiveChat("Cannot go to war with your own guild.", ChatType.System); return; } if(MyGuild.WarringGuilds.Contains(enemyGuild)) { ReceiveChat("Already at war with this guild.", ChatType.System); return; } if(MyGuild.GoToWar(enemyGuild)) { ReceiveChat(string.Format("You started a war with {0}.", parts[1]), ChatType.System); enemyGuild.SendMessage(string.Format("{0} has started a war", MyGuild.Name), ChatType.System); } break; default: foreach (string command in Envir.CustomCommands) { if (parts[0] != command) continue; CallDefaultNPC(DefaultNPCType.CustomCommand, parts[0]); } break; } } else { message = String.Format("{0}:{1}", CurrentMap.Info.NoNames ? "?????" : Name, message); p = new S.ObjectChat { ObjectID = ObjectID, Text = message, Type = ChatType.Normal }; Enqueue(p); Broadcast(p); } }