Files
bounty-hunter.sk
Code
1 157
bounty-hunter.sk
# ============================================================
# BOUNTY HUNTER
# ============================================================
function openBountyTargetMenu(p: player):
set {_s} to 0
set {_gui} to new chest inventory with 6 row with name "&8Select Target"
loop all players:
if loop-player is not {_p}:
set {_sk} to skull of loop-player
set slot {_s} of {_gui} to {_sk} named "%loop-player%"
add 1 to {_s}
wait 1 tick
open {_gui} to {_p}
# ============================================================
# RECOVERY COMPASS
# ============================================================
on right click:
if player's held item is recovery compass:
openBountyTargetMenu(player)
# ============================================================
# TEST COMMAND
# ============================================================
command /TestBounty:
permission: op
trigger:
openBountyTargetMenu(player)
# ============================================================
# TARGET SELECTION
# ============================================================
on inventory click:
if name of event-inventory is "&8Select Target":
cancel event
if event-item is a player head:
set {_uuid} to uuid of player
set {_target} to event-item's name
set {-T::%{_uuid}%} to {_target}
set {-Tplayer::%{_uuid}%} to {_target} parsed as player
set {-BountyCounter::%{_uuid}%} to 0
set {_gui} to a hopper inventory named "&8Place Items Belonging To Target"
open {_gui} to player
# ============================================================
# CLOSE BOUNTY GUI
# ============================================================
on inventory close:
if name of event-inventory is "&8Place Items Belonging To Target":
set {_uuid} to uuid of player
set {_target} to {-Tplayer::%{_uuid}%}
updateBountyCounter(player)
if {-BountyCounter::%{_uuid}%} is less than or equal to 0:
send "<##F10303>๐ฎ &cInsufficient amount of items." to player
delete {-T::%{_uuid}%}
delete {-Tplayer::%{_uuid}%}
delete {-BountyCounter::%{_uuid}%}
stop
send "<##F10303>๐ฎ &cActivated <##F10303>Bounty Hunter" to player
play sound "entity.warden.heartbeat" with volume 4 to {_target}
play sound "block.bell.use" with volume 10 and pitch 0.8 to {_target}
play sound "ambient.cave" with volume 8 and pitch 0.8 to {_target}
hunting({_target})
set {_count} to {-BountyCounter::%{_uuid}%} / 60
BountyHunter(player, {_target}, {_count})
set {-BountyCounter::%{_uuid}%} to 0
delete {-T::%{_uuid}%}
delete {-Tplayer::%{_uuid}%}
# ============================================================
# HUNTING
# ============================================================
function hunting(p: player):
loop 283 times:
send action bar "<##F10303>You feel like you're being watched..." to {_p}
wait 1 tick
# ============================================================
# BOUNTY HUNTER EFFECT
# Lasts for the full value of {_count}
# ============================================================
function BountyHunter(p1: player, p2: player, count: number):
loop {_count} times:
set {_v} to vector from {_p1}'s head to {_p2}'s head
set vector length of {_v} to 0.2
set {_loc} to the location 0.7 meters under {_p1}'s head
set {_distance} to 0
loop (distance between {_loc} and {_p2}) / 0.4 times:
add 1 to {_distance}
draw 3 dust using dustOption(rgb(241, 3, 3), 1) at {_loc} with force for {_p1}
set {_loc} to {_loc} ~ {_v}
if {_distance} is 8:
stop
wait 0.25 seconds
function updateBountyCounter(p: player):
set {_uuid} to uuid of {_p}
set {_target} to {-T::%{_uuid}%}
set {_count} to 0
loop 5 times:
set {_slot} to loop-number - 1
set {_item} to slot {_slot} of {_p}'s current inventory
if {_item} is not air:
if bountyItemBelongsTo({_item}, {_target}) is true:
add 60 to {_count}
set {-BountyCounter::%{_uuid}%} to {_count}
function bountyItemBelongsTo(i: item, target: text) :: boolean:
if {_i} is air:
return false
if lore of {_i} contains "&7(<#FFD773>%{_target}%'s&7)":
return true
if lore of {_i} contains "&7Return to <#FFD773>%{_target}%":
return true
if lore of {_i} contains "&7By <#FFD773>%{_target}%":
return true
return false