Example #1
0
        private void ApplyFeatChanges(NWPlayer oPC, NWItem unequippingItem)
        {
            NWItem         mainHand     = oPC.RightHand;
            NWItem         offHand      = oPC.LeftHand;
            CustomItemType mainType     = mainHand.CustomItemType;
            CustomItemType offType      = offHand.CustomItemType;
            bool           receivesFeat = true;

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

            if ((!mainHand.IsValid && !offHand.IsValid) ||
                (mainType != CustomItemType.MartialArtWeapon || offType != CustomItemType.MartialArtWeapon))
            {
                receivesFeat = false;
            }

            if (receivesFeat)
            {
                NWNXCreature.AddFeat(oPC, _.FEAT_CIRCLE_KICK);
            }
            else
            {
                NWNXCreature.RemoveFeat(oPC, _.FEAT_CIRCLE_KICK);
            }
        }
Example #2
0
        private SkillType GetSkillType(NWItem item)
        {
            CustomItemType repairItemType = (CustomItemType)item.GetLocalInt("REPAIR_CUSTOM_ITEM_TYPE_ID");

            switch (repairItemType)
            {
            case CustomItemType.LightArmor:
            case CustomItemType.HeavyArmor:
            case CustomItemType.ForceArmor:
            case CustomItemType.Shield:
                return(SkillType.Armorsmith);

            case CustomItemType.Vibroblade:
            case CustomItemType.FinesseVibroblade:
            case CustomItemType.Baton:
            case CustomItemType.HeavyVibroblade:
            case CustomItemType.Polearm:
            case CustomItemType.TwinBlade:
            case CustomItemType.MartialArtWeapon:
                return(SkillType.Weaponsmith);

            case CustomItemType.Lightsaber:
            case CustomItemType.BlasterPistol:
            case CustomItemType.BlasterRifle:
            case CustomItemType.Saberstaff:
                return(SkillType.Engineering);
            }

            if (item.GetLocalInt("LIGHTSABER") == TRUE)
            {
                return(SkillType.Engineering);
            }

            return(SkillType.Unknown);
        }
Example #3
0
        private static int EffectiveArmorClass(NWPlayer player, NWItem ignoreItem, EffectiveItemStats stats)
        {
            int baseAC = stats.AC + CustomEffectService.CalculateEffectAC(player);

            // Calculate AC bonus granted by skill ranks.
            // Only chest armor is checked for this bonus.

            if (ignoreItem != player.Chest)
            {
                CustomItemType armorType = player.Chest.CustomItemType;
                int            skillRank = 0;
                switch (armorType)
                {
                case CustomItemType.LightArmor:
                    skillRank = SkillService.GetPCSkillRank(player, SkillType.LightArmor);
                    break;

                case CustomItemType.HeavyArmor:
                    skillRank = SkillService.GetPCSkillRank(player, SkillType.HeavyArmor);
                    break;

                case CustomItemType.ForceArmor:
                    skillRank = SkillService.GetPCSkillRank(player, SkillType.ForceArmor);
                    break;
                }

                // +1 AC per 10 skill ranks, while wearing the appropriate armor.
                int skillACBonus = skillRank / 10;
                baseAC += skillACBonus;
            }

            int totalAC = _.GetAC(player) - baseAC;

            // Shield Oath and Precision Targeting affect a percentage of the TOTAL armor class on a creature.
            var stance = CustomEffectService.GetCurrentStanceType(player);

            if (stance == CustomEffectType.ShieldOath)
            {
                int bonus = (int)(totalAC * 0.2f);
                baseAC += bonus;
            }
            else if (stance == CustomEffectType.PrecisionTargeting)
            {
                int penalty = (int)(totalAC * 0.3f);
                baseAC -= penalty;
            }

            if (baseAC < 0)
            {
                baseAC = 0;
            }

            return(baseAC);
        }
Example #4
0
        private void ApplyFeatChanges(NWCreature creature, NWItem unequippingItem)
        {
            NWItem         mainHand     = creature.RightHand;
            NWItem         offHand      = creature.LeftHand;
            CustomItemType mainType     = mainHand.CustomItemType;
            CustomItemType offType      = offHand.CustomItemType;
            bool           receivesFeat = false;

            if (unequippingItem != null && Equals(unequippingItem, mainHand))
            {
                mainHand = _.OBJECT_INVALID;
            }
            else if (unequippingItem != null && Equals(unequippingItem, offHand))
            {
                offHand = _.OBJECT_INVALID;
            }

            // Main is Martial and off is invalid
            // OR
            // Main is invalid and off is martial
            if ((mainType == CustomItemType.MartialArtWeapon && !offHand.IsValid) ||
                (offType == CustomItemType.MartialArtWeapon && !mainHand.IsValid))
            {
                receivesFeat = true;
            }
            // Both main and off are invalid
            else if (!mainHand.IsValid && !offHand.IsValid)
            {
                receivesFeat = true;
            }

            if (receivesFeat)
            {
                NWNXCreature.AddFeat(creature, Feat.CircleKick);
            }
            else
            {
                NWNXCreature.RemoveFeat(creature, Feat.CircleKick);
            }
        }
Example #5
0
 public CustomItemType(Guid ID, CustomItemType parent)
 {
     this.ID     = ID;
     this.parent = parent;
 }
Example #6
0
        private void HandleAddItem()
        {
            NWPlayer oPC   = (_.GetLastDisturbed());
            NWItem   oItem = (_.GetInventoryDisturbItem());

            if (oItem.Resref == "cft_confirm")
            {
                return;
            }
            if (oPC.IsBusy)
            {
                ItemService.ReturnItem(oPC, oItem);
                oPC.SendMessage("You are too busy right now.");
                return;
            }

            var model              = CraftService.GetPlayerCraftingData(oPC);
            var mainComponent      = DataService.Get <Data.Entity.ComponentType>(model.Blueprint.MainComponentTypeID);
            var secondaryComponent = DataService.Get <Data.Entity.ComponentType>(model.Blueprint.SecondaryComponentTypeID);
            var tertiaryComponent  = DataService.Get <Data.Entity.ComponentType>(model.Blueprint.TertiaryComponentTypeID);

            NWPlaceable storage = _.GetObjectByTag("craft_temp_store");

            List <NWItem> list                    = null;
            ComponentType allowedType             = ComponentType.None;
            bool          reachedCap              = false;
            bool          reachedEnhancementLimit = false;

            string componentName = string.Empty;

            switch (model.Access)
            {
            case CraftingAccessType.MainComponent:
                allowedType   = (ComponentType)model.Blueprint.MainComponentTypeID;
                reachedCap    = model.MainMaximum < model.MainComponents.Count + 1;
                list          = model.MainComponents;
                componentName = mainComponent.Name;
                break;

            case CraftingAccessType.SecondaryComponent:
                allowedType   = (ComponentType)model.Blueprint.SecondaryComponentTypeID;
                reachedCap    = model.SecondaryMaximum < model.SecondaryComponents.Count + 1;
                list          = model.SecondaryComponents;
                componentName = secondaryComponent.Name;
                break;

            case CraftingAccessType.TertiaryComponent:
                allowedType   = (ComponentType)model.Blueprint.TertiaryComponentTypeID;
                reachedCap    = model.TertiaryMaximum < model.TertiaryComponents.Count + 1;
                list          = model.TertiaryComponents;
                componentName = tertiaryComponent.Name;
                break;

            case CraftingAccessType.Enhancement:
                allowedType             = ComponentType.Enhancement;
                reachedCap              = model.Blueprint.EnhancementSlots < model.EnhancementComponents.Count + 1;
                reachedEnhancementLimit = model.PlayerPerkLevel / 2 < model.EnhancementComponents.Count + 1;
                list          = model.EnhancementComponents;
                componentName = "Enhancement";
                break;
            }

            if (list == null)
            {
                ItemService.ReturnItem(oPC, oItem);
                oPC.FloatingText("There was an issue getting the item data. Notify an admin.");
                return;
            }

            if (reachedCap)
            {
                ItemService.ReturnItem(oPC, oItem);
                oPC.FloatingText("You cannot add any more components of that type.");
                return;
            }

            if (reachedEnhancementLimit)
            {
                ItemService.ReturnItem(oPC, oItem);
                oPC.FloatingText("Your perk level does not allow you to attach any more enhancements to this item.");
                return;
            }

            var            props            = oItem.ItemProperties.ToList();
            var            allowedItemTypes = new List <CustomItemType>();
            CustomItemType finishedItemType = ItemService.GetCustomItemTypeByResref(model.Blueprint.ItemResref);

            foreach (var ip in props)
            {
                if (_.GetItemPropertyType(ip) == (int)CustomItemPropertyType.ComponentItemTypeRestriction)
                {
                    int restrictionType = _.GetItemPropertyCostTableValue(ip);
                    allowedItemTypes.Add((CustomItemType)restrictionType);
                }
            }

            if (allowedItemTypes.Count > 0)
            {
                if (!allowedItemTypes.Contains(finishedItemType))
                {
                    oPC.FloatingText("This component cannot be used with this type of blueprint.");
                    ItemService.ReturnItem(oPC, oItem);
                    return;
                }
            }

            foreach (var ip in props)
            {
                if (_.GetItemPropertyType(ip) == (int)CustomItemPropertyType.ComponentType)
                {
                    int compType = _.GetItemPropertyCostTableValue(ip);
                    if (compType == (int)allowedType)
                    {
                        oItem.GetOrAssignGlobalID();
                        NWItem copy = (_.CopyItem(oItem.Object, storage.Object, TRUE));
                        list.Add(copy);
                        return;
                    }
                }
            }

            oPC.FloatingText("Only " + componentName + " components may be used with this component type.");
            ItemService.ReturnItem(oPC, oItem);
        }