public int GetGoldGainsFromKillData(
            MPPerkObject.MPPerkHandler killerPerkHandler,
            MPPerkObject.MPPerkHandler assistingHitterPerkHandler,
            MultiplayerClassDivisions.MPHeroClass victimClass,
            bool isAssist)
        {
            int num1;

            if (isAssist)
            {
                num1 = (killerPerkHandler != null ? killerPerkHandler.GetRewardedGoldOnAssist() : 0) + (assistingHitterPerkHandler != null ? assistingHitterPerkHandler.GetGoldOnAssist() : 0);
            }
            else
            {
                int num2 = this.ControlledAgent != null?MultiplayerClassDivisions.GetMPHeroClassForCharacter(this.ControlledAgent.Character).TroopCost : 0;

                num1 = killerPerkHandler != null?killerPerkHandler.GetGoldOnKill((float)num2, (float)victimClass.TroopCost) : 0;
            }
            if (num1 > 0)
            {
                GameNetwork.BeginModuleEventAsServer(this.Peer);
                GameNetwork.WriteMessage((GameNetworkMessage) new TDMGoldGain(new List <KeyValuePair <ushort, int> >()
                {
                    new KeyValuePair <ushort, int>((ushort)2048, num1)
                }));
                GameNetwork.EndModuleEventAsServer();
            }
            return(num1);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public int GetGoldGainsFromKillDataAndUpdateFlags(
            MPPerkObject.MPPerkHandler killerPerkHandler,
            MPPerkObject.MPPerkHandler assistingHitterPerkHandler,
            MultiplayerClassDivisions.MPHeroClass victimClass,
            bool isAssist,
            bool isRanged)
        {
            int num1 = 0;
            List <KeyValuePair <ushort, int> > goldChangeEventList = new List <KeyValuePair <ushort, int> >();

            if (isAssist)
            {
                int num2 = 1;
                int num3 = (killerPerkHandler != null ? killerPerkHandler.GetRewardedGoldOnAssist() : 0) + (assistingHitterPerkHandler != null ? assistingHitterPerkHandler.GetGoldOnAssist() : 0);
                if (num3 > 0)
                {
                    num1 += num3;
                    this._currentGoldGains |= GoldGainFlags.PerkBonus;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)2048, num3));
                }
                switch (this.MissionPeer.AssistCount - this._assistCountOnSpawn)
                {
                case 1:
                    num1 += 10;
                    this._currentGoldGains |= GoldGainFlags.FirstAssist;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)4, 10));
                    break;

                case 2:
                    num1 += 10;
                    this._currentGoldGains |= GoldGainFlags.SecondAssist;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)8, 10));
                    break;

                case 3:
                    num1 += 10;
                    this._currentGoldGains |= GoldGainFlags.ThirdAssist;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)16, 10));
                    break;

                default:
                    num1 += num2;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)256, num2));
                    break;
                }
            }
            else
            {
                int num2 = 0;
                if (this.ControlledAgent != null)
                {
                    num2 = MultiplayerClassDivisions.GetMPHeroClassForCharacter(this.ControlledAgent.Character).TroopCost;
                    int num3 = 2 + Math.Max(0, (victimClass.TroopCost - num2) / 2);
                    num1 += num3;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)128, num3));
                }
                int num4 = killerPerkHandler != null?killerPerkHandler.GetGoldOnKill((float)num2, (float)victimClass.TroopCost) : 0;

                if (num4 > 0)
                {
                    num1 += num4;
                    this._currentGoldGains |= GoldGainFlags.PerkBonus;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)2048, num4));
                }
                switch (this.MissionPeer.KillCount - this._killCountOnSpawn)
                {
                case 5:
                    num1 += 20;
                    this._currentGoldGains |= GoldGainFlags.FifthKill;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)32, 20));
                    break;

                case 10:
                    num1 += 30;
                    this._currentGoldGains |= GoldGainFlags.TenthKill;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)64, 30));
                    break;
                }
                if (isRanged && !this._currentGoldGains.HasAnyFlag <GoldGainFlags>(GoldGainFlags.FirstRangedKill))
                {
                    num1 += 10;
                    this._currentGoldGains |= GoldGainFlags.FirstRangedKill;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)1, 10));
                }
                if (!isRanged && !this._currentGoldGains.HasAnyFlag <GoldGainFlags>(GoldGainFlags.FirstMeleeKill))
                {
                    num1 += 10;
                    this._currentGoldGains |= GoldGainFlags.FirstMeleeKill;
                    goldChangeEventList.Add(new KeyValuePair <ushort, int>((ushort)2, 10));
                }
            }
            int num5 = 0;

            if (this.MissionPeer.Team == Mission.Current.Teams.Attacker)
            {
                num5 = MultiplayerOptions.OptionType.GoldGainChangePercentageTeam1.GetIntValue();
            }
            else if (this.MissionPeer.Team == Mission.Current.Teams.Defender)
            {
                num5 = MultiplayerOptions.OptionType.GoldGainChangePercentageTeam2.GetIntValue();
            }
            if (num5 != 0 && (num1 > 0 || goldChangeEventList.Count > 0))
            {
                num1 = 0;
                float num2 = (float)(1.0 + (double)num5 * 0.00999999977648258);
                for (int index = 0; index < goldChangeEventList.Count; ++index)
                {
                    int num3 = (int)((double)goldChangeEventList[index].Value * (double)num2);
                    goldChangeEventList[index] = new KeyValuePair <ushort, int>(goldChangeEventList[index].Key, num3);
                    num1 += num3;
                }
            }
            if (goldChangeEventList.Count > 0 && !this.Peer.Communicator.IsServerPeer && this.Peer.Communicator.IsConnectionActive)
            {
                GameNetwork.BeginModuleEventAsServer(this.Peer);
                GameNetwork.WriteMessage((GameNetworkMessage) new TDMGoldGain(goldChangeEventList));
                GameNetwork.EndModuleEventAsServer();
            }
            return(num1);
        }
Exemplo n.º 4
0
        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);
        }