Jump to content
  • 0
Vixus

NPC jump onbuy item

Question

requesting for a shop NPC that will jump on random location after a player bought an item

like jumper event but shop NPC..

like prontera,155,155,5 shop annie 757,501:50,502:50,503:50

set $@ran, rand(1,10);
if ($@ran == 10) set $@jmpmap$,"hugel";
if ($@ran == 9) set $@jmpmap$,"yuno";
if ($@ran == 8) set $@jmpmap$,"comodo";
if ($@ran == 7) set $@jmpmap$,"xmas";
if ($@ran == 6) set $@jmpmap$,"aldebaran";
if ($@ran == 5) set $@jmpmap$,"izlude";
if ($@ran == 4) set $@jmpmap$,"payon";
if ($@ran == 3) set $@jmpmap$,"geffen";
if ($@ran == 2) set $@jmpmap$,"morocc";
if ($@ran == 1) set $@jmpmap$,"prontera";
OnBuyItem:
movenpc "annie"+$@ran+"",1,1; //move the NPC
setnpcdisplay "annie"+$@ran+"",1002;
end;
}

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0
56 minutes ago, Vixus said:

requesting for a shop NPC that will jump on random location after a player bought an item

like jumper event but shop NPC..

like prontera,155,155,5 shop annie 757,501:50,502:50,503:50

set $@ran, rand(1,10);
if ($@ran == 10) set $@jmpmap$,"hugel";
if ($@ran == 9) set $@jmpmap$,"yuno";
if ($@ran == 8) set $@jmpmap$,"comodo";
if ($@ran == 7) set $@jmpmap$,"xmas";
if ($@ran == 6) set $@jmpmap$,"aldebaran";
if ($@ran == 5) set $@jmpmap$,"izlude";
if ($@ran == 4) set $@jmpmap$,"payon";
if ($@ran == 3) set $@jmpmap$,"geffen";
if ($@ran == 2) set $@jmpmap$,"morocc";
if ($@ran == 1) set $@jmpmap$,"prontera";
OnBuyItem:
movenpc "annie"+$@ran+"",1,1; //move the NPC
setnpcdisplay "annie"+$@ran+"",1002;
end;
}

I don't think you can move npc from one map to another. Afaik, you can only randomize the coordinates (x &y) of a certain map.

Share this post


Link to post
Share on other sites
  • 0

You can use this (it's based on rAthena, I haven't tested on Hercules ;x. I presume it's compatible though!).

-	shop	#annie_shop	-1,501:50,502:50,503:50

prontera,155,155,4	script	Annie Shop	757,{
	callshop "#annie_shop", 0;
	npcshopattach "#annie_shop";
	end;
OnBuyItem:
	.@map$ = .jmpmaps$[rand(getarraysize(.jmpmaps$))];
	getfreecell(.@map$, .@x, .@y);
	specialeffect EF_TELEPORTATION2; // For the teleport effect
	unitwarp getnpcid(0), .@map$, .@x, .@y;
	dispbottom "Teleported NPC to " + .@map$ + " (" + .@x + ", " + .@y + ")";
	end;
OnInit:
	setarray .jmpmaps$, "hugel", "yuno", "comodo", "xmas", "aldebaran", "izlude", "payon", "geffen", "morocc", "prontera";
	end;
}

 

Edited by Tokeiburu

Share this post


Link to post
Share on other sites
  • 0

Exactly what i need.. didnt tested it yet.. but if i do have some errors ill report it.. Rathena Herc.. i do have both.. ill try it on rathena and herc later

Share this post


Link to post
Share on other sites
  • 0
10 hours ago, Legend said:

@Tokeiburu Thanks for sharing that.
Herc. doesn't have getfreecell command https://github.com/HerculesWS/Hercules/blob/master/doc/script_commands.txt

It does have checkcell() though so one could just do a while() loop that randomize the coordinates until a cell is cell_chkpass

Share this post


Link to post
Share on other sites
  • 0

if use unitwarp on npc, and after run script reload, server may crash.

Share this post


Link to post
Share on other sites
  • 0

@meko Oh I see, I don't know what does getfreecell actually do  *since I dont use rA* was just pointing about compatibility of his script tho :kiss_wink:

Share this post


Link to post
Share on other sites
  • 0

By myself, I'll do it this way, as we want it to happen through several maps:

-	shop	#annie_shop	-1,501:50,502:50,503:50

prontera,155,155,4	script	Annie Shop::alansho0	757,{
	callshop "#annie_shop", 0;
	npcshopattach "#annie_shop";
	end;
	
OnBuyItem:
	callsub OnHideAllNpcs;
	goto OnUnhideOne;
	dispbottom "Teleported NPC to " + .@map$ + " (" + .@x + ", " + .@y + ")";
	end;
	
OnHideAllNpcs:
	for(set .@i,0; .@i<.maxNpcLocation; set .@i,.@i+1)
	{
		hideonnpc "alansho" + .@i;
	}
	return;
	
OnUnhideOne:
	set .@rand, rand(0,9);
	doevent "alansho" + .@rand + "::OnUnHide";
	end;
	
OnUnHide:
	do
	{		
		set .@movex,rand(0,150);
		set .@movey,rand(0,150);
		set .@map$,strcharinfo(3);
	}
	while(!checkcell(.@map$,.@movex,.@movey,cell_chkpass));
	movenpc strnpcinfo(3),.@movex,.@movey;
	hideoffnpc strnpcinfo(3);	
	end;
	
OnInit:
	set .maxNpcLocation, 10;
	if(strnpcinfo(3) == "alansho0")
	{
		callsub OnHideAllNpcs;
		goto OnUnhideOne;
	}
	end;
}

hugel,155,155,3	duplicate(alansho0)	Annie Shop::alansho1	757
yuno,155,155,3	duplicate(alansho0)	Annie Shop::alansho2	757
comodo,155,155,3	duplicate(alansho0)	Annie Shop::alansho3	757
xmas,155,155,3	duplicate(alansho0)	Annie Shop::alansho4	757
aldebaran,155,155,3	duplicate(alansho0)	Annie Shop::alansho5	757
izlude,155,155,3	duplicate(alansho0)	Annie Shop::alansho6	757
payon,155,155,3	duplicate(alansho0)	Annie Shop::alansho7	757
geffen,155,155,3	duplicate(alansho0)	Annie Shop::alansho8	757
morocc,155,155,3	duplicate(alansho0)	Annie Shop::alansho9	757

Can't test it, but I've it for other npcs. Just place the npcs where you want (map speaking), and they'll activate one randomly, located randomly, at server start and after each buy.

 

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
Answer this question...

×   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.