The performance impact is insignificant. Especially as we're talking about OSBot scripts here.
In my opinion two functions is much better for readability and usability. Performance should not be a consideration whatsoever here.
And you wouldn't have two functions with 100 lines of code, the functionality shouldn't be duplicated, it would look like:
public boolean interact(String itemName, String action) {
// Generate x, y point
interact(itemName, action, generatedX, generatedY);
}
public boolean interact(String itemName, String action, int x, int y) {
// Do interaction stuff
}
Generally you want to keep functions as simple as possible, a good rule to follow is that a function should do just one thing.
If you only had a single function, it would be doing two things, generating a random point, and then interacting at that point.
By defining separate functions it communicates more clearly what the intention is when you are making a call.
For example:
interact("Knife", "Use", -1, -1);
It's not clear what the intention is here, you would need to go to the API docs, or look at the function definition to figure out what -1, -1 does.
If you saw:
interact("Knife", "Use");
The intention is clear, the "Use" interaction will be performed on the knife.