Date: 2020/08/31 05:55:35 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
dragon_handler:
type: world
debug: true
events:
on ender_dragon spawns:
- adjust <context.entity> max_health:600
- adjust <context.entity> health:<context.entity.health_max>
- adjust <context.entity> dragon_phase:CIRCLING
#- narrate targets:<server.ops> "<bold>Dragon Spawned! <red><bold>HP: <red><context.entity.health> / <context.entity.health_max> <blue><bold>PHASE: <blue><context.entity.dragon_phase>"
on delta time secondly every:5:
- foreach <server.worlds>:
- define world <[value]>
- foreach <[value].entities[ender_dragon]>:
- define dragon <[value]>
- inject task
- define nearby_players <[dragon].location.find.players.within[100]>
- foreach <[nearby_players]>:
- define volley_chance <util.random.int[0].to[1]>
- if <[volley_chance]> == 0:
- inject dragon_volley_task
#- else:
# - narrate targets:<server.ops> "Failed volley"
on ender_dragon damaged:
#Should move this into a flag stored for dragon
- define perch_phases <list[SEARCH_FOR_BREATH_ATTACK_TARGET|BREATH_ATTACK|ROAR_BEFORE_ATTACK]>
- if <[perch_phases].contains_any[<context.entity.dragon_phase>]>:
- flag <context.entity> accumulated_damage:+:<context.final_damage>
- if <context.entity.flag[accumulated_damage]> > 100:
- narrate targets:<server.ops> "Change phases!"
- adjust <context.entity> dragon_phase:CIRCLING
- flag <context.entity> accumulated_damage:!
dragon_volley_task:
type: task
debug: false
script:
- define player <[value]>
#Same as before
- define perch_phases <list[SEARCH_FOR_BREATH_ATTACK_TARGET|BREATH_ATTACK|ROAR_BEFORE_ATTACK]>
- define safe_range 25
- repeat 5:
#If dragon is not perched
- if !<[perch_phases].contains_any[<[dragon].dragon_phase>]>:
#If player is far enough
- if <[dragon].location.distance_squared[<[player].location>]> > <element[<[safe_range]>].power[2]>:
- run shoot_dragon_fire def:<list_single[<[dragon]>].include[<[player]>]>
- wait 15t
projectile_task:
type: task
debug: false
definitions: shooter|origin|direction|duration|speed|density|tick_task|hit_task|end_task
script:
- define current_location <[origin]>
- define sub_points <[speed].mul[<[density]>].round_up>
#Projectile config
- define collision_radius 1
- define collide_with_entities true
- define collide_with_blocks true
- define controllable false
- repeat <[duration]>:
- if <[controllable]>:
- define velocity <[shooter].location.direction.vector>
- else:
- define velocity <[direction].mul[<[speed]>]>
- define increment_velocity <[velocity].div[<[sub_points]>]>
- define increment 0
- repeat <[sub_points]>:
- define current_increment_location <[current_location].add[<[increment_velocity].mul[<[increment]>]>]>
- inject <[tick_task]>
#Collision Detection
- if <[collide_with_entities]>:
- define collided_entities <[current_increment_location].find.living_entities.within[<[collision_radius]>]>
- foreach <[collided_entities]>:
- if <[value]> != <[shooter]>:
- if <[value].is_player>:
- if <[value].flag[shield_raised]> && !<[value].flag[shield_lowered]>:
- narrate targets:<server.ops> Parry!
- run fire_parry def:<[value]>
- stop
- inject <[hit_task]>
- inject <[end_task]>
- wait 1t
- stop
- if <[collide_with_blocks]>:
- if <[current_increment_location].material.is_solid>:
- inject <[end_task]>
- wait 1t
- stop
- define increment:++
- define current_location <[current_location].add[<[velocity]>]>
- wait 1t
- inject <[end_task]>
shoot_dragon_fire:
type: task
debug: false
definitions: shooter|target
script:
- define duration 40
- define speed 3
- define density 3
- define origin <[shooter].location.add[0,1,0]>
- define direction <[target].location.sub[<[origin]>].normalize>
- playsound <[shooter].location> sound:ENTITY_BLAZE_DEATH sound_category:AMBIENT volume:6 pitch:2
- playsound <[shooter].location> sound:ENTITY_ENDER_DRAGON_GROWL sound_category:AMBIENT volume:0.1 pitch:0.3
- playsound <[shooter].location> sound:ENTITY_ZOMBIE_HORSE_AMBIENT volume:6 pitch:0.2 sound_category:AMBIENT
- run projectile_task def:<list_single[<[shooter]>].include[<[origin]>].include[<[direction]>].include[<[duration]>].include[<[speed]>].include[<[density]>].include[dragon_fire_tick].include[dragon_fire_hit].include[dragon_fire_end]>
dragon_fire_tick:
type: task
debug: false
script:
- playeffect effect:REDSTONE at:<[current_increment_location]> quantity:2 offset:0.0 visibility:100 special_data:2|<color[255,50,200]>
- playeffect effect:DRAGON_BREATH at:<[current_increment_location]> quantity:2 offset:0.4 visibility:100
#- playeffect effect:DRAGON_BREATH at:<[current_increment_location]> quantity:1 offset:0.6 visibility:100
dragon_fire_hit:
type: task
debug: false
script:
- hurt <[value]> ammount:20 cause:DRAGON_BREATH source:<[shooter]>
#- if <[value].is_player>:
#- narrate targets:<server.ops> "<[value].name> was hit directly!"
dragon_fire_end:
type: task
debug: false
script:
- playeffect effect:EXPLOSION_HUGE at:<[current_location]> visibility:100 quantity:2 offset:0.1
#- explode <[current_location]> power:1 fire
- define range 4
- define target_blacklist <list[ARMOR_STAND|ENDER_DRAGON]>
- define targets <[current_location].find.living_entities.within[<[range]>]>
- foreach <[targets]>:
- if !<[target_blacklist].contains_any[<[value].entity_type>]>:
#Vector from explosion origin towards entity within blast radius, note that velocity is added as though the projectile has passed an additional tick
- define delta_vector <[value].location.sub[<[current_location]>].normalize>
#Distance from explosion to entity
- define delta_distance <[value].location.distance[<[current_location]>]>
#How far the entity will be launched
- define force_multiplier 2.5
#Force is inversely proportional to the distance, meaning the closer the entity, the larger the force
- define force <element[1].div[<[delta_distance]>].mul[<[force_multiplier]>]>
- adjust <[value]> velocity:<[value].velocity.add[<[delta_vector].mul[<[force]>]>]>
- if <[value].is_player>:
#- narrate targets:<server.ops> "<[value].name> hit with a force of <[force].round_to[2]>"
#- narrate targets:<server.ops> "<[value].name> was hit for <[force].mul[10].add[<[value].armor_bonus.mul[<[force]>].mul[2]>].round_to[2]>"
- hurt <[value]> ammount:<[force].mul[10].add[<[value].armor_bonus.mul[<[force]>].mul[2]>]> cause:DRAGON_BREATH source:<[shooter]>