################################################################################ # # Master Waitress Assignment Script # # The Waitress will greet players, deliver menus, take orders, and deliver food. # MasterWaitressNPC: type: assignment speed: 1t debug: true actions: on assignment: - run locally assignment instantly on spawn: - run locally spawn instantly delay:2s on despawn: - run locally despawn instantly delay:1s on click: - run locally click_ instantly on move proximity: - run locally proximity_ instantly assignment: # What happens on assignment. We want this as a subscript so we can run it # outside the on assignment action if needed. - trigger name:chat state:true radius:5 cooldown:5s - trigger name:click state:true radius:5 cooldown:5s - trigger name:proximity state:true radius:2 cooldown:2s - trigger name:damage state:true radius:5 cooldown:5s - vulnerable state:false - lookclose true range:5 realistic - flag npc respawn_location: - flag npc Pathfind.FidgetRadius:5 - flag npc Pathfind.FidgetSpeed:0.7 - flag npc Pathfind.FidgetWait:1 - flag npc Pathfind.FidgetLocation: - flag npc Pathfind.FidgetHeight:1 - flag npc Pathfind.FidgetPathMaterial: - flag npc dRestaurant_MenuQueue:! - flag npc TicketQueue:! - inject locally spawn instantly spawn: - narrate format:GenericNPCFormat "Alright, time to start work..." targets: - if ]> queue queue:fidgetQueue_ stop - inject locally processTicketQueue despawn: # Just a code stub - if ]> queue queue:fidgetQueue_ stop - narrate format:GenericNPCFormat "Phew... I<&sq>m glad to be done work for the day!" targets: damage: # Just a code stub - narrate format:GenericNPCFormat "Why would you do that?" targets: # #-------------------------------------- # # Logic Utilities # # collectMenus: # Run through a list of players that are waiting to have their menus collected # Then go and get them. We aren't going to walk to players that are offline or # 30 blocks or more away from the npc. This REALLY should check if the player # is in the restaurant cuboid and possibly if the player still has the menu in # inventory. # Should add nullChecks for this - ^if ! queue clear - if ]> queue queue:fidgetQueue_ stop - inject s@MasterWaitressNPC p:findRestaurant instantly - define menuQueue '' - if ! { - flag npc Status:order - foreach %menuQueue% { - define player '' - if && ].is[LESS].than[30]||false> { - define loc '].within[5].random||>' - ~walk %loc% 'speed:' - look d:2s - wait 10t - narrate format:GenericNPCFormat "Your order should be out in just a moment." targets:%player% } - take '].full>' player:%player% - flag %player% dRestaurant_Order_Placed:! - flag dRestaurant_MenuQueue:<-:%player% - wait 10t - if ! { - inject processTicketQueue locally } } - if ! { - inject collectMenus locally } } - if ! { - inject processTicketQueue locally } - flag npc Status:available - if ]> queue queue:fidgetQueue_ stop - run s@Fidget id:fidgetQueue_ - queue clear processTicketQueue: # Run through a list of orders waiting to be delivered. Rinse and repeat until # the queue is cleared. # Should add nullChecks for this - ^if ! queue clear - inject s@MasterWaitressNPC p:findRestaurant instantly - define ticketQueue '' - narrate format:GenericNPCFormat "" targets: - if ! { - narrate format:GenericNPCFormat "" targets: - flag npc Status:deliver - foreach { - define TicketQueueEntry %value% - define ticketNumber '' - define displayItems '' - define tickets '' - define ticket ']>' - define player '' - define foodItems '' - inject s@dRestaurant p:deliverFood_waitress - flag npc TicketQueue:<-:%TicketQueueEntry% - flag server dRestaurantTickets:<-:%ticket% - wait 5t - if { - inject locally collectMenus } } - if ! { - inject processTicketQueue locally } } # Finish up by collecting any menus in queue - if { - inject locally collectMenus } - flag npc Status:available - if ]> queue queue:fidgetQueue_ stop - run s@Fidget id:fidgetQueue_ - queue clear findRestaurant: # This requires an NPC object and should only be run when the player is # getting a menu from a waitress in the on click action - define restaurants li@ - foreach { - if { - define restaurant '' - define owner '' - if ]> { - define restaurants '' } } } # Because why else would any sane admin have restaurant cuboids overlap? - define restaurant '' - if { - narrate format:GenericNPCFormat "Oh dear, I seem to be quite lost..." targets: - flag npc status:drunk - queue stop } assignWaitress: # This assumes we know the restaurant - define waitresses li@ - define owner '' - foreach { - define npc %value% - if ]> && { - define waitresses '' } } # Now we have a list of waitresses, let's find the least busy - foreach %waitresses% { - define waitress '' - if ]> { - define waitress %value% } } assignChef: # This assumes we know the restaurant - define chefs li@ - define owner '' - foreach { - define npc %value% - if ]> && { - define chefs '' } } # Now we have a list of chefs, let's find the least busy - foreach %chefs% { - define chef '' - if ]> { - define chef %value% } } assignTicketNumber: - repeat 20 { - define ticketNumber - define ticketList - if ! repeat stop - if { - define ticketNumber "LastLostTicketDetails" - announce "<&b>dRestaurant<&co> <&c>Order Lost - Couldn<&sq>t get a valid ticket number!" to_console - announce "<&b>dRestaurant<&co> <&c>%ticketNumber%" to_console - announce "<&b>dRestaurant<&co> <&c>Chef<&co> %chef%" to_console - announce "<&b>dRestaurant<&co> <&c>Waitress<&co> %waitress%" to_console - announce "<&b>dRestaurant<&co> <&c>Player<&co> " to_console - announce "<&b>dRestaurant<&co> <&c>foodItems<&co> %foodItems%" to_console } } # # END Logic Utilities # #-------------------------------------- # # MasterWaitress Status Actions # # We're using an NPC status system for action responses. This is a low latency # and low load method that allows for very fast NPC reactions since they do not # have to do ANY comparisons. They just run the correct subscript based on the # action and their current status. # # #-------------------------------------- # Click Responses # click_drunk: # A catchall if something derps - flag npc status:drunk - if ]> queue queue:fidgetQueue_ stop - if random { - narrate format:GenericNPCFormat "I quit!" targets: - narrate format:GenericNPCFormat "I<&sq>m done with this place!" targets: - narrate format:GenericNPCFormat "I should have called out!" targets: - narrate format:GenericNPCFormat "I had way too much to drink last night..." targets: - narrate format:GenericNPCFormat "I<&sq>m not feeling well... I have to go." targets: } - wait 2s - despawn click_available: # When the Waitress is available for whatever - flag npc status:order - if { - narrate format:GenericNPCFormat "Someone will collect your menu soon." - flag npc status:available - queue stop } - if { - narrate format:GenericNPCFormat "Open up your menu and complete your order." - flag npc status:available - queue stop } - if ]> queue queue:fidgetQueue_ stop - inject locally findRestaurant instantly - flag dRestaurant_Order:%restaurant% - define loc ].within[2].get[1]||> - ~walk %loc% 'speed:' - look d:2s - wait 5t - random { - narrate format:GenericNPCFormat "Click on the items in the menu." targets: - narrate format:GenericNPCFormat "Browse through the menu. I<&sq>m sure you<&sq>ll find something you like." targets: - narrate format:GenericNPCFormat "We serve only the best food prepared by Master Chefs." targets: - narrate format:GenericNPCFormat "Open the menu and click on the items you want." targets: - narrate format:GenericNPCFormat "Here you go. Take a look through our menu and choose what you would like." } - give 'i@menu[display_name=%restaurant% Menu]' - wait 15t - random { - narrate format:GenericNPCFormat "Place your order and I<&sq>ll come get the menu." targets: - narrate format:GenericNPCFormat "Click the Order Accept button to place your order." targets: - narrate format:GenericNPCFormat "A waitress will take the menu when you<&sq>re done." targets: - narrate format:GenericNPCFormat "Click the Order Accept button when you<&sq>re finished." targets: - narrate format:GenericNPCFormat "Someone will come grab the menu when you are ready." } - wait 30t - inject processTicketQueue locally click_order: # When the Waitress is taking an order - wait 15t - random { - narrate format:GenericNPCFormat "I<&sq>ll be right with you ." - narrate format:GenericNPCFormat "I<&sq>m with another customer right now." targets: - narrate format:GenericNPCFormat "One moment please, I<&sq>m taking an order." targets: - narrate format:GenericNPCFormat "Someone will be with you soon." targets: - narrate format:GenericNPCFormat "Hold on a sec there dear, I<&sq>m taking another order right now." targets: } click_deliver: # When the Waitress is delivering food - wait 15t - random { - narrate format:GenericNPCFormat "We<&sq>re a little busy right now ." - narrate format:GenericNPCFormat "I<&sq>m running food right now ." targets: - narrate format:GenericNPCFormat "My hands are a little full " targets: - narrate format:GenericNPCFormat " they really don<&sq>t pay me enough for this..." targets: - narrate format:GenericNPCFormat "I<&sq>m pretty tired ." targets: - narrate format:GenericNPCFormat "Please have a seat and a Waitress will be right with you." targets: } # #-------------------------------------- # Order Up Responses # orderup_drunk: # A catchall if something derps - flag npc status:drunk - if ]> queue queue:fidgetQueue_ stop - random { - narrate format:GenericNPCFormat "I quit!" targets: - narrate format:GenericNPCFormat "I<&sq>m done with this place!" targets: - narrate format:GenericNPCFormat "I should have called out!" targets: - narrate format:GenericNPCFormat "I had way too much to drink last night..." targets: - narrate format:GenericNPCFormat "I<&sq>m not feeling well... I have to go." targets: } - wait 2s - despawn orderup_available: # When the Waitress is available for whatever - flag npc status:deliver - if ]> queue queue:fidgetQueue_ stop - if { - random { - narrate format:GenericNPCFormat "Ticket %ticketNumber% heard!" targets: - narrate format:GenericNPCFormat "Oh, another order is ready." targets: - narrate format:GenericNPCFormat "Yay! Food to run!" targets: - narrate format:GenericNPCFormat "I<&sq>m a happy little worker bee." targets: - narrate format:GenericNPCFormat "Time to get working." targets: } } - inject locally processTicketQueue orderup_order: # When the Waitress is taking an order - if { - random { - narrate format:GenericNPCFormat "Heard ticket %ticketNumber%! I<&sq>m taking an order right now." targets: - narrate format:GenericNPCFormat "Buzz buzz." targets: - narrate format:GenericNPCFormat "The kitchen sure is busy!" targets: - narrate format:GenericNPCFormat "They are working hard back there." targets: - narrate format:GenericNPCFormat "The guy on the grill is by bf." targets: } } orderup_deliver: # When the Waitress is delivering food - if { - random { - narrate format:GenericNPCFormat "Heard ticket %ticketNumber%! I<&sq>m running food right now." targets: - narrate format:GenericNPCFormat "My goodness, the food just keeps on coming!" targets: - narrate format:GenericNPCFormat "I<&sq>m in the weeds!" targets: - narrate format:GenericNPCFormat "I<&sq>m going as fast as I can!" targets: - narrate format:GenericNPCFormat "This is a rough night!" targets: } } # #-------------------------------------- # Proximity Responses # proximity_drunk: # A catchall if something derps - flag npc status:drunk - if ]> queue queue:fidgetQueue_ stop - random { - narrate format:GenericNPCFormat "I quit!" targets: - narrate format:GenericNPCFormat "I<&sq>m done with this place!" targets: - narrate format:GenericNPCFormat "I should have called out!" targets: - narrate format:GenericNPCFormat "I had way too much to drink last night..." targets: - narrate format:GenericNPCFormat "I<&sq>m not feeling well... I have to go." targets: } - wait 2s - despawn proximity_available: # When the Waitress is available for whatever - if { - random { - narrate format:GenericNPCFormat "Ticket %ticketNumber% heard!" targets: - narrate format:GenericNPCFormat "Oh, another order is ready." targets: - narrate format:GenericNPCFormat "Yay! Food to run!" targets: - narrate format:GenericNPCFormat "I<&sq>m a happy little worker bee." targets: - narrate format:GenericNPCFormat "Time to get working." targets: } } proximity_order: # When the Waitress is taking an order - if { - random { - narrate format:GenericNPCFormat "Heard ticket %ticketNumber%! I<&sq>m taking an order right now." targets: - narrate format:GenericNPCFormat "Buzz buzz." targets: - narrate format:GenericNPCFormat "The kitchen sure is busy!" targets: - narrate format:GenericNPCFormat "They are working hard back there." targets: - narrate format:GenericNPCFormat "The guy on the grill is by bf." targets: } } proximity_deliver: # When the Waitress is delivering food - define player '' - if { - random { - narrate format:GenericNPCFormat "Heard ticket %ticketNumber%! I<&sq>m running food right now." targets: - narrate format:GenericNPCFormat "My goodness, the food just keeps on coming!" targets: - narrate format:GenericNPCFormat "I<&sq>m in the weeds!" targets: - narrate format:GenericNPCFormat "I<&sq>m going as fast as I can!" targets: - narrate format:GenericNPCFormat "This is a rough night!" targets: } } # # END MasterWaitress Status Actions #-------------------------------------- # # # END MASTERWAITRESS ASSIGNMENT SCRIPT CONTAINER #