#(benjid) Get weapon from damage event

58 messages · Page 1 of 1 (latest)

humble cloud
#

I want to check things about the weapon in a on player damages player event. I need to check the custom_model_data of the weapon.

eternal orioleBOT
#

(benjid) Get weapon from damage event

eternal orioleBOT
#

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.

desert cliff
#

Check the item in their hand if it's a held item.

#

Otherwise you'll need to consider a way of getting the item from a projectile launched.

#

!t playertag.item_in_hand

desert spadeBOT
humble cloud
#

but then they could use a bow and then quickly switch

desert cliff
#

Correct.

#

!e damages entity

desert spadeBOT
desert cliff
#

!e entity damaged by entity

desert spadeBOT
# desert cliff !e entity damaged by entity
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

desert cliff
#

Check if the projectile exists, if so then they fired it somehow.

#

!e projectile launch

desert spadeBOT
# desert cliff !e projectile launch
Group

Entity

Event Lines

projectile launched <entity> launched

Triggers

when a projectile is launched.

Context

<context.entity> returns the projectile.

Has Known Location

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

Cancellable

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

desert cliff
#

Hmm.

#

This is not the correct event, one second.

#

!e entity shoots bow

desert spadeBOT
# desert cliff !e entity shoots bow
Group

Entity

Event Lines

entity shoots bow <entity> shoots <item>

Triggers

when an entity shoots something out of a bow.

Has Player

when the entity that shot the bow is a player. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.

Has NPC

when the entity that shot the bow is an NPC.

Context

<context.entity> returns the EntityTag that shot the bow.
<context.projectile> returns a EntityTag of the projectile.
<context.bow> returns the ItemTag of the bow used to shoot.
<context.force> returns the force of the shot.
<context.item> returns an ItemTag of the shot projectile, if any.
<context.hand> returns "HAND" or "OFF_HAND" for which hand the bow was in.

Determine

ListTag(EntityTag) to change the projectile(s) being shot. (Note that in certain cases, determining an arrow may not be valid).
"KEEP_ITEM" to keep the projectile item on shooting it.

Has Known Location

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

Cancellable

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

desert cliff
#

Here we go.

#

Flag the projectile entity with the bow that it was fired from.

humble cloud
#

i suppose i could check <context.projectile> to confirm it wasnt ranged?

desert cliff
#

Yes.

#

If the projectile doesn't exist, then grab the damagers hand item.

humble cloud
#

Is it possible to get the diarection a player is looking?

#

I want to shoot fireballs from them

desert cliff
#

This seems unrelated to your previous issue.

#

Do you mean a compass direction?

humble cloud
#

i want to shoot fireballs in the diarection that the player is looking

desert cliff
#

!c shoot

desert spadeBOT
# desert cliff !c shoot
Group

entity

Syntax

shoot [<entity>|...] (origin:<entity>/<location>) (destination:<location>) (height:<#.#>) (speed:<#.#>) (script:<name>) (def:<element>|...) (shooter:<entity>) (spread:<#.#>) (lead:<location>) (no_rotate)

Short Description

Shoots an entity through the air, useful for things like firing arrows.

Description

Shoots an entity through the air up to a certain height, optionally triggering a script on impact with a target.

The launch has three modes: arc, lead, and direct.

The "arc" mode calculates a launch arc to exactly hit the target location.
If you want to use this, specify the "height" argument as how high the arc should go, in blocks.
Do not specify "speed" or "lead".
You can optionally specify a custom "gravity" (hidden from syntax line intentionally) if you know what you're doing and really n...

desert cliff
#

It looks like there isn't a specific example for this.

#

!t locationtag.forward

desert spadeBOT
desert cliff
#

This should do, depending on how far you want it to go.

humble cloud
#

Is it possible to replace certain blocks in a radius of a player?

desert cliff
#

!xy

desert spadeBOT
# desert cliff !xy
Info: xy

Your question seems to be an XY Problem - you're asking about your attempted solution rather than your original problem.
Read in detail about the XY Problem here: http://xyproblem.info/

For an example of an XY Problem we've seen in Denizen, the question "how do I make an event for when a flag expires" has no answer, but the same question asked with full background detail will be something more like "I have this script: [LINK HERE], which sets a 3 minute cooldown flag on a player for when they use an ability. I want the player to be notified when the cooldown completes - how do I do this?" which we can then answer quite effectively (in this example, all that was needed was a simple wait command, no events or flag-listening or anything).

desert cliff
#

What are you trying to accomplish with all of these questions?

humble cloud
#

im making magic wands

desert cliff
#

Ah.

#

Yes, you can construct a cuboid of one locationtag to another.

#

!t location.to_cuboid

desert spadeBOT
desert cliff
#

!t cuboidtag.expand

desert spadeBOT
# desert cliff !t cuboidtag.expand

Expands the cuboid by the given amount, and returns the changed cuboid.
This will decrease the min coordinates by the given vector location, and increase the max coordinates by it.
Supplying a negative input will therefore contract the cuboid.
Note that you can also specify a single number to expand all coordinates by the same amount (equivalent to specifying a location that is that value on X, Y, and Z).
Not valid for multi-member CuboidTags.

Returns

CuboidTag

Examples
# If "my_cuboid" spans from 10,10,10 to 5,5,5 and gets expanded by 15 (15,15,15),
# then "my_expanded_cuboid" will span -10,-10,-10 (min) to 25,25,25 (max).
- note <cuboid[my_cuboid].expand[15]> as:my_expanded_cuboid
# If "my_cuboid" spans from 10,10,10 to 5,5,5 and gets expanded by 15,20,25,
# then "my_expanded_cuboid" will span -10,-15,-20 (min) to 25,30,35 (max).
- note <cuboid[my_cuboid].expand[15,20,25]> as:my_expanded_cuboid
desert cliff
#

Can expand it if necessary.

humble cloud
#

and how can i replace the blocks? I cant fine anything in the meta docs

desert cliff
#

!c modifyblock

desert spadeBOT
# desert cliff !c modifyblock
Group

world

Syntax

modifyblock [<location>|.../<ellipsoid>/<cuboid>] [<material>|...] (no_physics/naturally:<tool>) (delayed) (<script>) (<percent chance>|...) (source:<player>) (max_delay_ms:<#>)

Short Description

Modifies blocks.

Description

Changes blocks in the world based on the criteria given.

Use 'no_physics' to place the blocks without physics taking over the modified blocks.
This is useful for block types such as portals or water. This does NOT control physics for an extended period of time.

Specify (<percent chance>|...) to give a chance of each material being placed (in any material at all).

Use 'naturally:' when setting a block to air to break it naturally, meaning that it will drop items. Specify the tool item that sho...

desert cliff
#

!t cuboidtag.blocks

desert spadeBOT
# desert cliff !t cuboidtag.blocks

Returns each block location within the area.
Optionally, specify a material matcher to only return locations with that block type.

Returns

ListTag(LocationTag)

Examples
# Spawns a debugblock to highlight every plank-type block in the area.
- debugblock <cuboid[my_cuboid].blocks[*planks]>
desert cliff
#

Modifyblock can take a list of blocks, so this tag should help.

sturdy windBOT
#
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.)

#

@humble cloud