示例#1
0
        protected void MakeExplosion()
        {
            Pawn casterPawn = CasterPawn;

            if (!casterPawn.Spawned)
            {
                return;
            }
            Thing targetThing = currentTarget.Thing;

            if (targetThing != null && IsTargetImmobile(currentTarget) && casterPawn.skills != null)
            {
                casterPawn.skills.Learn(SkillDefOf.Shooting, 250 * verbProps.AdjustedFullCycleTime(this, casterPawn), false);
            }
            verbProperties = verbProps as VerbProperties_Gunlance;
            if (verbProperties != null)
            {
                GunlanceExplosion explosion = GenSpawn.Spawn(GunlanceDefOf.GunlanceExplosion, caster.Position, caster.Map, 0) as GunlanceExplosion;
                explosion.radius                               = verbProperties.range;
                explosion.damType                              = verbProperties.damageDef ?? DamageDefOf.Bomb;
                explosion.instigator                           = CasterPawn;
                explosion.damAmount                            = verbProperties.damageAmount;
                explosion.armorPenetration                     = 1f;
                explosion.weapon                               = CasterPawn.equipment.Primary.def;
                explosion.projectile                           = null;
                explosion.intendedTarget                       = null;
                explosion.preExplosionSpawnThingDef            = null;
                explosion.preExplosionSpawnChance              = 0f;
                explosion.preExplosionSpawnThingCount          = 0;
                explosion.postExplosionSpawnThingDef           = null;
                explosion.postExplosionSpawnChance             = 0f;
                explosion.postExplosionSpawnThingCount         = 0;
                explosion.applyDamageToExplosionCellsNeighbors = false;
                explosion.chanceToStartFire                    = 0f;
                explosion.damageFalloff                        = false;
                explosion.needLOSToCell1                       = null;
                explosion.needLOSToCell2                       = null;
                explosion.PreStartExplosion(TeleUtils.circularSectorCellsStartedCaster(casterPawn.Position, casterPawn.Map, currentTarget.Cell, verbProperties.range, verbProperties.angle, false).ToList());
                explosion.StartExplosion(null, null);
            }
            if (casterPawn != null && !casterPawn.Dead && casterPawn.Spawned)
            {
                casterPawn.stances.StaggerFor(95);
            }
        }
示例#2
0
        protected override bool TryCastShot()
        {
            Pawn casterPawn = CasterPawn;

            if (!casterPawn.Spawned || casterPawn.stances.FullBodyBusy)
            {
                return(false);
            }

            Thing targetThing = currentTarget.Thing;

            if (targetThing == null)
            {
                return(true);
            }
            if (!CanHitTarget(targetThing))
            {
                Log.Warning(string.Concat(new object[]
                {
                    casterPawn,
                    " meleed ",
                    targetThing,
                    " from out of melee position."
                }), false);
            }
            Pawn targetPawn = targetThing as Pawn;

            if (targetPawn != null && !targetPawn.Dead && (casterPawn.MentalStateDef != MentalStateDefOf.SocialFighting || targetPawn.MentalStateDef != MentalStateDefOf.SocialFighting))
            {
                targetPawn.mindState.meleeThreat             = casterPawn;
                targetPawn.mindState.lastMeleeThreatHarmTick = Find.TickManager.TicksGame;
            }
            if (!IsTargetImmobile(currentTarget) && casterPawn.skills != null)
            {
                ;
                casterPawn.skills.Learn(SkillDefOf.Melee, 100f * verbProps.AdjustedFullCycleTime(this, casterPawn), false);
                casterPawn.skills.Learn(SkillDefOf.Shooting, 100f * verbProps.AdjustedFullCycleTime(this, casterPawn), false);
            }
            verbProperties = verbProps as VerbProperties_Gunlance;
            GunlanceExplosion explosion = GenSpawn.Spawn(GunlanceDefOf.GunlanceExplosion, caster.Position, caster.Map, 0) as GunlanceExplosion;

            explosion.radius                               = verbProperties.range;
            explosion.damType                              = verbProperties.damageDef ?? DamageDefOf.Bomb;
            explosion.instigator                           = CasterPawn;
            explosion.damAmount                            = verbProperties.damageAmount;
            explosion.armorPenetration                     = 1f;
            explosion.weapon                               = CasterPawn.equipment.Primary.def;
            explosion.projectile                           = null;
            explosion.intendedTarget                       = null;
            explosion.preExplosionSpawnThingDef            = null;
            explosion.preExplosionSpawnChance              = 0f;
            explosion.preExplosionSpawnThingCount          = 0;
            explosion.postExplosionSpawnThingDef           = null;
            explosion.postExplosionSpawnChance             = 0f;
            explosion.postExplosionSpawnThingCount         = 0;
            explosion.applyDamageToExplosionCellsNeighbors = false;
            explosion.chanceToStartFire                    = 0f;
            explosion.damageFalloff                        = false;
            explosion.needLOSToCell1                       = null;
            explosion.needLOSToCell2                       = null;
            explosion.PreStartExplosion(TeleUtils.circularSectorCellsStartedTarget(casterPawn.Position, casterPawn.Map, targetThing.Position, verbProperties.range, verbProperties.angle, true).ToList());
            explosion.StartExplosion(null, null);
            CreateCombatLog((ManeuverDef maneuver) => maneuver.combatLogRulesHit, true);


            if (casterPawn.Spawned)
            {
                casterPawn.Drawer.Notify_MeleeAttackOn(targetThing);
            }
            if (targetPawn != null && !targetPawn.Dead && targetPawn.Spawned)
            {
                targetPawn.stances.StaggerFor(95);
            }
            if (casterPawn.Spawned)
            {
                casterPawn.rotationTracker.FaceCell(targetThing.Position);
            }
            if (casterPawn.caller != null)
            {
                casterPawn.caller.Notify_DidMeleeAttack();
            }
            return(true);
        }