Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Veteran Plugin.  () 1 Vote
Re: Veteran Plugin. [message #321166 is a reply to message #300286] Sat, 08 March 2008 09:22 Go to previous messageGo to previous message
Darknes2 is currently offline  Darknes2
Messages: 91
Registered: July 2007
Location: Alaberma
Karma:
Recruit
i have this at the top of gmscripts.cpp

/*	Renegade Scripts.dll
	SSGM scripts
	Copyright 2007 Vloktboky, Whitedragon(MDB), Mac, Jonathan Wilson

	This file is part of the Renegade scripts.dll
	The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
	the terms of the GNU General Public License as published by the Free
	Software Foundation; either version 2, or (at your option) any later
	version. See the file COPYING for more details.
	In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
	Only the source code to the module(s) containing the licenced code has to be released.
*/

#include "scripts.h"
#include "engine.h"
#include "gmmain.h"
#include "gmscripts.h"
#include <iostream>
#pragma warning(disable: 4996)

//Fix for the double created event bug when attaching scripts in the level loaded hook.
MDB_SSGM_Base::MDB_SSGM_Base() {
	WasCreated = false;
}

void MDB_SSGM_Base::Created(GameObject *obj) {
	if (!WasCreated) {
		NewCreated(obj);
		WasCreated = true;
	}
}

//******************************************************************************
//******************************************************************************
//******************************* veteran STUFF ********************************

struct veteranPlayers {
	std::string PlayerName;
	int veteranPoints;
};

std::vector<veteranPlayers> VetInfo;

void VetUpdate(int ID, int number, int score) {

	if (!VetInfo.empty()) {
		for (int i = 0; i < VetInfo.size(); i++) {
			if (VetInfo[i].PlayerName == Get_Player_Name_By_ID(ID)) {
				int cvp, now;
				cvp = VetInfo[i].veteranPoints;
				now = number + cvp;
				VetInfo[i].veteranPoints = now;

				int Team;
				Team = Get_Team(ID);
				if (cvp < 100 && now >= 100) {
					char Promote[255];
					sprintf(Promote,"msg veteran: %s just got promoted to the rank of General", Get_Player_Name_By_ID(ID));
					Console_Input(Promote);
					if (Team == 0) {
						sprintf(Promote, "ppage %d Kane has recognised your vision, you have been promoted to General, enjoy the extra 45HP armor on all NEW characters", ID);
						Commands->Create_2D_WAV_Sound("bonus_complete.wav");
					}
					else {
						sprintf(Promote, "ppage %d Locke himself has promoted you to a General, enjoy the extra 45HP armor on all NEW characters", ID);
						Commands->Create_2D_WAV_Sound("bonus_complete.wav");
					}
					Console_Input(Promote);
                }
				else if (cvp < 60 && now >= 60) {
                    char Promote[255];
				sprintf(Promote,"msg veteran: %s just got promoted to the rank of Brigadier", Get_Player_Name_By_ID(ID));
				Console_Input(Promote);
					if (Team == 0) {
						sprintf(Promote, "ppage %d The Brotherhood of Nod likes your style, you are promoted to rank Brigadier, enjoy the extra 30HP armor on all NEW characters", ID);
						Commands->Create_2D_WAV_Sound("m00bgwf_kill0031i1nbrs_snd.wav");
					}
					else {
						sprintf(Promote, "ppage %d Keep em coming! you done all that left handed? You are promoted to Brigadier, enjoy the extra 30HP armor on all NEW characters", ID);
						Commands->Create_2D_WAV_Sound("m00achk_kill0034i1gbmg_snd.wav");
					}
					Console_Input(Promote);
				}
				else if (cvp < 30 && now >= 30) {
                    char Promote[255];
					sprintf(Promote,"msg veteran: %s just got promoted to the rank of Major, he gets an extra 15HP armor on every character he now buys", Get_Player_Name_By_ID(ID));
				Console_Input(Promote);
					if (Team == 0) {
						sprintf(Promote, "ppage %d Kane wants you in his elite, you are promoted to Major, enjoy the splendors of war brother as every NEW character you buy will have an extra 15HP armor", ID);
						Commands->Create_2D_WAV_Sound("m00avis_kick0041i1nsmg_snd.wav");
					}
					else {
						sprintf(Promote, "ppage %d The deadsix needs people like you, you are promoted to Major! Every NEW character from now on will have an extra 15HP armor", ID);
						Commands->Create_2D_WAV_Sound("m00_wins0003eval_snd.wav");
					}
					Console_Input(Promote);
				}
				break;
			}
		}
	}
}

int VetCheckPoints(int ID) {
	if (!VetInfo.empty()) {
		for (int i = 0; i < VetInfo.size(); i++) {
			if (VetInfo[i].PlayerName == Get_Player_Name_By_ID(ID)) {
				int Points;
				Points = VetInfo[i].veteranPoints;
				return Points;
			}
		}
	}
	return 0;
}

bool VetCheck(int ID) {
	if (!VetInfo.empty()) {
		for (int i = 0; i < VetInfo.size(); i++) {
			if (VetInfo[i].PlayerName == Get_Player_Name_By_ID(ID)) {
				return true;
			}
		}
	}
	return false;
}

void VetAddPlayer(int ID) {
	if (VetCheck(ID) == false) {
		veteranPlayers temp;
		temp.PlayerName = Get_Player_Name_By_ID(ID);
		temp.veteranPoints = 0;
		VetInfo.push_back(temp);
	}
}

void VetClearPlayers() {
	VetInfo.erase(VetInfo.begin(), VetInfo.end());
	int Players = The_Game()->MaxPlayers;
	for (int i = 1; i <= Players; i++) {
		if (Get_GameObj(i)) {
			VetAddPlayer(i);
		}
	};
	bool IsLowClassVehicle(const char *Preset) {
	if (strstr(Preset,"CnC_GDI_APC")) return true;
	else if (strstr(Preset,"CnC_GDI_Humm-vee")) return true;
	else if (strstr(Preset,"CnC_GDI_MRLS")) return true;
	else if (strstr(Preset,"CnC_Civilian_Pickup01_Secret")) return true;
	else if (strstr(Preset,"CnC_Civilian_Sedan01_Secret")) return true;
	else if (strstr(Preset,"CnC_Nod_APC")) return true;
	else if (strstr(Preset,"CnC_Nod_Buggy")) return true;
	else if (strstr(Preset,"CnC_Nod_Mobile Artillery")) return true;
	else if (strstr(Preset,"Nod_Chameleon")) return true;
	else if (strstr(Preset,"CnC_Nod_Recon_Bike")) return true;
	else if (strstr(Preset,"CnC_Nod_Transport")) return true;
	else if (strstr(Preset,"CnC_GDI_Transport")) return true;
	return false;
}
int GetPoints(const char* Preset) {
	int VetWorth = 0;
	if (stricmp(Preset,"CnC_GDI_Engineer_0") == 0) VetWorth = 1;
	else if (stricmp(Preset,"CnC_GDI_Engineer_2SF") == 0) VetWorth = 3;
	else if (stricmp(Preset,"CnC_GDI_Grenadier_0") == 0) VetWorth = 1;
	else if (stricmp(Preset,"CnC_GDI_Grenadier_2SF") == 0) VetWorth = 2;
	else if (strstr(Preset,"CnC_Ignatio_Mobius")) VetWorth = 3;
	else if (stricmp(Preset,"CnC_GDI_MiniGunner_0") == 0) VetWorth = 1;
	else if (stricmp(Preset,"CnC_GDI_MiniGunner_1Off") == 0) VetWorth = 2;
	else if (stricmp(Preset,"CnC_GDI_MiniGunner_2SF") == 0) VetWorth = 2;
	else if (strstr(Preset,"CnC_GDI_MiniGunner_3Boss")) VetWorth = 3;
	else if (stricmp(Preset,"CnC_GDI_RocketSoldier_0") == 0) VetWorth = 1;
	else if (stricmp(Preset,"CnC_GDI_RocketSoldier_1Off") == 0) VetWorth = 2;
	else if (stricmp(Preset,"CnC_GDI_RocketSoldier_2SF") == 0) VetWorth = 2;
	else if (stricmp(Preset,"CnC_Nod_Engineer_0") == 0) VetWorth = 1;
	else if (stricmp(Preset,"CnC_Nod_FlameThrower_0") == 0) VetWorth = 1;
	else if (stricmp(Preset,"CnC_Nod_FlameThrower_1Off") == 0) VetWorth = 2;
	else if (stricmp(Preset,"CnC_Nod_FlameThrower_2SF") == 0) VetWorth = 2;
	else if (strstr(Preset,"CnC_Nod_FlameThrower_3Boss")) VetWorth = 3;
	else if (stricmp(Preset,"CnC_Nod_Minigunner_0") == 0) VetWorth = 1;
	else if (stricmp(Preset,"CnC_Nod_Minigunner_1Off") == 0) VetWorth = 2;
	else if (stricmp(Preset,"CnC_Nod_Minigunner_2SF") == 0) VetWorth = 2;
	else if (strstr(Preset,"CnC_Nod_Minigunner_3Boss")) VetWorth = 3;
	else if (strstr(Preset,"CnC_Nod_MiniGunner_3Boss")) VetWorth = 3;
	else if (stricmp(Preset,"CnC_Nod_RocketSoldier_0") == 0) VetWorth = 1;
	else if (stricmp(Preset,"CnC_Nod_RocketSoldier_1Off") == 0) VetWorth = 2;
	else if (stricmp(Preset,"CnC_Nod_RocketSoldier_2SF") == 0) VetWorth = 2;
	else if (strstr(Preset,"CnC_Nod_RocketSoldier_3Boss")) VetWorth = 3;
	else if (stricmp(Preset,"CnC_Nod_Technician_0") == 0) VetWorth = 3;
	else if (strstr(Preset,"CnC_Sydney_PowerSuit")) VetWorth = 3;
	else if (stricmp(Preset,"CnC_Sydney") == 0) VetWorth = 2;
	else if (strstr(Preset,"CnC_GDI_APC")) VetWorth = 3;
	else if (strstr(Preset,"CnC_GDI_Humm-vee")) VetWorth = 2;
	else if (strstr(Preset,"CnC_GDI_MRLS")) VetWorth = 3;
	else if (strstr(Preset,"CnC_Civilian_Pickup01_Secret")) VetWorth = 2;
	else if (strstr(Preset,"CnC_Civilian_Sedan01_Secret")) VetWorth = 2;
	else if (strstr(Preset,"CnC_Nod_APC")) VetWorth = 3;
	else if (strstr(Preset,"CnC_Nod_Buggy")) VetWorth = 2;
	else if (strstr(Preset,"CnC_Nod_Mobile Artillery")) VetWorth = 3;
	else if (strstr(Preset,"Nod_Chameleon")) VetWorth = 2;
	else if (strstr(Preset,"CnC_Nod_Recon_Bike")) VetWorth = 2;
	else if (strstr(Preset,"CnC_Nod_Transport")) VetWorth = 2;
	else if (strstr(Preset,"CnC_GDI_Transport")) VetWorth = 2;
	else if (strstr(Preset,"CnC_GDI_Medium_Tank")) VetWorth = 4;
	else if (strstr(Preset,"CnC_GDI_Mammoth_Tank")) VetWorth = 5;
	else if (strstr(Preset,"CnC_Nod_Light_Tank")) VetWorth = 4;
	else if (strstr(Preset,"CnC_Nod_Flame_Tank")) VetWorth = 4;
	else if (strstr(Preset,"CnC_Nod_Stealth_Tank")) VetWorth = 5;
	else if (strstr(Preset,"CnC_Nod_Apache")) VetWorth = 4;
	else if (strstr(Preset,"CnC_GDI_Orca")) VetWorth = 4;
	else if (strstr(Preset,"CnC_GDI_Harvester")) VetWorth = 2;
	else if (strstr(Preset,"CnC_Nod_Harvester")) VetWorth = 2;
	return VetWorth;
}

}

void reb_vet_System::Created(GameObject *obj) {
	int Points;
	Points = VetCheckPoints(Get_Player_ID(obj));
	if (Points >= 100) {
		Level = 3;

		GameObject *Icon = Commands->Create_Object_At_Bone(obj,"Invisible_Object", "c L THIGH");
		Commands->Attach_Script(Icon,"MDB_SSGM_Destroy_When_Object_Destroyed",ToString(Commands->Get_ID(obj)).c_str());
		IconID = Commands->Get_ID(Icon);
		Commands->Set_Model(Icon, "p_keycrd_red");
		Commands->Attach_To_Object_Bone(Icon, obj, "c L THIGH");
		Set_Max_Shield_Strength(obj, 145);
		Commands->Set_Shield_Strength(obj, 145);

		Commands->Start_Timer(obj, this, 2.0f, 3);
	}
	else if (Points >= 60) {
		Level = 2;

		GameObject *Icon = Commands->Create_Object_At_Bone(obj,"Invisible_Object", "c L THIGH");
		Commands->Attach_Script(Icon,"MDB_SSGM_Destroy_When_Object_Destroyed",ToString(Commands->Get_ID(obj)).c_str());
		Commands->Set_Model(Icon, "p_keycrd_yel");
		Commands->Attach_To_Object_Bone(Icon, obj, "c L THIGH");
		IconID = Commands->Get_ID(Icon);

		Set_Max_Shield_Strength(obj, 130);
		Commands->Set_Shield_Strength(obj, 130);

	}
	else if (Points >= 30) {

		Level = 1;

		GameObject *Icon = Commands->Create_Object_At_Bone(obj,"Invisible_Object", "c L THIGH");
		Commands->Attach_Script(Icon,"MDB_SSGM_Destroy_When_Object_Destroyed",ToString(Commands->Get_ID(obj)).c_str());
		Commands->Set_Model(Icon, "p_keycrd_grn");
		Commands->Attach_To_Object_Bone(Icon, obj, "c L THIGH");
		IconID = Commands->Get_ID(Icon);

		if (strstr(Commands->Get_Preset_Name(obj),"CnC_Nod_FlameThrower_2SF")){

		}

		Set_Max_Shield_Strength(obj, 115);
		Commands->Set_Shield_Strength(obj, 115);

	}
	else {
		Level = 0;
	}
	Commands->Start_Timer(obj, this, 60.0f, 10);
}

void reb_vet_System::Custom(GameObject *obj, int message, int param, GameObject *sender) {
	if (message == CUSTOM_EVENT_VEHICLE_ENTER) {
		Commands->Destroy_Object(Commands->Find_Object(IconID));
	}
	else if (Level == 3) {
		GameObject *Icon = Commands->Create_Object_At_Bone(obj,"Invisible_Object", "c L THIGH");
		Commands->Attach_Script(Icon,"MDB_SSGM_Destroy_When_Object_Destroyed",ToString(Commands->Get_ID(obj)).c_str());
		Commands->Set_Model(Icon, "p_keycrd_red");
		Commands->Attach_To_Object_Bone(Icon, obj, "c L THIGH");
		IconID = Commands->Get_ID(Icon);
		float Shield;
		Shield = Commands->Get_Shield_Strength(obj);
		Set_Max_Shield_Strength(obj, 145);
		Commands->Set_Shield_Strength(obj, Shield);

		}
		else if (Level == 2) {
		GameObject *Icon = Commands->Create_Object_At_Bone(obj,"Invisible_Object", "c L THIGH");
		Commands->Attach_Script(Icon,"MDB_SSGM_Destroy_When_Object_Destroyed",ToString(Commands->Get_ID(obj)).c_str());
		Commands->Set_Model(Icon, "p_keycrd_yel");
		Commands->Attach_To_Object_Bone(Icon, obj, "c L THIGH");
		IconID = Commands->Get_ID(Icon);
		float Shield;
		Shield = Commands->Get_Shield_Strength(obj);
		Set_Max_Shield_Strength(obj, 130);
		Commands->Set_Shield_Strength(obj, Shield);

		}
		else if (Level == 1) {
		GameObject *Icon = Commands->Create_Object_At_Bone(obj,"Invisible_Object", "c L THIGH");
		Commands->Attach_Script(Icon,"MDB_SSGM_Destroy_When_Object_Destroyed",ToString(Commands->Get_ID(obj)).c_str());
		IconID = Commands->Get_ID(Icon);
		Commands->Set_Model(Icon, "p_keycrd_grn");
		Commands->Attach_To_Object_Bone(Icon, obj, "c L THIGH");

				if (strstr(Commands->Get_Preset_Name(obj),"CnC_Nod_FlameThrower_2SF")){

		}
		
		float Shield;
		Shield = Commands->Get_Shield_Strength(obj);
		Set_Max_Shield_Strength(obj, 115);
		Commands->Set_Shield_Strength(obj, Shield);
		}
		Commands->Start_Timer(obj, this, 60.0f, 10);
	}

	


void reb_vet_System::Timer_Expired(GameObject *obj, int number) {
	if (number == 3) {
		Commands->Apply_Damage(obj, -1.0f, "Repair", false);
		Commands->Start_Timer(obj, this, 2.0f, 5);
	}
	else if (number == 10) {
		int Points;
		Points = VetCheckPoints(Get_Player_ID(obj));
		if (Points >= 100 && Level < 3) {
			Level = 3;
			if (Get_Vehicle(obj) == 0) {
				Commands->Destroy_Object(Commands->Find_Object(ID));
		GameObject *Icon = Commands->Create_Object_At_Bone(obj,"Invisible_Object", "c L THIGH");
		Commands->Set_Model(Icon, "p_keycrd_red");
		Commands->Attach_To_Object_Bone(Icon, obj, "c L THIGH");
		ID = Commands->Get_ID(Icon);

			}
			Commands->Start_Timer(obj, this, 2.0f, 3);
		}
		else if (Points >= 60 && Level < 2) {
			Level = 2;
			if (Get_Vehicle(obj) == 0) {
				Commands->Destroy_Object(Commands->Find_Object(ID));
		GameObject *Icon = Commands->Create_Object_At_Bone(obj,"Invisible_Object", "c L THIGH");
		Commands->Set_Model(Icon, "p_keycrd_yel");
		Commands->Attach_To_Object_Bone(Icon, obj, "c L THIGH");
		ID = Commands->Get_ID(Icon);

			}
		}
		else if (Points >= 30 && Level < 1) {
			Level = 1;
			if (Get_Vehicle(obj) == 0) {
				Commands->Destroy_Object(Commands->Find_Object(ID));
		GameObject *Icon = Commands->Create_Object_At_Bone(obj,"Invisible_Object", "c L THIGH");
		Commands->Set_Model(Icon, "p_keycrd_grn");
		Commands->Attach_To_Object_Bone(Icon, obj, "c L THIGH");
		ID = Commands->Get_ID(Icon);

			}
		}
		Commands->Start_Timer(obj, this, 60.0f, 10);		
	}
	
}

void reb_vet_System::Killed(GameObject *obj, GameObject *shooter) {
	
	Destroy_Script();
}

void reb_vet_System::Destroyed(GameObject *obj) {
    Commands->Destroy_Object(Commands->Find_Object(IconID));
	Destroy_Script();
}

void reb_vet_System_Vehicles::Custom(GameObject *obj, int message, int param, GameObject *sender) {
	if (message == CUSTOM_EVENT_VEHICLE_ENTER) {
		int Points;
		Points = VetCheckPoints(Get_Player_ID(sender));
		if (Points >= 100) {
			Level = 3;
			IsPoweredUp = true;

			if (IsLowClassVehicle(Commands->Get_Preset_Name(obj)) == true) {
//nothing			
			}
			else {
				Commands->Start_Timer(obj, this, 1.0f, 3);
			}
		}
		else if (Points >= 60) {
			Level = 2;
			IsPoweredUp = true;

			if (IsLowClassVehicle(Commands->Get_Preset_Name(obj)) == true) {
//nothing

				Commands->Start_Timer(obj, this, 1.0f, 2);
			}
			else {
				Commands->Start_Timer(obj, this, 1.0f, 3);
			}
		}
		else if (Points >= 30) {
			Level = 1;
			IsPoweredUp = true;

			if (IsLowClassVehicle(Commands->Get_Preset_Name(obj)) == true) {
//nothing
			}
			else {
				Commands->Start_Timer(obj, this, 1.0f, 1);
			}
		}
		Commands->Send_Custom_Event(sender, sender, CUSTOM_EVENT_VEHICLE_ENTER, 0, 0);
	}
	else if (message == CUSTOM_EVENT_VEHICLE_EXIT) {
		if (IsPoweredUp == true) {
			IsPoweredUp = false;
			if (Level == 1) {
				if (IsLowClassVehicle(Commands->Get_Preset_Name(obj)) == true) {
//nothing
				}
			}
			else if (Level == 2) {
				if (IsLowClassVehicle(Commands->Get_Preset_Name(obj)) == true) {
//nothing
				}
			}
			else if (Level == 3) {
				if (IsLowClassVehicle(Commands->Get_Preset_Name(obj)) == true) {
//nothing
				}
			}
		}
		Commands->Send_Custom_Event(sender, sender, CUSTOM_EVENT_VEHICLE_EXIT, 0, 0);
	}
}
void reb_vet_System_Vehicles::Timer_Expired(GameObject *obj, int number) {
	if (number == 3 && IsPoweredUp == true) {
		Commands->Destroy_Object(Commands->Find_Object(ID));
		Commands->Apply_Damage(obj, -3.0f, "Repair", false);
		Commands->Start_Timer(obj, this, 1.0f, 3);
	}
	else if (number == 2 && IsPoweredUp == true) {
		float Health, MaxHealth;
		Health = Commands->Get_Health(obj);
		MaxHealth = Commands->Get_Max_Health(obj);
		if (Health == MaxHealth) {
			// Nothing
		}
		else if (Health >= MaxHealth - 2) {
			Commands->Set_Health(obj, MaxHealth);
		}
		else if (Health <= MaxHealth - 3) {
			Commands->Set_Health(obj, Health + 3);
		}
		Commands->Start_Timer(obj, this, 1.0f, 2);
	}
	else if (number == 1 && IsPoweredUp == true) {
		float Shield, MaxShield;
		Shield = Commands->Get_Shield_Strength(obj);
		MaxShield = Commands->Get_Max_Shield_Strength(obj);
		if (Shield == MaxShield) {
			// Nothing
		}
		else if (Shield >= MaxShield - 2) {
			Commands->Set_Shield_Strength(obj, MaxShield);
		}
		else if (Shield <= MaxShield - 3) {
			Commands->Set_Shield_Strength(obj, Shield + 3);
		}
		Commands->Start_Timer(obj, this, 1.0f, 1);
	}
}

void reb_vet_System_Vehicles::Killed(GameObject *obj, GameObject *shooter) {
	Commands->Destroy_Object(Commands->Find_Object(ID));
	Destroy_Script();
}

void reb_vet_System_Vehicles::Destroyed(GameObject *obj) {
	Commands->Destroy_Object(Commands->Find_Object(ID));
	Destroy_Script();
}


 
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: c++ simple commands
Next Topic: strings
Goto Forum:
  


Current Time: Tue Jun 25 22:00:23 MST 2024

Total time taken to generate the page: 0.01537 seconds