Exemplo n.º 1
0
        public override void PostPreApplyDamage(DamageInfo dinfo, out bool absorbed)
        {
            bool flag = dinfo.Weapon != null;

            if (flag)
            {
                bool flag2 = !dinfo.Weapon.IsMeleeWeapon && dinfo.WeaponBodyPartGroup == null && GetPawn != null;
                if (flag2)
                {
                    bool hasCompActivatableEffect = this.HasCompActivatableEffect;
                    if (hasCompActivatableEffect)
                    {
                        bool?flag3 = new bool?((bool)AccessTools.Method(this.GetActivatableEffect.GetType(), "IsActive", null, null).Invoke(this.GetActivatableEffect, null));
                        bool flag4 = flag3 == false;
                        if (flag4)
                        {
                            absorbed = false;
                            return;
                        }
                    }
                    float deflectionChance      = this.DeflectionChance;
                    CompAbilityUserMagic holder = GetPawn.GetComp <CompAbilityUserMagic>();
                    if (holder != null && !holder.IsMagicUser)
                    {
                        deflectionChance = 0;
                    }
                    int  num   = (int)(deflectionChance * 100f);
                    bool flag5 = Rand.Range(1, 100) > num;
                    if (flag5)
                    {
                        absorbed = false;
                        this.lastShotReflected = false;
                        return;
                    }
                    //splicing in TM handling of reflection
                    Thing   instigator = dinfo.Instigator;
                    Vector3 drawPos    = this.GetPawn.DrawPos;
                    drawPos.x += ((instigator.DrawPos.x - drawPos.x) / 20f) + Rand.Range(-.2f, .2f);
                    drawPos.z += ((instigator.DrawPos.z - drawPos.z) / 20f) + Rand.Range(-.2f, .2f);
                    TM_MoteMaker.ThrowSparkFlashMote(drawPos, this.GetPawn.Map, 2f);
                    Thing thing = new Thing();
                    thing.def = dinfo.Weapon;
                    if (instigator is Pawn)
                    {
                        Pawn shooterPawn = instigator as Pawn;
                        if (!dinfo.Weapon.IsMeleeWeapon && dinfo.WeaponBodyPartGroup == null)
                        {
                            TM_CopyAndLaunchProjectile.CopyAndLaunchThing(shooterPawn.equipment.PrimaryEq.PrimaryVerb.verbProps.defaultProjectile, this.GetPawn, instigator, shooterPawn, ProjectileHitFlags.IntendedTarget, null);
                        }
                    }
                    //no longer using comp deflector handling
                    //this.ResolveDeflectVerb();
                    //this.GiveDeflectJob(dinfo);
                    dinfo.SetAmount(0);
                    absorbed = true; // true;
                    return;
                }
            }
            absorbed = false;
        }
 public override bool CanActivate()
 {
     //    Log.Message(string.Format("{0} CanActivate IsFighting: {1}, lastGivenWorkType: {2}, alwaysShowWeapon: {3}", GetPawn.LabelShortCap, GetPawn.IsFighting(), GetPawn.mindState.lastGivenWorkType, GetPawn.CurJobDef.alwaysShowWeapon));
     if (GetPawn is Pawn p && p.Spawned && p.Map != null)
     {
         return(base.CanActivate() && (GetPawn.isPsyker() || !specialRules.ForceEffectRequiresPsyker));
     }
     return(false);
 }
Exemplo n.º 3
0
 public virtual void CriticalFailureHandler(DamageInfo dinfo, Pawn newTarget, out bool shouldContinue)
 {
     shouldContinue = true;
     if (lastAccuracyRoll == AccuracyRoll.CritialFailure)
     {
         Pawn thisPawn = this.GetPawn;
         if (thisPawn != null && !thisPawn.Dead)
         {
             //If the target isn't the old target, then get out of this
             if (newTarget != dinfo.Instigator as Pawn)
             {
                 return;
             }
             shouldContinue = false;
             GetPawn.TakeDamage(new DamageInfo(dinfo.Def, dinfo.Amount));
         }
     }
 }
Exemplo n.º 4
0
        public override void PostPreApplyDamage(DamageInfo dinfo, out bool absorbed)
        {
            bool flag = dinfo.Weapon != null;

            if (flag)
            {
                bool flag2 = !dinfo.Weapon.IsMeleeWeapon && dinfo.WeaponBodyPartGroup == null;
                if (flag2)
                {
                    bool hasCompActivatableEffect = this.HasCompActivatableEffect;
                    if (hasCompActivatableEffect)
                    {
                        bool?flag3 = new bool?((bool)AccessTools.Method(this.GetActivatableEffect.GetType(), "IsActive", null, null).Invoke(this.GetActivatableEffect, null));
                        bool flag4 = flag3 == false;
                        if (flag4)
                        {
                            absorbed = false;
                            return;
                        }
                    }
                    float deflectionChance      = this.DeflectionChance;
                    CompAbilityUserMagic holder = GetPawn.GetComp <CompAbilityUserMagic>();
                    if (!holder.IsMagicUser)
                    {
                        deflectionChance = 0;
                    }
                    int  num   = (int)(deflectionChance * 100f);
                    bool flag5 = Rand.Range(1, 100) > num;
                    if (flag5)
                    {
                        absorbed = false;
                        this.lastShotReflected = false;
                        return;
                    }
                    this.ResolveDeflectVerb();
                    this.GiveDeflectJob(dinfo);
                    absorbed = false; // true;
                    return;
                }
            }
            absorbed = false;
        }
Exemplo n.º 5
0
        public override Verb ReflectionHandler(Verb newVerb)
        {
            CompAbilityUserMagic holder = GetPawn.GetComp <CompAbilityUserMagic>();
            bool canReflect             = this.Props.canReflect && holder.IsMagicUser;
            Verb result;

            if (canReflect)
            {
                this.lastAccuracyRoll = this.ReflectionAccuracy();
                VerbProperties verbProperties = new VerbProperties
                {
                    hasStandardCommand = newVerb.verbProps.hasStandardCommand,
                    defaultProjectile  = newVerb.verbProps.defaultProjectile,
                    range               = newVerb.verbProps.range,
                    muzzleFlashScale    = newVerb.verbProps.muzzleFlashScale,
                    warmupTime          = 0f,
                    defaultCooldownTime = 0f,
                    soundCast           = this.Props.deflectSound
                };
                switch (this.lastAccuracyRoll)
                {
                case CompDeflector.CompDeflector.AccuracyRoll.CritialFailure:
                {
                    verbProperties.accuracyLong   = 999f;
                    verbProperties.accuracyMedium = 999f;
                    verbProperties.accuracyShort  = 999f;
                    this.lastShotReflected        = true;
                    break;
                }

                case CompDeflector.CompDeflector.AccuracyRoll.Failure:
                    verbProperties.forcedMissRadius = 50f;
                    verbProperties.accuracyLong     = 0f;
                    verbProperties.accuracyMedium   = 0f;
                    verbProperties.accuracyShort    = 0f;
                    this.lastShotReflected          = false;
                    break;

                case CompDeflector.CompDeflector.AccuracyRoll.Success:
                    verbProperties.accuracyLong   = 999f;
                    verbProperties.accuracyMedium = 999f;
                    verbProperties.accuracyShort  = 999f;
                    this.lastShotReflected        = true;
                    break;

                case CompDeflector.CompDeflector.AccuracyRoll.CriticalSuccess:
                {
                    verbProperties.accuracyLong   = 999f;
                    verbProperties.accuracyMedium = 999f;
                    verbProperties.accuracyShort  = 999f;
                    this.lastShotReflected        = true;
                    break;
                }
                }
                newVerb.verbProps = verbProperties;
                result            = newVerb;
            }
            else
            {
                result = newVerb;
            }
            return(result);
            //return base.ReflectionHandler(newVerb);
        }
Exemplo n.º 6
0
        public void ConsumeStolenAura()
        {
            Hediff hediff = GetPawn.health.hediffSet.hediffs.Find(h => h.def == RWBYDefOf.RWBY_AuraStolen);

            if (hediff != null)
            {
                GetPawn.health.RemoveHediff(hediff);
            }
            if (stolenTraitDef != null && GetPawn.TryGetComp <CompAbilityUserAura>() is CompAbilityUserAura compAbilityUserAura)
            {
                if (compAbilityUserAura.IsInitialized && GetPawn.story.traits.allTraits.Any(t => SemblanceUtility.semblanceList.Contains(t.def))) // if pawn has Semblance
                {
                    compAbilityUserAura.aura.maxEnergy += 0.5f;
                    // Aura specific: Yang, Blake, Raven, Adam
                    // no active abilities: Nora, Qrow, Velvet
                    if (stolenTraitDef == RWBYDefOf.Semblance_Ruby)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Ruby_BurstIntoRosePetals))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Ruby_BurstIntoRosePetals);
                        }
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Ruby_CarryPawn))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Ruby_CarryPawn);
                        }
                    }
                    else if (stolenTraitDef == RWBYDefOf.Semblance_Weiss)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Weiss_TimeDilationGlyph_Summon))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_TimeDilationGlyph_Summon);
                        }
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Weiss_SummonArmaGigas))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonArmaGigas);
                        }
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Weiss_SummonArmaGigasSword))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Weiss_SummonArmaGigasSword);
                        }
                    }
                    else if (stolenTraitDef == RWBYDefOf.Semblance_Jaune)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Jaune_AmplifyAura))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Jaune_AmplifyAura);
                        }
                    }
                    else if (stolenTraitDef == RWBYDefOf.Semblance_Pyrrha)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Pyrrha_UnlockAura))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Pyrrha_UnlockAura);
                        }
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Pyrrha_UseMagnetism))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Pyrrha_UseMagnetism);
                        }
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Pyrrha_MagneticPulse))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Pyrrha_MagneticPulse);
                        }
                    }
                    else if (stolenTraitDef == RWBYDefOf.Semblance_Ren)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Ren_MaskEmotions))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Ren_MaskEmotions);
                        }
                    }
                    else if (stolenTraitDef == RWBYDefOf.Semblance_Cinder)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Cinder_ShootFireCrystal))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Cinder_ShootFireCrystal);
                        }
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Cinder_SummonExplosives))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Cinder_SummonExplosives);
                        }
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Cinder_CreateBlades))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Cinder_CreateBlades);
                        }
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Cinder_CreateBow))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Cinder_CreateBow);
                        }
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Cinder_CreateScimitar))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Cinder_CreateScimitar);
                        }
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Cinder_CreateSpear))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Cinder_CreateSpear);
                        }
                    }
                    else if (stolenTraitDef == RWBYDefOf.Semblance_Hazel)
                    {
                        if (!compAbilityUserAura.AbilityData.AllPowers.Any(a => a.Def == RWBYDefOf.Hazel_IgnorePain))
                        {
                            compAbilityUserAura.AddPawnAbility(RWBYDefOf.Hazel_IgnorePain);
                        }
                    }
                    RWBYDefOf.AuraFlicker.PlayOneShot(new TargetInfo(GetPawn.Position, GetPawn.Map, false));
                }
                else
                {
                    GetPawn.story.traits.allTraits.RemoveAll(t => t.def.Equals(RWBYDefOf.RWBY_Aura));
                    GetPawn.story.traits.GainTrait(new Trait(stolenTraitDef));
                    GetPawn.TryGetComp <CompAbilityUserAura>().Initialize();
                    RWBYDefOf.AuraBreak.PlayOneShot(new TargetInfo(GetPawn.Position, GetPawn.Map, false));
                }
                parent.Destroy();
            }
        }