Quote:
Originally Posted by showdax
Quote:
Originally Posted by sslice
Try hooking LevelInit instead.
|
I'm already hooking LevelInit. I don't want to override the entity list at that point, I want to override it between rounds. It seems as if the mod only spawns spawn points once, and doesn't care about any changes to them between rounds.
Are there any entity properties that will tell the mod to respawn these between rounds? Or should I do this the hard way and try to manually move the entities around between rounds? And if so, what would be the best way to go about doing that?
|
It's easy enough to get a dump of the spawnpoint coordinates from the entity list by classname. You could then teleport each player to a randomly selected opposition spawn point when they spawn, alternatively just change the entity spawnpoint coordinates directly ?
Code:
CON_COMMAND(ma_dumpspawnpoints, "ma_dumpspawnpoints (Dumps built in default spawn points for current to clipboard.txt file)")
{
FileHandle_t file_handle;
char base_filename[512];
// Valves FPrintf is broken :/
char temp_string[2048];
int temp_length;
if (!IsCommandIssuedByServerAdmin()) return;
if (ProcessPluginPaused()) return;
int edict_count = engine->GetEntityCount();
bool first_time;
Msg("This command will write the default coordinates for the map to clipboard.txt\n");
Msg("You can then copy and paste into spawnpoints.txt for the map\n");
//Write to clipboard.txt
Q_snprintf(base_filename, sizeof (base_filename), "./cfg/%s/clipboard.txt", mani_path.GetString());
// I can hear Bail laughing about the use of Valve's filesystem interface
if (filesystem->FileExists( base_filename))
{
filesystem->RemoveFile(base_filename);
if (filesystem->FileExists( base_filename))
{
Msg("Failed to delete clipboard.txt\n");
}
}
file_handle = filesystem->Open (base_filename,"wb", NULL);
if (file_handle == NULL)
{
Msg("Failed to open clipboard.txt for writing\n");
return;
}
temp_length = Q_snprintf(temp_string, sizeof(temp_string),
"\"spawnpoints.txt\"\n"
"{\n"
"\t// Spawn points for map %s\n"
"\t\"%s\"\n"
"\t{\n",
current_map,
current_map);
if (filesystem->Write((void *) temp_string, temp_length, file_handle) == 0)
{
Msg("Failed to write to clipboard.txt\n");
filesystem->Close(file_handle);
return;
}
for (int j = 0; j < 10; j++)
{
// Get classname for spawnpoints per team (you can find this in the .bsp entity list)
char *classname = gpManiGameType->GetTeamSpawnPointClassName(j);
if (!classname) continue;
int count;
count = 0;
first_time = true;
for (int i = 0; i < edict_count; i++)
{
edict_t *pEntity = engine->PEntityOfEntIndex(i);
if(pEntity)
{
if (Q_stristr(pEntity->GetClassName(), classname) != NULL)
{
if (first_time)
{
temp_length = Q_snprintf(temp_string, sizeof(temp_string),
"\t\t// Spawn points for team index %i (%s)\n"
"\t\t\"%i\"\n"
"\t\t{\n", j, classname, j);
if (filesystem->Write((void *) temp_string, temp_length, file_handle) == 0)
{
Msg("Failed to write to clipboard.txt\n");
filesystem->Close(file_handle);
return;
}
first_time = false;
}
Vector *position = GetVecOrigin(pEntity);
if (!position) continue;
QAngle *angle = GetAngRotation(pEntity);
if (!angle) continue;
temp_length = Q_snprintf(temp_string, sizeof(temp_string),
"\t\t\t\"%i\"\t\"%.0f %.0f %.0f %.0f %.0f %.0f\"\n",
count + 1,
position->x, position->y, position->z,
angle->x, angle->y, angle->z);
if (filesystem->Write((void *) temp_string, temp_length, file_handle) == 0)
{
Msg("Failed to write to clipboard.txt\n");
filesystem->Close(file_handle);
return;
}
count ++;
}
}
}
if (!first_time)
{
temp_length = Q_snprintf(temp_string, sizeof(temp_string),
"\t\t}\n\n");
if (filesystem->Write((void *) temp_string, temp_length, file_handle) == 0)
{
Msg("Failed to write to clipboard.txt\n");
filesystem->Close(file_handle);
return;
}
}
Msg("%i coordinates for classname %s\n", count, classname);
}
temp_length = Q_snprintf(temp_string, sizeof(temp_string), "\t}\n}\n");
if (filesystem->Write((void *) temp_string, temp_length, file_handle) == 0)
{
Msg("Failed to write to clipboard.txt\n");
filesystem->Close(file_handle);
return;
}
filesystem->Close(file_handle);
Msg("Written to clipboard.txt\n");
}
Unlike CSS you wouldn't have to worry about buy zones I guess.
Mani
__________________