예제 #1
0
        public static float getMeleeDPSBiased(ThingWithComps weapon, Pawn pawn, float speedBias, float averageSpeed)
        {
            //nicked from StatWorker_MeleeAverageDPS
            List <VerbProperties> verbProps;
            List <Tool>           tools;

            GetVerbsAndTools(weapon, out verbProps, out tools);
            float damage = (from x in VerbUtility.GetAllVerbProperties(verbProps, tools)
                            where x.verbProps.IsMeleeAttack
                            select x).AverageWeighted((VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedMeleeSelectionWeight(x.tool, pawn, weapon, null, false), (VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedMeleeDamageAmount(x.tool, pawn, weapon, null));
            float speed     = MeleeSpeed(weapon, pawn);
            float speedBase = speed;

            float diffFromAverage = speed - averageSpeed;

            diffFromAverage *= (speedBias - 1);
            speed           += diffFromAverage;

            //Log.Message(weapon.LabelCap + " damage:" + damage + " spdfac:" + speed + " spdFacBase:" + speedBase);
            if (speed == 0f)
            {
                return(0f);
            }
            return(damage / speed);
        }
예제 #2
0
        public override float GetValueUnfinalized(StatRequest req, bool applyPostProcess = true)
        {
            ThingDef thingDef = req.Def as ThingDef;

            if (thingDef == null)
            {
                return(0f);
            }
            List <VerbProperties> verbProps;
            List <Tool>           tools;

            this.GetVerbsAndTools(thingDef, out verbProps, out tools);
            Pawn  attacker = StatWorker_MeleeAverageDPS.GetCurrentWeaponUser(req.Thing);
            float num      = (from x in VerbUtility.GetAllVerbProperties(verbProps, tools)
                              where x.verbProps.IsMeleeAttack
                              select x).AverageWeighted((VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedMeleeSelectionWeight(x.tool, attacker, req.Thing, null, false), (VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedMeleeDamageAmount(x.tool, attacker, req.Thing, null));
            float num2 = (from x in VerbUtility.GetAllVerbProperties(verbProps, tools)
                          where x.verbProps.IsMeleeAttack
                          select x).AverageWeighted((VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedMeleeSelectionWeight(x.tool, attacker, req.Thing, null, false), (VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedCooldown(x.tool, attacker, req.Thing));

            if (num2 == 0f)
            {
                return(0f);
            }
            return(num / num2);
        }
예제 #3
0
        public static float MeleePenetration(ThingWithComps weapon, Pawn pawn)
        {
            GetVerbsAndTools(weapon, out List <VerbProperties> verbProps, out List <Tool> tools);
            float penetration = VerbUtility.GetAllVerbProperties(verbProps, tools).Where(x => x.verbProps.IsMeleeAttack).AverageWeighted(x => x.verbProps.AdjustedMeleeSelectionWeight(x.tool, pawn, weapon, null, false), x => x.verbProps.AdjustedArmorPenetration(x.tool, pawn, weapon, null));

            return(penetration);
        }
예제 #4
0
        public static float MeleeSpeed(ThingWithComps weapon, Pawn pawn)
        {
            List <VerbProperties> verbProps;
            List <Tool>           tools;

            GetVerbsAndTools(weapon, out verbProps, out tools);
            float speed = (from x in VerbUtility.GetAllVerbProperties(verbProps, tools)
                           where x.verbProps.IsMeleeAttack
                           select x).AverageWeighted((VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedMeleeSelectionWeight(x.tool, pawn, weapon, null, false), (VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedCooldown(x.tool, pawn, weapon));

            return(speed);
        }
예제 #5
0
        public override float GetValueUnfinalized(StatRequest req, bool applyPostProcess = true)
        {
            ThingDef thingDef = req.Def as ThingDef;

            if (thingDef == null)
            {
                return(0f);
            }
            Pawn attacker = StatWorker_MeleeAverageDPS.GetCurrentWeaponUser(req.Thing);

            return((from x in VerbUtility.GetAllVerbProperties(thingDef.Verbs, thingDef.tools)
                    where x.verbProps.IsMeleeAttack
                    select x).AverageWeighted((VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedMeleeSelectionWeight(x.tool, attacker, req.Thing, null, false), (VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedArmorPenetration(x.tool, attacker, req.Thing, null)));
        }
예제 #6
0
        public static float getMeleeDPSBiased(ThingWithComps weapon, Pawn pawn, float speedBias, float averageSpeed)
        {
            //nicked from StatWorker_MeleeAverageDPS
            GetVerbsAndTools(weapon, out List <VerbProperties> verbProps, out List <Tool> tools);
            float damage      = VerbUtility.GetAllVerbProperties(verbProps, tools).Where(x => x.verbProps.IsMeleeAttack).AverageWeighted(x => x.verbProps.AdjustedMeleeSelectionWeight(x.tool, pawn, weapon, null, false), x => x.verbProps.AdjustedMeleeDamageAmount(x.tool, pawn, weapon, null));
            float speed       = MeleeSpeed(weapon, pawn);
            float penetration = MeleePenetration(weapon, pawn);
            float speedBase   = speed;

            float diffFromAverage = speed - averageSpeed;

            diffFromAverage *= (speedBias - 1);
            speed           += diffFromAverage;

            if (speed == 0f)
            {
                return(0f);
            }
            return((damage + (damage * penetration)) / speed);
        }
예제 #7
0
        public override float GetValueUnfinalized(StatRequest req, bool applyPostProcess = true)
        {
            ThingDef thingDef = req.Def as ThingDef;

            if (thingDef == null)
            {
                return(0f);
            }
            GetVerbsAndTools(thingDef, out List <VerbProperties> verbs, out List <Tool> tools);
            if (req.Thing != null)
            {
                Pawn  attacker = GetCurrentWeaponUser(req.Thing);
                float num      = (from x in VerbUtility.GetAllVerbProperties(verbs, tools)
                                  where x.verbProps.IsMeleeAttack
                                  select x).AverageWeighted((VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedMeleeSelectionWeight(x.tool, attacker, req.Thing, null, comesFromPawnNativeVerbs: false), (VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedMeleeDamageAmount(x.tool, attacker, req.Thing, null));
                float num2 = (from x in VerbUtility.GetAllVerbProperties(verbs, tools)
                              where x.verbProps.IsMeleeAttack
                              select x).AverageWeighted((VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedMeleeSelectionWeight(x.tool, attacker, req.Thing, null, comesFromPawnNativeVerbs: false), (VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedCooldown(x.tool, attacker, req.Thing));
                if (num2 == 0f)
                {
                    return(0f);
                }
                return(num / num2);
            }
            float num3 = (from x in VerbUtility.GetAllVerbProperties(verbs, tools)
                          where x.verbProps.IsMeleeAttack
                          select x).AverageWeighted((VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedMeleeSelectionWeight_NewTmp(x.tool, null, thingDef, req.StuffDef, null, comesFromPawnNativeVerbs: false), (VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedMeleeDamageAmount_NewTmp(x.tool, null, thingDef, req.StuffDef, null));
            float num4 = (from x in VerbUtility.GetAllVerbProperties(verbs, tools)
                          where x.verbProps.IsMeleeAttack
                          select x).AverageWeighted((VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedMeleeSelectionWeight_NewTmp(x.tool, null, thingDef, req.StuffDef, null, comesFromPawnNativeVerbs: false), (VerbUtility.VerbPropertiesWithSource x) => x.verbProps.AdjustedCooldown_NewTmp(x.tool, null, thingDef, req.StuffDef));

            if (num4 == 0f)
            {
                return(0f);
            }
            return(num3 / num4);
        }
        public override string GetExplanationUnfinalized(StatRequest req, ToStringNumberSense numberSense)
        {
            ThingDef thingDef = req.Def as ThingDef;

            if (thingDef == null)
            {
                return(null);
            }
            Pawn currentWeaponUser = StatWorker_MeleeAverageDPS.GetCurrentWeaponUser(req.Thing);
            IEnumerable <VerbUtility.VerbPropertiesWithSource> enumerable = from x in VerbUtility.GetAllVerbProperties(thingDef.Verbs, thingDef.tools)
                                                                            where x.verbProps.IsMeleeAttack
                                                                            select x;
            StringBuilder stringBuilder = new StringBuilder();

            foreach (VerbUtility.VerbPropertiesWithSource current in enumerable)
            {
                float num  = current.verbProps.AdjustedMeleeDamageAmount(current.tool, currentWeaponUser, req.Thing, null);
                float num2 = current.verbProps.AdjustedCooldown(current.tool, currentWeaponUser, req.Thing);
                if (current.tool != null)
                {
                    stringBuilder.AppendLine(string.Format("  {0}: {1} ({2})", "Tool".Translate(), current.tool.LabelCap, current.ToolCapacity.defName));
                }
                else
                {
                    stringBuilder.AppendLine(string.Format("  {0}:", "StatsReport_NonToolAttack".Translate()));
                }
                stringBuilder.AppendLine(string.Format("    {0} {1}", num.ToString("F1"), "DamageLower".Translate()));
                stringBuilder.AppendLine(string.Format("    {0} {1}", num2.ToString("F2"), "SecondsPerAttackLower".Translate()));
                stringBuilder.AppendLine();
            }
            return(stringBuilder.ToString());
        }
예제 #9
0
        public override string GetExplanationUnfinalized(StatRequest req, ToStringNumberSense numberSense)
        {
            ThingDef thingDef = req.Def as ThingDef;

            if (thingDef == null)
            {
                return(null);
            }
            GetVerbsAndTools(thingDef, out List <VerbProperties> verbs, out List <Tool> tools);
            Pawn currentWeaponUser = GetCurrentWeaponUser(req.Thing);
            IEnumerable <VerbUtility.VerbPropertiesWithSource> enumerable = from x in VerbUtility.GetAllVerbProperties(verbs, tools)
                                                                            where x.verbProps.IsMeleeAttack
                                                                            select x;
            StringBuilder stringBuilder = new StringBuilder();

            foreach (VerbUtility.VerbPropertiesWithSource item in enumerable)
            {
                float num  = item.verbProps.AdjustedMeleeDamageAmount(item.tool, currentWeaponUser, req.Thing, null);
                float num2 = item.verbProps.AdjustedCooldown(item.tool, currentWeaponUser, req.Thing);
                if (item.tool != null)
                {
                    stringBuilder.AppendLine($"  {item.tool.LabelCap} ({item.ToolCapacity.label})");
                }
                else
                {
                    stringBuilder.AppendLine(string.Format("  {0}:", "StatsReport_NonToolAttack".Translate()));
                }
                stringBuilder.AppendLine(string.Format("    {0} {1}", num.ToString("F1"), "DamageLower".Translate()));
                stringBuilder.AppendLine(string.Format("    {0} {1}", num2.ToString("F2"), "SecondsPerAttackLower".Translate()));
            }
            return(stringBuilder.ToString());
        }
예제 #10
0
        public override string GetExplanationUnfinalized(StatRequest req, ToStringNumberSense numberSense)
        {
            ThingDef thingDef = req.Def as ThingDef;

            if (thingDef == null)
            {
                return(null);
            }
            Pawn currentWeaponUser = StatWorker_MeleeAverageDPS.GetCurrentWeaponUser(req.Thing);
            IEnumerable <VerbUtility.VerbPropertiesWithSource> enumerable = from x in VerbUtility.GetAllVerbProperties(thingDef.Verbs, thingDef.tools)
                                                                            where x.verbProps.IsMeleeAttack
                                                                            select x;
            StringBuilder stringBuilder = new StringBuilder();

            foreach (VerbUtility.VerbPropertiesWithSource item in enumerable)
            {
                float f = item.verbProps.AdjustedArmorPenetration(item.tool, currentWeaponUser, req.Thing, null);
                if (item.tool != null)
                {
                    stringBuilder.AppendLine($"  {item.tool.LabelCap} ({item.ToolCapacity.label})");
                }
                else
                {
                    stringBuilder.AppendLine(string.Format("  {0}:", "StatsReport_NonToolAttack".Translate()));
                }
                stringBuilder.AppendLine("    " + f.ToStringPercent());
            }
            return(stringBuilder.ToString());
        }