Skip to content

Commit

Permalink
Impulse for projectiles
Browse files Browse the repository at this point in the history
  • Loading branch information
ari-steas committed Jan 7, 2024
1 parent 2b41d57 commit 372bf75
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ private void m_GridDamageHandler(IMyCubeGrid Entity, DamageEvent DamageEvent)
Vector3I? HitPos = Entity.RayCastBlocks(DamageEvent.Projectile.Position, DamageEvent.Projectile.NextMoveStep);
if (HitPos != null)
{
Entity.Physics.ApplyImpulse(DamageEvent.Projectile.Direction * DamageEvent.Projectile.Definition.Ungrouped.Impulse, DamageEvent.Projectile.Position);

IMySlimBlock block = Entity.GetCubeBlock(HitPos.Value);
float damageMult = block.FatBlock == null ? DamageEvent.Projectile.Definition.Damage.SlimBlockDamageMod : DamageEvent.Projectile.Definition.Damage.FatBlockDamageMod;

Expand All @@ -77,8 +79,9 @@ private void m_GridDamageHandler(IMyCubeGrid Entity, DamageEvent DamageEvent)

foreach (var ablock in AoEBlocks)
{
float distMult = Vector3.Distance(ablock.Position, block.Position) / DamageEvent.Projectile.Definition.Damage.AreaRadius; // Do less damage at max radius
damageMult = ablock.FatBlock == null ? DamageEvent.Projectile.Definition.Damage.SlimBlockDamageMod : DamageEvent.Projectile.Definition.Damage.FatBlockDamageMod;
ablock.DoDamage(DamageEvent.Projectile.Definition.Damage.AreaDamage * damageMult, MyDamageType.Explosion, MyAPIGateway.Utilities.IsDedicated);
ablock.DoDamage(DamageEvent.Projectile.Definition.Damage.AreaDamage * damageMult * distMult, MyDamageType.Explosion, MyAPIGateway.Utilities.IsDedicated);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class ProjectileDefinitionManager
ReloadPowerUsage = 0,
Length = 1,
Recoil = 0,
Impulse = 0,
Impulse = 1000,
},
Damage = new Damage()
{
Expand Down

0 comments on commit 372bf75

Please sign in to comment.