Description: This is the first script I've posted on here, I've used this repository as a resource for a couple of months now, teaching myself denizen scripting from your work.
My server uses GriefPrevention and we needed a way to give our players a way to increase their claim block bonus each day to encourage them to visit often.
This script is customizable in that you can set the requirements and the reward (in number of claim blocks) in the 'default constants' section.
I had trouble with the NPC initially, he just wouldn't stop listening as I had put the chat trigger into the 'on assignment' section. Now I toggle it on when it is needed, then off when it isn't. It seems to work ok.
You'll notice there are a lot of 'Narrate' instead of 'chat'. I don't like having the chat clogged up with NPC chatter, so find it far neater to have narration appearing to just the player doing the quest.
# -------------------# Written by Krowerom, 7th May 2014# Requires Citizens, Denizen, GriefPrevention# -------------------# Place an NPC at desired location:# /npc create ClaimBlockGuy# /npc assign --set Assign_Blocks# -------------------
'Assign_Blocks':
type: assignment
interact scripts:
- 10 BlockGiverHi
# -------------------# You can customise the items required, quantity and reward here# -START-
default constants:
ItemRequiredName: books
ItemRequiredID: 340
ItemRequiredQty: 2
ClaimBlockReward: 100# -END-# -------------------
actions:
on assignment:
- trigger name:click toggle:true
'BlockGiverHi':
type: interact
steps:
'SayingHi*':
click trigger:
script:
- ^engage
- if <player.flag[DailyBlockBonus]> {
- wait 1
- narrate "<gold><npc.name><&co><white> Hello <player.name>, Thanks for the <npc.constant[ItemRequiredName]>."
- wait 1
- narrate "I have all I need for today, come and see me tomorrow."
- ^zap step:SayingHi
- ^disengage
} else {
- wait 1
- narrate "<gold><npc.name><&co><white> Hello <player.name>, I have a task for you, are you free?"
- wait 1
- narrate "<gray>You can respond <green>Yes<white> or <red>No"
- trigger name:chat toggle:true radius:5
- ^disengage
}
chat trigger:
'Yes':
trigger: /Yes/ <npc.name>, I have time now
script:
- ^engage
- wait 2
- narrate "<gold><npc.name><&co><white> Wonderful, I really need some help collecting <npc.constant[ItemRequiredName]>."
- wait 2
- narrate "If you would bring me just <npc.constant[ItemRequiredQty]> <npc.constant[ItemRequiredName]>, I will ensure that you receive permission to build an <gold>extra <npc.constant[ClaimBlockReward]> blocks!"
- trigger name:chat toggle:false
- ^zap step:RewardTime
- ^disengage
'No':
trigger: I'm sorry <npc.name>, I have /no/ time at the moment
script:
- ^engage
- wait 2
- narrate "<gold><npc.name><&co><white> Well return to me when you have time to help, you know where I am."
- trigger name:chat toggle:false
- ^zap step:SayingHi
- ^disengage
'Other':
trigger: /REGEX:^\w+$/
script:
- ^engage
- wait 1
- narrate "<gold><npc.name><&co><white> I have no idea what you mean, <player.name>."
- trigger name:chat toggle:false
- ^zap step:SayingHi
- ^disengage
'RewardTime':
click trigger:
script:
- ^engage
- wait 1
- narrate "<gold><npc.name><&co><white> Do you have my <npc.constant[ItemRequiredName]>?"
- wait 2
- if <player.inventory.contains[<npc.constant[ItemRequiredID]>].qty[<npc.constant[ItemRequiredQty]>]> {
- narrate "Great! I'll take those..."
- ^take <npc.constant[ItemRequiredID]>] qty:<npc.constant[ItemRequiredQty]>
- wait 2
- narrate "As promised, I have arranged for you to receive extra claim blocks."
- wait 1
- narrate "<gray>You have received a bonus <gold><npc.constant[ClaimBlockReward]> claim blocks!"
- ^execute as_npc "acb <player.name> <npc.constant[ClaimBlockReward]>"
- ^flag player DailyBlockBonus duration:20h
- ^zap step:SayingHi
- ^disengage
} else {
- narrate "I'll be here waiting, when you decide to bring me what I need."
- ^disengage
}