1
Need Command Help for Hide and Seek
So I'm currently in the middle of making a Hide and Seek map, and I've been trying to figure out the best way to make it so that whenever a hider is found, they immediately become a seeker.
The original way I was doing it was basically whenever the game was running, a /spawnpoint command was running at all times for all players, and the seeker had an insta-kill weapon which caused a death scoreboard to be set to 1, and whoever had the death score of 1 was then given the seeker tag. It works fine, but the way I was doing it made it possible for players to duplicate the items in their inventory into block inventories (chests, barrels, etc.) because I couldn't figure out a way to lock items to an inventory or stop them from duplication, so I want to try and avoid using any and all items.
I know there is a hit detection command of some form, but I haven't been able to get it to work correctly, so if there's anyone who could help me with that (where you hit a player, not killing them, and they'll be given the seeker tag), that would be greatly appreciated.
Currently on 1.21.8, FYI.
The original way I was doing it was basically whenever the game was running, a /spawnpoint command was running at all times for all players, and the seeker had an insta-kill weapon which caused a death scoreboard to be set to 1, and whoever had the death score of 1 was then given the seeker tag. It works fine, but the way I was doing it made it possible for players to duplicate the items in their inventory into block inventories (chests, barrels, etc.) because I couldn't figure out a way to lock items to an inventory or stop them from duplication, so I want to try and avoid using any and all items.
I know there is a hit detection command of some form, but I haven't been able to get it to work correctly, so if there's anyone who could help me with that (where you hit a player, not killing them, and they'll be given the seeker tag), that would be greatly appreciated.
Currently on 1.21.8, FYI.
2
If you want to avoid the "kill logic", you could try setting up the following Command Block layout:
----------------------------------------
Create the scoreboards (enter in chat):
/scoreboard objectives add damage_dealt minecraft.custom:minecraft.damage_dealt
/scoreboard objectives add damage_taken minecraft.custom:minecraft.damage_taken
/scoreboard objectives add is_seeker dummy
----------------------------------------
1st Command Block -> Repeating Command Block, Always Active:
execute if score @p[scores={damage_dealt=1..}] damage_dealt = @p[scores={damage_taken=1..}] damage_taken run scoreboard players set @p[scores={damage_taken=1..}] is_seeker 1
-> Place a Redstone Comparator directly on one side of this Command Block, facing away.
----------------------------------------
2nd Command Block -> (Impulse) Command Block, Needs Redstone
scoreboard players reset @a damage_dealt
-> Place this Command Block onto the other end of the Redstone Comparator, so the output of the comparator goes into this block.
----------------------------------------
3rd Command Block -> (Impulse) Command Block, Needs Redstone
scoreboard players reset @a damage_taken
-> Place this Command Block onto the other Impulse Command Block.
----------------------------------------
You can then use the scoreboard is_seeker to detect if a player was hit and apply the seeker tag according to your logic.
After the game ends, you need to reset the is_seeker scores of all players, preferably using a Command Block as well:
scoreboard players reset @a is_seeker
----------------------------------------
If you want to know more about these command in detail, or something else is unclear, let me know! (* ^ ω ^)
----------------------------------------
Create the scoreboards (enter in chat):
/scoreboard objectives add damage_dealt minecraft.custom:minecraft.damage_dealt
/scoreboard objectives add damage_taken minecraft.custom:minecraft.damage_taken
/scoreboard objectives add is_seeker dummy
----------------------------------------
1st Command Block -> Repeating Command Block, Always Active:
execute if score @p[scores={damage_dealt=1..}] damage_dealt = @p[scores={damage_taken=1..}] damage_taken run scoreboard players set @p[scores={damage_taken=1..}] is_seeker 1
-> Place a Redstone Comparator directly on one side of this Command Block, facing away.
----------------------------------------
2nd Command Block -> (Impulse) Command Block, Needs Redstone
scoreboard players reset @a damage_dealt
-> Place this Command Block onto the other end of the Redstone Comparator, so the output of the comparator goes into this block.
----------------------------------------
3rd Command Block -> (Impulse) Command Block, Needs Redstone
scoreboard players reset @a damage_taken
-> Place this Command Block onto the other Impulse Command Block.
----------------------------------------
You can then use the scoreboard is_seeker to detect if a player was hit and apply the seeker tag according to your logic.
After the game ends, you need to reset the is_seeker scores of all players, preferably using a Command Block as well:
scoreboard players reset @a is_seeker
----------------------------------------
If you want to know more about these command in detail, or something else is unclear, let me know! (* ^ ω ^)
There's a few ways, but the simplest for you (since you already have most of the code set up) is to use the /attribute command to keep their max health at half a heart so that they die from one punch
