private void ReplaceTools(AlienRace.ThingDef_AlienRace race)
        {
            // tools - li Class CombatExtended.ToolCE / armorPenetration
            var oldTools = race.tools.ToList();

            foreach (var tool in oldTools)
            {
                if (tool is ToolCE)
                {
                    continue;
                }

                trace.AppendLine($"* Replacing race tool {tool}");

                var newTool = new ToolCE
                {
                    label             = tool.label,
                    untranslatedLabel = tool.untranslatedLabel,

                    alwaysTreatAsWeapon = tool.alwaysTreatAsWeapon,
                    capacities          = tool.capacities,
                    chanceFactor        = tool.chanceFactor,
                    cooldownTime        = tool.cooldownTime,
                    ensureLinkedBodyPartsGroupAlwaysUsable = tool.ensureLinkedBodyPartsGroupAlwaysUsable,
                    id = tool.id,
                    labelUsedInLogging   = tool.labelUsedInLogging,
                    linkedBodyPartsGroup = tool.linkedBodyPartsGroup,
                    power          = tool.power,
                    surpriseAttack = tool.surpriseAttack,
                    hediff         = tool.hediff,

                    armorPenetration = 0.10f,
                };
                trace.AppendLine("Initialized new tool");

                race.tools.Remove(tool);
                trace.AppendLine("Removed existing tool");

                race.tools.Add(newTool);
                trace.AppendLine($"Added new tool {newTool}");
            }
        }
Example #2
0
        public static void Postfix(ref VerbPropertiesCE __instance, Verb ownerVerb, Pawn attacker, ref float __result)
        {
            ToolCE tool      = ownerVerb.tool as ToolCE;
            Thing  equipment = ownerVerb.EquipmentSource;

            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?.TryGetCompFast <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;
                                    }
                                }
                            }
                        }

                        Rand.PushState();
                        bool rend = Rand.Chance(RendingChance);
                        Rand.PopState();
                        if (rend)
                        {
                            //    MoteMaker.ThrowText(attacker.Position.ToVector3(), attacker.MapHeld, "AdeptusMechanicus.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)
             *                  {
             *
             *                  }
             *              }
             *          }
             *      }
             *  }
             * }
             */
        }