Hello, I made a custom script to add armor to my character. As far as I'm aware, defense on equipment only gets activated when guarding. (Please correct me if I'm wrong!) If I add DefenseRate as an attribute via the Inventory Manager, what script/function do I need to call?
Here's both a quick overview of how I manager the armor as well as the question at the end for a visual explanation.
I was going to originally change the 'Default Defense Rate' in the MeleeManager depending on the Defense Rate of the armor, but the Default Defense Rate doesn't seem to do anything when hit by enemies. At 100 and at 5, the EnemyAI_B consistently damages the player 15 health.
Additionally, is there a debug/display for finding out how much defense the player current has?
If im not mistaken, the defense rate is used in weapon..when a character is blocking, you can check the script OnReceiveAttack inside vMeleeCombatInput.cs
so if you're using an armor.. u can write something like this...depends on your set up
public virtual void OnReceiveAttack(vDamage damage, vIMeleeFighter attacker)
{
//if character wearing an armor
if(player.HasArmor)
var damageReduction = player.GetArmorDefenseRate()..
That worked perfectly, thank you! I didn't consider going to the root, but it makes a lot of sense.
I went with this approach, which completely ditches the Invector attributes. Although, you're right I can take the value from the defenseRate directly.. This is how I handled it (also added fire/poison resistance):
Then I handle the physical defense on the OnReceiveAttack (I reworked the blocking code as the fallback and made this the main form of damage reduction. I could merge the TotalDef and Blocking Defense if I want to later on add blocking back).
var damageReduction = GetComponent<ArmorChecker>().TotalDef;
if (damageReduction > 0)
damage.ReduceDamage(damageReduction); So here's a video of it in action, different armor ratings (and different resistance ratings).
Thanks! I'm using the 'Shadergraph Essentials' asset which gives a toon master node in the URP shadergraph. I hope to get it out on the PC and hopefully other systems as well, primarily a Nintendo device since my game has a lot of Zelda inspiration.