Skip to content

Commit 0aff1f6

Browse files
committed
🧑‍💻 装備時のステータス変動処理の内部化
1 parent ef334e3 commit 0aff1f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+637
-119
lines changed

TheSkyBlessing/data/asset/tags/functions/artifact/dis_equip.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

TheSkyBlessing/data/asset/tags/functions/artifact/equip.json

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#> asset_manager:artifact/data/new/fetch_data/
2+
#
3+
# プレイヤーデータからromを呼び出す
4+
#
5+
# @within function asset_manager:artifact/triggers/
6+
7+
# セッションを開く
8+
function lib:array/session/open
9+
# データを用意する
10+
data modify storage asset:context New.ItemData set value []
11+
# idを取得する
12+
data modify storage lib: Array append from storage asset:context New.Items.mainhand.tag.TSB
13+
data modify storage lib: Array append from storage asset:context New.Items.offhand.tag.TSB
14+
data modify storage lib: Array append from storage asset:context New.Items.feet.tag.TSB
15+
data modify storage lib: Array append from storage asset:context New.Items.legs.tag.TSB
16+
data modify storage lib: Array append from storage asset:context New.Items.chest.tag.TSB
17+
data modify storage lib: Array append from storage asset:context New.Items.head.tag.TSB
18+
data modify storage lib: Array append from storage asset:context New.Items.hotbar[].tag.TSB
19+
# 反転
20+
function lib:array/reverse
21+
# id毎にデータを取得する
22+
scoreboard players set $SlotIndex Temporary 0
23+
function asset_manager:artifact/data/new/fetch_data/foreach
24+
# リセット
25+
scoreboard players reset $SlotIndex Temporary
26+
function lib:array/session/close
27+
data remove storage asset:artifact TargetSlot
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#> asset_manager:artifact/data/new/fetch_data/foreach
2+
#
3+
#
4+
#
5+
# @within function asset_manager:artifact/data/new/fetch_data/*
6+
7+
#> private
8+
# @private
9+
#declare score_holder $ID
10+
#declare score_holder $InvalidSlot
11+
12+
# キーチェック
13+
execute store result score $ID Temporary run data get storage lib: Array[-1].ID
14+
# スロットチェック
15+
# 今のslotを取得する
16+
execute store result storage asset:artifact Enum.Index int 1 run scoreboard players add $SlotIndex Temporary 1
17+
function asset:artifact/enum/index/.m with storage asset:artifact Enum
18+
# autoを処理しておく
19+
data modify storage asset:artifact TargetSlot set from storage lib: Array[-1].Slot
20+
execute if data storage asset:artifact {TargetSlot:"auto"} if data storage asset:artifact Enum{Slot:"mainhand"} run data modify storage lib: Array[-1].Slot set from storage asset:artifact Enum.Slot
21+
execute if data storage asset:artifact {TargetSlot:"auto"} if data storage asset:artifact Enum{Slot: "offhand"} run data modify storage lib: Array[-1].Slot set from storage asset:artifact Enum.Slot
22+
data remove storage asset:artifact TargetSlot
23+
# Slotが一致しているか確認する
24+
execute store success score $InvalidSlot Temporary run data modify storage lib: Array[-1].Slot set from storage asset:artifact Enum.Slot
25+
# データが正しそうなら引っ張り出す
26+
data modify storage asset:context New.ItemData append value {}
27+
execute if score $ID Temporary matches 1.. unless score $InvalidSlot Temporary matches 1.. run data modify storage asset:context New.ItemData[-1] set from storage lib: Array[-1]
28+
# データが正しくなさそうならさようなら
29+
execute if score $ID Temporary matches ..0 run data modify storage asset:context New.ItemData[-1] set value {ID:-2,UUID:-2}
30+
execute unless data storage asset:context New.ItemData[-1].ID run data modify storage asset:context New.ItemData[-1] set value {ID:-2,UUID:-2}
31+
# 要素を削除し、残っていたら再帰する
32+
scoreboard players reset $ID Temporary
33+
scoreboard players reset $InvalidSlot Temporary
34+
data remove storage lib: Array[-1]
35+
execute if data storage lib: Array[0] run function asset_manager:artifact/data/new/fetch_data/foreach

TheSkyBlessing/data/asset_manager/functions/artifact/data/new/stash_to_entity_storage.mcfunction

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
# EntityStorage呼び出し
88
function oh_my_dat:please
99
# 突っ込む
10-
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ContextStash.Inventory set from storage asset:context New.Inventory
10+
# data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ContextStash.Inventory set from storage asset:context New.Inventory
1111
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ContextStash.SelectedItemSlot set from storage asset:context New.SelectedItemSlot
1212
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ContextStash.Items set from storage asset:context New.Items
13-
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ContextStash.id set from storage asset:context New.id
13+
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ContextStash.id set from storage asset:context New.id
14+
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ContextStash.ItemData set from storage asset:context New.ItemData

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
#> asset_manager:artifact/triggers/
22
#
3-
# 各トリガーに処理受け渡し
3+
# トリガー処理を行う
44
#
55
# @within function asset_manager:artifact/tick/player
66

77
# IDの代入
88
function asset_manager:artifact/data/old/init
99
function asset_manager:artifact/data/new/init
10+
# 装備のデータの抽出
11+
function asset_manager:artifact/data/new/fetch_data/
12+
# イベント情報を取得
13+
data modify storage asset:artifact ArtifactEvents set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents
14+
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents set value {}
1015
# 装備の変更チェック
1116
execute if data storage asset:context Old run function asset_manager:artifact/triggers/equipments/compare
1217
# 変更時の更新処理
1318
execute if data storage asset:artifact {EquipmentChanges:[{_:{_:false}}]} run function asset_manager:artifact/triggers/equipments/update_cooldown/
1419
execute if data storage asset:artifact {EquipmentChanges:[{_:{_:false}}]} run function asset_manager:artifact/triggers/equipments/update_cooldown_type
15-
# イベント情報を取得
16-
data modify storage asset:artifact ArtifactEvents set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents
17-
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].ArtifactEvents set value {}
20+
execute if data storage asset:artifact {EquipmentChanges:[{_:{_:false}}]} run function asset_manager:artifact/triggers/equipments/update_attribute/
21+
# 改宗時の更新処理
22+
execute if entity @s[tag=Believe.Changed] unless data storage asset:artifact {EquipmentChanges:[{_:{_:false}}]} run function asset_manager:artifact/triggers/equipments/update_attribute/
1823
# 各トリガーに処理受け渡し & AutoSlotのリセット
1924
function asset_manager:artifact/triggers/tick
2025
execute if entity @s[tag=TriggerFlag.ClickCarrot] run function asset_manager:artifact/triggers/click.carrot
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#> asset_manager:artifact/triggers/dis_equip/
2+
#
3+
#
4+
#
5+
# @within function asset_manager:artifact/triggers/equipments/update_attribute/equip_trigger
6+
7+
# idを取り出す
8+
data modify storage asset:context id set from storage asset:context Old.CopiedItemData[-1].ID
9+
# 処理を呼び出す
10+
function asset_manager:artifact/triggers/dis_equip/dis_equip.m with storage asset:context
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#> asset_manager:artifact/triggers/dis_equip/dis_equip.m
2+
#
3+
#
4+
#
5+
# @input args id : int
6+
# @within function asset_manager:artifact/triggers/dis_equip/
7+
8+
$function asset:artifact/alias/$(id)/dis_equip
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#> asset_manager:artifact/triggers/equip/
2+
#
3+
#
4+
#
5+
# @within function asset_manager:artifact/triggers/equipments/update_attribute/equip_trigger
6+
7+
# idを取り出す
8+
data modify storage asset:context id set from storage asset:context New.CopiedItemData[-1].ID
9+
# 処理を呼び出す
10+
function asset_manager:artifact/triggers/equip/equip.m with storage asset:context
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#> asset_manager:artifact/triggers/equip/equip.m
2+
#
3+
#
4+
#
5+
# @input args id : int
6+
# @within function asset_manager:artifact/triggers/equip/
7+
8+
$function asset:artifact/alias/$(id)/equip

TheSkyBlessing/data/asset_manager/functions/artifact/triggers/equipments/compare.mcfunction

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,14 @@
44
#
55
# @within function asset_manager:artifact/triggers/
66

7-
#> private use
8-
# @private
9-
#declare score_holder $Temp
10-
11-
# イベント発火前に実行するやつ
12-
function asset_manager:artifact/data/new/set_to_current
137
# セッション開く
148
function lib:array/session/open
159
# データ設定
16-
data modify storage lib: ArrayA append from storage asset:context New.Items.mainhand.tag.TSB.UUID
17-
data modify storage lib: ArrayA append from storage asset:context New.Items.offhand.tag.TSB.UUID
18-
data modify storage lib: ArrayA append from storage asset:context New.Items.feet.tag.TSB.UUID
19-
data modify storage lib: ArrayA append from storage asset:context New.Items.legs.tag.TSB.UUID
20-
data modify storage lib: ArrayA append from storage asset:context New.Items.chest.tag.TSB.UUID
21-
data modify storage lib: ArrayA append from storage asset:context New.Items.head.tag.TSB.UUID
22-
data modify storage lib: ArrayA append from storage asset:context New.Items.hotbar[].tag.TSB.UUID
23-
24-
data modify storage lib: ArrayB append from storage asset:context Old.Items.mainhand.tag.TSB.UUID
25-
data modify storage lib: ArrayB append from storage asset:context Old.Items.offhand.tag.TSB.UUID
26-
data modify storage lib: ArrayB append from storage asset:context Old.Items.feet.tag.TSB.UUID
27-
data modify storage lib: ArrayB append from storage asset:context Old.Items.legs.tag.TSB.UUID
28-
data modify storage lib: ArrayB append from storage asset:context Old.Items.chest.tag.TSB.UUID
29-
data modify storage lib: ArrayB append from storage asset:context Old.Items.head.tag.TSB.UUID
30-
data modify storage lib: ArrayB append from storage asset:context Old.Items.hotbar[].tag.TSB.UUID
10+
data modify storage lib: ArrayA append from storage asset:context New.ItemData[].UUID
11+
data modify storage lib: ArrayB append from storage asset:context Old.ItemData[].UUID
3112
# 比較
3213
function lib:array/compare
3314
# 比較結果を保存する
3415
data modify storage asset:artifact EquipmentChanges set from storage lib: CompareResult
3516
# リセット
3617
function lib:array/session/close
37-
scoreboard players reset $Temp Temporary

TheSkyBlessing/data/asset_manager/functions/artifact/triggers/equipments/mask_slot/.mcfunction

Lines changed: 0 additions & 16 deletions
This file was deleted.

TheSkyBlessing/data/asset_manager/functions/artifact/triggers/equipments/mask_slot/masking_foreach.mcfunction

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#> asset_manager:artifact/triggers/equipments/update_attribute/
2+
#
3+
#
4+
#
5+
# @within function asset_manager:artifact/triggers/
6+
7+
# 装備が変更されている箇所を抽出する
8+
# 新しい装備については、信仰が正しいか確認する
9+
data modify storage asset:artifact CopiedChanges set from storage asset:artifact EquipmentChanges
10+
data modify storage asset:context Old.CopiedItemData set from storage asset:context Old.ItemData
11+
data modify storage asset:context New.CopiedItemData set from storage asset:context New.ItemData
12+
function asset_manager:artifact/triggers/equipments/update_attribute/extract_changes
13+
# 各装備について、equip / dis_equip トリガーを走らせる
14+
data modify storage asset:context Old.CopiedItemData set from storage asset:context Old.MaskedItemData
15+
data modify storage asset:context New.CopiedItemData set from storage asset:context New.MaskedItemData
16+
function asset_manager:artifact/triggers/equipments/update_attribute/equip_trigger
17+
# セット装備効果の更新
18+
function asset_manager:artifact/triggers/equipments/update_attribute/attire/
19+
# 装備時補正を更新
20+
data modify storage asset:context Old.CopiedItemData set from storage asset:context Old.MaskedItemData
21+
function asset_manager:artifact/triggers/equipments/update_attribute/remove/
22+
data modify storage asset:context New.CopiedItemData set from storage asset:context New.MaskedItemData
23+
function asset_manager:artifact/triggers/equipments/update_attribute/add/
24+
25+
# リセット
26+
data remove storage asset:artifact CopiedChanges
27+
data remove storage asset:context Old.CopiedItemData
28+
data remove storage asset:context New.CopiedItemData
29+
data remove storage asset:context Old.MaskedItemData
30+
data remove storage asset:context New.MaskedItemData
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#> asset_manager:artifact/triggers/equipments/update_attribute/_index.d
2+
# @private
3+
4+
#> custom modifier
5+
# @within function asset_manager:artifact/triggers/equipments/update_attribute/**
6+
#declare score_holder $CustomModifier
7+
#declare score_holder $CheckBelieve
8+
9+
#> dec to hex
10+
# @within function asset_manager:artifact/triggers/equipments/update_attribute/dec_to_hex/**
11+
#declare score_holder $F
12+
#declare score_holder $FFFF
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#> asset_manager:artifact/triggers/equipments/update_attribute/add/
2+
# @within function
3+
# asset_manager:artifact/triggers/equipments/update_attribute/
4+
# asset_manager:artifact/triggers/equipments/update_attribute/add/
5+
6+
# Modifierを切り出す
7+
function asset_manager:artifact/triggers/equipments/update_attribute/add/stack/
8+
9+
# Modifierがあれば処理する
10+
execute if data storage asset:artifact MaskedModifiers[0] run function asset_manager:artifact/triggers/equipments/update_attribute/add/process
11+
12+
# リセット
13+
data remove storage asset:artifact MaskedModifiers
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#> asset_manager:artifact/triggers/equipments/update_attribute/add/calc_effective
2+
# @within function asset_manager:artifact/triggers/equipments/update_attribute/add/process
3+
4+
#> Private
5+
# @private
6+
#declare score_holder $Stack
7+
#declare score_holder $Amount
8+
#declare score_holder $MaxStack
9+
#declare score_holder $StackReduction
10+
11+
# 変数を取得
12+
execute store result score $Stack Temporary run data get storage asset:artifact Modifier.Stack
13+
execute store result score $Amount Temporary run data get storage asset:artifact Modifier.Amount 1000
14+
execute store result score $MaxStack Temporary run data get storage asset:artifact Modifier.MaxStack
15+
execute store result score $StackReduction Temporary run data get storage asset:artifact Modifier.StackReduction 1000
16+
execute if score $MaxStack Temporary matches 0 run scoreboard players set $MaxStack Temporary 9
17+
# 計算
18+
scoreboard players operation $Stack Temporary < $MaxStack Temporary
19+
scoreboard players operation $Amount Temporary *= $Stack Temporary
20+
execute unless score $StackReduction Temporary matches 0 run scoreboard players remove $Stack Temporary 1
21+
execute unless score $StackReduction Temporary matches 0 run scoreboard players operation $StackReduction Temporary *= $Stack Temporary
22+
execute unless score $StackReduction Temporary matches 0 run scoreboard players operation $Amount Temporary -= $StackReduction Temporary
23+
execute store result storage asset:artifact Modifier.Amount double 0.001 run scoreboard players get $Amount Temporary
24+
# リセット
25+
scoreboard players reset $Stack Temporary
26+
scoreboard players reset $Amount Temporary
27+
scoreboard players reset $MaxStack Temporary
28+
scoreboard players reset $StackReduction Temporary
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#> asset_manager:artifact/triggers/equipments/update_attribute/add/custom.m
2+
# @input args
3+
# Type : string
4+
# @within function asset_manager:artifact/triggers/equipments/update_attribute/add/process
5+
6+
$function api:modifier/$(Type)/add
7+
$execute store success score $CustomModifier Temporary run schedule function api:modifier/$(Type)/add 2147483647t
8+
$schedule clear api:modifier/$(Type)/add
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#> asset_manager:artifact/triggers/equipments/update_attribute/add/generic.m
2+
# @input args
3+
# Type : attribute.name
4+
# ID : int
5+
# ArtifactID : hexadecimal
6+
# SlotID : int
7+
# Amount : double
8+
# Operation : string
9+
# @within function asset_manager:artifact/triggers/equipments/update_attribute/add/process
10+
11+
$attribute @s $(Type) modifier add 1-0-1-0-$(ArtifactID)0000000$(SlotID) "$(ID).$(Type)" $(Amount) $(Operation)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#> asset_manager:artifact/triggers/equipments/update_attribute/add/process
2+
# @within function asset_manager:artifact/triggers/equipments/update_attribute/add/*
3+
4+
# データを取得
5+
data modify storage asset:artifact Modifier set from storage asset:artifact MaskedModifiers[-1]
6+
7+
# データを整える
8+
execute if data storage asset:artifact Modifier{Slot:"hotbar"} run function asset_manager:artifact/triggers/equipments/update_attribute/add/calc_effective
9+
data modify storage asset:artifact Modifier.UUID set value [I;1,1,-1,-1]
10+
data modify storage asset:artifact Modifier.UUID[2] set from storage asset:artifact Modifier.ID
11+
data modify storage asset:artifact Enum.Slot set from storage asset:artifact Modifier.Slot
12+
execute store result storage asset:artifact Modifier.UUID[3] int 1 run function asset:artifact/enum/slot/.m with storage asset:artifact Enum
13+
14+
# apiに移す
15+
data modify storage api: Argument.UUID set from storage asset:artifact Modifier.UUID
16+
data modify storage api: Argument.Amount set from storage asset:artifact Modifier.Amount
17+
data modify storage api: Argument.Operation set from storage asset:artifact Modifier.Operation
18+
# カスタムModifierで処理
19+
scoreboard players set $CustomModifier Temporary 0
20+
function asset_manager:artifact/triggers/equipments/update_attribute/add/custom.m with storage asset:artifact Modifier
21+
# バニラModifierで処理
22+
execute unless score $CustomModifier Temporary matches 1 run function asset_manager:artifact/triggers/equipments/update_attribute/dec_to_hex/
23+
execute unless score $CustomModifier Temporary matches 1 run function asset_manager:artifact/triggers/equipments/update_attribute/add/generic.m with storage asset:artifact Modifier
24+
25+
# リセット&ループ
26+
scoreboard players reset $CustomModifier Temporary
27+
data remove storage asset:artifact Modifier
28+
data remove storage asset:artifact MaskedModifiers[-1]
29+
execute if data storage asset:artifact MaskedModifiers[0] run function asset_manager:artifact/triggers/equipments/update_attribute/add/process

0 commit comments

Comments
 (0)