I am trying to generate a function that modifies a player's attributes based on some scaling factor.
I set up two scoreboard objectives:
/scoreboard objectives add Attribute dummy
/scoreboard objectives add Scale dummy
The way the function works is by running two commands: (1) store the base value for a particular attribute on the scoreboard under the objective Attribute, then (2) multiply the score of the objective Attribute by the score of the objective Scale to produce a modified Attribute score. This part of the function works fine, and successfully stores the scaled up attribute on the scoreboard under the objective Attribute.
(1) execute store result score @s Attribute run attribute @s <attribute> base get
For example: If the base value for generic.max_health is 20, and I wish to scale it by 2, the final result of running the above function would be an Attribute score of 40.
The problem that I am having now is adjusting the actual player attributes according to the modified Attribute score. I cannot use /data to modify player nbt, and there is no method of using /attribute to set the new base value according to a score (at least, I am not aware of a method). How would I be able to achieve this?
To do this, you will need to use a datapack and macros.
1. Perform the math In a scoreboard like you are doing now
2. Store the proper values with /data modify storage
3. Use a macro, something like: $attribute @s minecraft:generic.attack_damage base set $(value)
Hello,
I am trying to generate a function that modifies a player's attributes based on some scaling factor.
I set up two scoreboard objectives:
/scoreboard objectives add Attribute dummy
/scoreboard objectives add Scale dummy
The way the function works is by running two commands: (1) store the base value for a particular attribute on the scoreboard under the objective Attribute, then (2) multiply the score of the objective Attribute by the score of the objective Scale to produce a modified Attribute score. This part of the function works fine, and successfully stores the scaled up attribute on the scoreboard under the objective Attribute.
(1) execute store result score @s Attribute run attribute @s <attribute> base get
(2) scoreboard players operation @s Attribute *= @s Scale
For example: If the base value for generic.max_health is 20, and I wish to scale it by 2, the final result of running the above function would be an Attribute score of 40.
The problem that I am having now is adjusting the actual player attributes according to the modified Attribute score. I cannot use /data to modify player nbt, and there is no method of using /attribute to set the new base value according to a score (at least, I am not aware of a method). How would I be able to achieve this?
Thank you for any help
The Big Dog
Hello,
To do this, you will need to use a datapack and macros.
Here is a great intro resource into macros:
Hope this helps!
-TechnoBro03