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); } }