Skip to content

Commit

Permalink
add arrow augments
Browse files Browse the repository at this point in the history
  • Loading branch information
TheThanathor committed Sep 28, 2024
1 parent 6600dc4 commit 7f01851
Show file tree
Hide file tree
Showing 28 changed files with 804 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

tag @s add gm4_aa_archery_arrow

execute store success score $apply.blastshot gm4_aa_data if entity @s[tag=gm4_aa_blastshot_arrow]

data modify storage gm4_augmented_armor:temp archery_arrow set from entity @s {}

# multishot support (spawns half as many arrows)
execute store result score $pickup gm4_aa_data run data get storage gm4_augmented_armor:temp archery_arrow.pickup
execute unless score $pickup gm4_aa_data matches 1 run scoreboard players operation $archery_arrow_target gm4_aa_data /= #2 gm4_aa_data
execute unless score $pickup gm4_aa_data matches 1..2 run scoreboard players operation $archery_arrow_target gm4_aa_data /= #2 gm4_aa_data

function gm4_augmented_armor:armor/augment/type/archery/spawn_arrows
data remove storage gm4_augmented_armor:temp archery_arrow
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
# slightly adjust arrow motion
data modify storage gm4_augmented_armor:temp archery_arrow.Motion_adj set value [0.0d,0.0d,0.0d]

execute store result score $mot_adjust gm4_aa_data run random value -32..32
execute store result score $mot_adjust gm4_aa_data run random value -48..48
execute store result score $mot gm4_aa_data run data get storage gm4_augmented_armor:temp archery_arrow.Motion[0] 100
execute store result storage gm4_augmented_armor:temp archery_arrow.Motion_adj[0] double 0.01 run scoreboard players operation $mot gm4_aa_data += $mot_adjust gm4_aa_data

execute store result score $mot_adjust gm4_aa_data run random value -10..10
execute store result score $mot_adjust gm4_aa_data run random value -18..18
execute store result score $mot gm4_aa_data run data get storage gm4_augmented_armor:temp archery_arrow.Motion[1] 100
execute store result storage gm4_augmented_armor:temp archery_arrow.Motion_adj[1] double 0.01 run scoreboard players operation $mot gm4_aa_data += $mot_adjust gm4_aa_data

execute store result score $mot_adjust gm4_aa_data run random value -32..32
execute store result score $mot_adjust gm4_aa_data run random value -48..48
execute store result score $mot gm4_aa_data run data get storage gm4_augmented_armor:temp archery_arrow.Motion[2] 100
execute store result storage gm4_augmented_armor:temp archery_arrow.Motion_adj[2] double 0.01 run scoreboard players operation $mot gm4_aa_data += $mot_adjust gm4_aa_data

Expand All @@ -31,3 +31,6 @@ data modify entity @s item.components set from storage gm4_augmented_armor:temp

tag @s add gm4_aa_archery_arrow
tag @s add gm4_sr_arrow_checked

# apply buffs if needed
execute if score $apply.blastshot gm4_aa_data matches 1 run function gm4_augmented_armor:armor/augment/type/blastshot/prime
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

$damage @s $(damage) arrow by @p[tag=gm4_aa_augment_damager]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

# calculate and store damage of explosion
execute store result score $level gm4_aa_data run data get entity @s data.gm4_augmented_armor.blastshot_level
execute store result score $damage gm4_aa_data run data get entity @s data.gm4_augmented_armor.blastshot_damage
scoreboard players operation $damage gm4_aa_data *= $level gm4_aa_data
scoreboard players operation $damage gm4_aa_data /= #100 gm4_aa_data
execute store result storage gm4_augmented_armor:temp blastshot.damage float 0.1 run scoreboard players get $damage gm4_aa_data

# check if arrow just hit an entity or killed it
execute if score $landed gm4_aa_data matches 2 if entity @e[distance=..12,nbt={HurtTime:10s}] run scoreboard players set $landed gm4_aa_data 1

# tag the owner of the arrow to deal the damage from them
scoreboard players operation $id gm4_aa_data = @s gm4_aa_id
execute as @a if score @s gm4_aa_id = $id gm4_aa_data run tag @s add gm4_aa_augment_damager

# double radius if kill
execute unless score $landed gm4_aa_data matches 2 if entity @p[tag=gm4_aa_augment_damager] run function gm4_augmented_armor:armor/augment/type/blastshot/explode_normal
execute if score $landed gm4_aa_data matches 2 if entity @p[tag=gm4_aa_augment_damager] run function gm4_augmented_armor:armor/augment/type/blastshot/explode_big

# cleanup
tag @a remove gm4_aa_augment_damager
data remove storage gm4_augmented_armor:temp blastshot
execute on vehicle run kill @s
kill @s
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

execute as @e[predicate=gm4_augmented_armor:technical/pvp_able,distance=..9,tag=!gm4_aa_augment_damager] run function gm4_augmented_armor:armor/augment/type/blastshot/damage with storage gm4_augmented_armor:temp blastshot

# effects
playsound entity.generic.explode player @a[distance=..64] ~ ~ ~ 0.85 1.15 0.25
playsound entity.generic.explode player @a[distance=..64] ~ ~ ~ 1 1.025 0.5
particle explosion ~ ~ ~ 0.2 0.2 0.2 0.5 2 force @a[distance=..64]
particle explosion ~ ~ ~ 0.75 0.75 0.75 0.5 6 force @a[distance=..64]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

execute as @e[predicate=gm4_augmented_armor:technical/pvp_able,distance=..4.5,tag=!gm4_aa_augment_damager] run function gm4_augmented_armor:armor/augment/type/blastshot/damage with storage gm4_augmented_armor:temp blastshot

# effects
playsound entity.generic.explode player @a[distance=..64] ~ ~ ~ 0.85 1.15 0.25
particle explosion ~ ~ ~ 0.2 0.2 0.2 0.5 2 force @a[distance=..64]
particle explosion ~ ~ ~ 0.5 0.5 0.5 0.5 2 force @a[distance=..64]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

# store armor for checking
item replace block 29999998 1 7134 container.0 from entity @s armor.head
item replace block 29999998 1 7134 container.1 from entity @s armor.chest
item replace block 29999998 1 7134 container.2 from entity @s armor.legs
item replace block 29999998 1 7134 container.3 from entity @s armor.feet
data modify storage gm4_augmented_armor:temp Items set from block 29999998 1 7134 Items
data remove block 29999998 1 7134 Items

# get total blastshot level
scoreboard players set $blastshot_level gm4_aa_data 0

scoreboard players set $add_blastshot_level gm4_aa_data 0
execute if data storage gm4_augmented_armor:temp Items[{Slot:0b}].components."minecraft:custom_data".gm4_augmented_armor{augment:{name:blastshot}} store result score $add_blastshot_level gm4_aa_data run data get storage gm4_augmented_armor:temp Items[{Slot:0b}].components."minecraft:custom_data".gm4_augmented_armor.levels[0]
scoreboard players operation $blastshot_level gm4_aa_data += $add_blastshot_level gm4_aa_data

scoreboard players set $add_blastshot_level gm4_aa_data 0
execute if data storage gm4_augmented_armor:temp Items[{Slot:1b}].components."minecraft:custom_data".gm4_augmented_armor{augment:{name:blastshot}} store result score $add_blastshot_level gm4_aa_data run data get storage gm4_augmented_armor:temp Items[{Slot:1b}].components."minecraft:custom_data".gm4_augmented_armor.levels[0]
scoreboard players operation $blastshot_level gm4_aa_data += $add_blastshot_level gm4_aa_data

scoreboard players set $add_blastshot_level gm4_aa_data 0
execute if data storage gm4_augmented_armor:temp Items[{Slot:2b}].components."minecraft:custom_data".gm4_augmented_armor{augment:{name:blastshot}} store result score $add_blastshot_level gm4_aa_data run data get storage gm4_augmented_armor:temp Items[{Slot:2b}].components."minecraft:custom_data".gm4_augmented_armor.levels[0]
scoreboard players operation $blastshot_level gm4_aa_data += $add_blastshot_level gm4_aa_data

scoreboard players set $add_blastshot_level gm4_aa_data 0
execute if data storage gm4_augmented_armor:temp Items[{Slot:3b}].components."minecraft:custom_data".gm4_augmented_armor{augment:{name:blastshot}} store result score $add_blastshot_level gm4_aa_data run data get storage gm4_augmented_armor:temp Items[{Slot:3b}].components."minecraft:custom_data".gm4_augmented_armor.levels[0]
scoreboard players operation $blastshot_level gm4_aa_data += $add_blastshot_level gm4_aa_data

# spawn arrows
scoreboard players operation $id gm4_aa_data = @s gm4_aa_id
execute as @n[type=#gm4_survival_refightalized:arrow,tag=gm4_sr_current_arrow] at @s run function gm4_augmented_armor:armor/augment/type/blastshot/prime

# cleanup
data remove storage gm4_augmented_armor:temp Items
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

# make marker ride arrow
ride @s mount @n[type=#gm4_augmented_armor:arrow,tag=gm4_aa_target,distance=..0.1]
tag @s add gm4_aa_process_marker.tick
tag @s add gm4_aa_process_marker.blastshot

# store blast damage, arrow motion and level in marker in case arrow hits an entity
execute store result entity @s data.gm4_augmented_armor.blastshot_damage int 1 on vehicle run data get entity @s damage 500
execute store result entity @s data.gm4_augmented_armor.blastshot_level int 1 run scoreboard players get $blastshot_level gm4_aa_data

# set id to track owner
scoreboard players operation @s gm4_aa_id = $id gm4_aa_data
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

# add a marker to track the arrow
tag @s add gm4_aa_target
execute summon marker run function gm4_augmented_armor:armor/augment/type/blastshot/init_marker
tag @s remove gm4_aa_target

tag @s add gm4_aa_blastshot_arrow
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

# check if arrow is still in flight
scoreboard players set $landed gm4_aa_data 2
execute store result score $landed gm4_aa_data on vehicle run data get entity @s inGround

# explode if arrow has landed or hot something
execute if score $landed gm4_aa_data matches 1.. run return run function gm4_augmented_armor:armor/augment/type/blastshot/explode

# update damage in case its changing mid-flight (from other modifiers)
execute store result entity @s data.gm4_augmented_armor.blastshot_damage int 1 on vehicle run data get entity @s damage 500
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ scoreboard players operation $damage gm4_aa_data *= $level gm4_aa_data
scoreboard players operation $damage gm4_aa_data /= #100 gm4_aa_data

# if marker was just spawned add damage to it instead (to stack multiple pieces together)
execute if score @s gm4_aa_augment.gleaming.timer = @s gm4_aa_augment.gleaming.timer_full as @n[type=marker,tag=gm4_aa_gleaming.marker,distance=..0.01] if score @s gm4_aa_augment.gleaming.timer = @s gm4_aa_augment.gleaming.timer_full run scoreboard players operation @s gm4_aa_augment.gleaming.damage += $damage gm4_aa_data
execute if score @s gm4_aa_augment.gleaming.timer = @s gm4_aa_augment.gleaming.timer_full as @n[type=marker,tag=gm4_aa_process_marker.gleaming,distance=..0.01] if score @s gm4_aa_augment.gleaming.timer = @s gm4_aa_augment.gleaming.timer_full run scoreboard players operation @s gm4_aa_augment.gleaming.damage += $damage gm4_aa_data
execute if score @s gm4_aa_augment.gleaming.timer matches 1.. run return 0

# attack reach = 150% of player attack range
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

data modify entity @s data.gm4_augmented_armor.UUID set from entity @p[tag=gm4_aa_self] UUID

tag @s add gm4_aa_gleaming.marker
tag @s add gm4_aa_process_marker.tick
tag @s add gm4_aa_process_marker.gleaming

# set reach
scoreboard players operation @s gm4_aa_augment.gleaming.reach = $attack_reach gm4_aa_data
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

# check the bonus damage that is allowed to added in total (x100)
scoreboard players set @s gm4_aa_augment.hawkeye.max_damage 20
scoreboard players operation @s gm4_aa_augment.hawkeye.max_damage *= $hawkeye_level gm4_aa_data
# add original damage (x100) to get final max damage this arrow can do
scoreboard players operation $original_damage gm4_aa_data = $arrow_damage gm4_sr_data
scoreboard players operation $original_damage gm4_aa_data *= #100 gm4_aa_data
scoreboard players operation @s gm4_aa_augment.hawkeye.max_damage += $original_damage gm4_aa_data
# store on arrow for later
scoreboard players operation @s gm4_aa_augment.hawkeye.count = $hawkeye_count gm4_aa_data

# add tags and start a clock
tag @s add gm4_aa_hawkeye_arrow
tag @s add gm4_aa_hawkeye_arrow.process
execute unless score $keep_tick.hawkeye gm4_aa_keep_tick matches 1 run schedule function gm4_augmented_armor:clocks/temp/hawkeye 1t
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

# store armor for checking
item replace block 29999998 1 7134 container.0 from entity @s armor.head
item replace block 29999998 1 7134 container.1 from entity @s armor.chest
item replace block 29999998 1 7134 container.2 from entity @s armor.legs
item replace block 29999998 1 7134 container.3 from entity @s armor.feet
data modify storage gm4_augmented_armor:temp Items set from block 29999998 1 7134 Items
data remove block 29999998 1 7134 Items

# check amount of archer pieces
# original target is set to -1 as the first arrow does not need to be counted
scoreboard players set $hawkeye_level gm4_aa_data 0
scoreboard players set $hawkeye_count gm4_aa_data 0

scoreboard players set $add_hawkeye_level gm4_aa_data 0
execute if data storage gm4_augmented_armor:temp Items[{Slot:0b}].components."minecraft:custom_data".gm4_augmented_armor{augment:{name:hawkeye}} store result score $add_hawkeye_level gm4_aa_data run data get storage gm4_augmented_armor:temp Items[{Slot:0b}].components."minecraft:custom_data".gm4_augmented_armor.levels[0]
scoreboard players operation $hawkeye_level gm4_aa_data += $add_hawkeye_level gm4_aa_data
execute if score $add_hawkeye_level gm4_aa_data matches 1.. run scoreboard players add $hawkeye_count gm4_aa_data 20

scoreboard players set $add_hawkeye_level gm4_aa_data 0
execute if data storage gm4_augmented_armor:temp Items[{Slot:1b}].components."minecraft:custom_data".gm4_augmented_armor{augment:{name:hawkeye}} store result score $add_hawkeye_level gm4_aa_data run data get storage gm4_augmented_armor:temp Items[{Slot:1b}].components."minecraft:custom_data".gm4_augmented_armor.levels[0]
scoreboard players operation $hawkeye_level gm4_aa_data += $add_hawkeye_level gm4_aa_data
execute if score $add_hawkeye_level gm4_aa_data matches 1.. run scoreboard players add $hawkeye_count gm4_aa_data 20

scoreboard players set $add_hawkeye_level gm4_aa_data 0
execute if data storage gm4_augmented_armor:temp Items[{Slot:2b}].components."minecraft:custom_data".gm4_augmented_armor{augment:{name:hawkeye}} store result score $add_hawkeye_level gm4_aa_data run data get storage gm4_augmented_armor:temp Items[{Slot:2b}].components."minecraft:custom_data".gm4_augmented_armor.levels[0]
scoreboard players operation $hawkeye_level gm4_aa_data += $add_hawkeye_level gm4_aa_data
execute if score $add_hawkeye_level gm4_aa_data matches 1.. run scoreboard players add $hawkeye_count gm4_aa_data 20

scoreboard players set $add_hawkeye_level gm4_aa_data 0
execute if data storage gm4_augmented_armor:temp Items[{Slot:3b}].components."minecraft:custom_data".gm4_augmented_armor{augment:{name:hawkeye}} store result score $add_hawkeye_level gm4_aa_data run data get storage gm4_augmented_armor:temp Items[{Slot:3b}].components."minecraft:custom_data".gm4_augmented_armor.levels[0]
scoreboard players operation $hawkeye_level gm4_aa_data += $add_hawkeye_level gm4_aa_data
execute if score $add_hawkeye_level gm4_aa_data matches 1.. run scoreboard players add $hawkeye_count gm4_aa_data 20

# prep arrow
execute as @n[type=#gm4_survival_refightalized:arrow,tag=gm4_sr_current_arrow] at @s run function gm4_augmented_armor:armor/augment/type/hawkeye/apply

# cleanup
data remove storage gm4_augmented_armor:temp Items
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# in ground no longer process this arrow
execute store result score $in_ground gm4_aa_data run data get entity @s inGround
execute if score $in_ground gm4_aa_data matches 1 run return run tag @s remove gm4_aa_hawkeye_arrow.process

# add damage to arrow
execute store result score $damage gm4_aa_data run data get entity @s damage 1000
execute store result entity @s damage float 0.001 run scoreboard players operation $damage gm4_aa_data += @s gm4_aa_augment.hawkeye.count

# if damage reached max stop processing this arrow
execute if score $damage gm4_aa_data >= @s gm4_aa_augment.hawkeye.max_damage run return run tag @s remove gm4_aa_hawkeye_arrow.process

# keep clock on
scoreboard players set $keep_tick.hawkeye gm4_aa_keep_tick 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

# alter motion with reduction
execute store result score $mot_x gm4_aa_data run data get entity @s Motion[0] 1000
execute store result score $mot_y gm4_aa_data run data get entity @s Motion[1] 1000
execute store result score $mot_z gm4_aa_data run data get entity @s Motion[2] 1000

scoreboard players operation $mot_x_change gm4_aa_data = $mot_x gm4_aa_data
scoreboard players operation $mot_y_change gm4_aa_data = $mot_y gm4_aa_data
scoreboard players operation $mot_z_change gm4_aa_data = $mot_z gm4_aa_data
scoreboard players operation $mot_x_change gm4_aa_data *= $motion_reduction gm4_aa_data
scoreboard players operation $mot_y_change gm4_aa_data *= $motion_reduction gm4_aa_data
scoreboard players operation $mot_z_change gm4_aa_data *= $motion_reduction gm4_aa_data
scoreboard players operation $mot_x_change gm4_aa_data /= #100 gm4_aa_data
scoreboard players operation $mot_y_change gm4_aa_data /= #100 gm4_aa_data
scoreboard players operation $mot_z_change gm4_aa_data /= #100 gm4_aa_data
scoreboard players operation $mot_x gm4_aa_data += $mot_x_change gm4_aa_data
scoreboard players operation $mot_y gm4_aa_data += $mot_y_change gm4_aa_data
scoreboard players operation $mot_z gm4_aa_data += $mot_z_change gm4_aa_data

execute store result entity @s Motion[0] double 0.001 run scoreboard players get $mot_x gm4_aa_data
execute store result entity @s Motion[1] double 0.001 run scoreboard players get $mot_y gm4_aa_data
execute store result entity @s Motion[2] double 0.001 run scoreboard players get $mot_z gm4_aa_data
Loading

0 comments on commit 7f01851

Please sign in to comment.