View Single Post
  #9  
Old 11-05-2011, 06:28 PM
revloc02c's Avatar
revloc02c
Hill Giant
 
Join Date: Aug 2010
Location: UT
Posts: 215
Default

Quote:
Originally Posted by lerxst2112 View Post
You would need to add a new function exposed to perl. It's not hard to do, and there are many examples available. Once you have that you need to execute the same code the command does.

If you're lucky the command just calls another function to do the work and your perl function can do the same.

If you're unlucky the command has the code inside it. In that case you would need to move that code to another function that both can call.
Thanks lerxst this is just enough to get me started on the right foot. I post code if I figure something out, but don't hold your breath...even if I do it'll take a while, RL takes up a lot of my time.

Quote:
Originally Posted by trevius View Post
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.
Man Trev, I always appreciate your polite and informative posts. Now that you have so carefully walked me through this route I agree that it's tough and likely has more unseen obstacles. I think I'll try to get a GM command to execute in Perl, and if that doesn't work change the quest enough so that it is easier to implement. A lot can be done with some good SQL code.

Thanks again guys.
Reply With Quote