Agent Driven Properties Questions

Users who are viewing this thread

Hi guys, i need some information regarding the SetAIRelatedProperties method

Code:
protected void SetAiRelatedProperties(Agent agent, AgentDrivenProperties agentDrivenProperties, WeaponComponentData equippedItem, WeaponComponentData secondaryItem)
        {
            int meleeSkill = this.GetMeleeSkill(agent, equippedItem, secondaryItem);
            SkillObject skill = (equippedItem == null) ? DefaultSkills.Athletics : equippedItem.RelevantSkill;
            int effectiveSkill = this.GetEffectiveSkill(agent.Character, agent.Origin, agent.Formation, skill);
            float num = this.CalculateAILevel(agent, meleeSkill);
            float num2 = this.CalculateAILevel(agent, effectiveSkill);
            float num3 = num + agent.Defensiveness;
            agentDrivenProperties.AiRangedHorsebackMissileRange = 0.3f + 0.4f * num2;
            agentDrivenProperties.AiFacingMissileWatch = -0.96f + num * 0.06f;
            agentDrivenProperties.AiFlyingMissileCheckRadius = 8f - 6f * num;
            agentDrivenProperties.AiShootFreq = 0.3f + 0.7f * num2;
            agentDrivenProperties.AiWaitBeforeShootFactor = (agent._propertyModifiers.resetAiWaitBeforeShootFactor ? 0f : (1f - 0.5f * num2));
            bool flag = secondaryItem != null;
            agentDrivenProperties.AIBlockOnDecideAbility = MBMath.Lerp(0.25f, 0.99f, MBMath.ClampFloat((float)Math.Pow((double)num, 1.0), 0f, 1f), 1E-05f);
            agentDrivenProperties.AIParryOnDecideAbility = MBMath.Lerp(0.01f, 0.95f, MBMath.ClampFloat((float)Math.Pow((double)num, 1.5), 0f, 1f), 1E-05f);
            agentDrivenProperties.AiTryChamberAttackOnDecide = (num - 0.15f) * 0.1f;
            agentDrivenProperties.AIAttackOnParryChance = 0.3f - 0.1f * agent.Defensiveness;
            agentDrivenProperties.AiAttackOnParryTiming = -0.2f + 0.3f * num;
            agentDrivenProperties.AIDecideOnAttackChance = 0.15f * agent.Defensiveness;
            agentDrivenProperties.AIParryOnAttackAbility = MBMath.ClampFloat((float)Math.Pow((double)num, 3.0), 0f, 1f);
            agentDrivenProperties.AiKick = -0.1f + ((num > 0.4f) ? 0.4f : num);
            agentDrivenProperties.AiAttackCalculationMaxTimeFactor = num;
            agentDrivenProperties.AiDecideOnAttackWhenReceiveHitTiming = -0.25f * (1f - num);
            agentDrivenProperties.AiDecideOnAttackContinueAction = -0.5f * (1f - num);
            agentDrivenProperties.AiDecideOnAttackingContinue = 0.1f * num;
            agentDrivenProperties.AIParryOnAttackingContinueAbility = MBMath.Lerp(0.05f, 0.95f, MBMath.ClampFloat((float)Math.Pow((double)num, 3.0), 0f, 1f), 1E-05f);
            agentDrivenProperties.AIDecideOnRealizeEnemyBlockingAttackAbility = 0.5f * MBMath.ClampFloat((float)Math.Pow((double)num, 2.5) - 0.1f, 0f, 1f);
            agentDrivenProperties.AIRealizeBlockingFromIncorrectSideAbility = 0.5f * MBMath.ClampFloat((float)Math.Pow((double)num, 2.5) - 0.1f, 0f, 1f);
            agentDrivenProperties.AiAttackingShieldDefenseChance = 0.2f + 0.3f * num;
            agentDrivenProperties.AiAttackingShieldDefenseTimer = -0.3f + 0.3f * num;
            agentDrivenProperties.AiRandomizedDefendDirectionChance = 1f - (float)Math.Log((double)num * 7.0 + 1.0, 2.0) * 0.33333f;
            agentDrivenProperties.AISetNoAttackTimerAfterBeingHitAbility = MBMath.ClampFloat((float)Math.Pow((double)num, 2.0), 0.05f, 0.95f);
            agentDrivenProperties.AISetNoAttackTimerAfterBeingParriedAbility = MBMath.ClampFloat((float)Math.Pow((double)num, 2.0), 0.05f, 0.95f);
            agentDrivenProperties.AISetNoDefendTimerAfterHittingAbility = MBMath.ClampFloat((float)Math.Pow((double)num, 2.0), 0.05f, 0.95f);
            agentDrivenProperties.AISetNoDefendTimerAfterParryingAbility = MBMath.ClampFloat((float)Math.Pow((double)num, 2.0), 0.05f, 0.95f);
            agentDrivenProperties.AIEstimateStunDurationPrecision = 1f - MBMath.ClampFloat((float)Math.Pow((double)num, 2.0), 0.05f, 0.95f);
            agentDrivenProperties.AIHoldingReadyMaxDuration = MBMath.Lerp(0.25f, 0f, Math.Min(1f, num * 1.2f), 1E-05f);
            agentDrivenProperties.AIHoldingReadyVariationPercentage = num;
            agentDrivenProperties.AiRaiseShieldDelayTimeBase = -0.75f + 0.5f * num;
            agentDrivenProperties.AiUseShieldAgainstEnemyMissileProbability = 0.1f + num * 0.6f + num3 * 0.2f;
            agentDrivenProperties.AiCheckMovementIntervalFactor = 0.005f * (1.1f - num);
            agentDrivenProperties.AiMovemetDelayFactor = 4f / (3f + num2);
            agentDrivenProperties.AiParryDecisionChangeValue = 0.05f + 0.7f * num;
            agentDrivenProperties.AiDefendWithShieldDecisionChanceValue = Math.Min(1f, 0.2f + 0.5f * num + 0.2f * num3);
            agentDrivenProperties.AiMoveEnemySideTimeValue = -2.5f + 0.5f * num;
            agentDrivenProperties.AiMinimumDistanceToContinueFactor = 2f + 0.3f * (3f - num);
            agentDrivenProperties.AiStandGroundTimerValue = 0.5f * (-1f + num);
            agentDrivenProperties.AiStandGroundTimerMoveAlongValue = -1f + 0.5f * num;
            agentDrivenProperties.AiHearingDistanceFactor = 1f + num;
            agentDrivenProperties.AiChargeHorsebackTargetDistFactor = 1.5f * (3f - num);
            agentDrivenProperties.AiWaitBeforeShootFactor = (agent._propertyModifiers.resetAiWaitBeforeShootFactor ? 0f : (1f - 0.5f * num2));
            float num4 = 1f - num2;
            agentDrivenProperties.AiRangerLeadErrorMin = -num4 * 0.35f;
            agentDrivenProperties.AiRangerLeadErrorMax = num4 * 0.2f;
            agentDrivenProperties.AiRangerVerticalErrorMultiplier = num4 * 0.1f;
            agentDrivenProperties.AiRangerHorizontalErrorMultiplier = num4 * 0.0349065848f;
            agentDrivenProperties.AIAttackOnDecideChance = MathF.Clamp(0.23f * this.CalculateAIAttackOnDecideMaxValue() * (3f - agent.Defensiveness), 0.05f, 1f);
            agentDrivenProperties.SetStat(DrivenProperty.UseRealisticBlocking, (agent.Controller != Agent.ControllerType.Player) ? 1f : 0f);
        }

1. Where does this Method gets his agent.defensiveness from? Is it related to the Formation class or(in that case its 0 or 1)?
2. Some of these Properties will get negative like the "agentDrivenProperties.AiRaiseShieldDelayTimeBase = -0.75f + 0.5f * num;" , what does that mean? All Troops with a skill under 340 will have a malus in that regard?
3. Where can i find the distance checks? Especally for those with long two handers and Polearms? Because in that regard the Ai just run to close to actually swing effectivley. Or better the just run forward without positioning themselves correctly.(Edit: Maybe this case can be solved in the MovementOrder class)




4. Regarding the GetMeleeSkill Method, why does the method needs two items? If I read this Method the right way, a guy with a 2h weapon will only get the skillpoints(2h) for further mathematics if his second weapon is =null, otherwise he gets the one handed skill points. So nearly every 2h buddy will be wrong calculated, since all have throwing weapons or a 1h in their second slot.(If i read this method in the right way).
Code:
protected int GetMeleeSkill(Agent agent, WeaponComponentData equippedItem, WeaponComponentData secondaryItem)
        {
            SkillObject skill = DefaultSkills.Athletics;
            if (equippedItem != null)
            {
                SkillObject relevantSkill = equippedItem.RelevantSkill;   //1h, 2h, Polearm
                if (relevantSkill == DefaultSkills.OneHanded || relevantSkill == DefaultSkills.Polearm)   //Correct
                {
                    skill = relevantSkill;
                }
                else if (relevantSkill == DefaultSkills.TwoHanded)
                {
                    skill = ((secondaryItem == null) ? DefaultSkills.TwoHanded : DefaultSkills.OneHanded);  //This Part is where I struggle
                }
                else
                {
                    skill = DefaultSkills.OneHanded;
                }
            }
            return this.GetEffectiveSkill(agent.Character, agent.Origin, agent.Formation, skill);
        }

Im looking forward to your answers. Thank you
 
Back
Top Bottom