Date: 2014/09/04 06:45:37 UTC-07:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# NPC Blacksmith
# Citizens 2 (build #992)
# Denizen 0.9.3 (build #1352)
#
# @author Hyruii
#
# FOR EASY SETUP
# 1) Select the NPC and type /npc assign --set "blacksmith"
# Assignment script for blacksmith.
"blacksmith":
type: assignment
default constants:
# Costs to repair one point of durability
repairdurability: 10
# Costs to repair each level of enchant
repairenchant: 100
interact scripts:
# Priority starts from 10
- 10 SmithCheck
actions:
on assignment:
# Enable/disable triggers with NPC via chatting, clicking and entering proximity.
- trigger name:chat toggle:true
- trigger name:click toggle:true
- trigger name:proximity toggle:true radius:5
on enter proximity:
- chat "Hey <player.name>! Se hai qualcosa da riparare vieni qui e mostramelo."
on exit proximity:
- zap 's@SmithCheck' step:default
"SmithCheck":
type: interact
steps:
default:
click trigger:
script:
# Checks if item in player's hand is repairable. If so, run a task called CalcCost.
- if <<player.item_in_hand>.repairable> == true {
- chat "Mmm, fammelo vedere...."
- run CalcCost instantly
- wait 1s
- chat "Ti costerà <gold><flag.p:repaircost> <green> soldi per ripararlo."
- narrate "Scegli una della seguenti risposte digitando il numero corrispondente"
- narrate "1) Sì, riparamelo! (paga <flag.p:repaircost>)"
- narrate "2) No, grazie!"
- zap repair
}
else {
- chat "Non sono in grado di ripararlo."
}
repair:
chat trigger:
'Yes':
trigger: '/1/ Sì, riparamelo!'
script:
# Once player agree to repair, check for sufficient money and increase durability (number of times used) to zero.
- if <player.money> OR_MORE <flag.p:repaircost> {
- playsound <player.location> sound:anvil_use
- take money qty:<flag.p:repaircost>
- define item <player.item_in_hand>
- take iteminhand
- adjust <player.item_in_hand> durability:0 save:newitem
- give <entry[newitem].result>
- chat "Ecco a te, torna di nuovo se hai bisogno di riparare!"
- narrate "Ora hai <gold><player.money.as_money> soldi."
- zap default
}
else {
- chat "Hey, non hai soldi sufficienti! Torna quando li avrai, barbone!"
- zap default
}
'No':
trigger: '/2/ Non voglio ripararlo.'
script:
- chat "Torna da me quando dovrai ripararlo."
- zap default
"CalcCost":
type: task
script:
# Check for enchantments and the state of durability used.
- if <<player.item_in_hand>.enchantments> != null {
- flag player enchantlvl:0
- foreach <<player.item_in_hand>.enchantments.levels> {
- flag player enchantlvl:++:%value%
}
}
else {
- flag player enchantlvl:0
}
- flag player duralvl:<<player.item_in_hand>.durability>
# Calculates repair cost based on enchant level & durability.
- flag player enchantcost:<flag.p:enchantlvl>
- flag player enchantcost:**:<cons:repairenchant>
- flag player duracost:<flag.p:duralvl>
- flag player duracost:**:<cons:repairdurability>
- flag player repaircost:<flag.p:enchantcost>
- flag player repaircost:++:<flag.p:duracost>