Ejemplo n.º 1
0
        private static void HandleAbsorptionFieldEffect()
        {
            DamageEventData data = NWNXDamage.GetDamageEventData();

            if (data.Total <= 0)
            {
                return;
            }
            NWObject target = _.OBJECT_SELF;

            if (!target.IsPlayer)
            {
                return;
            }

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

            if (effectLevel <= 0)
            {
                return;
            }

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

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

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

            AbilityService.RestorePlayerFP(player, absorbed);
        }
Ejemplo n.º 2
0
        private static 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 = DataService.Where <PCCustomEffect>(x => x.PlayerID == player.GlobalID &&
                                                                                   x.StancePerkID == null).ToList();

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

                    PCCustomEffect result = RunPCCustomEffectProcess(player, effect);
                    if (result == null)
                    {
                        ICustomEffectHandler handler = CustomEffectService.GetCustomEffectHandler(effect.CustomEffectID);
                        string message = handler.WornOffMessage;
                        player.SendMessage(message);
                        player.DeleteLocalInt("CUSTOM_EFFECT_ACTIVE_" + effect.CustomEffectID);
                        DataService.SubmitDataChange(effect, DatabaseActionType.Delete);
                        handler.WearOff(null, player, effect.EffectiveLevel, effect.Data);
                    }
                    else
                    {
                        DataService.SubmitDataChange(effect, DatabaseActionType.Update);
                    }
                }
            }
        }