Re: Mdll ?? -
07-07-2004
The way that the KeyValue() function works, is that there is a table for each entity that indicates which member (or pev) variables can be set by a key/value pair in the BSP .map file.
When the engine spawns an entity, it creates the entity, then calls KeyValue() for each key/value pair that is assigned to that entity by the level designer. Like I said above, some of the variables being set are in the entvars_t structure (pev) and some are member variables of the C++ class.
For the variables that are in the entvars_t structure, they can be set directly instead of calling KeyValue() to set them. For example, you can set pev->origin (or pEdict->v.origin, same thing) directly and it will change the 'origin' variable for that entity. SET_ORIGIN() does this as well, but it also updates the engine's collision data information about where that entity is located in the world. If you have an entity that doesn't collide with anything, you can just set pEdict->v.origin directly. If you have an entity that needs to collide with something, you need to call SET_ORIGIN().
All of the key/value pairs are set for that entity before DispatchSpawn() is called to actually spawn that entity into the world. Once the entity is spawned, calling KeyValue() on that entity MAY update the member variables and it MAY NOT (depending on how the Spawn() function works for that particular entity. So don't just assume that you can keep calling KeyValue() on an entity after it has spawned to change any of it's member variables. Also, not all of the member variables can be changed by calling KeyValue(). You can ONLY change the variables that the MOD creators thought would need to be set by level designers when a map was being created and the entity was being spawned into the world.
botman
|