#(Revolver) How to reference a flag created inside of an item?

54 messages · Page 1 of 1 (latest)

surreal talon
#

what's the proper way to fetch a flag from inside of an item? I know you can establish flags within items but how can I refer to the that specific flag? For additional context, the flag inside of the item is a speed multiplier for the player based off of their health. Then, the grand idea is that inside of the "mechanisms:attribute_modifiers...amount: ?" I would insert the flag (that I know works). The problem isn't the flag, but getting the flag and using it somewhere else.

digital badgeBOT
#

(Revolver) How to reference a flag created inside of an item?

#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.
You can block this bot if you don't want to see these messages, I won't mind.
<@&525394568410038282>

surreal talon
#

The flag works, I know that much. I just want to reference the flag inside of the amount

loud estuary
#

Do you mean an item or an item script?

loud estuary
surreal talon
#

Yes, I know the script is working with the /ex narrate <player.item_in_hand> which lets me know that the flag is producing the value I want it to produce. However, what I want to do is take the value from that flag and put it into the amount inside of the attribute modifiers

loud estuary
#

Itemtags can use the flag tag. So you can do <player.item_in_hand.flag[berserker_speed_multiplier]>

surreal talon
#

Hmm, what about the flag_map? When I did the narrate, I got "...flag_map=map@[berserker_speed_multiplier]..."

#

or would I have to do something like <player.equipment_map.get[boots].flag[berserker_speed_multiplier]>

loud estuary
#

Using flag will pull information from the flag_map. This includes submapping so you can do <player.item_in_hand.flag[my_key.my_second_key.my_third_key]> and such.

As long as item tag has flags on it then flag should pull information from those flags.

loud estuary
surreal talon
loud estuary
#

Huh? That's strange.

odd trellisBOT
# loud estuary !debug
Info: debug

If you need help with a script issue, one of the most powerful tools Denizen has to offer is full debug output. This is displaying in your console whenever scripts are running until you turn debug off. To share a debug log quickly and easily with helpers, simply run the command /denizen debug -r in-game to begin recording, then run through the part of the script you need help with, then run the command /denizen submit. This will give you a link to a paste of the debug log, which you can then copy/paste back to us!

surreal talon
#

Ima try one more thing then I'll give that a whirl

loud estuary
odd trellisBOT
# loud estuary !checklogs https://paste.denizenscript.com/View/101976
Server Version

Paper version git-Paper-"fc9ee65" (MC: 1.18.2)

Plugin Version(s)

Citizens: 2.0.30-SNAPSHOT (build 2709) -- (Outdated build, behind by 1)
Denizen: 1.2.5-SNAPSHOT (build 1777-REL) -- (Current build :white_check_mark:)
Depenizen: 2.0.0 (build 802) -- (Current build :white_check_mark:)

Checked For

@loud estuary

Java Version

17 :white_check_mark:

Other Noteworthy Plugin(s)

WorldGuard: 7.0.7+216b061, MythicMobs: 5.1.4-3aa1b5d2, ProtocolLib: 4.8.0-b547

Possibly Relevant Plugin(s)

TAB: 3.1.1 - This plugin adds Below_Name scoreboards to NPCs.
ViaVersion: 4.4.3-SNAPSHOT - Mixed client vs server versions can sometimes cause packet-related issues.
ModelEngine: R3.0.1 - ModelEngine has Citizens support, but that support is known to be buggy. Issues related to NPCs that use ModelEngine should be reported to ModelEngine support, not Citizens.

loud estuary
surreal talon
#

I only posted the boots because it's the only relevant part I'm trying to tackle. I have my current version which works but there's a exploit that I'd like to get rid of so I've made this separate test version. I can show it off rq but the ultimate problem boiled down to that it worked, however, the buffs granted by the script remained even after the user removed the armor

loud estuary
#

I'm also going to bring up the fact that you're trying to change the attribute modifiers of an item based on a flag that assumes that the player exists, I am unsure of how you plan to give the item to players but I hope you don't have mobs spawning with the item somehow.

surreal talon
#

Hmm, an excellent point. Perhaps I should change player to <context.entity>? or does the context.* only work for world scripts?

loud estuary
#

I am unsure if context.entity can be called in an item script.

#

I am specifying this about your item script.

surreal talon
#

Good point. However, the flag does work cuz it returns the appropriate value. The only problem is trying to apply said value into the attribute modifier.
The armor will be a mythic reward item for a future event in the server so it's not going to be something worn by anything other than a player

loud estuary
#

When the item is created it will assume the player exists with that flag in mind, you're wanting to change the attribute modifier based on the players current health and logic. I feel like you should be changing this somewhere else, because you want this to be constantly based on the players health I assume?

surreal talon
#

Si.

I do have a working script that alters the player's buff every time they are damaged. However, there are still 2 exploits to the old script. There's the fact that if a player drops at say, 1 health, and then heals up without ever taking damage again, they will constantly retain that buff. The second exploit being that if they take the armor off in general, the buff still stays

loud estuary
#

It sounds like you need to check when the player equips or unequips the item, or the item is dropped onto the floor ( Or even put into a container of sorts. ) There exists events for equip/unequip but it's considered a bit unreliable.

#

!e equip

odd trellisBOT
# loud estuary !e equip
Required Plugins or Platforms

Paper

Group

Paper

**WARNING**

This event is not reliable, and may miss some types of equipment changes or fire when equipment hasn't actually changed.

Event Lines

player equips|unequips armor|helmet|chestplate|leggings|boots player equips|unequips <item>

Triggers

when a player (un)equips armor.

Has Player

Always. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.

Context

<context.new_item> returns the ItemTag that is now in the slot.
<context.old_item> returns the ItemTag that used to be in the slot.
<context.slot> returns the name of the slot.

surreal talon
#

I can certainly try this. I'll see what I can do

loud estuary
#

!e entity drops item

odd trellisBOT
# loud estuary !e entity drops item
Group

Entity

Event Lines

<entity> drops <item>

Triggers

when an entity drops an item.

Has Player

When the entity dropping an item is a player. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.

Context

<context.item> returns the ItemTag.
<context.entity> returns a EntityTag of the item.
<context.dropped_by> returns the EntityTag that dropped the item.
<context.location> returns a LocationTag of the item's location.

Has Known Location

True - this adds switches in:<area> + location_flagged:<flag name>.

Cancellable

True - this adds <context.cancelled> and determines cancelled + cancelled:false.

loud estuary
#

You could adjust the item mechanism of the context.entity when the specific armor is dropped, and then change the modifier. Setting it to potentially a default value. But since you're only allowing the modifier to be changed on the players current health when equipped, maybe you don't need to change the values at all on drop, unequip, and only on equip and damaged?

surreal talon
#

Okay, so, this works. NOW, the new problem is just updating the stats. lemme think

surreal talon
#

I got it, it's finally perfected

surreal talon
#

oh wait, I celebrated a bit fast, it's 85% there rofl

surreal talon
#

Okay, so I eliminated one of the problems. The buff now goes away when you unequip the armor. Now the only problem is that when you get low and then heal and never take damage again, you'll chill at that heightened state until you either take damage again or take the armor off

#

Okay, nevermind, NOW I got it for real.