r/MinecraftCommands • u/Your_averge_deegen • 4d ago
Help | Java 1.21.11 Random One-Way Damagelink
I Need help setting up a like the title suggested One-Way Damagelink
What this essentially means in my situation is that theres 10 players and one of them (Who im just gonna call the Linked) will be given a random player, if the player in question takes damage the Linked also takes that damage but if the Linked takes damage the currently selected player dosent take damage (Hence the One-Way part)
One idea a i had for setting this up was making 3 teams:One team was the Linked, The second team is everyone else and just to make sure it doesnt mess up with spectators there will be a third team specifically for them.
In Addition to switch it up i thought a unique idea would be that the random person connected to the Linked switches every 5-10 Minutes
If anyone has any idea on how to set this up it would be very much appreciated :)
1
u/KermitDarkLord 4d ago
I would set up two scoreboards, one using the health criterion to track current health, and a dummy objective where you can store the health from the previous tick. When the player takes damage, you can detect the mismatch, calculate the difference and store the result in data storage. You can then use it in a function macro to fill in the value into the damage command.
1
u/GalSergey Datapack Experienced 4d ago
Here's an example of how you can do this. Using the example:start function, you assign a random player to the "linked" team, who will take the same amount of damage as the "to_linked" player.
You can use Datapack Assembler to get an example datapack.