Raised This Month: $51 Target: $400
 12% 

Flipping Player Spawns Between Rounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
showdax
Senior Member
Join Date: Dec 2004
Old 05-09-2006 , 17:57   Flipping Player Spawns Between Rounds
Reply With Quote #1

So I've got this here plugin. It should flip player spawns between rounds in DOD:S, but it doesn't seem to be working. Here's my code: http://dackz.net/etc/dod_flip_mm.cpp.txt

I'm hooking IVEngineServer::GetMapEntitiesString. My hook gets called just fine, but the supercede seems to have no effect with the replacement string. If I return an empty string though, the entire map misses all of its entities. If I send new parameters in LevelInit with my flipped version of the string, spawns are flipped just fine, so it's not like the string is being built incorrectly.

Anyone have any ideas?
showdax is offline
Send a message via MSN to showdax
sslice
Senior Member
Join Date: Feb 2005
Location: Texas, USA
Old 05-09-2006 , 20:20  
Reply With Quote #2

Try hooking LevelInit instead.
__________________
sslice is offline
showdax
Senior Member
Join Date: Dec 2004
Old 05-09-2006 , 21:10  
Reply With Quote #3

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?
showdax is offline
Send a message via MSN to showdax
showdax
Senior Member
Join Date: Dec 2004
Old 05-09-2006 , 22:00  
Reply With Quote #4

It seems just using CBaseEntity::KeyValue() and setting classnames between rounds seems to work. Now I just need to find a signature for it under Windows!
showdax is offline
Send a message via MSN to showdax
Mani
Veteran Member
Join Date: Dec 2004
Location: UK
Old 05-10-2006 , 07:37  
Reply With Quote #5

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
__________________
Installation files, documentation and help can be found at: -

www.mani-admin-plugin.com
Mani is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:17.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode