public static bool Award(Mobile from, VirtueName virtue, int amount, ref bool gainedPath) { var current = from.Virtues.GetValue((int)virtue); var maxAmount = GetMaxAmount(virtue); if (current >= maxAmount) { return(false); } if (from.FindItemOnLayer(Layer.TwoHanded) is VirtueShield) { amount = amount + (int)(amount * 1.5); } if ((current + amount) >= maxAmount) { amount = maxAmount - current; } var oldLevel = GetLevel(from, virtue); from.Virtues.SetValue((int)virtue, current + amount); gainedPath = (GetLevel(from, virtue) != oldLevel); return(true); }
public static bool Award(Mobile from, VirtueName virtue, int amount, ref bool gainedPath) { int current = from.Virtues.GetValue((int)virtue); int maxAmount = GetMaxAmount(virtue); if (current >= maxAmount) { return(false); } if ((current + amount) >= maxAmount) { amount = maxAmount - current; } VirtueLevel oldLevel = GetLevel(from, virtue); from.Virtues.SetValue((int)virtue, current + amount); VirtueLevel newLevel = GetLevel(from, virtue); gainedPath = (newLevel != oldLevel); if (gainedPath) { EventSink.InvokeOnVirtueLevelChange(from, (int)oldLevel, (int)newLevel, (int)virtue); } return(true); }
public VirtueBonusEntry(VirtueName virtue, string mantra, Rectangle2D location, int cliloc) { Virtue = virtue; Mantra = mantra; Area = location; Cliloc = cliloc; }
public override void OnKilled(Mobile killed, Mobile killer) { base.OnKilled(killed, killer); if (killer == null) { return; } VirtueName g = (VirtueName)0; bool valid = true; bool gainedPath = false; try { g = (VirtueName)Enum.Parse(typeof(VirtueName), Virtue, true); } catch { valid = false; } if (valid) { // give the killer the Virtue VirtueHelper.Award(killer, g, Value, ref gainedPath); if (gainedPath) { killer.SendMessage("You have gained a path in {0}", Virtue); } killer.SendMessage("Receive {0}", OnIdentify(killer)); } }
public static bool Atrophy( Mobile from, VirtueName virtue ) { int current = from.Virtues.GetValue( (int)virtue ); if ( current > 0 ) from.Virtues.SetValue( (int)virtue, current - 1 ); return ( current > 0 ); }
public static int GetMaxAmount(VirtueName virtue) { if (virtue == VirtueName.Honor) return 20000; if (virtue == VirtueName.Sacrifice) return 22000; return 21000; }
public static VirtueLevel GetLevel( Mobile from, VirtueName virtue ) { int v = from.Virtues.GetValue( (int) virtue ) / 10; if ( v < 0 ) v = 0; else if ( v > 3 ) v = 3; return (VirtueLevel)v; }
public static bool Atrophy( Mobile from, VirtueName virtue, int amount ) { int current = from.Virtues.GetValue( (int)virtue ); if( (current - amount) >= 0 ) from.Virtues.SetValue( (int)virtue, current - amount ); else from.Virtues.SetValue( (int)virtue, 0 ); return ( current > 0 ); }
public static bool Atrophy(Mobile from, VirtueName virtue) { int current = from.Virtues.GetValue((int)virtue); if (current > 0) { from.Virtues.SetValue((int)virtue, current - 1); } return(current > 0); }
public static int GetMaxAmount( VirtueName virtue ) { //Edit by Silver return 30000; //if( virtue == VirtueName.Honor ) // return 20000; //if( virtue == VirtueName.Sacrifice ) // return 22000; //return 21000; }
public static void AwardVirtue(PlayerMobile pm, VirtueName virtue, int amount) { if (virtue == VirtueName.Compassion) { if (pm.CompassionGains > 0 && DateTime.UtcNow > pm.NextCompassionDay) { pm.NextCompassionDay = DateTime.MinValue; pm.CompassionGains = 0; } if (pm.CompassionGains >= 5) { pm.SendLocalizedMessage(1053004); // You must wait about a day before you can gain in compassion again. return; } } bool gainedPath = false; string virtueName = Enum.GetName(typeof(VirtueName), virtue); if (Award(pm, virtue, amount, ref gainedPath)) { // TODO: Localize? if (gainedPath) { pm.SendMessage("You have gained a path in {0}!", virtueName); } else { pm.SendMessage("You have gained in {0}.", virtueName); } if (virtue == VirtueName.Compassion) { pm.NextCompassionDay = DateTime.UtcNow + TimeSpan.FromDays(1.0); ++pm.CompassionGains; if (pm.CompassionGains >= 5) { pm.SendLocalizedMessage( 1053004); // You must wait about a day before you can gain in compassion again. } } } else { // TODO: Localize? pm.SendMessage("You have achieved the highest path of {0} and can no longer gain any further.", virtueName); } }
public static VirtueLevel GetLevel( Mobile from, VirtueName virtue ) { int v = from.Virtues.GetValue( (int)virtue ); int vl; if ( v < 4000 ) vl = 0; else if ( v >= 20000 ) vl = 3; else vl = ( v + 9999 ) / 10000; return (VirtueLevel)vl; }
public static int GetMaxAmount(VirtueName virtue) { if (virtue == VirtueName.Honor) { return(20000); } if (virtue == VirtueName.Sacrifice) { return(22000); } return(21000); }
public static VirtueLevel GetLevel(Mobile from, VirtueName virtue) { int v = from.Virtues.GetValue((int)virtue) / 10; if (v < 0) { v = 0; } else if (v > 3) { v = 3; } return((VirtueLevel)v); }
public static bool Atrophy(Mobile from, VirtueName virtue, int amount) { var current = from.Virtues.GetValue((int)virtue); if ((current - amount) >= 0) { from.Virtues.SetValue((int)virtue, current - amount); } else { from.Virtues.SetValue((int)virtue, 0); } return(current > 0); }
public override void OnAttach() { base.OnAttach(); // apply the mod if (this.AttachedTo is PlayerMobile) { // for players just add it immediately // lookup the virtue type VirtueName g = (VirtueName)0; bool valid = true; bool gainedPath = false; try { g = (VirtueName)Enum.Parse(typeof(VirtueName), this.Virtue, true); } catch { valid = false; } if (valid) { VirtueHelper.Award((Mobile)this.AttachedTo, g, this.Value, ref gainedPath); ((Mobile)this.AttachedTo).SendMessage("Receive {0}", this.OnIdentify((Mobile)this.AttachedTo)); if (gainedPath) { ((Mobile)this.AttachedTo).SendMessage("You have gained a path in {0}", this.Virtue); } } else { ((Mobile)this.AttachedTo).SendMessage("{0}: no such Virtue", this.Virtue); } // and then remove the attachment Timer.DelayCall(TimeSpan.Zero, new TimerCallback(Delete)); //Delete(); } else if (this.AttachedTo is Item) { // dont allow item attachments this.Delete(); } }
public static bool Award( Mobile from, VirtueName virtue, int amount, ref bool gainedPath ) { int current = from.Virtues.GetValue( (int)virtue ); if ( current >= 40 ) return false; if ( (current + amount) >= 40 ) amount = 40 - current; VirtueLevel oldLevel = GetLevel( from, virtue ); from.Virtues.SetValue( (int)virtue, current + amount ); gainedPath = ( GetLevel( from, virtue ) != oldLevel ); return true; }
public static void AwardVirtue( PlayerMobile pm, VirtueName virtue, int amount ) { if ( virtue == VirtueName.Compassion ) { if ( pm.CompassionGains > 0 && DateTime.Now > pm.NextCompassionDay ) { pm.NextCompassionDay = DateTime.MinValue; pm.CompassionGains = 0; } if ( pm.CompassionGains >= 5 ) { pm.SendLocalizedMessage( 1053004 ); // You must wait about a day before you can gain in compassion again. return; } } bool gainedPath = false; string virtueName = Enum.GetName( typeof( VirtueName ), virtue ); if ( VirtueHelper.Award( pm, virtue, amount, ref gainedPath ) ) { // TODO: Localize? if ( gainedPath ) pm.SendMessage( "You have gained a path in {0}!", virtueName ); else pm.SendMessage( "You have gained in {0}.", virtueName ); if ( virtue == VirtueName.Compassion ) { pm.NextCompassionDay = DateTime.Now + TimeSpan.FromDays( 1.0 ); ++pm.CompassionGains; if ( pm.CompassionGains >= 5 ) pm.SendLocalizedMessage( 1053004 ); // You must wait about a day before you can gain in compassion again. } } else { // TODO: Localize? pm.SendMessage( "You have achieved the highest path of {0} and can no longer gain any further.", virtueName ); } }
public static VirtueLevel GetLevel(Mobile from, VirtueName virtue) { int v = from.Virtues.GetValue((int)virtue); int vl; if (v < 4000) { vl = 0; } else if (v >= 20000) { vl = 3; } else { vl = (v + 9999) / 10000; } return((VirtueLevel)vl); }
public static VirtueLevel GetLevel(Mobile from, VirtueName virtue) { var v = from.Virtues.GetValue((int)virtue); int vl; var vmax = GetMaxAmount(virtue); if (v < 4000) { vl = 0; } else if (v >= vmax) { vl = 3; } else { vl = (v + 10000) / 10000; } return((VirtueLevel)vl); }
public static bool Award(Mobile from, VirtueName virtue, int amount, ref bool gainedPath) { /*int current = from.Virtues.GetValue( (int)virtue ); * * int maxAmount = GetMaxAmount( virtue ); * * if ( current >= maxAmount ) * return false; * * if( (current + amount) >= maxAmount ) * amount = maxAmount - current; * * VirtueLevel oldLevel = GetLevel( from, virtue ); * * from.Virtues.SetValue( (int)virtue, current + amount ); * * gainedPath = ( GetLevel( from, virtue ) != oldLevel ); * * return true;*/ return(false); }
public static bool Award(Mobile from, VirtueName virtue, int amount, ref bool gainedPath) { int current = from.Virtues.GetValue((int)virtue); if (current >= 30) { return(false); } if ((current + amount) >= 30) { amount = 30 - current; } VirtueLevel oldLevel = GetLevel(from, virtue); from.Virtues.SetValue((int)virtue, current + amount); gainedPath = (GetLevel(from, virtue) != oldLevel); return(true); }
public static bool Award(Mobile from, VirtueName virtue, int amount, ref bool gainedPath) { var current = from.Virtues.GetValue((int)virtue); var maxAmount = GetMaxAmount(virtue); if (current >= maxAmount) { return(false); } if (from.FindItemOnLayer(Layer.TwoHanded) is VirtueShield) { amount = amount + (int)(amount * 1.5); } if ((current + amount) >= maxAmount) { amount = maxAmount - current; } var oldLevel = GetLevel(from, virtue); from.Virtues.SetValue((int)virtue, current + amount); var newLevel = GetLevel(from, virtue); gainedPath = (newLevel != oldLevel); if (gainedPath) { EventSink.InvokeVirtueLevelChange(new VirtueLevelChangeEventArgs(from, (int)oldLevel, (int)newLevel, (int)virtue)); } return(true); }
public static bool IsSeeker(Mobile from, VirtueName virtue) => GetLevel(from, virtue) >= VirtueLevel.Seeker;
public VirtueAchievement(VirtueName virtue, VirtueLevel level, TextDefinition name, TextDefinition description, int points, int unlocks) : base(name, description, points, unlocks) { Virtue = virtue; Level = level; }
public VirtueBonusEntry( VirtueName virtue, string mantra, Rectangle2D location, int cliloc ) { Virtue = virtue; Mantra = mantra; Area = location; Cliloc = cliloc; }
public VirtueInfoGump(Mobile beholder, VirtueName virtue, int description, string webPage) : base(0, 0) { m_Beholder = beholder; m_Virtue = virtue; m_Desc = description; m_Page = webPage; int value = beholder.Virtues.GetValue((int)virtue); AddPage(0); AddImage(30, 40, 2080); AddImage(47, 77, 2081); AddImage(47, 147, 2081); AddImage(47, 217, 2081); AddImage(47, 267, 2083); AddImage(70, 213, 2091); AddPage(1); int maxValue = VirtueHelper.GetMaxAmount(m_Virtue); int valueDesc; int dots; if (value < 4000) { dots = value / 400; } else if (value < 10000) { dots = (value - 4000) / 600; } else if (value < maxValue) { dots = (value - 10000) / ((maxValue - 10000) / 10); } else { dots = 10; } for (int i = 0; i < 10; ++i) { AddImage(95 + (i * 17), 50, i < dots ? 2362 : 2360); } if (value < 1) { valueDesc = 1052044; // You have not started on the path of this Virtue. } else if (value < 400) { valueDesc = 1052045; // You have barely begun your journey through the path of this Virtue. } else if (value < 2000) { valueDesc = 1052046; // You have progressed in this Virtue, but still have much to do. } else if (value < 3600) { valueDesc = 1052047; // Your journey through the path of this Virtue is going well. } else if (value < 4000) { valueDesc = 1052048; // You feel very close to achieving your next path in this Virtue. } else if (dots < 1) { valueDesc = 1052049; // You have achieved a path in this Virtue. } else if (dots < 9) { valueDesc = 1052047; // Your journey through the path of this Virtue is going well. } else if (dots < 10) { valueDesc = 1052048; // You feel very close to achieving your next path in this Virtue. } else { valueDesc = 1052050; // You have achieved the highest path in this Virtue. } AddHtmlLocalized(157, 73, 200, 40, 1051000 + (int)virtue, false, false); AddHtmlLocalized(75, 95, 220, 140, description, false, false); AddHtmlLocalized(70, 224, 229, 60, valueDesc, false, false); AddButton(65, 277, 1209, 1209, 1, GumpButtonType.Reply, 0); AddButton(280, 43, 4014, 4014, 2, GumpButtonType.Reply, 0); AddHtmlLocalized( 83, 275, 400, 40, webPage == null ? 1052055 : 1052052, false, false); // This virtue is not yet defined. OR -click to learn more (opens webpage) }
public static bool IsKnight(Mobile from, VirtueName virtue) { return(GetLevel(from, virtue) >= VirtueLevel.Knight); }
public static bool IsHighestPath(Mobile from, VirtueName virtue) { return(from.Virtues.GetValue((int)virtue) >= GetMaxAmount(virtue)); }
public static bool HasAny( Mobile from, VirtueName virtue ) { return ( from.Virtues.GetValue( (int)virtue ) > 0 ); }
public VirtueInfoGump( Mobile beholder, VirtueName virtue, int description ) : base(0, 0) { m_Beholder = beholder; m_Virtue = virtue; m_Desc = description; int value = beholder.Virtues.GetValue( (int) virtue ); AddPage( 0 ); AddImage( 30, 40, 2080 ); AddImage( 47, 77, 2081 ); AddImage( 47, 147, 2081 ); AddImage( 47, 217, 2081 ); AddImage( 47, 267, 2083 ); AddImage( 70, 213, 2091 ); AddPage( 1 ); int maxValue = VirtueHelper.GetMaxAmount( m_Virtue ); int valueDesc; if ( value < 1 ) valueDesc = 1052044; // You have not started on the path of this Virtue. else if ( value < maxValue / 6 ) valueDesc = 1052045; // You have barely begun your journey through the path of this Virtue. else if ( value < maxValue / 3 ) valueDesc = 1052046; // You have progressed in this Virtue, but still have much to do. else if ( value < maxValue / 2 ) valueDesc = 1052047; // Your journey through the path of this Virtue is going well. else if ( value < 2 * maxValue / 3 ) valueDesc = 1052048; // You feel very close to achieving your next path in this Virtue. else if ( value < 5 * maxValue / 6 ) valueDesc = 1052049; // You have achieved a path in this Virtue. else valueDesc = 1052050; // You have achieved the highest path in this Virtue. AddHtmlLocalized( 157, 73, 200, 40, 1051000 + (int) virtue, false, false ); AddHtmlLocalized( 75, 95, 220, 140, description, false, false ); AddHtmlLocalized( 70, 224, 229, 60, valueDesc, false, false ); AddButton( 65, 277, 1209, 1209, 1, GumpButtonType.Reply, 0 ); AddButton( 280, 43, 4014, 4014, 2, GumpButtonType.Reply, 0 ); AddHtmlLocalized( 83, 275, 400, 40, 1052055, false, false ); // This virtue is not yet defined. AddKRHtmlLocalized( 0, 0, 0, 0, 1078056, false, false ); // MORE AddKRHtmlLocalized( 0, 0, 0, 0, 1011447, false, false ); // BACK AddKRHtmlLocalized( 0, 0, 0, 0, 1078055, false, false ); // USE AddKRHtmlLocalized( 0, 0, 0, 0, 0, false, false ); int dots; if ( value < 4000 ) dots = value / 400; else if ( value < 10000 ) dots = ( value - 4000 ) / 600; else if ( value < maxValue ) dots = ( value - 10000 ) / ( ( maxValue - 10000 ) / 10 ); else dots = 10; for ( int i = 0; i < 10; ++i ) AddImage( 95 + ( i * 17 ), 50, i < dots ? 2362 : 2360 ); }
public static bool IsKnight(Mobile from, VirtueName virtue) => GetLevel(from, virtue) >= VirtueLevel.Knight;
public static bool IsFollower(Mobile from, VirtueName virtue) => GetLevel(from, virtue) >= VirtueLevel.Follower;
public static bool Atrophy(Mobile from, VirtueName virtue) => Atrophy(from, virtue, 1);
public VirtueInfoGump(Mobile beholder, VirtueName virtue, int description) : this(beholder, virtue, description, null) { }
public static string GetName(this VirtueName virtue) => virtue switch {
public static int GetMaxAmount(VirtueName virtue) => virtue switch {
public static bool IsHighestPath( Mobile from, VirtueName virtue ) { return ( from.Virtues.GetValue( (int)virtue ) >= 40 ); }
public static bool Atrophy(Mobile from, VirtueName virtue) { return(Atrophy(from, virtue, 1)); }
public static bool IsKnight( Mobile from, VirtueName virtue ) { return ( GetLevel( from, virtue ) >= VirtueLevel.Knight ); }
public static bool IsFollower(Mobile from, VirtueName virtue) { return(GetLevel(from, virtue) >= VirtueLevel.Follower); }
public static bool IsSeeker( Mobile from, VirtueName virtue ) { return ( GetLevel( from, virtue ) >= VirtueLevel.Seeker ); }
public static bool HasAny(Mobile from, VirtueName virtue) { return(from.Virtues.GetValue((int)virtue) > 0); }
public static bool Atrophy(Mobile from, VirtueName virtue) { return Atrophy(from, virtue, 1); }
public VirtueInfoGump(Mobile beholder, VirtueName virtue, int description, string webPage) : base(0, 0) { this.m_Beholder = beholder; this.m_Virtue = virtue; this.m_Desc = description; this.m_Page = webPage; int value = beholder.Virtues.GetValue((int)virtue); this.AddPage(0); this.AddImage(30, 40, 2080); this.AddImage(47, 77, 2081); this.AddImage(47, 147, 2081); this.AddImage(47, 217, 2081); this.AddImage(47, 267, 2083); this.AddImage(70, 213, 2091); this.AddPage(1); int maxValue = VirtueHelper.GetMaxAmount(this.m_Virtue); int valueDesc; int dots; if (value < 4000) dots = value / 400; else if (value < 10000) dots = (value - 4000) / 600; else if (value < maxValue) dots = (value - 10000) / ((maxValue - 10000) / 10); else dots = 10; for (int i = 0; i < 10; ++i) this.AddImage(95 + (i * 17), 50, i < dots ? 2362 : 2360); if (value < 1) valueDesc = 1052044; // You have not started on the path of this Virtue. else if (value < 400) valueDesc = 1052045; // You have barely begun your journey through the path of this Virtue. else if (value < 2000) valueDesc = 1052046; // You have progressed in this Virtue, but still have much to do. else if (value < 3600) valueDesc = 1052047; // Your journey through the path of this Virtue is going well. else if (value < 4000) valueDesc = 1052048; // You feel very close to achieving your next path in this Virtue. else if (dots < 1) valueDesc = 1052049; // You have achieved a path in this Virtue. else if (dots < 9) valueDesc = 1052047; // Your journey through the path of this Virtue is going well. else if (dots < 10) valueDesc = 1052048; // You feel very close to achieving your next path in this Virtue. else valueDesc = 1052050; // You have achieved the highest path in this Virtue. this.AddHtmlLocalized(157, 73, 200, 40, 1051000 + (int)virtue, false, false); this.AddHtmlLocalized(75, 95, 220, 140, description, false, false); this.AddHtmlLocalized(70, 224, 229, 60, valueDesc, false, false); this.AddButton(65, 277, 1209, 1209, 1, GumpButtonType.Reply, 0); this.AddButton(280, 43, 4014, 4014, 2, GumpButtonType.Reply, 0); this.AddHtmlLocalized(83, 275, 400, 40, (webPage == null) ? 1052055 : 1052052, false, false); // This virtue is not yet defined. OR -click to learn more (opens webpage) }
public static bool HasAny(Mobile from, VirtueName virtue) => from.Virtues.GetValue((int)virtue) > 0;
public static bool IsHighestPath( Mobile from, VirtueName virtue ) { return false;//return ( from.Virtues.GetValue( (int)virtue ) >= GetMaxAmount( virtue ) ); }