public static void Convert_OnCommand(CommandEventArgs e) { e.Mobile.SendMessage("Converting all players to PlayerMobile. You will be disconnected. Please Restart the server after the world has finished saving."); List <Mobile> mobs = new List <Mobile>(World.Mobiles.Values); int count = 0; foreach (Mobile m in mobs) { if (m.Player && !(m is PlayerMobile)) { count++; if (m.NetState != null) { m.NetState.Dispose(); } PlayerMobile pm = new PlayerMobile(m.Serial); pm.DefaultMobileInit(); List <Item> copy = new List <Item>(m.Items); for (int i = 0; i < copy.Count; i++) { pm.AddItem(copy[i]); } CopyProps(pm, m); for (int i = 0; i < m.Skills.Length; i++) { pm.Skills[i].Base = m.Skills[i].Base; pm.Skills[i].SetLockNoRelay(m.Skills[i].Lock); } World.Mobiles[m.Serial] = pm; } } if (count > 0) { NetState.ProcessDisposedQueue(); World.Save(); Console.WriteLine("{0} players have been converted to PlayerMobile. {1}.", count, Core.NoConsole ? "The server is now restarting" : "Press any key to restart the server"); if (!Core.NoConsole && !Core.Service) { Console.ReadKey(true); } Core.Kill(true); } else { e.Mobile.SendMessage("Couldn't find any Players to convert."); } }
private void ResetPlayers() { foreach (KeyValuePair <PlayerMobile, TourneyEntry> item in m_Participants) { PlayerMobile m = item.Key; Refresh(m); m.Frozen = true; //Undress List <Item> dress = new List <Item>(m.Items); foreach (Item item2 in dress) { if (item2 == m.Backpack) { continue; } DeathMoveResult res = m.GetParentMoveResultFor(item2); if (res == DeathMoveResult.MoveToBackpack || res == DeathMoveResult.MoveToCorpse) { m.Backpack.AddItem(item2); } } //Clear backapck if (m_StolenBackpack.ContainsKey(m)) { m.Backpack.Delete(); } else { m.BankBox.DropItem(m.Backpack); } //New backpack Backpack pack = new Backpack(); pack.Movable = false; m.AddItem(pack); //Supply items AddItems(pack); //Robe m.EquipItem(new DeathRobe()); //Team colour m.SolidHueOverride = item.Value.Team; //Move to base TeamBase bas = bases[item.Value.Team]; if (bas != null) { m.MoveToWorld(bas.Location, bas.Map); } } }
public override void Transformer(PlayerMobile from) { if (raceSecrete == RaceSecrete.Aucun || Transformed == true) { return; } Race.SupprimerSkin(from); if (raceSecrete == RaceSecrete.Tieffelin) { if (from.FindItemOnLayer(Layer.Cloak) != null) { from.AddToBackpack(from.FindItemOnLayer(Layer.Cloak)); } from.AddItem(new AilesTieffelin()); from.AddItem(new CorpsTieffelin()); if (from.FindItemOnLayer(Layer.Helm) != null) { from.AddToBackpack(from.FindItemOnLayer(Layer.Helm)); } from.AddItem(new CornesTieffelin()); } else { from.AddItem(new CorpsAasimar()); } from.Hue = hueSecrete; int tmphue = from.HairHue; from.HairHue = hairhue; hairhue = tmphue; tmphue = from.FacialHairHue; from.FacialHairHue = beardhue; beardhue = tmphue; from.Identities.Transformer(); Transformed = true; }
public static void Convert_OnCommand(CommandEventArgs e) { e.Mobile.SendMessage("Converting all players to PlayerMobile. You will be disconnected. Please Restart the server after the world has finished saving."); ArrayList mobs = new ArrayList(World.Mobiles.Values); int count = 0; foreach (Mobile m in mobs) { if (m.Player && !(m is PlayerMobile)) { count++; if (m.NetState != null) { m.NetState.Dispose(); } PlayerMobile pm = new PlayerMobile(m.Serial); pm.DefaultMobileInit(); ArrayList copy = new ArrayList(m.Items); for (int i = 0; i < copy.Count; i++) { pm.AddItem((Item)copy[i]); } CopyProps(pm, m); for (int i = 0; i < m.Skills.Length; i++) { pm.Skills[i].Base = m.Skills[i].Base; pm.Skills[i].SetLockNoRelay(m.Skills[i].Lock); } World.Mobiles[m.Serial] = pm; } } if (count > 0) { NetState.ProcessDisposedQueue(); World.Save(); log.InfoFormat("{0} players have been converted to PlayerMobile. Restarting the server.", count); Core.Shutdown(true); } else { log.Info("Couldn't find any Players to convert."); } }
public static void StaffDress_OnCommand(CommandEventArgs e) { PlayerMobile pm = e.Mobile as PlayerMobile; if (pm != null) { bool foundsuit = false; int rank = (int)pm.StaffRank; if (pm.AccessLevel < AccessLevel.Administrator) { int hue = pm.Hue % 16384; if (hue < 1002 || hue > 1058) { pm.Hue = Utility.RandomMinMax(1002, 1058) + 32767; } } pm.Karma = pm.Fame = pm.Kills = pm.ShortTermMurders = 0; pm.BodyValue = (pm.Female ? 401 : 400); pm.SolidHueOverride = -1; pm.BodyMod = 0; pm.HueMod = -1; pm.Blessed = true; pm.DisplayChampionTitle = false; if (pm.Mount != null) { pm.Mount.Rider = null; } pm.Send(SpeedControl.MountSpeed); for (int i = pm.Items.Count - 1; i >= 0; i--) { Item item = pm.Items[i]; if (item.GetType() == m_StaffRobeTypes[rank]) { if (pm.AccessLevel >= AccessLevel.Administrator || (item.Hue == m_StaffRobeHues[rank] && item.Name == null)) { foundsuit = true; } else { item.Delete(); } } else { Layer layer = item.Layer; if (layer != Layer.Backpack && layer != Layer.Bank && layer != Layer.FacialHair && layer != Layer.Hair && layer != Layer.Mount && layer != Layer.ShopBuy && layer != Layer.ShopResale && layer != Layer.ShopSell) { pm.AddToBackpack(item); } } } if (!foundsuit) { try { Item item = Activator.CreateInstance(m_StaffRobeTypes[rank]) as Item; if (item != null) { pm.AddItem(item); } } catch { } } } }
public static void RestoreState( PlayerMobile m, Serial serial, bool moveExisting, bool logging, out int created, out int deleted, out int ignored, out int moved) { var pack = m.Backpack; if (pack == null || pack.Deleted) { m.AddItem( pack = new Backpack { Movable = false }); } var bank = m.BankBox; if (bank == null || bank.Deleted) { m.AddItem( bank = new BankBox(m) { Movable = false }); } if (serial == Serial.MinusOne) { serial = m.Serial; } var root = VitaNexCore.DataDirectory + "/PlayerBackup/" + m.Account.Username + "/" + serial; var idxFile = IOUtility.EnsureFile(root + ".idx"); var binFile = IOUtility.EnsureFile(root + ".bin"); var logFile = logging ? IOUtility.EnsureFile(root + ".log") : null; var log = logging ? new StringBuilder() : null; if (log != null) { log.AppendLine(); log.AppendLine(new String('*', 10)); log.AppendLine(); log.AppendLine("RESTORE:\tDate[{0}]\tMobile[{1}]", DateTime.UtcNow, m); log.AppendLine(); } int idxCreated = 0, idxDeleted = 0, idxIgnored = 0, idxMoved = 0; idxFile.Deserialize( idx => { idx.GetVersion(); var ser = idx.ReadInt(); if (ser != m.Serial.Value) { if (log != null) { log.AppendLine("INVALID:\tSerial[{0:X8}]", ser); } return; } long idxLength; int idxCount; ReadLength(idx, false, out idxLength, out idxCount); if (log != null) { log.AppendLine("INDEX:\tCount[{0}]\tLength[{1}]", idxCount, idxLength); } var items = new Tuple <Item, Serial, long, long, string> [idxCount]; binFile.Deserialize( bin => { bin.GetVersion(); var restored = new Dictionary <Item, Serial>(); Backpack oldPack = null; BankBox oldBank = null; for (var i = 0; i < idxCount; i++) { Type type; Serial s, parent; long binIndex, binLength; ReadIndex(idx, out type, out s, out parent, out binIndex, out binLength); var valid = s.IsValid && s.IsItem; var exists = World.Items.ContainsKey(s); Item item = null; if (exists) { item = World.Items[s]; if (item == null || item.Deleted) { World.Items.Remove(s); exists = false; } } object logItem; string status; if (!exists && valid && type.IsEqualOrChildOf <Item>()) { item = type.CreateInstanceSafe <Item>(s); if (item == null) { ++idxIgnored; logItem = s; status = "NULL"; } else if (item.Deleted) { ++idxDeleted; item = null; logItem = s; status = "DELETED"; } else { ++idxCreated; World.AddItem(item); logItem = item; status = "CREATED"; } } else if (exists && valid && moveExisting && item.RootParent != m) { ++idxMoved; logItem = item; status = "MOVE"; } else { ++idxIgnored; item = null; logItem = s; status = exists ? "EXISTS" : "INVALID"; } if (log != null) { log.AppendLine( "DATA:\tIndex[{0}]\t\tLength[{1}]\tStatus[{2}]\tItem[{3}]\t\t\tParent[{4}]", // binIndex, binLength, status, logItem, parent); } items[i] = Tuple.Create(item, parent, binIndex, binLength, status); } foreach (var t in items) { var item = t.Item1; var parent = t.Item2; var index = t.Item3; var length = t.Item4; var status = t.Item5; bin.Seek(index, SeekOrigin.Begin); if (item == null) { bin.Seek(index + length, SeekOrigin.Begin); continue; } Exception x = null; if (status == "MOVE") { bin.Seek(index + length, SeekOrigin.Begin); status = "IGNORED"; } else { try { item.Deserialize(bin); status = "LOADED"; } catch (Exception e) { --idxCreated; ++idxDeleted; item.Delete(); x = e; status = "ERROR"; } } if (log != null) { log.AppendLine( "READ:\tIndex[{0}]\tLength[{1}]\tStatus[{2}]\tItem[{3}]\t\t\tParent[{4}]", index, length, status, item, parent); if (x != null) { log.AppendLine(); log.AppendLine(new String('*', 10)); log.AppendLine(x.ToString()); log.AppendLine(new String('*', 10)); log.AppendLine(); } } if (parent == m.Serial) { if (item is BankBox) { oldBank = (BankBox)item; } else if (item is Backpack) { oldPack = (Backpack)item; } } restored.Add(item, parent); } if (log != null) { log.AppendLine(); } Point3D p; foreach (var kv in restored.Where(kv => !kv.Key.Deleted).OrderBy(kv => kv.Value)) { var item = kv.Key; if ((item == oldPack || item == oldBank) && item != pack && item != bank) { if (item.Parent is Item) { ((Item)item.Parent).RemoveItem(item); } else if (item.Parent is Mobile) { ((Mobile)item.Parent).RemoveItem(item); } item.Parent = null; continue; } var parent = World.FindEntity(kv.Value); if (item != pack && item != bank && (item.Parent == oldPack || item.Parent == oldBank)) { ((Item)item.Parent).RemoveItem(item); } if (parent != null) { if (item == pack || item == bank) { m.AddItem(item); } else if (parent == pack || parent == oldPack) { p = item.Location; pack.DropItem(item); item.Location = p; } else if (parent == bank || parent == oldBank) { p = item.Location; bank.DropItem(item); item.Location = p; } else if (parent is Container) { if (parent.Deleted) { bank.DropItem(item); } else { p = item.Location; ((Container)parent).DropItem(item); item.Location = p; } } else if (parent is Mobile) { if (!m.EquipItem(item)) { pack.DropItem(item); } } else { bank.DropItem(item); } item.SetLastMoved(); item.UpdateTotals(); item.Delta(ItemDelta.Update); } else if (Cleanup.IsBuggable(item)) { --idxCreated; ++idxDeleted; item.Delete(); } else { item.Internalize(); } } if (oldPack != null && oldPack != pack && !restored.ContainsKey(oldPack)) { oldPack.Delete(); } if (oldBank != null && oldBank != bank && !restored.ContainsKey(oldBank)) { oldBank.Delete(); } if (log != null) { log.AppendLine(); } foreach (var kv in restored) { if (kv.Key.Deleted) { if (log != null) { log.AppendLine("DELETED:\tItem[{0}]\t\tParent[{1}]", kv.Key, kv.Value); } } else if (kv.Key.RootParent == m && kv.Key.Map == Map.Internal && kv.Key.Location == Point3D.Zero) { if (log != null) { log.AppendLine("INTERNAL:\tItem[{0}]\t\tParent[{1}]", kv.Key, kv.Value); } } else if (kv.Key.RootParent != m) { if (log != null) { log.AppendLine("IGNORED:\tItem[{0}]\t\tParent[{1}]", kv.Key, kv.Value); } } else { if (log != null) { log.AppendLine("RESTORED:\tItem[{0}]\t\tParent[{1}]", kv.Key, kv.Key.Parent); } } } restored.Clear(); m.SendEverything(); }); }); created = idxCreated; deleted = idxDeleted; ignored = idxIgnored; moved = idxMoved; if (log == null) { return; } log.AppendLine(); log.AppendLine( "RESULT:\tCreated[{0}]\t\tDeleted[{1}]\t\tIgnored[{2}]\t\tMoved[{3}]", created, deleted, ignored, moved); logFile.AppendText(false, log.ToString()); }
public static void EventSink_AccountLogin(AccountLoginEventArgs e) { try { IAccount a = Accounts.GetAccount(e.Username); if (a == null) { return; // si pas de compte (bug xD) on sort } Account acc = a as Account; if (a == null || a.Count > 0) { return; // Si cast en compte est null ou s'il y a déjà des joueurs pour ce compte, on n'importe pas les joueurs de la save sphere } else if (acc != null && acc.Comments != null && acc.Comments.Count > 0) { return; // pareil s'il y a déjà un commentaire sur le compte } //else if (acc != null && acc.TotalGameTime > TimeSpan.FromMinutes(15)) return; // Vérifions que les fichiers nécessaires existent bien if (!SphereFiles.checkDataFiles()) { return; } // Commencons par récupérer les SERIAL des personnages associés au compte List <string> charUIDs = new List <string>(); int totalTime = 0; // on récupère le temps en sec joué par le joueurs sur sphere bool found = false; string username = e.Username.ToLower(); foreach (string line in File.ReadAllLines(SphereFiles.accountFile)) { // On cherche d'abord à retrouver l'utilisateur if (line.ToLower() == "[" + username + "]") { found = true; continue; } // Ensuite une fois qu'on l'a trouvé on ajout les SERIAL de ses personnages // jusqu'à tombé sur un autre compte (ou la fin du fichier) if (found) { if (line.StartsWith("[")) { break; } if (line.StartsWith("TOTALCONNECTTIME=")) { totalTime = Int32.Parse(line.Split('=')[1]); } if (line.StartsWith("CHARUID")) { charUIDs.Add(line.Split('=')[1]); } } } // On traite chacun des SERIAL des personnages des joueurs foreach (string c in charUIDs) { Mobile pm = null; // Le mobile qui sera créé found = false; // on remet found à false car on ne l'a pas encore trouvé bool woman = false; // dans le cas on on serait sur une femme il faut s'en souvenir bool hasHouse = false; // On parcourt toutes les lignes du fichier contenant les personnages foreach (string line in File.ReadAllLines(SphereFiles.playerFile)) { // Si l'on recontre une femme on s'en souvient pour lui mettre des seins ! if (line.StartsWith("[WORLDCHAR")) { woman = line.Contains("woman"); } // Si l'on tombe sur le SERIAL du joueur que l'on cherche on peut passer au traitement if (line.StartsWith("SERIAL=")) { if (line.Split('=')[1] == c) { found = true; continue; } } // On est sur le bon joueur, il faut en extraire les informations if (found) { // Si le Mobile est encore null on l'instancie et on l'initialise if (pm == null) { pm = new PlayerMobile(); pm.Player = true; // !!! nécessaire pour lire le paperdoll pm.AccessLevel = AccessLevel.Player; pm.Map = Map.Internal; // pour que le joueur soit déconnecté pm.LogoutLocation = new Point3D(3503, 2574, 14); // endroit de départ des joueurs pm.LogoutMap = Map.Trammel; // map de départ des joueurs pm.BodyValue = (woman ? 401 : 400); pm.Female = woman; pm.SkillsCap = 7000; // skill cap de 700 pm.StatCap = 225; // stat cap de 225 // Ajoutons un backpack au joueur pour qu'il puisse y ranger ses affaires Container pack = pm.Backpack; if (pack == null) { pack = new Backpack(); pack.Movable = false; pm.AddItem(pack); } // Une cape pour les vétérans ! pm.Backpack.DropItem(new VeteranCloak()); } // Si l'on arrive sur un autre joueur on ajoute l'actuel et on continue de chercher // les éventuels autres joueurs du compte if (line.StartsWith("[")) { // Effectuons quelques petits trucs avant d'ajouter le joueur sur le compte getHair(c, pm); // on récupère et on remet les cheveux du joueur getGold(c, pm); // on récupère l'or du joueur dressPlayer(pm); // on habille le joueur // On remet au joueur un cheque s'il avait une maison if (hasHouse) { Container bank = pm.BankBox; if (bank != null) { BankCheck check = new BankCheck(50000); check.Name = "Rémunération Maison"; bank.DropItem(check); } } hasHouse = false; // On remet de l'argent au joueur en fonction du temps joué sur Sphere if (totalTime > 0) { Container bank = pm.BankBox; if (bank != null) { BankCheck check = new BankCheck((int)(totalTime / (charUIDs.Count * 1.0))); check.Name = "Temps joué"; bank.DropItem(check); } } // Et maintenant on ajoute le joueur au compte à la première place libre for (int i = 0; i < a.Length; ++i) { if (a[i] == null) { a[i] = pm; break; } } pm = null; break; } #region Traitement des différentes propriétés à importer // Nom if (line.StartsWith("NAME=")) { pm.Name = line.Split('=')[1]; } // Body Hue else if (line.StartsWith("COLOR=")) { pm.Hue = Int32.Parse(line.Split('=')[1], NumberStyles.HexNumber); } // Body Hue si corps différent else if (pm.Hue == 0 && line.StartsWith("OSKIN=")) { pm.Hue = Int32.Parse(line.Split('=')[1], NumberStyles.HexNumber); } // Description paperdoll else if (line.StartsWith("PROFILE=")) { pm.Profile = line.Split('=')[1].Replace("\\r", "\r"); } // Force else if (line.StartsWith("STR=")) { pm.Str = Int32.Parse(line.Split('=')[1]); } // Int else if (line.StartsWith("INT=")) { pm.Int = Int32.Parse(line.Split('=')[1]); } // Dex else if (line.StartsWith("DEX=")) { pm.Dex = Int32.Parse(line.Split('=')[1]); } // Karma else if (line.StartsWith("KARMA=")) { pm.Karma = Int32.Parse(line.Split('=')[1]); } // Fame else if (line.StartsWith("FAME=")) { pm.Fame = Int32.Parse(line.Split('=')[1]); } // Female else if (line.StartsWith("FAME=")) { pm.Fame = Int32.Parse(line.Split('=')[1]); } // Titre RP else if (line.StartsWith("TITLE=")) { pm.Title = line.Split('=')[1]; } // Pour la rémunération de la maison else if (line.StartsWith("HOME=")) { hasHouse = true; } /* Position X,Y,Z * else if (line.StartsWith("P=")) * { * string[] location = line.Split('=')[1].Split(','); * pm.Location = new Point3D(Int32.Parse(location[0]), Int32.Parse(location[1]), Int32.Parse(location[2])); * } */ // Alchemy else if (line.StartsWith("Alchemy=")) { pm.Skills[SkillName.Alchemy].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } // Anatomy else if (line.StartsWith("Anatomy=")) { pm.Skills[SkillName.Anatomy].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } // Animal Lore else if (line.StartsWith("AnimalLore=")) { pm.Skills[SkillName.AnimalLore].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Archery else if (line.StartsWith("Archery=")) { pm.Skills[SkillName.Archery].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } // Arms Lore else if (line.StartsWith("ArmsLore=")) { pm.Skills[SkillName.ArmsLore].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Begging else if (line.StartsWith("Begging=")) { pm.Skills[SkillName.Begging].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Blacksmithing else if (line.StartsWith("Blacksmithing=")) { pm.Skills[SkillName.Blacksmith].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Bowcraft else if (line.StartsWith("Bowcraft=")) { pm.Skills[SkillName.Fletching].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } // Camping else if (line.StartsWith("Camping=")) { pm.Skills[SkillName.Camping].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Carpentry else if (line.StartsWith("Carpentry=")) { pm.Skills[SkillName.Carpentry].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Cartography else if (line.StartsWith("Cartography=")) { pm.Skills[SkillName.Cartography].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Cooking else if (line.StartsWith("Cooking=")) { pm.Skills[SkillName.Cooking].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //DetectingHidden else if (line.StartsWith("DetectingHidden=")) { pm.Skills[SkillName.DetectHidden].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Enticement else if (line.StartsWith("Enticement=")) { pm.Skills[SkillName.Discordance].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //EvaluatingIntel else if (line.StartsWith("EvaluatingIntel=")) { pm.Skills[SkillName.EvalInt].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Fencing else if (line.StartsWith("Fencing=")) { pm.Skills[SkillName.Fencing].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Fishing else if (line.StartsWith("Fishing=")) { pm.Skills[SkillName.Fishing].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Forensics else if (line.StartsWith("Forensics=")) { pm.Skills[SkillName.Forensics].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Healing else if (line.StartsWith("Healing=")) { pm.Skills[SkillName.Healing].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } // Herding else if (line.StartsWith("Herding=")) { pm.Skills[SkillName.Herding].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Hiding else if (line.StartsWith("Hiding=")) { pm.Skills[SkillName.Hiding].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Inscription else if (line.StartsWith("Inscription=")) { pm.Skills[SkillName.Inscribe].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //ItemID else if (line.StartsWith("ItemID=")) { pm.Skills[SkillName.ItemID].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //LockPicking else if (line.StartsWith("LockPicking=")) { pm.Skills[SkillName.Lockpicking].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Lumberjacking else if (line.StartsWith("Lumberjacking=")) { pm.Skills[SkillName.Lumberjacking].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Macefighting else if (line.StartsWith("Macefighting=")) { pm.Skills[SkillName.Macing].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Magery else if (line.StartsWith("Magery=")) { pm.Skills[SkillName.Magery].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //MagicResistance else if (line.StartsWith("MagicResistance=")) { pm.Skills[SkillName.MagicResist].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Meditation else if (line.StartsWith("Meditation=")) { pm.Skills[SkillName.Meditation].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Mining else if (line.StartsWith("Mining=")) { pm.Skills[SkillName.Mining].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } // Musicianship else if (line.StartsWith("Musicianship=")) { pm.Skills[SkillName.Musicianship].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Necromancy else if (line.StartsWith("Necromancy=")) { pm.Skills[SkillName.Necromancy].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Parrying else if (line.StartsWith("Parrying=")) { pm.Skills[SkillName.Parry].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Peacemaking else if (line.StartsWith("Peacemaking=")) { pm.Skills[SkillName.Peacemaking].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Poisoning else if (line.StartsWith("Poisoning=")) { pm.Skills[SkillName.Poisoning].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Provocation else if (line.StartsWith("Provocation=")) { pm.Skills[SkillName.Provocation].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //RemoveTrap else if (line.StartsWith("RemoveTrap=")) { pm.Skills[SkillName.RemoveTrap].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //SpiritSpeak else if (line.StartsWith("SpiritSpeak=")) { pm.Skills[SkillName.SpiritSpeak].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Stealth else if (line.StartsWith("Stealth=")) { pm.Skills[SkillName.Stealth].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } // Swordsmanship else if (line.StartsWith("Swordsmanship=")) { pm.Skills[SkillName.Swords].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Tactics else if (line.StartsWith("Tactics=")) { pm.Skills[SkillName.Tactics].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Tailoring else if (line.StartsWith("Tailoring=")) { pm.Skills[SkillName.Tailoring].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Taming else if (line.StartsWith("Taming=")) { pm.Skills[SkillName.AnimalTaming].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //TasteID else if (line.StartsWith("TasteID=")) { pm.Skills[SkillName.TasteID].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Tinkering else if (line.StartsWith("Tinkering=")) { pm.Skills[SkillName.Tinkering].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Tracking else if (line.StartsWith("Tracking=")) { pm.Skills[SkillName.Tracking].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Snooping else if (line.StartsWith("Snooping=")) { pm.Skills[SkillName.Snooping].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Stealing else if (line.StartsWith("Stealing=")) { pm.Skills[SkillName.Stealing].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Veterinary else if (line.StartsWith("Veterinary=")) { pm.Skills[SkillName.Veterinary].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } //Wrestling else if (line.StartsWith("Wrestling=")) { pm.Skills[SkillName.Wrestling].BaseFixedPoint = Int32.Parse(line.Split('=')[1]); } #endregion // On cap les skills à 100 maxi ! for (int i = 0; i < pm.Skills.Length; i++) { Skill skill = pm.Skills[i]; if (skill.Base > 100) { skill.Base = 100; } } } } } // Ajoutons un commentaire pour indiquer l'importation des personnages à cette date if (a.Count > 0 && a is Account) { ((Account)a).Comments.Add(new AccountComment("SphereImporter", a.Count + " players imported from Sphere save file.")); } } catch (Exception ex) { Console.WriteLine("SpherePlayerMobileImporter.EventSink_AccountLogin : " + ex.Message); } }
public override void OnDeath(Mobile mobile) { base.OnDeath(mobile); PlayerMobile player = mobile as PlayerMobile; if (player == null) { return; } if (player.AccessLevel > AccessLevel.Player) { return; } if (!UOACZPersistance.Active) { return; } UOACZPersistance.CheckAndCreateUOACZAccountEntry(player); player.Frozen = true; Queue m_Queue = new Queue(); foreach (BaseCreature creature in player.AllFollowers) { if (UOACZRegion.ContainsMobile(creature)) { m_Queue.Enqueue(creature); } } while (m_Queue.Count > 0) { BaseCreature creature = (BaseCreature)m_Queue.Dequeue(); int damage = (int)(Math.Round((double)creature.HitsMax * UOACZSystem.SwarmControllerDeathDamageScalar)); new Blood().MoveToWorld(creature.Location, creature.Map); AOS.Damage(creature, damage, 0, 100, 0, 0, 0); if (UOACZSystem.IsUOACZValidMobile(creature)) { if (creature.AIObject != null && creature.Controlled) { creature.AIObject.DoOrderRelease(); if (creature is UOACZBaseUndead) { UOACZBaseUndead undeadCreature = creature as UOACZBaseUndead; undeadCreature.m_LastActivity = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(3)); undeadCreature.m_NeedWaypoint = true; undeadCreature.CanTeleportToBaseNode = true; undeadCreature.InWilderness = true; } } } } Timer.DelayCall(TimeSpan.FromSeconds(.5), delegate { if (player == null) { return; } if (player.Deleted) { return; } if (!UOACZRegion.ContainsMobile(player)) { return; } if (!UOACZPersistance.Active) { return; } UOACZPersistance.CheckAndCreateUOACZAccountEntry(player); player.m_UOACZAccountEntry.UndeadProfile.Deaths++; }); Timer.DelayCall(TimeSpan.FromSeconds(2), delegate { if (player == null) { return; } if (player.Deleted) { return; } if (!UOACZRegion.ContainsMobile(player)) { return; } if (!UOACZPersistance.Active) { return; } UOACZPersistance.CheckAndCreateUOACZAccountEntry(player); UOACZDestination destination; bool lostFoodWater = false; bool lostBrains = false; player.m_UOACZAccountEntry.FatigueExpiration = DateTime.UtcNow + UOACZSystem.FatigueDuration; switch (player.m_UOACZAccountEntry.ActiveProfile) { case UOACZAccountEntry.ActiveProfileType.Human: if (player.m_UOACZAccountEntry.HumanProfile.HonorPoints <= UOACZSystem.HonorAggressionThreshold) { destination = UOACZDestination.GetRandomEntrance(false); if (destination != null) { player.MoveToWorld(destination.Location, destination.Map); } else { player.MoveToWorld(UOACZPersistance.DefaultUndeadLocation, UOACZPersistance.DefaultMap); } } else { destination = UOACZDestination.GetRandomEntrance(true); if (destination != null) { player.MoveToWorld(destination.Location, destination.Map); } else { player.MoveToWorld(UOACZPersistance.DefaultHumanLocation, UOACZPersistance.DefaultMap); } } player.Resurrect(); player.RevealingAction(); player.Frozen = false; #region Auto-Reequip Blessed Gear if (player.Backpack != null) { if (!player.Backpack.Deleted) { Item deathRobe = player.FindItemOnLayer(Layer.OuterTorso); if (!(deathRobe is DeathRobe)) { deathRobe = null; } UOACZSurvivalMachete survivalMachete = null; UOACZSurvivalLantern survivalLantern = null; List <Item> m_LayerShirt = new List <Item>(); List <Item> m_MiddleTorso = new List <Item>(); List <Item> m_OuterLegs = new List <Item>(); List <Item> m_Pants = new List <Item>(); List <Item> m_Shoes = new List <Item>(); List <Item> m_BackpackItems = player.Backpack.Items; bool foundPants = false; foreach (Item item in m_BackpackItems) { if (item is UOACZSurvivalMachete) { survivalMachete = item as UOACZSurvivalMachete; } //if (item is UOACZSurvivalLantern) //survivalLantern = item as UOACZSurvivalLantern; if (item.Layer == Layer.Shirt) { m_LayerShirt.Add(item); } if (item.Layer == Layer.MiddleTorso) { m_MiddleTorso.Add(item); } if (item.Layer == Layer.OuterLegs) { m_OuterLegs.Add(item); foundPants = true; } if (item.Layer == Layer.Pants) { m_Pants.Add(item); foundPants = true; } if (item.Layer == Layer.Shoes) { m_Shoes.Add(item); } } if (survivalMachete != null) { player.AddItem(survivalMachete); } //if (survivalLantern != null) //player.AddItem(survivalLantern); if (foundPants && deathRobe != null) { deathRobe.Delete(); } if (m_LayerShirt.Count > 0) { player.AddItem(m_LayerShirt[0]); } if (m_MiddleTorso.Count > 0) { player.AddItem(m_MiddleTorso[0]); } if (m_OuterLegs.Count > 0) { player.AddItem(m_OuterLegs[0]); } if (m_Pants.Count > 0) { player.AddItem(m_Pants[0]); } if (m_Shoes.Count > 0) { player.AddItem(m_Shoes[0]); } } } #endregion UOACZSystem.ApplyActiveProfile(player); player.Hits = (int)Math.Ceiling(UOACZSystem.HumanRessStatsPercent * (double)player.HitsMax); player.Stam = (int)Math.Ceiling(UOACZSystem.HumanRessStatsPercent * (double)player.StamMax); player.Mana = (int)Math.Ceiling(UOACZSystem.HumanRessStatsPercent * (double)player.ManaMax); if (player.Backpack != null) { Item[] consumptionItem = player.Backpack.FindItemsByType(typeof(UOACZConsumptionItem)); m_Queue = new Queue(); for (int a = 0; a < consumptionItem.Length; a++) { UOACZConsumptionItem foodItem = consumptionItem[a] as UOACZConsumptionItem; if (foodItem == null) { continue; } if (Utility.RandomDouble() <= UOACZSystem.HumanDeathFoodWaterLossChance) { lostFoodWater = true; if (foodItem.Charges > 1) { foodItem.Charges = (int)Math.Floor((double)foodItem.Charges / 2); } else { m_Queue.Enqueue(foodItem); } } } while (m_Queue.Count > 0) { Item item = (Item)m_Queue.Dequeue(); item.Delete(); } } Timer.DelayCall(TimeSpan.FromSeconds(.5), delegate { if (!UOACZSystem.IsUOACZValidMobile(player)) { return; } player.m_UOACZAccountEntry.HumanProfile.CauseOfDeath = UOACZAccountEntry.HumanProfileEntry.CauseOfDeathType.Misc; player.m_UOACZAccountEntry.HumanDeaths++; if (player.IsUOACZHuman) { if (player.m_UOACZAccountEntry.HumanAbilitiesHotbarDisplayed) { player.CloseGump(typeof(HumanProfileAbilitiesHotbarGump)); player.SendGump(new HumanProfileAbilitiesHotbarGump(player)); } if (player.m_UOACZAccountEntry.HumanStatsHotbarDisplayed) { player.CloseGump(typeof(HumanProfileStatsHotbarGump)); player.SendGump(new HumanProfileStatsHotbarGump(player)); } if (player.m_UOACZAccountEntry.ObjectivesDisplayed) { player.CloseGump(typeof(ObjectivesHotbarGump)); player.SendGump(new ObjectivesHotbarGump(player)); } } }); break; case UOACZAccountEntry.ActiveProfileType.Undead: destination = UOACZDestination.GetRandomEntrance(false); player.m_UOACZAccountEntry.UndeadDeaths++; if (destination != null) { player.MoveToWorld(destination.Location, destination.Map); } else { player.MoveToWorld(UOACZPersistance.DefaultUndeadLocation, UOACZPersistance.DefaultMap); } player.Resurrect(); player.RevealingAction(); player.Frozen = false; if (player.Backpack != null) { Item[] brainItems = player.Backpack.FindItemsByType(typeof(UOACZBrains)); m_Queue = new Queue(); for (int a = 0; a < brainItems.Length; a++) { UOACZBrains brainItem = brainItems[a] as UOACZBrains; if (brainItem == null) { continue; } if (Utility.RandomDouble() <= UOACZSystem.UndeadDeathBrainLossChance) { lostBrains = true; m_Queue.Enqueue(brainItem); } } while (m_Queue.Count > 0) { Item item = (Item)m_Queue.Dequeue(); item.Delete(); } } UOACZSystem.ApplyActiveProfile(player); player.Hits = (int)Math.Ceiling(UOACZSystem.UndeadRessStatsPercent * (double)player.HitsMax); player.Stam = (int)Math.Ceiling(UOACZSystem.UndeadRessStatsPercent * (double)player.StamMax); player.Mana = (int)Math.Ceiling(UOACZSystem.UndeadRessStatsPercent * (double)player.ManaMax); if (player.m_UOACZAccountEntry.UndeadAbilitiesHotbarDisplayed) { player.CloseGump(typeof(UndeadProfileAbilitiesHotbarGump)); player.SendGump(new UndeadProfileAbilitiesHotbarGump(player)); } if (player.m_UOACZAccountEntry.UndeadStatsHotbarDisplayed) { player.CloseGump(typeof(UndeadProfileStatsHotbarGump)); player.SendGump(new UndeadProfileStatsHotbarGump(player)); } if (player.m_UOACZAccountEntry.ObjectivesDisplayed) { player.CloseGump(typeof(ObjectivesHotbarGump)); player.SendGump(new ObjectivesHotbarGump(player)); } break; } string fatigueDuration = Utility.CreateTimeRemainingString(DateTime.UtcNow, DateTime.UtcNow + UOACZSystem.FatigueDuration, false, true, true, true, true); string fatiguePercentText = ((1.0 - UOACZSystem.FatigueActiveScalar) * 100).ToString() + "%"; player.SendMessage(UOACZSystem.orangeTextHue, "You have died and will be subject to a -" + fatiguePercentText + " PvP penalty for " + fatigueDuration + "."); Timer.DelayCall(TimeSpan.FromSeconds(2), delegate { if (player == null) { return; } if (player.IsUOACZHuman && lostFoodWater) { player.SendMessage(UOACZSystem.orangeTextHue, "As a result of your death, some of your food and water has been been lost."); } if (player.IsUOACZUndead && lostBrains) { player.SendMessage(UOACZSystem.orangeTextHue, "As a result of your death, some of your brains have been been lost."); } }); }); }
private static void JailPlayerInQueue() { try { PlayerMobile player = s_JailProcessingQueue.Dequeue() as PlayerMobile; if (null != player) { Boots boots = new JailBoots(player.Name); boots.MoveToWorld(player.Location, player.Map); player.MoveToWorld(JailConfig.JailLocation, JailConfig.JailMap); Item robe = new Robe(); robe.Hue = JailConfig.RobeHue; robe.Name = JailConfig.RobeTitle; player.AddItem(robe); player.SendMessage("You have been JAILED!"); if (0 < JailConfig.FineAmount) { if (!Banker.Withdraw(player, JailConfig.FineAmount)) { JailHammer hammer = player.FindItemOnLayer(Layer.OneHanded) as JailHammer; if (null != hammer) { hammer.UsesRemaining *= 2; player.SendMessage("You could not afford the fine so your sentence has been doubled!"); } } else { player.SendMessage("You have been fined {0} gold!", JailConfig.FineAmount); } } } } catch { } }
public static void JailThem(PlayerMobile player, JailOption option) { if (null == player || player.AccessLevel >= JailConfig.JailImmuneLevel) { return; } if (JailOption.Squelch == option) { player.Squelched = true; } foreach (Item item in player.Items) { if (item is JailHammer) // Jailed while jailed gets them another load of rock to mine { if (0 > (((JailHammer)item).UsesRemaining += JailConfig.UsesRemaining)) // handle integer overflow { ((JailHammer)item).UsesRemaining *= -1; } Banker.Withdraw(player, JailConfig.FineAmount); player.SendMessage("Your remaining sentence has been increased!"); player.SendMessage("You have been fined {0} gold and are being kicked!", JailConfig.FineAmount); // This gives a nice little delay for the message to be read s_KickProcessingQueue.Enqueue(player); player.Squelched = true; Server.Timer.DelayCall(TimeSpan.FromSeconds(kSecondsTillKick), new Server.TimerCallback(KickPlayerInQueue)); return; } } // If mounted, dismount them and stable mount if (player.Mounted) { if (player.Mount is EtherealMount) { EtherealMount pet = player.Mount as EtherealMount; pet.Internalize(); pet.Rider = null; } else if (player.Mount is BaseMount) { BaseMount pet = player.Mount as BaseMount; pet.Rider = null; Jail.StablePet(player, pet); } } // Stable all other pets foreach (Mobile mobile in World.Mobiles.Values) { if (mobile is BaseCreature) { BaseCreature bc = mobile as BaseCreature; if (null != bc && (bc.Controlled && bc.ControlMaster == player) || (bc.Summoned && bc.SummonMaster == player)) { Jail.StablePet(player, bc); } } } // Move all items to a bag and move that to the bank Container backpack = player.Backpack; Backpack bag = new Backpack(); bag.Hue = JailConfig.RobeHue; ArrayList equipedItems = new ArrayList(player.Items); foreach (Item item in equipedItems) { if (item.Layer == Layer.Bank || item.Layer == Layer.Backpack || item.Layer == Layer.Hair || item.Layer == Layer.FacialHair || item is DeathShroud) { continue; } bag.DropItem(item); } ArrayList backpackItems = new ArrayList(backpack.Items); foreach (Item item in backpackItems) { if (item is JailRock) { item.Delete(); } else if (item.Movable) // Non movable pack items must remain (i.e. skill balls) { bag.DropItem(item); } } // Remember their access level and make them a player JailHammer hammer = new JailHammer(); hammer.PlayerAccessLevel = player.AccessLevel; player.AccessLevel = AccessLevel.Player; // Bank the bag of belongings, give them a hammer and welcome them player.BankBox.DropItem(bag); player.AddItem(hammer); // Explosively move player to jail player.BoltEffect(0); player.FixedParticles(0x36BD, 20, 10, 5044, EffectLayer.Waist); player.PlaySound(0x307); player.FixedParticles(0x3709, 10, 30, 5052, EffectLayer.LeftFoot); player.PlaySound(0x225); // This gives a nice little delay for the effect to complete s_JailProcessingQueue.Enqueue(player); Server.Timer.DelayCall(TimeSpan.FromSeconds(kSecondsTillJail), new Server.TimerCallback(JailPlayerInQueue)); }