dragon_handler: type: world debug: true events: on ender_dragon spawns: - adjust max_health:600 - adjust health: - adjust dragon_phase:CIRCLING #- narrate targets: "Dragon Spawned! HP: / PHASE: " on delta time secondly every:5: - foreach : - 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 - if <[volley_chance]> == 0: - inject dragon_volley_task #- else: # - narrate targets: "Failed volley" on ender_dragon damaged: #Should move this into a flag stored for dragon - define perch_phases - if <[perch_phases].contains_any[]>: - flag accumulated_damage:+: - if > 100: - narrate targets: "Change phases!" - adjust dragon_phase:CIRCLING - flag accumulated_damage:! dragon_volley_task: type: task debug: false script: - define player <[value]> #Same as before - define perch_phases - 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>]> > ].power[2]>: - run shoot_dragon_fire def:].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: 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:].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| - 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: "<[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 - 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 ].mul[<[force_multiplier]>]> - adjust <[value]> velocity:<[value].velocity.add[<[delta_vector].mul[<[force]>]>]> - if <[value].is_player>: #- narrate targets: "<[value].name> hit with a force of <[force].round_to[2]>" #- narrate targets: "<[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]>