class reviveChatCommand : public ChatCommandClass {
void Triggered(int ID,const TokenClass &Text,int ChatType) {
char buffer[128];
GetCurrentDirectory(50, buffer);
strcat(buffer, "\\rrevive.ini");
INIClass *ini = Get_INI(buffer);
if(!ini)
{
Console_Input(StrFormat("msg Unable to load RRevive.ini !").c_str());
return;
}
bool allow = ini->Get_Bool("Main", "Allow_Revive", 0);
float cost = ini->Get_Float("Main", "Cost", 0.0);
bool allowb = ini->Get_Bool("Settings", "Allow_Revive_Soldier_Factories", 0);
bool allowp = ini->Get_Bool("Settings", "Allow_Revive_Power_Plants", 0);
bool allowr = ini->Get_Bool("Settings", "Allow_Revive_Refineries", 0);
bool allowv = ini->Get_Bool("Settings", "Allow_Revive_Vehicle_Factories", 0);
bool allowd = ini->Get_Bool("Settings", "Allow_Revive_Primary_Base_Defences", 0);
GameObject *obj = Get_GameObj(ID);
float Credits = Commands->Get_Money(obj);
int Team = Get_Object_Type(obj);
int BARID = Commands->Get_ID(Find_Soldier_Factory(Team));
GameObject *bar= Commands->Find_Object(BARID);
int PPID = Commands->Get_ID(Find_Power_Plant(Team));
GameObject *pp = Commands->Find_Object(PPID);
int REFID = Commands->Get_ID(Find_Refinery(Team));
GameObject *ref = Commands->Find_Object(REFID);
int WFID = Commands->Get_ID(Find_Vehicle_Factory(Team));
GameObject *wf = Commands->Find_Object(WFID);
int OBID = Commands->Get_ID(Find_Base_Defense(Team));
GameObject *ob = Commands->Find_Object(OBID);
if(allow == 1){
if (strcmp(Text[1].c_str(),"help")==0){
if (Team == 1) {
Console_Input(StrFormat("ppage %d [Revive_System]: The price you have to pay is %.0f",ID,cost).c_str());
Console_Input(StrFormat("ppage %d [Revive_System]: You need to say the building name: bar; pp; ref; wf; agt",ID).c_str());
}
else{
Console_Input(StrFormat("ppage %d [Revive_System]: The price you have to pay is %.0f",ID,cost).c_str());
Console_Input(StrFormat("ppage %d [Revive_System]: You need to say the building name: hon; pp; ref; air; ob",ID).c_str());
}
return;
}
if (strcmp(Text[1].c_str(),"bar")==0){
if(allowb == 1){
if(Is_Building_Dead(bar)) {
if (Team == 1) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the Barracks",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(bar, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the Barracks.",Get_Player_ID(obj)).c_str());
}
}
if (Team == 0) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the Hand of Nod",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(bar, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the Hand of Nod.",Get_Player_ID(obj)).c_str());
}
}
}
else {
if (Team == 1) {
Console_Input(StrFormat("ppage %d The Barracks is not dead.",Get_Player_ID(obj)).c_str());
}
else{
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 allowed to revive the Barracks.",Get_Player_ID(obj)).c_str());
}
}
if (strcmp(Text[1].c_str(),"hon")==0){
if(allowb == 1){
if(Is_Building_Dead(bar)) {
if (Team == 1) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the Barracks",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(bar, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the Barracks.",Get_Player_ID(obj)).c_str());
}
}
if (Team == 0) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the Hand of Nod",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(bar, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the Hand of Nod.",Get_Player_ID(obj)).c_str());
}
}
}
else {
if (Team == 1) {
Console_Input(StrFormat("ppage %d The Barracks is not dead.",Get_Player_ID(obj)).c_str());
}
else{
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 allowed to revive the Hand of Nod",Get_Player_ID(obj)).c_str());
}
}
if (strcmp(Text[1].c_str(),"pp")==0){
if(allowp == 1){
if(Is_Building_Dead(pp)) {
if (Team == 1) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the PowerPlant",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(pp, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the PowerPlant.",Get_Player_ID(obj)).c_str());
}
}
if (Team == 0) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the PowerPlant",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(pp, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the PowerPlant.",Get_Player_ID(obj)).c_str());
}
}
}
else {
if (Team == 1) {
Console_Input(StrFormat("ppage %d The PowerPlant is not dead.",Get_Player_ID(obj)).c_str());
}
else{
Console_Input(StrFormat("ppage %d The PowerPlant is not dead.",Get_Player_ID(obj)).c_str());
}
}
}
else{
Console_Input(StrFormat("ppage %d You are not allowed to revive the PowerPlant",Get_Player_ID(obj)).c_str());
}
}
if (strcmp(Text[1].c_str(),"ref")==0){
if(allowr == 1){
if(Is_Building_Dead(ref)) {
if (Team == 1) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the Refinery",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(ref, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the Refinery.",Get_Player_ID(obj)).c_str());
}
}
if (Team == 0) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the Refinery",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(ref, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the Refinery.",Get_Player_ID(obj)).c_str());
}
}
}
else {
if (Team == 1) {
Console_Input(StrFormat("ppage %d The Refinery is not dead.",Get_Player_ID(obj)).c_str());
}
else{
Console_Input(StrFormat("ppage %d The Refinery is not dead.",Get_Player_ID(obj)).c_str());
}
}
}
else{
Console_Input(StrFormat("ppage %d You are not allowed to revive the Refinery",Get_Player_ID(obj)).c_str());
}
}
if (strcmp(Text[1].c_str(),"wf")==0){
if(allowv == 1){
if(Is_Building_Dead(wf)) {
if (Team == 1) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the WeaponsFactory",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(wf, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the WeaponsFactory.",Get_Player_ID(obj)).c_str());
}
}
if (Team == 0) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the AirStrip",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(wf, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the AirStrip.",Get_Player_ID(obj)).c_str());
}
}
}
else {
if (Team == 1) {
Console_Input(StrFormat("ppage %d The WeaponsFactory is not dead.",Get_Player_ID(obj)).c_str());
}
else{
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 allowed to revive the WeaponsFactory",Get_Player_ID(obj)).c_str());
}
}
if (strcmp(Text[1].c_str(),"air")==0){
if(allowv == 1){
if(Is_Building_Dead(wf)) {
if (Team == 1) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the WeaponsFactory",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(wf, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the WeaponsFactory",Get_Player_ID(obj)).c_str());
}
}
if (Team == 0) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the AirStrip",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(wf, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the AirStrip.",Get_Player_ID(obj)).c_str());
}
}
}
else {
if (Team == 1) {
Console_Input(StrFormat("ppage %d The WeaponsFactory is not dead.",Get_Player_ID(obj)).c_str());
}
else{
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 allowed to revive the AirStrip",Get_Player_ID(obj)).c_str());
}
}
if (strcmp(Text[1].c_str(),"agt")==0){
if(allowd == 1){
if(Is_Building_Dead(ob)) {
if (Team == 1) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the AGT",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(ob, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the AGT.",Get_Player_ID(obj)).c_str());
}
}
if (Team == 0) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the Obelisk",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(ob, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the Obelisk.",Get_Player_ID(obj)).c_str());
}
}
}
else {
if (Team == 1) {
Console_Input(StrFormat("ppage %d The AGT is not dead.",Get_Player_ID(obj)).c_str());
}
else{
Console_Input(StrFormat("ppage %d The Obelisk is not dead.",Get_Player_ID(obj)).c_str());
}
}
}
else{
Console_Input(StrFormat("ppage %d You are not allowed to revive the AdvancedGuardTower",Get_Player_ID(obj)).c_str());
}
}
if (strcmp(Text[1].c_str(),"ob")==0){
if(allowd == 1){
if(Is_Building_Dead(ob)) {
if (Team == 1) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the AGT",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(ob, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the AGT",Get_Player_ID(obj)).c_str());
}
}
if (Team == 0) {
if(Credits >= cost){
Commands->Give_Money(obj,cost * -1,false);
Console_Input(StrFormat("msg %d Has just revived the Obelisk",Get_Wide_Player_Name(obj)).c_str());
Commands->Attach_Script(ob, "RR_ReviveBuilding", "");
}
else{
Console_Input(StrFormat("ppage %d You do not have enough credits to revive the Obelisk.",Get_Player_ID(obj)).c_str());
}
}
}
else {
if (Team == 1) {
Console_Input(StrFormat("ppage %d The AGT is not dead.",Get_Player_ID(obj)).c_str());
}
else{
Console_Input(StrFormat("ppage %d The Obelisk is not dead.",Get_Player_ID(obj)).c_str());
}
}
}
else{
Console_Input(StrFormat("ppage %d You are not allowed to revive the Obelisk",Get_Player_ID(obj)).c_str());
}
}
}
else{
Console_Input(StrFormat("ppage %d Revive is currently disabled.",Get_Player_ID(obj)).c_str());
}
}
};
ChatCommandRegistrant<reviveChatCommand> reviveChatCommandReg("!r;!revive",CHATTYPE_ALL,1,GAMEMODE_AOW);