14. Defense System
14.1 Block System
To activate the block system you’ll have to add your ACFDefenseStanceComponent to the selected Character.
To start entering in block mode, you can do as follows:
A brief explanation of how to configure the component:
When in Defence Mode, all your damage will be redirected to the DamagedStatistic instead of affecting health.
Additionally to block you’ll have to add a ACFBlockComponent to the Actor that is used for blocking (can be both a weapon, a shield or the character itself if the block is happening when unarmed).
If the received attack can be blocked, ActionToBeTriggeredOnBlock will be triggered.
Once the Damage is blocked, the incoming damage multiplied for the DamagedStatisticsMultiplier will be subtracted from DamagedStatistic. In our case IncomingDamage * DamagedStatisticsMultiplier will be removed from Stamina.
Once the DamagedStatistic reaches 0, ActionToBeTriggeredOnDefenseBreak will be triggered and the character will stop defending automatically. He will be able to enter Defense State when it’s DamagedStatistic (Stamina in our sample) will be above MinumumDamageToStartBlocking.
While in Defense stance, every damage received will be analyzed to identify if it can be blocked. You can define which damage types are blockable (the array BlockableDamage) and from what direction the character is able to block (BlockDirection). To be able to block when unarmed, CanBlockWhenUnarmed must be checked, To enter in defence stance at least one of the InHand weaponw must have the flag CanBeUsedForBlock checked.
2. Block Animation Overlay
Once in Defend Mode you’d need to set your BlockOverlay within your ACFOverlayLayer. Remember that any
moveset will have his own OverlayLayer, so for every weapon / unarmed setup that you are using with the block system you’ll need to setup a custom BlockOverlay animation, for more info check Character Controller - NEW V3
3. Counter Attacks
Counter attacks are special action that can be performed during a particular time window.
To set the actual beginning / end of a counter attack window you can use the animNotify ACFCounterEnabledNotifyState in any of yours animations (ideally in the block reaction one).
If the function TryCounterAttack is called while the opening window is enabled and the incoming damage is contained in CounterableDamages, CounterAttackAction will be triggered iwith an high priority.