Exemple #1
0
        public static void ProcessTick()
        {
            SigilCollection sigils = Sigil.Sigils;

            for (int i = 0; i < sigils.Count; ++i)
            {
                Sigil sigil = sigils[i];

                if (!sigil.IsBeingCorrupted && sigil.GraceStart != DateTime.MinValue && (sigil.GraceStart + Sigil.CorruptionGrace) < DateTime.Now)
                {
                    if (sigil.LastMonolith is StrongholdMonolith && (sigil.Corrupted == null || sigil.LastMonolith.Faction != sigil.Corrupted))
                    {
                        sigil.Corrupting      = sigil.LastMonolith.Faction;
                        sigil.CorruptionStart = DateTime.Now;
                    }
                    else
                    {
                        sigil.Corrupting      = null;
                        sigil.CorruptionStart = DateTime.MinValue;
                    }

                    sigil.GraceStart = DateTime.MinValue;
                }

                if (sigil.LastMonolith == null || sigil.LastMonolith.Sigil == null)
                {
                    if ((sigil.LastStolen + Sigil.ReturnPeriod) < DateTime.Now)
                    {
                        sigil.ReturnHome();
                    }
                }
                else
                {
                    if (sigil.IsBeingCorrupted && (sigil.CorruptionStart + Sigil.CorruptionPeriod) < DateTime.Now)
                    {
                        sigil.Corrupted       = sigil.Corrupting;
                        sigil.Corrupting      = null;
                        sigil.CorruptionStart = DateTime.MinValue;
                        sigil.GraceStart      = DateTime.MinValue;
                    }
                    else if (sigil.IsPurifying && (sigil.PurificationStart + Sigil.PurificationPeriod) < DateTime.Now)
                    {
                        sigil.PurificationStart = DateTime.MinValue;
                        sigil.Corrupted         = null;
                        sigil.Corrupting        = null;
                        sigil.CorruptionStart   = DateTime.MinValue;
                        sigil.GraceStart        = DateTime.MinValue;
                    }
                }
            }
        }
Exemple #2
0
        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.SendAsciiMessage("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.SendAsciiMessage("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.SendAsciiMessage("Thou hast earned " + silver.ToString("N0") + " silver for vanquishing the vile creature.");
                    }
                }

                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.SendAsciiMessage("This victim is not worth enough to get kill points from. ");
                }
                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.SendAsciiMessage("You have earned " + silver.ToString() + " pieces for vanquishing " + victim.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);

                        if (award > 1)
                        {
                            killer.SendAsciiMessage("Thou hast been honored with " + award.ToString() + " kill points for vanquishing " + victim.Name + "!");
                            victim.SendAsciiMessage("Thou has lost " + award.ToString() + " kill points to " + killer.Name + " for being vanquished!");
                        }
                        else
                        {
                            killer.SendAsciiMessage("Thou hast been honored with a kill point for vanquishing " + victim.Name + "!");
                            victim.SendAsciiMessage("Thou has lost a kill point(s) to " + killer.Name + " for being vanquished!");
                        }

                        victimState.OnGivenSilverTo(killer);
                    }
                    else
                    {
                        killer.SendAsciiMessage("You have recently defeated this enemy and thus their death brings you no honor.");
                    }
                }
            }
        }
Exemple #3
0
        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.
                    }
                }
            }
        }
Exemple #4
0
        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.
                    }
                }

                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.
                }
                else
                {
                    bool sameAccount = false;

                    Account killerAccount = killer.Account as Account;
                    Account victimAccount = victim.Account as Account;

                    ArrayList killerList;
                    ArrayList victimList;

                    killerList = new ArrayList(killerAccount.LoginIPs);
                    victimList = new ArrayList(victimAccount.LoginIPs);

                    for (int i = 0; i < killerList.Count; i++)
                    {
                        for (int j = 0; j < victimList.Count; j++)
                        {
                            if (Convert.ToString(victimList[j] as IPAddress) == Convert.ToString(killerList[i] as IPAddress))
                            {
                                //Console.WriteLine("{0} == {1}", (victimList[j] as IPAddress), (killerList[i] as IPAddress));
                                sameAccount = true;
                                break;
                            }
                            //Console.WriteLine("{0} == {1}", (victimList[j] as IPAddress), (killerList[i] as IPAddress));
                        }
                        if (sameAccount)
                        {
                            break;
                        }
                    }

                    //Console.WriteLine("sameAccount = {0}", sameAccount);
                    int award = 0;

                    if (!sameAccount)
                    {
                        award = Math.Max(victimState.KillPoints / 10, 1);

                        if (award > 40)
                        {
                            award = 40;
                        }
                    }
                    else
                    {
                        killer.SendMessage("You will not be rewarded killpoints for killing players on shared accounts!  It was a nice try though.");
                    }


                    if (victimState.CanGiveSilverTo(killer) && !sameAccount)
                    {
                        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!

                        victimState.OnGivenSilverTo(killer);
                    }
                    else
                    {
                        if (sameAccount)
                        {
                            killer.SendMessage("You will not be rewarded silver for killing players on shared accounts!  It was a nice try though.");
                        }
                        else
                        {
                            killer.SendLocalizedMessage(1042231);                               // You have recently defeated this enemy and thus their death brings you no honor.
                        }
                    }
                }
            }
        }