[TUTORIAL] How to add a parry shield

Started by TiberiumTree on

Topic category: User side tutorials

Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[TUTORIAL] How to add a parry shield

This tutorial brings Dark Souls' parry shield into Minecraft,

.......but without durability setting option.

sword and shield

 

1.The food shield

food visual

Food properties

Although it seemed pretty weird that a shield is a kind of food, trigger On player stopped using does not work on tools and items, and I don't know how to write java code to use that trigger, there is no other choice.

tag

Player finishes using item

This global trigger prevents players from eating up their shield after holding it 9999 ticks.

food trigger

set right-click to defend, and external custom key to parry.

ShieldValue recovers as shield time increases and absorbs equal value damage via global trigger setting.

reset value after using

When the player stops using the shield, the ShieldTick and ShieldValue reset.

 

2.Defence and Parry procedure

normal defence

Part1

Axes can not cool down this shield as vanilla ones, to make up, they can deal 1.5 times damage to ShieldValue.

x1y1z1 is the directional vector for the attacked player, and x2y2z2 is the directional vector for attacker or arrows.

Ranged items are not always facing forward, so the velocity vector is better for judging the incoming direction of the attack.

 

Part2

vector angle

cos 135°≈ -0.707106.

Angle of the vector determines whether a defence is successful.

Besides, this can be used not only for shields blocking attacks but also for weapons backstabbing, just reverse the >.

simplify 1

Ignoring the pitch simplifies the calculation relative to the Y-axis

simplify 2

Considering the case of yaw as only 2 kinds, face and back, more calculation can be simplified.

 

 

If the defence is successful, cancel the trigger, and if ShieldValue drops to 0 or below, punish the shield-bearer.

 

parry

Parry procedure is similar to normal defence procedure. 

 

3.Shield overlay

overlay

As ShieldValue is invisible to the player, they need HUD to keep a handle on the situation.

 

 

 

 

 

Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
not sure if affects, also is…
Thu, 07/25/2024 - 05:20

not sure if affects, also is old the post so not sure if there are new methods, the Y position of the mobs can be affected by its height, normal bipeds like player should be +1 since the player camera  or arrow is +1 blocks higher.

Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
aparently you can use…
Thu, 07/25/2024 - 20:19

aparently you can use raytrace and distance 0 to get the coords of the camera, it only helps with coord y since x and z camera coords and entity coords are the same, but my idea is a bit overkill.

 

also i know its almost impossible but technically can be achieve, dont put a divider without a security measure, i mean if its 0 everything explodes. just if divider = 0 -> divider =.1 idunno

Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
welp yeah you got the…
Thu, 07/25/2024 - 21:37

welp yeah you got the divider = 0 already there srry about that