Topic category: Advanced modding
I wanted to create some daggers that deal additional damage when used behind the target (similarly to the mod Backstab for 1.12.2).
I thought that if the player is attacking the target from behind, it means they have a similar direction. So I made a condition that checks if the absolute (if it's negative, turn it to positive) difference between the direction of the player and the target is littler than a set value (I chose 50).
However, after a few playtesting, I remembered that the direction is relative to south and can vary from 0 to 360. I tried working around that, but I later realised that the direction system is somehow weird (west, for example, sometimes it is considered as +270 and sometimes as - 90...).
After placing a circle of armorstands all facing a different direction and using a procedure block that sends a text showing both the player's and the target's direction, I managed to almost fix it by turning anything negative into positive and to have a condition that checks if a direction is higher than 180 and, if it is, to set it to 360 minus that value.
It works almost always, the only issue now is it doesn't really distinguish west from east so it triggers the "backstab" effect even if the player and the target are facing each other, if the directions are east and west.
So, after spending a whole afternoon trying to find a solution I began to hate armorstands... Does anybody have an idea? XD
(If you need it I can post the procedure here)
Anyone? :(
Nevermind, thanks to 2020.4 I managed to fix the issue by using the compare directions block (F for that day spent on overly complex procedures that didn't work).
If you want to check the Combat module it was just released
Oh I never noticed this topic. Otherwise I would have tried finding a solution.
Don't worry, 2020.4 removed the whole need to make that huge procedure XD
Well it would have taken me ages anyway since I don't know how most procedures work.
Since you figured it how can you show the procedure i dont quite understand it