protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(TargetIndex.A); Toil gotoThing = new Toil(); gotoThing.initAction = delegate { this.pawn.pather.StartPath(this.TargetThingA, PathEndMode.Touch); }; gotoThing.defaultCompleteMode = ToilCompleteMode.PatherArrival; gotoThing.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(gotoThing); Toil enchanting = new Toil();//actions performed to enchant an item enchanting.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); enchanting.FailOnDestroyedOrNull(TargetIndex.A); enchanting.initAction = delegate { actor = enchanting.actor; thing = TargetThingA; thingLoc = thing.Position; if (!(thing.def.IsMeleeWeapon || thing.def.IsRangedWeapon || thing.def.IsApparel)) { actor.jobs.EndCurrentJob(JobCondition.Incompletable, true); Log.Message("Failed to initialize enchanting - invalid item type."); } else if (thing.def.defName.Contains("TM_Artifact")) { Messages.Message("TM_CannotEnchantArtifact".Translate( actor.LabelShort, thing.LabelShort ), MessageTypeDefOf.RejectInput); actor.jobs.EndCurrentJob(JobCondition.Incompletable, true); } }; enchanting.tickAction = delegate { if (thing.Position != thingLoc || thing.Destroyed) { actor.jobs.EndCurrentJob(JobCondition.Incompletable, true); Log.Message("Failed to complete enchanting - item being enchanted not at enchanting location or destroyed"); } if (Find.TickManager.TicksGame % 5 == 0) { TM_MoteMaker.ThrowEnchantingMote(TargetLocA.ToVector3Shifted(), actor.Map, .6f); } }; enchanting.WithProgressBar(TargetIndex.A, delegate { if (thing == null) { return(1f); } return(1f - (float)enchanting.actor.jobs.curDriver.ticksLeftThisToil / 240); }, false, 0f); enchanting.defaultCompleteMode = ToilCompleteMode.Delay; enchanting.defaultDuration = 240; enchanting.AddFinishAction(delegate { CompEnchantedItem enchantment = thing.TryGetComp <CompEnchantedItem>(); CompEnchant enchantingItem = actor.TryGetComp <CompEnchant>(); CompAbilityUserMagic pawnComp = actor.TryGetComp <CompAbilityUserMagic>(); if (enchantment != null && enchantingItem != null && enchanting.actor.jobs.curDriver.ticksLeftThisToil < 1) { if (EnchantItem(enchantingItem.enchantingContainer[0], enchantment)) { enchantingItem.enchantingContainer[0].SplitOff(1).Destroy(DestroyMode.Vanish); pawnComp.Mana.CurLevel -= .5f; int num = Rand.Range(130, 180); pawnComp.MagicUserXP += num; MoteMaker.ThrowText(actor.DrawPos, actor.Map, "XP +" + num, -1f); MoteMaker.ThrowText(TargetLocA.ToVector3Shifted(), actor.Map, "TM_Enchanted".Translate(), -1); SoundStarter.PlayOneShotOnCamera(TorannMagicDefOf.ItemEnchanted, null); } else { Messages.Message("TM_NothingEnchanted".Translate(actor.LabelShort, thing.LabelShort, enchantingItem.enchantingContainer[0].LabelShort), MessageTypeDefOf.RejectInput); } //DestroyEnchantingStone(enchantingItem.innerContainer[0]); } else { Log.Message("Detected null enchanting comp."); } }); yield return(enchanting); }
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); } } } } } }
protected override bool TryCastShot() { bool result = false; if (this.currentTarget != null && base.CasterPawn != null) { if (this.currentTarget.Thing != null && this.currentTarget.Thing is Pawn) { Pawn victim = this.currentTarget.Thing as Pawn; if (victim.Faction != null && victim.RaceProps.Humanlike && victim.story != null && victim.story.traits != null && !TM_Calc.IsUndeadNotVamp(victim)) { int traitsApplied = 0; List <Apparel> apparel = this.CasterPawn.apparel.WornApparel; List <Trait> orbTraits = new List <Trait>(); orbTraits.Clear(); CompEnchantedItem itemComp = null; if (apparel != null) { for (int i = 0; i < apparel.Count; i++) { Apparel item = apparel[i]; if (item != null && item.def == TorannMagicDefOf.TM_Artifact_OrbOfSouls_Full) { itemComp = item.GetComp <CompEnchantedItem>(); if (itemComp != null) { orbTraits = itemComp.SoulOrbTraits; } } } } if (orbTraits.Count > 0) { for (int i = 0; i < orbTraits.Count; i++) { bool conflicting = false; for (int j = 0; j < victim.story.traits.allTraits.Count; j++) { if (victim.story.traits.allTraits[j].def.ConflictsWith(orbTraits[i])) { conflicting = true; } } if (!conflicting) { AddTrait(victim, orbTraits[i]); traitsApplied++; } } if (traitsApplied > 0) { Effects(victim.Position); result = true; } else { Messages.Message("TM_NoTraitsApplied".Translate(victim), MessageTypeDefOf.RejectInput); result = false; } } else { Log.Message("no traits found in orb - was this dev-mode generated?"); result = true; //destroy anyways } } else { //invalid target Messages.Message("TM_InvalidTarget".Translate( this.CasterPawn.LabelShort, this.verbProps.label ), MessageTypeDefOf.RejectInput); } } else { //invalid target Messages.Message("TM_InvalidTarget".Translate( this.CasterPawn.LabelShort, this.verbProps.label ), MessageTypeDefOf.RejectInput); } } else { Log.Warning("failed to TryCastShot"); } this.burstShotsLeft = 0; //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60; PostCastShot(result); return(false); }
private bool EnchantItem(Thing gemstone, CompEnchantedItem enchantment) { enchantment.HasEnchantment = true; int enchantmentsApplied = 0; switch (gemstone.def.defName) { case "TM_EStone_wonder_minor": if (enchantment.maxMP < .05f) { enchantment.maxMP = .05f; enchantment.maxMPTier = EnchantmentTier.Minor; enchantmentsApplied++; } if (enchantment.mpRegenRate < .05f) { enchantment.mpRegenRate = .05f; enchantment.mpRegenRateTier = EnchantmentTier.Minor; enchantmentsApplied++; } if (enchantment.mpCost > -.03f) { enchantment.mpCost = -.03f; enchantment.mpCostTier = EnchantmentTier.Minor; enchantmentsApplied++; } if (enchantment.coolDown > -.03f) { enchantment.coolDown = -.03f; enchantment.coolDownTier = EnchantmentTier.Minor; enchantmentsApplied++; } if (enchantment.xpGain < .05f) { enchantment.xpGain = .05f; enchantment.xpGainTier = EnchantmentTier.Minor; enchantmentsApplied++; } if (enchantment.arcaneRes < .10f) { enchantment.arcaneRes = .10f; enchantment.arcaneResTier = EnchantmentTier.Minor; enchantmentsApplied++; } if (enchantment.arcaneDmg < .04f) { enchantment.arcaneDmg = .04f; enchantment.arcaneDmgTier = EnchantmentTier.Minor; enchantmentsApplied++; } break; case "TM_EStone_wonder": if (enchantment.maxMP < .1f) { enchantment.maxMP = .1f; enchantment.maxMPTier = EnchantmentTier.Standard; enchantmentsApplied++; } if (enchantment.mpRegenRate < .1f) { enchantment.mpRegenRate = .1f; enchantment.mpRegenRateTier = EnchantmentTier.Standard; enchantmentsApplied++; } if (enchantment.mpCost > -.05f) { enchantment.mpCost = -.05f; enchantment.mpCostTier = EnchantmentTier.Standard; enchantmentsApplied++; } if (enchantment.coolDown > -.05f) { enchantment.coolDown = -.05f; enchantment.coolDownTier = EnchantmentTier.Standard; enchantmentsApplied++; } if (enchantment.xpGain < .10f) { enchantment.xpGain = .10f; enchantment.xpGainTier = EnchantmentTier.Standard; enchantmentsApplied++; } if (enchantment.arcaneRes < .20f) { enchantment.arcaneRes = .20f; enchantment.arcaneResTier = EnchantmentTier.Standard; enchantmentsApplied++; } if (enchantment.arcaneDmg < .08f) { enchantment.arcaneDmg = .08f; enchantment.arcaneDmgTier = EnchantmentTier.Standard; enchantmentsApplied++; } break; case "TM_EStone_wonder_major": if (enchantment.maxMP < .15f) { enchantment.maxMP = .15f; enchantment.maxMPTier = EnchantmentTier.Major; enchantmentsApplied++; } if (enchantment.mpRegenRate < .15f) { enchantment.mpRegenRate = .15f; enchantment.mpRegenRateTier = EnchantmentTier.Major; enchantmentsApplied++; } if (enchantment.mpCost > -.07f) { enchantment.mpCost = -.07f; enchantment.mpCostTier = EnchantmentTier.Major; enchantmentsApplied++; } if (enchantment.coolDown > -.07f) { enchantment.coolDown = -.07f; enchantment.coolDownTier = EnchantmentTier.Major; enchantmentsApplied++; } if (enchantment.xpGain < .15f) { enchantment.xpGain = .15f; enchantment.xpGainTier = EnchantmentTier.Major; enchantmentsApplied++; } if (enchantment.arcaneRes < .30f) { enchantment.arcaneRes = .30f; enchantment.arcaneResTier = EnchantmentTier.Major; enchantmentsApplied++; } if (enchantment.arcaneDmg < .12f) { enchantment.arcaneDmg = .12f; enchantment.arcaneDmgTier = EnchantmentTier.Major; enchantmentsApplied++; } break; case "TM_EStone_maxMP_minor": if (enchantment.maxMP < .05f) { enchantment.maxMP = .05f; enchantment.maxMPTier = EnchantmentTier.Minor; enchantmentsApplied++; } break; case "TM_EStone_maxMP": if (enchantment.maxMP < .1f) { enchantment.maxMP = .1f; enchantment.maxMPTier = EnchantmentTier.Standard; enchantmentsApplied++; } break; case "TM_EStone_maxMP_major": if (enchantment.maxMP < .15f) { enchantment.maxMP = .15f; enchantment.maxMPTier = EnchantmentTier.Major; enchantmentsApplied++; } break; case "TM_EStone_mpRegenRate_minor": if (enchantment.mpRegenRate < .05f) { enchantment.mpRegenRate = .05f; enchantment.mpRegenRateTier = EnchantmentTier.Minor; enchantmentsApplied++; } break; case "TM_EStone_mpRegenRate": if (enchantment.mpRegenRate < .1f) { enchantment.mpRegenRate = .1f; enchantment.mpRegenRateTier = EnchantmentTier.Standard; enchantmentsApplied++; } break; case "TM_EStone_mpRegenRate_major": if (enchantment.mpRegenRate < .15f) { enchantment.mpRegenRate = .15f; enchantment.mpRegenRateTier = EnchantmentTier.Major; enchantmentsApplied++; } break; case "TM_EStone_mpCost_minor": if (enchantment.mpCost > -.03f) { enchantment.mpCost = -.03f; enchantment.mpCostTier = EnchantmentTier.Minor; enchantmentsApplied++; } break; case "TM_EStone_mpCost": if (enchantment.mpCost > -.05f) { enchantment.mpCost = -.05f; enchantment.mpCostTier = EnchantmentTier.Standard; enchantmentsApplied++; } break; case "TM_EStone_mpCost_major": if (enchantment.mpCost > -.07f) { enchantment.mpCost = -.07f; enchantment.mpCostTier = EnchantmentTier.Major; enchantmentsApplied++; } break; case "TM_EStone_coolDown_minor": if (enchantment.coolDown > -.03f) { enchantment.coolDown = -.03f; enchantment.coolDownTier = EnchantmentTier.Minor; enchantmentsApplied++; } break; case "TM_EStone_coolDown": if (enchantment.coolDown > -.05f) { enchantment.coolDown = -.05f; enchantment.coolDownTier = EnchantmentTier.Standard; enchantmentsApplied++; } break; case "TM_EStone_coolDown_major": if (enchantment.coolDown > -.07f) { enchantment.coolDown = -.07f; enchantment.coolDownTier = EnchantmentTier.Major; enchantmentsApplied++; } break; case "TM_EStone_xpGain_minor": if (enchantment.xpGain < .05f) { enchantment.xpGain = .05f; enchantment.xpGainTier = EnchantmentTier.Minor; enchantmentsApplied++; } break; case "TM_EStone_xpGain": if (enchantment.xpGain < .10f) { enchantment.xpGain = .10f; enchantment.xpGainTier = EnchantmentTier.Standard; enchantmentsApplied++; } break; case "TM_EStone_xpGain_major": if (enchantment.xpGain < .15f) { enchantment.xpGain = .15f; enchantment.xpGainTier = EnchantmentTier.Major; enchantmentsApplied++; } break; case "TM_EStone_arcaneRes_minor": if (enchantment.arcaneRes < .10f) { enchantment.arcaneRes = .10f; enchantment.arcaneResTier = EnchantmentTier.Minor; enchantmentsApplied++; } break; case "TM_EStone_arcaneRes": if (enchantment.arcaneRes < .20f) { enchantment.arcaneRes = .20f; enchantment.arcaneResTier = EnchantmentTier.Standard; enchantmentsApplied++; } break; case "TM_EStone_arcaneRes_major": if (enchantment.arcaneRes < .30f) { enchantment.arcaneRes = .30f; enchantment.arcaneResTier = EnchantmentTier.Major; enchantmentsApplied++; } break; case "TM_EStone_arcaneDmg_minor": if (enchantment.arcaneDmg < .04f) { enchantment.arcaneDmg = .04f; enchantment.arcaneDmgTier = EnchantmentTier.Minor; enchantmentsApplied++; } break; case "TM_EStone_arcaneDmg": if (enchantment.arcaneDmg < .08f) { enchantment.arcaneDmg = .08f; enchantment.arcaneDmgTier = EnchantmentTier.Standard; enchantmentsApplied++; } break; case "TM_EStone_arcaneDmg_major": if (enchantment.arcaneDmg < .12f) { enchantment.arcaneDmg = .12f; enchantment.arcaneDmgTier = EnchantmentTier.Major; enchantmentsApplied++; } break; case "null": Log.Message("null"); break; } return(enchantmentsApplied > 0); }
protected override void FillTab() { CompEnchantedItem enchantedItem = ThingCompUtility.TryGetComp <CompEnchantedItem>(Find.Selector.SingleSelectedThing); Rect rect = GenUI.ContractedBy(new Rect(0f, 0f, ITab_Enchantment.WinSize.x, ITab_Enchantment.WinSize.y), 10f); Rect rect2 = rect; Text.Font = GameFont.Small; string rectLabel = "Enchantments:"; Widgets.Label(rect2, rectLabel); int num = 2; Text.Font = GameFont.Tiny; Rect rect3 = GetRowRect(rect2, num); if (enchantedItem.Props.maxMP != 0) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.Props.maxMPTier); rectLabel = enchantedItem.Props.MaxMPLabel; Widgets.Label(rect3, rectLabel); num++; } Rect rect4 = GetRowRect(rect3, num); if (enchantedItem.Props.mpCost != 0) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.Props.mpCostTier); rectLabel = enchantedItem.Props.MPCostLabel; Widgets.Label(rect4, rectLabel); num++; } Rect rect5 = GetRowRect(rect4, num); if (enchantedItem.Props.mpRegenRate != 0) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.Props.mpRegenRateTier); rectLabel = enchantedItem.Props.MPRegenRateLabel; Widgets.Label(rect5, rectLabel); num++; } Rect rect6 = GetRowRect(rect5, num); if (enchantedItem.Props.coolDown != 0) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.Props.coolDownTier); rectLabel = enchantedItem.Props.CoolDownLabel; Widgets.Label(rect6, rectLabel); num++; } Rect rect7 = GetRowRect(rect6, num); if (enchantedItem.Props.xpGain != 0) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.Props.xpGainTier); rectLabel = enchantedItem.Props.XPGainLabel; Widgets.Label(rect7, rectLabel); num++; } //rect3.yMin += Text.CalcHeight(rectLabel, rect.width); //QualityCategory qualityCategory; //QualityUtility.TryGetQuality(ITab_Enchantment.SelectedCompEnchantment.parent, out qualityCategory); //StringBuilder stringBuilder = new StringBuilder(); //stringBuilder.Append(GenText.CapitalizeFirst(QualityUtility.GetLabel(qualityCategory))).Append(" ").Append(ResourceBank.StringQuality).Append(" "); //if (ITab_Enchantment.SelectedCompEnchantment.parent.Stuff != null) //{ // stringBuilder.Append(ITab_Enchantment.SelectedCompEnchantment.parent.Stuff.LabelAsStuff).Append(" "); //} //stringBuilder.Append(ITab_Enchantment.SelectedCompEnchantment.parent.def.label); //string text = stringBuilder.ToString(); //Widgets.Label(rect3, text); //GUI.color = Color.white; //Text.Anchor = TextAnchor.UpperLeft; //Rect rect4 = rect; //rect4.yMin += rect3.yMin + Text.CalcHeight(text, rect.width); //Text.Font = GameFont.Tiny; //Widgets.Label(rect4, ITab_Enchantment.SelectedCompEnchantment.parent.GetInfusionDesc()); }
protected override bool TryCastShot() { bool result = false; if (this.currentTarget != null && base.CasterPawn != null) { if (this.currentTarget.Thing != null && this.currentTarget.Thing is Pawn) { Pawn victim = this.currentTarget.Thing as Pawn; if (victim.Faction != null && victim.RaceProps.Humanlike && victim.story != null && victim.story.traits != null && victim.story.traits.allTraits.Count > 0 && !TM_Calc.IsUndead(victim)) { if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, victim, true))) { Thing orb = ThingMaker.MakeThing(TorannMagicDefOf.TM_Artifact_OrbOfSouls_Full, null); GenPlace.TryPlaceThing(orb, this.CasterPawn.Position, this.CasterPawn.Map, ThingPlaceMode.Near); CompEnchantedItem orbComp = orb.TryGetComp <CompEnchantedItem>(); if (victim.Faction == this.CasterPawn.Faction) { if (orbComp != null) { orbComp.SoulOrbTraits = new List <Trait>(); orbComp.SoulOrbTraits.Clear(); List <Trait> allTraits = victim.story.traits.allTraits; int iterations = Mathf.Max(allTraits.Count, 1); for (int i = 0; i < iterations; i++) { Trait transferTrait = allTraits.RandomElement(); orbComp.SoulOrbTraits.AddDistinct(transferTrait); RemoveTrait(victim, allTraits, transferTrait.def); result = true; } if (Rand.Chance(.6f)) { victim.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk); } else if (Rand.Chance(.2f)) { victim.Kill(null, null); } } else { Log.Message("no comp found for orb of souls"); } } else { if (orbComp != null) { orbComp.SoulOrbTraits = new List <Trait>(); orbComp.SoulOrbTraits.Clear(); List <Trait> allTraits = victim.story.traits.allTraits; int iterations = Mathf.Max(allTraits.Count, 1); for (int i = 0; i < iterations; i++) { Trait transferTrait = allTraits.RandomElement(); orbComp.SoulOrbTraits.AddDistinct(transferTrait); RemoveTrait(victim, allTraits, transferTrait.def); Effects(victim.Position); result = true; } if (result) { if (Rand.Chance(.15f)) { victim.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk); int relationChange = Rand.RangeInclusive(-30, -20); this.CasterPawn.Faction.TryAffectGoodwillWith(victim.Faction, relationChange, true, true, TorannMagicDefOf.TM_OffensiveMagic, null); } else { victim.Kill(null, null); int relationChange = Rand.RangeInclusive(-50, -30); this.CasterPawn.Faction.TryAffectGoodwillWith(victim.Faction, relationChange, true, true, TorannMagicDefOf.TM_OffensiveMagic, null); } } } else { Log.Message("no comp found for orb of souls"); } } } else { MoteMaker.ThrowText(victim.DrawPos, victim.Map, "TM_ResistedSpell".Translate(), -1); } } else { //invalid target Messages.Message("TM_InvalidTarget".Translate( this.CasterPawn.LabelShort, this.verbProps.label ), MessageTypeDefOf.RejectInput); } } else { //invalid target Messages.Message("TM_InvalidTarget".Translate( this.CasterPawn.LabelShort, this.verbProps.label ), MessageTypeDefOf.RejectInput); } } else { Log.Warning("failed to TryCastShot"); } this.burstShotsLeft = 0; //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60; PostCastShot(result); return(false); }
private void EnchantItem(Thing gemstone, CompEnchantedItem enchantment) { enchantment.Props.HasEnchantment = true; switch (gemstone.def.defName) { case "TM_EStone_maxMP_minor": enchantment.Props.maxMP = .05f; enchantment.Props.maxMPTier = EnchantmentTier.Minor; break; case "TM_EStone_maxMP": enchantment.Props.maxMP = .1f; enchantment.Props.maxMPTier = EnchantmentTier.Standard; break; case "TM_EStone_maxMP_major": enchantment.Props.maxMP = .15f; enchantment.Props.maxMPTier = EnchantmentTier.Major; break; case "TM_EStone_mpRegenRate_minor": enchantment.Props.mpRegenRate = .05f; enchantment.Props.mpRegenRateTier = EnchantmentTier.Minor; break; case "TM_EStone_mpRegenRate": enchantment.Props.mpRegenRate = .1f; enchantment.Props.mpRegenRateTier = EnchantmentTier.Standard; break; case "TM_EStone_mpRegenRate_major": enchantment.Props.mpRegenRate = .15f; enchantment.Props.mpRegenRateTier = EnchantmentTier.Major; break; case "TM_EStone_mpCost_minor": enchantment.Props.mpCost = -.03f; enchantment.Props.mpCostTier = EnchantmentTier.Minor; break; case "TM_EStone_mpCost": enchantment.Props.mpCost = -.05f; enchantment.Props.mpCostTier = EnchantmentTier.Standard; break; case "TM_EStone_mpCost_major": enchantment.Props.mpCost = -.07f; enchantment.Props.mpCostTier = EnchantmentTier.Major; break; case "TM_EStone_coolDown_minor": enchantment.Props.coolDown = -.03f; enchantment.Props.coolDownTier = EnchantmentTier.Minor; break; case "TM_EStone_coolDown": enchantment.Props.coolDown = -.05f; enchantment.Props.coolDownTier = EnchantmentTier.Standard; break; case "TM_EStone_coolDown_major": enchantment.Props.coolDown = -.07f; enchantment.Props.coolDownTier = EnchantmentTier.Major; break; case "TM_EStone_xpGain_minor": enchantment.Props.xpGain = .05f; enchantment.Props.xpGainTier = EnchantmentTier.Minor; break; case "TM_EStone_xpGain": enchantment.Props.xpGain = .10f; enchantment.Props.xpGainTier = EnchantmentTier.Standard; break; case "TM_EStone_xpGain_major": enchantment.Props.xpGain = .15f; enchantment.Props.xpGainTier = EnchantmentTier.Major; break; case "null": Log.Message("null"); break; } }
public override void CompTickRare() { if (this.hediff != null) { Apparel artifact = this.parent as Apparel; if (artifact != null) { if (artifact.Wearer != null) { //Log.Message("" + artifact.LabelShort + " has holding owner " + artifact.Wearer.LabelShort); if (artifact.Wearer.health.hediffSet.GetFirstHediffOfDef(hediff, false) != null) { } else { HealthUtility.AdjustSeverity(artifact.Wearer, hediff, hediffSeverity); HediffComp_EnchantedItem hdc = artifact.Wearer.health.hediffSet.GetFirstHediffOfDef(hediff, false).TryGetComp <HediffComp_EnchantedItem>(); if (hdc != null) { hdc.enchantedItem = artifact; } //HediffComp_EnchantedItem comp = diff.TryGetComp<HediffComp_EnchantedItem>(); } } } } if (this.Props.hasAbility && !this.abilitiesInitialized) { Apparel artifact = this.parent as Apparel; if (artifact != null) { if (artifact.Wearer != null) { //Log.Message("" + artifact.LabelShort + " has holding owner " + artifact.Wearer.LabelShort); this.InitializeAbilities(artifact); } this.MagicAbilities = artifact.GetComp <CompAbilityItem>().Props.Abilities; //this.MagicAbilities = new List<AbilityDef>(); //this.MagicAbilities.Clear(); // abilities; } } if (GetEnchantedStuff_HediffDef != null) { if (WearingPawn != null) { hediffStuff.Clear(); List <Apparel> wornApparel = WearingPawn.apparel.WornApparel; for (int i = 0; i < wornApparel.Count; i++) { CompEnchantedItem itemComp = wornApparel[i].TryGetComp <CompEnchantedItem>(); if (itemComp != null && itemComp.GetEnchantedStuff_HediffDef != null) { int hdCount = GetStuffCount_Hediff(itemComp.EnchantedStuff.appliedHediff); if (hdCount >= itemComp.EnchantedStuff.applyHediffAtCount) { if (WearingPawn.health.hediffSet.HasHediff(itemComp.EnchantedStuff.appliedHediff)) { Hediff hd = WearingPawn.health.hediffSet.GetFirstHediffOfDef(itemComp.EnchantedStuff.appliedHediff); if (hd.Severity < (hdCount * itemComp.EnchantedStuff.severityPerCount)) { WearingPawn.health.RemoveHediff(hd); HealthUtility.AdjustSeverity(WearingPawn, itemComp.EnchantedStuff.appliedHediff, hdCount * itemComp.EnchantedStuff.severityPerCount); } } else { HealthUtility.AdjustSeverity(WearingPawn, itemComp.EnchantedStuff.appliedHediff, hdCount * itemComp.EnchantedStuff.severityPerCount); } } } } if (WearingPawn.equipment != null && WearingPawn.equipment.Primary != null && !EnchantedStuff.apparelOnly) { ThingWithComps eq = WearingPawn.equipment.Primary; CompEnchantedItem itemComp = eq.TryGetComp <CompEnchantedItem>(); if (itemComp != null && itemComp.GetEnchantedStuff_HediffDef != null) { int hdCount = GetStuffCount_Hediff(itemComp.EnchantedStuff.appliedHediff); if (hdCount >= itemComp.EnchantedStuff.applyHediffAtCount) { if (WearingPawn.health.hediffSet.HasHediff(itemComp.EnchantedStuff.appliedHediff)) { Hediff hd = WearingPawn.health.hediffSet.GetFirstHediffOfDef(itemComp.EnchantedStuff.appliedHediff); if (hd.Severity < (hdCount * itemComp.EnchantedStuff.severityPerCount)) { WearingPawn.health.RemoveHediff(hd); HealthUtility.AdjustSeverity(WearingPawn, itemComp.EnchantedStuff.appliedHediff, hdCount * itemComp.EnchantedStuff.severityPerCount); } } else { HealthUtility.AdjustSeverity(WearingPawn, itemComp.EnchantedStuff.appliedHediff, hdCount * itemComp.EnchantedStuff.severityPerCount); } } } } } } base.CompTickRare(); }
protected override void FillTab() { CompEnchantedItem enchantedItem = ThingCompUtility.TryGetComp <CompEnchantedItem>(Find.Selector.SingleSelectedThing); float enchantmentMultiplier = 1f; if (Find.Selector.SingleSelectedThing.Stuff != null && Find.Selector.SingleSelectedThing.Stuff.defName == "TM_Manaweave") { enchantmentMultiplier = 1.2f; } Rect rect = GenUI.ContractedBy(new Rect(0f, 0f, ITab_Enchantment.WinSize.x, ITab_Enchantment.WinSize.y), 10f); Rect rect2 = rect; Text.Font = GameFont.Small; string rectLabel = "Enchantments:"; Widgets.Label(rect2, rectLabel); int num = 2; Text.Font = GameFont.Tiny; Rect rect3 = GetRowRect(rect2, num); if (enchantedItem.maxMP != 0) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.maxMPTier); rectLabel = enchantedItem.MaxMPLabel; Widgets.Label(rect3, rectLabel); num++; } Rect rect4 = GetRowRect(rect3, num); if (enchantedItem.mpCost != 0) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.mpCostTier); rectLabel = enchantedItem.MPCostLabel; Widgets.Label(rect4, rectLabel); num++; } Rect rect5 = GetRowRect(rect4, num); if (enchantedItem.mpRegenRate != 0) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.mpRegenRateTier); rectLabel = enchantedItem.MPRegenRateLabel; Widgets.Label(rect5, rectLabel); num++; } Rect rect6 = GetRowRect(rect5, num); if (enchantedItem.coolDown != 0) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.coolDownTier); rectLabel = enchantedItem.CoolDownLabel; Widgets.Label(rect6, rectLabel); num++; } Rect rect7 = GetRowRect(rect6, num); if (enchantedItem.xpGain != 0) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.xpGainTier); rectLabel = enchantedItem.XPGainLabel; Widgets.Label(rect7, rectLabel); num++; } Rect rect71 = GetRowRect(rect7, num); if (enchantedItem.arcaneRes != 0) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.arcaneResTier); rectLabel = enchantedItem.ArcaneResLabel; Widgets.Label(rect71, rectLabel); num++; } Rect rect72 = GetRowRect(rect71, num); if (enchantedItem.arcaneDmg != 0) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.arcaneDmgTier); rectLabel = enchantedItem.ArcaneDmgLabel; Widgets.Label(rect72, rectLabel); num++; } Rect rect8 = GetRowRect(rect72, num); if (enchantedItem.arcaneSpectre != false) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.skillTier); rectLabel = enchantedItem.ArcaneSpectreLabel; Widgets.Label(rect8, rectLabel); num++; } Rect rect9 = GetRowRect(rect8, num); if (enchantedItem.phantomShift != false) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.skillTier); rectLabel = enchantedItem.PhantomShiftLabel; Widgets.Label(rect9, rectLabel); num++; } Rect rect10 = GetRowRect(rect9, num); if (enchantedItem.hediff != null) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.skillTier); rectLabel = enchantedItem.HediffLabel; Widgets.Label(rect10, rectLabel); num++; } Rect rect11 = GetRowRect(rect10, num); if (enchantedItem.MagicAbilities != null && enchantedItem.MagicAbilities.Count > 0) { StringBuilder stringBuilder = new StringBuilder(); GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.skillTier); string abilityLabels = "Abilities: "; stringBuilder.Append(abilityLabels); for (int i = 0; i < enchantedItem.MagicAbilities.Count; i++) { if (i + 1 < enchantedItem.MagicAbilities.Count) { stringBuilder.Append(enchantedItem.MagicAbilities[i].LabelCap + ", "); } else { stringBuilder.Append(enchantedItem.MagicAbilities[i].LabelCap); } } rectLabel = stringBuilder.ToString(); Widgets.Label(rect11, rectLabel); num++; } Rect rect12 = GetRowRect(rect11, num); if (enchantedItem.SoulOrbTraits != null && enchantedItem.SoulOrbTraits.Count > 0) { StringBuilder stringBuilder = new StringBuilder(); GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.skillTier); string abilityLabels = "Absorbed Traits: "; stringBuilder.Append(abilityLabels); for (int i = 0; i < enchantedItem.SoulOrbTraits.Count; i++) { //abilityLabels = enchantedItem.SoulOrbTraits[i].LabelCap + "\n"; if (i + 1 < enchantedItem.SoulOrbTraits.Count) { stringBuilder.Append(enchantedItem.SoulOrbTraits[i].LabelCap + ", "); } else { stringBuilder.Append(enchantedItem.SoulOrbTraits[i].LabelCap); } } rectLabel = stringBuilder.ToString(); Widgets.Label(rect12, rectLabel); num++; } Rect rect13 = GetRowRect(rect12, num); if (enchantedItem.enchantmentAction != null && (enchantedItem.enchantmentAction.type != EnchantmentActionType.Null)) { GUI.color = GenEnchantmentColor.EnchantmentColor(enchantedItem.skillTier); rectLabel = enchantedItem.EnchantmentActionLabel; Widgets.Label(rect13, rectLabel); num++; } //rect3.yMin += Text.CalcHeight(rectLabel, rect.width); //QualityCategory qualityCategory; //QualityUtility.TryGetQuality(ITab_Enchantment.SelectedCompEnchantment.parent, out qualityCategory); //StringBuilder stringBuilder = new StringBuilder(); //stringBuilder.Append(GenText.CapitalizeFirst(QualityUtility.GetLabel(qualityCategory))).Append(" ").Append(ResourceBank.StringQuality).Append(" "); //if (ITab_Enchantment.SelectedCompEnchantment.parent.Stuff != null) //{ // stringBuilder.Append(ITab_Enchantment.SelectedCompEnchantment.parent.Stuff.LabelAsStuff).Append(" "); //} //stringBuilder.Append(ITab_Enchantment.SelectedCompEnchantment.parent.def.label); //string text = stringBuilder.ToString(); //Widgets.Label(rect3, text); //GUI.color = Color.white; //Text.Anchor = TextAnchor.UpperLeft; //Rect rect4 = rect; //rect4.yMin += rect3.yMin + Text.CalcHeight(text, rect.width); //Text.Font = GameFont.Tiny; //Widgets.Label(rect4, ITab_Enchantment.SelectedCompEnchantment.parent.GetInfusionDesc()); }