プレイヤーから、プレイヤーの目線の5ブロック先までダメージ判定を与える方法

ビームを作ってみたいのですが、loop entitiesとか使っても上手くできません...毎度の如く、トライアンドエラーで1時間半ぐらい経過して分からなかったので聞きに来ました
18 Replies
Tsukineko(月雲)
実際にどんなコード書いたのかわかれば アドバイスしやすい 全部作って  なら話は別だけど
わし
わし7mo ago
#レーザーコマンド棒
on rightclick:
player's tool is stick named "&c&lLASER"
execute player command "laser"

#レーザーコマンド棒ゲット
command getlaser:
trigger:
give stick named "&c&lLASER" to player

#レーザーコマンド
command laser:
trigger:
set {_head} to location of player's head
set {_angle} to vector from yaw (yaw of player) and pitch (pitch of player)
play sound "entity.chicken.egg" with pitch 1.75 at player

#同時に何発も出したのを識別するID
set {_id} to random integer between 0 and 1000

loop 50 times:

#雪玉を等間隔に配置
add 0.1 to vector length of {_angle}
shoot snowball from location {_angle} {_head} at speed 0.1 {_angle}

#雪玉がビームの構成要素であることをスコアボードで示す
add "isLaser" to scoreboard tags of last shot snowball
add "laserId.%{_id}%" to scoreboard tags of last shot snowball
set shooter of last shot snowball to player

#1tick後に削除する
wait 1 ticks
loop all snowballs:
if loop-value has scoreboard tag "isLaser":
if shooter of loop-entity is player:
if loop-value has scoreboard tag "laserId.%{_id}%":
kill loop-entity

on projectile collide:
if event-projectile has scoreboard tag "isLaser":
cancel event
if invulnerability ticks of event-entity < 11:
if shooter of event-projectile is not event-entity:
damage event-entity by 6
play sound "entity.firework.blast" with pitch 1.75 at shooter

kill event-projectile
#レーザーコマンド棒
on rightclick:
player's tool is stick named "&c&lLASER"
execute player command "laser"

#レーザーコマンド棒ゲット
command getlaser:
trigger:
give stick named "&c&lLASER" to player

#レーザーコマンド
command laser:
trigger:
set {_head} to location of player's head
set {_angle} to vector from yaw (yaw of player) and pitch (pitch of player)
play sound "entity.chicken.egg" with pitch 1.75 at player

#同時に何発も出したのを識別するID
set {_id} to random integer between 0 and 1000

loop 50 times:

#雪玉を等間隔に配置
add 0.1 to vector length of {_angle}
shoot snowball from location {_angle} {_head} at speed 0.1 {_angle}

#雪玉がビームの構成要素であることをスコアボードで示す
add "isLaser" to scoreboard tags of last shot snowball
add "laserId.%{_id}%" to scoreboard tags of last shot snowball
set shooter of last shot snowball to player

#1tick後に削除する
wait 1 ticks
loop all snowballs:
if loop-value has scoreboard tag "isLaser":
if shooter of loop-entity is player:
if loop-value has scoreboard tag "laserId.%{_id}%":
kill loop-entity

on projectile collide:
if event-projectile has scoreboard tag "isLaser":
cancel event
if invulnerability ticks of event-entity < 11:
if shooter of event-projectile is not event-entity:
damage event-entity by 6
play sound "entity.firework.blast" with pitch 1.75 at shooter

kill event-projectile
雪玉を0.1mごとに召喚して当たったらダメージ できるかなーって思って気になったから書いちゃった 雪玉の棒がみょいーんって伸びていくのがキモいけど一応動きました on projectile hitは cancel eventできないのに on projectile collideはできるのうれしい
makaronipizaa
makaronipizaa7mo ago
on projectile collide: でcant understand this event出た.... loop all entities のあとに、front 5 blocks of playerみたいなのつけれないかなとか思って調べてました
loop all entities in radius 4 around player:
if loop-entities isn't "%player%":
make player damage loop-entity by 10
loop all entities in radius 4 around player:
if loop-entities isn't "%player%":
make player damage loop-entity by 10
これ見てfrontでもできないかなーとか思って
mirageeeeeeeeeeeeeeeeeeeeeeeeeee
Skript-paperを導入 ↑アドオン そしてraytraceを使用
わし
わし7mo ago
on projectile collideはskBeeだった rayTraceとかいう便利なのあるんだつよ
mirageeeeeeeeeeeeeeeeeeeeeeeeeee
両方あるやで
No description
mirageeeeeeeeeeeeeeeeeeeeeeeeeee
なんならSkript本体にも2.5から追加されてるっぽい
makaronipizaa
makaronipizaa7mo ago
これって結局難しい感じですか
Tsukineko(月雲)
できるよ set {_e::*} to all living entities where [distance between player and input <= 4]
わし
わし7mo ago
ぼくの解決法: https://skripthub.net/docs/?id=4443 大量の雪玉を前方5mに一瞬で敷き詰めて、当たったらダメージ与える みらげの解決法: https://skripthub.net/docs/?id=8344 実体の無い光線を前方に出して、物やエンティティに当たるかどうかの結果を出してくれるので、ダメージを与える
makaronipizaa
makaronipizaa7mo ago
なるほど!! なんかこれ違った プレイヤーを中心とした半径4ブロックになってた
Tsukineko(月雲)
あ、ごめん俺の勘違い 中心から4ブロックだと思ってた
makaronipizaa
makaronipizaa7mo ago
プレイヤーの見ている方向..?というか、プレイヤーの前方nブロック を変数に入れてmake player damage {_loc} by 100 みたいにできないかなー って思ってます これも試したんですけどraytraceがうまくいかない;;
unnnnnnnnnnn
unnnnnnnnnnn7mo ago
ヒント vector from yaw player's yaw pitch player's pitch location~vector loop entities in radius n around location 今気づいたけどこれよく見たらわかるはずだな これやりたいならblock n meters in front of playerみたいなの使えるけどおすすめしない 応用を考えるとvector使ってほしい
makaronipizaa
makaronipizaa7mo ago
set {_angle} to vector from yaw (yaw of player) and pitch (pitch of player)
set {_head} to location of player's head
loop 50 times:
loop all entities in radius 1 around location {_angle}:
make player damage loop-entity by 1
add 0.1 to vector length of {_angle}
set {_angle} to vector from yaw (yaw of player) and pitch (pitch of player)
set {_head} to location of player's head
loop 50 times:
loop all entities in radius 1 around location {_angle}:
make player damage loop-entity by 1
add 0.1 to vector length of {_angle}
なぜかloop 50 times:のところの数値を変えても↓のような場合だと一切相手に当たらないのですが
makaronipizaa
makaronipizaa7mo ago
No description
makaronipizaa
makaronipizaa7mo ago
なんなら↑のような場合でなくとも5ブロックぐらいまでしかあたらない... これもしかして add 0.1 to vector length of {_angle} ちがう? add {_angle} to {_head} にしてみた
set {_angle} to vector from yaw (yaw of player) and pitch (pitch of player)
set {_head} to location of player's head
loop 100 times:
loop all entities in radius 1 around {_head} ~ {_angle}:
make player damage loop-entity by 1
play flame on {_head} ~ {_angle}
add 0.1 to vector length of {_angle}
set {_angle} to vector from yaw (yaw of player) and pitch (pitch of player)
set {_head} to location of player's head
loop 100 times:
loop all entities in radius 1 around {_head} ~ {_angle}:
make player damage loop-entity by 1
play flame on {_head} ~ {_angle}
add 0.1 to vector length of {_angle}
flameはうまくいきました!!!!!!!!!!!!!!!!!!!!!!!! flameがあたってるモブにダメージが通ってないことが多々あります
loop all entities in radius 1 around {_head} ~ {_angle}:
loop all entities in radius 1 around {_head} ~ {_angle}:
多分悪いのここって思ってるんですけど どう直せばいいかわからない !! 1.5にしたらいい感じになった! vectorの仕様少し理解できたかも 二時間メモ帳とにらめっこした甲斐がありました
mirageeeeeeeeeeeeeeeeeeeeeeeeeee
そのまま数学のvectorにも行くぞ
Want results from more Discord servers?
Add your server
More Posts
if {test::%player%} is set:でクールタイムを作った時に、waitを使うとバグる```on rightclick holding enchanted book: if uncoloured name of player's tool is "test": テレポートしたとき、元の位置からどれだけ離れたかを変数にぶち込む方法お願いします視点を変えずに視点のところへTPする方法多分かなり初歩的な質問だと思うのですが、どうしても分からないのでご教授願います。スペクテイターのプレイヤーのみにタイトル表示させたいスペクテイターのプレイヤーのみにタイトルを表示させようと、 `if loop-player gamemode is “spectator”: send loop-player title “&Skriptでグラップリングフックの作り方右クリックした時に上と前側にプッシュされる簡単なやつではなく、Apexのパスファインダーみたいなグラップルが作りたいです。ほぼ制作依頼にはなりますが、何卒よろしくお願いしますskriptでwebsocketは使えるかskriptで、websocketは使えますか? もし使えたら、ドキュメントなどのURLが欲しいですymlファイルの画像部分のリストの取得方法がぞうのFN_5728みたいな、一番最初のkeyのリストが欲しいです ```yml test1: o: 1 test2: o: 1 test3: o: 1 ``` 例えば上記Y向いている方向に弾を飛ばすやり方を教えて欲しいやりたいことは ピストルを右クリックしたときにプレイヤーの向いている方向に距離減衰なし、即着の弾を飛ばすことです。 弾は透明にして、弾道にパーティクル(crit)をつけたいです。(障害物に当たると弾とon damageでアタッカーとして敵にダメージを入れたい``` on damage: if uncoloured name of attacker's tool is "護身用短剣": make attacker damage viSkrageのon cs damageについてevent-entityとは、ダメージを喰らったentityであっていますか? また、event-stringはダメージを与えた武器の登録名のことですか?