コード例 #1
0
ファイル: DurabilityService.cs プロジェクト: zunath/SWLOR_NWN
        private static void InitializeDurability(NWItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            SetLocalBool(item, "DURABILITY_OVERRIDE", true);
            if (item.GetLocalInt("DURABILITY_INITIALIZE") <= 0 &&
                item.GetLocalFloat("DURABILITY_CURRENT") <= 0.0f)
            {
                float durability = GetMaxDurability(item) <= 0 ? DefaultDurability : GetMaxDurability(item);
                item.SetLocalFloat("DURABILITY_CURRENT", durability);
                if (item.GetLocalFloat("DURABILITY_MAX") <= 0.0f)
                {
                    float maxDurability = DefaultDurability;
                    foreach (var ip in item.ItemProperties)
                    {
                        if (GetItemPropertyType(ip) == ItemPropertyType.MaxDurability)
                        {
                            maxDurability = GetItemPropertyCostTableValue(ip);
                            break;
                        }
                    }

                    item.SetLocalFloat("DURABILITY_MAX", maxDurability);
                }
            }
            item.SetLocalInt("DURABILITY_INITIALIZED", 1);
        }
コード例 #2
0
ファイル: DurabilityService.cs プロジェクト: zunath/SWLOR_NWN
        public static void SetMaxDurability(NWItem item, float value)
        {
            SetLocalBool(item, "DURABILITY_OVERRIDE", true);
            if (value <= 0)
            {
                value = DefaultDurability;
            }

            item.SetLocalFloat("DURABILITY_MAX", value);
            InitializeDurability(item);
        }
コード例 #3
0
ファイル: DurabilityService.cs プロジェクト: zunath/SWLOR_NWN
        public static void SetDurability(NWItem item, float value)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (value < 0.0f)
            {
                value = 0.0f;
            }

            SetLocalBool(item, "DURABILITY_OVERRIDE", true);
            InitializeDurability(item);
            item.SetLocalFloat("DURABILITY_CURRENT", value);
        }
コード例 #4
0
        public static void SetMaxDurability(NWItem item, float value)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            item.SetLocalInt("DURABILITY_OVERRIDE", TRUE);
            if (value <= 0)
            {
                value = DefaultDurability;
            }

            item.SetLocalFloat("DURABILITY_MAX", value);
            InitializeDurability(item);
        }
コード例 #5
0
        private static void CalculateEffectiveStats(NWPlayer player, NWItem item)
        {
            if (item == null || !item.IsValid || !player.IsPlayer || player.IsDMPossessed || player.IsDM || !player.IsInitializedAsPlayer)
            {
                return;
            }

            // Calculating effective stats can be expensive, so we cache it on the item.
            SkillType skill = ItemService.GetSkillTypeForItem(item);
            var       rank  = DataService.PCSkill.GetByPlayerIDAndSkillID(player.GlobalID, (int)skill).Rank;

            using (new Profiler("PlayerStatService::ApplyStatChanges::GetPlayerItemEffectiveStats::ItemLoop::CalculateEffectiveStats"))
            {
                // Only scale cooldown recovery if it's a bonus. Penalties remain regardless of skill level difference.
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_COOLDOWN_RECOVERY", item.CooldownRecovery > 0
                    ? CalculateAdjustedValue(item.CooldownRecovery, item.RecommendedLevel, rank, 1)
                    : item.CooldownRecovery);

                item.SetLocalFloat("STAT_EFFECTIVE_LEVEL_ENMITY_RATE", CalculateAdjustedValue(0.01f * item.EnmityRate, item.RecommendedLevel, rank, 0.00f));

                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_LUCK_BONUS", CalculateAdjustedValue(item.LuckBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_MEDITATE_BONUS", CalculateAdjustedValue(item.MeditateBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_REST_BONUS", CalculateAdjustedValue(item.RestBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_MEDICINE_BONUS", CalculateAdjustedValue(item.MedicineBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_HP_REGEN_BONUS", CalculateAdjustedValue(item.HPRegenBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_FP_REGEN_BONUS", CalculateAdjustedValue(item.FPRegenBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_WEAPONSMITH_BONUS", CalculateAdjustedValue(item.CraftBonusWeaponsmith, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_COOKING_BONUS", CalculateAdjustedValue(item.CraftBonusCooking, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_ENGINEERING_BONUS", CalculateAdjustedValue(item.CraftBonusEngineering, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_FABRICATION_BONUS", CalculateAdjustedValue(item.CraftBonusFabrication, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_ARMORSMITH_BONUS", CalculateAdjustedValue(item.CraftBonusArmorsmith, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_HARVESTING_BONUS", CalculateAdjustedValue(item.HarvestingBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_PILOTING_BONUS", CalculateAdjustedValue(item.PilotingBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_SCAVENGING_BONUS", CalculateAdjustedValue(item.ScavengingBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_SNEAK_ATTACK_BONUS", CalculateAdjustedValue(item.SneakAttackBonus, item.RecommendedLevel, rank, 0));

                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_STRENGTH_BONUS", CalculateAdjustedValue(item.StrengthBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_DEXTERITY_BONUS", CalculateAdjustedValue(item.DexterityBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_CONSTITUTION_BONUS", CalculateAdjustedValue(item.ConstitutionBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_WISDOM_BONUS", CalculateAdjustedValue(item.WisdomBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_INTELLIGENCE_BONUS", CalculateAdjustedValue(item.IntelligenceBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_CHARISMA_BONUS", CalculateAdjustedValue(item.CharismaBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_HP_BONUS", CalculateAdjustedValue(item.HPBonus, item.RecommendedLevel, rank, 0));
                item.SetLocalInt("STAT_EFFECTIVE_LEVEL_FP_BONUS", CalculateAdjustedValue(item.FPBonus, item.RecommendedLevel, rank, 0));
            }
        }
コード例 #6
0
ファイル: DurabilityService.cs プロジェクト: zunath/Freescape
        public void SetDurability(NWItem item, float value)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (value < 0.0f)
            {
                value = 0.0f;
            }

            if (!IsValidDurabilityType(item))
            {
                return;
            }
            InitializeDurability(item);
            item.SetLocalFloat("DURABILITY_CURRENT", value);
        }
コード例 #7
0
ファイル: DurabilityService.cs プロジェクト: zunath/Freescape
        public void SetMaxDurability(NWItem item, float value)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            if (!IsValidDurabilityType(item))
            {
                return;
            }
            if (value <= 0)
            {
                value = DefaultDurability;
            }

            item.SetLocalFloat("DURABILITY_MAX", value);
            InitializeDurability(item);
        }
コード例 #8
0
ファイル: DurabilityService.cs プロジェクト: zunath/Freescape
        private void InitializeDurability(NWItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            if (!IsValidDurabilityType(item))
            {
                return;
            }

            if (item.GetLocalInt("DURABILITY_INITIALIZE") <= 0 &&
                item.GetLocalFloat("DURABILITY_CURRENT") <= 0.0f)
            {
                float durability = GetMaxDurability(item) <= 0 ? DefaultDurability : GetMaxDurability(item);
                item.SetLocalFloat("DURABILITY_CURRENT", durability);
            }
            item.SetLocalInt("DURABILITY_INITIALIZED", 1);
        }