示例#1
0
        ////////////////////////////////////////////////////////////
        // Thing spawn functions for the middle of a game
        ////////////////////////////////////////////////////////////

        /// <summary>
        /// Spawn a mobj at the given position as the given type.
        /// </summary>
        public Mobj SpawnMobj(Fixed x, Fixed y, Fixed z, MobjType type)
        {
            var mobj = new Mobj(world);

            var info = DoomInfo.MobjInfos[(int)type];

            mobj.Type   = type;
            mobj.Info   = info;
            mobj.X      = x;
            mobj.Y      = y;
            mobj.Radius = info.Radius;
            mobj.Height = info.Height;
            mobj.Flags  = info.Flags;
            mobj.Flags2 = info.Flags2;
            mobj.Health = info.SpawnHealth;

            if (world.Options.Skill != GameSkill.Nightmare)
            {
                mobj.ReactionTime = info.ReactionTime;
            }

            mobj.LastLook = world.Random.Next() % Player.MaxPlayerCount;

            // Do not set the state with P_SetMobjState,
            // because action routines can not be called yet.
            var st = DoomInfo.States[(int)info.SpawnState];

            mobj.State  = st;
            mobj.Tics   = st.Tics;
            mobj.Sprite = st.Sprite;
            mobj.Frame  = st.Frame;

            // Set subsector and/or block links.
            world.ThingMovement.SetThingPosition(mobj);

            mobj.FloorZ   = mobj.Subsector.Sector.FloorHeight;
            mobj.CeilingZ = mobj.Subsector.Sector.CeilingHeight;

            if (z == Mobj.OnFloorZ)
            {
                mobj.Z = mobj.FloorZ;
            }
            else if (z == Mobj.OnCeilingZ)
            {
                mobj.Z = mobj.CeilingZ - mobj.Info.Height;
            }
            else
            {
                mobj.Z = z;
            }

            world.Thinkers.Add(mobj);

            return(mobj);
        }
示例#2
0
        public Mobj SpawnMissile(Mobj source, Mobj dest, MobjType type)
        {
            var missile = SpawnMobj(
                source.X,
                source.Y,
                source.Z + Fixed.FromInt(32), type);

            if (missile.Info.SeeSound != 0)
            {
                world.StartSound(missile, missile.Info.SeeSound);
            }

            // Where it came from?
            missile.Target = source;

            var angle = Geometry.PointToAngle(
                source.X, source.Y,
                dest.X, dest.Y);

            // Fuzzy player.
            if ((dest.Flags & MobjFlags.Shadow) != 0)
            {
                var random = world.Random;
                angle += new Angle((random.Next() - random.Next()) << 20);
            }

            var speed = GetMissileSpeed(missile.Type);

            missile.Angle = angle;
            missile.MomX  = new Fixed(speed) * Trig.Cos(angle);
            missile.MomY  = new Fixed(speed) * Trig.Sin(angle);

            var dist = Geometry.AproxDistance(
                dest.X - source.X,
                dest.Y - source.Y);

            var num = (dest.Z - source.Z).Data;
            var den = (dist / speed).Data;

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

            missile.MomZ = new Fixed(num / den);

            CheckMissileSpawn(missile);

            return(missile);
        }
示例#3
0
        /// <summary>
        /// Get the speed of the given missile type.
        /// Some missiles have different speeds according to the game setting.
        /// </summary>
        private int GetMissileSpeed(MobjType type)
        {
            //* not used?     if (world.Options.FastMonsters || world.Options.Skill == GameSkill.Nightmare)
            //     {
            //         switch (type)
            //         {
            //             // case MobjType.Bruisershot:
            //             // case MobjType.Headshot:

            //         }
            //     }
            //     else
            //     {
            return(22 * Fixed.FracUnit);
            //}
        }
示例#4
0
        public void SpawnPlayerMissile(Mobj source, MobjType type)
        {
            var hs = world.Hitscan;

            // See which target is to be aimed at.
            var angle = source.Angle;
            var slope = hs.AimLineAttack(source, angle, Fixed.FromInt(16 * 64));

            if (hs.LineTarget == null)
            {
                angle += new Angle(1 << 26);
                slope  = hs.AimLineAttack(source, angle, Fixed.FromInt(16 * 64));

                if (hs.LineTarget == null)
                {
                    angle -= new Angle(2 << 26);
                    slope  = hs.AimLineAttack(source, angle, Fixed.FromInt(16 * 64));
                }

                if (hs.LineTarget == null)
                {
                    angle = source.Angle;
                    slope = Fixed.Zero;
                }
            }

            var x = source.X;
            var y = source.Y;
            var z = source.Z + Fixed.FromInt(32);

            var missile = SpawnMobj(x, y, z, type);

            if (missile.Info.SeeSound != 0)
            {
                world.StartSound(missile, missile.Info.SeeSound);
            }

            missile.Target = source;
            missile.Angle  = angle;
            missile.MomX   = new Fixed(missile.Info.Speed) * Trig.Cos(angle);
            missile.MomY   = new Fixed(missile.Info.Speed) * Trig.Sin(angle);
            missile.MomZ   = new Fixed(missile.Info.Speed) * slope;

            CheckMissileSpawn(missile);
        }
示例#5
0
        private int GetMissileSpeed(MobjType type)
        {
            if (world.Options.FastMonsters || world.Options.Skill == GameSkill.Nightmare)
            {
                switch (type)
                {
                case MobjType.Bruisershot:
                case MobjType.Headshot:
                case MobjType.Troopshot:
                    return(20 * Fixed.FracUnit);

                default:
                    return(DoomInfo.MobjInfos[(int)type].Speed);
                }
            }
            else
            {
                return(DoomInfo.MobjInfos[(int)type].Speed);
            }
        }
示例#6
0
 public CastInfo(string name, MobjType type)
 {
     this.Name = name;
     this.Type = type;
 }
示例#7
0
 public FireProjectileComponentInfo(MobjType projectile)
 {
     this.Projectile = projectile;
 }
示例#8
0
 public CastInfo(string name, MobjType type)
 {
     Name = name;
     Type = type;
 }