![]() |
How to detect entity [properties] ?
Code:
if (strcmp("dod_control_point", item_name) == 0) point_allies_model point_allies_model_bodygroup point_allies_target point_allies_win_string etc...... But how can I detect it ? |
Re: How to detect entity [properties] ?
I don't know... are you talking about the entity's infobuffer ?
Look in some CS bot source code for the function that tells which team a bot is on. It calls the infobuffer and retrieves the "model" field. You may use the same method I believe. (curious, though, as I believed only game clients could have infobuffers ?) |
Re: How to detect entity [properties] ?
PM, I think he's refering to properties (key/value pairs) that can be set by level designers (mappers).
Tea, entity variables are usually stored as Class member variables in the MOD source code class definition (which you don't have the source code for). You can access these values by using the pvPrivateData point in the entvars structure. The pvPrivateData will point to the memory allocated by the engine for that Class instance. For example, if you create a CBasePlayer class in the MOD code, the engine will allocate space for the CBasePlayer class (which will probably not contain the same variables that the standard Half-Life SDK source code comes with, so don't assume these are the same). You can dump the pvPrivateData section of memory to see what byte values change when one of these class member variables is updated. A cleaner way to do this is to intercept the entity being spawned by the engine. The HPB bot does this for several entities, for example in TFC, the "info_tfdetect" entity is used to determine how many players are allowed on each team and how many teams there are. I intercept the "info_tfdetect" entity when it is being spawned and save the values of the key/value pairs in DispatchKeyValue() (in the dll.cpp file) when the entity is spawned. This method will ONLY work for things that DON'T change their value while the game is being played. For example, if you had something that toggle off and on (like a capture point) while the game is playing, you would have to intercept other network messages to know what the current state of that entity is. botman |
Re: How to detect entity [properties] ?
Code:
//DoD flag info |
Re: How to detect entity [properties] ?
Code:
BAStumm, since I am very new of bot coding and C++ so I didn't understand the code you show me, could you tell me more detail what are each line of the code doing so I can learn it but not just copy it, thank you very much. :) |
Re: How to detect entity [properties] ?
Intercepting the key/value pairs of an entity is a little more complex than that. First you have to store the entvars pointer when the entity is created, then in DispatchKeyValue, when keys are stored for that specific entity, you can examine what the values of those keys are.
For the HPB bot, I keep a global variable to store the pent (entvars pointer)... Code:
edict_t *pent_info_tfdetect = NULL; In DispatchKeyValue(), I check to see if an entity is being created by looking for the "classname" key (since Worldcraft/Hammer always makes the "classname" for entities the first key to be passed into the MOD code)... Code:
else if (pent_info_tfdetect == NULL) Code:
if (mod_id == TFC_DLL) Code:
edict_t *control_point = NULL; Code:
if (strcmp(pClassname, "worldspawn") == 0) Code:
if (mod_id == DOD_DLL) If there was more than one 'control_point' entity, then you would have to create and array of global edict_t pointers, and store each one separately. All of the entities that I intercept in the HPB bot code are assumed to have only 1 of those entities in each map (the HPB bot code doesn't contain any examples of reading the key/value properties from a bunch of entities having the exact same classname). botman |
Re: How to detect entity [properties] ?
I have tired your suggest but still no luck, then I think maybe the point_allies_target not use in this way, so I have changed to use flag_model to detect, but the result is the same........ :(
Code:
edict_t *dod_control_point = NULL; Code:
int Spawn( edict_t *pent ) Code:
Code:
1: Bots are only keep saying This is a ALLIES FLAG no matter which flag he saw, even before he spawn(in the dead mode), he has already keep saying this, that mean dod_flag always = 1, botman could you take a quick look of my above code to see if I have any mistake ? 2: Even I force the dod_flag to 0 (dod_flag = 0) at the top of BotFindItem(), bot still keep say this is a ALLIES FLAG but not FREE flag. ???:( 3: How do I know if my Keyvalue() have already ran and work ? FakeClientCommand(pEdict,"say","XXXX",0); not work in Keyvalue() , I have tried ClientPrint( pPlayer, HUD_PRINTNOTIFY, "XXXX\n"); but didn't see any message(maybe Keyvalue run before client connect ?), could you teach me which command can I use to debug in keyvalue ? 4: How can I call the Keyvalue() anytime just like the way I call the UTIL_GetTeam(pEdict) ? Please tell me the full command since I donno enter what after Keyvalue ? Code:
Keyvalue (What should I enter here ?); Code:
|
Re: How to detect entity [properties] ?
I don't understand why all this stuff is needed.
Wouldn't it be more simple to have something like this : Code:
#define FLAG_ALLIES 2 Code:
int GetFlagType (edict_t *pFlagEdict) Code:
// in BotFindItem() |
Re: How to detect entity [properties] ?
PM this code can work in most of the mod but not DoD, since bot in DoD can't see any w_sub_flag.mdl, they(allies and axis) only can see one model name w_flag.mdl.
DoD team use the properties function to let client show the right flag model only after you captured it. |
Re: How to detect entity [properties] ?
You have to dinamicaly store the flags state during gameplay.
Don't scan the flag but catch the dod net message "CapMsg" Store the value then let the bots check that value when it sees that flag. "CapMsg" has 2 important variables. the flags name (location) the team it's owned by. Those to variables are enuf to store the owner to the flag location. |
All times are GMT +2. The time now is 18:17. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.