private void Sigil_OnTarget(Mobile from, object obj) { if (Deleted || !IsChildOf(from.Backpack)) { return; } #region Give To Mobile if (obj is Mobile) { if (obj is PlayerMobile) { PlayerMobile targ = (PlayerMobile)obj; Faction toFaction = Faction.Find(targ); Faction fromFaction = Faction.Find(from); if (toFaction == null) { from.SendLocalizedMessage(1005223); // You cannot give the sigil to someone not in a faction } else if (fromFaction != toFaction) { from.SendLocalizedMessage(1005222); // You cannot give the sigil to someone not in your faction } else if (Sigil.ExistsOn(targ)) { from.SendLocalizedMessage(1005220); // You cannot give this sigil to someone who already has a sigil } else if (!targ.Alive) { from.SendLocalizedMessage(1042248); // You cannot give a sigil to a dead person. } else if (from.NetState != null && targ.NetState != null) { Container pack = targ.Backpack; if (pack != null) { pack.DropItem(this); } } } else { from.SendLocalizedMessage(1005221); //You cannot give the sigil to them } } #endregion else if (obj is BaseMonolith) { #region Put in Stronghold if (obj is StrongholdMonolith) { StrongholdMonolith m = (StrongholdMonolith)obj; if (m.Faction == null || m.Faction != Faction.Find(from)) { from.SendLocalizedMessage(1042246); // You can't place that on an enemy monolith } else if (m.Town == null || m.Town != m_Town) { from.SendLocalizedMessage(1042247); // That is not the correct faction monolith } else { m.Sigil = this; Faction newController = m.Faction; Faction oldController = m_Corrupting; if (oldController == null) { if (m_Corrupted != newController) { BeginCorrupting(newController); } } else if (m_GraceStart > DateTime.MinValue && (m_GraceStart + CorruptionGrace) < DateTime.Now) { if (m_Corrupted != newController) { BeginCorrupting(newController); // grace time over, reset period } else { ClearCorrupting(); } m_GraceStart = DateTime.MinValue; } else if (newController == oldController) { m_GraceStart = DateTime.MinValue; // returned within grace period } else if (m_GraceStart == DateTime.MinValue) { m_GraceStart = DateTime.Now; } m_PurificationStart = DateTime.MinValue; } } #endregion #region Put in Town else if (obj is TownMonolith) { TownMonolith m = (TownMonolith)obj; if (m.Town == null || m.Town != m_Town) { from.SendLocalizedMessage(1042245); // This is not the correct town sigil monolith } else if (m_Corrupted == null || m_Corrupted != Faction.Find(from)) { from.SendLocalizedMessage(1042244); // Your faction did not corrupt this sigil. Take it to your stronghold. } else { m.Sigil = this; m_Corrupting = null; m_PurificationStart = DateTime.Now; m_CorruptionStart = DateTime.MinValue; m_Town.Capture(m_Corrupted); m_Corrupted = null; } } #endregion } else { from.SendLocalizedMessage(1005224); // You can't use the sigil on that } Update(); }
public static void HandleDeath(Mobile victim, Mobile killer) { if (killer == null) { killer = victim.FindMostRecentDamager(true); } PlayerState killerState = PlayerState.Find(killer); Container pack = victim.Backpack; if (pack != null) { Container killerPack = (killer == null ? null : killer.Backpack); Item[] sigils = pack.FindItemsByType(typeof(Sigil)); for (int i = 0; i < sigils.Length; ++i) { Sigil sigil = (Sigil)sigils[i]; if (killerState != null && killerPack != null) { if (Sigil.ExistsOn(killer)) { sigil.ReturnHome(); killer.SendLocalizedMessage(1010258); // The sigil has gone back to its home location because you already have a sigil. } else if (!killerPack.TryDropItem(killer, sigil, false)) { sigil.ReturnHome(); killer.SendLocalizedMessage(1010259); // The sigil has gone home because your backpack is full. } } else { sigil.ReturnHome(); } } } if (killerState == null) { return; } if (victim is BaseCreature) { BaseCreature bc = (BaseCreature)victim; Faction victimFaction = bc.FactionAllegiance; if (bc.Map == Faction.Facet && victimFaction != null && killerState.Faction != victimFaction) { int silver = killerState.Faction.AwardSilver(killer, bc.FactionSilverWorth); if (silver > 0) { killer.SendLocalizedMessage(1042748, silver.ToString("N0")); // Thou hast earned ~1_AMOUNT~ silver for vanquishing the vile creature. } } #region Ethics if (bc.Map == Faction.Facet && bc.GetEthicAllegiance(killer) == BaseCreature.Allegiance.Enemy) { Ethics.Player killerEPL = Ethics.Player.Find(killer); if (killerEPL != null && (100 - killerEPL.Power) > Utility.Random(100)) { ++killerEPL.Power; ++killerEPL.History; } } #endregion return; } PlayerState victimState = PlayerState.Find(victim); if (victimState == null) { return; } if (killer == victim || killerState.Faction != victimState.Faction) { ApplySkillLoss(victim); } if (killerState.Faction != victimState.Faction) { if (victimState.KillPoints <= -6) { killer.SendLocalizedMessage(501693); // This victim is not worth enough to get kill points from. #region Ethics Ethics.Player killerEPL = Ethics.Player.Find(killer); Ethics.Player victimEPL = Ethics.Player.Find(victim); if (killerEPL != null && victimEPL != null && victimEPL.Power > 0 && victimState.CanGiveSilverTo(killer)) { int powerTransfer = Math.Max(1, victimEPL.Power / 5); if (powerTransfer > (100 - killerEPL.Power)) { powerTransfer = 100 - killerEPL.Power; } if (powerTransfer > 0) { victimEPL.Power -= (powerTransfer + 1) / 2; killerEPL.Power += powerTransfer; killerEPL.History += powerTransfer; victimState.OnGivenSilverTo(killer); } } #endregion } else { int award = Math.Max(victimState.KillPoints / 10, 1); if (award > 40) { award = 40; } if (victimState.CanGiveSilverTo(killer)) { if (victimState.KillPoints > 0) { int silver = 0; silver = killerState.Faction.AwardSilver(killer, award * 40); if (silver > 0) { killer.SendLocalizedMessage(1042736, String.Format("{0:N0} silver\t{1}", silver, victim.Name)); // You have earned ~1_SILVER_AMOUNT~ pieces for vanquishing ~2_PLAYER_NAME~! } } victimState.KillPoints -= award; killerState.KillPoints += award; int offset = (award != 1 ? 0 : 2); // for pluralization string args = String.Format("{0}\t{1}\t{2}", award, victim.Name, killer.Name); killer.SendLocalizedMessage(1042737 + offset, args); // Thou hast been honored with ~1_KILL_POINTS~ kill point(s) for vanquishing ~2_DEAD_PLAYER~! victim.SendLocalizedMessage(1042738 + offset, args); // Thou has lost ~1_KILL_POINTS~ kill point(s) to ~3_ATTACKER_NAME~ for being vanquished! #region Ethics Ethics.Player killerEPL = Ethics.Player.Find(killer); Ethics.Player victimEPL = Ethics.Player.Find(victim); if (killerEPL != null && victimEPL != null && victimEPL.Power > 0) { int powerTransfer = Math.Max(1, victimEPL.Power / 5); if (powerTransfer > (100 - killerEPL.Power)) { powerTransfer = 100 - killerEPL.Power; } if (powerTransfer > 0) { victimEPL.Power -= (powerTransfer + 1) / 2; killerEPL.Power += powerTransfer; killerEPL.History += powerTransfer; } } #endregion victimState.OnGivenSilverTo(killer); } else { killer.SendLocalizedMessage(1042231); // You have recently defeated this enemy and thus their death brings you no honor. } } } }