public void ApplyComponentConditions(string condition, float value = 0f) { if (condition == "NameOfTheWind") { windSpeed = 2f; windSpeedEndTick = Find.TickManager.TicksGame + Rand.Range(160000, 240000); } if (condition == "ArcaneInspiration") { List <Pawn> colonists = this.map.mapPawns.FreeColonistsSpawned.InRandomOrder().ToList(); int count = Mathf.Clamp(Rand.RangeInclusive(1, 3), 1, colonists.Count); for (int i = 0; i < count; i++) { InspirationDef id = TM_Calc.GetRandomAvailableInspirationDef(colonists[i]); colonists[i].mindState.inspirationHandler.TryStartInspiration(id); } } if (condition == "AllowAllIncidents") { this.allowAllIncidents = true; } }
private void DoChargeAttack(LocalTargetInfo t) { if (t == null) { t = this.rangedTarget; } this.nextChargeAttack = this.Props.chargeCooldownTicks + Find.TickManager.TicksGame; bool flag = t.Cell != default(IntVec3) && t.Cell.DistanceToEdge(this.Pawn.Map) > 6; float magnitude = (t.Cell - this.Pawn.Position).LengthHorizontal * .35f; if (flag && t.Thing != null) { for (int i = 0; i < 3; i++) { Vector3 moteDirection = TM_Calc.GetVector(this.Pawn.Position, t.Cell); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_GrappleHook, this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(1.1f, 1.4f), 0.15f, .02f + (.08f * i), .3f - (.04f * i), Rand.Range(-10, 10), magnitude + magnitude * i, (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), Rand.Chance(.5f) ? (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat() : (Quaternion.AngleAxis(-90, Vector3.up) * moteDirection).ToAngleFlat()); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_GrappleHook, t.Thing.DrawPos, this.Pawn.Map, Rand.Range(1.1f, 1.4f), 0.15f, .02f + (.08f * i), .3f - (.04f * i), Rand.Range(-10, 10), magnitude + magnitude * i, (Quaternion.AngleAxis(-90, Vector3.up) * moteDirection).ToAngleFlat(), Rand.Chance(.5f) ? (Quaternion.AngleAxis(-90, Vector3.up) * moteDirection).ToAngleFlat() : (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat()); } PullObject(t.Thing); TM_Action.PawnActionDelay(this.Pawn, 60, this.rangedTarget, this.Pawn.meleeVerbs.TryGetMeleeVerb(this.rangedTarget.Thing)); } }
private void UpdateHediff() { if (this.linkedPawn != null) { CompAbilityUserMagic comp = linkedPawn.TryGetComp <CompAbilityUserMagic>(); try { if (comp != null) { int ver = TM_Calc.GetMagicSkillLevel(linkedPawn, comp.MagicData.MagicPowerSkill_RaiseUndead, "TM_RaiseUndead", "_ver"); if (this.parent.Severity != ver + .5f) { this.parent.Severity = .5f + ver; } } } catch { base.Pawn.Kill(null, null); } } }
private void DoRangedAttack(LocalTargetInfo target) { bool flag = target.Cell != default(IntVec3); if (flag) { SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None); info.pitchFactor = .7f; info.volumeFactor = 2f; TorannMagicDefOf.TM_AirWoosh.PlayOneShot(info); CellRect cellRect = CellRect.CenteredOn(target.Cell, 3); cellRect.ClipInsideMap(this.Pawn.Map); IntVec3 destination = cellRect.RandomCell; if (launchableThing != null && destination != null) { float launchAngle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.Pawn.Position, destination)).ToAngleFlat(); for (int m = 0; m < 4; m++) { TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_ThickDust"), this.Pawn.Position.ToVector3Shifted(), this.Pawn.Map, Rand.Range(.4f, .7f), Rand.Range(.2f, .3f), .05f, Rand.Range(.4f, .6f), Rand.Range(-20, 20), Rand.Range(3f, 5f), launchAngle += Rand.Range(-25, 25), Rand.Range(0, 360)); } FlyingObject_Spinning flyingObject = (FlyingObject_Spinning)GenSpawn.Spawn(ThingDef.Named("FlyingObject_Spinning"), this.Pawn.Position, this.Pawn.Map); flyingObject.force = 1.4f; flyingObject.Launch(this.Pawn, destination, this.launchableThing.SplitOff(1), Rand.Range(45, 65)); } else if (launchableThing == null && destination != null) { float launchAngle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.Pawn.Position, destination)).ToAngleFlat(); for (int m = 0; m < 4; m++) { TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_ThickDust"), this.Pawn.Position.ToVector3Shifted(), this.Pawn.Map, Rand.Range(.4f, .7f), Rand.Range(.2f, .3f), .05f, Rand.Range(.4f, .6f), Rand.Range(-20, 20), Rand.Range(3f, 5f), launchAngle += Rand.Range(-25, 25), Rand.Range(0, 360)); } FlyingObject_Spinning flyingObject = (FlyingObject_Spinning)GenSpawn.Spawn(ThingDef.Named("FlyingObject_SpinningBone"), this.Pawn.Position, this.Pawn.Map); flyingObject.force = 1.4f; flyingObject.Launch(this.Pawn, destination, null, Rand.Range(120, 150)); } } }
public void AdjustBloodLoss() { float bloodLoss = 1 + (.25f * this.bleedRate); if (this.Pawn.Faction == this.linkedPawn.Faction) { bloodLoss = bloodLoss / 2f; } //Log.Message("adjusting blood loss by " + .03f * bloodLoss + " bleed rate is " + this.bleedRate); HediffDef bloodType = TM_Calc.GetBloodLossTypeDef(this.Pawn.health.hediffSet.hediffs); if (bloodType != null) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named(bloodType.ToString()), .04f * bloodLoss / Mathf.Clamp(this.Pawn.BodySize, .25f, 4f)); } bloodType = TM_Calc.GetBloodLossTypeDef(this.linkedPawn.health.hediffSet.hediffs); if (bloodType != null) { HealthUtility.AdjustSeverity(this.linkedPawn, HediffDef.Named(bloodType.ToString()), -(.03f * bloodLoss / Mathf.Clamp(this.linkedPawn.BodySize, .25f, 4f))); } }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; pawn = this.launcher as Pawn; Pawn victim = hitThing as Pawn; try { CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); verVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_Headshot, "TM_Headshot", "_ver", true); //MightPowerSkill ver = pawn.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_Headshot.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Headshot_ver"); //verVal = ver.level; //if (pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) //{ // MightPowerSkill mver = comp.MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); // verVal = mver.level; //} CellRect cellRect = CellRect.CenteredOn(base.Position, 1); cellRect.ClipInsideMap(map); int dmg = GetWeaponDmg(pawn); if (victim != null && Rand.Chance(this.launcher.GetStatValue(StatDefOf.ShootingAccuracyPawn, true))) { this.PenetratingShot(victim, dmg, this.def.projectile.damageDef); if (victim.Dead) { comp.Stamina.CurLevel += (.1f * verVal); } } } catch (NullReferenceException ex) { //Log.Message("null error " + ex); } }
protected override void Impact(Thing hitThing) { base.Impact(hitThing); ThingDef def = this.def; if (!this.initialized) { caster = this.launcher as Pawn; CompAbilityUserMight comp = caster.GetComp <CompAbilityUserMight>(); verVal = TM_Calc.GetMightSkillLevel(caster, comp.MightData.MightPowerSkill_ShotgunSpec, "TM_ShotgunSpec", "_ver", true); this.explosionCount = 5; if (verVal >= 3) { this.explosionCount++; } this.initialized = true; } landed = true; ticksToDetonation = def.projectile.explosionDelay; GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(this, def.projectile.damageDef, launcher.Faction); }
private void DisruptMentalState_NonClass(Pawn pawn) { if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, pawn, true))) { if (pawn.RaceProps.Humanlike && Rand.Chance(.08f)) { pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk); } else if (pawn.RaceProps.Animal && Rand.Chance(.1f)) { pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter); } else if (Rand.Chance(.5f)) { TM_Action.DamageEntities(pawn, null, Rand.Range(4, 8), DamageDefOf.Stun, this.CasterPawn); } } else { MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "TM_ResistedSpell".Translate(), -1); } }
protected override bool TryCastShot() { bool flag = false; this.TargetsAoE.Clear(); //this.UpdateTargets(); this.FindTargets(); MagicPowerSkill ver = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Rend.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Rend_ver"); verVal = ver.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++) { Pawn newPawn = this.TargetsAoE[i].Thing as Pawn; if (newPawn.RaceProps.IsFlesh) { if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, newPawn, true))) { HealthUtility.AdjustSeverity(newPawn, HediffDef.Named("TM_RendHD"), 3f + (.6f * ver.level)); } else { MoteMaker.ThrowText(newPawn.DrawPos, newPawn.Map, "TM_ResistedSpell".Translate(), -1); } } else { TM_Action.DamageEntities(newPawn, null, (4f), DamageDefOf.Cut, this.CasterPawn); } } this.PostCastShot(flag, out flag); return(flag); }
public void SearchForTargets(IntVec3 center, float radius) { if (faction == null) { faction = Faction.OfPlayer; } Pawn target = TM_Calc.FindNearbyEnemy(center, Map, faction, radius, 0f); if (target != null) { CellRect cellRect = CellRect.CenteredOn(target.Position, 2); cellRect.ClipInsideMap(base.Map); DrawStrike(center, target.Position.ToVector3()); for (int k = 0; k < Rand.Range(1, 5); k++) { IntVec3 randomCell = cellRect.RandomCell; GenExplosion.DoExplosion(randomCell, base.Map, Rand.Range(.4f, .8f), TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(4, 6)), 0, SoundDefOf.Thunder_OnMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true); } GenExplosion.DoExplosion(target.Position, base.Map, 1f, TMDamageDefOf.DamageDefOf.TM_Lightning, this.launcher, Mathf.RoundToInt(Rand.Range(5, 9) * this.arcaneDmg), 0, SoundDefOf.Thunder_OffMap, null, null, null, null, 0f, 1, false, null, 0f, 1, 0.1f, true); this.lastStrike = this.age; } DrawStrikeFading(); }
private void Initialize(Pawn pawn) { CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); pwrVal = TM_Calc.GetMagicSkillLevel(pawn, comp.MagicData.MagicPowerSkill_LightBurst, "TM_LightBurst", "_pwr", TorannMagicDefOf.TM_LightBurst.canCopy); verVal = TM_Calc.GetMagicSkillLevel(pawn, comp.MagicData.MagicPowerSkill_LightBurst, "TM_LightBurst", "_ver", TorannMagicDefOf.TM_LightBurst.canCopy); this.burstCount = 2; if (verVal >= 1) { burstCount++; if (verVal >= 3) { burstCount++; } } this.arcaneDmg = comp.arcaneDmg; if (pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_LightCapacitanceHD)) { HediffComp_LightCapacitance hd = pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_LightCapacitanceHD).TryGetComp <HediffComp_LightCapacitance>(); this.lightPotency = hd.LightPotency; hd.LightEnergy -= (2.5f * this.burstCount); } }
private void Initialize(Thing t) { GenClamor.DoClamor(this, 2f, ClamorDefOf.Ability); if (!t.DestroyedOrNull() && t is Pawn) { Pawn p = t as Pawn; CompAbilityUserMagic comp = p.TryGetComp <CompAbilityUserMagic>(); if (comp != null && comp.MagicData != null) { pwrVal = TM_Calc.GetMagicSkillLevel(p, comp.MagicData.MagicPowerSkill_ChainLightning, "TM_ChainLightning", "_pwr", true); verVal = TM_Calc.GetMagicSkillLevel(p, comp.MagicData.MagicPowerSkill_ChainLightning, "TM_ChainLightning", "_ver", true); this.arcaneDmg = comp.arcaneDmg; } } newStrikeLocs = new List <IntVec3>(); newStrikeLocs.Clear(); strikeLocs = new List <IntVec3>(); strikeLocs.Clear(); strikeMeshes = new List <Mesh>(); strikeMeshes.Clear(); chainedThings = new List <Thing>(); chainedThings.Clear(); }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; GenExplosion.DoExplosion(base.Position, map, this.def.projectile.explosionRadius, this.def.projectile.damageDef, this.launcher, this.def.projectile.GetDamageAmount(1, null), 0, SoundDefOf.Artillery_ShellLoaded, def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0f, false); Pawn p = this.launcher as Pawn; if (p != null) { CompAbilityUserMagic comp = p.TryGetComp <CompAbilityUserMagic>(); if (comp != null) { if (comp.MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_pwr").level >= 4) { List <Pawn> allPawns = TM_Calc.FindAllPawnsAround(map, base.Position, this.def.projectile.explosionRadius); if (allPawns != null && allPawns.Count > 0) { for (int i = 0; i < allPawns.Count; i++) { Pawn ele = allPawns[i]; if (TM_Calc.IsElemental(ele)) { TM_Action.DamageEntities(ele, null, Rand.Range(10, 20), DamageDefOf.Burn, p); } else if (ele.def == TorannMagicDefOf.TM_DemonR) { TM_Action.DamageEntities(ele, null, Rand.Range(30, 50), DamageDefOf.Burn, p); } } } } } } }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); Pawn pawn = this.launcher as Pawn; Pawn victim = hitThing as Pawn; if (!pawn.Spawned) { //pwrVal = pawn.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_PsionicStorm.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicStorm_pwr").level; pwrVal = TM_Calc.GetMightSkillLevel(pawn, pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_PsionicStorm, "TM_PsionicStorm", "_pwr", true); arcaneDmg = pawn.GetComp <CompAbilityUserMight>().mightPwr; } else { //MightPowerSkill pwr = pawn.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_PsionicBlast.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicBlast_pwr"); pwrVal = TM_Calc.GetMightSkillLevel(pawn, pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_PsionicBlast, "TM_PsionicBlast", "_pwr", true); //pwrVal = pwr.level; arcaneDmg = pawn.GetComp <CompAbilityUserMight>().mightPwr; } //if (pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) //{ // MightPowerSkill mpwr = pawn.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); // pwrVal = mpwr.level; //} TM_MoteMaker.MakePowerBeamMotePsionic(base.Position, map, this.def.projectile.explosionRadius * 6f, 2f, .7f, .1f, .6f); float angle = (Quaternion.AngleAxis(90, Vector3.up) * GetVector(pawn.Position, base.Position)).ToAngleFlat(); GenExplosion.DoExplosion(base.Position, map, this.def.projectile.explosionRadius, TMDamageDefOf.DamageDefOf.TM_PsionicInjury, this.launcher, Mathf.RoundToInt(this.def.projectile.GetDamageAmount(1, null) * pawn.GetStatValue(StatDefOf.PsychicSensitivity, false) * (1 + (0.15f * pwrVal)) * this.arcaneDmg), 0, this.def.projectile.soundExplode, def, this.equipmentDef, this.intendedTarget.Thing, null, 0f, 1, false, null, 0f, 1, 0.0f, false); }
protected override bool TryCastShot() { int shotCount = 3; if (!base.CasterPawn.DestroyedOrNull()) { CompAbilityUserMagic comp = base.CasterPawn.GetComp <CompAbilityUserMagic>(); if (comp != null) { shotCount -= TM_Calc.GetMagicSkillLevel(base.CasterPawn, comp.MagicData.MagicPowerSkill_LightLance, "TM_LightLance", "_pwr", true); } if (base.CasterPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_LightCapacitanceHD)) { HediffComp_LightCapacitance hd = base.CasterPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_LightCapacitanceHD).TryGetComp <HediffComp_LightCapacitance>(); hd.LightEnergy -= 3f; } } if (this.burstShotsLeft == this.verbProps.burstShotCount) { return(base.TryCastShot()); } else if (this.burstShotsLeft > (0 + shotCount)) { bool outResult = true; PostCastShot(outResult, out outResult); if (!outResult) { Ability.Notify_AbilityFailed(UseAbilityProps.refundsPointsAfterFailing); } return(outResult); } else { return(false); } }
private void DisruptClassPawn(Pawn pawn) { Hediff classHediff = null; float energyBurn = 0; if (TM_Calc.IsMightUser(pawn)) { CompAbilityUserMight mightComp = pawn.GetComp <CompAbilityUserMight>(); classHediff = pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_PsionicHD); classHediff = pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_HateHD); classHediff = pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ChiHD); if (mightComp != null && mightComp.Stamina != null) { energyBurn = Mathf.Clamp(mightComp.Stamina.CurLevel, 0, (.5f * (1f + (.20f * pwrVal)))); TM_Action.DamageEntities(pawn, null, Mathf.RoundToInt(Rand.Range(30f, 50f) * energyBurn), TMDamageDefOf.DamageDefOf.TM_ChiBurn, this.CasterPawn); mightComp.Stamina.CurLevel -= energyBurn; } } else if (TM_Calc.IsMagicUser(pawn)) { CompAbilityUserMagic magicComp = pawn.GetComp <CompAbilityUserMagic>(); classHediff = pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_BloodHD); if (magicComp != null && magicComp.Mana != null) { energyBurn = Mathf.Clamp(magicComp.Mana.CurLevel, 0, (.5f * (1f + (.20f * pwrVal)))); TM_Action.DamageEntities(pawn, null, Mathf.RoundToInt(Rand.Range(30f, 50f) * energyBurn), TMDamageDefOf.DamageDefOf.TM_ChiBurn, this.CasterPawn); magicComp.Mana.CurLevel -= energyBurn; } } TM_Action.DamageEntities(pawn, null, Mathf.RoundToInt(Rand.Range(20f, 30f) * energyBurn), DamageDefOf.Stun, this.CasterPawn); if (classHediff != null) { energyBurn = Mathf.Clamp(classHediff.Severity, 0, (.5f * (1f + (.20f * pwrVal))) * 100); classHediff.Severity -= energyBurn; } }
public int GetAttackDmg(Pawn pawn) { CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); //MightPowerSkill pwr = comp.MightData.MightPowerSkill_TigerStrike.FirstOrDefault((MightPowerSkill x) => x.label == "TM_TigerStrike_pwr"); //MightPowerSkill ver = comp.MightData.MightPowerSkill_TigerStrike.FirstOrDefault((MightPowerSkill x) => x.label == "TM_TigerStrike_ver"); verVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_TigerStrike, "TM_TigerStrike", "_ver", true); pwrVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_TigerStrike, "TM_TigerStrike", "_pwr", true); MightPowerSkill str = comp.MightData.MightPowerSkill_global_strength.FirstOrDefault((MightPowerSkill x) => x.label == "TM_global_strength_pwr"); //this.verVal = ver.level; //this.pwrVal = pwr.level; //if (pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) //{ // MightPowerSkill mver = comp.MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); // MightPowerSkill mpwr = comp.MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); // verVal = mver.level; // pwrVal = mpwr.level; //} int dmgNum = 0; float pawnDPS = pawn.GetStatValue(StatDefOf.MeleeDPS, false); float skillMultiplier = .8f + (.08f * pwrVal); return(dmgNum = Mathf.RoundToInt(skillMultiplier * pawnDPS * comp.mightPwr * Rand.Range(.75f, 1.25f))); }
protected override bool TryCastShot() { Pawn caster = this.CasterPawn; CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); MagicPowerSkill ver = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_ConsumeCorpse.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ConsumeCorpse_ver"); MagicPowerSkill manaRegen = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_global_regen.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_global_regen_pwr"); Thing undeadThing = this.currentTarget.Thing; if (undeadThing is Pawn) { Pawn undead = (Pawn)undeadThing; bool flag = undead != null && !undead.Dead; if (flag) { if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadHD)) { comp.Mana.CurLevel += (.225f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg); ConsumeHumanoid(undead); if (ver.level > 0) { HealCaster(caster, 2 + ver.level, 2, (5f + ver.level) * comp.arcaneDmg); } undead.Destroy(); } else if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadAnimalHD)) { comp.Mana.CurLevel += (.18f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg); ConsumeAnimalKind(undead); if (ver.level > 0) { HealCaster(caster, 2, 2, (3 + ver.level) * comp.arcaneDmg); } undead.Destroy(); } else { Messages.Message("TM_CannotUseOnLiving".Translate(), MessageTypeDefOf.RejectInput); } } } IntVec3 target = this.currentTarget.Cell; Thing corpseThing = null; Corpse corpse = null; List <Thing> thingList; thingList = target.GetThingList(caster.Map); int i = 0; while (i < thingList.Count) { corpseThing = thingList[i]; if (corpseThing != null) { bool validator = corpseThing is Corpse; if (validator) { corpse = corpseThing as Corpse; Pawn undeadPawn = corpse.InnerPawn; if ((undeadPawn.RaceProps.IsFlesh || TM_Calc.IsUndead(undeadPawn)) && (!TM_Calc.IsRobotPawn(undeadPawn))) { if (undeadPawn.RaceProps.Humanlike && !undeadPawn.RaceProps.Animal) { if (!corpse.IsNotFresh()) { comp.Mana.CurLevel += (.13f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg); if (caster.needs != null && caster.needs.rest != null) { caster.needs.rest.CurLevel += .3f; } if (caster.needs != null && caster.needs.mood != null) { caster.needs.mood.CurLevel += .3f; } ConsumeHumanoid(corpse); if (ver.level > 0) { HealCaster(caster, 1 + ver.level, 1 + ver.level, (2f + ver.level) * comp.arcaneDmg); } } else { comp.Mana.CurLevel += (.09f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg); ConsumeHumanoid(corpse); } corpse.Destroy(); } else if (undeadPawn.RaceProps.Animal || TM_Calc.IsUndead(undeadPawn)) { if (!corpse.IsNotFresh()) { comp.Mana.CurLevel += (.09f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg); if (caster.needs != null && caster.needs.food != null) { caster.needs.food.CurLevel += .4f; } ConsumeAnimalKind(corpse); if (ver.level > 0) { HealCaster(caster, 1, 1, (2f + ver.level) * comp.arcaneDmg); } } else { comp.Mana.CurLevel += (.07f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg); ConsumeAnimalKind(corpse); } corpse.Destroy(); } else { Messages.Message("TM_CannontConsumeCorpseType".Translate(), MessageTypeDefOf.RejectInput); } } else { Messages.Message("TM_InvalidCorpseType".Translate(), MessageTypeDefOf.RejectInput); } } } i++; } return(false); }
public override void CompPostTick(ref float severityAdjustment) { base.CompPostTick(ref severityAdjustment); bool flag = base.Pawn != null; if (flag) { if (initializing) { initializing = false; this.Initialize(); } } 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); } } } } bool flag4 = Find.TickManager.TicksGame % 600 == 0 && this.Pawn.def != TorannMagicDefOf.TM_SkeletonR && this.Pawn.def != TorannMagicDefOf.TM_GiantSkeletonR; if (flag4) { necroValid = false; float orbCount = 0; float orbEnergy = 0; List <Apparel> orbs = TM_Calc.GetNecroticOrbs(base.Pawn); if (orbs != null && orbs.Count > 0) { orbCount = orbs.Count; for (int i = 0; i < orbs.Count; i++) { Enchantment.CompEnchantedItem itemComp = orbs[i].GetComp <Enchantment.CompEnchantedItem>(); if (itemComp != null) { orbEnergy += itemComp.NecroticEnergy; } } } 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 && orbEnergy <= 0) { 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 && orbEnergy <= 0) { 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 { if (!necroValid && orbEnergy >= 0) { for (int i = 0; i < orbs.Count; i++) { Enchantment.CompEnchantedItem itemComp = orbs[i].GetComp <Enchantment.CompEnchantedItem>(); if (itemComp != null) { if (this.Pawn.RaceProps.Humanlike) { itemComp.NecroticEnergy -= (0.12f * .3f * 4f) / orbCount; } else if (this.Pawn.RaceProps.Animal) { itemComp.NecroticEnergy -= (0.12f * 4f * (this.Pawn.kindDef.combatPower / 100)) / orbCount; } } } } 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); } } } } } }
public override void DoEffect(Pawn user) { CompAbilityUserMagic comp = user.GetComp <CompAbilityUserMagic>(); if (parent.def != null && (TM_Calc.IsMagicUser(user) || TM_Calc.IsWanderer(user))) { string previousType = "unassigned"; string newType; if (comp.guardianSpiritType != null) { previousType = comp.guardianSpiritType.label; float rnd = Rand.Value; if (rnd < .34f) { if (comp.guardianSpiritType == TorannMagicDefOf.TM_SpiritBearR) { if (Rand.Chance(.5f)) { comp.guardianSpiritType = TorannMagicDefOf.TM_SpiritMongooseR; } else { comp.guardianSpiritType = TorannMagicDefOf.TM_SpiritCrowR; } } else { comp.guardianSpiritType = TorannMagicDefOf.TM_SpiritBearR; } } else if (rnd < .67f) { if (comp.guardianSpiritType == TorannMagicDefOf.TM_SpiritMongooseR) { if (Rand.Chance(.5f)) { comp.guardianSpiritType = TorannMagicDefOf.TM_SpiritBearR; } else { comp.guardianSpiritType = TorannMagicDefOf.TM_SpiritCrowR; } } else { comp.guardianSpiritType = TorannMagicDefOf.TM_SpiritMongooseR; } } else { if (comp.guardianSpiritType == TorannMagicDefOf.TM_SpiritCrowR) { if (Rand.Chance(.5f)) { comp.guardianSpiritType = TorannMagicDefOf.TM_SpiritBearR; } else { comp.guardianSpiritType = TorannMagicDefOf.TM_SpiritMongooseR; } } else { comp.guardianSpiritType = TorannMagicDefOf.TM_SpiritCrowR; } } newType = comp.guardianSpiritType.label; } else { newType = comp.GuardianSpiritType.label; } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); Messages.Message("TM_SpiritAnimalChange".Translate(user.LabelShort, previousType, newType), MessageTypeDefOf.TaskCompletion); } else { Messages.Message("NotMageToLearnSpell".Translate(), MessageTypeDefOf.RejectInput); } }
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 CompPostTick(ref float severityAdjustment) { if (this.Pawn.Spawned && !this.Pawn.Dead && !this.Pawn.Downed) { base.CompPostTick(ref severityAdjustment); if (base.Pawn != null & base.parent != null) { if (!initialized) { initialized = true; this.Initialize(); } } CompAbilityUserMagic comp = this.Pawn.GetComp <CompAbilityUserMagic>(); if (this.ticksBitWorking > 0 && this.nextBitEffect < Find.TickManager.TicksGame && this.moteLoc != Vector3.zero) { Vector3 rndVec = this.moteLoc; rndVec.x += Rand.Range(-.15f, .15f); rndVec.z += Rand.Range(-.15f, .15f); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_SparkFlash"), rndVec, this.Pawn.Map, Rand.Range(.9f, 1.5f), .05f, 0f, .1f, 0, 0f, 0f, 0f); rndVec = this.moteLoc; rndVec.x += Rand.Range(-.15f, .15f); rndVec.z += Rand.Range(-.15f, .15f); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_SparkFlash"), rndVec, this.Pawn.Map, Rand.Range(.6f, 1.1f), .05f, 0f, .1f, 0, 0f, 0f, 0f); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Enchanting, comp.bitPosition, this.Pawn.Map, Rand.Range(0.35f, 0.43f), .2f, .05f, Rand.Range(.4f, .6f), Rand.Range(-200, 200), 0, 0, 0); this.ticksBitWorking--; this.nextBitEffect = Find.TickManager.TicksGame + Rand.Range(6, 10); if (this.ticksBitWorking == 0) { this.moteLoc = Vector3.zero; } } if (comp.useTechnoBitToggle) { if (Find.TickManager.TicksGame % 60 == 0) { DetermineHDRank(); } if (Find.TickManager.TicksGame % 600 == 0 && !this.Pawn.Drafted) { if (comp.Mana.CurLevelPercentage >= .9f && comp.Mana.CurLevel >= (.06f - (.001f * this.VerVal)) && this.Pawn.CurJob.targetA.Thing != null) { if (this.Pawn.CurJob.targetA.Thing != null) { if ((this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal < 2 && (this.Pawn.CurJob.bill != null || this.Pawn.CurJob.def.defName == "FinishFrame" || this.Pawn.CurJob.def.defName == "Deconstruct" || this.Pawn.CurJob.def.defName == "Repair" || this.Pawn.CurJob.def.defName == "Mine" || this.Pawn.CurJob.def.defName == "SmoothFloor" || this.Pawn.CurJob.def.defName == "SmoothWall")) { comp.Mana.CurLevel -= (.05f - (.001f * this.VerVal)); HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_BitAssistHD"), .5f + 1f * this.VerVal); comp.MagicUserXP += Rand.Range(6, 8); this.ticksBitWorking = 8; this.moteLoc = this.Pawn.CurJob.targetA.Thing.DrawPos; } } } } if (comp.useTechnoBitRepairToggle && Find.TickManager.TicksGame % (160 - 3 * EffVal) == 0 && this.Pawn.Drafted && comp.Mana.CurLevel >= (.03f - .0006f * EffVal)) { Thing damagedThing = TM_Calc.FindNearbyDamagedThing(this.Pawn, Mathf.RoundToInt(5 + .33f * EffVal)); Building repairBuilding = damagedThing as Building; if (repairBuilding != null) { repairBuilding.HitPoints = Mathf.Min(Mathf.RoundToInt(repairBuilding.HitPoints + (Rand.Range(8, 12) + (.5f * EffVal))), repairBuilding.MaxHitPoints); comp.Mana.CurLevel -= (.03f - .0006f * EffVal); comp.MagicUserXP += Rand.Range(4, 5); this.ticksBitWorking = 8; this.moteLoc = repairBuilding.DrawPos; } Pawn damagedRobot = damagedThing as Pawn; if (damagedRobot != null) { TM_Action.DoAction_HealPawn(this.Pawn, damagedRobot, 1, (4 + .4f * EffVal)); comp.Mana.CurLevel -= (.03f - .0006f * EffVal); comp.MagicUserXP += Rand.Range(4, 6); this.ticksBitWorking = 5; this.moteLoc = damagedRobot.DrawPos; } } if (comp.useTechnoBitRepairToggle && Find.TickManager.TicksGame % (600 - 6 * EffVal) == 0 && !this.Pawn.Drafted && comp.Mana.CurLevel >= .05f) { Thing damagedThing = TM_Calc.FindNearbyDamagedThing(this.Pawn, Mathf.RoundToInt(10 + .5f * EffVal)); Building repairBuilding = damagedThing as Building; if (repairBuilding != null) { repairBuilding.HitPoints = Mathf.Min(repairBuilding.HitPoints + (25 + (2 * EffVal)), repairBuilding.MaxHitPoints); comp.Mana.CurLevel -= (.05f - .0008f * EffVal); comp.MagicUserXP += Rand.Range(9, 11); this.ticksBitWorking = 8; this.moteLoc = repairBuilding.DrawPos; } Pawn damagedRobot = damagedThing as Pawn; if (damagedRobot != null) { TM_Action.DoAction_HealPawn(this.Pawn, damagedRobot, 2, (8 + .4f * EffVal)); comp.Mana.CurLevel -= (.05f - .0008f * EffVal); comp.MagicUserXP += Rand.Range(9, 11); this.ticksBitWorking = 5; this.moteLoc = damagedRobot.DrawPos; } } if (comp.Mana.CurLevel >= .1f && (this.Pawn.Drafted || !this.Pawn.IsColonist)) { if (this.Pawn.TargetCurrentlyAimingAt != null && (this.Pawn.CurJob.def.defName == "AttackStatic" || this.Pawn.CurJob.def.defName == "Wait_Combat") && this.nextBitGrenade < Find.TickManager.TicksGame) { float maxRange = 25 + this.PwrVal; Thing targetThing = this.Pawn.TargetCurrentlyAimingAt.Thing; float targetDistance = (this.Pawn.Position - targetThing.Position).LengthHorizontal; float acc = 15f + (PwrVal / 3f); if (TM_Calc.HasLoSFromTo(this.Pawn.Position, this.Pawn.TargetCurrentlyAimingAt.Thing, this.Pawn as Thing, 2f, maxRange) && targetThing.Map != null && this.bitGrenadeCount > 0) { IntVec3 rndTargetCell = targetThing.Position; rndTargetCell.x += Mathf.RoundToInt(Rand.Range(-targetDistance / acc, targetDistance / acc)); //grenades were 8 rndTargetCell.z += Mathf.RoundToInt(Rand.Range(-targetDistance / acc, targetDistance / acc)); LocalTargetInfo ltiTarget = rndTargetCell; //if (this.bitGrenadeCount == 2) //{ // //launch emp grenade // Projectile projectile = (Projectile)GenSpawn.Spawn(ThingDef.Named("Projectile_TMEMPGrenade"), this.Pawn.Position, this.Pawn.Map, WipeMode.Vanish); // float launchAngle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.Pawn.Position, ltiTarget.Cell)).ToAngleFlat(); // for (int m = 0; m < 4; m++) // { // TM_MoteMaker.ThrowGenericMote(ThingDefOf.Gas_Smoke, comp.bitPosition, this.Pawn.Map, Rand.Range(.4f, .7f), Rand.Range(.2f, .3f), .05f, Rand.Range(.4f, .6f), Rand.Range(-20, 20), Rand.Range(3f, 5f), launchAngle += Rand.Range(-25, 25), Rand.Range(0, 360)); // } // SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None); // info.pitchFactor = 2f; // info.volumeFactor = .6f; // SoundDef.Named("Mortar_LaunchA").PlayOneShot(info); // projectile.def.projectile.speed = 20 + PwrVal; // projectile.def.projectile.explosionDelay = Rand.Range(80, 120) - (4 * PwrVal); // projectile.Launch(this.Pawn, comp.bitPosition, ltiTarget, targetThing, ProjectileHitFlags.All, null, null); //} //else //{ // //fire he grenade // Projectile projectile = (Projectile)GenSpawn.Spawn(ThingDef.Named("Projectile_TMFragGrenade"), this.Pawn.Position, this.Pawn.Map, WipeMode.Vanish); // float launchAngle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.Pawn.Position, ltiTarget.Cell)).ToAngleFlat(); // for (int m = 0; m < 4; m++) // { // TM_MoteMaker.ThrowGenericMote(ThingDefOf.Gas_Smoke, comp.bitPosition, this.Pawn.Map, Rand.Range(.4f, .7f), Rand.Range(.2f, .3f), .05f, Rand.Range(.4f, .6f), Rand.Range(-20, 20), Rand.Range(3f, 5f), launchAngle += Rand.Range(-25, 25), Rand.Range(0, 360)); // } // SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None); // info.pitchFactor = 1.4f; // info.volumeFactor = .5f; // SoundDef.Named("Mortar_LaunchA").PlayOneShot(info); // projectile.def.projectile.speed = 20 + PwrVal; // projectile.def.projectile.explosionDelay = Rand.Range(80, 120) - (4 * PwrVal); // projectile.Launch(this.Pawn, comp.bitPosition, ltiTarget, targetThing, ProjectileHitFlags.All, null, null); //} Projectile p = (Projectile)(GenSpawn.Spawn(ThingDef.Named("Projectile_TM_BitTechLaser"), this.Pawn.Position, this.Pawn.Map, WipeMode.Vanish)); //float launchAngle = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(this.Pawn.Position, ltiTarget.Cell)).ToAngleFlat(); SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None); info.pitchFactor = 1.5f; info.volumeFactor = .9f; SoundDef.Named("Shot_ChargeBlaster").PlayOneShot(info); if (rndTargetCell == targetThing.Position) { p.Launch(this.Pawn, comp.bitPosition, targetThing, targetThing, ProjectileHitFlags.IntendedTarget, false, null, null); } else { p.Launch(this.Pawn, comp.bitPosition, ltiTarget, targetThing, ProjectileHitFlags.All, false, null, null); } this.nextBitGrenade = 3 + Find.TickManager.TicksGame; this.bitGrenadeCount--; if (this.bitGrenadeCount == 0) { this.bitGrenadeCount = 3 + (int)((this.PwrVal) / 5); this.nextBitGrenade = Find.TickManager.TicksGame + (180 - 3 * PwrVal); comp.Mana.CurLevel -= (.06f - (.001f * this.PwrVal)); comp.MagicUserXP += Rand.Range(8, 12); } } else if (this.nextBitGrenade < Find.TickManager.TicksGame && this.bitGrenadeCount <= 0) { this.bitGrenadeCount = 3 + (int)((this.PwrVal) / 5); this.nextBitGrenade = Find.TickManager.TicksGame + (180 - 3 * PwrVal); } } } } } }
protected override bool TryCastShot() { bool flag = false; Pawn caster = this.CasterPawn; Pawn hitPawn = this.currentTarget.Thing as Pawn; CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); if (comp != null && comp.MagicData != null) { pwrVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_Enrage, "TM_Enrage", "_pwr", true); verVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_Enrage, "TM_Enrage", "_ver", true); arcaneDmg = comp.arcaneDmg; } if (hitPawn != null && hitPawn.RaceProps != null && hitPawn.RaceProps.Humanlike && !TM_Calc.IsUndead(hitPawn)) { if (hitPawn.Faction != caster.Faction && hitPawn.mindState != null && hitPawn.mindState.mentalStateHandler != null) { if (Rand.Chance(TM_Calc.GetSpellSuccessChance(caster, hitPawn, true))) { try { hitPawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk, null, true, false, caster); } catch { MoteMaker.ThrowText(hitPawn.DrawPos, hitPawn.Map, "Failed", -1); } } else { MoteMaker.ThrowText(hitPawn.DrawPos, hitPawn.Map, "TM_ResistedSpell".Translate(), -1); return(false); } } HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_EnrageHD, (.25f + (.05f + pwrVal)) * (.5f * arcaneDmg)); HediffComp_Enrage hdc = hitPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_EnrageHD).TryGetComp <HediffComp_Enrage>(); hdc.reductionFactor = (1f - (.1f * verVal)); if (verVal >= 4) { hdc.consumeJoy = true; } } else { Messages.Message("TM_InvalidTarget".Translate(CasterPawn.LabelShort, this.Ability.Def.label), MessageTypeDefOf.RejectInput); } this.PostCastShot(flag, out flag); return(flag); }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; Pawn victim = hitThing as Pawn; Pawn pawn = this.launcher as Pawn; ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); 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 = pawn.GetComp <CompAbilityUserMight>().mightPwr; } else { CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_LightningCloud.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_LightningCloud_pwr"); ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_LightningCloud.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_LightningCloud_ver"); pwrVal = pwr.level; verVal = ver.level; this.arcaneDmg = comp.arcaneDmg; } if (settingsRef.AIHardMode && !pawn.IsColonist) { pwrVal = 3; verVal = 3; } radius = (int)this.def.projectile.explosionRadius + (1 * verVal); CellRect cellRect = CellRect.CenteredOn(base.Position, radius - 3); cellRect.ClipInsideMap(map); IntVec3 randomCell = cellRect.RandomCell; duration = 900 + (verVal * 120); if (this.primed == true) { if ((this.shockDelay + this.lastStrike) < this.age) { for (int i = 0; i < 3; i++) { randomCell = cellRect.RandomCell; if (randomCell.InBounds(map)) { victim = randomCell.GetFirstPawn(map); if (victim != null) { if (Rand.Chance(TM_Calc.GetSpellSuccessChance(pawn, victim) - .3f)) { damageEntities(victim, Mathf.RoundToInt((this.def.projectile.GetDamageAmount(1, null) + pwrVal) * this.arcaneDmg)); } } } } Vector3 loc2 = base.Position.ToVector3Shifted(); Vector3 loc = randomCell.ToVector3Shifted(); bool rand1 = Rand.Range(0, 100) < 3; bool rand2 = Rand.Range(0, 100) < 16; if (rand1) { MoteMaker.ThrowSmoke(loc2, map, radius); SoundDefOf.Ambient_AltitudeWind.sustainFadeoutTime.Equals(30.0f); } if (rand2) { MoteMaker.ThrowSmoke(loc, map, 4f); } MoteMaker.ThrowMicroSparks(loc, map); MoteMaker.ThrowLightningGlow(loc, map, 2f); strikeInt++; this.lastStrike = this.age; this.shockDelay = Rand.Range(1, 5); bool flag1 = this.age <= duration; if (!flag1) { this.primed = false; } } } }
protected override bool TryCastShot() { bool flag = false; this.TargetsAoE.Clear(); this.UpdateTargets(); MagicPowerSkill pwr = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Polymorph.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Polymorph_pwr"); MagicPowerSkill ver = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Polymorph.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Polymorph_ver"); verVal = ver.level; pwrVal = pwr.level; CompAbilityUserMagic comp = base.CasterPawn.GetComp <CompAbilityUserMagic>(); this.arcaneDmg = base.CasterPawn.GetComp <CompAbilityUserMagic>().arcaneDmg; this.duration += Mathf.RoundToInt(600 * verVal * this.arcaneDmg); 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"); MightPowerSkill mver = base.CasterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); pwrVal = mpwr.level; verVal = mver.level; } ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (settingsRef.AIHardMode && !this.CasterPawn.IsColonist) { verVal = 2; pwrVal = 3; } 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++) { Pawn newPawn = this.TargetsAoE[i].Thing as Pawn; if (newPawn != this.CasterPawn) { CompPolymorph compPoly = newPawn.GetComp <CompPolymorph>(); if (compPoly != null && compPoly.Original != null && compPoly.TicksLeft > 0) { compPoly.Temporary = true; compPoly.TicksLeft = 0; } else { float enchantChance = .5f; if (!TM_Calc.IsRobotPawn(newPawn)) { enchantChance = (.5f + (.1f * pwrVal) * TM_Calc.GetSpellSuccessChance(this.CasterPawn, newPawn)); } else { enchantChance = (.0f + (.2f * pwrVal) * TM_Calc.GetSpellSuccessChance(this.CasterPawn, newPawn)); } if (Rand.Chance(enchantChance) && newPawn.GetComp <CompPolymorph>() != null) { FactionDef fDef = null; if (newPawn.Faction != null) { fDef = newPawn.Faction.def; } SpawnThings spawnThing = new SpawnThings(); spawnThing.factionDef = fDef; spawnThing.spawnCount = 1; spawnThing.temporary = false; GetPolyMinMax(newPawn); spawnThing = TM_Action.AssignRandomCreatureDef(spawnThing, this.min, this.max); if (spawnThing.def == null || spawnThing.kindDef == null) { spawnThing.def = ThingDef.Named("Rat"); spawnThing.kindDef = PawnKindDef.Named("Rat"); Log.Message("random creature was null"); } Pawn polymorphedPawn = TM_Action.PolymorphPawn(this.CasterPawn, newPawn, newPawn, spawnThing, newPawn.Position, true, duration, newPawn.Faction); if (polymorphedPawn.Faction != this.CasterPawn.Faction && polymorphedPawn.mindState != null && Rand.Chance(Mathf.Clamp((.2f * this.pwrVal), 0f, .5f))) { polymorphedPawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk, "wild beast!", true, false, null, true); } if (this.verVal >= 3) { polymorphedPawn.GetComp <CompPolymorph>().Temporary = false; } FleckMaker.ThrowSmoke(newPawn.DrawPos, newPawn.Map, 2); FleckMaker.ThrowMicroSparks(newPawn.DrawPos, newPawn.Map); FleckMaker.ThrowHeatGlow(newPawn.Position, newPawn.Map, 2); newPawn.DeSpawn(); if (polymorphedPawn.IsColonist && !base.CasterPawn.IsColonist) { TM_Action.SpellAffectedPlayerWarning(polymorphedPawn); } } else { MoteMaker.ThrowText(newPawn.DrawPos, newPawn.Map, "TM_ResistedSpell".Translate(), -1); } } } } this.PostCastShot(flag, out flag); return(flag); }
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(); } 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); SnowUtility.AddSnowRadial(cellList[i], map, 2.4f, Rand.Range(.08f, .13f)); 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)); } List <IntVec3> windList = GenRadial.RadialCellsAround(this.currentTarget.Cell, this.UseAbilityProps.TargetAoEProperties.range + 1, true).Except(cellList).ToList(); for (int i = 0; i < windList.Count; i++) { windList[i] = windList[i].ClampInsideMap(map); Vector3 angle = TM_Calc.GetVector(windList[i], this.currentTarget.Cell); TM_FleckMaker.ThrowGenericFleck(FleckDefOf.AirPuff, windList[i].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 CompPostTick(ref float severityAdjustment) { if (base.Pawn != null & base.parent != null && !this.Pawn.Dead) { if (!initialized) { initialized = true; this.Initialize(); } base.CompPostTick(ref severityAdjustment); if (Find.TickManager.TicksGame % 60 == 0 && initialized) { DeterminePsionicHD(); severityAdjustment += (this.Pawn.GetStatValue(StatDefOf.PsychicSensitivity, false) * Rand.Range(.04f, .12f)); if (Find.Selector.FirstSelectedObject == this.Pawn) { HediffStage hediffStage = this.Pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_PsionicHD"), false).CurStage; hediffStage.label = this.parent.Severity.ToString("0.00") + "%"; } Hediff hediff = this.Pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_Artifact_PsionicBoostHD); float maxSev = 100; if (hediff != null) { maxSev += hediff.Severity; } this.parent.Severity = Mathf.Clamp(this.parent.Severity, 0, maxSev); } if (base.Pawn.Spawned && !this.Pawn.Downed && base.Pawn.Map != null && comp != null) { if (this.doPsionicAttack) { this.ticksTillPsionicStrike--; if (this.ticksTillPsionicStrike <= 0) { this.doPsionicAttack = false; if (threat != null && !threat.Destroyed && !threat.Dead && !threat.Downed) { TM_MoteMaker.MakePowerBeamMotePsionic(threat.DrawPos.ToIntVec3(), threat.Map, 2f, 2f, .7f, .1f, .6f); DamageInfo dinfo2 = new DamageInfo(TMDamageDefOf.DamageDefOf.TM_PsionicInjury, Rand.Range(6, 12) * this.Pawn.GetStatValue(StatDefOf.PsychicSensitivity, false) + (2 * VerVal), 0, -1, this.Pawn, null, null, DamageInfo.SourceCategory.ThingOrUnknown, this.threat); this.threat.TakeDamage(dinfo2); } } } if (comp.usePsionicAugmentationToggle && this.Pawn.drafter != null && this.Pawn.CurJob != null) { if (Find.TickManager.TicksGame % 600 == 0 && !this.Pawn.Drafted) { if (this.parent.Severity >= 95 && this.Pawn.CurJob.targetA != null && this.Pawn.CurJob.targetA.Thing != null) { if ((this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal > 20 && (this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal < 300 && this.Pawn.CurJob.locomotionUrgency >= LocomotionUrgency.Jog && this.Pawn.CurJob.bill == null) { this.parent.Severity -= 10f; if (this.EffVal == 0) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD"), 1f + .02f * this.EffVal); } else if (this.EffVal == 1) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD_I"), 1f + .02f * this.EffVal); } else if (this.EffVal == 2) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD_II"), 1f + .02f * this.EffVal); } else { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicSpeedHD_III"), 1f + .02f * this.EffVal); } for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } comp.MightUserXP += Rand.Range(10, 15); } if ((this.Pawn.Position - this.Pawn.CurJob.targetA.Thing.Position).LengthHorizontal < 2 && (this.Pawn.CurJob.bill != null || this.Pawn.CurJob.def.defName == "Sow" || this.Pawn.CurJob.def.defName == "FinishFrame" || this.Pawn.CurJob.def.defName == "Deconstruct" || this.Pawn.CurJob.def.defName == "Repair" || this.Pawn.CurJob.def.defName == "Clean" || this.Pawn.CurJob.def.defName == "Mine" || this.Pawn.CurJob.def.defName == "SmoothFloor" || this.Pawn.CurJob.def.defName == "SmoothWall" || this.Pawn.CurJob.def.defName == "Harvest" || this.Pawn.CurJob.def.defName == "HarvestDesignated" || this.Pawn.CurJob.def.defName == "CutPlant" || this.Pawn.CurJob.def.defName == "CutPlantDesignated")) { this.parent.Severity -= 12f; if (this.PwrVal == 0) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD"), 1f + .02f * this.PwrVal); } else if (this.PwrVal == 1) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD_I"), 1f + .02f * this.PwrVal); } else if (this.PwrVal == 2) { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD_II"), 1f + .02f * this.PwrVal); } else { HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicManipulationHD_III"), 1f + .02f * this.PwrVal); } for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } comp.MightUserXP += Rand.Range(10, 15); } } } if (this.parent.Severity >= 20) { if (Find.TickManager.TicksGame % 180 == 0 && (this.Pawn.Drafted || !this.Pawn.IsColonist) && ((this.Pawn.equipment.Primary != null && !this.Pawn.equipment.Primary.def.IsRangedWeapon) || this.Pawn.equipment.Primary == null)) { if (this.Pawn.CurJob.targetA != null && this.Pawn.CurJob.targetA.Thing != null && this.Pawn.CurJob.targetA.Thing is Pawn && this.Pawn.CurJobDef == JobDefOf.AttackMelee) { //Log.Message("performing psionic dash - curjob " + this.Pawn.CurJob); //Log.Message("curjob def " + this.Pawn.CurJob.def.defName); //Log.Message("target " + this.Pawn.CurJob.targetA.Thing); //Log.Message("target range " + (this.Pawn.CurJob.targetA.Thing.Position - this.Pawn.Position).LengthHorizontal); Pawn targetPawn = this.Pawn.CurJob.targetA.Thing as Pawn; float targetDistance = (this.Pawn.Position - targetPawn.Position).LengthHorizontal; if (targetDistance > 3 && targetDistance < (12 + EffVal) && targetPawn.Map != null && !targetPawn.Downed) { for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } FlyingObject_PsionicLeap flyingObject = (FlyingObject_PsionicLeap)GenSpawn.Spawn(ThingDef.Named("FlyingObject_PsionicLeap"), this.Pawn.Position, this.Pawn.Map); flyingObject.Launch(this.Pawn, this.Pawn.CurJob.targetA.Thing, this.Pawn); HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicHD"), -3f); comp.Stamina.CurLevel -= .03f; comp.MightUserXP += Rand.Range(20, 30); } } } if (this.nextPsionicAttack < Find.TickManager.TicksGame && this.Pawn.Drafted && comp.usePsionicMindAttackToggle) { if (this.Pawn.CurJob.def != TorannMagicDefOf.JobDriver_PsionicBarrier && VerVal > 0) { this.threat = TM_Calc.FindNearbyEnemy(this.Pawn, 20 + (2 * verVal)); // GetNearbyTarget(20 + (2 * VerVal)); if (threat != null) { //start psionic attack; ends after delay SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None); TorannMagicDefOf.TM_Implosion.PlayOneShot(info); Effecter psionicAttack = TorannMagicDefOf.TM_GiantExplosion.Spawn(); psionicAttack.Trigger(new TargetInfo(threat.Position, threat.Map, false), new TargetInfo(threat.Position, threat.Map, false)); psionicAttack.Cleanup(); for (int i = 0; i < 12; i++) { float direction = Rand.Range(0, 360); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Psi"), this.Pawn.DrawPos, this.Pawn.Map, Rand.Range(.1f, .4f), 0.2f, .02f, .1f, 0, Rand.Range(8, 10), direction, direction); } float weaponModifier = 1; if (this.Pawn.equipment.Primary != null) { if (this.Pawn.equipment.Primary.def.IsRangedWeapon) { StatModifier wpnMass = this.Pawn.equipment.Primary.def.statBases.FirstOrDefault((StatModifier x) => x.stat.defName == "Mass"); weaponModifier = Mathf.Clamp(wpnMass.value, .8f, 6); } else //assume melee weapon { StatModifier wpnMass = this.Pawn.equipment.Primary.def.statBases.FirstOrDefault((StatModifier x) => x.stat.defName == "Mass"); weaponModifier = Mathf.Clamp(wpnMass.value, .6f, 4); } } else //unarmed { weaponModifier = .4f; } this.nextPsionicAttack = Find.TickManager.TicksGame + (int)(Mathf.Clamp((600 - (60 * verVal)) * weaponModifier, 120, 900)); float energyCost = Mathf.Clamp((10f - VerVal) * weaponModifier, 2f, 12f); HealthUtility.AdjustSeverity(this.Pawn, HediffDef.Named("TM_PsionicHD"), -energyCost); comp.MightUserXP += Rand.Range(8, 12); this.doPsionicAttack = true; this.ticksTillPsionicStrike = 24; } } } } } } } }
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); for (int i = 0; i < targets.Count(); i++) { curCell = targets.ToArray <IntVec3>()[i]; 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) { i = targets.Count(); } } }
protected override bool TryCastShot() { bool flag10 = false; this.TargetsAoE.Clear(); this.UpdateTargets(); int shotsPerBurst = this.ShotsPerBurst; 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++) { bool?flag3 = this.TryLaunchProjectile(this.verbProps.defaultProjectile, this.TargetsAoE[i]); bool hasValue = flag3.HasValue; if (hasValue) { bool flag4 = flag3 == true; if (flag4) { flag10 = true; } bool flag5 = flag3 == false; if (flag5) { flag10 = false; } } } CellRect cellRect = CellRect.CenteredOn(this.currentTarget.Cell, 1); Map map = caster.Map; cellRect.ClipInsideMap(map); IntVec3 centerCell = cellRect.CenterCell; Thing summonableThing = new Thing(); FlyingObject summonablePawn = new FlyingObject(); Pawn victim = null; //dinfo.SetAmount(10); //dinfo.SetWeaponHediff(TorannMagicDefOf.TM_GrapplingHook); bool pflag = true; summonableThing = centerCell.GetFirstPawn(map); if (summonableThing == null) { pflag = false; //miss } else { pVect = summonableThing.TrueCenter(); pVect.x = base.caster.TrueCenter().x; pVect.z = base.caster.TrueCenter().z; pVect.y = 0f; victim = summonableThing as Pawn; if (victim != null) { if (!victim.IsColonist && !victim.IsPrisoner && !victim.Faction.HostileTo(this.CasterPawn.Faction) && victim.Faction != null && victim.RaceProps.Humanlike) { Faction faction = victim.Faction; faction.TrySetRelationKind(this.CasterPawn.Faction, FactionRelationKind.Ally, false, null); } } } bool result; bool arg_40_0; if (this.currentTarget != null && base.caster != null) { IntVec3 arg_29_0 = this.currentTarget.Cell; arg_40_0 = this.caster.Position.IsValid; } else { arg_40_0 = false; } bool flag = arg_40_0; if (flag) { if (summonableThing != null) { if (pflag) { DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Stun, 10, 10, -1, this.CasterPawn, null, null, DamageInfo.SourceCategory.ThingOrUnknown, victim); if (!victim.RaceProps.Humanlike || victim.Faction == this.CasterPawn.Faction) { summonablePawn = (FlyingObject)GenSpawn.Spawn(ThingDef.Named("TM_SummonedPawn"), summonableThing.Position, summonableThing.Map); summonablePawn.impactDamage = dinfo2; summonablePawn.Launch(base.caster, new LocalTargetInfo(pVect.ToIntVec3()), summonableThing); } else if (victim.RaceProps.Humanlike && victim.Faction != this.CasterPawn.Faction && Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, victim, true))) { summonablePawn = (FlyingObject)GenSpawn.Spawn(ThingDef.Named("TM_SummonedPawn"), summonableThing.Position, summonableThing.Map); summonablePawn.impactDamage = dinfo2; summonablePawn.Launch(base.caster, new LocalTargetInfo(pVect.ToIntVec3()), summonableThing); } else { MoteMaker.ThrowText(victim.DrawPos, victim.Map, "TM_ResistedSpell".Translate(), -1); } } else { //miss } result = true; } } else { Log.Warning("failed to TryCastShot"); } //this.burstShotsLeft = 0; //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60; this.PostCastShot(flag10, out flag10); return(flag); }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; if (!initialized && this.age < this.duration && hitThing != null) { caster = this.launcher as Pawn; hitPawn = hitThing as Pawn; this.oldPosition = caster.Position; MightPowerSkill pwr = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Possess.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Possess_pwr"); MightPowerSkill ver = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Possess.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Possess_ver"); ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); pwrVal = pwr.level; verVal = ver.level; if (settingsRef.AIHardMode && !caster.IsColonist) { pwrVal = 3; verVal = 3; } this.duration += pwrVal * 300; if (hitPawn != null && hitPawn.Faction != null && hitPawn.RaceProps.Humanlike) { possessedFlag = hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_CoOpPossessionHD) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_CoOpPossessionHD_I) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_CoOpPossessionHD_II) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_CoOpPossessionHD_III) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_PossessionHD) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_PossessionHD_I) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_PossessionHD_II) || hitPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_PossessionHD_III); if (!hitPawn.Downed && !hitPawn.Dead && !possessedFlag && !hitPawn.IsPrisoner) { this.pFaction = hitPawn.Faction; this.prisoner = hitPawn.IsPrisoner; if (!caster.IsColonist && hitPawn.IsColonist) { IEnumerable <WorkTypeDef> allWorkTypes = WorkTypeDefsUtility.WorkTypeDefsInPriorityOrder; this.hitPawnWorkSetting = new List <int>(); foreach (var workType in allWorkTypes) { hitPawnWorkSetting.Add(hitPawn.workSettings.GetPriority(workType)); } } if (this.pFaction != caster.Faction) { if (Rand.Chance(TM_Calc.GetSpellSuccessChance(caster, hitPawn, true))) { //possess enemy or neutral int weaponCount = 0; if (hitPawn.equipment.PrimaryEq != null) { weaponCount = 1; } this.inventoryCount = hitPawn.inventory.innerContainer.Count + hitPawn.apparel.WornApparelCount + weaponCount; if (ModCheck.Validate.GiddyUp.Core_IsInitialized()) { ModCheck.GiddyUp.ForceDismount(caster); ModCheck.GiddyUp.ForceDismount(hitPawn); } hitPawn.SetFaction(caster.Faction, null); HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_DisguiseHD_II, 20f + (5f * pwrVal)); switch (verVal) { case 0: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_PossessionHD, 20f + (5f * pwrVal)); break; case 1: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_PossessionHD_I, 20f + (5f * pwrVal)); break; case 2: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_PossessionHD_II, 20f + (5f * pwrVal)); break; case 3: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_PossessionHD_III, 20f + (5f * pwrVal)); break; } initialized = true; MoteMaker.ThrowSmoke(caster.DrawPos, caster.Map, 1f); MoteMaker.ThrowSmoke(caster.DrawPos, caster.Map, 1.2f); MoteMaker.ThrowHeatGlow(caster.Position, caster.Map, .8f); if (!caster.IsColonist) { Lord lord = caster.GetLord(); LordJob lordJob = caster.GetLord().LordJob; try { PawnDuty duty = caster.mindState.duty; hitPawn.mindState.duty = duty; lord.AddPawn(hitPawn); } catch { Log.Message("error attempting to assign a duty to pawn during possession"); } } //loadPawn = caster; //loadPawn.ThingID += Rand.Range(0, 214).ToString(); if (caster.IsColonist) { // ModOptions.Constants.SetPawnInFlight(true); // } if (hitPawn.IsColonist && !caster.IsColonist) { TM_Action.SpellAffectedPlayerWarning(hitPawn); } caster.DeSpawn(); } else { MoteMaker.ThrowText(hitThing.DrawPos, hitThing.Map, "TM_ResistedSpell".Translate(), -1); this.age = this.duration; this.Destroy(DestroyMode.Vanish); } } else { //possess friendly if (ModCheck.Validate.GiddyUp.Core_IsInitialized()) { ModCheck.GiddyUp.ForceDismount(caster); } HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_DisguiseHD_II, 20f + (5f * pwrVal)); switch (verVal) { case 0: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_CoOpPossessionHD, 20f + (5f * pwrVal)); break; case 1: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_CoOpPossessionHD_I, 20f + (5f * pwrVal)); break; case 2: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_CoOpPossessionHD_II, 20f + (5f * pwrVal)); break; case 3: HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_CoOpPossessionHD_III, 20f + (5f * pwrVal)); break; } initialized = true; MoteMaker.ThrowSmoke(caster.DrawPos, caster.Map, 1f); MoteMaker.ThrowSmoke(caster.DrawPos, caster.Map, 1.2f); MoteMaker.ThrowHeatGlow(caster.Position, caster.Map, .8f); caster.DeSpawn(); } } else { Messages.Message("TM_CannotPossessNow".Translate( caster.LabelShort, hitPawn.LabelShort ), MessageTypeDefOf.RejectInput); this.age = this.duration; this.Destroy(DestroyMode.Vanish); } } else { Messages.Message("TM_CannotPossess".Translate( caster.LabelShort, hitThing.LabelShort ), MessageTypeDefOf.RejectInput); this.age = this.duration; this.Destroy(DestroyMode.Vanish); } } else { if (!this.initialized) { this.age = this.duration; Destroy(DestroyMode.Vanish); } } if (hitPawn != null && (hitPawn.Downed || hitPawn.Dead)) { this.age = this.duration; } }