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

モブへの攻撃時処理を追加 #677

Merged
merged 10 commits into from
Feb 19, 2025
Merged
4 changes: 4 additions & 0 deletions data/entity/function/damage/add/physical/melee.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#> entity:damage/add/physical/melee
### 与えた武器ダメージを取得
execute store result score _ Damage run data get entity @e[tag=Enemy,nbt=!{AbsorptionAmount:2048f},limit=1] AbsorptionAmount -1
execute store result storage entity: damage.physical int 1 run scoreboard players add _ Damage 2048
22 changes: 22 additions & 0 deletions data/entity/function/damage/add/physical/projectile.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#> entity:damage/add/physical/projectile
### 投射物の物理ダメージを計算・付与
#Add
data modify storage calc: List set value []
data modify storage calc: List append from storage item: Equipments[].components."minecraft:attribute_modifiers".modifiers[{type:"minecraft:generic.attack_damage",operation:"add_value"}].amount
execute store result score _ Damage run function calc:list/sum/x1
#Increase
data modify storage calc: List set value []
data modify storage calc: List append from storage item: Equipments[].components."minecraft:attribute_modifiers".modifiers[{type:"minecraft:generic.attack_damage",operation:"add_multiplied_base"}].amount
execute store result score _ Calc run function calc:list/sum/x100
scoreboard players add _ Calc 100
#More
data modify storage calc: List set value []
data modify storage calc: List append from storage item: Equipments[].components."minecraft:attribute_modifiers".modifiers[{type:"minecraft:generic.attack_damage",operation:"add_multiplied_total"}].amount
execute store result score _ _ run function calc:list/product/x100
scoreboard players add _ _ 100
#合計
scoreboard players operation _ Damage *= _ _
scoreboard players set _ _ 100
scoreboard players operation _ Damage /= _ _
scoreboard players operation _ Damage *= _ Calc
execute store result storage entity: damage.physical int 1 run scoreboard players operation _ Damage /= _ _
287 changes: 287 additions & 0 deletions data/player/advancement/trigger/hurt_entity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
{
"criteria": {
"hit_projectile": {
"trigger": "minecraft:player_hurt_entity",
"conditions": {
"damage": {
"type": {
"tags": [
{
"id": "minecraft:is_projectile",
"expected": true
}
]
}
}
}
},
"melee_attack": {
"trigger": "minecraft:player_hurt_entity",
"conditions": {
"player": [
{
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"mainhand": {
"items": "#item:bows"
}
}
}
}
}
],
"damage": {
"dealt": {
"min": 2
},
"type": {
"tags": [
{
"id": "minecraft:is_explosion",
"expected": false
},
{
"id": "minecraft:is_fire",
"expected": false
},
{
"id": "minecraft:is_projectile",
"expected": false
},
{
"id": "minecraft:bypasses_armor",
"expected": false
},
{
"id": "minecraft:bypasses_effects",
"expected": false
},
{
"id": "minecraft:bypasses_enchantments",
"expected": false
},
{
"id": "minecraft:bypasses_resistance",
"expected": false
},
{
"id": "player:thorns",
"expected": false
}
]
}
}
}
},
"melee_attack2": {
"trigger": "minecraft:player_hurt_entity",
"conditions": {
"player": [
{
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:any_of",
"terms": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"mainhand": {
"items": "#item:bows"
}
}
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"mainhand": {
"items": "#item:swords"
}
}
}
}
]
}
}
],
"damage": {
"dealt": {
"max": 1
},
"type": {
"tags": [
{
"id": "minecraft:is_explosion",
"expected": false
},
{
"id": "minecraft:is_fire",
"expected": false
},
{
"id": "minecraft:is_projectile",
"expected": false
},
{
"id": "minecraft:bypasses_armor",
"expected": false
},
{
"id": "minecraft:bypasses_effects",
"expected": false
},
{
"id": "minecraft:bypasses_enchantments",
"expected": false
},
{
"id": "minecraft:bypasses_resistance",
"expected": false
},
{
"id": "player:thorns",
"expected": false
}
]
}
}
}
},
"melee_bow_attack": {
"trigger": "minecraft:player_hurt_entity",
"conditions": {
"player": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"mainhand": {
"items": "#item:bows"
}
}
}
}
],
"damage": {
"dealt": {
"min": 2
},
"type": {
"tags": [
{
"id": "minecraft:is_explosion",
"expected": false
},
{
"id": "minecraft:is_fire",
"expected": false
},
{
"id": "minecraft:is_projectile",
"expected": false
},
{
"id": "minecraft:bypasses_armor",
"expected": false
},
{
"id": "minecraft:bypasses_effects",
"expected": false
},
{
"id": "minecraft:bypasses_enchantments",
"expected": false
},
{
"id": "minecraft:bypasses_resistance",
"expected": false
},
{
"id": "player:thorns",
"expected": false
}
]
}
}
}
},
"sword_attack_sweep": {
"trigger": "minecraft:player_hurt_entity",
"conditions": {
"player": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"mainhand": {
"items": "#item:swords"
}
}
}
}
],
"damage": {
"dealt": 1,
"type": {
"tags": [
{
"id": "minecraft:is_explosion",
"expected": false
},
{
"id": "minecraft:is_fire",
"expected": false
},
{
"id": "minecraft:is_projectile",
"expected": false
},
{
"id": "minecraft:bypasses_armor",
"expected": false
},
{
"id": "minecraft:bypasses_effects",
"expected": false
},
{
"id": "minecraft:bypasses_enchantments",
"expected": false
},
{
"id": "minecraft:bypasses_resistance",
"expected": false
},
{
"id": "player:thorns",
"expected": false
}
]
}
}
}
}
},
"requirements": [
[
"hit_projectile",
"melee_attack",
"melee_attack2",
"melee_bow_attack",
"sword_attack_sweep"
]
],
"rewards": {
"function": "player:trigger/hurt_entity/"
}
}
20 changes: 20 additions & 0 deletions data/player/function/trigger/hurt_entity/.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#> player:trigger/hurt_entity/
### モブへのダメージトリガー

#モブの位置をマーク
execute at @e[tag=Enemy,nbt=!{AbsorptionAmount:2048f}] run function calc:geometry/tp_00002
#分岐
execute if entity @s[advancements={player:trigger/hurt_entity={hit_projectile=true}}] run function player:trigger/hurt_entity/hit_projectile
execute if entity @s[advancements={player:trigger/hurt_entity={melee_attack=true}}] run function player:trigger/hurt_entity/melee_attack
execute if entity @s[advancements={player:trigger/hurt_entity={melee_attack2=true}}] run function player:trigger/hurt_entity/melee_attack
execute if entity @s[advancements={player:trigger/hurt_entity={melee_bow_attack=true}}] run function player:trigger/hurt_entity/melee_bow_attack
execute if entity @s[advancements={player:trigger/hurt_entity={sword_attack_sweep=true}}] run function player:trigger/hurt_entity/sword_attack_sweep

##AbsorptionAmountリセット
execute at 0-0-0-0-2 as @e[tag=Enemy,nbt=!{AbsorptionAmount:2048f},distance=0] run function enemy:damage/update_health

#トリガーリセット
advancement revoke @s only player:trigger/hurt_entity

#マーカー返却
execute as 0-0-0-0-2 run function calc:geometry/return_marker
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#> player:trigger/hurt_entity/hit_projectile
### 投射物による攻撃

#投射物からロード
execute at 0-0-0-0-2 as @e[type=#entity:projectiles,limit=1,sort=nearest] run function player:trigger/projectile/load

#物理ダメージ付与
data modify storage entity: damage.hit set value 1b
execute at 0-0-0-0-2 as @e[tag=Enemy,nbt=!{AbsorptionAmount:2048f},distance=0] run function entity:damage/apply/physical

#狩人バースト用フラグ
tag @s add BurstArrow
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#> player:trigger/hurt_entity/melee_attack
### 近接攻撃

#装備を取得
function player:load_equipments
#物理ダメージ取得
data remove storage entity: damage
function entity:damage/add/physical/melee
### 黒魔導士<ライトニングブロー>
# execute if score @s LightningBlow matches 1.. run function skill:act/black_mage/lightning_blow/hit

#スキル用装備リスト
function skill:equipments_to_items
data remove storage item: Item
data modify storage item: Item set from storage item: Items[{components:{"minecraft:custom_data":{Skill:{Trigger:"近接攻撃する"}}}}]

### 忍者<連舞>
# execute if score @s TsuremaiLevel matches 1.. run function skill:act/ninja/tsuremai/trigger/attack

#近接スキルの場合、物理ダメージはスキル側で計算するため0にする
execute if data storage item: Item.components."minecraft:custom_data".Skill.Damage{Melee:1b} at 0-0-0-0-2 run data modify entity @e[tag=Enemy,nbt=!{AbsorptionAmount:2048f},distance=0,limit=1] AbsorptionAmount set value 2048f

### スキル
execute if data storage item: Item.components."minecraft:custom_data".Skill{Trigger:"近接攻撃する"} run function skill:practice/
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#> player:trigger/hurt_entity/melee_bow_attack
### 弓による近接攻撃

#ダメージを1にする
execute at 0-0-0-0-2 run data modify entity @e[tag=Enemy,nbt=!{AbsorptionAmount:2048f},distance=0,limit=1] AbsorptionAmount set value 2047f
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#> player:trigger/hurt_entity/sword_attack_sweep
### 剣の薙ぎ払い攻撃
2 changes: 1 addition & 1 deletion data/player/function/trigger/projectile/load.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ data modify storage item: SelectedItem set from storage oh_my_dat: _[-4][-4][-4]
data modify storage item: Equipments set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Equipments

#ダメージをロード
function skill:damage/load
function entity:damage/load

### スキル
execute if entity @s[tag=Skill] run function player:trigger/projectile/skill
Expand Down
2 changes: 1 addition & 1 deletion data/player/function/trigger/projectile/save.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].SelectedItem se
data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Equipments set from storage item: Equipments

#ダメージを保存
function skill:damage/save
function entity:damage/save
Loading