mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
game: Add spawn on start point
It could be used for spawn weapon or opponnent for coop at spawn point.
This commit is contained in:
parent
2a8a2f390a
commit
cf110b5ea0
3 changed files with 70 additions and 1 deletions
|
@ -26,11 +26,15 @@ original clients (Vanilla Quake II) commands are still in place.
|
|||
whitespaces. The special class `all` lists the coordinates of all
|
||||
entities.
|
||||
|
||||
* **viewpos**: Show player position.
|
||||
|
||||
* **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.
|
||||
|
||||
* **spawnonstart classname**: Spawn new entity of `classname` at start point.
|
||||
|
||||
* **listmaps**: Lists available maps for the player to load. Maps from
|
||||
loaded pak files will be listed first followed by maps placed in
|
||||
the current game's maps folder.
|
||||
|
|
|
@ -613,6 +613,7 @@ CL_InitLocal(void)
|
|||
Cmd_AddCommand("listentities", NULL);
|
||||
Cmd_AddCommand("teleport", NULL);
|
||||
Cmd_AddCommand("spawnentity", NULL);
|
||||
Cmd_AddCommand("spawnonstart", NULL);
|
||||
Cmd_AddCommand("cycleweap", NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -1325,7 +1325,67 @@ Cmd_SpawnEntity_f(edict_t *ent)
|
|||
ED_CallSpawn(ent);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
Cmd_SpawnOnStartByClass(const char *classname, const vec3_t origin)
|
||||
{
|
||||
edict_t *opponent = G_Spawn();
|
||||
|
||||
// set position
|
||||
opponent->s.origin[0] = origin[0];
|
||||
opponent->s.origin[1] = origin[1];
|
||||
opponent->s.origin[2] = origin[2];
|
||||
// and class
|
||||
opponent->classname = strdup(classname);
|
||||
|
||||
ED_CallSpawn(opponent);
|
||||
|
||||
gi.dprintf("Spawned entity at %f %f %f\n",
|
||||
origin[0], origin[1], origin[2]);
|
||||
}
|
||||
|
||||
static void
|
||||
Cmd_SpawnOnStart_f(edict_t *ent)
|
||||
{
|
||||
edict_t *cur = NULL;
|
||||
|
||||
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() != 2)
|
||||
{
|
||||
gi.cprintf(ent, PRINT_HIGH, "Usage: spawnonstart classname\n");
|
||||
return;
|
||||
}
|
||||
|
||||
while ((cur = G_Find(cur, FOFS(classname),
|
||||
"info_player_deathmatch")) != NULL)
|
||||
{
|
||||
Cmd_SpawnOnStartByClass(gi.argv(1), cur->s.origin);
|
||||
}
|
||||
|
||||
while ((cur = G_Find(cur, FOFS(classname),
|
||||
"info_player_coop")) != NULL)
|
||||
{
|
||||
Cmd_SpawnOnStartByClass(gi.argv(1), cur->s.origin);
|
||||
}
|
||||
|
||||
while ((cur = G_Find(cur, FOFS(classname),
|
||||
"info_player_start")) != NULL)
|
||||
{
|
||||
Cmd_SpawnOnStartByClass(gi.argv(1), cur->s.origin);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Cmd_ListEntities_f(edict_t *ent)
|
||||
{
|
||||
if ((deathmatch->value || coop->value) && !sv_cheats->value)
|
||||
|
@ -1871,6 +1931,10 @@ ClientCommand(edict_t *ent)
|
|||
{
|
||||
Cmd_SpawnEntity_f(ent);
|
||||
}
|
||||
else if (Q_stricmp(cmd, "spawnonstart") == 0)
|
||||
{
|
||||
Cmd_SpawnOnStart_f(ent);
|
||||
}
|
||||
else if (Q_stricmp(cmd, "listentities") == 0)
|
||||
{
|
||||
Cmd_ListEntities_f(ent);
|
||||
|
|
Loading…
Reference in a new issue