Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Release Forum » [script]Base power crate function
[script]Base power crate function [message #300996] Tue, 04 December 2007 13:28 Go to next message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma: 0
General (3 Stars)
I made a base defence crate feature that turns off the enemies base defence when you pick it up. I based the model of this on vloktboky's version, but changed it a little.
Some might argue that the defence that goes down should be random, independant of the person that picks it up. If they prefer it that way then it is easily changed, but this is how I decided I wanted it to work.

There is a movie of it here: http://www.mp-gaming.com/reborn/movies/power/power.html

But it was one of the first movies I made and it is freaking huge, I wouldn't really bother watching it tbh.

But here is how I made it work.

void KAK_Power_Crate_Revert::Created(GameObject *obj) {
	Commands->Start_Timer(obj,this,72.0f,Get_Int_Parameter("Mode"));
}

void KAK_Power_Crate_Revert::Timer_Expired(GameObject *obj, int number) {
	char message[512];

	if (number == 1){
		Commands->Set_Building_Power(Find_Base_Defense(1),true);
		sprintf(message,"msg Crate: GDI's Base power has been reactivated.");
		Console_Input(message);
		Commands->Create_2D_WAV_Sound("m00evan_dsgn0006i1evan_snd.wav");
		
	}

	else if (number == 2){
		Commands->Set_Building_Power(Find_Base_Defense(0),true);
		sprintf(message,"msg Crate: Nod's Base power has been reactivated.");
		Console_Input(message);
		Commands->Create_2D_WAV_Sound("m00evan_dsgn0007i1evan_snd.wav");
	}

	Commands->Destroy_Object(obj);
}


ScriptRegistrant<KAK_Power_Crate_Revert> KAK_Power_Crate_Revert_Registrant("KAK_Power_Crate_Revert","Mode=0:int");



class KAK_Power_Crate_Revert : public ScriptImpClass {
	void Created(GameObject *obj);
	void Timer_Expired(GameObject *obj, int number);
};


You can slip this into SSGM's crate funtion, or however you want to do it, it's quite versatile.


if	((RandomIntCrate <=	(percent+=Settings->CratePower))	&& (Settings->CratePower	> 0)) {

char CrateMessage[512];

int Team = Get_Object_Type(sender);
					GameObject *Revert = Commands->Create_Object("Invisible_Object",Commands->Get_Position(obj));

					if (Team == 0) {
						 if (Commands->Get_Building_Power(Find_Base_Defense(1))) {
							Commands->Set_Building_Power(Find_Base_Defense(1),false);
							sprintf(CrateMessage,"msg Crate: GDI's base power is temporarily off-line for for 72 seconds");
							Console_Input(CrateMessage);
							Commands->Create_2D_WAV_Sound("m00evan_dsgn0068i1evan_snd.wav");
							Commands->Attach_Script(Revert,"KAK_Power_Crate_Revert","1");
						}
						 else {
                            Commands->Give_Money(sender,400,false);
							sprintf(CrateMessage,"ppage %d Crate: You just got 400 credits from the money crate.",Get_Player_ID(sender));
							Console_Input(CrateMessage);
							}
						
					}
					else {
						if (Commands->Get_Building_Power(Find_Base_Defense(0))) {
							Commands->Set_Building_Power(Find_Base_Defense(0),false);
							sprintf(CrateMessage,"msg Crate: Nod's base power is temporarily off-line for for 72 seconds");
							Console_Input(CrateMessage);
							Commands->Create_2D_WAV_Sound("m00evan_dsgn0069i1evan_snd.wav");
							Commands->Attach_Script(Revert,"KAK_Power_Crate_Revert","2");
						}
												 else {
                            Commands->Give_Money(sender,400,false);
							sprintf(CrateMessage,"ppage %d Crate: You just got 400 credits from the money crate.",Get_Player_ID(sender));
							Console_Input(CrateMessage);
							}

					}


			}




You may wonder why I did the else grant money part instead of "goto CrateStart;", well when I was testing it I set the crate chances of 100% to be the Poewr crate. So it would of looped forever.
If you do not wish to have it grant the player some credits in the absence of a working base defence then do something like this:

char CrateMessage[512];

int Team = Get_Object_Type(sender);
					GameObject *Revert = Commands->Create_Object("Invisible_Object",Commands->Get_Position(obj));

					if (Team == 0) {
						 if (Commands->Get_Building_Power(Find_Base_Defense(1))) {
							Commands->Set_Building_Power(Find_Base_Defense(1),false);
							sprintf(CrateMessage,"msg Crate: GDI's base power is temporarily off-line for for 72 seconds");
							Console_Input(CrateMessage);
							Commands->Create_2D_WAV_Sound("m00evan_dsgn0068i1evan_snd.wav");
							Commands->Attach_Script(Revert,"KAK_Power_Crate_Revert","1");
						}
						 else {
goto CrateStart;
							}
						
					}
					else {
						if (Commands->Get_Building_Power(Find_Base_Defense(0))) {
							Commands->Set_Building_Power(Find_Base_Defense(0),false);
							sprintf(CrateMessage,"msg Crate: Nod's base power is temporarily off-line for 72 seconds");
							Console_Input(CrateMessage);
							Commands->Create_2D_WAV_Sound("m00evan_dsgn0069i1evan_snd.wav");
							Commands->Attach_Script(Revert,"KAK_Power_Crate_Revert","2");
						}
												 else {
goto CrateStart;
							}

					}


			}



[Updated on: Fri, 30 January 2009 14:43] by Moderator

Report message to a moderator

Re: Base power crate function [message #300999 is a reply to message #300996] Tue, 04 December 2007 13:33 Go to previous messageGo to next message
cnc95fan is currently offline  cnc95fan
Messages: 1261
Registered: July 2007
Karma: 0
General (1 Star)
Jesus, lol, ever since i made that post about the veteran plugin, and you said, share fuckers share, youve definently been splashing out, nontheless, nais one Wink
Re: Base power crate function [message #301009 is a reply to message #300996] Tue, 04 December 2007 14:06 Go to previous messageGo to next message
Genesis2001
Messages: 1397
Registered: August 2006
Karma: 0
General (1 Star)
You could also mix it up a bit an have it randomly turn off power to EITHER your base or your opponent's base. Wink

int Team = Get_Object_Type(sender);



Change to:

float Team = Commands->Get_Random(-1,2);



Note that I'm not entirely sure how to use the Get_Random() function so someone like reborn will have to correct me if I'm wrong on my params ^,^


~MathK1LL
Re: Base power crate function [message #301099 is a reply to message #300999] Tue, 04 December 2007 19:57 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
cnc95fan wrote on Tue, 04 December 2007 14:33

Jesus, lol, ever since i made that post about the veteran plugin, and you said, share fuckers share, youve definently been splashing out, nontheless, nais one Wink


yes ty reborn even tho i have all this stuff i never had the source

Thumbs Up

Edit: i would release all my cool crates but creator doesn't want me 2 ....... god dammit


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

[Updated on: Tue, 04 December 2007 20:02]

Report message to a moderator

Re: Base power crate function [message #301168 is a reply to message #301009] Wed, 05 December 2007 08:15 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3812
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
MathK1LL wrote on Tue, 04 December 2007 14:06

You could also mix it up a bit an have it randomly turn off power to EITHER your base or your opponent's base. Wink

int Team = Get_Object_Type(sender);



Change to:

float Team = Commands->Get_Random(-1,2);



Note that I'm not entirely sure how to use the Get_Random() function so someone like reborn will have to correct me if I'm wrong on my params ^,^


~MathK1LL

-2 = civilian
-1 = mutant
0 = nod
1 = gdi
2 = renegade


Re: Base power crate function [message #301176 is a reply to message #300996] Wed, 05 December 2007 08:28 Go to previous messageGo to next message
Sir Kane
Messages: 1701
Registered: March 2003
Location: Angerville
Karma: 0
General (1 Star)
-4860945 = negative number.

Proud N9500 and proud N6270 user. Creator of the IEE libraries (original bhs.dll) and the RB series software.
http://n00bstories.com/image.fetch.php?id=1189992501http://www.n00bstories.com/image.fetch.php?id=1257492907
Re: Base power crate function [message #301179 is a reply to message #301176] Wed, 05 December 2007 08:32 Go to previous message
Jerad2142 is currently offline  Jerad2142
Messages: 3812
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
Sir Kane wrote on Wed, 05 December 2007 08:28

-4860945 = negative number.

-4860945 * -1 = positive number, which means that
-4860945 + -1 * -4860945 = 0


Previous Topic: [script]Bot paratroopers function
Next Topic: 2 new skin releases
Goto Forum:
  


Current Time: Wed Dec 11 09:17:01 MST 2024

Total time taken to generate the page: 0.00884 seconds