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

💥 Artifact Assetのトリガーのマクロ化 #1621

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@

# validate
execute unless data storage api: Argument.ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" ID","color":"red"}]
# 既存にasset:context idが存在する場合に備えて退避させる
function asset_manager:common/context/id/stash
# 代入
data modify storage asset:context id set from storage api: Argument.ID
data modify storage asset:context Type set value "box"
execute unless data storage api: Argument.ID run return fail
# 呼び出し
execute if data storage api: Argument.ID run function #asset:artifact/give
# 退避させたasset:context idを戻す
function asset_manager:common/context/id/pop
data modify storage api: Argument.Type set value "box"
function api:artifact/core/from_id
# リセット
data remove storage api: Argument.ID
data remove storage api: Argument.Type
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

# validate
execute unless data storage api: Argument.Rarity run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" Rarity","color":"red"}]
execute unless data storage api: Argument.Rarity run return fail
# 呼び出し
data modify storage asset:context Type set value "box"
execute if data storage api: Argument.Rarity run function asset_manager:artifact/give/
data modify storage api: Argument.Type set value "box"
function api:artifact/core/from_rarity/
# リセット
data remove storage api: Argument.Rarity
data remove storage api: Argument.Type
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#> api:artifact/core/from_id
# @within function
# api:artifact/*/from_id
# api:artifact/core/from_rarity/foreach

# 既存にasset:context idが存在する場合に備えて退避させる
function asset_manager:common/context/id/stash
# 既存にasset:context thisが存在する場合に備えて退避させる
function asset_manager:common/context/this/stash

# ID
data modify storage asset:context id set from storage api: Argument.ID
# データ登録
data modify storage asset:artifact Give set value 1b
function asset_manager:artifact/give/register.m with storage asset:context
data remove storage asset:artifact Give
# validate
execute unless data storage asset:artifact ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" ID","color":"red"}]
execute unless data storage asset:artifact ID run return fail
# フィールド設定
data modify storage asset:context this set from storage asset:context Field
data modify storage asset:context this merge from storage api: Argument.FieldOverride
# データをfill
data modify storage asset:context Type set from storage api: Argument.Type
execute if data storage asset:context {Type:"drop"} run data modify storage asset:context Important set from storage api: Argument.Important
# 神器をgive
function asset_manager:artifact/give/

# 退避させたasset:context idを戻す
function asset_manager:common/context/id/pop
# 退避させたasset:context thisを戻す
function asset_manager:common/context/this/pop
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#> api:artifact/core/from_rarity/
#
#
#
# @within function api:artifact/*/from_rarity

#> For calc
# @private
#declare score_holder $CandidateLength
#declare score_holder $Argument.Index
#declare score_holder $Pulls

# セッション開ける
function lib:array/session/open
# 該当レアリティのデータを取得
execute if data storage api: Argument{Rarity:1} run data modify storage lib: Array set from storage asset:artifact ShardPool[1]
execute if data storage api: Argument{Rarity:2} run data modify storage lib: Array set from storage asset:artifact ShardPool[2]
execute if data storage api: Argument{Rarity:3} run data modify storage lib: Array set from storage asset:artifact ShardPool[3]
execute if data storage api: Argument{Rarity:4} run data modify storage lib: Array set from storage asset:artifact ShardPool[4]
# データサイズを取得
execute store result score $CandidateLength Temporary if data storage lib: Array[]
# 対象Indexを決定
execute if data storage api: Argument{Rarity:1} run data modify storage lib: Args.key set value "artifact_lv-1"
execute if data storage api: Argument{Rarity:2} run data modify storage lib: Args.key set value "artifact_lv-2"
execute if data storage api: Argument{Rarity:3} run data modify storage lib: Args.key set value "artifact_lv-3"
execute if data storage api: Argument{Rarity:4} run data modify storage lib: Args.key set value "artifact_lv-4"
execute store result storage lib: Args.max int 1 run scoreboard players get $CandidateLength Temporary
execute store result storage lib: Args.scarcity_history_size int 0.35 run scoreboard players get $CandidateLength Temporary
execute store result score $Argument.Index Lib run function lib:random/with_biased/manual.m with storage lib: Args
# 候補データを操作して対象Indexを-1に持ってくる
function lib:array/move
# 一旦リセット
data modify storage asset:artifact Picks set from storage lib: Array[-1]
function lib:array/session/close
# 候補データの再設定
function lib:array/session/open
data modify storage lib: Array set from storage asset:artifact Picks
data remove storage asset:artifact Picks
# プル数を乱数により設定
# $Pulls = floor( $CandidateLength * 0.30~0.70(e2) ) / e2
execute store result score $CandidateLength Temporary if data storage lib: Array[]
scoreboard players remove $CandidateLength Temporary 1
execute store result score $Pulls Temporary run function lib:random/
scoreboard players operation $Pulls Temporary %= $41 Const
scoreboard players add $Pulls Temporary 30
scoreboard players operation $Pulls Temporary *= $CandidateLength Temporary
scoreboard players operation $Pulls Temporary /= $100 Const
# シャッフルして取り出す
scoreboard players add $CandidateLength Temporary 1
execute if data storage asset:artifact Picks[0] run function api:artifact/core/from_rarity/foreach
# リセット
function lib:array/session/close
scoreboard players reset $CandidateLength Temporary
scoreboard players reset $Pulls Temporary
data remove storage lib: Args
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,17 @@
#declare score_holder $Argument.Index
#declare score_holder $Pulls

# asset:context idがある場合は退避
function asset_manager:common/context/id/stash
# 配列をランダムに動かす
execute store result score $Argument.Index Lib run function lib:random/
scoreboard players operation $Argument.Index Lib %= $CandidateLength Temporary
function lib:array/move
# 引数に代入
data modify storage asset:context id set from storage lib: Array[-1]
data modify storage asset:context Type set from storage asset:artifact Type
data modify storage api: Argument.ID set from storage lib: Array[-1]
# 呼び出し
function #asset:artifact/give
# asset:context idを戻す
function asset_manager:common/context/id/pop
function api:artifact/core/from_id

# リセット&ループ
data remove storage lib: Array[-1]
scoreboard players remove $CandidateLength Temporary 1
scoreboard players remove $Pulls Temporary 1
execute if score $Pulls Temporary matches 0.. if data storage lib: Array[0] run function asset_manager:artifact/give/candidates
execute if score $Pulls Temporary matches 0.. if data storage lib: Array[0] run function api:artifact/core/from_rarity/foreach
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@

# validate
execute unless data storage api: Argument.ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" ID","color":"red"}]
# 既存にasset:context idが存在する場合に備えて退避させる
function asset_manager:common/context/id/stash
# 代入
data modify storage asset:context id set from storage api: Argument.ID
data modify storage asset:context Type set value "give"
execute unless data storage api: Argument.ID run return fail
# 呼び出し
execute if data storage api: Argument.ID run function #asset:artifact/give
# 退避させたasset:context idを戻す
function asset_manager:common/context/id/pop
data modify storage api: Argument.Type set value "give"
function api:artifact/core/from_id
# リセット
data remove storage api: Argument.ID
data remove storage api: Argument.Type
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

# validate
execute unless data storage api: Argument.Rarity run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" Rarity","color":"red"}]
execute unless data storage api: Argument.Rarity run return fail
# 呼び出し
data modify storage asset:context Type set value "give"
execute if data storage api: Argument.Rarity run function asset_manager:artifact/give/
data modify storage api: Argument.Type set value "give"
function api:artifact/core/from_rarity/
# リセット
data remove storage api: Argument.Rarity
data remove storage api: Argument.Type
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@
# 神器Assetの入手処理を叩く処理
#
# @input storage api:
# Argument.ID
# Argument.Slot
# Argument.ID : int
# Argument.Slot? : string (default: "mainhand")
# @api

# validate
execute unless data storage api: Argument.ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" ID","color":"red"}]
# 既存にasset:context idが存在する場合に備えて退避させる
function asset_manager:common/context/id/stash
# 代入
data modify storage asset:context id set from storage api: Argument.ID
execute if data storage api: Argument.Slot run data modify storage asset:context Slot set from storage api: Argument.Slot
data modify storage asset:context Type set value "replace"
execute unless data storage api: Argument.ID run return fail
execute unless data storage api: Argument.Slot run data modify storage api: Argument.Slot set value "mainhand"
# 呼び出し
execute if data storage api: Argument.ID run function #asset:artifact/give
# 退避させたasset:context idを戻す
function asset_manager:common/context/id/pop
data modify storage api: Argument.Type set value "replace"
function api:artifact/core/from_id
# リセット
data remove storage api: Argument.ID
data remove storage api: Argument.Slot
data remove storage api: Argument.Type
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
#
# 神器Assetの入手処理を叩く処理
#
# @input storage api: Argument.Rarity
# @input storage api:
# Argument.Rarity : (1 | 2 | 3 | 4)
# Argument.Slot? : string (default: "mainhand")
# @api

# validate
execute unless data storage api: Argument.Rarity run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" Rarity","color":"red"}]
execute unless data storage api: Argument.Rarity run return fail
execute unless data storage api: Argument.Slot run data modify storage api: Argument.Slot set value "mainhand"
# 呼び出し
data modify storage asset:context Type set value "replace"
execute if data storage api: Argument.Rarity run function asset_manager:artifact/give/
data modify storage api: Argument.Type set value "replace"
function api:artifact/core/from_rarity/
# リセット
data remove storage api: Argument.Rarity
data remove storage api: Argument.Slot
data remove storage api: Argument.Type
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,18 @@
# 神器Assetの入手処理を叩く処理
#
# @input storage api:
# Argument.Rarity : (1 | 2 | 3 | 4)
# Argument.Important : boolean
# Argument.ID : int
# Argument.Important? : boolean (default: true)
# @api

# validate
execute unless data storage api: Argument.ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" ID","color":"red"}]
# 既存にasset:context idが存在する場合に備えて退避させる
function asset_manager:common/context/id/stash
# 代入
data modify storage asset:context id set from storage api: Argument.ID
data modify storage asset:context Type set value "drop"
data modify storage asset:context Important set from storage api: Argument.Important
execute unless data storage api: Argument.ID run return fail
execute unless data storage api: Argument.Important run data modify storage api: Argument.Important set value true
# 呼び出し
execute if data storage api: Argument.ID run function #asset:artifact/give
# 退避させたasset:context idを戻す
function asset_manager:common/context/id/pop
data modify storage api: Argument.Type set value "drop"
function api:artifact/core/from_id
# リセット
data remove storage asset:context Important
data remove storage api: Argument.ID
data remove storage api: Argument.Important
data remove storage api: Argument.Type
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
#
# @input storage api:
# Argument.Rarity : (1 | 2 | 3 | 4)
# Argument.Important : boolean
# Argument.Important? : boolean (default: fa;se)
# @api

# validate
execute unless data storage api: Argument.Rarity run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" Rarity","color":"red"}]
execute unless data storage api: Argument.Rarity run return fail
execute unless data storage api: Argument.Important run data modify storage api: Argument.Important set value true
# 呼び出し
data modify storage asset:context Type set value "drop"
data modify storage asset:context Important set from storage api: Argument.Important
execute if data storage api: Argument.Rarity run function asset_manager:artifact/give/
data modify storage api: Argument.Type set value "drop"
function api:artifact/core/from_rarity/
# リセット
data remove storage asset:context Important
data remove storage api: Argument.Rarity
data remove storage api: Argument.Important
data remove storage api: Argument.Type
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#> asset:artifact/alias/65534/attack
#
# 神器の攻撃時の処理のエイリアス
#
# @within asset_manager:artifact/triggers/attack/attack.m

# 元の登録処理を呼び出す
function asset:artifact/ex.2/attack/
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#> asset:artifact/alias/65534/dis_equip
#
# 神器の装備解除時の処理のエイリアス
#
# @within asset_manager:artifact/triggers/dis_equip/dis-equip.m

# 元の登録処理を呼び出す
function asset:artifact/ex.2/dis-equip/
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#> asset:artifact/alias/65534/equip
#
# 神器の装備時の処理のエイリアス
#
# @within asset_manager:artifact/triggers/equip/equip.m

# 元の登録処理を呼び出す
function asset:artifact/ex.2/equip/
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#> asset:artifact/alias/65534/register
#
# 神器のデータ指定処理のエイリアス
#
# @within asset_manager:artifact/triggers/register.m

# 元の登録処理を呼び出す
function asset:artifact/ex.2/register
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#> asset:artifact/alias/65535/attack
#
# 神器の攻撃時の処理のエイリアス
#
# @within asset_manager:artifact/triggers/attack/attack.m

# 元の登録処理を呼び出す
function asset:artifact/ex.1/attack/
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#> asset:artifact/alias/65535/register
#
# 神器のデータ指定処理のエイリアス
#
# @within asset_manager:artifact/triggers/register.m

# 元の登録処理を呼び出す
function asset:artifact/ex.1/register
Loading
Loading