Esempio n. 1
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);
        }
Esempio n. 2
0
        protected override bool TryCastShot()
        {
            Pawn pawn = base.CasterPawn;
            Map  map  = pawn.Map;

            CompAbilityUserMight comp = caster.TryGetComp <CompAbilityUserMight>();

            pwrVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_60mmMortar, "TM_60mmMortar", "_pwr", true);
            verVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_60mmMortar, "TM_60mmMortar", "_ver", true);
            effVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_60mmMortar, "TM_60mmMortar", "_eff", true);

            if ((pawn.Position.IsValid && pawn.Position.Standable(map)))
            {
                AbilityUser.SpawnThings tempPod = new SpawnThings();
                IntVec3 shiftPos = TM_Calc.GetEmptyCellForNewBuilding(pawn.Position, map, 1.6f, false, 0);

                tempPod.def        = TorannMagicDefOf.TM_60mmMortar_Base;
                tempPod.spawnCount = 1;

                if (shiftPos != default(IntVec3))
                {
                    try
                    {
                        this.mortar = TM_Action.SingleSpawnLoop(pawn, tempPod, shiftPos, map, 1200, true, false, pawn.Faction);

                        for (int i = 0; i < 3; i++)
                        {
                            Vector3 rndPos = this.mortar.DrawPos;
                            rndPos.x += Rand.Range(-.5f, .5f);
                            rndPos.z += Rand.Range(-.5f, .5f);
                            TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_SparkFlash"), 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.Stamina.CurLevel += comp.ActualStaminaCost(TorannMagicDefOf.TM_60mmMortar);
                        Log.Message("TM_Exception".Translate(
                                        pawn.LabelShort,
                                        "60mm Mortar"
                                        ));
                    }
                }
                else
                {
                    Messages.Message("InvalidSummon".Translate(), MessageTypeDefOf.RejectInput);
                    comp.Stamina.GainNeed(comp.ActualStaminaCost(TorannMagicDefOf.TM_60mmMortar));
                }
            }
            else
            {
                Messages.Message("InvalidSummon".Translate(), MessageTypeDefOf.RejectInput);
                comp.Stamina.GainNeed(comp.ActualStaminaCost(TorannMagicDefOf.TM_60mmMortar));
            }


            if ((mortar != null && mortar.Spawned && mortar.Position.IsValid))
            {
                this.Ability.PostAbilityAttempt();
                mortar.def.interactionCellOffset = (caster.Position - mortar.Position);
                Job job = new Job(JobDefOf.ManTurret, mortar);
                pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                //this.Ability.PostAbilityAttempt();
            }
            else
            {
                Log.Message("mortar was null");
            }

            return(false);
        }