예제 #1
0
        public override void ResolveTrap(Mobile from)
        {
            PublicOverheadMessage(MessageType.Regular, UOACZSystem.yellowTextHue, false, ScavengeUndeadTrapText);

            int creatures = (int)(Math.Ceiling((double)TrapDifficulty / 50));

            for (int a = 0; a < creatures; a++)
            {
                Point3D spawnLocation = new Point3D(Location.X + Utility.RandomList(-1, 1), Location.Y + Utility.RandomList(-1, 1), Location.Z);
                SpellHelper.AdjustField(ref spawnLocation, Map, 12, false);

                int             threatLevel = UOACZPersistance.m_ThreatLevel - 30;
                UOACZBaseUndead bc_Creature = (UOACZBaseUndead)Activator.CreateInstance(UOACZBaseUndead.GetRandomUndeadType(0, threatLevel));

                if (bc_Creature != null)
                {
                    if (Map.CanSpawnMobile(spawnLocation))
                    {
                        bc_Creature.MoveToWorld(spawnLocation, Map);
                    }

                    else
                    {
                        if (UOACZSystem.IsUOACZValidMobile(from))
                        {
                            spawnLocation = new Point3D(from.Location.X + Utility.RandomList(-1, 1), from.Location.Y + Utility.RandomList(-1, 1), from.Location.Z);
                            SpellHelper.AdjustField(ref spawnLocation, Map, 12, false);

                            if (Map.CanSpawnMobile(spawnLocation))
                            {
                                bc_Creature.MoveToWorld(spawnLocation, Map);
                            }

                            else
                            {
                                bc_Creature.MoveToWorld(from.Location, Map);
                            }
                        }
                    }
                }
            }

            TrapType = ScavengeTrapType.None;
        }
예제 #2
0
        public virtual void Interact(Mobile from, InteractionType interactionType)
        {
            if (from == null)
            {
                return;
            }

            if (!from.CanBeginAction(typeof(BreakableStatic)))
            {
                from.SendMessage("You must wait a few moments before attempting to use that again.");
                return;
            }

            if (interactionType == InteractionType.None)
            {
                from.SendMessage("That cannot be interacted with in that way.");
                return;
            }

            PlayerMobile player      = from as PlayerMobile;
            BaseCreature bc_Creature = from as BaseCreature;

            from.RevealingAction();

            BeforeInteract(from, interactionType);

            TimeSpan usageDelay = GetInteractCooldown(from, interactionType);

            BaseWeapon weapon;

            from.BeginAction(typeof(BreakableStatic));

            Timer.DelayCall(usageDelay, delegate
            {
                if (from != null)
                {
                    from.EndAction(typeof(BreakableStatic));
                }
            });

            if (interactionType == InteractionType.Lumberjacking || interactionType == InteractionType.Mining || interactionType == InteractionType.Normal || interactionType == InteractionType.Weapon)
            {
                Timer.DelayCall(usageDelay + TimeSpan.FromSeconds(1), delegate
                {
                    if (player != null && !Deleted)
                    {
                        OnDoubleClick(player);
                    }
                });
            }

            int    damage       = 0;
            double randomScalar = (double)(Utility.RandomMinMax(75, 125)) / 100;

            Direction direction;

            switch (interactionType)
            {
            case InteractionType.None:
                return;

                break;

            case InteractionType.Normal:
                damage = (int)(Math.Round((double)(Utility.RandomMinMax(m_MinInteractDamage, m_MaxInteractDamage)) * InteractDamageScalar));

                direction = from.GetDirectionTo(Location);

                if (direction != from.Direction)
                {
                    from.Direction = direction;
                }

                Timer.DelayCall(TimeSpan.FromSeconds(.25), delegate
                {
                    if (from == null)
                    {
                        return;
                    }
                    if (!from.Alive)
                    {
                        return;
                    }

                    from.Animate(12, 5, 1, true, false, 0);
                    from.RevealingAction();

                    Timer.DelayCall(TimeSpan.FromSeconds(.5), delegate
                    {
                        if (from == null)
                        {
                            return;
                        }
                        if (!from.Alive)
                        {
                            return;
                        }

                        Effects.PlaySound(from.Location, from.Map, m_HitSound);
                    });
                });
                break;

            case InteractionType.Weapon:
                weapon = from.Weapon as BaseWeapon;

                if (weapon != null)
                {
                    int minDamage = weapon.MinDamage;
                    int maxDamage = weapon.MaxDamage;

                    if (bc_Creature != null)
                    {
                        minDamage = bc_Creature.DamageMin;
                        maxDamage = bc_Creature.DamageMax;
                    }

                    if ((weapon is Pickaxe || weapon is Hatchet))
                    {
                        minDamage = 10;
                        maxDamage = 20;
                    }

                    if (UOACZSystem.IsUOACZValidMobile(player))
                    {
                        if (player.IsUOACZUndead)
                        {
                            minDamage = player.m_UOACZAccountEntry.UndeadProfile.DamageMin;
                            maxDamage = player.m_UOACZAccountEntry.UndeadProfile.DamageMax;
                        }
                    }

                    if (minDamage < m_MinInteractDamage)
                    {
                        minDamage = m_MinInteractDamage;
                    }

                    if (maxDamage < m_MaxInteractDamage)
                    {
                        maxDamage = m_MaxInteractDamage;
                    }

                    damage = (int)(Math.Round((double)(Utility.RandomMinMax(minDamage, maxDamage)) * WeaponDamageScalar));
                }

                direction = from.GetDirectionTo(Location);

                if (direction != from.Direction)
                {
                    from.Direction = direction;
                }

                Timer.DelayCall(TimeSpan.FromSeconds(.25), delegate
                {
                    if (from == null)
                    {
                        return;
                    }
                    if (!from.Alive)
                    {
                        return;
                    }

                    if (bc_Creature != null)
                    {
                        UOACZBaseUndead undeadCreature = bc_Creature as UOACZBaseUndead;

                        if (undeadCreature != null)
                        {
                            undeadCreature.m_LastActivity = DateTime.UtcNow;
                        }

                        if (weapon != null)
                        {
                            weapon.PlaySwingAnimation(bc_Creature);
                        }
                    }

                    else
                    {
                        from.Animate(12, 5, 1, true, false, 0);
                    }

                    from.RevealingAction();

                    Timer.DelayCall(TimeSpan.FromSeconds(.5), delegate
                    {
                        if (from == null)
                        {
                            return;
                        }
                        if (!from.Alive)
                        {
                            return;
                        }

                        Effects.PlaySound(from.Location, from.Map, m_HitSound);
                    });
                });
                break;

            case InteractionType.Lockpick:
                damage = (int)(Math.Round(from.Skills.Lockpicking.Value * LockpickDamageScalar * randomScalar));

                if (damage < 20)
                {
                    damage = 20;
                }

                direction = from.GetDirectionTo(Location);

                if (direction != from.Direction)
                {
                    from.Direction = direction;
                }

                Timer.DelayCall(TimeSpan.FromSeconds(.25), delegate
                {
                    if (from == null)
                    {
                        return;
                    }
                    if (!from.Alive)
                    {
                        return;
                    }

                    from.Animate(32, 5, 1, true, false, 0);
                    from.RevealingAction();

                    Timer.DelayCall(TimeSpan.FromSeconds(.5), delegate
                    {
                        if (from == null)
                        {
                            return;
                        }
                        if (!from.Alive)
                        {
                            return;
                        }

                        Effects.PlaySound(from.Location, from.Map, 0x241);
                    });
                });
                break;

            case InteractionType.Mining:
                bool validMiningItem = false;

                Item equippedItem = from.FindItemOnLayer(Layer.FirstValid);

                if (equippedItem is Pickaxe || equippedItem is SturdyPickaxe || equippedItem is DiamondPickaxe)
                {
                    validMiningItem = true;
                }

                if (validMiningItem)
                {
                    damage = (int)(Math.Round(from.Skills.Mining.Value * MiningDamageScalar * randomScalar));

                    if (damage < 20)
                    {
                        damage = 20;
                    }
                }

                direction = from.GetDirectionTo(Location);

                if (direction != from.Direction)
                {
                    from.Direction = direction;
                }

                Timer.DelayCall(TimeSpan.FromSeconds(.25), delegate
                {
                    if (from == null)
                    {
                        return;
                    }
                    if (!from.Alive)
                    {
                        return;
                    }

                    from.Animate(Utility.RandomList(11, 12), 5, 1, true, false, 0);

                    from.RevealingAction();

                    Timer.DelayCall(TimeSpan.FromSeconds(.5), delegate
                    {
                        if (from == null)
                        {
                            return;
                        }
                        if (!from.Alive)
                        {
                            return;
                        }

                        Effects.PlaySound(from.Location, from.Map, m_HitSound);
                    });
                });
                break;

            case InteractionType.Lumberjacking:
                weapon = from.Weapon as BaseWeapon;

                if (weapon != null && (weapon is BaseAxe))
                {
                    damage = (int)(Math.Round(from.Skills.Lumberjacking.Value * LumberjackingDamageScalar * randomScalar));

                    if (damage < 20)
                    {
                        damage = 20;
                    }
                }

                direction = from.GetDirectionTo(Location);

                if (direction != from.Direction)
                {
                    from.Direction = direction;
                }

                Timer.DelayCall(TimeSpan.FromSeconds(.25), delegate
                {
                    if (from == null)
                    {
                        return;
                    }
                    if (!from.Alive)
                    {
                        return;
                    }

                    from.Animate(12, 5, 1, true, false, 0);
                    from.RevealingAction();

                    Timer.DelayCall(TimeSpan.FromSeconds(.5), delegate
                    {
                        if (from == null)
                        {
                            return;
                        }
                        if (!from.Alive)
                        {
                            return;
                        }

                        Effects.PlaySound(from.Location, from.Map, m_HitSound);
                    });
                });
                break;
            }

            if (damage < 1)
            {
                damage = 1;
            }

            ReceiveDamage(from, damage, interactionType);

            AfterInteract(from, interactionType);
        }
예제 #3
0
        public static int DetermineMobileNotoriety(Mobile source, Mobile target, bool useVengeance)
        {
            BaseCreature bc_Source = source as BaseCreature;
            PlayerMobile pm_Source = source as PlayerMobile;

            Mobile       m_SourceController  = null;
            BaseCreature bc_SourceController = null;
            PlayerMobile pm_SourceController = null;

            BaseCreature bc_Target = target as BaseCreature;
            PlayerMobile pm_Target = target as PlayerMobile;

            Mobile       m_TargetController  = null;
            BaseCreature bc_TargetController = null;
            PlayerMobile pm_TargetController = null;

            #region UOACZ

            if (UOACZRegion.ContainsMobile(target))
            {
                if (pm_Target != null)
                {
                    UOACZPersistance.CheckAndCreateUOACZAccountEntry(pm_Target);

                    if (pm_Target.IsUOACZUndead)
                    {
                        if (pm_Source != null)
                        {
                            if (pm_Source.IsUOACZHuman)
                            {
                                return(Notoriety.Enemy);
                            }

                            if (pm_Source.IsUOACZUndead)
                            {
                                if (pm_Target.Criminal)
                                {
                                    return(Notoriety.CanBeAttacked);
                                }

                                return(Notoriety.Innocent);
                            }
                        }

                        return(Notoriety.CanBeAttacked);
                    }

                    if (pm_Target.IsUOACZHuman)
                    {
                        if (pm_Source != null)
                        {
                            if (pm_Source.IsUOACZUndead)
                            {
                                return(Notoriety.Enemy);
                            }
                        }

                        if (pm_Target.m_UOACZAccountEntry.HumanProfile.HonorPoints <= UOACZSystem.HonorAggressionThreshold)
                        {
                            return(Notoriety.Enemy);
                        }

                        if (pm_Target.Criminal)
                        {
                            return(Notoriety.CanBeAttacked);
                        }

                        if (pm_Source != null)
                        {
                            return(Notoriety.Innocent);
                        }

                        return(Notoriety.CanBeAttacked);
                    }
                }

                if (bc_Target != null)
                {
                    if (bc_Target is UOACZBaseUndead)
                    {
                        UOACZBaseUndead bc_Undead = bc_Target as UOACZBaseUndead;

                        if (bc_Undead.ControlMaster == source)
                        {
                            return(Notoriety.Ally);
                        }

                        if (pm_Source != null && (bc_Undead == UOACZPersistance.UndeadChampion || bc_Undead == UOACZPersistance.UndeadBoss))
                        {
                            if (pm_Source.IsUOACZHuman)
                            {
                                return(Notoriety.Murderer);
                            }
                        }

                        return(Notoriety.CanBeAttacked);
                    }

                    if (bc_Target is UOACZBaseWildlife)
                    {
                        return(Notoriety.CanBeAttacked);
                    }

                    if (bc_Target is UOACZBaseHuman)
                    {
                        UOACZBaseHuman bc_Human = bc_Target as UOACZBaseHuman;

                        if (source is UOACZBaseWildlife || source is UOACZBaseUndead)
                        {
                            return(Notoriety.CanBeAttacked);
                        }

                        if (pm_Source != null)
                        {
                            if (pm_Source.IsUOACZUndead)
                            {
                                if (bc_Human == UOACZPersistance.HumanChampion || bc_Human == UOACZPersistance.HumanBoss)
                                {
                                    return(Notoriety.Murderer);
                                }

                                return(Notoriety.CanBeAttacked);
                            }
                        }

                        return(Notoriety.Innocent);
                    }
                }

                return(Notoriety.Innocent);
            }

            #endregion

            if (bc_Source != null)
            {
                m_SourceController  = bc_Source.ControlMaster as Mobile;
                bc_SourceController = bc_Source.ControlMaster as BaseCreature;
                pm_SourceController = bc_Source.ControlMaster as PlayerMobile;
            }

            if (bc_Target != null)
            {
                m_TargetController  = bc_Target.ControlMaster as Mobile;
                bc_TargetController = bc_Target.ControlMaster as BaseCreature;
                pm_TargetController = bc_Target.ControlMaster as PlayerMobile;
            }

            //Berserk Creatures
            if (bc_Source != null && (source is BladeSpirits || source is EnergyVortex))
            {
                if (bc_Source.ControlMaster != null && pm_Target != null)
                {
                    //Blade Spirits + Energy Vortexes Can Freely Attack Their Control Master Without Causing Criminal Action
                    if (bc_Source.ControlMaster == pm_Target)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }

                if (bc_Source.ControlMaster != null && bc_Target != null)
                {
                    //Blade Spirits + Energy Vortexes Can Freely Attack Other Followers Of Their Control Master Without Causing Criminal Action
                    if (bc_Source.ControlMaster == bc_Target.ControlMaster)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }
            }

            if (target is BladeSpirits || target is EnergyVortex)
            {
                return(Notoriety.Murderer);
            }

            //Staff Members Always Attackable
            if (target.AccessLevel > AccessLevel.Player)
            {
                return(Notoriety.CanBeAttacked);
            }

            if (m_TargetController != null)
            {
                //Creature Controlled By Staff Member
                if (m_TargetController.AccessLevel > AccessLevel.Player)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            //Consensual PvP
            if (pm_Source != null && pm_Target != null)
            {
                //Duel
                if (pm_Source.DuelContext != null && pm_Source.DuelContext.StartedBeginCountdown && !pm_Source.DuelContext.Finished && pm_Source.DuelContext == pm_Target.DuelContext)
                {
                    return(pm_Source.DuelContext.IsAlly(pm_Source, pm_Target) ? Notoriety.Ally : Notoriety.Enemy);
                }
            }

            //Enemy of One
            if (pm_Source != null && bc_Target != null)
            {
                if (!bc_Target.Summoned && !bc_Target.Controlled && pm_Source.EnemyOfOneType == target.GetType())
                {
                    return(Notoriety.Enemy);
                }
            }

            //Justice Free Zone
            if (SpellHelper.InBuccs(target.Map, target.Location) || SpellHelper.InYewOrcFort(target.Map, target.Location) || SpellHelper.InYewCrypts(target.Map, target.Location))
            {
                return(Notoriety.CanBeAttacked);
            }

            //Grey Zone Totem Nearby
            if (GreyZoneTotem.InGreyZoneTotemArea(target.Location, target.Map))
            {
                return(Notoriety.CanBeAttacked);
            }

            //Hotspot Nearby
            if (Custom.Hotspot.InHotspotArea(target.Location, target.Map, true))
            {
                return(Notoriety.CanBeAttacked);
            }

            //Player Notoriety
            if (pm_Target != null)
            {
                //Friendly
                if (pm_SourceController != null)
                {
                    if (pm_SourceController == pm_Target)
                    {
                        return(Notoriety.Ally);
                    }
                }

                //Murderer
                if (pm_Target.Murderer && !pm_Target.HideMurdererStatus)
                {
                    return(Notoriety.Murderer);
                }

                //Criminal
                if (pm_Target.Criminal)
                {
                    return(Notoriety.Criminal);
                }

                //Perma-Grey
                if (SkillHandlers.Stealing.ClassicMode && pm_Target.PermaFlags.Contains(source))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (pm_SourceController != null)
                {
                    //Target is Perma-Grey to Source Creature's Controller
                    if (SkillHandlers.Stealing.ClassicMode && pm_Target.PermaFlags.Contains(pm_SourceController))
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }
            }

            //Guilds
            //TEST: GUILD

            /*
             * Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
             * Guild targetGuild = GetGuildFor(target.Guild as Guild, target);
             *
             * if (sourceGuild != null && targetGuild != null)
             * {
             *  if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild))
             *      return Notoriety.Ally;
             *
             *  else if (sourceGuild.IsEnemy(targetGuild))
             *      return Notoriety.Enemy;
             * }
             */

            //Creature Notoriety
            if (bc_Target != null)
            {
                //Friendly
                if (m_TargetController != null)
                {
                    //Target is Source's Controller
                    if (source == m_TargetController)
                    {
                        return(Notoriety.Ally);
                    }
                }

                if (m_SourceController != null)
                {
                    //Source is Target's Controller
                    if (m_SourceController == bc_Target)
                    {
                        return(Notoriety.Ally);
                    }
                }

                //Murderer
                if (bc_Target.IsMurderer())
                {
                    return(Notoriety.Murderer);
                }

                if (pm_TargetController != null)
                {
                    if (pm_TargetController.Murderer)
                    {
                        return(Notoriety.Murderer);
                    }
                }

                if (bc_TargetController != null)
                {
                    if (bc_TargetController.IsMurderer())
                    {
                        return(Notoriety.Murderer);
                    }
                }

                //Criminal
                if (bc_Target.Criminal)
                {
                    return(Notoriety.Criminal);
                }

                if (pm_TargetController != null)
                {
                    if (pm_TargetController.Criminal)
                    {
                        return(Notoriety.Criminal);
                    }
                }

                if (bc_TargetController != null)
                {
                    if (bc_TargetController.Criminal)
                    {
                        return(Notoriety.Criminal);
                    }
                }

                //Perma-Grey
                if (pm_TargetController != null)
                {
                    if (SkillHandlers.Stealing.ClassicMode && pm_TargetController.PermaFlags.Contains(source))
                    {
                        return(Notoriety.CanBeAttacked);
                    }

                    if (pm_SourceController != null)
                    {
                        //Target is Perma-Grey to Source Creature's Controller
                        if (SkillHandlers.Stealing.ClassicMode && pm_TargetController.PermaFlags.Contains(pm_SourceController))
                        {
                            return(Notoriety.CanBeAttacked);
                        }
                    }
                }
            }

            //Housing
            if (CheckHouseFlag(source, target, target.Location, target.Map))
            {
                return(Notoriety.CanBeAttacked);
            }

            //Aggressor: Source to Target
            if (CheckAggressor(source.Aggressors, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckAggressed(source.Aggressed, target) && useVengeance)
            {
                return(Notoriety.CanBeAttacked);
            }

            //Aggressor: Source Controller to Target
            if (m_SourceController != null)
            {
                if (CheckAggressor(m_SourceController.Aggressors, target))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (CheckAggressed(m_SourceController.Aggressed, target) && useVengeance)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            //Aggressor: Source to Target's Controller
            if (m_TargetController != null)
            {
                if (CheckAggressor(source.Aggressors, m_TargetController))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (CheckAggressed(source.Aggressed, m_TargetController) && useVengeance)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            //Aggressor: Source Controller to Target's Controller
            if (m_SourceController != null && m_TargetController != null)
            {
                if (CheckAggressor(m_SourceController.Aggressors, m_TargetController))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (CheckAggressed(m_SourceController.Aggressed, m_TargetController) && useVengeance)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            //Player Followers: If A Player or Any of Their Followers Have been Aggressed or Barded, the Player and All Other Followers Can Attack the Aggressor
            PlayerMobile pm_Player = null;

            if (pm_Source != null)
            {
                pm_Player = pm_Source;
            }

            if (pm_SourceController != null)
            {
                pm_Player = pm_SourceController;
            }

            if (pm_Player != null)
            {
                if (pm_Player.AllFollowers.Count > 0)
                {
                    //Any of the Player's Other Followers
                    foreach (Mobile follower in pm_Player.AllFollowers)
                    {
                        BaseCreature bc_Follower = follower as BaseCreature;

                        if (bc_Follower == null)
                        {
                            continue;
                        }

                        //Follower Has Been Aggressed/Aggresor to Target
                        if (CheckAggressor(bc_Follower.Aggressors, target))
                        {
                            return(Notoriety.CanBeAttacked);
                        }

                        if (CheckAggressed(bc_Follower.Aggressed, target) && useVengeance)
                        {
                            return(Notoriety.CanBeAttacked);
                        }

                        //Follower Has Been Aggressed/Aggresor by/to Target's Controller
                        if (m_TargetController != null)
                        {
                            if (CheckAggressor(bc_Follower.Aggressors, m_TargetController))
                            {
                                return(Notoriety.CanBeAttacked);
                            }

                            if (CheckAggressed(bc_Follower.Aggressed, m_TargetController) && useVengeance)
                            {
                                return(Notoriety.CanBeAttacked);
                            }
                        }
                    }
                }
            }

            //Boats: Players and Creatures Friendly to a Boat Can Freely Attack Non-Friendly Mobiles on their Boat
            BaseBoat sourceBoat = null;

            if (bc_Source != null)
            {
                if (bc_Source.BoatOccupied != null)
                {
                    sourceBoat = bc_Source.BoatOccupied;
                }
            }

            if (pm_Source != null)
            {
                if (pm_Source.BoatOccupied != null)
                {
                    sourceBoat = pm_Source.BoatOccupied;
                }
            }

            if (sourceBoat != null)
            {
                BaseBoat targetBoat = null;

                if (bc_Target != null)
                {
                    if (bc_Target.BoatOccupied != null)
                    {
                        targetBoat = bc_Target.BoatOccupied;
                    }
                }

                if (pm_Target != null)
                {
                    if (pm_Target.BoatOccupied != null)
                    {
                        targetBoat = pm_Target.BoatOccupied;
                    }
                }

                //On Same Boat
                if (sourceBoat != null && targetBoat != null && !sourceBoat.Deleted && !targetBoat.Deleted && sourceBoat == targetBoat)
                {
                    bool sourceBelongs = false;
                    bool targetBelongs = false;

                    //Source Belongs n the Boat
                    if (sourceBoat.Crew.Contains(source) || sourceBoat.IsFriend(source) || sourceBoat.IsCoOwner(source) || sourceBoat.IsOwner(source))
                    {
                        sourceBelongs = true;
                    }

                    //Source's Owner Belongs on the Boat
                    else if (bc_Source != null)
                    {
                        if (m_SourceController != null)
                        {
                            if (sourceBoat.Crew.Contains(m_SourceController) || sourceBoat.IsFriend(m_SourceController) || sourceBoat.IsCoOwner(m_SourceController) || sourceBoat.IsOwner(m_SourceController))
                            {
                                sourceBelongs = true;
                            }
                        }
                    }

                    //Target Belongs On The Boat
                    if (sourceBoat.Crew.Contains(target) || sourceBoat.IsFriend(target) || sourceBoat.IsCoOwner(target) || sourceBoat.IsOwner(target))
                    {
                        targetBelongs = true;
                    }

                    //Target's Owner Belongs On the Boat
                    else if (bc_Target != null)
                    {
                        if (m_TargetController != null)
                        {
                            if (sourceBoat.Crew.Contains(m_TargetController) || sourceBoat.IsFriend(m_TargetController) || sourceBoat.IsCoOwner(m_TargetController) || sourceBoat.IsOwner(m_TargetController))
                            {
                                targetBelongs = true;
                            }
                        }
                    }

                    //Target May Be Freely Attacked on Boat
                    if (sourceBelongs && !targetBelongs)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }
            }

            //Polymorph or Body Transformation
            if (!(bc_Target != null && bc_Target.InitialInnocent))
            {
                if (target.Player && target.BodyMod > 0)
                {
                }

                else if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(bc_Target) && !TransformationSpellHelper.UnderTransformation(target))
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            //If somehow a player is attacking us with their tamed creatures, and their creatures are flagged to us but the player isn't
            //if (pm_Source != null && pm_Target != null)
            //{
            //    if (pm_Target.AllFollowers.Count > 0)
            //    {
            //        //Any of the Player's Other Followers
            //        foreach (Mobile follower in pm_Target.AllFollowers)
            //        {
            //            int notorietyResult = Notoriety.Compute(source, follower);

            //            //Enemy Tamer Adopts Notoriety of Their Creature (Anything other than Innocent)
            //            if (notorietyResult != 1)
            //            {
            //                foreach(var aggressor in source.Aggressors)
            //                {
            //                    if (aggressor.Attacker == follower)
            //                        return notorietyResult;
            //                }
            //            }
            //        }
            //    }
            //}

            return(Notoriety.Innocent);
        }
예제 #4
0
        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.");
                    }
                });
            });
        }
예제 #5
0
        public override void Spawn(Point3D point, Map map)
        {
            if (!UOACZPersistance.Active)
            {
                return;
            }

            int creatureThreatLevel = UOACZPersistance.m_ThreatLevel;

            if (!m_Wilderness)
            {
                creatureThreatLevel -= 30;
            }

            int minThreatLevel = 0;
            int maxThreatLevel = creatureThreatLevel;

            if (m_MinThreatLevel > -1)
            {
                minThreatLevel = m_MinThreatLevel;
            }

            if (m_MaxThreatLevel > -1)
            {
                maxThreatLevel = m_MaxThreatLevel;
            }

            Type creatureType = UOACZBaseUndead.GetRandomUndeadType(minThreatLevel, maxThreatLevel);

            if (creatureType != null)
            {
                UOACZBaseUndead creature = (UOACZBaseUndead)Activator.CreateInstance(creatureType);

                if (creature != null)
                {
                    creature.RangeHome             = HomeRange;
                    creature.Home                  = point;
                    creature.m_Spawner             = this;
                    creature.InWilderness          = m_Wilderness;
                    creature.CanTeleportToBaseNode = m_AllowTeleportToBaseNode;

                    creature.MoveToWorld(point, map);
                    m_Mobiles.Add(creature);

                    if (m_AllowTeleportToBaseNode)
                    {
                        if (m_GotoSplitGroup == -1)
                        {
                            creature.m_NeedWaypoint = true;
                        }

                        else
                        {
                            UOACZWayPoint closestWaypoint         = null;
                            int           closestWaypointDistance = 100000;

                            foreach (UOACZWayPoint waypoint in UOACZWayPoint.m_UOACZWaypoints)
                            {
                                if (waypoint == null)
                                {
                                    continue;
                                }
                                if (waypoint.Deleted)
                                {
                                    continue;
                                }
                                if (waypoint.m_GotoSplitGroup == -1)
                                {
                                    continue;
                                }
                                if (!UOACZRegion.ContainsItem(waypoint))
                                {
                                    continue;
                                }
                                if (waypoint.WaypointType == UOACZWayPoint.UOACZWaypointType.UndeadTown && m_Wilderness)
                                {
                                    continue;
                                }
                                if (waypoint.WaypointType == UOACZWayPoint.UOACZWaypointType.UndeadWilderness && !m_Wilderness)
                                {
                                    continue;
                                }

                                if (waypoint.SplitGroup == m_GotoSplitGroup)
                                {
                                    int distanceToWaypoint = Utility.GetDistance(creature.Location, waypoint.Location);

                                    if (distanceToWaypoint <= closestWaypointDistance)
                                    {
                                        closestWaypoint         = waypoint;
                                        closestWaypointDistance = distanceToWaypoint;
                                    }
                                }
                            }

                            if (closestWaypoint != null)
                            {
                                creature.CurrentWaypoint = closestWaypoint;
                            }
                        }
                    }
                }
            }
        }
예제 #6
0
            protected override void OnTarget(Mobile from, object target)
            {
                if (from == null || m_Net == null)
                {
                    return;
                }
                if (from.Deleted || !from.Alive || m_Net.Deleted || m_Net.RootParent != from)
                {
                    return;
                }

                PlayerMobile player = from as PlayerMobile;

                if (player == null)
                {
                    return;
                }

                if (!m_Net.IsChildOf(player.Backpack))
                {
                    player.SendMessage("That item must be in your pack in order to use it.");
                    return;
                }

                if (!player.CanBeginAction(typeof(UOACZThrowingNet)))
                {
                    player.SendMessage("You may only use a net once every " + m_Net.CooldownSeconds.ToString() + " seconds.");
                    return;
                }

                UOACZPersistance.CheckAndCreateUOACZAccountEntry(player);

                if (!UOACZSystem.IsUOACZValidMobile(player))
                {
                    return;
                }
                if (!player.IsUOACZHuman)
                {
                    return;
                }

                Mobile mobileTarget = null;

                if (target is Mobile)
                {
                    mobileTarget = target as Mobile;
                }

                else
                {
                    player.SendMessage("That is not a valid target.");
                    return;
                }

                if (mobileTarget == player)
                {
                    player.SendMessage("You cannot target yourself.");
                    return;
                }

                if (!UOACZSystem.IsUOACZValidMobile(mobileTarget))
                {
                    player.SendMessage("That is not a valid target.");
                    return;
                }

                if (Utility.GetDistance(player.Location, mobileTarget.Location) > 8)
                {
                    from.SendMessage("That is too far away");
                    return;
                }

                if (!player.Map.InLOS(player.Location, mobileTarget.Location))
                {
                    player.SendMessage("That is not within in your line of sight.");
                    return;
                }

                SpecialAbilities.HinderSpecialAbility(1.0, null, player, 1, 1, true, 0, false, "", "", "-1");

                if (!from.Mounted)
                {
                    player.Animate(31, 7, 1, true, false, 0);
                }

                double duration = 60;

                if (mobileTarget is UOACZBaseWildlife)
                {
                    duration = 60;
                }

                if (mobileTarget is UOACZBaseUndead)
                {
                    UOACZBaseUndead bc_Undead = mobileTarget as UOACZBaseUndead;

                    double reduction = 1 - (bc_Undead.Difficulty * .10);

                    if (reduction < .10)
                    {
                        reduction = .10;
                    }

                    duration *= reduction;
                }

                if (mobileTarget is UOACZBaseHuman)
                {
                    UOACZBaseCivilian bc_Human = mobileTarget as UOACZBaseCivilian;

                    double reduction = 1 - (bc_Human.Difficulty * .10);

                    if (reduction < .10)
                    {
                        reduction = .10;
                    }

                    duration *= reduction;
                }

                PlayerMobile playerTarget = mobileTarget as PlayerMobile;

                if (playerTarget != null)
                {
                    if (playerTarget.IsUOACZHuman)
                    {
                        duration = Utility.RandomMinMax(2, 4);
                    }

                    if (playerTarget.IsUOACZUndead)
                    {
                        duration = Utility.RandomMinMax(5, 10);
                    }
                }

                UOACZPersistance.CheckAndCreateUOACZAccountEntry(player);
                player.m_UOACZAccountEntry.NetsThrown++;

                int itemId  = m_Net.ItemID;
                int itemHue = m_Net.Hue;

                Effects.PlaySound(player.Location, player.Map, 0x5D3);

                player.DoHarmful(mobileTarget);

                Point3D playerLocation = player.Location;
                Map     playerMap      = player.Map;

                Point3D mobileLocation = mobileTarget.Location;
                Map     mobileMap      = mobileTarget.Map;

                IEntity startLocation = new Entity(Serial.Zero, new Point3D(playerLocation.X, playerLocation.Y, playerLocation.Z + 7), playerMap);
                IEntity endLocation   = new Entity(Serial.Zero, new Point3D(mobileTarget.X, mobileTarget.Y, mobileTarget.Z), mobileMap);

                double distance         = from.GetDistanceToSqrt(endLocation);
                double destinationDelay = (double)distance * .08;

                m_Net.Delete();

                Timer.DelayCall(TimeSpan.FromSeconds(destinationDelay), delegate
                {
                    if (!UOACZSystem.IsUOACZValidMobile(mobileTarget))
                    {
                        return;
                    }
                    if (Utility.GetDistance(playerLocation, mobileLocation) >= 25)
                    {
                        return;
                    }

                    SpecialAbilities.HinderSpecialAbility(1.0, player, mobileTarget, 1, duration, true, -1, true, "You ensnare them in a net", "You have been ensnared in a net!", "-1");

                    for (int a = 0; a < 9; a++)
                    {
                        TimedStatic net     = new TimedStatic(3538, duration - destinationDelay);
                        Point3D netLocation = mobileTarget.Location;

                        switch (a)
                        {
                        //Row 1
                        case 0:
                            net.ItemID  = 3538;
                            netLocation = new Point3D(netLocation.X - 1, netLocation.Y - 1, netLocation.Z);
                            break;

                        case 1:
                            net.ItemID  = 3528;
                            netLocation = new Point3D(netLocation.X, netLocation.Y - 1, netLocation.Z);
                            break;

                        case 2:
                            net.ItemID  = 3537;
                            netLocation = new Point3D(netLocation.X + 1, netLocation.Y - 1, netLocation.Z);
                            break;

                        //Row 2
                        case 3:
                            net.ItemID  = 3539;
                            netLocation = new Point3D(netLocation.X - 1, netLocation.Y, netLocation.Z);
                            break;

                        case 4:
                            net.ItemID  = 3530;
                            netLocation = new Point3D(netLocation.X, netLocation.Y, netLocation.Z);
                            break;

                        case 5:
                            net.ItemID  = 3531;
                            netLocation = new Point3D(netLocation.X + 1, netLocation.Y, netLocation.Z);
                            break;

                        //Row 3
                        case 6:
                            net.ItemID  = 3540;
                            netLocation = new Point3D(netLocation.X - 1, netLocation.Y + 1, netLocation.Z);
                            break;

                        case 7:
                            net.ItemID  = 3529;
                            netLocation = new Point3D(netLocation.X, netLocation.Y + 1, netLocation.Z);
                            break;

                        case 8:
                            net.ItemID  = 3541;
                            netLocation = new Point3D(netLocation.X + 1, netLocation.Y + 1, netLocation.Z);
                            break;
                        }

                        net.Hue  = itemHue;
                        net.Name = "a net";
                        net.MoveToWorld(netLocation, mobileMap);
                    }
                });
            }