Withern dgag

make the BountyHunter last as long {_count}

๐Ÿ“Ž 1 file 4,215 chars
๐Ÿ“„
pasted-code-1789769992296.txt
txt 156 lines
โ–ถ

# ============================================================
# 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 {_T} to event-item's name

			set {-T::%{_uuid}%} to {_T}
			set {-Tplayer::%{_uuid}%} to {_T} 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})

		# NO ENERGY COOLDOWN
		# NO ENERGY CHECK
		# NO ADVANCEMENT

		loop {-BountyCounter::%{_uuid}%} / 60 times:
			BountyHunter(player, {_target})
			wait 0.30 seconds

		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


function BountyHunter(p1: player, p2: player):
	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
	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} = 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
Kodari AI
KodariSep 18 at 10:22 pm 1
BountyHunterSystem
Creates a bounty hunting system where players use a recovery compass to select a target from a player list GUI. Players then place target-related items in a hopper GUI to activate a bounty. The system validates items via lore tags, calculates bounty value, plays warning sounds to the target, displays a "being watched" action bar message, and fires red particle beams toward the target. Includes inventory click handling, bounty counter updates, and item ownership verification.
Withern dgag

function bountyItemBelongsTo(i: item, target: text) :: boolean: if {_i} is air: return false

if {_i} is player skull: return true

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

Kodari AI
KodariSep 18 at 10:27 pm 1

Replace the function with:

Skript
function bountyItemBelongsTo(i: item, target: text) :: boolean:
    if {_i} is air:
        return false

    if {_i} is player skull:
        return true

    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

This makes every player skull count toward the bounty, regardless of its lore.

Kodari can make mistakes. Review important code before using.
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