Page 1 of 1

NPC functions to JS......Please!?

Posted: Fri Jun 29, 2007 3:09 pm
by stranf
The players on my shard had an interesting request: Use the pet commands to create mercenaries.

Here is how I would implement it, one would be easy, the other would take a bit more work:


1- Treat an NPC as a packhorse. Export a function from C++ to .js that allows the PC to treat the NPC as a packhorse. Give the NPC all the AI functions that the pet has, IE, transfer, stay follow, etc. The only function that probably should NOT be included is RENAME.

2- This would be ideal, but I think it would require a bit more coding. Since NPCs can also be "outfitted" by GMs, allow the owning "PC" to equip via the paperdoll like the GM his hired mercenary. That would be ideal, but may require some more programming. If someone has time to do the C++ coding for this, it would be appreciated.

Thanks for your help, any other tips would be great. Once the functions are exported to .js I think I can code up a mercenary script to allow for the hiring of mercenaries with my limited knowlege of .js.

Thanks!

Posted: Fri Jun 29, 2007 5:00 pm
by Xuri
Could you not simply set up the mercenaries as "pets" and command them around just like ordinary pets? Just create a script where the mercenary NPC, when the players say "hire" or whatever and drop X gold on them, you set the player as owner of the mercenary NPC.

Posted: Fri Jun 29, 2007 6:34 pm
by stranf
Xuri, that would be great but how do I set up an NPC as a pet?




How would you go about allowing a PC the GM ability of adding/removing armor from said mercenary, while still preventing him from doing it to other players?

Posted: Mon Jul 02, 2007 4:54 pm
by stranf
I wrote a quick script where a GM can set up an NPC as a "pet" and give ownership to a PC. It works like a charm, but interestingly enough if you tell the NPC to guard it dosen't say "guarded" like a pet does, but the script works perfectly.


The only thing now is that I don't have access to the pack, and the PC also can not equip the NPC like a GM can. I don't know how to script those functions.

Posted: Mon Jul 02, 2007 9:38 pm
by Xuri
Hm. You'll probably have to script custom commands like .equip and .disarm then, and check for ownership before allowing, as well as checking if anything's already occupying the layer they're trying to equip something to.