개인 자료란 (JE)

  서버 커뮤니티

Profile starbix 대표칭호 없음
Profile

질문하기 스크립트

무기 강화 스크립트

2024.07.07 조회 수 168 추천 수 0
이해도 입문자 
게임버전 (JE) 1.20.1 
게임버전 (BE) 관련없음 
스크립트 버전 최신 버전 
스크립트 애드온 SKbee 

# 아이템 강화 스크립트 (모루 사용)


variables:

    {_damage_increase::*} = 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0

    {_protection_increase::*} = 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0


function upgrade_cost(level: number) :: number:

    return {_level} + 1


on anvil prepare:

    if target item is a sword or target item is a helmet or target item is a chestplate or target item is leggings or target item is boots:

        set {_item} to target item

        set {_level} to nbt tag "UpgradeLevel" of {_item}

        if {_level} is not set:

            set {_level} to 0

        set {_next_level} to {_level} + 1

        set {_cost} to upgrade_cost({_level})

        if {_cost} > 1:

            set {_cost_display} to "%{_cost}% diamonds"

        else:

            set {_cost_display} to "%{_cost}% diamond"

        set {_tooltip} to "Upgrade Cost: %{_cost_display}%"

        set {_item} to {_item} with lore {_tooltip}

        set event-item to {_item}


on anvil repair:

    if target item is a sword or target item is a helmet or target item is a chestplate or target item is leggings or target item is boots:

        set {_item} to target item

        set {_level} to nbt tag "UpgradeLevel" of {_item}

        if {_level} is not set:

            set {_level} to 0

        set {_cost} to upgrade_cost({_level})

        if player has {_cost} of diamonds:

            remove {_cost} of diamonds from player

            add 1 to {_level}

            set nbt tag "UpgradeLevel" of {_item} to {_level}

            if target item is a sword:

                set {_damage} to {_damage_increase::%{_level}%}

                add {_damage} to nbt tag "AttributeModifiers:[{AttributeName:\"generic.attack_damage\",Name:\"generic.attack_damage\",Amount:%{_damage}%,Operation:0,UUID:[I;1,1,1,1]}]" of {_item}

            else if target item is a helmet or target item is a chestplate or target item is leggings or target item is boots:

                set {_protection} to {_protection_increase::%{_level}%}

                add {_protection} to nbt tag "AttributeModifiers:[{AttributeName:\"generic.armor\",Name:\"generic.armor\",Amount:%{_protection}%,Operation:0,UUID:[I;1,1,1,1]}]" of {_item}

            send "Your %{_item}% has been upgraded to level %{_level}%!" to player

        else:

            send "You need %{_cost}% diamonds to upgrade your %{_item}%." to player

            cancel event

잘못된 부분과 수정해주시면 감사하겠습니다


1개의 댓글

코코냐
2024.07.07

문제 없이 의도대로 돌아가면 잘못된게 없는겁니다. 안되는게 있으면 어디가 안되는지를 알려주셔야합니다.

뉴스 및 창작물
/files/thumbnails/761/908/003/262x150.crop.jpg?20241025153749

건축

서울 숭례문(崇禮門) 4

KHC

2024-10-25

2

/files/thumbnails/578/899/003/262x150.crop.jpg?20241010142350

건축

경주 월정교 1

KHC

2024-10-10

2

/files/thumbnails/219/899/003/262x150.crop.jpg?20241009200950

건축

송전탑+도시 2

dbasd12

2024-10-09

2

/files/thumbnails/246/898/003/262x150.crop.jpg?20241008102328

레드스톤

단다단 - 오토노케(オトノケ) | 마인크래프트 노트블럭 커버

노트블럭전문가

2024-10-08

1

/files/thumbnails/348/896/003/262x150.crop.jpg?20241006103035

디도스/봇테러등등을 낚는 방법 4

물귀신

2024-10-06

3