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 override void Execute(CommandEventArgs e, object obj) { Mobile mob = (Mobile)obj; switch (m_KickType) { case EthicKickType.Kick: { Player pl = Player.Find(mob); if (pl != null) { pl.Detach(); mob.SendMessage("You have been kicked from heroes/evil."); AddResponse("They have been kicked from heroes/evil."); } else { LogFailure("They are not in heroes/evils."); } break; } case EthicKickType.Ban: { Account acct = mob.Account as Account; if (acct != null) { if (acct.GetTag("EthicsBanned") == null) { acct.SetTag("EthicsBanned", "true"); AddResponse("The account has been banned from joining heroes/evil."); } else { AddResponse("The account is already banned from joining heroes/evil."); } for (int i = 0; i < acct.Length; ++i) { mob = acct[i]; if (mob != null) { Player pl = Player.Find(mob); if (pl != null) { pl.Detach(); mob.SendMessage("You have been kicked from heroes/evil."); AddResponse("They have been kicked from heroes/evil."); } } } } else { LogFailure("They have no assigned account."); } break; } case EthicKickType.Unban: { Account acct = mob.Account as Account; if (acct != null) { if (acct.GetTag("EthicsBanned") == null) { AddResponse("The account is not banned from joining heroes/evil."); } else { acct.RemoveTag("EthicsBanned"); AddResponse("The account may now freely join heroes/evil."); } } else { LogFailure("They have no assigned account."); } 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; } var eable = e.Mobile.GetItemsInRange(2); var found = false; foreach (var item in eable) { if (item is AnkhNorth or AnkhWest) { found = true; break; } } eable.Free(); if (!found) { 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 static void HandleDeath(Mobile victim, Mobile killer) { if (killer != null && victim != null && killer != victim && !(killer is BaseCreature)) { if (victim is BaseCreature) { BaseCreature bc = (BaseCreature)victim; Region homeregion = Region.Find(bc.Home, victim.Map); if ((homeregion == null || !homeregion.IsPartOf(typeof(ChampionSpawnRegion))) && (killer.Region == null || !killer.Region.IsPartOf(typeof(ChampionSpawnRegion)))) { if (!(victim is BaseVendor) && bc.GetEthicAllegiance(killer) == BaseCreature.Allegiance.Enemy) { Player killerEPL = Player.Find(killer); if (killerEPL != null && killerEPL.Power < Player.MaxPower) { ++killerEPL.Power; ++killerEPL.History; killer.SendMessage("You gain a little life force for slaying a minion of {0}.", killerEPL.Ethic == Ethic.Evil ? "good" : "evil"); } } } } else if (victim.Guild == null || killer.Guild == null || killer.Guild != victim.Guild) //not guild mates { Ethics.Player killerEPL = Player.Find(killer); Ethics.Player victimEPL = Player.Find(victim); PlayerState killerState = PlayerState.Find(killer); PlayerState victimState = PlayerState.Find(victim); bool applyskillloss = false; if (killerState != null && victimState != null && killerState.Faction == victimState.Faction) //Faction mate penalty { applyskillloss = true; } else if (killerEPL != null) //Killer is in ethics { if (victimEPL != null) //Victim is in ethics { if (killerEPL.Ethic != victimEPL.Ethic) { if ((killerEPL.Ethic == Ethic.Evil || (!killer.Criminal && killer.Kills < 5)) && victimEPL.Power > 0) { int powerTransfer = Math.Max(1, victimEPL.Power / 5); if (powerTransfer > (Player.MaxPower - killerEPL.Power)) { powerTransfer = Player.MaxPower - killerEPL.Power; } if (powerTransfer > 0) { victimEPL.Power -= powerTransfer; killerEPL.Power += powerTransfer; killerEPL.History += powerTransfer; killer.FixedEffect(0x373A, 10, 30); killer.PlaySound(0x209); string message = "a little"; if (powerTransfer > 20) { message = "a lot"; } else if (powerTransfer > 10) { message = "a good amount"; } else if (powerTransfer > 5) { message = "some"; } killer.SendMessage("You have gained {0} life force for killing {1}.", powerTransfer, victim.Name); victim.SendMessage("You have lost {1} life force for falling victim to {1}.", powerTransfer, killer.Name); } } } else if (victimEPL.Ethic == Ethic.Hero) //Both are Heros - PENALTY! { applyskillloss = true; } } else if (killerEPL.Ethic.IsAggressed(victim)) { killerEPL.Ethic.RemoveAggressor(victim); } else if ((victimState == null || killerState == null) && victim.Kills < 5) //Innocent - PENALTY! { ApplySkillLoss(killer); killerEPL.Power -= Math.Min(killerEPL.Power, 20); killer.PlaySound(0x133); killer.FixedParticles(0x377A, 244, 25, 9950, 31, 0, EffectLayer.Waist); } } else if (victimEPL != null && !(killer is BaseCreature)) //Killer is NOT in ethics, but victim is. { if (victimEPL.Ethic == Ethic.Evil) { if (killer.Kills < 5 && !killer.Criminal) { killer.FixedEffect(0x373A, 10, 30); killer.PlaySound(0x209); killer.SendMessage("You have slayed an evil soul and embraced the path of heros."); } } else if (victimEPL.Ethic == Ethic.Hero) { killer.FixedEffect(0x373A, 10, 30); killer.PlaySound(0x209); killer.SendMessage("You have slayed a heroic soul and embraced the path of the evil."); } } if (applyskillloss) { ApplySkillLoss(killer); killerEPL.Power /= 3; killer.PlaySound(0x133); killer.FixedParticles(0x377A, 244, 25, 9950, 31, 0, EffectLayer.Waist); } if (killer.Kills >= Mobile.MurderCount && killerEPL != null && killerEPL.Ethic == Ethic.Hero) { killer.SendMessage("You have been stripped of your hero status due to your dastardly actions."); Ethics.Player killerPLYR = Player.Find(killer, false); if (killerPLYR != null) { killerPLYR.Detach(); } } } } }