public static bool Impact(Bullet __instance, Thing hitThing) { Quaternion ExactRotation = Quaternion.LookRotation((Projectile_Patch.destination(__instance) - Projectile_Patch.origin(__instance)).Yto0()); Map map = __instance.Map; IntVec3 position = __instance.Position; Projectile_Patch.Base_Impact(__instance, hitThing); BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(Projectile_Patch.launcher(__instance), hitThing, __instance.intendedTarget.Thing, Projectile_Patch.equipmentDef(__instance), __instance.def, Projectile_Patch.targetCoverDef(__instance)); Find.BattleLog.Add(battleLogEntry_RangedImpact); NotifyImpact(__instance, hitThing, map, position); if (hitThing != null) { DamageInfo dinfo = new DamageInfo(__instance.def.projectile.damageDef, __instance.DamageAmount, __instance.ArmorPenetration, ExactRotation.eulerAngles.y, Projectile_Patch.launcher(__instance), null, Projectile_Patch.equipmentDef(__instance), DamageInfo.SourceCategory.ThingOrUnknown, __instance.intendedTarget.Thing); hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact); Pawn pawn = hitThing as Pawn; if (pawn != null && pawn.stances != null && pawn.BodySize <= __instance.def.projectile.StoppingPower + 0.001f) { pawn.stances.StaggerFor(95); } if (__instance.def.projectile.extraDamages != null) { foreach (ExtraDamage extraDamage in __instance.def.projectile.extraDamages) { if (Rand.Chance(extraDamage.chance)) { DamageInfo dinfo2 = new DamageInfo(extraDamage.def, extraDamage.amount, extraDamage.AdjustedArmorPenetration(), ExactRotation.eulerAngles.y, Projectile_Patch.launcher(__instance), null, Projectile_Patch.equipmentDef(__instance), DamageInfo.SourceCategory.ThingOrUnknown, __instance.intendedTarget.Thing); hitThing.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_RangedImpact); } } } } else { float StartingTicksToImpact = (Projectile_Patch.origin(__instance) - Projectile_Patch.destination(__instance)).magnitude / __instance.def.projectile.SpeedTilesPerTick; if (StartingTicksToImpact <= 0f) { StartingTicksToImpact = 0.001f; } float DistanceCoveredFraction = Mathf.Clamp01(1f - (float)(Projectile_Patch.ticksToImpact(__instance)) / StartingTicksToImpact); Vector3 b = (Projectile_Patch.destination(__instance) - Projectile_Patch.origin(__instance)).Yto0() * DistanceCoveredFraction; Vector3 ExactPosition = Projectile_Patch.origin(__instance).Yto0() + b + Vector3.up * __instance.def.Altitude; SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(__instance.Position, map)); if (__instance.Position.GetTerrain(map).takeSplashes) { MoteMaker.MakeWaterSplash(ExactPosition, map, Mathf.Sqrt(__instance.DamageAmount) * 1f, 4f); } else { MoteMaker.MakeStaticMote(ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt); } } return(false); }
public static bool Impact(Projectile_DoomsdayRocket __instance, Thing hitThing) { Map map = __instance.Map; Projectile_Patch.Base_Impact(__instance, hitThing); GenExplosion.DoExplosion(__instance.Position, map, __instance.def.projectile.explosionRadius, DamageDefOf.Bomb, Projectile_Patch.launcher(__instance), __instance.DamageAmount, __instance.ArmorPenetration, null, Projectile_Patch.equipmentDef(__instance), __instance.def, postExplosionSpawnThingDef: ThingDefOf.Filth_Fuel, intendedTarget: __instance.intendedTarget.Thing, postExplosionSpawnChance: 0.2f, postExplosionSpawnThingCount: 1, applyDamageToExplosionCellsNeighbors: false, preExplosionSpawnThingDef: null, preExplosionSpawnChance: 0f, preExplosionSpawnThingCount: 1, chanceToStartFire: 0.4f); CellRect cellRect = CellRect.CenteredOn(__instance.Position, 5); cellRect.ClipInsideMap(map); for (int i = 0; i < 3; i++) { IntVec3 randomCell = cellRect.RandomCell; DoFireExplosion(__instance, randomCell, map, 3.9f); } return(false); }
private static void DoFireExplosion(Projectile_DoomsdayRocket __instance, IntVec3 pos, Map map, float radius) { GenExplosion.DoExplosion(pos, map, radius, DamageDefOf.Flame, Projectile_Patch.launcher(__instance), __instance.DamageAmount, __instance.ArmorPenetration, null, Projectile_Patch.equipmentDef(__instance), __instance.def, __instance.intendedTarget.Thing); }
public static bool Explode(Projectile_Explosive __instance) { Map map = __instance.Map; __instance.Destroy(); if (__instance.def.projectile.explosionEffect != null) { Effecter effecter = __instance.def.projectile.explosionEffect.Spawn(); effecter.Trigger(new TargetInfo(__instance.Position, map), new TargetInfo(__instance.Position, map)); effecter.Cleanup(); } GenExplosion.DoExplosion(__instance.Position, map, __instance.def.projectile.explosionRadius, __instance.def.projectile.damageDef, Projectile_Patch.launcher(__instance), __instance.DamageAmount, __instance.ArmorPenetration, __instance.def.projectile.soundExplode, Projectile_Patch.equipmentDef(__instance), __instance.def, __instance.intendedTarget.Thing, __instance.def.projectile.postExplosionSpawnThingDef, __instance.def.projectile.postExplosionSpawnChance, __instance.def.projectile.postExplosionSpawnThingCount, preExplosionSpawnThingDef: __instance.def.projectile.preExplosionSpawnThingDef, preExplosionSpawnChance: __instance.def.projectile.preExplosionSpawnChance, preExplosionSpawnThingCount: __instance.def.projectile.preExplosionSpawnThingCount, applyDamageToExplosionCellsNeighbors: __instance.def.projectile.applyDamageToExplosionCellsNeighbors, chanceToStartFire: __instance.def.projectile.explosionChanceToStartFire, damageFalloff: __instance.def.projectile.explosionDamageFalloff, direction: Projectile_Patch.origin(__instance).AngleToFlat(Projectile_Patch.destination(__instance))); return(false); }