예제 #1
0
        public virtual void Init(MyModelsEnum modelEnum, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoEnum, bool spherePhysics = true)
        {
            base.Init(null, modelEnum, null, null, null, null);

            AmmoType = ammoEnum;
            m_gameplayProperties = MyGameplayConstants.GetGameplayProperties(MyMwcObjectBuilderTypeEnum.SmallShip_Ammo, (int)ammoEnum, Faction);
            m_ammoProperties = MyAmmoConstants.GetAmmoProperties(ammoEnum);

            //  Collision skin
            if (spherePhysics)
            {
                InitSpherePhysics(MyMaterialType.AMMO, ModelLod0, m_gameplayProperties.WeightPerUnit,
                                  MyPhysicsConfig.DefaultAngularDamping, MyConstants.COLLISION_LAYER_DEFAULT,
                                  RigidBodyFlag.RBF_DEFAULT);
            }
            else
            {
                InitBoxPhysics(MyMaterialType.AMMO, ModelLod0, m_gameplayProperties.WeightPerUnit,
                               MyPhysicsConfig.DefaultAngularDamping, MyConstants.COLLISION_LAYER_DEFAULT,
                               RigidBodyFlag.RBF_DEFAULT);
            }

            Physics.GetRBElementList()[0].Flags |= MyElementFlag.EF_MODEL_PREFER_LOD0;

            NeedsUpdate = true;
            RenderObjects[0].SkipIfTooSmall = false;
            CastShadows = false;
            Closed = true; //Because ammobase instance is going to pool. It is started by Start()

            IsDestructible = true;

            PreloadTextures();
        }
예제 #2
0
        protected Vector3 GetDeviatedVector(MyAmmoProperties ammoProperties)
        {
            float deviateAngle = ammoProperties.DeviateAngle;

            //  Create one projectile - but deviate projectile direction be random angle
            if (IsThisGunFriendly())            
                deviateAngle += MyGameplayConstants.GameplayDifficultyProfile.DeviatingAnglePlayerOnEnemy;            
            else            
                deviateAngle += MyGameplayConstants.GameplayDifficultyProfile.DeviatingAngleEnemyBotOnPlayer;

            return MyUtilRandomVector3ByDeviatingVector.GetRandom(WorldMatrix.Forward, deviateAngle);
        }        
예제 #3
0
 //  Add new projectile to the list
 public static void Add(MyAmmoProperties ammoProperties, MyEntity ignorePhysObject, Vector3 origin, Vector3 initialVelocity, Vector3 directionNormalized, bool groupStart, float thicknessMultiplier, MyEntity weapon, MyEntity ownerEntity = null)
 {
     MyProjectile newProjectile = m_projectiles.Allocate();
     if (newProjectile != null)
     {
         newProjectile.Start(
             ammoProperties,
             ignorePhysObject, 
             origin, 
             initialVelocity, 
             directionNormalized, 
             groupStart, 
             thicknessMultiplier,
             weapon
             );
         newProjectile.OwnerEntity = ownerEntity != null ? ownerEntity : ignorePhysObject;
     }
 }
예제 #4
0
        //  Add new projectile to the list
        public static void AddShotgun(MyAmmoProperties ammoProperties, MyEntity ignorePhysObject, Vector3 origin, Vector3 initialVelocity, Vector3 directionNormalized, bool groupStart, float thicknessMultiplier, MyEntity weapon, float frontBillboardSize, MyEntity ownerEntity = null)
        {
            MyProjectile newProjectile = m_projectiles.Allocate();
            if (newProjectile != null)
            {
                newProjectile.Start(
                    ammoProperties,
                    ignorePhysObject,
                    origin,
                    initialVelocity,
                    directionNormalized,
                    groupStart,
                    thicknessMultiplier,
                    weapon
                    );

                newProjectile.BlendByCameraDirection = true;
                newProjectile.FrontBillboardMaterial = MyTransparentMaterialEnum.ShotgunParticle;
                newProjectile.LengthMultiplier = 2;
                newProjectile.FrontBillboardSize = frontBillboardSize;
                newProjectile.OwnerEntity = ownerEntity != null ? ownerEntity : ignorePhysObject;
            }
        }
예제 #5
0
        private void FireShotGunShot(MyAmmoProperties ammoProperties)
        {
            int currentRound = ammoProperties.ProjectileGroupSize;
            float deviateAngle = ammoProperties.DeviateAngle;

            //  Create one projectile - but deviate projectile direction be random angle
            if (IsThisGunFriendly())
                deviateAngle += MyGameplayConstants.GameplayDifficultyProfile.DeviatingAnglePlayerOnEnemy;
            else
                deviateAngle += MyGameplayConstants.GameplayDifficultyProfile.DeviatingAngleEnemyBotOnPlayer;

            while (currentRound-- > 0)
            {
                Vector3 projectileForwardVector = MyUtilRandomVector3ByDeviatingVector.GetRandom(WorldMatrix.Forward, deviateAngle);

                float billboardSize = ammoProperties.AmmoType == MyAmmoType.Explosive ? 2 : 1;

                MyProjectiles.AddShotgun(ammoProperties, Parent, m_positionMuzzleInWorldSpace, Vector3.Zero/* Parent.Physics.LinearVelocity*/,
                                  projectileForwardVector, currentRound % MyShotgunConstants.PROJECTILE_GROUP_SIZE == 0, 2, this, billboardSize, Parent);
            }

            m_lastTimeShoot = MyMinerGame.TotalGamePlayTimeInMilliseconds;
            AddWeaponCue(ammoProperties.ShotSound);
        }
        protected void AddProjectile(MyAmmoProperties ammoProperties, Vector3 muzzlePosition)
        {
            float deviateAngle = ammoProperties.DeviateAngle;

            Vector3 projectileForwardVector = GetDeviatedVector(ammoProperties);

            Vector3 velocity = ((MyLargeShipGunBase)Parent).PrefabParent.Parent.Physics.LinearVelocity;
            MyProjectiles.Add(ammoProperties, Parent, muzzlePosition, velocity, projectileForwardVector, false, 1.0f, this, ((MyLargeShipGunBase)Parent).WeaponOwner);
        }
        protected Vector3 GetDeviatedVector(MyAmmoProperties ammoProperties)
        {
            float deviateAngle = ammoProperties.DeviateAngle;

            //  Create one projectile - but deviate projectile direction be random angle
            if (((Parent as MyGunBase).IsThisGunFriendly() || MyGuiScreenGamePlay.Static.ControlledEntity == (Parent as MyLargeShipGunBase).PrefabParent))
            {
                deviateAngle += MyGameplayConstants.GameplayDifficultyProfile.DeviatingAnglePlayerOnEnemy;
            }
            else
            {
                deviateAngle += MyGameplayConstants.GameplayDifficultyProfile.DeviatingAngleEnemyLargeWeaponOnPlayer;
                deviateAngle += GetDeviatedAngleByDamageRatio();
            }

            return MyUtilRandomVector3ByDeviatingVector.GetRandom(WorldMatrix.Forward, deviateAngle);
        }
예제 #8
0
        //  This method realy initiates/starts the missile
        //  IMPORTANT: Direction vector must be normalized!
        public void Start(MyAmmoProperties ammoProperties, MyEntity ignoreEntity, Vector3 origin, Vector3 initialVelocity, Vector3 directionNormalized, 
            bool groupStart, float thicknessMultiplier, MyEntity weapon
            )
        {
            if (MySession.Is25DSector)
            {
                directionNormalized.Y = 0;
                directionNormalized.Normalize();
                initialVelocity.Y = 0;
            }

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Projectile.Start");
            m_ammoProperties = ammoProperties;
            m_state = MyProjectileStateEnum.ACTIVE;
            m_ignorePhysObject = ignoreEntity;
            m_origin = origin;
            m_position = origin;
            m_externalAddition = 1.0f;
            m_weapon = weapon;

            IsDummy = weapon != null && weapon.IsDummy;

            LengthMultiplier = 1;
            FrontBillboardMaterial = null;
            FrontBillboardSize = 1;
            BlendByCameraDirection = false;

            Vector3? correctedDirection = null;

            if (MyGameplayConstants.GameplayDifficultyProfile.EnableAimCorrection)
            {
                MyEntity entityToCheck;
                if (MyGuiScreenGamePlay.Static.ControlledEntity is MyPrefabLargeWeapon)
                {
                    entityToCheck = (MyGuiScreenGamePlay.Static.ControlledEntity as MyPrefabLargeWeapon).GetGun();
                }
                else
                {
                    entityToCheck = MyGuiScreenGamePlay.Static.ControlledEntity;
                }
                // TODO: Make proper test that source off projectile is player ship, testing ignore object is STUPID!
                if (m_ammoProperties.AllowAimCorrection && (ignoreEntity == entityToCheck)) // Autoaim only available for player
                {
                    MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Projectile.Start autoaim generic");
                    //Intersection ignores children of "ignoreEntity", thus we must not hit our own barrels
                    correctedDirection = MyEntities.GetDirectionFromStartPointToHitPointOfNearestObject(ignoreEntity, origin, m_ammoProperties.MaxTrajectory);
                    MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                }
            }

            if (correctedDirection != null)
            {
                m_directionNormalized = correctedDirection.Value;
            }
            else
            {
                m_directionNormalized = directionNormalized;
            }

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

           
            m_thicknessMultiplier = thicknessMultiplier;

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

            if (groupStart)
            {
                m_trailEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Trail_Shotgun);
                m_trailEffect.AutoDelete = false;
                m_trailEffect.WorldMatrix = Matrix.CreateTranslation(m_position);
            }

            if (groupStart)
            {
                LastProjectileGroup = m_ownGroup;
                m_ownGroup.Killed = false;
            }

            if (LastProjectileGroup != null && LastProjectileGroup.Killed == false)
            {
                m_sharedGroup = LastProjectileGroup;
            }
            else
                m_sharedGroup = null;

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }
예제 #9
0
 internal static MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum FindAmmo(MyAmmoProperties ammoProperties)
 {
     for (int i = 0; i < m_ammoProperties.Length; i++)
     {
         if (m_ammoProperties[i] == ammoProperties)
         {
             return (MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum)i;
         }
     }
     return MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic;
 }
예제 #10
0
        protected void AddProjectile(MyAmmoProperties ammoProperties, MyEntity weapon)
        {
            Vector3 projectileForwardVector = GetDeviatedVector(ammoProperties);

            MyProjectiles.Add(ammoProperties, Parent, m_positionMuzzleInWorldSpace, Parent.Physics.LinearVelocity, projectileForwardVector, false, 1.0f, weapon);
        }