// Create smoke and debris particle at the place of voxel/model hit static void CreateBasicHitParticles(ref Vector3 hitPoint, ref Vector3 normal, ref Vector3 direction, MyEntity physObject, MyEntity weapon, MyEntity ownerEntity = null) { Vector3 reflectedDirection = Vector3.Reflect(direction, normal); MyUtilRandomVector3ByDeviatingVector randomVector = new MyUtilRandomVector3ByDeviatingVector(reflectedDirection); if (MyCamera.GetDistanceWithFOV(hitPoint) < 200) { MyParticleEffect effect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Hit_BasicAmmo); Matrix dirMatrix = MyMath.MatrixFromDir(reflectedDirection); effect.WorldMatrix = Matrix.CreateWorld(hitPoint, dirMatrix.Forward, dirMatrix.Up); } }
// One-time call public static Vector3 GetRandom(Vector3 originalVector, float maxAngle) { MyUtilRandomVector3ByDeviatingVector rnd = new MyUtilRandomVector3ByDeviatingVector(originalVector); return rnd.GetNext(maxAngle); }
// One-time call public static Vector3 GetRandom(Vector3 originalVector, float maxAngle) { MyUtilRandomVector3ByDeviatingVector rnd = new MyUtilRandomVector3ByDeviatingVector(originalVector); return(rnd.GetNext(maxAngle)); }
// Create smoke and debris particle at the place of voxel/model hit static void CreateEMPHitParticles(ref Vector3 hitPoint, ref Vector3 normal, ref Vector3 direction, MyEntity physObject, MyEntity weapon, MyEntity ownerEntity = null) { Vector3 reflectedDirection = Vector3.Reflect(direction, normal); MyUtilRandomVector3ByDeviatingVector randomVector = new MyUtilRandomVector3ByDeviatingVector(reflectedDirection); MyParticleEffect effect = GetEffectForWeapon(weapon, (int)MyParticleEffectsIDEnum.Hit_EMPAmmo); Matrix dirMatrix = MyMath.MatrixFromDir(reflectedDirection); effect.WorldMatrix = Matrix.CreateWorld(hitPoint, dirMatrix.Forward, dirMatrix.Up); }
// Create smoke and debris particle at the place of voxel/model hit from explosive projectil static void CreateExplosiveHitParticles(ref Vector3 hitPoint, ref Vector3 normal, ref Vector3 direction, MyEntity physObject, MyEntity weapon, MyEntity ownerEntity = null) { if (MyMwcUtils.GetRandomFloat(0.0f, 1.0f) > MyShotgunConstants.EXPLOSIVE_PROJECTILE_RELIABILITY) { //this projectile failed to explode Vector3 reflectedDirection = Vector3.Reflect(direction, normal); MyUtilRandomVector3ByDeviatingVector randomVector = new MyUtilRandomVector3ByDeviatingVector(reflectedDirection); MyParticleEffect effect = GetEffectForWeapon(weapon, (int)MyParticleEffectsIDEnum.Hit_ExplosiveAmmo); Matrix dirMatrix = MyMath.MatrixFromDir(reflectedDirection); effect.WorldMatrix = Matrix.CreateWorld(hitPoint, dirMatrix.Forward, dirMatrix.Up); } else { //this projectile exploded MyExplosion newExplosion = MyExplosions.AddExplosion(); if (newExplosion != null) { float radius = MyMwcUtils.GetRandomFloat(5, 20); newExplosion.Start(0, 0, 0, MyExplosionTypeEnum.AMMO_EXPLOSION, new BoundingSphere(hitPoint, radius), 1, MyExplosionForceDirection.EXPLOSION, MyGroupMask.Empty, false,ownerEntity: ownerEntity, hitEntity: physObject); } } }