Skip to content

Commit

Permalink
refactor how random numbers are generated. Much more streamlined
Browse files Browse the repository at this point in the history
  • Loading branch information
Frustrated-Programmer committed Jul 10, 2024
1 parent 5b27bfa commit 57e9635
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 218 deletions.
3 changes: 1 addition & 2 deletions Brilliance Datapack/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
- Randomly determine TIME of day, instead of just day/night
- Automate do2.lifetime.escaped.crowns
- Actually... is this score needed? It's essentially crowns spent + whatever crowns they have on them.
- Automate do2.lifetime.escaped.embers
- Actually... is this score needed? It's essentially embers spent...

- Track embers DROPPED in dungeon
- Track embers ATTEMPTED to be RELEASED.
- Track treasure DROPPED in dungoen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ function do2:scoreboard/config/balance_changes/actions

# Other Setup:
function do2:scoreboard/config/config_setup
function do2:random_gen/random_setup

# Whether Max Clank Disables Treasure
execute if score $dungeon do2.config.maxClankTreasure matches 1 run setblock -624 25 1990 minecraft:redstone_wire
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Whether it's DAY or NIGHT.
time set noon
function do2:random_gen/gen_random_percentage
execute if score @e[type=marker,tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum < $dungeon do2.config.nightTimeChance run time set night
scoreboard players set $dungeon do2.utility.randomNumberRange 100
function do2:random_gen/generate_random_number
execute if score $dungeon do2.utility.randomNum < $dungeon do2.config.nightTimeChance run time set night

# - Start Log -
execute unless score @e[type=marker,tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum < $dungeon do2.config.nightTimeChance as @a[scores={do2.logs.dungeon_setup=1..}] run tellraw @s ["",{"text":"§f[§9B§f]: Time of day randomly set to: §eDAY §r("},{"text":" ? ","color":"dark_red","hoverEvent":{"action":"show_text","contents":["",{"text":"§fChance of Night Time: "},{"score":{"name":"$dungeon","objective":"do2.config.nightTimeChance"},"color":"aqua"},{"text":"§b%\n§fRandomly Generated Number: "},{"color":"aqua","score":{"name":"@e[type=marker,tag=RandomGenerator_RESULT,limit=1]","objective":"do2.utility.randomNum"}}]}},{"text":")"}]
execute if score @e[type=marker,tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum < $dungeon do2.config.nightTimeChance as @a[scores={do2.logs.dungeon_setup=1..}] run tellraw @s ["",{"text":"§f[§9B§f]: Time of day randomly set to: §8NIGHT §r("},{"text":" ? ","color":"dark_red","hoverEvent":{"action":"show_text","contents":["",{"text":"§fChance of Night Time: "},{"score":{"name":"$dungeon","objective":"do2.config.nightTimeChance"},"color":"aqua"},{"text":"§b%\n§fRandomly Generated Number: "},{"color":"aqua","score":{"name":"@e[type=marker,tag=RandomGenerator_RESULT,limit=1]","objective":"do2.utility.randomNum"}}]}},{"text":")"}]
execute unless score $dungeon do2.utility.randomNum < $dungeon do2.config.nightTimeChance as @a[scores={do2.logs.dungeon_setup=1..}] run tellraw @s ["",{"text":"§f[§9B§f]: Time of day randomly set to: §eDAY §r("},{"text":" ? ","color":"dark_red","hoverEvent":{"action":"show_text","contents":["",{"text":"§fChance of Night Time: "},{"score":{"name":"$dungeon","objective":"do2.config.nightTimeChance"},"color":"aqua"},{"text":"§b%\n§fRandomly Generated Number: "},{"color":"aqua","score":{"name":"$dungeon","objective":"do2.utility.randomNum"}}]}},{"text":")"}]
execute if score $dungeon do2.utility.randomNum < $dungeon do2.config.nightTimeChance as @a[scores={do2.logs.dungeon_setup=1..}] run tellraw @s ["",{"text":"§f[§9B§f]: Time of day randomly set to: §8NIGHT §r("},{"text":" ? ","color":"dark_red","hoverEvent":{"action":"show_text","contents":["",{"text":"§fChance of Night Time: "},{"score":{"name":"$dungeon","objective":"do2.config.nightTimeChance"},"color":"aqua"},{"text":"§b%\n§fRandomly Generated Number: "},{"color":"aqua","score":{"name":"$dungeon","objective":"do2.utility.randomNum"}}]}},{"text":")"}]
# - End Log -
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Preset 256
scoreboard players set $num do2.utility.fishVariant 256

# Determine pattern color
scoreboard players set $dungeon do2.utility.randomNumberRange 16
function do2:random_gen/generate_random_number
scoreboard players operation $dungeon do2.utility.fishVariant += $dungeon do2.utility.randomNum
scoreboard players operation $dungeon do2.utility.fishVariant *= $num do2.utility.fishVariant

# Determine base color
scoreboard players set $dungeon do2.utility.randomNumberRange 16
function do2:random_gen/generate_random_number
scoreboard players operation $dungeon do2.utility.fishVariant += $dungeon do2.utility.randomNum
scoreboard players operation $dungeon do2.utility.fishVariant *= $num do2.utility.fishVariant

# Add fish pattern
scoreboard players set $dungeon do2.utility.randomNumberRange 6
function do2:random_gen/generate_random_number
scoreboard players operation $dungeon do2.utility.fishVariant += $dungeon do2.utility.randomNum
scoreboard players operation $dungeon do2.utility.fishVariant *= $num do2.utility.fishVariant

# Add fish Size
scoreboard players set $dungeon do2.utility.randomNumberRange 2
function do2:random_gen/generate_random_number
scoreboard players operation $dungeon do2.utility.fishVariant += $dungeon do2.utility.randomNum




This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,49 +1,27 @@
scoreboard players set @e[type=marker,tag=RandomGenerator_RESULT] do2.utility.randomNum 0
tag @e[tag=RandomGenerator_Using] remove RandomGenerator_Using
tag @e[tag=RandomGenerator_0] add RandomGenerator_Using
tag @e[tag=RandomGenerator_1] add RandomGenerator_Using
tag @e[tag=RandomGenerator_2] add RandomGenerator_Using
tag @e[tag=RandomGenerator_3] add RandomGenerator_Using
tag @e[tag=RandomGenerator_4] add RandomGenerator_Using
tag @e[tag=RandomGenerator_5] add RandomGenerator_Using
tag @e[tag=RandomGenerator_6] add RandomGenerator_Using
tag @e[tag=RandomGenerator_7] add RandomGenerator_Using
tag @e[tag=RandomGenerator_8] add RandomGenerator_Using
tag @e[tag=RandomGenerator_9] add RandomGenerator_Using
tag @e[tag=RandomGenerator_10] add RandomGenerator_Using
tag @e[tag=RandomGenerator_11] add RandomGenerator_Using
tag @e[tag=RandomGenerator_12] add RandomGenerator_Using
tag @e[tag=RandomGenerator_13] add RandomGenerator_Using
tag @e[tag=RandomGenerator_14] add RandomGenerator_Using
tag @e[tag=RandomGenerator_15] add RandomGenerator_Using
tag @e[tag=RandomGenerator_16] add RandomGenerator_Using
tag @e[tag=RandomGenerator_17] add RandomGenerator_Using
tag @e[tag=RandomGenerator_18] add RandomGenerator_Using
tag @e[tag=RandomGenerator_19] add RandomGenerator_Using
tag @e[tag=RandomGenerator_20] add RandomGenerator_Using
tag @e[tag=RandomGenerator_21] add RandomGenerator_Using
scoreboard players operation @e[type=marker,tag=RandomGenerator_RESULT] do2.utility.randomNum += @e[type=marker,tag=RandomGenerator_Using,limit=1,sort=random] do2.utility.randomNum

execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 0 run summon minecraft:tropical_fish ~ ~ ~ {Variant:65536,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 1 run summon minecraft:tropical_fish ~ ~ ~ {Variant:459008,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 2 run summon minecraft:tropical_fish ~ ~ ~ {Variant:917504,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 3 run summon minecraft:tropical_fish ~ ~ ~ {Variant:918273,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 4 run summon minecraft:tropical_fish ~ ~ ~ {Variant:918529,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 5 run summon minecraft:tropical_fish ~ ~ ~ {Variant:16778497,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 6 run summon minecraft:tropical_fish ~ ~ ~ {Variant:50660352,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 7 run summon minecraft:tropical_fish ~ ~ ~ {Variant:50726144,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 8 run summon minecraft:tropical_fish ~ ~ ~ {Variant:67108865,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 9 run summon minecraft:tropical_fish ~ ~ ~ {Variant:67110144,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 10 run summon minecraft:tropical_fish ~ ~ ~ {Variant:67371009,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 11 run summon minecraft:tropical_fish ~ ~ ~ {Variant:67699456,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 12 run summon minecraft:tropical_fish ~ ~ ~ {Variant:67764993,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 13 run summon minecraft:tropical_fish ~ ~ ~ {Variant:101253888,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 14 run summon minecraft:tropical_fish ~ ~ ~ {Variant:117441025,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 15 run summon minecraft:tropical_fish ~ ~ ~ {Variant:117441793,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 16 run summon minecraft:tropical_fish ~ ~ ~ {Variant:117506305,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 17 run summon minecraft:tropical_fish ~ ~ ~ {Variant:117899265,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 18 run summon minecraft:tropical_fish ~ ~ ~ {Variant:118161664,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 19 run summon minecraft:tropical_fish ~ ~ ~ {Variant:185008129,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 20 run summon minecraft:tropical_fish ~ ~ ~ {Variant:234882305,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 21 run summon minecraft:tropical_fish ~ ~ ~ {Variant:235340288,Tags:["do2.manually_spawned"]}
execute if score @e[tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 22.. run function do2:mob_spawning/fish_counts/summon_common_variant
scoreboard players set $dungeon do2.utility.randomNumberRange 22
function do2:random_gen/generate_random_number

execute if score $dungeon do2.utility.randomNum matches 0 run summon minecraft:tropical_fish ~ ~ ~ {Variant:65536,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 1 run summon minecraft:tropical_fish ~ ~ ~ {Variant:459008,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 2 run summon minecraft:tropical_fish ~ ~ ~ {Variant:917504,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 3 run summon minecraft:tropical_fish ~ ~ ~ {Variant:918273,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 4 run summon minecraft:tropical_fish ~ ~ ~ {Variant:918529,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 5 run summon minecraft:tropical_fish ~ ~ ~ {Variant:16778497,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 6 run summon minecraft:tropical_fish ~ ~ ~ {Variant:50660352,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 7 run summon minecraft:tropical_fish ~ ~ ~ {Variant:50726144,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 8 run summon minecraft:tropical_fish ~ ~ ~ {Variant:67108865,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 9 run summon minecraft:tropical_fish ~ ~ ~ {Variant:67110144,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 10 run summon minecraft:tropical_fish ~ ~ ~ {Variant:67371009,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 11 run summon minecraft:tropical_fish ~ ~ ~ {Variant:67699456,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 12 run summon minecraft:tropical_fish ~ ~ ~ {Variant:67764993,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 13 run summon minecraft:tropical_fish ~ ~ ~ {Variant:101253888,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 14 run summon minecraft:tropical_fish ~ ~ ~ {Variant:117441025,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 15 run summon minecraft:tropical_fish ~ ~ ~ {Variant:117441793,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 16 run summon minecraft:tropical_fish ~ ~ ~ {Variant:117506305,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 17 run summon minecraft:tropical_fish ~ ~ ~ {Variant:117899265,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 18 run summon minecraft:tropical_fish ~ ~ ~ {Variant:118161664,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 19 run summon minecraft:tropical_fish ~ ~ ~ {Variant:185008129,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 20 run summon minecraft:tropical_fish ~ ~ ~ {Variant:234882305,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 21 run summon minecraft:tropical_fish ~ ~ ~ {Variant:235340288,Tags:["do2.manually_spawned"]}
execute if score $dungeon do2.utility.randomNum matches 22.. run function do2:mob_spawning/fish_counts/summon_common_variant
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
function do2:random_gen/get_random_num
execute if score @e[type=marker,tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches ..8 run function do2:mob_spawning/fish_counts/summon_common_variant
execute if score @e[type=marker,tag=RandomGenerator_RESULT,limit=1] do2.utility.randomNum matches 9.. run function do2:mob_spawning/fish_counts/summon_random_variant
scoreboard players set $dungeon do2.utility.randomNumberRange 10
function do2:random_gen/generate_random_number
execute if score $dungeon do2.utility.randomNum matches ..8 run function do2:mob_spawning/fish_counts/summon_common_variant
execute if score $dungeon do2.utility.randomNum matches 9.. run function do2:mob_spawning/fish_counts/summon_random_variant
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
summon minecraft:tropical_fish ~ ~ ~ {Variant:235340288,Tags:["determine_variant","do2.manually_spawned"]}
function do2:mob_spawning/fish_counts/determine_variant/determine_variant
function do2:mob_spawning/fish_counts//determine_variant
execute store result entity @e[type=minecraft:tropical_fish,tag=determine_variant,limit=1] Variant double 1 run scoreboard players get $dungeon do2.utility.fishVariant
tag @e[type=minecraft:tropical_fish,tag=determine_variant] remove determine_variant
Loading

0 comments on commit 57e9635

Please sign in to comment.