@@ -14,7 +14,7 @@ dmodels_command:
1414 type : command
1515 debug : false
1616 name : dmodels
17- usage : /dmodels [load/loadall/spawn/remove/animate/stopanimate]
17+ usage : /dmodels [load/loadall/spawn/remove/animate/stopanimate/npcmodel ]
1818 description : Manages Denizen Models.
1919 permission : dmodels.help
2020 tab completions :
@@ -116,6 +116,38 @@ dmodels_command:
116116 - stop
117117 - run dmodels_end_animation def.root_entity:<[target] >
118118 - narrate "<&[base] > Animation stopped."
119+ - case npcmodel:
120+ - if !<player.has_permission[dmodels.npcmodel] > :
121+ - narrate "<&[error] > You do not have permission for that."
122+ - stop
123+ - if !<player.selected_npc.exists> :
124+ - narrate "<&[error] > You do not have any NPC selected."
125+ - stop
126+ - adjust <queue> linked_npc:<player.selected_npc>
127+ - if !<context.args.get[2] .exists> :
128+ - narrate "<&[warning] > /dmodels npcmodel [model] <&[error] > - sets an NPC to render as a given model (must be loaded). Use 'none' to remove the model."
129+ - stop
130+ - define model <context.args.get[2] >
131+ - if !<[model] .to_lowercase.matches_character_set[<script[dmodels_cmd_data] .data_key[valid_chars] > ] > :
132+ - narrate "<&[error] > Given model name has an invalid format."
133+ - stop
134+ - if <[model] > == none:
135+ - flag <npc> dmodels_model:!
136+ - if <npc.scripts.parse[name] .contains[dmodels_npc_assignment] ||false> :
137+ - run dmodels_npc_despawn
138+ - assignment remove script:dmodels_npc_assignment
139+ - narrate "<&[base] > NPC <npc.id.custom_color[emphasis] > (<npc.name><&[base] > ) will now render as a normal NPC."
140+ - stop
141+ - if !<server.has_flag[dmodels_data.model_<[model] > ] > :
142+ - narrate "<&[error] > No such model exists, or that model has never been loaded."
143+ - stop
144+ - flag <npc> dmodels_model:<[model] >
145+ - if !<npc.scripts.parse[name] .contains[dmodels_npc_assignment] ||false> :
146+ - assignment add script:dmodels_npc_assignment
147+ - else :
148+ - run dmodels_npc_despawn
149+ - run dmodels_npc_spawn
150+ - narrate "<&[base] > NPC <npc.id.custom_color[emphasis] > (<npc.name><&[base] > ) will now render as model <[model] .custom_color[emphasis] > "
119151 # help
120152 - default :
121153 - if <player.has_permission[dmodels.load] ||true> :
@@ -130,6 +162,8 @@ dmodels_command:
130162 - narrate "<&[warning] > /dmodels animate [animation] <&[error] > - causes the closest real-spawned model to start playing the given animation"
131163 - if <player.has_permission[dmodels.stopanimate] ||true> :
132164 - narrate "<&[warning] > /dmodels stopanimate <&[error] > - causes the closest real-spawned model to stop animating"
165+ - if <player.has_permission[dmodels.npcmodel] ||true> :
166+ - narrate "<&[warning] > /dmodels npcmodel [model] <&[error] > - sets an NPC to render as a given model (must be loaded). Use 'none' to remove the model."
133167 - narrate "<&[warning] > /dmodels help <&[error] > - this help output"
134168
135169dmodels_get_target :
@@ -146,7 +180,7 @@ dmodels_tab_1:
146180 debug : false
147181 script :
148182 - define list <list>
149- - foreach load|loadall|spawn|remove|animate|stopanimate|help as:key:
183+ - foreach load|loadall|spawn|remove|animate|stopanimate|npcmodel| help as:key:
150184 - if <player.has_permission[<[key] > ] ||true> :
151185 - define list:->:<[key] >
152186 - determine <[list] >
@@ -167,6 +201,8 @@ dmodels_tab_2:
167201 - determine <util.list_files[data/dmodels/<[path] > ] .parse[before_last[.bbmodel] ] ||<list> >
168202 - else if <[args] .first> == spawn && <player.has_permission[dmodels.spawn] ||true> :
169203 - determine <server.flag[dmodels_data] .keys.filter[starts_with[model_] ] .parse[after[model_] ] >
204+ - else if <[args] .first> == npcmodel && <player.has_permission[dmodels.npcmodel] ||true> :
205+ - determine <server.flag[dmodels_data] .keys.filter[starts_with[model_] ] .parse[after[model_] ] .include[none] >
170206 - else if <[args] .first> == animate && <player.has_permission[dmodels.animate] ||true> :
171207 - define target <player.location.find_entities[dmodel_part_stand] .within[10] .filter[has_flag[dmodel_model_id] ] .first||null>
172208 - if !<[target] .is_truthy> :
0 commit comments