public static void Initialize() { Setup set = new Setup(); if (set.AllowExpBar) CommandSystem.Register("ExpBar", AccessLevel.Player, new CommandEventHandler(ExpBar_OnCommand)); }
public static int Skills(Mobile m) { Setup set = new Setup(); double Multiplier = 0; if (set.ExpFromSkills) { if (set.ExpFromOnlyFightSkills) { if (Core.AOS) { Multiplier = set.TotalSkillExp / (10 * set.SkillCap); return ((int)Multiplier * AoS(m)); } else if (Core.SE | Core.ML) { Multiplier = set.TotalSkillExp / (12 * set.SkillCap); return ((int)Multiplier * SE(m)); } else { Multiplier = set.TotalSkillExp / (8 * set.SkillCap); return ((int)Multiplier * Pre(m)); } } else { Multiplier = set.TotalSkillExp / (set.SkillCap * set.SkillTotal); return ((int)Multiplier * m.Skills.Total); } } else return 0; }
public static int Stats(Mobile m) { Setup set = new Setup(); double Multiplier = 0; if (set.ExpFromStats) { Multiplier = set.TotalStatExp / set.StatCap; return ((int)Math.Round(Multiplier * m.RawStatTotal)); } else return 0; }
public ExpBar(Mobile m) : base(0, 0) { Closable = true; Disposable = true; Dragable = true; Resizable = false; AddPage(0); Setup set = new Setup(); PlayerMobile pm = m as PlayerMobile; AddBackground(10, 10, 295, 90, 9270); AddLabel(25, 25, 50, "EXP:"); AddLabel(60, 25, 3, "" + pm.Exp.ToString("#,0")); if (! (set.AccumulativeExp)) { AddLabel(164, 25, 66, "" + pm.Exp.ToString("#,0")); AddLabel(158, 25, 50, "(" + AddSpaces(pm.Exp.ToString()) + " Total)"); } AddLabel(25, 40, 50, "Level At:"); AddLabel(85, 40, 3, "" + pm.LevelAt.ToString("#,0")); AddLabel(187, 40, 3, "" + GetPercentage((int)pm.Exp, pm.LevelAt, 2) + "%"); AddLabel(181, 40, 50, "(" + AddSpaces(GetPercentage((int)pm.Exp, pm.LevelAt, 2) + "%") + " Reached)"); AddLabel(31, 55, 1153, "____________________________"); double ShowBarAt = pm.LevelAt / 100; double NextExtendAt = 0; int LengthOfBar = 0; if (NextExtendAt == 0) NextExtendAt = ShowBarAt; for (int i = 0; pm.Exp >= NextExtendAt; i++) { NextExtendAt += ShowBarAt; LengthOfBar = (int)(2.24 * i); } AddImageTiled(30, 70, LengthOfBar, 15, 58);//x, y, Width, Heigth, ID AddLabel(26, 68, 1153, "(____________________________)"); }
public static string NPCLevel(Mobile m) { Setup set = new Setup(); BaseCreature bc = m as BaseCreature; int npclevel = ((bc.HitsMax + bc.RawStatTotal) / 40) + ((bc.DamageMax * bc.DamageMin) / 30); if (bc is BaseVendor && !(set.ShowVendorLevels)) return ""; else { if (npclevel < 1) return "(level 1)"; else return "(level " + npclevel.ToString() + ")"; } }
public static void FinalizeExp(Mobile m, Mobile killed, double Gain, bool Craft, Setup set) { double BeforeFilter;//used only for party exp system double AfterLevelDiffFilter; double AfterCapFilter; Party party = Party.Get(m); if (!Craft && killed != null && party != null && set.ExpPartyShare) { int PlayersInRange = 0; foreach (PartyMemberInfo info in party.Members) { PlayerMobile pm = info.Mobile as PlayerMobile; if (pm.Alive && pm.InRange(killed, set.PartyRange)) PlayersInRange++; }//Dumb that I have to count players this way.... if (set.ExpEvenPartyShare) BeforeFilter = Gain / PlayersInRange; else BeforeFilter = Gain; foreach (PartyMemberInfo info in party.Members) { PlayerMobile pm = info.Mobile as PlayerMobile; if (pm.Alive && pm.InRange(killed, set.PartyRange)) { AfterLevelDiffFilter = Figures.LevelDiffFilter(pm, killed, BeforeFilter, new Setup()); AfterCapFilter = Figures.CapFilter(pm, AfterLevelDiffFilter, new Setup()); AddExp(pm, AfterCapFilter, new Setup()); } } } else { PlayerMobile pm = m as PlayerMobile; AfterLevelDiffFilter = Figures.LevelDiffFilter(pm, killed, Gain, new Setup()); AfterCapFilter = Figures.CapFilter(pm, AfterLevelDiffFilter, new Setup()); AddExp(pm, AfterCapFilter, new Setup()); } }
public static void StartGain(Mobile killer, Mobile killed) { Setup set = new Setup(); PlayerMobile pm = null; if (killer is PlayerMobile) //Find & Set killer pm = killer as PlayerMobile; else { BaseCreature bc = killer as BaseCreature; if (bc.Controlled && set.ExpFromPetKills) pm = bc.GetMaster() as PlayerMobile; } if (pm == null) //if no killer Exit system return; double Gain = Figures.GetKillExp(pm, killed, new Setup()); //Get the exp for the kill FinalizeExp(pm, killed, Gain, new Setup()); }
public static string Display(Mobile m, string suffix) { string display; Setup set = new Setup(); if (suffix == null) suffix = ""; if (m is BaseCreature) { display = NPCLevel(m); if (suffix.Length > 0) display = String.Concat(suffix, " " + display); return display; } PlayerMobile pm = m as PlayerMobile; if (pm.AccessLevel > AccessLevel.Player && !(set.ShowStaffLevel)) display = ""; else { if (set.ShowLevelCap == true) display = " " + pm.Level + "/" + pm.LevelCap; else display = " " + pm.Level; } if (suffix.Length > 0) { display = String.Concat(suffix, display); } return display; }
public static double GetKillExp(Mobile killer, Mobile killed, Setup set) { PlayerMobile pm = killer as PlayerMobile; double amount; if (killed is PlayerMobile) { PlayerMobile dead = killed as PlayerMobile; amount = ((dead.Str * dead.HitsMax) + (dead.Dex * dead.StamMax) + (dead.Int * dead.ManaMax) / 1000); if (dead.Skills.Total >= 100) amount += dead.Skills.Total / 5; else amount += 100; } else { BaseCreature dead = killed as BaseCreature; amount = dead.HitsMax + dead.RawStatTotal; if (IsMageryCreature(dead)) amount += 10; if (IsFireBreathingCreature(dead)) amount += 15; if (killed is VampireBat || killed is VampireBatFamiliar) amount += 5; amount += GetPoisonLevel(dead) * 10; } return amount / 10; }
public static double LevelDiffFilter(Mobile m, Mobile killed, double ToFilter, Setup set) { PlayerMobile pm = m as PlayerMobile; double Diff = 0; double Filtered = 0; if (!set.ExpFilterByLevel | killed == null) return ToFilter; if (killed is BaseCreature) { BaseCreature bc = killed as BaseCreature; int NPCLevel = ((bc.HitsMax + bc.RawStatTotal) / 40) + ((bc.DamageMax * bc.DamageMin) / 30); if (NPCLevel < pm.Level) { if (pm.Level - NPCLevel > set.FilterByLevelRange) { Diff = pm.Level - NPCLevel; Filtered = ToFilter - ((Diff - set.FilterByLevelRange) * set.ExpLostPerLevelDiff); } else Filtered = ToFilter; } else { if (NPCLevel - pm.Level > set.FilterByLevelRange) { Diff = NPCLevel - pm.Level; if (set.ReverseRangeEffect) Filtered = ToFilter + ((Diff - set.FilterByLevelRange) * set.ExpLostPerLevelDiff); else Filtered = ToFilter - ((Diff - set.FilterByLevelRange) * set.ExpLostPerLevelDiff); } else Filtered = ToFilter; } } else { PlayerMobile dead = killed as PlayerMobile; if (dead.Level < pm.Level) { if (pm.Level - dead.Level > set.FilterByLevelRange) { Diff = pm.Level - dead.Level; Filtered = ToFilter - ((Diff - set.FilterByLevelRange) * set.ExpLostPerLevelDiff); } else Filtered = ToFilter; } else { if (dead.Level - pm.Level > set.FilterByLevelRange) { Diff = dead.Level - pm.Level; if (set.ReverseRangeEffect) Filtered = ToFilter + ((Diff - set.FilterByLevelRange) * set.ExpLostPerLevelDiff); else Filtered = ToFilter - ((Diff - set.FilterByLevelRange) * set.ExpLostPerLevelDiff); } else Filtered = ToFilter; } } return Filtered; }
public static void EventSink_Save(WorldSaveEventArgs args) { ConsoleColor col = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine(); Console.Write("Level System: Saving... "); Setup set = new Setup(); DateTime Start = DateTime.Now; if (!Directory.Exists(FilePath)) { Directory.CreateDirectory(FilePath); } if (File.Exists(FilePath + FileName)) { File.Delete(FilePath + FileName); } XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = " "; XmlWriter writer = XmlWriter.Create(FilePath + FileName, settings); writer.WriteStartElement("Info"); string ID; foreach (Mobile mob in World.Mobiles.Values) { if (mob is PlayerMobile) { PlayerMobile pm = mob as PlayerMobile; if (PlayerInfo.ContainsKey(Convert.ToInt32(pm.Serial))) { InfoList info = PlayerInfo[Convert.ToInt32(pm.Serial)]; ID = Convert.ToString(Convert.ToInt32(pm.Serial)); writer.WriteStartElement("ID"); writer.WriteStartAttribute("", "Serial", ""); writer.WriteString(ID); writer.WriteEndAttribute(); if (info.Level > pm.Level && pm.Level == 0 || info.KillExp > pm.KillExp && pm.KillExp == 0) { //Login-Save-Restart-No Login-Save Saftey SystemInfo.SaveValue("Level", info.Level, 0, writer); SystemInfo.SaveValue("LevelCap", info.LevelCap, 0, writer); SystemInfo.SaveValue("KillExp", info.KillExp, 1, writer); SystemInfo.SaveValue("AccKillExp", info.AccKillExp, 1, writer); SystemInfo.SaveValue("LevelAt", info.LevelAt, 0, writer); SystemInfo.SaveValue("AccLevelAt", info.LevelAt, 0, writer); } else { SystemInfo.SaveValue("Level", pm.Level, 0, writer); SystemInfo.SaveValue("LevelCap", pm.LevelCap, 0, writer); SystemInfo.SaveValue("KillExp", pm.KillExp, 1, writer); SystemInfo.SaveValue("AccKillExp", pm.AccKillExp, 1, writer); SystemInfo.SaveValue("LevelAt", pm.LevelAt, 0, writer); SystemInfo.SaveValue("AccLevelAt", pm.LevelAt, 0, writer); } writer.WriteEndElement(); } } } writer.WriteEndElement(); writer.Close(); if (set.TimeSave) { Console.WriteLine("Done! ({0:F1} seconds)", (DateTime.Now - Start).TotalSeconds); } else { Console.WriteLine("Done!"); } Console.ForegroundColor = col; LoadPlayers(true); }
////////////////////////////////////////////////////////////////////// public static void DoLevel(Mobile m, Setup set) { PlayerMobile pm = m as PlayerMobile; for (int i = 1; pm.Exp >= pm.LevelAt; i++) { ///////testing int curlv = pm.Level + 1; if (pm.Level > 0 && pm.Level < 10) { m.StatCap = 210; m.Skills.Cap = 6000; pm.SendMessage( "Your stat cap has increase by 10." ); } else if (pm.Level > 9 && pm.Level < 20) { m.StatCap = 220; m.Skills.Cap = 6200; pm.SendMessage( "Your stat cap has increase by 10." ); } else if (pm.Level > 19 && pm.Level < 30) { m.StatCap = 230; m.Skills.Cap = 6400; pm.SendMessage( "Your stat cap has increase by 10." ); } else if (pm.Level > 29 && pm.Level < 40) { m.StatCap = 240; m.Skills.Cap = 6800; pm.SendMessage( "Your stat cap has increase by 10." ); } else if (pm.Level > 39 && pm.Level < 50) { m.StatCap = 250; m.Skills.Cap = 7000; pm.SendMessage( "Your stat cap has increase by 10." ); } else if (pm.Level > 49 && pm.Level < 60) { m.StatCap = 260; m.Skills.Cap = 7200; pm.SendMessage( "Your stat cap has increase by 10." ); } else if (pm.Level > 59 && pm.Level < 70) { m.StatCap = 270; m.Skills.Cap = 7400; pm.SendMessage( "Your stat cap has increase by 10." ); } else if (pm.Level > 69 && pm.Level < 80) { m.StatCap = 280; m.Skills.Cap = 7600; pm.SendMessage( "Your stat cap has increase by 10." ); } else if (pm.Level > 79 && pm.Level < 90) { m.StatCap = 290; m.Skills.Cap = 8000; pm.SendMessage( "Your stat cap has increase by 10." ); } else if (pm.Level > 89 && pm.Level < 100) { m.StatCap = 300; m.Skills.Cap = 8400; pm.SendMessage( "Your stat cap has increase by 10." ); } } }
public static void FinalizeExp(Mobile m, Mobile killed, double Gain, Setup set)//for kills (no Craft bool) { FinalizeExp(m, killed, Gain, false, new Setup()); }
public static void LoadPlayers(bool Reload) { string Root = null; string Parent = null; int PlayersLoaded = 0; Setup set = new Setup(); DateTime Start = DateTime.Now; ConsoleColor col = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.DarkGreen; if (Reload) { PlayerInfo.Clear(); Console.Write("Level System: Reloading... "); } else { Console.Write("Level System: Loading... "); } if (!Directory.Exists(FilePath)) { Directory.CreateDirectory(FilePath); } if (!File.Exists(FilePath + FileName)) { Console.WriteLine("-No Save Found- Done!"); Console.ForegroundColor = col; return; } XmlDocument doc = new XmlDocument(); doc.Load(FilePath + FileName); if (doc.DocumentElement != null) { Root = doc.DocumentElement.Name; } if (doc.DocumentElement.FirstChild != null) { Parent = doc.DocumentElement.FirstChild.Name; } if (Root == null | Parent == null) { Console.WriteLine("-Empty Save- Done!"); Console.ForegroundColor = col; return; } XmlNodeList IDList = doc.SelectNodes("/" + Root + "/" + Parent); foreach (XmlNode id in IDList) { try { int ID = Convert.ToInt32(id.Attributes["Serial"].Value); int Level = Convert.ToInt32(id.SelectSingleNode("Level").InnerText); int LevelCap = Convert.ToInt32(id.SelectSingleNode("LevelCap").InnerText); double KillExp = Convert.ToDouble(id.SelectSingleNode("KillExp").InnerText); double AccKillExp = Convert.ToDouble(id.SelectSingleNode("AccKillExp").InnerText); int LevelAt = Convert.ToInt32(id.SelectSingleNode("LevelAt").InnerText); int AccLevelAt = Convert.ToInt32(id.SelectSingleNode("AccLevelAt").InnerText); if (!PlayerInfo.ContainsKey(ID)) { PlayerInfo.Add(ID, new InfoList(Level, LevelCap, KillExp, AccKillExp, LevelAt, AccLevelAt)); } PlayersLoaded++; } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(); Console.WriteLine("ERROR: " + e); } } if (!Reload || Reload && set.TimeReload) { Console.WriteLine("Done! ({0} players, {1:F1} seconds)", PlayersLoaded, (DateTime.Now - Start).TotalSeconds); } if (Reload) { if (!set.TimeReload) { Console.WriteLine("Done!"); } Console.ForegroundColor = col; Console.Write("Save "); } Console.ForegroundColor = col; }
public static string ComputeTitle( Mobile beholder, Mobile beheld ) { StringBuilder title = new StringBuilder(); int fame = beheld.Fame; int karma = beheld.Karma; bool showSkillTitle = beheld.ShowFameTitle && ( (beholder == beheld) || (fame >= 5000) ); if ( beheld.Kills >= 5 ) { title.AppendFormat( beheld.Fame >= 10000 ? "The Murderer {1} {0}" : "The Murderer {0}", beheld.Name, beheld.Female ? "Lady" : "Lord" ); } //Level System 3 Rework 1 else if (beheld.Player) { Setup set = new Setup(); string display = String.Empty; if (showSkillTitle) { string skillTitle = GetSkillTitle(beheld); if (set.ShowLevelPaperdoll) display = Features.Display(beheld, skillTitle); else display = skillTitle; } else { if (set.ShowLevelPaperdoll) display = Features.Display(beheld, null); } if (display != null && display.Length > 0) title.AppendFormat(", {0}", display); } else { title.Append( beheld.Name ); } if( beheld is PlayerMobile && ((PlayerMobile)beheld).DisplayChampionTitle ) { PlayerMobile.ChampionTitleInfo info = ((PlayerMobile)beheld).ChampionTitles; if( info.Harrower > 0 ) title.AppendFormat( ": {0} of Evil", HarrowerTitles[Math.Min( HarrowerTitles.Length, info.Harrower )-1] ); else { int highestValue = 0, highestType = 0; for( int i = 0; i < ChampionSpawnInfo.Table.Length; i++ ) { int v = info.GetValue( i ); if( v > highestValue ) { highestValue = v; highestType = i; } } int offset = 0; if( highestValue > 800 ) offset = 3; else if( highestValue > 300 ) offset = (int)(highestValue/300); if( offset > 0 ) { ChampionSpawnInfo champInfo = ChampionSpawnInfo.GetInfo( (ChampionSpawnType)highestType ); title.AppendFormat( ": {0} of the {1}", champInfo.LevelNames[Math.Min( offset, champInfo.LevelNames.Length ) -1], champInfo.Name ); } } } string customTitle = beheld.Title; if ( customTitle != null && (customTitle = customTitle.Trim()).Length > 0 ) { title.AppendFormat( " {0}", customTitle ); } else if ( showSkillTitle && beheld.Player ) { string skillTitle = GetSkillTitle( beheld ); if ( skillTitle != null ) { title.Append( ", " ).Append( skillTitle ); } } return title.ToString(); }
public static bool MountCheck(Mobile m, BaseMount mnt) { Setup set = new Setup(); PlayerMobile pm = m as PlayerMobile; if (set.LTREveryMount > 0) { if (!(pm.Level >= set.LTREveryMount)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTREveryMount); return false; } return true; } else { if (mnt is Beetle) { if (set.LTRBeetle > 0 && !(pm.Level >= set.LTRBeetle)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRBeetle); return false; } return true; } else if (mnt is DesertOstard) { if (set.LTRDesertOstard > 0 && !(pm.Level >= set.LTRDesertOstard)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRDesertOstard); return false; } return true; } else if (mnt is FireSteed) { if (set.LTRFireSteed > 0 && !(pm.Level >= set.LTRFireSteed)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRFireSteed); return false; } return true; } else if (mnt is ForestOstard) { if (set.LTRForestOstard > 0 && !(pm.Level >= set.LTRForestOstard)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRForestOstard); return false; } return true; } else if (mnt is FrenziedOstard) { if (set.LTRFrenziedOstard > 0 && !(pm.Level >= set.LTRFrenziedOstard)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRFrenziedOstard); return false; } return true; } else if (mnt is HellSteed) { if (set.LTRHellSteed > 0 && !(pm.Level >= set.LTRHellSteed)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRHellSteed); return false; } return true; } else if (mnt is Hiryu) { if (set.LTRHiryu > 0 && !(pm.Level >= set.LTRHiryu)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRHiryu); return false; } return true; } else if (mnt is Horse) { if (set.LTRHorse > 0 && !(pm.Level >= set.LTRHorse)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRHorse); return false; } return true; } else if (mnt is Kirin) { if (set.LTRKirin > 0 && !(pm.Level >= set.LTRKirin)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRKirin); return false; } return true; } else if (mnt is LesserHiryu) { if (set.LTRLesserHiryu > 0 && !(pm.Level >= set.LTRLesserHiryu)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRLesserHiryu); return false; } return true; } else if (mnt is Nightmare) { if (set.LTRNightMare > 0 && !(pm.Level >= set.LTRNightMare)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRNightMare); return false; } return true; } else if (mnt is RidableLlama) { if (set.LTRRidableLlama > 0 && !(pm.Level >= set.LTRRidableLlama)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRRidableLlama); return false; } return true; } else if (mnt is Ridgeback) { if (set.LTRRidgeback > 0 && !(pm.Level >= set.LTRRidgeback)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRRidgeback); return false; } return true; } else if (mnt is SavageRidgeback) { if (set.LTRSavageRidgeback > 0 && !(pm.Level >= set.LTRSavageRidgeback)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRSavageRidgeback); return false; } return true; } else if (mnt is ScaledSwampDragon) { if (set.LTRScaledSwampDragon > 0 && !(pm.Level >= set.LTRScaledSwampDragon)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRScaledSwampDragon); return false; } return true; } else if (mnt is SeaHorse) { if (set.LTRSeaHorse > 0 && !(pm.Level >= set.LTRSeaHorse)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRSeaHorse); return false; } return true; } else if (mnt is SilverSteed) { if (set.LTRSilverSteed > 0 && !(pm.Level >= set.LTRSilverSteed)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRSilverSteed); return false; } return true; } else if (mnt is SkeletalMount) { if (set.LTRSkeletalMount > 0 && !(pm.Level >= set.LTRSkeletalMount)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRSkeletalMount); return false; } return true; } else if (mnt is SwampDragon) { if (set.LTRSwampDragon > 0 && !(pm.Level >= set.LTRSwampDragon)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRSwampDragon); return false; } return true; } else if (mnt is Unicorn) { if (set.LTRUnicorn > 0 && !(pm.Level >= set.LTRUnicorn)) { mnt.OnDisallowedRider(pm); pm.SendMessage("You are not level {0}!", set.LTRUnicorn); return false; } return true; } return true; } }
public static double CapFilter(Mobile m, double ToAdd, Setup set) { double over; double difference; PlayerMobile pm = m as PlayerMobile; if (pm.Level >= pm.LevelCap && pm.Exp + ToAdd > pm.LevelAt) { over = (pm.Exp + ToAdd) - pm.LevelAt; difference = ToAdd - over; } else difference = ToAdd; if (difference < 0) difference = 0; return difference; }
public static void GetCraftExp(Mobile m, Item created, int Quality, double SuccessChance, double ExcepChance) { double gain = 0; double chance = 100 * SuccessChance; Setup set = new Setup(); if (!set.ExpFromCrafting) { return; } if (created is BaseWeapon) { #region Weapon Resource Settings BaseWeapon bw = created as BaseWeapon; if (bw.Resource == CraftResource.Iron) { gain += 0.2; } else if (bw.Resource == CraftResource.DullCopper) { gain += 0.4; } else if (bw.Resource == CraftResource.ShadowIron) { gain += 0.8; } else if (bw.Resource == CraftResource.Copper) { gain += 1.6; } else if (bw.Resource == CraftResource.Bronze) { gain += 1.8; } else if (bw.Resource == CraftResource.Gold) { gain += 2.2; } else if (bw.Resource == CraftResource.Agapite) { gain += 3.0; } else if (bw.Resource == CraftResource.Verite) { gain += 4.6; } else if (bw.Resource == CraftResource.Valorite) { gain += 4.8; } #endregion } else if (created is BaseArmor) { #region Armour Resource Settings BaseArmor ba = created as BaseArmor; #region Armour Type (Ring/Chain/Plate) foreach (Type t in Armours.Ringmail) { if (t == ba.GetType()) { gain += 0.6; } } foreach (Type t in Armours.Chainmail) { if (t == ba.GetType()) { gain += 1.3; } } foreach (Type t in Armours.Platemail) { if (t == ba.GetType()) { gain += 2.1; } } #endregion #region Metals if (ba.Resource == CraftResource.Iron) { gain += 0.2; } else if (ba.Resource == CraftResource.DullCopper) { gain += 0.4; } else if (ba.Resource == CraftResource.ShadowIron) { gain += 0.8; } else if (ba.Resource == CraftResource.Copper) { gain += 1.6; } else if (ba.Resource == CraftResource.Bronze) { gain += 1.8; } else if (ba.Resource == CraftResource.Gold) { gain += 2.2; } else if (ba.Resource == CraftResource.Agapite) { gain += 3.0; } else if (ba.Resource == CraftResource.Verite) { gain += 4.6; } else if (ba.Resource == CraftResource.Valorite) { gain += 4.8; } #endregion #region Leathers else if (ba.Resource == CraftResource.RegularLeather) { gain += 0.8; } else if (ba.Resource == CraftResource.SpinedLeather) { gain += 1.6; } else if (ba.Resource == CraftResource.HornedLeather) { gain += 2.6; } else if (ba.Resource == CraftResource.BarbedLeather) { gain += 3.8; } #endregion #region Scales *NOT IN YET* //SCALES WILL GO HERE! #endregion #endregion } if (chance > 0 && chance < 20) { gain += 6.0; } else if (chance > 20 && chance < 40) { gain += 4.4; } else if (chance > 40 && chance < 60) { gain += 3.2; } else if (chance > 60 && chance < 80) { gain += 2.0; } else { gain += 0.3; } if (Quality > 1) { gain += 3.2; } gain -= ExcepChance; Actions.FinalizeExp(m, gain, true, new Setup()); }
public static double LevelDiffFilter(Mobile m, Mobile killed, double ToFilter, Setup set) { PlayerMobile pm = m as PlayerMobile; double Diff = 0; double Filtered = 0; if (!set.ExpFilterByLevel | killed == null) { return(ToFilter); } if (killed is BaseCreature) { BaseCreature bc = killed as BaseCreature; int NPCLevel = ((bc.HitsMax + bc.RawStatTotal) / 40) + ((bc.DamageMax * bc.DamageMin) / 30); if (NPCLevel < pm.Level) { if (pm.Level - NPCLevel > set.FilterByLevelRange) { Diff = pm.Level - NPCLevel; Filtered = ToFilter - ((Diff - set.FilterByLevelRange) * set.ExpLostPerLevelDiff); } else { Filtered = ToFilter; } } else { if (NPCLevel - pm.Level > set.FilterByLevelRange) { Diff = NPCLevel - pm.Level; if (set.ReverseRangeEffect) { Filtered = ToFilter + ((Diff - set.FilterByLevelRange) * set.ExpLostPerLevelDiff); } else { Filtered = ToFilter - ((Diff - set.FilterByLevelRange) * set.ExpLostPerLevelDiff); } } else { Filtered = ToFilter; } } } else { PlayerMobile dead = killed as PlayerMobile; if (dead.Level < pm.Level) { if (pm.Level - dead.Level > set.FilterByLevelRange) { Diff = pm.Level - dead.Level; Filtered = ToFilter - ((Diff - set.FilterByLevelRange) * set.ExpLostPerLevelDiff); } else { Filtered = ToFilter; } } else { if (dead.Level - pm.Level > set.FilterByLevelRange) { Diff = dead.Level - pm.Level; if (set.ReverseRangeEffect) { Filtered = ToFilter + ((Diff - set.FilterByLevelRange) * set.ExpLostPerLevelDiff); } else { Filtered = ToFilter - ((Diff - set.FilterByLevelRange) * set.ExpLostPerLevelDiff); } } else { Filtered = ToFilter; } } } return(Filtered); }
public static void GetCraftExp(Mobile m, Item created, int Quality, double SuccessChance, double ExcepChance) { double gain = 0; double chance = 100 * SuccessChance; Setup set = new Setup(); if (!set.ExpFromCrafting) return; if (created is BaseWeapon) { #region Weapon Resource Settings BaseWeapon bw = created as BaseWeapon; if (bw.Resource == CraftResource.Iron) gain += 0.2; else if (bw.Resource == CraftResource.DullCopper) gain += 0.4; else if (bw.Resource == CraftResource.ShadowIron) gain += 0.8; else if (bw.Resource == CraftResource.Copper) gain += 1.6; else if (bw.Resource == CraftResource.Bronze) gain += 1.8; else if (bw.Resource == CraftResource.Gold) gain += 2.2; else if (bw.Resource == CraftResource.Agapite) gain += 3.0; else if (bw.Resource == CraftResource.Verite) gain += 4.6; else if (bw.Resource == CraftResource.Valorite) gain += 4.8; #endregion } else if (created is BaseArmor) { #region Armour Resource Settings BaseArmor ba = created as BaseArmor; #region Armour Type (Ring/Chain/Plate) foreach (Type t in Armours.Ringmail) { if (t == ba.GetType()) gain += 0.6; } foreach (Type t in Armours.Chainmail) { if (t == ba.GetType()) gain += 1.3; } foreach (Type t in Armours.Platemail) { if (t == ba.GetType()) gain += 2.1; } #endregion #region Metals if (ba.Resource == CraftResource.Iron) gain += 0.2; else if (ba.Resource == CraftResource.DullCopper) gain += 0.4; else if (ba.Resource == CraftResource.ShadowIron) gain += 0.8; else if (ba.Resource == CraftResource.Copper) gain += 1.6; else if (ba.Resource == CraftResource.Bronze) gain += 1.8; else if (ba.Resource == CraftResource.Gold) gain += 2.2; else if (ba.Resource == CraftResource.Agapite) gain += 3.0; else if (ba.Resource == CraftResource.Verite) gain += 4.6; else if (ba.Resource == CraftResource.Valorite) gain += 4.8; #endregion #region Leathers else if (ba.Resource == CraftResource.RegularLeather) gain += 0.8; else if (ba.Resource == CraftResource.SpinedLeather) gain += 1.6; else if (ba.Resource == CraftResource.HornedLeather) gain += 2.6; else if (ba.Resource == CraftResource.BarbedLeather) gain += 3.8; #endregion #region Scales *NOT IN YET* //SCALES WILL GO HERE! #endregion #endregion } if (chance > 0 && chance < 20) gain += 6.0; else if (chance > 20 && chance < 40) gain += 4.4; else if (chance > 40 && chance < 60) gain += 3.2; else if (chance > 60 && chance < 80) gain += 2.0; else gain += 0.3; if (Quality > 1) gain += 3.2; gain -= ExcepChance; Actions.FinalizeExp(m, gain, true, new Setup()); }
public static void EventSink_Login(LoginEventArgs args) { Setup set = new Setup(); NetState ns = args.Mobile.NetState; PlayerMobile pm = args.Mobile as PlayerMobile; if (PlayerInfo.ContainsKey(Convert.ToInt32(pm.Serial)))//Loaded { InfoList info = PlayerInfo[Convert.ToInt32(pm.Serial)]; if (pm.Level > info.Level | pm.KillExp > info.KillExp)//Login-Logout-Login Saftey: return; pm.Level = info.Level; pm.LevelCap = info.LevelCap; pm.KillExp = info.KillExp; pm.AccKillExp = info.AccKillExp; pm.LevelAt = info.LevelAt; pm.AccLevelAt = info.AccLevelAt; } else//Newbie { pm.Level = 1; pm.LevelCap = set.StartingLevelCap; pm.KillExp = 0; pm.AccKillExp = 0; pm.LevelAt = set.NextLevelAt; pm.AccLevelAt = set.NextLevelAt; PlayerInfo.Add(Convert.ToInt32(pm.Serial), new InfoList(pm.Level, pm.LevelCap, pm.KillExp, pm.AccKillExp, pm.LevelAt, pm.AccLevelAt)); } }
public static void DoLevel(Mobile m, Setup set) { double TimesLeveled = 0; PlayerMobile pm = m as PlayerMobile; pm.PlaySound(0x20F); pm.FixedParticles(0x376A, 1, 31, 9961, 1160, 0, EffectLayer.Waist); pm.FixedParticles(0x37C4, 1, 31, 9502, 43, 2, EffectLayer.Waist); if (set.StatRefillOnLevel) { if (pm.Hits < pm.HitsMax) pm.Hits = pm.HitsMax; if (pm.Mana < pm.ManaMax) pm.Mana = pm.ManaMax; if (pm.Stam < pm.StamMax) pm.Stam = pm.StamMax; } /* while (pm.Exp >= pm.LevelAt && pm.Level != pm.LevelCap) { if (set.AccumulativeExp) set.pm.Exp = 0; return; int newexp = 0; if (pm.Exp > pm.LevelAt) newexp = pm.Exp - pm.LevelAt; pm.Exp = newexp; TimesLeveled++; } */ for (int i = 1; pm.Exp >= pm.LevelAt; i++) { ///////testing int curlv = pm.Level + 1; if (pm.Level > 0 && pm.Level < 5) pm.LevelAt += 250; else if (pm.Level > 4 && pm.Level < 10) pm.LevelAt += 500; else if (pm.Level > 9 && pm.Level < 15) pm.LevelAt += 1000; else if (pm.Level > 14 && pm.Level < 20) pm.LevelAt += 2500; else if (pm.Level > 19 && pm.Level < 25) pm.LevelAt += 5000; else if (pm.Level > 24 && pm.Level < 30) pm.LevelAt += 7500; else if (pm.Level > 29 && pm.Level < 35) pm.LevelAt += 10000; else if (pm.Level > 34 && pm.Level < 40) pm.LevelAt += 14000; else if (pm.Level > 39 && pm.Level < 45) pm.LevelAt += 19000; else if (pm.Level > 44 && pm.Level < 50) pm.LevelAt += 25000; else if (pm.Level > 49 && pm.Level < 55) pm.LevelAt += 32000; else if (pm.Level > 54 && pm.Level < 60) pm.LevelAt += 40000; else if (pm.Level > 59 && pm.Level < 65) pm.LevelAt += 55000; else if (pm.Level > 64 && pm.Level < 70) pm.LevelAt += 68000; else if (pm.Level > 69 && pm.Level < 75) pm.LevelAt += 80000; else if (pm.Level > 74 && pm.Level < 80) pm.LevelAt += 90000; else if (pm.Level > 79 && pm.Level < 85) pm.LevelAt += 100000; else if (pm.Level > 84 && pm.Level < 90) pm.LevelAt += 125000; else if (pm.Level > 89 && pm.Level < 95) pm.LevelAt += 150000; else if (pm.Level > 94 && pm.Level < 100) pm.LevelAt += 200000; ///testing //pm.LevelAt += set.NextLevelAt; //pm.AccLevelAt += (int)(set.NextLevelAt + pm.AccKillExp); if (set.BonusStatOnLevel && pm.RawStatTotal != pm.StatCap && set.ChanceForBonusStat < Utility.Random(100)) { switch (Utility.Random(3)) { case 0: pm.RawStr += 1; break; case 1: pm.RawDex += 1; break; case 2: pm.RawInt += 1; break; } } TimesLeveled = i; } if (set.RefreshExpBarOnGain && pm.HasGump(typeof(ExpBar))) { pm.CloseGump(typeof(ExpBar)); pm.SendGump(new ExpBar(pm)); } pm.SendMessage("You're Level has increased by {0}", TimesLeveled); pm.Level += (int)TimesLeveled; }
public static void EventSink_Save(WorldSaveEventArgs args) { ConsoleColor col = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine(); Console.Write("Level System: Saving... "); Setup set = new Setup(); DateTime Start = DateTime.Now; if (!Directory.Exists(FilePath)) Directory.CreateDirectory(FilePath); if (File.Exists(FilePath + FileName)) File.Delete(FilePath + FileName); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = " "; XmlWriter writer = XmlWriter.Create(FilePath + FileName, settings); writer.WriteStartElement("Info"); string ID; foreach (Mobile mob in World.Mobiles.Values) { if (mob is PlayerMobile) { PlayerMobile pm = mob as PlayerMobile; if (PlayerInfo.ContainsKey(Convert.ToInt32(pm.Serial))) { InfoList info = PlayerInfo[Convert.ToInt32(pm.Serial)]; ID = Convert.ToString(Convert.ToInt32(pm.Serial)); writer.WriteStartElement("ID"); writer.WriteStartAttribute("", "Serial", ""); writer.WriteString(ID); writer.WriteEndAttribute(); if (info.Level > pm.Level && pm.Level == 0 || info.KillExp > pm.KillExp && pm.KillExp == 0) { //Login-Save-Restart-No Login-Save Saftey SystemInfo.SaveValue("Level", info.Level, 0, writer); SystemInfo.SaveValue("LevelCap", info.LevelCap, 0, writer); SystemInfo.SaveValue("KillExp", info.KillExp, 1, writer); SystemInfo.SaveValue("AccKillExp", info.AccKillExp, 1, writer); SystemInfo.SaveValue("LevelAt", info.LevelAt, 0, writer); SystemInfo.SaveValue("AccLevelAt", info.LevelAt, 0, writer); } else { SystemInfo.SaveValue("Level", pm.Level, 0, writer); SystemInfo.SaveValue("LevelCap", pm.LevelCap, 0, writer); SystemInfo.SaveValue("KillExp", pm.KillExp, 1, writer); SystemInfo.SaveValue("AccKillExp", pm.AccKillExp, 1, writer); SystemInfo.SaveValue("LevelAt", pm.LevelAt, 0, writer); SystemInfo.SaveValue("AccLevelAt", pm.LevelAt, 0, writer); } writer.WriteEndElement(); } } } writer.WriteEndElement(); writer.Close(); if (set.TimeSave) Console.WriteLine("Done! ({0:F1} seconds)", (DateTime.Now - Start).TotalSeconds); else Console.WriteLine("Done!"); Console.ForegroundColor = col; LoadPlayers(true); }
public static void ExpPlugin(Mobile m, double Gain) { Setup set = new Setup(); FinalizeExp(m, null, Gain, false, new Setup()); }
public static void LoadPlayers(bool Reload) { string Root = null; string Parent = null; int PlayersLoaded = 0; Setup set = new Setup(); DateTime Start = DateTime.Now; ConsoleColor col = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.DarkGreen; if (Reload) { PlayerInfo.Clear(); Console.Write("Level System: Reloading... "); } else Console.Write("Level System: Loading... "); if (!Directory.Exists(FilePath)) Directory.CreateDirectory(FilePath); if (!File.Exists(FilePath + FileName)) { Console.WriteLine("-No Save Found- Done!"); Console.ForegroundColor = col; return; } XmlDocument doc = new XmlDocument(); doc.Load(FilePath + FileName); if (doc.DocumentElement != null) Root = doc.DocumentElement.Name; if (doc.DocumentElement.FirstChild != null) Parent = doc.DocumentElement.FirstChild.Name; if (Root == null | Parent == null) { Console.WriteLine("-Empty Save- Done!"); Console.ForegroundColor = col; return; } XmlNodeList IDList = doc.SelectNodes("/" + Root + "/" + Parent); foreach (XmlNode id in IDList) { try { int ID = Convert.ToInt32(id.Attributes["Serial"].Value); int Level = Convert.ToInt32(id.SelectSingleNode("Level").InnerText); int LevelCap = Convert.ToInt32(id.SelectSingleNode("LevelCap").InnerText); double KillExp = Convert.ToDouble(id.SelectSingleNode("KillExp").InnerText); double AccKillExp = Convert.ToDouble(id.SelectSingleNode("AccKillExp").InnerText); int LevelAt = Convert.ToInt32(id.SelectSingleNode("LevelAt").InnerText); int AccLevelAt = Convert.ToInt32(id.SelectSingleNode("AccLevelAt").InnerText); if (!PlayerInfo.ContainsKey(ID)) PlayerInfo.Add(ID, new InfoList(Level, LevelCap, KillExp, AccKillExp, LevelAt, AccLevelAt)); PlayersLoaded++; } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(); Console.WriteLine("ERROR: " + e); } } if (!Reload || Reload && set.TimeReload) Console.WriteLine("Done! ({0} players, {1:F1} seconds)", PlayersLoaded, (DateTime.Now - Start).TotalSeconds); if (Reload) { if (!set.TimeReload) Console.WriteLine("Done!"); Console.ForegroundColor = col; Console.Write("Save "); } Console.ForegroundColor = col; }
public static void FinalizeExp(Mobile m, double Gain, bool Craft, Setup set)//for craft (no killed Mobile) { FinalizeExp(m, null, Gain, Craft, new Setup()); }
public static double ExpMirror(Mobile m) { Setup set = new Setup(); PlayerMobile pm = m as PlayerMobile; if (set.AccumulativeExp) return pm.AccKillExp + Figures.Stats(pm) + Figures.Skills(pm); else return pm.KillExp + Figures.Stats(pm) + Figures.Skills(pm); }
public static void AddExp(Mobile m, double Gain, Setup set) { PlayerMobile pm = m as PlayerMobile; if (Gain > 0) pm.SendMessage("You've gained {0} exp.", Math.Round(Gain, 2)); pm.KillExp += Math.Round(Gain, 2); pm.AccKillExp += Math.Round(Gain, 2); if (set.RefreshExpBarOnGain && pm.HasGump(typeof(ExpBar))) { pm.CloseGump(typeof(ExpBar)); pm.SendGump(new ExpBar(pm)); } if (pm.Level < pm.LevelCap && pm.Exp >= pm.LevelAt) DoLevel(pm, new Setup()); }
public override void GetProperties( ObjectPropertyList list ) { base.GetProperties( list ); if ( Map == Faction.Facet ) { PlayerState pl = PlayerState.Find( this ); if ( pl != null ) { Faction faction = pl.Faction; if ( faction.Commander == this ) list.Add( 1042733, faction.Definition.PropName ); // Commanding Lord of the ~1_FACTION_NAME~ else if ( pl.Sheriff != null ) list.Add( 1042734, "{0}\t{1}", pl.Sheriff.Definition.FriendlyName, faction.Definition.PropName ); // The Sheriff of ~1_CITY~, ~2_FACTION_NAME~ else if ( pl.Finance != null ) list.Add( 1042735, "{0}\t{1}", pl.Finance.Definition.FriendlyName, faction.Definition.PropName ); // The Finance Minister of ~1_CITY~, ~2_FACTION_NAME~ else if ( pl.MerchantTitle != MerchantTitle.None ) list.Add( 1060776, "{0}\t{1}", MerchantTitles.GetInfo( pl.MerchantTitle ).Title, faction.Definition.PropName ); // ~1_val~, ~2_val~ else list.Add( 1060776, "{0}\t{1}", pl.Rank.Title, faction.Definition.PropName ); // ~1_val~, ~2_val~ } } //Level System 3 Rework 1 Setup set = new Setup(); if (set.ShowLevelBelowName && Level > 0 && Features.Display(this, null) != null) { list.Add( "Level: " + Features.Display(this, null)); } //END Level System 3 Rework 1 if ( Core.ML ) { for ( int i = AllFollowers.Count - 1; i >= 0; i-- ) { BaseCreature c = AllFollowers[ i ] as BaseCreature; if ( c != null && c.ControlOrder == OrderType.Guard ) { list.Add( 501129 ); // guarded break; } } } }