I have the "Intelligence" ability on my character, which has a base variable (working perfectly, currently set to 21 for this instance) and a weapon (which is being added to their inventory and forced him to hold it) with an enchantment for adding a specific modifier to the ability. Here's the ability class (without the parenting abilities / such)
public class IntClass {
int Scorea;
public int ScoreModifier;
public int Score() {
return (Scorea + ScoreModifier);
}
public int Modifier() {
return (Mathf.FloorToInt(Score() / 2 - 5));
}
public IntClass(int AbilityScore) {
Scorea = AbilityScore;
}
}
I have another part that updates it (I have it called every 0.1f seconds) with the current inventory modifiers (below)
public void UpdateInventory() {
Ability.Str.ScoreModifier = 0;
Ability.Dex.ScoreModifier = 0;
Ability.Con.ScoreModifier = 0;
Ability.Wis.ScoreModifier = 0;
Ability.Int.ScoreModifier = 0;
Ability.Cha.ScoreModifier = 0;
Health.HealthMods.Clear();
List- InventoryItems = Inventory.InventoryItems();
if (InventoryItems != null) {
foreach (Item item in InventoryItems) {
if (item != null && item.Enchantments != null && ((item.Armor == null && item.Weapon == null) || (item == Inventory.Weapon && item.Weapon != null) || (item == Inventory.Armor && item.Armor != null))) {
Ability.Str.ScoreModifier += item.Enchantments.Str;
Ability.Dex.ScoreModifier += item.Enchantments.Dex;
Ability.Con.ScoreModifier += item.Enchantments.Con;
Ability.Wis.ScoreModifier += item.Enchantments.Wis;
Ability.Int.ScoreModifier += item.Enchantments.Int;
Ability.Cha.ScoreModifier += item.Enchantments.Cha;
Health.HealthMods.Add(new HealthClass.HealthModClass("ItemEnchantment", item.Enchantments.Health));
}
}
}
}
Here's what's going on.....
I have the enchantment set to "0" for intelligence, and the debug text outputs the "21" that the character should have without modifiers... But when I put in "1" for intelligence, the debug script outputs a 41...... I don't know where I went wrong...
Here's a bit of a run through with it
[Google Photos Video][1]
I am willing to add any other scripts / classes that may be the problem... I don't really want to just divide it by 20 because I don't know WHERE to divide by 20 and I want to know where it's going wrong
Things to keep in mind
- This is ALL in a public class called "Character", for the "Updating" function, I just have a single script that has them all on invokerepeating
[1]: https://photos.google.com/share/AF1QipO6Hf42iwAhHwgFrj6RPiIESIYl62OIkXH4jiLPT7O_4LwAZ9m6KRONXq56rLJLyQ/photo/AF1QipP5cLd8R4bpsNLB7fzYxeBrWGcl0l2OFdd2Mo7l?key=TVVSZ2Flbk1HLTc1SlQ1SmhhNUwxZ2lPZE9ONWZR
↧