NPC jump onbuy item

Vixus

New member
Messages
4
Points
0
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;
}

 
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.

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

Code:
-	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;
}
 
Last edited by a moderator:
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

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

 
@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:

 
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.

 
Back
Top