private static WeaponBalancePartCollection GetWeaponBalancePartCollection( InfoDictionary <WeaponTypeDefinition> weaponTypes, Raw.WeaponBalancePartCollection raw) { if (raw == null) { return(null); } WeaponTypeDefinition type = null; if (string.IsNullOrEmpty(raw.Type) == false) { if (weaponTypes.ContainsKey(raw.Type) == false) { throw ResourceNotFoundException.Create("weapon type", raw.Type); } type = weaponTypes[raw.Type]; } return(new WeaponBalancePartCollection() { Type = type, Mode = raw.Mode, BodyParts = raw.BodyParts, GripParts = raw.GripParts, BarrelParts = raw.BarrelParts, SightParts = raw.SightParts, StockParts = raw.StockParts, ElementalParts = raw.ElementalParts, Accessory1Parts = raw.Accessory1Parts, Accessory2Parts = raw.Accessory2Parts, MaterialParts = raw.MaterialParts, }); }
private static WeaponBalancePartCollection CreateWeaponBalancePartCollection( InfoDictionary <WeaponTypeDefinition> weaponTypes, KeyValuePair <string, Raw.WeaponBalancePartCollection> kv) { var raw = kv.Value; WeaponTypeDefinition type = null; if (string.IsNullOrEmpty(raw.WeaponType) == false) { if (weaponTypes.TryGetValue(raw.WeaponType, out type) == false) { throw ResourceNotFoundException.Create("weapon type", raw.WeaponType); } } return(new WeaponBalancePartCollection() { WeaponType = type, Mode = raw.Mode, BodyParts = raw.BodyParts, GripParts = raw.GripParts, BarrelParts = raw.BarrelParts, SightParts = raw.SightParts, StockParts = raw.StockParts, ElementalParts = raw.ElementalParts, Accessory1Parts = raw.Accessory1Parts, Accessory2Parts = raw.Accessory2Parts, MaterialParts = raw.MaterialParts, }); }
static void Postfix(RulesetCharacterHero __instance, ref RulesetAttackMode __result, ref WeaponDescription weaponDescription) { DamageForm firstDamageForm = __result.EffectDescription.FindFirstDamageForm(); WeaponTypeDefinition element = DatabaseRepository.GetDatabase <WeaponTypeDefinition>().GetElement(weaponDescription.WeaponType); int originalAbilityScoreModifier = AttributeDefinitions.ComputeAbilityScoreModifier(__instance.Attributes[__result.AbilityScore].CurrentValue); __result.AbilityScore = element.WeaponProximity == RuleDefinitions.AttackProximity.Melee ? "Strength" : "Dexterity"; if (weaponDescription.WeaponTags.Contains("Finesse") && __instance.GetAttribute("Dexterity").CurrentValue > __instance.GetAttribute(__result.AbilityScore).CurrentValue) { __result.AbilityScore = "Dexterity"; } if (weaponDescription.WeaponTags.Contains("Knowledge") && __instance.GetAttribute("Intelligence").CurrentValue > __instance.GetAttribute(__result.AbilityScore).CurrentValue) { __result.AbilityScore = "Intelligence"; } if (weaponDescription.WeaponTags.Contains("Intuition") && __instance.GetAttribute("Wisdom").CurrentValue > __instance.GetAttribute(__result.AbilityScore).CurrentValue) { __result.AbilityScore = "Wisdom"; } if (weaponDescription.WeaponTags.Contains("Vigor") && __instance.GetAttribute("Constitution").CurrentValue > __instance.GetAttribute(__result.AbilityScore).CurrentValue) { __result.AbilityScore = "Constitution"; } if (weaponDescription.WeaponTags.Contains("Influence") && __instance.GetAttribute("Charisma").CurrentValue > __instance.GetAttribute(__result.AbilityScore).CurrentValue) { __result.AbilityScore = "Charisma"; } int abilityScoreModifier = AttributeDefinitions.ComputeAbilityScoreModifier(__instance.Attributes[__result.AbilityScore].CurrentValue); Predicate <RuleDefinitions.TrendInfo> predicate = FindAbilityScoreTrend; int ability_score_to_hit_trend_index = __result.ToHitBonusTrends.FindIndex(predicate); int ability_score_damage_bonus_trend_index = firstDamageForm.DamageBonusTrends.FindIndex(predicate); if (ability_score_to_hit_trend_index >= 0) { __result.ToHitBonus -= originalAbilityScoreModifier; __result.ToHitBonus += abilityScoreModifier; __result.ToHitBonusTrends.RemoveAt(ability_score_to_hit_trend_index); __result.ToHitBonusTrends.Add(new RuleDefinitions.TrendInfo(abilityScoreModifier, RuleDefinitions.FeatureSourceType.AbilityScore, __result.AbilityScore, (object)null)); } if (ability_score_damage_bonus_trend_index >= 0) { firstDamageForm.DamageBonusTrends.RemoveAt(ability_score_damage_bonus_trend_index); firstDamageForm.BonusDamage -= originalAbilityScoreModifier; firstDamageForm.BonusDamage += abilityScoreModifier; firstDamageForm.DamageBonusTrends.Add(new RuleDefinitions.TrendInfo(abilityScoreModifier, RuleDefinitions.FeatureSourceType.AbilityScore, __result.AbilityScore, (object)null)); } }
private static void WeaponTypeDefinitionCopyBuilder(WeaponTypeDefinition sourceWeaponTypeDefinition, string name, string weaponCategory) { Guid newGuid = GuidHelper.Create(ModGuidNamespace, name); WeaponTypeDefinition builtWeaponTypeDefinition = ScriptableObject.CreateInstance <WeaponTypeDefinition>(); Traverse.Create(builtWeaponTypeDefinition).Field("weaponCategory").SetValue(weaponCategory); Traverse.Create(builtWeaponTypeDefinition).Field("name").SetValue(name); builtWeaponTypeDefinition.name = name; Traverse.Create(builtWeaponTypeDefinition).Field("isAttachedToBone").SetValue(sourceWeaponTypeDefinition.IsAttachedToBone); Traverse.Create(builtWeaponTypeDefinition).Field("animationTag").SetValue(sourceWeaponTypeDefinition.AnimationTag); Traverse.Create(builtWeaponTypeDefinition).Field("soundEffectDescription").SetValue(sourceWeaponTypeDefinition.SoundEffectDescription); Traverse.Create(builtWeaponTypeDefinition).Field("soundEffectOnHitDescription").SetValue(sourceWeaponTypeDefinition.SoundEffectOnHitDescription); Traverse.Create(builtWeaponTypeDefinition).Field("MeleeAttackerParticle").SetValue(sourceWeaponTypeDefinition.MeleeAttackerParticle); Traverse.Create(builtWeaponTypeDefinition).Field("MeleeImpactParticle").SetValue(sourceWeaponTypeDefinition.MeleeImpactParticle); Traverse.Create(builtWeaponTypeDefinition).Field("ThrowAttackerParticle").SetValue(sourceWeaponTypeDefinition.ThrowAttackerParticle); Traverse.Create(builtWeaponTypeDefinition).Field("ThrowImpactParticle").SetValue(sourceWeaponTypeDefinition.ThrowImpactParticle); Traverse.Create(builtWeaponTypeDefinition).Field("guiPresentation").SetValue(sourceWeaponTypeDefinition.GuiPresentation); Traverse.Create(builtWeaponTypeDefinition).Field("guid").SetValue(newGuid.ToString()); DatabaseRepository.GetDatabase <WeaponTypeDefinition>().Add(builtWeaponTypeDefinition); }