luizragna Posted August 5, 2019 Group: Members Topic Count: 35 Topics Per Day: 0.01 Content Count: 107 Reputation: 28 Joined: 02/12/14 Last Seen: January 9, 2023 Share Posted August 5, 2019 Hello guys. How can i do it the right way? prontera,100,100,4 script Duplicator 84,{ prontera,162,193,4 duplicate(Healer) Healer#prt 909 //<----- } Quote Link to comment Share on other sites More sharing options...
1 Tokei Posted August 5, 2019 Group: Members Topic Count: 16 Topics Per Day: 0.00 Content Count: 695 Reputation: 721 Joined: 11/12/12 Last Seen: Wednesday at 10:42 PM Share Posted August 5, 2019 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}, 2 Quote Link to comment Share on other sites More sharing options...
0 onlineteam Posted August 5, 2019 Group: Members Topic Count: 1 Topics Per Day: 0.00 Content Count: 10 Reputation: 0 Joined: 12/07/16 Last Seen: November 6, 2024 Share Posted August 5, 2019 3 hours ago, luizragna said: Hello guys. How can i do it the right way? prontera,100,100,4 script Duplicator 84,{ prontera,162,193,4 duplicate(Healer) Healer#prt 909 //<----- } prontera,100,100,4 script Duplicator 84,{ script } prontera,162,193,4 duplicate(Duplicator) Healer#prt 909 Quote Link to comment Share on other sites More sharing options...
0 luizragna Posted August 5, 2019 Group: Members Topic Count: 35 Topics Per Day: 0.01 Content Count: 107 Reputation: 28 Joined: 02/12/14 Last Seen: January 9, 2023 Author Share Posted August 5, 2019 @Tokei It would be better if don't need to make modifications to the source. But that already helps. Thank You Quote Link to comment Share on other sites More sharing options...
Question
luizragna
Hello guys. How can i do it the right way?
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.