internal static void Notify_EquipmentAdded_Patch(ref ThingWithComps eq, ref Pawn_EquipmentTracker __instance)
        {
            Pawn pawn = __instance.ParentHolder as Pawn;

            if (eq.def.BaseMass > ChildrenUtility.ChildMaxWeaponMass(pawn) && pawn.ageTracker.CurLifeStageIndex <= AgeStage.Child)
            {
                Messages.Message("MessageWeaponTooLarge".Translate(new object[] { eq.def.label, ((Pawn)__instance.ParentHolder).NameStringShort }), MessageSound.Negative);
            }
        }
Пример #2
0
        internal static List <ThingStuffPair> FilterChildWeapons(Pawn pawn, List <ThingStuffPair> weapons)
        {
            var weapons_out = new List <ThingStuffPair>();

            if (weapons.Count > 0)
            {
                foreach (ThingStuffPair weapon in weapons)
                {
                    if (weapon.thing.BaseMass < ChildrenUtility.ChildMaxWeaponMass(pawn))
                    {
                        weapons_out.Add(weapon);
                    }
                }
            }
            return(weapons_out);
        }
Пример #3
0
        internal static void TryCastShot_Patch(ref Verb_Shoot __instance)
        {
            Pawn pawn = __instance.CasterPawn;

            if (pawn != null && ChildrenUtility.RaceUsesChildren(pawn) && pawn.ageTracker.CurLifeStageIndex <= AgeStage.Child)
            {
                // The weapon is too heavy and the child will (likely) drop it when trying to fire
                if (__instance.ownerEquipment.def.BaseMass > ChildrenUtility.ChildMaxWeaponMass(pawn))
                {
                    ThingWithComps benis;
                    pawn.equipment.TryDropEquipment(__instance.ownerEquipment, out benis, pawn.Position, false);

                    float recoilForce = (__instance.ownerEquipment.def.BaseMass - 3);

                    if (recoilForce > 0)
                    {
                        string[] hitPart =
                        {
                            "Torso",
                            "LeftShoulder",
                            "LeftArm",
                            "LeftHand",
                            "RightShoulder",
                            "RightArm",
                            "RightHand",
                            "Head",
                            "Neck",
                            "LeftEye",
                            "RightEye",
                            "Nose",
                        };
                        int hits = Rand.Range(1, 4);
                        while (hits > 0)
                        {
                            pawn.TakeDamage(new DamageInfo(DamageDefOf.Blunt, (int)((recoilForce + Rand.Range(0f, 3f)) / hits), -1, __instance.ownerEquipment,
                                                           ChildrenUtility.GetPawnBodyPart(pawn, hitPart.RandomElement <String> ()), null));
                            hits--;
                        }
                    }
                }
            }
        }
Пример #4
0
        internal static void Notify_EquipmentAdded_Patch(ref ThingWithComps eq, ref Pawn_EquipmentTracker __instance)
        {
            Pawn pawn = __instance.ParentHolder as Pawn;

            if (pawn != null && ChildrenUtility.RaceUsesChildren(pawn) && eq.def.BaseMass > ChildrenUtility.ChildMaxWeaponMass(pawn) && pawn.ageTracker.CurLifeStageIndex <= AgeStage.Child && pawn.Faction.IsPlayer)
            {
                Messages.Message("MessageWeaponTooLarge".Translate(new object[] { eq.def.label, ((Pawn)__instance.ParentHolder).NameStringShort }), MessageTypeDefOf.CautionInput);
            }
        }