private void FillAgentStatsFromData( ref AgentDrivenProperties agentDrivenProperties, MultiplayerClassDivisions.MPHeroClass heroClass, MissionPeer missionPeer, MissionPeer owningMissionPeer) { MissionPeer peer = missionPeer ?? owningMissionPeer; if (peer != null) { MPPerkObject.MPOnSpawnPerkHandler spawnPerkHandler = MPPerkObject.GetOnSpawnPerkHandler(peer); bool isPlayer = missionPeer != null; for (int index = 0; index < 56; ++index) { DrivenProperty drivenProperty = (DrivenProperty)index; float stat = agentDrivenProperties.GetStat(drivenProperty); if (drivenProperty == DrivenProperty.ArmorHead || drivenProperty == DrivenProperty.ArmorTorso || (drivenProperty == DrivenProperty.ArmorLegs || drivenProperty == DrivenProperty.ArmorArms)) { agentDrivenProperties.SetStat(drivenProperty, stat + (float)heroClass.ArmorValue + spawnPerkHandler.GetDrivenPropertyBonusOnSpawn(isPlayer, drivenProperty, stat)); } else { agentDrivenProperties.SetStat(drivenProperty, stat + spawnPerkHandler.GetDrivenPropertyBonusOnSpawn(isPlayer, drivenProperty, stat)); } } } agentDrivenProperties.TopSpeedReachDuration = heroClass.TopSpeedReachDuration; float managedParameter1 = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.BipedalCombatSpeedMinMultiplier); float managedParameter2 = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.BipedalCombatSpeedMaxMultiplier); agentDrivenProperties.CombatMaxSpeedMultiplier = managedParameter1 + (managedParameter2 - managedParameter1) * heroClass.CombatMovementSpeedMultiplier; }
private static void InitializeHorseAgentStats( Agent agent, Equipment spawnEquipment, AgentDrivenProperties agentDrivenProperties) { AgentDrivenProperties drivenProperties1 = agentDrivenProperties; EquipmentElement equipmentElement1 = spawnEquipment[EquipmentIndex.ArmorItemEndSlot]; HorseComponent horseComponent1 = equipmentElement1.Item.HorseComponent; int num1 = horseComponent1 != null ? horseComponent1.Monster.FamilyType : 0; drivenProperties1.AiSpeciesIndex = num1; AgentDrivenProperties drivenProperties2 = agentDrivenProperties; equipmentElement1 = spawnEquipment[EquipmentIndex.HorseHarness]; double num2 = 0.800000011920929 + (equipmentElement1.Item != null ? 0.200000002980232 : 0.0); drivenProperties2.AttributeRiding = (float)num2; float num3 = 0.0f; for (int index = 1; index < 12; ++index) { equipmentElement1 = spawnEquipment[index]; if (equipmentElement1.Item != null) { double num4 = (double)num3; equipmentElement1 = spawnEquipment[index]; double modifiedMountBodyArmor = (double)equipmentElement1.GetModifiedMountBodyArmor(); num3 = (float)(num4 + modifiedMountBodyArmor); } } agentDrivenProperties.ArmorTorso = num3; equipmentElement1 = spawnEquipment[EquipmentIndex.ArmorItemEndSlot]; ItemObject itemObject = equipmentElement1.Item; if (itemObject == null) { return; } HorseComponent horseComponent2 = itemObject.HorseComponent; EquipmentElement mountElement = spawnEquipment[EquipmentIndex.ArmorItemEndSlot]; EquipmentElement equipmentElement2 = spawnEquipment[EquipmentIndex.HorseHarness]; agentDrivenProperties.MountManeuver = (float)mountElement.GetModifiedMountManeuver(in equipmentElement2) * 0.8f; agentDrivenProperties.MountSpeed = (float)(mountElement.GetModifiedMountSpeed(in equipmentElement2) + 1) * 0.2f; agentDrivenProperties.MountChargeDamage = (float)mountElement.GetModifiedMountCharge(in equipmentElement2) * 0.01f; agentDrivenProperties.MountDifficulty = (float)mountElement.Item.Difficulty; Agent riderAgent = agent.RiderAgent; int ridingSkill = riderAgent != null?riderAgent.Character.GetSkillValue(DefaultSkills.Riding) : 0; agentDrivenProperties.TopSpeedReachDuration = Game.Current.BasicModels.RidingModel.CalculateAcceleration(in mountElement, in equipmentElement2, ridingSkill); if (agent.RiderAgent == null) { return; } agentDrivenProperties.MountSpeed *= (float)(1.0 + (double)ridingSkill * (2.0 / 625.0)); agentDrivenProperties.MountManeuver *= (float)(1.0 + (double)ridingSkill * 0.00350000010803342); }
public override void UpdateAgentStats(Agent agent, AgentDrivenProperties agentDrivenProperties) { if (agent.IsHuman) { this.UpdateHumanAgentStats(agent, agentDrivenProperties); } else { if (!agent.IsMount) { return; } this.UpdateMountAgentStats(agent, agentDrivenProperties); } }
private AgentDrivenProperties InitializeHumanAgentStats( Agent agent, AgentDrivenProperties agentDrivenProperties, AgentBuildData agentBuildData) { MultiplayerClassDivisions.MPHeroClass classForCharacter = MultiplayerClassDivisions.GetMPHeroClassForCharacter(agent.Character); if (classForCharacter != null) { this.FillAgentStatsFromData(ref agentDrivenProperties, classForCharacter, agentBuildData?.AgentMissionPeer, agentBuildData?.OwningAgentMissionPeer); agentDrivenProperties.SetStat(DrivenProperty.UseRealisticBlocking, MultiplayerOptions.OptionType.UseRealisticBlocking.GetBoolValue() ? 1f : 0.0f); } agent.BaseHealthLimit = classForCharacter == null ? 100f : (float)classForCharacter.Health; agent.HealthLimit = agent.BaseHealthLimit; agent.Health = agent.HealthLimit; return(agentDrivenProperties); }
private void UpdateMountAgentStats(Agent agent, AgentDrivenProperties agentDrivenProperties) { MPPerkObject.MPPerkHandler perkHandler = MPPerkObject.GetPerkHandler(agent.RiderAgent); EquipmentElement mountElement = agent.SpawnEquipment[EquipmentIndex.ArmorItemEndSlot]; EquipmentElement equipmentElement = agent.SpawnEquipment[EquipmentIndex.HorseHarness]; agentDrivenProperties.MountManeuver = (float)mountElement.GetModifiedMountManeuver(in equipmentElement) * (float)(1.0 + (perkHandler != null ? (double)perkHandler.GetMountManeuver() : 0.0)); agentDrivenProperties.MountSpeed = (float)((double)(mountElement.GetModifiedMountSpeed(in equipmentElement) + 1) * 0.219999998807907 * (1.0 + (perkHandler != null ? (double)perkHandler.GetMountSpeed() : 0.0))); Agent riderAgent = agent.RiderAgent; int ridingSkill = riderAgent != null?riderAgent.Character.GetSkillValue(DefaultSkills.Riding) : 0; agentDrivenProperties.TopSpeedReachDuration = Game.Current.BasicModels.RidingModel.CalculateAcceleration(in mountElement, in equipmentElement, ridingSkill); if (agent.RiderAgent == null) { return; } agentDrivenProperties.MountSpeed *= (float)(1.0 + (double)ridingSkill * (2.0 / 625.0)); agentDrivenProperties.MountManeuver *= (float)(1.0 + (double)ridingSkill * 0.00350000010803342); }
public override void InitializeAgentStats( Agent agent, Equipment spawnEquipment, AgentDrivenProperties agentDrivenProperties, AgentBuildData agentBuildData) { agentDrivenProperties.ArmorEncumbrance = spawnEquipment.GetTotalWeightOfArmor(agent.IsHuman); if (!agent.IsHuman) { MultiplayerAgentStatCalculateModel.InitializeHorseAgentStats(agent, spawnEquipment, agentDrivenProperties); } else { agentDrivenProperties = this.InitializeHumanAgentStats(agent, agentDrivenProperties, agentBuildData); } foreach (DrivenPropertyBonusAgentComponent bonusAgentComponent in agent.Components.OfType <DrivenPropertyBonusAgentComponent>()) { if (MBMath.IsBetween((int)bonusAgentComponent.DrivenProperty, 0, 56)) { float num = agentDrivenProperties.GetStat(bonusAgentComponent.DrivenProperty) + bonusAgentComponent.DrivenPropertyBonus; agentDrivenProperties.SetStat(bonusAgentComponent.DrivenProperty, num); } } }
private void UpdateHumanAgentStats(Agent agent, AgentDrivenProperties agentDrivenProperties) { MPPerkObject.MPPerkHandler perkHandler = MPPerkObject.GetPerkHandler(agent); BasicCharacterObject character = agent.Character; MissionEquipment equipment = agent.Equipment; float num1 = equipment.GetTotalWeightOfWeapons() * (float)(1.0 + (perkHandler != null ? (double)perkHandler.GetEncumbrance(true) : 0.0)); EquipmentIndex wieldedItemIndex1 = agent.GetWieldedItemIndex(Agent.HandIndex.MainHand); EquipmentIndex wieldedItemIndex2 = agent.GetWieldedItemIndex(Agent.HandIndex.OffHand); if (wieldedItemIndex1 != EquipmentIndex.None) { ItemObject itemObject = equipment[wieldedItemIndex1].Item; WeaponComponent weaponComponent = itemObject.WeaponComponent; float realWeaponLength = weaponComponent.PrimaryWeapon.GetRealWeaponLength(); float num2 = (weaponComponent.GetItemType() == ItemObject.ItemTypeEnum.Bow ? 4f : 1.5f) * itemObject.Weight * MathF.Sqrt(realWeaponLength) * (float)(1.0 + (perkHandler != null ? (double)perkHandler.GetEncumbrance(false) : 0.0)); num1 += num2; } if (wieldedItemIndex2 != EquipmentIndex.None) { float num2 = 1.5f * equipment[wieldedItemIndex2].Item.Weight * (float)(1.0 + (perkHandler != null ? (double)perkHandler.GetEncumbrance(false) : 0.0)); num1 += num2; } agentDrivenProperties.WeaponsEncumbrance = num1; EquipmentIndex wieldedItemIndex3 = agent.GetWieldedItemIndex(Agent.HandIndex.MainHand); WeaponComponentData weaponComponentData = wieldedItemIndex3 != EquipmentIndex.None ? equipment[wieldedItemIndex3].CurrentUsageItem : (WeaponComponentData)null; ItemObject primaryItem = wieldedItemIndex3 != EquipmentIndex.None ? equipment[wieldedItemIndex3].Item : (ItemObject)null; EquipmentIndex wieldedItemIndex4 = agent.GetWieldedItemIndex(Agent.HandIndex.OffHand); WeaponComponentData secondaryItem = wieldedItemIndex4 != EquipmentIndex.None ? equipment[wieldedItemIndex4].CurrentUsageItem : (WeaponComponentData)null; float inaccuracy; agentDrivenProperties.LongestRangedWeaponSlotIndex = (float)equipment.GetLongestRangedWeaponWithAimingError(out inaccuracy, agent); agentDrivenProperties.LongestRangedWeaponInaccuracy = inaccuracy; agentDrivenProperties.SwingSpeedMultiplier = (float)(0.930000007152557 + 0.000699999975040555 * (double)this.GetSkillValueForItem(character, primaryItem)); agentDrivenProperties.ThrustOrRangedReadySpeedMultiplier = agentDrivenProperties.SwingSpeedMultiplier; agentDrivenProperties.HandlingMultiplier = 1f; agentDrivenProperties.ShieldBashStunDurationMultiplier = 1f; agentDrivenProperties.KickStunDurationMultiplier = 1f; agentDrivenProperties.ReloadSpeed = (float)(0.930000007152557 + 0.000699999975040555 * (double)this.GetSkillValueForItem(character, primaryItem)); agentDrivenProperties.ReloadMovementPenaltyFactor = 1f; agentDrivenProperties.WeaponInaccuracy = 0.0f; MultiplayerClassDivisions.MPHeroClass classForCharacter = MultiplayerClassDivisions.GetMPHeroClassForCharacter(agent.Character); agentDrivenProperties.MaxSpeedMultiplier = (float)(1.04999995231628 * ((double)classForCharacter.MovementSpeedMultiplier * (100.0 / (100.0 + (double)num1)))); int skillValue = character.GetSkillValue(DefaultSkills.Riding); bool flag1 = false; bool flag2 = false; if (weaponComponentData != null) { int weaponSkill = character.GetSkillValue(weaponComponentData.RelevantSkill); if (weaponSkill > 0 && weaponComponentData.IsRangedWeapon && perkHandler != null) { weaponSkill = MathF.Ceiling((float)weaponSkill * (perkHandler.GetRangedAccuracy() + 1f)); } int thrustSpeed = weaponComponentData.ThrustSpeed; agentDrivenProperties.WeaponInaccuracy = this.GetWeaponInaccuracy(agent, weaponComponentData, weaponSkill); if (weaponComponentData.IsRangedWeapon) { agentDrivenProperties.WeaponMaxMovementAccuracyPenalty = (float)(500 - weaponSkill) * 0.00025f; agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty = (float)(500 - weaponSkill) * 0.0002f; if (agent.HasMount) { agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= Math.Max(1f, (float)(700 - weaponSkill - skillValue) * (3f / 1000f)); agentDrivenProperties.WeaponMaxMovementAccuracyPenalty *= Math.Max(1f, (float)(700 - weaponSkill - skillValue) * 0.0033f); } else if (weaponComponentData.RelevantSkill == DefaultSkills.Bow) { agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= 4.5f / MBMath.Lerp(0.75f, 2f, (float)(((double)thrustSpeed - 60.0) / 75.0)); agentDrivenProperties.WeaponMaxMovementAccuracyPenalty *= 6f; } else if (weaponComponentData.RelevantSkill == DefaultSkills.Crossbow) { agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= 1.2f; agentDrivenProperties.WeaponMaxMovementAccuracyPenalty *= 2.5f; } else if (weaponComponentData.RelevantSkill == DefaultSkills.Throwing) { agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= 3.5f * MBMath.Lerp(1.5f, 0.8f, (float)(((double)thrustSpeed - 89.0) / 13.0)); } if (weaponComponentData.WeaponClass == WeaponClass.Bow) { flag1 = true; agentDrivenProperties.WeaponBestAccuracyWaitTime = (float)(0.300000011920929 + (95.75 - (double)thrustSpeed) * 0.00499999988824129); agentDrivenProperties.WeaponUnsteadyBeginTime = (float)(0.100000001490116 + (double)weaponSkill * 0.00999999977648258 * (double)MBMath.Lerp(1f, 2f, (float)(((double)thrustSpeed - 60.0) / 75.0))); if (agent.IsAIControlled) { agentDrivenProperties.WeaponUnsteadyBeginTime *= 4f; } agentDrivenProperties.WeaponUnsteadyEndTime = 2f + agentDrivenProperties.WeaponUnsteadyBeginTime; agentDrivenProperties.WeaponRotationalAccuracyPenaltyInRadians = 0.1f; } else if (weaponComponentData.WeaponClass == WeaponClass.Javelin || weaponComponentData.WeaponClass == WeaponClass.ThrowingAxe || weaponComponentData.WeaponClass == WeaponClass.ThrowingKnife) { agentDrivenProperties.WeaponBestAccuracyWaitTime = (float)(0.400000005960464 + (89.0 - (double)thrustSpeed) * 0.0299999993294477); agentDrivenProperties.WeaponUnsteadyBeginTime = (float)(2.5 + (double)weaponSkill * 0.00999999977648258); agentDrivenProperties.WeaponUnsteadyEndTime = 10f + agentDrivenProperties.WeaponUnsteadyBeginTime; agentDrivenProperties.WeaponRotationalAccuracyPenaltyInRadians = 0.025f; } else { agentDrivenProperties.WeaponBestAccuracyWaitTime = 0.1f; agentDrivenProperties.WeaponUnsteadyBeginTime = 0.0f; agentDrivenProperties.WeaponUnsteadyEndTime = 0.0f; agentDrivenProperties.WeaponRotationalAccuracyPenaltyInRadians = 0.1f; } } else if (weaponComponentData.WeaponFlags.HasAllFlags <WeaponFlags>(WeaponFlags.WideGrip)) { flag2 = true; agentDrivenProperties.WeaponUnsteadyBeginTime = (float)(1.0 + (double)weaponSkill * 0.00499999988824129); agentDrivenProperties.WeaponUnsteadyEndTime = (float)(3.0 + (double)weaponSkill * 0.00999999977648258); } } agentDrivenProperties.AttributeShieldMissileCollisionBodySizeAdder = 0.3f; Agent mountAgent = agent.MountAgent; float num3 = mountAgent != null?mountAgent.GetAgentDrivenPropertyValue(DrivenProperty.AttributeRiding) : 1f; agentDrivenProperties.AttributeRiding = (float)skillValue * num3; agentDrivenProperties.AttributeHorseArchery = Game.Current.BasicModels.StrikeMagnitudeModel.CalculateHorseArcheryFactor(character); agentDrivenProperties.BipedalRangedReadySpeedMultiplier = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.BipedalRangedReadySpeedMultiplier); agentDrivenProperties.BipedalRangedReloadSpeedMultiplier = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.BipedalRangedReloadSpeedMultiplier); foreach (DrivenPropertyBonusAgentComponent bonusAgentComponent in agent.Components.OfType <DrivenPropertyBonusAgentComponent>()) { if (!MBMath.IsBetween((int)bonusAgentComponent.DrivenProperty, 0, 56)) { float num2 = agentDrivenProperties.GetStat(bonusAgentComponent.DrivenProperty) + bonusAgentComponent.DrivenPropertyBonus; agentDrivenProperties.SetStat(bonusAgentComponent.DrivenProperty, num2); } } if (perkHandler != null) { for (int index = 56; index < 85; ++index) { DrivenProperty drivenProperty = (DrivenProperty)index; if (((drivenProperty == DrivenProperty.WeaponUnsteadyBeginTime ? 0 : (drivenProperty != DrivenProperty.WeaponUnsteadyEndTime ? 1 : 0)) | (flag1 ? 1 : 0) | (flag2 ? 1 : 0)) != 0 && drivenProperty != DrivenProperty.WeaponRotationalAccuracyPenaltyInRadians | flag1) { float stat = agentDrivenProperties.GetStat(drivenProperty); agentDrivenProperties.SetStat(drivenProperty, stat + perkHandler.GetDrivenPropertyBonus(drivenProperty, stat)); } } } this.SetAiRelatedProperties(agent, agentDrivenProperties, weaponComponentData, secondaryItem); }
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 aiLevel1 = this.CalculateAILevel(agent, meleeSkill); float aiLevel2 = this.CalculateAILevel(agent, effectiveSkill); float num1 = aiLevel1 + agent.Defensiveness; agentDrivenProperties.AiRangedHorsebackMissileRange = (float)(0.300000011920929 + 0.400000005960464 * (double)aiLevel2); agentDrivenProperties.AiFacingMissileWatch = (float)((double)aiLevel1 * 0.0599999986588955 - 0.959999978542328); agentDrivenProperties.AiFlyingMissileCheckRadius = (float)(8.0 - 6.0 * (double)aiLevel1); agentDrivenProperties.AiShootFreq = (float)(0.300000011920929 + 0.699999988079071 * (double)aiLevel2); agentDrivenProperties.AiWaitBeforeShootFactor = agent._propertyModifiers.resetAiWaitBeforeShootFactor ? 0.0f : (float)(1.0 - 0.5 * (double)aiLevel2); int num2 = secondaryItem != null ? 1 : 0; agentDrivenProperties.AIBlockOnDecideAbility = MBMath.Lerp(0.25f, 0.99f, MBMath.ClampFloat((float)Math.Pow((double)aiLevel1, 1.0), 0.0f, 1f)); agentDrivenProperties.AIParryOnDecideAbility = MBMath.Lerp(0.01f, 0.95f, MBMath.ClampFloat((float)Math.Pow((double)aiLevel1, 1.5), 0.0f, 1f)); agentDrivenProperties.AiTryChamberAttackOnDecide = (float)(((double)aiLevel1 - 0.150000005960464) * 0.100000001490116); agentDrivenProperties.AIAttackOnParryChance = (float)(0.300000011920929 - 0.100000001490116 * (double)agent.Defensiveness); agentDrivenProperties.AiAttackOnParryTiming = (float)(0.300000011920929 * (double)aiLevel1 - 0.200000002980232); agentDrivenProperties.AIDecideOnAttackChance = 0.15f * agent.Defensiveness; agentDrivenProperties.AIParryOnAttackAbility = MBMath.ClampFloat((float)Math.Pow((double)aiLevel1, 3.0), 0.0f, 1f); agentDrivenProperties.AiKick = (float)(((double)aiLevel1 > 0.400000005960464 ? 0.400000005960464 : (double)aiLevel1) - 0.100000001490116); agentDrivenProperties.AiAttackCalculationMaxTimeFactor = aiLevel1; agentDrivenProperties.AiDecideOnAttackWhenReceiveHitTiming = (float)(-0.25 * (1.0 - (double)aiLevel1)); agentDrivenProperties.AiDecideOnAttackContinueAction = (float)(-0.5 * (1.0 - (double)aiLevel1)); agentDrivenProperties.AiDecideOnAttackingContinue = 0.1f * aiLevel1; agentDrivenProperties.AIParryOnAttackingContinueAbility = MBMath.Lerp(0.05f, 0.95f, MBMath.ClampFloat((float)Math.Pow((double)aiLevel1, 3.0), 0.0f, 1f)); agentDrivenProperties.AIDecideOnRealizeEnemyBlockingAttackAbility = 0.5f * MBMath.ClampFloat((float)Math.Pow((double)aiLevel1, 2.5) - 0.1f, 0.0f, 1f); agentDrivenProperties.AIRealizeBlockingFromIncorrectSideAbility = 0.5f * MBMath.ClampFloat((float)Math.Pow((double)aiLevel1, 2.5) - 0.1f, 0.0f, 1f); agentDrivenProperties.AiAttackingShieldDefenseChance = (float)(0.200000002980232 + 0.300000011920929 * (double)aiLevel1); agentDrivenProperties.AiAttackingShieldDefenseTimer = (float)(0.300000011920929 * (double)aiLevel1 - 0.300000011920929); agentDrivenProperties.AiRandomizedDefendDirectionChance = (float)(1.0 - Math.Log((double)aiLevel1 * 7.0 + 1.0, 2.0) * 0.333330005407333); agentDrivenProperties.AISetNoAttackTimerAfterBeingHitAbility = MBMath.ClampFloat((float)Math.Pow((double)aiLevel1, 2.0), 0.05f, 0.95f); agentDrivenProperties.AISetNoAttackTimerAfterBeingParriedAbility = MBMath.ClampFloat((float)Math.Pow((double)aiLevel1, 2.0), 0.05f, 0.95f); agentDrivenProperties.AISetNoDefendTimerAfterHittingAbility = MBMath.ClampFloat((float)Math.Pow((double)aiLevel1, 2.0), 0.05f, 0.95f); agentDrivenProperties.AISetNoDefendTimerAfterParryingAbility = MBMath.ClampFloat((float)Math.Pow((double)aiLevel1, 2.0), 0.05f, 0.95f); agentDrivenProperties.AIEstimateStunDurationPrecision = 1f - MBMath.ClampFloat((float)Math.Pow((double)aiLevel1, 2.0), 0.05f, 0.95f); agentDrivenProperties.AIHoldingReadyMaxDuration = MBMath.Lerp(0.25f, 0.0f, Math.Min(1f, aiLevel1 * 1.2f)); agentDrivenProperties.AIHoldingReadyVariationPercentage = aiLevel1; agentDrivenProperties.AiRaiseShieldDelayTimeBase = (float)(0.5 * (double)aiLevel1 - 0.75); agentDrivenProperties.AiUseShieldAgainstEnemyMissileProbability = (float)(0.100000001490116 + (double)aiLevel1 * 0.600000023841858 + (double)num1 * 0.200000002980232); agentDrivenProperties.AiCheckMovementIntervalFactor = (float)(0.00499999988824129 * (1.10000002384186 - (double)aiLevel1)); agentDrivenProperties.AiMovemetDelayFactor = (float)(4.0 / (3.0 + (double)aiLevel2)); agentDrivenProperties.AiParryDecisionChangeValue = (float)(0.0500000007450581 + 0.699999988079071 * (double)aiLevel1); agentDrivenProperties.AiDefendWithShieldDecisionChanceValue = Math.Min(1f, (float)(0.200000002980232 + 0.5 * (double)aiLevel1 + 0.200000002980232 * (double)num1)); agentDrivenProperties.AiMoveEnemySideTimeValue = (float)(0.5 * (double)aiLevel1 - 2.5); agentDrivenProperties.AiMinimumDistanceToContinueFactor = (float)(2.0 + 0.300000011920929 * (3.0 - (double)aiLevel1)); agentDrivenProperties.AiStandGroundTimerValue = (float)(0.5 * ((double)aiLevel1 - 1.0)); agentDrivenProperties.AiStandGroundTimerMoveAlongValue = (float)(0.5 * (double)aiLevel1 - 1.0); agentDrivenProperties.AiHearingDistanceFactor = 1f + aiLevel1; agentDrivenProperties.AiChargeHorsebackTargetDistFactor = (float)(1.5 * (3.0 - (double)aiLevel1)); agentDrivenProperties.AiWaitBeforeShootFactor = agent._propertyModifiers.resetAiWaitBeforeShootFactor ? 0.0f : (float)(1.0 - 0.5 * (double)aiLevel2); float num3 = 1f - aiLevel2; agentDrivenProperties.AiRangerLeadErrorMin = (float)(-(double)num3 * 0.349999994039536); agentDrivenProperties.AiRangerLeadErrorMax = num3 * 0.2f; agentDrivenProperties.AiRangerVerticalErrorMultiplier = num3 * 0.1f; agentDrivenProperties.AiRangerHorizontalErrorMultiplier = num3 * ((float)Math.PI / 90f); agentDrivenProperties.AIAttackOnDecideChance = MathF.Clamp((float)(0.230000004172325 * (double)this.CalculateAIAttackOnDecideMaxValue() * (3.0 - (double)agent.Defensiveness)), 0.05f, 1f); agentDrivenProperties.SetStat(DrivenProperty.UseRealisticBlocking, agent.Controller != Agent.ControllerType.Player ? 1f : 0.0f); }
public abstract void UpdateAgentStats(Agent agent, AgentDrivenProperties agentDrivenProperties);
public abstract void InitializeAgentStats( Agent agent, Equipment spawnEquipment, AgentDrivenProperties agentDrivenProperties, AgentBuildData agentBuildData);
public override void UpdateAgentStats(Agent agent, AgentDrivenProperties agentDrivenProperties) { if (!agent.IsHuman) { return; } BasicCharacterObject character1 = agent.Character; MissionEquipment equipment = agent.Equipment; float totalWeightOfWeapons = equipment.GetTotalWeightOfWeapons(); int weight = agent.Monster.Weight; float num1 = agentDrivenProperties.ArmorEncumbrance + totalWeightOfWeapons; EquipmentIndex wieldedItemIndex1 = agent.GetWieldedItemIndex(Agent.HandIndex.MainHand); EquipmentIndex wieldedItemIndex2 = agent.GetWieldedItemIndex(Agent.HandIndex.OffHand); if (wieldedItemIndex1 != EquipmentIndex.None) { ItemObject itemObject = equipment[wieldedItemIndex1].Item; float realWeaponLength = itemObject.WeaponComponent.PrimaryWeapon.GetRealWeaponLength(); totalWeightOfWeapons += 1.5f * itemObject.Weight * MathF.Sqrt(realWeaponLength); } if (wieldedItemIndex2 != EquipmentIndex.None) { ItemObject itemObject = equipment[wieldedItemIndex2].Item; totalWeightOfWeapons += 1.5f * itemObject.Weight; } agentDrivenProperties.WeaponsEncumbrance = totalWeightOfWeapons; EquipmentIndex wieldedItemIndex3 = agent.GetWieldedItemIndex(Agent.HandIndex.MainHand); MissionWeapon missionWeapon; WeaponComponentData weaponComponentData1; if (wieldedItemIndex3 == EquipmentIndex.None) { weaponComponentData1 = (WeaponComponentData)null; } else { missionWeapon = equipment[wieldedItemIndex3]; weaponComponentData1 = missionWeapon.CurrentUsageItem; } WeaponComponentData equippedItem = weaponComponentData1; ItemObject itemObject1; if (wieldedItemIndex3 == EquipmentIndex.None) { itemObject1 = (ItemObject)null; } else { missionWeapon = equipment[wieldedItemIndex3]; itemObject1 = missionWeapon.Item; } ItemObject primaryItem = itemObject1; EquipmentIndex wieldedItemIndex4 = agent.GetWieldedItemIndex(Agent.HandIndex.OffHand); WeaponComponentData weaponComponentData2; if (wieldedItemIndex4 == EquipmentIndex.None) { weaponComponentData2 = (WeaponComponentData)null; } else { missionWeapon = equipment[wieldedItemIndex4]; weaponComponentData2 = missionWeapon.CurrentUsageItem; } WeaponComponentData secondaryItem = weaponComponentData2; float inaccuracy; agentDrivenProperties.LongestRangedWeaponSlotIndex = (float)equipment.GetLongestRangedWeaponWithAimingError(out inaccuracy, agent); agentDrivenProperties.LongestRangedWeaponInaccuracy = inaccuracy; agentDrivenProperties.SwingSpeedMultiplier = (float)(0.930000007152557 + 0.000699999975040555 * (double)this.GetSkillValueForItem(agent, primaryItem)); agentDrivenProperties.ThrustOrRangedReadySpeedMultiplier = agentDrivenProperties.SwingSpeedMultiplier; agentDrivenProperties.HandlingMultiplier = 1f; agentDrivenProperties.ShieldBashStunDurationMultiplier = 1f; agentDrivenProperties.KickStunDurationMultiplier = 1f; agentDrivenProperties.ReloadSpeed = (float)(0.930000007152557 + 0.000699999975040555 * (double)this.GetSkillValueForItem(agent, primaryItem)); agentDrivenProperties.ReloadMovementPenaltyFactor = 1f; agentDrivenProperties.WeaponInaccuracy = 0.0f; IAgentOriginBase origin = agent.Origin; BasicCharacterObject character2 = agent.Character; Formation formation = agent.Formation; int effectiveSkill1 = this.GetEffectiveSkill(character2, origin, agent.Formation, DefaultSkills.Athletics); int effectiveSkill2 = this.GetEffectiveSkill(character2, origin, formation, DefaultSkills.Riding); if (equippedItem != null) { int thrustSpeed = equippedItem.ThrustSpeed; WeaponComponentData weapon = equippedItem; int effectiveSkill3 = this.GetEffectiveSkill(character2, origin, formation, equippedItem.RelevantSkill); agentDrivenProperties.WeaponInaccuracy = this.GetWeaponInaccuracy(agent, weapon, effectiveSkill3); if (equippedItem.IsRangedWeapon) { agentDrivenProperties.WeaponMaxMovementAccuracyPenalty = (float)(500 - effectiveSkill3) * 0.00025f; agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty = (float)(500 - effectiveSkill3) * 0.0002f; if (agent.HasMount) { agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= Math.Max(1f, (float)(700 - effectiveSkill3 - effectiveSkill2) * (3f / 1000f)); agentDrivenProperties.WeaponMaxMovementAccuracyPenalty *= Math.Max(1f, (float)(700 - effectiveSkill3 - effectiveSkill2) * 0.0033f); } else if (weapon.RelevantSkill == DefaultSkills.Bow) { agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= 4.5f / MBMath.Lerp(0.75f, 2f, (float)(((double)thrustSpeed - 45.0) / 90.0)); agentDrivenProperties.WeaponMaxMovementAccuracyPenalty *= 6f; } else if (weapon.RelevantSkill == DefaultSkills.Crossbow) { agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= 1.2f; agentDrivenProperties.WeaponMaxMovementAccuracyPenalty *= 2.5f; } else if (weapon.RelevantSkill == DefaultSkills.Throwing) { agentDrivenProperties.WeaponMaxUnsteadyAccuracyPenalty *= 3.5f * MBMath.Lerp(1.5f, 0.8f, (float)(((double)thrustSpeed - 89.0) / 13.0)); } if (weapon.WeaponClass == WeaponClass.Bow) { agentDrivenProperties.WeaponBestAccuracyWaitTime = (float)(0.300000011920929 + (95.75 - (double)thrustSpeed) * 0.00499999988824129); agentDrivenProperties.WeaponUnsteadyBeginTime = (float)(0.600000023841858 + (double)effectiveSkill3 * 0.00999999977648258 * (double)MBMath.Lerp(2f, 4f, (float)(((double)thrustSpeed - 45.0) / 90.0))); if (agent.IsAIControlled) { agentDrivenProperties.WeaponUnsteadyBeginTime *= 4f; } agentDrivenProperties.WeaponUnsteadyEndTime = 2f + agentDrivenProperties.WeaponUnsteadyBeginTime; agentDrivenProperties.WeaponRotationalAccuracyPenaltyInRadians = 0.1f; } else if (weapon.WeaponClass == WeaponClass.Javelin || weapon.WeaponClass == WeaponClass.ThrowingAxe || weapon.WeaponClass == WeaponClass.ThrowingKnife) { agentDrivenProperties.WeaponBestAccuracyWaitTime = (float)(0.400000005960464 + (89.0 - (double)thrustSpeed) * 0.0299999993294477); agentDrivenProperties.WeaponUnsteadyBeginTime = (float)(2.5 + (double)character1.GetSkillValue(equippedItem.RelevantSkill) * 0.00999999977648258); agentDrivenProperties.WeaponUnsteadyEndTime = 10f + agentDrivenProperties.WeaponUnsteadyBeginTime; agentDrivenProperties.WeaponRotationalAccuracyPenaltyInRadians = 0.025f; } else { agentDrivenProperties.WeaponBestAccuracyWaitTime = 0.1f; agentDrivenProperties.WeaponUnsteadyBeginTime = 0.0f; agentDrivenProperties.WeaponUnsteadyEndTime = 0.0f; agentDrivenProperties.WeaponRotationalAccuracyPenaltyInRadians = 0.1f; } } else if (equippedItem.RelevantSkill == DefaultSkills.Polearm && equippedItem.WeaponFlags.HasAllFlags <WeaponFlags>(WeaponFlags.WideGrip)) { agentDrivenProperties.WeaponUnsteadyBeginTime = (float)(1.0 + (double)effectiveSkill3 * 0.00499999988824129); agentDrivenProperties.WeaponUnsteadyEndTime = (float)(3.0 + (double)effectiveSkill3 * 0.00999999977648258); } if (agent.HasMount) { float num2 = 1f - Math.Max(0.0f, (float)(0.200000002980232 - (double)effectiveSkill2 * (1.0 / 500.0))); agentDrivenProperties.SwingSpeedMultiplier *= num2; agentDrivenProperties.ThrustOrRangedReadySpeedMultiplier *= num2; agentDrivenProperties.ReloadSpeed *= num2; } } agentDrivenProperties.TopSpeedReachDuration = 2f / Math.Max((float)((200.0 + (double)effectiveSkill1) / 300.0 * ((double)weight / ((double)weight + (double)num1))), 0.3f); float num3 = 1f; if (!agent.Mission.Scene.IsAtmosphereIndoor && (double)agent.Mission.Scene.GetRainDensity() > 0.0) { num3 *= 0.9f; } agentDrivenProperties.MaxSpeedMultiplier = num3 * Math.Min((float)((200.0 + (double)effectiveSkill1) / 300.0 * ((double)weight * 2.0 / ((double)weight * 2.0 + (double)num1))), 1f); float managedParameter1 = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.BipedalCombatSpeedMinMultiplier); float managedParameter2 = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.BipedalCombatSpeedMaxMultiplier); float amount = Math.Min(num1 / (float)weight, 1f); agentDrivenProperties.CombatMaxSpeedMultiplier = Math.Min(MBMath.Lerp(managedParameter2, managedParameter1, amount), 1f); agentDrivenProperties.AttributeShieldMissileCollisionBodySizeAdder = 0.3f; Agent mountAgent = agent.MountAgent; float num4 = mountAgent != null?mountAgent.GetAgentDrivenPropertyValue(DrivenProperty.AttributeRiding) : 1f; agentDrivenProperties.AttributeRiding = (float)effectiveSkill2 * num4; agentDrivenProperties.AttributeHorseArchery = Game.Current.BasicModels.StrikeMagnitudeModel.CalculateHorseArcheryFactor(character1); agentDrivenProperties.BipedalRangedReadySpeedMultiplier = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.BipedalRangedReadySpeedMultiplier); agentDrivenProperties.BipedalRangedReloadSpeedMultiplier = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.BipedalRangedReloadSpeedMultiplier); this.SetAiRelatedProperties(agent, agentDrivenProperties, equippedItem, secondaryItem); }
public override void InitializeAgentStats( Agent agent, Equipment spawnEquipment, AgentDrivenProperties agentDrivenProperties, AgentBuildData agentBuildData) { agentDrivenProperties.ArmorEncumbrance = spawnEquipment.GetTotalWeightOfArmor(agent.IsHuman); if (!agent.IsHuman) { AgentDrivenProperties drivenProperties1 = agentDrivenProperties; EquipmentElement equipmentElement1 = spawnEquipment[EquipmentIndex.ArmorItemEndSlot]; int internalValue = (int)equipmentElement1.Item.Id.InternalValue; drivenProperties1.AiSpeciesIndex = internalValue; AgentDrivenProperties drivenProperties2 = agentDrivenProperties; equipmentElement1 = spawnEquipment[EquipmentIndex.HorseHarness]; double num1 = 0.800000011920929 + (equipmentElement1.Item != null ? 0.200000002980232 : 0.0); drivenProperties2.AttributeRiding = (float)num1; float num2 = 0.0f; for (int index = 1; index < 12; ++index) { equipmentElement1 = spawnEquipment[index]; if (equipmentElement1.Item != null) { double num3 = (double)num2; equipmentElement1 = spawnEquipment[index]; double modifiedMountBodyArmor = (double)equipmentElement1.GetModifiedMountBodyArmor(); num2 = (float)(num3 + modifiedMountBodyArmor); } } agentDrivenProperties.ArmorTorso = num2; equipmentElement1 = spawnEquipment[EquipmentIndex.ArmorItemEndSlot]; ItemObject itemObject = equipmentElement1.Item; if (itemObject != null) { float num3 = 1f; if (!agent.Mission.Scene.IsAtmosphereIndoor) { if ((double)agent.Mission.Scene.GetRainDensity() > 0.0) { num3 *= 0.9f; } if (!MBMath.IsBetween(agent.Mission.Scene.TimeOfDay, 4f, 20.01f)) { num3 *= 0.9f; } } HorseComponent horseComponent = itemObject.HorseComponent; EquipmentElement mountElement = spawnEquipment[EquipmentIndex.ArmorItemEndSlot]; EquipmentElement equipmentElement2 = spawnEquipment[EquipmentIndex.HorseHarness]; agentDrivenProperties.MountManeuver = (float)mountElement.GetModifiedMountManeuver(in equipmentElement2); agentDrivenProperties.MountSpeed = (float)((double)num3 * (double)(mountElement.GetModifiedMountSpeed(in equipmentElement2) + 1) * 0.219999998807907); agentDrivenProperties.MountChargeDamage = (float)mountElement.GetModifiedMountCharge(in equipmentElement2) * 0.01f; agentDrivenProperties.MountDifficulty = (float)mountElement.Item.Difficulty; int effectiveSkill = this.GetEffectiveSkill(agent.RiderAgent.Character, agent.RiderAgent.Origin, agent.RiderAgent.Formation, DefaultSkills.Riding); agentDrivenProperties.TopSpeedReachDuration = Game.Current.BasicModels.RidingModel.CalculateAcceleration(in mountElement, in equipmentElement2, effectiveSkill); if (agent.RiderAgent != null) { agentDrivenProperties.MountSpeed *= (float)(1.0 + (double)effectiveSkill * (1.0 / 1000.0)); agentDrivenProperties.MountManeuver *= (float)(1.0 + (double)effectiveSkill * 0.00039999998989515); } } } else { agentDrivenProperties.ArmorHead = spawnEquipment.GetHeadArmorSum(); agentDrivenProperties.ArmorTorso = spawnEquipment.GetHumanBodyArmorSum(); agentDrivenProperties.ArmorLegs = spawnEquipment.GetLegArmorSum(); agentDrivenProperties.ArmorArms = spawnEquipment.GetArmArmorSum(); } foreach (DrivenPropertyBonusAgentComponent bonusAgentComponent in agent.Components.OfType <DrivenPropertyBonusAgentComponent>()) { if (MBMath.IsBetween((int)bonusAgentComponent.DrivenProperty, 0, 56)) { float num = agentDrivenProperties.GetStat(bonusAgentComponent.DrivenProperty) + bonusAgentComponent.DrivenPropertyBonus; agentDrivenProperties.SetStat(bonusAgentComponent.DrivenProperty, num); } } }