private static void HandleFPRegenerationTick(NWPlayer oPC, Data.Entity.Player entity) { entity.CurrentFPTick = entity.CurrentFPTick - 1; int rate = 20; int amount = 1; if (entity.CurrentFPTick <= 0) { if (entity.CurrentFP < entity.MaxFP) { var effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(oPC); // CHA bonus int cha = oPC.CharismaModifier; if (cha > 0) { amount += cha; } amount += effectiveStats.FPRegen; if (oPC.Chest.CustomItemType == CustomItemType.ForceArmor) { int clarityLevel = PerkService.GetPCPerkLevel(oPC, PerkType.Clarity); if (clarityLevel > 0) { amount += clarityLevel + 1; } } entity = AbilityService.RestoreFP(oPC, amount, entity); } entity.CurrentFPTick = rate; } }
private static void HandleAbsorptionFieldEffect() { DamageEventData data = NWNXDamage.GetDamageEventData(); if (data.Total <= 0) { return; } NWObject target = Object.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.RestoreFP(player, absorbed); }
private static void HandleBattlemagePerk() { DamageEventData data = NWNXDamage.GetDamageEventData(); if (data.Base <= 0) { return; } NWObject target = Object.OBJECT_SELF; if (!data.Damager.IsPlayer || !target.IsNPC) { return; } if (_.GetHasFeat((int)CustomFeatType.Battlemage, data.Damager.Object) == FALSE) { return; } NWPlayer player = data.Damager.Object; NWItem weapon = _.GetLastWeaponUsed(player.Object); if (weapon.CustomItemType != CustomItemType.Baton) { return; } if (player.Chest.CustomItemType != CustomItemType.ForceArmor) { return; } int perkRank = PerkService.GetPCPerkLevel(player, PerkType.Battlemage); int restoreAmount = 0; bool metRoll = RandomService.Random(100) + 1 <= 50; switch (perkRank) { case 1 when metRoll: restoreAmount = 1; break; case 2: restoreAmount = 1; break; case 3: restoreAmount = 1; if (metRoll) { restoreAmount++; } break; case 4: restoreAmount = 2; break; case 5: restoreAmount = 2; if (metRoll) { restoreAmount++; } break; case 6: restoreAmount = 3; break; } if (restoreAmount > 0) { AbilityService.RestoreFP(player, restoreAmount); } }