So I got my Omni-bots running around in HL2DM with the independant movement and aim and such. From what I've read server plugins are still waiting on some functionality for weapons to work. I started looking at weapon stuff a bit yesterday and wrote some code to print out the players weaponselect field of his command
Code:
IPlayerInfo *pLocalCharacter = g_pPlayerInfoManager->GetPlayerInfo(INDEXENT(1));
if(pLocalCharacter)
{
CBotCmd cmd = pLocalCharacter->GetLastUserCommand();
if(cmd.weaponselect != 0)
{
char buffer[64];
sprintf(buffer,"weaponselect : %d\n", cmd.weaponselect);
Msg(buffer);
}
}
I was hoping the value would be some enumerated number defined somewhere in the mod, but the resulting output was some arbitrary numbers that jumped all over the place. Also odd was that sometimes changing weapons no new value was printed.
Anyways, by the looks of things we don't have a way of seeing what equipment a bot currently has, and a bit of investigating into IBotController.SetActiveWeapon seems to show that it will give the bot the weapon if they don't have it, which is clearly cheating and a less than ideal solution. At least if it returned a bool it could be used to check the presence of weapons.
So, can we compile a list of things we are missing from a server plugin standpoint to get fully functional bots, and I will re-submit it to valve in hopes of getting it taken care of. No doubt some of you have done this already. I want to hopefully be allowed access to methods of doing these things the right way, as opposed to hacking around and trying to get a plugin compiled pulling in all the extra stuff that wasn't intended to come in.
Here's a list I have so far in my < 1 week of messing with the plugin bot integration. If theres a way to do these things please let me know.
1) Check if a bot has a certain weapon or item. A bool IBotController.HasWeapon(const char *) would be nice, as well as a HasItem(const char *) that mods can implement for custom non-weapon equipment(kevlar vests, helmets...)
2) Access to an entities velocity? This is critical for some weapons to calculate proper leading. I'd rather not hack around this by getting the position each frame and calculating this myself, though I will if I have to I suppose.
3) Access to any entities position/orientation/velocity. Seems right now we're limited to players, but any decent bot is probably going to want to have perceptions of projectiles/grenades/dynamic map props.
4) Access to any entity in general. I suppose we can blindly loop through the edict list, but an interface to CGlobalEntityList would be so much better.
5) IPlayerInfo.ChangeClass would be nice. Empty by default, but at least provides an interface for future mods to implement. More mods than not will likely be class based.
6) Can we have access to trace_t.GetEdict() ? It's wrapped in #if defined( ENGINE_DLL ). Is it safe to define these in a plugin?
7) Minor issue, is there a reason IBotController and IPlayerInfo returns angles/vectors by value as opposed to const & ?
8 ) We need access to ammo values without switching to the weapon. Perhaps IBotController.GetWeaponAmmo(const char *weaponname, int &_curClip1, int &_curClip2, int &_maxclip1, int &_maxclip2). The reason there are 2 is to support weapons that use different ammo types for their alt-fire. Other stuff like max ammo, max clip size, ammo per shot I suppose are normally constants so I don't suppose we need access to them. Also what would be useful is IBotController.GetAmmo(const char *ammoname, int &_current, int &_max), to get the total amount of ammo the bot has, not counting what's in the weapon clips(or counting I guess it doesnt matter).
9) How to choose the model for a bot? How about spraypaint?
Simply giving us access to CGlobalEntityList and CBaseEntity in plugins would solve most of these problems. There are velocity accessors in there and it is not specific to players only like IPlayerInfo or IBotController. Adding accessors in the IPlayerInfo once again limits their use to players only, and we need to have access to any entity if we ever hope to create bots that are not retarded to their surroundings and capable of some level of avoidance of the props that could be anywhere, as well as projectile awareness and stuff.(The wall mounted armor dispensers in hl2dm.)
Please post any additional things you think we will need, or correct me if there is a way to do something that I have posted. Hopefully we can petition some time out of valve to finish up what we need in one final go and we can leave them alone
Thanks
Jeremy