Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » C++ void On_Player_Death???
Re: C++ void On_Player_Death??? [message #432219 is a reply to message #432193] Wed, 07 July 2010 00:42 Go to previous messageGo to previous message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma:
General (3 Stars)
If you really must use SSGM and not a plugin for it, then do the following:


Open gmmain.ccp and find this portion of code:

void ObjectHookCall(void *data,GameObject *obj) {
	if (Settings->Is_Disabled(obj)) {
		Commands->Destroy_Object(obj);
		return;
	}
	else if (Commands->Is_A_Star(obj)) {
		if ((Settings->GameMode == 3 || Settings->GameMode == 4) && !Settings->Is_Sniper(obj)) {
			Commands->Destroy_Object(obj);
			return;
		}
		else {
			Attach_Script_Once(obj,"MDB_SSGM_Player","");
		}
	}


This is a hook, and it is catching Game Objects when they are created. The "else if (Commands->Is_A_Star(obj)) {" part is basically saying "if the object is a player", so everything encapsulated in that part is dealing with players...

The first part in that encapsulation (the part saying " if ((Settings->GameMode == 3 || Settings->GameMode == 4) && !Settings->Is_Sniper(obj)) {") basically means, if the game mode is 3 or 4, and the player isn't a sniper, then destroy the object.
The the second part is saying, otherwise, attach this script to them "Attach_Script_Once(obj,"MDB_SSGM_Player","");".

Now you could very well modify the MDB_SSGM_Player script so that on ::Killed it is changing the team if they are on GDI.

However, it is better to add you script at this point instead, so you would change the above code to this:

void ObjectHookCall(void *data,GameObject *obj) {
	if (Settings->Is_Disabled(obj)) {
		Commands->Destroy_Object(obj);
		return;
	}
	else if (Commands->Is_A_Star(obj)) {
		if ((Settings->GameMode == 3 || Settings->GameMode == 4) && !Settings->Is_Sniper(obj)) {
			Commands->Destroy_Object(obj);
			return;
		}
		else {
			Attach_Script_Once(obj,"MDB_SSGM_Player","");
			Attach_Script_Once(obj,"MutateMeh_Death_Script","");
		}
	}


So basically, what you've done is attach the script "MutateMeh_Death_Script" to every single player. Now you need to write the actual script...


//note, not tested and not properly indented due to typing directly into the browser and no IDE.
// place in the .cpp file
void MutateMeh_Death_Script::Killed(GameObject *obj,GameObject *shooter)
{
if (Commands->Get_Player_Type(obj) == 1)
{
Change_Team(obj, 0);
Commands->Attach_Script(obj, "JFW_Change_Spawn_Character", "Mutant_1_Renegade");
}
}

// registrant, will compile without it, but script will not work, so do not forget this
ScriptRegistrant<MutateMeh_Death_Script> MutateMeh_Death_Script_Registrant("MutateMeh_Death_Script","");


// place in the header file
class MutateMeh_Death_Script : public ScriptImpClass {
void Killed(GameObject *obj,GameObject *shooter);
};



This should do what you want, but again, please not I did not test this, and I wasn't able to format the code properly either.



[Updated on: Wed, 07 July 2010 00:42]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Lua Plugin V5
Next Topic: distance between two objects c++
Goto Forum:
  


Current Time: Sun Oct 27 12:22:09 MST 2024

Total time taken to generate the page: 0.01031 seconds