Пример #1
0
        public void OnImpact(NWPlayer oPC, NWObject oTarget)
        {
            int level = _perk.GetPCPerkLevel(oPC, PerkType.Purify);
            int luck  = _perk.GetPCPerkLevel(oPC, PerkType.Lucky);

            bool luckBonus = _random.Random(100) + 1 <= luck;

            if (level >= 1 || luckBonus)
            {
                _customEffect.RemovePCCustomEffect((NWPlayer)oTarget, CustomEffectType.Bleeding);
            }
            if (level >= 2 || luckBonus)
            {
                _customEffect.RemovePCCustomEffect((NWPlayer)oTarget, CustomEffectType.Poison);
            }
            if (level >= 3 || luckBonus)
            {
                _customEffect.RemovePCCustomEffect((NWPlayer)oTarget, CustomEffectType.Burning);
            }

            Effect vfx = _.EffectVisualEffect(VFX_IMP_HEALING_S);

            _.ApplyEffectToObject(DURATION_TYPE_INSTANT, vfx, oTarget.Object);

            foreach (Effect effect in oTarget.Effects)
            {
                int effectType = _.GetEffectType(effect);
                if (effectType == EFFECT_TYPE_POISON || effectType == EFFECT_TYPE_DISEASE)
                {
                    _.RemoveEffect(oTarget.Object, effect);
                }
            }

            _skill.RegisterPCToAllCombatTargetsForSkill(oPC, SkillType.AlterationMagic);
        }
Пример #2
0
        private void HandleAbsorptionFieldEffect()
        {
            DamageData data   = _nwnxDamage.GetDamageEventData();
            NWObject   target = Object.OBJECT_SELF;

            if (!target.IsPlayer)
            {
                return;
            }

            NWPlayer player      = target.Object;
            int      effectLevel = _customEffect.GetCustomEffectLevel(player, CustomEffectType.AbsorptionField);

            if (effectLevel <= 0)
            {
                return;
            }

            // Remove effect if player activates ability and removes the armor.
            if (player.Chest.CustomItemType != CustomItemType.ForceArmor)
            {
                _customEffect.RemovePCCustomEffect(player, CustomEffectType.AbsorptionField);
            }

            float absorptionRate = effectLevel * 0.1f;
            int   absorbed       = (int)(data.Total * absorptionRate);

            if (absorbed < 1)
            {
                absorbed = 1;
            }

            RestoreFP(player, absorbed);
        }
Пример #3
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            _customEffect.RemovePCCustomEffect(target.Object, CustomEffectType.Poison);

            foreach (Effect effect in target.Effects)
            {
                if (_.GetIsEffectValid(effect) == TRUE)
                {
                    int effectType = _.GetEffectType(effect);
                    if (effectType == EFFECT_TYPE_POISON || effectType == EFFECT_TYPE_DISEASE)
                    {
                        _.RemoveEffect(target.Object, effect);
                    }
                }
            }

            user.SendMessage("You successfully treat " + target.Name + "'s infection.");

            int rank = _skill.GetPCSkillRank(user.Object, SkillType.Medicine);

            if (target.IsPlayer)
            {
                int xp = (int)_skill.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank);
                _skill.GiveSkillXP(user.Object, SkillType.Medicine, xp);
            }
        }
Пример #4
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            _customEffect.RemovePCCustomEffect((NWPlayer)target, CustomEffectType.Bleeding);
            _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(2), target.Object);
            user.SendMessage("You finish bandaging " + target.Name + "'s wounds.");

            PCSkill skill = _skill.GetPCSkill((NWPlayer)user, SkillType.FirstAid);
            int     xp    = (int)_skill.CalculateSkillAdjustedXP(100, item.RecommendedLevel, skill.Rank);

            _skill.GiveSkillXP((NWPlayer)user, SkillType.FirstAid, xp);
        }
Пример #5
0
        public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
        {
            NWPlayer player   = oTarget.Object;
            int      restTick = oTarget.GetLocalInt("REST_TICK") + 1;


            // Pull original position from data
            string[] values           = data.Split(',');
            Vector   originalPosition = _.Vector
                                        (
                Convert.ToSingle(values[0]),
                Convert.ToSingle(values[1]),
                Convert.ToSingle(values[2])
                                        );

            // Check position
            Vector position = player.Position;

            if ((Math.Abs(position.m_X - originalPosition.m_X) > 0.01f ||
                 Math.Abs(position.m_Y - originalPosition.m_Y) > 0.01f ||
                 Math.Abs(position.m_Z - originalPosition.m_Z) > 0.01f) ||
                !CanRest(player) ||
                !player.IsValid)
            {
                player.IsBusy = false;
                _customEffect.RemovePCCustomEffect(player, CustomEffectType.Rest);
                return;
            }

            player.IsBusy = true;

            player.AssignCommand(() =>
            {
                _.ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0f, 6.1f);
            });

            if (restTick >= 6)
            {
                int amount = CalculateAmount(player);

                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(amount), player);
                Effect vfx = _.EffectVisualEffect(VFX_IMP_HEAD_HOLY);
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, vfx, player);
                restTick = 0;
            }

            oTarget.SetLocalInt("REST_TICK", restTick);
        }
Пример #6
0
        public void Tick(NWCreature oCaster, NWObject oTarget, int currentTick, int effectiveLevel, string data)
        {
            NWPlayer targetPlayer = oTarget.Object;

            if (targetPlayer.Chest.CustomItemType != CustomItemType.HeavyArmor)
            {
                _customEffect.RemovePCCustomEffect(targetPlayer, CustomEffectType.ShieldBoost);
                _stat.ApplyStatChanges(targetPlayer, null);

                var vfx = targetPlayer.Effects.SingleOrDefault(x => _.GetEffectTag(x) == "SHIELD_BOOST_VFX");

                if (vfx != null)
                {
                    _.RemoveEffect(targetPlayer, vfx);
                }
            }
        }
Пример #7
0
        private void ProcessPCCustomEffects()
        {
            foreach (var player in NWModule.Get().Players)
            {
                if (!player.IsInitializedAsPlayer)
                {
                    continue;                                // Ignored to prevent a timing issue where new characters would be included in this processing.
                }
                List <PCCustomEffect> effects = _data.Where <PCCustomEffect>(x =>
                {
                    var customEffect = _data.Get <Data.Entity.CustomEffect>(x.CustomEffectID);
                    return(x.PlayerID == player.GlobalID &&
                           customEffect.CustomEffectCategoryID != (int)CustomEffectCategoryType.Stance);
                }).ToList();

                foreach (var effect in effects)
                {
                    if (player.CurrentHP <= -11)
                    {
                        _customEffect.RemovePCCustomEffect(player, effect.CustomEffectID);
                        return;
                    }

                    PCCustomEffect result = RunPCCustomEffectProcess(player, effect);
                    if (result == null)
                    {
                        var    customEffect  = _data.Get <Data.Entity.CustomEffect>(effect.CustomEffectID);
                        string message       = customEffect.WornOffMessage;
                        string scriptHandler = customEffect.ScriptHandler;
                        player.SendMessage(message);
                        player.DeleteLocalInt("CUSTOM_EFFECT_ACTIVE_" + effect.CustomEffectID);
                        _data.SubmitDataChange(effect, DatabaseActionType.Delete);

                        App.ResolveByInterface <ICustomEffect>("CustomEffect." + scriptHandler, (handler) =>
                        {
                            handler?.WearOff(null, player, effect.EffectiveLevel, effect.Data);
                        });
                    }
                    else
                    {
                        _data.SubmitDataChange(effect, DatabaseActionType.Update);
                    }
                }
            }
        }
Пример #8
0
        public void OnImpact(NWPlayer player, NWObject target, int level)
        {
            var effectiveStats = _playerStat.GetPlayerItemEffectiveStats(player);
            int lightBonus     = effectiveStats.LightAbility;

            PCCustomEffect spreadEffect = _data.SingleOrDefault <PCCustomEffect>(x => x.PlayerID == player.GlobalID && x.CustomEffectID == (int)CustomEffectType.ForceSpread);
            string         spreadData   = spreadEffect?.Data ?? string.Empty;
            int            spreadLevel  = spreadEffect?.EffectiveLevel ?? 0;
            int            spreadUses   = spreadEffect == null ? 0 : Convert.ToInt32(spreadData.Split(',')[0]);
            float          spreadRange  = spreadEffect == null ? 0 : Convert.ToSingle(spreadData.Split(',')[1]);

            if (spreadLevel <= 0)
            {
                HealTarget(player, target, lightBonus, level);
            }
            else
            {
                var members = player.PartyMembers.Where(x => _.GetDistanceBetween(x, target) <= spreadRange ||
                                                        Equals(x, target));
                spreadUses--;

                foreach (var member in members)
                {
                    HealTarget(player, member, lightBonus, level);
                }

                if (spreadUses <= 0)
                {
                    _customEffect.RemovePCCustomEffect(player, CustomEffectType.ForceSpread);
                }
                else
                {
                    // ReSharper disable once PossibleNullReferenceException
                    spreadEffect.Data = spreadUses + "," + spreadRange;
                    _data.SubmitDataChange(spreadEffect, DatabaseActionType.Update);
                    player.SendMessage("Force Spread uses remaining: " + spreadUses);
                }
            }

            _skill.RegisterPCToAllCombatTargetsForSkill(player, SkillType.LightSideAbilities, target.Object);
        }
Пример #9
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            NWPlayer player         = (user.Object);
            var      effectiveStats = _playerStat.GetPlayerItemEffectiveStats(player);

            _customEffect.RemovePCCustomEffect(target.Object, CustomEffectType.Bleeding);
            player.SendMessage("You finish bandaging " + target.Name + "'s wounds.");

            int rank = _skill.GetPCSkillRank(player, SkillType.Medicine);

            int healAmount = 2 + effectiveStats.Medicine / 2;

            healAmount += item.MedicineBonus;
            if (rank >= item.RecommendedLevel && item.MedicineBonus > 0)
            {
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(healAmount), target);
            }

            int xp = (int)_skill.CalculateRegisteredSkillLevelAdjustedXP(100, item.RecommendedLevel, rank);

            _skill.GiveSkillXP(player, SkillType.Medicine, xp);
        }