Skip to content

Commit

Permalink
macro's everywhere!
Browse files Browse the repository at this point in the history
  • Loading branch information
TheThanathor committed Oct 27, 2023
1 parent 345a06e commit 3e3d713
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@

function gm4_combat_expanded:player/calculate_hp

# calculate amount of max_health to remove to get to new health
scoreboard players operation $remove_health gm4_ce_data = $max_health gm4_ce_data

scoreboard players operation $remove_health gm4_ce_data -= @s gm4_ce_health
scoreboard players operation @s gm4_ce_guard /= #10 gm4_ce_data
scoreboard players operation $remove_health gm4_ce_data += @s gm4_ce_guard
# store damage in storage
execute store result storage gm4_combat_expanded:temp damage_player.damage int 1 run scoreboard players operation @s gm4_ce_guard /= #10 gm4_ce_data

# sound
execute at @s run playsound minecraft:item.shield.block player @s ~ ~ ~ 0.4 0

# damage player if they are alive
execute if score $remove_health gm4_ce_data < $max_health gm4_ce_data run function gm4_combat_expanded:player/damage/apply
execute if score @s gm4_ce_guard < @s gm4_ce_health run function gm4_combat_expanded:player/damage with storage gm4_combat_expanded:temp damage_player

# kill player if health reached 0 (and player is alive)
execute if score @s gm4_ce_health matches 1.. if score $remove_health gm4_ce_data >= $max_health gm4_ce_data run function gm4_combat_expanded:armor/modifier/type/guardian/guard_death
execute if score @s gm4_ce_health matches 1.. if score @s gm4_ce_guard >= @s gm4_ce_health run function gm4_combat_expanded:armor/modifier/type/guardian/guard_death

# cleanup
data remove storage gm4_combat_expanded:temp damage_player.damage
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# run from armor/modifier/type/half/apply

scoreboard players operation $remove_health gm4_ce_data = @s gm4_ce_health
scoreboard players operation $remove_health gm4_ce_data -= $half_health gm4_ce_data

execute if score $remove_health gm4_ce_data matches 2.. run damage @s 2 out_of_world
execute if score $remove_health gm4_ce_data matches 1 run damage @s 1 out_of_world
execute store result storage gm4_combat_expanded:temp damage_player.damage int 1 run scoreboard players operation $remove_health gm4_ce_data -= $half_health gm4_ce_data
function gm4_combat_expanded:player/damage with storage gm4_combat_expanded:temp damage_player
data remove storage gm4_combat_expanded:temp damage_player.damage
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ scoreboard players operation @s gm4_ce_absorp += $level gm4_ce_data
scoreboard players set @s gm4_ce_t_reactive 37

# grant effect
function gm4_combat_expanded:player/shield_player
function gm4_combat_expanded:player/shield/prep
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
# damage player according to score
# damage player according to damage storage
# @s = player that is taking damage
# at unspecified
# run from armor/modifier/type/guardian/damage_calc
# run from armor/modifier/type/half/damage
# run from weapon/modifier/delay/explode_player

# lower player's health to their new health
execute if score $remove_health gm4_ce_data matches 512.. run damage @s 512 out_of_world
execute if score $remove_health gm4_ce_data matches 512.. run scoreboard players remove $remove_health gm4_ce_data 512
execute if score $remove_health gm4_ce_data matches 256.. run damage @s 256 out_of_world
execute if score $remove_health gm4_ce_data matches 256.. run scoreboard players remove $remove_health gm4_ce_data 256
execute if score $remove_health gm4_ce_data matches 128.. run damage @s 128 out_of_world
execute if score $remove_health gm4_ce_data matches 128.. run scoreboard players remove $remove_health gm4_ce_data 128
execute if score $remove_health gm4_ce_data matches 64.. run damage @s 64 out_of_world
execute if score $remove_health gm4_ce_data matches 64.. run scoreboard players remove $remove_health gm4_ce_data 64
execute if score $remove_health gm4_ce_data matches 32.. run damage @s 32 out_of_world
execute if score $remove_health gm4_ce_data matches 32.. run scoreboard players remove $remove_health gm4_ce_data 32
execute if score $remove_health gm4_ce_data matches 16.. run damage @s 16 out_of_world
execute if score $remove_health gm4_ce_data matches 16.. run scoreboard players remove $remove_health gm4_ce_data 16
execute if score $remove_health gm4_ce_data matches 8.. run damage @s 8 out_of_world
execute if score $remove_health gm4_ce_data matches 8.. run scoreboard players remove $remove_health gm4_ce_data 8
execute if score $remove_health gm4_ce_data matches 4.. run damage @s 4 out_of_world
execute if score $remove_health gm4_ce_data matches 4.. run scoreboard players remove $remove_health gm4_ce_data 4
execute if score $remove_health gm4_ce_data matches 2.. run damage @s 2 out_of_world
execute if score $remove_health gm4_ce_data matches 2.. run scoreboard players remove $remove_health gm4_ce_data 2
execute if score $remove_health gm4_ce_data matches 1.. run damage @s 1 out_of_world
$damage @s $(damage) out_of_world
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,10 @@
# calculate max health to get player to new health
scoreboard players operation $remove_health gm4_ce_data = $max_health gm4_ce_data
scoreboard players operation $remove_health gm4_ce_data -= @s gm4_ce_health
scoreboard players operation $remove_health gm4_ce_data -= @s gm4_ce_healstore
execute if score $remove_health gm4_ce_data matches ..-1 run scoreboard players set $remove_health gm4_ce_data 0
execute store result storage gm4_combat_expanded heal_player.remove_health int 1 run scoreboard players operation $remove_health gm4_ce_data -= @s gm4_ce_healstore

# lower player's max health to their new health
execute if score $remove_health gm4_ce_data matches 512.. run attribute @s minecraft:generic.max_health modifier add 8a3726c1-9a5c-4b10-86ba-b72a2540eeb2 "gm4_ce_remove_512" -512 add
execute if score $remove_health gm4_ce_data matches 512.. run scoreboard players remove $remove_health gm4_ce_data 512
execute if score $remove_health gm4_ce_data matches 256.. run attribute @s minecraft:generic.max_health modifier add 8c30a1b2-d915-4d46-93cc-49470b558bf9 "gm4_ce_remove_256" -256 add
execute if score $remove_health gm4_ce_data matches 256.. run scoreboard players remove $remove_health gm4_ce_data 256
execute if score $remove_health gm4_ce_data matches 128.. run attribute @s minecraft:generic.max_health modifier add 236c6079-0f55-4a22-b02d-2110b6a845fc "gm4_ce_remove_128" -128 add
execute if score $remove_health gm4_ce_data matches 128.. run scoreboard players remove $remove_health gm4_ce_data 128
execute if score $remove_health gm4_ce_data matches 64.. run attribute @s minecraft:generic.max_health modifier add 3017b672-58d6-451a-97cf-c3f4b08f6282 "gm4_ce_remove_64" -64 add
execute if score $remove_health gm4_ce_data matches 64.. run scoreboard players remove $remove_health gm4_ce_data 64
execute if score $remove_health gm4_ce_data matches 32.. run attribute @s minecraft:generic.max_health modifier add fc8491d8-e398-44ed-b79d-c0d6bc648501 "gm4_ce_remove_32" -32 add
execute if score $remove_health gm4_ce_data matches 32.. run scoreboard players remove $remove_health gm4_ce_data 32
execute if score $remove_health gm4_ce_data matches 16.. run attribute @s minecraft:generic.max_health modifier add 17948ed4-e422-47af-880e-7cc1a09cac92 "gm4_ce_remove_16" -16 add
execute if score $remove_health gm4_ce_data matches 16.. run scoreboard players remove $remove_health gm4_ce_data 16
execute if score $remove_health gm4_ce_data matches 8.. run attribute @s minecraft:generic.max_health modifier add edf68005-ec49-4e92-a311-2a54ea4870d9 "gm4_ce_remove_8" -8 add
execute if score $remove_health gm4_ce_data matches 8.. run scoreboard players remove $remove_health gm4_ce_data 8
execute if score $remove_health gm4_ce_data matches 4.. run attribute @s minecraft:generic.max_health modifier add 4bd118d8-a5dd-4bec-a93b-8d4daeab14be "gm4_ce_remove_4" -4 add
execute if score $remove_health gm4_ce_data matches 4.. run scoreboard players remove $remove_health gm4_ce_data 4
execute if score $remove_health gm4_ce_data matches 2.. run attribute @s minecraft:generic.max_health modifier add 0caacdc0-1ca3-4e75-90c4-2756efe9ca50 "gm4_ce_remove_2" -2 add
execute if score $remove_health gm4_ce_data matches 2.. run scoreboard players remove $remove_health gm4_ce_data 2
execute if score $remove_health gm4_ce_data matches 1.. run attribute @s minecraft:generic.max_health modifier add cb62a34a-4a87-4c18-b0a0-6bb31d2e9300 "gm4_ce_remove_1" -1 add
execute if score $remove_health gm4_ce_data matches 1.. run scoreboard players remove $remove_health gm4_ce_data 1
execute if score $remove_health gm4_ce_data matches 1.. run function gm4_combat_expanded:player/heal/eval with storage gm4_combat_expanded heal_player
data remove storage gm4_combat_expanded heal_player.remove_health

# prepare reverting
tag @s add gm4_ce_healed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# reduce max health of player to their new health
# @s = player to heal
# at unspecified
# run from armor/type/heal/activate

$attribute @s minecraft:generic.max_health modifier add 8a3726c1-9a5c-4b10-86ba-b72a2540eeb2 "gm4_ce_remove_health" -$(remove_health) add
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,4 @@

# revert max health
attribute @s minecraft:generic.max_health modifier remove 8a3726c1-9a5c-4b10-86ba-b72a2540eeb2
attribute @s minecraft:generic.max_health modifier remove 8c30a1b2-d915-4d46-93cc-49470b558bf9
attribute @s minecraft:generic.max_health modifier remove 236c6079-0f55-4a22-b02d-2110b6a845fc
attribute @s minecraft:generic.max_health modifier remove 3017b672-58d6-451a-97cf-c3f4b08f6282
attribute @s minecraft:generic.max_health modifier remove fc8491d8-e398-44ed-b79d-c0d6bc648501
attribute @s minecraft:generic.max_health modifier remove 17948ed4-e422-47af-880e-7cc1a09cac92
attribute @s minecraft:generic.max_health modifier remove edf68005-ec49-4e92-a311-2a54ea4870d9
attribute @s minecraft:generic.max_health modifier remove 4bd118d8-a5dd-4bec-a93b-8d4daeab14be
attribute @s minecraft:generic.max_health modifier remove 0caacdc0-1ca3-4e75-90c4-2756efe9ca50
attribute @s minecraft:generic.max_health modifier remove cb62a34a-4a87-4c18-b0a0-6bb31d2e9300

attribute @s minecraft:generic.max_health modifier remove 971283fb-1c05-429c-a266-9564f36f6ec1

tag @s remove gm4_ce_healed
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ execute if entity @s[tag=gm4_ce_immune_active] run function gm4_combat_expanded:
execute if predicate gm4_combat_expanded:modified_armor/wearing run function gm4_combat_expanded:armor/process

# shield players if they have stored shield
execute if score @s gm4_ce_absorp matches 1.. run function gm4_combat_expanded:player/shield_player
execute if score @s gm4_ce_absorp matches 1.. run function gm4_combat_expanded:player/shield/prep
# heal players if they have stored health
execute if score @s gm4_ce_healstore matches 1.. run function gm4_combat_expanded:player/heal/heal_calc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# give player absorption effect based on their score in gm4_ce_absorp
# @s = player to grant shield
# at unspecified
# run from player/shield/prep

$effect give @s absorption 30 $(shield) true
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# give player absorption effect based on their score in gm4_ce_absorp
# @s = player to grant shield
# at unspecified
# run from armor/modifier/type/reactive/add_level
# run from player/process

# remove one to match absorption level and store
execute store result storage gm4_combat_expanded player_shield.shield int 1 run scoreboard players remove @s gm4_ce_absorp 1

# clear absorption to stop bug (MC-182497)
effect clear @s absorption

# apply absorption
function gm4_combat_expanded:player/shield/eval with storage gm4_combat_expanded player_shield

# cleanup
data remove storage gm4_combat_expanded player_shield.shield
scoreboard players reset @s gm4_ce_absorp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@

function gm4_combat_expanded:player/calculate_hp

# calculate amount of max_health to remove to get to new health
scoreboard players operation $remove_health gm4_ce_data = $max_health gm4_ce_data

scoreboard players operation $remove_health gm4_ce_data -= @s gm4_ce_health
execute if entity @s[tag=gm4_cd_delay_lvl_1] run scoreboard players add $remove_health gm4_ce_data 6
execute if entity @s[tag=gm4_cd_delay_lvl_2] run scoreboard players add $remove_health gm4_ce_data 9
execute if entity @s[tag=gm4_cd_delay_lvl_3] run scoreboard players add $remove_health gm4_ce_data 12
execute if entity @s[tag=gm4_cd_delay_lvl_1] store result storage gm4_combat_expanded:temp damage_player.damage int 1 run scoreboard players set $delay_damage gm4_ce_data 6
execute if entity @s[tag=gm4_cd_delay_lvl_2] store result storage gm4_combat_expanded:temp damage_player.damage int 1 run scoreboard players set $delay_damage gm4_ce_data 9
execute if entity @s[tag=gm4_cd_delay_lvl_3] store result storage gm4_combat_expanded:temp damage_player.damage int 1 run scoreboard players set $delay_damage gm4_ce_data 12

# damage player if they are alive
execute if score $remove_health gm4_ce_data < $max_health gm4_ce_data run function gm4_combat_expanded:player/damage/apply
execute if score $delay_damage gm4_ce_data < @s gm4_ce_health run function gm4_combat_expanded:player/damage with storage gm4_combat_expanded:temp damage_player

# kill player if health reached 0
execute if score $remove_health gm4_ce_data >= $max_health gm4_ce_data run function gm4_combat_expanded:weapon/modifier/delay/player_death
execute if score $delay_damage gm4_ce_data >= s gm4_ce_health run function gm4_combat_expanded:weapon/modifier/delay/player_death

# reset entity
scoreboard players reset @s gm4_ce_t_delay
Expand All @@ -30,3 +26,6 @@ tag @s remove gm4_cd_delay_lvl_3
execute anchored eyes run particle minecraft:sweep_attack ^ ^ ^ 0.3 0.3 0.3 0.1 3
particle minecraft:cloud ~ ~0.5 ~ 0.4 0.2 0.4 0.2 8
playsound minecraft:block.bell.use player @a ~ ~ ~ 0.7 1.6

# cleanup
data remove storage gm4_combat_expanded:temp damage_player.damage

0 comments on commit 3e3d713

Please sign in to comment.