Пример #1
0
 static void Postfix(ref Pawn __instance, ref List <VerbProperties> __result)
 {
     if (__instance.equipment != null)
     {
         if (__instance.equipment.PrimaryEq.PrimaryVerb.verbProps.range > 1.5f)
         {
             return;
         }
     }
     if (__instance.health.hediffSet.hediffs.Any(x => x.TryGetComp <HediffComp_VerbGiver>() != null))
     {
         foreach (HediffWithComps hdc in __instance.health.hediffSet.hediffs.Where(x => x.def.HasComp(typeof(HediffComp_VerbGiver))))
         {
             HediffComp_VerbGiver _VerbGiver = hdc.TryGetComp <HediffComp_VerbGiver>();
             if (_VerbGiver.Props.verbs != null)
             {
                 foreach (VerbProperties verb in _VerbGiver.Props.verbs)
                 {
                     if (!__result.Contains(verb))
                     {
                         __result.Add(verb);
                     }
                 }
             }
         }
     }
 }
Пример #2
0
 public static void PostFix(ref float __result, Tool tool, Pawn attacker, HediffComp_VerbGiver hediffCompSource)
 {
     //EliteBionicsFrameworkMain.LogError("Dump vars: " + __result + ", " + tool.LabelCap + ", " + attacker.Name + ", " + hediffCompSource);
     if (attacker != null)
     {
         // There is an attacker.
         int   tempLinearAdjustment  = 0;
         float tempScalingAdjustment = 1;
         // Handle several cases.
         if (ToolFinderUtils.ToolIsOriginalToolOfPawn(tool, attacker))
         {
             // Attacks by bare-hand; no hediff source.
             // May have implant or no implant...
             BodyPartGroupDef hostGroup = tool.linkedBodyPartsGroup;
             foreach (HediffWithComps candidateHediff in attacker.health.hediffSet.GetHediffs <HediffWithComps>())
             {
                 if (!(candidateHediff is Hediff_Implant))
                 {
                     // Normal hediff only.
                     continue;
                 }
                 // I think in some cases the Part can be null, especially when for whole-body hediffs.
                 if ((bool)(candidateHediff.Part?.IsInGroup(hostGroup)))
                 {
                     // Relevant.
                     HediffComp_ToolPowerAdjust adjustmentComps = candidateHediff.TryGetComp <HediffComp_ToolPowerAdjust>();
                     if (adjustmentComps != null)
                     {
                         // Have adjustment comps
                         __result *= adjustmentComps.Props.ActualScalingFactor;
                     }
                 }
             }
         }
         else if (hediffCompSource != null)
         {
             // Attacks by bionic parts; bionic may have power adjustment components.
             if (ToolPowerAdjuster.CalculatePowerAdjustmentDueToImplants(attacker, hediffCompSource.parent.Part, ref tempLinearAdjustment, ref tempScalingAdjustment))
             {
                 // Successfully calculated.
                 __result *= tempScalingAdjustment;
             }
             if (ToolPowerAdjuster.CalculatePowerAdjustmentDueToToolUpgrade(attacker, hediffCompSource.parent.Part, tool, ref tempLinearAdjustment, ref tempScalingAdjustment))
             {
                 // Successfully calculated.
                 __result *= tempScalingAdjustment;
             }
         }
     }
 }
Пример #3
0
 public static void PostFix(ref float __result, Tool tool, Pawn attacker, HediffComp_VerbGiver hediffCompSource)
 {
     // __result already has the scaling multipliers within it.
     if (attacker != null)
     {
         // There is an attacker.
         int   tempLinearAdjustment  = 0;
         float tempScalingAdjustment = 1;
         // Handle several cases.
         if (ToolFinderUtils.ToolIsOriginalToolOfPawn(tool, attacker))
         {
             // Attacks by bare-hand; no hediff source.
             // May have implant or no implant...
             BodyPartGroupDef hostGroup = tool.linkedBodyPartsGroup;
             foreach (HediffWithComps candidateHediff in attacker.health.hediffSet.GetHediffs <HediffWithComps>())
             {
                 if (!(candidateHediff is Hediff_Implant))
                 {
                     // Normal hediff only.
                     continue;
                 }
                 if (candidateHediff.Part.IsInGroup(hostGroup))
                 {
                     // Relevant.
                     HediffComp_ToolPowerAdjust adjustmentComps = candidateHediff.TryGetComp <HediffComp_ToolPowerAdjust>();
                     if (adjustmentComps != null)
                     {
                         // Have adjustment comps
                         __result += adjustmentComps.Props.linearAdjustment;
                     }
                 }
             }
         }
         else if (hediffCompSource != null)
         {
             // Attacks by bionic parts; bionic may have power adjustment components.
             if (ToolPowerAdjuster.CalculatePowerAdjustmentDueToImplants(attacker, hediffCompSource.parent.Part, ref tempLinearAdjustment, ref tempScalingAdjustment))
             {
                 // Successfully calculated.
                 __result += tempLinearAdjustment;
             }
             if (ToolPowerAdjuster.CalculatePowerAdjustmentDueToToolUpgrade(attacker, hediffCompSource.parent.Part, tool, ref tempLinearAdjustment, ref tempScalingAdjustment))
             {
                 // Successfully calculated.
                 __result += tempLinearAdjustment;
             }
         }
     }
 }
Пример #4
0
        public static void AdjustedMeleeDamageAmountPostfix(Tool tool, Pawn attacker, Thing equipment, HediffComp_VerbGiver hediffCompSource, ref float __result)
        {
            PawnLvComp pawnlvcomp = attacker.TryGetComp <PawnLvComp>();

            Log.Message(__result.ToString());
            if (pawnlvcomp != null)
            {
                //Log.Message(__result.ToString() + "i");

                __result *= (float)(1.0f + (0.01 * pawnlvcomp.STR));
                //Log.Message(__result.ToString() + "in postfix");
            }
        }
Пример #5
0
            private static float AdjustedToolArmourPenetration(float armourPenetration, VerbProperties instance, Tool tool, Pawn attacker, Thing equipment, HediffComp_VerbGiver hediffCompSource)
            {
                // Scale AP with stuff and pawn age
                if (TinyTweaksSettings.meleeArmourPenetrationFix && armourPenetration > -1)
                {
                    // Factor in equipment stuff
                    if (equipment != null && equipment.Stuff != null && instance.meleeDamageDef != null)
                    {
                        armourPenetration *= equipment.Stuff.GetStatValueAbstract(instance.meleeDamageDef.armorCategory.multStat);
                    }

                    // Factor in attacker
                    if (attacker != null)
                    {
                        armourPenetration *= instance.GetDamageFactorFor(tool, attacker, hediffCompSource);
                    }
                }
                return(armourPenetration);
            }
Пример #6
0
        public static void AdjustedArmorPenetration_RendingWeapon_Postfix(ref VerbProperties __instance, Tool tool, Pawn attacker, Thing equipment, HediffComp_VerbGiver hediffCompSource, ref float __result)
        {
            if (tool != null)
            {
                if (!tool.capacities.NullOrEmpty())
                {
                    if (tool.capacities.Any(x => x.defName.Contains("OG_RendingWeapon")))
                    {
                        float RendingChance = 0.167f;

                        if (equipment != null)
                        {
                            CompWeapon_MeleeSpecialRules _MeleeSpecialRules = equipment?.TryGetComp <CompWeapon_MeleeSpecialRules>();
                            if (_MeleeSpecialRules != null)
                            {
                                RendingChance = _MeleeSpecialRules.RendingChance;
                            }
                        }
                        else
                        {
                            if (attacker != null)
                            {
                                foreach (Tool item in attacker.Tools.Where(x => x != tool))
                                {
                                    if (item.capacities.Any(x => x.defName.Contains("OG_RendingWeapon")))
                                    {
                                        RendingChance += 0.167f;
                                    }
                                }
                            }
                        }

                        if (Rand.Chance(RendingChance))
                        {
                            MoteMaker.ThrowText(attacker.Position.ToVector3(), attacker.MapHeld, "AMA_Rending_Strike".Translate(), 3f);
                            __result = 2f;
                            return;
                        }
                    }
                }
            }

            /*
             * if (__instance.EquipmentSource != null)
             * {
             *  if (!__instance.EquipmentSource.AllComps.NullOrEmpty())
             *  {
             *      if (__instance.EquipmentSource.GetComp<CompWeapon_MeleeSpecialRules>() != null)
             *      {
             *          if (__instance.EquipmentSource.GetComp<CompWeapon_MeleeSpecialRules>() is CompWeapon_MeleeSpecialRules WeaponRules)
             *          {
             *              if (AMASettings.Instance.AllowRendingMeleeEffect)
             *              {
             *                  bool RendingAttack = __result.Any(x => x.Def.rendingWeapon());
             *                  if (WeaponRules.RendingWeapon && RendingAttack && __instance.CasterPawn is Pawn Caster)
             *                  {
             *
             *                  }
             *              }
             *          }
             *      }
             *  }
             * }
             */
        }
        public float AdjustedArmorPenetrationCE(ToolCE tool, Pawn attacker, Thing equipment, HediffComp_VerbGiver hediffCompSource)
        {
            float num;

            if (tool != null)
            {
                num = tool.armorPenetration;
            }
            else
            {
                num = this.meleeArmorPenetrationBase;
            }
            if (num < 0f)
            {
                float num2 = this.AdjustedMeleeDamageAmount(tool, attacker, equipment, hediffCompSource);
                num = num2 * 0.015f;
            }
            return(num);
        }
 private static void VerbProperties_GetDamageFactorForPostfix(VerbProperties __instance, Tool tool, Pawn attacker, HediffComp_VerbGiver hediffCompSource, ref float __result)
 {
     if (tool == null && __instance.linkedBodyPartsGroup != null)
     {
         float damageFactor = PawnCapacityUtility.CalculateNaturalPartsAverageEfficiency(attacker.health.hediffSet, __instance.linkedBodyPartsGroup);
         if (__instance.ensureLinkedBodyPartsGroupAlwaysUsable)
         {
             return;
         }
         else if (damageFactor == 0f)
         {
             __result = 0f;
             return;
         }
     }
     return;
 }