mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
game: add spawn entity by coordinates
This commit is contained in:
parent
021d6480d6
commit
2a8a2f390a
3 changed files with 58 additions and 1 deletions
|
@ -28,6 +28,9 @@ original clients (Vanilla Quake II) commands are still in place.
|
||||||
|
|
||||||
* **teleport <x y z>**: Teleports the player to the given coordinates.
|
* **teleport <x y z>**: Teleports the player to the given coordinates.
|
||||||
|
|
||||||
|
* **spawnentity classname x y z <angle_x angle_y angle_z> <flags>**:
|
||||||
|
Spawn new entity of `classname` at `x y z` coordinates.
|
||||||
|
|
||||||
* **listmaps**: Lists available maps for the player to load. Maps from
|
* **listmaps**: Lists available maps for the player to load. Maps from
|
||||||
loaded pak files will be listed first followed by maps placed in
|
loaded pak files will be listed first followed by maps placed in
|
||||||
the current game's maps folder.
|
the current game's maps folder.
|
||||||
|
|
|
@ -612,6 +612,7 @@ CL_InitLocal(void)
|
||||||
Cmd_AddCommand("weapprev", NULL);
|
Cmd_AddCommand("weapprev", NULL);
|
||||||
Cmd_AddCommand("listentities", NULL);
|
Cmd_AddCommand("listentities", NULL);
|
||||||
Cmd_AddCommand("teleport", NULL);
|
Cmd_AddCommand("teleport", NULL);
|
||||||
|
Cmd_AddCommand("spawnentity", NULL);
|
||||||
Cmd_AddCommand("cycleweap", NULL);
|
Cmd_AddCommand("cycleweap", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -249,7 +249,7 @@ Cmd_Give_f(edict_t *ent)
|
||||||
if (gi.argc() == 3)
|
if (gi.argc() == 3)
|
||||||
{
|
{
|
||||||
ent->health = (int)strtol(gi.argv(2), (char **)NULL, 10);
|
ent->health = (int)strtol(gi.argv(2), (char **)NULL, 10);
|
||||||
ent->health = ent->health < 1 ? 1 : ent->health;
|
ent->health = ent->health < 1 ? 1 : ent->health;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1276,6 +1276,55 @@ Cmd_Teleport_f(edict_t *ent)
|
||||||
gi.linkentity(ent);
|
gi.linkentity(ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
edict_t* G_Spawn(void);
|
||||||
|
void ED_CallSpawn(edict_t* ent);
|
||||||
|
|
||||||
|
static void
|
||||||
|
Cmd_SpawnEntity_f(edict_t *ent)
|
||||||
|
{
|
||||||
|
if (!ent)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((deathmatch->value || coop->value) && !sv_cheats->value)
|
||||||
|
{
|
||||||
|
gi.cprintf(ent, PRINT_HIGH,
|
||||||
|
"You must run the server with '+set cheats 1' to enable this command.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gi.argc() < 5 || gi.argc() > 9)
|
||||||
|
{
|
||||||
|
gi.cprintf(ent, PRINT_HIGH,
|
||||||
|
"Usage: spawnentity classname x y z <angle_x angle_y angle_z> <flags>\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ent = G_Spawn();
|
||||||
|
|
||||||
|
// set position
|
||||||
|
ent->s.origin[0] = atof(gi.argv(2));
|
||||||
|
ent->s.origin[1] = atof(gi.argv(3));
|
||||||
|
ent->s.origin[2] = atof(gi.argv(4));
|
||||||
|
// angles
|
||||||
|
if (gi.argc() >= 8)
|
||||||
|
{
|
||||||
|
ent->s.angles[0] = atof(gi.argv(5));
|
||||||
|
ent->s.angles[1] = atof(gi.argv(6));
|
||||||
|
ent->s.angles[2] = atof(gi.argv(7));
|
||||||
|
}
|
||||||
|
// flags
|
||||||
|
if (gi.argc() >= 9)
|
||||||
|
{
|
||||||
|
ent->spawnflags = atoi(gi.argv(8));
|
||||||
|
}
|
||||||
|
|
||||||
|
ent->classname = strdup(gi.argv(1));
|
||||||
|
|
||||||
|
ED_CallSpawn(ent);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cmd_ListEntities_f(edict_t *ent)
|
Cmd_ListEntities_f(edict_t *ent)
|
||||||
{
|
{
|
||||||
|
@ -1818,6 +1867,10 @@ ClientCommand(edict_t *ent)
|
||||||
{
|
{
|
||||||
Cmd_Teleport_f(ent);
|
Cmd_Teleport_f(ent);
|
||||||
}
|
}
|
||||||
|
else if (Q_stricmp(cmd, "spawnentity") == 0)
|
||||||
|
{
|
||||||
|
Cmd_SpawnEntity_f(ent);
|
||||||
|
}
|
||||||
else if (Q_stricmp(cmd, "listentities") == 0)
|
else if (Q_stricmp(cmd, "listentities") == 0)
|
||||||
{
|
{
|
||||||
Cmd_ListEntities_f(ent);
|
Cmd_ListEntities_f(ent);
|
||||||
|
|
Loading…
Reference in a new issue