Skip to content

Commit

Permalink
爆発の魔導書 実装
Browse files Browse the repository at this point in the history
  • Loading branch information
EllaCoat committed Aug 25, 2024
1 parent a7b9bee commit 2b235a6
Show file tree
Hide file tree
Showing 21 changed files with 244 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#> asset:mob/0400.explosion_spellbook/_/death
#
# Mobの死亡時に実行されるfunction
#
# @within tag/function asset:mob/death

execute if data storage asset:context {id:400} run function asset:mob/0400.explosion_spellbook/death/
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#> asset:mob/0400.explosion_spellbook/_/init
#
# Mobの召喚時に実行されるfunction
#
# @within tag/function asset:mob/initialize

execute if data storage asset:context {id:400} run function asset:mob/0400.explosion_spellbook/init/
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#> asset:mob/0400.explosion_spellbook/_/register
#
#
#
# @within tag/function asset:mob/register

execute if data storage asset:context {id:400} run function asset:mob/0400.explosion_spellbook/register
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#> asset:mob/0400.explosion_spellbook/_/summon
#
#
#
# @within tag/function asset:mob/summon

execute if data storage asset:context {id:400} run function asset:mob/0400.explosion_spellbook/summon/
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#> asset:mob/0400.explosion_spellbook/_/tick
#
# Mobが生きている間毎tick実行されるfunction
#
# @within tag/function asset:mob/tick

execute if data storage asset:context {id:400} run function asset:mob/0400.explosion_spellbook/tick/
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#> asset:mob/0400.explosion_spellbook/_index.d
# @private

#> tag
# @within function asset:mob/0400.explosion_spellbook/**
#declare tag B4.Explode
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#> asset:mob/0400.explosion_spellbook/ai/explode/
#
# 爆発する
#
# @within function asset:mob/0400.explosion_spellbook/tick/

# 爆発タグを付ける
tag @s add B4.Explode

# 演出
particle explosion_emitter ~ ~1 ~ 0 0 0 0 1 force @a[distance=..32]
particle witch ~ ~1 ~ 2 2 2 1 100 force @a[distance=..32]
playsound entity.generic.explode hostile @a[distance=..32] ~ ~ ~ 2 1 0
playsound entity.generic.explode hostile @a[distance=..32] ~ ~ ~ 2 1.01 0

# ダメージ
# 引数の設定
# 与えるダメージ
data modify storage lib: Argument.Damage set value 45.0f
# 第一属性
data modify storage lib: Argument.AttackType set value "Magic"
# デスログ
data modify storage lib: Argument.DeathMessage append value '[{"translate": "%1$sの爆発によって%2$sは消し飛ばされた","with":[{"selector":"@s"},{"nbt":"Return.AttackerName","storage":"lib:","interpret":true}]}]'
# 補正functionを実行
function lib:damage/modifier
# ダメージを与える
execute as @a[gamemode=!creative,distance=..4] at @s run function lib:damage/
# リセット
function lib:damage/reset

# キル
kill @s
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#> asset:mob/0400.explosion_spellbook/death/
#
# Mobの死亡時の処理
#
# @within function asset:mob/0400.explosion_spellbook/_/death

# 死ぬ音
playsound minecraft:entity.zombie.break_wooden_door hostile @a ~ ~ ~ 0.6 0.7
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#> asset:mob/0400.explosion_spellbook/init/
#
# Mob召喚時のInit処理
#
# @within function asset:mob/0400.explosion_spellbook/_/init

# スコア設定
scoreboard players set @s B4.Tick 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#> asset:mob/0400.explosion_spellbook/load
#
# MOBに利用するスコアボード等の初期化処理
#
# @within tag/function asset:mob/load

#> 定義類はここに
# @within function asset:mob/0400.explosion_spellbook/**
scoreboard objectives add B4.Tick dummy
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#> asset:mob/0400.explosion_spellbook/register
#
# Mobのデータを指定
#
# @within function asset:mob/0400.explosion_spellbook/_/register

# 継承 (int) (オプション)
# data modify storage asset:mob Extends append value
# function asset:mob/extends

# 他のモブに継承されることを許可するか (boolean) (オプション)
# data modify storage asset:mob ExtendsSafe set value true
# ID (int)
data modify storage asset:mob ID set value 400
# Type (string) Wikiを参照
data modify storage asset:mob Type set value "Enemy"
# 干渉可能か否か (boolean)
data modify storage asset:mob Interferable set value true
# 名前 (TextComponentString) (オプション)
data modify storage asset:mob Name set value '{"text":"爆発の魔導書","color":"#FF8800"}'
# Mobの説明文 (TextComponentString[]) (オプション)
# data modify storage asset:mob Lore set value
# 武器
# メインハンド (Compound(Item)) (オプション)
# data modify storage asset:mob Weapon.Mainhand set value
# オフハンド (Compound(Item)) (オプション)
# data modify storage asset:mob Weapon.Offhand set value
# 武器ドロップ率 ([float, float]) (オプション)
# data modify storage asset:mob WeaponDropChances set value
# 防具
# 頭 (Compound(Item)) (オプション)
data modify storage asset:mob Armor.Head set value {id:"leather_horse_armor",Count:1b,tag:{CustomModelData:20138,display:{color:16746496}}}
# 胴 (Compound(Item)) (オプション)
# data modify storage asset:mob Armor.Chest set value
# 脚 (Compound(Item)) (オプション)
# data modify storage asset:mob Armor.Legs set value
# 足 (Compound(Item)) (オプション)
# data modify storage asset:mob Armor.Feet set value
# 防具ドロップ率 ([float, float]) (オプション)
# data modify storage asset:mob ArmorDropChances set value
# 体力 (double) (オプション)
data modify storage asset:mob Health set value 800
# 攻撃力 (double) (オプション)
# data modify storage asset:mob AttackDamage set value
# 防御力 (double) (オプション) // 被ダメージがある程度大きい場合1ptにつき0.8%カット、小さい場合1ptにつき約4%カット 20pt以上は頭打ち
data modify storage asset:mob Defense set value 0
# 特殊防御力 (double) (オプション) // 4pointにつきダメージを大きく減らす
# data modify storage asset:mob SpecialDefense set value
# 移動速度 (double) (オプション)
# data modify storage asset:mob Speed set value
# 索敵範囲 (double) (オプション)
# data modify storage asset:mob FollowRange set value
# ノックバック耐性 (double) (オプション)
# data modify storage asset:mob KnockBackResist set value
# 属性倍率 // 1.0fで100% 最低でも25%は軽減されずに入る
# 物理倍率 (float) (オプション)
data modify storage asset:mob Resist.Physical set value 1
# 魔法倍率 (float) (オプション)
data modify storage asset:mob Resist.Magic set value 0
# 火倍率 (float) (オプション)
data modify storage asset:mob Resist.Fire set value 1
# 水倍率 (float) (オプション)
data modify storage asset:mob Resist.Water set value 1
# 雷倍率 (float) (オプション)
data modify storage asset:mob Resist.Thunder set value 1

# フィールド
# data modify storage asset:mob Field set value {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#> asset:mob/0400.explosion_spellbook/summon/
#
# Mob召喚処理の呼び出し時に実行されるfunction
#
# @within asset:mob/0400.explosion_spellbook/_/summon

# 元となるMobを召喚する
summon zombie ~ ~ ~ {NoAI:1b,Silent:1b,Tags:["MobInit","AlwaysInvisible"],DeathLootTable:"asset:mob/death/0400.explosion_spellbook"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> asset:mob/0400.explosion_spellbook/summon/debug
#
# モブの動作チェック用の召喚処理 使い終わったら消してもいいかも
#
# @user
# @private

# モブを召喚
data modify storage api: Argument.ID set value 400
function api:mob/summon
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#> asset:mob/0400.explosion_spellbook/tick/
#
# Mobのtick時の処理
#
# @within function asset:mob/0400.explosion_spellbook/_/tick

# パーティクル
particle enchant ~ ~1.68 ~ 0.25 0.25 0.25 0 2 force @a[distance=..40]

# 接地で上を向く
execute unless block ~ ~-0.1 ~ #lib:no_collision at @s run tp @s ~ ~ ~ ~ ~-35
execute unless block ~ ~1 ~ #lib:no_collision at @s run tp @s ~ ~ ~ ~ ~80

# カベにぶつかった際の処理
execute at @s unless block ^ ^ ^0.5 #lib:no_collision at @s run tp @s ~ ~ ~ ~45 ~-45
execute at @s unless block ^ ^ ^0.2 #lib:no_collision at @s run tp @s ~ ~ ~ ~45 ~-45

# 範囲内ならホーミングじみた移動
execute facing entity @p feet positioned ^ ^ ^-100 rotated as @s positioned ^ ^ ^-800 facing entity @s feet positioned as @s run tp @s ^ ^ ^0.2 ~ ~

# スコア増やす
scoreboard players add @s B4.Tick 1

# プレイヤーが近くにいたら爆発
execute if entity @p[gamemode=!spectator,distance=..2] run function asset:mob/0400.explosion_spellbook/ai/explode/

# 時間が経過したら爆発
execute if score @s B4.Tick matches 500 run function asset:mob/0400.explosion_spellbook/ai/explode/
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"type": "entity",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "loot_table",
"name": "asset:mob/death/abstract_detect_item",
"functions": [
{
"function": "set_nbt",
"tag": "{TSB:{ID:400}}"
}
]
}
]
}
]
}
3 changes: 2 additions & 1 deletion Asset/data/asset/tags/functions/mob/death.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"values": [
"asset:mob/0400.explosion_spellbook/_/death",
"asset:mob/0398.crystal_healer/_/death",
"asset:mob/0397.crystal_turret/_/death",
"asset:mob/0392.ecual_first/_/death",
Expand Down Expand Up @@ -84,4 +85,4 @@
"asset:mob/0139.blast_eye/death/1.trigger",
"asset:mob/0186.ferocious_bee/death/1.trigger"
]
}
}
3 changes: 2 additions & 1 deletion Asset/data/asset/tags/functions/mob/initialize.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"values": [
"asset:mob/0400.explosion_spellbook/_/init",
"asset:mob/0398.crystal_healer/_/init",
"asset:mob/0397.crystal_turret/_/init",
"asset:mob/0392.ecual_first/_/init",
Expand All @@ -16,4 +17,4 @@
"asset:mob/0332.aurora_missile/_/init",
"asset:mob/0331.aurora_sorcerer/_/init"
]
}
}
3 changes: 2 additions & 1 deletion Asset/data/asset/tags/functions/mob/load.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"values": [
"asset:mob/0400.explosion_spellbook/load",
"asset:mob/0398.crystal_healer/load",
"asset:mob/0397.crystal_turret/load",
"asset:mob/0392.ecual_first/load",
Expand Down Expand Up @@ -98,4 +99,4 @@
"asset:mob/0139.blast_eye/0.load",
"asset:mob/0171.lumberjack_of_blue_forest/0.load"
]
}
}
3 changes: 2 additions & 1 deletion Asset/data/asset/tags/functions/mob/register.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"values": [
"asset:mob/0400.explosion_spellbook/_/register",
"asset:mob/0398.crystal_healer/_/register",
"asset:mob/0397.crystal_turret/_/register",
"asset:mob/0392.ecual_first/_/register",
Expand All @@ -26,4 +27,4 @@
"asset:mob/0083.thunder_trifler/_/register",
"asset:mob/0056.thunder_trifler/_/register"
]
}
}
3 changes: 2 additions & 1 deletion Asset/data/asset/tags/functions/mob/summon.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"values": [
"asset:mob/0400.explosion_spellbook/_/summon",
"asset:mob/0398.crystal_healer/_/summon",
"asset:mob/0397.crystal_turret/_/summon",
"asset:mob/0392.ecual_first/_/summon",
Expand Down Expand Up @@ -170,4 +171,4 @@
"asset:mob/0186.ferocious_bee/summon/1.trigger",
"asset:mob/0214.water_magic/summon/1.trigger"
]
}
}
3 changes: 2 additions & 1 deletion Asset/data/asset/tags/functions/mob/tick.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"values": [
"asset:mob/0400.explosion_spellbook/_/tick",
"asset:mob/0398.crystal_healer/_/tick",
"asset:mob/0397.crystal_turret/_/tick",
"asset:mob/0392.ecual_first/_/tick",
Expand Down Expand Up @@ -113,4 +114,4 @@
"asset:mob/0059.jack_o_lantern/tick/1.trigger",
"asset:mob/0139.blast_eye/tick/1.trigger"
]
}
}

0 comments on commit 2b235a6

Please sign in to comment.