There has been work done to allow using gm commands from perl, but it doesn't work yet. I think KLS said she wanted to implement it at some point, but I don't think it is too high on the priority list.
I think Caryatis was the closest to the solution you need. You should be able to use default.pl in your templates folder to give the same script to all NPCs on your server that don't have a script assigned to them already in the zone they are in.
You can write a simple EVENT_KILLED_MERIT in your default.pl that sets a qglobal on the character, which can be checked by your quest NPC later. That will be your way of verifying they killed the NPC.
As Caryatis mentioned, this would cause issues with any NPCs that have a script assigned to them already, which wouldn't work with the templates/default.pl and would break your system. My only solution to that would be to also check for existing script files for the NPC you randomly selected. So, you would get the NPC name from the DB and do a file search within your quests folder with perl to find a .pl file for that NPC name. I don't know how to search for the file off the top of my head, but I assume it is most likely possible with a little googling. You would also have to account for any names that have a ` in them, as they would need to be replaced with - when searching for the file name. If you also query spawn points and find the zone that the NPC spawns in, you can use that to find the zone short name so you know the zone folder to search in for quests. You will need to do that anyway if any of your zones have an existing default.pl within them as that will override the templates/default.pl and break your system. If your script finds any perl scripts for the NPC it selected, it just keeps looping through another randomly selected NPCID until it gets one that doesn't have a script.
The idea is kinda neat, but I have a feeling it is going to be a bit more work than you may expect for it to be flawless. You will have to account for zones that may not be fully implemented or maybe not even have any way for players to access. You will also probably have to check spawn points to make sure the NPC isn't a quest spawned only NPC. I am sure there are other things you will run into in the process of trying to implement it.
|