OK I really hate opening topics up and being everywhere, but this one is quite a bug, because sometimes it works, and sometimes it doesn’t, and the only way for me to figure it out is by deactivating the damage randomizer from time to time (I made up my mind I’m not re-activating it until release date, since clearly it can be quite the mess behind the scenes, and I want to catch it before it causes chaos…)
In my progression System, I have introduced stats for my player to progress through, and this includes Attack, Ranged, Defence and Mage, as part of me replacing the current system with a skilling system. The problem is, it’s… not working as expected. The way it currently works is that it first levels up normally for one level, and then it never levels up again. The weapons are effective, as per the formula in the code below, but the stats of the player himself just never improve, as his hits are not affected by his stats, just his weapon, hence making his combat stats, quite literally, ineffective. Here is the code that I suspect is responsible for this:
public int GetDamage() {
if (currentWeaponConfig.GetSkill() == Skill.Attack) {
return (int) (GetComponent<BaseStats>().GetStat(Stat.Attack) + (currentWeaponConfig.GetDamage() * (1 + currentWeaponConfig.GetPercentageBonus() / 100)));
/* int attackDamage = (int)(GetComponent<BaseStats>().GetStat(Stat.Attack) + (currentWeaponConfig.GetDamage() * (1 + currentWeaponConfig.GetPercentageBonus() / 100)));
playerDamageComponent.DealDamage(Skill.Attack, attackDamage);
return attackDamage; */
}
else if (currentWeaponConfig.GetSkill() == Skill.Ranged) {
return (int) (GetComponent<BaseStats>().GetStat(Stat.Ranged) + (currentWeaponConfig.GetDamage() * (1 + currentWeaponConfig.GetPercentageBonus()/100)));
/* int rangedDamage = (int)(GetComponent<BaseStats>().GetStat(Stat.Ranged) + (currentWeaponConfig.GetDamage() * (1 + currentWeaponConfig.GetPercentageBonus() / 100)));
playerDamageComponent.DealDamage(Skill.Ranged, rangedDamage);
return rangedDamage; */
}
else {
return (int) (GetComponent<BaseStats>().GetStat(Stat.Magic) + (currentWeaponConfig.GetDamage() * (1 + currentWeaponConfig.GetPercentageBonus()/100)));
/* int magicDamage = (int)(GetComponent<BaseStats>().GetStat(Stat.Magic) + (currentWeaponConfig.GetDamage() * (1 + currentWeaponConfig.GetPercentageBonus() / 100)));
playerDamageComponent.DealDamage(Skill.Magic, magicDamage);
return magicDamage; */
}
}
void Hit() {
// This function is only used in the AttackBehaviour() function, and
//it ensures damage is slightly delayed until the player punches the enemy
// It also checks if our current weapon has a Projectile or not (in case our player is a ranger)
// If he does, we launch our projectile (E.g: arrows)
// If not, just do regular melee damage (as usual)
if(target == null) return; // ensures no errors occur if the attack animation is playing, but we can't find a target
// (like when we walk away from an incomplete attack animation: this produces an error, and this is the solution)
// float damage = GetComponent<BaseStats>().GetStat(Stat.Damage);
float damage = GetDamage();
// Defending our Player from damage done by target, based on the shield or item he's wearing:
BaseStats targetBaseStats = target.GetComponent<BaseStats>();
if (targetBaseStats != null) {
float defence = targetBaseStats.GetStat(Stat.Defence);
// This formula reduces the effectiveness of weapons as the player gets stronger:
damage /= (1 + (defence/damage)); // Damage Formula (Power = Power * (1 + defence/enemy damage))
// damage *= UnityEngine.Random.Range(0, 1.25f); // Randomizing the Damage
// if (UnityEngine.Random.Range(0,100) > 95) damage *= 2.0f; // Critical hit
}
// Rest of the hit function...
What changes can I possibly do, to ensure the damage he deals considers his Skill level as well?
Edit: After a little more investigation, I realized the combat and defence skills are effective, but BASED ON THE COMBAT LEVEL, NOT THE INDIVIDUAL SKILLS THEMSELVES, so when the player levels his combat up, the damage from his progression system and defence become more effective too, and they all iterate to the next progression bar value (not to my visible eye, but that’s how the game system works based on try and error right now, and it’s definitely not how I want it to work), rather than doing it when the skills individually iterate, which also means that some of the untrained skills also miraculously get better when the combat level increases, although I didn’t even start training them… Where did I go so wrong?! If it helps in anyway, this is the thread that links to the Skills Based system we were developing