public virtual int GetEffectiveSkill( BasicCharacterObject agentCharacter, IAgentOriginBase agentOrigin, Formation agentFormation, SkillObject skill) { return(agentCharacter.GetSkillValue(skill)); }
private static void Postfix(IAgentOriginBase __instance, ref Banner __result) { var party = (PartyBase)__instance.BattleCombatant; if (Globals.Settings.RandomBanners && party.MobileParty != null && IsBM(party.MobileParty)) { __result = PartyMilitiaMap[party.MobileParty]?.Banner; } }
/// <summary> /// Tries to get the PartyBase of the Agent origin being evaluated /// </summary> /// <param name="origin">The Agent origin to evaluate</param> /// <param name="party">The Agent's party or null</param> /// <returns>Returns true if the Agent's party was found</returns> public static bool TryGetParty(this IAgentOriginBase origin, out PartyBase party) { switch (origin) { case PartyAgentOrigin partyAgentOrigin: party = partyAgentOrigin.Party; return(party != null); case PartyGroupAgentOrigin partyGroupAgentOrigin: party = partyGroupAgentOrigin.Party; return(party != null); case SimpleAgentOrigin simpleAgentOrigin: party = simpleAgentOrigin.Party; return(party != null); default: party = null; return(false); } }
public AgentBuildData TroopOrigin(IAgentOriginBase troopOrigin) { this.AgentData.TroopOrigin(troopOrigin); return(this); }
public AgentBuildData(IAgentOriginBase agentOrigin) : this() { this.AgentData = new AgentData(agentOrigin); }
public int SpawnTroops(int number, bool isReinforcement, bool enforceSpawningOnInitialPoint = false) { if (number <= 0) { return(0); } int formationTroopIndex = 0; List <IAgentOriginBase> agentOriginBaseList1 = new List <IAgentOriginBase>(); int count1 = Math.Min(this._preSuppliedTroops.Count, number); if (count1 > 0) { for (int index = 0; index < count1; ++index) { agentOriginBaseList1.Add(this._preSuppliedTroops[index]); } this._preSuppliedTroops.RemoveRange(0, count1); } int numberToAllocate = number - count1; agentOriginBaseList1.AddRange(this._troopSupplier.SupplyTroops(numberToAllocate)); List <IAgentOriginBase> agentOriginBaseList2 = new List <IAgentOriginBase>(); for (int index = 0; index < 8; ++index) { agentOriginBaseList2.Clear(); IAgentOriginBase agentOriginBase1 = (IAgentOriginBase)null; FormationClass formationClass = (FormationClass)index; foreach (IAgentOriginBase agentOriginBase2 in agentOriginBaseList1) { if (formationClass == agentOriginBase2.Troop.GetFormationClass(agentOriginBase2.BattleCombatant)) { if (agentOriginBase2.Troop == Game.Current.PlayerTroop) { agentOriginBase1 = agentOriginBase2; } else { agentOriginBaseList2.Add(agentOriginBase2); } } } if (agentOriginBase1 != null) { agentOriginBaseList2.Add(agentOriginBase1); } int count2 = agentOriginBaseList2.Count; if (count2 > 0) { foreach (IAgentOriginBase troopOrigin in agentOriginBaseList2) { Formation formation = Mission.GetAgentTeam(troopOrigin, this.IsPlayerSide).GetFormation(formationClass); bool isMounted = this._spawnWithHorses && (formationClass == FormationClass.Cavalry || formationClass == FormationClass.LightCavalry || formationClass == FormationClass.HeavyCavalry || formationClass == FormationClass.HorseArcher); if (formation != null && !formation.HasBeenPositioned) { formation.BeginSpawn(count2, isMounted); Mission.Current.SpawnFormation(formation, count2, this._spawnWithHorses, isMounted, isReinforcement); this._spawnedFormations.Add(formation); } Mission.Current.SpawnTroop(troopOrigin, this.IsPlayerSide, true, this._spawnWithHorses, isReinforcement, enforceSpawningOnInitialPoint, count2, formationTroopIndex, true, true); ++formationTroopIndex; } } } if (formationTroopIndex > 0) { foreach (Team team in (ReadOnlyCollection <Team>)Mission.Current.Teams) { team.QuerySystem.Expire(); } Debug.Print(formationTroopIndex.ToString() + " troops spawned on " + (object)this._side + " side.", color: Debug.DebugColor.DarkGreen, debugFilter: 64UL); } foreach (Team team in (ReadOnlyCollection <Team>)Mission.Current.Teams) { foreach (Formation formation in team.Formations) { formation.GroupSpawnIndex = 0; } } return(formationTroopIndex); }
private bool IsAlreadySpawned(IAgentOriginBase agentOrigin) { return(Mission.Current != null && Mission.Current.Agents.Any((Agent x) => x.Origin == agentOrigin)); }
public static bool IsOnPlayerEnemySide(this IAgentOriginBase origin) { return(origin.TryGetParty(out var party) && (party.MapEventSide?.OtherSide?.IsMainPartyAmongParties() ?? false)); }
public override int GetEffectiveSkill(BasicCharacterObject agentCharacter, IAgentOriginBase agentOrigin, Formation agentFormation, SkillObject skill) { return(_previousModel?.GetEffectiveSkill(agentCharacter, agentOrigin, agentFormation, skill) ?? base.GetEffectiveSkill(agentCharacter, agentOrigin, agentFormation, skill)); }
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); }