Not the script itself, it will be able to read what is being sent to the client. This is NOT the script, but messages (packets) to do the actions that the client has to see.
for example, when you a script like that:
prontera,150,123,4 script Nice Npc 1_M_01,{
mes("Hello");
mes("How are you?");
next();
switch (select("Fine", "Bad")) {
case 1:
.@var = rand(100);
mesf("Cool! %d", .@var);
close();
case 2:
mes("That's bad");
close();
}
}
Let's go back to the NPC identification first, once the player character (regardless of being a real client or a bot) gets near the NPC, hercules will send something like:
- Hey, there is a unit of type NPC (GID: 1234, Sprite: 47) at coordinates 150,123 looking in direction 4. This NPC is named "Nice Npc".
The player clicks the NPC, and client sends:
- Hey server, I want to talk to unit 1234
Hercules will then process this request, see that the player is in distance and start executing the script, and thus will start sending messages telling the client what it needs to do:
- Hey, Show Message "Hello" (first mes)
- Hey, Show Message: "How are you?" (second mes)
- Hey, Show Next Button
At some point, the client will send a next clikcked input, and then Hercules:
- Hey, Show Menu: "Fine, "Bad"
Client will then send whether it clicked in 1 or 2, let's say the client says it clicked 1. Hercules wil lthen send:
- Hey, Show Message "Cool! 50" --- Or any random number here ; note that the variable and "rand" didn't send info to the client
- Hey, Show Close Button
It won't send the script itself, but the stuff it needed for the client to show. It won't give script internals, like variables or function calls, but if there is something that does something in the client (e.g. render a message, show a next/close/menu, show a effect), these will be sent to the client in a message format that is suited for the communication.
Note that some things in this example were NOT sent to the client:
- Variables,
- The random itself -- only the result of the execution is
- The message for case 2 (we just clicked case 1, only case 1 will be sent)
You can check what is being sent to the client using packetlogger plugin (
https://github.com/HerculesWS/StaffPlugins/tree/master/4144/packetlogger), it will dump every packet sent on the network to a file (in binary form, so some knowledge on how RO networking works would be required to actually understand everything).
The example I gave before that openkore could generate a script is that, if you pick all those "Hey, SHow MessagE" and write to a file as being a "mes("message")" , you kinda create the NPC back. it is not perfect, but except for the internal logic, you got all the messages, menus, effects, etc