Here's the basic question - What are the implications of managing a group of NPC's?
(snip)
We've established, I think, that all five of these Hellions need to have presence in the atlaspark and atlaspark_meta rooms. They all need costumes. They each need to have their own XMPP connection in order to communicate their presence and position. They each, therefore, need to have their own thread or their own process that is controlling their personal XMPP connection.
I am intending to use this exact structure, except it would be for contacts scattered across various zones, not random street mobs in one cluster. I'm not intending to replicate COH combat, just some narrative semblance of missions (i.e. "something to do"). And yeah, from the player's standpoint, they are talking to five different characters, but really they are talking to the same bot wearing five different masks in five different places.
What does this mean for the server? Do the individual Hellion NPC's each need a unique JID? That is, does the bot login as mybot@chat.cohtitan.com with password "mybot" or does each Hellion require its own Titan account? Can one account join a chat room five times under five different nicks?
Obviously it is possible to join multiple rooms with one account, because Paragon Chat is doing exactly this for the zone room, zone meta room, and every global chat channel you are on. But a single account can
also join a single room multiple times. That's how running multiple copies of PChat and COH works when both clients are in the same zone. I've even been logged into the same zone three times on a few occasions already. One via Pidgin, and two via PChat.
For example, in the screenshot
here the two characters on the left are me. If I also happened to be in the main galaxycity room via Pidgin at the time, that'd be a single account joining that room three times, and the galaxycity_meta room twice (one less because Pidgin doesn't care about the meta, though I could join it too if I wanted). Technically, I was also on various global channels multiple times as well, especially paragonchat.
Unless the server is set to cap the number of simultaneous logins on one account, there's no reason it can't be more than three. And there's certainly no reason a bot can't do the same thing that I do manually.
What does this mean for the server? Do the individual Hellion NPC's each need a unique JID?
The
full JID differs, but only by resource name. The bits without the resource name are the bare JID, which I believe remain constant as long as the XMPP server name you log into and the account you use to log into it remain constant. The resource name can be set to anything (Paragon Chat puts your character name there). It gets auto-assigned by the server if you don't bother (which in openfire seems to gives the bot a hex number as a resource).
Which reminds me that the bare JID is one way that players can trust NPCs, at least to the extent they can trust anything. Imagine a mission that has a "go talk to Statesman in Independence Port" step, and the player walks up and sees three different Statesmans lounging around. Rather than being the City of Heroes equivalent of a "Reign of the Supermen" scenario, it probably just means there are missions run by three different bots that each have a "go talk to Statesman in IP" step. So which one do you actually talk to?
If the Statesman for your mission had a separate account from whatever bot you have that sends the player there to see him, the player would have no way of knowing which Statesman was correct other than trying to interact with each one until they get an interaction that makes sense (if any, given that bot writing skills do not equal story writing skills).
On the other hand, if your set of NPCs all use the same bot account, the bare JID will be identical for each NPC it controls, so players sent from one NPC to another could distinguish between NPCs that happened to have the same character name and costume. So there's a legitimate reason (aside from convenience) to code multiple NPCs as a unified system rather than as a bunch of independent bot accounts.
Another (probably more likely) scenario is a griefer version of Arcana's MirrorBot, cloning your Statesman to distract players from the "real" one.
If I create this encounter, am I going to be "hogging" resources on the server? What sort of resources should a bot owner be priveleged to use and to be considered to be "playing nice" with the other people who might be doing the same thing with their own resources?
My rule of thumb is always whether it, as a whole, improves the experience for players. There's no hard line, and I tend to assume members of the bot community are generally well-meaning and care about that. There is obviously potential for griefing, or even a DOS attack, but that potential exists already. Bots didn't create it.
The first bot on the public servers giving players "stuff to do" will be very beneficial. For bots 2 through N (where N is some unknown number), the drop due to declining novelty is way more than offset by the variety. Still, each is offset a little less than the previous one. Eventually there are too many bots using resources, and adding another one on the pile is more likely to subtract from the overall experience, even if the newest bot is the greatest thing since sliced bread.
Also, bear in mind that server resources aren't the only consideration here. XMPP is inherently less efficient than the normal COH protocol (as was discussed back when Codewalker posted the protocol), so a hundred bots in one area in Paragon Chat are going to be much worse on network bandwidth on the client end than a hundred mobs were in the same situation when the game was live. It uses higher resources strictly on each client machine as well, since there's an extra XMPP -> COH translation step going on as well as communication between PChat and COH. As Codewalker said awhile back, performance was not the primary design consideration.
Among the implications, it behooves you to default to NOT put any given bot or NPC into Atlas Park without a reason, as that will inevitably be the zone that sees the most traffic. My intent was to have a single avatar in each of the starting zones to direct people to "contacts" in less well-traveled zones, like blueside initial contacts, and even that was more for visibility than out of necessity. (I was never a huge fan of AP, but I recognize the practicality of it being the primary starting zone.)
Of course, all of this presupposes that I can ever wrap my head around sleekxmpp. The official docs are ...
special. Fritzy's are a little better, but the info
here didn't help. Turning to code, the demos are enough to let me figure out how to log in but don't seem to handle enough of what I need to know to implement PC's protocol, and the example code that ostensibly does is missing some context. I'm also apparently missing something important in the code posted here. I resorted to looking at the XEP plugins, but so far it hasn't helped me get any further than a more elaborate version of the MUC bot demo.
But damn have I nailed using Python's argparse and logging modules. I got your timestamps. I got your fancy loglevels. I got your multiple log streams, so I can have both console and file debugging without duplicating every single message as both a print statement
and a call to a logging method. I can even have different loglevels for the logfile and the console.
Based on the debug messages sleekxmpp itself generates in my logs, the bot is receiving u stanzas and such; it just isn't reacting to them. So it has to be something I've done wrong.
I did quickly put in a quit command, though, so I can stop the bot more easily.