// 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; } }
public static void AddShrapnel(MyProjectileAmmoDefinition ammoDefinition, MyEntity ignoreEntity, 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, ignoreEntity, origin, initialVelocity, directionNormalized, weapon ); newProjectile.OwnerEntity = ownerEntity != null ? ownerEntity : ignoreEntity; }
// 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; }
// 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; 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(); }
// 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(); }
static MyExplosion() { // Hardcoded -> so far we dont want to let players modify the values SHRAPNEL_DATA = new MyProjectileAmmoDefinition(); SHRAPNEL_DATA.DesiredSpeed = 100; SHRAPNEL_DATA.SpeedVar = 0; SHRAPNEL_DATA.MaxTrajectory = 1000; SHRAPNEL_DATA.ProjectileHitImpulse = 10.0f; SHRAPNEL_DATA.ProjectileMassDamage = 10; SHRAPNEL_DATA.ProjectileHealthDamage = 10; SHRAPNEL_DATA.ProjectileTrailColor = MyProjectilesConstants.GetProjectileTrailColorByType(MyAmmoType.HighSpeed); SHRAPNEL_DATA.AmmoType = MyAmmoType.HighSpeed; SHRAPNEL_DATA.ProjectileTrailScale = 0.1f; SHRAPNEL_DATA.ProjectileOnHitEffectName = "Hit_BasicAmmoSmall"; }
static MyExplosion() { // Hardcoded -> so far we dont want to let players modify the values SHRAPNEL_DATA = new MyProjectileAmmoDefinition(); SHRAPNEL_DATA.DesiredSpeed = 100; SHRAPNEL_DATA.SpeedVar = 0; SHRAPNEL_DATA.MaxTrajectory = 1000; SHRAPNEL_DATA.ProjectileHitImpulse = 10.0f; SHRAPNEL_DATA.ProjectileMassDamage = 10; SHRAPNEL_DATA.ProjectileHealthDamage = 10; SHRAPNEL_DATA.ProjectileTrailColor = MyProjectilesConstants.GetProjectileTrailColorByType(MyAmmoType.HighSpeed); SHRAPNEL_DATA.AmmoType = MyAmmoType.HighSpeed; SHRAPNEL_DATA.ProjectileTrailScale = 0.1f; SHRAPNEL_DATA.ProjectileOnHitMaterialParticles = MyParticleEffects.GetCustomHitMaterialMethodById((int)MyCustomHitMaterialMethodType.Small); SHRAPNEL_DATA.ProjectileOnHitParticles = MyParticleEffects.GetCustomHitParticlesMethodById((int)MyCustomHitParticlesMethodType.BasicSmall); }