Ejemplo n.º 1
0
        public void OnTarget(Mobile from, Point3D point)
        {
            BaseBoat fromBoat   = BaseBoat.FindBoatAt(from.Location, from.Map);
            BaseBoat targetBoat = BaseBoat.FindBoatAt(point, this.Map);

            if (targetBoat != null)
            {
                bool automaticBoarding = false;

                if (targetBoat.MobileControlType != MobileControlType.Player && !targetBoat.HasCrewAlive())
                {
                    automaticBoarding = true;
                }

                double shipHullPercent = (double)((float)targetBoat.HitPoints / (float)targetBoat.MaxHitPoints);

                if (targetBoat.IsOwner(from) || targetBoat.IsCoOwner(from) || targetBoat.IsFriend(from))
                {
                    from.SendMessage("You already have access to that boat.");
                    return;
                }

                else if (shipHullPercent > m_MinimumHullPercent && !automaticBoarding)
                {
                    from.SendMessage("The hull of that ship is not yet damaged enough to risk a boarding attempt.");
                    return;
                }

                else
                {
                    double baseSuccessChance = m_FullSuccessChancePercent;
                    double hullPercentFactor = (m_MinimumHullPercent - shipHullPercent) * (1 / m_MinimumHullPercent);

                    if (hullPercentFactor < 0)
                    {
                        hullPercentFactor = 0;
                    }

                    double finalSuccessChance = hullPercentFactor * baseSuccessChance;

                    if (targetBoat.MobileControlType != MobileControlType.Player)
                    {
                        ;
                    }
                    finalSuccessChance *= m_NPCShipBonusMultiplier;

                    //Successful Boarding
                    if ((Utility.RandomDouble() <= finalSuccessChance) || automaticBoarding)
                    {
                        //Valid Boarding
                        if (targetBoat.Embark(from, true))
                        {
                            List <Mobile> targets = targetBoat.GetMobilesOnBoat(false, false);

                            //Mobile Boarding Boat Becomes Aggressor to Everyone on Target Boat (Who Belongs on the Boat)
                            foreach (Mobile target in targets)
                            {
                                //Target Belongs on Boat
                                if (targetBoat.Crew.Contains(target) || targetBoat.IsFriend(target) || targetBoat.IsCoOwner(target) || targetBoat.IsOwner(target))
                                {
                                    //Do Harmful Action to Target
                                    if (from.CanBeHarmful(target, false))
                                    {
                                        from.DoHarmful(target);
                                    }
                                }
                            }

                            from.SendMessage("You board the ship!");
                            Effects.PlaySound(from.Location, from.Map, 0x056); //Alternate Sound 0x0EF

                            if (targetBoat.TillerMan != null)
                            {
                                if (targetBoat.HasCrewAlive())
                                {
                                    targetBoat.TillerMan.Say("Arr! We've been boarded!");
                                }
                            }

                            from.NextBoardingAttemptAllowed = DateTime.UtcNow + boardingCooldown;
                            CurrentCharges--;

                            return;
                        }

                        else
                        {
                            from.NextBoardingAttemptAllowed = DateTime.UtcNow + boardingCooldown;
                            from.SendMessage("You fail to board the ship");
                            Effects.PlaySound(from.Location, from.Map, 0x5D2);
                            CurrentCharges--;

                            return;
                        }
                    }

                    //Failed Boarding Attempt
                    else
                    {
                        from.NextBoardingAttemptAllowed = DateTime.UtcNow + boardingCooldown;
                        from.SendMessage("You fail to board the ship");
                        Effects.PlaySound(from.Location, from.Map, 0x5D2);
                        CurrentCharges--;

                        return;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override void OnDoubleClick(Mobile from)
        {
            if (m_Boat == null)
            {
                return;
            }
            if (m_Boat.Deleted)
            {
                return;
            }
            if (this == null)
            {
                return;
            }
            if (Deleted)
            {
                return;
            }

            if (from.AccessLevel > AccessLevel.Player)
            {
                from.SendMessage("You use your godly power's to access the hold.");
                base.OnDoubleClick(from);
                return;
            }

            if (m_Boat == null || !m_Boat.Contains(from))
            {
                from.SendMessage("You must be onboard that ship to access it's hold.");
                return;
            }

            //NPC Boat
            if (m_Boat.MobileControlType != MobileControlType.Player)
            {
                if (m_Boat.HasCrewAlive())
                {
                    from.SendMessage("You cannot attempt to access that ship's hold while it's crew members still live.");
                    return;
                }
            }

            //Player Boat
            else
            {
                //Refresh Boat
                if (m_Boat.IsOwner(from) || m_Boat.IsCoOwner(from) || m_Boat.IsFriend(from))
                {
                    m_Boat.Refresh();
                }

                //Don't Have Access
                if (!(m_Boat.IsOwner(from) || m_Boat.IsCoOwner(from)))
                {
                    from.SendMessage("You must use a lockpick to attempt to access that.");
                    return;
                }
            }

            base.OnDoubleClick(from);
        }