/*	Renegade Scripts.dll
	Engine calls
	Copyright 2006 Vloktboky, WhiteDragon(MDB), Joshua "NeoSaber" Kraft, 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.
*/

typedef void (*ChatHook) (int PlayerID,int Type,const wchar_t *Message);
typedef void (*HostHook) (int PlayerID,int Type,const char *Message);
typedef void (*ObjectCreateHook) (void *data,GameObject *obj);
typedef void (*PlayerJoin) (int PlayerID,const char *PlayerName);
typedef void (*LoadLevelHook) ();
typedef void (*ConsoleOutputHook) (const char *output);
typedef void (*BHSVersion) (int PlayerID,float Version);
typedef void (*CRCHook) (unsigned int CRC,int PlayerID);
typedef void (*DataHook) (int PlayerID,unsigned int count, unsigned int *data);

struct ObjectCreateHookStruct {
	ObjectCreateHook hook;
	void *data;
};

typedef void (*KeyHook) (void *data);
struct KeyHookStruct {
	KeyHook hook;
	const char *key;
	int PlayerID;
	void *data;
};

#ifdef WIN32
struct GenericSLNode {
	GenericSLNode *NodeNext;
	void *NodeData;
};
#elif defined RH8
struct GenericSLNode {
	GenericSLNode *NodeNext;
	void *NodeData;
};
#else
struct GenericSLNode {
	int unknown;
	GenericSLNode *NodeNext;
	void *NodeData;
};
#endif

struct RefStruct {
	int unknown;
	GameObject* obj;
};

template <class T1,class T2> class TypedEventPair {
	T1 signal;
	T2 data;
};

template <class T> class Signaler {
public:
	int unknown;
	virtual void ReceiveSignal(T &signal)
	{
	}
	virtual void SignalDropped(Signaler &sig)
	{
	}
	virtual ~Signaler()
	{
	}
};

template <class T> class SList {
public:
	GenericSLNode *HeadNode;
	GenericSLNode *TailNode;
	virtual ~SList()
	{
	}
	virtual bool Add_Head(T *data)
	{
		return false;
	}
	virtual bool Add_Head(SList<T> &list)
	{
		return false;
	}
	virtual bool Add_Tail(T *data)
	{
		return false;
	}
	virtual bool Add_Tail(SList<T> &list)
	{
		return false;
	}
	virtual T *Remove_Head()
	{
		return 0;
	}
	virtual T *Remove_Tail()
	{
		return 0;
	}
	virtual bool Remove(T *element)
	{
		return false;
	}
	virtual void Remove_All()
	{
	}
	virtual bool Insert_Before(T *newnode,T *oldnode)
	{
		return false;
	}
	virtual bool Insert_After(T *newnode,T *oldnode)
	{
		return false;
	}
	virtual bool Is_Empty()
	{
		return false;
	}
	virtual long Get_Count()
	{
		return 0;
	}
};

template <class T> class SimpleVecClass {
protected:
	T *Vector;
	int VectorMax;
public:
	SimpleVecClass(unsigned int size)
	{
		Vector = 0;
		VectorMax = 0;
		if (size > 0)
		{
			Resize(size);
		}
	}
	virtual bool Uninitialised_Grow(int newsize)
	{
		if ((newsize > 0) && (newsize > VectorMax))
		{
			delete Vector;
			Vector = new T[newsize*4];
			VectorMax = newsize;
		}
		return true;
	}
	SimpleVecClass(const SimpleVecClass<T> &cl)
	{
		VectorMax = cl.VectorMax;
		Vector = new T[VectorMax*4];
		memcpy(Vector,cl.Vector,VectorMax*4);
	}
	int Length()
	{
		return VectorMax;
	}
	T &operator[](int index)
	{
		return Vector[index];
	}
	virtual ~SimpleVecClass()
	{
		if (Vector)
		{
			delete Vector;
			Vector = 0;
			VectorMax = 0;
		}
	}
	virtual bool Resize(int newsize)
	{
		T *vec;
		if (VectorMax == newsize)
		{
			return true;
		}
		if (newsize > 0)
		{
			vec = new T[newsize*4];
			if (Vector)
			{
				int count;
				count = VectorMax;
				if (newsize < count)
				{
					count = newsize;
				}
				memcpy(vec,Vector,count*4);
				delete Vector;
				Vector = 0;
			}
			Vector = vec;
			VectorMax = newsize;
		}
		else
		{
			VectorMax = 0;
			if (Vector)
			{
				delete Vector;
				Vector = 0;
			}
		}
		return true;
	}
	SimpleVecClass &operator=(const SimpleVecClass<T> &cl)
	{
		if (Vector)
		{
			delete Vector;
		}
		VectorMax = cl.VectorMax;
		Vector = new T[VectorMax*4];
		memcpy(Vector,cl.Vector,VectorMax*4);
		return *this;
	}
};

template <class T> class SimpleDynVecClass : public SimpleVecClass<T> {
protected:
	int ActiveCount;
public:
	SimpleDynVecClass(int size) : SimpleVecClass<T>(size)
	{
		ActiveCount = 0;
	}
	SimpleDynVecClass(const SimpleDynVecClass<T> &cl) : SimpleVecClass<T>(cl)
	{
		ActiveCount = cl.ActiveCount;
	}
	int Count()
	{
		return ActiveCount;
	}
	virtual ~SimpleDynVecClass()
	{
		if (Vector)
		{
			delete Vector;
			Vector = 0;
		}
	}
	virtual bool Resize(int newsize)
	{
		if (SimpleVecClass<T>::Resize(newsize))
		{
			if (VectorMax < ActiveCount)
			{
				ActiveCount = VectorMax;
			}
			return true;
		}
		return false;
	}
	int Add(T& data)
	{
		for (int i = 0;i < VectorMax;i++)
		{
			if (!Vector[i])
			{
				Vector[i] = data;
				ActiveCount++;
				return i;
			}
		}
		Resize(VectorMax+1);
		Vector[VectorMax-1] = data;
		ActiveCount++;
		return VectorMax-1;
	}
	void Delete(int position)
	{
		Vector[position] = 0;
		ActiveCount--;
	}
	SimpleDynVecClass &operator=(const SimpleDynVecClass<T> &cl)
	{
		SimpleVecClass<T>::operator =(cl);
		ActiveCount = cl.ActiveCount;
		return *this;
	}
};

template <class T> class VectorClass {
private:
	T *Vector;
	int VectorMax;
	bool IsValid;
	bool IsAllocated;
public:
	virtual ~VectorClass()
	{
	}
	int Length()
	{
		return VectorMax;
	}
	T &operator[](int index)
	{
		return Vector[index];
	}
	virtual bool operator==(VectorClass<T> &vector)
	{
		return false;
	}
	virtual bool Resize(int newsize,T *array)
	{
		return false;
	}
	virtual void Clear()
	{
	}
	virtual int ID(T &object)
	{
		return 0;
	}
	virtual int ID(T *ptr)
	{
		return 0;
	}
};

template <class T> class DynamicVectorClass : public VectorClass<T> {
private:
	int ActiveCount;
	int GrowthStep;
public:
	int Count()
	{
		return ActiveCount;
	}
	virtual ~DynamicVectorClass()
	{
	}
	virtual bool Resize(int newsize,T *array)
	{
		return false;
	}
	virtual void Clear()
	{
	}
	virtual int ID(T &object)
	{
		return 0;
	}
	virtual int ID(T *ptr)
	{
		return 0;
	}
};

class StringClass {
public:
	char* m_Buffer;
	StringClass();
	StringClass& operator=(StringClass&);
	void Uninitialised_Grow(int size);
};

class WideStringClass {
public:
	wchar_t* m_Buffer;
	WideStringClass& operator=(WideStringClass&);
	void Uninitialised_Grow(int size);
	void Convert_From(char const *text);
	void Get_String(int length,bool is_temp);
	void Free_String();
};

typedef void *ChunkSaveClass;
typedef void *ChunkLoadClass;

class TDBObjClass {
	bool unk;
	StringClass EnglishString;
	StringClass Description;
	unsigned long ID;
	unsigned long SoundID;
	unsigned long CategoryID;
	StringClass Animation;
	DynamicVectorClass<WideStringClass> Strings;
public:
	virtual ~TDBObjClass();
	virtual void On_Post_Load();
	virtual void *Get_Factory();
	virtual void Save(ChunkSaveClass &save);
	virtual void Load(ChunkLoadClass &load);
	virtual void *As_StringTwiddlerClass();
	virtual TDBObjClass *Clone();
	virtual WideStringClass *Get_String(unsigned long language);
	virtual WideStringClass *Get_String();
	virtual StringClass *Get_English_String();
	virtual unsigned long Get_ID();
	virtual const char *Get_ID_Desc();
	virtual unsigned long Get_Sound_ID();
	virtual const char *Get_Animation_Name();
	virtual unsigned long Get_Category_ID();
	virtual void Set_String(unsigned long language,const wchar_t *string);
	virtual void Set_English_String(const char *string);
	virtual void Set_ID(unsigned long ID);
	virtual void Set_ID_Desc(const char *description);
	virtual void Set_Animation_Name(const char *name);
	virtual void Set_Sound_ID(unsigned long ID);
	virtual void Set_Category_ID(unsigned long ID);
	virtual void Contains_Translation(unsigned long language);
};

class GenericNode {
	GenericNode* NextNode;
	GenericNode* PrevNode;
public:
	virtual ~GenericNode();
};

class GenericList {
	GenericNode FirstNode;
	GenericNode LastNode;
public:
	virtual ~GenericList();
};

template <class T> class List : GenericList {
public:
	virtual ~List();
};

template <typename T1,class T2> class IndexClass {
	struct NodeElement {
		int ID;
		T2 Data;
	};
	NodeElement* IndexTable;
	int IndexCount;
	int IndexSize;
	unsigned char IsSorted;
	NodeElement* Archive;
};

class INISection;

class INIClass {
	List<INISection *> *SectionList;
	IndexClass<int,INISection *> *SectionIndex;
public:
	int Get_Int(char const *section,char const *entry,int defaultvalue);
	float Get_Float(char const *section,char const *entry,float defaultvalue);
	bool Get_Bool(char const *section,char const *entry,bool defaultvalue);
	void Get_String(char const *section,char const *entry,char const *defaultvalue,char *result,int size);
	virtual ~INIClass();
};

#ifdef WIN32
struct TIME {
	short wYear;
	short wMonth;
	short wDayOfWeek;
	short wDay;
	short wHour;
	short wMinute;
	short wSecond;
	short wMilliseconds;
};
#else
struct TIME {
	int wMonth;
	int wDay;
	int wYear;
	int wHour;
	int wMinute;
	int wSecond;
};
#endif

class cGameDataCnc;
class cGameDataSkirmish;
class cGameDataSinglePlayer;

class cGameData : public Signaler<TypedEventPair<bool,int> > {
public:
	bool GameplayPermitted;
	bool IsDedicated;
	bool IsAutoRestart;
	bool IsFriendlyFirePermitted;
	bool IsTeamChangingAllowed;
	bool IsPassworded;
	bool Unknown;
	bool IsLaddered;
	bool IsClanGame;
	bool UseLagReduction;
	bool RemixTeams;
	bool CanRepairBuildings;
	bool DriverIsAlwaysGunner;
	bool SpawnWeapons;
	bool DoMapsLoop;
	bool MapCycleOver;
	unsigned int MapNumber;
	WideStringClass GameTitle;
	WideStringClass Motd;
	WideStringClass Password;
	char *MapName;
	char *ModName;
	char *MapList[100];
	WideStringClass Owner;
	DynamicVectorClass<WideStringClass> BottomText;
	DynamicVectorClass<WideStringClass> SettingsLimits;
	WideStringClass SettingsDescription;
	unsigned int MaxPlayers;
	unsigned int TimeLimit_Minutes;
	unsigned int IntermissionTime_Seconds;
	unsigned int ExeKey;
	bool ExeVersionsMatch;
	bool StringVersionsMatch;
	unsigned int IP;
	unsigned int Port;
	char *INI;
	unsigned int RadarMode;
	unsigned int CFGModTime;
	unsigned int CurrentPlayers;
	float IntermissionTimeLeft;
	float TimeRemaining_Seconds;
	float MaxWorldDistance;
	unsigned int MinQualifyingTime_Minutes;
	unsigned int WinnerID;
	unsigned int WinType;
	TIME unknown4;
	unsigned int GameStartTime;
	unsigned long FrameCount;
	WideStringClass MVPName;
	unsigned int MVPCount;
	unsigned int GameDuration_Seconds;
	bool IsQuickMatch;
	unsigned long Clan1;
	unsigned long Clan2;
	virtual void ReceiveSignal(TypedEventPair<bool,int> &signal)
	{
	}
	virtual cGameData::~cGameData()
	{
	}
	virtual void On_Game_Begin()
	{
	}
	virtual void On_Game_End()
	{
	}
	virtual void Think()
	{
	}
	virtual void Render()
	{
	}
	virtual void Reset_Game()
	{
	}
	virtual WideStringClass Get_Game_Name() = 0;
	virtual int Get_Game_Type() = 0;
	virtual int Choose_Player_Type(void *Player,int type,bool unk)
	{
	}
	virtual void Load_From_Server_Config()
	{
	}
	virtual void Save_To_Server_Config()
	{
	}
	virtual bool Is_Editable_Teaming()
	{
	}
	virtual bool Is_Editable_Clan_Game()
	{
	}
	virtual bool Is_Editable_Friendly_Fire()
	{
	}
	virtual void Soldier_Added(GameObject *obj)
	{
	}
	virtual void Show_Game_Settings_Limits()
	{
	}
	virtual bool Is_Single_Player()
	{
	}
	virtual bool Is_Skirmish()
	{
	}
	virtual bool Is_Cnc()
	{
	}
	virtual cGameDataSinglePlayer *As_Single_Player()
	{
	}
	virtual cGameDataSkirmish *As_Skirmish()
	{
	}
	virtual cGameDataCnc *As_Cnc()
	{
	}
	virtual unsigned int Get_Min_Players()
	{
	}
	virtual bool Is_Game_Over()
	{
	}
	virtual bool Is_Limited()
	{
	}
	virtual bool Is_Valid_Settings(WideStringClass &w,bool b)
	{
	}
	virtual void Export_Tier_1_Data(void *packet)
	{
	}
	virtual void Import_Tier_1_Data(void *packet)
	{
	}
	virtual void Import_Tier_1_Data_Wol(void *packet)
	{
	}
	virtual void Export_Tier_2_Data(void *packet)
	{
	}
	virtual void Import_Tier_2_Data(void *packet)
	{
	}
	virtual bool Is_Gameplay_Permitted()
	{
	}
	virtual bool Remember_Inventory()
	{
	}
	virtual void Get_Description(WideStringClass &w)
	{
	}
};

struct Update {
	unsigned int LastUpdateTime;
	short UpdateRate;
	unsigned char HintCount;
};

enum DIRTY_BIT {
	DB_CREATION = 0x0F,
	DB_RARE = 7,
	DB_OCCASIONAL = 3,
	DB_FREQUENT = 1,
};

class NetworkObjectClass {
public:
	unsigned int NetworkID;
	Update UpdateData[128];
	char DirtyBits[128];
	unsigned int ImportStateCount;
	unsigned int LastClientsideUpdateTime;
	unsigned int CreationTime;
	unsigned int ClientUpdateCount;
	unsigned int unk2;
	bool DeletePending;
	unsigned char PacketType;
	unsigned int LastDamaged;
	unsigned int LastDamager;
	unsigned char FrequentUpdateExportSize;
	float CachedPriority;
	float Unknown[128];
	bool UnreliableOverride;
	virtual ~NetworkObjectClass();
	virtual unsigned int Get_Network_Class_ID();
	virtual void Import_Creation(void *BitStream);
	virtual void Import_Rare(void *BitStream);
	virtual void Import_Occasional(void *BitStream);
	virtual void Import_Frequent(void *BitStream);
	virtual void Export_Creation(void *BitStream);
	virtual void Export_Rare(void *BitStream);
	virtual void Export_Occasional(void *BitStream);
	virtual void Export_Frequent(void *BitStream);
	virtual void Network_Think();
	virtual void Set_Delete_Pending();
	virtual void Delete() = 0;
	virtual void Set_Object_Dirty_Bit(DIRTY_BIT Bit, bool Set);
	virtual void Set_Object_Dirty_Bit(int Client_ID, DIRTY_BIT Bit, bool Set);
	virtual void Clear_Object_Dirty_Bits();
	virtual bool Get_Object_Dirty_Bit(int Client_ID,DIRTY_BIT Bit);
	virtual bool Get_Object_Dirty_Bits(int Client_ID);
	virtual bool Set_Object_Dirty_Bits(int Client_ID,unsigned char Bits);
	virtual bool Is_Client_Dirty(int Client_ID);
	virtual int Get_Vis_ID();
	virtual bool Get_World_Position(Vector3 &Position);
	virtual float Get_Filter_Distance();
	virtual bool Is_Tagged();
	virtual void Get_Description(StringClass &Description);
	virtual float Get_Cached_Priority();
};

class OBBoxClass {
public:
	float Basis[3][3];
	Vector3 Center;
	Vector3 Extent;
};

class BaseControllerClass : public NetworkObjectClass {
public:
	float OperationTimeFactor;
	int team;
	DynamicVectorClass<GameObject *> BuildingList;
	bool IsPowered;
	bool CanGenerateSoldiers;
	bool CanGenerateVehicles;
	bool RadarEnabled;
	bool BaseDestroyed;
	bool BeaconDestroyedBase;
	OBBoxClass BeaconZone;
	unsigned int AnnouncementInterval;
	unsigned int AnnouncementUnknown;
	unsigned int AnnouncementUnknown2;
	unsigned int Unknown1;
	unsigned int Unknown2;
	virtual ~BaseControllerClass();
	virtual void Import_Occasional(void *BitStream);
	virtual void Export_Occasional(void *BitStream);
	virtual void Set_Delete_Pending();
	virtual void Delete();
	static BaseControllerClass *Find_Base(int Team);
	GameObject *Get_Harvester_Vehicle();
	GameObject *Find_Building(unsigned int Type);
	void Power_Base(bool Power);
	void Set_Can_Generate_Soldiers(bool CanGenerate);
	void Set_Can_Generate_Vehicles(bool CanGenerate);
	void Destroy_Base();
	void Set_Beacon_Destroyed_Base(bool BeaconDestroyed);
	void Enable_Radar(bool Enable);
};

typedef int (*PurchaseHook) (BaseControllerClass *base,GameObject *purchaser,unsigned int cost,unsigned int preset,const char *data);
typedef void (*PurchaseMonHook) (BaseControllerClass *base,GameObject *purchaser,unsigned int cost,unsigned int preset,unsigned int purchaseret,const char *data);

class cGameDataCnc : public cGameData {
public:
	bool BaseDestructionEndsGame;
	bool BeaconPlacementEndsGame;
	unsigned int StartingCredits;
	BaseControllerClass GDI;
	BaseControllerClass Nod;
	bool BasesInitalized;
	virtual cGameDataCnc::~cGameDataCnc()
	{
	}
	virtual void On_Game_Begin()
	{
	}
	virtual void On_Game_End()
	{
	}
	virtual void Think()
	{
	}
	virtual void Reset_Game()
	{
	}
	virtual WideStringClass Get_Game_Name()
	{
	}
	virtual int Get_Game_Type()
	{
	}
	virtual void Load_From_Server_Config()
	{
	}
	virtual void Save_To_Server_Config()
	{
	}
	virtual bool Is_Editable_Teaming()
	{
	}
	virtual bool Is_Editable_Clan_Game()
	{
	}
	virtual bool Is_Editable_Friendly_Fire()
	{
	}
	virtual void Soldier_Added(GameObject *obj)
	{
	}
	virtual void Show_Game_Settings_Limits()
	{
	}
	virtual bool Is_Cnc()
	{
	}
	virtual cGameDataCnc *As_Cnc()
	{
	}
	virtual bool Is_Game_Over()
	{
	}
	virtual bool Is_Limited()
	{
	}
	virtual bool Is_Valid_Settings(WideStringClass &w,bool b)
	{
	}
	virtual void Export_Tier_2_Data(void *packet)
	{
	}
	virtual void Import_Tier_2_Data(void *packet)
	{
	}
	virtual bool Is_Gameplay_Permitted()
	{
	}
	virtual void Get_Description(WideStringClass &w)
	{
	}
};

class cGameDataSkirmish : public cGameData {
public:
	bool BaseDestructionEndsGame;
	bool BeaconPlacementEndsGame;
	unsigned int StartingCredits;
	BaseControllerClass GDI;
	BaseControllerClass Nod;
	bool BasesInitalized;
	virtual cGameDataSkirmish::~cGameDataSkirmish()
	{
	}
	virtual void On_Game_Begin()
	{
	}
	virtual void On_Game_End()
	{
	}
	virtual void Think()
	{
	}
	virtual void Reset_Game()
	{
	}
	virtual WideStringClass Get_Game_Name()
	{
	}
	virtual int Get_Game_Type()
	{
	}
	virtual void Load_From_Server_Config()
	{
	}
	virtual void Save_To_Server_Config()
	{
	}
	virtual bool Is_Editable_Teaming()
	{
	}
	virtual bool Is_Editable_Clan_Game()
	{
	}
	virtual bool Is_Editable_Friendly_Fire()
	{
	}
	virtual void Soldier_Added(GameObject *obj)
	{
	}
	virtual void Show_Game_Settings_Limits()
	{
	}
	virtual bool Is_Skirmish()
	{
	}
	virtual cGameDataSkirmish *As_Skirmish()
	{
	}
	virtual bool Is_Game_Over()
	{
	}
	virtual bool Is_Limited()
	{
	}
	virtual void Get_Description(WideStringClass &w)
	{
	}
};

class cGameDataSinglePlayer : public cGameData {
public:
	virtual cGameDataSinglePlayer::~cGameDataSinglePlayer()
	{
	}
	virtual WideStringClass Get_Game_Name()
	{
	}
	virtual int Get_Game_Type()
	{
	}
	virtual int Choose_Player_Type(void *Player,int type,bool unk)
	{
	}
	virtual bool Is_Single_Player()
	{
	}
	virtual cGameDataSinglePlayer *As_Single_Player()
	{
	}
	virtual bool Is_Limited()
	{
	}
	virtual bool Remember_Inventory()
	{
	}
};

typedef unsigned long WeaponClass;
class WeaponBagClass {
public:
	GameObject *owner;
	DynamicVectorClass<WeaponClass *> Vector;
	int current;
	bool flag1;
	bool flag2;
};

struct Vector4 {
	float X;
	float Y;
	float Z;
	float W;
};

struct Matrix3D {
	Vector4 Row[3];
};

class PostLoadableClass {
	bool IsPostLoadRegistered;
public:
	virtual ~PostLoadableClass()
	{
	}
	virtual void On_Post_Load()
	{
	}
};

class PersistClass : public PostLoadableClass {
public:
	virtual ~PersistClass()
	{
	}
	virtual void *Get_Factory() = 0;
	virtual bool Save(void *csave)
	{
		return 0;
	}
	virtual bool Load(void *cload)
	{
		return 0;
	}
};

class EditableClass : public PersistClass {
public:
	virtual ~EditableClass()
	{
	}
	virtual int Get_Parameter_Count()
	{
		return 0;
	}
	virtual void *Lock_Parameter(int i)
	{
		return 0;
	}
	virtual void Unlock_Parameter(int i)
	{
	}
};

class DefinitionClass : public EditableClass {
	int m_DefinitionMgrLink;
	StringClass m_Name;
	unsigned long m_ID;
	unsigned long m_GenericUserData;
	bool m_SaveEnabled;
public:
	virtual ~DefinitionClass()
	{
	}
	virtual bool Save(void *csave)
	{
		return 0;
	}
	virtual bool Load(void *cload)
	{
		return 0;
	}
	virtual unsigned long Get_Class_ID() = 0;
	virtual unsigned long Get_ID()
	{
		return 0;
	}
	virtual void Set_ID(unsigned long id)
	{
	}
	virtual PersistClass *Create() = 0;
	virtual char *Get_Name()
	{
		return 0;
	}
	virtual void Set_Name(char *new_name)
	{
	}
	virtual bool Is_Valid_Config(const char *message)
	{
		return 0;
	}
};

class TeamPurchaseSettingsDefClass : public DefinitionClass {
public:
	unsigned int team;
	unsigned int presetid[4];
	unsigned int stringid[4];
	StringClass texture[4];
	unsigned int beaconcost;
	unsigned int beaconpresetid;
	unsigned int beaconstringid;
	StringClass beacontexture;
	unsigned int refillstringid;
	StringClass refilltexture;
	virtual ~TeamPurchaseSettingsDefClass()
	{
	}
	virtual void *Get_Factory()
	{
		return 0;
	}
	virtual bool Save(void *csave)
	{
		return 0;
	}
	virtual bool Load(void *cload)
	{
		return 0;
	}
	virtual unsigned long Get_Class_ID()
	{
		return 0;
	}
	virtual PersistClass *Create()
	{
		return 0;
	}
	static TeamPurchaseSettingsDefClass *Get_Definition(unsigned long team);
};

class PurchaseSettingsDefClass : public DefinitionClass {
public:
	unsigned int team;
	unsigned int type;
	unsigned int costs[10];
	unsigned int presetids[10];
	unsigned int stringids[10];
	StringClass textures[10];
	unsigned int altpresetids[10][3];
	StringClass alttextures[10][3];
	virtual ~PurchaseSettingsDefClass()
	{
	}
	virtual void *Get_Factory()
	{
		return 0;
	}
	virtual bool Save(void *csave)
	{
		return 0;
	}
	virtual bool Load(void *cload)
	{
		return 0;
	}
	virtual unsigned long Get_Class_ID()
	{
		return 0;
	}
	virtual PersistClass *Create()
	{
		return 0;
	}
	static PurchaseSettingsDefClass *Find_Definition(unsigned long type,unsigned long team);
};

#ifdef WIN32
#define IMPLEMENT_THUNK(address) { \
	_asm { \
		mov eax, address \
	} \
	_asm { \
		jmp eax \
	} \
}
#define THUNK __declspec(naked)
#else
#define THUNK
#ifdef BHS
#define IMPLEMENT_THUNK(address) { \
	__asm__ ( \
			"jmp *" #address "\n\t" \
		); \
}
#else
#define IMPLEMENT_THUNK(address) { \
	__asm__ ( \
			".byte 0xC9;	\n\t" \
			"jmp *" #address "\n\t" \
		); \
}
#endif
#endif

//type/class ID values for various things
#define Beacon 0x3016
#define Building 0xD001 //only covers generic buildings,not the special stuff like PowerPlant or Refinery
#define C4 0x3006
#define PowerPlant 0xD003
#define PowerUp 0x3003
#define Refinery 0xD002
#define RepairBay 0xD009
#define SamSite 0x3007
#define ScriptZone 0x300E
#define Simple 0x3004
#define Soldier 0x3001
#define SoldierFactory 0xD004
#define SpecialEffects 0x3013
#define Vehicle 0x3010
#define VehicleFactory 0xD005 //for WarFactory or Airstrip,use the relavent values
#define WarFactory 0xD007
#define Airstrip 0xD006
#define Cinematic 0x3011
#define ComCenter 0xD008

//values for Set_Fog_Mode and Set_Fog_Mode_Player
#define FOG_EXP 1 //Set_Fog_Density applies to this mode
#define FOG_EXP2 2 //Set_Fog_Density applies to this mode
#define FOG_LINEAR 3 //This is the default if you are using fog

//start per-player script commands stuff
typedef void (*_Enable_Stealth_Player) (GameObject *obj,GameObject *obj2,bool enable);
typedef void (*_Set_Fog_Enable_Player) (GameObject *obj,bool enable);
typedef void (*_Set_Fog_Range_Player) (GameObject *obj,float Start_Distance,float End_Distance,float transition);
typedef void (*_Set_Background_Music_Player) (GameObject *obj,const char *music);
typedef void (*_Fade_Background_Music_Player) (GameObject *obj,const char *music,int unk1,int unk2);
typedef void (*_Stop_Background_Music_Player) (GameObject *obj);
typedef void (*_Enable_Radar_Player) (GameObject *obj,bool enable);
typedef void (*_Display_GDI_Player_Terminal_Player) (GameObject *obj);
typedef void (*_Display_NOD_Player_Terminal_Player) (GameObject *obj);
typedef void (*_Set_Screen_Fade_Color_Player) (GameObject *obj,float red,float green,float blue,float transition);
typedef void (*_Set_Screen_Fade_Opacity_Player) (GameObject *obj,float opacity,float transition);
typedef void (*_Force_Camera_Look_Player) (GameObject *obj,const Vector3 & look);
typedef void (*_Enable_HUD_Player) (GameObject *obj,bool enable);
typedef int (*_Create_Sound_Player) (GameObject *obj,const char *soundname,const Vector3 & position,GameObject *obj2);
typedef int (*_Create_2D_Sound_Player) (GameObject *obj,const char *soundname);
typedef int (*_Create_2D_WAV_Sound_Player) (GameObject *obj,const char *soundname);
typedef int (*_Create_3D_WAV_Sound_At_Bone_Player) (GameObject *obj,const char *soundname,GameObject *obj2,const char *bonename);
typedef int (*_Create_3D_Sound_At_Bone_Player) (GameObject *obj,const char *soundname,GameObject *obj2,const char *bonename);
typedef void (*_Set_Display_Color_Player) (GameObject *obj,unsigned char red,unsigned char green,unsigned char blue);
typedef void (*_Display_Text_Player) (GameObject *obj,int strnum);
typedef void (*_Display_Int_Player) (GameObject *obj,int num,const char *msg);
typedef void (*_Display_Float_Player) (GameObject *obj,float num,const char *msg);
typedef void (*_Set_Obj_Radar_Blip_Shape_Player) (GameObject *obj,GameObject *obj2,int shape);
typedef void (*_Set_Obj_Radar_Blip_Color_Player) (GameObject *obj,GameObject *obj2,int color);
typedef int (*aoch) (ObjectCreateHookStruct *h);
typedef void (*roch) (int pos);
typedef int (*akh) (KeyHookStruct *h);
typedef void (*rkh) (int pos);
typedef void (*ss) (GameObject *obj,int scope);
typedef void (*sh) (GameObject *obj,const char *texture);
typedef void (*ach) (ChatHook h);
typedef void (*avh) (BHSVersion h);
typedef void (*ahh) (HostHook h);
typedef void (*allh) (LoadLevelHook h);
typedef int (*aph) (PurchaseHook h,const char *data);
typedef int (*apmh) (PurchaseMonHook h,const char *data);
typedef void (*rph) (int pos);
typedef void (*apjh) (PlayerJoin h);
typedef const char *(*gcmt) ();
typedef double (*gbhsv) ();
typedef void (*sit) (GameObject *obj,const char *texture);
typedef void (*cit) (GameObject *obj);
typedef void (*svl) (unsigned int limit);
typedef unsigned long (*gvl) ();
typedef void (*sm) (unsigned int red,unsigned int green,unsigned int blue, const char *msg);
typedef void (*smp) (GameObject *obj,unsigned int red,unsigned int green,unsigned int blue, const char *msg);
typedef void (*sw) (int mode);
typedef void (*lnhi) (GameObject *obj,const char *ini);
typedef void (*rw) (GameObject *obj,const char *weapon);
typedef void (*upd) ();
typedef void (*crm) (float scale,float offsetx,float offsety,const char *texture);
typedef float (*gbm) (int team);
typedef void (*scb) (bool building,int team);
typedef bool (*icb) (int team);
typedef void (*acoh) (ConsoleOutputHook h);
typedef void (*acrch) (CRCHook h);
typedef void (*adh) (DataHook h);
typedef void (*srt) (GameObject *obj,const char *texture);
typedef void (*sfc) (unsigned int red, unsigned int green, unsigned int blue);
typedef void (*sfcp) (GameObject *obj,unsigned int red, unsigned int green, unsigned int blue);
typedef void (*sfm) (unsigned int mode);
typedef void (*sfmp) (GameObject *obj,unsigned int mode);
typedef void (*sfd) (float density);
typedef void (*sfdp) (GameObject *obj,float density);
typedef void (*ctr) (float time);
typedef void (*ctl) (int time);
typedef void (*dps) (GameObject *obj);
#ifndef BHS
extern ach AddChatHook;
extern ahh AddHostHook;
extern ss Set_Scope;
extern sh Set_HUD_Texture;
extern aoch AddObjectCreateHook;
extern roch RemoveObjectCreateHook;
extern akh AddKeyHook;
extern rkh RemoveKeyHook;
extern gcmt GetCurrentMusicTrack;
extern gbhsv GetBHSVersion;
extern allh AddLoadLevelHook;
extern allh AddGameOverHook;
extern apjh AddPlayerJoinHook;
extern aph AddPowerupPurchaseHook;
extern aph AddVehiclePurchaseHook;
extern aph AddCharacterPurchaseHook;
extern apmh AddPowerupPurchaseMonHook;
extern apmh AddVehiclePurchaseMonHook;
extern apmh AddCharacterPurchaseMonHook;
extern rph RemovePowerupPurchaseHook;
extern rph RemoveVehiclePurchaseHook;
extern rph RemoveCharacterPurchaseHook;
extern rph RemovePowerupPurchaseMonHook;
extern rph RemoveVehiclePurchaseMonHook;
extern rph RemoveCharacterPurchaseMonHook;
extern sit Set_Info_Texture;
extern cit Clear_Info_Texture;
extern _Enable_Stealth_Player Enable_Stealth_Player;
extern _Set_Fog_Enable_Player Set_Fog_Enable_Player;
extern _Set_Fog_Range_Player Set_Fog_Range_Player;
extern _Set_Background_Music_Player Set_Background_Music_Player;
extern _Fade_Background_Music_Player Fade_Background_Music_Player;
extern _Stop_Background_Music_Player Stop_Background_Music_Player;
extern _Enable_Radar_Player Enable_Radar_Player;
extern _Display_GDI_Player_Terminal_Player Display_GDI_Player_Terminal_Player;
extern _Display_NOD_Player_Terminal_Player Display_NOD_Player_Terminal_Player;
extern _Set_Screen_Fade_Color_Player Set_Screen_Fade_Color_Player;
extern _Set_Screen_Fade_Opacity_Player Set_Screen_Fade_Opacity_Player;
extern _Force_Camera_Look_Player Force_Camera_Look_Player;
extern _Enable_HUD_Player Enable_HUD_Player;
extern _Create_Sound_Player Create_Sound_Player;
extern _Create_2D_Sound_Player Create_2D_Sound_Player;
extern _Create_2D_WAV_Sound_Player Create_2D_WAV_Sound_Player;
extern _Create_3D_WAV_Sound_At_Bone_Player Create_3D_WAV_Sound_At_Bone_Player;
extern _Create_3D_Sound_At_Bone_Player Create_3D_Sound_At_Bone_Player;
extern _Set_Display_Color_Player Set_Display_Color_Player;
extern _Display_Text_Player Display_Text_Player;
extern _Display_Int_Player Display_Int_Player;
extern _Display_Float_Player Display_Float_Player;
extern _Set_Obj_Radar_Blip_Shape_Player Set_Obj_Radar_Blip_Shape_Player;
extern _Set_Obj_Radar_Blip_Color_Player Set_Obj_Radar_Blip_Color_Player;
extern svl Set_Vehicle_Limit;
extern gvl Get_Vehicle_Limit;
extern sm Send_Message;
extern smp Send_Message_Player;
extern avh AddVersionHook;
extern sw Set_Wireframe_Mode;
extern lnhi Load_New_HUD_INI;
extern rw Remove_Weapon;
extern upd Update_PT_Data;
extern crm Change_Radar_Map;
extern gbm Get_Build_Time_Multiplier;
extern scb Set_Currently_Building;
extern icb Is_Currently_Building;
extern acoh AddConsoleOutputHook;
extern acrch AddCRCHook;
extern adh AddDataHook;
extern srt Set_Reticle_Texture1;
extern srt Set_Reticle_Texture2;
extern sfc Set_Fog_Color;
extern sfcp Set_Fog_Color_Player;
extern sfm Set_Fog_Mode;
extern sfmp Set_Fog_Mode_Player;
extern sfd Set_Fog_Density;
extern sfdp Set_Fog_Density_Player;
extern ctr Change_Time_Remaining;
extern ctl Change_Time_Limit;
extern dps Display_GDI_Sidebar;
extern dps Display_NOD_Sidebar;
#endif

#ifndef BHS
class JFW_Key_Hook_Base : public ScriptImpClass {
public:
	KeyHookStruct *k;
	int hookid;
	int is_keyhook_set;
	void Detach(GameObject *obj);
	void Destroyed(GameObject *obj);
	void InstallHook(const char *keyname,GameObject *obj);
	void RemoveHook();
	virtual void KeyHook() = 0;
};

class JFW_Object_Created_Hook_Base : public ScriptImpClass {
public:
	int hookid;
	int is_objecthook_set;
	ObjectCreateHookStruct *h;
	void Detach(GameObject *obj);
	void Created(GameObject *obj);
	void InstallHook();
	void RemoveHook();
	virtual void ObjectCreateHook(GameObject *obj) = 0;
};
#endif

extern int Exe; //0 = game.exe,1 = server.dat,2 = RH73 LFDS,3 = RH8 LFDS,4 = leveledit,6 = invalid
void InitEngine(); //initalize pointers to engine functions
GameObject *Get_GameObj(int PlayerID); //convert a player ID into a GameObject
long Get_Player_ID(GameObject *obj); //convert a GameObject into a player ID
const char *Get_Model(GameObject *obj); //get the name of the 3d model used by an object,opposite of Set_Model
int Get_Object_Type(GameObject *obj); //get the team of an object,0 = Nod,1 = GDI,2 = neutral,works on buildings
void Set_Object_Type(GameObject *obj,int type); //set the team of an object,0 = Nod,1 = GDI,2 = neutral,works on buildings
bool Change_Character(GameObject *obj,const char *Preset_Name); //will change the character of the passed in object to the passed in preset
const char *Get_Player_Name(GameObject *obj); //converts a GameObject into a player name
GameObject *Find_Building_By_Team(int Team); //finds the first building of this team,0 = Nod,1 = GDI
GameObject *Find_Building_By_Name(int Team,const char *Preset_Name); //finds the first building of team where preset name matches name,0 = Nod,1 = GDI
void Kill_All_Buildings_By_Team(int Team); //kill all buildings of the specified team,ending the game with the other team winning,0 = Nod,1 = GDI
void Damage_All_Buildings_By_Team(int Team,float Damage,const char *Warhead,GameObject *Damager); //damages all buildings of the specified team,the Damager is the object that will be passed to the Damaged callback for the buildings and also the one that will get the points,0 = Nod,1 = GDI,2 = both
void Repair_All_Buildings_By_Team(int Team,int ConstructionYardID,float Health); //repairs all buildings for the team except the passed in ConstructionYardID,0 = Nod,1 = GDI
void Repair_All_Static_Vehicles_By_Team(int Team,int Message); //sends a custom to all vechicles of the team with the DecorationPhys physics type (i.e. all base defence vechicles etc),0 = Nod,1 = GDI,Message is the message to send. Use with JFW_Repair_On_Custom on the vechicles you want repaired to do the actual repairing
GameObject *Find_Smart_Object_By_Team(int Team); //will find the first SmartGameObj (i.e. soldier or vechicle) for the team,0 = Nod,1 = GDI
GameObject *Find_Object_By_Team(int Team); //will find the first object for the team,0 = Nod,1 = GDI
GameObject *Find_Non_Player_Object_By_Team(int Team); //will find the first non player object for the team,0 = Nod,1 = GDI
GameObject *Find_Object_By_Preset(int Team,const char *Preset_Name); //will find the first object of team matching preset,0 = Nod,1 = GDI,2 = either
GameObject *Find_Power_Plant(int Team); //finds the first powerplant for Team,0 = Nod,1 = GDI,2 = either
GameObject *Find_Refinery(int Team); //finds the first refinery for Team,0 = Nod,1 = GDI,2 = either
GameObject *Find_Repair_Bay(int Team); //finds the first repair bay for Team,0 = Nod,1 = GDI,2 = either
GameObject *Find_Soldier_Factory(int Team); //finds the first soldier factory for Team,0 = Nod,1 = GDI,2 = either
GameObject *Find_Airstrip(int Team); //finds the first airstrip for Team,0 = Nod,1 = GDI,2 = either
GameObject *Find_War_Factory(int Team); //finds the first war factory for Team,0 = Nod,1 = GDI,2 = either
GameObject *Find_Vehicle_Factory(int Team); //finds the first airstrip for Team,if none is found,finds the first war factory for Team,0 = Nod,1 = GDI,2 = either
GameObject *Find_Com_Center(int Team); //finds the first communications center for Team,0 = Nod,1 = GDI,2 = either
bool Is_Building(GameObject *obj); //is a BuildingGameObj
bool Is_Soldier(GameObject *obj); //is a SoldierGameObj
bool Is_Vehicle(GameObject *obj); //is a VechicleGameObj
bool Is_Cinematic(GameObject *obj); //is a CinematicGameObj
bool Is_ScriptZone(GameObject *obj); //is a ScriptZoneGameObj
void Set_Max_Health(GameObject *obj,float health); //set the max health of obj
void Set_Max_Shield_Strength(GameObject *obj,float shieldstrength); //set the max shield strength of obj
GameObject *Find_First_Player(int Team); //finds the first player of Team,0 = Nod,1 = GDI,2 = either
float Get_Animation_Frame(GameObject *obj); //gets the current animation frame for obj,may not work for all objects
void Grant_Refill(GameObject *obj); //triggers the same code as the refill button on the PT
void Grant_Powerup(GameObject *obj,const char *Preset_Name); //grants a powerup
GameObject *Get_Vehicle(GameObject *obj); //gets the vechicle that obj is driving
const char *Get_Shield_Type(GameObject *obj); //gets the shield type of obj
const char *Get_Skin(GameObject *obj); //gets the skin type of obj
void Set_Skin(GameObject *obj,const char *Skintype); //sets the skin type of obj
void Create_Vehicle(const char *Preset_Name,float Delay,GameObject *Owner,int Team); //creates a vechicle,dont know what Delay is for,Owner is for the owner of the vechicle,Team says which sides factories to create it at
void Toggle_Fly_Mode(GameObject *obj); //makes a soldier fly if they arent flying or not fly if they are
void Console_Input(const char *Input); //triggers console input (i.e. passes the string in as though it was typed into the console)
void Console_Output(const char *Output,...); //prints stuff to the console, works like printf
bool Is_TrackedVehicle(GameObject *obj); //has TrackedVechicle physics
bool Is_VTOLVehicle(GameObject *obj); //has VTOLVechicle physics
bool Is_WheeledVehicle(GameObject *obj); //has WheeledVechicle physics
bool Is_Motorcycle(GameObject *obj); //has Morotcycle physics
bool Is_Door(GameObject *obj); //has Door physics
bool Is_Elevator(GameObject *obj); //has Elevator physics
bool Is_DamageableStaticPhys(GameObject *obj); //has DamageableStaticPhys physics
bool Is_AccessablePhys(GameObject *obj); //has AccessablePhys physics
bool Is_DecorationPhys(GameObject *obj); //has DecorationPhys physics
bool Is_HumanPhys(GameObject *obj); //has HumanPhys physics
bool Is_MotorVehicle(GameObject *obj); //has MotorVehicle physics
bool Is_Phys3(GameObject *obj); //has Phys3 physics
bool Is_RigidBody(GameObject *obj); //has RigidBody physics
bool Is_ShakeableStatricPhys(GameObject *obj); //has ShakeableStaticPhys physics
bool Is_StaticAnimPhys(GameObject *obj); //has StaticAnimPhys physics
bool Is_StaticPhys(GameObject *obj); //has StaticPhys physics
bool Is_TimedDecorationPhys(GameObject *obj); //has TimedDecorationPhys physics
bool Is_VehiclePhys(GameObject *obj); //has VechiclePhys physics
bool Is_DynamicAnimPhys(GameObject *obj); //has DenamicAnimPhys physics
bool Is_BuildingAggregate(GameObject *obj); //has BuildingAggregate physics
bool Is_Projectile(GameObject *obj); //has Projectile physics
const char *Get_Player_Name_By_ID(int PlayerID); //gets the player name from a player ID. Will return NULL if that player doesnt exist.
void Change_Team(GameObject *obj,int Team); //changes the team of a player given their GameObject and also kills the player so they respwan,passing anything other than 0 = Nod,1 = GDI will crash
void Change_Team_By_ID(int PlayerID,int Team); //changes the team of a player given their ID and also kills the player so they respwan,passing anything other than 0 = Nod,1 = GDI will crash
int Get_Player_Count(); //gets the count of how many players there are
bool Is_Powerup(GameObject *obj); //is a PowerUpGameObj
bool Is_C4(GameObject *obj); //is a C4GameObj
bool Is_Beacon(GameObject *obj); //is a BeaconGameObj
bool Is_Armed(GameObject *obj); //is an ArmedGameObj
bool Is_Simple(GameObject *obj); //is a SimpleGameObj
bool Is_PowerPlant(GameObject *obj); //is a PowerPlantGameObj
bool Is_SoldierFactory(GameObject *obj); //is a SoldierFactoryGameObj
bool Is_VehicleFactory(GameObject *obj); //is a VehicleFactoryGameObj
bool Is_Airstrip(GameObject *obj); //is an AirstripGameObj
bool Is_WarFactory(GameObject *obj); //is a WarFactoryGameObj
bool Is_Refinery(GameObject *obj); //is a RefineryGameObj
bool Is_ComCenter(GameObject *obj); //is a ComCenterGameObj
bool Is_RepairBay(GameObject *obj); //is a RepairBayGameObj
void Damage_All_Vehicles_Area(float Damage,const char *Warhead,const Vector3 &Position,float Distance,GameObject *Host,GameObject *Damager); //damages all vechicles in a given area except the host
void Damage_All_Objects_Area(float Damage,const char *Warhead,const Vector3 &Position,float Distance,GameObject *Host,GameObject *Damager); //damages all objects in a given area except the host
int Get_Team_Player_Count(int Team); //gets the count of players for a given team,0 = Nod,1 = GDI)
const char *Get_Physics(GameObject *obj); //returns a string indicating the physics type of an object
const char *Get_Building_Type(GameObject *obj); //returns a string indicating the building type of an object
void Disarm_Nearest_Beacon(GameObject *Host,int Team,bool Nearest); //disarms the nearest beacon
bool Change_Player_Team(GameObject *obj,bool Retain_Score,bool Retain_Money,bool Show_Host_Message); //changes the players team
#ifndef BHS
void Set_Occupants_Fade(GameObject *obj,float red,float green,float blue,float opacity); //sets the screen fade of all the occupants of a vehicle
void Enable_Team_Radar(int Team,bool Enable); //enable radar for a given team
void Create_Sound_Team(const char *soundname,const Vector3 & position,GameObject *obj,int team); //play a 3D sound for a team
void Create_2D_Sound_Team(const char *soundname,int team); //play a 2D sound for a team
void Create_2D_WAV_Sound_Team(const char *soundname,int team); //play a 2D WAV sound for a team
void Create_3D_WAV_Sound_At_Bone_Team(const char *soundname,GameObject *obj,const char *bonename,int team); //play a 3D WAV sound at a bone for a team
void Create_3D_Sound_At_Bone_Team(const char *soundname,GameObject *obj,const char *bonename,int team); //play a 3D sound at a bone for a team
void Set_Display_Color_Team(unsigned char red,unsigned char green,unsigned char blue,int team); //set the display color for a team
void Display_Text_Team(int strnum,int team); //display a text string for a team
void Display_Int_Team(int num,const char *msg,int team); //display a message with an int for a team
void Display_Float_Team(float num,const char *msg,int team); //display a message with a float for a team
void Set_Obj_Radar_Blip_Shape_Team(int Team,GameObject *obj,int shape); //set obj radar blip shape for team
void Set_Obj_Radar_Blip_Color_Team(int Team,GameObject *obj,int color); //set obj radar blip color for team 
void Send_Message_Team(int team,unsigned int red,unsigned int green,unsigned int blue,const char *msg); //send a message to a team
void Send_Message_With_Obj_Color(GameObject *obj,const char *Msg); //send a messages in a given objects color
void Send_Message_With_Team_Color(int Team,const char *Msg); //Send a message in a given teams color
#endif
//these only do damage if the building is close enough
void Ranged_Damage_To_Buildings(float Damage,const char *Warhead,Vector3 Location,float DamageRadius,GameObject *Damager); //damage buildings
void Ranged_Scale_Damage_To_Buildings(float Damage,const char *Warhead,Vector3 Location,float DamageRadius,GameObject *Damager); //damage buildings based on a scale factor
void Ranged_Percentage_Damage_To_Buildings(float Percentage,const char *Warhead,Vector3 Location,float DamageRadius,GameObject *Damager); //damage buildings based on a percentage factor
void Ranged_Damage_To_Buildings_Team(int Team,float Damage,const char *Warhead,Vector3 Location,float DamageRadius,GameObject *Damager); //damage buildings per team
void Ranged_Scale_Damage_To_Buildings_Team(int Team,float Damage,const char *Warhead,Vector3 Location,float DamageRadius,GameObject *Damager); //damage buildings per team based on a scale factor
void Ranged_Percentage_Damage_To_Buildings_Team(int Team,float Percentage,const char *Warhead,Vector3 Location,float DamageRadius,GameObject *Damager); //damage buildings per team based on a percentage factor
void Send_Custom_To_Team_Buildings(int Team,GameObject *sender,int message,int param,float delay); //send custom to team buildings
void Send_Custom_To_Team_Preset(int Team,const char *PresetName,GameObject *sender,int message,int param,float delay); //send custom to team preset
void Remove_Script(GameObject *obj,const char *script); //removes all copies of <script> from an object
void Remove_All_Scripts(GameObject *obj); //removes all scripts from an object
int Get_Vehicle_Occupant_Count(GameObject *obj); //gets the count of occupants in a vehicle
//these next 3 may return NULL (e.g. if no-one is in the seat or if its not a vehicle)
GameObject *Get_Vehicle_Occupant(GameObject *obj,int seat); //gets the occupant in the given seat of the vehicle
GameObject *Get_Vehicle_Driver(GameObject *obj); //gets the driver of a vehicle
GameObject *Get_Vehicle_Gunner(GameObject *obj); //gets the gunner of a vehicle,if there is only one person this should be the driver as well as the gunner
void Attach_Script_Preset(const char *script,const char *params,const char *preset,int team); //attached <script> to all objects of <preset> in team <team>
void Attach_Script_Type(const char *script,const char *params,unsigned long type,int team); //attaches <script> to all objects of <type> in team <team>
void Remove_Script_Preset(const char *script,const char *preset,int team); //removes all copies of <script> from all objects of <preset> in team <team>
void Remove_Script_Type(const char *script,unsigned long type,int team); //removes all copies of <script> from all objects of <type> in team <team>
void Copy_Transform(GameObject *in,GameObject *out); //copies the complete transform (including rotation) from one object to another
const char *Get_Current_Weapon(GameObject *obj); //gets the current weapon of an object
int Get_Weapon_Count(GameObject *obj); //gets the weapon count for an object
const char *Get_Weapon(GameObject *obj,int position); //get the specified position in the weapon bag
bool Has_Weapon(GameObject *obj,const char *weapon); //does the object have the weapon
float Get_Mass(GameObject *obj); //returns the mass of an object
const char *Get_Htree_Name(GameObject *obj); //returns the Hierarchy Tree name for an object
char Get_Sex(GameObject *obj); //gets the character (e.g. "A" for male or "B" for female) for use with animations
void Force_Occupant_Exit(GameObject *obj,int seat); //kick the object in <seat> out of the vehicle,if anyone is in that seat
void Force_Occupants_Exit(GameObject *obj); //kick all occupants out of the vehicle
void Damage_Objects_Half(); //damage all objects by half
GameObject *Get_Vehicle_Return(GameObject *obj); //like Get_Vehicle but will return the soldier if its not inside a vehicle instead of NULL
GameObject *Find_Beacon(int Number,int Team); //find a beacon
int Get_C4_Count(int Team); //get the C4 count
int Get_Beacon_Count(int Team); //get the beacon count
cGameData *The_Game(); //get the cGameData
cGameDataSkirmish *The_Skirmish_Game(); //get the cGameDataSkirmish
cGameDataCnc *The_Cnc_Game(); //get the cGameDataCnc
cGameDataSinglePlayer *The_Single_Player_Game(); //get the cGameDataSinglePlayer
bool Is_Script_Attached(GameObject *obj,const char *script); //is the script attached
void Attach_Script_Once(GameObject *obj,const char *script,const char *params); //attach a script if its not already attached
void Attach_Script_Preset_Once(const char *script,const char *params,const char *preset,int team); //attach a script to all objects of preset if its not already attached
void Attach_Script_Type_Once(const char *script,const char *params,unsigned long type,int team); //attach a script to all objects of type if its not already attached
void Attach_Script_Building(const char *script,const char *params,int team); //attach a script to all buildings
void Attach_Script_Is_Preset(GameObject *obj,const char *preset,const char *script,const char *params,int team); //attach the script if object is of preset
void Attach_Script_Is_Type(GameObject *obj,unsigned long type,const char *script,const char *params,int team); //attach the script if object is of type
void Attach_Script_Player_Once(const char *script,const char *params,int team); //attach a script to all players if its not already attached
bool Is_A_Building(GameObject *obj); //is this object any building type
GameObject *Find_Closest_Non_Building_Object_By_Team(int Team,Vector3 position); //find the closest non building object to position
bool Is_Stealth(GameObject *obj); //is this object stealth
bool Get_Fly_Mode(GameObject *obj); //is this infantry flying via Set_Fly_Mode
void Send_Custom_All_Objects_Area(int message,const Vector3 &Position,float Distance,GameObject *sender,int team); //sends a custom to all objects in a given area
void Create_Effect_All_Stealthed_Objects_Area(const Vector3 &Position,float Distance,const char *object,const Vector3 &offset,int team); //creates an indicator object near every stealthed object in a given area
void Send_Custom_All_Objects(int message,GameObject *sender,int team); //sends a custom to all objects
void Kill_Occupants(GameObject *obj); //kill all the occupants of a vehicle
int Tally_Team_Size(int team); //gets the team size for a team
float Get_Team_Score(int team); //gets the score for a team (same as Game_Info uses)
const char *Get_IP_Address(int PlayerID); //gets the IP address for a player as a string in 1.2.3.4 format
char Get_Mine_Limit(); //gets the current mine limit (use the MLIMIT console command to set it)
bool Is_Gameplay_Permitted(); //is gameplay permitted
unsigned long Get_Ping(int PlayerID); //get the ping of a player
unsigned long Get_Kbits(int PlayerID); //get the Kbits/s of a player
void Remove_Duplicate_Script(GameObject *obj, const char *script); //remove duplicate scripts from an object
void Send_Custom_Event_To_Object(GameObject *sender,const char *Preset,int message,int param,float delay); //this is like Send_Custom_Event except it sends to all objects of the passed in preset
int Get_Vehicle_Seat_Count(GameObject *obj,int seat); //get the seat count for a vehicle
char *Get_Spawn_Char(int Team); //get the spawn character for a team
void Change_Spawn_Char(int Team,const char *Name); //change the spawn character for a team (does not reset after the map ends)
int Get_Building_Count_Team(int Team); //number of buildings a team has that are alive
void Ranged_Percentage_Damage_To_Vehicles(float Percentage,const char *Warhead,Vector3 Location,float DamageRadius,GameObject *Damager); //damage vehicles based on a percentage factor
int Get_Bandwidth(int PlayerID); //Get players current bandwidth (same as set by sbbo)
bool Is_Dedicated(); //returns false if game.exe, true if WFDS/LFDS
void Soldier_Transition_Vehicle(GameObject *obj); //makes the soldier exit the vehicle they are in (or if right next to a vehicle, get in)
bool Is_Linux(); //returns true if linux, false if win32
unsigned int Get_Current_Game_Mode(); //Get the current game mode, 0 = function error, 1 = single player, 2 = skirmish, 3 = WOL, 4 = GameSpy, 5 = LAN. May not always differentiate correctly between WOL, Gamespy and LAN, especially when running as a non-dedicated server.
int Get_Team(int PlayerID); //get the team of a player
int Get_Rank(int PlayerID); //get the rank of a player
int Get_Kills(int PlayerID); //get the kills of a player
int Get_Deaths(int PlayerID); //get the deaths of a player
float Get_Score(int PlayerID); //get the score of a player
float Get_Money(int PlayerID); //get the money of a player
float Get_Kill_To_Death_Ratio(int PlayerID); //get the kill/death ratio of a player
float Get_Damage_Points(GameObject *obj); //get the damage points for an object
float Get_Death_Points(GameObject *obj); //get the death points for an object
int Get_C4_Mode(GameObject *obj); //get the C4 mode for a C4GameObj, 1 = remote, 2 = timed, 3 = proximity, anything else is invalid
const char *Get_IP_Port(int PlayerID); //gets the IP address and port for a player as a string in 1.2.3.4;5 format
bool Is_Scriptable(GameObject *obj); //is a ScriptableGameObj
void Set_Damage_Points(GameObject *obj,float points); //Set the damage points for an object
void Set_Death_Points(GameObject *obj,float points); //Set the death points for an object
void Repair_All_Buildings_By_Team_Radius(int Team,int ConstructionYardID,float Health,float Radius); //repairs all buildings in the specified radius around the object represented by ConstructionYardID for the team except the passed in ConstructionYardID,0 = Nod,1 = GDI
const char *Get_Translated_String(unsigned long ID); //Get a string from the translation database given its ID
const char *Get_Translated_Preset_Name(GameObject *obj); //Get the translated name for the preset of this object, if it has one
int Get_C4_Count_Proximity(int Team); //Get the proximity C4 count for a team
int Get_C4_Count_Remote(int Team); //Get the remote C4 count for a team
void Attach_Script_All_Buildings_Team(int Team,const char *Script,const char *Params,bool Once); //attach a script to all buildings by team
void Attach_Script_All_Turrets_Team(int Team,const char *Script,const char *Params,bool Once); //attach a script to all static vehicles by team
const char *Get_Translated_Weapon(GameObject *obj,int position); //Get the translated name of a weapon
const char *Get_Current_Translated_Weapon(GameObject *obj); //Get the translated name of the current weapon
GameObject *Get_Part_Name(const char *name1); //Will return the player with this string as part of their name if there is exactly one player with it
int Get_Part_Names(const char *name1); //Will return the count of players with this string as part of their name
GameObject *Find_Base_Defense(int Team); //will find the AGT or the Obelisk, based on what team is sent, 0 = Nod, 1 = GDI
GameObject *Get_C4_Planter(GameObject *obj); //Gets the planter of a C4GameObj
GameObject *Get_C4_Attached(GameObject *obj); //Gets the object a C4GameObj is attached to (if any)
GameObject *Get_Beacon_Planter(GameObject *obj); //Gets the planter of a BeaconGameObj
unsigned int Get_Vehicle_Mode(GameObject *obj); //Gets the mode of a vehicle
//mode values for vehicles
#define CAR 0 //note that this list reflects the list in leveledit
#define TANK 1
#define BIKE 2
#define FLYING 3
#define TURRET 4
void Repair_All_Turrets_By_Team(int team,float health); //repairs all vehicles that have mode = turret
void Get_Team_Color(unsigned int team, unsigned int *red, unsigned int *green, unsigned int *blue); //get color for a team
void Get_Player_Color(int PlayerID, unsigned int *red, unsigned int *green, unsigned int *blue); //get color for a player
void Get_Object_Color(GameObject *obj, unsigned int *red, unsigned int *green, unsigned int *blue); //get color for a player
void Get_Private_Message_Color(unsigned int *red, unsigned int *green, unsigned int *blue); //get color for private messages
void Get_Public_Message_Color(unsigned int *red, unsigned int *green, unsigned int *blue); //get color for public messages
void Disarm_C4(GameObject *obj); //Disarm a C4 object
void Disarm_All_Proxy_C4(int PlayerID); //Disarm all proximity C4 owned by a player
void Disarm_All_C4(int PlayerID); //Disarm all C4 owned by a player
int Get_Team_Vehicle_Count(int team); //Gets the current vehicle count for a team
bool Is_Base_Powered(int team); //Is this teams base powered
bool Can_Generate_Vehicles(int team); //Can this team buy vehicles
bool Can_Generate_Soliders(int team); //Can this team buy soldiers
void Damage_Occupants(GameObject *obj,float Damage,const char *Warhead); //Damage all the occupants of a vehicle
int Get_Current_Bullets(GameObject *obj); //Get loaded bullets for an objects current gun
int Get_Current_Clip_Bullets(GameObject *obj); //Get clip/backpack bullets for an objects current gun
int Get_Current_Total_Bullets(GameObject *obj); //Get total bullets for an objects current gun
int Get_Total_Bullets(GameObject *obj,const char *weapon); //Get total bullets for a specific gun (if the object doesnt have the gun, return is zero)
int Get_Clip_Bullets(GameObject *obj,const char *weapon); //Get clip/backpack bullets bullets for a specific gun (if the object doesnt have the gun, return is zero)
int Get_Bullets(GameObject *obj,const char *weapon); //Get loaded bullets bullets for a specific gun (if the object doesnt have the gun, return is zero)
int Get_Current_Max_Bullets(GameObject *obj); //Get max loaded bullets for an objects current gun
int Get_Current_Clip_Max_Bullets(GameObject *obj); //Get max clip/backpack bullets for an objects current gun
int Get_Current_Total_Max_Bullets(GameObject *obj); //Get total bullets for an objects current gun
int Get_Max_Total_Bullets(GameObject *obj,const char *weapon); //Get max total bullets for a specific gun (if the object doesnt have the gun, return is zero)
int Get_Max_Clip_Bullets(GameObject *obj,const char *weapon); //Get max clip/backpack bullets bullets for a specific gun (if the object doesnt have the gun, return is zero)
int Get_Max_Bullets(GameObject *obj,const char *weapon); //Get max loaded bullets bullets for a specific gun (if the object doesnt have the gun, return is zero)
int Get_Position_Total_Bullets(GameObject *obj, int position); //Get total bullets for an objects gun at a specific position
int Get_Position_Bullets(GameObject *obj,int position); //Get loaded bullets for an objects gun at a specific position
int Get_Position_Clip_Bullets(GameObject *obj,int position); //Get clip/backpack bullets for an objects gun at a specific position
int Get_Position_Total_Max_Bullets(GameObject *obj, int position); //Get total bullets for an objects gun at a specific position
int Get_Position_Max_Bullets(GameObject *obj,int position); //Get loaded bullets for an objects gun at a specific position
int Get_Position_Clip_Max_Bullets(GameObject *obj,int position); //Get clip/backpack bullets for an objects gun at a specific position
void Set_Current_Bullets(GameObject *obj,int bullets); //Set current loaded bullets for an object
void Set_Current_Clip_Bullets(GameObject *obj,int bullets); //Set current clip/backpack bullets for an object
void Set_Position_Bullets(GameObject *obj,int position,int bullets); //Set position loaded bullets for an object
void Set_Position_Clip_Bullets(GameObject *obj,int position,int bullets); //Set position clip/backpack bullets for an object
void Set_Bullets(GameObject *obj,const char *weapon,int bullets); //Set loaded bullets for an object
void Set_Clip_Bullets(GameObject *obj,const char *weapon,int bullets); //Set clip/backpack bullets for an object
//For all of these, -1 means "infinate ammo"
const char *Get_Team_Name(int Team); //Get a teams name
const char *Get_Vehicle_Name(GameObject *obj); //Get the name of a vehicle (as used for the HUD display)
INIClass *Get_INI(char const *filename); //Open an INI file and read stuff from it
void Release_INI(INIClass *ini); //Close an INI file
void Disarm_Beacon(GameObject *obj); //Disarm a beacon
void Disarm_Beacons(int PlayerID); //Disarm all beacons for a player
GameObject *Find_Harvester(int team); //Find this teams current harvester, if any
int GetMaxPlayerID(); //Get the maximum currently used player ID
const char *Get_Powerup_Weapon(const char *Powerup); //Get the weapon name that a powerup will grant if collected
GameObject *Get_Vehicle_Owner(GameObject *obj); //Gets the owner (if any) of a vehicle. Will not work if used within the first second after the ::Created event is called
TeamPurchaseSettingsDefClass *Get_Team_Purchase_Definition(unsigned long team); //Gets the TeamPurchaseSettingsDefClass for a team
PurchaseSettingsDefClass *Get_Purchase_Definition(unsigned long type, unsigned long team); //Gets the PurchaseSettingsDefClass for a given team and type
//type values for PurchaseSettingsDefClass
#define CHARACTERS 0 //note that this list reflects the list in leveledit
#define VEHICLES 1
#define EQUIPMENT 2
#define SECRETCHARS 3
#define SECRETVEHICLES 4
const char *Get_Definition_Name(unsigned long id); //Convert a definition/preset ID into a name
unsigned long Get_Definition_ID(const char *name); //Convert a definition/preset name into an ID
unsigned int Get_Team_Cost(const char *preset,unsigned int team); //Get the cost of a preset for a given team. Returns zero if the preset is not found in any of the purchase terminal data or if it is one of the free units.
unsigned int Get_Cost(const char *preset); //Get the cost of a preset. Returns zero if the preset is not found in any of the purchase terminal data or if it is one of the free units.
void Set_Enlisted(unsigned int team, unsigned int position, unsigned int presetid, unsigned int stringid, const char *texture); //Change an enlisted soldier for a team
void Set_Beacon(unsigned int team, unsigned int cost, unsigned int presetid, unsigned int stringid, const char *texture); //Change the beacon for a team
void Set_Refill(unsigned int team, unsigned int stringid, const char *texture); //Change the refill for a team. Setting this to zero or blank does not actually disable refill.
void Set_Preset(unsigned int team, unsigned int type, unsigned int position, unsigned int cost, unsigned int presetid, unsigned int stringid, const char *texture); //Change a preset given a type and team
void Set_Alternate(unsigned int team, unsigned int type, unsigned int position, unsigned int altpos, unsigned int presetid, const char *texture); //Change an alternate given a type and a team
void Force_Occupants_Exit_Team(GameObject *obj,int team); //kick all occupants not of a given team out of the vehicle
void Power_Base(int team,bool powered); //Power a base up or down, correctly handles the doubled build time and costs
void Set_Can_Generate_Soldiers(int team,bool cangenerate); //Sets if soliders are purchasable
void Set_Can_Generate_Vehicles(int team,bool cangenerate); //Sets if vehicles are purchaseable
void Destroy_Base(int team); //Destroys a base completly
void Beacon_Destroyed_Base(int team, bool destroyed); //Sets if a base was destroyed by a beacon in the beacon zone
void Enable_Base_Radar(int team, bool enable); //Enables radar for a base, same thing as the communications center does
bool Is_Harvester(GameObject *obj); //Is this object one of the 2 team AI harvesters?
void Disable_Enlisted(unsigned int team, unsigned int position); //Disable an enlisted soldier
void Disable_Preset(unsigned int team, unsigned int type, unsigned int position); //Disable a preset
GameObject *Get_GameObj_By_Player_Name(const char *name); //get the gameobject of a player given their name
unsigned long Get_Definition_Class_ID(const char *name); //get the class ID of a definition (matches the #defines above)
unsigned int Get_Vehicle_Definition_Mode(const char *preset); //get the mode of a vehicle given its preset name
bool Is_Radar_Enabled(int team); //returns if the radar is enabled
int Building_Type(GameObject *obj); //returns the type of a BuildingGameObj
//type values for building objects
#define NONE -1
#define POWER_PLANT 0 //note that this list reflects the list in leveledit
#define SOLDIER_FACTORY 1
#define VEHICLE_FACTORY 2
#define REFINERY 3
#define COM_CENTER 4
#define REPAIR_BAY 5
#define SHRINE 6
#define HELIPAD 7
#define CONYARD 8
#define BASE_DEFENCE 9
bool Is_Building_Dead(GameObject *obj); //Does the game consider the building dead
GameObject *Find_Building(int team,int type); //Find a building by team and type
GameObject *Find_Base_Defence(int team); //Find base defence for a team
bool Purchase_Item(GameObject *obj,int cost); //Pass a soldier object & a cost to deduct that much money from the soldier. Returns true if the transaction suceeded, false otherwise
bool Is_Map_Flying(); //Is the current map a flying map
GameObject *Find_Closest_Zone(Vector3 &Location,unsigned int Type); //Find the closest zone
//type values for script zones
#define DEFAULT 0 //note that this list reflects the list in leveledit
#define CTF 1 
#define VEHICLE_CONSTRUCTION 2
#define VEHICLE_REPAIR 3
#define TIBERIUM 4
#define BEACON 5
#define GDITIBERIUM 6
#define NODTIBERIUM 7
bool IsInsideZone(GameObject *zone,GameObject *obj); //is <solder/vehicle> inside <zone>. Wont work if object is inside a zone when its created (e.g. spawns inside zone or zone is moved around them with Create_Zone or Set_Zone_Box)
bool Can_Team_Build_Vehicle(int Team); //Can this team build vehicles
GameObject *Find_Closest_Preset_By_Team(int Team,const Vector3 &pos,const char *Preset); //Find the closest object of this preset to this position
GameObject *Find_Random_Preset_By_Team(int Team,const char *Preset); //Find a random object on this team with this preset
void Disable_All_Ground_Vehicles(unsigned int team); //Removes all ground vehicles from this teams PT menu
void Disable_All_Flying_Vehicles(unsigned int team); //Removes all flying vehicles from this teams PT menu
int Get_Object_Count(int Team,const char *Preset); //Get the number of objects that exist with this preset
bool Is_Valid_Preset_ID(unsigned long ID); //Is this a valid preset id
bool Is_Valid_Preset(const char *Preset); //Is this a valid preset name
GameObject *Find_Building_With_Script(int Team,int Type,const char *Script,GameObject *Caller); //Find a building of this type with this script attached to it
unsigned int Get_Vehicle_Definition_Mode_By_ID(unsigned long ID); //Get the mode of a vehicle given its preset ID
SimpleDynVecClass<GameObject*> Get_All_Objects_By_Preset(int Team,const char *Preset); //Returns an array of all objects of this preset
void Damage_All_Objects_In_Zone(GameObject *Zone,float Damage,const char *Warhead,GameObject *Damager); //Damages all objects in this zone
#define PTTEAM(t) (t?0:1) //Convert a normal team into a PT team
GameObject *Create_Building(const char *preset,const Vector3 & Position); //Create a building controller
unsigned int Get_Zone_Type(GameObject *obj); //Get the type of a script zone
OBBoxClass *Get_Zone_Box(GameObject *obj); //Get the box (size/position) of a ScriptZoneGameObj
void Set_Zone_Box(GameObject *obj,const OBBoxClass &box); //Set the box (size/position) of a ScriptZoneGameObj
GameObject *Create_Zone(const char *preset,const OBBoxClass &box); //Create a script zone and set its box
void Set_Money(int PlayerID,float amount); //Set the money of a player
void Set_Score(int PlayerID,float amount); //Set the score of a player
bool PointInZone(GameObject *obj,const Vector3 &v); //Is a point in a zone
unsigned int Overlap_Test(const OBBoxClass &box,const Vector3 &v); //Test if a vector is inside an OBBoxClass
wchar_t *newwcs(const wchar_t *str); //duplicate a wide character string
/***** The following were implemented by bond5820 *****/
class C4_Detonation : public ScriptImpClass {
	void Destroyed(GameObject *obj);
	void Created(GameObject *obj);
};
GameObject *Find_Closest_Object_To_Pos(Vector3 position); //finds the closest object to the position
GameObject *Find_Closest_Building_To_Pos_By_Team(Vector3 position, int team); //finds the closest building of that team
GameObject *Find_Closest_Object_To_Pos_By_Preset(Vector3 position, const char *Name); //finds the closest to the position with the specified preset name
float Get_Distance(Vector3 p2, Vector3 p); //returns the distance between two positions
void Destroy_All_Objects_By_Preset(const char *Preset_Name); //destroys all objects with the specified preset
void Destroy_Duplicate_Objects_In_A_Position(GameObject *obj); //destroys objects that are in the same position as the specified object
void Say_Nearest_Objects_To_Pos(Vector3 p); //Messages the server with the preset names of objects with the same 'X' position as the specified position.
void Disable_Radar(GameObject *obj); //doesn't work
void List_RGHP_Users(); //doesn't work
void Track_New_C4_Proxy(); //attaches "Proximity_C4" to all proxies (for team proxy destruction)
void Track_New_Beacons(); //attaches "BeaconRepair" to all beacons (for team beacon repair)
void Drop_All_Weapons(GameObject *obj); //Drops all of a players weapons where they stand.
void Drop_All_Weapons2(GameObject *obj); //Drops all of a players weapons where they stand, doesn't destroy them instantly
void All_Weps(GameObject *o); //Gives a player every weapon
void Destroy_Invalids(const char *Preset, Vector3 p, GameObject *obj); //Destroys default weapons so they are not transferred
void Destroy_Invalid_Bots(); //Destroys all bots without "Destroy_Bot" script attached to them.