Date: 2021/04/27 13:52:13 UTC-07:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Item Throwing Skill for Denizen
# By: Xarieste
## For best results when using the "stuck" function, use custom_model_data to change how the item looks when equipped to the head slot.
# This is a sample item with the flag necessary to use this skill
Example_Item:
type: item
material: wooden_axe
display name: Wooden Throwing Axe
lore:
- An axe that can be thrown.
allow in material recipes: false
flags:
throwing_skill: throwing_skill
Item_Skills:
type: world
debug: true
defintions: generic_attack_damage
events:
# This event throws the item:
on player right clicks block:
- if <player.item_in_hand.has_flag[throwing_skill]>:
- shoot snowball[item=<player.item_in_hand>] origin:<player> shooter:<player> speed:1
- take iteminhand
- define generic_attack_damage <player.attribute_modifiers.get[GENERIC_ATTACK_DAMAGE]> save:generic_attack_damage
## This event allows the player to remove a stuck thrown item from their enemy's head (can be removed if not using "stuck" function):
on entity damaged by player with:air:
- ratelimit <player> 1t
- if <context.cause.contains[projectile]>:
- stop
- else if <context.entity.equipment_map.contains_text[throwing_skill_stuck]>:
- define dagger <context.entity.equipment.last>
- equip <context.entity> head:air
- take item:<[dagger]> from:<context.entity.inventory>
- give <[dagger].with_flag[throwing_skill_stuck:!]> to:<player.inventory>
## This event removes the "stuck" flag from the item if the struck enemy removes it from their own head (can be removed if not using the "stuck" function):
on player unequips armor:
- if <context.old_item.has_flag[throwing_skill_stuck]>:
- flag <context.old_item> throwing_skill_stuck:!
# This event determines the overall outcome of throwing the item:
on entity damaged by snowball:
- define projectile <context.projectile.item>
- if <context.projectile.item.has_flag[throwing_skill]>:
# This line determines the original damage value on-hit:
- determine passively <context.damage.add[2]>
# This line fires if it's a headshot AND the target is wearing a helmet:
- if <context.projectile.location.y> >= <context.entity.eye_location.y.sub[0.05]> && <context.projectile.location.y> <= <context.entity.eye_location.y.add[0.70]> && <context.projectile.item.has_flag[throwing_skill]> && <context.entity.has_equipped[*helmet]>:
- playeffect <context.entity.eye_location> effect:CRIT quantity:5 offset:0.3 data:0.4
- narrate target:<context.damager> "<&f><&l>Headshot! <&a>(2x damage)"
- drop <[projectile]> <context.projectile.location>
- determine <context.damage.mul[2]>
# This line fires if it's a headshot and the target IS NOT wearing a helmet:
- else if <context.projectile.location.y> >= <context.entity.eye_location.y.sub[0.05]> && <context.projectile.location.y> <= <context.entity.eye_location.y.add[0.70]>:
- playeffect <context.entity.eye_location> effect:CRIT quantity:5 offset:0.3 data:0.4
- narrate target:<context.damager> "<&f><&l>Headshot! <&a>(3x damage)"
## >READ ME: If you want the item to get stuck when a headshot occurs, replace the below line with "- equip <context.entity> head:<[projectile].with_flag[throwing_skill_stuck]>"
- drop <[projectile]> <context.projectile.location>
- determine <context.damage.mul[3]>
# This line fires if the target is blocking:
- else if <context.entity.is_blocking>:
- drop <[projectile]> <context.projectile.location>
- determine <context.damage.mul[0.5]>
# This line fires in any other case:
- else:
- drop <[projectile]> <context.projectile.location>
- determine <context.damage.mul[1.5]>
# This event drops the item if no entity is hit:
on projectile hits block:
- if <context.projectile.item.has_flag[throwing_skill]>:
- drop <context.projectile.item.with[custom_model_data=1]> <context.projectile.location>
# This event drops the item if an entity dies with it equipped to the head slot:
on entity dies:
- if <context.entity.equipment_map.contains_text[throwing_skill_stuck]>:
- drop <context.entity.equipment_map.get[helmet]> <context.entity.location>