Esempio n. 1
0
    private void OnTriggerExit(Collider other)
    {
        if (other.GetComponentInParent <ArenaParticipant>() == null)
        {
            return;
        }

        ArenaParticipant arenaParticipant = other.GetComponentInParent <ArenaParticipant>();

        if (zoneType == ZoneType.LeaveAndFail)
        { // Old better to rework
            arenaParticipant.enabled = false;
            Rigidbody rb = other.GetComponentInParent <Rigidbody>();
            rb.mass      += 35f;
            rb.useGravity = true;
            arenaParticipant.OutOfGame();
        }
        else if (zoneType == ZoneType.LeaveAndJump)
        {
            arenaParticipant.LeaveZoneAndJump();
        }
    }
Esempio n. 2
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;

            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;
            }

            ArenaController fromArenaController   = ArenaController.GetArenaAtLocation(source.Location, source.Map);
            ArenaController targetArenaController = ArenaController.GetArenaAtLocation(target.Location, target.Map);

            if (fromArenaController != null && targetArenaController != null && fromArenaController == targetArenaController)
            {
                if (fromArenaController.m_ArenaFight != null)
                {
                    if (fromArenaController.m_ArenaFight.m_FightPhase == ArenaFight.FightPhaseType.Fight)
                    {
                        if (fromArenaController.m_ArenaFight.m_ArenaMatch != null)
                        {
                            ArenaMatch arenaMatch = fromArenaController.m_ArenaFight.m_ArenaMatch;

                            if (ArenaMatch.IsValidArenaMatch(arenaMatch, null, false))
                            {
                                PlayerMobile rootPlayerFrom   = null;
                                PlayerMobile rootPlayerTarget = null;

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

                                if (pm_Target != null)
                                {
                                    rootPlayerTarget = pm_Target;
                                }

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

                                if (pm_TargetController != null)
                                {
                                    rootPlayerTarget = pm_TargetController;
                                }

                                ArenaParticipant fromArenaParticipant   = fromArenaController.m_ArenaFight.m_ArenaMatch.GetParticipant(rootPlayerFrom);
                                ArenaParticipant targetArenaParticipant = fromArenaController.m_ArenaFight.m_ArenaMatch.GetParticipant(rootPlayerTarget);

                                if (fromArenaParticipant != null && targetArenaParticipant != null)
                                {
                                    if (fromArenaParticipant.m_FightStatus == ArenaParticipant.FightStatusType.Alive && targetArenaParticipant.m_FightStatus == ArenaParticipant.FightStatusType.Alive)
                                    {
                                        ArenaTeam fromTeam   = null;
                                        ArenaTeam targetTeam = null;

                                        foreach (ArenaTeam team in arenaMatch.m_Teams)
                                        {
                                            if (team == null)
                                            {
                                                continue;
                                            }
                                            if (team.Deleted)
                                            {
                                                continue;
                                            }

                                            ArenaParticipant participant = team.GetPlayerParticipant(rootPlayerFrom);

                                            if (participant != null)
                                            {
                                                fromTeam = team;
                                            }

                                            participant = team.GetPlayerParticipant(rootPlayerTarget);

                                            if (participant != null)
                                            {
                                                targetTeam = team;
                                            }
                                        }

                                        if (fromTeam != null && targetTeam != null)
                                        {
                                            if (fromTeam == targetTeam)
                                            {
                                                return(Notoriety.Ally);
                                            }

                                            if (fromTeam != targetTeam)
                                            {
                                                return(Notoriety.Enemy);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //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);
                }
            }

            //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);
                            }
                        }
                    }
                }
            }

            //Ships: Players and Creatures Friendly to a Ship Can Freely Attack Non-Friendly Mobiles on their Ship
            BaseShip sourceShip = null;

            if (bc_Source != null)
            {
                if (bc_Source.ShipOccupied != null)
                {
                    sourceShip = bc_Source.ShipOccupied;
                }
            }

            if (pm_Source != null)
            {
                if (pm_Source.ShipOccupied != null)
                {
                    sourceShip = pm_Source.ShipOccupied;
                }
            }

            if (sourceShip != null)
            {
                BaseShip targetShip = null;

                if (bc_Target != null)
                {
                    if (bc_Target.ShipOccupied != null)
                    {
                        targetShip = bc_Target.ShipOccupied;
                    }
                }

                if (pm_Target != null)
                {
                    if (pm_Target.ShipOccupied != null)
                    {
                        targetShip = pm_Target.ShipOccupied;
                    }
                }

                //On Same Ship
                if (sourceShip != null && targetShip != null && !sourceShip.Deleted && !targetShip.Deleted && sourceShip == targetShip)
                {
                    bool sourceBelongs = false;
                    bool targetBelongs = false;

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

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

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

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

                    //Target May Be Freely Attacked on Ship
                    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);
        }