Skip to content

Commit

Permalink
🧑‍💻 装備変更時のステータス変動処理を内部化
Browse files Browse the repository at this point in the history
  • Loading branch information
haiiro2gou committed Nov 23, 2024
1 parent d578157 commit 9156bc7
Show file tree
Hide file tree
Showing 31 changed files with 505 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# 変更時の更新処理
execute if data storage asset:artifact {EquipmentChanges:[{_:{_:false}}]} run function asset_manager:artifact/triggers/equipments/update_cooldown/
execute if data storage asset:artifact {EquipmentChanges:[{_:{_:false}}]} run function asset_manager:artifact/triggers/equipments/update_cooldown_type
execute if data storage asset:artifact {EquipmentChanges:[{_:{_:false}}]} run function asset_manager:artifact/triggers/equipments/update_attribute/
execute if data storage asset:artifact {EquipmentChanges:[{_:{_:false}}]} if entity @s[tag=TriggerFlag.Sneak] run function asset_manager:artifact/triggers/event/sneak/reset_when_change_item
execute if data storage asset:artifact {EquipmentChanges:[{_:{_:false}}]} if entity @s[tag=TriggerFlag.UsingItem] run function asset_manager:artifact/triggers/event/use_item/reset_when_change_item
# 各神器にトリガー受けわたし
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> asset_manager:artifact/triggers/dis_equip/
#
#
#
# @within function asset_manager:artifact/triggers/equipments/update_attribute/equip_trigger

# idを取り出す
data modify storage asset:context id set from storage asset:artifact Old.CopiedItemData[-1].ID
# 処理を呼び出す
function asset_manager:artifact/triggers/dis_equip/dis_equip.m with storage asset:context
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#> asset_manager:artifact/triggers/dis_equip/dis_equip.m
#
#
#
# @input args id : int
# @within function asset_manager:artifact/triggers/dis_equip/

$function asset:artifact/alias/$(id)/dis_equip
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> asset_manager:artifact/triggers/equip/
#
#
#
# @within function asset_manager:artifact/triggers/equipments/update_attribute/equip_trigger

# idを取り出す
data modify storage asset:context id set from storage asset:artifact New.CopiedItemData[-1].ID
# 処理を呼び出す
function asset_manager:artifact/triggers/equip/equip.m with storage asset:context
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#> asset_manager:artifact/triggers/equip/equip.m
#
#
#
# @input args id : int
# @within function asset_manager:artifact/triggers/equip/

$function asset:artifact/alias/$(id)/equip
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/
#
#
#
# @within function asset_manager:artifact/triggers/

# 装備が変更されている箇所を抽出する
# 新しい装備については、信仰が正しいか確認する
data modify storage asset:artifact CopiedChanges set from storage asset:artifact EquipmentChanges
data modify storage asset:artifact Old.CopiedItemData set from storage asset:artifact Old.ItemData
data modify storage asset:artifact New.CopiedItemData set from storage asset:artifact New.ItemData
function asset_manager:artifact/triggers/equipments/update_attribute/extract_changes
# 各装備について、equip / dis_equip トリガーを走らせる
data modify storage asset:artifact Old.CopiedItemData set from storage asset:artifact Old.MaskedItemData
data modify storage asset:artifact New.CopiedItemData set from storage asset:artifact New.MaskedItemData
function asset_manager:artifact/triggers/equipments/update_attribute/equip_trigger
# セット装備効果の更新
function asset_manager:artifact/triggers/equipments/update_attribute/attire/
# 装備時補正を更新
data modify storage asset:artifact Old.CopiedItemData set from storage asset:artifact Old.MaskedItemData
function asset_manager:artifact/triggers/equipments/update_attribute/remove/
data modify storage asset:artifact New.CopiedItemData set from storage asset:artifact New.MaskedItemData
function asset_manager:artifact/triggers/equipments/update_attribute/add/

# リセット
data remove storage asset:artifact CopiedChanges
data remove storage asset:artifact Old.CopiedItemData
data remove storage asset:artifact New.CopiedItemData
data remove storage asset:artifact Old.MaskedItemData
data remove storage asset:artifact New.MaskedItemData
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/_index.d
# @private

#> custom modifier
# @within function asset_manager:artifact/triggers/equipments/update_attribute/**
#declare score_holder $CustomModifier
#declare score_holder $CheckBelieve

#> dec to hex
# @within function asset_manager:artifact/triggers/equipments/update_attribute/dec_to_hex/**
#declare score_holder $F
#declare score_holder $FFFF
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/add/
# @within function
# asset_manager:artifact/triggers/equipments/update_attribute/
# asset_manager:artifact/triggers/equipments/update_attribute/add/

# Modifierを切り出す
function asset_manager:artifact/triggers/equipments/update_attribute/add/stack/

# Modifierがあれば処理する
execute if data storage asset:artifact MaskedModifiers[0] run function asset_manager:artifact/triggers/equipments/update_attribute/add/process

# リセット
data remove storage asset:artifact MaskedModifiers
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/add/calc_effective
# @within function asset_manager:artifact/triggers/equipments/update_attribute/add/process

#> Private
# @private
#declare score_holder $Stack
#declare score_holder $Amount
#declare score_holder $MaxStack
#declare score_holder $StackReduction

# 変数を取得
execute store result score $Stack Temporary run data get storage asset:artifact Modifier.Stack
execute store result score $Amount Temporary run data get storage asset:artifact Modifier.Amount 1000
execute store result score $MaxStack Temporary run data get storage asset:artifact Modifier.MaxStack
execute store result score $StackReduction Temporary run data get storage asset:artifact Modifier.StackReduction 1000
execute if score $MaxStack Temporary matches 0 run scoreboard players set $MaxStack Temporary 9
# 計算
scoreboard players operation $Stack Temporary < $MaxStack Temporary
scoreboard players operation $Amount Temporary *= $Stack Temporary
execute unless score $StackReduction Temporary matches 0 run scoreboard players remove $Stack Temporary 1
execute unless score $StackReduction Temporary matches 0 run scoreboard players operation $StackReduction Temporary *= $Stack Temporary
execute unless score $StackReduction Temporary matches 0 run scoreboard players operation $Amount Temporary -= $StackReduction Temporary
execute store result storage asset:artifact Modifier.Amount double 0.001 run scoreboard players get $Amount Temporary
# リセット
scoreboard players reset $Stack Temporary
scoreboard players reset $Amount Temporary
scoreboard players reset $MaxStack Temporary
scoreboard players reset $StackReduction Temporary
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/add/custom.m
# @input args
# Type : string
# @within function asset_manager:artifact/triggers/equipments/update_attribute/add/process

$function api:modifier/$(Type)/add
$execute store success score $CustomModifier Temporary run schedule function api:modifier/$(Type)/add 2147483647t
$schedule clear api:modifier/$(Type)/add
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/add/generic.m
# @input args
# Type : attribute.name
# ID : int
# ArtifactID : hexadecimal
# SlotID : int
# Amount : double
# Operation : string
# @within function asset_manager:artifact/triggers/equipments/update_attribute/add/process

$attribute @s $(Type) modifier add 1-0-1-0-$(ArtifactID)0000000$(SlotID) "$(ID).$(Type)" $(Amount) $(Operation)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/add/process
# @within function asset_manager:artifact/triggers/equipments/update_attribute/add/*

# データを取得
data modify storage asset:artifact Modifier set from storage asset:artifact MaskedModifiers[-1]

# データを整える
execute if data storage asset:artifact Modifier.MaxStack run function asset_manager:artifact/triggers/equipments/update_attribute/add/calc_effective
data modify storage asset:artifact Modifier.UUID set value [I;1,1,-1,-1]
data modify storage asset:artifact Modifier.UUID[2] set from storage asset:artifact Modifier.ID
data modify storage asset:artifact Enum.Slot set from storage asset:artifact Modifier.Slot
execute store result storage asset:artifact Modifier.UUID[3] int 1 run function asset:artifact/enum/slot/.m with storage asset:artifact Enum

# apiに移す
data modify storage api: Argument.UUID set from storage asset:artifact Modifier.UUID
data modify storage api: Argument.Amount set from storage asset:artifact Modifier.Amount
data modify storage api: Argument.Operation set from storage asset:artifact Modifier.Operation
# カスタムModifierで処理
scoreboard players set $CustomModifier Temporary 0
function asset_manager:artifact/triggers/equipments/update_attribute/add/custom.m with storage asset:artifact Modifier
# バニラModifierで処理
execute unless score $CustomModifier Temporary matches 1 run data modify storage asset:artifact Modifier.SlotID set from storage asset:artifact Modifier.UUID[3]
execute unless score $CustomModifier Temporary matches 1 run function asset_manager:artifact/triggers/equipments/update_attribute/dec_to_hex/
execute unless score $CustomModifier Temporary matches 1 run function asset_manager:artifact/triggers/equipments/update_attribute/add/generic.m with storage asset:artifact Modifier

# リセット&ループ
scoreboard players reset $CustomModifier Temporary
data remove storage asset:artifact Modifier
data remove storage asset:artifact MaskedModifiers[-1]
execute if data storage asset:artifact MaskedModifiers[0] run function asset_manager:artifact/triggers/equipments/update_attribute/add/process
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/add/stack/
# @within function
# asset_manager:artifact/triggers/equipments/update_attribute/add/
# asset_manager:artifact/triggers/equipments/update_attribute/add/stack/

# Modifier一覧を切り出す
# execute if data storage asset:artifact New.CopiedItemData[-1].Modifiers[0] run data modify storage asset:artifact New.CopiedItemData[-1].Modifiers[].ID set from storage asset:artifact New.CopiedItemData[-1].ID
# execute if data storage asset:artifact New.CopiedItemData[-1].Modifiers[0] run data modify storage asset:artifact New.CopiedItemData[-1].Modifiers[].Slot set from storage asset:artifact New.CopiedItemData[-1].Slot
data modify storage asset:artifact Modifiers append from storage asset:artifact New.CopiedItemData[-1].Modifiers[]

# Modifierのスタック処理
execute if data storage asset:artifact Modifiers[0] run function asset_manager:artifact/triggers/equipments/update_attribute/add/stack/foreach

# 要素を削除して、残っているならば再帰
data remove storage asset:artifact Modifiers
data remove storage asset:artifact New.CopiedItemData[-1]
execute if data storage asset:artifact New.CopiedItemData[0] run function asset_manager:artifact/triggers/equipments/update_attribute/add/stack/
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/add/stack/calc.m
# @input args
# ID : int
# Type : string
# @within function asset_manager:artifact/triggers/equipments/update_attribute/add/stack/foreach

#> Private
# @private
#declare score_holder $SameModifier
#declare score_holder $ModifierStack

# 同一スロット、タイプ、IDのものがないかチェック
$execute store result score $SameModifier Temporary if data storage asset:artifact MaskedModifiers[{ID:$(ID),Type:"$(Type)"}]
# 一致しているものがあればスタック追加
$execute if score $SameModifier Temporary matches 1.. store result score $ModifierStack Temporary run data get storage asset:artifact MaskedModifiers[{ID:$(ID),Type:"$(Type)"}].Stack
execute if score $SameModifier Temporary matches 1.. run scoreboard players add $ModifierStack Temporary 1
$execute if score $SameModifier Temporary matches 1.. store result storage asset:artifact MaskedModifiers[{ID:$(ID),Type:"$(Type)"}].Stack int 1 run scoreboard players get $ModifierStack Temporary
# 一致しているものがなければ追加
execute if score $SameModifier Temporary matches 0 run data modify storage asset:artifact MaskedModifiers append from storage asset:artifact Modifier
execute if score $SameModifier Temporary matches 0 run data modify storage asset:artifact MaskedModifiers[-1].Stack set value 1
# リセット
scoreboard players reset $SameModifier Temporary
scoreboard players reset $ModifierStack Temporary
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/add/stack/foreach
# @within function asset_manager:artifact/triggers/equipments/update_attribute/add/stack/*

# Modifierを切り出す
data modify storage asset:artifact Modifier set from storage asset:artifact Modifiers[-1]

# Modifierのスタックを行う
function asset_manager:artifact/triggers/equipments/update_attribute/add/stack/calc.m with storage asset:artifact Modifier

# 要素を削除して、残っているならば再帰
data remove storage asset:artifact Modifier
data remove storage asset:artifact Modifiers[-1]
execute if data storage asset:artifact Modifiers[0] run function asset_manager:artifact/triggers/equipments/update_attribute/add/stack/foreach
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/attire/
#
#
#
# @within function asset_manager:artifact/triggers/equipments/update_attribute/

# tellraw @a [{"storage":"asset:artifact","nbt":"Old.MaskedItemData[].EquipID"}]
# tellraw @a [{"storage":"asset:artifact","nbt":"New.MaskedItemData[].EquipID"}]

# 2つの配列を重複を起こさないように結合する
data modify storage asset:artifact Attire.List set value []
data modify storage asset:artifact Attire.Target append from storage asset:artifact Old.MaskedItemData[].EquipID
data modify storage asset:artifact Attire.Target append from storage asset:artifact New.MaskedItemData[].EquipID
function asset_manager:artifact/triggers/equipments/update_attribute/attire/concat
# 各要素ごとに当てはまる部位数を確認して反映する
function asset_manager:artifact/triggers/equipments/update_attribute/attire/foreach
# リセット
data remove storage asset:artifact Attire
data remove storage asset:artifact CopiedNewEquipIDs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/attire/concat
#
#
#
# @within function asset_manager:artifact/triggers/equipments/update_attribute/attire/*

# idを一つ取り出す
data modify storage asset:artifact Attire.Value set from storage asset:artifact Attire.Target[-1]
# upsertする
function asset_manager:artifact/triggers/equipments/update_attribute/attire/upsert.m with storage asset:artifact Attire
# 要素を削除して、残っているならば再帰
data remove storage asset:artifact Attire.Value
data remove storage asset:artifact Attire.Target[-1]
execute if data storage asset:artifact Attire.Target[0] run function asset_manager:artifact/triggers/equipments/update_attribute/attire/concat
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/attire/foreach
#
#
#
# @within function asset_manager:artifact/triggers/equipments/update_attribute/attire/*

#> private
# @private
#declare score_holder $SetID

# idを取得する
execute store result score $SetID Temporary run data get storage asset:artifact Attire.List[-1]._

# エフェクトを付与する / 削除する
execute if score $SetID Temporary matches 1.. run data modify storage api: Argument.ID set from storage asset:artifact Attire.List[-1]._
execute if score $SetID Temporary matches 1.. run function asset_manager:artifact/triggers/equipments/update_attribute/attire/parts_count.m with storage api: Argument
execute if score $SetID Temporary matches 1.. unless data storage api: Argument{Stack:0} run function api:entity/mob/effect/give
execute if score $SetID Temporary matches 1.. if data storage api: Argument{Stack:0} run function api:entity/mob/effect/remove/from_id

# 要素を削除して、残っているならば再帰
scoreboard players reset $SetID Temporary
data remove storage asset:artifact Attire.List[-1]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/attire/parts_count.m
# @input args ID : int
# @within function asset_manager:artifact/triggers/equipments/update_attribute/attire/foreach

$execute store result storage api: Argument.Stack int 1 if data storage asset:artifact New.MaskedItemData[{EquipID:$(ID)}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/attire/upsert.m
#
#
#
# @input args Value : int
# @within function asset_manager:artifact/triggers/equipments/update_attribute/attire/concat

#> private
# @private
#declare score_holder $ExistsID

$execute store result score $ExistsID Temporary if data storage asset:artifact Attire.List[{_:$(Value)}]
$execute unless score $ExistsID Temporary matches 1.. run data modify storage asset:artifact Attire.List append value {_:$(Value)}
scoreboard players reset $ExistsID Temporary
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#> asset_manager:artifact/triggers/equipments/update_attribute/check_religion
#
#
#
# @within function asset_manager:artifact/triggers/equipments/update_attribute/extract_changes

execute if data storage asset:artifact {CanUsedGod:["Flora"]} if predicate player_manager:is_believe/flora run scoreboard players set $CheckBelieve Temporary 1
execute if data storage asset:artifact {CanUsedGod:["Nyaptov"]} if predicate player_manager:is_believe/nyaptov run scoreboard players set $CheckBelieve Temporary 1
execute if data storage asset:artifact {CanUsedGod:["Rumor"]} if predicate player_manager:is_believe/rumor run scoreboard players set $CheckBelieve Temporary 1
execute if data storage asset:artifact {CanUsedGod:["Urban"]} if predicate player_manager:is_believe/urban run scoreboard players set $CheckBelieve Temporary 1
execute if data storage asset:artifact {CanUsedGod:["Wi-ki"]} if predicate player_manager:is_believe/wi-ki run scoreboard players set $CheckBelieve Temporary 1
Loading

0 comments on commit 9156bc7

Please sign in to comment.