Home » Renegade Discussions » Mod Release Forum » [script]Base power crate function
[script]Base power crate function [message #300996] |
Tue, 04 December 2007 13:28 |
|
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 #301009 is a reply to message #300996] |
Tue, 04 December 2007 14:06 |
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.
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 |
|
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
|
yes ty reborn even tho i have all this stuff i never had the source
Edit: i would release all my cool crates but creator doesn't want me 2 ....... god dammit
[Updated on: Tue, 04 December 2007 20:02] Report message to a moderator
|
|
|
|
|
|
Goto Forum:
Current Time: Tue Dec 03 04:26:56 MST 2024
Total time taken to generate the page: 0.01523 seconds
|