Example #1
0
        private void Initialize()
        {
            caster = this.launcher as Pawn;
            CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();

            if (comp != null && comp.MagicData != null)
            {
                pwrVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_Sunfire, "TM_Sunfire", "_pwr", true);
                verVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_Sunfire, "TM_Sunfire", "_ver", true);
            }
            this.arcaneDmg = comp.arcaneDmg;
            if (caster.health.hediffSet.HasHediff(TorannMagicDefOf.TM_LightCapacitanceHD))
            {
                HediffComp_LightCapacitance hd = caster.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_LightCapacitanceHD).TryGetComp <HediffComp_LightCapacitance>();
                this.lightPotency = hd.LightPotency;
                hd.LightEnergy   -= 25f;
            }
            int mapTime = GenLocalDate.HourOfDay(caster.Map);

            if (mapTime > 13)
            {
                this.angle = (float)Mathf.Abs(mapTime - 12f) * -5f;
            }
            else if (mapTime < 12)
            {
                this.angle = (float)Mathf.Abs(12 - mapTime) * 5f;
            }
            else
            {
                this.angle = 0f;
            }
            this.radius += .15f * this.def.projectile.explosionRadius;
            this.CheckSpawnSustainer();
            this.InitializeBeams();
        }
Example #2
0
        private void Initialize()
        {
            caster = this.launcher as Pawn;
            this.launchPosition = caster.Position;
            CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();

            pwrVal         = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_LightLance, "TM_LightLance", "_pwr", true);
            verVal         = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_LightLance, "TM_LightLance", "_ver", true);
            this.arcaneDmg = comp.arcaneDmg;
            if (caster.health.hediffSet.HasHediff(TorannMagicDefOf.TM_LightCapacitanceHD))
            {
                HediffComp_LightCapacitance hd = caster.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_LightCapacitanceHD).TryGetComp <HediffComp_LightCapacitance>();
                this.lightPotency = hd.LightPotency;
            }
            this.radius = Mathf.Clamp(1.8f + (.25f * verVal * lightPotency), 1f, 3f);
            this.angle  = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(caster.Position, base.Position)).ToAngleFlat();
            this.CheckSpawnSustainer();
            this.burnTime += pwrVal * 22;
            lanceAngle     = Vector3Utility.FromAngleFlat(this.angle - 90);             //angle of beam
            lanceAngleInv  = Vector3Utility.FromAngleFlat(this.angle + 90);             //opposite angle of beam
            drawPosStart   = this.launchPosition.ToVector3Shifted() + lanceAngle;       //this.parent.DrawPos;
            drawPosEnd     = base.Position.ToVector3Shifted() + lanceAngleInv;
            lanceLength    = (drawPosEnd - drawPosStart).magnitude;
            lanceVector    = drawPosStart + (lanceAngle * lanceLength * 0.5f);
            lanceVectorInv = drawPosEnd + (lanceAngleInv * lanceLength * .5f);          //draw for double beam
            lanceVector.y  = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays);         //graphic depth
        }
Example #3
0
        protected override bool TryCastShot()
        {
            Pawn    caster            = base.CasterPawn;
            Map     map               = caster.Map;
            IntVec3 cell              = currentTarget.Cell;
            CompAbilityUserMagic comp = caster.TryGetComp <CompAbilityUserMagic>();

            pwrVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_Totems, "TM_Totems", "_pwr", true);
            verVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_Totems, "TM_Totems", "_ver", true);
            effVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_Totems, "TM_Totems", "_eff", true);
            IntVec3 shiftPos = TM_Calc.GetEmptyCellForNewBuilding(cell, map, 2f, true, 0, true);

            if (shiftPos != null && shiftPos.IsValid && shiftPos.Standable(map))
            {
                AbilityUser.SpawnThings tempPod = new SpawnThings();
                tempPod.def        = TorannMagicDefOf.TM_EarthTotem;
                tempPod.spawnCount = 1;

                try
                {
                    this.totem = TM_Action.SingleSpawnLoop(caster, tempPod, shiftPos, map, 2500 + (125 * verVal), true, false, caster.Faction, false, ThingDefOf.BlocksGranite);
                    this.totem.SetFaction(caster.Faction);
                    Building_TMTotem_Earth totemBuilding = this.totem as Building_TMTotem_Earth;
                    if (totemBuilding != null)
                    {
                        totemBuilding.pwrVal = pwrVal;
                        totemBuilding.verVal = verVal;
                    }
                    for (int i = 0; i < 3; i++)
                    {
                        Vector3 rndPos = this.totem.DrawPos;
                        rndPos.x += Rand.Range(-.5f, .5f);
                        rndPos.z += Rand.Range(-.5f, .5f);
                        TM_MoteMaker.ThrowGenericMote(ThingDefOf.Mote_DustPuffThick, rndPos, map, Rand.Range(.6f, 1f), .1f, .05f, .05f, 0, 0, 0, Rand.Range(0, 360));
                        MoteMaker.ThrowSmoke(rndPos, map, Rand.Range(.8f, 1.2f));
                    }
                }
                catch
                {
                    comp.Mana.CurLevel += comp.ActualManaCost(TorannMagicDefOf.TM_SummonTotemEarth);
                    if (caster.IsColonist)
                    {
                        Log.Message("TM_Exception".Translate(
                                        caster.LabelShort,
                                        "Earth Totem"
                                        ));
                    }
                }
            }
            else
            {
                if (caster.IsColonist)
                {
                    Messages.Message("InvalidSummon".Translate(), MessageTypeDefOf.RejectInput);
                    comp.Mana.GainNeed(comp.ActualManaCost(TorannMagicDefOf.TM_SummonTotemEarth));
                }
            }
            return(false);
        }
Example #4
0
        protected override bool TryCastShot()
        {
            bool flag = false;

            this.TargetsAoE.Clear();
            this.FindTargets();
            CompAbilityUserMagic comp = CasterPawn.GetComp <CompAbilityUserMagic>();

            if (comp != null && comp.MagicData != null)
            {
                pwrVal    = TM_Calc.GetMagicSkillLevel(CasterPawn, comp.MagicData.MagicPowerSkill_Hex, "TM_Hex", "_pwr", true);
                verVal    = TM_Calc.GetMagicSkillLevel(CasterPawn, comp.MagicData.MagicPowerSkill_Hex, "TM_Hex", "_ver", true);
                arcaneDmg = comp.arcaneDmg;
            }
            bool flag2 = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1;

            if (flag2)
            {
                this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1);
            }
            bool addAbilities       = false;
            bool shouldAddAbilities = comp.HexedPawns.Count <= 0;

            for (int i = 0; i < this.TargetsAoE.Count; i++)
            {
                Pawn newPawn = this.TargetsAoE[i].Thing as Pawn;
                if (newPawn.RaceProps.IsFlesh && !TM_Calc.IsUndead(newPawn))
                {
                    if (Rand.Chance(.4f + (.1f * pwrVal * TM_Calc.GetSpellSuccessChance(this.CasterPawn, newPawn, true))))
                    {
                        HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_HexHD, 1f);
                        var hexedPawns = comp.HexedPawns;
                        if (!hexedPawns.Contains(newPawn))
                        {
                            hexedPawns.Add(newPawn);
                        }
                        addAbilities = true;
                        TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Hex, newPawn.DrawPos, newPawn.Map, .6f, .1f, .2f, .2f, 0, 0, 0, 0);
                    }
                    else
                    {
                        MoteMaker.ThrowText(newPawn.DrawPos, newPawn.Map, "TM_ResistedSpell".Translate(), -1);
                    }
                }
            }
            if (shouldAddAbilities && addAbilities)
            {
                comp.AddPawnAbility(TorannMagicDefOf.TM_Hex_CriticalFail);
                comp.AddPawnAbility(TorannMagicDefOf.TM_Hex_Pain);
                comp.AddPawnAbility(TorannMagicDefOf.TM_Hex_MentalAssault);
            }
            this.PostCastShot(flag, out flag);
            return(flag);
        }
        protected override bool TryCastShot()
        {
            Pawn caster = base.CasterPawn;
            Pawn pawn   = this.currentTarget.Thing as Pawn;

            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
            int verVal     = TM_Calc.GetMagicSkillLevel(CasterPawn, comp.MagicData.MagicPowerSkill_Hex, "TM_Hex", "_ver", true);
            var hexedPawns = comp.HexedPawns;

            if (comp != null && hexedPawns.Count > 0)
            {
                foreach (Pawn p in hexedPawns)
                {
                    if (p.mindState != null && p.mindState.mentalStateHandler != null)
                    {
                        if (Rand.Chance(TM_Calc.GetSpellSuccessChance(caster, p, true) * (.4f + (.1f * verVal))))
                        {
                            if (Rand.Chance(.3f) || p.RaceProps.Animal)
                            {
                                if (p.RaceProps.Animal)
                                {
                                    p.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Manhunter);
                                }
                                else
                                {
                                    p.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk);
                                }
                            }
                            else
                            {
                                if (p.Faction == Faction.OfPlayer)
                                {
                                    if (p.drafter != null && p.Drafted)
                                    {
                                        p.drafter.Drafted = false;
                                    }
                                    p.jobs.EndCurrentJob(JobCondition.InterruptForced);
                                    Job job = new Job(JobDefOf.FleeAndCower, p.Position);
                                    pawn.jobs.TryTakeOrderedJob(job, JobTag.DraftedOrder);
                                }
                                else
                                {
                                    p.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.PanicFlee);
                                }
                            }
                            TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_ScreamMote, p.DrawPos, p.Map, .4f, .2f, .2f, .3f, 0, Rand.Range(.5f, 1f), Rand.Range(-90, 90), 0);
                        }
                    }
                }
            }
            return(true);
        }
Example #6
0
        protected override bool TryCastShot()
        {
            bool flag    = false;
            Pawn caster  = this.CasterPawn;
            Pawn hitPawn = this.currentTarget.Thing as Pawn;
            CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();

            if (comp != null && comp.MagicData != null)
            {
                pwrVal    = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_Enrage, "TM_Enrage", "_pwr", true);
                verVal    = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_Enrage, "TM_Enrage", "_ver", true);
                arcaneDmg = comp.arcaneDmg;
            }

            if (hitPawn != null && hitPawn.RaceProps != null && hitPawn.RaceProps.Humanlike && !TM_Calc.IsUndead(hitPawn))
            {
                if (hitPawn.Faction != caster.Faction && hitPawn.mindState != null && hitPawn.mindState.mentalStateHandler != null)
                {
                    if (Rand.Chance(TM_Calc.GetSpellSuccessChance(caster, hitPawn, true)))
                    {
                        try
                        {
                            hitPawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk, null, true, false, caster);
                        }
                        catch
                        {
                            MoteMaker.ThrowText(hitPawn.DrawPos, hitPawn.Map, "Failed", -1);
                        }
                    }
                    else
                    {
                        MoteMaker.ThrowText(hitPawn.DrawPos, hitPawn.Map, "TM_ResistedSpell".Translate(), -1);
                        return(false);
                    }
                }
                HealthUtility.AdjustSeverity(hitPawn, TorannMagicDefOf.TM_EnrageHD, (.25f + (.05f + pwrVal)) * (.5f * arcaneDmg));

                HediffComp_Enrage hdc = hitPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_EnrageHD).TryGetComp <HediffComp_Enrage>();
                hdc.reductionFactor = (1f - (.1f * verVal));
                if (verVal >= 4)
                {
                    hdc.consumeJoy = true;
                }
            }
            else
            {
                Messages.Message("TM_InvalidTarget".Translate(CasterPawn.LabelShort, this.Ability.Def.label), MessageTypeDefOf.RejectInput);
            }

            this.PostCastShot(flag, out flag);
            return(flag);
        }
        protected override bool TryCastShot()
        {
            Pawn caster = base.CasterPawn;
            Map  map    = caster.Map;

            cellList.Clear();
            List <IntVec3>       tmpList = GenRadial.RadialCellsAround(currentTarget.Cell, this.Projectile.projectile.explosionRadius, true).ToList();
            CompAbilityUserMagic comp    = caster.TryGetComp <CompAbilityUserMagic>();

            pwrVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_SpiritWolves, "TM_SpiritWolves", "_pwr", true);
            verVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_SpiritWolves, "TM_SpiritWolves", "_ver", true);
            effVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_SpiritWolves, "TM_SpiritWolves", "_eff", true);
            if (tmpList != null && tmpList.Count > 0)
            {
                foreach (IntVec3 c in tmpList)
                {
                    if (c != null && (c.IsValid && c.Standable(map) && c.InBounds(map)))
                    {
                        cellList.Add(c);
                    }
                }
                int summonCount = 5 + verVal;
                for (int i = 0; i < summonCount; i++)
                {
                    FleckMaker.ThrowSmoke(cellList.RandomElement().ToVector3Shifted(), map, Rand.Range(3f, 4f));
                    IntVec3 cell = cellList.RandomElement();

                    AbilityUser.SpawnThings tempPod = new SpawnThings();
                    tempPod.def        = TorannMagicDefOf.TM_SpiritWolfR;
                    tempPod.kindDef    = TorannMagicDefOf.TM_SpiritWolf;
                    tempPod.spawnCount = 1;
                    tempPod.temporary  = true;

                    Thing newPawn = null;
                    newPawn = TM_Action.SingleSpawnLoop(caster, tempPod, cell, map, Rand.Range(1000, 1200) + (120 * effVal), true, false, caster.Faction, false);
                    Pawn animal = newPawn as Pawn;
                    HealthUtility.AdjustSeverity(animal, TorannMagicDefOf.TM_EnrageHD, .2f + (.1f * pwrVal));
                    for (int j = 0; j < 3; j++)
                    {
                        FleckMaker.ThrowSmoke(animal.DrawPos, map, Rand.Range(.5f, 1.1f));
                    }
                }
            }
            else
            {
                Messages.Message("InvalidSummon".Translate(), MessageTypeDefOf.RejectInput);
                comp.Mana.GainNeed(comp.ActualManaCost(TorannMagicDefOf.TM_SpiritWolves));
            }
            return(false);
        }
Example #8
0
 private void UpdateSoLPower()
 {
     if (!pawn.DestroyedOrNull() && pawn.Spawned)
     {
         CompAbilityUserMagic comp = pawn.TryGetComp <CompAbilityUserMagic>();
         if (comp != null && comp.IsMagicUser)
         {
             pwrVal         = TM_Calc.GetMagicSkillLevel(pawn, comp.MagicData.MagicPowerSkill_SpiritOfLight, "TM_SpiritOfLight", "_pwr");
             effVal         = TM_Calc.GetMagicSkillLevel(pawn, comp.MagicData.MagicPowerSkill_SpiritOfLight, "TM_SpiritOfLight", "_eff");
             verVal         = TM_Calc.GetMagicSkillLevel(pawn, comp.MagicData.MagicPowerSkill_SpiritOfLight, "TM_SpiritOfLight", "_ver");
             this.arcaneDmg = comp.arcaneDmg;
         }
     }
 }
Example #9
0
 private void UpdateHediff()
 {
     if (this.linkedPawn != null)
     {
         CompAbilityUserMagic comp = linkedPawn.TryGetComp <CompAbilityUserMagic>();
         if (comp != null)
         {
             int ver = TM_Calc.GetMagicSkillLevel(linkedPawn, comp.MagicData.MagicPowerSkill_RaiseUndead, "TM_RaiseUndead", "_ver");
             if (this.parent.Severity != ver + .5f)
             {
                 this.parent.Severity = .5f + ver;
             }
         }
     }
 }
Example #10
0
 private void Initialize()
 {
     if (caster != null)
     {
         CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();
         pwrVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_Refraction, "TM_Refraction", "_pwr", TorannMagicDefOf.TM_Refraction.canCopy);
         verVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_Refraction, "TM_Refraction", "_ver", TorannMagicDefOf.TM_Refraction.canCopy);
         if (caster.health.hediffSet.HasHediff(TorannMagicDefOf.TM_LightCapacitanceHD))
         {
             HediffComp_LightCapacitance hd = caster.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_LightCapacitanceHD).TryGetComp <HediffComp_LightCapacitance>();
             this.wallEnergy *= hd.LightPotency;
             hd.LightEnergy  -= 20f;
         }
     }
 }
        protected override bool TryCastShot()
        {
            Pawn pawn = this.currentTarget.Thing as Pawn;
            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
            int verVal     = TM_Calc.GetMagicSkillLevel(CasterPawn, comp.MagicData.MagicPowerSkill_Hex, "TM_Hex", "_ver", true);
            var hexedPawns = comp.HexedPawns;

            if (comp != null && hexedPawns.Count > 0)
            {
                foreach (Pawn p in hexedPawns)
                {
                    HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_Hex_CriticalFailHD, .6f + (.1f * verVal));
                    TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_BlackSmoke, p.DrawPos, p.Map, .7f, .1f, .1f, .2f, Rand.Range(-50, 50), Rand.Range(.5f, 1f), Rand.Range(-90, 90), Rand.Range(0, 360));
                }
            }
            return(true);
        }
 private void Initialize()
 {
     if (pawn != null)
     {
         FleckMaker.Static(pawn.TrueCenter(), pawn.Map, FleckDefOf.ExplosionFlash, 12f);
         SoundDefOf.Ambient_AltitudeWind.sustainFadeoutTime.Equals(30.0f);
         FleckMaker.ThrowDustPuff(pawn.Position, pawn.Map, Rand.Range(1.2f, 1.8f));
         GetVector();
         this.angle = (Quaternion.AngleAxis(90, Vector3.up) * this.direction).ToAngleFlat();
         CompAbilityUserMagic comp = pawn.TryGetComp <CompAbilityUserMagic>();
         if (comp != null && comp.IsMagicUser)
         {
             verVal    = TM_Calc.GetMagicSkillLevel(pawn, comp.MagicData.MagicPowerSkill_SpiritWolves, "TM_SpiritWolves", "_ver", true);
             pwrVal    = TM_Calc.GetMagicSkillLevel(pawn, comp.MagicData.MagicPowerSkill_SpiritWolves, "TM_SpiritWolves", "_pwr", true);
             arcaneDmg = comp.arcaneDmg;
         }
     }
 }
Example #13
0
        protected override bool TryCastShot()
        {
            Pawn caster = base.CasterPawn;
            Pawn pawn   = this.currentTarget.Thing as Pawn;

            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
            int verVal = TM_Calc.GetMagicSkillLevel(CasterPawn, comp.MagicData.MagicPowerSkill_Hex, "TM_Hex", "_ver", true);

            if (comp != null && comp.HexedPawns.Count > 0)
            {
                foreach (Pawn p in comp.HexedPawns)
                {
                    TM_Action.DamageEntities(p, null, Rand.Range(2f, 4f) * (1f + (.1f * verVal)), 2, TMDamageDefOf.DamageDefOf.TM_PainDD, caster);
                    TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_BloodMist, p.DrawPos, p.Map, .7f, .2f, .2f, .3f, Rand.Range(-50, 50), Rand.Range(.5f, 1f), Rand.Range(-90, 90), Rand.Range(0, 360));
                }
            }
            return(true);
        }
Example #14
0
 private void Initialize(Pawn p)
 {
     if (!p.DestroyedOrNull())
     {
         GenClamor.DoClamor(this, 2f, ClamorDefOf.Ability);
         CompAbilityUserMagic comp = p.TryGetComp <CompAbilityUserMagic>();
         if (comp != null && comp.MagicData != null)
         {
             pwrVal         = TM_Calc.GetMagicSkillLevel(p, comp.MagicData.MagicPowerSkill_ChainLightning, "TM_ChainLightning", "_pwr", true);
             verVal         = TM_Calc.GetMagicSkillLevel(p, comp.MagicData.MagicPowerSkill_ChainLightning, "TM_ChainLightning", "_ver", true);
             this.arcaneDmg = comp.arcaneDmg;
         }
         maxStrikes   += verVal;
         newStrikeLocs = new List <IntVec3>();
         strikeLocs    = new List <IntVec3>();
         strikeMeshes  = new List <Mesh>();
         chainedThings = new HashSet <Thing>();
     }
 }
        protected override bool TryCastShot()
        {
            bool result = false;
            Pawn pawn   = this.CasterPawn;
            Map  map    = this.CasterPawn.Map;

            if (map != null && !pawn.Position.Roofed(map))
            {
                this.pawn        = this.CasterPawn;
                launcherPosition = this.CasterPawn.Position;
                CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
                pwrVal         = TM_Calc.GetMagicSkillLevel(this.pawn, comp.MagicData.MagicPowerSkill_LightSkip, "TM_LightSkip", "_pwr", false);
                this.arcaneDmg = comp.arcaneDmg;
                this.draftFlag = this.pawn.drafter != null ? this.pawn.Drafted : false;
                this.gi        = 0;
                podTList.Clear();
                pawnList.Clear();
                pods.Clear();

                List <Pawn> tmpList = TM_Calc.FindAllPawnsAround(this.CasterPawn.Map, launcherPosition, 5f, this.pawn.Faction, true);
                for (int i = 0; i < tmpList.Count; i++)
                {
                    if (!tmpList[i].Position.Roofed(map))
                    {
                        if (ModCheck.Validate.GiddyUp.Core_IsInitialized())
                        {
                            if (ModCheck.GiddyUp.IsMount(tmpList[i]))
                            {
                                continue;
                            }
                        }
                        pawnList.Add(tmpList[i]);
                    }
                }
                StartChoosingDestination();
            }
            else
            {
                Messages.Message("TM_CannotCastUnderRoof".Translate(pawn.LabelShort, Ability.Def.label), MessageTypeDefOf.NegativeEvent);
                MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, "Light Skip: " + StringsToTranslate.AU_CastFailure, -1f);
            }
            return(result);
        }
Example #16
0
        private void Initialize(Pawn pawn)
        {
            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();

            pwrVal          = TM_Calc.GetMagicSkillLevel(pawn, comp.MagicData.MagicPowerSkill_LightBurst, "TM_LightBurst", "_pwr", TorannMagicDefOf.TM_LightBurst.canCopy);
            verVal          = TM_Calc.GetMagicSkillLevel(pawn, comp.MagicData.MagicPowerSkill_LightBurst, "TM_LightBurst", "_ver", TorannMagicDefOf.TM_LightBurst.canCopy);
            this.burstCount = 2;
            if (verVal >= 1)
            {
                burstCount++;
                if (verVal >= 3)
                {
                    burstCount++;
                }
            }
            this.arcaneDmg = comp.arcaneDmg;
            if (pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_LightCapacitanceHD))
            {
                HediffComp_LightCapacitance hd = pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_LightCapacitanceHD).TryGetComp <HediffComp_LightCapacitance>();
                this.lightPotency = hd.LightPotency;
                hd.LightEnergy   -= (2.5f * this.burstCount);
            }
        }
Example #17
0
        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 void Impact(Thing hitThing)
        {
            Map map = base.Map;

            if (!this.initialized)
            {
                caster = this.launcher as Pawn;
                CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();
                verVal         = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_Custom, "TM_Explosion", "_ver", true);
                pwrVal         = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_Custom, "TM_Explosion", "_pwr", true);
                this.arcaneDmg = comp.arcaneDmg;
                this.CheckSpawnSustainer();
                this.strikePos   = base.Position;
                this.duration    = 360 - (verVal * 3);
                this.damage      = this.DamageAmount * this.arcaneDmg * (1f + (.02f * pwrVal));
                this.radius      = this.def.projectile.explosionRadius + (int)(verVal / 10);
                this.initialized = true;
                this.outerRing   = TM_Calc.GetOuterRing(this.strikePos, radius - 1, radius);
                Color color = colorInt.ToColor;
                Projectile_Explosion.MatPropertyBlock.SetColor(ShaderPropertyIDs.Color, color);
            }

            if (this.sustainer != null)
            {
                this.sustainer.info.volumeFactor = this.age / this.duration;
                this.sustainer.Maintain();
                if (this.TicksLeft <= 0)
                {
                    this.sustainer.End();
                    this.sustainer = null;
                }
            }

            //there are 6 + 3 phases to explosion (this is no simple matter)
            //phase 1 - warmup and power collection; depicted by wind drawing into a focal point
            //phase 2 - pause (for dramatic effect)
            //phase 3 - initial explosion, ie the "shockwave"
            //phase 4 - ripping winds (the debris launched by the explosion)
            //phase 5 - burning winds (heat and flame - scorched earth)
            //phase 6 - aftershock
            //training adds 3 phases
            //phase 3a - emp
            //phase 4a - secondary explosions
            //phase 5a - radiation

            //warmup 2 seconds
            if (this.age <= (int)(this.duration * .4f) && this.outerRing.Count > 0)
            {
                for (int i = 0; i < 3; i++)
                {
                    Vector3 startPos  = outerRing.RandomElement().ToVector3Shifted();
                    Vector3 direction = TM_Calc.GetVector(startPos, strikePos.ToVector3Shifted());
                    TM_MoteMaker.ThrowGenericMote(ThingDefOf.Mote_Smoke, startPos, this.Map, .8f, .3f, .05f, .6f, 0, 12f, (Quaternion.AngleAxis(90, Vector3.up) * direction).ToAngleFlat(), 0);
                }
            }
            else if (this.age <= (int)(this.duration * .6f))
            {
                //pause
            }
            else if (this.age > (int)(this.duration * .6f) && !phase3Flag)
            {
                if (!phase2Flag)
                {
                    TargetInfo ti = new TargetInfo(this.strikePos, map, false);
                    TM_MoteMaker.MakeOverlay(ti, TorannMagicDefOf.TM_Mote_PsycastAreaEffect, map, Vector3.zero, 2, 0f, .1f, .4f, 0, 15f);
                    Effecter igniteED = TorannMagicDefOf.TM_ExplosionED.Spawn();
                    igniteED.Trigger(new TargetInfo(this.strikePos, map, false), new TargetInfo(this.strikePos, map, false));
                    igniteED.Cleanup();
                    SoundInfo info = SoundInfo.InMap(new TargetInfo(this.strikePos, map, false), MaintenanceType.None);
                    info.pitchFactor  = .75f;
                    info.volumeFactor = 2.6f;
                    TorannMagicDefOf.TM_FireWooshSD.PlayOneShot(info);
                    this.phase2Flag = true;
                }
                this.expandingTick++;
                if (expandingTick <= this.radius)
                {
                    IntVec3 centerCell = base.Position;
                    if (this.expandingTick <= 1 || oldExplosionCells.Count() <= 0)
                    {
                        oldExplosionCells = GenRadial.RadialCellsAround(centerCell, expandingTick - 1, true);
                    }
                    else
                    {
                        oldExplosionCells = newExplosionCells;
                    }

                    newExplosionCells = GenRadial.RadialCellsAround(centerCell, expandingTick, true);
                    IEnumerable <IntVec3> explosionCells = newExplosionCells.Except(oldExplosionCells);
                    foreach (IntVec3 cell in explosionCells)
                    {
                        if (cell.InBounds(map))
                        {
                            Vector3 heading   = (cell - centerCell).ToVector3();
                            Vector3 direction = TM_Calc.GetVector(centerCell, cell);
                            float   angle     = (Quaternion.AngleAxis(90, Vector3.up) * direction).ToAngleFlat();
                            if (this.expandingTick >= 6 && this.expandingTick < 8)
                            {
                                TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_DirectionalDirt, cell.ToVector3Shifted(), map, .8f, .2f, .15f, .5f, 0, 7f, angle, angle);
                                TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_ExpandingFlame, cell.ToVector3Shifted(), map, 1.1f, .3f, .02f, .25f, 0, 15f, angle, angle);
                            }
                            List <Thing> hitList = cell.GetThingList(map);
                            for (int j = 0; j < hitList.Count; j++)
                            {
                                Thing      burnThing = hitList[j];
                                DamageInfo dinfo     = new DamageInfo(DamageDefOf.Flame, Mathf.RoundToInt(Rand.Range(this.damage * .25f, this.damage * .35f)), 1, -1, this.launcher, null, null, DamageInfo.SourceCategory.ThingOrUnknown);
                                burnThing.TakeDamage(dinfo);
                            }
                        }
                    }
                }
                else
                {
                    TargetInfo ti = new TargetInfo(this.strikePos, map, false);
                    TM_MoteMaker.MakeOverlay(ti, TorannMagicDefOf.TM_Mote_PsycastAreaEffect, map, Vector3.zero, 4, 0f, .1f, .4f, .5f, 2f);
                    this.expandingTick = 0;
                    this.phase3Flag    = true;
                }
            }
            else if (phase3Flag)
            {
                this.expandingTick++;
                if (expandingTick < 4)
                {
                    float energy = 80000 * this.arcaneDmg;
                    GenTemperature.PushHeat(this.strikePos, this.Map, energy);
                    GenExplosion.DoExplosion(this.strikePos, this.Map, this.radius / (4 - this.expandingTick), DamageDefOf.Bomb, this.launcher, Mathf.RoundToInt(Rand.Range(this.damage * .7f, this.damage * .9f)), 1, DamageDefOf.Bomb.soundExplosion, null, null, null, null, 0, 0, false, null, 0, 0, .4f, true);
                }
            }
            this.Destroy(DestroyMode.Vanish);
        }
Example #19
0
        public override void CompTick()
        {
            if (this.age > 0)
            {
                if (!this.initialized)
                {
                    if (summonerPawn != null)
                    {
                        CompAbilityUserMagic comp = summonerPawn.TryGetComp <CompAbilityUserMagic>();
                        if (comp != null)
                        {
                            verVal                 = TM_Calc.GetMagicSkillLevel(summonerPawn, comp.MagicData.MagicPowerSkill_GuardianSpirit, "TM_GuardianSpirit", "_ver", true);
                            pwrVal                 = TM_Calc.GetMagicSkillLevel(summonerPawn, comp.MagicData.MagicPowerSkill_GuardianSpirit, "TM_GuardianSpirit", "_pwr", true);
                            tauntRange             = 15 + pwrVal;
                            tauntTargetsMax        = 4 + pwrVal;
                            tauntChance            = .6f + (.03f * pwrVal);
                            damageMitigation       = 4 + Mathf.RoundToInt((float)pwrVal / 1.5f);
                            shadowStrikeDamage     = 11 + pwrVal;
                            shadowStrikeCritChance = .4f + (.05f * pwrVal);
                            invisDuration          = 90 + (10 * pwrVal);
                            hasteDuration          = 120 + (10 * pwrVal);
                            hexChance              = .5f + (.05f * pwrVal);
                        }
                    }
                    this.initialized = true;
                }

                if (this.Pawn.Spawned && this.Props.abilities != null)
                {
                    if (!this.Pawn.Downed && Find.TickManager.TicksGame >= this.nextEvalTick)
                    {
                        this.nextEvalTick = Find.TickManager.TicksGame + Mathf.RoundToInt(Rand.Range(.8f, 1.2f) * this.Props.abilityAttemptFrequency);
                        DetermineThreats();
                        if (closeThreats != null && closeThreats.Count >= 1)
                        {
                            if (this.Props.abilities.Contains(TorannMagicDefOf.TM_Taunt) && this.Pawn.needs?.food?.CurLevel > .06f)
                            {
                                SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None);
                                info.pitchFactor  = Rand.Range(.3f, .4f);
                                info.volumeFactor = .7f;
                                TorannMagicDefOf.TM_Roar.PlayOneShot(info);
                                Effecter RageWave = TorannMagicDefOf.TM_RageWaveED.Spawn();
                                RageWave.Trigger(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), new TargetInfo(this.Pawn.Position, this.Pawn.Map, false));
                                RageWave.Cleanup();
                                SearchAndTaunt();
                                this.Pawn.needs.food.CurLevel -= .3f;
                            }
                        }
                        if (farThreats != null && farThreats.Count >= 1 && this.Pawn.needs?.food?.CurLevel > .05f)
                        {
                            if (this.Props.abilities.Contains(TorannMagicDefOf.TM_ShadowStrike))
                            {
                                Thing target = farThreats.RandomElement();
                                if (DoMove(target))
                                {
                                    DoStrike(target);
                                    this.Pawn.needs.food.CurLevel -= .3f;
                                }
                            }
                        }
                        if (PawnThreatList != null && PawnThreatList.Count > 0 && this.Pawn.needs?.food?.CurLevel > .025f)
                        {
                            if (this.Props.abilities.Contains(TorannMagicDefOf.TM_Hex))
                            {
                                Pawn p = PawnThreatList.RandomElement();
                                if (p.health != null && p.health.hediffSet != null && !p.health.hediffSet.HasHediff(TorannMagicDefOf.TM_HexHD))
                                {
                                    if (Rand.Chance(hexChance))
                                    {
                                        HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_HexHD, 1f);
                                        CompAbilityUserMagic bondedMagicComp = this.summonerPawn.TryGetComp <CompAbilityUserMagic>();

                                        if (bondedMagicComp != null && !bondedMagicComp.HexedPawns.Contains(p) && bondedMagicComp.MagicData != null && bondedMagicComp.MagicData.MagicPowersShaman.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Hex).learned)
                                        {
                                            bool addAbilities       = false;
                                            bool shouldAddAbilities = bondedMagicComp.HexedPawns.Count <= 0;
                                            if (!bondedMagicComp.HexedPawns.Contains(p))
                                            {
                                                bondedMagicComp.HexedPawns.Add(p);
                                                addAbilities = true;
                                            }
                                            if (shouldAddAbilities && addAbilities)
                                            {
                                                bondedMagicComp.AddPawnAbility(TorannMagicDefOf.TM_Hex_CriticalFail);
                                                bondedMagicComp.AddPawnAbility(TorannMagicDefOf.TM_Hex_Pain);
                                                bondedMagicComp.AddPawnAbility(TorannMagicDefOf.TM_Hex_MentalAssault);
                                            }
                                        }
                                        TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Hex, p.DrawPos, p.Map, .6f, .1f, .2f, .2f, 0, 0, 0, 0);
                                    }
                                    this.Pawn.needs.food.CurLevel -= .1f;
                                }
                            }
                        }
                    }
                }
            }
            age++;
        }
        protected override bool TryCastShot()
        {
            Pawn    caster            = base.CasterPawn;
            Map     map               = caster.Map;
            IntVec3 cell              = currentTarget.Cell;
            CompAbilityUserMagic comp = caster.TryGetComp <CompAbilityUserMagic>();

            pwrVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_GuardianSpirit, "TM_GuardianSpirit", "_pwr", true);
            verVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_GuardianSpirit, "TM_GuardianSpirit", "_ver", true);
            effVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_GuardianSpirit, "TM_GuardianSpirit", "_eff", true);

            if (cell != null && cell.IsValid && cell.Walkable(map))
            {
                AbilityUser.SpawnThings tempPod = new SpawnThings();
                IntVec3 shiftPos = cell;

                tempPod.def = comp.GuardianSpiritType;
                if (comp.GuardianSpiritType == TorannMagicDefOf.TM_SpiritBearR)
                {
                    tempPod.kindDef = PawnKindDef.Named("TM_SpiritBear");
                }
                else if (comp.GuardianSpiritType == TorannMagicDefOf.TM_SpiritMongooseR)
                {
                    tempPod.kindDef = PawnKindDef.Named("TM_SpiritMongoose");
                }
                else
                {
                    tempPod.kindDef = PawnKindDef.Named("TM_SpiritCrow");
                }
                tempPod.spawnCount = 1;

                if (shiftPos != default(IntVec3))
                {
                    try
                    {
                        if (comp.bondedSpirit != null)
                        {
                            if (comp.bondedSpirit.Map != null)
                            {
                                MoteMaker.ThrowSmoke(comp.bondedSpirit.DrawPos, comp.bondedSpirit.Map, 1f);
                                TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Ghost, comp.bondedSpirit.DrawPos, comp.bondedSpirit.Map, 1.3f, .25f, .1f, .45f, 0, Rand.Range(1f, 2f), 0, 0);
                            }
                            comp.bondedSpirit.Destroy(DestroyMode.Vanish);
                        }
                        this.spirit = TM_Action.SingleSpawnLoop(caster, tempPod, shiftPos, map, 5, false, false, caster.Faction, false);
                        Pawn animal = this.spirit as Pawn;
                        TM_Action.TrainAnimalFull(animal, caster);
                        HealthUtility.AdjustSeverity(animal, TorannMagicDefOf.TM_SpiritBondHD, -4f);
                        HealthUtility.AdjustSeverity(animal, TorannMagicDefOf.TM_SpiritBondHD, .5f + verVal);
                        if (animal.def == TorannMagicDefOf.TM_SpiritCrowR)
                        {
                            HealthUtility.AdjustSeverity(animal, TorannMagicDefOf.TM_BirdflightHD, .5f);
                        }
                        comp.bondedSpirit = animal;
                        CompAnimalController animalComp = animal.TryGetComp <CompAnimalController>();
                        if (animalComp != null)
                        {
                            animalComp.summonerPawn = caster;
                        }
                        for (int i = 0; i < 3; i++)
                        {
                            Vector3 rndPos = this.spirit.DrawPos;
                            rndPos.x += Rand.Range(-.5f, .5f);
                            rndPos.z += Rand.Range(-.5f, .5f);
                            TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Healing_Small, rndPos, map, Rand.Range(.6f, .8f), .1f, .05f, .05f, 0, 0, 0, Rand.Range(0, 360));
                            MoteMaker.ThrowSmoke(rndPos, map, Rand.Range(.8f, 1.2f));
                        }
                    }
                    catch
                    {
                        comp.Mana.CurLevel += comp.ActualManaCost(TorannMagicDefOf.TM_GuardianSpirit);
                        Log.Message("TM_Exception".Translate(
                                        caster.LabelShort,
                                        "Guardian Spirit"
                                        ));
                    }
                }
                else
                {
                    Messages.Message("InvalidSummon".Translate(), MessageTypeDefOf.RejectInput);
                    comp.Mana.GainNeed(comp.ActualManaCost(TorannMagicDefOf.TM_GuardianSpirit));
                }
            }
            else
            {
                Messages.Message("InvalidSummon".Translate(), MessageTypeDefOf.RejectInput);
                comp.Mana.GainNeed(comp.ActualManaCost(TorannMagicDefOf.TM_GuardianSpirit));
            }
            return(false);
        }
        protected override void Impact(Thing hitThing)
        {
            base.Impact(hitThing);
            if (!this.initialized)
            {
                this.pawn        = this.launcher as Pawn;
                launcherPosition = this.Launcher.Position;
                CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
                pwrVal         = TM_Calc.GetMagicSkillLevel(this.pawn, comp.MagicData.MagicPowerSkill_LightSkip, "TM_LightSkip", "_pwr", false);
                this.arcaneDmg = comp.arcaneDmg;
                this.draftFlag = this.pawn.drafter != null ? this.pawn.Drafted : false;
                this.gi        = 0;
                podTList.Clear();
                pawnList.Clear();
                pods.Clear();
                this.initialized = true;
            }

            if (!launchedFlag)
            {
                ModOptions.Constants.SetPawnInFlight(true);
                List <Pawn> tmpList = TM_Calc.FindAllPawnsAround(this.Map, launcherPosition, 5f, this.pawn.Faction, true);
                if (tmpList != null)
                {
                    for (int i = 0; i < tmpList.Count; i++)
                    {
                        if (!tmpList[i].Position.Roofed(this.Map))
                        {
                            if (ModCheck.Validate.GiddyUp.Core_IsInitialized())
                            {
                                if (ModCheck.GiddyUp.IsMount(tmpList[i]))
                                {
                                    continue;
                                }
                            }
                            pawnList.Add(tmpList[i]);
                        }
                    }
                    unroofedCells = GetUnroofedCellsAround(base.Position, this.radius);
                    CreatePodGroup();
                    this.allPawnsLaunched = false;
                    launchedFlag          = true;
                }
                else
                {
                    this.allPawnsLaunched = true;
                    launchedFlag          = true;
                }
            }

            if (launchedFlag)
            {
                if (allPawnsLaunched)
                {
                    this.age++;
                    this.Destroy(DestroyMode.Vanish);
                }
                else if (Find.TickManager.TicksGame % 2 == 0)
                {
                    if (podTList != null && podTList.Count > 0)
                    {
                        if (gi < podTList.Count)
                        {
                            IntVec3          newPosition = GetRelativePositionOffset(base.Position, launcherPosition, pods[gi].Position);
                            GlobalTargetInfo gti         = new GlobalTargetInfo(newPosition, base.Map, false);
                            LaunchLightPod(pods[gi], podTList[gi], gti.Tile, gti.Cell);
                            gi++;
                        }
                        else
                        {
                            allPawnsLaunched = true;
                        }
                    }
                    else
                    {
                        allPawnsLaunched = true;
                    }
                }
            }
        }