protected override bool TryCastShot() { Pawn caster = base.CasterPawn; Pawn pawn = this.currentTarget.Thing as Pawn; bool flag = pawn != null && !pawn.Dead; if (flag) { CompAbilityUserMight comp = caster.GetComp <CompAbilityUserMight>(); int verVal = TM_Calc.GetMightSkillLevel(caster, comp.MightData.MightPowerSkill_Custom, "TM_Taunt", "_ver", true); int pwrVal = TM_Calc.GetMightSkillLevel(caster, comp.MightData.MightPowerSkill_Custom, "TM_Taunt", "_pwr", true); radius += (2f * verVal); tauntChance += (pwrVal * .05f); targetsMax += pwrVal; SoundInfo info = SoundInfo.InMap(new TargetInfo(caster.Position, caster.Map, false), MaintenanceType.None); if (this.CasterPawn.gender == Gender.Female) { info.pitchFactor = Rand.Range(1.1f, 1.3f); } else { info.pitchFactor = Rand.Range(.7f, .9f); } TorannMagicDefOf.TM_Roar.PlayOneShot(info); Effecter RageWave = TorannMagicDefOf.TM_RageWaveED.Spawn(); RageWave.Trigger(new TargetInfo(caster.Position, caster.Map, false), new TargetInfo(caster.Position, caster.Map, false)); RageWave.Cleanup(); SearchAndTaunt(); } return(true); }
public void SingleSpawnLoop(SpawnThings spawnables, Pawn pawn, IntVec3 position, Map map) { bool flag = spawnables.def != null; if (flag) { Faction faction = pawn.Faction; bool flag2 = spawnables.def.race != null; if (flag2) { Log.Error("Trying to spawn a pawn instead of a building."); } else { ThingDef def = spawnables.def; ThingDef stuff = null; bool madeFromStuff = def.MadeFromStuff; if (madeFromStuff) { stuff = ThingDefOf.WoodLog; } Thing thing = ThingMaker.MakeThing(def, stuff); thing.SetFaction(faction, null); CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); GenSpawn.Spawn(thing, position, map, Rot4.North, false); comp.combatItems.Add(thing); } } }
protected override bool TryCastShot() { Pawn caster = base.CasterPawn; bool flag = caster != null && !caster.Dead; if (flag) { CompAbilityUserMight comp = caster.TryGetComp <CompAbilityUserMight>(); verVal = TM_Calc.GetMightSkillLevel(caster, comp.MightData.MightPowerSkill_ShadowSlayer, "TM_ShadowSlayer", "_ver", true); pwrVal = TM_Calc.GetMightSkillLevel(caster, comp.MightData.MightPowerSkill_ShadowSlayer, "TM_ShadowSlayer", "_pwr", true); float sev = 40 + (comp.mightPwr * (3 * verVal)); HealthUtility.AdjustSeverity(caster, TorannMagicDefOf.TM_ShadowSlayerCloakHD, sev); HediffComp_Disappears hdComp = caster.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ShadowSlayerCloakHD).TryGetComp <HediffComp_Disappears>(); if (hdComp != null) { hdComp.ticksToDisappear = Mathf.RoundToInt(60 * sev); } for (int i = 0; i < 3; i++) { Vector3 rndPos = caster.DrawPos; rndPos.x += Rand.Range(-.5f, .5f); rndPos.z += Rand.Range(-.5f, .5f); FleckMaker.ThrowSmoke(rndPos, caster.Map, Rand.Range(.6f, 1.2f)); } } return(true); }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; if (!this.initialized) { caster = this.launcher as Pawn; this.strikePos = base.Position; CompAbilityUserMight comp = caster.GetComp <CompAbilityUserMight>(); verVal = TM_Calc.GetMightSkillLevel(caster, comp.MightData.MightPowerSkill_RifleSpec, "TM_RifleSpec", "_ver", true); this.radius = this.def.projectile.explosionRadius; this.initialized = true; } GenExplosion.DoExplosion(this.strikePos, map, this.def.projectile.explosionRadius, this.def.projectile.damageDef, this.launcher as Pawn, Mathf.RoundToInt((this.def.projectile.GetDamageAmount(1f) + (1.5f * verVal)) * mightPwr), 3, this.def.projectile.soundExplode, def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0f, true); strikePos.x += Mathf.RoundToInt(Rand.Range(-radius, radius)); strikePos.z += Mathf.RoundToInt(Rand.Range(-radius, radius)); GenExplosion.DoExplosion(this.strikePos, map, this.def.projectile.explosionRadius / 2f, this.def.projectile.damageDef, this.launcher as Pawn, Mathf.RoundToInt(((this.def.projectile.GetDamageAmount(1f) / 2f) + (1f * verVal)) * mightPwr), 0, this.def.projectile.soundExplode, def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0f, true); strikePos = base.Position; strikePos.x += Mathf.RoundToInt(Rand.Range(-radius, radius)); strikePos.z += Mathf.RoundToInt(Rand.Range(-radius, radius)); GenExplosion.DoExplosion(this.strikePos, map, this.def.projectile.explosionRadius / 2f, this.def.projectile.damageDef, this.launcher as Pawn, Mathf.RoundToInt(((this.def.projectile.GetDamageAmount(1f) / 2f) + (1f * verVal)) * mightPwr), 0, this.def.projectile.soundExplode, def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0f, true); }
public override void Tick() { base.Tick(); if (Find.TickManager.TicksGame % 2 == 0 && daggerCount > 0 && this.launcher != null && this.launcher is Pawn) { Pawn caster = this.launcher as Pawn; CompAbilityUserMight comp = caster.TryGetComp <CompAbilityUserMight>(); if (comp != null) { ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if ((comp.MightData.MightPowerSkill_FieldTraining.FirstOrDefault((MightPowerSkill x) => x.label == "TM_FieldTraining_pwr").level >= 12) || (!caster.IsColonist && settingsRef.AIHardMode)) { Projectile_Spinning newProjectile = (Projectile_Spinning)ThingMaker.MakeThing(this.def, null); newProjectile.daggerCount = 0; TM_CopyAndLaunchProjectile.CopyAndLaunchProjectile(newProjectile, caster, this.intendedTarget, this.intendedTarget, ProjectileHitFlags.All, null); this.daggerCount--; } else { daggerCount = 0; } } else { daggerCount = 0; } } }
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_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 static int GetWeaponDmg(Pawn caster) { int dmgNum = 2; CompAbilityUserMight comp = caster.GetComp <CompAbilityUserMight>(); MightPowerSkill pwr = comp.MightData.MightPowerSkill_Whirlwind.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Whirlwind_pwr"); MightPowerSkill str = comp.MightData.MightPowerSkill_global_strength.FirstOrDefault((MightPowerSkill x) => x.label == "TM_global_strength_pwr"); float weaponDPS = 0; float dmgMultiplier = 1; float pawnDPS = 0; float skillMultiplier = 1; ThingWithComps weaponComp; pwrVal = pwr.level; if (caster.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { MightPowerSkill mpwr = comp.MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); verVal = mpwr.level; } if (caster.equipment.Primary != null && !caster.equipment.Primary.def.IsRangedWeapon) { weaponComp = caster.equipment.Primary; weaponDPS = weaponComp.GetStatValue(StatDefOf.MeleeWeapon_AverageDPS, false) * .7f; dmgMultiplier = weaponComp.GetStatValue(StatDefOf.MeleeWeapon_DamageMultiplier, false) * comp.mightPwr; pawnDPS = caster.GetStatValue(StatDefOf.MeleeDPS, false); skillMultiplier = (.8f + (.08f * pwrVal)); dmgNum = Mathf.RoundToInt(skillMultiplier * dmgMultiplier * (pawnDPS + weaponDPS)); } else { dmgNum = 2; } return(Mathf.Max(2, dmgNum)); }
//bool validTarg; //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() { Map map = base.CasterPawn.Map; Pawn pawn = base.CasterPawn; CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); MightPowerSkill pwr = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_BladeFocus.FirstOrDefault((MightPowerSkill x) => x.label == "TM_BladeFocus_pwr"); List <Trait> traits = this.CasterPawn.story.traits.allTraits; for (int i = 0; i < traits.Count; i++) { if (traits[i].def.defName == "Bladedancer") { if (traits[i].Degree < pwr.level) { traits.Remove(traits[i]); this.CasterPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Bladedancer"), pwr.level, false)); FleckMaker.ThrowHeatGlow(base.CasterPawn.Position, map, 2); } } } this.burstShotsLeft = 0; return(false); }
private void UpdateBond() { CompAbilityUserMight comp = this.bonderPawn.GetComp <CompAbilityUserMight>(); MightPowerSkill ver = comp.MightData.MightPowerSkill_AnimalFriend.FirstOrDefault((MightPowerSkill x) => x.label == "TM_AnimalFriend_ver"); this.parent.Severity = .5f + ver.level; }
protected override Job TryGiveJob(Pawn pawn) { if (pawn != null && pawn.Map != null && pawn.health != null && pawn.health.hediffSet != null && pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_ChiHD) && !pawn.Drafted) { if (pawn.InBed() || HealthAIUtility.ShouldSeekMedicalRest(pawn) || !(pawn.GetPosture() == PawnPosture.Standing)) { return(null); } Need_Joy curJoy = pawn.needs.joy; if (curJoy == null) { return(null); } if (curJoy.CurLevel >= .8f) { return(null); } CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); if (comp != null) { MightPower mightPower = comp.MightData.MightPowersM.FirstOrDefault <MightPower>((MightPower x) => x.abilityDef == TorannMagicDefOf.TM_Meditate); if (mightPower == null) { return(null); } if (!mightPower.AutoCast) { return(null); } Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ChiHD); PawnAbility ability = pawn.GetComp <CompAbilityUserMight>().AbilityData.Powers.FirstOrDefault((PawnAbility x) => x.Def == TorannMagicDefOf.TM_Meditate); if (ability.CooldownTicksLeft > 0 || hediff.Severity >= 70) { return(null); } Building_Bed building_Bed = pawn.ownership.OwnedBed; if (building_Bed != null) { if (building_Bed.GetRoom() != null && !building_Bed.GetRoom().PsychologicallyOutdoors) { List <IntVec3> roomCells = building_Bed.GetRoom().Cells.ToList(); for (int i = 0; i < roomCells.Count; i++) { if (roomCells[i].IsValid && roomCells[i].Walkable(pawn.Map) && roomCells[i].GetFirstBuilding(pawn.Map) == null) { return(new Job(TorannMagicDefOf.JobDriver_TM_Meditate, roomCells[i])); } } } } return(new Job(TorannMagicDefOf.JobDriver_TM_Meditate, pawn.Position)); } } return(null); }
protected override void Impact(Thing hitThing) { if (!this.initialized && !hitThing.DestroyedOrNull()) { this.initialized = true; this.caster = this.launcher as Pawn; CompAbilityUserMight comp = caster.GetComp <CompAbilityUserMight>(); verVal = TM_Calc.GetMightSkillLevel(caster, comp.MightData.MightPowerSkill_ShadowStrike, "TM_ShadowStrike", "_ver", true); this.startPos = caster.Position; this.age = 0; this.weaponDamage = GetWeaponDmg(caster); this.critChance = comp.weaponCritChance; GenClamor.DoClamor(caster, 2f, ClamorDefOf.Ability); if (DoMove(hitThing)) { DoStrike(hitThing); } } if (age >= 0) { age++; } Destroy(DestroyMode.Vanish); }
private void Initialize() { bool spawned = base.Pawn.Spawned; if (bonderPawn == null) { if (spawned) { MoteMaker.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; } } } } } }
protected override bool TryCastShot() { Map map = base.CasterPawn.Map; Pawn pawn = base.CasterPawn; CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); MightPowerSkill pwr = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_BladeArt.FirstOrDefault((MightPowerSkill x) => x.label == "TM_BladeArt_pwr"); if (pawn != null && !pawn.Dead) { if (comp.IsMightUser) { HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_BladeArtHD, -5f); HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_BladeArtHD, (.5f) + pwr.level); ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (!pawn.IsColonist && settingsRef.AIHardMode) { HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_BladeArtHD, 4); } MoteMaker.ThrowHeatGlow(pawn.Position, map, 1.5f); MoteMaker.ThrowAirPuffUp(pawn.Position.ToVector3(), map); } else { Log.Message("Pawn not detected as might user."); } } this.burstShotsLeft = 0; return(false); }
public static int GetWeaponDmg(Pawn pawn) { CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); MightPowerSkill pwr = comp.MightData.MightPowerSkill_SeismicSlash.FirstOrDefault((MightPowerSkill x) => x.label == "TM_SeismicSlash_pwr"); MightPowerSkill ver = comp.MightData.MightPowerSkill_SeismicSlash.FirstOrDefault((MightPowerSkill x) => x.label == "TM_SeismicSlash_ver"); MightPowerSkill str = comp.MightData.MightPowerSkill_global_strength.FirstOrDefault((MightPowerSkill x) => x.label == "TM_global_strength_pwr"); verVal = ver.level; 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; ThingWithComps weaponComp = pawn.equipment.Primary; float weaponDPS = weaponComp.GetStatValue(StatDefOf.MeleeWeapon_AverageDPS, false) * .7f; float dmgMultiplier = weaponComp.GetStatValue(StatDefOf.MeleeWeapon_DamageMultiplier, false); float pawnDPS = pawn.GetStatValue(StatDefOf.MeleeDPS, false); float skillMultiplier = (.7f + (.07f * pwrVal)); return(dmgNum = Mathf.RoundToInt(skillMultiplier * dmgMultiplier * (pawnDPS + weaponDPS) * comp.mightPwr)); }
private void AssignXP() { CompAbilityUserMight comp = this.pawn.GetComp <CompAbilityUserMight>(); if (comp != null) { try { int xpBase = Rand.Range(50, 75); int xpGain = Mathf.RoundToInt(xpBase * comp.xpGain); MoteMaker.ThrowText(pawn.DrawPos, pawn.MapHeld, "XP +" + xpGain, -1f); comp.MightUserXP += xpGain; if (this.pawn.needs.joy != null) { this.pawn.needs.joy.GainJoy(.4f, TorannMagicDefOf.Social); } if (this.pawn.skills != null) { this.pawn.skills.Learn(SkillDefOf.Social, Rand.Range(200f, 500f)); } } catch (NullReferenceException ex) { //failed } } }
public override void CompPostTick(ref float severityAdjustment) { base.CompPostTick(ref severityAdjustment); bool flag = base.Pawn != null; if (flag) { if (!initialized) { initialized = true; this.Initialize(); } if (Find.TickManager.TicksGame > this.nextApplyTick) { this.nextApplyTick = Find.TickManager.TicksGame + (Rand.Range(1000, 1200) - (50 * verVal)); if (base.Pawn.Map != null) { List <Pawn> mapPawns = this.Pawn.Map.mapPawns.AllPawnsSpawned; for (int i = 0; i < mapPawns.Count; i++) { if (mapPawns[i].RaceProps.Humanlike && mapPawns[i].Faction != null && mapPawns[i].Faction == base.Pawn.Faction && mapPawns[i] != this.Pawn) { if (!TM_Calc.IsUndeadNotVamp(mapPawns[i])) { if (base.Pawn.Position.InHorDistOf(mapPawns[i].Position, radius)) { ApplyHediff(mapPawns[i]); } } } } } else //map null { if (this.Pawn.ParentHolder.ToString().Contains("Caravan")) { foreach (Pawn current in base.Pawn.holdingOwner) { if (current != null) { if (current.RaceProps.Humanlike && current.Faction != null && current.Faction == this.Pawn.Faction && current != this.Pawn) { ApplyHediff(current); } } } } } CompAbilityUserMight comp = this.Pawn.GetComp <CompAbilityUserMight>(); comp.MightUserXP += Rand.Range(2, 5); } if (Find.TickManager.TicksGame % 1200 == 0) { DetermineHediff(); } } }
private void DeterminePsionicHD() { CompAbilityUserMight comp = this.Pawn.GetComp <CompAbilityUserMight>(); this.PwrVal = this.Pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_PsionicAugmentation.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicAugmentation_pwr").level; this.EffVal = this.Pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_PsionicAugmentation.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicAugmentation_eff").level; this.VerVal = this.Pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_PsionicAugmentation.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicAugmentation_ver").level; }
public static void DoAction_ApplySplashDamage(DamageInfo dinfo, Pawn caster, Pawn target, Map map, int ver = 0) { bool multiplePawns = false; bool flag = !dinfo.InstantPermanentInjury; CompAbilityUserMight comp = caster.GetComp <CompAbilityUserMight>(); MightPowerSkill eff = comp.MightData.MightPowerSkill_DragonStrike.FirstOrDefault((MightPowerSkill x) => x.label == "TM_DragonStrike_eff"); MightPowerSkill globalSkill = comp.MightData.MightPowerSkill_global_seff.FirstOrDefault((MightPowerSkill x) => x.label == "TM_global_seff_pwr"); float actualStaminaCost = .1f * (1 - (.1f * eff.level) * (1 - (.03f * globalSkill.level))); if (flag && comp != null && comp.Stamina.CurLevel >= actualStaminaCost) { bool flag2 = dinfo.Instigator != null; if (flag2) { bool flag3 = caster != null && caster.PositionHeld != default(IntVec3) && !caster.Downed; if (flag3) { System.Random random = new System.Random(); int rnd = GenMath.RoundRandom(random.Next(0, 100)); if (rnd < (ver * 15)) { target.TakeDamage(dinfo); MoteMaker.ThrowMicroSparks(target.Position.ToVector3(), map); } target.TakeDamage(dinfo); MoteMaker.ThrowMicroSparks(target.Position.ToVector3(), map); for (int i = 0; i < 8; i++) { IntVec3 intVec = target.PositionHeld + GenAdj.AdjacentCells[i]; Pawn cleaveVictim = new Pawn(); cleaveVictim = intVec.GetFirstPawn(map); if (cleaveVictim != null && cleaveVictim.Faction != caster.Faction) { cleaveVictim.TakeDamage(dinfo); MoteMaker.ThrowMicroSparks(cleaveVictim.Position.ToVector3(), map); multiplePawns = true; rnd = GenMath.RoundRandom(random.Next(0, 100)); if (rnd < (ver * 15)) { cleaveVictim.TakeDamage(dinfo); MoteMaker.ThrowMicroSparks(cleaveVictim.Position.ToVector3(), map); } } } } } } if (multiplePawns) { Vector3 angle = TM_Calc.GetVector(caster.DrawPos, target.DrawPos); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_DragonStrike, target.DrawPos, caster.Map, 1.1f, .1f, .01f, .1f, 650, 0, 0, (Quaternion.AngleAxis(-25, Vector3.up) * angle).ToAngleFlat()); if (comp != null) { comp.Stamina.CurLevel -= actualStaminaCost; comp.MightUserXP += (int)(.1f * 180); } } }
protected override IEnumerable <Toil> MakeNewToils() { Toil gotoSpot = new Toil() { initAction = () => { pawn.pather.StartPath(TargetLocA, PathEndMode.Touch); }, defaultCompleteMode = ToilCompleteMode.PatherArrival }; yield return(gotoSpot); Toil placeTrap = new Toil() { initAction = () => { SpawnThings tempPod = new SpawnThings(); tempPod.def = ThingDef.Named("TM_PoisonTrap"); try { CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); MightPowerSkill ver = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_PoisonTrap.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PoisonTrap_ver"); for (int i = 0; i < comp.combatItems.Count; i++) { if (comp.combatItems[i].Destroyed) { comp.combatItems.Remove(comp.combatItems[i]); i--; } } if (comp.combatItems.Count > ver.level + 1) { Messages.Message("TM_TooManyTraps".Translate(new object[] { pawn.LabelShort, ver.level + 2 }), MessageTypeDefOf.NeutralEvent); Thing tempThing = comp.combatItems[0]; comp.combatItems.Remove(tempThing); if (tempThing != null && !tempThing.Destroyed) { tempThing.Destroy(); } } this.SingleSpawnLoop(tempPod, pawn, TargetLocA, pawn.Map); } catch { Log.Message("Attempted to place a poison trap but threw an unknown exception - recovering and ending attempt"); return; } }, defaultCompleteMode = ToilCompleteMode.Instant }; yield return(placeTrap); }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; Pawn pawn = this.launcher as Pawn; Pawn victim = hitThing as Pawn; try { CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); //MightPowerSkill ver = pawn.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_DisablingShot.FirstOrDefault((MightPowerSkill x) => x.label == "TM_DisablingShot_ver"); verVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_DisablingShot, "TM_DisablingShot", "_ver", true); MightPowerSkill str = comp.MightData.MightPowerSkill_global_strength.FirstOrDefault((MightPowerSkill x) => x.label == "TM_global_strength_pwr"); ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); //verVal = ver.level; //if (pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) //{ // MightPowerSkill mver = pawn.GetComp<CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); // verVal = mver.level; //} //if (settingsRef.AICasting && !pawn.IsColonist) //{ // verVal = 3; //} if (victim != null && !victim.Dead && Rand.Chance(this.launcher.GetStatValue(StatDefOf.ShootingAccuracyPawn, true))) { int dmg = (this.def.projectile.GetDamageAmount(1, null)); if (victim.RaceProps.IsFlesh) { System.Random rnd = new System.Random(); if (verVal > 0 && victim.needs.food != null) { int randomTranqSev = GenMath.RoundRandom(rnd.Next((int)(verVal * .5f * str.level), (int)((verVal + .5f * str.level) * 3))); LegShot(victim, randomTranqSev, TMDamageDefOf.DamageDefOf.TM_Tranquilizer); } else { LegShot(victim, dmg, TMDamageDefOf.DamageDefOf.TM_DisablingShot); } } else { damageEntities(victim, null, dmg, this.def.projectile.damageDef); } } else { Log.Message("No valid target for Disabling Shot"); } } catch (NullReferenceException ex) { } }
public void Initialize(Map map) { pawn = this.launcher as Pawn; CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); pwr = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_ArrowStorm.FirstOrDefault((MightPowerSkill x) => x.label == "TM_ArrowStorm_pwr"); ver = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_ArrowStorm.FirstOrDefault((MightPowerSkill x) => x.label == "TM_ArrowStorm_ver"); str = comp.MightData.MightPowerSkill_global_strength.FirstOrDefault((MightPowerSkill x) => x.label == "TM_global_strength_pwr"); initialized = true; }
private void DetermineHediff() { CompAbilityUserMight comp = this.Pawn.GetComp <CompAbilityUserMight>(); if (parent.def == TorannMagicDefOf.TM_ProvisionerAuraHD && comp != null) { pwrVal = comp.MightData.MightPowerSkill_ProvisionerAura.FirstOrDefault((MightPowerSkill x) => x.label == "TM_ProvisionerAura_pwr").level; verVal = comp.MightData.MightPowerSkill_ProvisionerAura.FirstOrDefault((MightPowerSkill x) => x.label == "TM_ProvisionerAura_ver").level; } this.radius = 15f + (2f * verVal); }
protected override bool TryCastShot() { Pawn caster = base.CasterPawn; Pawn pawn = this.currentTarget.Thing as Pawn; bool flag = caster != null && !caster.Dead; if (flag) { TMAbilityDef ability = (TMAbilityDef)this.Ability.Def; if (ability != null && ability.abilityHediff != null) { HediffDef hdDef = ability.abilityHediff; if (caster.health.hediffSet.HasHediff(hdDef)) { Hediff hd = caster.health.hediffSet.GetFirstHediffOfDef(hdDef); caster.health.RemoveHediff(hd); } else { HealthUtility.AdjustSeverity(caster, hdDef, hdDef.initialSeverity); if (caster.Map != null) { MoteMaker.ThrowLightningGlow(caster.DrawPos, caster.Map, 1f); MoteMaker.ThrowDustPuff(caster.Position, caster.Map, 1f); } } CompAbilityUserMagic magicComp = caster.TryGetComp <CompAbilityUserMagic>(); if (magicComp != null && magicComp.MagicData != null) { MagicPower mp = magicComp.MagicData.ReturnMatchingMagicPower(ability); if (mp != null) { mp.autocast = caster.health.hediffSet.HasHediff(hdDef); } } CompAbilityUserMight mightComp = caster.TryGetComp <CompAbilityUserMight>(); if (mightComp != null && mightComp.MightData != null) { MightPower mp = mightComp.MightData.ReturnMatchingMightPower(ability); if (mp != null) { mp.autocast = caster.health.hediffSet.HasHediff(hdDef); } } } else { Log.Warning("Unrecognized ability or no hediff assigned for this ability."); } } return(true); }
public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks) { CompAbilityUserMight compInit = initiator.GetComp <CompAbilityUserMight>(); CompAbilityUserMight compRec = recipient.GetComp <CompAbilityUserMight>(); base.Interacted(initiator, recipient, extraSentencePacks); int num = compInit.MightUserLevel - compRec.MightUserLevel; int num2 = (int)(20f + Rand.Range(3f, 10f) * (float)num); compRec.MightUserXP += num2; MoteMaker.ThrowText(recipient.DrawPos, recipient.MapHeld, "XP +" + num2, -1f); }
public override bool InspirationCanOccur(Pawn pawn) { bool baseInspiration = base.InspirationCanOccur(pawn); bool mightInspiration = false; CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); if (comp.IsMightUser) { mightInspiration = true; } return(baseInspiration && mightInspiration); }
public static int GetWeaponDmg(Pawn pawn) { CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); MightPowerSkill str = comp.MightData.MightPowerSkill_global_strength.FirstOrDefault((MightPowerSkill x) => x.label == "TM_global_strength_pwr"); ThingWithComps weaponComp = pawn.equipment.Primary; float weaponDPS = weaponComp.GetStatValue(StatDefOf.MeleeWeapon_AverageDPS, false) * .7f; float dmgMultiplier = weaponComp.GetStatValue(StatDefOf.MeleeWeapon_DamageMultiplier, false); float pawnDPS = pawn.GetStatValue(StatDefOf.MeleeDPS, false); float skillMultiplier = (.6f) * comp.mightPwr; return(Mathf.RoundToInt(skillMultiplier * dmgMultiplier * (pawnDPS + weaponDPS))); }
public override void DoEffect(Pawn user) { CompAbilityUserMagic compMagic = user.GetComp <CompAbilityUserMagic>(); CompAbilityUserMight compMight = user.GetComp <CompAbilityUserMight>(); int essenceXP = 0; if (compMagic != null && compMagic.IsMagicUser && compMagic.MagicUserXP != 0 && compMagic.MagicData != null) { essenceXP += Rand.Range(300, 500); for (int i = 0; i < compMagic.MagicData.MagicPowersStandalone.Count; i++) { MagicPower mp = compMagic.MagicData.MagicPowersStandalone[i]; if (mp.learned) { essenceXP += Rand.Range(80, 120); } } essenceXP += Mathf.RoundToInt(compMagic.MagicUserXP / Rand.Range(1.7f, 2.3f)); Thing mes = ThingMaker.MakeThing(TorannMagicDefOf.TM_MagicArtifact_MagicEssence, null); CompEnchantedItem itemComp = mes.TryGetComp <CompEnchantedItem>(); if (itemComp != null && itemComp.HasEnchantment) { itemComp.magicEssence = essenceXP; } GenPlace.TryPlaceThing(mes, this.parent.Position, this.parent.Map, ThingPlaceMode.Near); essenceXP = 0; } if (compMight != null && compMight.IsMightUser && compMight.MightUserXP != 0 && compMight.MightData != null) { essenceXP += Rand.Range(300, 500); for (int i = 0; i < compMight.MightData.MightPowersStandalone.Count; i++) { MightPower mp = compMight.MightData.MightPowersStandalone[i]; if (mp.learned) { essenceXP += Rand.Range(80, 120); } } essenceXP += Mathf.RoundToInt(compMight.MightUserXP / Rand.Range(1.7f, 2.3f)); Thing mes = ThingMaker.MakeThing(TorannMagicDefOf.TM_MagicArtifact_MightEssence, null); CompEnchantedItem itemComp = mes.TryGetComp <CompEnchantedItem>(); if (itemComp != null && itemComp.HasEnchantment) { itemComp.mightEssence = essenceXP; } GenPlace.TryPlaceThing(mes, this.parent.Position, this.parent.Map, ThingPlaceMode.Near); essenceXP = 0; } ModOptions.TM_DebugTools.RemoveClass(user); TM_Action.TransmutateEffects(user.Position, user); TM_Action.TransmutateEffects(parent.Position, user); }
public override void DoEffect(Pawn user) { CompAbilityUserMagic compMagic = user.GetComp <CompAbilityUserMagic>(); CompAbilityUserMight compMight = user.GetComp <CompAbilityUserMight>(); if (this.parent.def == TorannMagicDefOf.TM_MagicArtifact_MightEssence && compMight != null && compMight.IsMightUser) { CompEnchantedItem compItem = this.parent.TryGetComp <CompEnchantedItem>(); if (compItem != null && compItem.HasEnchantment) { if (compItem.mightEssence != 0) { compMight.MightUserXP += compItem.mightEssence; } else { Log.Message("might essence granted 0 experience"); } FleckMaker.ThrowSmoke(this.parent.DrawPos, this.parent.Map, Rand.Range(.5f, .8f)); FleckMaker.ThrowHeatGlow(this.parent.Position, this.parent.Map, .8f); TM_Action.TransmutateEffects(user.Position, user); TargetInfo ti = new TargetInfo(this.parent.Position, this.parent.Map, false); TM_MoteMaker.MakeOverlay(ti, TorannMagicDefOf.TM_Mote_PsycastAreaEffect, user.Map, Vector3.zero, .1f, 0f, .05f, .4f, .2f, 1f); parent.SplitOff(1).Destroy(); } } else if (this.parent.def == TorannMagicDefOf.TM_MagicArtifact_MagicEssence && compMagic != null && compMagic.IsMagicUser) { CompEnchantedItem compItem = this.parent.TryGetComp <CompEnchantedItem>(); if (compItem != null && compItem.HasEnchantment) { if (compItem.magicEssence != 0) { compMagic.MagicUserXP += compItem.magicEssence; } else { Log.Message("magic essence granted 0 experience"); } FleckMaker.ThrowSmoke(this.parent.DrawPos, this.parent.Map, Rand.Range(.5f, .8f)); FleckMaker.ThrowHeatGlow(this.parent.Position, this.parent.Map, .8f); TM_Action.TransmutateEffects(user.Position, user); TargetInfo ti = new TargetInfo(this.parent.Position, this.parent.Map, false); TM_MoteMaker.MakeOverlay(ti, TorannMagicDefOf.TM_Mote_PsycastAreaEffect, user.Map, Vector3.zero, .1f, 0f, .05f, .4f, .2f, 1f); parent.SplitOff(1).Destroy(); } } else { Messages.Message("TM_InvalidAction".Translate(user.LabelShort, this.parent.def.label), MessageTypeDefOf.RejectInput); } }
public static int GetWeaponDmg(Pawn pawn, ThingDef projectileDef) { CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); MightPowerSkill pwr = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Headshot.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Headshot_pwr"); MightPowerSkill str = comp.MightData.MightPowerSkill_global_strength.FirstOrDefault((MightPowerSkill x) => x.label == "TM_global_strength_pwr"); pwrVal = pwr.level; if (pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { MightPowerSkill mpwr = comp.MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); pwrVal = mpwr.level; } ThingWithComps arg_3C_0; int value = 0; if (pawn == null) { arg_3C_0 = null; } else { Pawn_EquipmentTracker expr_eq = pawn.equipment; arg_3C_0 = ((expr_eq != null) ? expr_eq.Primary : null); } ThingWithComps thing; bool flag31 = (thing = arg_3C_0) != null; if (flag31) { value = Mathf.RoundToInt(thing.GetStatValue(StatDefOf.MarketValue)); } int dmg; if (value > 1000) { value -= 1000; dmg = (projectileDef.projectile.GetDamageAmount(1, null)) + (int)((20 + (value / 120)) * (1 + (.1f * pwrVal))); } else { dmg = (projectileDef.projectile.GetDamageAmount(1, null)) + (int)((value / 50) * (1 + (.1f * pwrVal))); } ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (!pawn.IsColonist && settingsRef.AIHardMode) { dmg += 8; } return(Mathf.RoundToInt(dmg * comp.mightPwr)); }
private void Initialize() { bool spawned = base.Pawn.Spawned; CompAbilityUserMight comp = this.Pawn.GetComp <CompAbilityUserMight>(); if (spawned && comp != null && comp.IsMightUser) { DetermineHediff(); } else { this.Pawn.health.RemoveHediff(this.parent); } }