private void HandleStances() { DamageData data = _nwnxDamage.GetDamageEventData(); NWPlayer damager = data.Damager.Object; NWPlayer receiver = Object.OBJECT_SELF; NWItem damagerWeapon = _.GetLastWeaponUsed(damager); if (damager.IsPlayer) { CustomEffectType stance = _customEffect.GetCurrentStanceType(damager); switch (stance) { case CustomEffectType.ShieldOath: data.AdjustAllByPercent(-0.30f); break; case CustomEffectType.SwordOath: if (_item.MeleeWeaponTypes.Contains(damagerWeapon.BaseItemType)) { data.AdjustAllByPercent(0.20f); } break; } } if (receiver.IsPlayer) { CustomEffectType stance = _customEffect.GetCurrentStanceType(receiver); } _nwnxDamage.SetDamageEventData(data); }
private void HandleStances() { DamageData data = _nwnxDamage.GetDamageEventData(); NWPlayer damager = data.Damager.Object; NWItem damagerWeapon = _.GetLastWeaponUsed(damager); if (damager.IsPlayer) { CustomEffectType stance = _customEffect.GetCurrentStanceType(damager); switch (stance) { case CustomEffectType.ShieldOath: data.AdjustAllByPercent(-0.30f); break; case CustomEffectType.PrecisionTargeting: if (damagerWeapon.CustomItemType == CustomItemType.BlasterPistol || damagerWeapon.CustomItemType == CustomItemType.BlasterRifle) { data.AdjustAllByPercent(0.20f); } break; } } _nwnxDamage.SetDamageEventData(data); }
private int EffectiveArmorClass(EffectiveItemStats stats, NWPlayer player) { int baseAC = stats.AC + _customEffect.CalculateEffectAC(player); int totalAC = _.GetAC(player) - baseAC; // Shield Oath and Precision Targeting affect a percentage of the TOTAL armor class on a creature. var stance = _customEffect.GetCurrentStanceType(player); if (stance == CustomEffectType.ShieldOath) { int bonus = (int)(totalAC * 0.2f); baseAC = baseAC + bonus; } else if (stance == CustomEffectType.PrecisionTargeting) { int penalty = (int)(totalAC * 0.3f); baseAC = baseAC - penalty; } return(baseAC); }
public int EffectiveArmorClass(NWPlayer player, NWItem ignoreItem) { int[] skills = { (int)SkillType.HeavyArmor, (int)SkillType.LightArmor, (int)SkillType.ForceArmor }; var armorSkills = _data.Where <PCSkill>(x => x.PlayerID == player.GlobalID && skills.Contains(x.SkillID)).ToList(); int heavyRank = armorSkills.Single(x => x.SkillID == (int)SkillType.HeavyArmor).Rank; int lightRank = armorSkills.Single(x => x.SkillID == (int)SkillType.LightArmor).Rank; int forceRank = armorSkills.Single(x => x.SkillID == (int)SkillType.ForceArmor).Rank; int baseAC = 0; for (int slot = 0; slot < NUM_INVENTORY_SLOTS; slot++) { NWItem oItem = _.GetItemInSlot(slot, player.Object); if (oItem.Equals(ignoreItem)) { continue; } if (!oItem.IsValid) { continue; } if (!_item.ArmorBaseItemTypes.Contains(oItem.BaseItemType)) { continue; } if (oItem.CustomItemType != CustomItemType.HeavyArmor && oItem.CustomItemType != CustomItemType.LightArmor && oItem.CustomItemType != CustomItemType.ForceArmor) { continue; } int skillRankToUse = 0; if (oItem.CustomItemType == CustomItemType.HeavyArmor && oItem.RecommendedLevel > heavyRank) { skillRankToUse = heavyRank; } else if (oItem.CustomItemType == CustomItemType.LightArmor && oItem.RecommendedLevel > lightRank) { skillRankToUse = lightRank; } else if (oItem.CustomItemType == CustomItemType.ForceArmor && oItem.RecommendedLevel > forceRank) { skillRankToUse = forceRank; } int itemAC = oItem.CustomAC; itemAC = CalculateAdjustedValue(itemAC, oItem.RecommendedLevel, skillRankToUse, 0); baseAC += itemAC; } baseAC = baseAC + _customEffect.CalculateEffectAC(player); int totalAC = _.GetAC(player) - baseAC; // Shield Oath and Sword Oath affect a percentage of the TOTAL armor class on a creature. var stance = _customEffect.GetCurrentStanceType(player); if (stance == CustomEffectType.ShieldOath) { int bonus = (int)(totalAC * 0.2f); baseAC = baseAC + bonus; } else if (stance == CustomEffectType.SwordOath) { int penalty = (int)(totalAC * 0.3f); baseAC = baseAC - penalty; } return(baseAC); }