自作投げナイフにおける与ダメの数値設定の動作不良

on right click:
cooldown of diamond sword of player <= 0
set {_k} to player's tool
name of {_k} contains "Knife"
type of {_k} is diamond sword
if name of {_k} contains "Survival":
set {_damage} to 25
set {_name} to name of player's tool
# 名前から残段数とか取得する処理
# 文字数過多のため省略
if {_n} > 0:
set name of player's tool to "%{_n1}%«%{_n}-1%»%{_n2}%"
else if {_n} is 0:
add -1 to item amount of player's tool
play sound "entity.player.attack.sweep" with volume 1.2 and pitch 1.5 at {_loc}
set cooldown of diamond sword of player to 2
set {_p} to player
if {_p} is set:
set {_vec} to entityHeadVec({_p})
set {_loc} to location at {_p}'s head ~ {_vec}
set normal length of {_vec} to 0.9
set yaw of {_loc} to yaw of player's head
set pitch of {_loc} to pitch of player's head
spawn armor stand at {_loc} ~ vector 0,-1,0 with nbt "{Invisible:true,Small:true,NoBasePlate:true,Pose:{Head:[%pitch of player%f,0f,0f]}}"
#spawn armor stand at {_loc} ~ vector 0,-1,0 with nbt "{Small:true,NoBasePlate:true,Pose:{Head:[%pitch of player%f,0f,0f]}}"
set {_knife} to last spawned entity
#set {_knife}'s gravity to false
#set shooter of {_knife} to player
set metadata "damage" of {_knife} to {_damage}
set metadata "shooter" of {_knife} to player
loop 350 times:
if {_knife} is not alive:
exit 2 sections
delete velocity of {_knife}
set {_l} to {_loc}
set {_loc} to {_loc} ~ {_vec}
set {_loc} to {_loc} ~ vector 0,-0.01,0
set {_vec} to vector from {_l} to {_loc}
push {_knife} {_vec}
wait 1 tick
loop-num is 1
set {_knife}'s helmet to {_k}
on right click:
cooldown of diamond sword of player <= 0
set {_k} to player's tool
name of {_k} contains "Knife"
type of {_k} is diamond sword
if name of {_k} contains "Survival":
set {_damage} to 25
set {_name} to name of player's tool
# 名前から残段数とか取得する処理
# 文字数過多のため省略
if {_n} > 0:
set name of player's tool to "%{_n1}%«%{_n}-1%»%{_n2}%"
else if {_n} is 0:
add -1 to item amount of player's tool
play sound "entity.player.attack.sweep" with volume 1.2 and pitch 1.5 at {_loc}
set cooldown of diamond sword of player to 2
set {_p} to player
if {_p} is set:
set {_vec} to entityHeadVec({_p})
set {_loc} to location at {_p}'s head ~ {_vec}
set normal length of {_vec} to 0.9
set yaw of {_loc} to yaw of player's head
set pitch of {_loc} to pitch of player's head
spawn armor stand at {_loc} ~ vector 0,-1,0 with nbt "{Invisible:true,Small:true,NoBasePlate:true,Pose:{Head:[%pitch of player%f,0f,0f]}}"
#spawn armor stand at {_loc} ~ vector 0,-1,0 with nbt "{Small:true,NoBasePlate:true,Pose:{Head:[%pitch of player%f,0f,0f]}}"
set {_knife} to last spawned entity
#set {_knife}'s gravity to false
#set shooter of {_knife} to player
set metadata "damage" of {_knife} to {_damage}
set metadata "shooter" of {_knife} to player
loop 350 times:
if {_knife} is not alive:
exit 2 sections
delete velocity of {_knife}
set {_l} to {_loc}
set {_loc} to {_loc} ~ {_vec}
set {_loc} to {_loc} ~ vector 0,-0.01,0
set {_vec} to vector from {_l} to {_loc}
push {_knife} {_vec}
wait 1 tick
loop-num is 1
set {_knife}'s helmet to {_k}
8 Replies
月猫ch
月猫chOP10mo ago
on spawn of armor stand:
wait 1 tick
set {_knife} to entity
metadata "damage" of {_knife} > 0
delete {_damagesource}
set {_shooter} to metadata "shooter" of {_knife}
set {_damagesource} to new damage source with type "player"
set damage source entity of {_damagesource} to {_shooter}
set ignore no damage ticks of {_damagesource} to true
set prevent knockback of {_damagesource} to true
set {_flag} to false
set {_uuid} to uuid of {_knife}
loop 350 times:
wait 1 tick
loop living entities where [distance between {_knife} and input <= 2.5]:
loop-entity is not {_knife}
set {_damage} to metadata "damage" of {_knife}
if distance between loop-entity's head and {_knife}'s head <= 0.6:
set {_damage} to {_damage}*4
set {_flag} to true
else if distance between loop-entity and {_knife} <= 1:
set {_flag} to true
if {_flag} is true:
# ↓skRageの構文でもskQueryの構文でもダメージのバグは同じ
#damage loop-entity by {_damage} with damage source {_damagesource}
make {_shooter} damage loop-entity by {_damage}
# skQueryの構文だと、なぜかここから先が処理されない
send "&f%{_shooter}%&7➡%loop-entity% &e%{_damage}% &f: &e% distance between loop-entity's head and {_knife}'s head%m" to {_shooter}
play sound "entity.wither.break_block" with pitch 2 at location at {_knife} ~ vector 0,1,0
play sound "entity.wither.break_block" with pitch 2 to {_shooter}
play sound "item.shield.break" with volume 0.25 and pitch 1 at location at {_knife} ~ vector 0,1,0
kill entity
delete {knifeLoc::%{_uuid}%}
exit 3 sections
set {knifeLoc::%{_uuid}%} to location at {_knife}
on spawn of armor stand:
wait 1 tick
set {_knife} to entity
metadata "damage" of {_knife} > 0
delete {_damagesource}
set {_shooter} to metadata "shooter" of {_knife}
set {_damagesource} to new damage source with type "player"
set damage source entity of {_damagesource} to {_shooter}
set ignore no damage ticks of {_damagesource} to true
set prevent knockback of {_damagesource} to true
set {_flag} to false
set {_uuid} to uuid of {_knife}
loop 350 times:
wait 1 tick
loop living entities where [distance between {_knife} and input <= 2.5]:
loop-entity is not {_knife}
set {_damage} to metadata "damage" of {_knife}
if distance between loop-entity's head and {_knife}'s head <= 0.6:
set {_damage} to {_damage}*4
set {_flag} to true
else if distance between loop-entity and {_knife} <= 1:
set {_flag} to true
if {_flag} is true:
# ↓skRageの構文でもskQueryの構文でもダメージのバグは同じ
#damage loop-entity by {_damage} with damage source {_damagesource}
make {_shooter} damage loop-entity by {_damage}
# skQueryの構文だと、なぜかここから先が処理されない
send "&f%{_shooter}%&7➡%loop-entity% &e%{_damage}% &f: &e% distance between loop-entity's head and {_knife}'s head%m" to {_shooter}
play sound "entity.wither.break_block" with pitch 2 at location at {_knife} ~ vector 0,1,0
play sound "entity.wither.break_block" with pitch 2 to {_shooter}
play sound "item.shield.break" with volume 0.25 and pitch 1 at location at {_knife} ~ vector 0,1,0
kill entity
delete {knifeLoc::%{_uuid}%}
exit 3 sections
set {knifeLoc::%{_uuid}%} to location at {_knife}
月猫ch
月猫chOP10mo ago
こんな感じのアイテムを持ってるときに 投げナイフをぶん投げるシステムです 構造としては ①アイテム識別 ②vectorを使って事前に飛翔経路を作成 ③アマスタをスポーンさせてヘルメットにナイフを置く ※ナイフアイテムをリソパで飛翔するナイフの見た目にしてある ④アマスタがスポーンしてから毎ティック、周囲のエンティティを取得する ⑤位置とか比較してボディに当たったかHSかを識別 ⑥skRageの構文でダメージを与える ⑦アマスタを消す といったもの
No description
月猫ch
月猫chOP10mo ago
上記コードである程度問題なく動くのですが 致命的な謎の挙動が起きています
set metadata "damage" of {_knife} to {_damage}
set metadata "shooter" of {_knife} to player
set metadata "damage" of {_knife} to {_damage}
set metadata "shooter" of {_knife} to player
ここらへんでmetadataをアマスタに与えて それを二個目のコードのほうで取得して
loop living entities where [distance between {_knife} and input <= 2.5]:
loop-entity is not {_knife}
set {_damage} to metadata "damage" of {_knife}
if distance between loop-entity's head and {_knife}'s head <= 0.6:
set {_damage} to {_damage}*4
set {_flag} to true
else if distance between loop-entity and {_knife} <= 1:
set {_flag} to true
if {_flag} is true:
broadcast "&f%{_shooter}%➡%loop-entity% &e%{_damage}% &f: &e% distance between loop-entity's head and {_knife}'s head%m"
damage loop-entity by {_damage} with damage source {_damagesource}
exit 3 sections
loop living entities where [distance between {_knife} and input <= 2.5]:
loop-entity is not {_knife}
set {_damage} to metadata "damage" of {_knife}
if distance between loop-entity's head and {_knife}'s head <= 0.6:
set {_damage} to {_damage}*4
set {_flag} to true
else if distance between loop-entity and {_knife} <= 1:
set {_flag} to true
if {_flag} is true:
broadcast "&f%{_shooter}%➡%loop-entity% &e%{_damage}% &f: &e% distance between loop-entity's head and {_knife}'s head%m"
damage loop-entity by {_damage} with damage source {_damagesource}
exit 3 sections
ダメージとして使う想定なのですが ここをどれだけ変えても20固定になります 厳密には、単発で当てても どれだけ{_damage}の数値を直にいじっても20しか入らないのに対して なぜか連射すると20、{_damage}の数値、20、{_damage}の数値と、きれいに交互に {_damage}が適応されたりされなかったりします metadata "damage" of {_knife}の数値が直に適応されてるのかと思い そっちも変えてみたりしたのですが、どれだけいじっても交互に20ダメージが発生します
月猫ch
月猫chOP10mo ago
動画にしてきました この時は{_damage}を固定で25とかにしてます 判定的にはしっかりHS入ってますが 実際の数値は20と100を前後します 原因がわかりません くそ長コードで申し訳ないのですが誰か中身見てもらえないでしょうか
akon
akon10mo ago
それskqueryのdamage使ってもそうなるの
月猫ch
月猫chOP10mo ago
なるっすね… だから、たぶん根本的にはskRageが原因じゃないとおもいやす ダメージ自体はskRageとskQueryで同じでした
loop 350 times:
wait 1 tick
if block at (location at {_knife} ~ vector 0,0.5,0) is not air, wall sign, sunflower, vine or grass:
exit 2 sections
if {_knife} is on ground:
exit 2 sections
if distance between {knifeLoc::%{_uuid}%} and location at {_knife} <= 0.2:
exit 2 sections
loop living entities where [distance between {_knife} and input <= 2.5]:
loop-entity is not {_knife}
set {_damage} to metadata "damage" of {_knife}
if distance between loop-entity's head and {_knife}'s head <= 0.6:
set {_damage} to {_damage}*4
set {_flag} to true
else if distance between loop-entity and {_knife} <= 1:
set {_flag} to true
if {_flag} is true:
broadcast "&f%{_shooter}%➡%loop-entity% &e%{_damage}% &f: &e% distance between loop-entity's head and {_knife}'s head%m"
#damage loop-entity by {_damage} with damage source {_damagesource}
make {_shooter} damage loop-entity by {_damage}
exit 3 sections
set {knifeLoc::%{_uuid}%} to location at {_knife}
if {_flag} is true:
play sound "entity.wither.break_block" with pitch 2 at location at {_knife} ~ vector 0,1,0
play sound "entity.wither.break_block" with pitch 2 to {_shooter}
play sound "item.shield.break" with volume 0.25 and pitch 1 at location at {_knife} ~ vector 0,1,0
kill entity
delete {knifeLoc::%{_uuid}%}
loop 350 times:
wait 1 tick
if block at (location at {_knife} ~ vector 0,0.5,0) is not air, wall sign, sunflower, vine or grass:
exit 2 sections
if {_knife} is on ground:
exit 2 sections
if distance between {knifeLoc::%{_uuid}%} and location at {_knife} <= 0.2:
exit 2 sections
loop living entities where [distance between {_knife} and input <= 2.5]:
loop-entity is not {_knife}
set {_damage} to metadata "damage" of {_knife}
if distance between loop-entity's head and {_knife}'s head <= 0.6:
set {_damage} to {_damage}*4
set {_flag} to true
else if distance between loop-entity and {_knife} <= 1:
set {_flag} to true
if {_flag} is true:
broadcast "&f%{_shooter}%➡%loop-entity% &e%{_damage}% &f: &e% distance between loop-entity's head and {_knife}'s head%m"
#damage loop-entity by {_damage} with damage source {_damagesource}
make {_shooter} damage loop-entity by {_damage}
exit 3 sections
set {knifeLoc::%{_uuid}%} to location at {_knife}
if {_flag} is true:
play sound "entity.wither.break_block" with pitch 2 at location at {_knife} ~ vector 0,1,0
play sound "entity.wither.break_block" with pitch 2 to {_shooter}
play sound "item.shield.break" with volume 0.25 and pitch 1 at location at {_knife} ~ vector 0,1,0
kill entity
delete {knifeLoc::%{_uuid}%}
が、skRage➡skQueryにしただけで それ以降の処理がされなくなりました
akon
akon10mo ago
それエラーかなんかconsoleにでてるの
月猫ch
月猫chOP10mo ago
なんもでなかったっす あああああああああああああああああああああ わかった!!! これ、skRageだろうが何だろうが とりあえず殴った判定でダメージ与えてるから CSの近接項目でダメージが上書きされてるんだ!! (投げナイフアイテムはCSの近接項目で元のアイテムを作ってる) んで殴るCTでCSの近接が発生してない間は、投げナイフで上書きされる だからスピーディに連射したらダメージがCSで上書きされずに 投げナイフ通りに動くんだ… あ~~~~
Want results from more Discord servers?
Add your server