public static void MakeEvil_OnTarget(Mobile from, object obj) { if (obj is PlayerMobile) { PlayerMobile pm = obj as PlayerMobile; if (pm.EthicPlayer != null) { Player p = Player.Find(pm); if (p != null) { p.Detach(); pm.Delta(MobileDelta.Noto); from.SendMessage("That player has been removed from the ethics system."); } } Player pl = new Player(Server.Ethics.Ethic.Evil, pm); pl.Attach(); pm.Delta(MobileDelta.Noto); pm.FixedEffect(0x373A, 10, 30); pm.PlaySound(0x209); pm.SendLocalizedMessage(502595); // You are now evil. from.SendMessage("That player has been added to the ethics system."); } else { from.BeginTarget(-1, false, TargetFlags.None, new TargetCallback(RemoveEthic_OnTarget)); from.SendMessage("That is not a player. Try again."); } }
public static void EventSink_Speech(SpeechEventArgs e) { if (e.Blocked || e.Handled) { return; } Player pl = Player.Find(e.Mobile); if (pl == null) { for (int i = 0; i < Ethics.Length; ++i) { Ethic ethic = Ethics[i]; if (!ethic.IsEligible(e.Mobile)) { continue; } if (!Insensitive.Equals(ethic.Definition.JoinPhrase.String, e.Speech)) { continue; } bool isNearAnkh = false; foreach (Item item in e.Mobile.GetItemsInRange(2)) { if (item is Items.AnkhNorth || item is Items.AnkhWest) { isNearAnkh = true; break; } } if (!isNearAnkh) { continue; } pl = new Player(ethic, e.Mobile); pl.Attach(); e.Mobile.FixedEffect(0x373A, 10, 30); e.Mobile.PlaySound(0x209); e.Handled = true; break; } } else { Ethic ethic = pl.Ethic; for (int i = 0; i < ethic.Definition.Powers.Length; ++i) { Power power = ethic.Definition.Powers[i]; if (!Insensitive.Equals(power.Definition.Phrase.String, e.Speech)) { continue; } if (!power.CheckInvoke(pl)) { continue; } power.BeginInvoke(pl); e.Handled = true; break; } } }
public static void EventSink_Speech( SpeechEventArgs e ) { if ( e.Blocked || e.Handled ) return; Player pl = Player.Find( e.Mobile ); if ( pl == null ) { for ( int i = 0; i < Ethics.Length; ++i ) { Ethic ethic = Ethics[i]; if ( !ethic.IsEligible( e.Mobile ) ) continue; if ( !Insensitive.Equals( ethic.Definition.JoinPhrase.String, e.Speech ) ) continue; bool isNearAnkh = false; foreach ( Item item in e.Mobile.GetItemsInRange( 2 ) ) { if ( item is Items.AnkhNorth || item is Items.AnkhWest ) { isNearAnkh = true; break; } } if ( !isNearAnkh ) continue; pl = new Player( ethic, e.Mobile ); pl.Attach(); e.Mobile.FixedEffect( 0x373A, 10, 30 ); e.Mobile.PlaySound( 0x209 ); e.Handled = true; break; } } else { Ethic ethic = pl.Ethic; for ( int i = 0; i < ethic.Definition.Powers.Length; ++i ) { Power power = ethic.Definition.Powers[i]; if ( !Insensitive.Equals( power.Definition.Phrase.String, e.Speech ) ) continue; if ( !power.CheckInvoke( pl ) ) continue; power.BeginInvoke( pl ); e.Handled = true; break; } } }
public static void HandleDeath(Mobile victim, Mobile killer) { if (killer == null) { killer = victim.FindMostRecentDamager(true); } if (killer == null) { return; // happens if GM [kill'ed } // creature points if (victim is BaseCreature) { BaseCreature bc = (BaseCreature)victim; if (bc.Map == Factions.Faction.Facet && bc.GetEthicAllegiance(killer) == BaseCreature.Allegiance.Enemy) { Ethics.Player killerEPL = Server.Ethics.Player.Find(killer); if (killerEPL != null && (100 - killerEPL.Power) > Utility.Random(100)) { // killer belongs to an ethic if (killer is PlayerMobile) { // sanity if ((killerEPL.Ethic == Ethic.Evil && killer.ShortTermMurders == 0) || (killerEPL.Ethic == Ethic.Hero && killer.ShortTermMurders == 0 && !killer.Murderer)) { // no murder counts if Hero. Evil ok to have longs (this is how I read the docs) if (killerEPL.Ethic == Ethic.Evil || ((killer as PlayerMobile).NpcGuild != NpcGuild.ThievesGuild)) { // Heros can't belong to the Thieves guild and gain life force. Evil ok // from the evil/hero system doc // Note that in everything below, "kills" is defined by "the person who did the most damage when the // person was killed." (I assum this applied to creatures as well.) if (Mobile.MostDamage(victim, killer)) { if (killerEPL.Power < 100) { ++killerEPL.Power; ++killerEPL.History; killer.SendLocalizedMessage(1045100); // You have gained LifeForce } else { killer.SendLocalizedMessage(1045101); // Your LifeForce is at the maximum } } } } } } } return; } else { // player points Ethics.Player killerEPL = Server.Ethics.Player.Find(killer, true); Ethics.Player victimEPL = Server.Ethics.Player.Find(victim); // evil kill an innocent // When evils kill innocents that they attacked, all the evil's stats and skills fall by 50% for five minutes . // They also lose lifeforce. If the evil has 0 lifeforce, then the evil can also be reported for murder. // Lastly, they cannot hide, recall, or gate away for those five minutes. if (killer.Evil && !victim.Hero && !victim.Evil) { if (ComputeMurder(victim, killer)) { // stats and skills ApplySkillLoss(killer); ApplyStatLoss(killer); // loss of life force (no idea how much) killerEPL.Power -= Math.Min(killerEPL.Power, Utility.Random(10, 50)); // loss of sphere killerEPL.History -= Math.Min(killerEPL.History, Utility.Random(10, 50)); // set the EvilCrim state which will prevent gate and hide for 5 minutes killer.ExpirationFlags.Add(new Mobile.ExpirationFlag(killer, Mobile.ExpirationFlagID.EvilCrim, TimeSpan.FromMinutes(5))); killer.SendLocalizedMessage(1045108); // You have lost lifeforce killer.LocalOverheadMessage(Server.Network.MessageType.Regular, 0x3B2, 500913); // The life force of this victim was not pure. You stumble back in pain. } } // good kill an innocent // Innocents who die to heroes are covered under the standard reputation system. In addition, the heroes are stripped of their status. // If you lose too much sphere or lifeforce, you become a "fallen hero." You are still gray to evils for an additional five minutes. // If a hero is reported for murder, all lifeforce and sphere immediately vanishes, and you become a fallen hero if (killer.Hero && !victim.Hero && !victim.Evil) { if (ComputeMurder(victim, killer)) { // the killer murdered the victim // loss of life force (no idea how much) killerEPL.Power -= Math.Min(killerEPL.Power, Utility.Random(10, 50)); // loss of sphere killerEPL.History -= Math.Min(killerEPL.History, Utility.Random(10, 50)); if (killerEPL.Power == 0 || killerEPL.History == 0) { // set the FallenHero state which make you gray to evil for 5 minutes (what does it mean for a hero to be gray to an evil?) killer.ExpirationFlags.Add(new Mobile.ExpirationFlag(killer, Mobile.ExpirationFlagID.FallenHero, TimeSpan.FromMinutes(5))); } killer.SendLocalizedMessage(1045108); // You have lost lifeforce } } // transfer lifeforce if (Mobile.MostDamage(victim, killer)) { // we did the most damage if (killerEPL != null && victimEPL != null && victimEPL.Power > 0) { // two participants in the ethics system if (killer is PlayerMobile) { // sanity if ((killerEPL.Ethic == Ethic.Evil && killer.ShortTermMurders == 0) || (killerEPL.Ethic == Ethic.Hero && killer.ShortTermMurders == 0 && !killer.Murderer)) { // no murder counts if Hero. Evil ok to have longs (this is how I read the docs) if (killerEPL.Ethic == Ethic.Evil || ((killer as PlayerMobile).NpcGuild != NpcGuild.ThievesGuild)) { // Heros can't belong to the Thieves guild and gain life force. Evil ok if (victim.CheckState(Mobile.ExpirationFlagID.NoPoints) == false) { // [un]holy word - No sphere nor lifeforce is granted for the kill. if (killerEPL.Ethic != victimEPL.Ethic) { // heros can't gain life force by killing other heros (we'll apply this to evils as well) // 20% of victim's power int powerTransfer = victimEPL.Power / 5; if (powerTransfer > (100 - killerEPL.Power)) { powerTransfer = 100 - killerEPL.Power; } if (powerTransfer > 0) { victimEPL.Power -= powerTransfer; killerEPL.Power += powerTransfer; killerEPL.History += powerTransfer; killer.SendLocalizedMessage(1045100); // You have gained LifeForce victim.SendLocalizedMessage(1045108); // You have lost lifeforce } else { killer.SendLocalizedMessage(1045101); // Your LifeForce is at the maximum } } } } } } } } // award special kill points to pre ethic enrollment participants that kill evil // to qualify we will use the rules for gaining life force for Hero i.e., // You cannot gain points life force while you are red, not while you have any short murder counts, // nor if you are a member of the Thieves' Guild. if (killerEPL == null && victimEPL != null && victimEPL.Ethic == Ethic.Evil) { // killer not in ethics && victim is Evil if (killer.ShortTermMurders == 0 && !killer.Murderer) { // no murder counts if (killer is PlayerMobile && (killer as PlayerMobile).NpcGuild != NpcGuild.ThievesGuild) { // not in the Thieves' Guild PlayerMobile pm = (killer as PlayerMobile); // check to make sure we have not killed thie evil before bool goodKill = true; foreach (PlayerMobile.EthicKillsLog ekl in pm.EthicKillsLogList) { if (ekl.Serial == victim.Serial && !ekl.Expired) { // we've killed this guy within the last 5 days goodKill = false; break; } } if (goodKill) { pm.EthicKillsLogList.Add(new PlayerMobile.EthicKillsLog(victim.Serial, DateTime.Now)); if (pm.EthicPoints >= 5) { // Add to Good alignment (EthicPoints log will be wipped on next serialization) if (Ethic.Hero.IsEligible(killer)) // make sure they are old enough { Player pl = new Player(Ethic.Hero, killer); pl.Attach(); pm.Delta(MobileDelta.Noto); killer.FixedEffect(0x373A, 10, 30); killer.PlaySound(0x209); killer.SendLocalizedMessage(501994); // For your heroic deeds you are granted the title of hero. } } else { // tell them they are on the path to hero! killer.SendLocalizedMessage(502598); // Strive to continue on the path of benevolence. } } } } } } }
public static void EventSink_Speech(SpeechEventArgs e) { if (e.Blocked || e.Handled) { return; } Player pl = Player.Find(e.Mobile); if (pl == null) { for (int i = 0; i < Ethics.Length; ++i) { Ethic ethic = Ethics[i]; if (!Insensitive.Equals(ethic.Definition.JoinPhrase.String, e.Speech)) { continue; } if (!ethic.IsEligible(e.Mobile)) { if (Core.OldEthics) { if ((e.Mobile.CreationTime + TimeSpan.FromHours(24)) > DateTime.Now) { e.Mobile.SendLocalizedMessage(502593); // Thou art too young to choose this fate. } } break; } // don't allow tarnished players to join as Heros if (Core.OldEthics) { // no murder counts if Hero. Evil ok if (!(ethic == Ethic.Evil || (e.Mobile.ShortTermMurders == 0 && !e.Mobile.Murderer))) { // not an official H/E string. I wish I knew what it was! e.Mobile.SendMessage("Your murderous ways prevent you from taking this path."); break; } // Heros can't belong to the Thieves guild and gain life force. Evil ok if (!(ethic == Ethic.Evil || ((e.Mobile is PlayerMobile) && (e.Mobile as PlayerMobile).NpcGuild != NpcGuild.ThievesGuild))) { // not an official H/E string. I wish I knew what it was! e.Mobile.SendMessage("You must first quit the thieves' guild."); break; } } bool isNearAnkh = false; foreach (Item item in e.Mobile.GetItemsInRange(2)) { if (item is Items.AnkhNorth || item is Items.AnkhWest) { isNearAnkh = true; break; } } if (!isNearAnkh) { continue; } pl = new Player(ethic, e.Mobile); pl.Attach(); e.Mobile.Delta(MobileDelta.Noto); e.Mobile.FixedEffect(0x373A, 10, 30); e.Mobile.PlaySound(0x209); if (Core.OldEthics) { if (ethic == Ethic.Evil) { e.Mobile.SendLocalizedMessage(502595); // You are now evil. } } //else //don't know if or what the message is here e.Handled = true; break; } } else { Ethic ethic = pl.Ethic; for (int i = 0; i < ethic.Definition.Powers.Length; ++i) { Power power = ethic.Definition.Powers[i]; if (!Insensitive.Equals(power.Definition.Phrase.String, e.Speech)) { continue; } if (!power.CheckInvoke(pl)) { continue; } power.BeginInvoke(pl); e.Handled = true; break; } } }
public static void EventSink_Speech(SpeechEventArgs e) { if (e.Blocked || e.Handled) { return; } var pl = Player.Find(e.Mobile); if (pl == null) { for (var i = 0; i < Ethics.Length; ++i) { var ethic = Ethics[i]; if (!ethic.IsEligible(e.Mobile)) { continue; } if (!ethic.Definition.JoinPhrase.String.InsensitiveEquals(e.Speech)) { continue; } if (!e.Mobile.GetItemsInRange(2).Any(item => item is AnkhNorth || item is AnkhWest)) { continue; } pl = new Player(ethic, e.Mobile); pl.Attach(); e.Mobile.FixedEffect(0x373A, 10, 30); e.Mobile.PlaySound(0x209); e.Handled = true; break; } } else { if (e.Mobile is PlayerMobile mobile && mobile.DuelContext != null) { return; } var ethic = pl.Ethic; for (var i = 0; i < ethic.Definition.Powers.Length; ++i) { var power = ethic.Definition.Powers[i]; if (!power.Definition.Phrase.String.InsensitiveEquals(e.Speech)) { continue; } if (!power.CheckInvoke(pl)) { continue; } power.BeginInvoke(pl); e.Handled = true; break; } } }
public void JoinAlone(Mobile mob) { AddMember(mob); Player pl = Player.Find(mob); if (Ethic.Enabled && pl == null) { switch (m_Definition.FriendlyName) { case "Shadowlords": case "Minax": pl = new Player(Ethic.Evil, mob); break; case "Council of Mages": case "True Britannians": pl = new Player(Ethic.Hero, mob); break; } if (pl != null) { pl.Attach(); } } mob.SendLocalizedMessage(1005058); // You have joined the faction if (mob is PlayerMobile) { Conquests.CheckProgress<FactionStateConquest>(mob as PlayerMobile, this); } }
public void JoinGuilded(PlayerMobile mob, Guild guild) { Faction faction = this; if (mob.Young) { guild.RemoveMember(mob); mob.SendLocalizedMessage(1042283); // You have been kicked out of your guild! Young players may not remain in a guild which is allied with a faction. } else if (AlreadyHasCharInFaction(mob, faction)) { guild.RemoveMember(mob); mob.SendLocalizedMessage(1005281); // You have been kicked out of your guild due to factional overlap } else if (IsFactionBanned(mob)) { guild.RemoveMember(mob); mob.SendLocalizedMessage(1005052); // You are currently banned from the faction system } else if (mob.SkillsTotal < 7000) { guild.RemoveMember(mob); mob.SendMessage("You are not skilled enough to join a faction."); } else { AddMember(mob); Player pl = Player.Find(mob); if (Ethic.Enabled && pl == null) { switch (m_Definition.FriendlyName) { case "Shadowlords": case "Minax": pl = new Player(Ethic.Evil, mob); break; case "Council of Mages": case "True Britannians": pl = new Player(Ethic.Hero, mob); break; } if (pl != null) { pl.Attach(); } } mob.SendLocalizedMessage(1042756, true, " " + m_Definition.FriendlyName); // You are now joining a faction: } }