#(snozbear) Entity damaged by entity

60 messages · Page 1 of 1 (latest)

young tiger
#

Hey there,

I'm having a little trouble understanding the "entity damaged by entity event"

I'm trying to trigger something when a player takes damage while flagged "test" but it only runs if the player flagged is the one doing the damage.

on player damaged flagged:test:
- narrate "damaged"

Sorry if this is basic the wording just has me confused lol. Should I just do an if <context.entity.has_flag[test]> line after it and go from there or is there a better way to do it?

Tysm

full cloudBOT
#

(snozbear) Entity damaged by entity

full cloudBOT
#

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.

rigid meadow
#

seems to work as intended for me

#

!debug

inner wrenBOT
# rigid meadow !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!

rigid meadow
#

are you testing this by having a player hit another?

dapper lichen
#

Usually isn't the flagged switch only for the first player in the event? So in this case it's only for the damager?

vocal stream
#

!e entity damaged

inner wrenBOT
# vocal stream !e entity damaged
Group

Entity

Event Lines

<entity> damaged by <entity> <entity> damaged (by <cause>) <entity> damages <entity>

Switches

with:<item> to only process the event when the item used to cause damage (in the damager's hand) is a specified item.
type:<entity> to only run if the entity damaged matches the entity input.
block:<block-matcher> to only run if the damage came from a block that matches the given material or location matcher.

Triggers

when an entity is damaged.

Has Player

when the damager or damaged entity is a player. Cannot be both. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.

Has NPC

when the damager or damaged entity is an NPC. Cannot be both.

Context

<context.entity> returns the EntityTag that was damaged.
<context.damager> returns the EntityTag damaging the other entity, if any.
<context.damager_block> returns the LocationTag of a block that damaged the entity, if any.
<context.cause> returns an ElementTag of reason the entity was damaged - see !language damage cause for causes.
<context.damage> returns an ElementTag(Decimal) of the amount of damage dealt.
<context.final_damage> returns an ElementTag(Decimal) of the amount of damage dealt, after armor is calculated.
<context.projectile> returns a EntityTag of the projectile, if one caused the event.
<context.damage_type_map> returns a MapTag the damage dealt by a specific damage type with keys: B...
<context.was_critical> returns 'true' if the damage was a critical hit. (Warning: this value is ca...

Determine

ElementTag(Decimal) to set the amount of damage the entity receives.
"CLEAR_MODIFIERS" to zero out all damage modifiers other than "BASE", effectively making damage == final_damage.

Has Known Location

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

Examples

Examples too long to display... Check the website for more examples

vocal stream
#

They both take a matcher, you can just use the player_flagged: entity matcher if you want to be specific

#

!obj EntityTag

inner wrenBOT
# vocal stream !obj EntityTag

An EntityTag represents a spawned entity, or a generic entity type.

Note that players and NPCs are valid EntityTags, but are generally represented by the more specific
PlayerTag and NPCTag objects.

Note that a spawned entity can be a living entity (a player, NPC, or mob) or a nonliving entity (a painting, item frame, etc).

This object type is flaggable.
Flags on this object type will be stored in the world chunk files as a part of the entity's NBT.

Prefix

e

Base Type

ElementTag

Implements

FlaggableObject, PropertyHolderObject

Format

The identity format for entities is a spawned entity's UUID, or an entity type.
For example, 'e@abc123' or 'e@zombie'.

vocal stream
#

"player_flagged:<flag>": a Flag Matchable for PlayerTag flags (will never match non-players).

young tiger
#

sorry for some reason my stinking discord didn't notify me of updates to the thread 🥴

#

I think I mightve been misreading "player damaged" as "player is damaged" rather than "player damaged something" when what I want is the former

rigid meadow
#

that's what it is

#

"player damaged" = "player is damaged"

#

but the "flagged" switch fires on whatever player is registered to that event

#

if the damager is a player, it'll check for the flag on that player

#

if the damager or cause of damage is not a player, it'll check the entity for the flag

young tiger
#

I dunno what I'm doing then lol, if I use flagged or not it seems to just default to the person who caused the damage

The first one Wrackspurt hit Tanis, and the second was the other way around just using

- narrate "damaged"```

https://paste.denizenscript.com/View/139782
rigid meadow
#

yeah, that's intentional

#

again, the player link will check if the damager is a player first

#

if it is, it'll link <player> to them

#

by extension, the narrate command and flagged: switch

young tiger
#

Even if the damagee is flagged it still does the same thing though

rigid meadow
#

does it work as you want when a player isn't damaged by another player

young tiger
#

lemme check

#

yes that works fine

rigid meadow
#

then it works as intended

young tiger
#

Okay thats sorta confusing but fair enough

rigid meadow
#

i'll give you a scenario

#

you have two players, A and B

#

if A punches B, the event will link the <player> tag to player A

#

because the damage_r_ is a player

#

if A takes fall damage, it'll link the <player> tag to player A because there is no damage_r_

#

now let's say that player B gets hits by a zombie

#

because the zombie is not a player, the <player> tag can't get linked to it, so it goes to the damage_e_

#

in this case, player B

#

but <player> cannot be both players A and B in the same event

young tiger
#

Yeah, I understand it now just for some reason

"player damaged" reads to me as "player is damaged" which is how it functions if its just one party involved. but if another person is involved then its actually "player damaged someone else"

I get it now its just not very intuitive to me at least

rigid meadow
#

i get that, but if there's any consolation, <context.entity> will always return the one that was damaged, and <context.damager> will always return the one that caused the damage (if there is one)

young tiger
#

Ye, I'll have to just do it that way

#

tysm for explaining prayer

rigid meadow
#

np

hazy questBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@young tiger

#
Resolved

Thread closed as resolved.

vocal stream
hazy questBOT
#
Thread Reopened

Thread was manually reopened by @vocal stream.

vocal stream
#

CC @young tiger ^

#

The matchers in the event line are explicitly either the damager or damagee, so you can just combine that with player_flagged:

#

player_flagged:test damaged damagee is flagged

#

entity damaged by player_flagged:test the damager is flagged

hazy questBOT
#
Changed to Help/Support

Thread is now a Help/Support thread. A helper will check your thread when available.

#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@young tiger