Jump to content

Recommended Posts

thumb-5682b59e7f9a13880cf7e48c3b2c0ab7-screenhercules017.jpg

File Name: Duplicate NPC Commands

File Submitter: Dastgir

File Submitted: 12 Jan 2015

File Category: Plugins

 

2 Self Explanatory Commands:

duplicatenpc("NpcName", "DuplicateName", "DupHiddenName", "map", x, y, dir{, sprite{, xs, ys}});duplicateremove({"NPCname"});

 

Example Script:

prontera,150,150,5	script	DupTest	999,{mes strnpcinfo(0);close;OnInit:duplicatenpc(strnpcinfo(0),"Duplicated","","prontera",150,148,5,998);end;OnWhisperGlobal:duplicateremove();}

^ Above script will self-duplicate itself with name "Duplicated" to prontera,150,148 with Sprite ID 998, and upon whispering to any of those npc, the duplicate will be removed.

 

 

Requested by GMOcean @ http://herc.ws/board/topic/7718-duplicatenpc-duplicateremove/?view=getnewpost

 

Click here to download this file

Share this post


Link to post
Share on other sites

Sweet mother of god! This, just made things sooo much better. Now I can rewrite sooo many scripts that rely on hard-coded duplicates, and just soft-duplicate them when needed and then remove. Efficiency + Over 100% less resource consumption since they don't all need to be active at once anymore.

 

Thanks, Dastgir. Though it sucks school started for me... not much time to play with it T.T;

 

Edit:

Just 1 question. The duplicateremove command. Does it work in such that, it can remove just 1 duplicate or all if so chosen?

Because, I had originally hoped that, we'd be able to remove 1 specific duplicate and/or all of them, by specifying either a DuplicateNPC's name, or the Source NPC name.

(Sorry, don't actually have time to play around with it @work/@school).

Edited by GmOcean

Share this post


Link to post
Share on other sites

By looking at the file, it removes the duplicate you name/on which duplicateremove() is called, or removes all duplicates if the NPC named/called from is the source NPC. From the example above, if you'll PM "DupTest", it will remove all duplicates, if you'll PM "Duplicated", only that one duplicate will be removed.

 

Thank you for release!

Share this post


Link to post
Share on other sites

Sweet mother of god! This, just made things sooo much better. Now I can rewrite sooo many scripts that rely on hard-coded duplicates, and just soft-duplicate them when needed and then remove. Efficiency + Over 100% less resource consumption since they don't all need to be active at once anymore.

 

Thanks, Dastgir. Though it sucks school started for me... not much time to play with it T.T;

 

Edit:

Just 1 question. The duplicateremove command. Does it work in such that, it can remove just 1 duplicate or all if so chosen?

Because, I had originally hoped that, we'd be able to remove 1 specific duplicate and/or all of them, by specifying either a DuplicateNPC's name, or the Source NPC name.

(Sorry, don't actually have time to play around with it @work/@school).

Garr mentioned it right,

In duplicateremov, put the duplicated NPC name, then that duplicated NPC will only be removed. If you put the source NPC name, it will remove all duplicate.

Share this post


Link to post
Share on other sites

First of all, thanks for this great plugin :D This is just so cool, and better than before x), but i was wondering if it was possible that every duplicated npc have their own npc variable.

Because for now, they share their variable. And i would need them to have their own variable.

 

Also duplicated npc doesn't trigger the OnInit label, I know that this is because the map-server is already loaded when my npc is duplicated but i would be cool to be able to set up a little bit our npc. For the moment i call the OnInit label trough a donpcevent.

 

Thx :)

Edited by Khazou

Share this post


Link to post
Share on other sites

@@Khazou - If I'm not mistaken, NPC's & their duplicates share the same npc_variables as an intended feature in Hercules (rA as well I think).

You can test this by making an NPC, and hardcoding a duplicate (the default way) and setting a variable, it should set it for both of them.

 

Either way, whether they share or not, there is a small fix you can do on the script side to make it work as you want. All you would need to do is set the variables using setd/getd and add extra information to it, in this case you can just add the duplicates unique name to the variable.

 

Ex:

setd ".variable_name"+ strnpcinfo(3) +"$", "data_here";
Edited by GmOcean

Share this post


Link to post
Share on other sites

Ok thanks for your advice i wasn't sure if it was a good method :)

I will use setd and getd then, do npc have a maximum of npc variable ?

Edited by Khazou

Share this post


Link to post
Share on other sites

Ok thanks for your advice i wasn't sure if it was a good method :)

I will use setd and getd then, do npc have a maximum of npc variable ?

No limits...

Share this post


Link to post
Share on other sites

I'm having difficulties on building this pluguin is it still working on late revisions?

Uploaded new version

Share this post


Link to post
Share on other sites

Seems like it's not working on lastest Hercules revisions.

 

Or maybe it's just me. Can anyone confirm ?

Tested, its not working properly and throws an error:

[Error]: map_addblock: bl->prev != NULL

if @dastgir can see it would be fantastic

pd: Tested with the lasted Hercules in git

 

UPDATE:

Implementing my own version of the plugin Based on this one, i get the error.

you have to change this line:

npc->duplicate_sub(nd_source, nd_target, txs, tys, NPO_ONINIT);

to this:

npc->duplicate_sub(nd_target, nd_source, txs, tys, NPO_ONINIT);

and it work perfect

Edited by Enthr

Share this post


Link to post
Share on other sites

Could anyone please update this plugin?
Error say's that are to many arguments near this

 

if (nd != NULL) {
		st->state = END;
		if(nd->src_id == 0) {  // Remove All Duplicates
			npc->unload_duplicates(nd);
			npc->unload(nd, true);
		} else { // Remove single duplicate
			npc->unload(nd, true);
			if (nd->u.scr.script) {
				script->free_code(nd->u.scr.script);
				nd->u.scr.script = NULL;
			}
		}
		npc->read_event_script();
	}

 

Share this post


Link to post
Share on other sites

Can anyone please update this?
Map server crashing when using the 
duplicateremove

Thread 1 "map-server" received signal SIGSEGV, Segmentation fault.
script_free_code (code=0xfdfdfdfdfdfdfdfd) at script.c:4199
4199            if (code->instances)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.