Пример #1
0
 public bool ReducesItemCharge(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
 {
     return(false);
 }
Пример #2
0
 public void OnCustomEnmityRule(NWCreature creature, int amount)
 {
 }
Пример #3
0
 public string CanCastSpell(NWCreature oPC, NWObject oTarget, int spellTier)
 {
     return(string.Empty);
 }
Пример #4
0
 public void OnImpact(NWCreature creature, NWObject target, int perkLevel, int spellTier)
 {
 }
Пример #5
0
 public void OnRemoved(NWCreature creature)
 {
 }
Пример #6
0
 public int FPCost(NWCreature oPC, int baseFPCost, int spellTier)
 {
     return(baseFPCost);
 }
Пример #7
0
 public float CooldownTime(NWCreature oPC, float baseCooldownTime, int spellTier)
 {
     return(baseCooldownTime);
 }
        private void ApplyPCEffect(NWCreature caster, NWCreature target, int customEffectID, int ticks, int effectiveLevel, string data)
        {
            Data.Entity.CustomEffect customEffect = _data.Single <Data.Entity.CustomEffect>(x => x.ID == customEffectID);
            PCCustomEffect           pcEffect     = _data.SingleOrDefault <PCCustomEffect>(x => x.PlayerID == target.GlobalID && x.CustomEffectID == customEffectID);
            CustomEffectCategoryType category     = (CustomEffectCategoryType)customEffect.CustomEffectCategoryID;

            if (category == CustomEffectCategoryType.FoodEffect)
            {
                var customEffectPC = _data.Get <Data.Entity.CustomEffect>(pcEffect.CustomEffectID);
                if (pcEffect != null && customEffectPC.CustomEffectCategoryID == (int)category)
                {
                    caster.SendMessage("You are not hungry.");
                    return;
                }
            }

            DatabaseActionType action = DatabaseActionType.Update;

            if (pcEffect == null)
            {
                pcEffect = new PCCustomEffect {
                    PlayerID = target.GlobalID
                };
                action = DatabaseActionType.Insert;
            }

            if (pcEffect.EffectiveLevel > effectiveLevel)
            {
                caster.SendMessage("A more powerful effect already exists on your target.");
                return;
            }

            pcEffect.CustomEffectID    = customEffectID;
            pcEffect.EffectiveLevel    = effectiveLevel;
            pcEffect.Ticks             = ticks;
            pcEffect.CasterNWNObjectID = _.ObjectToString(caster);
            _data.SubmitDataChange(pcEffect, action);

            target.SendMessage(customEffect.StartMessage);

            App.ResolveByInterface <ICustomEffect>("CustomEffect." + customEffect.ScriptHandler, handler =>
            {
                if (string.IsNullOrWhiteSpace(data))
                {
                    data = handler?.Apply(caster, target, effectiveLevel);
                }

                if (string.IsNullOrWhiteSpace(data))
                {
                    data = string.Empty;
                }
                pcEffect.Data = data;
                _data.SubmitDataChange(pcEffect, DatabaseActionType.Update);

                // Was already queued for removal, but got cast again. Take it out of the list to be removed.
                if (_cache.PCEffectsForRemoval.Contains(pcEffect.ID))
                {
                    _cache.PCEffectsForRemoval.Remove(pcEffect.ID);
                }
            });
        }
 public void ApplyCustomEffect(NWCreature caster, NWCreature target, CustomEffectType effectType, int ticks, int level, string data)
 {
     ApplyCustomEffect(caster, target, (int)effectType, ticks, level, data);
 }
Пример #10
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 = (new NWGameObject());
            }
            else if (oItem != null && Equals(oItem, offHand))
            {
                offHand = (new NWGameObject());
            }

            if (!mainHand.IsValid && !offHand.IsValid)
            {
                if (PerkService.GetCreaturePerkLevel(creature, PerkType.ImprovedCriticalMartialArts) > 0)
                {
                    NWNXCreature.AddFeat(creature, 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.GetCreaturePerkLevel(creature, perkType);
            int type      = equipped.BaseItemType;

            if (perkLevel > 0)
            {
                AddCriticalFeat(creature, type);
            }
        }
Пример #11
0
 public void OnRemoved(NWCreature creature)
 {
     NWNXCreature.RemoveFeat(creature, Feat.WeaponFinesse);
 }
Пример #12
0
 public void OnRemoved(NWCreature creature)
 {
     ApplyFeatChanges(creature, null);
 }
Пример #13
0
        private void AddCriticalFeat(NWCreature creature, int type)
        {
            int feat;

            switch (type)
            {
            case (BASE_ITEM_BASTARDSWORD): feat = FEAT_IMPROVED_CRITICAL_BASTARD_SWORD; break;

            case (BASE_ITEM_BATTLEAXE): feat = FEAT_IMPROVED_CRITICAL_BATTLE_AXE; break;

            case (BASE_ITEM_CLUB): feat = FEAT_IMPROVED_CRITICAL_CLUB; break;

            case (BASE_ITEM_DAGGER): feat = FEAT_IMPROVED_CRITICAL_DAGGER; break;

            case (BASE_ITEM_DART): feat = FEAT_IMPROVED_CRITICAL_DART; break;

            case (BASE_ITEM_DIREMACE): feat = FEAT_IMPROVED_CRITICAL_DIRE_MACE; break;

            case (BASE_ITEM_DOUBLEAXE): feat = FEAT_IMPROVED_CRITICAL_DOUBLE_AXE; break;

            case (BASE_ITEM_DWARVENWARAXE): feat = FEAT_IMPROVED_CRITICAL_DWAXE; break;

            case (BASE_ITEM_GREATAXE): feat = FEAT_IMPROVED_CRITICAL_GREAT_AXE; break;

            case (BASE_ITEM_GREATSWORD): feat = FEAT_IMPROVED_CRITICAL_GREAT_SWORD; break;

            case (BASE_ITEM_HALBERD): feat = FEAT_IMPROVED_CRITICAL_HALBERD; break;

            case (BASE_ITEM_HANDAXE): feat = FEAT_IMPROVED_CRITICAL_HAND_AXE; break;

            case (BASE_ITEM_HEAVYCROSSBOW): feat = FEAT_IMPROVED_CRITICAL_HEAVY_CROSSBOW; break;

            case (BASE_ITEM_HEAVYFLAIL): feat = FEAT_IMPROVED_CRITICAL_HEAVY_FLAIL; break;

            case (BASE_ITEM_KAMA): feat = FEAT_IMPROVED_CRITICAL_KAMA; break;

            case (BASE_ITEM_KATANA): feat = FEAT_IMPROVED_CRITICAL_KATANA; break;

            case (BASE_ITEM_KUKRI): feat = FEAT_IMPROVED_CRITICAL_KUKRI; break;

            case (BASE_ITEM_LIGHTCROSSBOW): feat = FEAT_IMPROVED_CRITICAL_LIGHT_CROSSBOW; break;

            case (BASE_ITEM_LIGHTFLAIL): feat = FEAT_IMPROVED_CRITICAL_LIGHT_FLAIL; break;

            case (BASE_ITEM_LIGHTHAMMER): feat = FEAT_IMPROVED_CRITICAL_LIGHT_HAMMER; break;

            case (BASE_ITEM_LIGHTMACE): feat = FEAT_IMPROVED_CRITICAL_LIGHT_MACE; break;

            case (BASE_ITEM_LONGBOW): feat = FEAT_IMPROVED_CRITICAL_LONGBOW; break;

            case (BASE_ITEM_LONGSWORD): feat = FEAT_IMPROVED_CRITICAL_LONG_SWORD; break;

            case (BASE_ITEM_MORNINGSTAR): feat = FEAT_IMPROVED_CRITICAL_MORNING_STAR; break;

            case (BASE_ITEM_RAPIER): feat = FEAT_IMPROVED_CRITICAL_RAPIER; break;

            case (BASE_ITEM_SCIMITAR): feat = FEAT_IMPROVED_CRITICAL_SCIMITAR; break;

            case (BASE_ITEM_SCYTHE): feat = FEAT_IMPROVED_CRITICAL_SCYTHE; break;

            case (BASE_ITEM_SHORTBOW): feat = FEAT_IMPROVED_CRITICAL_SHORTBOW; break;

            case (BASE_ITEM_SHORTSWORD): feat = FEAT_IMPROVED_CRITICAL_SHORT_SWORD; break;

            case (BASE_ITEM_SHURIKEN): feat = FEAT_IMPROVED_CRITICAL_SHURIKEN; break;

            case (BASE_ITEM_SICKLE): feat = FEAT_IMPROVED_CRITICAL_SICKLE; break;

            case (BASE_ITEM_SLING): feat = FEAT_IMPROVED_CRITICAL_SLING; break;

            case (BASE_ITEM_SHORTSPEAR): feat = FEAT_IMPROVED_CRITICAL_SPEAR; break;

            case (BASE_ITEM_QUARTERSTAFF): feat = FEAT_IMPROVED_CRITICAL_STAFF; break;

            case (BASE_ITEM_THROWINGAXE): feat = FEAT_IMPROVED_CRITICAL_THROWING_AXE; break;

            case (BASE_ITEM_TRIDENT): feat = FEAT_IMPROVED_CRITICAL_TRIDENT; break;

            case (BASE_ITEM_TWOBLADEDSWORD): feat = FEAT_IMPROVED_CRITICAL_TWO_BLADED_SWORD; break;

            case (BASE_ITEM_INVALID): feat = FEAT_IMPROVED_CRITICAL_UNARMED_STRIKE; break;

            case (BASE_ITEM_WARHAMMER): feat = FEAT_IMPROVED_CRITICAL_WAR_HAMMER; break;

            case (BASE_ITEM_WHIP): feat = FEAT_IMPROVED_CRITICAL_WHIP; break;

            case (CustomBaseItemType.Lightsaber): feat = FEAT_IMPROVED_CRITICAL_LONG_SWORD; break;

            case (CustomBaseItemType.Saberstaff): feat = FEAT_IMPROVED_CRITICAL_TWO_BLADED_SWORD; break;

            default: return;
            }

            NWNXCreature.AddFeat(creature, feat);
        }
Пример #14
0
 public string IsValidTarget(NWCreature user, NWItem item, NWObject target, Location targetLocation)
 {
     return(null);
 }
Пример #15
0
 public void OnItemEquipped(NWCreature creature, NWItem oItem)
 {
     ApplyFeatChanges(creature, null);
 }
Пример #16
0
        public float CalculateEffectHPBonusPercent(NWCreature creature)
        {
            int effectLevel = GetCustomEffectLevel(creature, CustomEffectType.ShieldBoost);

            return(effectLevel * 0.05f);
        }
Пример #17
0
 public void OnItemUnequipped(NWCreature creature, NWItem oItem)
 {
     ApplyFeatChanges(creature, oItem);
 }
Пример #18
0
 public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
 {
 }
Пример #19
0
 public float CastingTime(NWCreature oPC, float baseCastingTime, int spellTier)
 {
     return(baseCastingTime);
 }
Пример #20
0
 public void WearOff(NWCreature oCaster, NWObject oTarget, int effectiveLevel, string data)
 {
 }
Пример #21
0
 public int?CooldownCategoryID(NWCreature creature, int?baseCooldownCategoryID, int spellTier)
 {
     return(baseCooldownCategoryID);
 }
Пример #22
0
 public string Apply(NWCreature oCaster, NWObject oTarget, int effectiveLevel)
 {
     return(null);
 }
Пример #23
0
 public void OnPurchased(NWCreature creature, int newLevel)
 {
 }
Пример #24
0
        private void OnFinishAbilityUse(OnFinishAbilityUse data)
        {
            using (new Profiler(nameof(FinishAbilityUse)))
            {
                // These arguments are sent from the AbilityService's ActivateAbility method.
                NWCreature activator    = data.Activator;
                string     spellUUID    = data.SpellUUID;
                int        perkID       = data.PerkID;
                NWObject   target       = data.Target;
                int        pcPerkLevel  = data.PCPerkLevel;
                int        spellTier    = data.SpellTier;
                float      armorPenalty = data.ArmorPenalty;

                // Get the relevant perk information from the database.
                Data.Entity.Perk dbPerk = DataService.Perk.GetByID(perkID);

                // The execution type determines how the perk behaves and the rules surrounding it.
                PerkExecutionType executionType = dbPerk.ExecutionTypeID;

                // Get the class which handles this perk's behaviour.
                IPerkHandler perk = PerkService.GetPerkHandler(perkID);

                // Pull back cooldown information.
                int?cooldownID            = perk.CooldownCategoryID(activator, dbPerk.CooldownCategoryID, spellTier);
                CooldownCategory cooldown = cooldownID == null ? null : DataService.CooldownCategory.GetByIDOrDefault((int)cooldownID);

                // If the activator interrupted the spell or died, we can bail out early.
                if (activator.GetLocalInt(spellUUID) == (int)SpellStatusType.Interrupted || // Moved during casting
                    activator.CurrentHP < 0 || activator.IsDead)                            // Or is dead/dying
                {
                    activator.DeleteLocalInt(spellUUID);
                    return;
                }

                // Remove the temporary UUID which is tracking this spell cast.
                activator.DeleteLocalInt(spellUUID);

                // Force Abilities, Combat Abilities, Stances, and Concentration Abilities
                if (executionType == PerkExecutionType.ForceAbility ||
                    executionType == PerkExecutionType.CombatAbility ||
                    executionType == PerkExecutionType.Stance ||
                    executionType == PerkExecutionType.ConcentrationAbility)
                {
                    // Run the impact script.
                    perk.OnImpact(activator, target, pcPerkLevel, spellTier);

                    // If an animation is specified for this perk, play it now.
                    if (dbPerk.CastAnimationID != null && dbPerk.CastAnimationID > 0)
                    {
                        activator.AssignCommand(() => { _.ActionPlayAnimation((int)dbPerk.CastAnimationID, 1f, 1f); });
                    }

                    // If the target is an NPC, assign enmity towards this creature for that NPC.
                    if (target.IsNPC)
                    {
                        AbilityService.ApplyEnmity(activator, target.Object, dbPerk);
                    }
                }

                // Adjust creature's current FP, if necessary.
                // Adjust FP only if spell cost > 0
                PerkFeat perkFeat = DataService.PerkFeat.GetByPerkIDAndLevelUnlocked(perkID, spellTier);
                int      fpCost   = perk.FPCost(activator, perkFeat.BaseFPCost, spellTier);

                if (fpCost > 0)
                {
                    int currentFP = AbilityService.GetCurrentFP(activator);
                    int maxFP     = AbilityService.GetMaxFP(activator);
                    currentFP -= fpCost;
                    AbilityService.SetCurrentFP(activator, currentFP);
                    activator.SendMessage(ColorTokenService.Custom("FP: " + currentFP + " / " + maxFP, 32, 223, 219));
                }

                // Notify activator of concentration ability change and also update it in the DB.
                if (executionType == PerkExecutionType.ConcentrationAbility)
                {
                    AbilityService.StartConcentrationEffect(activator, perkID, spellTier);
                    activator.SendMessage("Concentration ability activated: " + dbPerk.Name);

                    // The Skill Increase effect icon and name has been overwritten. Apply the effect to the player now.
                    // This doesn't do anything - it simply gives a visual cue that the player has an active concentration effect.
                    _.ApplyEffectToObject(_.DURATION_TYPE_PERMANENT, _.EffectSkillIncrease(_.SKILL_USE_MAGIC_DEVICE, 1), activator);
                }

                // Handle applying cooldowns, if necessary.
                if (cooldown != null)
                {
                    AbilityService.ApplyCooldown(activator, cooldown, perk, spellTier, armorPenalty);
                }

                // Mark the creature as no longer busy.
                activator.IsBusy = false;

                // Mark the spell cast as complete.
                activator.SetLocalInt(spellUUID, (int)SpellStatusType.Completed);
            }
        }
Пример #25
0
 public void OnItemUnequipped(NWCreature creature, NWItem oItem)
 {
 }
Пример #26
0
 public void OnPurchased(NWCreature creature, int newLevel)
 {
     ApplyFeatChanges(creature, null);
 }
Пример #27
0
 public void OnConcentrationTick(NWCreature creature, NWObject target, int perkLevel, int tick)
 {
 }
Пример #28
0
 public void OnRemoved(NWCreature creature)
 {
     NWNXCreature.RemoveFeat(creature, _.FEAT_CIRCLE_KICK);
 }
Пример #29
0
 public CustomData StartUseItem(NWCreature user, NWItem item, NWObject target, Location targetLocation)
 {
     return(null);
 }
Пример #30
0
 public float MaxDistance(NWCreature user, NWItem item, NWObject target, Location targetLocation)
 {
     return(0);
 }