Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Release Forum » [Plug-in] SSGM2.02 Commander BETA  () 1 Vote
Re: [Plug-in] SSGM2.02 Commander BETA [message #385242 is a reply to message #383047] Sat, 09 May 2009 09:51 Go to previous messageGo to previous message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma:
General (3 Stars)
I made some Revivable buildings commands using reborns team fund function and commander function. The team all donate to team fund and if a building dies the commander can revive the building if there is enough money in the team fund. I made it ini configurable for the amount it cost for the buildings to be revived.

Requirements
-Renegade Resurrection
-Add to Reborns Commander plugin so it can uses its functions.

Under the SettingsStruct in the .h file

		powerplantcost = 20000;
		vehiclefactoriescost = 20000;
		soldierfactories = 20000;
		refcost = 20000;
		basedefensecost = 20000;



Under void Load(); in the .h file

	int	powerplantcost;
	int	vehiclefactoriescost;
	int	soldierfactories;
	int	refcost;
	int	basedefensecost;



Under the SettingsLoader;


	LoadInt(powerplantcost,"powerplantcost");
	printf("The cost for a Power Plant is %i credits\n",powerplantcost);
	LoadInt(vehiclefactoriescost,"vehiclefactoriescost");
	printf("The cost for a Vehicle Factory is %i credits\n",vehiclefactoriescost);
	LoadInt(soldierfactories,"soldierfactories");
	printf("The cost for a Charcter Factory is %i credits\n",soldierfactories);
	LoadInt(refcost,"refcost");
	printf("The cost for the Refinary is %i credits\n",refcost);
	LoadInt(basedefensecost,"basedefensecost");
	printf("The cost for Basedefences is %i credits\n",basedefensecost);



Add to the .ini file

powerplantcost=20000;

vehiclefactoriescost=20000;

soldierfactories=20000;

refcost=20000;

basedefensecost=20000;



Main Revive Commands


//////////////////////
///Revive Buildings///
//////////////////////

class revive_vehiclefactoriesChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
		GameObject *obj = Get_GameObj(ID);
		int Team = Get_Object_Type(obj);
		int BuildingID = Commands->Get_ID(Find_Vehicle_Factory(Team));
		GameObject *thebuilding = Commands->Find_Object(BuildingID);
		if(Is_Building_Dead(Find_Vehicle_Factory(Team))) {
			if(GDICommander[ID]){
				if(GDITeamFund >= CSettings->vehiclefactoriescost){
					GDITeamFund = GDITeamFund - CSettings->vehiclefactoriescost;
					Console_Input(StrFormat("msg The GDI Commander just revived the Weapons Factory",Get_Player_ID(obj)).c_str());
					Commands->Attach_Script(thebuilding, "RR_ReviveBuilding", "");
					Commands->Create_2D_WAV_Sound("pplant_powerup.wav");
				}
				else{
				Console_Input(StrFormat("ppage %d There is not enough credits in the team fund you need $%i. Use !tfdonate to add to the fund.",Get_Player_ID(obj),CSettings->vehiclefactoriescost).c_str());
				}
			}
			else if(NodCommander[ID]){
				if(NodTeamFund >= CSettings->vehiclefactoriescost){
					NodTeamFund = NodTeamFund - CSettings->vehiclefactoriescost;
					Console_Input(StrFormat("msg The GDI Commander just revived the Airstrip",Get_Player_ID(obj)).c_str());
					Commands->Attach_Script(thebuilding, "RR_ReviveBuilding", "");
					Commands->Create_2D_WAV_Sound("pplant_powerup.wav");
				}
				else{
				Console_Input(StrFormat("ppage %d There is not enough credits in the team fund you need $%i. Use !tfdonate to add to the fund.",Get_Player_ID(obj),CSettings->vehiclefactoriescost).c_str());
				}
			}
		}
		else if(GDICommander[ID]){
			Console_Input(StrFormat("ppage %d The Weapons Factory is not dead.",Get_Player_ID(obj)).c_str());	
		}
		else if(NodCommander[ID]){
			Console_Input(StrFormat("ppage %d The Airstrip is not dead.",Get_Player_ID(obj)).c_str());
		}
		else{
			Console_Input(StrFormat("ppage %d You are not a team commander and cannot use this command.",ID).c_str());
		}
	}
};
ChatCommandRegistrant<revive_vehiclefactoriesChatCommand> revive_vehiclefactoriesChatCommandReg("!revive_wf;!revive_air;!r wf;!r air",CHATTYPE_TEAM,0,GAMEMODE_ALL);

class revive_refineriesChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
		GameObject *obj = Get_GameObj(ID);
		int Team = Get_Object_Type(obj);
		int BuildingID = Commands->Get_ID(Find_Refinery(Team));
		GameObject *thebuilding = Commands->Find_Object(BuildingID);
		//if(CSettings->enablerevive){
		if(Is_Building_Dead(Find_Refinery(Team))) {
			if(GDICommander[ID]){
				if(GDITeamFund >= CSettings->refcost){
					GDITeamFund = GDITeamFund - CSettings->refcost;
					Console_Input(StrFormat("msg The GDI Commander just revived the GDI Refinary",Get_Player_ID(obj)).c_str());
					Commands->Attach_Script(thebuilding, "RR_ReviveBuilding", "");
					Commands->Create_2D_WAV_Sound("pplant_powerup.wav");
				}
				else{
				Console_Input(StrFormat("ppage %d There is not enough credits in the team fund you need $%i. Use !tfdonate to add to the fund.",Get_Player_ID(obj),CSettings->refcost).c_str());
				}
			}
			else if(NodCommander[ID]){
				if(NodTeamFund >= CSettings->refcost){
					NodTeamFund = NodTeamFund - CSettings->refcost;
					Console_Input(StrFormat("msg The Nod Commander just revived the Nod Refinary",Get_Player_ID(obj)).c_str());
					Commands->Attach_Script(thebuilding, "RR_ReviveBuilding", "");
					Commands->Create_2D_WAV_Sound("pplant_powerup.wav");
				}
				else{
				Console_Input(StrFormat("ppage %d There is not enough credits in the team fund you need $%i. Use !tfdonate to add to the fund.",Get_Player_ID(obj),CSettings->refcost).c_str());
				}
			}
		}
		else if(GDICommander[ID]){
			Console_Input(StrFormat("ppage %d The GDI Refinary is not dead.",Get_Player_ID(obj)).c_str());	
		}
		else if(NodCommander[ID]){
			Console_Input(StrFormat("ppage %d The Nod Refinary is not dead.",Get_Player_ID(obj)).c_str());
		}
		else{
			Console_Input(StrFormat("ppage %d You are not a team commander and cannot use this command.",ID).c_str());
		}
	}
};
ChatCommandRegistrant<revive_refineriesChatCommand> revive_refineriesChatCommandReg("!revive_ref;!r_ref",CHATTYPE_TEAM,0,GAMEMODE_AOW);


class revive_powerplantsChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
		GameObject *obj = Get_GameObj(ID);
		int Team = Get_Object_Type(obj);
		int BuildingID = Commands->Get_ID(Find_Power_Plant(Team));
		GameObject *thebuilding = Commands->Find_Object(BuildingID);
		if(Is_Building_Dead(Find_Power_Plant(Team))) {
			if(GDICommander[ID]){
				if(GDITeamFund >= CSettings->powerplantcost){
					GDITeamFund = GDITeamFund - CSettings->powerplantcost;
					Console_Input(StrFormat("msg The GDI Commander just revived the GDI PowerPlant",Get_Player_ID(obj)).c_str());
					Commands->Attach_Script(thebuilding, "RR_ReviveBuilding", "");
					Commands->Create_2D_WAV_Sound("pplant_powerup.wav");
				}
				else{
				Console_Input(StrFormat("ppage %d There is not enough credits in the team fund you need $%i. Use !tfdonate to add to the fund.",Get_Player_ID(obj),CSettings->powerplantcost).c_str());
				}
			}
			else if(NodCommander[ID]){
				if(NodTeamFund >= CSettings->powerplantcost){
					NodTeamFund = NodTeamFund - CSettings->powerplantcost;
					Console_Input(StrFormat("msg The Nod Commander just revived the Nod Powerplant",Get_Player_ID(obj)).c_str());
					Commands->Attach_Script(thebuilding, "RR_ReviveBuilding", "");
					Commands->Create_2D_WAV_Sound("pplant_powerup.wav");
				}
				else{
				Console_Input(StrFormat("ppage %d There is not enough credits in the team fund you need $%i. Use !tfdonate to add to the fund.",Get_Player_ID(obj),CSettings->powerplantcost).c_str());
				}
			}
		}
		else if(GDICommander[ID]){
			Console_Input(StrFormat("ppage %d The GDI Powerplant is not dead.",Get_Player_ID(obj)).c_str());	
		}
		else if(NodCommander[ID]){
			Console_Input(StrFormat("ppage %d The Nod Powerplant is not dead.",Get_Player_ID(obj)).c_str());
		}
		else{
			Console_Input(StrFormat("ppage %d You are not a team commander and cannot use this command.",ID).c_str());
		}
	}
};
ChatCommandRegistrant<revive_powerplantsChatCommand> revive_powerplantsChatCommandReg("!revive_pp;!r_pp",CHATTYPE_TEAM,0,GAMEMODE_AOW);


class revive_soldierfactoriesChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
		GameObject *obj = Get_GameObj(ID);
		int Team = Get_Object_Type(obj);
		int BuildingID = Commands->Get_ID(Find_Soldier_Factory(Team));
		GameObject *thebuilding = Commands->Find_Object(BuildingID);
		if(Is_Building_Dead(Find_Building(Team,SOLDIER_FACTORY))) {
			if(GDICommander[ID]){
				if(GDITeamFund >= CSettings->soldierfactories){
					GDITeamFund = GDITeamFund - CSettings->soldierfactories;
					Console_Input(StrFormat("msg The GDI Commander just revived the GDI Barracks",Get_Player_ID(obj)).c_str());
					Commands->Attach_Script(thebuilding, "RR_ReviveBuilding", "");
					Commands->Create_2D_WAV_Sound("pplant_powerup.wav");
				}
				else{
				Console_Input(StrFormat("ppage %d There is not enough credits in the team fund you need $%i. Use !tfdonate to add to the fund.",Get_Player_ID(obj),CSettings->soldierfactories).c_str());
				}
			}
			else if(NodCommander[ID]){
				if(NodTeamFund >= CSettings->soldierfactories){
					NodTeamFund = NodTeamFund - CSettings->soldierfactories;
					Console_Input(StrFormat("msg The Nod Commander just revived the Hand of Nod",Get_Player_ID(obj)).c_str());
					Commands->Attach_Script(thebuilding, "RR_ReviveBuilding", "");
					Commands->Create_2D_WAV_Sound("pplant_powerup.wav");
				}
				else{
				Console_Input(StrFormat("ppage %d There is not enough credits in the team fund you need $%i. Use !tfdonate to add to the fund.",Get_Player_ID(obj),CSettings->soldierfactories).c_str());
				}
			}
		}
		else if(GDICommander[ID]){
			Console_Input(StrFormat("ppage %d The GDI Barracks is not dead.",Get_Player_ID(obj)).c_str());	
		}
		else if(NodCommander[ID]){
			Console_Input(StrFormat("ppage %d The Hand of Nod is not dead.",Get_Player_ID(obj)).c_str());
		}
		else{
			Console_Input(StrFormat("ppage %d You are not a team commander and cannot use this command.",ID).c_str());
		}
	}
};
ChatCommandRegistrant<revive_soldierfactoriesChatCommand> revive_soldierfactoriesChatCommandReg("!revive_bar;!revive_hon;!r_hon;!r_bar",CHATTYPE_TEAM,0,GAMEMODE_AOW);


class revive_basedefenseChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
		GameObject *obj = Get_GameObj(ID);
		int Team = Get_Object_Type(obj);
		int BuildingID = Commands->Get_ID(Find_Base_Defense(Team));
		GameObject *thebuilding = Commands->Find_Object(BuildingID);
		if(Is_Building_Dead(Find_Building(Team,BASE_DEFENSE))) {
			if(GDICommander[ID]){
				if(GDITeamFund >= CSettings->basedefensecost){
					GDITeamFund = GDITeamFund - CSettings->basedefensecost;
					Console_Input(StrFormat("msg The GDI Commander just revived the GDI Advance Guard Tower",Get_Player_ID(obj)).c_str());
					Commands->Attach_Script(thebuilding, "RR_ReviveBuilding", "");
					Commands->Create_2D_WAV_Sound("pplant_powerup.wav");
				}
				else{
				Console_Input(StrFormat("ppage %d There is not enough credits in the team fund you need $%i. Use !tfdonate to add to the fund.",Get_Player_ID(obj),CSettings->basedefensecost).c_str());
				}
			}
			else if(NodCommander[ID]){
				if(NodTeamFund >= CSettings->basedefensecost){
					NodTeamFund = NodTeamFund - GDITeamFund - CSettings->basedefensecost;
					Console_Input(StrFormat("msg The Nod Commander just revived the Nod Obelisk",Get_Player_ID(obj)).c_str());
					Commands->Attach_Script(thebuilding, "RR_ReviveBuilding", "");
					Commands->Create_2D_WAV_Sound("pplant_powerup.wav");
				}
				else{
				Console_Input(StrFormat("ppage %d There is not enough credits in the team fund you need $%i. Use !tfdonate to add to the fund.",Get_Player_ID(obj),CSettings->basedefensecost).c_str());	
				}
			}
		}
		else if(GDICommander[ID]){
			Console_Input(StrFormat("ppage %d The GDI Advance Guard Tower is not dead.",Get_Player_ID(obj)).c_str());	
		}
		else if(NodCommander[ID]){
			Console_Input(StrFormat("ppage %d The Nod Obelisk is not dead.",Get_Player_ID(obj)).c_str());
		}
		else{
			Console_Input(StrFormat("ppage %d You are not a team commander and cannot use this command.",ID).c_str());
		}
	}
};
ChatCommandRegistrant<revive_basedefenseChatCommand> revive_basedefenseChatCommandReg("!revive_ob;!revive_agt;!r_agt;!r_ob",CHATTYPE_TEAM,0,GAMEMODE_AOW);




Commands used to kill buildings so its easier to test the revive commands.


/////////////////////
///Kill Buildings////
/////////////////////


class kill_vehiclefactoriesChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
		GameObject *obj = Get_GameObj(ID);
		int Team = Get_Object_Type(obj);
		int BuildingID = Commands->Get_ID(Find_Vehicle_Factory(Team));
		GameObject *thebuilding = Commands->Find_Object(BuildingID);
		Vector3 position = Commands->Get_Position(thebuilding);
		Commands->Apply_Damage(thebuilding,99999,"Death",false);
		if (Team == 1) {
			Console_Input(StrFormat("msg War Factory Destroyed",Get_Player_ID(obj)).c_str());
		}
		else {
			Console_Input(StrFormat("msg Airstrip Destroyed",Get_Player_ID(obj)).c_str());
		}
	}
};
ChatCommandRegistrant<kill_vehiclefactoriesChatCommand> kill_vehiclefactoriesChatCommandReg("!kill_wf;!kill_air",CHATTYPE_TEAM,0,GAMEMODE_ALL);


class kill_refineriesChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
		GameObject *obj = Get_GameObj(ID);
		int Team = Get_Object_Type(obj);
		int BuildingID = Commands->Get_ID(Find_Refinery(Team));
		GameObject *thebuilding = Commands->Find_Object(BuildingID);
		Vector3 position = Commands->Get_Position(thebuilding);
		Commands->Apply_Damage(thebuilding,99999,"Death",false);
		if (Team == 1) {
			Console_Input(StrFormat("msg GDI Refinary Destroyed",Get_Player_ID(obj)).c_str());
		}
		else {
			Console_Input(StrFormat("msg Nod Refinary Destroyed",Get_Player_ID(obj)).c_str());
		}
	}
};
ChatCommandRegistrant<kill_refineriesChatCommand> kill_refineriesChatCommandReg("!kill_ref",CHATTYPE_TEAM,0,GAMEMODE_ALL);


class kill_basedefenseChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
		GameObject *obj = Get_GameObj(ID);
		int Team = Get_Object_Type(obj);
		int BuildingID = Commands->Get_ID(Find_Base_Defense(Team));
		GameObject *thebuilding = Commands->Find_Object(BuildingID);
		Vector3 position = Commands->Get_Position(thebuilding);
		Commands->Apply_Damage(thebuilding,99999,"Death",false);
		if (Team == 1) {
			Console_Input(StrFormat("msg GDI AGT Destroyed",Get_Player_ID(obj)).c_str());
		}
		else {
			Console_Input(StrFormat("msg Nod Obelisk Destroyed",Get_Player_ID(obj)).c_str());
		}
	}
};
ChatCommandRegistrant<kill_basedefenseChatCommand> kill_basedefenseChatCommandReg("!kill_agt;!kill_ob",CHATTYPE_TEAM,0,GAMEMODE_ALL);


class kill_powerplantChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
		GameObject *obj = Get_GameObj(ID);
		int Team = Get_Object_Type(obj);
		int BuildingID = Commands->Get_ID(Find_Power_Plant(Team));
		GameObject *thebuilding = Commands->Find_Object(BuildingID);
		Vector3 position = Commands->Get_Position(thebuilding);
		Commands->Apply_Damage(thebuilding,99999,"Death",false);
		if (Team == 1) {
			Console_Input(StrFormat("msg GDI Power Plant Destroyed",Get_Player_ID(obj)).c_str());
		}
		else {
			Console_Input(StrFormat("msg Nod Power Plant Destroyed",Get_Player_ID(obj)).c_str());
		}
	}
};
ChatCommandRegistrant<kill_powerplantChatCommand> kill_powerplantChatCommandReg("!kill_pp;!kill_powerplant",CHATTYPE_TEAM,0,GAMEMODE_ALL);


class kill_soldierfactoriesChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
		GameObject *obj = Get_GameObj(ID);
		int Team = Get_Object_Type(obj);
		int BuildingID = Commands->Get_ID(Find_Soldier_Factory(Team));
		GameObject *thebuilding = Commands->Find_Object(BuildingID);
		Vector3 position = Commands->Get_Position(thebuilding);
		Commands->Apply_Damage(thebuilding,99999,"Death",false);
		if (Team == 1) {
			Console_Input(StrFormat("msg GDI Barracks Destroyed",Get_Player_ID(obj)).c_str());
		}
		else {
			Console_Input(StrFormat("msg Nod Hand of Nod Destroyed",Get_Player_ID(obj)).c_str());
		}
	}
};
ChatCommandRegistrant<kill_soldierfactoriesChatCommand> kill_soldierfactoriesChatCommandReg("!kill_bar;!kill_hon",CHATTYPE_TEAM,0,GAMEMODE_ALL);




The the only problem I have seen so far is when the building is dead and a player that is not a commander uses the command. It wont tell the player hes not a commander. If the building is alive it will.


http://s18.postimage.org/jc6qbn4k9/bricks3.png

[Updated on: Sat, 09 May 2009 09:52]

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
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
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
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
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Hot Snow [3rd Havoc Mode]
Next Topic: [SKIN] C&C 3 Medium Tank
Goto Forum:
  


Current Time: Wed Jun 26 01:41:47 MST 2024

Total time taken to generate the page: 0.01744 seconds