To assign to an NPC, type:
/npc assign --set "fireworks"
Description:
Every town needs a pyrotechnician! This guy doesn't sell fireworks, he's in the entertainment industry. When the player talks to this NPC, he will present a couple of options: sample or show.
If the player picks the free sample, they get to choose the fireworks 'type' and 'color' and the NPC will shoot that into the air. If the player chooses 'show', they will be presented with 3 different shows - from least to most expensive.
This script just shoots the firework from the NPC. On my server, I'm going to modify the 'location' parameter in the fireworks command to be in a variety of different spots - maybe from the four watch towers on the corners of the city, or dispensers.
Syntax and explanation for the 'firework' command:
Command: firework
Location: Where you want to launch the fireworks from, format x,y,z,world ( e.g. 128,65,250,world)
Power: The height. I got client lag when I used 4 and over for this value
Type: Type of firework - http://jd.bukkit.org/rb/apidocs/org/bukkit/FireworkEffect.Type.html
Primary: Colors. You can specify multiple by using the | delimiter. List of colors http://jd.bukkit.org/rb/apidocs/org/bukkit/Color.html
Fade: Fade to this color before fading away
Flicker: Self explanatory (Don't need this)
Trail: Self explanatory (Don't need this)
Credits: Thanks to davidcernat for adding the firework command!! It's awesome :D
# Fireworks Shows & Sample Fireworks# Denizen 0.9.3# Build #1325## To assign to an NPC, type:# /npc assign --set "fireworks"## Description:## Every town needs a pyrotechnician! This guy doesn't sell fireworks, he's in the entertainment# industry. When the player talks to this NPC, he will first present a couple of options: sample or show.## If the player picks the free sample, they get to choose the fireworks 'type' and 'color' and the NPC# will shoot that into the air. If the player chooses 'show', they will be presented with 3 different# shows - from least to most expensive.## This script just shoots the firework from the NPC. On my server, I'm going to modify the 'location' parameter# in the fireworks command to be in a variety of different spots - maybe from the four watch towers on # the corners of the city, or dispensers.## Syntax and explanation for the 'firework' command:## - firework location:<npc.location> power:1 type:creeper primary:fuchsia|blue|green fade:gray flicker trail## Command: firework# Location: Where you want to launch the fireworks from, format x,y,z,world ( e.g. 128,65,250,world)# Power: The height. I got client lag when I used 4 and over for this value# Type: Type of firework - http://jd.bukkit.org/rb/apidocs/org/bukkit/FireworkEffect.Type.html# Primary: Colors. You can specify multiple by using the | delimiter. List of colors http://jd.bukkit.org/rb/apidocs/org/bukkit/Color.html# Fade: Fade to this color before fading away# Flicker: Self explanatory (Don't need this)# Trail: Self explanatory (Don't need this)## @author mythanical# @script version 0.3# @denizen v0.9.3# @last-updated October 20 2013# @irc EsperNet IRC Network #denizen-dev# @Minecraft Server - minecraft.geek.nz# @Donate Bitcoin: 1Fzacc2gZ5NGRMXg5jWP6NcUkWei34xjzt
"Fireworks":
type: assignment
#The default constants allow you to specify values before hand, like the price of an item or available options in a list
default constants:
# The following is a list of firework types supported by Bukkit. This will be presented to the player when they pick 'sample'
Sample_Fireworks: ball|ball_large|burst|creeper|star
# These are the Bukkit colors available for the fireworks
Sample_Colors: aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow
# The prices for the 3 different fireworks shows.
Small_Display: 100
Medium_Display: 500
Large_Display: 2000# Name of your town - used in dialog.
Townname: 'Arrowin'
interact scripts:
- 1 Fireworks Display
#Turning on the triggers I will use later for the player to interact with the NPC
actions:
on assignment:
# This enables interaction with NPC via clicking, chatting, proximity and damage. The cooldown prevents spamming.
- trigger name:chat toggle:true
- trigger name:click toggle:true
- trigger name:proximity toggle:true
- trigger name:damage toggle:true
# Make the NPC vulnerable so they can be killed by the player. They will respawn a few seconds later.
- execute as_npc "npc sel <npc.id>"
- execute as_npc "npc vulnerable"
- execute as_npc "npc lookclose"
"Fireworks Display":
type: interact
steps:
"Initial*":
proximity trigger:
entry:
script:
# On player entering proximity range, use the random command to pick any of the 5 chat lines.
- random 5
- chat "<yellow>Come right up, for the fireworks display of a lifetime!"
- chat "<yellow>Fireworks! Fireworks show over here! Different options for different pocket sizes!"
- chat "<yellow>Like things that explode and make noise? Then come check out my fireworks show!"
- chat "<yellow>Step right up and witness the greatest fireworks show you'll ever see!"
- chat "<yellow>Fireworks you say? Fireworks indeed! A show (or two) to hypnotise and mesmerise!"
click trigger:
script:
# When the player clicks the NPC, it will run any one of the first 3 chats and then always the 4th chat.
- random 3
- chat "<yellow>Why hello there, <player.name>!"
- chat "<yellow>Welcome to my Fireworks Emporium!"
- chat "<yellow>I've been making Fireworks for years!"
- chat "<yellow>Are you interested in a <light_purple>sample<yellow> (free) or a <light_purple>show<yellow> (pay)?"
chat trigger:
'Sample':
trigger: I'm interested in a /sample/
# If the player types 'sample', it will narrate the list of types specified in the 'sample_fireworks'# default constant specified at the top of the script.# It then 'zaps' the player to the 'Sample Type' section little bit further down where it's waiting# for their reply.
script:
- chat "<yellow>What type of firework do you want me to shoot?"
- narrate "<light_purple><cons:Sample_Fireworks.aslist.ascslist>"
- ^zap "step:Sample Type"
'Show':
trigger: I want you to put on a /show/ for the whole of <cons:Townname> to see!
# If the player types 'show' instead, it will run the script further below called 'Show Options'
script:
- run "Show Fireworks Options"
'What Did You Say':
trigger: /REGEX:\w+/
# This is a catch-all trigger that will repeat what the player said if what they# typed didn't match any of the chat triggers above.
script:
- engage
- chat "<yellow>Sorry<white> <player.name><yellow>, but I don<&sq>t know what <&sq><white><context.message><yellow><&sq> means."
- ^narrate "<red>Say<&co>"
- ^narrate " <light_purple>Sample or Show"
- disengage
"Sample Type":
chat trigger:
'Which Type':
trigger: "I'm interested in a /regex:^(<cons:Sample_Fireworks>)$/ type."# In this section, the list of 'sample_fireworks' is matched to what the player typed. It then 'zaps'# into the 'sample color' section if they typed it in correctly.
script:
- ^flag "FireworkType:<context.message>"
- chat "<yellow>Great, you chose <light_purple><player.flag[FireworkType]><yellow>. Now which color would you like?"
- narrate "<light_purple><cons:Sample_Colors.aslist.ascslist>"
- ^zap "step:Sample Color"
click trigger:
script:
# If the player forgets what to type, right clicking the NPC will present them with the list again.
- ^narrate "<red>Say<&co>"
- ^narrate "<light_purple><cons:Sample_Fireworks.aslist.ascslist>"
proximity trigger:
exit:
script:
# If the player triggers the exit proximity for the NPC, put them back at the 'Initial' step so they get presented with the# relevant options when they come back later.
- ^zap "step:Initial"
"Sample Color":
chat trigger:
'Which Color':
trigger: "I want to see the explosion in the color /regex:^(<cons:Sample_Colors>)$/."# Match 'sample_colors' constant value to what the player typed and then run the 'Shoot Sample' script further# down.
script:
- ^flag "FireworkColor:<context.message>"
- chat "<yellow>Ok, stand back and look up. Here it comes!"
- wait 3
- execute as_npc "npc sel <npc.id>"
- execute as_npc "npc lookclose"
- wait 1t
- look "location:<npc.location.x>,<npc.location.y.add[10]>,<npc.location.z>,world"
- firework location:<npc.location> power:1 type:<player.flag[FireworkType]> primary:<player.flag[FireworkColor]> flicker trail
- ^flag FireworkType:!
- ^flag FireworkColor:!
- wait 1
- execute as_npc "npc lookclose"
- random 3
- chat "<yellow>Spectacular, isn't it?"
- chat "<yellow>Thought that was cool? You should try one of the shows!"
- chat "<yellow>Whiz, pop, bang! I love these things."
- ^zap "step:Initial"
click trigger:
script:
- ^narrate "<red>Say<&co>"
- ^narrate "<light_purple><cons:Sample_Colors.aslist.ascslist>"
proximity trigger:
exit:
script:
- ^zap "step:Initial"
"Show Size":
chat trigger:
"Size":
trigger: /REGEX:\w+/
script:
# Here it checks to see what the last thing is the player said. If they said 'small', then the first# IF statement will match. It then checks to see if they have enough money.. if they do, it'll# take the money, set a flag called 'Fireworks Show Size' and run the 'Fireworks Handler' script# further down. The same principles apply if the player typed 'medium' or 'large'.
- if <context.message> == small {
- chat "<yellow>So what if you're not a big spender? It's still worth it!"
- ^if <cons:Small_Display> > <player.money>
narrate "<red>You have <gold><player.money.asint><red> <player.money.currency>, but need <gold><cons:Small_Display><red> <player.money.currency><red> to pay <npc.name>."
else {
- engage
- take money qty:<cons:Small_Display>
- flag npc "Fireworks Show Size:small"
- narrate "<red>You pay <npc.name> <gold><cons:Small_Display> <player.money.currency>."
- chat "<yellow>Ok, stand back and look up. Here it comes!"
- flag npc "Fireworks Pause Queue:<q.id>"
- ^run "Fireworks Handler"
- queue pause
- wait 1
- chat "<yellow>All done! You should try one of the larger shows if you want to see more."
- zap "step:Initial"
- disengage
}}
else if <context.message> == medium {
- chat "<yellow>Ah yes, this is the classic medium display. I bet you'll go for the large one next!"
- if <cons:Medium_Display> > <player.money>
narrate "<red>You have <gold><player.money.asint><red> <player.money.currency>, but need <gold><cons:Medium_Display><red> <player.money.currency><red> to pay <npc.name>."
else {
- engage
- take money qty:<cons:Medium_Display>
- flag npc "Fireworks Show Size:medium"
- narrate "<red>You pay <npc.name> <gold><cons:Medium_Display> <player.money.currency>."
- chat "<yellow>Ok, stand back and look up. Here it comes!"
- wait 1
- flag npc "Fireworks Pause Queue:<q.id>"
- run "Fireworks Handler"
- queue pause
- wait 1
- chat "<yellow>Aaaaand finished! Hope you enjoyed the medium sized fireworks display!"
- zap "step:Initial"
- disengage
}}
else if <context.message> == large {
- chat "<yellow>Oh my, I hope you are ready for this one. It's big, it's loud.. it's simply.. awesome."
- if <cons:Large_Display> > <player.money>
narrate "<red>You have <gold><player.money.asint><red> <player.money.currency>, but need <gold><cons:Large_Display><red> <player.money.currency><red> to pay <npc.name>."
else {
- engage
- take money qty:<cons:Large_Display>
- flag npc "Fireworks Show Size:large"
- narrate "<red>You pay <npc.name> <gold><cons:Large_Display> <player.money.currency>."
- chat "<yellow>Ok, stand back and look up. Here it comes!"
- wait 1
- flag npc "Fireworks Pause Queue:<q.id>"
- run "Fireworks Handler"
- queue pause
- wait 1
- random 3
- chat "<yellow>There you have it! My best of the best! Still not happy? Well, then I'd like to see you do better!"
- chat "<yellow>My career, summed up in less than a minute. I hope you enjoyed my lifes work."
- chat "<yellow>Haha, great show eh? You are welcome to try the others, but this was my best one!"
- zap "step:Initial"
- disengage
}}
else {
- chat "<yellow>Sorry <white><player.name><yellow>, but I don<&sq>t know what '<white><context.message><yellow>' means."
- narrate "<red>Say<&co>"
- narrate " <light_purple>Small, Medium or Large"}
click trigger:
script:
- ^narrate "<red>Say<&co>"
- ^narrate " <light_purple>Small, Medium or Large"
proximity trigger:
exit:
script:
- ^zap "step:Initial"
"Show Fireworks Options":
type: task
speed: 0
script:
# If the player chooses 'show', it will use this task to present them with their options. It reads back the money values# specified in the default constant values specified at the top of the script.
- chat "<yellow>Great! I have the following available for your viewing pleasure<&co>"
- ^narrate " <light_purple>Small - <gold><cons:Small_Display> <player.money.currency>"
- ^narrate " <light_purple>Medium - <gold><cons:Medium_Display> <player.money.currency>"
- ^narrate " <light_purple>Large - <gold><cons:Large_Display> <player.money.currency>"
- ^zap "s@Fireworks Display""step:Show Size"
"Fireworks Handler":
type: task
script:
# So, this part is the starting point for the fireworks show. It flags the NPC with the# number of times you want each of the fireworks types to shoot. So, if the player picked# a 'small' show, on the first IF it'll flag the NPC with a value of 4 and run the# "Boring Fireworks" subscript in the "Shoot Fireworks" script. This will run 4 times# and then on the second IF, it'll flag the "Normal Fireworks" to run twice. Then# on the third IF, it flags the "Exciting Fireworks" to run only once.## If you feel the number of fireworks it shoots isn't right, just adjust the counts# below to shoot more/less fireworks.
- execute as_npc "npc sel <npc.id>"
- execute as_npc "npc lookclose"
- ^look "location:<npc.location.x>,<npc.location.y.add[10]>,<npc.location.z>,world"
- ^flag npc "Fireworks Queue:<q.id>"
- if "<npc.flag[Fireworks Show Size]>" == small flag npc "Loop Counter:4"
else if "<npc.flag[Fireworks Show Size]>" == medium flag npc "Loop Counter:5"
else flag npc "Loop Counter:6"
- ^run "s@Shoot Fireworks""Boring Fireworks" delay:1t
- queue pause
- if "<npc.flag[Fireworks Show Size]>" == small flag npc "Loop Counter:2"
else if "<npc.flag[Fireworks Show Size]>" == medium flag npc "Loop Counter:4"
else flag npc "Loop Counter:15"
- ^run "s@Shoot Fireworks""Normal Fireworks" delay:1t
- queue pause
- if "<npc.flag[Fireworks Show Size]>" == small flag npc "Loop Counter:1"
else if "<npc.flag[Fireworks Show Size]>" == medium flag npc "Loop Counter:3"
else flag npc "Loop Counter:20"
- ^run "s@Shoot Fireworks""Exciting Fireworks" delay:1t
- queue pause
- queue resume "<npc.flag[Fireworks Pause Queue]>"
- execute as_npc "npc lookclose"
"Shoot Fireworks":
type: task
# You'll notice in this task, we actually have 3 subscripts. So instead of creating 3 separate task# scripts, we are instead grouping them together. The benefit of doing this is that there are# less script containers out there which you need to reference to. So easier to maintain and# update these if you have many scripts on your server.
"Boring Fireworks":
- ^wait 0.5
- firework location:<npc.location> power:3 type:burst primary:blue fade:blue
- ^flag npc "Loop Counter:--"
- if "<npc.flag[Loop Counter]>" == 0 queue resume "<npc.flag[Fireworks Queue]>"
else run locally "Boring Fireworks"
"Normal Fireworks":
- ^wait 0.5
- firework location:<npc.location> power:2 type:random primary:random fade:blue
- ^flag npc "Loop Counter:--"
- if "<npc.flag[Loop Counter]>" == 0 queue resume "<npc.flag[Fireworks Queue]>"
else run locally "Normal Fireworks"
"Exciting Fireworks":
- ^wait 0.5
- firework location:<npc.location> power:<util.random.int[1].to[2]> type:random primary:random|random|random fade:random flicker trail
- ^flag npc "Loop Counter:--"
- if "<npc.flag[Loop Counter]>" == 0 queue resume "<npc.flag[Fireworks Queue]>"
else run locally "Exciting Fireworks"
I'm not sure why, but it seems like you have to be extremely close (like less than a block away) away from the npc to get him to pick up your chat commands
I'm not sure why, but it seems like you have to be extremely close (like less than a block away) away from the npc to get him to pick up your chat commands