I don't know either if there's already such script (but it probably is on the other forums), but I just wrote a basic script.
Since I'm not at home I'm unable to test if it actually works.
What the script does:
- checks if the player is less then 5 cells away (checkdistance(...)<5)
- check if player has required item (countitem(607), Ygg Berry in this case)
- 60% chance (rand(0,100) < 60) to get the materials (getitem 501,1;)
- basic protection to prevent massive farming (the npc will be disable for 30-60 seconds)
map,x,y,0 script Name::identifier 111,{
getmapxy(
[email protected]$,
[email protected],
[email protected], 0); // get Player coordinates
getmapxy(
[email protected]$,
[email protected],
[email protected], 1, strnpcinfo(3)); // get NPC coordinates
// Check if player is near enough (distance < 5)
if (distance(
[email protected],
[email protected],
[email protected],
[email protected]) < 5) {
// Check if user has required item [in this case: Ygg Berry#607]
if (countitem(607)) {
progressbar "0x00ff00", 2000;
// 60% chance to obtain item
if (rand(0,100) < 60) {
getitem 501,1; // Red Potion#501
specialeffect2 154;
donpcevent strnpcinfo(3)+"::OnDisable";
end;
}
specialeffect2 155;
dispbottom "You didn't get anything this time.";
end;
}
dispbottom "You don't have the necessary tools..";
end;
}
dispbottom "You're too far away.";
end;
OnDisable:
disablenpc strnpcinfo(3);
initnpctimer
end;
// 10% chance to reactivate after 30, 40 or 50 seconds. otherwise reactive after 60 seconds
OnTimer30000:
OnTimer40000:
OnTimer50000:
if (rand(0,100) < 90)
end;
OnTimer60000:
OnEnable:
stopnpctimer;
enablenpc strnpcinfo(3);
end;
}