Example #1
0
 protected override bool TryCastShot()
 {
     if (burstShotsLeft > 1)
     {
         RatkinSoundDefOf.RK_Charge.PlayOneShot(new TargetInfo(caster.Position, caster.Map, false));
         if (verbProps.consumeFuelPerShot > 0f)
         {
             CompRefuelable compGunlance = EquipmentSource.TryGetComp <CompGunlanceFuel>();
             if (compGunlance != null)
             {
                 compGunlance.ConsumeFuel(verbProps.consumeFuelPerShot);
             }
         }
         AttachableThing_GunlanceIgnition ignition = ThingMaker.MakeThing(GunlanceDefOf.GunlancePreIgnition, null) as AttachableThing_GunlanceIgnition;
         ignition.AttachTo(CasterPawn);
         GenSpawn.Spawn(ignition, CasterPawn.Position, CasterPawn.Map, caster.Rotation, WipeMode.Vanish, false);
     }
     else
     {
         CasterPawn.GetAttachment(GunlanceDefOf.GunlancePreIgnition).Destroy();
         AttachableThing_AfterIgnition ignition = ThingMaker.MakeThing(GunlanceDefOf.GunlanceAfterIgnition, null) as AttachableThing_AfterIgnition;
         ignition.AttachTo(CasterPawn);
         GenSpawn.Spawn(ignition, CasterPawn.Position, CasterPawn.Map, caster.Rotation, WipeMode.Vanish, false);
         RatkinSoundDefOf.RK_WyvernFire.PlayOneShot(new TargetInfo(caster.Position, caster.Map, false));
         MakeExplosion();
     }
     return(true);
 }
        public virtual void Effect()
        {
            try
            {
                var comp = CasterPawn.GetComp <CompWizardry>();
                comp.SecondTarget = null;

                var t          = currentTarget;
                var targetCell = t.Cell;

                launchableThing = t.Cell.GetFirstPawn(CasterPawn.Map);

                if (launchableThing == null)
                {
                    var cellThings = t.Cell.GetThingList(CasterPawn.Map);
                    for (var i = 0; i < cellThings.Count; i++)
                    {
                        if (!cellThings[i].def.EverHaulable)
                        {
                            continue;
                        }

                        launchableThing = cellThings[i];
                        i = cellThings.Count;
                    }
                }

                if (launchableThing == null)
                {
                    return;
                }

                if (targetCell.InBounds(base.CasterPawn.Map) && targetCell.IsValid)
                {
                    LongEventHandler.QueueLongEvent(delegate
                    {
                        var flyingObject = (Manwe_FlyingObject_WindControl)GenSpawn.Spawn(
                            ThingDef.Named("FlyingObject_WindControl"), currentTarget.Cell, CasterPawn.Map);
                        flyingObject.Launch(CasterPawn, t.Cell, launchableThing);
                    }, "LaunchingFlyer", false, null);
                }
                else
                {
                    Log.Message("invalid map or cell");
                }

                Find.Targeter.StopTargeting();
                BeginTargetingWithVerb(WizardryDefOf.CompVerb, WizardryDefOf.CompVerb.MainVerb.targetParams,
                                       delegate(LocalTargetInfo info)
                {
                    action            = info;
                    comp              = CasterPawn.GetComp <CompWizardry>();
                    comp.SecondTarget = info;
                }, CasterPawn);
            }
            catch (NullReferenceException ex)
            {
                Log.Message(ex.ToString());
            }
        }
Example #3
0
        public virtual void Effect()
        {
            CompAbilityUserMagic comp = CasterPawn.TryGetComp <CompAbilityUserMagic>();

            if (comp.SoL != null)
            {
                comp.SoL.shouldDismiss = true;
            }
            else
            {
                LocalTargetInfo t    = this.TargetsAoE[0];
                bool            flag = t.Cell != default(IntVec3);
                if (flag)
                {
                    Thing sol = new Thing();
                    sol.def = TorannMagicDefOf.FlyingObject_SpiritOfLight;

                    LongEventHandler.QueueLongEvent(delegate
                    {
                        FlyingObject_SpiritOfLight flyingObject = (FlyingObject_SpiritOfLight)GenSpawn.Spawn(ThingDef.Named("FlyingObject_SpiritOfLight"), this.CasterPawn.Position, this.CasterPawn.Map);
                        flyingObject.Launch(this.CasterPawn, t.Cell, sol);
                        flyingObject.shouldDismiss = false;
                        comp.SoL = flyingObject;
                    }, "LaunchingFlyer", false, null);
                }
            }
        }
Example #4
0
 protected override bool TryCastShot()
 {
     if (caster.def.category == ThingCategory.Pawn)
     {
         Pawn launcherPawn = caster as Pawn;
         AddHediffChance = AddHediffChance * CasterPawn.GetStatValue(StatDefOf.ToxicSensitivity, true);
         var rand = Rand.Value;       // This is a random percentage between 0% and 100%
         if (rand <= AddHediffChance) // If the percentage falls under the chance, success!
         {
             var randomSeverity = Rand.Range(0.05f, 0.15f);
             var effectOnPawn   = launcherPawn?.health?.hediffSet?.GetFirstHediffOfDef(HediffToAdd);
             if (effectOnPawn != null)
             {
                 effectOnPawn.Severity += randomSeverity;
             }
             else
             {
                 Hediff hediff = HediffMaker.MakeHediff(HediffToAdd, launcherPawn, null);
                 hediff.Severity = randomSeverity;
                 launcherPawn.health.AddHediff(hediff, null, null);
             }
         }
     }
     return(base.TryCastShot());
 }
        public bool TryJumpTo(LocalTargetInfo target, LocalTargetInfo dest)
        {
            bool result = false;

            if (target.IsValid)
            {
                if (target.Cell != default(IntVec3))
                {
                    if (this.CasterPawn != null && this.CasterPawn.Position.IsValid && this.CasterPawn.Spawned && this.CasterPawn.Map != null && !this.CasterPawn.Downed && !this.CasterPawn.Dead)
                    {
                        this.CasterPawn.jobs.StopAll(false);
                        FlyingObject_JumpPack flyingObject_Leap = (FlyingObject_JumpPack)GenSpawn.Spawn(ThingDef.Named(Props.jumpingThing), this.CasterPawn.Position, this.CasterPawn.Map, WipeMode.Vanish);

                        Find.TickManager.DeRegisterAllTickabilityFor(CasterPawn);
                        CasterPawn.DeSpawn(DestroyMode.Vanish);
                        if (target.HasThing)
                        {
                            //	Log.Message("jumping at " + target.Thing.LabelShortCap);
                            flyingObject_Leap.Launch(this.CasterPawn, target, this.CasterPawn);
                        }
                        flyingObject_Leap.Launch(this.CasterPawn, target.Cell, this.CasterPawn);
                        flyingObject_Leap.GetDirectlyHeldThings().TryAdd(CasterPawn, false);
                        result = true;
                    }
                }
            }
            return(result);
        }
        /*
         * public override IEnumerable<Gizmo> EquippedGizmos()
         * {
         *  ThingWithComps owner = IsWorn ? GetWearer : parent;
         *  bool flag = Find.Selector.SingleSelectedThing == GetWearer;
         *  if (flag && GetWearer.Drafted && GetWearer.IsColonist && DualFireMode)
         *  {
         *      int num = 700000101;
         *      yield return new Command_Toggle
         *      {
         *          icon = this.CommandTex,
         *          defaultLabel = "AdeptusMechanicus.ToggleFireModeCommandLabel".Translate(Toggled ? PrimaryMode.defaultProjectile.label : SecondaryMode.defaultProjectile.label),
         *          defaultDesc = Toggled ? PrimaryMode.defaultProjectile.description : SecondaryMode.defaultProjectile.description,
         *          isActive = (() => Toggled),
         *          toggleAction = delegate ()
         *          {
         *              Toggled = !Toggled;
         *              SwitchFireMode();
         *          },
         *          activateSound = SoundDef.Named("Click"),
         *          groupKey = num,
         *          disabled = GetWearer.stances.curStance.StanceBusy,
         *          disabledReason = "Busy"
         *      };
         *  }
         *  yield break;
         * }
         */

        public override IEnumerable <Gizmo> EquippedGizmos()
        {
            ThingWithComps owner = IsWorn ? CasterPawn : parent;
            bool           flag  = IsWorn ? Find.Selector.SingleSelectedThing == CasterPawn : false;

            if (flag)
            {
                string desc  = string.Empty;
                string desc2 = string.Empty;
                if (ForceWeapon)
                {
                    int  level  = 0;
                    bool psyker = IsWorn ? CasterPawn.isPsyker(out level) : false;
                    desc = "Force Weapon";
                    if (psyker)
                    {
                        if (level == 1)
                        {
                            desc = desc + " and posses minor latent psyhic ability";
                        }
                        if (level == 2)
                        {
                            desc = desc + " and posses potent latent psyhic ability";
                        }
                        desc = desc + " \nThey may use this weapons special effects";
                    }
                    else if (!psyker && !ForceEffectRequiresPsyker)
                    {
                        desc = desc + "utilizeable by Non Psykers";
                        desc = desc + " \nThey may use this weapons special effects";
                    }
                    yield return(new Command_Toggle
                    {
                        icon = parent.def.uiIcon,
                        defaultLabel = parent.def.label,
                        defaultDesc = "Equipped with a " + desc,
                        isActive = (() => psyker),
                        toggleAction = delegate()
                        {
                        },
                        disabled = true,
                        disabledReason = !psyker && ForceEffectRequiresPsyker? "User posses no psyhic ability\nThey may use this weapon, however it will not have any special effect": null,
                    });
                }
                else if (PowerWeapon)
                {
                    desc = "Power Weapon";

                    Command_Action command_Action = new Command_Action();
                    command_Action.defaultLabel = parent.def.label;
                    command_Action.defaultDesc  = "Equipped with a " + desc;
                    //    command_Action.hotKey = KeyBindingDefOf.Misc2;
                    command_Action.icon     = parent.def.uiIcon;
                    command_Action.disabled = true;
                    yield return(command_Action);
                }
            }
            yield break;
        }
Example #7
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);
        }
Example #8
0
 private float GetNonMissChance(LocalTargetInfo target)
 {
     if (surpriseAttack)
     {
         return(1f);
     }
     if (IsTargetImmobile(target))
     {
         return(1f);
     }
     return(CasterPawn.GetStatValue(StatDefOf.MeleeHitChance));
 }
Example #9
0
        public bool MesaTryStartCastOn(LocalTargetInfo castTarg, bool attack = false,
                                       bool canHitNonTargetPawns             = true)
        {
            if (newWarmupTime > verbProps.warmupTime)
            {
                newWarmupTime = verbProps.warmupTime;
            }

            if (caster == null)
            {
                Log.Error("Verb " + GetUniqueLoadID() + " needs caster to work (possibly lost during saving/loading).");
                return(false);
            }

            if (!caster.Spawned)
            {
                return(false);
            }

            if (state == VerbState.Bursting || !CanHitTarget(castTarg))
            {
                return(false);
            }

            if (CausesTimeSlowdown(castTarg))
            {
                Find.TickManager.slower.SignalForceNormalSpeed();
            }

            surpriseAttack          = attack;
            canHitNonTargetPawnsNow = canHitNonTargetPawns;
            currentTarget           = castTarg;
            if (CasterIsPawn && verbProps.warmupTime > 0f)
            {
                if (!TryFindShootLineFromTo(caster.Position, castTarg, out var newShootLine))
                {
                    return(false);
                }

                CasterPawn.Drawer.Notify_WarmingCastAlongLine(newShootLine, caster.Position);
                var statValue = CasterPawn.GetStatValue(StatDefOf.AimingDelayFactor);
                var ticks     = (newWarmupTime * statValue).SecondsToTicks();
                CasterPawn.stances.SetStance(new Stance_Warmup(ticks, castTarg, this));
            }
            else
            {
                WarmupComplete();
            }

            return(true);
        }
Example #10
0
        public override void PostCastShot(bool inResult, out bool outResult)
        {
            var comp = base.CasterPawn.GetComp <CompWizardry>();

            comp.SecondTarget = null;

            Find.Targeter.StopTargeting();
            BeginTargetingWithVerb(WizardryDefOf.CompVerb, WizardryDefOf.CompVerb.MainVerb.targetParams,
                                   delegate(LocalTargetInfo info)
            {
                action            = info;
                comp              = CasterPawn.GetComp <CompWizardry>();
                comp.SecondTarget = info;
            }, CasterPawn);
            outResult = inResult;
        }
 // unmodified
 private float GetHitChance(LocalTargetInfo target)
 {
     if (surpriseAttack)
     {
         return(1f);
     }
     if (IsTargetImmobile(target))
     {
         return(1f);
     }
     if (CasterPawn.skills != null)
     {
         return(CasterPawn.GetStatValue(StatDefOf.MeleeHitChance, true));
     }
     return(DefaultHitChance);
 }
Example #12
0
        protected override bool TryCastShot()
        {
            bool flag = false;

            this.TargetsAoE.Clear();
            this.UpdateTargets();
            int  shotsPerBurst = this.ShotsPerBurst;
            bool flag2         = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1;

            if (flag2)
            {
                this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1);
            }
            bool flag3 = this.UseAbilityProps.mustHaveTarget && this.TargetsAoE.Count == 0;
            bool result;

            if (flag3)
            {
                Messages.Message("AU_NoTargets".Translate(), MessageTypeDefOf.RejectInput, true);
                this.Ability.Notify_AbilityFailed(true);
                result = false;
            }
            else
            {
                for (int i = 0; i < this.TargetsAoE.Count; i++)
                {
                    Thing glyph = ThingMaker.MakeThing(RWBYDefOf.Weiss_Glyph_Summon);
                    glyph.TryGetComp <CompGlyphSummon>().SetData(GenTicks.SecondsToTicks(1.5f), RWBYDefOf.Grimm_ArmaGigas_Summoned);
                    GenSpawn.Spawn(glyph, TargetsAoE[i].Cell, caster.Map);
                    CasterPawn.TryGetComp <CompAbilityUserAura>().AbilityData.AllPowers.Find(a => a.Def == RWBYDefOf.Weiss_SummonArmaGigas).CooldownTicksLeft      = 3600;
                    CasterPawn.TryGetComp <CompAbilityUserAura>().AbilityData.AllPowers.Find(a => a.Def == RWBYDefOf.Weiss_SummonArmaGigasSword).CooldownTicksLeft = 3600;
                    bool abilitySucceeded = true;
                    if (abilitySucceeded)
                    {
                        flag = true;
                    }
                }
                this.PostCastShot(flag, out flag);
                bool postSucceed = !flag;
                if (postSucceed)
                {
                    this.Ability.Notify_AbilityFailed(this.UseAbilityProps.refundsPointsAfterFailing);
                }
                result = flag;
            }
            return(result);
        }
        public bool PreCastShotCheck(LocalTargetInfo castTarg, LocalTargetInfo destTarg, bool surpriseAttack, bool canHitNonTargetPawns)
        {
            if (caster == null)
            {
                Log.Error("Verb " + GetUniqueLoadID() + " needs caster to work (possibly lost during saving/loading).");
                return(false);
            }
            if (!caster.Spawned)
            {
                return(false);
            }
            if (state == VerbState.Bursting || (!CanHitTarget(castTarg) && verbProps.requireLineOfSight))
            {
                return(false);
            }
            if (CausesTimeSlowdown(castTarg))
            {
                Find.TickManager.slower.SignalForceNormalSpeed();
            }

            this.surpriseAttack          = surpriseAttack;
            this.canHitNonTargetPawnsNow = canHitNonTargetPawns;
            this.currentTarget           = castTarg;
            this.currentDestination      = destTarg;
            if (CasterIsPawn && verbProps.warmupTime > 0f)
            {
                if (verbProps.requireLineOfSight)
                {
                    ShootLine resultingLine;
                    if (!TryFindShootLineFromTo(caster.Position, castTarg, out resultingLine))
                    {
                        Messages.Message("AU_NoLineOfSight".Translate(), MessageTypeDefOf.RejectInput);
                        return(false);
                    }
                    CasterPawn.Drawer.Notify_WarmingCastAlongLine(resultingLine, caster.Position);
                }
                float statValue = CasterPawn.GetStatValue(StatDefOf.AimingDelayFactor);
                int   ticks     = (verbProps.warmupTime * statValue).SecondsToTicks();
                CasterPawn.stances.SetStance(new Stance_Warmup(ticks, castTarg, this));
            }
            else
            {
                WarmupComplete();
            }
            return(true);
        }
Example #14
0
 public override bool ValidateTarget(LocalTargetInfo target)
 {
     if (!base.ValidateTarget(target))
     {
         return(false);
     }
     if (CasterPawn.GetStatValue(StatDefOf.PsychicSensitivity) < float.Epsilon)
     {
         Messages.Message("CommandPsycastZeroPsychicSensitivity".Translate(), caster, MessageTypeDefOf.RejectInput);
         return(false);
     }
     if (Psycast.def.EntropyGain > float.Epsilon && CasterPawn.psychicEntropy.WouldOverflowEntropy(Psycast.def.EntropyGain + PsycastUtility.TotalEntropyFromQueuedPsycasts(CasterPawn)))
     {
         Messages.Message("CommandPsycastWouldExceedEntropy".Translate(), caster, MessageTypeDefOf.RejectInput);
         return(false);
     }
     return(true);
 }
        protected override bool TryCastShot()
        {
            bool flag = false;

            this.TargetsAoE.Clear();
            this.UpdateTargets();
            int  shotsPerBurst = this.ShotsPerBurst;
            bool flag2         = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1;

            if (flag2)
            {
                this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1);
            }
            bool flag3 = this.UseAbilityProps.mustHaveTarget && this.TargetsAoE.Count == 0;
            bool result;

            if (flag3)
            {
                Messages.Message("AU_NoTargets".Translate(), MessageTypeDefOf.RejectInput, true);
                this.Ability.Notify_AbilityFailed(true);
                result = false;
            }
            else
            {
                for (int i = 0; i < this.TargetsAoE.Count; i++)
                {
                    ((Aura_Blake)CasterPawn.TryGetComp <CompAbilityUserAura>().aura).SetClone(RWBYDefOf.Blake_ShadowClone_Stone, 10f, new Color(0.5f, 0.5f, 0.5f));
                    bool abilitySucceeded = true;
                    if (abilitySucceeded)
                    {
                        flag = true;
                    }
                }
                this.PostCastShot(flag, out flag);
                bool postSucceed = !flag;
                if (postSucceed)
                {
                    this.Ability.Notify_AbilityFailed(this.UseAbilityProps.refundsPointsAfterFailing);
                }
                result = flag;
            }
            return(result);
        }
Example #16
0
        public void Effect()
        {
            CasterPawn.Drawer.Notify_DebugAffected();
            if (TargetsAoE.FirstOrDefault(x => x is LocalTargetInfo y && y.Cell != default(IntVec3)) is LocalTargetInfo t)
            {
                var destination = t.Cell;

                MoteMaker.ThrowText(CasterPawn.DrawPos, CasterPawn.Map, AbilityUser.StringsToTranslate.AU_CastSuccess);
                if (destination.IsValid)
                {
                    CasterPawn.Position = destination;
                    CasterPawn.stances.stunner.StunFor(new IntRange(5, 10).RandomInRange, CasterPawn, addBattleLog: false);
                    CasterPawn.Notify_Teleported();

                    //Cheap solution...
                    this.Ability.CooldownTicksLeft = this.Ability.MaxCastingTicks;
                    CasterPawn.BloodNeed().AdjustBlood(-3);
                    return;
                }
                MoteMaker.ThrowText(CasterPawn.DrawPos, CasterPawn.Map, AbilityUser.StringsToTranslate.AU_CastFailure);
            }
        }
        public virtual bool TryStartCastOn(GlobalTargetInfo castTarg, float heading, bool surpriseAttack = false, bool canHitNonTargetPawns = true)
        {
            if (caster is null)
            {
                Log.Error("Verb " + GetUniqueLoadID() + " needs caster to work (possibly lost during saving/loading).", false);
                return(false);
            }
            if (!caster.Spawned)
            {
                return(false);
            }
            if (state == VerbState.Bursting || !CanHitTarget(castTarg))
            {
                return(false);
            }
            this.heading = heading;
            IntVec3 exitTarget = caster.Position.CellFromDistAngle(Building_Artillery.MaxMapDistance, this.heading);

            if (CausesTimeSlowdown(castTarg))
            {
                Find.TickManager.slower.SignalForceNormalSpeed();
            }
            this.surpriseAttack     = surpriseAttack;
            canHitNonTargetPawnsNow = canHitNonTargetPawns;
            target = castTarg;
            if (CasterIsPawn && verbProps.warmupTime > 0f)
            {
                CasterPawn.Drawer.Notify_WarmingCastAlongLine(new ShootLine(caster.Position, exitTarget), caster.Position);
                float statValue = CasterPawn.GetStatValue(StatDefOf.AimingDelayFactor, true);
                int   ticks     = (verbProps.warmupTime * statValue).SecondsToTicks();
                CasterPawn.stances.SetStance(new Stance_Warmup(ticks, exitTarget, this));
            }
            else
            {
                WarmupComplete();
            }
            return(true);
        }
        public virtual void Effect()
        {
            CasterPawn.Drawer.Notify_DebugAffected();
            MoteMaker.ThrowText(CasterPawn.DrawPos, CasterPawn.Map, AbilityUser.StringsToTranslate.AU_CastSuccess);
            int num = GenRadial.NumCellsInRadius(3.9f);

            for (int i = 0; i < num; i++)
            {
                IntVec3 curCell = CasterPawn.PositionHeld + GenRadial.RadialPattern[i];
                if (curCell.GetThingList(CasterPawn.MapHeld) is List <Thing> things && !things.NullOrEmpty())
                {
                    List <Thing> temp = new List <Thing>(things);
                    foreach (Thing t in temp)
                    {
                        if (t.def.defName == "FilthBlood")
                        {
                            CasterPawn.BloodNeed().AdjustBlood(1);
                            t.Destroy();
                        }
                    }
                }
            }
        }
        // Token: 0x060039DF RID: 14815 RVA: 0x001B80A4 File Offset: 0x001B64A4
        protected override DamageWorker.DamageResult ApplyMeleeDamageToTarget(LocalTargetInfo target)
        {
            DamageWorker.DamageResult result = new DamageWorker.DamageResult();
            Pawn hitPawn = (Pawn)target;

            if (infect && !XenomorphUtil.IsInfectedPawn(hitPawn) && !hitPawn.Dead && hitPawn.RaceProps.body.AllParts.Any(x => x.def.defName.Contains("Head")))
            {
                foreach (var part in hitPawn.RaceProps.body.AllParts.Where(x => x.def.defName.Contains("Head")))
                {
                    Hediff                    hediff      = HediffMaker.MakeHediff(XenomorphDefOf.RRY_FaceHuggerInfection, hitPawn, null);
                    Comp_Facehugger           _Facehugger = CasterPawn.TryGetComp <Comp_Facehugger>();
                    HediffComp_XenoFacehugger comp        = hediff.TryGetComp <HediffComp_XenoFacehugger>();
                    comp.instigator            = CasterPawn;
                    comp.instigatorKindDef     = CasterPawn.kindDef;
                    comp.royaleHugger          = _Facehugger.RoyaleHugger;
                    comp.previousImpregnations = _Facehugger.Impregnations;
                    hitPawn.health.AddHediff(hediff, part, null);
                    string text = TranslatorFormattedStringExtensions.Translate("Xeno_Facehugger_Attach", hitPawn.LabelShort, part.LabelShortCap);
                    MoteMaker.ThrowText(hitPawn.Position.ToVector3(), hitPawn.Map, text, 5f);
                    comp.GetDirectlyHeldThings();
                    caster.DeSpawn();
                    infect = false;
                }
            }
            else
            {
                foreach (DamageInfo dinfo in this.DamageInfosToApply(target))
                {
                    if (target.ThingDestroyed)
                    {
                        break;
                    }
                    result = target.Thing.TakeDamage(dinfo);
                }
            }
            return(result);
        }
        protected override bool TryCastShot()
        {
            bool flag = false;

            this.TargetsAoE.Clear();
            this.UpdateTargets();
            int  shotsPerBurst = this.ShotsPerBurst;
            bool flag2         = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1;

            if (flag2)
            {
                this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1);
            }
            bool flag3 = this.UseAbilityProps.mustHaveTarget && this.TargetsAoE.Count == 0;
            bool result;

            if (flag3)
            {
                Messages.Message("AU_NoTargets".Translate(), MessageTypeDefOf.RejectInput, true);
                this.Ability.Notify_AbilityFailed(true);
                result = false;
            }
            else
            {
                for (int i = 0; i < this.TargetsAoE.Count; i++)
                {
                    bool abilitySucceeded = true;
                    if (TargetsAoE[i].Thing != null && TargetsAoE[i].Thing is Pawn targetPawn && CasterPawn.TryGetComp <CompAbilityUserAura>().aura is Aura_Raven aura_Raven)
                    {
                        abilitySucceeded = aura_Raven.RegisterBondedPawn(targetPawn);
                    }
                    if (abilitySucceeded)
                    {
                        flag = true;
                    }
                }
                this.PostCastShot(flag, out flag);
                bool postSucceed = !flag;
                if (postSucceed)
                {
                    this.Ability.Notify_AbilityFailed(this.UseAbilityProps.refundsPointsAfterFailing);
                }
                result = flag;
            }
            return(result);
        }
        /// <summary>
        /// Calculates primary DamageInfo from verb, as well as secondary DamageInfos to apply (i.e. surprise attack stun damage).
        /// Also calculates the maximum body height an attack can target, so we don't get rabbits biting out a colonist's eye or something.
        /// </summary>
        /// <param name="target">The target damage is to be applied to</param>
        /// <returns>Collection with primary DamageInfo, followed by secondary types</returns>
        private IEnumerable <DamageInfo> DamageInfosToApply(LocalTargetInfo target, bool isCrit = false)
        {
            //START 1:1 COPY Verb_MeleeAttack.DamageInfosToApply
            float damAmount    = verbProps.AdjustedMeleeDamageAmount(this, CasterPawn);
            var   critModifier = isCrit && verbProps.meleeDamageDef.armorCategory == DamageArmorCategoryDefOf.Sharp &&
                                 !CasterPawn.def.race.Animal
                ? 2
                : 1;
            var              armorPenetration = (verbProps.meleeDamageDef.armorCategory == DamageArmorCategoryDefOf.Sharp ? ArmorPenetrationSharp : ArmorPenetrationBlunt) * critModifier;
            DamageDef        damDef           = verbProps.meleeDamageDef;
            BodyPartGroupDef bodyPartGroupDef = null;
            HediffDef        hediffDef        = null;

            if (EquipmentSource != null)
            {
                //melee weapon damage variation
                damAmount *= Rand.Range(StatWorker_MeleeDamage.GetDamageVariationMin(CasterPawn), StatWorker_MeleeDamage.GetDamageVariationMax(CasterPawn));
            }
            else if (!CE_StatDefOf.UnarmedDamage.Worker.IsDisabledFor(CasterPawn))  //ancient soldiers can punch even if non-violent, this prevents the disabled stat from being used
            {
                //unarmed damage bonus offset
                damAmount += CasterPawn.GetStatValue(CE_StatDefOf.UnarmedDamage);
            }

            if (CasterIsPawn)
            {
                bodyPartGroupDef = verbProps.AdjustedLinkedBodyPartsGroup(tool);
                if (damAmount >= 1f)
                {
                    if (HediffCompSource != null)
                    {
                        hediffDef = HediffCompSource.Def;
                    }
                }
                else
                {
                    damAmount = 1f;
                    damDef    = DamageDefOf.Blunt;
                }
            }

            var       source    = EquipmentSource != null ? EquipmentSource.def : CasterPawn.def;
            Vector3   direction = (target.Thing.Position - CasterPawn.Position).ToVector3();
            DamageDef def       = damDef;
            //END 1:1 COPY
            BodyPartHeight bodyRegion = GetBodyPartHeightFor(target);                                                                                           //Custom // Add check for body height
            //START 1:1 COPY
            DamageInfo mainDinfo = new DamageInfo(def, damAmount, armorPenetration, -1f, caster, null, source, DamageInfo.SourceCategory.ThingOrUnknown, null); //Alteration

            // Predators get a neck bite on immobile targets
            if (caster.def.race.predator && IsTargetImmobile(target) && target.Thing is Pawn pawn)
            {
                var neck = pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Top, BodyPartDepth.Outside)
                           .FirstOrDefault(r => r.def == BodyPartDefOf.Neck);
                mainDinfo.SetHitPart(neck);
            }

            mainDinfo.SetBodyRegion(bodyRegion); //Alteration
            mainDinfo.SetWeaponBodyPartGroup(bodyPartGroupDef);
            mainDinfo.SetWeaponHediff(hediffDef);
            mainDinfo.SetAngle(direction);
            yield return(mainDinfo);

            DamageInfo damageInfo = new DamageInfo(def, damAmount, armorPenetration, -1f, this.caster, null, source, DamageInfo.SourceCategory.ThingOrUnknown, null);

            damageInfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside);
            damageInfo.SetWeaponBodyPartGroup(bodyPartGroupDef);
            damageInfo.SetWeaponHediff(hediffDef);
            damageInfo.SetAngle(direction);
            yield return(damageInfo);

            if (this.tool != null && this.tool.extraMeleeDamages != null)
            {
                foreach (ExtraDamage extraDamage in this.tool.extraMeleeDamages)
                {
                    if (Rand.Chance(extraDamage.chance))
                    {
                        damAmount  = extraDamage.amount;
                        damAmount  = Rand.Range(damAmount * 0.8f, damAmount * 1.2f);
                        damageInfo = new DamageInfo(extraDamage.def, damAmount, extraDamage.AdjustedArmorPenetration(this, this.CasterPawn), -1f, this.caster, null, source, DamageInfo.SourceCategory.ThingOrUnknown, null);
                        damageInfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside);
                        damageInfo.SetWeaponBodyPartGroup(bodyPartGroupDef);
                        damageInfo.SetWeaponHediff(hediffDef);
                        damageInfo.SetAngle(direction);
                        yield return(damageInfo);
                    }
                }
                List <ExtraDamage> .Enumerator enumerator = default(List <ExtraDamage> .Enumerator);
            }

            // Apply critical damage
            if (isCrit && !CasterPawn.def.race.Animal && verbProps.meleeDamageDef.armorCategory != DamageArmorCategoryDefOf.Sharp && target.Thing.def.race.IsFlesh)
            {
                var critAmount = GenMath.RoundRandom(mainDinfo.Amount * 0.25f);
                var critDinfo  = new DamageInfo(DamageDefOf.Stun, critAmount, armorPenetration,
                                                -1, caster, null, source);
                critDinfo.SetBodyRegion(bodyRegion, BodyPartDepth.Outside);
                critDinfo.SetWeaponBodyPartGroup(bodyPartGroupDef);
                critDinfo.SetWeaponHediff(hediffDef);
                critDinfo.SetAngle(direction);
                yield return(critDinfo);
            }
        }
Example #22
0
 protected override int TicksToNextHit()
 {
     return((int)Math.Round(BaseTicksBetweenPickHits / (double)CasterPawn.GetStatValue(StatDefOf.MiningSpeed)));
 }
Example #23
0
        protected override bool TryCastShot()
        {
            bool flag = false;

            this.TargetsAoE.Clear();
            this.UpdateTargets();
            int  shotsPerBurst = this.ShotsPerBurst;
            bool flag2         = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1;

            if (flag2)
            {
                this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1);
            }
            bool flag3 = this.UseAbilityProps.mustHaveTarget && this.TargetsAoE.Count == 0;
            bool result;

            if (flag3)
            {
                Messages.Message("AU_NoTargets".Translate(), MessageTypeDefOf.RejectInput, true);
                this.Ability.Notify_AbilityFailed(true);
                result = false;
            }
            else
            {
                for (int i = 0; i < this.TargetsAoE.Count; i++)
                {
                    bool abilitySucceeded = true;
                    if (TargetsAoE[i].Thing != null && TargetsAoE[i].Thing is Pawn targetPawn)
                    {
                        float damageToDeal = ((Aura_Adam)CasterPawn.TryGetComp <CompAbilityUserAura>().aura).absorbedDamage;
                        if (targetPawn.TryGetComp <CompAbilityUserAura>() is CompAbilityUserAura compAbilityUserAura && targetPawn.TryGetComp <CompAbilityUserAura>().IsInitialized&& compAbilityUserAura.aura.currentEnergy > 0f)
                        {
                            float damageToDealToAura = 0f;
                            if (compAbilityUserAura.aura.currentEnergy > damageToDeal)
                            {
                                damageToDealToAura = damageToDeal;
                                damageToDeal       = 0;
                            }
                            else
                            {
                                damageToDealToAura = compAbilityUserAura.aura.currentEnergy * 100f + 1f;
                                damageToDeal       = damageToDeal - compAbilityUserAura.aura.currentEnergy;
                            }
                            DamageInfo extraDinfoToAura = new DamageInfo(DamageDefOf.Cut, damageToDealToAura, 0f, -1f, CasterPawn, null, CasterPawn.def, DamageInfo.SourceCategory.ThingOrUnknown, targetPawn);
                            extraDinfoToAura.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside);
                            Vector3 direction = (targetPawn.Position - CasterPawn.Position).ToVector3();
                            extraDinfoToAura.SetAngle(direction);
                            targetPawn.TakeDamage(extraDinfoToAura);
                        }
                        if (damageToDeal > 0)
                        {
                            DamageInfo extraDinfo = new DamageInfo(DamageDefOf.Cut, damageToDeal, 0f, -1f, CasterPawn, null, CasterPawn.def, DamageInfo.SourceCategory.ThingOrUnknown, targetPawn);
                            extraDinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside);
                            Vector3 direction = (targetPawn.Position - CasterPawn.Position).ToVector3();
                            extraDinfo.SetAngle(direction);
                            targetPawn.TakeDamage(extraDinfo);
                        }
                        Projectile projectile = (Projectile)GenSpawn.Spawn(RWBYDefOf.RWBY_Ability_Adam_Projectile, CasterPawn.Position, CasterPawn.Map, WipeMode.Vanish);
                        projectile.Launch(CasterPawn, targetPawn, targetPawn, ProjectileHitFlags.IntendedTarget);
                        ((Aura_Adam)CasterPawn.TryGetComp <CompAbilityUserAura>().aura).absorbedDamage = 1f;
                    }
                    else
                    {
                        abilitySucceeded = false;
                    }
                    if (abilitySucceeded)
                    {
                        flag = true;
                    }
                }
                this.PostCastShot(flag, out flag);
                bool postSucceed = !flag;
                if (postSucceed)
                {
                    this.Ability.Notify_AbilityFailed(this.UseAbilityProps.refundsPointsAfterFailing);
                }
                result = flag;
            }
            return(result);
        }