public static void PostFix(ref StunHandler __instance, ref int ___EMPAdaptedTicksLeft, DamageInfo dinfo)
        {
            var pawn = __instance.parent as Pawn;

            if (pawn != null && (pawn.Downed || pawn.Dead))
            {
                return;
            }

            var Haywire = DefDatabase <DamageDef> .GetNamed("GGHaywireEMP");

            if (dinfo.Def != Haywire || !EMPAffects(pawn))
            {
                return;
            }

            if (___EMPAdaptedTicksLeft <= 0 || HaywireUtility.Rnd100() < (int)Controller.Settings.HWChance)
            {
                __instance.StunFor(Mathf.RoundToInt(dinfo.Amount * 15f), dinfo.Instigator);
                if (pawn != null && pawn.RaceProps.IsMechanoid)
                {
                    ___EMPAdaptedTicksLeft = 2000;
                }

                HaywireUtility.DoHaywireEffect(pawn);
                return;
            }

            var position = __instance.parent.Position;

            MoteMaker.ThrowText(new Vector3(position.x + 1f, position.y, position.z + 1f), __instance.parent.Map,
                                "Adapted".Translate(), Color.white);
        }
Beispiel #2
0
 // Token: 0x06000097 RID: 151 RVA: 0x00005A01 File Offset: 0x00003C01
 public override void DoHWEffect(Pawn pawn)
 {
     if (HaywireUtility.Rnd100() < 50)
     {
         HaywireEffect.DoHWBreakDown(pawn);
     }
 }
 // Token: 0x0600009C RID: 156 RVA: 0x00005A41 File Offset: 0x00003C41
 public virtual void DoHWEffect(Pawn pawn)
 {
     if (HaywireUtility.Rnd100() < 40)
     {
         HaywireEffect.DoHWExplosion(pawn);
     }
 }
Beispiel #4
0
        // Token: 0x0600006E RID: 110 RVA: 0x00004AB0 File Offset: 0x00002CB0
        public static void SetUpBDVars(Pawn Victim, Thing instigator, out BodyPartRecord candidate,
                                       out DamageDef DamDef, out float dmg)
        {
            DamDef = null;
            var Rnd = HaywireUtility.Rnd100();

            if (Rnd < 50)
            {
                DamDef = DamageDefOf.Cut;
            }
            else if (Rnd < 87)
            {
                DamDef = DamageDefOf.Blunt;
            }
            else
            {
                DamDef = DamageDefOf.EMP;
            }

            dmg = RndDmg(7f, 15f);
            if (Victim != null)
            {
                var bodyV = Victim.BodySize;
                if (bodyV > 0f)
                {
                    dmg *= bodyV;
                }
            }

            if (DamDef == DamageDefOf.EMP)
            {
                dmg *= 3f;
            }

            candidate = null;
            var  potentials = new List <BodyPartRecord>();
            var  raceProps  = Victim?.RaceProps;
            bool hasParts;

            if (raceProps == null)
            {
                hasParts = false;
            }
            else
            {
                var body = raceProps.body;
                hasParts = body?.AllParts != null;
            }

            if (hasParts)
            {
                potentials.AddRange(Victim.RaceProps.body.AllParts);
            }

            if (potentials.Count > 0)
            {
                candidate = GetCandidate(potentials);
            }
        }
Beispiel #5
0
        // Token: 0x06000002 RID: 2 RVA: 0x0000206C File Offset: 0x0000026C
        public override void Tick()
        {
            spawnTick++;
            if (spawnTick >= (2500f * Controller.Settings.CaltropDuration) + HaywireUtility.RndTicks(-25, 25))
            {
                DoCaltropBurst(null, "TM", this);
                return;
            }

            if (spawnTick < 300 || Find.TickManager.TicksGame % 60 != 0)
            {
                return;
            }

            var TargetMap  = Map;
            var TargetCell = Position;
            var Pawnlist   = TargetCell.GetThingList(TargetMap);

            if (Pawnlist.Count <= 0)
            {
                return;
            }

            foreach (var thing in Pawnlist)
            {
                Pawn pawn;
                if ((pawn = thing as Pawn) == null || GhostGearUtility.IsWearingGhostGear(pawn, out _) ||
                    thing.Position != TargetCell)
                {
                    continue;
                }

                if ((thing as Pawn).RaceProps.IsMechanoid)
                {
                    DoCaltropBurst(thing as Pawn, "ME", this);
                }
                else if ((thing as Pawn).RaceProps.FleshType.defName == "Insectoid")
                {
                    DoCaltropBurst(thing as Pawn, "IF", this);
                }
                else
                {
                    DoCaltropBurst(thing as Pawn, "OS", this);
                }
            }
        }
Beispiel #6
0
        // Token: 0x06000064 RID: 100 RVA: 0x0000465C File Offset: 0x0000285C
        public override void CompTick()
        {
            if (!IsHaywired(pawn))
            {
                return;
            }

            HaywireTicks--;
            if ((HaywireTicks + pawn.thingIDNumber) % 120 != 0)
            {
                return;
            }

            var pawn1 = pawn;

            if (pawn1?.Map == null)
            {
                return;
            }

            HaywireEffect.MakeHaywireOverlay(pawn);
            HaywireUtility.TryStartHaywireJob(pawn, 120);
        }
Beispiel #7
0
        // Token: 0x0600006D RID: 109 RVA: 0x00004984 File Offset: 0x00002B84
        public static void SetUpExpVars(Pawn pawn, out float radius, out DamageDef dmgdef, out int dmg,
                                        out ThingDef postTD, out float postChance, out int postNum, out ThingDef preTD, out float preChance,
                                        out int preNum, out float fireChance)
        {
            radius     = Mathf.Lerp(1.9f, 5.9f, Math.Min(pawn.BodySize, 5f) / 5f);
            dmgdef     = DamageDefOf.EMP;
            dmg        = 50;
            postTD     = null;
            postChance = 0f;
            postNum    = 0;
            preTD      = null;
            preChance  = 0f;
            preNum     = 0;
            fireChance = 0f;
            var rnd = HaywireUtility.Rnd100();

            if (rnd < 10)
            {
                dmgdef = DefDatabase <DamageDef> .GetNamed("GGHaywireEMP");

                return;
            }

            if (rnd < 50)
            {
                dmgdef     = DamageDefOf.Smoke;
                dmg        = 0;
                postTD     = ThingDefOf.Gas_Smoke;
                postChance = 1f;
                postNum    = 1;
                return;
            }

            if (rnd < 70)
            {
                dmgdef     = DamageDefOf.Flame;
                dmg        = 20;
                dmg        = (int)(dmg * pawn.BodySize);
                postTD     = ThingDefOf.Gas_Smoke;
                postChance = 1f;
                postNum    = 1;
                preTD      = ThingDefOf.Filth_Fuel;
                preChance  = 1f;
                preNum     = 1;
                fireChance = 0.95f;
                return;
            }

            if (rnd >= 85)
            {
                return;
            }

            dmgdef     = DamageDefOf.Bomb;
            dmg        = 25;
            dmg        = (int)(dmg * pawn.BodySize);
            postTD     = ThingDefOf.Gas_Smoke;
            postChance = 1f;
            postNum    = 1;
            fireChance = 0.5f;
        }