Пример #1
0
        public virtual void DoDamageBoat(BaseBoat boat)
        {
            int damage = Utility.RandomMinMax(MinBoatDamage, MaxBoatDamage);

            boat.OnTakenDamage(this, damage);

            for (int x = X - 2; x <= X + 2; x++)
            {
                for (int y = Y - 2; y <= Y + 2; y++)
                {
                    BaseBoat b = BaseBoat.FindBoatAt(new Point2D(x, y), Map);

                    if (b != null && boat == b)
                    {
                        Direction toPush = Direction.North;
                        if (X < x && x - X > 1)
                        {
                            toPush = Direction.West;
                        }
                        else if (X > x && X - x > 1)
                        {
                            toPush = Direction.East;
                        }
                        else if (Y < y)
                        {
                            toPush = Direction.South;
                        }
                        else if (Y > y)
                        {
                            toPush = Direction.North;
                        }

                        boat.StartMove(toPush, 1, 0x2, boat.SlowDriftInterval, true, false);
                        //TODO: Message and Sound?
                    }
                }
            }
        }
Пример #2
0
        public virtual void OnShipHit(object obj)
        {
            object[] list   = (object[])obj;
            BaseBoat target = list[0] as BaseBoat;
            Point3D  pnt    = (Point3D)list[1];

            var ammoInfo = AmmoInfo.GetAmmoInfo((AmmunitionType)list[2]);

            if (ammoInfo != null && target != null)
            {
                int damage = (Utility.RandomMinMax(ammoInfo.MinDamage, ammoInfo.MaxDamage));
                damage /= 7;
                target.OnTakenDamage(Operator, damage);

                int z = target.ZSurface;

                if (target.TillerMan != null && target.TillerMan is IEntity)
                {
                    z = ((IEntity)target.TillerMan).Z;
                }

                Direction d       = Utility.GetDirection(this, pnt);
                int       xOffset = 0;
                int       yOffset = 0;
                Point3D   hit     = pnt;

                if (!ammoInfo.RequiresSurface)
                {
                    switch (d)
                    {
                    default:
                    case Direction.North:
                        xOffset = Utility.RandomMinMax(-1, 1);
                        yOffset = Utility.RandomMinMax(-2, 0);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;

                    case Direction.South:
                        xOffset = Utility.RandomMinMax(-1, 1);
                        yOffset = Utility.RandomMinMax(0, 2);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;

                    case Direction.East:
                        xOffset = Utility.RandomMinMax(0, 2);
                        yOffset = Utility.RandomMinMax(-1, 1);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;

                    case Direction.West:
                        xOffset = Utility.RandomMinMax(-2, 0);
                        yOffset = Utility.RandomMinMax(-1, 1);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;
                    }
                }

                Effects.SendLocationEffect(hit, target.Map, Utility.RandomBool() ? 14000 : 14013, 15, 10);
                Effects.PlaySound(hit, target.Map, 0x207);

                if (Operator != null && (!Operator.Deleted || CanFireUnmanned))
                {
                    Mobile victim = target.Owner;

                    if (victim != null && target.Contains(victim) && Operator.CanBeHarmful(victim, false))
                    {
                        Operator.DoHarmful(victim);
                    }
                    else
                    {
                        List <Mobile> candidates = new List <Mobile>();
                        SecurityLevel highest    = SecurityLevel.Passenger;

                        foreach (var mob in target.GetMobilesOnBoard().OfType <PlayerMobile>().Where(pm => Operator.CanBeHarmful(pm, false)))
                        {
                            if (target is BaseGalleon && ((BaseGalleon)target).GetSecurityLevel(mob) > highest)
                            {
                                candidates.Insert(0, mob);
                            }
                            else
                            {
                                candidates.Add(mob);
                            }
                        }

                        if (candidates.Count > 0)
                        {
                            Operator.DoHarmful(candidates[0]);
                        }
                        else if (victim != null && Operator.IsHarmfulCriminal(victim))
                        {
                            Operator.CriminalAction(false);
                        }

                        ColUtility.Free(candidates);
                    }
                }
            }
        }
Пример #3
0
        public void OnTick(Point3DList path, Direction dir, int i)
        {
            if (path.Count > i)
            {
                Point3D point = path[i];
                int     o     = i - 1;

                Server.Effects.PlaySound(point, Map, 278);
                Server.Effects.PlaySound(point, Map, 279);

                for (int rn = 0; rn < (o * 2) + 1; rn++)
                {
                    int  y = 0, x = 0, y2 = 0, x2 = 0;
                    bool diag = false;
                    switch ((int)dir)
                    {
                    case (int)Direction.Running:
                    case (int)Direction.North: { x = x - o + rn; break; }

                    case 129:
                    case (int)Direction.Right: { x = x - o + rn; y = y - o + rn; break; }

                    case 130:
                    case (int)Direction.East: { y = y - o + rn; break; }

                    case 131:
                    case (int)Direction.Down: { y = y - o + rn; x = x + o - rn; break; }

                    case 132:
                    case (int)Direction.South: { x = x + o - rn; break; }

                    case 133:
                    case (int)Direction.Left: { x = x + o - rn; y = y + o - rn; break; }

                    case 134:
                    case (int)Direction.West: { y = y + o - rn; break; }

                    case (int)Direction.ValueMask:
                    case (int)Direction.Up: { y = y + o - rn; x = x - o + rn; break; }
                    }
                    switch ((int)dir)
                    {
                    case 129:
                    case (int)Direction.Right: { y2++; diag = true; break; }

                    case 131:
                    case (int)Direction.Down: { x2--; diag = true; break; }

                    case 133:
                    case (int)Direction.Left: { y2--; diag = true; break; }

                    case (int)Direction.ValueMask:
                    case (int)Direction.Up: { x2++; diag = true; break; }

                    default: { break; }
                    }

                    Point3D ep  = new Point3D(point.X + x, point.Y + y, point.Z);
                    Point3D ep2 = new Point3D(ep.X + x2, ep.Y + y2, ep.Z);

                    if (diag && i >= ((2 * path.Count) / 3))
                    {
                        return;
                    }

                    Point3D p;
                    if (diag && rn < (o * 2))
                    {
                        p = ep2;
                    }
                    else
                    {
                        p = ep;
                    }

                    if (Spells.SpellHelper.CheckMulti(p, Map))
                    {
                        BaseBoat boat = BaseBoat.FindBoatAt(p, Map);

                        if (boat != null && !m_HasPushed)
                        {
                            int damage = Utility.RandomMinMax(MinBoatDamage, MaxBoatDamage);
                            boat.OnTakenDamage(this, damage);

                            boat.StartMove(dir, 1, 0x2, boat.SlowDriftInterval, true, false);
                            m_HasPushed = true;
                        }
                        continue;
                    }

                    LandTile t = Map.Tiles.GetLandTile(x, y);

                    if (IsSeaTile(t))
                    {
                        Mobile spawn = new EffectSpawn();
                        spawn.MoveToWorld(p, Map);
                    }
                }
            }
        }