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:
|
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
|
|
|
Goto Forum:
Current Time: Wed Dec 04 09:27:34 MST 2024
Total time taken to generate the page: 0.00710 seconds
|