protected override bool TryCastShot() { Pawn caster = base.CasterPawn; Pawn pawn = this.currentTarget.Thing as Pawn; CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = comp.MagicData.MagicPowerSkill_Purify.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Purify_pwr"); MagicPowerSkill ver = comp.MagicData.MagicPowerSkill_Purify.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Purify_ver"); pwrVal = pwr.level; verVal = ver.level; if (caster.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; } bool flag = pawn != null && !pawn.Dead; if (flag) { int num = Mathf.RoundToInt(1f + (.4f * verVal)); using (IEnumerator <BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator()) { while (enumerator.MoveNext()) { BodyPartRecord rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { int num2 = 1 + verVal; IEnumerable <Hediff_Injury> arg_BB_0 = pawn.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 flag4 = num2 > 0; if (flag4) { bool flag5 = !current.CanHealNaturally() && current.IsPermanent(); if (flag5) { if (rec.def.tags.Contains(BodyPartTagDefOf.ConsciousnessSource)) { if (pwrVal >= 1) { current.Heal(pwrVal * comp.arcaneDmg); num--; num2--; } } else { current.Heal((2f + pwrVal * 2) * comp.arcaneDmg); //current.Heal(5.0f + (float)pwrVal * 3f); // power affects how much to heal num--; num2--; } TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f); TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f); } } } } } } //if (pawn.RaceProps.Humanlike) //{ using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { if (rec.def.defName == "Cataract" || rec.def.defName == "HearingLoss" || rec.def.defName.Contains("ToxicBuildup")) { rec.Heal(.4f + .3f * pwrVal); num--; } if ((rec.def.defName == "Blindness" || rec.def.defName.Contains("Asthma") || rec.def.defName == "Cirrhosis" || rec.def.defName == "ChemicalDamageModerate") && verVal >= 1) { rec.Heal(.3f + .2f * pwrVal); if (rec.def.defName.Contains("Asthma")) { pawn.health.RemoveHediff(rec); } num--; } if ((rec.def.defName == "Frail" || rec.def.defName == "BadBack" || rec.def.defName.Contains("Carcinoma") || rec.def.defName == "ChemicalDamageSevere") && verVal >= 2) { rec.Heal(.2f + .15f * pwrVal); num--; } if ((rec.def.defName.Contains("Alzheimers") || rec.def.defName == "Dementia" || rec.def.defName.Contains("HeartArteryBlockage") || rec.def.defName == "PsychicShock" || rec.def.defName == "CatatonicBreakdown") && verVal >= 3) { rec.Heal(.1f + .1f * pwrVal); num--; } TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f); TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f); } } } //} using (IEnumerator <Hediff_Addiction> enumerator = pawn.health.hediffSet.GetHediffs <Hediff_Addiction>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff_Addiction rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { if (rec.Chemical.defName == "Alcohol" || rec.Chemical.defName == "Smokeleaf") { rec.Severity -= ((.3f + .3f * pwrVal) * comp.arcaneDmg); num--; } if ((rec.Chemical.defName == "GoJuice" || rec.Chemical.defName == "WakeUp") && verVal >= 1) { rec.Severity -= ((.25f + .25f * pwrVal) * comp.arcaneDmg); num--; } if (rec.Chemical.defName == "Psychite" && verVal >= 2) { rec.Severity -= ((.25f + .25f * pwrVal) * comp.arcaneDmg); num--; } if (verVal >= 3) { if (rec.Chemical.defName == "Luciferium" && (rec.Severity - ((.15f + .15f * pwrVal) * comp.arcaneDmg) < 0)) { Hediff luciHigh = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("LuciferiumHigh"), false); pawn.health.RemoveHediff(luciHigh); } rec.Severity -= ((.15f + .15f * pwrVal) * comp.arcaneDmg); num--; } TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f); TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f); } } } } return(true); }
public override void Tick() { if (!initialized) { DetermineElementalType(); BeginAssaultCondition(); SpawnCycle(); this.ticksTillNextAssault = Rand.Range(1600, 3000); this.ticksTillNextEvent = (int)(Rand.Range(160, 300) * this.eventFrequencyMultiplier); initialized = true; } if (Find.TickManager.TicksGame % 8 == 0) { this.assaultTimer += 8; this.eventTimer += 8; this.matRng = Rand.RangeInclusive(0, 2); this.matMagnitude = 4 * this.arcaneEnergyMax; Vector3 rndVec = this.DrawPos; if (this.rnd < 2) //earth { rndVec.x += Rand.Range(-5, 5); rndVec.z += Rand.Range(-5, 5); MoteMaker.ThrowSmoke(rndVec, this.Map, Rand.Range(.6f, 1.2f)); } else if (this.rnd < 4) //fire { rndVec.x += Rand.Range(-1.2f, 1.2f); rndVec.z += Rand.Range(-1.2f, 1.2f); TM_MoteMaker.ThrowFlames(rndVec, this.Map, Rand.Range(.6f, 1f)); } else if (this.rnd < 6) //water { rndVec.x += Rand.Range(-2f, 2f); rndVec.z += Rand.Range(-2f, 2f); TM_MoteMaker.ThrowManaPuff(rndVec, this.Map, Rand.Range(.6f, 1f)); } else //air { rndVec.x += Rand.Range(-2f, 2f); rndVec.z += Rand.Range(-2f, 2f); MoteMaker.ThrowLightningGlow(rndVec, this.Map, Rand.Range(.6f, .8f)); } } if (this.eventTimer > this.ticksTillNextEvent) { DoMapEvent(); this.eventTimer = 0; this.ticksTillNextEvent = (int)(Rand.Range(160, 300) * this.eventFrequencyMultiplier); } if (this.notifier == false && this.assaultTimer > (.9f * this.ticksTillNextAssault)) { Messages.Message("TM_AssaultPending".Translate(), MessageTypeDefOf.ThreatSmall); this.notifier = true; } if (this.assaultTimer > this.ticksTillNextAssault) { SpawnCycle(); this.assaultTimer = 0; this.ticksTillNextAssault = Rand.Range(1600, 3000); this.notifier = false; } }
public void DrawStrike(IntVec3 center, Vector3 strikePos, Map map) { TM_MoteMaker.ThrowMultiStrike(strikePos, map, .5f); TM_MoteMaker.ThrowBloodSquirt(strikePos, map, 1.2f); }
public void ConsumeAnimalKind(Corpse corpse) { TM_MoteMaker.ThrowSiphonMote(corpse.Position.ToVector3Shifted(), corpse.Map, .8f); TM_MoteMaker.ThrowBloodSquirt(corpse.Position.ToVector3Shifted(), corpse.Map, 1.5f); TM_MoteMaker.ThrowManaPuff(caster.Position.ToVector3Shifted(), caster.Map, .8f); }
//non-saved vars protected override void Impact(Thing hitThing) { GenClamor.DoClamor(this, 2.1f, ClamorDefOf.Impact); caster = this.launcher as Pawn; Building existingSentinel = base.Position.GetFirstBuilding(caster.Map); if (existingSentinel != null) { if (existingSentinel.def.defName == "TM_Sentinel") { for (int m = 0; m < 5; m++) { TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_ThickDust"), base.Position.ToVector3Shifted(), caster.Map, Rand.Range(.4f, .7f), Rand.Range(.2f, .3f), .05f, Rand.Range(.4f, .6f), Rand.Range(-20, 20), Rand.Range(.5f, 1f), Rand.Range(0, 360), Rand.Range(0, 360)); } existingSentinel.Destroy(DestroyMode.Vanish); } else { Messages.Message("TM_NoSpawnSentinelOnBuilding".Translate( caster.LabelShort ), MessageTypeDefOf.RejectInput, false); } } else { CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); verVal = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Sentinel.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Sentinel_ver").level; if (comp.summonedSentinels.Count > verVal + 1) { Messages.Message("TM_TooManySentinels".Translate( caster.LabelShort, verVal + 2 ), MessageTypeDefOf.NeutralEvent); Thing tempThing = comp.summonedSentinels[0]; comp.summonedSentinels.Remove(tempThing); if (tempThing != null && !tempThing.Destroyed) { tempThing.Destroy(); } } AbilityUser.SpawnThings tempPod = new SpawnThings(); tempPod.def = ThingDef.Named("TM_Sentinel"); tempPod.spawnCount = 1; SingleSpawnLoop(tempPod, base.Position, caster.Map); float magnitude = (base.Position.ToVector3Shifted() - Find.Camera.transform.position).magnitude; Find.CameraDriver.shaker.DoShake(4 / magnitude); for (int m = 0; m < 5; m++) { TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_ThickDust"), base.Position.ToVector3Shifted(), caster.Map, Rand.Range(.4f, .7f), Rand.Range(.2f, .3f), .05f, Rand.Range(.4f, .6f), Rand.Range(-20, 20), Rand.Range(.5f, 1f), Rand.Range(0, 360), Rand.Range(0, 360)); } if (this.spawnedThing != null) { comp.summonedSentinels.Add(spawnedThing); } } Destroy(); }
protected override bool TryCastShot() { Pawn p = this.CasterPawn; Map map = this.CasterPawn.Map; CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>(); corpses.Clear(); pawns.Clear(); plants.Clear(); GenClamor.DoClamor(p, this.UseAbilityProps.TargetAoEProperties.range, ClamorDefOf.Ability); Effecter igniteED = TorannMagicDefOf.TM_IgniteED.Spawn(); igniteED.Trigger(new TargetInfo(this.currentTarget.Cell, map, false), new TargetInfo(this.currentTarget.Cell, map, false)); igniteED.Cleanup(); SoundInfo info = SoundInfo.InMap(new TargetInfo(this.currentTarget.Cell, map, false), MaintenanceType.None); info.pitchFactor = 1.1f; info.volumeFactor = 1.8f; TorannMagicDefOf.TM_FireWooshSD.PlayOneShot(info); TargetInfo ti = new TargetInfo(this.currentTarget.Cell, map, false); TM_MoteMaker.MakeOverlay(ti, TorannMagicDefOf.TM_Mote_PsycastAreaEffect, map, Vector3.zero, .2f, 0f, .1f, .4f, .4f, 4.3f); float classBonus = 1f; if (p.story != null && p.story.traits != null && p.story.traits.HasTrait(TorannMagicDefOf.InnerFire)) { classBonus = 1.5f; } if (this.currentTarget != null && p != null && comp != null) { this.arcaneDmg = comp.arcaneDmg; this.TargetsAoE.Clear(); this.FindTargets(); float energy = 200000 * this.arcaneDmg * classBonus; GenTemperature.PushHeat(this.currentTarget.Cell, p.Map, energy); ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); for (int i = 0; i < pawns.Count; i++) { if (!pawns[i].RaceProps.IsMechanoid) { float distanceModifier = (classBonus) / (pawns[i].Position - currentTarget.Cell).LengthHorizontal; if (distanceModifier > 1f) { distanceModifier = 1f; } if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, pawns[i], true)) && Rand.Chance(distanceModifier)) { pawns[i].TryAttachFire(Rand.Range(distanceModifier / 2f, distanceModifier)); } } } for (int i = 0; i < corpses.Count; i++) { //if (corpses[i].CanEverAttachFire()) //{ float distanceModifier = 1f / (corpses[i].Position - currentTarget.Cell).LengthHorizontal; // corpses[i].TryAttachFire(Rand.Range(distanceModifier / 2f, distanceModifier)); FireUtility.TryStartFireIn(corpses[i].Position, map, Rand.Range(distanceModifier / 2f, distanceModifier)); //} } for (int i = 0; i < plants.Count; i++) { float distanceModifier = 1f / (plants[i].Position - currentTarget.Cell).LengthHorizontal; if (distanceModifier > 1f) { distanceModifier = 1f; } if (plants[i].def.plant.IsTree) { if (Rand.Chance(distanceModifier / 2f)) { plants[i].TryAttachFire(Rand.Range(distanceModifier / 3f, distanceModifier / 2f)); FireUtility.TryStartFireIn(plants[i].Position, map, Rand.Range(distanceModifier / 3f, distanceModifier / 2f)); } } else { if (Rand.Chance(distanceModifier)) { plants[i].TryAttachFire(Rand.Range(distanceModifier / 2f, distanceModifier)); FireUtility.TryStartFireIn(plants[i].Position, map, Rand.Range(distanceModifier / 2f, distanceModifier)); } } } List <IntVec3> cellList = GenRadial.RadialCellsAround(this.currentTarget.Cell, this.UseAbilityProps.TargetAoEProperties.range, true).ToList(); bool raining = map.weatherManager.RainRate > 0f || map.weatherManager.SnowRate > 0f; for (int i = 0; i < cellList.Count; i++) { cellList[i] = cellList[i].ClampInsideMap(map); if (cellList[i].GetSnowDepth(map) > 0f) { map.snowGrid.SetDepth(cellList[i], 0f); FleckMaker.ThrowSmoke(cellList[i].ToVector3Shifted(), map, Rand.Range(.8f, 1.6f)); Thing smoke = ThingMaker.MakeThing(ThingDefOf.Gas_Smoke, null); GenSpawn.Spawn(smoke, cellList[i], map, WipeMode.Vanish); } else if (raining || cellList[i].GetTerrain(map).IsWater) { Thing smoke = ThingMaker.MakeThing(ThingDefOf.Gas_Smoke, null); GenSpawn.Spawn(smoke, cellList[i], map, WipeMode.Vanish); } TM_FleckMaker.ThrowGenericFleck(FleckDefOf.AirPuff, cellList[i].ToVector3Shifted(), map, 2.5f, .05f, .05f, Rand.Range(2f, 3f), Rand.Range(-60, 60), .5f, -70, Rand.Range(0, 360)); } } this.burstShotsLeft = 0; return(true); }
protected override bool TryCastShot() { Pawn p = this.CasterPawn; Map map = this.CasterPawn.Map; CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>(); pawns.Clear(); plants.Clear(); GenClamor.DoClamor(p, this.UseAbilityProps.TargetAoEProperties.range, ClamorDefOf.Ability); Effecter snapeFreezeED = TorannMagicDefOf.TM_SnapFreezeED.Spawn(); snapeFreezeED.Trigger(new TargetInfo(this.currentTarget.Cell, map, false), new TargetInfo(this.currentTarget.Cell, map, false)); snapeFreezeED.Cleanup(); SoundInfo info = SoundInfo.InMap(new TargetInfo(this.currentTarget.Cell, map, false), MaintenanceType.None); info.pitchFactor = .4f; info.volumeFactor = 1.2f; TorannMagicDefOf.TM_WindLowSD.PlayOneShot(info); TargetInfo ti = new TargetInfo(this.currentTarget.Cell, map, false); TM_MoteMaker.MakeOverlay(ti, TorannMagicDefOf.TM_Mote_PsycastAreaEffect, map, Vector3.zero, 3f, 0f, .1f, .4f, 1.2f, -3f); float classBonus = 1f; if (p.story != null && p.story.traits != null && p.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost)) { classBonus = 1.5f; } if (this.currentTarget != null && p != null && comp != null) { this.arcaneDmg = comp.arcaneDmg; this.TargetsAoE.Clear(); this.FindTargets(); float energy = -125000 * this.arcaneDmg * classBonus; GenTemperature.PushHeat(this.currentTarget.Cell, p.Map, energy); for (int i = 0; i < pawns.Count; i++) { if (!pawns[i].RaceProps.IsMechanoid && pawns[i].RaceProps.body.AllPartsVulnerableToFrostbite.Count > 0) { float distanceModifier = 1f / (pawns[i].Position - currentTarget.Cell).LengthHorizontal; if (distanceModifier > 1f) { distanceModifier = 1f; } int bites = Mathf.RoundToInt(Rand.Range(1f, 5f) * classBonus); for (int j = 0; j < bites; j++) { if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, pawns[i], true)) && Rand.Chance(distanceModifier)) { TM_Action.DamageEntities(pawns[i], pawns[i].def.race.body.AllPartsVulnerableToFrostbite.RandomElement(), Rand.Range(10, 20) * distanceModifier, 1f, DamageDefOf.Frostbite, p); } if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, pawns[i], true)) && Rand.Chance(distanceModifier)) { HealthUtility.AdjustSeverity(pawns[i], HediffDefOf.Hypothermia, distanceModifier / 5f); } } } } for (int i = 0; i < plants.Count; i++) { float distanceModifier = 1f / (plants[i].Position - currentTarget.Cell).LengthHorizontal; if (distanceModifier > 1f) { distanceModifier = 1f; } if (plants[i].def.plant.IsTree) { if (Rand.Chance(distanceModifier / 2f)) { plants[i].MakeLeafless(Plant.LeaflessCause.Cold); } } else { if (Rand.Chance(distanceModifier)) { plants[i].MakeLeafless(Plant.LeaflessCause.Cold); } } plants[i].Notify_ColorChanged(); } IEnumerable <IntVec3> cellList = GenRadial.RadialCellsAround(this.currentTarget.Cell, this.UseAbilityProps.TargetAoEProperties.range, true); foreach (var cell in cellList) { cell.ClampInsideMap(map); SnowUtility.AddSnowRadial(cell, map, 2.4f, Rand.Range(.08f, .13f)); TM_MoteMaker.ThrowGenericMote(ThingDefOf.Mote_AirPuff, cell.ToVector3Shifted(), map, 2.5f, .05f, .05f, Rand.Range(2f, 3f), Rand.Range(-60, 60), .5f, -70, Rand.Range(0, 360)); } IEnumerable <IntVec3> windList = GenRadial.RadialCellsAround(this.currentTarget.Cell, this.UseAbilityProps.TargetAoEProperties.range + 1, true).Except(cellList); foreach (var windLoc in windList) { windLoc.ClampInsideMap(map); Vector3 angle = TM_Calc.GetVector(windLoc, this.currentTarget.Cell); TM_MoteMaker.ThrowGenericMote(ThingDefOf.Mote_AirPuff, windLoc.ToVector3Shifted(), map, Rand.Range(1.2f, 2f), .45f, Rand.Range(0f, .25f), .5f, -200, Rand.Range(3, 5), (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat(), Rand.Range(0, 360)); } } this.burstShotsLeft = 0; return(true); }
public override void CompTick() { if (this.age > 0) { if (!this.initialized) { if (summonerPawn != null) { CompAbilityUserMagic comp = summonerPawn.TryGetComp <CompAbilityUserMagic>(); if (comp != null) { verVal = TM_Calc.GetMagicSkillLevel(summonerPawn, comp.MagicData.MagicPowerSkill_GuardianSpirit, "TM_GuardianSpirit", "_ver", true); pwrVal = TM_Calc.GetMagicSkillLevel(summonerPawn, comp.MagicData.MagicPowerSkill_GuardianSpirit, "TM_GuardianSpirit", "_pwr", true); tauntRange = 15 + pwrVal; tauntTargetsMax = 4 + pwrVal; tauntChance = .6f + (.03f * pwrVal); damageMitigation = 4 + Mathf.RoundToInt((float)pwrVal / 1.5f); shadowStrikeDamage = 11 + pwrVal; shadowStrikeCritChance = .4f + (.05f * pwrVal); invisDuration = 90 + (10 * pwrVal); hasteDuration = 120 + (10 * pwrVal); hexChance = .5f + (.05f * pwrVal); } } this.initialized = true; } if (this.Pawn.Spawned && this.Props.abilities != null) { if (!this.Pawn.Downed && Find.TickManager.TicksGame >= this.nextEvalTick) { this.nextEvalTick = Find.TickManager.TicksGame + Mathf.RoundToInt(Rand.Range(.8f, 1.2f) * this.Props.abilityAttemptFrequency); DetermineThreats(); if (closeThreats != null && closeThreats.Count >= 1) { if (this.Props.abilities.Contains(TorannMagicDefOf.TM_Taunt) && this.Pawn.needs?.food?.CurLevel > .06f) { SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None); info.pitchFactor = Rand.Range(.3f, .4f); info.volumeFactor = .7f; TorannMagicDefOf.TM_Roar.PlayOneShot(info); Effecter RageWave = TorannMagicDefOf.TM_RageWaveED.Spawn(); RageWave.Trigger(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), new TargetInfo(this.Pawn.Position, this.Pawn.Map, false)); RageWave.Cleanup(); SearchAndTaunt(); this.Pawn.needs.food.CurLevel -= .3f; } } if (farThreats != null && farThreats.Count >= 1 && this.Pawn.needs?.food?.CurLevel > .05f) { if (this.Props.abilities.Contains(TorannMagicDefOf.TM_ShadowStrike)) { Thing target = farThreats.RandomElement(); if (DoMove(target)) { DoStrike(target); this.Pawn.needs.food.CurLevel -= .3f; } } } if (PawnThreatList != null && PawnThreatList.Count > 0 && this.Pawn.needs?.food?.CurLevel > .025f) { if (this.Props.abilities.Contains(TorannMagicDefOf.TM_Hex)) { Pawn p = PawnThreatList.RandomElement(); if (p.health != null && p.health.hediffSet != null && !p.health.hediffSet.HasHediff(TorannMagicDefOf.TM_HexHD)) { if (Rand.Chance(hexChance)) { HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_HexHD, 1f); CompAbilityUserMagic bondedMagicComp = this.summonerPawn.TryGetComp <CompAbilityUserMagic>(); if (bondedMagicComp != null && !bondedMagicComp.HexedPawns.Contains(p) && bondedMagicComp.MagicData != null && bondedMagicComp.MagicData.MagicPowersShaman.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Hex).learned) { bool addAbilities = false; bool shouldAddAbilities = bondedMagicComp.HexedPawns.Count <= 0; if (!bondedMagicComp.HexedPawns.Contains(p)) { bondedMagicComp.HexedPawns.Add(p); addAbilities = true; } if (shouldAddAbilities && addAbilities) { bondedMagicComp.AddPawnAbility(TorannMagicDefOf.TM_Hex_CriticalFail); bondedMagicComp.AddPawnAbility(TorannMagicDefOf.TM_Hex_Pain); bondedMagicComp.AddPawnAbility(TorannMagicDefOf.TM_Hex_MentalAssault); } } TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Hex, p.DrawPos, p.Map, .6f, .1f, .2f, .2f, 0, 0, 0, 0); } this.Pawn.needs.food.CurLevel -= .1f; } } } } } } age++; }
protected override bool TryCastShot() { // power affects enumerator // DamageWorker.DamageResult result = DamageWorker.DamageResult.MakeNew(); Pawn caster = this.CasterPawn; CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AdvancedHeal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AdvancedHeal_pwr"); MagicPowerSkill ver = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AdvancedHeal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AdvancedHeal_ver"); pwrVal = pwr.level; verVal = ver.level; if (caster.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { MightPowerSkill mpwr = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); MightPowerSkill mver = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); pwrVal = mpwr.level; verVal = mver.level; } Pawn pawn = (Pawn)this.currentTarget; bool flag = pawn != null && !pawn.Dead && !TM_Calc.IsUndead(pawn); bool undeadFlag = pawn != null && !pawn.Dead && TM_Calc.IsUndead(pawn); if (flag) { int num = 3 + verVal; using (IEnumerator <BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator()) { while (enumerator.MoveNext()) { BodyPartRecord rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { int num2 = 1 + verVal; ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (!this.CasterPawn.IsColonist && settingsRef.AIHardMode) { num2 = 5; } IEnumerable <Hediff_Injury> arg_BB_0 = pawn.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 flag4 = num2 > 0; if (flag4) { bool flag5 = current.CanHealNaturally() && !current.IsPermanent(); if (flag5) { //current.Heal((float)((int)current.Severity + 1)); if (!this.CasterPawn.IsColonist) { current.Heal(30.0f + (float)pwrVal * 3f); // power affects how much to heal } else { current.Heal((14.0f + (float)pwrVal * 3f) * comp.arcaneDmg); // power affects how much to heal } TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, 1f + .2f * pwrVal); TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .8f + .1f * pwrVal); num--; num2--; } } } using (IEnumerator <Hediff> enumerator1 = pawn.health.hediffSet.GetHediffsTendable().GetEnumerator()) { while (enumerator1.MoveNext()) { if (num > 0) { Hediff rec1 = enumerator1.Current; if (rec1.TendableNow() && rec1.Bleeding && rec1 is Hediff_MissingPart) { Traverse.Create(root: rec1).Field(name: "isFreshInt").SetValue(false); num--; } } } } } } } } if (undeadFlag) { for (int i = 0; i < 2 + verVal; i++) { TM_Action.DamageUndead(pawn, (8.0f + (float)pwrVal * 5f) * comp.arcaneDmg, this.CasterPawn); } } return(true); }
public void DrawEffects(Vector3 effectVec, Map map) { effectVec.x += Rand.Range(-0.4f, 0.4f); effectVec.z += Rand.Range(-0.4f, 0.4f); TM_MoteMaker.ThrowDiseaseMote(effectVec, map, 0.4f, 0.1f, .01f, 0.35f); }
protected override bool TryCastShot() { bool flag = false; this.TargetsAoE.Clear(); //this.UpdateTargets(); this.FindTargets(); MagicPowerSkill pwr = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_SootheAnimal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SootheAnimal_pwr"); pwrVal = pwr.level; if (base.CasterPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { MightPowerSkill mpwr = base.CasterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); pwrVal = mpwr.level; } bool flag2 = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1; if (flag2) { this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1); } for (int i = 0; i < this.TargetsAoE.Count; i++) { if (this.TargetsAoE[i].Thing.Faction != this.CasterPawn.Faction) { Pawn newPawn = this.TargetsAoE[i].Thing as Pawn; bool flag1 = (newPawn.mindState.mentalStateHandler.CurStateDef == MentalStateDefOf.ManhunterPermanent) || (newPawn.mindState.mentalStateHandler.CurStateDef == MentalStateDefOf.Manhunter); if (flag1) { if (newPawn.kindDef.RaceProps.Animal) { newPawn.mindState.mentalStateHandler.Reset(); newPawn.jobs.StopAll(); MoteMaker.ThrowMicroSparks(newPawn.Position.ToVector3().normalized, newPawn.Map); float sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_AntiManipulation, sev); sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_AntiMovement, sev); sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_AntiBreathing, sev); sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_AntiSight, sev); if (pwrVal > 0) { TM_MoteMaker.ThrowSiphonMote(newPawn.Position.ToVector3(), newPawn.Map, 1f); } } } if (!flag1) { if (newPawn.kindDef.RaceProps.Animal) { newPawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, true, false, null); float sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_Manipulation, sev); sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_Movement, sev); sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_Breathing, sev); sev = Rand.Range(pwrVal, 2 * pwrVal); HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_Sight, sev); MoteMaker.ThrowMicroSparks(newPawn.Position.ToVector3().normalized, newPawn.Map); if (pwrVal > 0) { TM_MoteMaker.ThrowManaPuff(newPawn.Position.ToVector3(), newPawn.Map, 1f); } } } } } this.PostCastShot(flag, out flag); return(flag); }
public override void Tick() { //base.Tick(); age++; if (this.ticksToImpact >= 0) { DrawEffects(this.ExactPosition, base.Map); } if (this.reverseDirection) { this.ticksToImpact++; } else { this.ticksToImpact--; } this.ticksFollowingImpact--; base.Position = this.ExactPosition.ToIntVec3(); bool flag = !this.ExactPosition.InBounds(base.Map); if (flag) { this.ticksToImpact++; this.Destroy(DestroyMode.Vanish); } else if (!this.ExactPosition.ToIntVec3().Walkable(base.Map) && !this.ExactPosition.ToIntVec3().CanBeSeenOverFast(this.Map)) { if (this.reverseDirection) { this.Destroy(DestroyMode.Vanish); } else { this.reverseDirection = true; this.ImpactSomething(); } } else { bool flag2 = this.ticksToImpact <= 0 && !impacted; if (flag2) { bool flag3 = this.DestinationCell.InBounds(base.Map); if (flag3) { base.Position = this.DestinationCell; } this.ImpactSomething(); } } if (this.impacted) { if (this.ticksFollowingImpact > 0 && Find.TickManager.TicksGame % 5 == 0) { CellRect cellRect = CellRect.CenteredOn(base.Position, 2); cellRect.ClipInsideMap(base.Map); IntVec3 spreadingDarknessCell; if (!(cellRect.CenterCell.GetTerrain(base.Map).passability == Traversability.Impassable) && !cellRect.CenterCell.IsValid || !cellRect.CenterCell.InBounds(base.Map)) { this.ticksFollowingImpact = -1; } for (int i = 0; i < 2; i++) { spreadingDarknessCell = cellRect.RandomCell; if (spreadingDarknessCell.InBounds(base.Map) && spreadingDarknessCell.IsValid) { GenExplosion.DoExplosion(spreadingDarknessCell, base.Map, .4f, TMDamageDefOf.DamageDefOf.TM_DeathBolt, this.pawn, Mathf.RoundToInt((Rand.Range(.4f * this.def.projectile.GetDamageAmount(1, null), .8f * this.def.projectile.GetDamageAmount(1, null)) + (3f * pwrVal)) * this.arcaneDmg), 2, this.def.projectile.soundExplode, def, null, null, null, 0f, 1, false, null, 0f, 0, 0.0f, true); TM_MoteMaker.ThrowDiseaseMote(base.Position.ToVector3Shifted(), base.Map, .6f); if (powered) { TM_MoteMaker.ThrowBoltMote(base.Position.ToVector3Shifted(), base.Map, 0.3f); } } } } if (this.ticksFollowingImpact < 0) { this.Destroy(DestroyMode.Vanish); } } }
public override void Tick() { age++; Vector3 exactPosition = this.ExactPosition; this.ticksToImpact--; if (!initialized) { Initialize(); if (this.glowing && this.glowCenter != default(IntVec3)) { this.shouldGlow = true; } } if (Find.TickManager.TicksGame % this.chargeFrequency == 0) { LightEnergy += ChargeAmount; } bool dFlag = false; if (this.pawn.DestroyedOrNull()) { dFlag = true; this.Destroy(DestroyMode.Vanish); } else if (!this.pawn.Spawned || this.pawn.Map != this.Map || this.pawn.Map == null) { solAction = SoLAction.Limbo; dFlag = true; this.delayCount++; if (delayCount >= 300) { StopGlow(); this.shouldGlow = false; this.Destroy(DestroyMode.Vanish); } if (this.delayCount == 10) { MoteMaker.ThrowLightningGlow(this.ExactPosition, this.Map, 1f); MoteMaker.ThrowLightningGlow(this.ExactPosition, this.Map, .7f); MoteMaker.ThrowLightningGlow(this.ExactPosition, this.Map, .4f); } } else if (this.shouldDismiss) { if (this.glowing) { this.glowCenter = default(IntVec3); StopGlow(); this.Destroy(DestroyMode.Vanish); } } if (!dFlag) { bool flag = !this.ExactPosition.InBounds(base.Map); if (flag) { if (!this.pawn.DestroyedOrNull() && this.pawn.Spawned) { base.Position = pawn.Position; this.destination = GetCasterOffset_Exact; this.speed = speed_dash; this.ticksToImpact = this.StartingTicksToImpact; } this.ticksToImpact++; base.Position = this.ExactPosition.ToIntVec3(); } else if (this.solAction == SoLAction.Limbo) { UpdateAction(this.solAction); } else { base.Position = this.ExactPosition.ToIntVec3(); if (Find.TickManager.TicksGame % ActionDelay == 0) { DoAction(); } bool flag2 = this.ticksToImpact <= 0; if (flag2) { if (this.shouldDismiss) { bool flag3 = this.DestinationCell.InBounds(base.Map); if (flag3) { base.Position = this.DestinationCell; } this.ImpactSomething(); } else { UpdateSoLPower(); if (this.curveVariance > 0) { if ((this.curvePoints.Count() - 1) > this.destinationCurvePoint) { this.origin = curvePoints[destinationCurvePoint]; this.destinationCurvePoint++; this.destination = this.curvePoints[this.destinationCurvePoint]; this.ticksToImpact = this.StartingTicksToImpact; } else { bool flag3 = this.DestinationCell.InBounds(base.Map); if (flag3) { base.Position = this.DestinationCell; } this.origin = this.ExactPosition; solAction = SoLAction.Pending; UpdateAction(solAction); } } else { bool flag3 = this.DestinationCell.InBounds(base.Map); if (flag3) { base.Position = this.DestinationCell; } if (this.solAction == SoLAction.ChargeAttacking) { ActualLightCost(5f); int moteAngle = Mathf.RoundToInt(Vector3Utility.ToAngleFlat(this.origin - this.destination) - 90f); TM_Action.DamageEntities(this.assignedTarget, null, Rand.Range(10f, 15f) * LightPotency, TMDamageDefOf.DamageDefOf.TM_BurningLight, this.pawn); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_LightShield, this.ExactPosition, this.Map, 1.5f, .1f, 0f, .2f, 0, 2f, moteAngle, moteAngle); } this.origin = this.destination; solAction = SoLAction.Pending; UpdateAction(solAction); } } } if (this.nextMoteTick <= this.age && solAction != SoLAction.Limbo) { DrawMotes(); } } } }
protected override bool TryCastShot() { Pawn caster = base.CasterPawn; Pawn pawn = this.currentTarget.Thing as Pawn; MagicPowerSkill pwr = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_CureDisease.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_CureDisease_pwr"); MagicPowerSkill ver = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_CureDisease.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_CureDisease_ver"); verVal = ver.level; pwrVal = pwr.level; this.arcaneDmg = caster.GetComp <CompAbilityUserMagic>().arcaneDmg; if (caster.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { MightPowerSkill mpwr = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); MightPowerSkill mver = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); pwrVal = mpwr.level; verVal = mver.level; } bool flag = pawn != null; if (flag) { int num = 1; float sevAdjustment = 0; if (pwrVal >= 2) { //apply immunity buff, 60k ticks in a day if (pwrVal == 3) { HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_DiseaseImmunity2HD, 5); pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_DiseaseImmunity2HD).TryGetComp <HediffComp_DiseaseImmunity>().verVal = verVal; } else { HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_DiseaseImmunityHD, 3); } } if (pwrVal >= 1) { sevAdjustment = 5; } else { sevAdjustment = (Rand.Range(0f, 1f) * this.arcaneDmg); } if (sevAdjustment >= .25f) { bool success = false; using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; bool flag2 = num > 0; if (rec.def.defName == "WoundInfection" || rec.def.defName.Contains("Flu") || rec.def.defName == "Animal_Flu" || rec.def.defName.Contains("Infection")) { //rec.Severity -= sevAdjustment; pawn.health.RemoveHediff(rec); success = true; } if (verVal >= 1 && (rec.def.defName == "GutWorms" || rec.def == HediffDefOf.Malaria || rec.def == HediffDefOf.FoodPoisoning)) { //rec.Severity -= sevAdjustment; pawn.health.RemoveHediff(rec); success = true; } if (verVal >= 2 && (rec.def.defName == "SleepingSickness" || rec.def.defName == "MuscleParasites") || rec.def == HediffDefOf.Scaria) { //rec.Severity -= sevAdjustment; pawn.health.RemoveHediff(rec); success = true; } if (verVal == 3 && (rec.def.makesSickThought && rec.def.isBad)) { //rec.Severity -= sevAdjustment; if (rec.def.defName == "BloodRot") { rec.Severity = 0.01f; MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Tended Blood Rot", -1f); TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3(), pawn.Map, 1.5f); return(false); } else if (rec.def.defName == "Abasia") { //do nothing } else { pawn.health.RemoveHediff(rec); success = true; } } } } if (success == true) { TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3(), pawn.Map, 1.5f); MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Cure Disease" + ": " + StringsToTranslate.AU_CastSuccess, -1f); } else { Messages.Message("TM_CureDiseaseTypeFail".Translate(), MessageTypeDefOf.NegativeEvent); MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Cure Disease" + ": " + StringsToTranslate.AU_CastFailure, -1f); } } else { MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Cure Disease" + ": " + StringsToTranslate.AU_CastFailure, -1f); } } return(false); }
public bool CheckDruidSurgeryFail(Pawn surgeon, Pawn patient, List <Thing> ingredients, BodyPartRecord part, Bill bill) { CompAbilityUserMagic comp = surgeon.GetComp <CompAbilityUserMagic>(); string reason; if (comp.IsMagicUser) { bool canRegrow = false; if (comp.spell_RegrowLimb) { canRegrow = true; } if (comp.customClass != null && comp.MagicData.MagicPowersD.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_RegrowLimb).learned) { canRegrow = true; } if (canRegrow) { MagicPowerSkill eff = surgeon.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_RegrowLimb.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RegrowLimb_eff"); if (comp.Mana.CurLevel < (.9f - (eff.level * TorannMagicDefOf.TM_RegrowLimb.efficiencyReductionPercent * .9f))) { comp.Mana.CurLevel = comp.Mana.CurLevel / 2; //TM_MedicalRecipesUtility.RestorePartAndSpawnAllPreviousParts(patient, part, patient.Position, patient.Map); reason = "TM_InsufficientManaForSurgery".Translate(); Find.LetterStack.ReceiveLetter("LetterLabelRegrowthSurgeryFail".Translate(), "LetterRegrowthSurgeryFail".Translate( surgeon.LabelCap, this.recipe.defName, patient.Label, reason, surgeon.LabelShort ), LetterDefOf.NegativeEvent, null); return(true); } else // regrowth surgery success { comp.Mana.CurLevel -= (.9f - (eff.level * TorannMagicDefOf.TM_RegrowLimb.efficiencyReductionPercent * .9f)) / comp.arcaneDmg; int num = Mathf.RoundToInt(Rand.Range(160, 280) * comp.xpGain); comp.MagicUserXP += num; MoteMaker.ThrowText(surgeon.DrawPos, surgeon.MapHeld, "XP +" + num, -1f); TM_MoteMaker.ThrowRegenMote(patient.Position.ToVector3(), patient.Map, 1.2f); TM_MoteMaker.ThrowRegenMote(patient.Position.ToVector3(), patient.Map, .8f); TM_MoteMaker.ThrowRegenMote(patient.Position.ToVector3(), patient.Map, .8f); return(false); } } else { comp.Mana.CurLevel = comp.Mana.CurLevel / 2; //TM_MedicalRecipesUtility.RestorePartAndSpawnAllPreviousParts(patient, part, patient.Position, patient.Map); reason = "TM_NoRegrowthSpell".Translate(); Find.LetterStack.ReceiveLetter("LetterLabelRegrowthSurgeryFail".Translate(), "LetterRegrowthSurgeryFail".Translate( surgeon.LabelCap, this.recipe.defName, patient.Label, reason, surgeon.LabelShort ), LetterDefOf.NegativeEvent, null); return(true); } } reason = "TM_NotMagicUser".Translate(); Find.LetterStack.ReceiveLetter("LetterLabelRegrowthSurgeryFail".Translate(), "LetterRegrowthSurgeryFail".Translate( surgeon.LabelCap, this.recipe.defName, patient.Label, reason, surgeon.LabelShort ), LetterDefOf.NegativeEvent, null); return(true); }
public override void CompTick() { if (this.age > 0) { if (!this.initialized) { HealthUtility.AdjustSeverity(this.Pawn, TorannMagicDefOf.TM_LichHD, .5f); this.initialized = true; } if (this.Pawn.Spawned) { if (!this.Pawn.Downed) { if (!this.Pawn.stances.curStance.StanceBusy) { if (this.tauntTarget != null && this.Pawn.Faction != null && !this.Pawn.Faction.IsPlayer && this.NextTaunt < Find.TickManager.TicksGame && this.Pawn.CurJob.def != JobDefOf.Goto) { if ((this.tauntTarget.Cell - this.Pawn.Position).LengthHorizontal > 5) { GotoRaiseLocation(this.Pawn.Map, this.tauntTarget); } else { StartTaunt(this.Pawn.Map, this.tauntTarget); } } if (this.shouldDoTaunt) { DoTaunt(this.Pawn.Map, this.tauntTarget.Cell); } if (this.flightTarget != null) { DoChargeAttack(this.flightTarget.Cell); goto exitTick; } if (this.rangedBurstShots > 0 && this.rangedNextBurst < Find.TickManager.TicksGame) { DoRangedAttack(this.rangedTarget); this.rangedBurstShots--; this.rangedNextBurst = Find.TickManager.TicksGame + this.Props.rangedTicksBetweenBursts; } if (shouldDoAOEAttack) { if (this.attackTarget != null) { DoAoEAttack(this.attackTarget.Cell, this.attackTarget); } } if (shouldDoKnockBackAttack) { if (this.attackTarget != null) { DoKnockbackAttack(this.attackTarget.Cell, 5); } } if (Find.TickManager.TicksGame % 30 == 0) { if (this.buildingThreats.Count() > 0) { Building randomBuildingThreat = this.buildingThreats.RandomElement(); if ((randomBuildingThreat.Position - this.Pawn.Position).LengthHorizontal < 80 && this.NextRangedAttack < Find.TickManager.TicksGame && TargetIsValid(randomBuildingThreat)) { this.rangedTarget = randomBuildingThreat; StartRangedAttack(); } } if (this.Pawn.CurJob != null && this.Pawn.CurJob.targetA != null && this.Pawn.CurJob.targetA.Thing != null && this.Pawn.TargetCurrentlyAimingAt == null) { Thing currentTargetThing = this.Pawn.CurJob.targetA.Thing; if ((currentTargetThing.Position - this.Pawn.Position).LengthHorizontal > (this.Props.maxRangeForCloseThreat * 2)) { if (Rand.Chance(.6f) && this.NextRangedAttack < Find.TickManager.TicksGame && TargetIsValid(currentTargetThing)) { this.rangedTarget = currentTargetThing; StartRangedAttack(); } } } else if (this.Pawn.TargetCurrentlyAimingAt != null && this.closeThreats.Count() > 3) { if (Rand.Chance(.4f) && this.NextAoEAttack < Find.TickManager.TicksGame && TM_Calc.HasLoSFromTo(this.Pawn.Position, this.attackTarget, this.Pawn, 0, 60)) { this.attackTarget = this.Pawn.TargetCurrentlyAimingAt; StartAoEAttack(this.attackTarget.Cell, this.attackTarget); } if (Rand.Chance(.8f) && this.NextAoEAttack < Find.TickManager.TicksGame && this.farThreats.Count() > (4 * this.closeThreats.Count()) && TM_Calc.HasLoSFromTo(this.Pawn.Position, this.attackTarget, this.Pawn, 0, 60)) { Pawn p = this.farThreats.RandomElement(); if (TM_Calc.FindAllPawnsAround(this.Pawn.Map, p.Position, 5, p.Faction, false).Count > 3) { this.attackTarget = p; StartAoEAttack(p.Position, p); } } } if (this.closeThreats != null && this.closeThreats.Count > 5) { if (Rand.Chance(.2f) && this.NextKnockbackAttack < Find.TickManager.TicksGame) { Pawn p = this.closeThreats.RandomElement(); if (p.health != null && p.health.hediffSet != null && !p.health.hediffSet.HasHediff(TorannMagicDefOf.TM_DeathMarkHD)) { this.attackTarget = p; StartKnockbackAttack(p.Position, 5); } } else if (Rand.Chance(.4f) && this.NextChargeAttack < Find.TickManager.TicksGame) { this.flightTarget = TM_Calc.TryFindSafeCell(this.Pawn, this.Pawn.Position, 40, 3, 2); StartChargeAttack(this.flightTarget.Cell); } } if (this.farThreats.Count() < 2 * this.closeThreats.Count() && Rand.Chance(.3f)) { if (this.NextChargeAttack < Find.TickManager.TicksGame && this.farThreats.Count >= 1) { Pawn tempTarget = this.farThreats.RandomElement(); if (TargetIsValid(tempTarget) && (tempTarget.Position - this.Pawn.Position).LengthHorizontal > (this.Props.maxRangeForCloseThreat * 3) && (tempTarget.Position - this.Pawn.Position).LengthHorizontal < (this.Props.maxRangeForCloseThreat * 6)) { this.flightTarget = tempTarget; StartChargeAttack(this.flightTarget.Cell); } } } if (this.farThreats.Count() > 2) { if (Rand.Chance(.4f) && this.NextRangedAttack < Find.TickManager.TicksGame) { Pawn randomRangedPawn = this.farThreats.RandomElement(); if ((randomRangedPawn.Position - this.Pawn.Position).LengthHorizontal < this.Props.maxRangeForFarThreat * 2f) { this.rangedTarget = randomRangedPawn; StartRangedAttack(); } } if (Rand.Chance(.2f) && this.NextAoEAttack < Find.TickManager.TicksGame) { Pawn p = this.farThreats.RandomElement(); if ((p.Position - this.Pawn.Position).LengthHorizontal < this.Props.maxRangeForFarThreat * 2f && TM_Calc.HasLoSFromTo(this.Pawn.Position, this.attackTarget, this.Pawn, 0, 60)) { List <Pawn> threatPawns = TM_Calc.FindAllPawnsAround(this.Pawn.Map, p.Position, 5, p.Faction, true); if (threatPawns != null && threatPawns.Count > 3) { this.attackTarget = p; StartAoEAttack(this.attackTarget.Cell, this.attackTarget); } } } } if (this.Pawn.CurJob != null) { if (this.Pawn.CurJob.targetA == null || this.Pawn.CurJob.targetA == this.Pawn) { if (this.closeThreats.Count() > 0) { Thing tempTarget = this.closeThreats.RandomElement(); if (TargetIsValid(tempTarget)) { this.Pawn.CurJob.targetA = tempTarget; this.Pawn.TryStartAttack(this.Pawn.CurJob.targetA); } } else if (this.farThreats.Count() > 0) { Thing tempTarget = this.farThreats.RandomElement(); if (TargetIsValid(tempTarget)) { this.Pawn.CurJob.targetA = tempTarget; this.Pawn.TryStartAttack(this.Pawn.CurJob.targetA); } } else if (this.buildingThreats.Count() > 0) { Thing tempTarget = this.buildingThreats.RandomElement(); if (TargetIsValid(tempTarget)) { this.Pawn.CurJob.targetA = tempTarget; this.Pawn.TryStartAttack(this.Pawn.CurJob.targetA); } } } } } } else if (IsCasting) { if (Find.TickManager.TicksGame % 12 == 0) { TM_MoteMaker.ThrowCastingMote_Anti(this.Pawn.DrawPos, this.Pawn.Map, 2f); } } if (Find.TickManager.TicksGame % 279 == 0) { DetermineThreats(); } } if (Find.TickManager.TicksGame % 4 == 0) { ThingDef rndMote = ThingDefOf.Gas_Smoke; TM_MoteMaker.ThrowGenericMote(rndMote, MoteDrawPos, this.Pawn.Map, Rand.Range(.4f, .5f), .1f, 0f, Rand.Range(.5f, .6f), Rand.Range(-40, 40), Rand.Range(.2f, .3f), Rand.Range(-95, -110), Rand.Range(0, 360)); TM_MoteMaker.ThrowGenericMote(rndMote, MoteDrawPos, this.Pawn.Map, Rand.Range(.4f, .5f), .1f, 0f, Rand.Range(.5f, .6f), Rand.Range(-40, 40), Rand.Range(.2f, .3f), Rand.Range(90, 110), Rand.Range(0, 360)); } if (this.Pawn.Downed) { this.Pawn.Kill(null); } } } exitTick :; age++; }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; if (!this.initialized) { if (this.launcher is Pawn) { caster = this.launcher as Pawn; CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); MagicPowerSkill ver = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Resurrection.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Resurrection_ver"); MagicPowerSkill pwr = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Resurrection.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Resurrection_eff"); verVal = ver.level; pwrVal = pwr.level; } this.angle = Rand.Range(-12f, 12f); IntVec3 curCell = base.Position; this.CheckSpawnSustainer(); if (curCell.InBounds(map)) { Corpse corpse = null; List <Thing> thingList; thingList = curCell.GetThingList(map); int z = 0; while (z < thingList.Count) { corpseThing = thingList[z]; if (corpseThing != null) { bool validator = corpseThing is Corpse; if (validator) { corpse = corpseThing as Corpse; CompRottable compRot = corpse.GetComp <CompRottable>(); deadPawn = corpse.InnerPawn; deadPawnPosition = corpse.Position; if (deadPawn.RaceProps.IsFlesh && !TM_Calc.IsUndead(deadPawn) && compRot != null) { if (!corpse.IsNotFresh()) { z = thingList.Count; this.validTarget = true; corpse.SetForbidden(true); } else { Messages.Message("TM_ResurrectionTargetExpired".Translate(), MessageTypeDefOf.RejectInput); } } if (TM_Calc.IsUndead(deadPawn)) { z = thingList.Count; this.validTarget = true; } } } z++; } } this.initialized = true; } if (corpseThing.Position != this.deadPawnPosition || corpseThing.Map == null) { Log.Message("Corpse was moved or destroyed during resurrection process."); this.age = this.timeToRaise; } if (this.validTarget) { if (this.sustainer != null) { this.sustainer.info.volumeFactor = this.age / this.timeToRaise; this.sustainer.Maintain(); if (this.TicksLeft <= 0) { this.sustainer.End(); this.sustainer = null; } } if (this.age + 1 == this.timeToRaise) { TM_MoteMaker.MakePowerBeamMoteColor(base.Position, base.Map, this.radius * 3f, 2f, 2f, .1f, 1.5f, colorInt.ToColor); if (this.deadPawn == null) { if (corpseThing != null) { Corpse corpse = corpseThing as Corpse; if (corpse != null) { this.deadPawn = corpse.InnerPawn; } } } if (deadPawn != null) { if (TM_Calc.IsUndead(deadPawn)) { if (deadPawn.RaceProps.Humanlike) { GenExplosion.DoExplosion(base.Position, this.Map, Rand.Range(10, 16), TMDamageDefOf.DamageDefOf.TM_Holy, this.launcher, Mathf.RoundToInt(Rand.Range(20, 32)), 6, TMDamageDefOf.DamageDefOf.TM_Holy.soundExplosion); } else { GenExplosion.DoExplosion(base.Position, this.Map, Rand.Range(10, 16), TMDamageDefOf.DamageDefOf.TM_Holy, this.launcher, Mathf.RoundToInt(Rand.Range(16, 24)), 3, TMDamageDefOf.DamageDefOf.TM_Holy.soundExplosion); } } else { if (!deadPawn.kindDef.RaceProps.Animal && deadPawn.kindDef.RaceProps.Humanlike) { ResurrectionUtility.ResurrectWithSideEffects(deadPawn); SoundDef.Named("Thunder_OffMap").PlayOneShot(null); SoundDef.Named("Thunder_OffMap").PlayOneShot(null); using (IEnumerator <Hediff> enumerator = deadPawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; if (rec.def.defName == "ResurrectionPsychosis") { if (Rand.Chance(verVal * .33f)) { deadPawn.health.RemoveHediff(rec); } } } } HealthUtility.AdjustSeverity(deadPawn, HediffDef.Named("TM_ResurrectionHD"), 1f); ReduceSkillsOfPawn(deadPawn, .35f - (.035f * pwrVal)); ApplyHealthDefects(deadPawn, .6f - (.06f * verVal), .3f - (.03f * verVal)); } if (deadPawn.kindDef.RaceProps.Animal) { ResurrectionUtility.Resurrect(deadPawn); HealthUtility.AdjustSeverity(deadPawn, HediffDef.Named("TM_ResurrectionHD"), 1f); } } } } } else { Messages.Message("TM_InvalidResurrection".Translate( caster.LabelShort ), MessageTypeDefOf.RejectInput); this.age = this.timeToRaise; } }
protected override bool TryCastShot() { bool continueAttack = true; if (this.CasterPawn.equipment.Primary == null) { Thing target = this.currentTarget.Thing; if (target != null && this.burstShotsLeft > 0) { int dmgNum = this.GetAttackDmg(this.CasterPawn); BodyPartRecord hitPart = null; DamageDef dmgType = TMDamageDefOf.DamageDefOf.TM_TigerStrike; if (verVal > 0 && Rand.Chance(.1f)) { TM_Action.DamageEntities(target, null, 4, DamageDefOf.Stun, this.CasterPawn); } if (verVal > 1 && Rand.Chance(.4f) && target is Pawn) { if (TM_Calc.IsMagicUser(target as Pawn)) { CompAbilityUserMagic compMagic = target.TryGetComp <CompAbilityUserMagic>(); float manaDrain = Mathf.Clamp(compMagic.Mana.CurLevel, 0, .25f); this.CasterPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ChiHD).Severity += (manaDrain * 100); compMagic.Mana.CurLevel -= manaDrain; } else if (TM_Calc.IsMightUser(target as Pawn)) { CompAbilityUserMight compMight = target.TryGetComp <CompAbilityUserMight>(); float staminaDrain = Mathf.Clamp(compMight.Stamina.CurLevel, 0, .25f); this.CasterPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ChiHD).Severity += (staminaDrain * 100); compMight.Stamina.CurLevel -= staminaDrain; } } if (verVal > 2 && Rand.Chance(.1f) && target is Pawn) { Pawn targetPawn = target as Pawn; IEnumerable <BodyPartRecord> rangeOfParts = (targetPawn.RaceProps.body.GetPartsWithTag(BodyPartTagDefOf.BloodPumpingSource).Concat( targetPawn.RaceProps.body.GetPartsWithTag(BodyPartTagDefOf.BloodFiltrationSource).Concat( targetPawn.RaceProps.body.GetPartsWithTag(BodyPartTagDefOf.BreathingPathway).Concat( targetPawn.RaceProps.body.GetPartsWithTag(BodyPartTagDefOf.SightSource))))); hitPart = rangeOfParts.RandomElement(); dmgNum = Mathf.RoundToInt(dmgNum * 1.4f); } //DamageInfo dinfo2 = new DamageInfo(TMDamageDefOf.DamageDefOf.TM_TigerStrike, dmgNum, 0, (float)-1, this.CasterPawn, null, null, DamageInfo.SourceCategory.ThingOrUnknown); TM_Action.DamageEntities(target, hitPart, dmgNum, dmgType, this.CasterPawn); Vector3 strikeEndVec = this.currentTarget.CenterVector3; strikeEndVec.x += Rand.Range(-.2f, .2f); strikeEndVec.z += Rand.Range(-.2f, .2f); Vector3 strikeStartVec = this.CasterPawn.DrawPos; strikeStartVec.z += Rand.Range(-.2f, .2f); strikeStartVec.x += Rand.Range(-.2f, .2f); Vector3 angle = TM_Calc.GetVector(strikeStartVec, strikeEndVec); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_TigerStrike, strikeStartVec, this.CasterPawn.Map, .4f, .08f, .03f, .05f, 0, 8f, (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat(), (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat()); if (!target.DestroyedOrNull() && target is Pawn) { Pawn targetPawn = target as Pawn; if (targetPawn.Downed || targetPawn.Dead) { continueAttack = false; } } if (this.burstShotsLeft <= (10 - (4 + verVal))) { this.burstShotsLeft = 0; continueAttack = false; } } } else { Messages.Message("MustBeUnarmed".Translate( this.CasterPawn.LabelCap, this.verbProps.label ), MessageTypeDefOf.RejectInput); this.burstShotsLeft = 0; return(false); } return(continueAttack); }
public override void Tick() { base.Tick(); //if (!manPawn.DestroyedOrNull() && !manPawn.Dead && !manPawn.Downed && manPawn.Position == this.InteractionCell) 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 = .04f - (.001f * this.effVal); } if (this.verVal >= 10) { this.mortarTicksToFire = 900 - ((verVal - 10) * 40); this.mortarMaxRange += (verVal - 10) * 5; this.mortarManaCost = .08f - (.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, Mathf.RoundToInt(Rand.Range(22f, 30f) * comp.arcaneDmg), 2, TMDamageDefOf.DamageDefOf.TM_PersonnelBombDD, 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.DistanceToEdge(this.Map) > 8) { bool flag = target.Position != default(IntVec3); if (flag) { for (int i = 0; i < 5; i++) { IntVec3 rndTarget = target.Position; rndTarget.x += Rand.RangeInclusive(-6, 6); rndTarget.z += Rand.RangeInclusive(-6, 6); 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 (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); } }
public override void CompPostTick(ref float severityAdjustment) { base.CompPostTick(ref severityAdjustment); bool flag = base.Pawn != null; if (flag) { if (!initialized) { initialized = true; this.Initialize(); } } if (Find.TickManager.TicksGame % 16 == 0) { IEnumerable <Hediff> hdEnum = this.Pawn.health.hediffSet.GetHediffs <Hediff>(); foreach (Hediff hd in hdEnum) { if (hd.def.defName == "SpaceHypoxia") { this.Pawn.health.RemoveHediff(hd); break; } } } if (Find.TickManager.TicksGame % 6000 == 0) { TM_Action.UpdateAnimalTraining(base.Pawn); } bool flag4 = Find.TickManager.TicksGame % 600 == 0 && this.Pawn.def != TorannMagicDefOf.TM_SkeletonR && this.Pawn.def != TorannMagicDefOf.TM_GiantSkeletonR; if (flag4) { UpdateHediff(); necroValid = false; if (base.Pawn != null && !linkedPawn.DestroyedOrNull()) { necroValid = true; lichStrike = 0; } else { lichStrike++; } if (!necroValid && lichStrike > 2) { if (base.Pawn.Map != null) { TM_MoteMaker.ThrowScreamMote(base.Pawn.Position.ToVector3(), base.Pawn.Map, .8f, 255, 255, 255); base.Pawn.Kill(null, null); } else { base.Pawn.Kill(null, null); } } else { List <Need> needs = base.Pawn.needs.AllNeeds; for (int i = 0; i < needs.Count; i++) { if (needs[i].def == NeedDefOf.Food || needs[i].def == NeedDefOf.Joy || needs[i].def == NeedDefOf.Rest || needs[i].def.defName == "Mood" || needs[i].def.defName == "Beauty" || needs[i].def.defName == "Comfort" || needs[i].def.defName == "Outdoors" || needs[i].def.defName == "RoomSize") { needs[i].CurLevel = needs[i].MaxLevel; } } //if (base.Pawn.needs.food != null) //{ // base.Pawn.needs.food.CurLevel = base.Pawn.needs.food.MaxLevel; //} //if (base.Pawn.needs.rest != null) //{ // base.Pawn.needs.rest.CurLevel = base.Pawn.needs.rest.MaxLevel; //} //if (base.Pawn.IsColonist) //{ // base.Pawn.needs.beauty.CurLevel = .5f; // base.Pawn.needs.comfort.CurLevel = .5f; // base.Pawn.needs.joy.CurLevel = .5f; // base.Pawn.needs.mood.CurLevel = .5f; // base.Pawn.needs.space.CurLevel = .5f; //} Pawn pawn = base.Pawn; int num = 1; int num2 = 1; using (IEnumerator <BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator()) { while (enumerator.MoveNext()) { BodyPartRecord rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { IEnumerable <Hediff_Injury> arg_BB_0 = pawn.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.IsPermanent(); if (flag5) { current.Heal(2.0f); num--; num2--; } else { current.Heal(1.0f); num--; num2--; } } } } } } using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffsTendable().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; if (rec.TendableNow()) // && !currentTendable.IsPermanent() { rec.Tended(1, 1); } } } using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; if (!rec.IsPermanent()) { if (rec.def.defName == "Cataract" || rec.def.defName == "HearingLoss" || rec.def.defName.Contains("ToxicBuildup") || rec.def.defName == "Abasia" || rec.def.defName == "BloodRot") { pawn.health.RemoveHediff(rec); } if ((rec.def.defName == "Blindness" || rec.def.defName.Contains("Asthma") || rec.def.defName == "Cirrhosis" || rec.def.defName == "ChemicalDamageModerate") || rec.def.defName == "Scaria") { pawn.health.RemoveHediff(rec); } if ((rec.def.defName == "Frail" || rec.def.defName == "BadBack" || rec.def.defName.Contains("Carcinoma") || rec.def.defName == "ChemicalDamageSevere")) { pawn.health.RemoveHediff(rec); } if ((rec.def.defName.Contains("Alzheimers") || rec.def.defName == "Dementia" || rec.def.defName.Contains("HeartArteryBlockage") || rec.def.defName == "CatatonicBreakdown")) { pawn.health.RemoveHediff(rec); } } if (rec.def.makesSickThought) { pawn.health.RemoveHediff(rec); } if (rec.def.defName.Contains("Pregnant") || rec.def.defName == "DrugOverdose") { pawn.health.RemoveHediff(rec); } } } CompHatcher cp_h = this.Pawn.TryGetComp <CompHatcher>(); if (cp_h != null) { Traverse.Create(root: cp_h).Field(name: "gestateProgress").SetValue(0); } CompMilkable cp_m = this.Pawn.TryGetComp <CompMilkable>(); if (cp_m != null) { Traverse.Create(root: cp_m).Field(name: "fullness").SetValue(0); } } } }
public void ConsumeAnimalKind(Pawn undead) { TM_MoteMaker.ThrowSiphonMote(undead.Position.ToVector3Shifted(), undead.Map, .8f); TM_MoteMaker.ThrowBloodSquirt(undead.Position.ToVector3Shifted(), undead.Map, 1.5f); TM_MoteMaker.ThrowManaPuff(caster.Position.ToVector3Shifted(), caster.Map, .8f); }
protected override void Impact(Thing hitThing) { base.Impact(hitThing); ThingDef def = this.def; Pawn victim = null; if (!this.initialized) { this.pawn = this.launcher as Pawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Repulsion.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Repulsion_pwr"); MagicPowerSkill ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Repulsion.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Repulsion_ver"); 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; } this.arcaneDmg = comp.arcaneDmg; if (settingsRef.AIHardMode && !pawn.IsColonist) { pwrVal = 3; verVal = 3; } this.strikeDelay = this.strikeDelay - verVal; this.radius = this.def.projectile.explosionRadius; this.duration = Mathf.RoundToInt(this.radius * this.strikeDelay); this.initialized = true; this.targets = GenRadial.RadialCellsAround(base.Position, strikeNum, false); cellList = targets.ToList <IntVec3>(); } if (Find.TickManager.TicksGame % this.strikeDelay == 0) { int force = (10 + (2 * pwrVal) - strikeNum); IntVec3 curCell; for (int i = 0; i < cellList.Count; i++) { curCell = cellList[i]; Vector3 angle = GetVector(base.Position, curCell); TM_MoteMaker.ThrowArcaneWaveMote(curCell.ToVector3(), pawn.Map, .3f * (curCell - base.Position).LengthHorizontal, .1f, .05f, .3f, 0, 3, (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat(), (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat()); if (curCell.IsValid && curCell.InBounds(pawn.Map)) { victim = curCell.GetFirstPawn(pawn.Map); if (victim != null && !victim.Dead) { Vector3 launchVector = GetVector(base.Position, victim.Position); IntVec3 projectedPosition = victim.Position + (force * launchVector).ToIntVec3(); if (projectedPosition.IsValid && projectedPosition.InBounds(pawn.Map)) { if (Rand.Chance(TM_Calc.GetSpellSuccessChance(pawn, victim, true))) { damageEntities(victim, force * (.2f * verVal), DamageDefOf.Blunt); LaunchFlyingObect(projectedPosition, victim, force); } } } } } strikeNum++; IEnumerable <IntVec3> newTargets = GenRadial.RadialCellsAround(base.Position, strikeNum, false); try { cellList = newTargets.Except(targets).ToList <IntVec3>(); } catch { cellList = newTargets.ToList <IntVec3>(); } targets = newTargets; } }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; int raisedPawns = 0; Pawn pawn = this.launcher as Pawn; Pawn victim = hitThing as Pawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); pwr = comp.MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_pwr"); ver = comp.MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_ver"); Thing corpseThing = null; IntVec3 curCell; IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(base.Position, this.def.projectile.explosionRadius, true); foreach (var cell in targets) { curCell = cell; TM_MoteMaker.ThrowPoisonMote(curCell.ToVector3Shifted(), map, .3f); if (curCell.InBounds(map)) { Corpse corpse = null; List <Thing> thingList; thingList = curCell.GetThingList(map); int z = 0; while (z < thingList.Count) { corpseThing = thingList[z]; if (corpseThing != null) { bool validator = corpseThing is Corpse; if (validator) { corpse = corpseThing as Corpse; Pawn undeadPawn = corpse.InnerPawn; CompRottable compRottable = corpse.GetComp <CompRottable>(); float rotStage = 0; if (compRottable != null && compRottable.Stage == RotStage.Dessicated) { rotStage = 1f; } if (compRottable != null) { rotStage += compRottable.RotProgressPct; } bool flag_SL = false; if (undeadPawn.def.defName == "SL_Runner" || undeadPawn.def.defName == "SL_Peon" || undeadPawn.def.defName == "SL_Archer" || undeadPawn.def.defName == "SL_Hero") { PawnGenerationRequest pgr = new PawnGenerationRequest(PawnKindDef.Named("Tribesperson"), pawn.Faction, PawnGenerationContext.NonPlayer, -1, true, false, false, false, false, true, 0, false, false, false, false, false, false, false, false, 0, null, 0); Pawn newUndeadPawn = PawnGenerator.GeneratePawn(pgr); GenSpawn.Spawn(newUndeadPawn, corpse.Position, corpse.Map, WipeMode.Vanish); corpse.Strip(); corpse.Destroy(DestroyMode.Vanish); rotStage = 1f; flag_SL = true; undeadPawn = newUndeadPawn; } if (!undeadPawn.def.defName.Contains("ROM_") && undeadPawn.RaceProps.IsFlesh && (undeadPawn.Dead || flag_SL) && undeadPawn.def.thingClass.FullName != "TorannMagic.TMPawnSummoned") { bool wasVampire = false; IEnumerable <ThingDef> enumerable = from hd in DefDatabase <HediffDef> .AllDefs where def.defName == "ROM_Vampirism" select def; if (enumerable.Count() > 0) { bool hasVampHediff = undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("ROM_Vampirism")) || undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("ROM_GhoulHediff")); if (hasVampHediff) { wasVampire = true; } } if (!wasVampire) { undeadPawn.SetFaction(pawn.Faction); if (undeadPawn.Dead) { ResurrectionUtility.Resurrect(undeadPawn); } raisedPawns++; comp.supportedUndead.Add(undeadPawn); if (undeadPawn.kindDef != null && undeadPawn.kindDef.RaceProps != null && undeadPawn.kindDef.RaceProps.Animal) { RemoveHediffsAddictionsAndPermanentInjuries(undeadPawn); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, -4f); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, .5f + ver.level); undeadPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_UndeadAnimalHD).TryGetComp <HediffComp_Undead>().linkedPawn = pawn; HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), -2f); HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), rotStage); if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Tameness).Accepted) { while (!undeadPawn.training.HasLearned(TrainableDefOf.Tameness)) { undeadPawn.training.Train(TrainableDefOf.Tameness, pawn); } } if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Obedience).Accepted) { while (!undeadPawn.training.HasLearned(TrainableDefOf.Obedience)) { undeadPawn.training.Train(TrainableDefOf.Obedience, pawn); } } if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Release).Accepted) { while (!undeadPawn.training.HasLearned(TrainableDefOf.Release)) { undeadPawn.training.Train(TrainableDefOf.Release, pawn); } } if (undeadPawn.training.CanAssignToTrain(TorannMagicDefOf.Haul).Accepted) { while (!undeadPawn.training.HasLearned(TorannMagicDefOf.Haul)) { undeadPawn.training.Train(TorannMagicDefOf.Haul, pawn); } } if (undeadPawn.training.CanAssignToTrain(TorannMagicDefOf.Rescue).Accepted) { while (!undeadPawn.training.HasLearned(TorannMagicDefOf.Rescue)) { undeadPawn.training.Train(TorannMagicDefOf.Rescue, pawn); } } undeadPawn.playerSettings.medCare = MedicalCareCategory.NoMeds; undeadPawn.def.tradeability = Tradeability.None; } else if (undeadPawn.story != null && undeadPawn.story.traits != null && undeadPawn.needs != null && undeadPawn.playerSettings != null) { CompAbilityUserMagic compMagic = undeadPawn.GetComp <CompAbilityUserMagic>(); if (compMagic != null && TM_Calc.IsMagicUser(undeadPawn)) //(compMagic.IsMagicUser && !undeadPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) || { compMagic.Initialize(); compMagic.RemovePowers(true); } CompAbilityUserMight compMight = undeadPawn.GetComp <CompAbilityUserMight>(); if (compMight != null && TM_Calc.IsMightUser(undeadPawn)) //compMight.IsMightUser || { compMight.Initialize(); compMight.RemovePowers(true); } RemoveHediffsAddictionsAndPermanentInjuries(undeadPawn); RemovePsylinkAbilities(undeadPawn); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, -4f); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, .5f + ver.level); undeadPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_UndeadHD).TryGetComp <HediffComp_Undead>().linkedPawn = pawn; HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), -2f); HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), rotStage); RedoSkills(undeadPawn, pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_LichHD"))); if (undeadPawn.story.traits.HasTrait(TorannMagicDefOf.ChaosMage)) { compMagic.RemovePawnAbility(TorannMagicDefOf.TM_ChaosTradition); } RemoveTraits(undeadPawn, undeadPawn.story.traits.allTraits); undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Undead"), 0, false)); undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Psychopath"), 0, false)); undeadPawn.needs.AddOrRemoveNeedsAsAppropriate(); RemoveClassHediff(undeadPawn); if (undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("DeathAcidifier"))) { Hediff hd = undeadPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("DeathAcidifier")); undeadPawn.health.RemoveHediff(hd); } //Color undeadColor = new Color(.2f, .4f, 0); //undeadPawn.story.hairColor = undeadColor; //CompAbilityUserMagic undeadComp = undeadPawn.GetComp<CompAbilityUserMagic>(); //if (undeadComp.IsMagicUser) //{ // undeadComp.ClearPowers(); //} List <SkillRecord> skills = undeadPawn.skills.skills; for (int j = 0; j < skills.Count; j++) { skills[j].passion = Passion.None; } undeadPawn.playerSettings.hostilityResponse = HostilityResponseMode.Attack; undeadPawn.playerSettings.medCare = MedicalCareCategory.NoMeds; for (int h = 0; h < 24; h++) { undeadPawn.timetable.SetAssignment(h, TimeAssignmentDefOf.Work); } } } else { Messages.Message("Vampiric powers have prevented undead reanimation of " + undeadPawn.LabelShort, MessageTypeDefOf.RejectInput); } } } else if (corpseThing is Pawn) { Pawn undeadPawn = corpseThing as Pawn; if (undeadPawn != pawn && !TM_Calc.IsNecromancer(undeadPawn) && TM_Calc.IsUndead(corpseThing as Pawn)) { RemoveHediffsAddictionsAndPermanentInjuries(undeadPawn); TM_MoteMaker.ThrowPoisonMote(curCell.ToVector3Shifted(), map, .6f); } } } z++; } } if (raisedPawns > pwr.level + 1) { break; } } }
protected override IEnumerable <Toil> MakeNewToils() { bool flag; yield return(Toils_Misc.ThrowColonistAttackingMote(TargetIndex.A)); Verb_UseAbility curJob = this.pawn.CurJob.verbToUse as Verb_UseAbility; if (base.TargetA.HasThing) { flag = (!base.GetActor().IsFighting() ? true : !curJob.UseAbilityProps.canCastInMelee); if (flag) { Toil toil = Toils_Combat.GotoCastPosition(TargetIndex.A, false); yield return(toil); toil = null; } } if (this.Context == AbilityContext.Player) { Find.Targeter.targetingVerb = curJob; } Pawn targetPawn = null; if (this.TargetThingA != null) { targetPawn = TargetThingA as Pawn; } if (targetPawn != null) { //yield return Toils_Combat.CastVerb(TargetIndex.A, false); Toil combatToil = new Toil(); combatToil.FailOnDestroyedOrNull(TargetIndex.A); combatToil.FailOnDespawnedOrNull(TargetIndex.A); //combatToil.FailOnDowned(TargetIndex.A); //CompAbilityUserMagic comp = this.pawn.GetComp<CompAbilityUserMagic>(); this.duration = (int)((curJob.verbProps.warmupTime * 60) * this.pawn.GetStatValue(StatDefOf.AimingDelayFactor, false)); //JobDriver curDriver = this.pawn.jobs.curDriver; combatToil.initAction = delegate { arg_45_0 = combatToil.actor.jobs.curJob.verbToUse; if (this.pawn.RaceProps.Humanlike) { if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { CompAbilityUserMight mightComp = this.pawn.GetComp <CompAbilityUserMight>(); CompAbilityUserMagic magicComp = this.pawn.GetComp <CompAbilityUserMagic>(); if (mightComp.mimicAbility != null && mightComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass) { mightComp.RemovePawnAbility(mightComp.mimicAbility); } if (magicComp.mimicAbility != null && magicComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass) { magicComp.RemovePawnAbility(magicComp.mimicAbility); } } } LocalTargetInfo target = combatToil.actor.jobs.curJob.GetTarget(TargetIndex.A); // bool canFreeIntercept2 = false; arg_45_0.TryStartCastOn(target, false, false); using (IEnumerator <Hediff> enumerator = this.pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; if (rec.def == TorannMagicDefOf.TM_PossessionHD || rec.def == TorannMagicDefOf.TM_DisguiseHD || rec.def == TorannMagicDefOf.TM_DisguiseHD_I || rec.def == TorannMagicDefOf.TM_DisguiseHD_II || rec.def == TorannMagicDefOf.TM_DisguiseHD_III) { this.pawn.health.RemoveHediff(rec); } } } }; combatToil.tickAction = delegate { if (Find.TickManager.TicksGame % 12 == 0) { TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); } this.duration--; }; combatToil.AddFinishAction(delegate { if (this.duration <= 5) { curJob.Ability.PostAbilityAttempt(); } }); //if (combatToil.actor.CurJob != this.job) //{ // curDriver.ReadyForNextToil(); //} combatToil.defaultCompleteMode = ToilCompleteMode.FinishedBusy; yield return(combatToil); //Toil toil2 = new Toil() //{ // initAction = () => // { // if (curJob.UseAbilityProps.isViolent) // { // JobDriver_CastAbilityVerb.CheckForAutoAttack(this.pawn); // } // }, // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil2; //Toil toil1 = new Toil() //{ // initAction = () => curJob.Ability.PostAbilityAttempt(), // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil1; } else { if ((pawn.Position - TargetLocA).LengthHorizontal < curJob.verbProps.range) { if (TargetLocA.IsValid && TargetLocA.InBounds(pawn.Map) && !TargetLocA.Fogged(pawn.Map) && TargetLocA.Walkable(pawn.Map)) { ShootLine shootLine; bool validTarg = curJob.TryFindShootLineFromTo(pawn.Position, TargetLocA, out shootLine); if (validTarg) { //yield return Toils_Combat.CastVerb(TargetIndex.A, false); //Toil toil2 = new Toil() //{ // initAction = () => // { // if (curJob.UseAbilityProps.isViolent) // { // JobDriver_CastAbilityVerb.CheckForAutoAttack(this.pawn); // } // }, // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil2; this.duration = (int)((curJob.verbProps.warmupTime * 60) * this.pawn.GetStatValue(StatDefOf.AimingDelayFactor, false)); Toil toil = new Toil(); toil.initAction = delegate { arg_45_0 = toil.actor.jobs.curJob.verbToUse; if (this.pawn.RaceProps.Humanlike) { if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { CompAbilityUserMight mightComp = this.pawn.GetComp <CompAbilityUserMight>(); CompAbilityUserMagic magicComp = this.pawn.GetComp <CompAbilityUserMagic>(); if (mightComp.mimicAbility != null && mightComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass) { mightComp.RemovePawnAbility(mightComp.mimicAbility); } if (magicComp.mimicAbility != null && magicComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass) { magicComp.RemovePawnAbility(magicComp.mimicAbility); } } } LocalTargetInfo target = toil.actor.jobs.curJob.GetTarget(TargetIndex.A); bool canFreeIntercept2 = false; arg_45_0.TryStartCastOn(target, false, canFreeIntercept2); using (IEnumerator <Hediff> enumerator = this.pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; if (rec.def == TorannMagicDefOf.TM_PossessionHD || rec.def == TorannMagicDefOf.TM_DisguiseHD || rec.def == TorannMagicDefOf.TM_DisguiseHD_I || rec.def == TorannMagicDefOf.TM_DisguiseHD_II || rec.def == TorannMagicDefOf.TM_DisguiseHD_III) { this.pawn.health.RemoveHediff(rec); } } } }; toil.tickAction = delegate { if (Find.TickManager.TicksGame % 12 == 0) { TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); } this.duration--; }; toil.AddFinishAction(delegate { if (this.duration <= 5) { curJob.Ability.PostAbilityAttempt(); } }); toil.defaultCompleteMode = ToilCompleteMode.FinishedBusy; yield return(toil); //Toil toil1 = new Toil() //{ // initAction = () => curJob.Ability.PostAbilityAttempt(), // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil1; } else { //No LoS if (pawn.IsColonist) { Messages.Message("TM_OutOfLOS".Translate(new object[] { pawn.LabelShort }), MessageTypeDefOf.RejectInput); } } } } else { if (pawn.IsColonist) { //out of range Messages.Message("TM_OutOfRange".Translate(), MessageTypeDefOf.RejectInput); } } } }
public override void Tick() { if (!initialized) { DetermineElementalType(); BeginAssaultCondition(); SpawnCycle(); ModOptions.SettingsRef settings = new ModOptions.SettingsRef(); if (Find.Storyteller.difficulty.difficulty != 0) { this.STDMultiplier = (float)(Find.Storyteller.difficulty.difficulty / 20f); } if (settings.riftChallenge < 2f) { this.difficultyMultiplier = 1f; } else if (settings.riftChallenge < 3f) { this.difficultyMultiplier = .85f; } else { this.difficultyMultiplier = .75f; } this.difficultyMultiplier -= this.STDMultiplier; this.ticksTillNextAssault = (int)(Rand.Range(2600, 4000) * this.difficultyMultiplier); this.ticksTillNextEvent = (int)(Rand.Range(160, 300) * this.eventFrequencyMultiplier); initialized = true; } if (Find.TickManager.TicksGame % 8 == 0) { this.assaultTimer += 8; this.eventTimer += 8; this.matRng = Rand.RangeInclusive(0, 2); this.matMagnitude = 4 * this.arcaneEnergyMax; Vector3 rndVec = this.DrawPos; if (this.rnd < 2) //earth { rndVec.x += Rand.Range(-5, 5); rndVec.z += Rand.Range(-5, 5); MoteMaker.ThrowSmoke(rndVec, this.Map, Rand.Range(.6f, 1.2f)); } else if (this.rnd < 4) //fire { rndVec.x += Rand.Range(-1.2f, 1.2f); rndVec.z += Rand.Range(-1.2f, 1.2f); TM_MoteMaker.ThrowFlames(rndVec, this.Map, Rand.Range(.6f, 1f)); } else if (this.rnd < 6) //water { rndVec.x += Rand.Range(-2f, 2f); rndVec.z += Rand.Range(-2f, 2f); TM_MoteMaker.ThrowManaPuff(rndVec, this.Map, Rand.Range(.6f, 1f)); } else //air { rndVec.x += Rand.Range(-2f, 2f); rndVec.z += Rand.Range(-2f, 2f); MoteMaker.ThrowLightningGlow(rndVec, this.Map, Rand.Range(.6f, .8f)); } } if (this.eventTimer > this.ticksTillNextEvent) { DoMapEvent(); this.eventTimer = 0; this.ticksTillNextEvent = (int)(Rand.Range(160, 300) * this.eventFrequencyMultiplier); } if (this.notifier == false && this.assaultTimer > (.9f * this.ticksTillNextAssault)) { Messages.Message("TM_AssaultPending".Translate(), MessageTypeDefOf.ThreatSmall); this.notifier = true; } if (this.assaultTimer > this.ticksTillNextAssault) { SpawnCycle(); this.assaultTimer = 0; this.ticksTillNextAssault = Mathf.RoundToInt(Rand.Range(2000, 3500) * this.difficultyMultiplier); this.notifier = false; } }
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 = 1; verVal = 1; } 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); if (explosionRadii[i] <= 3) { 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 * (2+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); damageEntities(victim, null, Mathf.RoundToInt((4 * (2 + this.def.projectile.GetDamageAmount(1, null) + pwrVal) * this.arcaneDmg)), DamageDefOf.Stun); } else { damageEntities(victim, null, Mathf.RoundToInt(((2 + this.def.projectile.GetDamageAmount(1, null) + pwrVal) * this.arcaneDmg)), DamageDefOf.Stun); //GenExplosion.DoExplosion(curCell, pawn.Map, .4f, DamageDefOf.Stun, this.launcher, Mathf.RoundToInt(((2+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); } } } victim = null; } } explosionRadii[i]++; if (explosionCenters.Count <= 3) { this.maxRadius = 6 + verVal; } else if (explosionCenters.Count <= 5) { this.maxRadius = 5 + verVal; } else if (explosionCenters.Count <= 7) { this.maxRadius = 4 + verVal; } else { this.maxRadius = 3 + verVal; } 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); } } } }
protected override bool TryCastShot() { CompAbilityUserMight comp = this.CasterPawn.GetComp <CompAbilityUserMight>(); MightPowerSkill ver = comp.MightData.MightPowerSkill_SeismicSlash.FirstOrDefault((MightPowerSkill x) => x.label == "TM_SeismicSlash_ver"); pwrVal = TM_Calc.GetMightSkillLevel(this.CasterPawn, comp.MightData.MightPowerSkill_SeismicSlash, "TM_SeismicSlash", "_pwr", true); CellRect cellRect = CellRect.CenteredOn(base.CasterPawn.Position, 1); Map map = base.CasterPawn.Map; cellRect.ClipInsideMap(map); IntVec3 centerCell = cellRect.CenterCell; this.origin = base.CasterPawn.Position.ToVector3(); this.destination = this.currentTarget.Cell.ToVector3Shifted(); this.ticksToImpact = Mathf.RoundToInt((this.origin - this.destination).magnitude); if (this.CasterPawn.equipment.Primary != null && !this.CasterPawn.equipment.Primary.def.IsRangedWeapon) { TMAbilityDef ad = (TMAbilityDef)this.Ability.Def; int dmgNum = Mathf.RoundToInt(comp.weaponDamage * ad.weaponDamageFactor * (1 + (.1f * pwrVal))); ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (!this.CasterPawn.IsColonist && settingsRef.AIHardMode) { dmgNum += 10; } Vector3 strikeVec = this.origin; DrawBlade(strikeVec, 0); for (int i = 0; i < this.StartingTicksToImpact; i++) { strikeVec = this.ExactPosition; Pawn victim = strikeVec.ToIntVec3().GetFirstPawn(map); if (victim != null && victim.Faction != base.CasterPawn.Faction) { DrawStrike(strikeVec.ToIntVec3(), strikeVec, map); damageEntities(victim, null, dmgNum, DamageDefOf.Cut); } float angle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.CasterPawn.DrawPos, this.currentTarget.CenterVector3)).ToAngleFlat(); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_DirectionalDirt"), strikeVec, this.CasterPawn.Map, .3f + (.08f * i), .05f, .15f, .38f, 0, 5f - (.2f * i), angle, angle); if (i == 2) { TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Cleave"), strikeVec, this.CasterPawn.Map, .6f + (.05f * i), .05f, .04f + (.03f * i), .15f, -10000, 30, angle, angle); } //MoteMaker.ThrowTornadoDustPuff(strikeVec, map, .6f, Color.white); for (int j = 0; j < 2 + (2 * verVal); j++) { IntVec3 searchCell = strikeVec.ToIntVec3() + GenAdj.AdjacentCells8WayRandomized()[j]; TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_DirectionalDirt"), searchCell.ToVector3Shifted(), this.CasterPawn.Map, .1f + (.04f * i), .05f, .04f, .28f, 0, 4f - (.2f * i), angle, angle); //MoteMaker.ThrowTornadoDustPuff(searchCell.ToVector3(), map, .4f, Color.gray); victim = searchCell.GetFirstPawn(map); if (victim != null && victim.Faction != base.CasterPawn.Faction) { DrawStrike(searchCell, searchCell.ToVector3(), map); damageEntities(victim, null, dmgNum, DamageDefOf.Cut); } } this.ticksToImpact--; } } else { Messages.Message("MustHaveMeleeWeapon".Translate( this.CasterPawn.LabelCap ), MessageTypeDefOf.RejectInput); return(false); } this.burstShotsLeft = 0; this.PostCastShot(flag10, out flag10); return(flag10); }
public void GetAffectedPawns(IntVec3 center, Map map) { Pawn victim = null; IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(center, this.def.projectile.explosionRadius, true); foreach (var curCell in targets) { if (curCell.InBounds(map) && curCell.IsValid) { victim = curCell.GetFirstPawn(map); } if (victim != null && victim.Faction == this.caster.Faction && !victim.Dead) { if (verVal >= 1) { HealthUtility.AdjustSeverity(victim, TorannMagicDefOf.TM_HediffTimedInvulnerable, 1f); Hediff hd = victim.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_HediffTimedInvulnerable); HediffComp_Disappears hdc = hd.TryGetComp <HediffComp_Disappears>(); if (hdc != null) { hdc.ticksToDisappear += 360; } } if (verVal >= 2) { Pawn pawn = victim; bool flag = pawn != null && !pawn.Dead && !TM_Calc.IsUndead(pawn); bool undeadFlag = pawn != null && !pawn.Dead && TM_Calc.IsUndead(pawn); if (flag) { int num = 3; using (IEnumerator <BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator()) { while (enumerator.MoveNext()) { BodyPartRecord rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { int num2 = 1; IEnumerable <Hediff_Injury> arg_BB_0 = pawn.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 flag4 = num2 > 0; if (flag4) { bool flag5 = current.CanHealNaturally() && !current.IsPermanent(); if (flag5) { //current.Heal((float)((int)current.Severity + 1)); if (!this.caster.IsColonist) { current.Heal(20.0f); // power affects how much to heal } else { current.Heal(5.0f * this.arcaneDmg); // power affects how much to heal } TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f); TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f); num--; num2--; } } } } } } } } if (verVal >= 3) { HealthUtility.AdjustSeverity(victim, HediffDef.Named("BestowMightHD"), 1f); } } if (victim != null && !victim.Dead && TM_Calc.IsUndead(victim)) { TM_Action.DamageUndead(victim, Rand.Range(5f, 12f) * this.arcaneDmg, this.launcher); } } }
public override void CompPostTick(ref float severityAdjustment) { base.CompPostTick(ref severityAdjustment); bool flag = base.Pawn != null; if (flag) { if (initializing) { initializing = false; this.Initialize(); } } bool flag4 = Find.TickManager.TicksGame % 600 == 0; if (flag4) { if (Find.TickManager.TicksGame % 6000 == 0) { if (base.Pawn.RaceProps.Animal) { if (base.Pawn.training.CanAssignToTrain(TrainableDefOf.Tameness).Accepted) { while (!base.Pawn.training.HasLearned(TrainableDefOf.Tameness)) { base.Pawn.training.Train(TrainableDefOf.Tameness, null); } } if (base.Pawn.training.CanAssignToTrain(TrainableDefOf.Obedience).Accepted) { while (!base.Pawn.training.HasLearned(TrainableDefOf.Obedience)) { base.Pawn.training.Train(TrainableDefOf.Obedience, null); } } if (base.Pawn.training.CanAssignToTrain(TrainableDefOf.Release).Accepted) { while (!base.Pawn.training.HasLearned(TrainableDefOf.Release)) { base.Pawn.training.Train(TrainableDefOf.Release, null); } } if (base.Pawn.training.CanAssignToTrain(TorannMagicDefOf.Haul).Accepted) { while (!base.Pawn.training.HasLearned(TorannMagicDefOf.Haul)) { base.Pawn.training.Train(TorannMagicDefOf.Haul, null); } } if (base.Pawn.training.CanAssignToTrain(TorannMagicDefOf.Rescue).Accepted) { while (!base.Pawn.training.HasLearned(TorannMagicDefOf.Rescue)) { base.Pawn.training.Train(TorannMagicDefOf.Rescue, null); } } } } necroValid = false; if (base.Pawn.Map != null) { foreach (Pawn current in base.Pawn.Map.mapPawns.PawnsInFaction(base.Pawn.Faction)) { if (current.RaceProps.Humanlike) { if (current.story.traits.HasTrait(TorannMagicDefOf.Necromancer) || current.story.traits.HasTrait(TorannMagicDefOf.Lich)) { //necromancer alive to sustain undead necroValid = true; lichStrike = 0; } } } if (necroValid == false) //give a buffer that allows flight or other temporary despawning of the necromancers or lichs before destroying undead { if (lichStrike < 3) { lichStrike++; necroValid = true; } } } else //for caravans { if (this.Pawn.ParentHolder.ToString().Contains("Caravan")) { foreach (Pawn current in base.Pawn.holdingOwner) { if (current != null) { if (current.RaceProps.Humanlike) { if (current.story.traits.HasTrait(TorannMagicDefOf.Necromancer) || current.story.traits.HasTrait(TorannMagicDefOf.Lich)) { necroValid = true; } } } } } else { //being carried necroValid = true; } } if (!necroValid && base.Pawn.Map != null) { TM_MoteMaker.ThrowScreamMote(base.Pawn.Position.ToVector3(), base.Pawn.Map, .8f, 255, 255, 255); base.Pawn.Kill(null, null); } else if (!necroValid && base.Pawn.Map == null) { base.Pawn.Kill(null, null); } else { List <Need> needs = base.Pawn.needs.AllNeeds; for (int i = 0; i < needs.Count; i++) { if (needs[i].def.defName != "TM_Mana" && needs[i].def.defName != "TM_Stamina") { needs[i].CurLevel = needs[i].MaxLevel; } } //if (base.Pawn.needs.food != null) //{ // base.Pawn.needs.food.CurLevel = base.Pawn.needs.food.MaxLevel; //} //if (base.Pawn.needs.rest != null) //{ // base.Pawn.needs.rest.CurLevel = base.Pawn.needs.rest.MaxLevel; //} //if (base.Pawn.IsColonist) //{ // base.Pawn.needs.beauty.CurLevel = .5f; // base.Pawn.needs.comfort.CurLevel = .5f; // base.Pawn.needs.joy.CurLevel = .5f; // base.Pawn.needs.mood.CurLevel = .5f; // base.Pawn.needs.space.CurLevel = .5f; //} Pawn pawn = base.Pawn; int num = 1; int num2 = 1; using (IEnumerator <BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator()) { while (enumerator.MoveNext()) { BodyPartRecord rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { IEnumerable <Hediff_Injury> arg_BB_0 = pawn.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.IsPermanent(); if (flag5) { current.Heal(2.0f); num--; num2--; } else { current.Heal(1.0f); num--; num2--; } } } } } } using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffsTendable().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; if (rec.TendableNow()) // && !currentTendable.IsPermanent() { rec.Tended(1, 1); } } } using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; if (!rec.IsPermanent()) { if (rec.def.defName == "Cataract" || rec.def.defName == "HearingLoss" || rec.def.defName.Contains("ToxicBuildup")) { pawn.health.RemoveHediff(rec); } if ((rec.def.defName == "Blindness" || rec.def.defName.Contains("Asthma") || rec.def.defName == "Cirrhosis" || rec.def.defName == "ChemicalDamageModerate")) { pawn.health.RemoveHediff(rec); } if ((rec.def.defName == "Frail" || rec.def.defName == "BadBack" || rec.def.defName.Contains("Carcinoma") || rec.def.defName == "ChemicalDamageSevere")) { pawn.health.RemoveHediff(rec); } if ((rec.def.defName.Contains("Alzheimers") || rec.def.defName == "Dementia" || rec.def.defName.Contains("HeartArteryBlockage") || rec.def.defName == "CatatonicBreakdown")) { pawn.health.RemoveHediff(rec); } } if (rec.def.makesSickThought) { pawn.health.RemoveHediff(rec); } } } } } }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; this.caster = this.launcher as Pawn; if (!this.initialized) { CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_HealingCircle.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_HealingCircle_pwr"); MagicPowerSkill ver = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_HealingCircle.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_HealingCircle_ver"); pwrVal = pwr.level; verVal = ver.level; if (caster.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { MightPowerSkill mpwr = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); MightPowerSkill mver = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); pwrVal = mpwr.level; verVal = mver.level; } this.arcaneDmg = comp.arcaneDmg; ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (!caster.IsColonist && settingsRef.AIHardMode) { pwrVal = 3; verVal = 3; } this.radius = this.def.projectile.explosionRadius; this.angle = Rand.Range(-12, 12); this.duration = this.duration + (180 * (pwrVal + verVal)); //TM_MoteMaker.MakePowerBeamMote(base.Position, base.Map, this.radius * 8f, 1.2f, this.duration/60f); this.initialized = true; } if (this.age >= this.lastWave) { if (this.age >= this.lastHeal + this.healDelay) { switch (ringFrac) { case 0: this.innerRing = 0; this.outerRing = this.radius * ((ringFrac + .1f) / 5f); TM_MoteMaker.MakePowerBeamMote(base.Position, base.Map, this.radius * 6f, 1.2f, this.waveDelay / 60f, (this.healDelay * 3f) / 60f, (this.healDelay * 2f) / 60f); break; case 1: this.innerRing = this.outerRing; this.outerRing = this.radius * ((ringFrac) / 5f); break; case 2: this.innerRing = this.outerRing; this.outerRing = this.radius * ((ringFrac) / 5f); break; case 3: this.innerRing = this.outerRing; this.outerRing = this.radius * ((ringFrac) / 5f); break; case 4: this.innerRing = this.outerRing; this.outerRing = this.radius * ((ringFrac) / 5f); break; case 5: this.innerRing = this.outerRing; this.outerRing = this.radius; this.lastWave = this.age + this.waveDelay; break; } ringFrac++; this.lastHeal = this.age; Search(map); } if (ringFrac >= 6) { ringFrac = 0; } } }