コード例 #1
0
        public static UOACZDestination GetRandomEntrance(bool isHuman)
        {
            UOACZDestination entranceDestination = null;

            List <UOACZDestination> m_Destinations = new List <UOACZDestination>();

            foreach (UOACZDestination destination in UOACZDestination.m_UOACZDestinations)
            {
                if (destination == null)
                {
                    continue;
                }
                if (destination.Deleted)
                {
                    continue;
                }
                if (!UOACZRegion.ContainsItem(destination))
                {
                    continue;
                }

                if (isHuman && destination.m_ProfileTypeAllowed == ProfileType.Human && destination.GateDirection == UOACZDestination.DirectionType.Entrance)
                {
                    m_Destinations.Add(destination);
                }

                if (!isHuman && destination.m_ProfileTypeAllowed == ProfileType.Undead && destination.GateDirection == UOACZDestination.DirectionType.Entrance)
                {
                    m_Destinations.Add(destination);
                }
            }

            if (m_Destinations.Count == 0)
            {
                return(entranceDestination);
            }

            entranceDestination = m_Destinations[Utility.RandomMinMax(0, m_Destinations.Count - 1)];

            return(entranceDestination);
        }
コード例 #2
0
        public static UOACZDestination GetRandomExit(bool murderer)
        {
            UOACZDestination destination = null;

            List <UOACZDestination> m_Destinations = new List <UOACZDestination>();

            foreach (UOACZDestination Destination in UOACZDestination.m_UOACZDestinations)
            {
                if (Destination == null)
                {
                    continue;
                }
                if (Destination.Deleted)
                {
                    continue;
                }
                if (Destination.GateDirection == UOACZDestination.DirectionType.Exit)
                {
                    if (Destination.MurdererFriendly && murderer)
                    {
                        m_Destinations.Add(Destination);
                    }

                    if (!Destination.MurdererFriendly && !murderer)
                    {
                        m_Destinations.Add(Destination);
                    }
                }
            }

            if (m_Destinations.Count == 0)
            {
                return(destination);
            }

            destination = m_Destinations[Utility.RandomMinMax(0, m_Destinations.Count - 1)];

            return(destination);
        }
コード例 #3
0
ファイル: UOACZRegion.cs プロジェクト: Pumpk1ns/outlands
        public override void OnDeath(Mobile mobile)
        {
            base.OnDeath(mobile);

            PlayerMobile player = mobile as PlayerMobile;

            if (player == null)
            {
                return;
            }
            if (player.AccessLevel > AccessLevel.Player)
            {
                return;
            }

            if (!UOACZPersistance.Active)
            {
                return;
            }

            UOACZPersistance.CheckAndCreateUOACZAccountEntry(player);

            player.Frozen = true;

            Queue m_Queue = new Queue();

            foreach (BaseCreature creature in player.AllFollowers)
            {
                if (UOACZRegion.ContainsMobile(creature))
                {
                    m_Queue.Enqueue(creature);
                }
            }

            while (m_Queue.Count > 0)
            {
                BaseCreature creature = (BaseCreature)m_Queue.Dequeue();

                int damage = (int)(Math.Round((double)creature.HitsMax * UOACZSystem.SwarmControllerDeathDamageScalar));

                new Blood().MoveToWorld(creature.Location, creature.Map);
                AOS.Damage(creature, damage, 0, 100, 0, 0, 0);

                if (UOACZSystem.IsUOACZValidMobile(creature))
                {
                    if (creature.AIObject != null && creature.Controlled)
                    {
                        creature.AIObject.DoOrderRelease();

                        if (creature is UOACZBaseUndead)
                        {
                            UOACZBaseUndead undeadCreature = creature as UOACZBaseUndead;

                            undeadCreature.m_LastActivity        = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(3));
                            undeadCreature.m_NeedWaypoint        = true;
                            undeadCreature.CanTeleportToBaseNode = true;
                            undeadCreature.InWilderness          = true;
                        }
                    }
                }
            }

            Timer.DelayCall(TimeSpan.FromSeconds(.5), delegate
            {
                if (player == null)
                {
                    return;
                }
                if (player.Deleted)
                {
                    return;
                }
                if (!UOACZRegion.ContainsMobile(player))
                {
                    return;
                }
                if (!UOACZPersistance.Active)
                {
                    return;
                }

                UOACZPersistance.CheckAndCreateUOACZAccountEntry(player);

                player.m_UOACZAccountEntry.UndeadProfile.Deaths++;
            });

            Timer.DelayCall(TimeSpan.FromSeconds(2), delegate
            {
                if (player == null)
                {
                    return;
                }
                if (player.Deleted)
                {
                    return;
                }
                if (!UOACZRegion.ContainsMobile(player))
                {
                    return;
                }
                if (!UOACZPersistance.Active)
                {
                    return;
                }

                UOACZPersistance.CheckAndCreateUOACZAccountEntry(player);
                UOACZDestination destination;

                bool lostFoodWater = false;
                bool lostBrains    = false;

                player.m_UOACZAccountEntry.FatigueExpiration = DateTime.UtcNow + UOACZSystem.FatigueDuration;

                switch (player.m_UOACZAccountEntry.ActiveProfile)
                {
                case UOACZAccountEntry.ActiveProfileType.Human:
                    if (player.m_UOACZAccountEntry.HumanProfile.HonorPoints <= UOACZSystem.HonorAggressionThreshold)
                    {
                        destination = UOACZDestination.GetRandomEntrance(false);

                        if (destination != null)
                        {
                            player.MoveToWorld(destination.Location, destination.Map);
                        }

                        else
                        {
                            player.MoveToWorld(UOACZPersistance.DefaultUndeadLocation, UOACZPersistance.DefaultMap);
                        }
                    }

                    else
                    {
                        destination = UOACZDestination.GetRandomEntrance(true);

                        if (destination != null)
                        {
                            player.MoveToWorld(destination.Location, destination.Map);
                        }

                        else
                        {
                            player.MoveToWorld(UOACZPersistance.DefaultHumanLocation, UOACZPersistance.DefaultMap);
                        }
                    }

                    player.Resurrect();
                    player.RevealingAction();
                    player.Frozen = false;

                    #region Auto-Reequip Blessed Gear

                    if (player.Backpack != null)
                    {
                        if (!player.Backpack.Deleted)
                        {
                            Item deathRobe = player.FindItemOnLayer(Layer.OuterTorso);

                            if (!(deathRobe is DeathRobe))
                            {
                                deathRobe = null;
                            }

                            UOACZSurvivalMachete survivalMachete = null;
                            UOACZSurvivalLantern survivalLantern = null;

                            List <Item> m_LayerShirt  = new List <Item>();
                            List <Item> m_MiddleTorso = new List <Item>();
                            List <Item> m_OuterLegs   = new List <Item>();
                            List <Item> m_Pants       = new List <Item>();
                            List <Item> m_Shoes       = new List <Item>();

                            List <Item> m_BackpackItems = player.Backpack.Items;

                            bool foundPants = false;

                            foreach (Item item in m_BackpackItems)
                            {
                                if (item is UOACZSurvivalMachete)
                                {
                                    survivalMachete = item as UOACZSurvivalMachete;
                                }

                                //if (item is UOACZSurvivalLantern)
                                //survivalLantern = item as UOACZSurvivalLantern;

                                if (item.Layer == Layer.Shirt)
                                {
                                    m_LayerShirt.Add(item);
                                }

                                if (item.Layer == Layer.MiddleTorso)
                                {
                                    m_MiddleTorso.Add(item);
                                }

                                if (item.Layer == Layer.OuterLegs)
                                {
                                    m_OuterLegs.Add(item);
                                    foundPants = true;
                                }

                                if (item.Layer == Layer.Pants)
                                {
                                    m_Pants.Add(item);
                                    foundPants = true;
                                }

                                if (item.Layer == Layer.Shoes)
                                {
                                    m_Shoes.Add(item);
                                }
                            }

                            if (survivalMachete != null)
                            {
                                player.AddItem(survivalMachete);
                            }

                            //if (survivalLantern != null)
                            //player.AddItem(survivalLantern);

                            if (foundPants && deathRobe != null)
                            {
                                deathRobe.Delete();
                            }

                            if (m_LayerShirt.Count > 0)
                            {
                                player.AddItem(m_LayerShirt[0]);
                            }

                            if (m_MiddleTorso.Count > 0)
                            {
                                player.AddItem(m_MiddleTorso[0]);
                            }

                            if (m_OuterLegs.Count > 0)
                            {
                                player.AddItem(m_OuterLegs[0]);
                            }

                            if (m_Pants.Count > 0)
                            {
                                player.AddItem(m_Pants[0]);
                            }

                            if (m_Shoes.Count > 0)
                            {
                                player.AddItem(m_Shoes[0]);
                            }
                        }
                    }

                    #endregion

                    UOACZSystem.ApplyActiveProfile(player);

                    player.Hits = (int)Math.Ceiling(UOACZSystem.HumanRessStatsPercent * (double)player.HitsMax);
                    player.Stam = (int)Math.Ceiling(UOACZSystem.HumanRessStatsPercent * (double)player.StamMax);
                    player.Mana = (int)Math.Ceiling(UOACZSystem.HumanRessStatsPercent * (double)player.ManaMax);

                    if (player.Backpack != null)
                    {
                        Item[] consumptionItem = player.Backpack.FindItemsByType(typeof(UOACZConsumptionItem));

                        m_Queue = new Queue();

                        for (int a = 0; a < consumptionItem.Length; a++)
                        {
                            UOACZConsumptionItem foodItem = consumptionItem[a] as UOACZConsumptionItem;

                            if (foodItem == null)
                            {
                                continue;
                            }

                            if (Utility.RandomDouble() <= UOACZSystem.HumanDeathFoodWaterLossChance)
                            {
                                lostFoodWater = true;

                                if (foodItem.Charges > 1)
                                {
                                    foodItem.Charges = (int)Math.Floor((double)foodItem.Charges / 2);
                                }

                                else
                                {
                                    m_Queue.Enqueue(foodItem);
                                }
                            }
                        }

                        while (m_Queue.Count > 0)
                        {
                            Item item = (Item)m_Queue.Dequeue();
                            item.Delete();
                        }
                    }

                    Timer.DelayCall(TimeSpan.FromSeconds(.5), delegate
                    {
                        if (!UOACZSystem.IsUOACZValidMobile(player))
                        {
                            return;
                        }

                        player.m_UOACZAccountEntry.HumanProfile.CauseOfDeath = UOACZAccountEntry.HumanProfileEntry.CauseOfDeathType.Misc;
                        player.m_UOACZAccountEntry.HumanDeaths++;

                        if (player.IsUOACZHuman)
                        {
                            if (player.m_UOACZAccountEntry.HumanAbilitiesHotbarDisplayed)
                            {
                                player.CloseGump(typeof(HumanProfileAbilitiesHotbarGump));
                                player.SendGump(new HumanProfileAbilitiesHotbarGump(player));
                            }

                            if (player.m_UOACZAccountEntry.HumanStatsHotbarDisplayed)
                            {
                                player.CloseGump(typeof(HumanProfileStatsHotbarGump));
                                player.SendGump(new HumanProfileStatsHotbarGump(player));
                            }

                            if (player.m_UOACZAccountEntry.ObjectivesDisplayed)
                            {
                                player.CloseGump(typeof(ObjectivesHotbarGump));
                                player.SendGump(new ObjectivesHotbarGump(player));
                            }
                        }
                    });
                    break;

                case UOACZAccountEntry.ActiveProfileType.Undead:
                    destination = UOACZDestination.GetRandomEntrance(false);

                    player.m_UOACZAccountEntry.UndeadDeaths++;

                    if (destination != null)
                    {
                        player.MoveToWorld(destination.Location, destination.Map);
                    }

                    else
                    {
                        player.MoveToWorld(UOACZPersistance.DefaultUndeadLocation, UOACZPersistance.DefaultMap);
                    }

                    player.Resurrect();
                    player.RevealingAction();
                    player.Frozen = false;

                    if (player.Backpack != null)
                    {
                        Item[] brainItems = player.Backpack.FindItemsByType(typeof(UOACZBrains));

                        m_Queue = new Queue();

                        for (int a = 0; a < brainItems.Length; a++)
                        {
                            UOACZBrains brainItem = brainItems[a] as UOACZBrains;

                            if (brainItem == null)
                            {
                                continue;
                            }

                            if (Utility.RandomDouble() <= UOACZSystem.UndeadDeathBrainLossChance)
                            {
                                lostBrains = true;

                                m_Queue.Enqueue(brainItem);
                            }
                        }

                        while (m_Queue.Count > 0)
                        {
                            Item item = (Item)m_Queue.Dequeue();
                            item.Delete();
                        }
                    }

                    UOACZSystem.ApplyActiveProfile(player);

                    player.Hits = (int)Math.Ceiling(UOACZSystem.UndeadRessStatsPercent * (double)player.HitsMax);
                    player.Stam = (int)Math.Ceiling(UOACZSystem.UndeadRessStatsPercent * (double)player.StamMax);
                    player.Mana = (int)Math.Ceiling(UOACZSystem.UndeadRessStatsPercent * (double)player.ManaMax);

                    if (player.m_UOACZAccountEntry.UndeadAbilitiesHotbarDisplayed)
                    {
                        player.CloseGump(typeof(UndeadProfileAbilitiesHotbarGump));
                        player.SendGump(new UndeadProfileAbilitiesHotbarGump(player));
                    }

                    if (player.m_UOACZAccountEntry.UndeadStatsHotbarDisplayed)
                    {
                        player.CloseGump(typeof(UndeadProfileStatsHotbarGump));
                        player.SendGump(new UndeadProfileStatsHotbarGump(player));
                    }

                    if (player.m_UOACZAccountEntry.ObjectivesDisplayed)
                    {
                        player.CloseGump(typeof(ObjectivesHotbarGump));
                        player.SendGump(new ObjectivesHotbarGump(player));
                    }
                    break;
                }

                string fatigueDuration    = Utility.CreateTimeRemainingString(DateTime.UtcNow, DateTime.UtcNow + UOACZSystem.FatigueDuration, false, true, true, true, true);
                string fatiguePercentText = ((1.0 - UOACZSystem.FatigueActiveScalar) * 100).ToString() + "%";

                player.SendMessage(UOACZSystem.orangeTextHue, "You have died and will be subject to a -" + fatiguePercentText + " PvP penalty for " + fatigueDuration + ".");

                Timer.DelayCall(TimeSpan.FromSeconds(2), delegate
                {
                    if (player == null)
                    {
                        return;
                    }

                    if (player.IsUOACZHuman && lostFoodWater)
                    {
                        player.SendMessage(UOACZSystem.orangeTextHue, "As a result of your death, some of your food and water has been been lost.");
                    }

                    if (player.IsUOACZUndead && lostBrains)
                    {
                        player.SendMessage(UOACZSystem.orangeTextHue, "As a result of your death, some of your brains have been been lost.");
                    }
                });
            });
        }
コード例 #4
0
ファイル: UOACZMoongate.cs プロジェクト: Pumpk1ns/outlands
        public override void OnDoubleClick(Mobile from)
        {
            base.OnDoubleClick(from);

            if (!Visible)
            {
                if (from.AccessLevel == AccessLevel.Player)
                {
                    return;
                }
            }

            PlayerMobile player = from as PlayerMobile;

            if (player == null)
            {
                return;
            }

            UOACZPersistance.CheckAndCreateUOACZAccountEntry(player);

            if (!player.Alive)
            {
                player.SendMessage("You are dead and cannot do that.");
                return;
            }

            //UOACZ Restrictions
            if (player.AccessLevel == AccessLevel.Player)
            {
                if (Utility.GetDistance(from.Location, Location) >= 3)
                {
                    return;
                }

                switch (m_GateDirection)
                {
                case GateDirectionType.Entrance:
                    if (player.Criminal)
                    {
                        player.SendMessage("You are currently a criminal and cannot enter.");
                        return;
                    }

                    if (player.Followers > 0)
                    {
                        player.SendMessage("You must stable your followers before entering.");
                        return;
                    }

                    if (player.HasTrade)
                    {
                        player.SendMessage("You must cancel your pending trade before entering.");
                        return;
                    }

                    if (!from.CanBeginAction(typeof(IncognitoSpell)))
                    {
                        from.SendMessage("You may not enter while under the effects of incognito.");
                        return;
                    }

                    if (!from.CanBeginAction(typeof(PolymorphSpell)))
                    {
                        from.SendMessage("You may not enter while under the effects of polymorph.");
                        return;
                    }

                    if (DisguiseTimers.IsDisguised(from))
                    {
                        from.SendMessage("You may not enter while being disguised.");
                    }

                    if (DateTime.UtcNow < player.LastCombatTime + UOACZSystem.CombatDelayBeforeEnteringMoongate)
                    {
                        DateTime cooldown = player.LastCombatTime + UOACZSystem.CombatDelayBeforeEnteringMoongate;

                        string nextActivationAllowed = Utility.CreateTimeRemainingString(DateTime.UtcNow, cooldown, false, false, false, true, true);

                        player.SendMessage("You have been in combat recently and must wait another " + nextActivationAllowed + " before entering.");
                        return;
                    }

                    if (player.m_UOACZAccountEntry.NextEntryAllowed > DateTime.UtcNow && player.AccessLevel == AccessLevel.Player)
                    {
                        string nextEntranceAllowed = Utility.CreateTimeRemainingString(DateTime.UtcNow, player.m_UOACZAccountEntry.NextEntryAllowed, false, false, false, true, true);
                        from.SendMessage("You may not use this for another " + nextEntranceAllowed + ".");

                        return;
                    }
                    break;

                case GateDirectionType.Exit:
                    if (player.HasTrade)
                    {
                        player.SendMessage("You must cancel your pending trade before exiting.");
                        return;
                    }

                    if (DateTime.UtcNow < player.LastPlayerCombatTime + UOACZSystem.TunnelDigPvPThreshold)
                    {
                        DateTime cooldown = player.LastPlayerCombatTime + UOACZSystem.TunnelDigPvPThreshold;

                        string nextActivationAllowed = Utility.CreateTimeRemainingString(DateTime.UtcNow, cooldown, false, false, false, true, true);

                        player.SendMessage("You have been in PvP recently and must wait another " + nextActivationAllowed + " before exiting.");
                        return;
                    }

                    if (player.m_UOACZAccountEntry.NextEntryAllowed > DateTime.UtcNow && player.AccessLevel == AccessLevel.Player)
                    {
                        string nextEntranceAllowed = Utility.CreateTimeRemainingString(DateTime.UtcNow, player.m_UOACZAccountEntry.NextEntryAllowed, false, false, false, true, true);
                        from.SendMessage("You may not use this for another " + nextEntranceAllowed + ".");

                        return;
                    }
                    break;
                }
            }

            switch (m_GateDirection)
            {
            case GateDirectionType.Entrance:
                player.SendSound(0x103);

                if (player.AccessLevel > AccessLevel.Player)
                {
                    player.MoveToWorld(UOACZPersistance.DefaultHumanLocation, UOACZPersistance.DefaultMap);
                    return;
                }

                UOACZSystem.PlayerEnterUOACZRegion(player);
                break;

            case GateDirectionType.Exit:
                player.SendSound(0x0FC);

                if (player.AccessLevel > AccessLevel.Player)
                {
                    player.MoveToWorld(UOACZPersistance.DefaultBritainLocation, UOACZPersistance.DefaultBritainMap);
                    return;
                }

                UOACZDestination destination = UOACZDestination.GetRandomExit(player.Murderer);

                if (destination != null)
                {
                    player.MoveToWorld(destination.Location, destination.Map);
                }

                else
                {
                    player.MoveToWorld(UOACZPersistance.DefaultBritainLocation, UOACZPersistance.DefaultBritainMap);
                }
                break;
            }

            if (player.AccessLevel == AccessLevel.Player)
            {
                player.m_UOACZAccountEntry.NextEntryAllowed = DateTime.UtcNow + UOACZSystem.DelayBetweenMoongateActivation;
            }
        }