Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns value for horse using its properties and filter settings
        /// </summary>
        /// <param name="sourceItem">Horse item</param>
        /// <returns>calculated value for horse</returns>
        public float CalculateHorseValue(EquipmentElement sourceItem, FilterMountSettings filterMount)
        {
            HorseComponent horseComponentItem = sourceItem.Item.HorseComponent;

            float sum =
                Math.Abs(filterMount.ChargeDamage) +
                Math.Abs(filterMount.HitPoints) +
                Math.Abs(filterMount.Maneuver) +
                Math.Abs(filterMount.Speed);

            int ChargeDamage = horseComponentItem.ChargeDamage,
                HitPoints    = horseComponentItem.HitPoints,
                Maneuver     = horseComponentItem.Maneuver,
                Speed        = horseComponentItem.Speed;

            ItemModifier mod = sourceItem.ItemModifier;

            if (mod != null)
            {
                ChargeDamage = mod.ModifyMountCharge(ChargeDamage);
                Maneuver     = mod.ModifyMountManeuver(Maneuver);
                Speed        = mod.ModifyMountSpeed(Speed);
            }

            var   weights = filterMount;
            float value   = (
                ChargeDamage * weights.ChargeDamage +
                HitPoints * weights.HitPoints +
                Maneuver * weights.Maneuver +
                Speed * weights.Speed
                ) / sum;

#if DEBUG
            InformationManager.DisplayMessage(new InformationMessage(String.Format("{0}: CD {1}, HP {2}, MR {3}, SD {4}",
                                                                                   sourceItem.Item.Name, ChargeDamage, HitPoints, Maneuver, Speed)));

            InformationManager.DisplayMessage(new InformationMessage("Total score: " + value));
#endif

            return(value);
        }
Ejemplo n.º 3
0
        private void AddMount(bool isRiderAgentMounted = false)
        {
            this.RemoveMount();
            HorseComponent horseComponent = this._equipment[10].Item.HorseComponent;
            Monster        arg_39_0       = horseComponent.Monster;

            this._mountEntity = GameEntity.CreateEmpty(this._tableauScene, true);
            AnimationSystemData    animationSystemData    = arg_39_0.FillAnimationSystemData(MBGlobals.GetActionSet(horseComponent.Monster.ActionSetCode), 1f, false);
            AgentVisualsNativeData agentVisualsNativeData = arg_39_0.FillAgentVisualsNativeData();

            this._mountEntity.CreateSkeletonWithActionSet(ref agentVisualsNativeData, ref animationSystemData);
            if (isRiderAgentMounted)
            {
                this._mountEntity.Skeleton.SetAgentActionChannel(0, (horseComponent.Monster.MonsterUsage == "camel") ? SpouseCharacterTableau.act_camel_stand : SpouseCharacterTableau.act_horse_stand, MBRandom.RandomFloat, -0.2f);
            }
            else
            {
                this._mountEntity.Skeleton.SetAgentActionChannel(0, SpouseCharacterTableau.act_inventory_idle_start, MBRandom.RandomFloat, -0.2f);
            }
            this._mountEntity.EntityFlags |= EntityFlags.AnimateWhenVisible;
            MountVisualCreator.AddMountMeshToEntity(this._mountEntity, this._equipment[10].Item, this._equipment[11].Item, this._mountCreationKey, null);
            this._mountEntity.SetFrame(ref this._mountSpawnPoint);
        }
Ejemplo n.º 4
0
        private static bool UpdateHorseStatsPrefix(ref SandboxAgentStatCalculateModel __instance, Agent agent, AgentDrivenProperties agentDrivenProperties)
        {
            Equipment spawnEquipment = agent.SpawnEquipment;

            agentDrivenProperties.AiSpeciesIndex  = (int)spawnEquipment[EquipmentIndex.ArmorItemEndSlot].Item.Id.InternalValue;
            agentDrivenProperties.AttributeRiding = 0.8f + ((spawnEquipment[EquipmentIndex.HorseHarness].Item != null) ? 0.2f : 0f);
            float num = 0f;

            for (int i = 1; i < 12; i++)
            {
                if (spawnEquipment[i].Item != null)
                {
                    num += (float)spawnEquipment[i].GetBodyArmorHorse();
                }
            }
            agentDrivenProperties.ArmorTorso = num;
            ItemObject item = spawnEquipment[EquipmentIndex.ArmorItemEndSlot].Item;

            if (item != null)
            {
                float num2 = 1f;
                if (!agent.Mission.Scene.IsAtmosphereIndoor)
                {
                    if (agent.Mission.Scene.GetRainDensity() > 0f)
                    {
                        num2 *= 0.9f;
                    }
                    if (CampaignTime.Now.IsNightTime)
                    {
                        num2 *= 0.9f;
                    }
                }
                HorseComponent   horseComponent   = item.HorseComponent;
                EquipmentElement equipmentElement = spawnEquipment[EquipmentIndex.ArmorItemEndSlot];
                EquipmentElement harness          = spawnEquipment[EquipmentIndex.HorseHarness];
                int baseHorseManeuver             = equipmentElement.GetBaseHorseManeuver(harness);
                int num3 = equipmentElement.GetBaseHorseSpeed(harness) + 1;
                agentDrivenProperties.MountChargeDamage = (float)equipmentElement.GetBaseHorseCharge(harness) * 0.004f;
                agentDrivenProperties.MountDifficulty   = (float)equipmentElement.Item.Difficulty;
                RidingModel ridingModel = Game.Current.BasicModels.RidingModel;
                ItemObject  item2       = equipmentElement.Item;
                Agent       riderAgent  = agent.RiderAgent;
                agentDrivenProperties.TopSpeedReachDuration = ridingModel.CalculateAcceleration(item2, (riderAgent != null) ? riderAgent.Character : null);
                if (agent.RiderAgent != null)
                {
                    ExplainedNumber explainedNumber  = new ExplainedNumber((float)baseHorseManeuver, null);
                    ExplainedNumber explainedNumber2 = new ExplainedNumber((float)num3, null);
                    SkillHelper.AddSkillBonusForCharacter(DefaultSkills.Riding, DefaultSkillEffects.HorseManeuver, agent.RiderAgent.Character as CharacterObject, ref explainedNumber, true);
                    SkillHelper.AddSkillBonusForCharacter(DefaultSkills.Riding, DefaultSkillEffects.HorseSpeed, agent.RiderAgent.Character as CharacterObject, ref explainedNumber2, true);
                    if (harness.Item == null)
                    {
                        explainedNumber.AddFactor(-0.1f, null);
                        explainedNumber2.AddFactor(-0.1f, null);
                    }
                    agentDrivenProperties.MountManeuver = explainedNumber.ResultNumber;
                    if (HorseCrippleLogic.CheckHorseCrippled(agent))
                    {
                        agentDrivenProperties.MountSpeed = 1;
                    }
                    else
                    {
                        agentDrivenProperties.MountSpeed = num2 * 0.22f * (1f + explainedNumber2.ResultNumber);
                    }

                    return(false);
                }
                agentDrivenProperties.MountManeuver = (float)baseHorseManeuver;

                if (HorseCrippleLogic.CheckHorseCrippled(agent))
                {
                    agentDrivenProperties.MountSpeed = 1;
                }
                else
                {
                    agentDrivenProperties.MountSpeed = num2 * 0.22f * (float)(1 + num3);
                }
            }

            return(false);
        }
 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);
         }
     }
 }