Heya,
This is possible, but it usually means the solution/algoritm you're trying to use is the wrong one to start with. That aside, you can use something similar to:
duplicate "prontera", 154, 182, 4, "SourceNPC", "DuplicatedNPC", 77;
And you'll have to do the changes below:
diff --git a/src/map/npc.hpp b/src/map/npc.hpp
index 0ce0c96a0..ffde62587 100644
--- a/src/map/npc.hpp
+++ b/src/map/npc.hpp
@@ -1219,6 +1219,7 @@ void do_clear_npc(void);
void do_final_npc(void);
void do_init_npc(void);
void npc_event_do_oninit(void);
+const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath);
int npc_event_do(const char* name);
int npc_event_do_id(const char* name, int rid);
diff --git a/src/map/script.cpp b/src/map/script.cpp
index 604274ecd..9da5d4690 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -24548,6 +24548,38 @@ BUILDIN_FUNC(preg_match) {
#endif
}
+BUILDIN_FUNC(duplicate)
+{
+ const char *map = script_getstr(st,2);
+ int x = script_getnum(st,3);
+ int y = script_getnum(st,4);
+ int dir = script_getnum(st,5);
+ const char *duplicate_name = script_getstr(st,6);
+ const char *npc_name = script_getstr(st,7);
+ char w1[2048], w2[2048], w3[2048], w4[2048], p[2048];
+ int view_id = script_getnum(st,8);
+ struct npc_data* nd = map_id2nd(st->oid);
+
+ if (!nd) {
+ return SCRIPT_CMD_FAILURE;
+ }
+
+ sprintf(w1, "%s,%d,%d,%d", map, x, y, dir);
+ sprintf(w2, "duplicate(%s)", duplicate_name);
+ sprintf(w3, "%s", npc_name);
+
+ if (script_hasdata(st,9) && script_hasdata(st,10)) {
+ sprintf(w4, "%d,%d,%d", view_id, script_getnum(st,9), script_getnum(st,10));
+ }
+ else {
+ sprintf(w4, "%d", view_id);
+ }
+
+ sprintf(p, "%s\t%s\t%s\t%s", w1, w2, w3, w4);
+ npc_parse_duplicate(w1,w2,w3,w4, p, p, nd->path);
+ return SCRIPT_CMD_SUCCESS;
+}
+
/// script command definitions
/// for an explanation on args, see add_buildin_func
struct script_function buildin_func[] = {
@@ -25170,6 +25202,8 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(achievement_condition,"i"),
BUILDIN_DEF(getvariableofinstance,"ri"),
BUILDIN_DEF(convertpcinfo,"vi"),
+
+ BUILDIN_DEF(duplicate,"siiissi??"),
#include "../custom/script_def.inc"
{NULL,NULL,NULL},