Пример #1
0
        //  Not used apparently
        public static void AddShotgun(MyProjectileAmmoDefinition ammoDefinition, MyEntity ignorePhysObject, Vector3 origin, Vector3 initialVelocity, Vector3 directionNormalized, bool groupStart, float thicknessMultiplier, MyEntity weapon, float frontBillboardSize, MyEntity ownerEntity = null, float projectileCountMultiplier = 1)
        {
            MyProjectile newProjectile = m_projectiles.Allocate();

            if (newProjectile != null)
            {
                //newProjectile.Start(
                //    ammoDefinition,
                //    ignorePhysObject,
                //    origin,
                //    initialVelocity,
                //    directionNormalized,
                //    groupStart,
                //    thicknessMultiplier,
                //    1,
                //    weapon,
                //    projectileCountMultiplier
                //    );

                //    newProjectile.BlendByCameraDirection = true;
                //    newProjectile.FrontBillboardMaterial = "ShotgunParticle";
                //    newProjectile.LengthMultiplier = 2;
                //    newProjectile.FrontBillboardSize = frontBillboardSize;
                //   newProjectile.OwnerEntity = ownerEntity != null ? ownerEntity : ignorePhysObject;
            }
        }
Пример #2
0
        public static AmmoDefinition CreateFromKeenDefinition(MyProjectileAmmoDefinition p)
        {
            return(new AmmoDefinition {
                SubtypeId = p.Id.SubtypeId.String,
                DesiredSpeed = p.DesiredSpeed,
                SpeedVariance = p.SpeedVar,
                MaxTrajectory = p.MaxTrajectory,
                BackkickForce = p.BackkickForce,
                //PhysicalMaterial = p.PhysicalMaterial.ToString(),

                ProjectileHitImpulse = p.ProjectileHitImpulse,
                ProjectileTrailScale = p.ProjectileTrailScale,
                ProjectileTrailColor = p.ProjectileTrailColor,
                ProjectileTrailMaterial = p.ProjectileTrailMaterial,
                ProjectileTrailProbability = p.ProjectileTrailProbability,
                ProjectileOnHitEffectName = p.ProjectileOnHitEffectName,
                ProjectileMassDamage = p.ProjectileMassDamage,
                ProjectileHealthDamage = p.ProjectileHealthDamage,
                ProjectileHeadShotDamage = p.ProjectileHeadShotDamage,
                ProjectileCount = p.ProjectileCount,

                Ricochet = new RicochetDefinition()
                {
                    DeflectionAngle = 45,
                    MaxVelocityTransfer = 0.5f,
                    MaxDamageTransfer = 0.5f,
                    RicochetChance = 1,
                },
            });
        }
Пример #3
0
        public static void AddShrapnel(MyProjectileAmmoDefinition ammoDefinition, MyEntity[] ignoreEntities, Vector3 origin, Vector3 initialVelocity, Vector3 directionNormalized, bool groupStart, float thicknessMultiplier, float trailProbability, MyEntity weapon, MyEntity ownerEntity = null, float projectileCountMultiplier = 1)
        {
            MyProjectile newProjectile;

            m_projectiles.AllocateOrCreate(out newProjectile);

            newProjectile.Start(
                ammoDefinition,
                ignoreEntities,
                origin,
                initialVelocity,
                directionNormalized,
                weapon
                );
            newProjectile.OwnerEntity = ownerEntity ?? (ignoreEntities != null && ignoreEntities.Length > 0 ? ignoreEntities[0] : null);
        }
Пример #4
0
        //  Add new projectile to the list
        public static void Add(MyProjectileAmmoDefinition ammoDefinition, Vector3D origin, Vector3 initialVelocity, Vector3 directionNormalized, IMyGunBaseUser user)
        {
            //MyProjectile newProjectile = m_projectiles.Allocate();
            MyProjectile newProjectile;

            m_projectiles.AllocateOrCreate(out newProjectile);

            newProjectile.Start(
                ammoDefinition,
                user.IgnoreEntity,
                origin,
                initialVelocity,
                directionNormalized,
                user.Weapon
                );
            newProjectile.OwnerEntity = user.Owner != null ? user.Owner : user.IgnoreEntity;
        }
Пример #5
0
        //  Add new projectile to the list
        public static void Add(MyProjectileAmmoDefinition ammoDefinition, Vector3D origin, Vector3 initialVelocity, Vector3 directionNormalized, IMyGunBaseUser user, MyEntity owner)
        {
            //MyProjectile newProjectile = m_projectiles.Allocate();
            MyProjectile newProjectile;

            m_projectiles.AllocateOrCreate(out newProjectile);

            newProjectile.Start(
                ammoDefinition,
                user.IgnoreEntities,
                origin,
                initialVelocity,
                directionNormalized,
                user.Weapon
                );
            newProjectile.OwnerEntity         = user.Owner ?? (user.IgnoreEntities != null && user.IgnoreEntities.Length > 0 ? user.IgnoreEntities[0] : null);
            newProjectile.OwnerEntityAbsolute = owner;
        }
Пример #6
0
        //  This method realy initiates/starts the missile
        //  IMPORTANT: Direction vector must be normalized!
        // Projectile count multiplier - when real rate of fire it 45, but we shoot only 10 projectiles as optimization count multiplier will be 4.5
        public void Start(MyProjectileAmmoDefinition ammoDefinition, MyEntity ignoreEntity, Vector3D origin, Vector3 initialVelocity, Vector3 directionNormalized, MyEntity weapon)
        {
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Projectile.Start");

            m_projectileAmmoDefinition = ammoDefinition;
            m_state        = MyProjectileStateEnum.ACTIVE;
            m_ignoreEntity = ignoreEntity;
            m_origin       = origin + 0.1 * (Vector3D)directionNormalized;
            m_position     = m_origin;
            m_weapon       = weapon;

            if (ammoDefinition.ProjectileTrailProbability >= MyUtils.GetRandomFloat(0, 1))
            {
                LengthMultiplier = 40;
            }
            else
            {
                LengthMultiplier = 0;
            }

            /*
             * if (MyConstants.EnableAimCorrection)
             * {
             * if (m_ammoProperties.AllowAimCorrection) // Autoaim only available for player
             * {
             * VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Projectile.Start autoaim generic");
             * //Intersection ignores children of "ignoreEntity", thus we must not hit our own barrels
             * correctedDirection = MyEntities.GetDirectionFromStartPointToHitPointOfNearestObject(ignoreEntity, m_weapon, origin, m_ammoProperties.MaxTrajectory);
             * VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
             * }
             * }             */

            m_directionNormalized = directionNormalized;
            m_speed         = ammoDefinition.DesiredSpeed * (ammoDefinition.SpeedVar > 0.0f ? MyUtils.GetRandomFloat(1 - ammoDefinition.SpeedVar, 1 + ammoDefinition.SpeedVar) : 1.0f);
            m_velocity      = initialVelocity + m_directionNormalized * m_speed;;
            m_maxTrajectory = ammoDefinition.MaxTrajectory * MyUtils.GetRandomFloat(0.8f, 1.2f); // +/- 20%

            m_checkIntersectionIndex  = checkIntersectionCounter % CHECK_INTERSECTION_INTERVAL;
            checkIntersectionCounter += 3;
            m_positionChecked         = false;

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
Пример #7
0
        //  This method realy initiates/starts the missile
        //  IMPORTANT: Direction vector must be normalized!
        // Projectile count multiplier - when real rate of fire it 45, but we shoot only 10 projectiles as optimization count multiplier will be 4.5
        public void Start(MyProjectileAmmoDefinition ammoDefinition, MyEntity[] ignoreEntities, Vector3D origin, Vector3 initialVelocity, Vector3 directionNormalized, MyEntity weapon)
        {
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Projectile.Start");

            m_projectileAmmoDefinition = ammoDefinition;
            m_state           = MyProjectileStateEnum.ACTIVE;
            m_ignoredEntities = ignoreEntities;  // store ref to ignored entities
            m_origin          = origin + 0.1 * (Vector3D)directionNormalized;
            m_position        = m_origin;
            m_weapon          = weapon;

            if (ammoDefinition.ProjectileTrailProbability >= MyUtils.GetRandomFloat(0, 1))
            {
                LengthMultiplier = 40;
            }
            else
            {
                LengthMultiplier = 0;
            }

            /*
             * if (MyConstants.EnableAimCorrection)
             * {
             * if (m_ammoProperties.AllowAimCorrection) // Autoaim only available for player
             * {
             * VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Projectile.Start autoaim generic");
             * //Intersection ignores children of "ignoreEntity", thus we must not hit our own barrels
             * correctedDirection = MyEntities.GetDirectionFromStartPointToHitPointOfNearestObject(ignoreEntity, m_weapon, origin, m_ammoProperties.MaxTrajectory);
             * VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
             * }
             * }             */

            m_directionNormalized = directionNormalized;
            m_speed         = ammoDefinition.DesiredSpeed * (ammoDefinition.SpeedVar > 0.0f ? MyUtils.GetRandomFloat(1 - ammoDefinition.SpeedVar, 1 + ammoDefinition.SpeedVar) : 1.0f);
            m_velocity      = initialVelocity + m_directionNormalized * m_speed;
            m_maxTrajectory = ammoDefinition.MaxTrajectory * MyUtils.GetRandomFloat(0.8f, 1.2f); // +/- 20%

            m_checkIntersectionIndex  = checkIntersectionCounter % CHECK_INTERSECTION_INTERVAL;
            checkIntersectionCounter += 3;
            m_positionChecked         = false;

            LineD line = new LineD(m_origin, m_origin + m_directionNormalized * m_maxTrajectory);

            if (m_entityRaycastResult == null)
            {
                m_entityRaycastResult = new List <MyLineSegmentOverlapResult <MyEntity> >(16);
            }
            else
            {
                m_entityRaycastResult.Clear();
            }
            MyGamePruningStructure.GetAllEntitiesInRay(ref line, m_entityRaycastResult, MyEntityQueryType.Static);

            foreach (var entity in m_entityRaycastResult)
            {
                MyVoxelPhysics planetPhysics = entity.Element as MyVoxelPhysics;
                if (planetPhysics != null)
                {
                    planetPhysics.PrefetchShapeOnRay(ref line);
                }
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }