ent_create(STRING* filename, VECTOR* position, function);
ent_createlocal(STRING* filename, VECTOR* position, function);
Creates a model, sprite or map entity in the current level. Mostly
used for creating bullets or explosions, or for creating players
in a multiplayer game. The given function will start immediately after
creation,
with the
my
pointer set to the created entity, and
you set to the creating (if any).
The instruction returns a pointer to the created entity that can be used for
setting further entity parameters.
ent_create creates a global entity on
the server and on all connected clients. The entity function runs
on the server.
ent_createlocal creates the entity on the local machine only.
A local entity is
not transmitted to the server, and thus not visible on other clients. The local
entity
function runs on the
local machine only. Local entities can be used for advanced particle effects,
player weapons or the like. In a single player system, both instructions are
identical.
Parameters:
filename
- name of the entity file to be created, in wmp, mdl, tga, pcx,
bmp, or dds format;
or NULL for creating a dummy entity.
position
- Inital position of the entity.
function
- Action of the entity, or NULL for no action.
Returns:
Pointer to the created entity.
Remarks:
- A level must be loaded before creating level entities.
Thus the functions can not be called immediately at game start or on the
client before it's connected to the server.
In a multiplayer system, wait 0.5 seconds (wait(-0.5);)
after level_load before creating
entities; in a single player system wait 2 frames (wait(2);).
- Creating map entities only creates the entity itself, not any
sub-entities that were stored in it.
- A local entities' function runs only on the client
who has created it. Local entities perform collision detection,
but are passable for global entities.
-
On a single player system, the entity function is started immediately when the
entity is created. On multiplayer systems, entity functions are triggered by a
server transmission, which can occur up to 0.5 seconds later. It is not
determined whether the entity function is already running after this
instruction, or not.
-
On a single player system, the entity handle (►handle())
is valid immediately after entity creation. On multiplayer systems,
it can take up to 0.5 seconds until the entity is created on
all connected machines and the handle becomes valid. During that
time the entity handle can not be used and entity skills not
be sent (►send_skill()).
- The entity file is stored in an internal cache for speeding
up subsequent creation of similar entities. This cache is cleared by level_load.
-
Dummy entities (to be used for c_trace or similar instructions)
can be created by passing NULL for the file name. A dummy entity is always
invisible and passable, and does not affect the frame rate.
Speed:
Slow
when the entity file was not used in this level, medium otherwise.
Example:
you = ent_create ("flash.pcx", temp, flash_prog);
See also:
ent_morph, ent_purge,
ent_preload, ptr_remove, ent_createlayer, level_load
► latest
version online