.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life 2 SDK (http://forums.bots-united.com/forumdisplay.php?f=62)
-   -   HL2 plugin Weapon support (http://forums.bots-united.com/showthread.php?t=4026)

DrEvil 27-05-2005 14:13

HL2 plugin Weapon support
 
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

DrEvil 27-05-2005 15:12

Re: HL2 plugin Weapon support
 
ok, after a little more messing around with CBotCmd.weaponselect I noticed that the values appear to be different on the same weapon in different maps(wtf?), so this doesn't appear to be a constant that we can rely on unless we know what that number actually means.

Anyone know where to find a master list of the weapon names that are to be used in IBotController.SetActiveWeapon ?

Pierre-Marie Baty 28-05-2005 22:00

Re: HL2 plugin Weapon support
 
for point 4, I loop though the edict list. What would be the advantages of your method ? Most MODs would make changes to their CBaseEntity anyway...

for point 6, you already can get the edict after a trace: use
Code:

gameents->BaseEntityToEdict (tr.m_pEnt)
it's a method from the IServerGameEnts interface, the provider of it is gameServerFactory()

Cheeseh 29-05-2005 16:45

Re: HL2 plugin Weapon support
 
ooh nice function!

DrEvil 29-05-2005 17:18

Re: HL2 plugin Weapon support
 
I suppose mods COULD make changes to baseentity, though IMO it is stupid to do so. Fortress Forever is far along with their coding and hasn't touched it. A good programmer should implement new functionality in their own mod specific sub classes.

Anyways, the reason I brought up access to CBaseEntity, and therefore CGlobalEntityList, is that there is functionality built into there that would be nice to have access to, like being able to get the position/velocity/orientation of any arbitrary entity, kinda like #3. Do you know of a way to get this info about non-player entities?

One of the major problems other than lack of access to weapon/ammo data is being limited to getting info about anything other than players. In a prop filled environment it is necessary to get this info about other entities too in order to make a smarter bot.

Thanks for the info for point 6.

DrEvil 29-05-2005 23:03

Re: HL2 plugin Weapon support
 
sigh, Anyone get much weapon stuff working? It's become clear that IPlayerInfo.SetActiveWeapon isn't very useful. Every time you call it, another weapon is created. After a while of weapon switching the game shuts down after running out of edicts.

Anyone made sense out of CBotCmd.weaponselect ? The values for a particular weapon seem to change per map. Wonder if it's the index for a weapon edict in the master list or something. hmm.

edit: ahh looks like it is.

DrEvil 30-05-2005 00:05

Re: HL2 plugin Weapon support
 
Ok, so CBotCmd.weaponselect is the index of the weapon in the edict list apparently. Unfortunately that doesn't help us much since I don't know of a way to get which weapons a particular player has so I could then use their index. Grr, seems this is kinda stuck until valve can give us more access, or fix the behavior of SetActiveWeapon so it doesn't create a new weapon each time or something.

Pierre-Marie Baty 30-05-2005 14:42

Re: HL2 plugin Weapon support
 
How about bumping on HLCoders again ?

DrEvil 01-06-2005 00:05

Re: HL2 plugin Weapon support
 
Theres a discussion going in there now, please everyone interested in bot coding lend your support to the mailing list. If they see there is a higher demand than 1 person they might take the requests more seriously.

Pierre-Marie Baty 01-06-2005 01:10

Re: HL2 plugin Weapon support
 
I jumped in to back you up bro.

I do hope someone at Valve will grace us with a response this time... :|


All times are GMT +2. The time now is 15:45.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.