private void DoKnockbackAttack(IntVec3 target, float radius)
        {
            int         pwrVal     = 3;
            int         verVal     = 3;
            List <Pawn> TargetsAoE = TM_Calc.FindPawnsNearTarget(this.Pawn, 5, target, true);

            if (TargetsAoE != null && TargetsAoE.Count > 0)
            {
                for (int i = 0; i < TargetsAoE.Count; i++)
                {
                    Pawn victim = TargetsAoE[i];
                    if (!victim.RaceProps.IsMechanoid)
                    {
                        if (Rand.Chance(TM_Calc.GetSpellSuccessChance(this.Pawn, victim, true)))
                        {
                            HealthUtility.AdjustSeverity(victim, HediffDef.Named("TM_DeathMarkCurse"), (Rand.Range(1f + pwrVal, 4 + 2 * pwrVal)));
                            TM_MoteMaker.ThrowSiphonMote(victim.DrawPos, victim.Map, 1f);

                            if (Rand.Chance(verVal * .2f))
                            {
                                if (Rand.Chance(verVal * .1f)) //terror
                                {
                                    HealthUtility.AdjustSeverity(victim, HediffDef.Named("TM_Terror"), Rand.Range(3f * verVal, 5f * verVal));
                                    TM_MoteMaker.ThrowDiseaseMote(victim.DrawPos, victim.Map, 1f, .5f, .2f, .4f);
                                    MoteMaker.ThrowText(victim.DrawPos, victim.Map, "Terror", -1);
                                }
                                if (Rand.Chance(verVal * .1f)) //berserk
                                {
                                    if (victim.mindState != null && victim.RaceProps != null && victim.RaceProps.Humanlike)
                                    {
                                        victim.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk, "cursed", true, false, null);
                                        FleckMaker.ThrowMicroSparks(victim.DrawPos, victim.Map);
                                        MoteMaker.ThrowText(victim.DrawPos, victim.Map, "Berserk", -1);
                                    }
                                }
                            }
                        }
                        else
                        {
                            MoteMaker.ThrowText(victim.DrawPos, victim.Map, "TM_ResistedSpell".Translate(), -1);
                        }
                    }
                }
            }
            this.shouldDoKnockBackAttack = false;
        }
        public void DoStrike(Thing target)
        {
            if (target != null && target is Pawn)
            {
                Pawn t = target as Pawn;
                if (t.Faction == null || (t.Faction != null && t.Faction != caster.Faction))
                {
                    //List<BodyPartRecord> partList = new List<BodyPartRecord>();
                    //partList.Clear();
                    //for (int i = 0; i < t.RaceProps.body.AllParts.Count; i++)
                    //{
                    //    BodyPartRecord part = t.RaceProps.body.AllParts[i];
                    //    if (part.depth == BodyPartDepth.Outside)
                    //    {
                    //        partList.Add(part);
                    //    }
                    //}
                    for (int i = 0; i < 4; i++)
                    {
                        if (!t.DestroyedOrNull() && !t.Dead && t.Map != null)
                        {
                            int dmg = Mathf.RoundToInt(this.weaponDamage);
                            if (Rand.Chance(critChance))
                            {
                                dmg *= 3;
                            }
                            BodyPartRecord bpr = t.health.hediffSet.GetRandomNotMissingPart(DamageDefOf.Stab, BodyPartHeight.Undefined, BodyPartDepth.Outside);
                            TM_Action.DamageEntities(target, bpr, dmg, Rand.Range(0f, .5f), DamageDefOf.Stab, this.caster);
                            Vector3 rndPos = t.DrawPos;
                            rndPos.x += Rand.Range(-.2f, .2f);
                            rndPos.z += Rand.Range(-.2f, .2f);
                            TM_MoteMaker.ThrowBloodSquirt(rndPos, t.Map, Rand.Range(.6f, 1f));
                            TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_CrossStrike, rndPos, t.Map, Rand.Range(.6f, 1f), .4f, 0f, Rand.Range(.2f, .5f), 0, 0, 0, Rand.Range(0, 360));
                        }
                    }
                    if (!t.DestroyedOrNull() && !t.Dead && !t.Downed && caster.IsColonist)
                    {
                        caster.drafter.Drafted = true;
                        Job job = new Job(JobDefOf.AttackMelee, t);
                        caster.jobs.TryTakeOrderedJob(job, JobTag.DraftedOrder);
                    }
                }
            }
            if (verVal >= 1)
            {
                int invisDuration = 120;
                if (verVal >= 2)
                {
                    invisDuration = 180;
                }
                HealthUtility.AdjustSeverity(caster, TorannMagicDefOf.TM_ShadowCloakHD, .2f);

                HediffComp_Disappears hdComp = caster.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ShadowCloakHD).TryGetComp <HediffComp_Disappears>();
                if (hdComp != null)
                {
                    hdComp.ticksToDisappear = invisDuration;
                }
            }
            if (verVal >= 3)
            {
                int radius = 2;
                if (verVal >= 5)
                {
                    radius = 3;
                }
                float sev = 1.5f;
                if (verVal >= 4)
                {
                    sev = 2.2f;
                }
                List <Pawn> targetList = TM_Calc.FindPawnsNearTarget(caster, radius, caster.Position, true);
                if (targetList != null && targetList.Count > 0)
                {
                    for (int i = 0; i < targetList.Count; i++)
                    {
                        if (targetList[i].RaceProps.IsFlesh)
                        {
                            HealthUtility.AdjustSeverity(targetList[i], TorannMagicDefOf.TM_NightshadeToxinHD, Rand.Range(.7f * sev, 1.3f * sev));
                        }
                    }
                }
                ThingDef fog = TorannMagicDefOf.Fog_Shadows;
                fog.gas.expireSeconds.min = 2;
                fog.gas.expireSeconds.max = 3;
                GenExplosion.DoExplosion(caster.Position, caster.Map, radius, TMDamageDefOf.DamageDefOf.TM_Toxin, caster, 0, 0, TMDamageDefOf.DamageDefOf.TM_Toxin.soundExplosion, null, null, null, fog, 1f, 1, false, null, 0f, 0, 0.0f, false);

                for (int i = 0; i < 6; i++)
                {
                    Vector3 rndPos = caster.DrawPos;
                    rndPos.x += Rand.Range(-.5f, .5f);
                    rndPos.z += Rand.Range(-.5f, .5f);
                    TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_ShadowCloud, rndPos, caster.Map, Rand.Range(.6f, 1f), .4f, .05f, Rand.Range(.2f, .5f), Rand.Range(-40, 40), Rand.Range(1, 2f), Rand.Range(0, 360), Rand.Range(0, 360));
                }
            }
            ApplyHaste(caster);
        }
Exemple #3
0
        protected override bool TryCastShot()
        {
            bool result = false;
            bool arg_40_0;

            if (this.currentTarget != null && base.CasterPawn != null)
            {
                IntVec3 arg_29_0 = this.currentTarget.Cell;
                Vector3 vector   = this.currentTarget.CenterVector3;
                arg_40_0 = this.currentTarget.Cell.IsValid;
                arg_41_0 = vector.InBounds(base.CasterPawn.Map);
                arg_42_0 = true; // vector.ToIntVec3().Standable(base.CasterPawn.Map);
            }
            else
            {
                arg_40_0 = false;
            }
            bool flag  = arg_40_0;
            bool flag2 = arg_41_0;
            bool flag3 = arg_42_0;

            if (flag)
            {
                if (flag2 & flag3)
                {
                    Pawn    p         = this.CasterPawn;
                    Map     map       = this.CasterPawn.Map;
                    IntVec3 cell      = this.CasterPawn.Position;
                    bool    draftFlag = this.CasterPawn.Drafted;
                    try
                    {
                        if (this.CasterPawn.IsColonist)
                        {
                            ModOptions.Constants.SetPawnInFlight(true);
                            ThingSelectionUtility.SelectNextColonist();
                            this.CasterPawn.DeSpawn();
                            //p.SetPositionDirect(this.currentTarget.Cell);
                            GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                            p.drafter.Drafted = draftFlag;
                            if (base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_ver").level >= 1)
                            {
                                List <Pawn> eList = TM_Calc.FindPawnsNearTarget(p, 2, this.currentTarget.Cell, true);
                                if (eList != null && eList.Count > 0)
                                {
                                    for (int i = 0; i < eList.Count; i++)
                                    {
                                        Pawn e = eList[i];
                                        TM_Action.DamageEntities(e, null, 5f, DamageDefOf.Stun, p);
                                    }
                                }
                            }
                            CameraJumper.TryJumpAndSelect(p);
                            ModOptions.Constants.SetPawnInFlight(false);
                        }
                        else
                        {
                            ModOptions.Constants.SetPawnInFlight(true);
                            this.CasterPawn.DeSpawn();
                            GenSpawn.Spawn(p, this.currentTarget.Cell, map);
                            ModOptions.Constants.SetPawnInFlight(false);
                        }
                    }
                    catch
                    {
                        if (!this.CasterPawn.Spawned)
                        {
                            GenSpawn.Spawn(p, cell, map);
                            Log.Message("Exception occured when trying to blink - recovered pawn at position ability was used from.");
                        }
                    }
                    //this.Ability.PostAbilityAttempt();
                    //this.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                    //base.CasterPawn.SetPositionDirect(this.currentTarget.Cell);
                    //this.CasterPawn.pather.ResetToCurrentPosition();
                    result = true;
                }
                else
                {
                    Messages.Message("InvalidTargetLocation".Translate(), MessageTypeDefOf.RejectInput);
                }
            }
            else
            {
                Log.Warning("failed to TryCastShot");
            }
            this.burstShotsLeft = 0;
            //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60;
            return(result);
        }