Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧑‍💻 装備時のModifier処理をcore内部で行うように #1485

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,25 @@
# DisableCooldownMessage? : boolean
# DisableMPMessage? : boolean
# DisableBreakSound? : boolean
# EquipID? : int
# Modifiers : Component[]
# ├ Type : string
# ├ Amount : double
# ├ Operation : "add" | "multiply_base" | "multiply"
# ├ MaxStack? : int
# └ StackReduction? : double
# CanUsedGod : God[]
# CustomNBT? : Component
# @output item 神器
# @within function asset:artifact/*/give/2.give

#> Inv
# @private
#declare score_holder $InvSize
#declare score_holder $InvSize

# AttributeModifierの内部化
execute if data storage asset:artifact CustomNBT.AttributeModifiers[0] run function asset:artifact/common/modifier/migrate
data modify storage asset:artifact CustomNBT.AttributeModifiers set value []

# storage検証
execute unless data storage asset:artifact ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" ID","color":"red"}]
Expand All @@ -37,6 +49,9 @@
execute unless data storage asset:artifact Slot run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" Slot","color":"red"}]
execute unless data storage asset:artifact Trigger run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" Trigger","color":"red"}]
execute unless data storage asset:artifact MPCost run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" MPCost","color":"red"}]
execute if data storage asset:artifact Modifiers[0] run data modify storage asset:temp Modifiers set from storage asset:artifact Modifiers
execute if data storage asset:artifact Modifiers[0] run function asset:artifact/common/modifier/check
execute if data storage asset:artifact Modifiers[0] run data remove storage asset:temp Modifiers
execute unless data storage asset:artifact CanUsedGod run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" CanUsedGod","color":"red"}]
# 各データ設定
function asset_manager:artifact/create/set_data
Expand Down Expand Up @@ -67,10 +82,12 @@
data remove storage asset:artifact MPCost
data remove storage asset:artifact MPRequire
data remove storage asset:artifact CostText
data remove storage asset:artifact CanUsedGod
data remove storage asset:artifact CustomNBT
data remove storage asset:artifact LocalCooldown
data remove storage asset:artifact SpecialCooldown
data remove storage asset:artifact DisableCooldownMessage
data remove storage asset:artifact DisableMPMessage
data remove storage asset:artifact DisableBreakSound
data remove storage asset:artifact EquipID
data remove storage asset:artifact Modifiers
data remove storage asset:artifact CanUsedGod
data remove storage asset:artifact CustomNBT
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#> asset:artifact/common/modifier/check
# @within function
# asset:artifact/common/give
# asset:artifact/common/modifier/check

# validate
execute unless data storage asset:temp Modifiers[-1].Type run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" Type","color":"red"}]
execute unless data storage asset:temp Modifiers[-1].Amount run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" Amount","color":"red"}]
execute unless data storage asset:temp Modifiers[-1].Operation run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" Operation","color":"red"}]
# execute unless data storage asset:temp Modifiers[-1].MaxStack
# execute unless data storage asset:temp Modifiers[-1].StackReduction

# loop
data remove storage asset:temp Modifiers[-1]
execute if data storage asset:temp Modifiers[0] run function asset:artifact/common/modifier/check
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#> asset:artifact/common/modifier/migrate
# @within function
# asset:artifact/common/give
# asset:artifact/common/modifier/migrate

# 前データの用意
data modify storage asset:temp Modifier set from storage asset:artifact CustomNBT.AttributeModifiers[-1]
data modify storage asset:artifact Modifiers append value {}
# データを移し替える
data modify storage asset:artifact Modifiers[-1].Type set from storage asset:temp Modifier.AttributeName
data modify storage asset:artifact Modifiers[-1].Amount set from storage asset:temp Modifier.Amount
execute if data storage asset:temp Modifier{Operation:0} run data modify storage asset:artifact Modifiers[-1].Operation set value "add"
execute if data storage asset:temp Modifier{Operation:1} run data modify storage asset:artifact Modifiers[-1].Operation set value "multiply_base"
execute if data storage asset:temp Modifier{Operation:2} run data modify storage asset:artifact Modifiers[-1].Operation set value "multiply"

# 他の要素があればループ
data remove storage asset:temp Modifier
data remove storage asset:artifact CustomNBT.AttributeModifiers[-1]
execute if data storage asset:artifact CustomNBT.AttributeModifiers[0] run function asset:artifact/common/modifier/migrate
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
# @within function
# asset_manager:artifact/create/lore_append
# asset_manager:artifact/create/set_lore
# asset_manager:artifact/create/set_equipment

loot replace block 10000 0 10000 container.0 loot asset_manager:artifact/get_lore
data modify storage asset:artifact Item.tag.display.Lore append from block 10000 0 10000 Items[0].tag.display.Lore[0]
data remove storage asset:artifact Lore[0]

execute if data storage asset:artifact Lore[0] run function asset_manager:artifact/create/lore_append
execute if data storage asset:artifact Lore[0] run function asset_manager:artifact/create/lore_append
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#> asset_manager:artifact/create/modifier/
#
# 装備時効果の内容をLoreに追加
#
# @within function
# asset_manager:artifact/create/set_lore
# asset_manager:artifact/create/modifier/

#> temp
# @private
#declare score_holder $AmountFrac
#declare score_holder $AmountFrac2
#declare score_holder $AmountInt
#declare score_holder $CustomModifier

# 変数を用意
scoreboard players set $CustomModifier Temporary 0
data modify storage asset:artifact Modifier set from storage asset:artifact CopiedModifiers[0]
data modify storage asset:artifact Line set value ['{"text":"","color":"green","italic":false}','""','" +"','{"translate":"%s","with":[{"storage":"asset:artifact","nbt":"Amount.Int"}]}','""']

# カスタムModifier
execute if data storage asset:artifact Modifier{Type:"attackBase"} run scoreboard players set $CustomModifier Temporary 1
execute if data storage asset:artifact Modifier{Type:"attackBase"} run data modify storage asset:artifact Line[1] set value '"攻撃"'
execute if data storage asset:artifact Modifier{Type:"attackFire"} run scoreboard players set $CustomModifier Temporary 1
execute if data storage asset:artifact Modifier{Type:"attackFire"} run data modify storage asset:artifact Line[1] set value '"火攻撃"'
execute if data storage asset:artifact Modifier{Type:"attackMagic"} run scoreboard players set $CustomModifier Temporary 1
execute if data storage asset:artifact Modifier{Type:"attackMagic"} run data modify storage asset:artifact Line[1] set value '"魔法攻撃"'
execute if data storage asset:artifact Modifier{Type:"attackPhysical"} run scoreboard players set $CustomModifier Temporary 1
execute if data storage asset:artifact Modifier{Type:"attackPhysical"} run data modify storage asset:artifact Line[1] set value '"物理攻撃"'
execute if data storage asset:artifact Modifier{Type:"attackThunder"} run scoreboard players set $CustomModifier Temporary 1
execute if data storage asset:artifact Modifier{Type:"attackThunder"} run data modify storage asset:artifact Line[1] set value '"雷攻撃"'
execute if data storage asset:artifact Modifier{Type:"attackWater"} run scoreboard players set $CustomModifier Temporary 1
execute if data storage asset:artifact Modifier{Type:"attackWater"} run data modify storage asset:artifact Line[1] set value '"水攻撃"'
execute if data storage asset:artifact Modifier{Type:"defenseBase"} run scoreboard players set $CustomModifier Temporary 1
execute if data storage asset:artifact Modifier{Type:"defenseBase"} run data modify storage asset:artifact Line[1] set value '"耐性"'
execute if data storage asset:artifact Modifier{Type:"defenseFire"} run scoreboard players set $CustomModifier Temporary 1
execute if data storage asset:artifact Modifier{Type:"defenseFire"} run data modify storage asset:artifact Line[1] set value '"火耐性"'
execute if data storage asset:artifact Modifier{Type:"defenseMagic"} run scoreboard players set $CustomModifier Temporary 1
execute if data storage asset:artifact Modifier{Type:"defenseMagic"} run data modify storage asset:artifact Line[1] set value '"魔法耐性"'
execute if data storage asset:artifact Modifier{Type:"defensePhysical"} run scoreboard players set $CustomModifier Temporary 1
execute if data storage asset:artifact Modifier{Type:"defensePhysical"} run data modify storage asset:artifact Line[1] set value '"物理耐性"'
execute if data storage asset:artifact Modifier{Type:"defenseThunder"} run scoreboard players set $CustomModifier Temporary 1
execute if data storage asset:artifact Modifier{Type:"defenseThunder"} run data modify storage asset:artifact Line[1] set value '"雷耐性"'
execute if data storage asset:artifact Modifier{Type:"defenseWater"} run scoreboard players set $CustomModifier Temporary 1
execute if data storage asset:artifact Modifier{Type:"defenseWater"} run data modify storage asset:artifact Line[1] set value '"水耐性"'
execute if data storage asset:artifact Modifier{Type:"heal"} run scoreboard players set $CustomModifier Temporary 1
execute if data storage asset:artifact Modifier{Type:"heal"} run data modify storage asset:artifact Line[1] set value '"回復量"'
execute if data storage asset:artifact Modifier{Type:"receiveHeal"} run scoreboard players set $CustomModifier Temporary 1
execute if data storage asset:artifact Modifier{Type:"receiveHeal"} run data modify storage asset:artifact Line[1] set value '"被回復量"'
execute if data storage asset:artifact Modifier{Type:"mpRegen"} run scoreboard players set $CustomModifier Temporary 1
execute if data storage asset:artifact Modifier{Type:"mpRegen"} run data modify storage asset:artifact Line[1] set value '"MP回復量"'
execute if score $CustomModifier Temporary matches 0 run function asset_manager:artifact/create/modifier/generic.m with storage asset:artifact Modifier
# 数値チェック
execute store result score $AmountFrac Temporary run data get storage asset:artifact Modifier.Amount 1000
execute unless data storage asset:artifact Modifier{Operation:"add"} run data modify storage asset:artifact Line[4] set value '"%"'
execute unless data storage asset:artifact Modifier{Operation:"add"} run scoreboard players operation $AmountFrac Temporary *= $100 Const
execute unless score $AmountFrac Temporary matches 0.. run data modify storage asset:artifact Line[0] set value '{"text":"","color":"red","italic":false}'
execute unless score $AmountFrac Temporary matches 0.. run data modify storage asset:artifact Line[2] set value '" -"'
execute unless score $AmountFrac Temporary matches 0.. run scoreboard players operation $AmountFrac Temporary *= $-1 Const
scoreboard players operation $AmountInt Temporary = $AmountFrac Temporary
scoreboard players operation $AmountInt Temporary /= $1000 Const
scoreboard players operation $AmountFrac Temporary %= $1000 Const
scoreboard players operation $AmountFrac2 Temporary = $AmountFrac Temporary
scoreboard players operation $AmountFrac2 Temporary %= $10 Const
execute if score $AmountFrac2 Temporary matches 0 run scoreboard players operation $AmountFrac Temporary /= $10 Const
scoreboard players operation $AmountFrac2 Temporary = $AmountFrac Temporary
scoreboard players operation $AmountFrac2 Temporary %= $10 Const
execute if score $AmountFrac2 Temporary matches 0 run scoreboard players operation $AmountFrac Temporary /= $10 Const
execute store result storage asset:artifact Amount.Int int 1 run scoreboard players get $AmountInt Temporary
execute store result storage asset:artifact Amount.Frac int 1 run scoreboard players get $AmountFrac Temporary
execute if score $AmountFrac Temporary matches 1.. run data modify storage asset:artifact Line[3] set value '{"translate":"%s.%s","with":[{"storage":"asset:artifact","nbt":"Amount.Int"},{"storage":"asset:artifact","nbt":"Amount.Frac"}]}'
# Lore追加
loot replace block 10000 0 10000 container.0 loot asset_manager:artifact/generate_lore/modifier
data modify storage asset:artifact Item.tag.display.Lore append from block 10000 0 10000 Items[].tag.display.Lore[]

# リセット
scoreboard players reset $CustomModifier Temporary
scoreboard players reset $AmountInt Temporary
scoreboard players reset $AmountFrac Temporary
scoreboard players reset $AmountFrac2 Temporary
data modify block 10000 0 10000 Items set value []
data remove storage asset:artifact Line
data remove storage asset:artifact Amount
# 残っていればループ
data remove storage asset:artifact Modifier
data remove storage asset:artifact CopiedModifiers[0]
execute if data storage asset:artifact CopiedModifiers[0] run function asset_manager:artifact/create/modifier/
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#> asset_manager:artifact/create/modifier/generic.m
# @input args Type : string
# @within function asset_manager:artifact/create/modifier/

$data modify storage asset:artifact Line[1] set value '{"translate":"attribute.name.$(Type)"}'
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
# LocalCooldown : int
# SpecialCooldown : int
# CanUsedGod : God[]
# EquipID? : int
# Modifiers : Component[]
# ├ Type : string
# ├ Amount : double
# ├ Operation : "add" | "multiply_base" | "multiply"
# ├ MaxStack? : int
# └ StackReduction? : double
# CustomNBT : Item.tag
# @within function asset:artifact/common/give

Expand All @@ -46,6 +53,7 @@
data modify storage asset:artifact Item.tag.CustomModelData set from storage asset:artifact ID
data modify storage asset:artifact Item.tag.TSB.rawName set from storage asset:artifact Name
data modify storage asset:artifact Item.tag.TSB.ID set from storage asset:artifact ID
data modify storage asset:artifact Item.tag.TSB.Slot set from storage asset:artifact Slot
data modify storage asset:artifact Item.tag.TSB.Trigger set from storage asset:artifact Trigger
data modify storage asset:artifact Item.tag.TSB.MPCost set from storage asset:artifact MPCost
data modify storage asset:artifact Item.tag.TSB.MPRequire set from storage asset:artifact MPRequire
Expand All @@ -57,6 +65,8 @@
data modify storage asset:artifact Item.tag.TSB.DisableCooldownMessage set from storage asset:artifact DisableCooldownMessage
data modify storage asset:artifact Item.tag.TSB.DisableMPMessage set from storage asset:artifact DisableMPMessage
data modify storage asset:artifact Item.tag.TSB.DisableBreakSound set from storage asset:artifact DisableBreakSound
data modify storage asset:artifact Item.tag.TSB.EquipID set from storage asset:artifact EquipID
data modify storage asset:artifact Item.tag.TSB.Modifiers set from storage asset:artifact Modifiers

# 名前
# 残り回数が存在する場合
Expand All @@ -75,4 +85,4 @@
data modify block 10000 0 10000 Items[0] set from storage asset:artifact Item

# リセット
data remove storage asset:artifact BaseItem
data remove storage asset:artifact BaseItem
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#> asset_manager:artifact/create/set_equipment
#
# 装備セットによる効果を設定する
#
# @within function asset_manager:artifact/create/set_lore

# IDから効果を抜き取る
function asset_manager:common/context_id/stash
data modify storage asset:context id set from storage asset:artifact EquipID
function #asset:effect/register
function asset_manager:common/context_id/pop

# 空行セパレータ
data modify storage asset:artifact Item.tag.display.Lore append value '""'
# 名前をLoreに組み込む
data modify storage asset:artifact EquipName set from storage asset:effect Name
loot replace block 10000 0 10000 container.0 loot asset_manager:artifact/generate_lore/equipment
data modify storage asset:artifact Item.tag.display.Lore append from block 10000 0 10000 Items[0].tag.display.Lore[0]
# 説明文をLoreに組み込む
data modify storage asset:artifact Lore set from storage asset:effect Description
execute if data storage asset:artifact Lore[0] run function asset_manager:artifact/create/lore_append

# リセット
data remove storage asset:artifact EquipName
data remove storage asset:artifact Lore
data remove storage asset:effect ExtendsSafe
data remove storage asset:effect ID
data remove storage asset:effect Name
data remove storage asset:effect Description
data remove storage asset:effect Duration
data remove storage asset:effect Stack
data remove storage asset:effect DurationOperation
data remove storage asset:effect StackOperation
data remove storage asset:effect MaxDuration
data remove storage asset:effect MaxStack
data remove storage asset:effect IsBadEffect
data remove storage asset:effect ProcessOnDied
data remove storage asset:effect RequireClearLv
data remove storage asset:effect Field
Loading
Loading