Example #1
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(base.launcher, hitThing, base.intendedTarget, base.equipmentDef, base.def);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            if (hitThing != null)
            {
                int        damageAmountBase = base.def.projectile.damageAmountBase;
                DamageDef  damageDef        = base.def.projectile.damageDef;
                int        amount           = damageAmountBase;
                Vector3    eulerAngles      = this.ExactRotation.eulerAngles;
                float      y            = eulerAngles.y;
                Thing      launcher     = base.launcher;
                ThingDef   equipmentDef = base.equipmentDef;
                DamageInfo dinfo        = new DamageInfo(damageDef, amount, y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown);
                hitThing.TakeDamage(dinfo).InsertIntoLog(battleLogEntry_RangedImpact);
            }
            else
            {
                SoundDefOf.BulletImpactGround.PlayOneShot(new TargetInfo(base.Position, map, false));
                MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
                if (base.Position.GetTerrain(map).takeSplashes)
                {
                    MoteMaker.MakeWaterSplash(this.ExactPosition, map, (float)(Mathf.Sqrt((float)base.def.projectile.damageAmountBase) * 1.0), 4f);
                }
            }
        }
Example #2
0
        protected virtual void ImpactDirectly(Thing hitThing, Map map)
        {
            base.Impact(hitThing);

            BattleLogEntry_RangedImpact entry = new BattleLogEntry_RangedImpact(base.launcher, hitThing, this.intendedTarget.Thing, base.equipmentDef, base.def, base.targetCoverDef);

            Find.BattleLog.Add(entry);
            if (hitThing != null)
            {
                int        damageAmount     = base.DamageAmount;
                DamageDef  damageDef        = base.def.projectile.damageDef;
                float      y                = this.ExactRotation.eulerAngles.y;
                float      armorPenetration = base.ArmorPenetration;
                Thing      launcher         = base.launcher;
                ThingDef   equipmentDef     = base.equipmentDef;
                DamageInfo dinfo            = new DamageInfo(damageDef, damageAmount, armorPenetration, y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(entry);
            }
            else
            {
                SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false));
                MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
                if (base.Position.GetTerrain(map).takeSplashes)
                {
                    MoteMaker.MakeWaterSplash(this.ExactPosition, map, (float)(Mathf.Sqrt((float)base.DamageAmount) * 1.0), 4f);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Impacts a pawn/object or the ground.
        /// </summary>
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact =
                new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget, this.equipmentDef,
                                                this.def);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            if (hitThing != null)
            {
                var damageAmountBase = this.def.projectile.damageAmountBase;
                var damageDef        = this.def.projectile.damageDef;
                var amount           = damageAmountBase;
                var y     = this.ExactRotation.eulerAngles.y;
                var dinfo = new DamageInfo(damageDef, amount, y, launcher, null, equipmentDef,
                                           DamageInfo.SourceCategory.ThingOrUnknown);
                hitThing.TakeDamage(dinfo).InsertIntoLog(battleLogEntry_RangedImpact);
                if (compED != null && hitThing is Pawn pawn && !pawn.Downed && Rand.Value < compED.chanceToProc)
                {
                    GuassImpact(hitThing);
                }
            }
            else
            {
                SoundDefOf.BulletImpactGround.PlayOneShot(new TargetInfo(base.Position, map, false));
                MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
                if (base.Position.GetTerrain(map).takeSplashes)
                {
                    MoteMaker.MakeWaterSplash(this.ExactPosition, map,
                                              Mathf.Sqrt((float)this.def.projectile.damageAmountBase) * 1f, 4f);
                }
            }
        }
Example #4
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget.Thing, this.equipmentDef, this.def, this.targetCoverDef);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            if (hitThing != null)
            {
                DamageDef  damageDef        = this.def.projectile.damageDef;
                float      amount           = (float)base.DamageAmount;
                float      armorPenetration = base.ArmorPenetration;
                float      y            = this.ExactRotation.eulerAngles.y;
                Thing      launcher     = this.launcher;
                ThingDef   equipmentDef = this.equipmentDef;
                DamageInfo dinfo        = new DamageInfo(damageDef, amount, armorPenetration, y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                Pawn pawn = hitThing as Pawn;
            }
            else
            {
                SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false));
                MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
            }
        }
Example #5
0
        // Token: 0x0600002C RID: 44 RVA: 0x000032BC File Offset: 0x000014BC
        protected virtual void ImpactDirectly(Thing hitThing, Map map)
        {
            base.Impact(hitThing);
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget.Thing, this.equipmentDef, this.def, this.targetCoverDef);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            bool flag = hitThing != null;

            if (flag)
            {
                int        damageAmountBase = this.def.projectile.GetDamageAmount(this.launcher);
                DamageDef  damageDef        = this.def.projectile.damageDef;
                float      y            = this.ExactRotation.eulerAngles.y;
                Thing      launcher     = this.launcher;
                ThingDef   equipmentDef = this.equipmentDef;
                DamageInfo damageInfo   = new DamageInfo(damageDef, damageAmountBase, 0, y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown);
                hitThing.TakeDamage(damageInfo).AssociateWithLog(battleLogEntry_RangedImpact);
            }
            else
            {
                SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false));
                MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
                bool takeSplashes = base.Position.GetTerrain(map).takeSplashes;
                if (takeSplashes)
                {
                    MoteMaker.MakeWaterSplash(this.ExactPosition, map, (float)((double)Mathf.Sqrt((float)this.def.projectile.GetDamageAmount(this.launcher)) * 1.0), 4f);
                }
            }
        }
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget.Thing, this.equipmentDef, this.def, this.targetCoverDef);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            if (hitThing != null)
            {
                DamageDef  damageDef        = this.def.projectile.damageDef;
                float      amount           = (float)base.DamageAmount;
                float      armorPenetration = base.ArmorPenetration;
                float      y            = this.ExactRotation.eulerAngles.y;
                Thing      launcher     = this.launcher;
                ThingDef   equipmentDef = this.equipmentDef;
                DamageInfo dinfo        = new DamageInfo(damageDef, amount, armorPenetration, y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                Pawn pawn = hitThing as Pawn;
                if (pawn != null && pawn.stances != null && pawn.BodySize <= this.def.projectile.StoppingPower + 0.001f)
                {
                    pawn.stances.StaggerFor(95);
                }
            }
            else
            {
                SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false));
                MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
                if (base.Position.GetTerrain(map).takeSplashes)
                {
                    MoteMaker.MakeWaterSplash(this.ExactPosition, map, Mathf.Sqrt((float)base.DamageAmount) * 1f, 4f);
                }
            }
        }
        protected override void Impact(Thing hitThing)
        {
            if (hitThing is not Pawn p)
            {
                return;
            }

            var harmType = canBeHarm(p);


            if (harmType == 1)
            {
                var entry = new BattleLogEntry_RangedImpact(launcher, hitThing, intendedTarget.Thing,
                                                            equipmentDef, def, targetCoverDef);
                Find.BattleLog.Add(entry);

                var damageAmountBase = DamageAmount / 3;
                var damageDef        = def.projectile.damageDef;
                var y          = ExactRotation.eulerAngles.y;
                var instigator = launcher;
                var thingDef   = equipmentDef;
                var dinfo      = new DamageInfo(damageDef, damageAmountBase, ArmorPenetration, y, instigator, null,
                                                thingDef, DamageInfo.SourceCategory.ThingOrUnknown, intendedTarget.Thing);


                hitThing.TakeDamage(dinfo).AssociateWithLog(entry);
            }
            else
            {
                base.Impact(hitThing);
            }
        }
Example #8
0
        protected override void Impact(Thing hitThing)
        {
            if (hitThing != null)
            {
                Pawn p = hitThing as Pawn;
                if (p != null)
                {
                    int harmType = canBeHarm(p);


                    if (harmType == 1)
                    {
                        BattleLogEntry_RangedImpact entry = new BattleLogEntry_RangedImpact(base.launcher, hitThing, this.intendedTarget.Thing, base.equipmentDef, base.def, base.targetCoverDef);
                        Find.BattleLog.Add(entry);

                        int        damageAmountBase = base.DamageAmount / 3;
                        DamageDef  damageDef        = base.def.projectile.damageDef;
                        float      y            = this.ExactRotation.eulerAngles.y;
                        Thing      launcher     = base.launcher;
                        ThingDef   equipmentDef = base.equipmentDef;
                        DamageInfo dinfo        = new DamageInfo(damageDef, damageAmountBase, base.ArmorPenetration, y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);



                        hitThing.TakeDamage(dinfo).AssociateWithLog(entry);
                        return;
                    }
                    else
                    {
                        base.Impact(hitThing);
                    }
                }
            }
        }
Example #9
0
        protected override void Impact(Thing hitThing)
        {
            var map = Map;     // before Impact!

            base.Impact(hitThing);

            var impact = new BattleLogEntry_RangedImpact(launcher, hitThing, intendedTarget.Thing, equipmentDef, def, targetCoverDef);

            Find.BattleLog.Add(impact);

            if (hitThing != null)
            {
                var dinfo = new DamageInfo(def.projectile.damageDef, DamageAmount, armorPenetration: ArmorPenetration, angle: ExactRotation.eulerAngles.y, instigator: launcher, weapon: equipmentDef, intendedTarget: intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(impact);

                var hitPawn = hitThing as Pawn;
                if (hitPawn != null && hitPawn.stances != null && hitPawn.BodySize <= def.projectile.StoppingPower + 0.001f)
                {
                    hitPawn.stances.StaggerFor(Pawn_StanceTracker.StaggerBulletImpactTicks);
                }
            }
            else
            {
                SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(Position, map));
                MoteMaker.MakeStaticMote(ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt);

                if (Position.GetTerrain(map).takeSplashes)
                {
                    MoteMaker.MakeWaterSplash(ExactPosition, map, Mathf.Sqrt(DamageAmount) * MoteSplash.SizeGunfire, MoteSplash.VelocityGunfire);
                }
            }
        }
Example #10
0
        protected override void Impact(Thing hitThing)
        {
            Map map = Map;
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget.Thing, this.equipmentDef, this.def, this.targetCoverDef);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            if (hitThing != null)
            {
                DamageDef  damageDef        = def.projectile.damageDef;
                float      amount           = DamageAmount;
                float      armorPenetration = ArmorPenetration;
                float      y            = ExactRotation.eulerAngles.y;
                Thing      launcher     = this.launcher;
                ThingDef   equipmentDef = this.equipmentDef;
                DamageInfo dinfo        = new DamageInfo(damageDef, amount, armorPenetration, y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                Pawn pawn = hitThing as Pawn;
                if (pawn != null && pawn.stances != null && pawn.BodySize <= def.projectile.StoppingPower + 0.001f)
                {
                    pawn.stances.StaggerFor(95);
                }
                RKSoundDefOf.Ballista_Impact.PlayOneShot(new TargetInfo(hitThing.Position, map, false));
                FilthMaker.TryMakeFilth(Position, map, ThingDefOf.Filth_Blood, 4);
            }
            else
            {
                MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_Bombardment, 1f);
                if (Position.GetTerrain(map).takeSplashes)
                {
                    MoteMaker.MakeBombardmentMote(this.DestinationCell, map, 4f);
                }
            }
            Explode();
        }
Example #11
0
        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);
        }
Example #12
0
        protected virtual void ImpactDirectly(Thing hitThing, Map map)
        {
            base.Impact(hitThing);

            var entry = new BattleLogEntry_RangedImpact(launcher, hitThing, intendedTarget.Thing,
                                                        equipmentDef, def, targetCoverDef);

            Find.BattleLog.Add(entry);
            if (hitThing != null)
            {
                var damageAmount     = DamageAmount;
                var damageDef        = def.projectile.damageDef;
                var y                = ExactRotation.eulerAngles.y;
                var armorPenetration = ArmorPenetration;
                var instigator       = launcher;
                var thingDef         = equipmentDef;
                var dinfo            = new DamageInfo(damageDef, damageAmount, armorPenetration, y, instigator, null, thingDef,
                                                      DamageInfo.SourceCategory.ThingOrUnknown, intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(entry);
            }
            else
            {
                SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(Position, map));
                FleckMaker.Static(ExactPosition, map, FleckDefOf.ShotHit_Dirt);
                if (Position.GetTerrain(map).takeSplashes)
                {
                    FleckMaker.WaterSplash(ExactPosition, map, (float)(Mathf.Sqrt(DamageAmount) * 1.0), 4f);
                }
            }
        }
        protected override void Impact(Thing hitThing)
        {
            if (def.stopWhenHit && !stopped && !customImpact)
            {
                StopMotion();
            }
            if (hitThings == null)
            {
                hitThings = new List <Thing>();
            }
            if (this.def.dealsDamageOnce && hitThings.Contains(hitThing))
            {
                return;
            }
            hitThings.Add(hitThing);
            Map     map      = base.Map;
            IntVec3 position = base.Position;
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact;

            if (equipmentDef == null)
            {
                battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(launcher, hitThing, intendedTarget.Thing, ThingDef.Named("Gun_Autopistol"), def, targetCoverDef);
            }
            else
            {
                battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(launcher, hitThing, intendedTarget.Thing, equipmentDef, def, targetCoverDef);
            }
            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            this.NotifyImpact(hitThing, map, position);
            if (hitThing != null && (!def.disableVanillaDamageMethod || customImpact && def.disableVanillaDamageMethod))
            {
                DamageInfo dinfo = new DamageInfo(def.projectile.damageDef, this.DamageAmount, base.ArmorPenetration, ExactRotation.eulerAngles.y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                Pawn pawn = hitThing as Pawn;
                if (pawn != null && pawn.stances != null && pawn.BodySize <= def.projectile.StoppingPower + 0.001f)
                {
                    pawn.stances.StaggerFor(95);
                }
                if (def.projectile.extraDamages != null)
                {
                    foreach (ExtraDamage extraDamage in def.projectile.extraDamages)
                    {
                        if (Rand.Chance(extraDamage.chance))
                        {
                            DamageInfo dinfo2 = new DamageInfo(extraDamage.def, extraDamage.amount, extraDamage.AdjustedArmorPenetration(), ExactRotation.eulerAngles.y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, intendedTarget.Thing);
                            hitThing.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_RangedImpact);
                        }
                    }
                }

                if (this.def.stopWhenHitAt.Contains(hitThing.def.defName))
                {
                    if (!stopped)
                    {
                        StopMotion();
                    }
                }
            }
        }
Example #14
0
        protected override void Impact(Thing hitThing)
        {
            var oldValue = def.projectile.damageDef.isRanged; // all of this jazz is to make shield belt deflecting tesla projectiles

            def.projectile.damageDef.isRanged = true;
            base.Impact(hitThing);
            def.projectile.damageDef.isRanged = oldValue;

            if (this.mainLauncher == null)
            {
                this.mainLauncher = this.launcher;
            }

            if (equipmentDef == null)
            {
                equipmentDef = ThingDef.Named("Gun_Autopistol");
            }
            if (wasDeflected)
            {
                wasDeflected = false;
                if (Rand.Chance(0.3f))
                {
                    this.DestroyAll();
                }
                return;
            }
            if (hitThing == null && !shotAnything)
            {
                shotAnything = true;
            }
            else if (hitThing != null && !shotAnything)
            {
                BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(launcher, hitThing, intendedTarget.Thing, equipmentDef, def, targetCoverDef);
                Find.BattleLog.Add(battleLogEntry_RangedImpact);
                var dinfo = new DamageInfo(Props.damageDef, this.def.projectile.GetDamageAmount(1f), -1f, Holder.DrawPos.AngleToFlat(hitThing.DrawPos), this.Launcher);
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);

                if (Props.addFire && hitThing.TryGetComp <CompAttachBase>() != null)
                {
                    var fire = (Fire)GenSpawn.Spawn(ThingDefOf.Fire, hitThing.Position, hitThing.Map);
                    fire.AttachTo(hitThing);
                }
                if (Props.impactRadius > 0f)
                {
                    GenExplosion.DoExplosion(hitThing.Position, Map, Props.impactRadius, Props.explosionDamageDef, this.Launcher, this.def.projectile.GetDamageAmount(1f));
                }
                RegisterHit(hitThing);
                if (numBounces < Props.maxBounceCount)
                {
                    var target = NextTarget(hitThing);
                    if (target != null)
                    {
                        FireAt(target);
                    }
                }
                shotAnything = true;
            }
        }
        private void DoDamage(IntVec3 c, float damageFactor)
        {
            BTMExplosiveboulder.tmpThings.Clear();
            BTMExplosiveboulder.tmpThings.AddRange(c.GetThingList(base.Map));
            Vector3 vector = c.ToVector3Shifted();
            Vector2 b      = new Vector2(vector.x, vector.z);

            //float num = -this.realPosition.AngleTo(b) + 180f;
            for (int i = 0; i < BTMExplosiveboulder.tmpThings.Count; i++)
            {
                BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = null;
                switch (BTMExplosiveboulder.tmpThings[i].def.category)
                {
                case ThingCategory.Pawn:
                {
                    Pawn pawn = (Pawn)BTMExplosiveboulder.tmpThings[i];
                    battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact
                                                      (this.launcher, pawn, this.intendedTarget.Thing, this.equipmentDef, this.def, this.targetCoverDef);
                    Find.BattleLog.Add(battleLogEntry_RangedImpact);
                    if (pawn.RaceProps.baseHealthScale < 1f)
                    {
                        damageFactor *= pawn.RaceProps.baseHealthScale;
                    }
                    if (pawn.RaceProps.Animal)
                    {
                        damageFactor *= 0.75f;
                    }
                    if (pawn.Downed)
                    {
                        damageFactor *= 0.2f;
                    }
                    break;
                }

                case ThingCategory.Item:
                    damageFactor *= 0.68f;
                    break;

                case ThingCategory.Building:
                    damageFactor *= 0.8f;
                    break;

                case ThingCategory.Plant:
                    damageFactor *= 1.7f;
                    break;
                }
                //int amount = Mathf.Max(GenMath.RoundRandom(30f * damageFactor), 1);

                int   amount    = Mathf.RoundToInt(Mathf.Max(damageFactor, 5));
                Thing arg_184_0 = BTMExplosiveboulder.tmpThings[i];
                //Verse.Log.Message(amount.ToString() + "da", false);

                arg_184_0.TakeDamage(new DamageInfo(DamageDefOf.Crush, amount, this.ArmorPenetration, 0, launcher, null, this.def, DamageInfo.SourceCategory.ThingOrUnknown, null)).AssociateWithLog(battleLogEntry_RangedImpact);
            }
            BTMExplosiveboulder.tmpThings.Clear();
        }
        private static void LogImpact(ProjectileCE __instance, Thing launcher, ThingDef equipmentDef, Thing hitThing, out LogEntry_DamageResult logEntry)
        {
            logEntry = new BattleLogEntry_RangedImpact(launcher, hitThing, __instance.intendedTarget.Thing, equipmentDef, __instance.def, null);
            bool flag = !(launcher is AmmoThing);

            if (flag)
            {
                Find.BattleLog.Add(logEntry);
            }
        }
Example #17
0
        protected override void Impact(Thing hitThing)
        {
            var map      = base.Map;
            var position = base.Position;

            GenClamor.DoClamor(this, 2.1f, ClamorDefOf.Impact);
            FleckMaker.Static(position, Map, DefDatabase <FleckDef> .GetNamed("BlastFlame"), 2);
            SoundDef.Named("Explosion_Bomb").PlayOneShot(new TargetInfo(base.Position, base.Map, false));

            this.Destroy(DestroyMode.Vanish);
            var battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget.Thing, this.equipmentDef, this.def, this.targetCoverDef);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            this.NotifyImpact(hitThing, map, position);
            if (hitThing != null)
            {
                var dinfo = new DamageInfo(this.def.projectile.damageDef, (float)base.DamageAmount, base.ArmorPenetration, this.ExactRotation.eulerAngles.y, this.launcher, null, this.equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                var pawn  = hitThing as Pawn;
                if (pawn != null)
                {
                    var mult = pawn.BodySize <= 1 ? 1 : pawn.BodySize * 2.5f;
                    dinfo.SetAmount(dinfo.Amount * mult);
                }
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                if (pawn != null && pawn.stances != null && pawn.BodySize <= this.def.projectile.StoppingPower + 0.001f)
                {
                    pawn.stances.StaggerFor(95);
                }
                if (this.def.projectile.extraDamages == null)
                {
                    return;
                }
                using (List <ExtraDamage> .Enumerator enumerator = this.def.projectile.extraDamages.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ExtraDamage extraDamage = enumerator.Current;
                        if (Rand.Chance(extraDamage.chance))
                        {
                            var dinfo2 = new DamageInfo(extraDamage.def, extraDamage.amount, extraDamage.AdjustedArmorPenetration(), this.ExactRotation.eulerAngles.y, this.launcher, null, this.equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                            hitThing.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_RangedImpact);
                        }
                    }
                    return;
                }
            }
            SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false));
            if (base.Position.GetTerrain(map).takeSplashes)
            {
                FleckMaker.WaterSplash(this.ExactPosition, map, Mathf.Sqrt((float)base.DamageAmount) * 1f, 4f);
                return;
            }
            FleckMaker.Static(this.ExactPosition, map, FleckDefOf.ShotHit_Dirt, 1f);
        }
Example #18
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget.Thing, ThingDef.Named("Gun_Autopistol"), this.def, this.targetCoverDef);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            if (hitThing != null)
            {
                DamageDef  damageDef        = this.def.projectile.damageDef;
                float      amount           = (float)base.DamageAmount;
                float      armorPenetration = base.ArmorPenetration;
                float      y            = this.ExactRotation.eulerAngles.y;
                Thing      launcher     = this.launcher;
                ThingDef   equipmentDef = this.equipmentDef;
                DamageInfo dinfo        = new DamageInfo(damageDef, amount, armorPenetration, y, launcher, null, null, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                Pawn pawn = hitThing as Pawn;
                if (pawn != null && pawn.stances != null && pawn.BodySize <= this.def.projectile.StoppingPower + 0.001f)
                {
                    pawn.stances.StaggerFor(95);
                }
                if (this.def.defName == "AA_FrostWeb")
                {
                    DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Frostbite, amount / 2, armorPenetration, y, launcher, null, null, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                    hitThing.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_RangedImpact);
                }
                if (this.def.defName == "AA_FireWeb")
                {
                    DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Burn, amount / 2, armorPenetration, y, launcher, null, null, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                    hitThing.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_RangedImpact);
                }
                if (this.def.defName == "AA_AcidicWeb")
                {
                    DamageInfo dinfo2 = new DamageInfo(DefDatabase <DamageDef> .GetNamed("AA_AcidSpit", true), amount / 2, armorPenetration, y, launcher, null, null, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                    hitThing.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_RangedImpact);
                }
                if (this.def.defName == "AA_ExplodingWeb")
                {
                    DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Bomb, amount / 2, armorPenetration, y, launcher, null, null, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                    hitThing.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_RangedImpact);
                }
            }
            else
            {
                SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false));
                FleckMaker.Static(this.ExactPosition, map, FleckDefOf.ShotHit_Dirt, 1f);
                if (base.Position.GetTerrain(map).takeSplashes)
                {
                    FleckMaker.WaterSplash(this.ExactPosition, map, Mathf.Sqrt((float)base.DamageAmount) * 1f, 4f);
                }
            }
        }
Example #19
0
        private void DoDamage(IntVec3 c, float damageFactor)
        {
            tmpThings.Clear();
            tmpThings.AddRange(c.GetThingList(base.Map));
            Vector3 vector = c.ToVector3Shifted();
            Vector2 b      = new Vector2(vector.x, vector.z);
            float   angle  = -new Vector2(this.DrawPos.z, this.DrawPos.y).AngleTo(b) + 180f;

            for (int i = 0; i < tmpThings.Count; i++)
            {
                BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = null;
                switch (tmpThings[i].def.category)
                {
                case ThingCategory.Pawn:
                {
                    Pawn pawn = (Pawn)tmpThings[i];
                    battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, pawn, this.intendedTarget.Thing, this.equipmentDef, this.def, this.targetCoverDef);
                    Find.BattleLog.Add(battleLogEntry_RangedImpact);
                    if (pawn.RaceProps.baseHealthScale < 1f)
                    {
                        damageFactor *= pawn.RaceProps.baseHealthScale;
                    }
                    damageFactor += pawn.BodySize;

                    /*
                     * if (pawn.RaceProps.Animal)
                     * {
                     *      damageFactor *= AnimalPawnDamageFactor;
                     * }
                     * if (pawn.Downed)
                     * {
                     *      damageFactor *= DownedPawnDamageFactor;
                     * }
                     */
                    break;
                }

                case ThingCategory.Item:
                    damageFactor *= tmpThings[i].GetStatValue(StatDefOf.Mass);
                    break;

                case ThingCategory.Building:
                    damageFactor *= 1f;
                    break;

                case ThingCategory.Plant:
                    damageFactor *= 1f;
                    break;
                }
                int num = Mathf.Max(GenMath.RoundRandom(30f * damageFactor), 1);
                tmpThings[i].TakeDamage(new DamageInfo(DamageDefOf.TornadoScratch, (float)num, 0f, angle, this, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null)).AssociateWithLog(battleLogEntry_RangedImpact);
            }
            tmpThings.Clear();
        }
Example #20
0
        /// <summary>
        /// Impacts a pawn/object or the ground.
        /// </summary>
        protected override void Impact(Thing hitThing)
        {
            if (hitThing != null)
            {
                Map map = base.Map;
                BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher,
                                                                                                          hitThing, this.intendedTarget.Thing, this.equipmentDef, this.def, this.targetCoverDef);
                Find.BattleLog.Add(battleLogEntry_RangedImpact);
                if (hitThing != null)
                {
                    int        damageAmountBase = this.def.projectile.GetDamageAmount(this.launcher);
                    DamageDef  damageDef        = this.def.projectile.damageDef;
                    int        amount           = damageAmountBase;
                    float      y            = this.ExactRotation.eulerAngles.y;
                    Thing      launcher     = this.launcher;
                    ThingDef   equipmentDef = this.equipmentDef;
                    DamageInfo dinfo        = new DamageInfo(damageDef, amount, this.ArmorPenetration, y, launcher, null, equipmentDef,
                                                             DamageInfo.SourceCategory.ThingOrUnknown);
                    hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                }
//                else
//                {
//                    SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false));
//                    MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
//                    if (base.Position.GetTerrain(map).takeSplashes)
//                    {
//                        MoteMaker.MakeWaterSplash(this.ExactPosition, map, Mathf.Sqrt((float)this.def.projectile.GetDamageAmount(this.launcher) * 1f, 4f);
//                    }
//                }
                //int damageAmountBase = this.def.projectile.DamageAmount;
                //DamageInfo dinfo = new DamageInfo(this.def.projectile.damageDef, damageAmountBase, this.ExactRotation.eulerAngles.y, this.launcher, null, equipmentDef);
                //hitThing.TakeDamage(dinfo);
                //hitThing.TakeDamage(dinfo);
                if (this.canStartFire && Rand.Range(0f, 1f) > startFireChance)
                {
                    hitThing.TryAttachFire(0.05f);
                }
                Pawn pawn = hitThing as Pawn;
                if (pawn != null)
                {
                    PostImpactEffects(this.launcher as Pawn, pawn);
                    MoteMaker.ThrowMicroSparks(this.destination, this.Map);
                    MoteMaker.MakeStaticMote(this.destination, this.Map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
                }
            }
            else
            {
                SoundInfo info = SoundInfo.InMap(new TargetInfo(base.Position, this.Map, false), MaintenanceType.None);
                SoundDefOf.BulletImpact_Ground.PlayOneShot(info);
                MoteMaker.MakeStaticMote(this.ExactPosition, this.Map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
                MoteMaker.ThrowMicroSparks(this.ExactPosition, this.Map);
            }
        }
Example #21
0
        private void LogImpact(Thing hitThing, out BattleLogEntry_RangedImpact logEntry)
        {
            logEntry =
                new BattleLogEntry_RangedImpact(
                    launcher,
                    hitThing,
                    intendedTarget,
                    equipmentDef,
                    def);

            Find.BattleLog.Add(logEntry);
        }
Example #22
0
        public override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            if (this.ticksToImpact <= 0)
            {
                base.Impact(hitThing);
            }
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget.Thing, this.equipmentDef, this.def, null);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            int damageAmount = this.def.projectile.GetDamageAmount(1f, null);

            if (hitThing != null)
            {
                DamageDefExtensionCE   damageDefExtensionCE   = this.def.projectile.damageDef.GetModExtension <DamageDefExtensionCE>() ?? new DamageDefExtensionCE();
                ProjectilePropertiesCE projectilePropertiesCE = (ProjectilePropertiesCE)this.def.projectile;
                DamageInfo             dinfo = new DamageInfo(this.def.projectile.damageDef, (float)damageAmount, (this.def.projectile.damageDef.armorCategory == DamageArmorCategoryDefOf.Sharp) ? projectilePropertiesCE.armorPenetrationSharp : projectilePropertiesCE.armorPenetrationBlunt, this.ExactRotation.eulerAngles.y, this.launcher, null, this.equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                Pawn pawn = hitThing as Pawn;
                if (pawn != null && pawn.stances != null && pawn.BodySize <= this.def.projectile.StoppingPower + 0.001f)
                {
                    pawn.stances.StaggerFor(95);
                }
                if (this.def.projectile.extraDamages == null)
                {
                    return;
                }
                using (List <ExtraDamage> .Enumerator enumerator = this.def.projectile.extraDamages.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ExtraDamage extraDamage = enumerator.Current;
                        Rand.PushState();
                        if (Rand.Chance(extraDamage.chance))
                        {
                            DamageInfo dinfo2 = new DamageInfo(extraDamage.def, extraDamage.amount, extraDamage.AdjustedArmorPenetration(), this.ExactRotation.eulerAngles.y, this.launcher, null, this.equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                            hitThing.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_RangedImpact);
                        }
                        Rand.PopState();
                    }
                    return;
                }
            }
            SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false));
            if (base.Position.GetTerrain(map).takeSplashes)
            {
                MoteMaker.MakeWaterSplash(this.ExactPosition, map, Mathf.Sqrt((float)damageAmount) * 1f, 4f);
                return;
            }
            MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
        }
Example #23
0
        private void GuassImpact(Thing hitThing)
        {
            var extraDamageDef = DefDatabase <DamageDef> .GetNamed(compED.damageDef, true);

            var extraDam = new DamageInfo(extraDamageDef,
                                          compED.damageAmount, this.ExactRotation.eulerAngles.y, this.launcher, null, null);
            var battleLogEntry_RangedImpactExtra =
                new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget, this.equipmentDef,
                                                this.def);

            MoteMaker.ThrowMicroSparks(this.destination, Map);
            Find.BattleLog.Add(battleLogEntry_RangedImpactExtra);
            hitThing.TakeDamage(extraDam).InsertIntoLog(battleLogEntry_RangedImpactExtra);
        }
Example #24
0
        // Token: 0x06002721 RID: 10017 RVA: 0x0012A314 File Offset: 0x00128714
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget.Thing, this.equipmentDef, this.def, this.targetCoverDef);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            if (this.timesBounced == 0)
            {
                this.OriginalPawn       = (Pawn)launcher;
                this.OriginalWeapon     = launcher;
                this.OriginalProjectile = this;
            }
            if (hitThing != null)
            {
                DamageDef  damageDef        = this.def.projectile.damageDef;
                float      amount           = (float)base.DamageAmount;
                float      armorPenetration = base.ArmorPenetration;
                float      y            = this.ExactRotation.eulerAngles.y;
                Thing      launcher     = this.launcher;
                ThingDef   equipmentDef = this.equipmentDef;
                DamageInfo dinfo        = new DamageInfo(damageDef, amount, armorPenetration, y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                if (hitThing is Pawn pawn && pawn.stances != null && pawn.BodySize <= this.def.projectile.StoppingPower + 0.001f)
                {
                    pawn.stances.StaggerFor(95);
                }
            }
            else
            {
                SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false));
                MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
                if (base.Position.GetTerrain(map).takeSplashes)
                {
                    MoteMaker.MakeWaterSplash(this.ExactPosition, map, Mathf.Sqrt((float)base.DamageAmount) * 1f, 4f);
                }
            }
            if (OriginalPawn != null)
            {
                if (OriginalPawn.kindDef.race != YautjaDefOf.RRY_Alien_Yautja && Rand.Chance(0.5f))
                {
                    ReturnDef = YautjaDefOf.RRY_SmartDisk_Thrown;
                }
                else
                {
                    ReturnDef = YautjaDefOf.RRY_SmartDisk_Returning;
                }
            }
            PostPostImpactEffects(hitThing);
            this.DeSpawn();
        }
        protected override void Impact(Thing hitThing)
        {
            if (!stopped && !customImpact)
            {
                stopped     = true;
                curPosition = this.DrawPos;
            }
            if (hitThings == null)
            {
                hitThings = new HashSet <Thing>();
            }
            if (this.def.dealsDamageOnce && hitThings.Contains(hitThing))
            {
                return;
            }
            hitThings.Add(hitThing);
            //if (!customImpact)
            //{
            //	GenSpawn.Spawn(ThingDefOf.MineableComponentsIndustrial, base.Position, this.Map);
            //}
            Map     map      = base.Map;
            IntVec3 position = base.Position;
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(launcher, hitThing, intendedTarget.Thing, equipmentDef, def, targetCoverDef);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            this.NotifyImpact(hitThing, map, position);
            if (hitThing != null && (!def.disableVanillaDamageMethod || customImpact && def.disableVanillaDamageMethod))
            {
                DamageInfo dinfo = new DamageInfo(def.projectile.damageDef, base.DamageAmount, base.ArmorPenetration, ExactRotation.eulerAngles.y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                Pawn pawn = hitThing as Pawn;
                if (pawn != null && pawn.stances != null && pawn.BodySize <= def.projectile.StoppingPower + 0.001f)
                {
                    pawn.stances.StaggerFor(95);
                }
                if (def.projectile.extraDamages != null)
                {
                    foreach (ExtraDamage extraDamage in def.projectile.extraDamages)
                    {
                        if (Rand.Chance(extraDamage.chance))
                        {
                            DamageInfo dinfo2 = new DamageInfo(extraDamage.def, extraDamage.amount, extraDamage.AdjustedArmorPenetration(), ExactRotation.eulerAngles.y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, intendedTarget.Thing);
                            hitThing.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_RangedImpact);
                        }
                    }
                }
            }
        }
Example #26
0
        protected override void Impact(Thing hitThing)
        {
            Map map = Map;
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, intendedTarget.Thing, this.equipmentDef, this.def, this.targetCoverDef);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            if (hitThing != null)
            {
                DamageDef  damageDef        = def.projectile.damageDef;
                float      amount           = DamageAmount - ((ProjectileProperties_BallistaBoltAP)def.projectile).damageReduceRate * currentPenetrationCount;
                float      armorPenetration = ArmorPenetration - ((ProjectileProperties_BallistaBoltAP)def.projectile).damageReduceRate * currentPenetrationCount;
                float      y            = ExactRotation.eulerAngles.y;
                Thing      launcher     = this.launcher;
                ThingDef   equipmentDef = this.equipmentDef;
                DamageInfo dinfo        = new DamageInfo(damageDef, amount, armorPenetration, y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                Pawn pawn = hitThing as Pawn;
                if (pawn != null)
                {
                    FilthMaker.TryMakeFilth(Position, map, ThingDefOf.Filth_Blood, 4);
                    RKSoundDefOf.Ballista_Impact.PlayOneShot(new TargetInfo(Position, map, false));
                    if (pawn.stances != null && pawn.BodySize <= def.projectile.StoppingPower + 0.001f)
                    {
                        pawn.stances.StaggerFor(95);
                    }
                }
                currentPenetrationCount++;
            }
            else
            {
                FleckMaker.Static(ExactPosition, map, FleckDefOf.ShotHit_Dirt, 1f);
                if (Position.GetTerrain(map).takeSplashes)
                {
                    FleckMaker.WaterSplash(ExactPosition, map, Mathf.Sqrt(DamageAmount) * 1f, 4f);
                }
            }
            if (currentPenetrationCount < ((ProjectileProperties_BallistaBoltAP)def.projectile).maxPenetrationCount)
            {
                if (hitThing != null && hitThing.def.category == ThingCategory.Building || ticksToImpact <= 0)
                {
                    Explode();
                }
            }
            else
            {
                base.Impact(hitThing);
            }
        }
Example #27
0
 private void LogImpact(Thing hitThing, out LogEntry_DamageResult logEntry)
 {
     logEntry =
         new BattleLogEntry_RangedImpact(
             launcher,
             hitThing,
             intendedTarget,
             equipmentDef,
             def,
             null //CoverDef Missing!
             );
     if (!(launcher is AmmoThing))
     {
         Find.BattleLog.Add(logEntry);
     }
 }
Example #28
0
        // Token: 0x060026E7 RID: 9959 RVA: 0x00127F60 File Offset: 0x00126360
        protected override void Impact(Thing hitThing)
        {
            var map = Map;

            base.Impact(hitThing);
            var battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(launcher, hitThing,
                                                                              intendedTarget.Thing, equipmentDef, def, targetCoverDef);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            if (hitThing != null)
            {
                var   damageDef        = def.projectile.damageDef;
                float amount           = DamageAmount;
                var   armorPenetration = ArmorPenetration;
                var   y          = ExactRotation.eulerAngles.y;
                var   instigator = launcher;
                var   thingDef   = equipmentDef;
                var   finaldmg   = changeDamage(amount);
                var   dinfo      = new DamageInfo(damageDef, finaldmg, armorPenetration, y, instigator, null, thingDef,
                                                  DamageInfo.SourceCategory.ThingOrUnknown, intendedTarget.Thing);
                if (isCR)
                {
                    WarframeStaticMethods.ShowColorText(hitThing, "X3 -" + finaldmg, Color.magenta, GameFont.Medium);
                }
                else
                {
                    WarframeStaticMethods.ShowDamageAmount(hitThing, finaldmg + "");
                }

                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                if (hitThing is Pawn {
                    stances : { }
                } pawn&& pawn.BodySize <= def.projectile.StoppingPower + 0.001f)
                {
                    pawn.stances.StaggerFor(95);
                }
            }
            else
            {
                SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(Position, map));
                FleckMaker.Static(ExactPosition, map, FleckDefOf.ShotHit_Dirt);
                if (Position.GetTerrain(map).takeSplashes)
                {
                    FleckMaker.WaterSplash(ExactPosition, map, Mathf.Sqrt(DamageAmount) * 1f, 4f);
                }
            }
        }
Example #29
0
        // Token: 0x060026E7 RID: 9959 RVA: 0x00127F60 File Offset: 0x00126360
        protected override void Impact(Thing hitThingf)
        {
            Thing hitThing = target;
            var   unused   = Map;

            base.Impact(hitThing);
            var battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(launcher, hitThing,
                                                                              intendedTarget.Thing, equipmentDef, def, targetCoverDef);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            if (hitThing == null)
            {
                return;
            }

            var   damageDef        = def.projectile.damageDef;
            float Baseamount       = DamageAmount;
            var   armorPenetration = ArmorPenetration;
            var   y          = ExactRotation.eulerAngles.y;
            var   instigator = launcher;
            var   thingDef   = equipmentDef;
            var   amount     = Baseamount * (1 + ((instigator as Pawn).GetLevel() / 6f));
            var   dinfo      = new DamageInfo(damageDef, amount, armorPenetration, y, instigator, null, thingDef,
                                              DamageInfo.SourceCategory.ThingOrUnknown, intendedTarget.Thing);

            WarframeStaticMethods.ShowDamageAmount(target, amount.ToString());
            hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
            if (hitThing is Pawn {
                stances : { }
            } pawn&& pawn.BodySize <= def.projectile.StoppingPower + 0.001f)
            {
                pawn.stances.StaggerFor(95);
            }

            /*
             * else
             * {
             *  SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false));
             *  MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
             *  if (base.Position.GetTerrain(map).takeSplashes)
             *  {
             *      MoteMaker.MakeWaterSplash(this.ExactPosition, map, Mathf.Sqrt((float)base.DamageAmount) * 1f, 4f);
             *  }
             * }
             */
        }
Example #30
0
        protected override void Impact(Thing hitThing)
        {
            Map     map      = base.Map;
            IntVec3 position = base.Position;

            base.Impact(hitThing);
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(launcher, hitThing, intendedTarget.Thing, equipmentDef, def, targetCoverDef);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            NotifyImpact(hitThing, map, position);
            if (hitThing != null)
            {
                DamageInfo dinfo = new DamageInfo(def.projectile.damageDef, base.DamageAmount, base.ArmorPenetration, ExactRotation.eulerAngles.y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                Pawn pawn = hitThing as Pawn;
                if (pawn != null && pawn.stances != null && pawn.BodySize <= def.projectile.StoppingPower + 0.001f)
                {
                    pawn.stances.StaggerFor(95);
                }
                if (def.projectile.extraDamages == null)
                {
                    return;
                }
                foreach (ExtraDamage extraDamage in def.projectile.extraDamages)
                {
                    if (Rand.Chance(extraDamage.chance))
                    {
                        DamageInfo dinfo2 = new DamageInfo(extraDamage.def, extraDamage.amount, extraDamage.AdjustedArmorPenetration(), ExactRotation.eulerAngles.y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, intendedTarget.Thing);
                        hitThing.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_RangedImpact);
                    }
                }
            }
            else
            {
                SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map));
                if (base.Position.GetTerrain(map).takeSplashes)
                {
                    MoteMaker.MakeWaterSplash(ExactPosition, map, Mathf.Sqrt(base.DamageAmount) * 1f, 4f);
                }
                else
                {
                    MoteMaker.MakeStaticMote(ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt);
                }
            }
        }