Date: 2017/12/10 15:54:14 UTC-08: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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
all_npc_list:
type: yaml data
debug: false
# List all NPCs to load into the world.
#
# When writing new NPCs, do NOT use the following entity types:
# - PLAYER
# - ARMOR_STAND
# - BOAT (any variant)
# - MINECART (any variant)
# - DROPPED_ITEM
# - FALLING_BLOCK
# - EXPERIENCE_ORB
# - any projectile
# - FIREWORK
# - PRIMED_TNT
# - LIGHTNING
# - LEASH_HITCH
# - PAINTING
# - SMALL_FIREBALL
# - FIREBALL
# - WITHER_SKULL
# - DRAGON_FIREBALL
#
# None of those will be accounted for. If you want total NPC support, just
# use Citizens2 instead.
npcs:
0:
custom_name: 'default'
entity: 'zombie_villager'
nickname: ''
location: '0.0,0.0,0.0,world'
# Traits
lookclose: 'false'
click: 'false'
age: 0
# For age, it can be "baby", "adult", or an integer from -24000 to 0.
#
color: 'none'
# For colors, refer to Denizen's available coloring. Use the same syntax
# as if you were adjusting the color mechanism.
#
# https://one.denizenscript.com/denizen/mecs/color/
#
powered: false
# Determines if a creeper is powered.
profession: FARMER
# Determines the entity's profession. Available professions are:
# - BLACKSMITH
# - BUTCHER
# - FARMER
# - LIBRARIAN
# - PRIEST
# - HUSK (for zombies)
health: '20/20'
equipment:
head: 'air'
chest: 'air'
legs: 'air'
boots: 'air'
item_in_hand: 'air'
item_in_offhand: 'air'
all_npc_handler:
type: world
speed: 0
debug: false
events:
on entity spawns:
- wait 1t
- if !<context.entity.has_flag[npc.id]> {
- queue clear
}
# Lock age
- if <context.entity.is_ageable> {
- define age '<context.entity.flag[npc.age].max[-24000].min[0].round_down||0>'
- if <li@baby|adult.contains[<def[age]>]> || <def[age]> matches number {
- adjust <context.entity> age:<def[age]>|locked
}
}
# Determine color
- if <context.entity.is_colorable> {
- if <context.entity.entity_type> == HORSE {
- define d_color 'BLACK|NONE|HORSE'
}
else if <context.entity.entity_type> == WOLF && <context.entity.is_tamed> {
- define d_color 'red'
}
else if <context.entity.entity_type> == SHEEP {
- define d_color 'white'
}
else if <context.entity.entity_type> == OCELOT {
- define d_color 'WILD_OCELOT'
}
else if <context.entity.entity_type> == RABBIT {
- define d_color 'BROWN'
}
else {
- define d_color 'BLUE'
}
- adjust <context.entity> color:<context.entity.flag[npc.color]||<def[d_color]>>
}
# If a Guardian is an Elder variant
- if <context.entity.entity_type> == GUARDIAN {
- adjust <context.entity> elder:<context.entity.flag[npc.guardian.elder].as_boolean||false>
}
# Change armor
- define i_d 'i@air'
- if <context.entity.entity_type> != ENDERMAN {
- define e_d 'li@i@air|i@air|i@air|i@air'
- adjust <context.entity> equipment:<context.entity.flag[npc.equipment.equipment]||<def[e_d]>>
- adjust <context.entity> item_in_hand:<context.entity.flag[npc.equipment.item_in_hand]||<def[i_d]>>
- adjust <context.entity> item_in_offhand:<context.entity.flag[npc.equipment.item_in_offhand]||<def[i_d]>>
}
else {
- adjust <context.entity> item:<context.entity.flag[npc.equipment.item_in_hand]||<def[i_d]>>
}
# Power a creeper
- if <context.entity.entity_type> == CREEPER {
- adjust <context.entity> powered:<context.entity.flag[npc.powered]||false>
}
# Adjust HP
- adjust <context.entity> health_data:<context.entity.flag[npc.health]>
load_npcs:
- foreach <s@all_npc_list.list_keys[npcs].exclude[0]> {
# Build the base for the NPC
- define e '<s@all_npc_list.yaml_key[npcs.<def[value]>.entity].as_entity>'
- define name '<s@all_npc_list.yaml_key[npcs.<def[value]>.custom_name].unescaped||null>'
- if <def[name]> != null {
- define name 'custom_name=<def[name]>;custom_name_visible=true'
}
else {
- define name ''
}
- define loc '<s@all_npc_list.yaml_key[npcs.<def[value]>.location]>'
- define spawn_constants 'has_ai=false;can_pickup_items=false;silent=true;invulnerable=true;remove_when_far_away=false'
- spawn '<def[e]>[<def[spawn_constants]>;<def[name]||>]' <def[loc]> save:loaded_npc
- defined s_e '<entry[loaded_npc].spawned_entities.get[1]>'
# Begin reading extra data
# Health
- define hp_data '<s@all_npc_list.yaml_key[npcs.<def[value]>.health]||20/20>'
- flag <def[s_e]> 'npc.health:<def[hp_data]>'
# ID and nickname
- define nick '<s@all_npc_list.yaml_key[npcs.<def[value]>.nickname]||<&f>NPC>'
- flag <def[s_e]> 'npc.id:<def[value]>'
- flag <def[s_e]> 'npc.nickname:<def[value]>'
# Lookclose
- define lookclose '<s@all_npc_list.yaml_key[npcs.<def[value]>.lookclose].split[/]||li@false>'
- flag <def[s_e]> 'npc.lookclose.enabled:<def[lookclose].get[1]>'
- if <def[lookclose].get[1]> {
- flag <def[s_e]> 'npc.lookclose.range:<def[lookclose].get[2].as_decimal.max[0].min[32]||5>'
- flag <def[s_e]> 'npc.lookclose.realistic:<def[lookclose].get[3].as_boolean||true>'
}
# Click
- define click '<s@all_npc_list.yaml_key[npcs.<def[value]>.click].split[/]||li@false>'
- if <def[click].get[1]||false> && <server.list_scripts.parse[name].contains[<def[click].get[2]||null-<util.random.uuid>>]> {
- flag <def[s_e]> 'npc.click.enabled:<def[click].get[1]>'
- flag <def[s_e]> 'npc.click.script:<def[click].get[2]>'
}
# Equipment
- define equip_h '<s@all_npc_list.yaml_key[npcs.<def[value]>.equipment.head].as_item||i@air>'
- define equip_c '<s@all_npc_list.yaml_key[npcs.<def[value]>.equipment.chest].as_item||i@air>'
- define equip_l '<s@all_npc_list.yaml_key[npcs.<def[value]>.equipment.legs].as_item||i@air>'
- define equip_b '<s@all_npc_list.yaml_key[npcs.<def[value]>.equipment.boots].as_item||i@air>'
- define equip_imh '<s@all_npc_list.yaml_key[npcs.<def[value]>.equipment.item_in_hand].as_item||i@air>'
- define equip_ioh '<s@all_npc_list.yaml_key[npcs.<def[value]>.equipment.item_in_offhand].as_item||i@air>'
- define equip_list 'li@<def[equip_b]>|<def[equip_l]>|<def[equip_c]>|<def[equip_h]>'
- flag <def[s_e]> 'npc.equipment.equipment:<def[equip_list]>'
- flag <def[s_e]> 'npc.equipment.item_in_hand:<def[equip_imh]>'
- flag <def[s_e]> 'npc.equipment.item_in_offhand:<def[equip_ioh]>'
# Creeper power
- define power '<s@all_npc_list.yaml_key[npc.<def[value]>.powered].as_boolean||false>'
- flag <def[s_e]> 'npc.powered:<def[power]>'
# Profession
- define prof '<s@all_npc_list.yaml_key[npc.<def[value]>.profession]||FARMER>'
- flag <def[s_e]> 'npc.profession:<def[prof]>'
}