private void StartGameSuccess() { Connection.Stage = GameStage.Game; Enqueue(new S.StartGame { Result = 4 }); ReceiveChat("Welcome to the Legend of Mir 2 C# Server.", ChatType.Hint); if (Info.GuildIndex != -1) { MyGuild = Envir.GetGuild(Info.GuildIndex); if (MyGuild == null) { Info.GuildIndex = -1; ReceiveChat("You have been removed from the guild.", ChatType.System); } else { MyGuildRank = MyGuild.FindRank(Info.Name); if (MyGuildRank == null) { MyGuild = null; Info.GuildIndex = -1; ReceiveChat("You have been removed from the guild.", ChatType.System); } } } Spawned(); GetItemInfo(); GetMapInfo(); GetUserInfo(); Enqueue(new S.BaseStatsInfo { Stats = Settings.ClassBaseStats[(byte)Class] }); GetObjectsPassive(); Enqueue(new S.TimeOfDay { Lights = Envir.Lights }); Enqueue(new S.ChangeAMode { Mode = AMode }); if (Class == MirClass.Wizard || Class == MirClass.Taoist) Enqueue(new S.ChangePMode {Mode = PMode}); Enqueue(new S.SwitchGroup { AllowGroup = AllowGroup }); if (Info.Thrusting) Enqueue(new S.SpellToggle { Spell = Spell.Thrusting, CanUse = true }); if (Info.HalfMoon) Enqueue(new S.SpellToggle { Spell = Spell.HalfMoon, CanUse = true }); if (Info.CrossHalfMoon) Enqueue(new S.SpellToggle { Spell = Spell.CrossHalfMoon, CanUse = true }); if (Info.DoubleSlash) Enqueue(new S.SpellToggle { Spell = Spell.DoubleSlash, CanUse = true }); for (int i = 0; i < Info.Pets.Count; i++) { PetInfo info = Info.Pets[i]; MonsterObject monster = MonsterObject.GetMonster(Envir.GetMonsterInfo(info.MonsterIndex)); monster.PetLevel = info.Level; monster.MaxPetLevel = info.MaxPetLevel; monster.PetExperience = info.Experience; monster.Master = this; Pets.Add(monster); monster.RefreshAll(); if (!monster.Spawn(CurrentMap, Back)) monster.Spawn(CurrentMap, CurrentLocation); monster.SetHP(info.HP); } Info.Pets.Clear(); if (MyGuild != null) MyGuild.PlayerLogged(this, true); SMain.Enqueue(string.Format("{0} has connected.", Info.Name)); }
public bool CreateGuild(string GuildName) { if ((MyGuild != null) || (Info.GuildIndex != -1)) return false; if (Envir.GetGuild(GuildName) != null) return false; if (Info.Level < Settings.Guild_RequiredLevel) { ReceiveChat(String.Format("Your level is not high enough to create a guild, required: {0}", Settings.Guild_RequiredLevel), ChatType.System); return false; } //check if we have the required items for (int i = 0; i < Settings.Guild_CreationCostList.Count; i++) { ItemVolume Required = Settings.Guild_CreationCostList[i]; if (Required.Item == null) { if (Info.AccountInfo.Gold < Required.Amount) { ReceiveChat(String.Format("Insufficient gold. Creating a guild requires {0} gold.", Required.Amount), ChatType.System); return false; } } else { uint count = Required.Amount; foreach (var item in Info.Inventory.Where(item => item != null && item.Info == Required.Item)) { if ((Required.Item.Type == ItemType.Ore) && (item.CurrentDura / 1000 > Required.Amount)) { count = 0; break; } if (item.Count > count) count = 0; else count = count - item.Count; if (count == 0) break; } if (count != 0) { if (Required.Amount == 1) ReceiveChat(String.Format("{0} is required to create a guild.", Required.Item.Name), ChatType.System); else { if (Required.Item.Type == ItemType.Ore) ReceiveChat(string.Format("{0} with purity {1} is recuired to create a guild.", Required.Item.Name, Required.Amount / 1000), ChatType.System); else ReceiveChat(string.Format("Insufficient {0}, you need {1} to create a guild.", Required.Item.Name, Required.Amount), ChatType.System); } return false; } } } //take the required items for (int i = 0; i < Settings.Guild_CreationCostList.Count; i++) { ItemVolume Required = Settings.Guild_CreationCostList[i]; if (Required.Item == null) { if (Info.AccountInfo.Gold >= Required.Amount) { Info.AccountInfo.Gold -= Required.Amount; Enqueue(new S.LoseGold { Gold = Required.Amount }); } } else { uint count = Required.Amount; for (int o = 0; o < Info.Inventory.Length; o++) { UserItem item = Info.Inventory[o]; if (item == null) continue; if (item.Info != Required.Item) continue; if ((Required.Item.Type == ItemType.Ore) && (item.CurrentDura / 1000 > Required.Amount)) { Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = item.Count }); Info.Inventory[o] = null; break; } if (count > item.Count) { Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = item.Count }); Info.Inventory[o] = null; count -= item.Count; continue; } Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = count }); if (count == item.Count) Info.Inventory[o] = null; else item.Count -= count; break; } } } RefreshStats(); //make the guild GuildObject guild = new GuildObject(this, GuildName) { Guildindex = ++Envir.NextGuildID }; Envir.GuildList.Add(guild); Info.GuildIndex = guild.Guildindex; MyGuild = guild; MyGuildRank = guild.FindRank(Name); GuildMembersChanged = true; GuildNoticeChanged = true; GuildCanRequestItems = true; //tell us we now have a guild BroadcastInfo(); MyGuild.SendGuildStatus(this); return true; }
private void StartGameSuccess() { Connection.Stage = GameStage.Game; Enqueue(new S.StartGame { Result = 4 }); ReceiveChat("Welcome to the Legend of Mir 2 C# Server.", ChatType.Hint); if (Info.GuildIndex != -1) { MyGuild = Envir.GetGuild(Info.GuildIndex); if (MyGuild == null) { Info.GuildIndex = -1; ReceiveChat("You have been removed from the guild.", ChatType.System); } else { MyGuildRank = MyGuild.FindRank(Info.Name); if (MyGuildRank == null) { MyGuild = null; Info.GuildIndex = -1; ReceiveChat("You have been removed from the guild.", ChatType.System); } } } Spawned(); SetLevelEffects(); GetItemInfo(); GetMapInfo(); GetUserInfo(); GetQuestInfo(); GetCompletedQuests(); GetMail(); for (int i = 0; i < CurrentQuests.Count; i++) { QuestProgressInfo quest = CurrentQuests[i]; quest.ResyncTasks(); SendUpdateQuest(quest, QuestState.Add); } Enqueue(new S.BaseStatsInfo { Stats = Settings.ClassBaseStats[(byte)Class] }); GetObjectsPassive(); Enqueue(new S.TimeOfDay { Lights = Envir.Lights }); Enqueue(new S.ChangeAMode { Mode = AMode }); if (Class == MirClass.Wizard || Class == MirClass.Taoist) Enqueue(new S.ChangePMode { Mode = PMode }); Enqueue(new S.SwitchGroup { AllowGroup = AllowGroup }); Enqueue(new S.DefaultNPC { ObjectID = DefaultNPC.ObjectID }); if (Info.Thrusting) Enqueue(new S.SpellToggle { Spell = Spell.Thrusting, CanUse = true }); if (Info.HalfMoon) Enqueue(new S.SpellToggle { Spell = Spell.HalfMoon, CanUse = true }); if (Info.CrossHalfMoon) Enqueue(new S.SpellToggle { Spell = Spell.CrossHalfMoon, CanUse = true }); if (Info.DoubleSlash) Enqueue(new S.SpellToggle { Spell = Spell.DoubleSlash, CanUse = true }); for (int i = 0; i < Info.Pets.Count; i++) { PetInfo info = Info.Pets[i]; MonsterObject monster = MonsterObject.GetMonster(Envir.GetMonsterInfo(info.MonsterIndex)); monster.PetLevel = info.Level; monster.MaxPetLevel = info.MaxPetLevel; monster.PetExperience = info.Experience; monster.Master = this; Pets.Add(monster); monster.RefreshAll(); if (!monster.Spawn(CurrentMap, Back)) monster.Spawn(CurrentMap, CurrentLocation); monster.SetHP(info.HP); if (!Settings.PetSave) { if (info.Time < 1 || (Envir.Time > info.Time + (Settings.PetTimeOut * Settings.Minute))) monster.Die(); } } Info.Pets.Clear(); for (int i = 0; i < Info.Buffs.Count; i++) { Buff buff = Info.Buffs[i]; buff.ExpireTime += Envir.Time; //buff.Caster = this; AddBuff(buff); } Info.Buffs.Clear(); for (int i = 0; i < Info.Poisons.Count; i++) { Poison poison = Info.Poisons[i]; poison.TickTime += Envir.Time; //poison.Owner = this; ApplyPoison(poison, poison.Owner); } Info.Poisons.Clear(); if (MyGuild != null) MyGuild.PlayerLogged(this, true); Report.Connected(Connection.IPAddress); SMain.Enqueue(string.Format("{0} has connected.", Info.Name)); }