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);
            }
        }
Exemple #2
0
        public void OnModuleActivatedItem()
        {
            NWPlayer oPC            = NWPlayer.Wrap(_.GetItemActivator());
            NWItem   oItem          = NWItem.Wrap(_.GetItemActivated());
            NWObject oTarget        = NWObject.Wrap(_.GetItemActivatedTarget());
            Location targetLocation = _.GetItemActivatedTargetLocation();

            string className = oItem.GetLocalString("JAVA_SCRIPT");

            if (string.IsNullOrWhiteSpace(className))
            {
                className = oItem.GetLocalString("ACTIVATE_JAVA_SCRIPT");
            }
            if (string.IsNullOrWhiteSpace(className))
            {
                className = oItem.GetLocalString("JAVA_ACTION_SCRIPT");
            }
            if (string.IsNullOrWhiteSpace(className))
            {
                className = oItem.GetLocalString("SCRIPT");
            }
            if (string.IsNullOrWhiteSpace(className))
            {
                return;
            }

            oPC.ClearAllActions();

            // Remove "Item." prefix if it exists.
            if (className.StartsWith("Item."))
            {
                className = className.Substring(5);
            }

            IActionItem item = App.ResolveByInterface <IActionItem>("Item." + className);

            if (oPC.IsBusy)
            {
                oPC.SendMessage("You are busy.");
                return;
            }

            string invalidTargetMessage = item.IsValidTarget(oPC, oItem, oTarget, targetLocation);

            if (!string.IsNullOrWhiteSpace(invalidTargetMessage))
            {
                oPC.SendMessage(invalidTargetMessage);
                return;
            }

            if (item.MaxDistance() > 0.0f)
            {
                if (_.GetDistanceBetween(oPC.Object, oTarget.Object) > item.MaxDistance() ||
                    oPC.Area.Resref != oTarget.Area.Resref)
                {
                    oPC.SendMessage("Your target is too far away.");
                    return;
                }
            }

            CustomData customData   = item.StartUseItem(oPC, oItem, oTarget, targetLocation);
            float      delay        = item.Seconds(oPC, oItem, oTarget, targetLocation, customData);
            int        animationID  = item.AnimationID();
            bool       faceTarget   = item.FaceTarget();
            Vector     userPosition = oPC.Position;

            oPC.AssignCommand(() =>
            {
                oPC.IsBusy = true;
                if (faceTarget)
                {
                    _.SetFacingPoint(oTarget.Position);
                }
                if (animationID > 0)
                {
                    _.ActionPlayAnimation(animationID, 1.0f, delay);
                }
            });

            _nwnxPlayer.StartGuiTimingBar(oPC, delay, string.Empty);
            oPC.DelayCommand(() =>
            {
                FinishActionItem(item, oPC, oItem, oTarget, targetLocation, userPosition, customData);
            }, delay);
        }
Exemple #3
0
 public string CannotCastSpellMessage(NWPlayer oPC, NWObject oTarget)
 {
     return("You cannot meditate while you or a party member are in combat.");
 }
 public bool CanCastSpell(NWPlayer oPC, NWObject oTarget)
 {
     return(false);
 }
Exemple #5
0
 public void ReturnItem(NWObject target, NWItem item)
 {
     _.CopyItem(item.Object, target.Object, TRUE);
     item.Destroy();
 }
Exemple #6
0
 public float MaxDistance(NWCreature user, NWItem item, NWObject target, Location targetLocation)
 {
     return(3.5f + _perk.GetPCPerkLevel(user.Object, PerkType.RangedHealing));
 }
 public string CannotCastSpellMessage(NWPlayer oPC, NWObject oTarget)
 {
     return(null);
 }
Exemple #8
0
 public void OnImpact(NWPlayer player, NWObject target, int perkLevel)
 {
 }
Exemple #9
0
 public string CannotCastSpellMessage(NWPlayer oPC, NWObject oTarget)
 {
     return("Target out of range.");
 }
Exemple #10
0
 public string CanCastSpell(NWCreature oPC, NWObject oTarget, int spellTier)
 {
     return(string.Empty);
 }
Exemple #11
0
 public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args)
 {
     _dialog.StartConversation(user, user, "KeyItems");
 }
Exemple #12
0
 public void OnConcentrationTick(NWCreature creature, NWObject target, int perkLevel, int tick)
 {
 }
Exemple #13
0
 public void OnImpact(NWCreature creature, NWObject target, int perkLevel, int spellTier)
 {
 }
Exemple #14
0
 public CustomData(NWObject owner)
 {
     Owner = owner;
 }
 public string Apply(NWCreature oCaster, NWObject oTarget, int effectiveLevel)
 {
     return(null);
 }
Exemple #16
0
        public void OnImpact(NWPlayer player, NWObject target, int level)
        {
            var effectiveStats = _playerStat.GetPlayerItemEffectiveStats(player);
            int darkBonus      = effectiveStats.DarkAbility;
            int amount;
            int length;
            int dotAmount;
            int min = 1;

            int wisdom       = player.WisdomModifier;
            int intelligence = player.IntelligenceModifier;

            min += darkBonus / 3 + intelligence / 2 + wisdom / 3;

            switch (level)
            {
            case 1:
                amount    = _random.D6(2, min);
                length    = 0;
                dotAmount = 0;
                break;

            case 2:
                amount    = _random.D6(2, min);
                length    = 6;
                dotAmount = 1;
                break;

            case 3:
                amount    = _random.D12(2, min);
                length    = 6;
                dotAmount = 1;
                break;

            case 4:
                amount    = _random.D12(2, min);
                length    = 12;
                dotAmount = 1;
                break;

            case 5:
                amount    = _random.D12(2, min);
                length    = 6;
                dotAmount = 2;
                break;

            case 6:
                amount    = _random.D12(2, min);
                length    = 12;
                dotAmount = 2;
                break;

            case 7:
                amount    = _random.D12(3, min);
                length    = 12;
                dotAmount = 2;
                break;

            case 8:
                amount    = _random.D12(3, min);
                length    = 6;
                dotAmount = 4;
                break;

            case 9:
                amount    = _random.D12(4, min);
                length    = 6;
                dotAmount = 4;
                break;

            case 10:
                amount    = _random.D12(4, min);
                length    = 12;
                dotAmount = 4;
                break;

            case 11:     // Only attainable with background bonus
                amount    = _random.D12(5, min);
                length    = 12;
                dotAmount = 4;
                break;

            default: return;
            }

            int luck = _perk.GetPCPerkLevel(player, PerkType.Lucky) + effectiveStats.Luck;

            if (_random.Random(100) + 1 <= luck)
            {
                length = length * 2;
                player.SendMessage("Lucky force lightning!");
            }

            player.AssignCommand(() =>
            {
                Effect damage = _.EffectDamage(amount, DAMAGE_TYPE_ELECTRICAL);
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, damage, target);
            });

            if (length > 0.0f && dotAmount > 0)
            {
                _customEffect.ApplyCustomEffect(player, target.Object, CustomEffectType.ForceShock, length, level, dotAmount.ToString());
            }

            _skill.RegisterPCToAllCombatTargetsForSkill(player, SkillType.DarkSideAbilities, target.Object);

            player.AssignCommand(() =>
            {
                Effect vfx = _.EffectVisualEffect(VFX_BEAM_LIGHTNING);
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, vfx, target);
            });
        }
 public void WearOff(NWCreature oCaster, NWObject oTarget, int effectiveLevel, string data = "")
 {
 }
Exemple #18
0
 public CustomData StartUseItem(NWCreature user, NWItem item, NWObject target, Location targetLocation)
 {
     return(null);
 }
Exemple #19
0
 public CustomData StartUseItem(NWCreature user, NWItem item, NWObject target, Location targetLocation)
 {
     user.SendMessage("You begin treating " + target.Name + "'s wounds...");
     return(null);
 }
Exemple #20
0
 public float MaxDistance(NWCreature user, NWItem item, NWObject target, Location targetLocation)
 {
     return(5.0f);
 }
Exemple #21
0
 public void OnImpact(NWPlayer player, NWObject target, int perkLevel, int spellFeatID)
 {
 }
Exemple #22
0
 public bool ReducesItemCharge(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
 {
     return(false);
 }
Exemple #23
0
        public string OnModuleExamine(string existingDescription, NWPlayer examiner, NWObject examinedObject)
        {
            if (!examiner.IsPlayer)
            {
                return(existingDescription);
            }
            if (examinedObject.ObjectType != OBJECT_TYPE_ITEM)
            {
                return(existingDescription);
            }

            NWItem examinedItem = NWItem.Wrap(examinedObject.Object);
            string description  = "";

            if (examinedItem.RecommendedLevel > 0)
            {
                description += _color.Orange("Recommended Level: ") + examinedItem.RecommendedLevel + "\n";
            }
            if (examinedItem.AssociatedSkillType > 0)
            {
                PCSkill pcSkill = _skill.GetPCSkillByID(examiner.GlobalID, (int)examinedItem.AssociatedSkillType);
                description += _color.Orange("Associated Skill: ") + pcSkill.Skill.Name + "\n";
            }
            if (examinedItem.CustomAC > 0)
            {
                description += _color.Orange("AC: ") + examinedItem.CustomAC + "\n";
            }
            if (examinedItem.HPBonus > 0)
            {
                description += _color.Orange("HP Bonus: ") + examinedItem.HPBonus + "\n";
            }
            if (examinedItem.ManaBonus > 0)
            {
                description += _color.Orange("Mana Bonus: ") + examinedItem.ManaBonus + "\n";
            }
            if (examinedItem.CastingSpeed > 0)
            {
                description += _color.Orange("Casting Speed: +") + examinedItem.CastingSpeed + "%\n";
            }
            else if (examinedItem.CastingSpeed < 0)
            {
                description += _color.Orange("Casting Penalty: -") + examinedItem.CastingSpeed + "%\n";
            }

            if (examinedItem.LoggingBonus > 0)
            {
                description += _color.Orange("Logging Bonus: ") + examinedItem.LoggingBonus + "\n";
            }
            if (examinedItem.MiningBonus > 0)
            {
                description += _color.Orange("Mining Bonus: ") + examinedItem.MiningBonus + "\n";
            }
            if (examinedItem.CraftBonusArmorsmith > 0)
            {
                description += _color.Orange("Armorsmith Bonus: ") + examinedItem.CraftBonusArmorsmith + "\n";
            }
            if (examinedItem.CraftBonusWeaponsmith > 0)
            {
                description += _color.Orange("Weaponsmith Bonus: ") + examinedItem.CraftBonusWeaponsmith + "\n";
            }
            if (examinedItem.CraftBonusCooking > 0)
            {
                description += _color.Orange("Cooking Bonus: ") + examinedItem.CraftBonusCooking + "\n";
            }
            if (examinedItem.CraftTierLevel > 0)
            {
                description += _color.Orange("Tool Level: ") + examinedItem.CraftTierLevel + "\n";
            }
            if (examinedItem.EnmityRate != 0)
            {
                description += _color.Orange("Enmity: ") + examinedItem.EnmityRate + "%\n";
            }
            if (examinedItem.EvocationBonus > 0)
            {
                description += _color.Orange("Evocation Bonus: ") + examinedItem.EvocationBonus + "\n";
            }
            if (examinedItem.AlterationBonus > 0)
            {
                description += _color.Orange("Alteration Bonus: ") + examinedItem.AlterationBonus + "\n";
            }
            if (examinedItem.SummoningBonus > 0)
            {
                description += _color.Orange("Summoning Bonus: ") + examinedItem.SummoningBonus + "\n";
            }
            if (examinedItem.LuckBonus > 0)
            {
                description += _color.Orange("Luck Bonus: ") + examinedItem.LuckBonus + "\n";
            }
            if (examinedItem.MeditateBonus > 0)
            {
                description += _color.Orange("Meditate Bonus: ") + examinedItem.MeditateBonus + "\n";
            }
            if (examinedItem.FirstAidBonus > 0)
            {
                description += _color.Orange("First Aid Bonus: ") + examinedItem.FirstAidBonus + "\n";
            }
            if (examinedItem.HPRegenBonus > 0)
            {
                description += _color.Orange("HP Regen Bonus: ") + examinedItem.HPRegenBonus + "\n";
            }
            if (examinedItem.ManaRegenBonus > 0)
            {
                description += _color.Orange("Mana Regen Bonus: ") + examinedItem.ManaRegenBonus + "\n";
            }
            if (examinedItem.BaseAttackBonus > 0)
            {
                description += _color.Orange("Base Attack Bonus: ") + examinedItem.BaseAttackBonus + "\n";
            }
            if (examinedItem.DamageBonus > 0)
            {
                description += _color.Orange("Damage Bonus: ") + examinedItem.DamageBonus + "\n";
            }

            return(existingDescription + "\n" + description);
        }
Exemple #24
0
 public static bool CanHandleChat(NWObject sender)
 {
     return(sender.GetLocalInt("CRAFT_RENAMING_ITEM") == TRUE);
 }
Exemple #25
0
        private void FinishActionItem(IActionItem actionItem, NWPlayer user, NWItem item, NWObject target, Location targetLocation, Vector userStartPosition, CustomData customData)
        {
            user.IsBusy = false;

            Vector userPosition = user.Position;

            if (userPosition.m_X != userStartPosition.m_X ||
                userPosition.m_Y != userStartPosition.m_Y ||
                userPosition.m_Z != userStartPosition.m_Z)
            {
                user.SendMessage("You move and interrupt your action.");
                return;
            }

            if (actionItem.MaxDistance() > 0.0f)
            {
                if (_.GetDistanceBetween(user.Object, target.Object) > actionItem.MaxDistance() ||
                    user.Area.Resref != target.Area.Resref)
                {
                    user.SendMessage("Your target is too far away.");
                    return;
                }
            }

            if (!target.IsValid && !actionItem.AllowLocationTarget())
            {
                user.SendMessage("Unable to locate target.");
                return;
            }

            string invalidTargetMessage = actionItem.IsValidTarget(user, item, target, targetLocation);

            if (!string.IsNullOrWhiteSpace(invalidTargetMessage))
            {
                user.SendMessage(invalidTargetMessage);
                return;
            }

            actionItem.ApplyEffects(user, item, target, targetLocation, customData);

            if (actionItem.ReducesItemCharge(user, item, target, targetLocation, customData))
            {
                if (item.Charges > 0)
                {
                    item.ReduceCharges();
                }
                else
                {
                    item.Destroy();
                }
            }
        }
Exemple #26
0
 public CustomData StartUseItem(NWCreature user, NWItem item, NWObject target, Location targetLocation)
 {
     user.SendMessage("You begin applying a force pack to " + target.Name + "...");
     return(null);
 }
Exemple #27
0
 public bool CanCastSpell(NWPlayer oPC, NWObject oTarget)
 {
     return(MeditateEffect.CanMeditate(oPC));
 }
Exemple #28
0
 public void OnImpact(NWPlayer oPC, NWObject oTarget)
 {
 }
Exemple #29
0
 public void OnImpact(NWPlayer player, NWObject target, int perkLevel)
 {
     _customEffect.ApplyCustomEffect(player, player, CustomEffectType.Meditate, -1, 0, null);
 }
Exemple #30
0
 public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
 {
 }