protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; Pawn pawn = this.launcher as Pawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Snowball.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Snowball_pwr"); MagicPowerSkill ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Snowball.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Snowball_ver"); ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); pwrVal = pwr.level; verVal = ver.level; if (settingsRef.AIHardMode && !pawn.IsColonistPlayerControlled) { pwrVal = 3; verVal = 3; } GenExplosion.DoExplosion(base.Position, map, this.def.projectile.explosionRadius + (0.7f * (float)pwrVal), TMDamageDefOf.DamageDefOf.Snowball, this.launcher, this.def.projectile.damageAmountBase, SoundDefOf.Crunch, def, this.equipmentDef, null, 0f, 1, false, null, 0f, 1, 0f, true); CellRect cellRect = CellRect.CenteredOn(base.Position, 3 + (verVal * 1)); cellRect.ClipInsideMap(map); for (int i = 0; i < verVal * 5; i++) { IntVec3 randomCell = cellRect.RandomCell; this.IceExplosion(pwrVal, randomCell, map, (float)verVal * 0.4f); Vector3 loc = randomCell.ToVector3Shifted(); MoteMaker.ThrowSmoke(loc, map, 4.2f); MoteMaker.ThrowSmoke(loc, map, 0.6f * (float)pwrVal); MoteMaker.ThrowAirPuffUp(loc, map); MoteMaker.ThrowDustPuff(loc, map, 1.0f * (float)pwrVal); AddSnowRadial(randomCell, map, this.def.projectile.explosionRadius, (this.def.projectile.explosionRadius / 2) + (0.7f * (float)verVal)); } AddSnowRadial(base.Position, map, this.def.projectile.explosionRadius, this.def.projectile.explosionRadius + (0.7f * (float)verVal)); }
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; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Firebolt.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Firebolt_pwr"); pwrVal = pwr.level; 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; } GenExplosion.DoExplosion(base.Position, map, 0.4f, TMDamageDefOf.DamageDefOf.Firebolt, this.launcher, Mathf.RoundToInt(this.def.projectile.damageAmountBase * comp.arcaneDmg), this.def.projectile.soundExplode, def, this.equipmentDef, null, 0f, 1, false, null, 0f, 1, 0.6f, false); CellRect cellRect = CellRect.CenteredOn(base.Position, 3); cellRect.ClipInsideMap(map); victim = base.Position.GetFirstPawn(map); if (victim != null) { int dmg = Mathf.RoundToInt(((this.def.projectile.damageAmountBase / 3) * pwr.level) * comp.arcaneDmg); //projectile = 16 if (settingsRef.AIHardMode && !pawn.IsColonist) { dmg += 10; } damageEntities(victim, dmg, TMDamageDefOf.DamageDefOf.Firebolt); } }
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 bool TryCastShot() { bool result = false; CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>(); Pawn soulPawn = comp.soulBondPawn; if (soulPawn != null && !soulPawn.Dead && !soulPawn.Destroyed) { bool drafted = soulPawn.Drafted; Map map = this.CasterPawn.Map; IntVec3 casterCell = this.CasterPawn.Position; IntVec3 targetCell = soulPawn.Position; try { soulPawn.DeSpawn(); GenSpawn.Spawn(soulPawn, casterCell, map); if (drafted) { soulPawn.drafter.Drafted = true; } } catch { Log.Message("Exception occured when trying to summon soul bound pawn - recovered pawn at original position"); GenSpawn.Spawn(soulPawn, targetCell, map); } //this.Ability.PostAbilityAttempt(); result = true; } else { Log.Warning("No soul bond found to shadow call."); } this.burstShotsLeft = 0; //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60; return(result); }
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; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Icebolt.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Icebolt_pwr"); MagicPowerSkill ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Icebolt.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Icebolt_ver"); pwrVal = pwr.level; verVal = ver.level; if (settingsRef.AIHardMode && !pawn.IsColonistPlayerControlled) { pwrVal = 3; verVal = 3; } GenExplosion.DoExplosion(base.Position, map, 0.4f, TMDamageDefOf.DamageDefOf.Iceshard, this.launcher, this.def.projectile.damageAmountBase, this.def.projectile.soundExplode, def, this.equipmentDef, null, 0f, 1, false, null, 0f, 1, 0f, false); CellRect cellRect = CellRect.CenteredOn(base.Position, 3); cellRect.ClipInsideMap(map); for (int i = 0; i < Rand.Range((1 * verVal), (6 * verVal)); i++) { IntVec3 randomCell = cellRect.RandomCell; if (pwrVal > 0) { this.Shrapnel(pwrVal, randomCell, map, 0.4f); } else { this.Shrapnel(1, randomCell, map, 0.4f); } } }
protected override bool TryCastShot() { Pawn caster = base.CasterPawn; Pawn pawn = this.currentTarget.Thing as Pawn; comp = caster.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = comp.MagicData.MagicPowerSkill_EnchantWeapon.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_EnchantWeapon_pwr"); pwrVal = pwr.level; ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (caster.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { pwrVal = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr").level; } if (settingsRef.AIHardMode && !caster.IsColonist) { pwrVal = 3; } if (pawn != null) { if (pawn.equipment != null && pawn.equipment.Primary != null && pawn.equipment.Primary.def.IsMeleeWeapon) { RemoveExistingEnchantment(pawn); ApplyEnchantment(pawn); } else if (this.CasterPawn.IsColonist) { Messages.Message("TM_NoMeleeWeaponToEnchant".Translate( pawn ), MessageTypeDefOf.RejectInput); return(false); } } return(true); }
public void ApplyEnchantment(Pawn pawn) { HediffDef hediff = null; float rnd = Rand.Range(0, 1f); if (rnd < .25f) { hediff = TorannMagicDefOf.TM_WeaponEnchantment_FireHD; TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Heat"), pawn.DrawPos, pawn.Map, 1f, .2f, .1f, .8f, Rand.Range(-30, 30), .3f, Rand.Range(-30, 30), Rand.Range(0, 360)); FleckMaker.ThrowFireGlow(pawn.Position.ToVector3Shifted(), pawn.Map, 1f); } else if (rnd < .5f) { hediff = TorannMagicDefOf.TM_WeaponEnchantment_IceHD; TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Ice"), pawn.DrawPos, pawn.Map, 1f, .2f, .1f, .8f, Rand.Range(-30, 30), .3f, Rand.Range(-30, 30), Rand.Range(0, 360)); } else if (rnd < .75f) { hediff = TorannMagicDefOf.TM_WeaponEnchantment_LitHD; FleckMaker.ThrowLightningGlow(pawn.DrawPos, pawn.Map, 1f); FleckMaker.ThrowSmoke(pawn.DrawPos, pawn.Map, 1f); } else { hediff = TorannMagicDefOf.TM_WeaponEnchantment_DarkHD; TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Shadow"), pawn.DrawPos, pawn.Map, 1f, .2f, .1f, .8f, Rand.Range(-30, 30), .3f, Rand.Range(-30, 30), Rand.Range(0, 360)); } HealthUtility.AdjustSeverity(pawn, hediff, .5f + pwrVal); CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>(); comp.weaponEnchants.Add(pawn); Hediff diff = pawn.health.hediffSet.GetFirstHediffOfDef(hediff, false); HediffComp_EnchantedWeapon ewComp = diff.TryGetComp <HediffComp_EnchantedWeapon>(); ewComp.enchantedWeapon = pawn.equipment.Primary; ewComp.enchanterPawn = this.CasterPawn; }
public void Launch(Thing launcher, Vector3 origin, LocalTargetInfo targ, Thing flyingThing, DamageInfo?newDamageInfo = null) { bool spawned = flyingThing.Spawned; pawn = launcher as Pawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); this.arcaneDmg = comp.arcaneDmg; MagicPowerSkill pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_EyeOfTheStorm.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_EyeOfTheStorm_pwr"); MagicPowerSkill ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_EyeOfTheStorm.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_EyeOfTheStorm_ver"); verVal = ver.level; pwrVal = pwr.level; ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (settingsRef.AIHardMode && !pawn.IsColonist) { pwrVal = 1; verVal = 1; } if (spawned) { flyingThing.DeSpawn(); } this.launcher = launcher; this.origin = origin; this.impactDamage = newDamageInfo; this.flyingThing = flyingThing; bool flag = targ.Thing != null; if (flag) { this.assignedTarget = targ.Thing; } this.destination = targ.Cell.ToVector3Shifted() + new Vector3(Rand.Range(-0.3f, 0.3f), 0f, Rand.Range(-0.3f, 0.3f)); this.ticksToImpact = this.StartingTicksToImpact; this.Initialize(); }
private void Initialize() { bool spawned = base.Pawn.Spawned; if (bonderPawn == null) { if (spawned) { FleckMaker.ThrowHeatGlow(base.Pawn.DrawPos.ToIntVec3(), base.Pawn.Map, 2f); } List <Pawn> mapPawns = this.Pawn.Map.mapPawns.AllPawnsSpawned; for (int i = 0; i < mapPawns.Count(); i++) { if (!mapPawns[i].DestroyedOrNull() && mapPawns[i].Spawned && !mapPawns[i].Downed && mapPawns[i].RaceProps.Humanlike) { CompAbilityUserMight comp = mapPawns[i].GetComp <CompAbilityUserMight>(); if (comp.IsMightUser && comp.bondedPet != null) { if (comp.bondedPet == this.Pawn) { this.bonderPawn = comp.Pawn; break; } } CompAbilityUserMagic compMagic = mapPawns[i].GetComp <CompAbilityUserMagic>(); if (compMagic.IsMagicUser && compMagic.bondedSpirit != null) { if (compMagic.bondedSpirit == this.Pawn) { this.bonderPawn = compMagic.Pawn; break; } } } } } }
protected override bool TryCastShot() { bool flag = false; CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>(); if (comp.IsMagicUser) { if (comp.earthSpriteType != 0) { comp.earthSpriteType = 0; comp.earthSpriteMap = null; comp.earthSprites = IntVec3.Invalid; } else { Messages.Message("TM_NoSpritesToDismiss".Translate( this.CasterPawn.LabelShort ), MessageTypeDefOf.RejectInput); } } this.PostCastShot(flag, out flag); return(flag); }
//public override bool CanHitTargetFrom(IntVec3 root, LocalTargetInfo targ) //{ // if (targ.Thing != null && targ.Thing == this.caster) // { // return this.verbProps.targetParams.canTargetSelf; // } // if (targ.IsValid && targ.CenterVector3.InBounds(base.CasterPawn.Map) && !targ.Cell.Fogged(base.CasterPawn.Map) && targ.Cell.Walkable(base.CasterPawn.Map)) // { // if ((root - targ.Cell).LengthHorizontal < this.verbProps.range) // { // ShootLine shootLine; // validTarg = this.TryFindShootLineFromTo(root, targ, out shootLine); // } // else // { // validTarg = false; // } // } // else // { // validTarg = false; // } // return validTarg; //} protected override bool TryCastShot() { bool result = false; Pawn pawn = this.CasterPawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); int burstCountMin = 1; ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_pwr").level >= 2) { burstCountMin++; if (pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_pwr").level >= 7) { burstCountMin++; } } if (!pawn.IsColonist && settingsRef.AIHardMode) { burstCountMin = 3; } Map map = this.CasterPawn.Map; IntVec3 targetVariation = this.currentTarget.Cell; targetVariation.x += Mathf.RoundToInt(Rand.Range(-.05f, .05f) * Vector3.Distance(pawn.DrawPos, this.currentTarget.CenterVector3)); // + Rand.Range(-1f, 1f)); targetVariation.z += Mathf.RoundToInt(Rand.Range(-.05f, .05f) * Vector3.Distance(pawn.DrawPos, this.currentTarget.CenterVector3)); // + Rand.Range(-1f, 1f)); this.TryLaunchProjectile(this.verbProps.defaultProjectile, targetVariation); this.burstShotsLeft--; //Log.Message("burst shots left " + this.burstShotsLeft); float burstCountFloat = (float)(15f - this.burstShotsLeft); float mageLevelFloat = (float)(burstCountMin + (comp.MagicUserLevel / 10f)); result = Rand.Chance(mageLevelFloat - burstCountFloat); return(result); }
private void Initialize() { Pawn pawn = this.CasterPawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_ReverseTime.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ReverseTime_pwr"); MagicPowerSkill ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_ReverseTime.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ReverseTime_ver"); ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); pwrVal = pwr.level; verVal = ver.level; arcaneDmg = comp.arcaneDmg; if (pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { MightPowerSkill mpwr = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); MightPowerSkill mver = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); pwrVal = mpwr.level; verVal = mver.level; } if (settingsRef.AIHardMode && !pawn.IsColonist) { pwrVal = 3; verVal = 3; } }
private static void RecallNeeds(Pawn pawn, CompAbilityUserMagic comp) { for (int i = 0; i < pawn.needs.AllNeeds.Count; i++) { bool hasNeed = false; for (int j = 0; j < comp.recallNeedValues.Count; j++) { if (comp.recallNeedDefnames[j] == pawn.needs.AllNeeds[i].def.defName) { //Log.Message("setting " + pawn.needs.AllNeeds[i].def.defName + " from " + pawn.needs.AllNeeds[i].CurLevel + " to " + comp.recallNeedValues[j]); pawn.needs.AllNeeds[i].CurLevel = comp.recallNeedValues[j]; hasNeed = true; } } if (!hasNeed) { //Log.Message("removing need " + pawn.needs.AllNeeds[i].def.defName); pawn.needs.AllNeeds.Remove(pawn.needs.AllNeeds[i]); } } pawn.needs.AddOrRemoveNeedsAsAppropriate(); comp.recallNeedDefnames.Clear(); comp.recallNeedValues.Clear(); }
public static void Evaluate(CompAbilityUserMagic casterComp, TMAbilityDef abilitydef, PawnAbility ability, MagicPower power, out bool success) { success = false; if (casterComp.Mana.CurLevel >= casterComp.ActualManaCost(abilitydef) && ability.CooldownTicksLeft <= 0) { Pawn caster = casterComp.Pawn; LocalTargetInfo jobTarget = TM_Calc.FindNearbyMage(caster, (int)(abilitydef.MainVerb.range * 1.5f), false); float distanceToTarget = (jobTarget.Cell - caster.Position).LengthHorizontal; if (distanceToTarget < (abilitydef.MainVerb.range * 1.5f) && jobTarget != null && jobTarget.Thing != null && jobTarget.Thing is Pawn) { Pawn targetPawn = jobTarget.Thing as Pawn; CompAbilityUserMagic targetPawnComp = targetPawn.GetComp <CompAbilityUserMagic>(); if (targetPawn.CurJobDef.joyKind != null || targetPawn.CurJobDef == JobDefOf.Wait_Wander || targetPawn.CurJobDef == JobDefOf.GotoWander) { if (targetPawn.IsColonist && targetPawnComp.MagicUserLevel < casterComp.MagicUserLevel && caster.relations.OpinionOf(targetPawn) >= 0) { Job job = ability.GetJob(AbilityContext.AI, jobTarget); caster.jobs.TryTakeOrderedJob(job); success = true; } } } } }
public static void EvaluateMinSeverity(CompAbilityUserMagic casterComp, TMAbilityDef abilitydef, PawnAbility ability, MagicPower power, HediffDef hediffDef, float minSeverity, out bool success) { success = false; if (casterComp.Mana.CurLevel >= casterComp.ActualManaCost(abilitydef) && ability.CooldownTicksLeft <= 0) { Pawn caster = casterComp.Pawn; LocalTargetInfo jobTarget = TM_Calc.FindNearbyInjuredPawn(caster, (int)(abilitydef.MainVerb.range * .9f), minSeverity); if (jobTarget != null) { float distanceToTarget = (jobTarget.Cell - caster.Position).LengthHorizontal; if (distanceToTarget < (abilitydef.MainVerb.range * .9f) && jobTarget.Thing != null && jobTarget.Thing is Pawn) { Pawn targetPawn = jobTarget.Thing as Pawn; if (targetPawn.health != null && targetPawn.health.hediffSet != null && !targetPawn.health.hediffSet.HasHediff(hediffDef, false)) { Job job = ability.GetJob(AbilityContext.AI, jobTarget); caster.jobs.TryTakeOrderedJob(job); success = true; TM_Action.TM_Toils.GotoAndWait(jobTarget.Thing as Pawn, caster, Mathf.RoundToInt(ability.Def.MainVerb.warmupTime * 60)); } } } } }
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 override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { List <FloatMenuOption> list = new List <FloatMenuOption>(); CompAbilityUserMagic comp = myPawn.GetComp <CompAbilityUserMagic>(); if (!myPawn.CanReach(this, PathEndMode.InteractionCell, Danger.Some, false, TraverseMode.ByPawn)) { list.Add(new FloatMenuOption("CannotUseNoPath".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { if (comp.IsMagicUser && this.CapacitorIsOn) { list.Add(new FloatMenuOption("TM_ChargeManaStorage".Translate( Mathf.RoundToInt(this.arcaneEnergyCur * 100) ), delegate { Job job = new Job(TorannMagicDefOf.ChargePortal, this); myPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, MenuOptionPriority.Default, null, null, 0f, null, null)); } } return(list); }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; Pawn hitPawn = hitThing as Pawn; Pawn caster = this.launcher as Pawn; CompAbilityUserMagic compHitPawn = hitPawn.GetComp <CompAbilityUserMagic>(); CompAbilityUserMagic compCaster = caster.GetComp <CompAbilityUserMagic>(); if (hitPawn != null) { if (compHitPawn.IsMagicUser) { MagicPowerSkill regen = hitPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_global_regen.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_global_regen_pwr"); compHitPawn.Mana.CurLevel += (.2f + (.01f * regen.level)); TM_MoteMaker.ThrowManaPuff(hitPawn.Position.ToVector3(), hitPawn.Map, 1f); TM_MoteMaker.ThrowManaPuff(hitPawn.Position.ToVector3(), hitPawn.Map, 1f); } else { float sev = Rand.Range(0, 10); HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_Manipulation, sev); sev = Rand.Range(0, 10); HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_Movement, sev); sev = Rand.Range(0, 10); HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_Breathing, sev); sev = Rand.Range(0, 10); HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_Sight, sev); TM_MoteMaker.ThrowManaPuff(hitPawn.Position.ToVector3(), hitPawn.Map, 1f); TM_MoteMaker.ThrowManaPuff(hitPawn.Position.ToVector3(), hitPawn.Map, 1f); } } }
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 % 120 == 0) { compMagic = this.Pawn.GetComp <CompAbilityUserMagic>(); compMight = this.Pawn.GetComp <CompAbilityUserMight>(); DetermineEnchantments(); } if (Find.TickManager.TicksGame % 480 == 0 && this.enchantment == "unknown") { this.removeNow = true; } }
protected override bool TryCastShot() { Pawn caster = base.CasterPawn; Pawn pawn = this.currentTarget.Thing as Pawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); if (comp.IsMagicUser) { if (comp.summonedMinions.Count > 0) { TMPawnSummoned minion = (TMPawnSummoned)comp.summonedMinions[0]; minion.TicksLeft = 1; } else { Messages.Message("TM_NoMinionToDismiss".Translate(new object[] { this.CasterPawn.LabelShort }), MessageTypeDefOf.RejectInput); } } return(true); }
private void Initialize() { bool spawned = base.Pawn.Spawned; if (spawned) { CompAbilityUserMagic comp = this.Pawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = comp.MagicData.MagicPowerSkill_BattleHymn.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_BattleHymn_pwr"); MagicPowerSkill ver = comp.MagicData.MagicPowerSkill_BattleHymn.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_BattleHymn_ver"); MagicPowerSkill eff = comp.MagicData.MagicPowerSkill_BattleHymn.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_BattleHymn_eff"); this.verVal = ver.level; this.pwrVal = pwr.level; this.effVal = eff.level; ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (settingsRef.AIHardMode && !this.Pawn.IsColonist) { pwrVal = 1; verVal = 1; effVal = 1; } this.chantRange = this.chantRange + (this.verVal * 3f); this.chantFrequency = 300 - (30 * verVal); } }
public static float GetSpellPenetration(Pawn pawn) { float penetration = 0; CompAbilityUserMagic compMagic = pawn.GetComp <CompAbilityUserMagic>(); if (compMagic != null) { penetration += (compMagic.arcaneDmg - 1); } CompAbilityUserMight compMight = pawn.GetComp <CompAbilityUserMight>(); if (compMight != null) { penetration += (compMight.mightPwr - 1); } if (pawn.health != null && pawn.health.capacities != null) { penetration += (pawn.health.capacities.GetLevel(PawnCapacityDefOf.Consciousness) - 1); } return(penetration); }
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); } }
protected override bool TryCastShot() { Map map = base.CasterPawn.Map; Pawn pawn = base.CasterPawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); List <Trait> traits = pawn.story.traits.allTraits; for (int i = 0; i < traits.Count; i++) { if (traits[i].def.defName == "Necromancer") { FixTrait(pawn, pawn.story.traits.allTraits); AdjustPlayerSettings(pawn); pawn.story.traits.GainTrait(new Trait(TraitDef.Named("Lich"), 4, false)); HealthUtility.AdjustSeverity(pawn, HediffDef.Named("TM_LichHD"), .5f); for (int h = 0; h < 24; h++) { pawn.timetable.SetAssignment(h, TimeAssignmentDefOf.Work); } pawn.needs.AddOrRemoveNeedsAsAppropriate(); comp.MagicData.MagicPowersN.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_DeathBolt).learned = true; comp.AddPawnAbility(TorannMagicDefOf.TM_DeathBolt, false); comp.spell_Flight = true; comp.InitializeSpell(); TM_MoteMaker.ThrowScreamMote(pawn.Position.ToVector3(), pawn.Map, 2f, 216, 255, 0); } else { //Log.Message("Necromancer trait not found."); } } this.burstShotsLeft = 0; return(false); }
public static void Evaluate(CompAbilityUserMagic casterComp, TMAbilityDef abilitydef, PawnAbility ability, MagicPower power, out bool success) { success = false; Pawn caster = casterComp.Pawn; LocalTargetInfo jobTarget = caster; if (casterComp.Mana.CurLevel >= casterComp.ActualManaCost(abilitydef) && ability.CooldownTicksLeft <= 0 && jobTarget.Thing != null) { float injurySeverity = 0; using (IEnumerator <BodyPartRecord> enumerator = caster.health.hediffSet.GetInjuredParts().GetEnumerator()) { while (enumerator.MoveNext()) { BodyPartRecord rec = enumerator.Current; IEnumerable <Hediff_Injury> arg_BB_0 = caster.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 flag5 = current.CanHealNaturally() && !current.IsPermanent(); if (flag5) { injurySeverity += current.Severity; } } } } if (injurySeverity != 0 && !(caster.health.hediffSet.HasHediff(HediffDef.Named("TM_HediffShield")))) { Job job = ability.GetJob(AbilityContext.AI, jobTarget); caster.jobs.TryTakeOrderedJob(job); success = true; } } }
public override void Init() { Map map = base.SingleMap; if (map != null) { victims = map.mapPawns.FreeColonistsAndPrisoners.ToList(); } else { victims = new List <Pawn>(); List <Map> allMaps = base.AffectedMaps; for (int i = 0; i < allMaps.Count; i++) { victims.AddRange(allMaps[i].mapPawns.AllPawnsSpawned); } } int num = victims.Count; Pawn pawn; for (int i = 0; i < num; i++) { pawn = victims[i]; if (pawn != null) { CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); if (comp != null && comp.IsMagicUser && comp.Mana != null) { if (comp.Mana.CurLevel == 1) { comp.Mana.CurLevel -= .01f; } } } } }
protected override void Impact(Thing hitThing) { Map map = base.Map; GenClamor.DoClamor(this, 2.1f, ClamorDefOf.Impact); //base.Impact(hitThing); string msg; ThingDef def = this.def; Pawn victim = hitThing as Pawn; Thing item = hitThing as Thing; IntVec3 arg_pos_1; IntVec3 arg_pos_2; IntVec3 arg_pos_3; Pawn pawn = this.launcher as Pawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = comp.MagicData.MagicPowerSkill_Teleport.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Teleport_pwr"); MagicPowerSkill ver = comp.MagicData.MagicPowerSkill_Teleport.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Teleport_ver"); pwrVal = pwr.level; verVal = ver.level; CellRect cellRect = CellRect.CenteredOn(base.Position, 1); cellRect.ClipInsideMap(map); IntVec3 centerCell = cellRect.CenterCell; if (pawn.story.traits.HasTrait(TorannMagicDefOf.TM_Wanderer) || (comp.customClass != null && comp.customClass.classMageAbilities.Contains(TorannMagicDefOf.TM_Cantrips))) { int tmpPwrVal = (int)((pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_pwr").level) / 5); int tmpVerVal = (int)((pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_ver").level) / 5); pwrVal = (tmpPwrVal > pwrVal) ? tmpPwrVal : pwrVal; verVal = (tmpVerVal > verVal) ? tmpVerVal : verVal; } if (this.primed != false) { destructTimer = Mathf.RoundToInt((4800 + (pwrVal * 1200) + (pwrVal * 1200)) * comp.arcaneDmg); arg_pos_1 = centerCell; centerCell.x++; arg_pos_2 = centerCell; centerCell.z++; arg_pos_3 = centerCell; centerCell = cellRect.CenterCell; if ((arg_pos_1.IsValid && arg_pos_1.Standable(map)) && (arg_pos_2.IsValid && arg_pos_2.Standable(map)) && (arg_pos_3.IsValid && arg_pos_3.Standable(map))) { AbilityUser.SpawnThings tempPod = new SpawnThings(); IntVec3 shiftPos = centerCell; centerCell.x++; if (pwrVal == 1) { tempPod.def = ThingDef.Named("TM_Teleporter_I"); } else if (pwrVal == 2) { tempPod.def = ThingDef.Named("TM_Teleporter_II"); } else if (pwrVal == 3) { tempPod.def = ThingDef.Named("TM_Teleporter_III"); } else { tempPod.def = ThingDef.Named("TM_Teleporter"); } tempPod.spawnCount = 1; try { this.SingleSpawnLoop(tempPod, shiftPos, map); Building teleporter = shiftPos.GetFirstBuilding(map); int num = teleporter.TryGetComp <CompRefuelable>().GetFuelCountToFullyRefuel(); teleporter.TryGetComp <CompRefuelable>().Refuel(num); } catch { Log.Message("Attempted to create a portal but threw an unknown exception - recovering and ending attempt"); PortalCollapse(shiftPos, map, 3); if (pawn != null) { comp.Mana.CurLevel += comp.ActualManaCost(TorannMagicDefOf.TM_Teleport); } this.age = this.destructTimer; return; } if (verVal == 1) { tempPod.def = ThingDef.Named("TM_TeleportPod_I"); } else if (verVal == 2) { tempPod.def = ThingDef.Named("TM_TeleportPod_II"); } else if (verVal == 3) { tempPod.def = ThingDef.Named("TM_TeleportPod_III"); } else { tempPod.def = ThingDef.Named("TM_TeleportPod"); } tempPod.spawnCount = 1; shiftPos = centerCell; centerCell.z++; try { this.SingleSpawnLoop(tempPod, shiftPos, map); } catch { Log.Message("Attempted to create a portal but threw an unknown exception - recovering and ending attempt"); PortalCollapse(shiftPos, map, 3); if (pawn != null) { comp.Mana.CurLevel += comp.ActualManaCost(TorannMagicDefOf.TM_Teleport); } this.age = this.destructTimer; return; } //tempPod.def = ThingDef.Named("Portfuel"); //tempPod.spawnCount = 45 + (pwr.level * 15); //tempPod.factionDef = null; //shiftPos = centerCell; //for (int i = 0; i < tempPod.spawnCount; i++) //{ // try // { // this.SingleSpawnLoop(tempPod, shiftPos, map); // } // catch // { // Log.Message("Attempted to create a portal but threw an unknown exception - recovering and ending attempt"); // PortalCollapse(shiftPos, map, 3); // if (pawn != null) // { // comp.Mana.CurLevel += comp.ActualManaCost(TorannMagicDefOf.TM_Teleport); // } // this.age = this.destructTimer; // i = tempPod.spawnCount; // return; // } //} msg = "PortalCollapseIn".Translate(((destructTimer - this.age) / 60).ToString() ); Messages.Message(msg, MessageTypeDefOf.NeutralEvent); this.primed = false; } else { Messages.Message("InvalidPortal".Translate(), MessageTypeDefOf.RejectInput); comp.Mana.GainNeed(comp.ActualManaCost(TorannMagicDefOf.TM_Teleport)); this.destructTimer = 0; } } //foreach (SpawnThings current in this.localSpawnThings) //{ // string msg = "spawned thing is " + current.def; // Messages.Message(msg, MessageSound.Standard); //} if (this.age < this.destructTimer) { if (this.age == (destructTimer * 0.5)) { msg = "PortalCollapseIn".Translate( ((destructTimer - this.age) / 60).ToString() ); Messages.Message(msg, MessageTypeDefOf.NeutralEvent); } if (this.age == (destructTimer * 0.75)) { msg = "PortalCollapseIn".Translate( ((destructTimer - this.age) / 60).ToString() ); Messages.Message(msg, MessageTypeDefOf.NeutralEvent); } if (this.age == (destructTimer * 0.95)) { //msg = "Portal collapses in " + ((destructTimer - this.age) / 60) + " seconds!!"; //Messages.Message(msg, MessageTypeDefOf.ThreatBig); msg = "PortalCollapseIn".Translate( ((destructTimer - this.age) / 60).ToString() ); Messages.Message(msg, MessageTypeDefOf.NeutralEvent); } } else { //age expired, destroy teleport this.PortalCollapse(centerCell, map, 3); } Destroy(); }
public override float RandomSelectionWeight(Pawn initiator, Pawn recipient) { CompAbilityUserMagic compInit = initiator.GetComp <CompAbilityUserMagic>(); CompAbilityUserMagic compRec = recipient.GetComp <CompAbilityUserMagic>(); bool flag = !initiator.IsColonist || !recipient.IsColonist; float result; if (flag) { result = 0f; } else { bool flag2 = !compInit.IsMagicUser; if (flag2) { result = 0f; } else { bool flag3 = !compRec.IsMagicUser; if (flag3) { result = 0f; } else { if (initiator.jobs.curDriver.asleep) { result = 0f; } else { if (recipient.jobs.curDriver.asleep) { result = 0f; } else { int levelInit = compInit.MagicUserLevel; int levelRec = compRec.MagicUserLevel; if (levelInit <= levelRec) { result = 0f; } else { bool flag5 = initiator.relations.OpinionOf(recipient) > 0; if (flag5) { result = Rand.Range(0.6f, 0.8f); } else { result = 0f; } } } } } } } return(result); }
public override void Tick() { if (this.age > 10) { if (!initialized) { List <Pawn> mapPawns = this.Map.mapPawns.AllPawnsSpawned; for (int i = 0; i < mapPawns.Count(); i++) { if (!mapPawns[i].DestroyedOrNull() && mapPawns[i].Spawned && !mapPawns[i].Downed && mapPawns[i].RaceProps.Humanlike) { CompAbilityUserMagic comp = mapPawns[i].GetComp <CompAbilityUserMagic>(); if (comp.IsMagicUser && comp.summonedSentinels.Count > 0) { for (int j = 0; j < comp.summonedSentinels.Count(); j++) { if (comp.summonedSentinels[j] == this) { this.sustainerPawn = comp.Pawn; pwrVal = comp.MagicData.MagicPowerSkill_Sentinel.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Sentinel_pwr").level; break; } } } } if (this.sustainerPawn != null) { break; } } for (int m = 0; m < 5; m++) { TM_MoteMaker.ThrowGenericMote(ThingDefOf.Gas_Smoke, base.Position.ToVector3Shifted(), this.Map, Rand.Range(.5f, .8f), Rand.Range(.8f, 1.3f), .05f, Rand.Range(1f, 1.5f), Rand.Range(-20, 20), Rand.Range(1f, 2f), Rand.Range(0, 360), Rand.Range(0, 360)); } initialized = true; } if (Find.TickManager.TicksGame % 180 == 0) { if (this.initialized) { if (this.sustainerPawn == null || this.sustainerPawn.Destroyed || this.sustainerPawn.Dead) { Messages.Message("TM_SentinelDeSpawn".Translate( this.def.label ), MessageTypeDefOf.NegativeEvent, false); this.sustainerPawn = null; this.Destroy(DestroyMode.Vanish); } } if (this.sustainerPawn != null) { if (this.HitPoints < this.MaxHitPoints) { this.HitPoints += 1; if (this.HitPoints > this.MaxHitPoints) { this.HitPoints = this.MaxHitPoints; } } else { this.hostilePawn = SearchForTargets(); if (hostilePawn != null) { SpawnSentinel(); CompAbilityUserMagic comp = this.sustainerPawn.GetComp <CompAbilityUserMagic>(); comp.summonedSentinels.Remove(this); comp.summonedSentinels.Add(this.newPawn as Thing); this.Destroy(DestroyMode.Vanish); } } } } } age++; }
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; } } } }