Exemplo n.º 1
0
        public void CreateLightBurst(IntVec3 center, Map map, float radius)
        {
            GenClamor.DoClamor(this.CasterPawn, 2 * radius, ClamorDefOf.Ability);
            Effecter flashED = TorannMagicDefOf.TM_LightBurstED.Spawn();

            flashED.Trigger(new TargetInfo(center, map, false), new TargetInfo(center, map, false));
            flashED.Cleanup();
            TargetInfo ti = new TargetInfo(center, map, false);

            TM_MoteMaker.MakeOverlay(ti, TorannMagicDefOf.TM_Mote_PsycastAreaEffect, map, Vector3.zero, .1f, 0f, .05f, .1f, .1f, 4.3f);
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        protected override bool TryCastShot()
        {
            Pawn p   = this.CasterPawn;
            Map  map = this.CasterPawn.Map;
            CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>();

            pawns.Clear();
            plants.Clear();
            GenClamor.DoClamor(p, this.UseAbilityProps.TargetAoEProperties.range, ClamorDefOf.Ability);
            Effecter snapeFreezeED = TorannMagicDefOf.TM_SnapFreezeED.Spawn();

            snapeFreezeED.Trigger(new TargetInfo(this.currentTarget.Cell, map, false), new TargetInfo(this.currentTarget.Cell, map, false));
            snapeFreezeED.Cleanup();
            SoundInfo info = SoundInfo.InMap(new TargetInfo(this.currentTarget.Cell, map, false), MaintenanceType.None);

            info.pitchFactor  = .4f;
            info.volumeFactor = 1.2f;
            TorannMagicDefOf.TM_WindLowSD.PlayOneShot(info);
            TargetInfo ti = new TargetInfo(this.currentTarget.Cell, map, false);

            TM_MoteMaker.MakeOverlay(ti, TorannMagicDefOf.TM_Mote_PsycastAreaEffect, map, Vector3.zero, 3f, 0f, .1f, .4f, 1.2f, -3f);
            float classBonus = 1f;

            if (p.story != null && p.story.traits != null && p.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost))
            {
                classBonus = 1.5f;
            }
            if (this.currentTarget != null && p != null && comp != null)
            {
                this.arcaneDmg = comp.arcaneDmg;
                this.TargetsAoE.Clear();
                this.FindTargets();
                float energy = -125000 * this.arcaneDmg * classBonus;
                GenTemperature.PushHeat(this.currentTarget.Cell, p.Map, energy);
                for (int i = 0; i < pawns.Count; i++)
                {
                    if (!pawns[i].RaceProps.IsMechanoid && pawns[i].RaceProps.body.AllPartsVulnerableToFrostbite.Count > 0)
                    {
                        float distanceModifier = 1f / (pawns[i].Position - currentTarget.Cell).LengthHorizontal;
                        if (distanceModifier > 1f)
                        {
                            distanceModifier = 1f;
                        }
                        int bites = Mathf.RoundToInt(Rand.Range(1f, 5f) * classBonus);
                        for (int j = 0; j < bites; j++)
                        {
                            if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, pawns[i], true)) && Rand.Chance(distanceModifier))
                            {
                                TM_Action.DamageEntities(pawns[i], pawns[i].def.race.body.AllPartsVulnerableToFrostbite.RandomElement(), Rand.Range(10, 20) * distanceModifier, 1f, DamageDefOf.Frostbite, p);
                            }
                            if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, pawns[i], true)) && Rand.Chance(distanceModifier))
                            {
                                HealthUtility.AdjustSeverity(pawns[i], HediffDefOf.Hypothermia, distanceModifier / 5f);
                            }
                        }
                    }
                }
                for (int i = 0; i < plants.Count; i++)
                {
                    float distanceModifier = 1f / (plants[i].Position - currentTarget.Cell).LengthHorizontal;
                    if (distanceModifier > 1f)
                    {
                        distanceModifier = 1f;
                    }
                    if (plants[i].def.plant.IsTree)
                    {
                        if (Rand.Chance(distanceModifier / 2f))
                        {
                            plants[i].MakeLeafless(Plant.LeaflessCause.Cold);
                        }
                    }
                    else
                    {
                        if (Rand.Chance(distanceModifier))
                        {
                            plants[i].MakeLeafless(Plant.LeaflessCause.Cold);
                        }
                    }
                    plants[i].Notify_ColorChanged();
                }
                List <IntVec3> cellList = GenRadial.RadialCellsAround(this.currentTarget.Cell, this.UseAbilityProps.TargetAoEProperties.range, true).ToList();
                bool           raining  = map.weatherManager.RainRate > 0f || map.weatherManager.SnowRate > 0f;
                for (int i = 0; i < cellList.Count; i++)
                {
                    cellList[i] = cellList[i].ClampInsideMap(map);
                    SnowUtility.AddSnowRadial(cellList[i], map, 2.4f, Rand.Range(.08f, .13f));
                    TM_FleckMaker.ThrowGenericFleck(FleckDefOf.AirPuff, cellList[i].ToVector3Shifted(), map, 2.5f, .05f, .05f, Rand.Range(2f, 3f), Rand.Range(-60, 60), .5f, -70, Rand.Range(0, 360));
                }
                List <IntVec3> windList = GenRadial.RadialCellsAround(this.currentTarget.Cell, this.UseAbilityProps.TargetAoEProperties.range + 1, true).Except(cellList).ToList();
                for (int i = 0; i < windList.Count; i++)
                {
                    windList[i] = windList[i].ClampInsideMap(map);
                    Vector3 angle = TM_Calc.GetVector(windList[i], this.currentTarget.Cell);
                    TM_FleckMaker.ThrowGenericFleck(FleckDefOf.AirPuff, windList[i].ToVector3Shifted(), map, Rand.Range(1.2f, 2f), .45f, Rand.Range(0f, .25f), .5f, -200, Rand.Range(3, 5), (Quaternion.AngleAxis(90, Vector3.up) * angle).ToAngleFlat(), Rand.Range(0, 360));
                }
            }

            this.burstShotsLeft = 0;
            return(true);
        }
Exemplo n.º 4
0
        protected override bool TryCastShot()
        {
            Pawn p   = this.CasterPawn;
            Map  map = this.CasterPawn.Map;
            CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>();

            corpses.Clear();
            pawns.Clear();
            plants.Clear();
            GenClamor.DoClamor(p, this.UseAbilityProps.TargetAoEProperties.range, ClamorDefOf.Ability);
            Effecter igniteED = TorannMagicDefOf.TM_IgniteED.Spawn();

            igniteED.Trigger(new TargetInfo(this.currentTarget.Cell, map, false), new TargetInfo(this.currentTarget.Cell, map, false));
            igniteED.Cleanup();
            SoundInfo info = SoundInfo.InMap(new TargetInfo(this.currentTarget.Cell, map, false), MaintenanceType.None);

            info.pitchFactor  = 1.1f;
            info.volumeFactor = 1.8f;
            TorannMagicDefOf.TM_FireWooshSD.PlayOneShot(info);
            TargetInfo ti = new TargetInfo(this.currentTarget.Cell, map, false);

            TM_MoteMaker.MakeOverlay(ti, TorannMagicDefOf.TM_Mote_PsycastAreaEffect, map, Vector3.zero, .2f, 0f, .1f, .4f, .4f, 4.3f);
            float classBonus = 1f;

            if (p.story != null && p.story.traits != null && p.story.traits.HasTrait(TorannMagicDefOf.InnerFire))
            {
                classBonus = 1.5f;
            }
            if (this.currentTarget != null && p != null && comp != null)
            {
                this.arcaneDmg = comp.arcaneDmg;
                this.TargetsAoE.Clear();
                this.FindTargets();
                float energy = 200000 * this.arcaneDmg * classBonus;
                GenTemperature.PushHeat(this.currentTarget.Cell, p.Map, energy);
                for (int i = 0; i < pawns.Count; i++)
                {
                    if (!pawns[i].RaceProps.IsMechanoid)
                    {
                        float distanceModifier = classBonus / (pawns[i].Position - currentTarget.Cell).LengthHorizontal;
                        if (distanceModifier > 1f)
                        {
                            distanceModifier = 1f;
                        }
                        if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, pawns[i], true)) && Rand.Chance(distanceModifier))
                        {
                            pawns[i].TryAttachFire(Rand.Range(distanceModifier / 2f, distanceModifier));
                        }
                    }
                }
                for (int i = 0; i < corpses.Count; i++)
                {
                    //if (corpses[i].CanEverAttachFire())
                    //{
                    float distanceModifier = 1f / (corpses[i].Position - currentTarget.Cell).LengthHorizontal;
                    //    corpses[i].TryAttachFire(Rand.Range(distanceModifier / 2f, distanceModifier));
                    FireUtility.TryStartFireIn(corpses[i].Position, map, Rand.Range(distanceModifier / 2f, distanceModifier));
                    //}
                }
                for (int i = 0; i < plants.Count; i++)
                {
                    float distanceModifier = 1f / (plants[i].Position - currentTarget.Cell).LengthHorizontal;
                    if (distanceModifier > 1f)
                    {
                        distanceModifier = 1f;
                    }
                    if (plants[i].def.plant.IsTree)
                    {
                        if (Rand.Chance(distanceModifier / 2f))
                        {
                            plants[i].TryAttachFire(Rand.Range(distanceModifier / 3f, distanceModifier / 2f));
                            FireUtility.TryStartFireIn(plants[i].Position, map, Rand.Range(distanceModifier / 3f, distanceModifier / 2f));
                        }
                    }
                    else
                    {
                        if (Rand.Chance(distanceModifier))
                        {
                            plants[i].TryAttachFire(Rand.Range(distanceModifier / 2f, distanceModifier));
                            FireUtility.TryStartFireIn(plants[i].Position, map, Rand.Range(distanceModifier / 2f, distanceModifier));
                        }
                    }
                }
                IEnumerable <IntVec3> cellList = GenRadial.RadialCellsAround(this.currentTarget.Cell, this.UseAbilityProps.TargetAoEProperties.range, true);
                bool raining = map.weatherManager.RainRate > 0f || map.weatherManager.SnowRate > 0f;
                foreach (var cell in cellList)
                {
                    cell.ClampInsideMap(map);
                    if (cell.GetSnowDepth(map) > 0f)
                    {
                        map.snowGrid.SetDepth(cell, 0f);
                        MoteMaker.ThrowSmoke(cell.ToVector3Shifted(), map, Rand.Range(.8f, 1.6f));
                        Thing smoke = ThingMaker.MakeThing(ThingDefOf.Gas_Smoke, null);
                        GenSpawn.Spawn(smoke, cell, map, WipeMode.Vanish);
                    }
                    else if (raining || cell.GetTerrain(map).IsWater)
                    {
                        Thing smoke = ThingMaker.MakeThing(ThingDefOf.Gas_Smoke, null);
                        GenSpawn.Spawn(smoke, cell, map, WipeMode.Vanish);
                    }
                    TM_MoteMaker.ThrowGenericMote(ThingDefOf.Mote_AirPuff, cell.ToVector3Shifted(), map, 2.5f, .05f, .05f, Rand.Range(2f, 3f), Rand.Range(-60, 60), .5f, -70, Rand.Range(0, 360));
                }
            }

            this.burstShotsLeft = 0;
            return(true);
        }
        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);
        }