예제 #1
0
        private bool IsMainValid()
        {
            NWPlayer player = GetPC();
            NWItem   main   = player.RightHand;

            bool canModifyMain = main.IsValid &&
                                 !main.IsPlot &&
                                 !main.IsCursed &&
                                 // https://github.com/zunath/SWLOR_NWN/issues/942#issue-467176236
                                 main.CustomItemType != CustomItemType.Lightsaber &&
                                 main.CustomItemType != CustomItemType.Saberstaff &&
                                 main.GetLocalBool("LIGHTSABER") == false;

            if (canModifyMain)
            {
                var mainModelTypeID = (ItemAppearanceType)Convert.ToInt32(Get2DAString("baseitems", "ModelType", (int)main.BaseItemType));
                canModifyMain = mainModelTypeID == ItemAppearanceType.WeaponModel;
            }

            return(canModifyMain);
        }
예제 #2
0
        private void ApplyFeatChanges(NWCreature creature, NWItem oItem)
        {
            NWItem equipped = oItem ?? creature.RightHand;

            RemoveAllFeats(creature);

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

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

            if (!mainHand.IsValid && !offHand.IsValid)
            {
                int martialArtsLevel = PerkService.GetCreaturePerkLevel(creature, PerkType.WeaponFocusMartialArts);
                if (martialArtsLevel >= 1)
                {
                    NWNXCreature.AddFeat(creature, Feat.WeaponFocus_UnarmedStrike);
                }
                if (martialArtsLevel >= 2)
                {
                    NWNXCreature.AddFeat(creature, Feat.WeaponSpecialization_UnarmedStrike);
                }

                return;
            }

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

            // All other weapon types
            PerkType perkType;

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

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

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

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

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

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

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

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

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

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

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

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

            default: return;
            }

            if (equipped.GetLocalBool("LIGHTSABER") == true)
            {
                perkType = PerkType.WeaponFocusLightsaber;
            }

            var perkLevel = PerkService.GetCreaturePerkLevel(creature, perkType);
            var type      = equipped.BaseItemType;

            if (perkLevel >= 1)
            {
                AddFocusFeat(creature, type);
            }
            if (perkLevel >= 2)
            {
                AddSpecializationFeat(creature, type);
            }
        }
예제 #3
0
        private bool IsOffHandValid()
        {
            NWPlayer player  = GetPC();
            NWItem   offHand = player.LeftHand;
            Player   pc      = DataService.Player.GetByID(player.GlobalID);

            bool canModifyOffHand = offHand.IsValid && !offHand.IsPlot && !offHand.IsCursed &&
                                    // https://github.com/zunath/SWLOR_NWN/issues/942#issue-467176236
                                    offHand.CustomItemType != CustomItemType.Lightsaber && offHand.GetLocalBool("LIGHTSABER") == false &&
                                    !(pc.ModeDualPistol && offHand.CustomItemType == CustomItemType.BlasterPistol);

            if (canModifyOffHand)
            {
                var offHandModelTypeID = (ItemAppearanceType)Convert.ToInt32(Get2DAString("baseitems", "ModelType", (int)offHand.BaseItemType));
                canModifyOffHand = offHandModelTypeID == ItemAppearanceType.WeaponModel;
            }

            return(canModifyOffHand);
        }
예제 #4
0
        private void ApplyFeatChanges(NWCreature creature, NWItem oItem)
        {
            NWItem equipped = oItem ?? creature.RightHand;

            if (Equals(equipped, oItem) || (equipped.CustomItemType != CustomItemType.Lightsaber && equipped.CustomItemType != CustomItemType.Saberstaff && equipped.GetLocalBool("LIGHTSABER") == false))
            {
                NWNXCreature.RemoveFeat(creature, Feat.WeaponFinesse);
                return;
            }
            NWNXCreature.AddFeat(creature, Feat.WeaponFinesse);
        }
예제 #5
0
 public void OnItemUnequipped(NWCreature creature, NWItem oItem)
 {
     if (oItem.CustomItemType != CustomItemType.Lightsaber && oItem.CustomItemType != CustomItemType.Saberstaff && oItem.GetLocalBool("LIGHTSABER") == false)
     {
         return;
     }
     if (oItem == creature.LeftHand)
     {
         return;
     }
     ApplyFeatChanges(creature, oItem);
 }