コード例 #1
0
        public string IsValidTarget(NWCreature user, NWItem mod, NWObject target, Location targetLocation)
        {
            if (target.ObjectType != ObjectType.Item)
            {
                return("Only items may be targeted by mods.");
            }
            if (!user.IsPlayer && !user.IsDM)
            {
                return("Only players may use mods.");
            }
            NWPlayer player     = (user.Object);
            NWItem   targetItem = (target.Object);

            int modLevel          = mod.RecommendedLevel;
            int itemLevel         = targetItem.RecommendedLevel;
            int requiredPerkLevel = modLevel / 5;

            if (requiredPerkLevel <= 0)
            {
                requiredPerkLevel = 1;
            }
            int perkLevel             = 0;
            ItemPropertyType modType  = ModService.GetModType(mod);
            ModSlots         modSlots = ModService.GetModSlots(targetItem);
            int modID = mod.GetLocalInt("RUNE_ID");

            string[] modArgs = mod.GetLocalString("RUNE_VALUE").Split(',');

            // Check for a misconfigured mod item.
            if (modType == ItemPropertyType.Invalid)
            {
                return("Mod color couldn't be found. Notify an admin that this mod item is not set up properly.");
            }
            if (modID <= 0)
            {
                return("Mod ID couldn't be found. Notify an admin that this mod item is not set up properly.");
            }
            if (modArgs.Length <= 0)
            {
                return("Mod value couldn't be found. Notify an admin that this mod item is not set up properly.");
            }

            // No available slots on target item
            if (modType == ItemPropertyType.RedMod && !modSlots.CanRedModBeAdded)
            {
                return("That item has no available red mod slots.");
            }
            if (modType == ItemPropertyType.BlueMod && !modSlots.CanBlueModBeAdded)
            {
                return("That item has no available blue mod slots.");
            }
            if (modType == ItemPropertyType.GreenMod && !modSlots.CanGreenModBeAdded)
            {
                return("That item has no available green mod slots.");
            }
            if (modType == ItemPropertyType.YellowMod && !modSlots.CanYellowModBeAdded)
            {
                return("That item has no available yellow mod slots.");
            }

            // Get the perk level based on target item type and mod type.
            if (GetLocalBool(targetItem, "LIGHTSABER") == false && WeaponsmithBaseItemTypes.Contains(targetItem.BaseItemType))
            {
                perkLevel = PerkService.GetCreaturePerkLevel(player, PerkType.WeaponModInstallation);
            }
            else if (ArmorBaseItemTypes.Contains(targetItem.BaseItemType))
            {
                perkLevel = PerkService.GetCreaturePerkLevel(player, PerkType.ArmorModInstallation);
            }
            else if (GetLocalBool(targetItem, "LIGHTSABER") == true || EngineeringBaseItemTypes.Contains(targetItem.BaseItemType))
            {
                perkLevel = PerkService.GetCreaturePerkLevel(player, PerkType.EngineeringModInstallation);
            }

            // Ensure item isn't equipped.
            for (int slot = 0; slot < NumberOfInventorySlots; slot++)
            {
                if (_.GetItemInSlot((InventorySlot)slot, user.Object) == targetItem.Object)
                {
                    return("Targeted item must be unequipped before installing a mod.");
                }
            }

            // Check for perk level requirement
            if (perkLevel < requiredPerkLevel && !player.IsDM)
            {
                return("You do not have the necessary perk rank required. (Required: " + requiredPerkLevel + ", Your level: " + perkLevel + ")");
            }

            // Can't modify items above perk level * 10
            if (itemLevel > perkLevel * 10 && !player.IsDM)
            {
                return("Your current perks allow you to add mods to items up to level " + perkLevel * 10 + ". This item is level " + itemLevel + " so you can't install a mod into it.");
            }

            // Item must be in the user's inventory.
            if (!targetItem.Possessor.Equals(player))
            {
                return("Targeted item must be in your inventory.");
            }

            // It's possible that this mod is no longer usable. Notify the player if we can't find one registered.
            if (!ModService.IsModHandlerRegistered(modID))
            {
                return("Unfortunately, this mod can no longer be used.");
            }

            var handler = ModService.GetModHandler(modID);

            // Run the individual mod's rules for application. Will return the error message or a null.
            return(handler.CanApply(player, targetItem, modArgs));
        }
コード例 #2
0
ファイル: StimPack.cs プロジェクト: xephnin/SWLOR_NWN
 public float MaxDistance(NWCreature user, NWItem item, NWObject target, Location targetLocation)
 {
     return(3.5f + _perk.GetPCPerkLevel(user.Object, PerkType.RangedHealing));
 }
コード例 #3
0
        /// <summary>
        /// Returns an ID tied to the MarketCategory table. This is where players may find
        /// the item on the marketplace.
        /// </summary>
        /// <param name="item">The item to use for the determination.</param>
        /// <returns>The market category ID or a value of -1 if item is not supported.</returns>
        public static int DetermineMarketCategory(NWItem item)
        {
            // ===============================================================================
            // The following items are intentionally excluded from market transactions:
            // Lightsaber, Saberstaff
            // ===============================================================================

            // Some of the determinations require looking at the item's properties. Pull that list back now for later use.
            var properties = item.ItemProperties.ToList();
            var resref     = item.Resref;

            // Weapons - These IDs are based solely on the NWN BaseItemType
            switch (item.BaseItemType)
            {
            case BASE_ITEM_GREATAXE: return(1);

            case BASE_ITEM_BATTLEAXE: return(2);

            case BASE_ITEM_BASTARDSWORD: return(3);

            case BASE_ITEM_DAGGER: return(4);

            case BASE_ITEM_GREATSWORD: return(5);

            case BASE_ITEM_LONGSWORD: return(7);

            case BASE_ITEM_RAPIER: return(8);

            case BASE_ITEM_KATANA: return(9);

            case BASE_ITEM_SHORTSWORD: return(10);

            case BASE_ITEM_CLUB: return(11);

            case BASE_ITEM_LIGHTMACE: return(12);

            case BASE_ITEM_MORNINGSTAR: return(13);

            case BASE_ITEM_QUARTERSTAFF: return(15);

            case BASE_ITEM_DOUBLEAXE: return(16);

            case BASE_ITEM_TWOBLADEDSWORD: return(17);

            case BASE_ITEM_KUKRI: return(18);

            case BASE_ITEM_HALBERD: return(19);

            case BASE_ITEM_SHORTSPEAR: return(20);

            case BASE_ITEM_LIGHTCROSSBOW: return(21); // Blaster Rifles

            case BASE_ITEM_SHORTBOW: return(22);      // Blaster Pistols

            case BASE_ITEM_HELMET: return(23);

            case BASE_ITEM_SMALLSHIELD: return(28);    // Shields

            case BASE_ITEM_LARGESHIELD: return(28);    // Shields

            case BASE_ITEM_TOWERSHIELD: return(28);    // Shields

            case BASE_ITEM_BOOK: return(29);

            case BASE_ITEM_GLOVES: return(30);    // Power Gloves

            case BASE_ITEM_AMULET: return(102);   // Necklace

            case BASE_ITEM_RING: return(103);
            }

            // Check for armor.
            if (item.BaseItemType == BASE_ITEM_ARMOR ||
                item.BaseItemType == BASE_ITEM_BELT ||
                item.BaseItemType == BASE_ITEM_CLOAK ||
                item.BaseItemType == BASE_ITEM_BOOTS)
            {
                switch (item.CustomItemType)
                {
                case CustomItemType.LightArmor: return(24);

                case CustomItemType.ForceArmor: return(25);

                case CustomItemType.HeavyArmor: return(26);

                default: return(23);    // Default to clothes if no armor type is specified.
                }
            }

            // Check for Scanners
            if (item.GetLocalString("SCRIPT") == "ResourceScanner" ||
                item.GetLocalString("SCRIPT") == "MineralScanner")
            {
                return(31);
            }
            // Check for Harvesters
            if (item.GetLocalString("SCRIPT") == "ResourceHarvester")
            {
                return(32);
            }
            // Check for Repair Kits
            if (item.GetLocalString("SCRIPT") == "RepairKit")
            {
                return(104);
            }
            // Check for Stim Packs
            if (item.GetLocalString("JAVA_ACTION_SCRIPT") == "Medicine.StimPack")
            {
                return(105);
            }
            // Check for Force Packs
            if (item.GetLocalString("JAVA_ACTION_SCRIPT") == "Medicine.ForcePack")
            {
                return(106);
            }
            // Check for Healing Kits
            if (item.GetLocalString("JAVA_ACTION_SCRIPT") == "Medicine.HealingKit")
            {
                return(107);
            }
            // Check for Resuscitation Devices
            if (item.GetLocalString("JAVA_ACTION_SCRIPT") == "Medicine.ResuscitationKit")
            {
                return(108);
            }
            // Check for Starcharts
            if (item.GetLocalString("SCRIPT") == "StarchartDisk" &&
                item.GetLocalInt("Starcharts") > 0)
            {
                return(109);
            }
            // Check for Starship Equipment
            if (item.GetLocalString("SCRIPT") == "SSEnhancement")
            {
                return(124);
            }
            // Check for Starship Repair Kits
            if (item.GetLocalString("SCRIPT") == "SSRepairKit")
            {
                return(104);
            }

            // Check item properties
            foreach (var prop in properties)
            {
                var propertyType = _.GetItemPropertyType(prop);
                // Check for components
                if (propertyType == (int)CustomItemPropertyType.ComponentType)
                {
                    // IDs are mapped to the iprp_comptype.2da file.
                    switch (_.GetItemPropertyCostTableValue(prop))
                    {
                    case 1: return(33);

                    case 2: return(34);

                    case 3: return(35);

                    case 4: return(36);

                    case 5: return(37);

                    case 6: return(38);

                    case 7: return(39);

                    case 8: return(40);

                    case 9: return(41);

                    case 10: return(42);

                    case 11: return(43);

                    case 12: return(44);

                    case 13: return(45);

                    case 14: return(46);

                    case 15: return(47);

                    case 16: return(48);

                    case 17: return(49);

                    case 18: return(50);

                    case 19: return(51);

                    case 20: return(52);

                    case 21: return(53);

                    case 22: return(54);

                    case 23: return(55);

                    case 24: return(56);

                    case 25: return(57);

                    case 26: return(58);

                    case 27: return(59);

                    case 28: return(60);

                    case 29: return(61);

                    case 30: return(62);

                    case 31: return(63);

                    case 32: return(64);

                    case 33: return(65);

                    case 34: return(66);

                    case 35: return(67);

                    case 36: return(68);

                    case 37: return(69);

                    case 38: return(70);

                    case 39: return(71);

                    case 40: return(72);

                    case 41: return(73);

                    case 42: return(74);

                    case 43: return(75);

                    case 44: return(76);

                    case 45: return(77);

                    case 46: return(78);

                    case 47: return(79);

                    case 48: return(80);

                    case 49: return(81);

                    case 50: return(82);

                    case 51: return(83);

                    case 52: return(84);

                    case 53: return(85);

                    case 54: return(86);

                    case 55: return(87);

                    case 56: return(88);

                    case 57: return(89);

                    case 58: return(90);

                    case 59: return(91);

                    case 60: return(92);

                    case 61: return(93);

                    case 62: return(94);

                    case 63: return(95);

                    case 64: return(96);

                    case 65: return(97);
                    }
                }

                // Check for mods
                if (propertyType == (int)CustomItemPropertyType.BlueMod)
                {
                    return(98);
                }
                if (propertyType == (int)CustomItemPropertyType.GreenMod)
                {
                    return(99);
                }
                if (propertyType == (int)CustomItemPropertyType.RedMod)
                {
                    return(100);
                }
                if (propertyType == (int)CustomItemPropertyType.YellowMod)
                {
                    return(101);
                }
            }

            // Check base structures.
            int baseStructureID = item.GetLocalInt("BASE_STRUCTURE_ID");

            if (baseStructureID > 0)
            {
                var baseStructure     = DataService.Get <BaseStructure>(baseStructureID);
                var baseStructureType = (BaseStructureType)baseStructure.BaseStructureTypeID;

                switch (baseStructureType)
                {
                case BaseStructureType.ControlTower: return(111);

                case BaseStructureType.Drill: return(112);

                case BaseStructureType.ResourceSilo: return(113);

                case BaseStructureType.Turret: return(114);

                case BaseStructureType.Building: return(115);

                case BaseStructureType.MassProduction: return(116);

                case BaseStructureType.StarshipProduction: return(117);

                case BaseStructureType.Furniture: return(118);

                case BaseStructureType.StronidiumSilo: return(119);

                case BaseStructureType.FuelSilo: return(120);

                case BaseStructureType.CraftingDevice: return(121);

                case BaseStructureType.PersistentStorage: return(122);

                case BaseStructureType.Starship: return(123);
                }
            }

            // Check for individual resrefs. This should be used as a last-resort.
            switch (resref)
            {
            case "fuel_cell":
            case "stronidium":
                return(110);
            }

            // A -1 represents that this item is not supported on the market system.
            // This could be because we forgot to add a determination for it but more than likely it was
            // excluded on purpose. Lightsabers and Saberstaffs are an example of this.
            return(-1);
        }
コード例 #4
0
        public string Description(NWPlayer player, NWItem target, params string[] args)
        {
            int value = Convert.ToInt32(args[0]);

            return("Electrical Defense +" + value);
        }
コード例 #5
0
ファイル: StimPack.cs プロジェクト: xephnin/SWLOR_NWN
 public CustomData StartUseItem(NWCreature user, NWItem item, NWObject target, Location targetLocation)
 {
     return(null);
 }
コード例 #6
0
        public 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;

            if (item.BaseItemType == BaseItem.Amulet || item.BaseItemType == BaseItem.Ring)
            {
                var forceArmor = SkillService.GetPCSkill(player, (int)SkillType.ForceArmor);
                var lightArmor = SkillService.GetPCSkill(player, (int)SkillType.LightArmor);
                var heavyArmor = SkillService.GetPCSkill(player, (int)SkillType.HeavyArmor);
                var highest    = forceArmor.Rank;
                skill = SkillType.ForceArmor;

                if (lightArmor.Rank > highest)
                {
                    highest = lightArmor.Rank;
                    skill   = SkillType.LightArmor;
                }
                if (heavyArmor.Rank > highest)
                {
                    skill = SkillType.HeavyArmor;
                }
            }
            else
            {
                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));
            }
        }
コード例 #7
0
        public static void ApplyStatChanges(NWPlayer player, NWItem ignoreItem, bool isInitialization = false)
        {
            if (!player.IsPlayer)
            {
                return;
            }
            if (!player.IsInitializedAsPlayer)
            {
                return;
            }
            if (player.GetLocalInt("IS_SHIP") == 1)
            {
                return;
            }

            // Don't fire for ammo as it reapplies bonuses we **just** removed from blasters.
            if (ignoreItem != null &&
                (ignoreItem.BaseItemType == BaseItem.Bolt ||
                 ignoreItem.BaseItemType == BaseItem.Arrow ||
                 ignoreItem.BaseItemType == BaseItem.Bullet))
            {
                return;
            }

            Player         pcEntity = DataService.Player.GetByID(player.GlobalID);
            List <PCSkill> skills   = DataService.PCSkill
                                      .GetAllByPlayerID(player.GlobalID)
                                      .Where(x => x.Rank > 0).ToList();
            EffectiveItemStats itemBonuses = GetPlayerItemEffectiveStats(player, ignoreItem);

            float strBonus = 0.0f;
            float dexBonus = 0.0f;
            float conBonus = 0.0f;
            float intBonus = 0.0f;
            float wisBonus = 0.0f;
            float chaBonus = 0.0f;

            foreach (PCSkill pcSkill in skills)
            {
                Skill           skill     = DataService.Skill.GetByID(pcSkill.SkillID);
                CustomAttribute primary   = (CustomAttribute)skill.Primary;
                CustomAttribute secondary = (CustomAttribute)skill.Secondary;
                CustomAttribute tertiary  = (CustomAttribute)skill.Tertiary;

                // Primary Bonuses
                if (primary == CustomAttribute.STR)
                {
                    strBonus += PrimaryIncrease * pcSkill.Rank;
                }
                else if (primary == CustomAttribute.DEX)
                {
                    dexBonus += PrimaryIncrease * pcSkill.Rank;
                }
                else if (primary == CustomAttribute.CON)
                {
                    conBonus += PrimaryIncrease * pcSkill.Rank;
                }
                else if (primary == CustomAttribute.INT)
                {
                    intBonus += PrimaryIncrease * pcSkill.Rank;
                }
                else if (primary == CustomAttribute.WIS)
                {
                    wisBonus += PrimaryIncrease * pcSkill.Rank;
                }
                else if (primary == CustomAttribute.CHA)
                {
                    chaBonus += PrimaryIncrease * pcSkill.Rank;
                }

                // Secondary Bonuses
                if (secondary == CustomAttribute.STR)
                {
                    strBonus += SecondaryIncrease * pcSkill.Rank;
                }
                else if (secondary == CustomAttribute.DEX)
                {
                    dexBonus += SecondaryIncrease * pcSkill.Rank;
                }
                else if (secondary == CustomAttribute.CON)
                {
                    conBonus += SecondaryIncrease * pcSkill.Rank;
                }
                else if (secondary == CustomAttribute.INT)
                {
                    intBonus += SecondaryIncrease * pcSkill.Rank;
                }
                else if (secondary == CustomAttribute.WIS)
                {
                    wisBonus += SecondaryIncrease * pcSkill.Rank;
                }
                else if (secondary == CustomAttribute.CHA)
                {
                    chaBonus += SecondaryIncrease * pcSkill.Rank;
                }

                // Tertiary Bonuses
                if (tertiary == CustomAttribute.STR)
                {
                    strBonus += TertiaryIncrease * pcSkill.Rank;
                }
                else if (tertiary == CustomAttribute.DEX)
                {
                    dexBonus += TertiaryIncrease * pcSkill.Rank;
                }
                else if (tertiary == CustomAttribute.CON)
                {
                    conBonus += TertiaryIncrease * pcSkill.Rank;
                }
                else if (tertiary == CustomAttribute.INT)
                {
                    intBonus += TertiaryIncrease * pcSkill.Rank;
                }
                else if (tertiary == CustomAttribute.WIS)
                {
                    wisBonus += TertiaryIncrease * pcSkill.Rank;
                }
                else if (tertiary == CustomAttribute.CHA)
                {
                    chaBonus += TertiaryIncrease * pcSkill.Rank;
                }
            }

            // Check caps.
            if (strBonus > MaxAttributeBonus)
            {
                strBonus = MaxAttributeBonus;
            }
            if (dexBonus > MaxAttributeBonus)
            {
                dexBonus = MaxAttributeBonus;
            }
            if (conBonus > MaxAttributeBonus)
            {
                conBonus = MaxAttributeBonus;
            }
            if (intBonus > MaxAttributeBonus)
            {
                intBonus = MaxAttributeBonus;
            }
            if (wisBonus > MaxAttributeBonus)
            {
                wisBonus = MaxAttributeBonus;
            }
            if (chaBonus > MaxAttributeBonus)
            {
                chaBonus = MaxAttributeBonus;
            }

            // Apply item bonuses
            strBonus += itemBonuses.Strength;
            dexBonus += itemBonuses.Dexterity;
            conBonus += itemBonuses.Constitution;
            wisBonus += itemBonuses.Wisdom;
            intBonus += itemBonuses.Intelligence;
            chaBonus += itemBonuses.Charisma;

            // Check final caps
            if (strBonus > 55)
            {
                strBonus = 55;
            }
            if (dexBonus > 55)
            {
                dexBonus = 55;
            }
            if (conBonus > 55)
            {
                conBonus = 55;
            }
            if (intBonus > 55)
            {
                intBonus = 55;
            }
            if (wisBonus > 55)
            {
                wisBonus = 55;
            }
            if (chaBonus > 55)
            {
                chaBonus = 55;
            }

            // Apply attributes
            NWNXCreature.SetRawAbilityScore(player, AbilityType.Strength, (int)strBonus + pcEntity.STRBase);
            NWNXCreature.SetRawAbilityScore(player, AbilityType.Dexterity, (int)dexBonus + pcEntity.DEXBase);
            NWNXCreature.SetRawAbilityScore(player, AbilityType.Constitution, (int)conBonus + pcEntity.CONBase);
            NWNXCreature.SetRawAbilityScore(player, AbilityType.Intelligence, (int)intBonus + pcEntity.INTBase);
            NWNXCreature.SetRawAbilityScore(player, AbilityType.Wisdom, (int)wisBonus + pcEntity.WISBase);
            NWNXCreature.SetRawAbilityScore(player, AbilityType.Charisma, (int)chaBonus + pcEntity.CHABase);

            // Apply AC
            int ac = EffectiveArmorClass(player, ignoreItem, itemBonuses);

            NWNXCreature.SetBaseAC(player, ac);

            // Apply BAB
            int bab = CalculateBAB(player, ignoreItem, itemBonuses);

            NWNXCreature.SetBaseAttackBonus(player, bab);

            // Apply HP
            int hp = EffectiveMaxHitPoints(player, itemBonuses);

            for (int level = 1; level <= 5; level++)
            {
                hp--;
                NWNXCreature.SetMaxHitPointsByLevel(player, level, 1);
            }

            for (int level = 1; level <= 5; level++)
            {
                if (hp > 255) // Levels can only contain a max of 255 HP
                {
                    NWNXCreature.SetMaxHitPointsByLevel(player, level, 255);
                    hp = hp - 254;
                }
                else // Remaining value gets set to the level. (<255 hp)
                {
                    NWNXCreature.SetMaxHitPointsByLevel(player, level, hp + 1);
                    break;
                }
            }

            if (player.CurrentHP > player.MaxHP)
            {
                int amount = player.CurrentHP - player.MaxHP;
                var damage = _.EffectDamage(amount);
                _.ApplyEffectToObject(DurationType.Instant, damage, player.Object);
            }

            // Apply FP
            pcEntity.MaxFP = EffectiveMaxFP(player, itemBonuses);

            if (isInitialization)
            {
                pcEntity.CurrentFP = pcEntity.MaxFP;
            }

            DataService.SubmitDataChange(pcEntity, DatabaseActionType.Update);

            // Attempt a refresh of the character sheet UI in a second.
            _.DelayCommand(1.0f, () =>
            {
                NWNXPlayer.UpdateCharacterSheet(player);
            });
        }
コード例 #8
0
 public float MaxDistance(NWCreature user, NWItem item, NWObject target, Location targetLocation)
 {
     return(0);
 }
コード例 #9
0
        public string IsValidTarget(NWCreature user, NWItem mod, NWObject target, Location targetLocation)
        {
            if (target.ObjectType != OBJECT_TYPE_ITEM)
            {
                return("Only items may be targeted by mods.");
            }
            if (!user.IsPlayer)
            {
                return("Only players may use mods.");
            }
            NWPlayer player     = (user.Object);
            NWItem   targetItem = (target.Object);

            int modLevel          = mod.RecommendedLevel;
            int itemLevel         = targetItem.RecommendedLevel;
            int requiredPerkLevel = modLevel / 5;

            if (requiredPerkLevel <= 0)
            {
                requiredPerkLevel = 1;
            }
            int perkLevel = 0;
            CustomItemPropertyType modType = _mod.GetModType(mod);
            ModSlots modSlots = _mod.GetModSlots(targetItem);
            int      modID    = mod.GetLocalInt("RUNE_ID");

            string[] modArgs = mod.GetLocalString("RUNE_VALUE").Split(',');

            // Check for a misconfigured mod item.
            if (modType == CustomItemPropertyType.Unknown)
            {
                return("Mod color couldn't be found. Notify an admin that this mod item is not set up properly.");
            }
            if (modID <= 0)
            {
                return("Mod ID couldn't be found. Notify an admin that this mod item is not set up properly.");
            }
            if (modArgs.Length <= 0)
            {
                return("Mod value couldn't be found. Notify an admin that this mod item is not set up properly.");
            }

            // No available slots on target item
            if (modType == CustomItemPropertyType.RedMod && !modSlots.CanRedModBeAdded)
            {
                return("That item has no available red mod slots.");
            }
            if (modType == CustomItemPropertyType.BlueMod && !modSlots.CanBlueModBeAdded)
            {
                return("That item has no available blue mod slots.");
            }
            if (modType == CustomItemPropertyType.GreenMod && !modSlots.CanGreenModBeAdded)
            {
                return("That item has no available green mod slots.");
            }
            if (modType == CustomItemPropertyType.YellowMod && !modSlots.CanYellowModBeAdded)
            {
                return("That item has no available yellow mod slots.");
            }

            // Get the perk level based on target item type and mod type.
            if (WeaponsmithBaseItemTypes.Contains(targetItem.BaseItemType))
            {
                switch (modType)
                {
                case CustomItemPropertyType.RedMod:
                    perkLevel = _perk.GetPCPerkLevel(player, PerkType.CombatModInstallationWeapons);
                    break;

                case CustomItemPropertyType.BlueMod:
                    perkLevel = _perk.GetPCPerkLevel(player, PerkType.ForceModInstallationWeapons);
                    break;

                case CustomItemPropertyType.GreenMod:
                    perkLevel = _perk.GetPCPerkLevel(player, PerkType.CraftingModInstallationWeapons);
                    break;

                case CustomItemPropertyType.YellowMod:
                    perkLevel = _perk.GetPCPerkLevel(player, PerkType.SpecialModInstallationWeapons);
                    break;

                default:
                    perkLevel = 0;
                    break;
                }
            }
            else if (ItemService.ArmorBaseItemTypes.Contains(targetItem.BaseItemType))
            {
                switch (modType)
                {
                case CustomItemPropertyType.RedMod:
                    perkLevel = _perk.GetPCPerkLevel(player, PerkType.CombatModInstallationArmors);
                    break;

                case CustomItemPropertyType.BlueMod:
                    perkLevel = _perk.GetPCPerkLevel(player, PerkType.ForceModInstallationArmors);
                    break;

                case CustomItemPropertyType.GreenMod:
                    perkLevel = _perk.GetPCPerkLevel(player, PerkType.CraftingModInstallationArmors);
                    break;

                case CustomItemPropertyType.YellowMod:
                    perkLevel = _perk.GetPCPerkLevel(player, PerkType.SpecialModInstallationArmors);
                    break;

                default:
                    perkLevel = 0;
                    break;
                }
            }
            else if (EngineeringBaseItemTypes.Contains(targetItem.BaseItemType))
            {
                switch (modType)
                {
                case CustomItemPropertyType.RedMod:
                    perkLevel = _perk.GetPCPerkLevel(player, PerkType.CombatModInstallationElectronics);
                    break;

                case CustomItemPropertyType.BlueMod:
                    perkLevel = _perk.GetPCPerkLevel(player, PerkType.ForceModInstallationElectronics);
                    break;

                case CustomItemPropertyType.GreenMod:
                    perkLevel = _perk.GetPCPerkLevel(player, PerkType.CraftingModInstallationElectronics);
                    break;

                case CustomItemPropertyType.YellowMod:
                    perkLevel = _perk.GetPCPerkLevel(player, PerkType.SpecialModInstallationElectronics);
                    break;

                default:
                    perkLevel = 0;
                    break;
                }
            }

            // Ensure item isn't equipped.
            for (int slot = 0; slot < NUM_INVENTORY_SLOTS; slot++)
            {
                if (_.GetItemInSlot(slot, user.Object) == targetItem.Object)
                {
                    return("Targeted item must be unequipped before installing a mod.");
                }
            }

            // Check for perk level requirement
            if (perkLevel < requiredPerkLevel)
            {
                return("You do not have the necessary perk rank required. (Required: " + requiredPerkLevel + ", Your level: " + perkLevel + ")");
            }

            // Can't modify items above perk level * 10
            if (itemLevel > perkLevel * 10)
            {
                return("Your current perks allow you to add mods to items up to level " + perkLevel * 10 + ". This item is level " + itemLevel + " so you can't install a mod into it.");
            }

            // Item must be in the user's inventory.
            if (!targetItem.Possessor.Equals(player))
            {
                return("Targeted item must be in your inventory.");
            }

            // Look for a database entry for this mod type.
            var dbMod = _data.SingleOrDefault <Data.Entity.Mod>(x => x.ID == modID && x.IsActive);

            if (dbMod == null)
            {
                return("Couldn't find a matching mod ID in the database. Inform an admin of this issue.");
            }

            // Run the individual mod's rules for application. Will return the error message or a null.
            string canApply = App.ResolveByInterface <IMod, string>("Mod." + dbMod.Script,
                                                                    (modRules) => modRules.CanApply(player, targetItem, modArgs));

            return(canApply);
        }
コード例 #10
0
ファイル: OnDamaged.cs プロジェクト: zunath/Freescape
        public bool Run(params object[] args)
        {
            NWPlaceable resource = NWPlaceable.Wrap(Object.OBJECT_SELF);
            NWPlayer    oPC      = NWPlayer.Wrap(_.GetLastDamager(resource.Object));

            if (oPC.GetLocalInt("NOT_USING_CORRECT_WEAPON") == 1)
            {
                oPC.DeleteLocalInt("NOT_USING_CORRECT_WEAPON");
                return(true);
            }

            PlayerCharacter pcEntity = _db.PlayerCharacters.Single(x => x.PlayerID == oPC.GlobalID);

            NWItem    oWeapon            = NWItem.Wrap(_.GetLastWeaponUsed(oPC.Object));
            Location  location           = oPC.Location;
            string    resourceItemResref = resource.GetLocalString("RESOURCE_RESREF");
            int       activityID         = resource.GetLocalInt("RESOURCE_ACTIVITY");
            string    resourceName       = resource.GetLocalString("RESOURCE_NAME");
            int       resourceCount      = resource.GetLocalInt("RESOURCE_COUNT");
            int       difficultyRating   = resource.GetLocalInt("RESOURCE_DIFFICULTY_RATING");
            int       weaponChanceBonus;
            SkillType skillType;
            int       perkChanceBonus;
            int       secondResourceChance;
            int       durabilityChanceReduction = 0;
            int       hasteChance;
            int       lucky = _perk.GetPCPerkLevel(oPC, PerkType.Lucky);
            bool      hasBaggerPerk;

            if (activityID == 1) // 1 = Logging
            {
                weaponChanceBonus = oWeapon.LoggingBonus;
                if (weaponChanceBonus > 0)
                {
                    weaponChanceBonus        += _perk.GetPCPerkLevel(oPC, PerkType.LoggingAxeExpert) * 5;
                    durabilityChanceReduction = _perk.GetPCPerkLevel(oPC, PerkType.LoggingAxeExpert) * 10 + lucky;
                }

                skillType            = SkillType.Logging;
                perkChanceBonus      = _perk.GetPCPerkLevel(oPC, PerkType.Lumberjack) * 5 + lucky;
                secondResourceChance = _perk.GetPCPerkLevel(oPC, PerkType.PrecisionLogging) * 10;
                hasteChance          = _perk.GetPCPerkLevel(oPC, PerkType.SpeedyLogger) * 10 + lucky;

                if (pcEntity.BackgroundID == (int)BackgroundType.Lumberjack)
                {
                    hasteChance += 10;
                }

                hasBaggerPerk = _perk.GetPCPerkLevel(oPC, PerkType.WoodBagger) > 0;
            }
            else if (activityID == 2) // Mining
            {
                weaponChanceBonus = oWeapon.MiningBonus;
                if (weaponChanceBonus > 0)
                {
                    weaponChanceBonus        += _perk.GetPCPerkLevel(oPC, PerkType.PickaxeExpert) * 5;
                    durabilityChanceReduction = _perk.GetPCPerkLevel(oPC, PerkType.PickaxeExpert) * 10 + lucky;
                }
                skillType            = SkillType.Mining;
                perkChanceBonus      = _perk.GetPCPerkLevel(oPC, PerkType.Miner) * 5 + lucky;
                secondResourceChance = _perk.GetPCPerkLevel(oPC, PerkType.PrecisionMining) * 10;
                hasteChance          = _perk.GetPCPerkLevel(oPC, PerkType.SpeedyMiner) * 10 + lucky;

                if (pcEntity.BackgroundID == (int)BackgroundType.Miner)
                {
                    hasteChance += 10;
                }

                hasBaggerPerk = _perk.GetPCPerkLevel(oPC, PerkType.OreBagger) > 0;
            }
            else
            {
                return(false);
            }
            PCSkill skill = _skill.GetPCSkillByID(oPC.GlobalID, (int)skillType);
            int     durabilityLossChance = 100 - durabilityChanceReduction;

            if (_random.Random(100) <= durabilityLossChance)
            {
                _durability.RunItemDecay(oPC, oWeapon);
            }

            int baseChance = 10;
            int chance     = baseChance + weaponChanceBonus;

            chance += CalculateSuccessChanceDeltaModifier(difficultyRating, skill.Rank);
            chance += perkChanceBonus;

            bool givePityItem = false;

            if (chance > 0)
            {
                if (_random.Random(100) + 1 <= hasteChance)
                {
                    _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, _.EffectHaste(), oPC.Object, 8.0f);
                }

                // Give an item if the player hasn't gotten anything after 6-8 attempts.
                int      attemptFailureCount = oPC.GetLocalInt("RESOURCE_ATTEMPT_FAILURE_COUNT") + 1;
                NWObject failureResource     = NWObject.Wrap(oPC.GetLocalObject("RESOURCE_ATTEMPT_FAILURE_OBJECT"));

                if (!failureResource.IsValid || !Equals(failureResource, resource))
                {
                    failureResource     = resource;
                    attemptFailureCount = 1;
                }

                int pityItemChance = 0;
                if (attemptFailureCount == 6)
                {
                    pityItemChance = 60;
                }
                else if (attemptFailureCount == 7)
                {
                    pityItemChance = 80;
                }
                else if (attemptFailureCount >= 8)
                {
                    pityItemChance = 100;
                }

                if (_random.Random(100) + 1 <= pityItemChance)
                {
                    givePityItem        = true;
                    attemptFailureCount = 0;
                }

                oPC.SetLocalInt("RESOURCE_ATTEMPT_FAILURE_COUNT", attemptFailureCount);
                oPC.SetLocalObject("RESOURCE_ATTEMPT_FAILURE_OBJECT", failureResource.Object);
            }

            if (chance <= 0)
            {
                oPC.FloatingText("You do not have enough skill to harvest this resource...");
            }
            else if (_random.Random(100) <= chance || givePityItem)
            {
                if (hasBaggerPerk)
                {
                    _.CreateItemOnObject(resourceItemResref, oPC.Object);
                }
                else
                {
                    _.CreateObject(OBJECT_TYPE_ITEM, resourceItemResref, location);
                }


                oPC.FloatingText("You break off some " + resourceName + ".");
                resource.SetLocalInt("RESOURCE_COUNT", --resourceCount);
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(10000), resource.Object);

                if (_random.Random(100) + 1 <= secondResourceChance)
                {
                    oPC.FloatingText("You break off a second piece.");

                    if (hasBaggerPerk)
                    {
                        _.CreateItemOnObject(resourceItemResref, oPC.Object);
                    }
                    else
                    {
                        _.CreateObject(OBJECT_TYPE_ITEM, resourceItemResref, location);
                    }
                }

                float deltaModifier = CalculateXPDeltaModifier(difficultyRating, skill.Rank);
                float baseXP        = (100 + _random.Random(20)) * deltaModifier;
                int   xp            = (int)_skill.CalculateSkillAdjustedXP(baseXP, oWeapon.RecommendedLevel, skill.Rank);
                _skill.GiveSkillXP(oPC, skillType, xp);

                oPC.DeleteLocalInt("RESOURCE_ATTEMPT_FAILURE_COUNT");
                oPC.DeleteLocalObject("RESOURCE_ATTEMPT_FAILURE_OBJECT");
            }

            if (resourceCount <= 0)
            {
                SpawnSeed(resource, oPC);

                NWObject prop = NWObject.Wrap(resource.GetLocalObject("RESOURCE_PROP_OBJ"));
                if (prop.IsValid)
                {
                    prop.Destroy();
                }
                resource.Destroy();
            }
            return(true);
        }
コード例 #11
0
        private void ApplyFeatChanges(NWPlayer oPC, NWItem oItem)
        {
            NWItem equipped = oItem ?? oPC.RightHand;

            RemoveAllFeats(oPC);

            // Unarmed check
            NWItem mainHand = oPC.RightHand;
            NWItem offHand  = oPC.LeftHand;

            if (oItem != null && Equals(oItem, mainHand))
            {
                mainHand = (new Object());
            }
            else if (oItem != null && Equals(oItem, offHand))
            {
                offHand = (new Object());
            }

            if (!mainHand.IsValid && !offHand.IsValid)
            {
                if (PerkService.GetPCPerkLevel(oPC, PerkType.ImprovedCriticalMartialArts) > 0)
                {
                    NWNXCreature.AddFeat(oPC, FEAT_IMPROVED_CRITICAL_UNARMED_STRIKE);
                }
                return;
            }

            if (oItem != null && Equals(oItem, equipped))
            {
                return;
            }

            // All other weapon types
            PerkType perkType;

            switch (equipped.CustomItemType)
            {
            case CustomItemType.Vibroblade: perkType = PerkType.ImprovedCriticalVibroblades; break;

            case CustomItemType.FinesseVibroblade: perkType = PerkType.ImprovedCriticalFinesseVibroblades; break;

            case CustomItemType.Baton: perkType = PerkType.ImprovedCriticalBatons; break;

            case CustomItemType.HeavyVibroblade: perkType = PerkType.ImprovedCriticalHeavyVibroblades; break;

            case CustomItemType.Polearm: perkType = PerkType.ImprovedCriticalPolearms; break;

            case CustomItemType.TwinBlade: perkType = PerkType.ImprovedCriticalTwinVibroblades; break;

            case CustomItemType.MartialArtWeapon: perkType = PerkType.ImprovedCriticalMartialArts; break;

            case CustomItemType.BlasterPistol: perkType = PerkType.ImprovedCriticalBlasterPistols; break;

            case CustomItemType.BlasterRifle: perkType = PerkType.ImprovedCriticalBlasterRifles; break;

            case CustomItemType.Throwing: perkType = PerkType.ImprovedCriticalThrowing; break;

            case CustomItemType.Lightsaber: perkType = PerkType.ImprovedCriticalLightsabers; break;

            case CustomItemType.Saberstaff: perkType = PerkType.ImprovedCriticalSaberstaffs; break;

            default: return;
            }

            if (equipped.GetLocalInt("LIGHTSABER") == TRUE)
            {
                perkType = PerkType.ImprovedCriticalLightsabers;
            }

            int perkLevel = PerkService.GetPCPerkLevel(oPC, perkType);
            int type      = equipped.BaseItemType;

            if (perkLevel > 0)
            {
                AddCriticalFeat(oPC, type);
            }
        }
コード例 #12
0
        private void OnReassembleComplete(OnReassembleComplete data)
        {
            _player = data.Player;
            int xp = 100; // Always grant at least this much XP to player.

            // Remove the immobilization effect
            foreach (var effect in _player.Effects)
            {
                if (_.GetEffectTag(effect) == "CRAFTING_IMMOBILIZATION")
                {
                    _.RemoveEffect(_player, effect);
                }
            }

            // Check for a fuel cell in the player's inventory again. If it doesn't exist, we exit early with an error message.
            NWItem fuel = _.GetItemPossessedBy(_player, "ass_power");

            if (!fuel.IsValid)
            {
                _player.SendMessage(ColorTokenService.Red("A 'Reassembly Fuel Cell' was not found in your inventory. Reassembly failed."));
                return;
            }

            // Otherwise the fuel cell was found. Destroy it and continue on with the process.
            fuel.Destroy();

            _playerItemStats = PlayerStatService.GetPlayerItemEffectiveStats(_player);
            string      serializedSalvageItem = data.SerializedSalvageItem;
            NWPlaceable tempStorage           = _.GetObjectByTag("TEMP_ITEM_STORAGE");
            NWItem      item = SerializationService.DeserializeItem(serializedSalvageItem, tempStorage);
            int         salvageComponentTypeID = data.SalvageComponentTypeID;

            _componentType = DataService.ComponentType.GetByID(salvageComponentTypeID);

            // Create an item with no bonuses every time.
            _.CreateItemOnObject(_componentType.ReassembledResref, _player);

            // Now check specific custom properties which are stored as local variables on the item.
            xp += ProcessProperty(item.HarvestingBonus, 3, ComponentBonusType.HarvestingUp);
            xp += ProcessProperty(item.PilotingBonus, 3, ComponentBonusType.PilotingUp);
            xp += ProcessProperty(item.ScanningBonus, 3, ComponentBonusType.ScanningUp);
            xp += ProcessProperty(item.ScavengingBonus, 3, ComponentBonusType.ScavengingUp);
            xp += ProcessProperty(item.CooldownRecovery, 3, ComponentBonusType.CooldownRecoveryUp);
            xp += ProcessProperty(item.CraftBonusArmorsmith, 3, ComponentBonusType.ArmorsmithUp);
            xp += ProcessProperty(item.CraftBonusWeaponsmith, 3, ComponentBonusType.WeaponsmithUp);
            xp += ProcessProperty(item.CraftBonusCooking, 3, ComponentBonusType.CookingUp);
            xp += ProcessProperty(item.CraftBonusEngineering, 3, ComponentBonusType.EngineeringUp);
            xp += ProcessProperty(item.CraftBonusFabrication, 3, ComponentBonusType.FabricationUp);
            xp += ProcessProperty(item.HPBonus, 5, ComponentBonusType.HPUp, 0.5f);
            xp += ProcessProperty(item.FPBonus, 5, ComponentBonusType.FPUp, 0.5f);
            xp += ProcessProperty(item.EnmityRate, 3, ComponentBonusType.EnmityUp);

            xp += ProcessProperty(item.LuckBonus, 3, ComponentBonusType.LuckUp);
            xp += ProcessProperty(item.MeditateBonus, 3, ComponentBonusType.MeditateUp);
            xp += ProcessProperty(item.RestBonus, 3, ComponentBonusType.RestUp);
            xp += ProcessProperty(item.MedicineBonus, 3, ComponentBonusType.MedicineUp);
            xp += ProcessProperty(item.HPRegenBonus, 3, ComponentBonusType.HPRegenUp);
            xp += ProcessProperty(item.FPRegenBonus, 3, ComponentBonusType.FPRegenUp);
            xp += ProcessProperty(item.BaseAttackBonus, 3, ComponentBonusType.BaseAttackBonusUp, 6f);
            xp += ProcessProperty(item.StructureBonus, 3, ComponentBonusType.StructureBonusUp);
            xp += ProcessProperty(item.SneakAttackBonus, 3, ComponentBonusType.SneakAttackUp);
            xp += ProcessProperty(item.DamageBonus, 3, ComponentBonusType.DamageUp);
            xp += ProcessProperty(item.StrengthBonus, 3, ComponentBonusType.StrengthUp);
            xp += ProcessProperty(item.DexterityBonus, 3, ComponentBonusType.DexterityUp);
            xp += ProcessProperty(item.ConstitutionBonus, 3, ComponentBonusType.ConstitutionUp);
            xp += ProcessProperty(item.WisdomBonus, 3, ComponentBonusType.WisdomUp);
            xp += ProcessProperty(item.IntelligenceBonus, 3, ComponentBonusType.IntelligenceUp);
            xp += ProcessProperty(item.CharismaBonus, 3, ComponentBonusType.CharismaUp);
            xp += ProcessProperty(item.DurationBonus, 3, ComponentBonusType.DurationUp);

            item.Destroy();

            SkillService.GiveSkillXP(_player, SkillType.Harvesting, xp);
        }
コード例 #13
0
        private int ProcessProperty(int amount, int maxBonuses, ComponentBonusType bonus, float levelsPerBonus = 1.0f)
        {
            string resref  = _componentType.ReassembledResref;
            int    penalty = 0;
            int    luck    = PerkService.GetCreaturePerkLevel(_player, PerkType.Lucky) + (_playerItemStats.Luck / 3);
            int    xp      = 0;

            ItemPropertyUnpacked bonusIP = new ItemPropertyUnpacked
            {
                Property       = (int)CustomItemPropertyType.ComponentBonus,
                SubType        = (int)bonus,
                CostTable      = 62,
                CostTableValue = 0,
                Param1         = 255,
                Param1Value    = 0,
                UsesPerDay     = 255,
                ChanceToAppear = 100,
                IsUseable      = true,
                SpellID        = -1
            };

            while (amount > 0)
            {
                int chanceToTransfer = CraftService.CalculateReassemblyChance(_player, penalty);
                // Roll to see if the item can be created.
                bool success = RandomService.Random(0, 100) <= chanceToTransfer;

                // Do a lucky roll if we failed the first time.
                if (!success && luck > 0 && RandomService.Random(0, 100) <= luck)
                {
                    _player.SendMessage("Lucky reassemble!");
                    success = true;
                }

                if (amount >= maxBonuses)
                {
                    if (success)
                    {
                        int levelIncrease = (int)(maxBonuses * levelsPerBonus);
                        // Roll succeeded. Create item.
                        bonusIP.CostTableValue = maxBonuses;
                        ItemProperty bonusIPPacked = NWNXItemProperty.PackIP(bonusIP);
                        NWItem       item          = _.CreateItemOnObject(resref, _player);
                        item.RecommendedLevel = levelIncrease;
                        BiowareXP2.IPSafeAddItemProperty(item, bonusIPPacked, 0.0f, AddItemPropertyPolicy.ReplaceExisting, true, false);

                        xp += (150 * maxBonuses + RandomService.Random(0, 5));
                    }
                    else
                    {
                        _player.SendMessage(ColorTokenService.Red("You failed to create a component. (+" + maxBonuses + ")"));
                        xp += (50 + RandomService.Random(0, 5));
                    }
                    // Penalty to chance increases regardless if item was created or not.
                    penalty += (maxBonuses * 5);
                    amount  -= maxBonuses;
                }
                else
                {
                    if (success)
                    {
                        int levelIncrease = (int)(amount * levelsPerBonus);
                        bonusIP.CostTableValue = amount;
                        ItemProperty bonusIPPacked = NWNXItemProperty.PackIP(bonusIP);
                        NWItem       item          = _.CreateItemOnObject(resref, _player);
                        item.RecommendedLevel = levelIncrease;
                        BiowareXP2.IPSafeAddItemProperty(item, bonusIPPacked, 0.0f, AddItemPropertyPolicy.ReplaceExisting, true, false);

                        xp += (150 * amount + RandomService.Random(0, 5));
                    }
                    else
                    {
                        _player.SendMessage(ColorTokenService.Red("You failed to create a component. (+" + amount + ")"));
                        xp += (50 + RandomService.Random(0, 5));
                    }
                    break;
                }
            }

            return(xp);
        }
コード例 #14
0
ファイル: RepairKit.cs プロジェクト: zunath/SWLOR_NWN
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            SkillType skillType  = GetSkillType(item);
            NWItem    targetitem = (target.Object);
            int       tech       = item.GetLocalInt("TECH_LEVEL");
            float     maxDurabilityReductionPenalty = item.GetLocalFloat("MAX_DURABILITY_REDUCTION_PENALTY");
            int       repairAmount = tech * 2;
            int       skillRank;
            int       level  = targetitem.RecommendedLevel;
            int       delta  = 0;
            int       baseXP = 0;

            if (skillType == SkillType.Armorsmith)
            {
                skillRank     = (SkillService.GetPCSkillRank(user.Object, skillType));
                repairAmount += item.CraftBonusArmorsmith + (PerkService.GetCreaturePerkLevel(user.Object, PerkType.ArmorRepair) * 2);
                delta         = level - skillRank;
            }
            else if (skillType == SkillType.Weaponsmith)
            {
                skillRank     = (SkillService.GetPCSkillRank(user.Object, skillType));
                repairAmount += item.CraftBonusWeaponsmith + (PerkService.GetCreaturePerkLevel(user.Object, PerkType.WeaponRepair) * 2);
                delta         = level - skillRank;
            }
            else if (skillType == SkillType.Engineering)
            {
                skillRank     = (SkillService.GetPCSkillRank(user.Object, skillType));
                repairAmount += item.CraftBonusEngineering + (PerkService.GetCreaturePerkLevel(user.Object, PerkType.ElectronicRepair) * 2);
                delta         = level - skillRank;
            }
            float minReduction    = 0.05f * tech;
            float maxReduction    = 0.15f * tech;
            float reductionAmount = RandomService.RandomFloat(minReduction, maxReduction);

            if (delta >= 6)
            {
                baseXP = 400;
            }
            else if (delta == 5)
            {
                baseXP = 350;
            }
            else if (delta == 4)
            {
                baseXP = 325;
            }
            else if (delta == 3)
            {
                baseXP = 300;
            }
            else if (delta == 2)
            {
                baseXP = 250;
            }
            else if (delta == 1)
            {
                baseXP = 225;
            }
            else if (delta == 0)
            {
                baseXP = 200;
            }
            else if (delta == -1)
            {
                baseXP = 150;
            }
            else if (delta == -2)
            {
                baseXP = 100;
            }
            else if (delta == -3)
            {
                baseXP = 50;
            }
            else if (delta == -4)
            {
                baseXP = 25;
            }
            SkillService.GiveSkillXP(user.Object, skillType, baseXP);
            DurabilityService.RunItemRepair(user.Object, target.Object, repairAmount, reductionAmount + maxDurabilityReductionPenalty);
        }
コード例 #15
0
 public void OnItemUnequipped(NWPlayer oPC, NWItem oItem)
 {
     ApplyFeatChanges(oPC, oItem);
 }
コード例 #16
0
        public void ApplyEffects(NWCreature user, NWItem modItem, NWObject target, Location targetLocation, CustomData customData)
        {
            NWPlayer player                = (user.Object);
            NWItem   targetItem            = (target.Object);
            ModSlots slots                 = _mod.GetModSlots(targetItem);
            CustomItemPropertyType modType = _mod.GetModType(modItem);
            int modID = modItem.GetLocalInt("RUNE_ID");

            string[] modArgs       = modItem.GetLocalString("RUNE_VALUE").Split(',');
            int      modLevel      = modItem.RecommendedLevel;
            int      levelIncrease = modItem.LevelIncrease;

            var dbMod = _data.Single <Data.Entity.Mod>(x => x.ID == modID && x.IsActive);

            App.ResolveByInterface <IMod>("Mod." + dbMod.Script, mod =>
            {
                mod.Apply(player, targetItem, modArgs);

                string description = mod.Description(player, targetItem, modArgs);
                bool usePrismatic  = false;
                switch (modType)
                {
                case CustomItemPropertyType.RedMod:
                    if (slots.FilledRedSlots < slots.RedSlots)
                    {
                        targetItem.SetLocalInt("MOD_SLOT_RED_" + (slots.FilledRedSlots + 1), modID);
                        targetItem.SetLocalString("MOD_SLOT_RED_DESC_" + (slots.FilledRedSlots + 1), description);
                        player.SendMessage("Mod installed into " + _color.Red("red") + " slot #" + (slots.FilledRedSlots + 1));
                    }
                    else
                    {
                        usePrismatic = true;
                    }
                    break;

                case CustomItemPropertyType.BlueMod:
                    if (slots.FilledBlueSlots < slots.BlueSlots)
                    {
                        targetItem.SetLocalInt("MOD_SLOT_BLUE_" + (slots.FilledBlueSlots + 1), modID);
                        targetItem.SetLocalString("MOD_SLOT_BLUE_DESC_" + (slots.FilledBlueSlots + 1), description);
                        player.SendMessage("Mod installed into " + _color.Blue("blue") + " slot #" + (slots.FilledBlueSlots + 1));
                    }
                    else
                    {
                        usePrismatic = true;
                    }
                    break;

                case CustomItemPropertyType.GreenMod:
                    if (slots.FilledBlueSlots < slots.GreenSlots)
                    {
                        targetItem.SetLocalInt("MOD_SLOT_GREEN_" + (slots.FilledGreenSlots + 1), modID);
                        targetItem.SetLocalString("MOD_SLOT_GREEN_DESC_" + (slots.FilledGreenSlots + 1), description);
                        player.SendMessage("Mod installed into " + _color.Green("green") + " slot #" + (slots.FilledGreenSlots + 1));
                    }
                    else
                    {
                        usePrismatic = true;
                    }
                    break;

                case CustomItemPropertyType.YellowMod:
                    if (slots.FilledBlueSlots < slots.YellowSlots)
                    {
                        targetItem.SetLocalInt("MOD_SLOT_YELLOW_" + (slots.FilledYellowSlots + 1), modID);
                        targetItem.SetLocalString("MOD_SLOT_YELLOW_DESC_" + (slots.FilledYellowSlots + 1), description);
                        player.SendMessage("Mod installed into " + _color.Yellow("yellow") + " slot #" + (slots.FilledYellowSlots + 1));
                    }
                    else
                    {
                        usePrismatic = true;
                    }
                    break;
                }

                if (usePrismatic)
                {
                    string prismaticText = _mod.PrismaticString();
                    targetItem.SetLocalInt("MOD_SLOT_PRISMATIC_" + (slots.FilledPrismaticSlots + 1), modID);
                    targetItem.SetLocalString("MOD_SLOT_PRISMATIC_DESC_" + (slots.FilledPrismaticSlots + 1), description);
                    player.SendMessage("Mod installed into " + prismaticText + " slot #" + (slots.FilledPrismaticSlots + 1));
                }

                targetItem.RecommendedLevel += levelIncrease;
                modItem.Destroy();

                SkillType skillType;
                if (ItemService.ArmorBaseItemTypes.Contains(targetItem.BaseItemType))
                {
                    skillType = SkillType.Armorsmith;
                }
                else if (WeaponsmithBaseItemTypes.Contains(targetItem.BaseItemType))
                {
                    skillType = SkillType.Weaponsmith;
                }
                else if (EngineeringBaseItemTypes.Contains(targetItem.BaseItemType))
                {
                    skillType = SkillType.Engineering;
                }
                else
                {
                    return;
                }

                int rank = _skill.GetPCSkillRank(player, skillType);
                int xp   = (int)_skill.CalculateRegisteredSkillLevelAdjustedXP(400, modLevel, rank);
                _skill.GiveSkillXP(player, skillType, xp);
            });
        }
コード例 #17
0
 public void OnItemUnequipped(NWPlayer oPC, NWItem oItem)
 {
 }
コード例 #18
0
ファイル: WaterJug.cs プロジェクト: zunath/Freescape
 public string IsValidTarget(NWCreature user, NWItem item, NWObject target, Location targetLocation)
 {
     return(null);
 }
コード例 #19
0
        public static EffectiveItemStats GetPlayerItemEffectiveStats(NWPlayer player, NWItem ignoreItem = null)
        {
            int heavyRank   = DataService.PCSkill.GetByPlayerIDAndSkillID(player.GlobalID, (int)SkillType.HeavyArmor).Rank;
            int lightRank   = DataService.PCSkill.GetByPlayerIDAndSkillID(player.GlobalID, (int)SkillType.LightArmor).Rank;
            int forceRank   = DataService.PCSkill.GetByPlayerIDAndSkillID(player.GlobalID, (int)SkillType.ForceArmor).Rank;
            int martialRank = DataService.PCSkill.GetByPlayerIDAndSkillID(player.GlobalID, (int)SkillType.MartialArts).Rank;

            EffectiveItemStats stats = new EffectiveItemStats();

            stats.EnmityRate = 1.0f;

            HashSet <NWItem> processed = new HashSet <NWItem>();

            for (int itemSlot = 0; itemSlot < NumberOfInventorySlots; itemSlot++)
            {
                NWItem item = _.GetItemInSlot((InventorySlot)itemSlot, player);

                if (!item.IsValid || item.Equals(ignoreItem))
                {
                    continue;
                }

                // Have we already processed this particular item? Skip over it.
                // NWN likes to include the same weapon in multiple slots for some reasons, so this works around that.
                // If someone has a better solution to this please feel free to change it.
                if (processed.Contains(item))
                {
                    continue;
                }
                processed.Add(item);

                SkillType skill = ItemService.GetSkillTypeForItem(item);
                var       rank  = DataService.PCSkill.GetByPlayerIDAndSkillID(player.GlobalID, (int)skill).Rank;
                stats.CooldownRecovery += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_COOLDOWN_RECOVERY");
                stats.EnmityRate       += item.GetLocalFloat("STAT_EFFECTIVE_LEVEL_ENMITY_RATE");
                stats.Luck             += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_LUCK_BONUS");
                stats.Meditate         += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_MEDITATE_BONUS");
                stats.Rest             += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_REST_BONUS");
                stats.Medicine         += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_MEDICINE_BONUS");
                stats.HPRegen          += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_HP_REGEN_BONUS");
                stats.FPRegen          += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_FP_REGEN_BONUS");
                stats.Weaponsmith      += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_WEAPONSMITH_BONUS");
                stats.Cooking          += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_COOKING_BONUS");
                stats.Engineering      += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_ENGINEERING_BONUS");
                stats.Fabrication      += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_FABRICATION_BONUS");
                stats.Armorsmith       += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_ARMORSMITH_BONUS");
                stats.Harvesting       += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_HARVESTING_BONUS");
                stats.Piloting         += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_PILOTING_BONUS");
                stats.Scavenging       += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_SCAVENGING_BONUS");
                stats.SneakAttack      += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_SNEAK_ATTACK_BONUS");
                stats.Strength         += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_STRENGTH_BONUS");
                stats.Dexterity        += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_DEXTERITY_BONUS");
                stats.Constitution     += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_CONSTITUTION_BONUS");
                stats.Wisdom           += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_WISDOM_BONUS");
                stats.Intelligence     += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_INTELLIGENCE_BONUS");
                stats.Charisma         += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_CHARISMA_BONUS");
                stats.HP += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_HP_BONUS");
                stats.FP += item.GetLocalInt("STAT_EFFECTIVE_LEVEL_FP_BONUS");

                // Calculate base attack bonus
                if (ItemService.WeaponBaseItemTypes.Contains(item.BaseItemType))
                {
                    int itemLevel = item.RecommendedLevel;
                    int delta     = itemLevel - rank;
                    int itemBAB   = item.BaseAttackBonus;
                    if (delta >= 1)
                    {
                        itemBAB--;
                    }
                    if (delta > 0)
                    {
                        itemBAB = itemBAB - delta / 5;
                    }

                    if (itemBAB <= 0)
                    {
                        itemBAB = 0;
                    }
                    stats.BAB += itemBAB;
                }


                // Calculate AC
                if (ItemService.ArmorBaseItemTypes.Contains(item.BaseItemType) ||
                    ItemService.ShieldBaseItemTypes.Contains(item.BaseItemType))
                {
                    int skillRankToUse;
                    if (item.CustomItemType == CustomItemType.HeavyArmor)
                    {
                        skillRankToUse = heavyRank;
                    }
                    else if (item.CustomItemType == CustomItemType.LightArmor)
                    {
                        skillRankToUse = lightRank;
                    }
                    else if (item.CustomItemType == CustomItemType.ForceArmor)
                    {
                        skillRankToUse = forceRank;
                    }
                    else if (item.CustomItemType == CustomItemType.MartialArtWeapon)
                    {
                        skillRankToUse = martialRank;
                    }
                    else
                    {
                        continue;
                    }

                    int itemAC = item.CustomAC;
                    itemAC    = CalculateAdjustedValue(itemAC, item.RecommendedLevel, skillRankToUse, 0);
                    stats.AC += itemAC;
                }
            }

            // Final casting speed adjustments
            if (stats.CooldownRecovery < -99)
            {
                stats.CooldownRecovery = -99;
            }
            else if (stats.CooldownRecovery > 99)
            {
                stats.CooldownRecovery = 99;
            }

            // Final enmity adjustments
            if (stats.EnmityRate < 0.5f)
            {
                stats.EnmityRate = 0.5f;
            }
            else if (stats.EnmityRate > 1.5f)
            {
                stats.EnmityRate = 1.5f;
            }

            var stance = CustomEffectService.GetCurrentStanceType(player);

            if (stance == CustomEffectType.ShieldOath)
            {
                stats.EnmityRate = stats.EnmityRate + 0.2f;
            }

            return(stats);
        }
コード例 #20
0
        public void InitializePlayer(NWPlayer player)
        {
            if (player == null)
            {
                throw new ArgumentNullException(nameof(player));
            }
            if (player.Object == null)
            {
                throw new ArgumentNullException(nameof(player.Object));
            }
            if (!player.IsPlayer)
            {
                return;
            }

            if (!player.IsInitializedAsPlayer)
            {
                player.DestroyAllInventoryItems();
                player.InitializePlayer();
                _.AssignCommand(player, () => _.TakeGoldFromCreature(_.GetGold(player), player, 1));

                _.DelayCommand(0.5f, () =>
                {
                    _.GiveGoldToCreature(player, 100);
                });

                // Capture original stats before we level up the player.
                int str  = _nwnxCreature.GetRawAbilityScore(player, ABILITY_STRENGTH);
                int con  = _nwnxCreature.GetRawAbilityScore(player, ABILITY_CONSTITUTION);
                int dex  = _nwnxCreature.GetRawAbilityScore(player, ABILITY_DEXTERITY);
                int @int = _nwnxCreature.GetRawAbilityScore(player, ABILITY_INTELLIGENCE);
                int wis  = _nwnxCreature.GetRawAbilityScore(player, ABILITY_WISDOM);
                int cha  = _nwnxCreature.GetRawAbilityScore(player, ABILITY_CHARISMA);

                // Take player to level 5 in NWN levels so that we have access to more HP slots
                _.GiveXPToCreature(player, 10000);

                for (int level = 1; level <= 5; level++)
                {
                    _.LevelUpHenchman(player, player.Class1);
                }

                // Set stats back to how they were on entry.
                _nwnxCreature.SetRawAbilityScore(player, ABILITY_STRENGTH, str);
                _nwnxCreature.SetRawAbilityScore(player, ABILITY_CONSTITUTION, con);
                _nwnxCreature.SetRawAbilityScore(player, ABILITY_DEXTERITY, dex);
                _nwnxCreature.SetRawAbilityScore(player, ABILITY_INTELLIGENCE, @int);
                _nwnxCreature.SetRawAbilityScore(player, ABILITY_WISDOM, wis);
                _nwnxCreature.SetRawAbilityScore(player, ABILITY_CHARISMA, cha);

                NWItem knife = (_.CreateItemOnObject("survival_knife", player));
                knife.Name     = player.Name + "'s Survival Knife";
                knife.IsCursed = true;
                _durability.SetMaxDurability(knife, 5);
                _durability.SetDurability(knife, 5);

                NWItem book = (_.CreateItemOnObject("player_guide", player));
                book.Name     = player.Name + "'s Player Guide";
                book.IsCursed = true;

                NWItem dyeKit = (_.CreateItemOnObject("tk_omnidye", player));
                dyeKit.IsCursed = true;

                int numberOfFeats = _nwnxCreature.GetFeatCount(player);
                for (int currentFeat = numberOfFeats; currentFeat >= 0; currentFeat--)
                {
                    _nwnxCreature.RemoveFeat(player, _nwnxCreature.GetFeatByIndex(player, currentFeat - 1));
                }

                _nwnxCreature.AddFeatByLevel(player, FEAT_ARMOR_PROFICIENCY_LIGHT, 1);
                _nwnxCreature.AddFeatByLevel(player, FEAT_ARMOR_PROFICIENCY_MEDIUM, 1);
                _nwnxCreature.AddFeatByLevel(player, FEAT_ARMOR_PROFICIENCY_HEAVY, 1);
                _nwnxCreature.AddFeatByLevel(player, FEAT_SHIELD_PROFICIENCY, 1);
                _nwnxCreature.AddFeatByLevel(player, FEAT_WEAPON_PROFICIENCY_EXOTIC, 1);
                _nwnxCreature.AddFeatByLevel(player, FEAT_WEAPON_PROFICIENCY_MARTIAL, 1);
                _nwnxCreature.AddFeatByLevel(player, FEAT_WEAPON_PROFICIENCY_SIMPLE, 1);
                _nwnxCreature.AddFeatByLevel(player, (int)CustomFeatType.StructureManagementTool, 1);
                _nwnxCreature.AddFeatByLevel(player, (int)CustomFeatType.OpenRestMenu, 1);
                _nwnxCreature.AddFeatByLevel(player, (int)CustomFeatType.RenameCraftedItem, 1);
                _nwnxCreature.AddFeatByLevel(player, (int)CustomFeatType.ChatCommandTargeter, 1);

                for (int iCurSkill = 1; iCurSkill <= 27; iCurSkill++)
                {
                    _nwnxCreature.SetSkillRank(player, iCurSkill - 1, 0);
                }
                _.SetFortitudeSavingThrow(player, 0);
                _.SetReflexSavingThrow(player, 0);
                _.SetWillSavingThrow(player, 0);

                int classID = _.GetClassByPosition(1, player);

                for (int index = 0; index <= 255; index++)
                {
                    _nwnxCreature.RemoveKnownSpell(player, classID, 0, index);
                }

                Player entity = CreateDBPCEntity(player);
                _data.SubmitDataChange(entity, DatabaseActionType.Insert);

                var skills = _data.GetAll <Skill>();
                foreach (var skill in skills)
                {
                    var pcSkill = new PCSkill
                    {
                        IsLocked = false,
                        SkillID  = skill.ID,
                        PlayerID = entity.ID,
                        Rank     = 0,
                        XP       = 0
                    };

                    _data.SubmitDataChange(pcSkill, DatabaseActionType.Insert);
                }

                _race.ApplyDefaultAppearance(player);
                _nwnxCreature.SetAlignmentLawChaos(player, 50);
                _nwnxCreature.SetAlignmentGoodEvil(player, 50);
                _background.ApplyBackgroundBonuses(player);

                _stat.ApplyStatChanges(player, null, true);
                _language.InitializePlayerLanguages(player);

                _.DelayCommand(1.0f, () => _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(999), player));

                InitializeHotBar(player);
            }
        }
コード例 #21
0
        private static int CalculateBAB(NWPlayer oPC, NWItem ignoreItem, EffectiveItemStats stats)
        {
            NWItem weapon = oPC.RightHand;

            // The unequip event fires before the item is actually unequipped, so we need
            // to have additional checks to make sure we're not getting the weapon that's about to be
            // unequipped.
            if (weapon.Equals(ignoreItem))
            {
                weapon = null;
                NWItem offHand = oPC.LeftHand;

                if (offHand.CustomItemType == CustomItemType.Vibroblade ||
                    offHand.CustomItemType == CustomItemType.FinesseVibroblade ||
                    offHand.CustomItemType == CustomItemType.Baton ||
                    offHand.CustomItemType == CustomItemType.HeavyVibroblade ||
                    offHand.CustomItemType == CustomItemType.Saberstaff ||
                    offHand.CustomItemType == CustomItemType.Polearm ||
                    offHand.CustomItemType == CustomItemType.TwinBlade ||
                    offHand.CustomItemType == CustomItemType.MartialArtWeapon ||
                    offHand.CustomItemType == CustomItemType.BlasterPistol ||
                    offHand.CustomItemType == CustomItemType.BlasterRifle ||
                    offHand.CustomItemType == CustomItemType.Throwing)
                {
                    weapon = offHand;
                }
            }

            if (weapon == null || !weapon.IsValid)
            {
                weapon = oPC.Arms;
            }
            if (!weapon.IsValid)
            {
                return(0);
            }

            SkillType itemSkill = ItemService.GetSkillTypeForItem(weapon);

            if (itemSkill == SkillType.Unknown ||
                itemSkill == SkillType.LightArmor ||
                itemSkill == SkillType.HeavyArmor ||
                itemSkill == SkillType.ForceArmor ||
                itemSkill == SkillType.Shields)
            {
                return(0);
            }

            int     weaponSkillID = (int)itemSkill;
            PCSkill skill         = DataService.PCSkill.GetByPlayerIDAndSkillID(oPC.GlobalID, weaponSkillID);

            if (skill == null)
            {
                return(0);
            }
            int            skillBAB                = skill.Rank / 10;
            int            perkBAB                 = 0;
            int            backgroundBAB           = 0;
            BackgroundType background              = (BackgroundType)oPC.Class1;
            bool           receivesBackgroundBonus = false;

            switch (weapon.CustomItemType)
            {
            case CustomItemType.FinesseVibroblade:
                receivesBackgroundBonus = background == BackgroundType.Duelist;
                break;

            case CustomItemType.Baton:
                receivesBackgroundBonus = background == BackgroundType.SecurityOfficer;
                break;

            case CustomItemType.HeavyVibroblade:
                receivesBackgroundBonus = background == BackgroundType.Soldier;
                break;

            case CustomItemType.TwinBlade:
                receivesBackgroundBonus = background == BackgroundType.Berserker;
                break;

            case CustomItemType.MartialArtWeapon:
                receivesBackgroundBonus = background == BackgroundType.TerasKasi;
                break;

            case CustomItemType.BlasterPistol:
                receivesBackgroundBonus = background == BackgroundType.Smuggler;
                break;

            case CustomItemType.BlasterRifle:
                receivesBackgroundBonus = background == BackgroundType.Sharpshooter || background == BackgroundType.Mandalorian;
                break;
            }

            if (receivesBackgroundBonus)
            {
                backgroundBAB = background == BackgroundType.Mandalorian ? 1 : 2;
            }

            return(1 + skillBAB + perkBAB + stats.BAB + backgroundBAB); // Note: Always add 1 to BAB. 0 will cause a crash in NWNX.
        }
コード例 #22
0
        private void HandleSaveOutfit(int responseID)
        {
            NWPlayer oPC      = GetPC();
            NWItem   oClothes = (_.GetItemInSlot(INVENTORY_SLOT_CHEST, oPC.Object));

            if (!CanModifyClothes())
            {
                oPC.FloatingText("You cannot save your currently equipped clothes.");
                return;
            }

            PCOutfit entity = GetPlayerOutfits(oPC);
            var      action = DatabaseActionType.Update;

            if (entity == null)
            {
                entity = new PCOutfit
                {
                    PlayerID = oPC.GlobalID
                };
                action = DatabaseActionType.Insert;
            }

            if (!oClothes.IsValid)
            {
                oPC.FloatingText(_color.Red("You do not have clothes equipped"));
                return;
            }

            string clothesData = _serialization.Serialize(oClothes);

            if (responseID == 1)
            {
                entity.Outfit1 = clothesData;
            }
            else if (responseID == 2)
            {
                entity.Outfit2 = clothesData;
            }
            else if (responseID == 3)
            {
                entity.Outfit3 = clothesData;
            }
            else if (responseID == 4)
            {
                entity.Outfit4 = clothesData;
            }
            else if (responseID == 5)
            {
                entity.Outfit5 = clothesData;
            }
            else if (responseID == 6)
            {
                entity.Outfit6 = clothesData;
            }
            else if (responseID == 7)
            {
                entity.Outfit7 = clothesData;
            }
            else if (responseID == 8)
            {
                entity.Outfit8 = clothesData;
            }
            else if (responseID == 9)
            {
                entity.Outfit9 = clothesData;
            }
            else if (responseID == 10)
            {
                entity.Outfit10 = clothesData;
            }

            _data.SubmitDataChange(entity, action);
            ShowSaveOutfitOptions();
        }
コード例 #23
0
ファイル: OnDisturbed.cs プロジェクト: Terallis/SWLOR_NWN
        public bool Run(params object[] args)
        {
            NWPlaceable container = Object.OBJECT_SELF;
            NWObject    owner     = container.GetLocalObject("QUEST_OWNER");

            NWPlayer player            = _.GetLastDisturbed();
            NWItem   item              = _.GetInventoryDisturbItem();
            int      disturbType       = _.GetInventoryDisturbType();
            string   crafterPlayerID   = item.GetLocalString("CRAFTER_PLAYER_ID");
            Guid?    crafterPlayerGUID = null;

            if (!string.IsNullOrWhiteSpace(crafterPlayerID))
            {
                crafterPlayerGUID = new Guid(crafterPlayerID);
            }

            if (disturbType == INVENTORY_DISTURB_TYPE_ADDED)
            {
                int                 questID  = container.GetLocalInt("QUEST_ID");
                PCQuestStatus       status   = DataService.Single <PCQuestStatus>(x => x.PlayerID == player.GlobalID && x.QuestID == questID);
                PCQuestItemProgress progress = DataService.SingleOrDefault <PCQuestItemProgress>(x => x.PCQuestStatusID == status.ID && x.Resref == item.Resref);
                DatabaseActionType  action   = DatabaseActionType.Update;

                if (progress == null)
                {
                    _.CopyItem(item, player, TRUE);
                    player.SendMessage(ColorTokenService.Red("That item is not required for this quest."));
                }
                else if (progress.MustBeCraftedByPlayer && crafterPlayerGUID != player.GlobalID)
                {
                    _.CopyItem(item, player, TRUE);
                    player.SendMessage(ColorTokenService.Red("You may only submit items which you have personally created for this quest."));
                }
                else
                {
                    progress.Remaining--;

                    if (progress.Remaining <= 0)
                    {
                        var progressCopy = progress;
                        progress = DataService.Single <PCQuestItemProgress>(x => x.ID == progressCopy.ID);
                        action   = DatabaseActionType.Delete;
                    }
                    DataService.SubmitDataChange(progress, action);

                    // Recalc the remaining items needed.
                    int remainingCount = DataService.GetAll <PCQuestItemProgress>().Count(x => x.PCQuestStatusID == status.ID);
                    if (remainingCount <= 0)
                    {
                        QuestService.AdvanceQuestState(player, owner, questID);
                    }

                    player.SendMessage("You need " + progress.Remaining + " " + item.Name + " for this quest.");
                }
                item.Destroy();

                var questItemProgresses = DataService.Where <PCQuestItemProgress>(x => x.PCQuestStatusID == status.ID);
                if (!questItemProgresses.Any())
                {
                    string conversation = _.GetLocalString(owner, "CONVERSATION");
                    if (!string.IsNullOrWhiteSpace(conversation))
                    {
                        DialogService.StartConversation(player, owner, conversation);
                    }
                    else
                    {
                        player.AssignCommand(() =>
                        {
                            _.ActionStartConversation(owner, "", TRUE, FALSE);
                        });
                    }
                }
            }

            return(true);
        }
コード例 #24
0
        private void HandleLoadOutfit(int responseID)
        {
            DialogResponse response = GetResponseByID("LoadOutfitPage", responseID);
            NWPlayer       oPC      = GetPC();

            if (!CanModifyClothes())
            {
                oPC.FloatingText("You cannot modify your currently equipped clothes.");
                return;
            }

            int      outfitID = (int)response.CustomData;
            PCOutfit entity   = GetPlayerOutfits(GetPC());

            NWPlaceable oTempStorage  = (_.GetObjectByTag("OUTFIT_BARREL"));
            NWItem      oClothes      = oPC.Chest;
            NWItem      storedClothes = null;

            oClothes.SetLocalString("TEMP_OUTFIT_UUID", oPC.GlobalID.ToString());

            if (outfitID == 1)
            {
                storedClothes = _serialization.DeserializeItem(entity.Outfit1, oTempStorage);
            }
            else if (outfitID == 2)
            {
                storedClothes = _serialization.DeserializeItem(entity.Outfit2, oTempStorage);
            }
            else if (outfitID == 3)
            {
                storedClothes = _serialization.DeserializeItem(entity.Outfit3, oTempStorage);
            }
            else if (outfitID == 4)
            {
                storedClothes = _serialization.DeserializeItem(entity.Outfit4, oTempStorage);
            }
            else if (outfitID == 5)
            {
                storedClothes = _serialization.DeserializeItem(entity.Outfit5, oTempStorage);
            }
            else if (outfitID == 6)
            {
                storedClothes = _serialization.DeserializeItem(entity.Outfit6, oTempStorage);
            }
            else if (outfitID == 7)
            {
                storedClothes = _serialization.DeserializeItem(entity.Outfit7, oTempStorage);
            }
            else if (outfitID == 8)
            {
                storedClothes = _serialization.DeserializeItem(entity.Outfit8, oTempStorage);
            }
            else if (outfitID == 9)
            {
                storedClothes = _serialization.DeserializeItem(entity.Outfit9, oTempStorage);
            }
            else if (outfitID == 10)
            {
                storedClothes = _serialization.DeserializeItem(entity.Outfit10, oTempStorage);
            }

            if (storedClothes == null)
            {
                throw new Exception("Unable to locate stored clothes.");
            }

            Object oCopy = _.CopyItem(oClothes.Object, oTempStorage.Object, TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LBICEP, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LBICEP), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LBICEP, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LBICEP), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_BELT, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_BELT), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_BELT, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_BELT), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LFOOT, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LFOOT), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LFOOT, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LFOOT), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LFOREARM, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LFOREARM), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LFOREARM, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LFOREARM), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LHAND, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LHAND), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LHAND, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LHAND), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LSHIN, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LSHIN), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LSHIN, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LSHIN), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LSHOULDER, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LSHOULDER), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LSHOULDER, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LSHOULDER), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LTHIGH, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_LTHIGH), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LTHIGH, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_LTHIGH), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_NECK, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_NECK), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_NECK, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_NECK), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_PELVIS, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_PELVIS), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_PELVIS, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_PELVIS), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RBICEP, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RBICEP), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RBICEP, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RBICEP), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RFOOT, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RFOOT), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RFOOT, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RFOOT), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RFOREARM, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RFOREARM), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RFOREARM, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RFOREARM), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RHAND, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RHAND), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RHAND, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RHAND), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_ROBE, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_ROBE), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_ROBE, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_ROBE), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RSHIN, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RSHIN), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RSHIN, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RSHIN), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RSHOULDER, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RSHOULDER), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RSHOULDER, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RSHOULDER), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RTHIGH, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_RTHIGH), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RTHIGH, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_RTHIGH), TRUE);

            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO), TRUE);
            oCopy = _.CopyItemAndModify(oCopy, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_TORSO, _.GetItemAppearance(storedClothes.Object, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_MODEL_TORSO), TRUE);

            NWItem oFinal = (_.CopyItem(oCopy, oPC.Object, TRUE));

            oFinal.DeleteLocalString("TEMP_OUTFIT_UUID");
            _.DestroyObject(oCopy);
            oClothes.Destroy();
            storedClothes.Destroy();

            oPC.AssignCommand(() => _.ActionEquipItem(oFinal.Object, INVENTORY_SLOT_CHEST));

            foreach (NWItem item in oTempStorage.InventoryItems)
            {
                if (item.GetLocalString("TEMP_OUTFIT_UUID") == oPC.GlobalID.ToString())
                {
                    item.Destroy();
                }
            }

            ShowLoadOutfitOptions();
        }
コード例 #25
0
ファイル: StimPack.cs プロジェクト: xephnin/SWLOR_NWN
 public float Seconds(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
 {
     return(3.0f);
 }
コード例 #26
0
        private void HandleBattlemagePerk()
        {
            DamageData data   = _nwnxDamage.GetDamageEventData();
            NWObject   target = (Object.OBJECT_SELF);

            if (!data.Damager.IsPlayer || !target.IsNPC)
            {
                return;
            }
            if (_.GetHasFeat((int)CustomFeatType.Battlemage, data.Damager.Object) == FALSE)
            {
                return;
            }

            NWPlayer player = (data.Damager.Object);
            NWItem   weapon = (_.GetLastWeaponUsed(player.Object));

            if (weapon.CustomItemType != CustomItemType.Baton)
            {
                return;
            }
            if (player.Chest.CustomItemType != CustomItemType.ForceArmor)
            {
                return;
            }

            int perkRank = _perk.GetPCPerkLevel(player, PerkType.Battlemage);

            int  restoreAmount = 0;
            bool metRoll       = _random.Random(100) + 1 <= 50;

            switch (perkRank)
            {
            case 1 when metRoll:
                restoreAmount = 1;
                break;

            case 2:
                restoreAmount = 1;
                break;

            case 3:
                restoreAmount = 1;
                if (metRoll)
                {
                    restoreAmount++;
                }
                break;

            case 4:
                restoreAmount = 2;
                break;

            case 5:
                restoreAmount = 2;
                if (metRoll)
                {
                    restoreAmount++;
                }
                break;

            case 6:
                restoreAmount = 3;
                break;
            }

            if (restoreAmount > 0)
            {
                RestoreFP(player, restoreAmount);
            }
        }
コード例 #27
0
ファイル: StimPack.cs プロジェクト: xephnin/SWLOR_NWN
 public bool ReducesItemCharge(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
 {
     return(true);
 }
コード例 #28
0
 public void OnItemEquipped(NWPlayer oPC, NWItem oItem)
 {
     ApplyFeatChanges(oPC, null);
 }
コード例 #29
0
ファイル: LegShot.cs プロジェクト: Terallis/SWLOR_NWN
 public void OnItemUnequipped(NWCreature creature, NWItem oItem)
 {
 }
コード例 #30
0
        public static void ApplyComponentBonus(NWItem product, ItemProperty sourceIP)
        {
            ComponentBonusType bonusType = (ComponentBonusType)_.GetItemPropertySubType(sourceIP);
            int          amount          = _.GetItemPropertyCostTableValue(sourceIP);
            ItemProperty prop            = null;
            string       sourceTag       = string.Empty;
            int          attackBonus     = 0;

            // A note about the sourceTags:
            // It's not currently possible to create custom item properties on items. To get around this,
            // we look in an inaccessible container which holds the custom item properties. Then, we get the
            // item that has the item property we want. From there we take that item property and copy it to
            // the crafted item.
            // This is a really roundabout way to do it, but it's the only option for now. Hopefully a feature to
            // directly add the item properties comes in to NWNX in the future.
            // 2019-06-12: Directly modifying item properties is possible now but I'm not going to do a refactor until later.
            //             Anyone interested in working on this let me know and I can point you in the right direction. - Z
            for (int x = 1; x <= amount; x++)
            {
                switch (bonusType)
                {
                case ComponentBonusType.ModSocketRed:
                    sourceTag = "rslot_red";
                    break;

                case ComponentBonusType.ModSocketBlue:
                    sourceTag = "rslot_blue";
                    break;

                case ComponentBonusType.ModSocketGreen:
                    sourceTag = "rslot_green";
                    break;

                case ComponentBonusType.ModSocketYellow:
                    sourceTag = "rslot_yellow";
                    break;

                case ComponentBonusType.ModSocketPrismatic:
                    sourceTag = "rslot_prismatic";
                    break;

                case ComponentBonusType.DurabilityUp:
                    var maxDur = DurabilityService.GetMaxDurability(product) + amount;
                    DurabilityService.SetMaxDurability(product, maxDur);
                    DurabilityService.SetDurability(product, maxDur);
                    break;

                case ComponentBonusType.ChargesUp:
                    product.Charges += amount;
                    break;

                case ComponentBonusType.ACUp:
                    product.CustomAC += amount;
                    break;

                case ComponentBonusType.HarvestingUp:
                    product.HarvestingBonus += amount;
                    break;

                case ComponentBonusType.CooldownRecoveryUp:
                    product.CooldownRecovery += amount;
                    break;

                case ComponentBonusType.ArmorsmithUp:
                    product.CraftBonusArmorsmith += amount;
                    break;

                case ComponentBonusType.WeaponsmithUp:
                    product.CraftBonusWeaponsmith += amount;
                    break;

                case ComponentBonusType.CookingUp:
                    product.CraftBonusCooking += amount;
                    break;

                case ComponentBonusType.EngineeringUp:
                    product.CraftBonusEngineering += amount;
                    break;

                case ComponentBonusType.FabricationUp:
                    product.CraftBonusFabrication += amount;
                    break;

                case ComponentBonusType.HPUp:
                    product.HPBonus += amount;
                    break;

                case ComponentBonusType.FPUp:
                    product.FPBonus += amount;
                    break;

                case ComponentBonusType.EnmityUp:
                    product.EnmityRate += amount;
                    break;

                case ComponentBonusType.EnmityDown:
                    product.EnmityRate -= amount;
                    break;

                case ComponentBonusType.LuckUp:
                    product.LuckBonus += amount;
                    break;

                case ComponentBonusType.MeditateUp:
                    product.MeditateBonus += amount;
                    break;

                case ComponentBonusType.RestUp:
                    product.RestBonus += amount;
                    break;

                case ComponentBonusType.MedicineUp:
                    product.MedicineBonus += amount;
                    break;

                case ComponentBonusType.HPRegenUp:
                    product.HPRegenBonus += amount;
                    break;

                case ComponentBonusType.FPRegenUp:
                    product.FPRegenBonus += amount;
                    break;

                case ComponentBonusType.BaseAttackBonusUp:
                    product.BaseAttackBonus += amount;
                    break;

                case ComponentBonusType.SneakAttackUp:
                    product.SneakAttackBonus += amount;
                    break;

                case ComponentBonusType.DamageUp:
                    product.DamageBonus += amount;
                    break;

                case ComponentBonusType.StructureBonusUp:
                    product.StructureBonus += amount;
                    break;

                case ComponentBonusType.StrengthUp:
                    product.StrengthBonus += amount;
                    break;

                case ComponentBonusType.DexterityUp:
                    product.DexterityBonus += amount;
                    break;

                case ComponentBonusType.ConstitutionUp:
                    product.ConstitutionBonus += amount;
                    break;

                case ComponentBonusType.WisdomUp:
                    product.WisdomBonus += amount;
                    break;

                case ComponentBonusType.IntelligenceUp:
                    product.IntelligenceBonus += amount;
                    break;

                case ComponentBonusType.CharismaUp:
                    product.CharismaBonus += amount;
                    break;

                case ComponentBonusType.AttackBonusUp:
                    attackBonus += amount;
                    break;

                case ComponentBonusType.DurationUp:
                    product.DurationBonus += amount;
                    break;

                case ComponentBonusType.ScanningUp:
                    product.ScanningBonus += amount;
                    break;

                case ComponentBonusType.ScavengingUp:
                    product.ScavengingBonus += amount;
                    break;

                case ComponentBonusType.PilotingUp:
                    product.PilotingBonus += amount;
                    break;

                // Legacy and other component bonus types won't do anything.
                default:
                    return;
                }

                if (!string.IsNullOrWhiteSpace(sourceTag))
                {
                    prop = ItemService.GetCustomItemPropertyByItemTag(sourceTag);
                }

                if (prop == null)
                {
                    return;
                }

                BiowareXP2.IPSafeAddItemProperty(product, prop, 0.0f, AddItemPropertyPolicy.IgnoreExisting, true, true);
            }

            // Attack bonus is aggregated into one item property, ensuring that the amount doesn't go over 20.
            if (attackBonus > 0)
            {
                // Look for existing properties, get the value and add it. Then remove that item property.
                foreach (var ip in product.ItemProperties)
                {
                    if (_.GetItemPropertyType(ip) == _.ITEM_PROPERTY_ATTACK_BONUS)
                    {
                        amount       = _.GetItemPropertyCostTableValue(ip);
                        attackBonus += amount;

                        _.RemoveItemProperty(product, ip);
                    }
                }

                // Clamp bonus to 20.
                if (attackBonus > 20)
                {
                    attackBonus = 20;
                }

                // Time to add the new item property.
                prop = _.ItemPropertyAttackBonus(attackBonus);
                BiowareXP2.IPSafeAddItemProperty(product, prop, 0.0f, AddItemPropertyPolicy.ReplaceExisting, false, false);
            }
        }