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) { 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 void Impact(Thing hitThing) { base.Impact(hitThing); ThingDef def = this.def; Pawn victim = null; if (!this.initialized) { pawn = this.launcher as Pawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Attraction.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Attraction_pwr"); MagicPowerSkill ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Attraction.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Attraction_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.duration = this.duration + (180 * verVal); this.strikeDelay = this.strikeDelay - verVal; this.radius = this.def.projectile.explosionRadius + (1.5f * pwrVal); this.initialized = true; IEnumerable <IntVec3> hediffCells = GenRadial.RadialCellsAround(base.Position, 2, true); hediffCellList = hediffCells.ToList <IntVec3>(); IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(base.Position, this.radius, false).Except(hediffCells); cellList = targets.ToList <IntVec3>(); for (int i = 0; i < cellList.Count(); i++) { if (cellList[i].IsValid && cellList[i].InBounds(pawn.Map)) { victim = cellList[i].GetFirstPawn(pawn.Map); if (victim != null && !victim.Dead && !victim.Downed) { HealthUtility.AdjustSeverity(victim, HediffDef.Named("TM_GravitySlowHD"), .5f); } } } } IntVec3 curCell = cellList.RandomElement(); Vector3 angle = GetVector(base.Position, curCell); TM_MoteMaker.ThrowArcaneWaveMote(curCell.ToVector3(), base.Map, .4f * (curCell - base.Position).LengthHorizontal, .1f, .05f, .5f, 0, Rand.Range(1, 2), (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat(), (Quaternion.AngleAxis(-90, Vector3.up) * angle).ToAngleFlat()); if (Find.TickManager.TicksGame % this.strikeDelay == 0) { for (int i = 0; i < 3; i++) { curCell = cellList.RandomElement(); if (curCell.IsValid && curCell.InBounds(base.Map)) { victim = curCell.GetFirstPawn(base.Map); if (victim != null && !victim.Dead && victim.RaceProps.IsFlesh && victim != this.pawn) { Vector3 launchVector = GetVector(base.Position, victim.Position); HealthUtility.AdjustSeverity(victim, HediffDef.Named("TM_GravitySlowHD"), (.4f + (.1f * verVal))); LaunchFlyingObect(victim.Position + (2f * (1 + (.4f * pwrVal)) * launchVector).ToIntVec3(), victim); } else if (victim != null && !victim.Dead && !victim.RaceProps.IsFlesh) { HealthUtility.AdjustSeverity(victim, HediffDef.Named("TM_GravitySlowHD"), .4f + (.1f * verVal)); } } } for (int i = 0; i < hediffCellList.Count(); i++) { curCell = hediffCellList[i]; if (curCell.IsValid && curCell.InBounds(base.Map)) { victim = curCell.GetFirstPawn(base.Map); if (victim != null && !victim.Dead) { HealthUtility.AdjustSeverity(victim, HediffDef.Named("TM_GravitySlowHD"), .3f + (.1f * verVal)); } } } } }