Paste #124180: Pie Slingshot v0.8

Date: 2024/06/29 01:03:24 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# # ******************************************************************************
#   ___  _        ___  _  _                _          _
#  | . \<_> ___  / __>| |<_>._ _  ___  ___| |_  ___ _| |_
#  |  _/| |/ ._> \__ \| || || ' |/ . |<_-<| . |/ . \ | | by: Kalebbroo & Collossal
#  |_|  |_|\___. <___/|_||_||_|_|\_. |/__/|_|_|\___/ |_| art by: LittleRoomDev
# # ******************************************************************************
#
# This script is free and open source. You are permitted to do
# whatever you want with it, EXCEPT sell any part of this or claim it
# as your own work. Selling in game access, items, or item skins is fine.
# If you use this script or model, please credit the creator and artist.
# link to:
#
# # Developer https://github.com/kalebbroo
# # Artist https://www.patreon.com/littleroomdev
#
# This Is a submission for the Denizen Script Contest
#
# Usage Instructions:
# 1. Craft the Pie Slingshot using the following recipe:
#    - leather | string | leather
#    - stick   |  bow   | stick
#    - leather | string | leather
# 2. Craft Exploding Pies using the following recipe:
#    - gunpowder | sugar | gunpowder
#    - sugar     | pie   | sugar
#    - gunpowder | sugar | gunpowder
# 3. Equip the Pie Slingshot and place regular pies or Exploding Pies
#    in your offhand.
# 4. Shoot the Pie Slingshot to fire the pie. Regular pies will
#    blind and slow targets, while Exploding Pies will create
#    a large explosion.
# ******************************************************************

Pie_Slingshot:
    type: item
    material: bow
    mechanisms:
        unbreakable: true
        custom_model_data: 1
    display name: <gold>Pie Slingshot
    lore:
        - <yellow>Launches pies at enemies
        - <gold>Special Ability: Pie Barrage
        - <gray>Fires a barrage of pies, blinding and slowing targets
    flags:
        ability: pie_barrage
    recipes:
        1:
            type: shaped
            recipe_id: pie_slingshot_recipe
            group: joke_weapons
            output_quantity: 1
            input:
            - leather|string|leather
            - stick|bow|stick
            - leather|string|leather

Exploding_Pie:
    type: item
    material: arrow
    mechanisms:
        unbreakable: true
        custom_model_data: 1
    display name: <red>Exploding Pie
    lore:
        - <red>Explodes on impact
        - <dark_red>Use with the Pie Slingshot for explosive results
    recipes:
        1:
            type: shaped
            recipe_id: exploding_pie_recipe
            group: joke_weapons
            output_quantity: 1
            input:
            - gunpowder|sugar|gunpowder
            - sugar|pumpkin_pie|sugar
            - gunpowder|sugar|gunpowder

Pie_Slingshot_Ability:
  type: world
  debug: true
  events:
    on player raises Pie_Slingshot:
            - narrate "<gold>Hold right-click to charge up your Pie Slingshot!"
            - define offhand <player.inventory.slot[offhand].display||air>
            - if <player.gamemode> != creative && !<[offhand].advanced_matches[*pie]>:
                - narrate "<red>You are out of AMMO! You need to have a pie in your offhand!"
                - animate player animation:START_USE_MAINHAND_ITEM
                - determine cancelled
            - else:
                - animate player animation:START_USE_MAINHAND_ITEM
                - wait 1s
            - animate player animation:STOP_USE_ITEM
    on player chooses arrow:
        - narrate "<gold>Release right-click to fire your Pie Slingshot!"
        - determine cancelled

    on player lowers Pie_Slingshot reason:lower:
        # Check if the player has a pie or exploding pie in their offhand. If not, cancel the event and send a message
        - narrate "<gold>Release right-click to fire your Pie Slingshot!"
        - define offhand <player.inventory.slot[offhand].display||air>
        - if <player.gamemode> != creative:
            - if !<[offhand].advanced_matches[*pie]>:
                - narrate "<red>You are out of AMMO! You need to have a pie in your offhand!"
                - animate <player> animation:STOP_USE_ITEM
                - determine cancelled
            - else:
                - take slot:offhand
                - define projectile <[offhand]>
        - define time <context.held_for.in_seconds>
        - if <[offhand].advanced_matches[Exploding_pie]>:
            - define type exploding
        - else:
            - define type regular
        - if <[time]> > 0.1:
            - playsound <player.location> sound:ENTITY_GLOW_SQUID_HURT volume:3 pitch:<util.delta_time_since_start.in_ticks.as_element.sin.add[2]>
            - shoot <[offhand]> origin:<player.location.add[0,1.2,0].forward[1]> destination:<player.eye_location.forward[50]> speed:<[time].min[4]> spread:<[time].mul[5].min[10]> script:pie_fire shooter:<player> def:type
    on player shoots Pie_Slingshot:
        # prevent using arrows
        - determine cancelled

pie_fire:
  type: task
  debug: true
  definitions: type
  script:
    - define projectile <[last_entity]>
    - define shooter <[projectile].shooter>
    - shoot <[projectile]> source:<[shooter]> speed:2.0 spread:0.0
    - while <[projectile].is_valid>:
        - wait 1t
        - define projectile_location <[projectile].location>
        - if <[type]> == regular:
        # define the location once for performance
            - playeffect at:<[projectile_location]> effect:ITEM_CRACK qty:10 spread:0.2 item:pumpkin_pie
            - playeffect <[projectile_location]> effect:CLOUD qty:5 spread:0.1
            - playeffect <[projectile_location]> effect:NOTE qty:3 spread:0.05
            - playeffect <[projectile_location]> effect:HEART qty:5 spread:0.1
            - playeffect <[projectile_location]> effect:SPELL_MOB qty:5 spread:0.1
        - if <[type]> == exploding:
            - playeffect <[projectile_location]> effect:EXPLOSION_NORMAL qty:5 spread:0.1
            - playeffect <[projectile_location]> effect:ITEM_CRACK qty:10 spread:0.2 item:tnt
            - playeffect <[projectile_location]> effect:SMOKE_NORMAL qty:5 spread:0.1
            - playeffect <[projectile_location]> effect:CRIT qty:5 spread:0.1
            - playeffect <[projectile_location]> effect:VILLAGER_ANGRY qty:5 spread:0.1
    - run pie_impact def:<[projectile_location]>|<[shooter]>|<[type]>

pie_impact:
  type: task
  debug: true
  definitions: location|shooter|type
  script:
    - define impact_location <[location]>
    - if <[type]> == regular:
        - playeffect <[impact_location]> effect:ITEM_CRACK qty:50 spread:0.5 item:pumpkin_pie
        - playeffect <[impact_location]> effect:CLOUD qty:30 spread:0.3
        - playeffect <[impact_location]> effect:NOTE qty:20 spread:0.2
        - playeffect <[impact_location]> effect:HEART qty:20 spread:0.2
        - playeffect <[impact_location]> effect:SPELL_MOB qty:20 spread:0.2
        - foreach <[impact_location].find.living_entities.within[5]> as:target:
            - if <[target].entity_type> != player:
                - adjust <[target]> potion_effects:[type=BLINDNESS;amplifier=0;duration=200t;ambient=false;particles=true;icon=true]
                - adjust <[target]> potion_effects:[type=SLOW;amplifier=2;duration=200t;ambient=false;particles=true;icon=true]
                - hurt <[target]> damage:0.5 source:<[shooter]>
                - playeffect <[target].location.add[0,1,0]> effect:ITEM_CRACK qty:20 spread:0.1 item:pumpkin_pie
    - if <[type]> == exploding:
        - playeffect <[impact_location]> effect:EXPLOSION_HUGE qty:1 spread:0.0
        - playeffect <[impact_location]> effect:ITEM_CRACK qty:50 spread:0.5 item:tnt
        - playeffect <[impact_location]> effect:CRIT qty:50 spread:0.5
        - playeffect <[impact_location]> effect:VILLAGER_ANGRY qty:50 spread:0.5
        - foreach <[impact_location].find.living_entities.within[5]> as:target:
            - if <[target].entity_type> != player:
                - adjust <[target]> health:<[target].health.sub[10]>
                - playeffect <[target].location.add[0,1,0]> effect:ITEM_CRACK qty:20 spread:0.1 item:tnt
                - playeffect <[target].location.add[0,1,0]> effect:CRIT qty:20 spread:0.1
                - playeffect <[target].location.add[0,1,0]> effect:VILLAGER_ANGRY qty:20 spread:0.1