Skip to content

Commit 1f357eb

Browse files
authored
✨ HealAPI で超過回復量・回復前の体力を取得できるように (#2174)
1 parent 963b137 commit 1f357eb

6 files changed

Lines changed: 69 additions & 16 deletions

File tree

TheSkyBlessing/data/api/functions/heal/_index.d.mcfunction

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@
55
# @within function api:heal/core/**
66
#declare score_holder $LatestModifiedUser
77
#declare score_holder $ModifierIndex
8+
9+
#> 超過回復量
10+
# @within function api:heal/core/push_heal_events/**
11+
#declare score_holder $OverHeal
12+
#declare score_holder $MaxHealth
13+
#declare score_holder $CurrentHealth

TheSkyBlessing/data/api/functions/heal/core/push_heal_events/.mcfunction

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@
44
#
55
# @within function api:heal/core/player
66

7-
#> Private
8-
# @within api:heal/core/push_heal_events/*
9-
#declare score_holder $ReceiverUUID
7+
# 現在体力の取得
8+
function api:data_get/health
9+
10+
# 超過回復量の計算
11+
function api:heal/core/push_heal_events/calc_over_heal
1012

1113
# ヒールされた側にイベントを追加する
1214
function oh_my_dat:please
1315
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.ReceiveHeal append value {}
14-
execute store result storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.ReceiveHeal[-1].Amount double 0.01 run data get storage api: Argument.Fluctuation 100
16+
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.ReceiveHeal[-1].Amount.Base set from storage api: Argument.Fluctuation
17+
execute store result storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.ReceiveHeal[-1].Amount.Over float 0.01 run scoreboard players get $OverHeal Temporary
18+
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.ReceiveHeal[-1].PreviousHealth set from storage api: Health
1519
execute if data storage api: Argument{ApplyTrigger:true} run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.ReceiveHeal[-1].IsHoT set value false
1620
execute if data storage api: Argument{ApplyTrigger:false} run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.ReceiveHeal[-1].IsHoT set value true
1721
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.ReceiveHeal[-1].Metadata set from storage api: Argument.Metadata
1822

19-
# ApplyTriggerがtrueでないなら与回復トリガーは実行しない
20-
execute unless data storage api: Argument{ApplyTrigger:true} run return fail
23+
# ApplyTriggerがtrueなら、ヒールした側からトリガーをpushする
24+
execute if data storage api: Argument{ApplyTrigger:true} run function api:heal/core/push_heal_events/from_healer/
2125

22-
# ヒールした側から行う処理
23-
scoreboard players operation $ReceiverUUID Temporary = @s UserID
24-
execute as @a if score @s UserID = $LatestModifiedUser UserID run function api:heal/core/push_heal_events/healer
25-
scoreboard players reset $ReceiverUUID Temporary
26+
# リセット
27+
scoreboard players reset $OverHeal Temporary
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#> api:heal/core/push_heal_events/calc_over_heal
2+
#
3+
# 超過回復量を計算
4+
#
5+
# @within function api:heal/core/push_heal_events/
6+
7+
# 必要な値を取得
8+
execute store result score $OverHeal Temporary run data get storage api: Argument.Fluctuation 100
9+
execute store result score $MaxHealth Temporary run attribute @s generic.max_health get 100
10+
execute store result score $CurrentHealth Temporary run data get storage api: Health 100
11+
12+
# 計算
13+
# OverHeal = (CurrentHealth + Heal) - MaxHealth
14+
scoreboard players operation $OverHeal Temporary += $CurrentHealth Temporary
15+
scoreboard players operation $OverHeal Temporary -= $MaxHealth Temporary
16+
17+
# 0未満なら0にする
18+
scoreboard players operation $OverHeal Temporary > $0 Const
19+
20+
# リセット
21+
scoreboard players reset $MaxHealth Temporary
22+
scoreboard players reset $CurrentHealth Temporary
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#> api:heal/core/push_heal_events/from_healer/
2+
#
3+
#
4+
#
5+
# @within function api:heal/core/push_heal_events/
6+
7+
#> Private
8+
# @within function api:heal/core/push_heal_events/from_healer/*
9+
#declare score_holder $ReceiverUUID
10+
11+
scoreboard players operation $ReceiverUUID Temporary = @s UserID
12+
execute as @a if score @s UserID = $LatestModifiedUser UserID run function api:heal/core/push_heal_events/from_healer/push
13+
scoreboard players reset $ReceiverUUID Temporary

TheSkyBlessing/data/api/functions/heal/core/push_heal_events/healer.mcfunction renamed to TheSkyBlessing/data/api/functions/heal/core/push_heal_events/from_healer/push.mcfunction

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#> api:heal/core/push_heal_events/healer
1+
#> api:heal/core/push_heal_events/from_healer/push
22
#
33
#
44
#
5-
# @within function api:heal/core/push_heal_events/
5+
# @within function api:heal/core/push_heal_events/from_healer/
66

77
#> Private
88
# @private
@@ -18,8 +18,12 @@
1818
execute unless score $LastIndex Temporary = $ModifierIndex Global run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.Heal append value {}
1919
execute unless score $LastIndex Temporary = $ModifierIndex Global run execute store result storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.Heal[-1].Index int 1 run scoreboard players get $ModifierIndex Global
2020
# ヒール対象に追加する
21-
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.Heal[-1].Amounts append value -1d
22-
execute store result storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.Heal[-1].Amounts[-1] double 0.01 run data get storage api: Argument.Fluctuation 100
21+
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.Heal[-1].Amounts.Base append value -1f
22+
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.Heal[-1].Amounts.Over append value -1f
23+
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.Heal[-1].Amounts.Base[-1] set from storage api: Argument.Fluctuation
24+
execute store result storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.Heal[-1].Amounts.Over[-1] float 0.01 run scoreboard players get $OverHeal Temporary
25+
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.Heal[-1].PreviousHealth append value -1f
26+
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.Heal[-1].PreviousHealth[-1] set from storage api: Health
2327
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.Heal[-1].To append value -1
2428
execute store result storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.Heal[-1].To[-1] int 1 run scoreboard players get $ReceiverUUID Temporary
2529
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents.Heal[-1].Metadata set from storage api: Argument.Metadata

TheSkyBlessing/data/asset_manager/functions/artifact/triggers/heal/foreach.mcfunction

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@
1212
execute if data storage asset:artifact HealTargets[0] run function asset_manager:artifact/triggers/heal/add_tag_each_receiver
1313
# 最大ヒール量の計算
1414
function lib:array/session/open
15-
data modify storage lib: Array set from storage asset:context Heal.Amounts
15+
data modify storage lib: Array set from storage asset:context Heal.Amounts.Base
1616
function lib:array/math/max
17-
data modify storage asset:context Heal.Amount set from storage lib: MaxResult
17+
data modify storage asset:context Heal.Amount.Base set from storage lib: MaxResult
18+
function lib:array/session/close
19+
# 最大オーバーヒール量の計算
20+
function lib:array/session/open
21+
data modify storage lib: Array set from storage asset:context Heal.Amounts.Over
22+
function lib:array/math/max
23+
data modify storage asset:context Heal.Amount.Over set from storage lib: MaxResult
1824
function lib:array/session/close
1925
# 神器側に受け渡し
2026
function #asset:artifact/heal

0 commit comments

Comments
 (0)