public override void CompTickRare() { base.CompTickRare(); HeatDissipationCoefficient = parentArea * 0.1f; foreach (IntVec3 cell in GenAdj.CellsAdjacent8Way(parent)) { float sum = 0; if (cell.GetCover(parent.Map) != null) { sum = cell.GetCover(parent.Map).def.fillPercent; } HeatDissipationCoefficient += (1f - sum) * 0.2f; } //HeatDissipationCoefficient /= parent.def.size.x * parent.def.size.z; outSide = parent.GetRoom().UsesOutdoorTemperature; //if (outSide) //{ // heatStorage *= 0.9f; //} //if (energyStorage / energyStorageMax > 0.5) //{ //精确一点,分多次计算 float roomTemperature = parent.AmbientTemperature; for (remainderSec += 4.16666667f; remainderSec >= 1f; remainderSec--) { if (active) { if (heatStorage > 200f)//0.15是之前产能公式在200~201的导数 { heatStorage += (heatAccumulationRate * ((heatStorage - 200f) * 0.15f + 8.8125f) * produceEnergyPerSec) / parentArea; } else { heatStorage += (heatAccumulationRate * ProduceEnergy * 60f) / parentArea; } } //} //else //{ // heatStorage = Mathf.Max(0, heatStorage - 1f); //} //热交换 if (heatStorage > roomTemperature) { //交换的热量=温差*导热系数*散热面积 float dltHeat = (heatStorage - roomTemperature) * HeatDissipationCoefficient * thermalConductivity; //自身降低的温度=热量/面积 heatStorage -= dltHeat / parentArea; //外部提高的温度(其实也是热量/面积),直接把热量丢到房间里去就行了 parent.GetRoomGroup()?.PushHeat(heatStorage); //float dltHeat = GenTemperature.ControlTemperatureTempChange(parent.Position, parent.Map, (heatStorage-parent.AmbientTemperature)*0.5f, 1000f); //RoomGroup rg = parent.GetRoomGroup(); //rg.Temperature += dltHeat; //heatStorage -= dltHeat *0.5f *(float)rg.CellCount/9f;//Mathf.Max(0, (heatStorage - parent.AmbientTemperature) * 0.2f); //不低于环境温度 heatStorage = Mathf.Max(roomTemperature, heatStorage, 0); //zzLib.Log.Message("环境" + parent.AmbientTemperature + " 热量" + heatStorage + " 环境升温" + dltHeat); } } //过热 if (heatStorage > 250f && Rand.Chance(0.1f)) { GenExplosion.DoExplosion(parent.Position, parent.Map, 3.9f, DamageDefOf.Bomb, null, 25, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false, null, null); if (!disableExplosionMessage) { Messages.Message("OverHeatAndExplosion".Translate(), new LookTargets(parent), MessageTypeDefOf.ThreatSmall); disableExplosionMessage = true; } } if (heatStorage > 225 && !disableOverHeatMessage) { Messages.Message("OverHeatAndStop".Translate(), new LookTargets(parent), MessageTypeDefOf.NegativeEvent); disableOverHeatMessage = true; } if (heatStorage < 150) { disableOverHeatMessage = false; disableExplosionMessage = false; } }
public void Hatch() { try { PawnGenerationRequest request = new PawnGenerationRequest(this.Props.hatcherPawn, this.hatcheeFaction, PawnGenerationContext.NonPlayer, -1, false, true, false, false, true, false, 1f, false, true, true, true, false, false, false, false, 0f, null, 1f, null, null, null, null, null, null, null, null, null, null, null, null); for (int i = 0; i < this.parent.stackCount; i++) { Pawn pawn = PawnGenerator.GeneratePawn(request); if (PawnUtility.TrySpawnHatchedOrBornPawn(pawn, this.parent)) { if (pawn != null) { if (this.hatcheeParent != null) { if (pawn.playerSettings != null && this.hatcheeParent.playerSettings != null && this.hatcheeParent.Faction == this.hatcheeFaction) { pawn.playerSettings.AreaRestriction = this.hatcheeParent.playerSettings.AreaRestriction; } if (pawn.RaceProps.IsFlesh) { pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, this.hatcheeParent); } } if (this.otherParent != null && (this.hatcheeParent == null || this.hatcheeParent.gender != this.otherParent.gender) && pawn.RaceProps.IsFlesh) { pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, this.otherParent); } if (parent.Map != null) { List <Thing> ignoredThings = new List <Thing>(); List <Pawn> allPawnsSpawned = pawn.Map.mapPawns.AllPawnsSpawned; for (int k = 0; k < allPawnsSpawned.Count; k++) { if (allPawnsSpawned[k] != null && allPawnsSpawned[k].def.defName == pawn.def.defName) { ignoredThings.Add(allPawnsSpawned[k]); } } Thing pawnThing = pawn as Thing; ignoredThings.Add(pawnThing); // Log.Message(DefDatabase<DamageDef>.GetNamed(Props.damageDef).defName); GenExplosion.DoExplosion(parent.Position, parent.Map, Props.range, DefDatabase <DamageDef> .GetNamed(Props.damageDef), parent, Props.damage, -1, SoundDef.Named(Props.soundDef), null, null, null, null, 0f, 1, false, null, 0f, 1, 0, false, null, ignoredThings); } } if (this.parent.Spawned) { FilthMaker.TryMakeFilth(this.parent.Position, this.parent.Map, ThingDefOf.Filth_AmnioticFluid, 1, FilthSourceFlags.None); } } else { Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard); } } } finally { this.parent.Destroy(DestroyMode.Vanish); } }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; Pawn pawn = this.launcher as Pawn; Pawn victim = hitThing as Pawn; try { CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); //MightPowerSkill pwr = pawn.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_AntiArmor.FirstOrDefault((MightPowerSkill x) => x.label == "TM_AntiArmor_pwr"); verVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_AntiArmor, "TM_AntiArmor", "_ver", true); pwrVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_AntiArmor, "TM_AntiArmor", "_pwr", true); //MightPowerSkill ver = pawn.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_AntiArmor.FirstOrDefault((MightPowerSkill x) => x.label == "TM_AntiArmor_ver"); MightPowerSkill str = comp.MightData.MightPowerSkill_global_strength.FirstOrDefault((MightPowerSkill x) => x.label == "TM_global_strength_pwr"); //ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); //pwrVal = pwr.level; //verVal = ver.level; //if (pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) //{ // MightPowerSkill mpwr = pawn.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); // MightPowerSkill mver = pawn.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); // pwrVal = mpwr.level; // verVal = mver.level; //} //if (settingsRef.AIHardMode && !pawn.IsColonist) //{ // pwrVal = 3; // verVal = 3; //} this.Initialize(base.Position, pawn); if (victim != null && !victim.Dead && Rand.Chance(this.launcher.GetStatValue(StatDefOf.ShootingAccuracyPawn, true))) { int dmg = GetWeaponDmg(pawn); if (victim.RaceProps.FleshType != FleshTypeDefOf.Normal) { MoteMaker.ThrowMicroSparks(victim.Position.ToVector3(), map); damageEntities(victim, null, dmg, this.def.projectile.damageDef); MoteMaker.MakeStaticMote(victim.Position, pawn.Map, ThingDefOf.Mote_ExplosionFlash, 4f); damageEntities(victim, null, GetWeaponDmgMech(pawn, dmg), this.def.projectile.damageDef); MoteMaker.ThrowMicroSparks(victim.Position.ToVector3(), map); for (int i = 0; i < 1 + verVal; i++) { GenExplosion.DoExplosion(newPos, map, Rand.Range((.1f) * (1 + verVal), (.3f) * (1 + verVal)), DamageDefOf.Bomb, this.launcher, (this.def.projectile.GetDamageAmount(1, null) / 4) * (1 + verVal), 0, SoundDefOf.MetalHitImportant, def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0f, true); GenExplosion.DoExplosion(newPos, map, Rand.Range((.2f) * (1 + verVal), (.4f) * (1 + verVal)), DamageDefOf.Stun, this.launcher, (this.def.projectile.GetDamageAmount(1, null) / 2) * (1 + verVal), 0, SoundDefOf.MetalHitImportant, def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0f, true); newPos = GetNewPos(newPos, pawn.Position.x <= victim.Position.x, pawn.Position.z <= victim.Position.z, false, 0, 0, xProb, 1 - xProb); MoteMaker.ThrowMicroSparks(victim.Position.ToVector3(), base.Map); MoteMaker.ThrowDustPuff(newPos, map, Rand.Range(1.2f, 2.4f)); } } else { damageEntities(victim, null, dmg, this.def.projectile.damageDef); } } else { Log.Message("No valid target for anti armor shot or missed"); } } catch (NullReferenceException ex) { // } }
public void RemoveFireAtPosition(IntVec3 pos) { GenExplosion.DoExplosion(pos, this.Map, 1, DamageDefOf.Extinguish, this.launcher, 100, 0, SoundDef.Named("ExpandingFlames"), def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0f, false); }
protected new void Impact(Thing hitThing) { bool flag = hitThing == null; if (flag) { Pawn pawn; bool flag2 = (pawn = (base.Position.GetThingList(base.Map).FirstOrDefault((Thing x) => x == this.assignedTarget) as Pawn)) != null; if (flag2) { hitThing = pawn; } } bool hasValue = this.impactDamage.HasValue; if (hasValue) { hitThing.TakeDamage(this.impactDamage.Value); } try { SoundDefOf.Ambient_AltitudeWind.sustainFadeoutTime.Equals(30.0f); if (this.flyingThing != null) { GenSpawn.Spawn(this.flyingThing, base.Position, base.Map); if (this.flyingThing is Pawn) { Pawn p = this.flyingThing as Pawn; if (p.IsColonist && this.drafted) { p.drafter.Drafted = true; } if (this.earlyImpact) { damageEntities(p, this.impactForce, DamageDefOf.Blunt); damageEntities(p, this.impactForce, DamageDefOf.Stun); } } else if (flyingThing.def.thingCategories != null && (flyingThing.def.thingCategories.Contains(ThingCategoryDefOf.Chunks) || flyingThing.def.thingCategories.Contains(ThingCategoryDef.Named("StoneChunks")))) { float radius = 4f; Vector3 center = this.ExactPosition; if (this.earlyImpact) { bool wallFlag90neg = false; IntVec3 wallCheck = (center + (Quaternion.AngleAxis(-90, Vector3.up) * this.direction)).ToIntVec3(); FleckMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); wallFlag90neg = wallCheck.Walkable(base.Map); wallCheck = (center + (Quaternion.AngleAxis(90, Vector3.up) * this.direction)).ToIntVec3(); FleckMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); bool wallFlag90 = wallCheck.Walkable(base.Map); if ((!wallFlag90 && !wallFlag90neg) || (wallFlag90 && wallFlag90neg)) { //fragment energy bounces in reverse direction of travel center = center + ((Quaternion.AngleAxis(180, Vector3.up) * this.direction) * 3); } else if (wallFlag90) { center = center + ((Quaternion.AngleAxis(90, Vector3.up) * this.direction) * 3); } else if (wallFlag90neg) { center = center + ((Quaternion.AngleAxis(-90, Vector3.up) * this.direction) * 3); } } List <IntVec3> damageRing = GenRadial.RadialCellsAround(base.Position, radius, true).ToList(); List <IntVec3> outsideRing = GenRadial.RadialCellsAround(base.Position, radius, false).Except(GenRadial.RadialCellsAround(base.Position, radius - 1, true)).ToList(); for (int i = 0; i < damageRing.Count; i++) { List <Thing> allThings = damageRing[i].GetThingList(base.Map); for (int j = 0; j < allThings.Count; j++) { if (allThings[j] is Pawn) { damageEntities(allThings[j], Rand.Range(14, 22), DamageDefOf.Blunt); } else if (allThings[j] is Building) { damageEntities(allThings[j], Rand.Range(56, 88), DamageDefOf.Blunt); } else { if (Rand.Chance(.1f)) { GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDefOf.Filth_RubbleRock), damageRing[i], base.Map, ThingPlaceMode.Near); } } } } for (int i = 0; i < outsideRing.Count; i++) { IntVec3 intVec = outsideRing[i]; if (intVec.IsValid && intVec.InBounds(base.Map)) { Vector3 moteDirection = TM_Calc.GetVector(this.ExactPosition.ToIntVec3(), intVec); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Rubble"), this.ExactPosition, base.Map, Rand.Range(.3f, .6f), .2f, .02f, .05f, Rand.Range(-100, 100), Rand.Range(8f, 13f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); TM_MoteMaker.ThrowGenericMote(ThingDefOf.Gas_Smoke, this.ExactPosition, base.Map, Rand.Range(.9f, 1.2f), .3f, .02f, Rand.Range(.25f, .4f), Rand.Range(-100, 100), Rand.Range(5f, 8f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); GenExplosion.DoExplosion(intVec, base.Map, .4f, DamageDefOf.Blunt, pawn, 0, 0, SoundDefOf.Pawn_Melee_Punch_HitBuilding, null, null, null, ThingDefOf.Filth_RubbleRock, .25f, 1, false, null, 0f, 1, 0, false); //FleckMaker.ThrowSmoke(intVec.ToVector3Shifted(), base.Map, Rand.Range(.6f, 1f)); } } //damageEntities(this.flyingThing, 305, DamageDefOf.Blunt); this.flyingThing.Destroy(DestroyMode.Vanish); } else if ((flyingThing.def.thingCategories != null && (flyingThing.def.thingCategories.Contains(ThingCategoryDefOf.Corpses))) || this.flyingThing is Corpse) { Corpse flyingCorpse = this.flyingThing as Corpse; float radius = 3f; Vector3 center = this.ExactPosition; if (this.earlyImpact) { bool wallFlag90neg = false; IntVec3 wallCheck = (center + (Quaternion.AngleAxis(-90, Vector3.up) * this.direction)).ToIntVec3(); FleckMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); wallFlag90neg = wallCheck.Walkable(base.Map); wallCheck = (center + (Quaternion.AngleAxis(90, Vector3.up) * this.direction)).ToIntVec3(); FleckMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); bool wallFlag90 = wallCheck.Walkable(base.Map); if ((!wallFlag90 && !wallFlag90neg) || (wallFlag90 && wallFlag90neg)) { //fragment energy bounces in reverse direction of travel center = center + ((Quaternion.AngleAxis(180, Vector3.up) * this.direction) * 3); } else if (wallFlag90) { center = center + ((Quaternion.AngleAxis(90, Vector3.up) * this.direction) * 3); } else if (wallFlag90neg) { center = center + ((Quaternion.AngleAxis(-90, Vector3.up) * this.direction) * 3); } } List <IntVec3> damageRing = GenRadial.RadialCellsAround(base.Position, radius, true).ToList(); List <IntVec3> outsideRing = GenRadial.RadialCellsAround(base.Position, radius, false).Except(GenRadial.RadialCellsAround(base.Position, radius - 1, true)).ToList(); Filth filth = (Filth)ThingMaker.MakeThing(flyingCorpse.InnerPawn.def.race.BloodDef); for (int i = 0; i < damageRing.Count; i++) { List <Thing> allThings = damageRing[i].GetThingList(base.Map); for (int j = 0; j < allThings.Count; j++) { if (allThings[j] is Pawn) { damageEntities(allThings[j], Rand.Range(18, 28), DamageDefOf.Blunt); } else if (allThings[j] is Building) { damageEntities(allThings[j], Rand.Range(56, 88), DamageDefOf.Blunt); } else { if (Rand.Chance(.05f)) { if (filth != null) { filth = (Filth)ThingMaker.MakeThing(flyingCorpse.InnerPawn.def.race.BloodDef); GenPlace.TryPlaceThing(filth, damageRing[i], base.Map, ThingPlaceMode.Near); } else { GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDefOf.Filth_Blood), damageRing[i], base.Map, ThingPlaceMode.Near); } } if (Rand.Chance(.05f)) { GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDefOf.Filth_CorpseBile), damageRing[i], base.Map, ThingPlaceMode.Near); } } } } for (int i = 0; i < outsideRing.Count; i++) { IntVec3 intVec = outsideRing[i]; if (intVec.IsValid && intVec.InBounds(base.Map)) { Vector3 moteDirection = TM_Calc.GetVector(this.ExactPosition.ToIntVec3(), intVec); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_BloodSquirt, this.ExactPosition, base.Map, Rand.Range(.3f, .6f), .2f, .02f, .05f, Rand.Range(-100, 100), Rand.Range(4f, 13f), (Quaternion.AngleAxis(Rand.Range(60, 120), Vector3.up) * moteDirection).ToAngleFlat(), 0); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_BloodMist, this.ExactPosition, base.Map, Rand.Range(.9f, 1.2f), .3f, .02f, Rand.Range(.25f, .4f), Rand.Range(-100, 100), Rand.Range(5f, 8f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); GenExplosion.DoExplosion(intVec, base.Map, .4f, DamageDefOf.Blunt, pawn, 0, 0, SoundDefOf.Pawn_Melee_Punch_HitBuilding, null, null, null, filth.def, .08f, 1, false, null, 0f, 1, 0, false); //FleckMaker.ThrowSmoke(intVec.ToVector3Shifted(), base.Map, Rand.Range(.6f, 1f)); } } //damageEntities(this.flyingThing, 305, DamageDefOf.Blunt); //this.flyingThing.Destroy(DestroyMode.Vanish); } } else { float radius = 2f; Vector3 center = this.ExactPosition; if (this.earlyImpact) { bool wallFlag90neg = false; IntVec3 wallCheck = (center + (Quaternion.AngleAxis(-90, Vector3.up) * this.direction)).ToIntVec3(); FleckMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); wallFlag90neg = wallCheck.Walkable(base.Map); wallCheck = (center + (Quaternion.AngleAxis(90, Vector3.up) * this.direction)).ToIntVec3(); FleckMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); bool wallFlag90 = wallCheck.Walkable(base.Map); if ((!wallFlag90 && !wallFlag90neg) || (wallFlag90 && wallFlag90neg)) { //fragment energy bounces in reverse direction of travel center = center + ((Quaternion.AngleAxis(180, Vector3.up) * this.direction) * 3); } else if (wallFlag90) { center = center + ((Quaternion.AngleAxis(90, Vector3.up) * this.direction) * 3); } else if (wallFlag90neg) { center = center + ((Quaternion.AngleAxis(-90, Vector3.up) * this.direction) * 3); } } List <IntVec3> damageRing = GenRadial.RadialCellsAround(base.Position, radius, true).ToList(); List <IntVec3> outsideRing = GenRadial.RadialCellsAround(base.Position, radius, false).Except(GenRadial.RadialCellsAround(base.Position, radius - 1, true)).ToList(); for (int i = 0; i < damageRing.Count; i++) { List <Thing> allThings = damageRing[i].GetThingList(base.Map); for (int j = 0; j < allThings.Count; j++) { if (allThings[j] is Pawn) { damageEntities(allThings[j], Rand.Range(10, 16), DamageDefOf.Blunt); } else if (allThings[j] is Building) { damageEntities(allThings[j], Rand.Range(32, 88), DamageDefOf.Blunt); } else { if (Rand.Chance(.1f)) { GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDefOf.Filth_RubbleRock), damageRing[i], base.Map, ThingPlaceMode.Near); } } } } for (int i = 0; i < outsideRing.Count; i++) { IntVec3 intVec = outsideRing[i]; if (intVec.IsValid && intVec.InBounds(base.Map)) { Vector3 moteDirection = TM_Calc.GetVector(this.ExactPosition.ToIntVec3(), intVec); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Rubble"), this.ExactPosition, base.Map, Rand.Range(.3f, .6f), .2f, .02f, .05f, Rand.Range(-100, 100), Rand.Range(8f, 13f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); TM_MoteMaker.ThrowGenericMote(ThingDefOf.Gas_Smoke, this.ExactPosition, base.Map, Rand.Range(.9f, 1.2f), .3f, .02f, Rand.Range(.25f, .4f), Rand.Range(-100, 100), Rand.Range(5f, 8f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); GenExplosion.DoExplosion(intVec, base.Map, .4f, DamageDefOf.Blunt, pawn, 0, 0, SoundDefOf.Pawn_Melee_Punch_HitBuilding, null, null, null, null, .4f, 1, false, null, 0f, 1, 0, false); //FleckMaker.ThrowSmoke(intVec.ToVector3Shifted(), base.Map, Rand.Range(.6f, 1f)); } } } this.Destroy(DestroyMode.Vanish); } catch { if (this.flyingThing != null) { if (!this.flyingThing.Spawned) { GenSpawn.Spawn(this.flyingThing, base.Position, base.Map); Log.Message("catch"); } } this.Destroy(DestroyMode.Vanish); } }
// Token: 0x060000DB RID: 219 RVA: 0x000065C8 File Offset: 0x000047C8 public virtual void StartStrike() { if (!Spawned) { Log.Error("Called StartStrike() on unspawned thing."); return; } startTick = Find.TickManager.TicksGame; // base.GetComp<CompAffectsSky>().StartFadeInHoldFadeOut(30, this.duration - 30 - 15, 15, 1f); // MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named("Mote_NukeFlash"), null); // moteThrown.Scale = 400f; // moteThrown.exactPosition = base.Position.ToVector3(); // GenSpawn.Spawn(moteThrown, base.Position, base.Map, WipeMode.Vanish); // MoteThrown moteThrown2 = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named("Mote_NukeCloud"), null); // moteThrown2.Scale = 150f; // moteThrown2.rotationRate = 1f; // moteThrown2.exactPosition = base.Position.ToVector3(); // GenSpawn.Spawn(moteThrown2, base.Position, base.Map, WipeMode.Vanish); // MoteThrown moteThrown3 = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named("Mote_NukeCloud"), null); // moteThrown3.rotationRate = -1f; // GenSpawn.Spawn(moteThrown3, base.Position, base.Map, WipeMode.Vanish); /* * if (Find.CurrentMap == this.Map) * { * SoundStarter.PlayOneShotOnCamera(SoundDef.Named("ra2_NuclearExpBefore")); * } * else * { * // DubDef.hugeExplosionDistantDef.PlayOneShotOnCamera(null); * } */ Find.TickManager.slower.SignalForceNormalSpeed(); // this.StripRoofs(); LongEventHandler.QueueLongEvent(delegate { if (Find.CurrentMap == Map) { SoundDef.Named("ra2_NuclearExpBefore").PlayOneShotOnCamera(); } }, "Emmmm", false, null); /* * this.Flash(); * this.GetCells(); * this.BlastWaveLeaves(); * this.BlastWavePawn(); * this.BlastWaveThing(); * this.BurnSurface(); * this.LeaveAsh(); */ LongEventHandler.QueueLongEvent(StripRoofs, "Detonating", false, null); LongEventHandler.QueueLongEvent(Flash, "Detonating", false, null); LongEventHandler.QueueLongEvent(GetCells, "Detonating", false, null); LongEventHandler.QueueLongEvent(BlastWaveLeaves, "Detonating", false, null); LongEventHandler.QueueLongEvent(BlastWavePawn, "Detonating", false, null); LongEventHandler.QueueLongEvent(BlastWaveThing, "Detonating", false, null); LongEventHandler.QueueLongEvent(BurnSurface, "Detonating", false, null); LongEventHandler.QueueLongEvent(LeaveAsh, "Detonating", false, null); GenExplosion.DoExplosion(landPos, Map, range, DefDatabase <DamageDef> .GetNamed("Nuclear"), this, 1, -1, null, null, null, null, null, 0, 1, true); if (Find.CurrentMap == Map) { SoundDef.Named("ra2_NuclearExplode").PlayOneShotOnCamera(); } }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; ThingDef thingDef = DefDatabase <ThingDef> .GetNamed("CrashedCryptoSleepCasket"); CellRect mapRect; int numXZ = thingDef.Size.x > thingDef.Size.z ? thingDef.Size.x : thingDef.Size.z; //numXZ +=1; int count = 0; // find valid place while (true) { IntVec3 pos = CellFinder.RandomNotEdgeCell(20, map); mapRect = new CellRect(pos.x, pos.z, numXZ, numXZ); // Valid position if (IsMapRectClear(mapRect, map)) { ClearMapRect(mapRect, map); break; } count++; if (count > 100) { return(false); } } // Create casket Building_CryptosleepCasket casket = TryMakeCasket(mapRect, map, thingDef); if (casket == null) { return(false); } // Do bomb and flame explosion at place of impact GenExplosion.DoExplosion(casket.PositionHeld, map, 7, DamageDefOf.Bomb, casket); GenExplosion.DoExplosion(casket.PositionHeld, map, 4, DamageDefOf.Flame, casket); // Passenger count: 1 to 4 rnd int ccount = Rand.RangeInclusive(1, 4); for (int i = 0; i < ccount; i++) { MakeCasketContents(casket); } casket = GenSpawn.Spawn(casket, casket.Position, map) as Building_CryptosleepCasket; if (casket.DestroyedOrNull()) { return(false); } Letter letter = LetterMaker.MakeLetter("Letter_Label_CrashedCasket".Translate(), "Letter_Text_CrashedCasket".Translate(), LetterDefOf.ThreatSmall, casket); //Letter letter = LetterMaker.MakeLetter("Letter_Label_CrashedCasket".Translate(), "Letter_Text_CrashedCasket".Translate(), LetterDefOf.NeutralEvent, new TargetInfo(mapRect.CenterCell, map, false)); Find.LetterStack.ReceiveLetter(letter); return(true); }
public void SearchForTargets(IntVec3 center, float radius) { Pawn curPawnTarg = null; Building curBldgTarg = null; //IntVec3 curCell; //IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(center, radius, true); //for (int i = 0; i < targets.Count(); i++) //{ // curCell = targets.ToArray<IntVec3>()[i]; // if ( curCell.InBounds(base.Map) && curCell.IsValid) // { // curPawnTarg = curCell.GetFirstPawn(base.Map); // curBldgTarg = curCell.GetFirstBuilding(base.Map); // } List <Pawn> targets = new List <Pawn>(); targets.Clear(); if (this.age > this.lastStrike) { targets = TM_Calc.FindAllPawnsAround(base.Map, center, radius); if (targets != null && targets.Count > 0) { curPawnTarg = targets.RandomElement(); if (curPawnTarg != launcher) { CellRect cellRect = CellRect.CenteredOn(curPawnTarg.Position, 2); cellRect.ClipInsideMap(base.Map); DrawStrike(center, curPawnTarg.Position.ToVector3()); for (int k = 0; k < Rand.Range(1, 8); k++) { IntVec3 randomCell = cellRect.RandomCell; GenExplosion.DoExplosion(randomCell, base.Map, Rand.Range(.4f, .8f), TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(5 + pwrVal, 9 + 3 * pwrVal) * this.arcaneDmg), 0, SoundDefOf.Thunder_OnMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true); } GenExplosion.DoExplosion(curPawnTarg.Position, base.Map, 1f, TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(5 + pwrVal, 9 + 3 * pwrVal) * this.arcaneDmg), 0, SoundDefOf.Thunder_OffMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true); this.lastStrike = this.age + (this.maxStrikeDelay - (int)Rand.Range(0 + (pwrVal * 20), 50 + (pwrVal * 10))); } else { this.lastStrike += 10; } } else { this.lastStrike += 10; } } if (this.age > this.lastStrikeBldg) { List <Building> list = new List <Building>(); list.Clear(); list = (from x in base.Map.listerThings.AllThings where x.Position.InHorDistOf(center, radius) && !x.DestroyedOrNull() && x is Building select x as Building).ToList <Building>(); if (list.Count > 0) { curBldgTarg = list.RandomElement(); CellRect cellRect = CellRect.CenteredOn(curBldgTarg.Position, 1); cellRect.ClipInsideMap(base.Map); DrawStrike(center, curBldgTarg.Position.ToVector3()); for (int k = 0; k < Rand.Range(1, 8); k++) { IntVec3 randomCell = cellRect.RandomCell; GenExplosion.DoExplosion(randomCell, base.Map, Rand.Range(.2f, .6f), TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(3 + 3 * pwrVal, 7 + 5 * pwrVal) * this.arcaneDmg), 0, SoundDefOf.Thunder_OffMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true); } GenExplosion.DoExplosion(curBldgTarg.Position, base.Map, 1f, TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(10 + 3 * pwrVal, 25 + 5 * pwrVal) * this.arcaneDmg), 0, SoundDefOf.Thunder_OffMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true); this.lastStrikeBldg = this.age + (this.maxStrikeDelayBldg - (int)Rand.Range(0 + (pwrVal * 10), (pwrVal * 15))); } else { this.lastStrikeBldg += 10; } } //} DrawStrikeFading(); age++; }
public override IEnumerable <Gizmo> GetWornGizmos() { if (Find.Selector.SingleSelectedThing != base.Wearer) { yield break; } yield return(new Command_Toggle { hotKey = KeyBindingDefOf.Command_TogglePower, icon = TexCommand.ForbidOn, defaultLabel = "PlrsLightningActiveLabel".Translate(), defaultDesc = "PlrsLightningActiveDESC".Translate(), isActive = () => this.canLightning, toggleAction = () => { this.canLightning = !this.canLightning; }, }); if (this.Wearer.Drafted) { if (this.ShieldState == ShieldState.Active) { yield return(new Command_Action { action = delegate { if (this.energy <= 0.5f) { Messages.Message("PlrsNoEnoughEnergyToDoExplosion".Translate(), this.Wearer, MessageTypeDefOf.NegativeEvent); } else { this.energy -= 0.5f; GenExplosion.DoExplosion(this.Wearer.PositionHeld, this.Wearer.MapHeld, 2.2f, DamageDefOf.Bomb, this.Wearer, 20, -1f, DamageDefOf.Bomb.soundExplosion, null, null, null, null, 0, 1, false, null, 0, 1, 0, false); } }, defaultLabel = "PlrsDoExplosionLabel".Translate(), defaultDesc = "PlrsDoExplosionDESC".Translate(), icon = base.def.uiIcon, hotKey = KeyBindingDefOf.Misc6, }); } if (this.ShieldState != ShieldState.Active) { yield return(new Command_Action { action = delegate { if (this.HitPoints <= 20) { Messages.Message("PlrsNoEnoughHitPointsToReset".Translate(), this.Wearer, MessageTypeDefOf.NegativeEvent); } else { this.HitPoints -= 20; this.Reset(); } }, defaultLabel = "PlrsForceResetLabel".Translate(), defaultDesc = "PlrsForceResetDESC".Translate(), icon = TexCommand.DesirePower, hotKey = KeyBindingDefOf.Misc7, }); } } yield return((Gizmo) new Gizmo_PolarisShield_IVStatus { shield = this }); }
public override void Tick() { base.Tick(); if (Manned) { if (!initialized) { comp = mannableComp.ManningPawn.GetComp <CompAbilityUserMagic>(); this.verVal = mannableComp.ManningPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_TechnoTurret.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_TechnoTurret_ver").level; this.pwrVal = mannableComp.ManningPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_TechnoTurret.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_TechnoTurret_pwr").level; this.effVal = mannableComp.ManningPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_TechnoTurret.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_TechnoTurret_eff").level; if (this.verVal >= 5) { this.rocketTicksToFire = 600 - ((verVal - 5) * 20); this.rocketCount = verVal / 5; this.rocketManaCost = .055f - (.001f * this.effVal); } if (this.verVal >= 10) { this.mortarTicksToFire = 900 - ((verVal - 10) * 40); this.mortarMaxRange += ((verVal - 10) * 5); this.mortarManaCost = .1f - (.002f * effVal); } this.initialized = true; } if (!mannableComp.ManningPawn.DestroyedOrNull() && !mannableComp.ManningPawn.Dead && !mannableComp.ManningPawn.Downed) { if (this.verVal >= 5 && this.nextRocketFireTick < Find.TickManager.TicksGame && this.TargetCurrentlyAimingAt != null && comp.Mana.CurLevel >= this.rocketManaCost) { if (this.TargetCurrentlyAimingAt.Cell.IsValid && this.TargetCurrentlyAimingAt.Cell.DistanceToEdge(this.Map) > 5 && (this.TargetCurrentlyAimingAt.Cell - this.Position).LengthHorizontal >= this.rocketMinRange) { bool flag = this.TargetCurrentlyAimingAt.Cell != default(IntVec3); if (flag) { Thing launchedThing = new Thing() { def = ThingDef.Named("FlyingObject_RocketSmall") }; FlyingObject_Advanced flyingObject = (FlyingObject_Advanced)GenSpawn.Spawn(ThingDef.Named("FlyingObject_RocketSmall"), this.Position, this.Map); flyingObject.AdvancedLaunch(this, ThingDef.Named("Mote_Smoke"), 1, Rand.Range(5, 25), false, this.DrawPos, this.TargetCurrentlyAimingAt.Cell, launchedThing, Rand.Range(32, 38), true, Rand.Range(16, 22), 2, DamageDefOf.Bomb, null); this.rocketCount--; SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Position, this.Map, false), MaintenanceType.None); info.pitchFactor = 1.3f; info.volumeFactor = 1.5f; TorannMagicDefOf.TM_AirWoosh.PlayOneShot(info); } if (rocketCount <= 0) { this.rocketCount = verVal / 5; this.nextRocketFireTick = Find.TickManager.TicksGame + (600 - ((verVal - 5) * 20)); comp.Mana.CurLevel -= this.rocketManaCost; comp.MagicUserXP += Rand.Range(9, 12); } else { this.nextRocketFireTick = Find.TickManager.TicksGame + 20; } } } if (this.verVal >= 10 && this.mortarTicksToFire < Find.TickManager.TicksGame && comp.Mana.CurLevel >= this.mortarManaCost) { this.mortarTicksToFire = Find.TickManager.TicksGame + (900 - ((verVal - 10) * 40)); Pawn target = TM_Calc.FindNearbyEnemy(this.Position, this.Map, this.Faction, this.mortarMaxRange, this.mortarMinRange); if (target != null && target.Position.IsValid && target.Position.DistanceToEdge(this.Map) > 5) { bool flag = target.Position != default(IntVec3); if (flag) { IntVec3 rndTarget = target.Position; rndTarget.x += Rand.RangeInclusive(-4, 4); rndTarget.z += Rand.RangeInclusive(-4, 4); Projectile newProjectile = (Projectile)GenSpawn.Spawn(ThingDef.Named("Bullet_Shell_TechnoTurretExplosive"), this.Position, this.Map, WipeMode.Vanish); newProjectile.Launch(this, rndTarget, target, ProjectileHitFlags.All, null); } SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Position, this.Map, false), MaintenanceType.None); info.pitchFactor = 1.3f; info.volumeFactor = .8f; SoundDef.Named("Mortar_LaunchA").PlayOneShot(info); comp.Mana.CurLevel -= this.mortarManaCost; comp.MagicUserXP += Rand.Range(12, 15); } } if (CanExtractShell && MannedByColonist) { CompChangeableProjectile compChangeableProjectile = gun.TryGetComp <CompChangeableProjectile>(); if (!compChangeableProjectile.allowedShellsSettings.AllowedToAccept(compChangeableProjectile.LoadedShell)) { ExtractShell(); } } if (forcedTarget.IsValid && !CanSetForcedTarget) { ResetForcedTarget(); } if (!CanToggleHoldFire) { holdFire = false; } if (forcedTarget.ThingDestroyed) { ResetForcedTarget(); } if ((powerComp == null || powerComp.PowerOn) && (mannableComp == null || mannableComp.MannedNow) && base.Spawned) { GunCompEq.verbTracker.VerbsTick(); if (!stunner.Stunned && AttackVerb.state != VerbState.Bursting) { if (WarmingUp) { burstWarmupTicksLeft--; if (burstWarmupTicksLeft == 0) { BeginBurst(); } } else { if (burstCooldownTicksLeft > 0) { burstCooldownTicksLeft--; } if (burstCooldownTicksLeft <= 0 && this.IsHashIntervalTick(10)) { TryStartShootSomething(canBeginBurstImmediately: true); } } top.TurretTopTick(); } } else { ResetCurrentTarget(); } } } else { for (int i = 0; i < 4; i++) { Vector3 rndPos = this.DrawPos; rndPos.x += Rand.Range(-.5f, .5f); rndPos.z += Rand.Range(-.5f, .5f); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_SparkFlash"), rndPos, this.Map, Rand.Range(.6f, .8f), .1f, .05f, .05f, 0, 0, 0, Rand.Range(0, 360)); MoteMaker.ThrowSmoke(rndPos, this.Map, Rand.Range(.8f, 1.2f)); rndPos = this.DrawPos; rndPos.x += Rand.Range(-.5f, .5f); rndPos.z += Rand.Range(-.5f, .5f); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_ElectricalSpark"), rndPos, this.Map, Rand.Range(.4f, .7f), .2f, .05f, .1f, 0, 0, 0, Rand.Range(0, 360)); } GenExplosion.DoExplosion(this.Position, this.Map, 1f, DamageDefOf.EMP, this, 0, 0, SoundDefOf.Crunch, null, null, this, null, 0, 0, false, null, 0, 0, 0, false); this.Destroy(DestroyMode.Vanish); } }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; Pawn pawn = this.launcher as Pawn; Pawn victim = null; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_FogOfTorment.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_FogOfTorment_pwr"); MagicPowerSkill ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_FogOfTorment.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_FogOfTorment_ver"); ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); pwrVal = pwr.level; verVal = ver.level; this.arcaneDmg = comp.arcaneDmg; if (settingsRef.AIHardMode && !pawn.IsColonistPlayerControlled) { pwrVal = 3; verVal = 3; } if (!this.initialized) { fog = TorannMagicDefOf.Fog_Torment; this.duration = this.duration + (360 * verVal); this.strikeDelay = this.strikeDelay - (18 * verVal); fog.gas.expireSeconds.min = this.duration / 60; fog.gas.expireSeconds.max = this.duration / 60; GenExplosion.DoExplosion(base.Position, map, this.def.projectile.explosionRadius + verVal, TMDamageDefOf.DamageDefOf.TM_Torment, this.launcher, 0, this.def.projectile.soundExplode, def, this.equipmentDef, fog, 1f, 1, false, null, 0f, 0, 0.0f, false); this.initialized = true; } if (this.age > this.lastStrike + this.strikeDelay) { IntVec3 curCell; IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(base.Position, this.def.projectile.explosionRadius + verVal, true); for (int i = 0; i < targets.Count(); i++) { curCell = targets.ToArray <IntVec3>()[i]; if (curCell.InBounds(map) && curCell.IsValid) { victim = curCell.GetFirstPawn(map); if (victim != null && !victim.Dead && victim.RaceProps.IsFlesh) { if (victim.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadHD) || victim.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadAnimalHD) || victim.needs.food == null) { //heals undead int num = 1; int num2 = 1; using (IEnumerator <BodyPartRecord> enumerator = victim.health.hediffSet.GetInjuredParts().GetEnumerator()) { while (enumerator.MoveNext()) { BodyPartRecord rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { IEnumerable <Hediff_Injury> arg_BB_0 = victim.health.hediffSet.GetHediffs <Hediff_Injury>(); Func <Hediff_Injury, bool> arg_BB_1; arg_BB_1 = ((Hediff_Injury injury) => injury.Part == rec); foreach (Hediff_Injury current in arg_BB_0.Where(arg_BB_1)) { bool flag3 = num2 > 0; if (flag3) { bool flag5 = current.CanHealNaturally() && !current.IsOld(); if (flag5) { current.Heal(2.0f + pwrVal); num--; num2--; } } } } } } } else { //kills living damageEntities(victim, Mathf.RoundToInt(Rand.Range(.5f + pwrVal, 3f + pwrVal) * this.arcaneDmg), TMDamageDefOf.DamageDefOf.TM_Torment); } } } } this.lastStrike = this.age; } }
protected virtual void Explode() { Map map = base.Map; Destroy(DestroyMode.Vanish); if (base.def.projectile.explosionEffect != null) { Effecter effecter = base.def.projectile.explosionEffect.Spawn(); effecter.Trigger(new TargetInfo(base.Position, map, false), new TargetInfo(base.Position, map, false)); effecter.Cleanup(); } IntVec3 position = base.Position; Map map2 = map; float explosionRadius = base.def.projectile.explosionRadius; DamageDef damageDef = base.def.projectile.damageDef; Thing launcher = base.launcher; int damageAmount = base.DamageAmount; float armorPenetration = base.ArmorPenetration; SoundDef soundExplode = base.def.projectile.soundExplode; ThingDef equipmentDef = base.equipmentDef; ThingDef def = base.def; Thing thing = intendedTarget.Thing; ThingDef postExplosionSpawnThingDef = base.def.projectile.postExplosionSpawnThingDef; float postExplosionSpawnChance = base.def.projectile.postExplosionSpawnChance; int postExplosionSpawnThingCount = base.def.projectile.postExplosionSpawnThingCount; ThingDef preExplosionSpawnThingDef = base.def.projectile.preExplosionSpawnThingDef; GenExplosion.DoExplosion(position, map2, explosionRadius, damageDef, launcher, damageAmount, armorPenetration, soundExplode, equipmentDef, def, thing, postExplosionSpawnThingDef, postExplosionSpawnChance, postExplosionSpawnThingCount, base.def.projectile.applyDamageToExplosionCellsNeighbors, preExplosionSpawnThingDef, base.def.projectile.preExplosionSpawnChance, base.def.projectile.preExplosionSpawnThingCount, base.def.projectile.explosionChanceToStartFire, base.def.projectile.explosionDamageFalloff); foreach (Pawn pawn in map.mapPawns.AllPawns) { if (pawn.Dead) { continue; } try { if (position.DistanceTo(pawn.Position) < 15f) { pawn.health.AddHediff(HediffDef.Named("LethalRadiationPoisoning")); } else if (position.DistanceTo(pawn.Position) < 50f && position.DistanceTo(pawn.Position) > 15f) { pawn.health.AddHediff(HediffDef.Named("HeavyRadiationPoisoning")); } else if (position.DistanceTo(pawn.Position) < 70f && position.DistanceTo(pawn.Position) > 50f) { pawn.health.AddHediff(HediffDef.Named("MediumRadiationPoisoning")); } else { pawn.health.AddHediff(HediffDef.Named("LightRadiationPoisoning")); } } catch (Exception e) { Log.Message(e.ToString()); } } }
public void SearchForTargets(IntVec3 center, float radius) { Pawn curPawnTarg = null; Building curBldgTarg = null; IntVec3 curCell; IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(center, radius, true); for (int i = 0; i < targets.Count(); i++) { curCell = targets.ToArray <IntVec3>()[i]; if (curCell.InBounds(base.Map) && curCell.IsValid) { curPawnTarg = curCell.GetFirstPawn(base.Map); curBldgTarg = curCell.GetFirstBuilding(base.Map); } if (curPawnTarg != null && curPawnTarg != launcher) { bool newTarg = false; if (this.age > this.lastStrike + (this.maxStrikeDelay - (int)Rand.Range(0 + (pwrVal * 20), 40 + (pwrVal * 15)))) { if (Rand.Chance(.1f)) { newTarg = true; } if (newTarg) { CellRect cellRect = CellRect.CenteredOn(curCell, 2); cellRect.ClipInsideMap(base.Map); DrawStrike(center, curPawnTarg.Position.ToVector3()); for (int k = 0; k < Rand.Range(1, 8); k++) { IntVec3 randomCell = cellRect.RandomCell; GenExplosion.DoExplosion(randomCell, base.Map, Rand.Range(.4f, .8f), TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(5 + pwrVal, 9 + 3 * pwrVal) * this.arcaneDmg), 0, SoundDefOf.Thunder_OnMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true); } GenExplosion.DoExplosion(curPawnTarg.Position, base.Map, 1f, TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(5 + pwrVal, 9 + 3 * pwrVal) * this.arcaneDmg), 0, SoundDefOf.Thunder_OffMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true); this.lastStrike = this.age; } } } if (curBldgTarg != null) { bool newTarg = false; if (this.age > this.lastStrikeBldg + (this.maxStrikeDelayBldg - (int)Rand.Range(0 + (pwrVal * 10), (pwrVal * 15)))) { if (Rand.Chance(.1f)) { newTarg = true; } if (newTarg) { CellRect cellRect = CellRect.CenteredOn(curCell, 1); cellRect.ClipInsideMap(base.Map); DrawStrike(center, curBldgTarg.Position.ToVector3()); for (int k = 0; k < Rand.Range(1, 8); k++) { IntVec3 randomCell = cellRect.RandomCell; GenExplosion.DoExplosion(randomCell, base.Map, Rand.Range(.2f, .6f), TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(3 + 3 * pwrVal, 7 + 5 * pwrVal) * this.arcaneDmg), 0, SoundDefOf.Thunder_OffMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true); } GenExplosion.DoExplosion(curBldgTarg.Position, base.Map, 1f, TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(5 + 5 * pwrVal, 10 + 10 * pwrVal) * this.arcaneDmg), 0, SoundDefOf.Thunder_OffMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true); this.lastStrikeBldg = this.age; } } } targets.GetEnumerator().MoveNext(); } DrawStrikeFading(); age++; }
public static void DamageInfosToApply_ForceWeapon_Postfix(ref Verb_MeleeAttackDamage __instance, LocalTargetInfo target, ref IEnumerable <DamageInfo> __result) { if (__instance.EquipmentSource != null) { if (!__instance.EquipmentSource.AllComps.NullOrEmpty()) { if (__instance.EquipmentSource.GetComp <CompWeapon_MeleeSpecialRules>() != null) { if (__instance.EquipmentSource.GetComp <CompWeapon_MeleeSpecialRules>() is CompWeapon_MeleeSpecialRules WeaponRules) { if (AMASettings.Instance.AllowForceWeaponEffect) { bool ForceAttack = __result.Any(x => x.Def.forceWeapon()); if (WeaponRules.ForceWeapon && ForceAttack && __instance.CasterPawn is Pawn Caster) { bool casterPsychiclySensitive = Caster.RaceProps.Humanlike ? Caster.story.traits.HasTrait(TraitDefOf.PsychicSensitivity) : false; bool Activate = false; if ((casterPsychiclySensitive || !WeaponRules.ForceEffectRequiresPsyker) && target.Thing.def.category == ThingCategory.Pawn && target.Thing is Pawn Victim) { int casterPsychiclySensitiveDegree = casterPsychiclySensitive ? Caster.story.traits.DegreeOfTrait(TraitDefOf.PsychicSensitivity) : 0; if ((casterPsychiclySensitiveDegree >= 1 || !WeaponRules.ForceEffectRequiresPsyker)) { float?casterPsychicSensitivity = Caster.GetStatValue(StatDefOf.PsychicSensitivity, true) * 100f; bool targetPsychiclySensitive = Victim.RaceProps.Humanlike ? Victim.story.traits.HasTrait(TraitDefOf.PsychicSensitivity) : false; float?targetPsychicSensitivity = Victim.GetStatValue(StatDefOf.PsychicSensitivity, true) * 100f; if (targetPsychiclySensitive == true) { int targetPsychiclySensitiveDegree = Victim.story.traits.DegreeOfTrait(TraitDefOf.PsychicSensitivity); if (targetPsychiclySensitiveDegree == -1) { targetPsychicSensitivity = Victim.def.statBases.GetStatValueFromList(StatDefOf.PsychicSensitivity, 1.5f) * 100f; } else if (targetPsychiclySensitiveDegree == -2) { targetPsychicSensitivity = Victim.def.statBases.GetStatValueFromList(StatDefOf.PsychicSensitivity, 2f) * 100f; } } else { int targetPsychiclySensitiveDegree = 0; } if (__result.Any(x => x.Def.forceWeapon())) { // Log.Message(string.Format("1")); float CasterMood = Caster.needs.mood.CurLevelPercentage; float VictimMood = Victim?.needs?.mood != null ? Victim.needs.mood.CurLevelPercentage : 1; foreach (var item in __result.Where(x => x.Def.forceWeapon())) { float?casterRoll = Rand.Range(0, (int)casterPsychicSensitivity) * CasterMood; float?targetRoll = Rand.Range(0, (int)targetPsychicSensitivity) * VictimMood; casterRoll = (casterRoll - (targetPsychicSensitivity / 2)); Activate = (casterRoll > targetRoll); // Log.Message(string.Format("Caster:{0}, Victim:{1}", casterRoll, targetRoll)); if (Activate) { DamageDef damDef = WeaponRules.ForceWeaponEffect; float damAmount = __instance.verbProps.AdjustedMeleeDamageAmount(__instance, __instance.CasterPawn); float armorPenetration = __instance.verbProps.AdjustedArmorPenetration(__instance, __instance.CasterPawn); BodyPartRecord bodyPart = Rand.Chance(0.05f) && Victim.RaceProps.body.AllParts.Any(x => x.def.defName.Contains("Brain")) ? Victim.RaceProps.body.AllParts.Find(x => x.def.defName.Contains("Brain")) : null; BodyPartGroupDef bodyPartGroupDef = null; HediffDef hediffDef = WeaponRules.ForceWeaponHediff; damAmount = Rand.Range(damAmount * 0.1f, damAmount * 0.5f); ThingDef source = __instance.EquipmentSource.def; Thing caster = __instance.caster; Vector3 direction = (target.Thing.Position - __instance.CasterPawn.Position).ToVector3(); float num = damAmount; float num2 = armorPenetration; DamageInfo mainDinfo = new DamageInfo(damDef, num, num2, -1f, caster, bodyPart, source, DamageInfo.SourceCategory.ThingOrUnknown, null); mainDinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside); mainDinfo.SetWeaponBodyPartGroup(bodyPartGroupDef); mainDinfo.SetWeaponHediff(hediffDef); mainDinfo.SetAngle(direction); Victim.TakeDamage(mainDinfo); Map map = Caster.Map; IntVec3 position = target.Cell; Map map2 = map; float explosionRadius = 0f; Thing launcher = __instance.EquipmentSource; SoundDef soundExplode = WeaponRules.ForceWeaponTriggerSound; Thing thing = target.Thing; GenExplosion.DoExplosion(position, map2, explosionRadius, damDef, launcher, (int)damAmount, armorPenetration, soundExplode, source, null, thing, null, 0f, 0, false, null, 0, 0, 0, false); float KillChance = WeaponRules.ForceWeaponKillChance; if (KillChance != 0) { float KillRoll = Rand.Range(0, 100); if (Rand.Chance(WeaponRules.ForceWeaponKillChance)) { string msg = string.Format("{0} was slain by a force strike", target.Thing.LabelCap); target.Thing.Kill(mainDinfo); if (target.Thing.Faction == Faction.OfPlayer) { Messages.Message(msg, MessageTypeDefOf.PawnDeath); } } } /* */ } } } } } } } } } } } }
public void RemoveFireAtPosition(IntVec3 pos, Map map) { GenExplosion.DoExplosion(pos, map, 1, DamageDefOf.Extinguish, CasterPawn, 100, 0, SoundDef.Named("ExpandingFlames")); }
protected override bool TryCastShot() { GenExplosion.DoExplosion(caster.Position, caster.Map, verbPropsExplode.explosionRadius, verbPropsExplode.explosionDamageType, caster, Mathf.RoundToInt(this.verbPropsExplode.AdjustedExplosionDamageAmount(this, this.CasterPawn)), -1, this.verbPropsExplode.explosionSound, this.TryGetWeapon(), null, null, this.verbPropsExplode.postExplosionSpawnThingDef, this.verbPropsExplode.postExplosionSpawnThingChance, this.verbPropsExplode.postExplosionSpawnThingCount, this.verbPropsExplode.applyDamageToExplosionCellsNeighbors, this.verbPropsExplode.preExplosionSpawnThingDef, this.verbPropsExplode.preExplosionSpawnThingChance, this.verbPropsExplode.preExplosionSpawnThingCount, this.verbPropsExplode.chanceToStartFire, this.verbPropsExplode.damageFalloff); return(true); }
protected override void Impact(Thing hitThing) { bool shielded = hitThing.IsShielded() && def.IsWeakToShields; LaserGunDef defWeapon = equipmentDef as LaserGunDef; Vector3 dir = (destination - origin).normalized; dir.y = 0; Vector3 a = origin + dir * (defWeapon == null ? 0.9f : defWeapon.barrelLength); Vector3 b = shielded ? hitThing.TrueCenter() - dir.RotatedBy(Rand.Range(-22.5f, 22.5f)) * 0.8f : destination; a.y = b.y = def.Altitude; SpawnBeam(a, b); bool createsExplosion = this.def.projectile.explosionRadius > 0f; if (createsExplosion) { this.Explode(hitThing, false); GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(this, this.def.projectile.damageDef, this.launcher.Faction); } Pawn pawn = launcher as Pawn; IDrawnWeaponWithRotation weapon = null; if (pawn != null && pawn.equipment != null) { weapon = pawn.equipment.Primary as IDrawnWeaponWithRotation; } if (weapon == null) { Building_LaserGun turret = launcher as Building_LaserGun; if (turret != null) { weapon = turret.gun as IDrawnWeaponWithRotation; } } if (weapon != null) { float angle = (b - a).AngleFlat() - (intendedTarget.CenterVector3 - a).AngleFlat(); weapon.RotationOffset = (angle + 180) % 360 - 180; } if (hitThing == null) { TriggerEffect(def.explosionEffect, destination); bool flag2 = this.def.causefireChance > 0f && Rand.Chance(this.def.causefireChance); if (flag2) { FireUtility.TryStartFireIn(destination.ToIntVec3(), pawn.Map, 0.05f); } } else { if (hitThing is Pawn) { Pawn hitPawn = hitThing as Pawn; if (shielded) { weaponDamageMultiplier *= def.shieldDamageMultiplier; SpawnBeamReflections(a, b, 5); } } bool flag2 = this.def.causefireChance > 0f && Rand.Range(0f, 1f) > this.def.causefireChance; if (flag2) { hitThing.TryAttachFire(0.05f); } TriggerEffect(def.explosionEffect, ExactPosition); } if (def.HediffToAdd != null) { AddedEffect(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 = DamageAmount; float armorPenetration = 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 hitPawn = hitThing as Pawn; if (hitPawn != null && hitPawn.stances != null && hitPawn.BodySize <= this.def.projectile.StoppingPower + 0.001f) { hitPawn.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); } } }
public static void MakeColony(params ColonyMakerFlag[] flags) { bool godMode = DebugSettings.godMode; DebugSettings.godMode = true; Thing.allowDestroyNonDestroyable = true; if (usedCells == null) { usedCells = new BoolGrid(Map); } else { usedCells.ClearAndResizeTo(Map); } overRect = new CellRect(Map.Center.x - 50, Map.Center.z - 50, 100, 100); DeleteAllSpawnedPawns(); GenDebug.ClearArea(overRect, Find.CurrentMap); if (flags.Contains(ColonyMakerFlag.Animals)) { foreach (PawnKindDef item in DefDatabase <PawnKindDef> .AllDefs.Where((PawnKindDef k) => k.RaceProps.Animal)) { if (!TryGetFreeRect(6, 3, out var result)) { return; } result = result.ContractedBy(1); foreach (IntVec3 item2 in result) { Map.terrainGrid.SetTerrain(item2, TerrainDefOf.Concrete); } GenSpawn.Spawn(PawnGenerator.GeneratePawn(item), result.Cells.ElementAt(0), Map); IntVec3 intVec = result.Cells.ElementAt(1); HealthUtility.DamageUntilDead((Pawn)GenSpawn.Spawn(PawnGenerator.GeneratePawn(item), intVec, Map)); CompRottable compRottable = ((Corpse)intVec.GetThingList(Find.CurrentMap).First((Thing t) => t is Corpse)).TryGetComp <CompRottable>(); if (compRottable != null) { compRottable.RotProgress += 1200000f; } if (item.RaceProps.leatherDef != null) { GenSpawn.Spawn(item.RaceProps.leatherDef, result.Cells.ElementAt(2), Map); } if (item.RaceProps.meatDef != null) { GenSpawn.Spawn(item.RaceProps.meatDef, result.Cells.ElementAt(3), Map); } } } if (flags.Contains(ColonyMakerFlag.ConduitGrid)) { Designator_Build designator_Build = new Designator_Build(ThingDefOf.PowerConduit); for (int i = overRect.minX; i < overRect.maxX; i++) { for (int j = overRect.minZ; j < overRect.maxZ; j += 7) { designator_Build.DesignateSingleCell(new IntVec3(i, 0, j)); } } for (int l = overRect.minZ; l < overRect.maxZ; l++) { for (int m = overRect.minX; m < overRect.maxX; m += 7) { designator_Build.DesignateSingleCell(new IntVec3(m, 0, l)); } } } if (flags.Contains(ColonyMakerFlag.PowerPlants)) { List <ThingDef> list = new List <ThingDef> { ThingDefOf.SolarGenerator, ThingDefOf.WindTurbine }; for (int n = 0; n < 8; n++) { if (TryMakeBuilding(list[n % list.Count]) == null) { Log.Message("Could not make solar generator."); break; } } } if (flags.Contains(ColonyMakerFlag.Batteries)) { for (int num = 0; num < 6; num++) { Thing thing = TryMakeBuilding(ThingDefOf.Battery); if (thing == null) { Log.Message("Could not make battery."); break; } ((Building_Battery)thing).GetComp <CompPowerBattery>().AddEnergy(999999f); } } if (flags.Contains(ColonyMakerFlag.WorkTables)) { foreach (ThingDef item3 in DefDatabase <ThingDef> .AllDefs.Where((ThingDef def) => typeof(Building_WorkTable).IsAssignableFrom(def.thingClass))) { Thing thing2 = TryMakeBuilding(item3); if (thing2 == null) { Log.Message("Could not make worktable: " + item3.defName); break; } Building_WorkTable building_WorkTable = thing2 as Building_WorkTable; if (building_WorkTable == null) { continue; } foreach (RecipeDef allRecipe in building_WorkTable.def.AllRecipes) { building_WorkTable.billStack.AddBill(allRecipe.MakeNewBill()); } } } if (flags.Contains(ColonyMakerFlag.AllBuildings)) { foreach (ThingDef item4 in DefDatabase <ThingDef> .AllDefs.Where((ThingDef def) => def.category == ThingCategory.Building && def.BuildableByPlayer)) { if (item4 != ThingDefOf.PowerConduit && TryMakeBuilding(item4) == null) { Log.Message("Could not make building: " + item4.defName); break; } } } if (!TryGetFreeRect(33, 33, out var result2)) { Log.Error("Could not get wallable rect"); } result2 = result2.ContractedBy(1); if (flags.Contains(ColonyMakerFlag.AllItems)) { List <ThingDef> itemDefs = DefDatabase <ThingDef> .AllDefs.Where((ThingDef def) => DebugThingPlaceHelper.IsDebugSpawnable(def) && def.category == ThingCategory.Item).ToList(); FillWithItems(result2, itemDefs); } else if (flags.Contains(ColonyMakerFlag.ItemsRawFood)) { List <ThingDef> list2 = new List <ThingDef>(); list2.Add(ThingDefOf.RawPotatoes); FillWithItems(result2, list2); } if (flags.Contains(ColonyMakerFlag.Filth)) { foreach (IntVec3 item5 in result2) { GenSpawn.Spawn(ThingDefOf.Filth_Dirt, item5, Map); } } if (flags.Contains(ColonyMakerFlag.ItemsWall)) { CellRect cellRect = result2.ExpandedBy(1); Designator_Build designator_Build2 = new Designator_Build(ThingDefOf.Wall); designator_Build2.SetStuffDef(ThingDefOf.WoodLog); foreach (IntVec3 edgeCell in cellRect.EdgeCells) { designator_Build2.DesignateSingleCell(edgeCell); } } if (flags.Contains(ColonyMakerFlag.ColonistsMany)) { MakeColonists(15, overRect.CenterCell); } else if (flags.Contains(ColonyMakerFlag.ColonistOne)) { MakeColonists(1, overRect.CenterCell); } if (flags.Contains(ColonyMakerFlag.Fire)) { if (!TryGetFreeRect(30, 30, out var result3)) { Log.Error("Could not get free rect for fire."); } ThingDef plant_TreeOak = ThingDefOf.Plant_TreeOak; foreach (IntVec3 item6 in result3) { GenSpawn.Spawn(plant_TreeOak, item6, Map); } foreach (IntVec3 item7 in result3) { if (item7.x % 7 == 0 && item7.z % 7 == 0) { GenExplosion.DoExplosion(item7, Find.CurrentMap, 3.9f, DamageDefOf.Flame, null); } } } if (flags.Contains(ColonyMakerFlag.ColonistsHungry)) { DoToColonists(0.4f, delegate(Pawn col) { col.needs.food.CurLevel = Mathf.Max(0f, Rand.Range(-0.05f, 0.05f)); }); } if (flags.Contains(ColonyMakerFlag.ColonistsTired)) { DoToColonists(0.4f, delegate(Pawn col) { col.needs.rest.CurLevel = Mathf.Max(0f, Rand.Range(-0.05f, 0.05f)); }); } if (flags.Contains(ColonyMakerFlag.ColonistsInjured)) { DoToColonists(0.4f, delegate(Pawn col) { DamageDef def2 = DefDatabase <DamageDef> .AllDefs.Where((DamageDef d) => d.ExternalViolenceFor(null)).RandomElement(); col.TakeDamage(new DamageInfo(def2, 10f)); }); } if (flags.Contains(ColonyMakerFlag.ColonistsDiseased)) { foreach (HediffDef item8 in DefDatabase <HediffDef> .AllDefs.Where((HediffDef d) => d.hediffClass != typeof(Hediff_AddedPart) && (d.HasComp(typeof(HediffComp_Immunizable)) || d.HasComp(typeof(HediffComp_GrowthMode))))) { Pawn pawn = PawnGenerator.GeneratePawn(Faction.OfPlayer.def.basicMemberKind, Faction.OfPlayer); TryGetFreeRect(1, 1, out var result4); GenSpawn.Spawn(pawn, result4.CenterCell, Map); pawn.health.AddHediff(item8); } } if (flags.Contains(ColonyMakerFlag.Beds)) { IEnumerable <ThingDef> source = DefDatabase <ThingDef> .AllDefs.Where((ThingDef def) => def.thingClass == typeof(Building_Bed)); int freeColonistsCount = Map.mapPawns.FreeColonistsCount; for (int num2 = 0; num2 < freeColonistsCount; num2++) { if (TryMakeBuilding(source.RandomElement()) == null) { Log.Message("Could not make beds."); break; } } } if (flags.Contains(ColonyMakerFlag.Stockpiles)) { Designator_ZoneAddStockpile_Resources designator_ZoneAddStockpile_Resources = new Designator_ZoneAddStockpile_Resources(); foreach (StoragePriority value in Enum.GetValues(typeof(StoragePriority))) { TryGetFreeRect(7, 7, out var result5); result5 = result5.ContractedBy(1); designator_ZoneAddStockpile_Resources.DesignateMultiCell(result5.Cells); ((Zone_Stockpile)Map.zoneManager.ZoneAt(result5.CenterCell)).settings.Priority = value; } } if (flags.Contains(ColonyMakerFlag.GrowingZones)) { Zone_Growing dummyZone = new Zone_Growing(Map.zoneManager); Map.zoneManager.RegisterZone(dummyZone); foreach (ThingDef item9 in DefDatabase <ThingDef> .AllDefs.Where((ThingDef d) => d.plant != null && PlantUtility.CanSowOnGrower(d, dummyZone))) { if (!TryGetFreeRect(6, 6, out var result6)) { Log.Error("Could not get growing zone rect."); } result6 = result6.ContractedBy(1); foreach (IntVec3 item10 in result6) { Map.terrainGrid.SetTerrain(item10, TerrainDefOf.Soil); } new Designator_ZoneAdd_Growing().DesignateMultiCell(result6.Cells); (Map.zoneManager.ZoneAt(result6.CenterCell) as Zone_Growing)?.SetPlantDefToGrow(item9); } dummyZone.Delete(); } ClearAllHomeArea(); FillWithHomeArea(overRect); DebugSettings.godMode = godMode; Thing.allowDestroyNonDestroyable = false; }
public override void CompTick() { base.CompTick(); if (this.pawn.Spawned) { if (Find.TickManager.TicksGame % 10 == 0) { if (this.pawn.Downed && !this.pawn.Dead) { GenExplosion.DoExplosion(this.pawn.Position, this.pawn.Map, Rand.Range(this.explosionRadius * .5f, this.explosionRadius * 1.5f), DamageDefOf.Burn, this.pawn, Rand.Range(6, 10), null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false); this.pawn.Kill(null, null); } } if (Find.TickManager.TicksGame % nextLeap == 0 && !pawn.Downed && !pawn.Dead) { LocalTargetInfo lti = null; if (this.pawn.CurJob != null && this.pawn.CurJob.targetA != null) { lti = this.pawn.jobs.curJob.targetA.Thing; } if (lti != null && lti.Thing != null) { Thing target = lti.Thing; if (target is Pawn && target.Spawned) { float targetRange = (target.Position - this.pawn.Position).LengthHorizontal; if (targetRange <= this.Props.leapRangeMax && targetRange > this.Props.leapRangeMin) { if (Rand.Chance(this.Props.GetLeapChance)) { if (CanHitTargetFrom(this.pawn.Position, target)) { LeapAttack(target); } } else { if (this.Props.textMotes) { if (Rand.Chance(.5f)) { MoteMaker.ThrowText(this.pawn.DrawPos, this.pawn.Map, "grrr", -1); } else { MoteMaker.ThrowText(this.pawn.DrawPos, this.pawn.Map, "hsss", -1); } } } } else if (this.Props.bouncingLeaper) { Faction targetFaction = null; if (target != null && target.Faction != null) { targetFaction = target.Faction; } IntVec3 curCell; IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(this.pawn.Position, this.Props.leapRangeMax, false); for (int i = 0; i < targets.Count(); i++) { Pawn bounceTarget = null; curCell = targets.ToArray <IntVec3>()[i]; if (curCell.InBounds(this.pawn.Map) && curCell.IsValid) { bounceTarget = curCell.GetFirstPawn(this.pawn.Map); if (bounceTarget != null && bounceTarget != target && !bounceTarget.Downed && !bounceTarget.Dead && bounceTarget.RaceProps != null) { if (bounceTarget.Faction != null && bounceTarget.Faction == targetFaction) { if (Rand.Chance(1 - this.Props.leapChance)) { i = targets.Count(); } else { bounceTarget = null; } } else { bounceTarget = null; } } else { bounceTarget = null; } } if (bounceTarget != null) { if (CanHitTargetFrom(this.pawn.Position, target)) { if (!bounceTarget.Downed && !bounceTarget.Dead) { LeapAttack(bounceTarget); } LeapAttack(bounceTarget); break; } } targets.GetEnumerator().MoveNext(); } } } } } } }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; Pawn pawn = this.launcher as Pawn; if (!this.initialized) { CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_CorpseExplosion.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_CorpseExplosion_pwr"); MagicPowerSkill ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_CorpseExplosion.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_CorpseExplosion_ver"); this.arcaneDmg = comp.arcaneDmg; pwrVal = pwr.level; verVal = ver.level; Initialize(); CellRect cellRect = CellRect.CenteredOn(base.Position, 1); cellRect.ClipInsideMap(map); IntVec3 curCell = cellRect.CenterCell; if (curCell.InBounds(map) && curCell.IsValid) { Pawn undead = curCell.GetFirstPawn(map); bool flag = undead != null && !undead.Dead; if (flag) { if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadHD)) { this.targetPawn = undead; } if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadAnimalHD)) { this.targetPawn = undead; } } Thing corpseThing = curCell.GetFirstItem(map); Corpse corpse = null; if (corpseThing != null) { bool validator = corpseThing is Corpse; if (validator) { corpse = corpseThing as Corpse; Pawn corpsePawn = corpse.InnerPawn; if (corpsePawn.RaceProps.IsFlesh) { if (corpsePawn.RaceProps.Humanlike || corpsePawn.RaceProps.Animal) { this.targetCorpse = corpse; } } } } } } if (this.targetPawn != null && !this.targetPawn.Destroyed) { if (this.age == 360) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "6", -.5f); } if (this.age == 300) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "5", -.5f); } if (this.age == 240) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "4", -.5f); } if (this.age == 180) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "3", -.5f); } if (this.age == 120) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "2", -.5f); } if (this.age == 60) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "1", -.5f); } if (this.age == 1) { //explode TM_MoteMaker.ThrowBloodSquirt(this.targetPawn.Position.ToVector3Shifted(), map, 1.2f); TM_MoteMaker.ThrowBloodSquirt(this.targetPawn.Position.ToVector3Shifted(), map, .6f); TM_MoteMaker.ThrowBloodSquirt(this.targetPawn.Position.ToVector3Shifted(), map, .8f); if (this.targetPawn.RaceProps.Humanlike) { this.targetPawn.inventory.DropAllNearPawn(this.targetPawn.Position, false, true); this.targetPawn.equipment.DropAllEquipment(this.targetPawn.Position, false); this.targetPawn.apparel.DropAll(this.targetPawn.Position, false); } GenExplosion.DoExplosion(this.targetPawn.Position, map, this.radius, TMDamageDefOf.DamageDefOf.TM_CorpseExplosion, this.launcher, Mathf.RoundToInt((Rand.Range(18f, 30f) + (5f * pwrVal)) * this.arcaneDmg), this.def.projectile.soundExplode, def, this.equipmentDef, null, 0f, 01, false, null, 0f, 0, 0.0f, true); if (!this.targetPawn.Destroyed) { this.targetPawn.Destroy(); } } } if (this.targetCorpse != null && !this.targetCorpse.Destroyed) { if (this.age == 360) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "6", -.5f); } if (this.age == 300) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "5", -.5f); } if (this.age == 240) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "4", -.5f); } if (this.age == 180) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "3", -.5f); } if (this.age == 120) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "2", -.5f); } if (this.age == 60) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "1", -.5f); } if (this.age == 1) { //explode TM_MoteMaker.ThrowBloodSquirt(this.targetCorpse.Position.ToVector3Shifted(), map, 1.2f); TM_MoteMaker.ThrowBloodSquirt(this.targetCorpse.Position.ToVector3Shifted(), map, .6f); TM_MoteMaker.ThrowBloodSquirt(this.targetCorpse.Position.ToVector3Shifted(), map, .8f); Pawn corpsePawn = this.targetCorpse.InnerPawn; if (corpsePawn.RaceProps.Humanlike) { corpsePawn.inventory.DropAllNearPawn(this.targetCorpse.Position, false, true); corpsePawn.equipment.DropAllEquipment(this.targetCorpse.Position, false); corpsePawn.apparel.DropAll(this.targetCorpse.Position, false); } GenExplosion.DoExplosion(this.targetCorpse.Position, map, this.radius, TMDamageDefOf.DamageDefOf.TM_CorpseExplosion, this.launcher, Mathf.RoundToInt((Rand.Range(18f, 30f) + (5f * pwrVal)) * this.arcaneDmg), this.def.projectile.soundExplode, def, this.equipmentDef, null, 0f, 01, false, null, 0f, 0, 0.0f, true); if (!this.targetCorpse.Destroyed) { this.targetCorpse.Destroy(); } } } }
static bool Prefix(Building culprit) { PowerNet powerNet = culprit.PowerComp.PowerNet; Map map = culprit.Map; float totalEnergy = 0f; float totalEnergyHistoric = 0f; float explosionRadius = 0f; bool shouldStartFire = false; bool startedFire = false; string culpritString; if (powerNet.batteryComps.Any((CompPowerBattery x) => x.StoredEnergy > 20f)) { foreach (CompPowerBattery batteryComp in powerNet.batteryComps) { totalEnergy += batteryComp.StoredEnergy; batteryComp.DrawPower(batteryComp.StoredEnergy); } totalEnergyHistoric = totalEnergy; foreach (CompPower transmitter in powerNet.transmitters) { CompRTFuse fuseComp = transmitter.parent.GetComp <CompRTFuse>(); if (fuseComp != null) { totalEnergy -= fuseComp.MitigateSurge(totalEnergy); if (totalEnergy <= 0) { break; } } } } else { shouldStartFire = true; bool mitigated = false; foreach (CompPower transmitter in powerNet.transmitters) { CompRTFuse fuseComp = transmitter.parent.GetComp <CompRTFuse>(); if (fuseComp != null) { fuseComp.MitigateSurge(fuseComp.surgeMitigation); mitigated = true; break; } } startedFire = !mitigated && TryStartFireNear(culprit); } if (culprit.def == ThingDefOf.PowerConduit) { culpritString = "AnElectricalConduit".Translate(); } else { culpritString = Find.ActiveLanguageWorker.WithIndefiniteArticle(culprit.Label); } StringBuilder stringBuilder = new StringBuilder(); if (shouldStartFire) { if (startedFire) { stringBuilder.Append("ShortCircuitStartedFire".Translate(new object[] { culpritString })); } else { stringBuilder.Append("ShortCircuit".Translate(new object[] { culpritString })); } } else { stringBuilder.Append("ShortCircuit".Translate(new object[] { culpritString })); if (totalEnergy > 0f) { explosionRadius = Mathf.Sqrt(totalEnergy) * 0.05f; explosionRadius = Mathf.Clamp(explosionRadius, 1.5f, 14.9f); GenExplosion.DoExplosion(culprit.Position, powerNet.Map, explosionRadius, DamageDefOf.Flame, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false); if (explosionRadius > 3.5f) { GenExplosion.DoExplosion(culprit.Position, powerNet.Map, explosionRadius * 0.3f, DamageDefOf.Bomb, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false); } if (totalEnergy == totalEnergyHistoric) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); stringBuilder.Append("ShortCircuitDischargedEnergy".Translate(new object[] { totalEnergyHistoric.ToString("F0") })); } else { stringBuilder.AppendLine(); stringBuilder.AppendLine(); stringBuilder.Append("IncidentWorker_RTShortCircuit_PartialMitigation".Translate(new object[] { totalEnergyHistoric.ToString("F0"), (totalEnergyHistoric - totalEnergy).ToString("F0") })); } } else { culprit.TakeDamage(new DamageInfo( DamageDefOf.Bomb, Rand.Range(0, (int)Math.Floor(0.1f * culprit.MaxHitPoints)), 0f, -1f, null, null)); stringBuilder.AppendLine(); stringBuilder.AppendLine(); stringBuilder.Append("IncidentWorker_RTShortCircuit_FullMitigation".Translate(new object[] { totalEnergyHistoric.ToString("F0") })); } if (explosionRadius > 5f) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); stringBuilder.Append("ShortCircuitWasLarge".Translate()); } if (explosionRadius > 8f) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); stringBuilder.Append("ShortCircuitWasHuge".Translate()); } } Find.LetterStack.ReceiveLetter("LetterLabelShortCircuit".Translate(), stringBuilder.ToString(), LetterDefOf.NegativeEvent, new TargetInfo(culprit.Position, map, false), null); return(false); }
protected override void Impact(Thing hitThing) { base.Impact(hitThing); Map thisMap = this.launcher.Map; int sizex = thisMap.Size.x; int sizey = thisMap.Size.y; int sizez = thisMap.Size.z; float explosionRadius = Def.explodeClusterSize; int totalRadius = Def.totalRadius; int clusterFrequency = Def.clusterFrequency; int damageToDo = Def.damageToDo; IntVec3 explodePosition; if (hitThing != null) { explodePosition = new IntVec3(hitThing.Position.x, hitThing.Position.y, hitThing.Position.z); } else { explodePosition = new IntVec3(base.Position.x, this.launcher.Position.y, base.launcher.Position.z); } Random rnd = new Random(); int randomChance = rnd.Next(0, 1000); for (int x = (explodePosition.x - totalRadius); x < (explodePosition.x + totalRadius); x++) { for (int z = (explodePosition.z - totalRadius); z < (explodePosition.z + totalRadius); z++) { if (z > 0 && z < sizez && x > 0 && x < sizex) { if (randomChance > clusterFrequency) { GenExplosion.DoExplosion(new IntVec3(x, this.launcher.Position.y, z), this.launcher.Map, explosionRadius, DamageDefOf.Bomb, this, damageToDo, damageToDo); GenClamor.DoClamor(this, explosionRadius, ClamorDefOf.Impact); } if (randomChance < 120) { //GenSpawn.Spawn(ThingDefOf.Fire, new IntVec3(x, this.launcher.Position.y, z), thisMap); Fire fireToStart = (Fire)ThingMaker.MakeThing(ThingDefOf.Fire); fireToStart.fireSize = Fire.MaxFireSize; GenSpawn.Spawn(fireToStart, new IntVec3(x, this.launcher.Position.y, z), thisMap); } if (randomChance > 120 && randomChance < 130) { GenSpawn.Spawn(ThingDefOf.Filth_Dirt, new IntVec3(x, this.launcher.Position.y, z), thisMap); } if (randomChance > 130 && randomChance < 260) { GenSpawn.Spawn(ThingDefOf.Filth_Ash, new IntVec3(x, this.launcher.Position.y, z), thisMap); } } randomChance = rnd.Next(0, 1000); } } //Log.Message("done", true); //well that was a pain in the ass. //} }
public static void MakeColony(params ColonyMakerFlag[] flags) { bool godMode = DebugSettings.godMode; DebugSettings.godMode = true; Thing.allowDestroyNonDestroyable = true; if (Autotests_ColonyMaker.usedCells == null) { Autotests_ColonyMaker.usedCells = new BoolGrid(Autotests_ColonyMaker.Map); } else { Autotests_ColonyMaker.usedCells.ClearAndResizeTo(Autotests_ColonyMaker.Map); } Autotests_ColonyMaker.overRect = new CellRect(Autotests_ColonyMaker.Map.Center.x - 50, Autotests_ColonyMaker.Map.Center.z - 50, 100, 100); Autotests_ColonyMaker.DeleteAllSpawnedPawns(); GenDebug.ClearArea(Autotests_ColonyMaker.overRect, Find.CurrentMap); if (flags.Contains(ColonyMakerFlag.Animals)) { foreach (PawnKindDef current in from k in DefDatabase <PawnKindDef> .AllDefs where k.RaceProps.Animal select k) { CellRect cellRect; if (!Autotests_ColonyMaker.TryGetFreeRect(6, 3, out cellRect)) { return; } cellRect = cellRect.ContractedBy(1); foreach (IntVec3 current2 in cellRect) { Autotests_ColonyMaker.Map.terrainGrid.SetTerrain(current2, TerrainDefOf.Concrete); } GenSpawn.Spawn(PawnGenerator.GeneratePawn(current, null), cellRect.Cells.ElementAt(0), Autotests_ColonyMaker.Map, WipeMode.Vanish); IntVec3 intVec = cellRect.Cells.ElementAt(1); Pawn p = (Pawn)GenSpawn.Spawn(PawnGenerator.GeneratePawn(current, null), intVec, Autotests_ColonyMaker.Map, WipeMode.Vanish); HealthUtility.DamageUntilDead(p); Corpse thing = (Corpse)intVec.GetThingList(Find.CurrentMap).First((Thing t) => t is Corpse); CompRottable compRottable = thing.TryGetComp <CompRottable>(); if (compRottable != null) { compRottable.RotProgress += 1200000f; } if (current.RaceProps.leatherDef != null) { GenSpawn.Spawn(current.RaceProps.leatherDef, cellRect.Cells.ElementAt(2), Autotests_ColonyMaker.Map, WipeMode.Vanish); } if (current.RaceProps.meatDef != null) { GenSpawn.Spawn(current.RaceProps.meatDef, cellRect.Cells.ElementAt(3), Autotests_ColonyMaker.Map, WipeMode.Vanish); } } } if (flags.Contains(ColonyMakerFlag.ConduitGrid)) { Designator_Build designator_Build = new Designator_Build(ThingDefOf.PowerConduit); for (int i = Autotests_ColonyMaker.overRect.minX; i < Autotests_ColonyMaker.overRect.maxX; i++) { for (int j = Autotests_ColonyMaker.overRect.minZ; j < Autotests_ColonyMaker.overRect.maxZ; j += 7) { designator_Build.DesignateSingleCell(new IntVec3(i, 0, j)); } } for (int k2 = Autotests_ColonyMaker.overRect.minZ; k2 < Autotests_ColonyMaker.overRect.maxZ; k2++) { for (int l = Autotests_ColonyMaker.overRect.minX; l < Autotests_ColonyMaker.overRect.maxX; l += 7) { designator_Build.DesignateSingleCell(new IntVec3(l, 0, k2)); } } } if (flags.Contains(ColonyMakerFlag.PowerPlants)) { List <ThingDef> list = new List <ThingDef> { ThingDefOf.SolarGenerator, ThingDefOf.WindTurbine }; for (int m = 0; m < 8; m++) { if (Autotests_ColonyMaker.TryMakeBuilding(list[m % list.Count]) == null) { Log.Message("Could not make solar generator.", false); break; } } } if (flags.Contains(ColonyMakerFlag.Batteries)) { for (int n = 0; n < 6; n++) { Thing thing2 = Autotests_ColonyMaker.TryMakeBuilding(ThingDefOf.Battery); if (thing2 == null) { Log.Message("Could not make battery.", false); break; } ((Building_Battery)thing2).GetComp <CompPowerBattery>().AddEnergy(999999f); } } if (flags.Contains(ColonyMakerFlag.WorkTables)) { IEnumerable <ThingDef> enumerable = from def in DefDatabase <ThingDef> .AllDefs where typeof(Building_WorkTable).IsAssignableFrom(def.thingClass) select def; foreach (ThingDef current3 in enumerable) { Thing thing3 = Autotests_ColonyMaker.TryMakeBuilding(current3); if (thing3 == null) { Log.Message("Could not make worktable: " + current3.defName, false); break; } Building_WorkTable building_WorkTable = thing3 as Building_WorkTable; if (building_WorkTable != null) { foreach (RecipeDef current4 in building_WorkTable.def.AllRecipes) { building_WorkTable.billStack.AddBill(current4.MakeNewBill()); } } } } if (flags.Contains(ColonyMakerFlag.AllBuildings)) { IEnumerable <ThingDef> enumerable2 = from def in DefDatabase <ThingDef> .AllDefs where def.category == ThingCategory.Building && def.BuildableByPlayer select def; foreach (ThingDef current5 in enumerable2) { if (current5 != ThingDefOf.PowerConduit) { if (Autotests_ColonyMaker.TryMakeBuilding(current5) == null) { Log.Message("Could not make building: " + current5.defName, false); break; } } } } CellRect rect; if (!Autotests_ColonyMaker.TryGetFreeRect(33, 33, out rect)) { Log.Error("Could not get wallable rect", false); } rect = rect.ContractedBy(1); if (flags.Contains(ColonyMakerFlag.AllItems)) { List <ThingDef> itemDefs = (from def in DefDatabase <ThingDef> .AllDefs where DebugThingPlaceHelper.IsDebugSpawnable(def, false) && def.category == ThingCategory.Item select def).ToList <ThingDef>(); Autotests_ColonyMaker.FillWithItems(rect, itemDefs); } else if (flags.Contains(ColonyMakerFlag.ItemsRawFood)) { List <ThingDef> list2 = new List <ThingDef>(); list2.Add(ThingDefOf.RawPotatoes); Autotests_ColonyMaker.FillWithItems(rect, list2); } if (flags.Contains(ColonyMakerFlag.Filth)) { foreach (IntVec3 current6 in rect) { GenSpawn.Spawn(ThingDefOf.Filth_Dirt, current6, Autotests_ColonyMaker.Map, WipeMode.Vanish); } } if (flags.Contains(ColonyMakerFlag.ItemsWall)) { CellRect cellRect2 = rect.ExpandedBy(1); Designator_Build designator_Build2 = new Designator_Build(ThingDefOf.Wall); designator_Build2.SetStuffDef(ThingDefOf.WoodLog); foreach (IntVec3 current7 in cellRect2.EdgeCells) { designator_Build2.DesignateSingleCell(current7); } } if (flags.Contains(ColonyMakerFlag.ColonistsMany)) { Autotests_ColonyMaker.MakeColonists(15, Autotests_ColonyMaker.overRect.CenterCell); } else if (flags.Contains(ColonyMakerFlag.ColonistOne)) { Autotests_ColonyMaker.MakeColonists(1, Autotests_ColonyMaker.overRect.CenterCell); } if (flags.Contains(ColonyMakerFlag.Fire)) { CellRect cellRect3; if (!Autotests_ColonyMaker.TryGetFreeRect(30, 30, out cellRect3)) { Log.Error("Could not get free rect for fire.", false); } ThingDef plant_TreeOak = ThingDefOf.Plant_TreeOak; foreach (IntVec3 current8 in cellRect3) { GenSpawn.Spawn(plant_TreeOak, current8, Autotests_ColonyMaker.Map, WipeMode.Vanish); } foreach (IntVec3 current9 in cellRect3) { if (current9.x % 7 == 0 && current9.z % 7 == 0) { GenExplosion.DoExplosion(current9, Find.CurrentMap, 3.9f, DamageDefOf.Flame, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false); } } } if (flags.Contains(ColonyMakerFlag.ColonistsHungry)) { Autotests_ColonyMaker.DoToColonists(0.4f, delegate(Pawn col) { col.needs.food.CurLevel = Mathf.Max(0f, Rand.Range(-0.05f, 0.05f)); }); } if (flags.Contains(ColonyMakerFlag.ColonistsTired)) { Autotests_ColonyMaker.DoToColonists(0.4f, delegate(Pawn col) { col.needs.rest.CurLevel = Mathf.Max(0f, Rand.Range(-0.05f, 0.05f)); }); } if (flags.Contains(ColonyMakerFlag.ColonistsInjured)) { Autotests_ColonyMaker.DoToColonists(0.4f, delegate(Pawn col) { DamageDef def = (from d in DefDatabase <DamageDef> .AllDefs where d.ExternalViolenceFor(null) select d).RandomElement <DamageDef>(); col.TakeDamage(new DamageInfo(def, 10f, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null)); }); } if (flags.Contains(ColonyMakerFlag.ColonistsDiseased)) { foreach (HediffDef current10 in from d in DefDatabase <HediffDef> .AllDefs where d.hediffClass != typeof(Hediff_AddedPart) && (d.HasComp(typeof(HediffComp_Immunizable)) || d.HasComp(typeof(HediffComp_GrowthMode))) select d) { Pawn pawn = PawnGenerator.GeneratePawn(Faction.OfPlayer.def.basicMemberKind, Faction.OfPlayer); CellRect cellRect4; Autotests_ColonyMaker.TryGetFreeRect(1, 1, out cellRect4); GenSpawn.Spawn(pawn, cellRect4.CenterCell, Autotests_ColonyMaker.Map, WipeMode.Vanish); pawn.health.AddHediff(current10, null, null, null); } } if (flags.Contains(ColonyMakerFlag.Beds)) { IEnumerable <ThingDef> source = from def in DefDatabase <ThingDef> .AllDefs where def.thingClass == typeof(Building_Bed) select def; int freeColonistsCount = Autotests_ColonyMaker.Map.mapPawns.FreeColonistsCount; for (int num = 0; num < freeColonistsCount; num++) { if (Autotests_ColonyMaker.TryMakeBuilding(source.RandomElement <ThingDef>()) == null) { Log.Message("Could not make beds.", false); break; } } } if (flags.Contains(ColonyMakerFlag.Stockpiles)) { Designator_ZoneAddStockpile_Resources designator_ZoneAddStockpile_Resources = new Designator_ZoneAddStockpile_Resources(); foreach (StoragePriority priority in Enum.GetValues(typeof(StoragePriority))) { CellRect cellRect5; Autotests_ColonyMaker.TryGetFreeRect(7, 7, out cellRect5); cellRect5 = cellRect5.ContractedBy(1); designator_ZoneAddStockpile_Resources.DesignateMultiCell(cellRect5.Cells); Zone_Stockpile zone_Stockpile = (Zone_Stockpile)Autotests_ColonyMaker.Map.zoneManager.ZoneAt(cellRect5.CenterCell); zone_Stockpile.settings.Priority = priority; } } if (flags.Contains(ColonyMakerFlag.GrowingZones)) { Zone_Growing dummyZone = new Zone_Growing(Autotests_ColonyMaker.Map.zoneManager); Autotests_ColonyMaker.Map.zoneManager.RegisterZone(dummyZone); foreach (ThingDef current11 in from d in DefDatabase <ThingDef> .AllDefs where d.plant != null && PlantUtility.CanSowOnGrower(d, dummyZone) select d) { CellRect cellRect6; if (!Autotests_ColonyMaker.TryGetFreeRect(6, 6, out cellRect6)) { Log.Error("Could not get growing zone rect.", false); } cellRect6 = cellRect6.ContractedBy(1); foreach (IntVec3 current12 in cellRect6) { Autotests_ColonyMaker.Map.terrainGrid.SetTerrain(current12, TerrainDefOf.Soil); } Designator_ZoneAdd_Growing designator_ZoneAdd_Growing = new Designator_ZoneAdd_Growing(); designator_ZoneAdd_Growing.DesignateMultiCell(cellRect6.Cells); Zone_Growing zone_Growing = Autotests_ColonyMaker.Map.zoneManager.ZoneAt(cellRect6.CenterCell) as Zone_Growing; if (zone_Growing != null) { zone_Growing.SetPlantDefToGrow(current11); } } dummyZone.Delete(); } Autotests_ColonyMaker.ClearAllHomeArea(); Autotests_ColonyMaker.FillWithHomeArea(Autotests_ColonyMaker.overRect); DebugSettings.godMode = godMode; Thing.allowDestroyNonDestroyable = false; }
public override void PawnDied(Corpse corpse) { GenExplosion.DoExplosion(corpse.Position, corpse.Map, 1.9f, DamageDefOf.Flame, corpse.InnerPawn, -1, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false); }
public override void PawnDied(Corpse corpse) { GenExplosion.DoExplosion(corpse.Position, corpse.Map, 1.9f, InternalDefOf.GR_Acid, corpse.InnerPawn, 10, -1, InternalDefOf.GR_Pop, null, null, null, ThingDef.Named("Filth_Fuel"), 0.3f, 1, false, null, 0f, 1); }
// Token: 0x06002627 RID: 9767 RVA: 0x00122210 File Offset: 0x00120610 public override void Tick() { if (base.Spawned) { HiveLike hive = (HiveLike)ThingMaker.MakeThing(hiveDef, null); this.sustainer.Maintain(); Vector3 vector = base.Position.ToVector3Shifted(); IntVec3 c; ResetStaticData(); if (Rand.MTBEventOccurs(FilthSpawnMTB, 1f, 1.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(base.Position, base.Map, TunnelHiveLikeSpawner.FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c, 999999)) { FilthMaker.MakeFilth(c, base.Map, filthTypes.RandomElement <ThingDef>(), 1); } if (Rand.MTBEventOccurs(DustMoteSpawnMTB, 1f, 1.TicksToSeconds())) { MoteMaker.ThrowDustPuffThick(new Vector3(vector.x, 0f, vector.z) { y = AltitudeLayer.MoteOverhead.AltitudeFor() }, base.Map, Rand.Range(1.5f, 3f), new Color(1f, 1f, 1f, 2.5f)); } if (this.secondarySpawnTick <= Find.TickManager.TicksGame) { this.sustainer.End(); Map map = base.Map; IntVec3 position = base.Position; this.Destroy(DestroyMode.Vanish); if (this.spawnHive) { if (Def.strikespreexplode) { FireEvent(map, position); EventDraw(map, position); } if (Def.explodesprespawn) { GenExplosion.DoExplosion(position, map, Def.blastradius, Def.damageDef, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false); } hive = (HiveLike)GenSpawn.Spawn(ThingMaker.MakeThing(hiveDef, null), position, map, WipeMode.Vanish); hive.SetFaction(faction, null); foreach (CompSpawnerLike compSpawner in hive.GetComps <CompSpawnerLike>()) { if (compSpawner.PropsSpawner.thingToSpawn == ThingDefOf.InsectJelly) { compSpawner.TryDoSpawn(); break; } } } if (this.hivePoints > 0f) { this.hivePoints = Mathf.Max(this.hivePoints, pawnKinds.Min((PawnKindDef x) => x.combatPower)); float pointsLeft = this.hivePoints; List <Pawn> list = new List <Pawn>(); int num = 0; while (pointsLeft > 0f) { num++; if (num > 1000) { Log.Error("Too many iterations.", false); break; } IEnumerable <PawnKindDef> source = from x in pawnKinds where x.combatPower <= pointsLeft select x; PawnKindDef pawnKindDef; if (!source.TryRandomElement(out pawnKindDef)) { break; } Pawn pawn = PawnGenerator.GeneratePawn(pawnKindDef, faction); GenSpawn.Spawn(pawn, CellFinder.RandomClosewalkCellNear(position, map, 2, null), map, WipeMode.Vanish); pawn.mindState.spawnedByInfestationThingComp = this.spawnedByInfestationThingComp; list.Add(pawn); pointsLeft -= pawnKindDef.combatPower; } if (list.Any <Pawn>()) { LordMaker.MakeNewLord(faction, new LordJob_AssaultColony(faction, true, false, false, false, true), map, list); } } } } }
protected new void Impact(Thing hitThing) { bool flag = hitThing == null; if (flag) { Pawn pawn; bool flag2 = (pawn = (base.Position.GetThingList(base.Map).FirstOrDefault((Thing x) => x == this.assignedTarget) as Pawn)) != null; if (flag2) { hitThing = pawn; } } bool hasValue = this.impactDamage.HasValue; if (hasValue) { for (int i = 0; i < this.timesToDamage; i++) { bool flag3 = this.damageLaunched; if (flag3) { this.flyingThing.TakeDamage(this.impactDamage.Value); } else { hitThing.TakeDamage(this.impactDamage.Value); } } bool flag4 = this.explosion; if (flag4) { GenExplosion.DoExplosion(base.Position, base.Map, 0.9f, DamageDefOf.Stun, this, -1, 0, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false); } } try { SoundDefOf.Ambient_AltitudeWind.sustainFadeoutTime.Equals(30.0f); this.FireExplosion(pwrVal, verVal, base.Position, base.Map, (1.2f + (float)(verVal * .8f))); MoteMaker.ThrowSmoke(pawn.Position.ToVector3(), base.Map, (0.8f + (float)(verVal * .8f))); for (int i = 0; i < (2 + verVal); i++) { expCell1 = GetNewPos(expCell1, this.origin.x <= this.DestinationCell.x, this.origin.z <= this.DestinationCell.z, false, 0, 0, xProb, 1 - xProb); MoteMaker.ThrowSmoke(expCell1.ToVector3(), base.Map, 1.6f); expCell2 = GetNewPos(expCell2, this.origin.x <= this.DestinationCell.x, this.origin.z <= this.DestinationCell.z, false, 0, 0, 1 - xProb, xProb); MoteMaker.ThrowSmoke(expCell2.ToVector3(), base.Map, 1.6f); } for (int i = 0; i < (4 + (3 * verVal)); i++) { CellRect cellRect = CellRect.CenteredOn(expCell1, (1 + verVal)); cellRect.ClipInsideMap(base.Map); IntVec3 randomCell = cellRect.RandomCell; this.FireExplosion(pwrVal, verVal, randomCell, base.Map, .4f); cellRect = CellRect.CenteredOn(expCell2, (1 + verVal)); randomCell = cellRect.RandomCell; this.FireExplosion(pwrVal, verVal, randomCell, base.Map, .4f); } GenSpawn.Spawn(this.flyingThing, base.Position, base.Map); ModOptions.Constants.SetPawnInFlight(false); Pawn p = this.flyingThing as Pawn; RemoveInvul(p); this.Destroy(DestroyMode.Vanish); } catch { GenSpawn.Spawn(this.flyingThing, base.Position, base.Map); ModOptions.Constants.SetPawnInFlight(false); Pawn p = this.flyingThing as Pawn; RemoveInvul(p); this.Destroy(DestroyMode.Vanish); } }
public override void Destroy(DestroyMode mode = DestroyMode.Vanish) { GenExplosion.DoExplosion(Position, Map, 8f, DamageDefOf.Bomb, null); base.Destroy(mode); }
protected override void Impact(Thing hitThing) { base.Impact(hitThing); ThingDef def = this.def; if (!initialized) { pawn = this.launcher as Pawn; float psychicEnergy = pawn.GetStatValue(StatDefOf.PsychicSensitivity, false); CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_PsychicShock.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_PsychicShock_pwr"); MagicPowerSkill ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_PsychicShock.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_PsychicShock_ver"); ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); pwrVal = pwr.level; verVal = ver.level; this.arcaneDmg = comp.arcaneDmg * psychicEnergy; if (settingsRef.AIHardMode && !pawn.IsColonist) { pwrVal = 3; verVal = 3; } explosionCenters.Add(base.Position); explosionRadii.Add(1); shockedPawns.Add(pawn); this.maxRadius += verVal; this.initialized = true; } if (Find.TickManager.TicksGame % frequency == 0) { for (int i = 0; i < explosionCenters.Count(); i++) { if (explosionRadii[i] == 1) { targets = GenRadial.RadialCellsAround(explosionCenters[i], explosionRadii[i], false); } else { IEnumerable <IntVec3> oldTargets = GenRadial.RadialCellsAround(explosionCenters[i], explosionRadii[i] - 1, false); targets = GenRadial.RadialCellsAround(explosionCenters[i], explosionRadii[i], false).Except(oldTargets); } for (int j = 0; j < targets.Count(); j++) { IntVec3 curCell = targets.ToArray <IntVec3>()[j]; if (curCell.IsValid && curCell.InBounds(pawn.Map)) { Vector3 angle = GetVector(explosionCenters[i], curCell); TM_MoteMaker.ThrowArcaneWaveMote(curCell.ToVector3(), pawn.Map, .2f * (curCell - explosionCenters[i]).LengthHorizontal, .1f, .05f, .3f, 0, 3, (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat(), (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat()); Pawn victim = curCell.GetFirstPawn(pawn.Map); if (victim != null && !victim.Dead) { if (victim.Faction != this.pawn.Faction) { GenExplosion.DoExplosion(curCell, pawn.Map, .4f, DamageDefOf.Stun, this.launcher, Mathf.RoundToInt((4 * (this.def.projectile.GetDamageAmount(1, null) + pwrVal) * this.arcaneDmg)), 0, SoundDefOf.Crunch, def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0f, false); } else { GenExplosion.DoExplosion(curCell, pawn.Map, .4f, DamageDefOf.Stun, this.launcher, Mathf.RoundToInt(((this.def.projectile.GetDamageAmount(1, null) + pwrVal) * this.arcaneDmg)), 0, SoundDefOf.Crunch, def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0f, false); } } if (victim != null && !victim.Dead && victim.RaceProps.IsFlesh && Rand.Chance(victim.GetStatValue(StatDefOf.PsychicSensitivity, false))) { if (!shockedPawns.Contains(victim)) { explosionCenters.Add(victim.Position); shockedPawns.Add(victim); explosionRadii.Add(1); if (victim != pawn && victim.Faction != pawn.Faction && Rand.Chance(victim.GetStatValue(StatDefOf.PsychicSensitivity, false))) { DoMentalDamage(victim); } } } } } explosionRadii[i]++; if (explosionRadii[i] > this.maxRadius) { explosionRadii.Remove(explosionRadii[i]); explosionCenters.Remove(explosionCenters[i]); } if (explosionCenters.Count() == 0) { this.age = this.duration; this.Destroy(DestroyMode.Vanish); } } } }
/// <summary> /// Clean up when it is destroyed /// </summary> public override void Destroy(DestroyMode mode = DestroyMode.Vanish) { if (Map == null) { base.Destroy(DestroyMode.Vanish); return; } // Check for in bed bool isInBed = IsInBed(Map); bool notConscious = false; if (health.capacities.GetLevel(PawnCapacityDefOf.Consciousness) < 0.02f) { notConscious = true; } // No explosion while under anesthetic or shutdown bool doExplosion = true; if (!isAnestheticIncap && !isInBed && !notConscious) { doExplosion = false; } Map lastMap = this.Map; IntVec3 lastPosition = this.Position; if (!Destroyed) { base.Destroy(DestroyMode.Vanish); } else { // Is already destroyed? } if (lastMap == null) { return; } // If destroyed go with an explosion if (!destroyMeWithoutExplosion) { // No explosion while under anesthetic or shutdown if (doExplosion) { GenExplosion.DoExplosion(lastPosition, lastMap, 2.4f, DamageDefOf.Bomb, this); } if (enhancedAI) { Thing thing = ThingMaker.MakeThing(ThingDef.Named(thingDefName_KilledLeaving), null); GenPlace.TryPlaceThing(thing, lastPosition, lastMap, ThingPlaceMode.Near, out thing); thing.stackCount = Rand.RangeInclusive(10, 50); thing.SetForbidden(true); } else { Thing thing = ThingMaker.MakeThing(ThingDef.Named(thingDefName_KilledLeaving), null); GenPlace.TryPlaceThing(thing, lastPosition, lastMap, ThingPlaceMode.Near, out thing); thing.stackCount = Rand.RangeInclusive(5, 40); thing.SetForbidden(true); } } }