Closed didasy closed 7 years ago
Don't know what to say, but having a script command is kinda limited, I believe direct coding from c would be more open and could do much more thing than via script. Moreover, the latency and delay for accessing external services would be high and interacting with npc would make it somewhat boring and time wasting. However, that's my opinion, and if there's some useful case then I am for it.
Direct coding from C would be more limited to the server operator if one want to make a more dynamic NPC. Not everyone understands C.
Latency and delay would be negligible as long as it is below (IMO) 100ms, which will be no problem if the external service sits right on the same network (usually, same machine) as Hercules.
Interacting with NPC experience is a subjective matters. Not everyone plays RO just to have fun with their friends, some also want to do RP.
This is my opinion anyway. Thanks for your response.
Any examples ? So as I could personally think about the commands needed, while waiting for feedbacks from other devs..
Examples for a scenario or usage?
For scenario:
I imagine a dynamic event (also dialogue) NPC that will spawn boss or monsters or giving items or giving quest and quest requirements based on external parameters and without having to restart the server or use @reloadscript
to apply.
I realised you can do this through query_sql
but I think it would be better if I don't clutter the database with more junk and add more load to it. This is just an example, but I think the possibility is endless.
For usage, I was thinking about 2 commands:
tcpconnect <host> <port> <timeout>
This is for connecting to a TCP server, it will return 0 on success or -1 on failure (or true
and false
).tcprequest <data> <timeout>
This is for sending data to the server, it will return the response string on success, or empty string on timeout.@JesusIslam you cant use any blocking sockets api. Or server can be locked completly in your script. This mean you can use sockets only in async way, like hercules using it. And this mean tcprequest as you show it make no sense you should use labels for trigger event for receiving data or socket status.
btw query_sql not safe too. It may lock server too.
You can replace @reloadscript to some admin npc what will set/change any parameters
Closing this since this is dead for half a year. Also 4144 and Dast stated pretty much everything.
Like the title says. This would open great opportunities into creating a more flexible NPCs.
Like if someone want to look up external database through a service to determine the action of the NPC, they could simply communicate with said service through TCP.
In the meantime, I will try to add new script commands for this for a PR. But I would be glad too if you guys really pick this feature up before me doing it myself.
Thanks.