示例#1
0
        public 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);
                }
            }
            else
            {
                SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false));
                AdeptusMoteMaker.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);
                }
            }
        }
示例#2
0
 public override void ExplosionStart(Explosion explosion, List <IntVec3> cellsToAffect)
 {
     if (this.def.explosionHeatEnergyPerCell > 1.401298E-45f)
     {
         GenTemperature.PushHeat(explosion.Position, explosion.Map, this.def.explosionHeatEnergyPerCell * (float)cellsToAffect.Count);
     }
     AdeptusMoteMaker.MakeStaticMote(explosion.DrawPos, explosion.Map, ThingDefOf.Mote_ExplosionFlash, explosion.radius * 6f);
 }
示例#3
0
 // Token: 0x0600005C RID: 92 RVA: 0x00003EBC File Offset: 0x000020BC
 private void Break()
 {
     SoundDefOf.EnergyShield_Broken.PlayOneShot(new TargetInfo(base.Wearer.Position, base.Wearer.Map, false));
     AdeptusMoteMaker.MakeStaticMote(base.Wearer.TrueCenter(), base.Wearer.Map, ThingDefOf.Mote_ExplosionFlash, 12f);
     for (int i = 0; i < 6; i++)
     {
         Rand.PushState();
         AdeptusMoteMaker.ThrowDustPuff(base.Wearer.TrueCenter() + Vector3Utility.HorizontalVectorFromAngle((float)Rand.Range(0, 360)) * Rand.Range(0.3f, 0.6f), base.Wearer.Map, Rand.Range(0.8f, 1.2f));
         Rand.PopState();
     }
     this.energy       = 0f;
     this.ticksToReset = this.StartingTicksToReset;
 }
示例#4
0
        public override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            if (this.ticksToImpact <= 0)
            {
                base.Impact(hitThing);
            }
            else
            {
                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)
                {
                    DamageInfo 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);
                    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)base.DamageAmount) * 1f, 4f);
                    return;
                }
                AdeptusMoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
            }
        }
示例#5
0
        protected virtual void Ignite()
        {
            Map map = Map;

            Destroy();
            float ignitionChance = def.projectile.explosionChanceToStartFire;
            var   radius         = def.projectile.explosionRadius;
            var   cellsToAffect  = SimplePool <List <IntVec3> > .Get();

            cellsToAffect.Clear();
            cellsToAffect.AddRange(def.projectile.damageDef.Worker.ExplosionCellsToHit(Position, map, radius));

            AdeptusMoteMaker.MakeStaticMote(ExactPosition, map, ThingDefOf.Mote_ExplosionFlash, radius * 4f);
            for (int i = 0; i < 4; i++)
            {
                MoteMaker.ThrowSmoke(Position.ToVector3Shifted() + Gen.RandomHorizontalVector(radius * 0.7f), map, radius * 0.6f);
            }

            Rand.PushState();
            if (Rand.Chance(ignitionChance))
            {
                foreach (var vec3 in cellsToAffect)
                {
                    var fireSize = radius - vec3.DistanceTo(Position);
                    if (fireSize > 0.1f)
                    {
                        if (this.def.projectile.damageDef == AdeptusDamageDefOf.OG_Chaos_Deamon_Warpfire)
                        {
                            WarpfireUtility.TryStartWarpfireIn(vec3, map, fireSize);
                        }
                        else
                        {
                            FireUtility.TryStartFireIn(vec3, map, fireSize);
                        }
                    }
                }
            }
            Rand.PopState();

            //Fire explosion should be tiny.
            if (this.def.projectile.explosionEffect != null)
            {
                Effecter effecter = this.def.projectile.explosionEffect.Spawn();
                effecter.Trigger(new TargetInfo(this.Position, map, false), new TargetInfo(this.Position, map, false));
                effecter.Cleanup();
            }
            GenExplosion.DoExplosion(this.Position, map, this.def.projectile.explosionRadius, this.def.projectile.damageDef, this.launcher, this.def.projectile.GetDamageAmount(1, null), this.def.projectile.GetArmorPenetration(1, null), this.def.projectile.soundExplode, this.equipmentDef, this.def, null, this.def.projectile.postExplosionSpawnThingDef, this.def.projectile.postExplosionSpawnChance, this.def.projectile.postExplosionSpawnThingCount, this.def.projectile.applyDamageToExplosionCellsNeighbors, this.def.projectile.preExplosionSpawnThingDef, this.def.projectile.preExplosionSpawnChance, this.def.projectile.preExplosionSpawnThingCount, this.def.projectile.explosionChanceToStartFire, this.def.projectile.explosionDamageFalloff);
        }
示例#6
0
        // Token: 0x0600005B RID: 91 RVA: 0x00003DCC File Offset: 0x00001FCC
        private void AbsorbedDamage(DamageInfo dinfo)
        {
            SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(base.Wearer.Position, base.Wearer.Map, false));

            float num = Mathf.Min(10f, 2f + (float)dinfo.Amount / 10f);

            AdeptusMoteMaker.MakeStaticMote(base.Wearer.DrawPos, base.Wearer.Map, ThingDefOf.Mote_ExplosionFlash, num);
            int num2 = (int)num;

            for (int i = 0; i < num2; i++)
            {
                Rand.PushState();
                AdeptusMoteMaker.ThrowDustPuff(base.Wearer.DrawPos, base.Wearer.Map, Rand.Range(0.8f, 1.2f));
                Rand.PopState();
            }
        }
示例#7
0
        // Token: 0x0600273E RID: 10046 RVA: 0x0012ABA0 File Offset: 0x00128FA0
        private void AbsorbedDamage(DamageInfo dinfo)
        {
            SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(base.Wearer.Position, base.Wearer.Map, false));
            this.impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle);
            Vector3 loc = base.Wearer.TrueCenter() + this.impactAngleVect.RotatedBy(180f) * 0.5f;
            float   num = Mathf.Min(10f, 2f + dinfo.Amount / 10f);

            AdeptusMoteMaker.MakeStaticMote(loc, base.Wearer.Map, ThingDefOf.Mote_ExplosionFlash, num);
            int num2 = (int)num;

            for (int i = 0; i < num2; i++)
            {
                Rand.PushState();
                AdeptusMoteMaker.ThrowDustPuff(loc, base.Wearer.Map, Rand.Range(0.8f, 1.2f));
                Rand.PopState();
            }
            this.lastAbsorbDamageTick = Find.TickManager.TicksGame;
            this.KeepDisplaying();
        }
示例#8
0
        public override void PostPreApplyDamage(DamageInfo dinfo, out bool absorbed)
        {
            //Log.Message(string.Format("Bypassing: {0}", !Props.BypassingDamageDefs.Any(def => dinfo.Def == def)));

            Rand.PushState();
            bool invSave = Rand.Chance(Props.InvunerableSaveChance);

            Rand.PopState();
            if (dinfo.Def != null && base.parent is Pawn pawn && pawn != null && invSave && !Props.BypassingDamageDefs.Any(def => dinfo.Def == def))
            {
                absorbed = true;
                SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(base.parent.Position, base.parent.Map, false));
                Vector3 impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle);
                Vector3 loc             = base.parent.TrueCenter() + impactAngleVect.RotatedBy(180f) * 0.5f;
                float   num             = Mathf.Min(10f, 2f + (float)dinfo.Amount / 10f);
                AdeptusMoteMaker.MakeStaticMote(loc, base.parent.Map, ThingDefOf.Mote_ExplosionFlash, num);
                int num2 = (int)num;
                for (int i = 0; i < num2; i++)
                {
                    Rand.PushState();
                    AdeptusMoteMaker.ThrowDustPuff(loc, base.parent.Map, Rand.Range(0.8f, 1.2f));
                    float angle = (float)Rand.Range(0, 360);
                    Rand.PopState();
                    float   num3   = Mathf.Lerp(1.2f, 1.55f, 2f);
                    Vector3 vector = pawn.Drawer.DrawPos;
                    vector.y = Altitudes.AltitudeFor(AltitudeLayer.MoteOverhead);
                    int num4 = Find.TickManager.TicksGame - this.lastAbsorbDamageTick;
                    if (num4 < 8)
                    {
                        float num5 = (float)(8 - num4) / 8f * 0.05f;
                        vector += impactAngleVect * num5;
                        num3   -= num5;
                    }
                    Vector3   s      = new Vector3(num3, 1f, num3);
                    Matrix4x4 matrix = default;
                    matrix.SetTRS(vector, Quaternion.AngleAxis(angle, Vector3.up), s);
                    Graphics.DrawMesh(MeshPool.plane10, matrix, CompInvunerableSaveOGStatic.BubbleMat, 0);
                }
                this.lastAbsorbDamageTick = Find.TickManager.TicksGame;
            }
        public override bool TryCastShot()
        {
            Pawn casterPawn = this.CasterPawn;

            if (!casterPawn.Spawned)
            {
                return(false);
            }
            if (casterPawn.stances.FullBodyBusy)
            {
                return(false);
            }
            Thing thing = this.currentTarget.Thing;

            if (!this.CanHitTarget(thing))
            {
                Log.Warning(string.Concat(new object[]
                {
                    casterPawn,
                    " meleed ",
                    thing,
                    " from out of melee position."
                }), false);
            }
            else
            {
                //	Log.Message("Verb_MeleeAttackDamage_Polearm CanHitTarget");
            }
            casterPawn.rotationTracker.Face(thing.DrawPos);
            if (!this.IsTargetImmobile(this.currentTarget) && casterPawn.skills != null)
            {
                casterPawn.skills.Learn(SkillDefOf.Melee, 200f * this.verbProps.AdjustedFullCycleTime(this, casterPawn), false);
            }
            Pawn pawn = thing as Pawn;

            if (pawn != null && !pawn.Dead && (casterPawn.MentalStateDef != MentalStateDefOf.SocialFighting || pawn.MentalStateDef != MentalStateDefOf.SocialFighting))
            {
                pawn.mindState.meleeThreat             = casterPawn;
                pawn.mindState.lastMeleeThreatHarmTick = Find.TickManager.TicksGame;
            }
            Map      map     = thing.Map;
            Vector3  drawPos = thing.DrawPos;
            SoundDef soundDef;
            bool     result;

            if (Rand.Chance(this.GetNonMissChance(thing)))
            {
                if (!Rand.Chance(this.GetDodgeChance(thing)))
                {
                    if (thing.def.category == ThingCategory.Building)
                    {
                        soundDef = this.SoundHitBuilding();
                    }
                    else
                    {
                        soundDef = this.SoundHitPawn();
                    }
                    if (this.verbProps.impactMote != null)
                    {
                        AdeptusMoteMaker.MakeStaticMote(drawPos, map, this.verbProps.impactMote, 1f);
                    }
                    BattleLogEntry_MeleeCombat battleLogEntry_MeleeCombat = this.CreateCombatLog((ManeuverDef maneuver) => maneuver.combatLogRulesHit, true);
                    result = true;
                    DamageWorker.DamageResult damageResult = this.ApplyMeleeDamageToTarget(this.currentTarget);
                    if (damageResult.stunned && damageResult.parts.NullOrEmpty <BodyPartRecord>())
                    {
                        Find.BattleLog.RemoveEntry(battleLogEntry_MeleeCombat);
                    }
                    else
                    {
                        damageResult.AssociateWithLog(battleLogEntry_MeleeCombat);
                        if (damageResult.deflected)
                        {
                            battleLogEntry_MeleeCombat.RuleDef             = this.maneuver.combatLogRulesDeflect;
                            battleLogEntry_MeleeCombat.alwaysShowInCompact = false;
                        }
                    }
                }
                else
                {
                    result   = false;
                    soundDef = this.SoundDodge(thing);
                    MoteMaker.ThrowText(drawPos, map, "TextMote_Dodge".Translate(), 1.9f);
                    this.CreateCombatLog((ManeuverDef maneuver) => maneuver.combatLogRulesDodge, false);
                }
            }
            else
            {
                result   = false;
                soundDef = this.SoundMiss();
                this.CreateCombatLog((ManeuverDef maneuver) => maneuver.combatLogRulesMiss, false);
            }
            soundDef.PlayOneShot(new TargetInfo(thing.Position, map, false));
            if (casterPawn.Spawned)
            {
                casterPawn.Drawer.Notify_MeleeAttackOn(thing);
            }
            if (pawn != null && !pawn.Dead && pawn.Spawned)
            {
                pawn.stances.StaggerFor(95);
            }
            if (casterPawn.Spawned)
            {
                casterPawn.rotationTracker.FaceCell(thing.Position);
            }
            if (casterPawn.caller != null)
            {
                casterPawn.caller.Notify_DidMeleeAttack();
            }
            return(result);
        }