diff -uwr sourceold/AntiSpawnKill/AntiSpawnKill.vcxproj source/AntiSpawnKill/AntiSpawnKill.vcxproj
--- sourceold/AntiSpawnKill/AntiSpawnKill.vcxproj	2011-11-26 13:17:17.329101500 +0800
+++ source/AntiSpawnKill/AntiSpawnKill.vcxproj	2012-05-28 13:38:14.127546900 +0800
@@ -153,7 +153,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
diff -uwr sourceold/CTF/CTF.cpp source/CTF/CTF.cpp
--- sourceold/CTF/CTF.cpp	2012-01-11 22:13:42.196289000 +0800
+++ source/CTF/CTF.cpp	2012-04-14 04:09:52.823242100 +0800
@@ -281,7 +281,7 @@
 		GameObject *Flag = Commands->Create_Object(mapConfiguration.CTFFlagPreset,FlagLoc);
 		Commands->Set_Player_Type(Flag,Team);
 		Commands->Set_Model(Flag,mapConfiguration.CTFFlagModel[Team]);
-		Commands->Attach_Script(Flag,"MDB_SSGM_CTF_Flag","");
+		Commands->Attach_Script(Flag,"SSGM_CTF_Flag","");
 		Commands->Attach_Script(Flag,"KAK_Prevent_Kill","");
 		Set_Flag_Location(Team,1);
 		return Flag;
@@ -452,6 +452,7 @@
 				tmp.Format("ppage %d %s Flag Captures: %d/%d - %s Flag Captures: %d/%d",PlayerID,str,CTFCaps[0],mapConfiguration.CTFCapLimit,str2,CTFCaps[1],mapConfiguration.CTFCapLimit);
 				delete[] str;
 				delete[] str2;
+				Console_Input(tmp);
 				return false;
 			}
 			if (wcsistr(Message,L"!flag") == Message)
diff -uwr sourceold/CTF/ctf.vcxproj source/CTF/ctf.vcxproj
--- sourceold/CTF/ctf.vcxproj	2011-11-26 13:17:40.789062500 +0800
+++ source/CTF/ctf.vcxproj	2012-05-28 13:38:15.341414100 +0800
@@ -153,7 +153,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
diff -uwr sourceold/CharacterRefund/CharacterRefund.vcxproj source/CharacterRefund/CharacterRefund.vcxproj
--- sourceold/CharacterRefund/CharacterRefund.vcxproj	2011-11-26 13:17:53.663085900 +0800
+++ source/CharacterRefund/CharacterRefund.vcxproj	2012-05-28 13:38:15.684187600 +0800
@@ -153,7 +153,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
diff -uwr sourceold/ExtraConsoleCommands/ExtraConsoleCommands.vcxproj source/ExtraConsoleCommands/ExtraConsoleCommands.vcxproj
--- sourceold/ExtraConsoleCommands/ExtraConsoleCommands.vcxproj	2011-11-26 13:17:47.099609300 +0800
+++ source/ExtraConsoleCommands/ExtraConsoleCommands.vcxproj	2012-05-28 13:38:15.609968800 +0800
@@ -153,7 +153,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
diff -uwr sourceold/FirstBlood/FirstBlood.vcxproj source/FirstBlood/FirstBlood.vcxproj
--- sourceold/FirstBlood/FirstBlood.vcxproj	2011-11-26 13:17:33.343750000 +0800
+++ source/FirstBlood/FirstBlood.vcxproj	2012-05-28 13:38:14.959578200 +0800
@@ -153,7 +153,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
diff -uwr sourceold/MemoryManager/MemTracker.cpp source/MemoryManager/MemTracker.cpp
--- sourceold/MemoryManager/MemTracker.cpp	2011-10-11 21:35:07.162109300 +0800
+++ source/MemoryManager/MemTracker.cpp	2012-04-17 17:41:01.289062500 +0800
@@ -17,6 +17,7 @@
 #include <MMSystem.h>
 #pragma warning (disable:6387)
 #include <shlobj.h>
+#include <shlwapi.h>
 #pragma warning (default:6387)
 #pragma comment(lib, "winmm.lib")
 #include "FastAllocator.h"
@@ -59,10 +60,13 @@
 	char path_to_exe[256];
 	GetModuleFileNameA(NULL, path_to_exe, sizeof(path_to_exe));
 	strrchr(path_to_exe,'\\')[0] = 0;
+	SetCurrentDirectoryA(path_to_exe);
 	strcat(path_to_exe,"\\");
 	strcat(path_to_exe,LEAK_LOG_DIR);
+	if (!PathFileExistsA(path_to_exe))
+	{
 	SHCreateDirectoryExA(NULL,path_to_exe,NULL);
-
+	}
 	FILE* leakLogFile = fopen(LEAK_LOG_DIR "\\leaks.txt", "wb");
 	if (!leakLogFile)
 		OutputDebugStringA("Failed to write to " LEAK_LOG_DIR "\\leaks.txt");
diff -uwr sourceold/MemoryManager/MemoryManager.vcxproj source/MemoryManager/MemoryManager.vcxproj
--- sourceold/MemoryManager/MemoryManager.vcxproj	2011-11-26 13:17:56.498046800 +0800
+++ source/MemoryManager/MemoryManager.vcxproj	2012-05-28 13:38:16.140242300 +0800
@@ -61,7 +61,7 @@
       <StringPooling>true</StringPooling>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <PrecompiledHeader>
       </PrecompiledHeader>
       <AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
@@ -78,6 +78,7 @@
       <SubSystem>Windows</SubSystem>
       <TargetMachine>MachineX86</TargetMachine>
       <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
+      <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <PostBuildEvent>
       <Command>if defined RenPath (
@@ -130,6 +131,7 @@
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <TargetMachine>MachineX86</TargetMachine>
       <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
+      <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <PostBuildEvent>
       <Command>if defined RenPath (
diff -uwr sourceold/Mute/Mute.cpp source/Mute/Mute.cpp
--- sourceold/Mute/Mute.cpp	2012-01-11 22:15:17.976562500 +0800
+++ source/Mute/Mute.cpp	2012-04-09 23:34:39.794921800 +0800
@@ -148,7 +148,7 @@
 		}
 	}
 
-	virtual bool OnRadioCommand(int PlayerType, int PlayerID, int AnnouncementID, int IconID, uint8 AnnouncementType)
+	virtual bool OnRadioCommand(int PlayerType, int PlayerID, int AnnouncementID, int IconID, AnnouncementEnum AnnouncementType)
 	{
 		if(MutedPlayers[PlayerID] == false)
 		{
diff -uwr sourceold/Mute/Mute.vcxproj source/Mute/Mute.vcxproj
--- sourceold/Mute/Mute.vcxproj	2011-11-26 13:18:02.164062500 +0800
+++ source/Mute/Mute.vcxproj	2012-05-28 13:38:16.400984400 +0800
@@ -153,7 +153,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
diff -uwr sourceold/NoPoints/NoPoints.vcxproj source/NoPoints/NoPoints.vcxproj
--- sourceold/NoPoints/NoPoints.vcxproj	2011-11-26 13:17:34.499023400 +0800
+++ source/NoPoints/NoPoints.vcxproj	2012-05-28 13:38:15.014265700 +0800
@@ -153,7 +153,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
diff -uwr sourceold/PointsDistribution/PointsDistribution.cpp source/PointsDistribution/PointsDistribution.cpp
--- sourceold/PointsDistribution/PointsDistribution.cpp	2012-01-11 22:20:50.635742100 +0800
+++ source/PointsDistribution/PointsDistribution.cpp	2012-04-24 13:45:18.509765600 +0800
@@ -14,6 +14,7 @@
 #include "DamagePoints.h"
 #include "gmgame.h"
 #include "Iterator.h"
+#include "SoldierGameObj.h"
 
 void* HookupAT3x(void* a, void* b, void* c, void* patch_start, void* patch_end, int (*version_selector)())
 {
@@ -49,23 +50,23 @@
 
 	virtual void OnObjectCreate(void *data,GameObject *obj)
 	{
-		if(Is_Soldier(obj) && EnabledForInfantry == true)
+		if (obj->As_SoldierGameObj() && EnabledForInfantry == true)
 		{
 			Attach_Script_Once(obj,"CollectDamage","");
 		}
-		else if (Is_Vehicle(obj) && EnabledForVehicles == true) 
+		else if (obj->As_VehicleGameObj() && EnabledForVehicles == true) 
 		{
 			Attach_Script_Once(obj,"CollectDamage","");
 		}
-		else if (Is_Beacon(obj) && EnabledForBeacons == true) 
+		else if (obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->As_BeaconGameObj() && EnabledForBeacons == true) 
 		{
 			Attach_Script_Once(obj,"CollectDamage","");
 		}
-		else if (Is_C4(obj) && EnabledForC4 == true) 
+		else if (obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->As_C4GameObj() && EnabledForC4 == true) 
 		{
 			Attach_Script_Once(obj,"CollectDamage","");
 		}
-		else if(Is_Building(obj) && EnabledForBuildings == true)
+		else if(obj->As_BuildingGameObj() && EnabledForBuildings == true)
 		{
 			Attach_Script_Once(obj,"CollectDamage","");
 		}
diff -uwr sourceold/PointsDistribution/PointsDistribution.vcxproj source/PointsDistribution/PointsDistribution.vcxproj
--- sourceold/PointsDistribution/PointsDistribution.vcxproj	2011-11-26 13:17:39.563476500 +0800
+++ source/PointsDistribution/PointsDistribution.vcxproj	2012-05-28 13:38:15.275007900 +0800
@@ -153,7 +153,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
diff -uwr sourceold/Spectate/Spectate.cpp source/Spectate/Spectate.cpp
--- sourceold/Spectate/Spectate.cpp	2012-01-11 22:21:06.802734300 +0800
+++ source/Spectate/Spectate.cpp	2012-05-02 14:15:37.150390600 +0800
@@ -16,6 +16,7 @@
 #include "CommandLineParser.h"
 #include "engine_tt.h"
 #include "SoldierGameObj.h"
+#include "VehicleGameObj.h"
 #include "WeaponBagClass.h"
 #include "engine_weap.h"
 #include "engine_obj2.h"
@@ -145,10 +146,15 @@
 
 void Spectate(GameObject *obj,int id)
 {
-	int team = Get_Team(Get_Player_ID(obj));
+	SoldierGameObj *soldier = obj->As_SoldierGameObj();
+	int team = soldier->Get_Player_Type();
 	if(team != -4)
 	{
-		SoldierGameObj *soldier = obj->As_SoldierGameObj();
+		if (soldier->Get_Vehicle())
+		{
+			Console_Output("Can't enable spectate mode when in a vehicle\n");
+			return;
+		}
 		if (!Get_Fly_Mode(soldier))
 		{
 			Toggle_Fly_Mode(soldier);
@@ -161,10 +167,6 @@
 		Commands->Set_Is_Rendered(soldier,false);
 		Commands->Set_Shield_Type(soldier,"Blamo");
 		Disarm_All_C4_Beacons(id);
-		if (soldier->Get_Vehicle())
-		{
-			Soldier_Transition_Vehicle(soldier);
-		}
 		for (SLNode<cPlayer>* PlayerIter = Get_Player_List()->Head(); (PlayerIter != NULL); PlayerIter = PlayerIter->Next())
 		{
 			cPlayer *p = PlayerIter->Data();
diff -uwr sourceold/Spectate/Spectate.vcxproj source/Spectate/Spectate.vcxproj
--- sourceold/Spectate/Spectate.vcxproj	2011-11-26 13:17:57.673828100 +0800
+++ source/Spectate/Spectate.vcxproj	2012-05-28 13:38:16.221296900 +0800
@@ -153,7 +153,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
diff -uwr sourceold/SuddenDeath/SuddenDeath.cpp source/SuddenDeath/SuddenDeath.cpp
--- sourceold/SuddenDeath/SuddenDeath.cpp	2012-01-11 22:16:29.383789000 +0800
+++ source/SuddenDeath/SuddenDeath.cpp	2012-04-24 13:46:41.072265600 +0800
@@ -16,6 +16,7 @@
 #include "CommandLineParser.h"
 #include "GameObjManager.h"
 #include "VehicleGameObj.h"
+#include "BuildingGameObj.h"
 #include "engine_tt.h"
 
 void* HookupAT3x(void* a, void* b, void* c, void* patch_start, void* patch_end, int (*version_selector)())
@@ -178,7 +179,7 @@
 	while (x)
 	{
 		GameObject *o = (GameObject *)x->Data();
-		if (o && Is_Building(o))
+		if (o && o->As_BuildingGameObj())
 		{
 			Commands->Attach_Script(o, "SuddenDeathBuilding", "");
 		}
@@ -204,7 +205,7 @@
 	}
 	if(The_Game()->Get_Game_Duration_S() <= 300) //If it less than 5 minutes into the game.
 	{
-		if(Is_Refinery(obj))
+		if(obj->As_BuildingGameObj() && obj->As_BuildingGameObj()->As_RefineryGameObj())
 		{
 			if(suddendeath.ActivateOnRefs == true)
 			{
diff -uwr sourceold/SuddenDeath/SuddenDeath.vcxproj source/SuddenDeath/SuddenDeath.vcxproj
--- sourceold/SuddenDeath/SuddenDeath.vcxproj	2011-11-26 13:17:24.999023400 +0800
+++ source/SuddenDeath/SuddenDeath.vcxproj	2012-05-28 13:38:14.452742300 +0800
@@ -153,7 +153,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
diff -uwr sourceold/bansystem/bansystem.vcxproj source/bansystem/bansystem.vcxproj
--- sourceold/bansystem/bansystem.vcxproj	2011-11-26 13:17:30.898437500 +0800
+++ source/bansystem/bansystem.vcxproj	2012-05-28 13:38:14.879500100 +0800
@@ -153,7 +153,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
Only in source/bin/Debug: debug
Binary files sourceold/bin/Debug/shaders.lib and source/bin/Debug/shaders.lib differ
Only in source/bin: Debug SSGM
Binary files sourceold/bin/Release/shaders.lib and source/bin/Release/shaders.lib differ
Only in source/bin: Release SSGM
diff -uwr sourceold/crates/crates.cpp source/crates/crates.cpp
--- sourceold/crates/crates.cpp	2012-01-11 22:29:04.188476500 +0800
+++ source/crates/crates.cpp	2012-04-24 13:41:43.463867100 +0800
@@ -123,16 +123,16 @@
 		mapConfiguration = globalConfiguration;
 		const StringClass key = StringClass(The_Game()->Get_Map_Name()).AsLower() + "_Crates";
 		LoadGenericINISettings(SSGMIni, key, mapConfiguration);
-		mapConfiguration.CrateVehSpawnPos[0].X = SSGMIni->Get_Float(key, "NodRVCx", mapConfiguration.CrateVehSpawnPos[0].X);
-		mapConfiguration.CrateVehSpawnPos[0].Y = SSGMIni->Get_Float(key, "NodRVCy", mapConfiguration.CrateVehSpawnPos[0].Y);
-		mapConfiguration.CrateVehSpawnPos[0].Z = SSGMIni->Get_Float(key, "NodRVCz", mapConfiguration.CrateVehSpawnPos[0].Z);
-		mapConfiguration.CrateVehSpawnPos[1].X = SSGMIni->Get_Float(key, "GDIRVCx", mapConfiguration.CrateVehSpawnPos[1].X);
-		mapConfiguration.CrateVehSpawnPos[1].Y = SSGMIni->Get_Float(key, "GDIRVCy", mapConfiguration.CrateVehSpawnPos[1].Y);
-		mapConfiguration.CrateVehSpawnPos[1].Z = SSGMIni->Get_Float(key, "GDIRVCz", mapConfiguration.CrateVehSpawnPos[1].Z);
+		mapConfiguration.CrateVehSpawnPos[0].X = SSGMIni->Get_Float(key, "NodRVCX", mapConfiguration.CrateVehSpawnPos[0].X);
+		mapConfiguration.CrateVehSpawnPos[0].Y = SSGMIni->Get_Float(key, "NodRVCY", mapConfiguration.CrateVehSpawnPos[0].Y);
+		mapConfiguration.CrateVehSpawnPos[0].Z = SSGMIni->Get_Float(key, "NodRVCZ", mapConfiguration.CrateVehSpawnPos[0].Z);
+		mapConfiguration.CrateVehSpawnPos[1].X = SSGMIni->Get_Float(key, "GDIRVCX", mapConfiguration.CrateVehSpawnPos[1].X);
+		mapConfiguration.CrateVehSpawnPos[1].Y = SSGMIni->Get_Float(key, "GDIRVCY", mapConfiguration.CrateVehSpawnPos[1].Y);
+		mapConfiguration.CrateVehSpawnPos[1].Z = SSGMIni->Get_Float(key, "GDIRVCZ", mapConfiguration.CrateVehSpawnPos[1].Z);
 	}
 	virtual void OnObjectCreate(void *data,GameObject *obj)
 	{
-		if (Is_Powerup(obj))
+		if (obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->As_PowerUpGameObj())
 		{
 			if (stristr(Commands->Get_Preset_Name(obj),"crate"))
 			{
@@ -420,8 +420,8 @@
 					StringClass cine;
 					cine.Format("%scrate.txt",Commands->Get_Player_Type(sender)	== 0?"Nod":"GDI");
 					Commands->Attach_Script(Temp,"Test_Cinematic",cine);
-					GameObject *veh = Commands->Create_Object(RandomVehicle[Index][3],Vector3(0,0,0));
-					Commands->Send_Custom_Event(Temp,Temp,CUSTOM_EVENT_CINEMATIC_SET_FIRST_SLOT+4,Commands->Get_Preset_ID(veh),0);
+					GameObject *veh = Commands->Create_Object(RandomVehicle[Index][2],Vector3(0,0,0));
+					Commands->Send_Custom_Event(Temp,Temp,CUSTOM_EVENT_CINEMATIC_SET_FIRST_SLOT+4,Commands->Get_ID(veh),0);
 					StringClass msg;
 					const char *str = Get_Team_Name(Team);
 					msg.Format("msg Crate: Looks like %s just got a random vehicle! Go them!",str);
@@ -645,7 +645,7 @@
 					int team = Commands->Get_Player_Type(sender);
 					Commands->Send_Custom_Event(obj,sender,100101,1,1);//enable generating of money on player
 					message2.Format("%ls picked up a Human Silo crate.",Get_Wide_Player_Name(sender));
-					message1.Format("ppage %d [Crate] You got the Human Silo Crate, your entier team will be granted an additional $1 credit a second until you die or change character.",Get_Player_ID(sender));
+					message1.Format("ppage %d [Crate] You got the Human Silo Crate, your entire team will be granted an additional $1 credit a second until you die or change character.",Get_Player_ID(sender));
 					Create_2D_WAV_Sound_Team("m00pc$$_aqob0002i1evag_snd.wav",team);//credits acquired
 					Vector3	pos	= Commands->Get_Position(sender);
 					message3.Format("CRATE;HUMANSILO;;%d;%s;%f;%f;%f;%f;%f;%f;%d", Commands->Get_ID(sender), Commands->Get_Preset_Name(sender), pos.Y,pos.X,pos.Z, Commands->Get_Facing(sender), Commands->Get_Max_Health(sender),Commands->Get_Max_Shield_Strength(sender),Get_Object_Type(sender));
diff -uwr sourceold/crates/crates.vcxproj source/crates/crates.vcxproj
--- sourceold/crates/crates.vcxproj	2011-11-26 13:17:42.841796800 +0800
+++ source/crates/crates.vcxproj	2012-05-28 13:38:15.428328200 +0800
@@ -153,7 +153,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
diff -uwr sourceold/example-plugin/example-plugin.vcxproj source/example-plugin/example-plugin.vcxproj
--- sourceold/example-plugin/example-plugin.vcxproj	2011-11-26 13:17:22.956054600 +0800
+++ source/example-plugin/example-plugin.vcxproj	2012-05-28 13:38:14.331648500 +0800
@@ -65,7 +65,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
diff -uwr sourceold/makemix/general.cpp source/makemix/general.cpp
--- sourceold/makemix/general.cpp	2009-04-12 11:54:00.781250000 +0800
+++ source/makemix/general.cpp	2012-05-02 02:02:33.078125000 +0800
@@ -1 +1,12 @@
+/*	Renegade Scripts.dll
+	Copyright 2011 Tiberian Technologies
+
+	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 "general.h"
diff -uwr sourceold/makemix/general.h source/makemix/general.h
--- sourceold/makemix/general.h	2011-03-08 09:59:47.156250000 +0800
+++ source/makemix/general.h	2012-05-02 02:02:38.716796800 +0800
@@ -1,3 +1,14 @@
+/*	Renegade Scripts.dll
+	Copyright 2011 Tiberian Technologies
+
+	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.
+*/
 #ifndef ACHASH_INCLUDE__GENERAL_H
 #define ACHASH_INCLUDE__GENERAL_H
 #include "Defines.h"
diff -uwr sourceold/makemix/makemix.cpp source/makemix/makemix.cpp
--- sourceold/makemix/makemix.cpp	2011-11-26 13:48:43.054687500 +0800
+++ source/makemix/makemix.cpp	2012-05-02 02:02:43.840820300 +0800
@@ -1,3 +1,14 @@
+/*	Renegade Scripts.dll
+	Copyright 2011 Tiberian Technologies
+
+	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 "General.h"
 #include "MixFileFactoryClass.h"
 #include "SimpleFileFactoryClass.h"
diff -uwr sourceold/makemix/makemix.vcxproj source/makemix/makemix.vcxproj
--- sourceold/makemix/makemix.vcxproj	2011-11-26 13:17:26.556640600 +0800
+++ source/makemix/makemix.vcxproj	2012-05-28 13:38:14.603132900 +0800
@@ -123,7 +123,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
diff -uwr sourceold/randomstartingcredits/RandomStartingCredits.vcxproj source/randomstartingcredits/RandomStartingCredits.vcxproj
--- sourceold/randomstartingcredits/RandomStartingCredits.vcxproj	2011-11-26 13:17:37.231445300 +0800
+++ source/randomstartingcredits/RandomStartingCredits.vcxproj	2012-05-28 13:38:15.165632900 +0800
@@ -153,7 +153,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
diff -uwr sourceold/scripts/AirFactoryGameObj.h source/scripts/AirFactoryGameObj.h
--- sourceold/scripts/AirFactoryGameObj.h	2011-10-21 09:32:28.004882800 +0800
+++ source/scripts/AirFactoryGameObj.h	2012-05-23 15:32:38.041015600 +0800
@@ -21,7 +21,7 @@
 	~AirFactoryGameObj (void);
 	virtual	void					Init( void );
 	void								Init (const AirFactoryGameObjDef & definition);
-	const AirFactoryGameObjDef &	Get_Definition (void) const;
+	SCRIPTS_API const AirFactoryGameObjDef &	Get_Definition (void) const;
 	AirFactoryGameObj *				As_AirFactoryGameObj (void)	{ return this; }
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
@@ -40,6 +40,11 @@
 	void					Import_Rare (BitStreamClass &packet);
 	void					Export_Rare (BitStreamClass &packet);
 	void					Create_Vehicle(int defintion_id,SoldierGameObj * player);
+	void Set_Busy(bool busy)
+	{
+		IsBusy = busy;
+		Set_Object_Dirty_Bit(NetworkObjectClass::BIT_RARE,true);
+	}
 private:
 	void					Load_Variables (ChunkLoadClass &cload);	
 	ReferencerClass	Vehicle;
diff -uwr sourceold/scripts/AirFactoryGameObjDef.h source/scripts/AirFactoryGameObjDef.h
--- sourceold/scripts/AirFactoryGameObjDef.h	2011-10-11 21:37:09.316406200 +0800
+++ source/scripts/AirFactoryGameObjDef.h	2012-05-06 16:37:04.946203100 +0800
@@ -22,6 +22,9 @@
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
 	const PersistFactoryClass &	Get_Factory (void) const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE (AirFactoryGameObjDef, BuildingGameObjDef);
 protected:
 	void					Load_Variables (ChunkLoadClass &cload);
diff -uwr sourceold/scripts/AirStripGameObj.h source/scripts/AirStripGameObj.h
--- sourceold/scripts/AirStripGameObj.h	2011-10-11 21:37:11.875976500 +0800
+++ source/scripts/AirStripGameObj.h	2012-05-23 11:12:05.150390600 +0800
@@ -46,7 +46,7 @@
 	virtual const PersistFactoryClass& Get_Factory() const;
 	virtual void Init();
 	void Init(const AirStripGameObjDef&);
-	const AirStripGameObjDef & Get_Definition( void ) const ;
+	SCRIPTS_API const AirStripGameObjDef & Get_Definition( void ) const ;
 	virtual bool Save(ChunkSaveClass&);
 	virtual bool Load(ChunkLoadClass&);
 	void Load_Variables(ChunkLoadClass&);
diff -uwr sourceold/scripts/AirStripGameObjDef.h source/scripts/AirStripGameObjDef.h
--- sourceold/scripts/AirStripGameObjDef.h	2011-10-11 21:37:14.416992100 +0800
+++ source/scripts/AirStripGameObjDef.h	2012-05-06 16:37:04.961828100 +0800
@@ -29,6 +29,9 @@
 	virtual bool                       Load         (ChunkLoadClass& chunkLoader);
 	virtual uint32                     Get_Class_ID () const;
 	virtual PersistClass*              Create       () const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE (AirStripGameObjDef, VehicleFactoryGameObjDef);
 private:
 	void					Load_Variables (ChunkLoadClass &cload);
diff -uwr sourceold/scripts/ArmedGameObj.h source/scripts/ArmedGameObj.h
--- sourceold/scripts/ArmedGameObj.h	2011-10-11 21:37:23.454101500 +0800
+++ source/scripts/ArmedGameObj.h	2012-05-23 11:12:13.034179600 +0800
@@ -23,7 +23,7 @@
 	void							Init( const ArmedGameObjDef & definition );
 	void							Copy_Settings( const ArmedGameObjDef & definition );
 	void							Re_Init( const ArmedGameObjDef & definition );
-	const	ArmedGameObjDef & Get_Definition( void ) const ;
+	SCRIPTS_API const	ArmedGameObjDef & Get_Definition( void ) const ;
 	virtual	bool				Save( ChunkSaveClass & csave );
 	virtual	bool				Load( ChunkLoadClass & cload );
 	virtual	void				On_Post_Load( void );
@@ -32,7 +32,7 @@
 	virtual	void				Import_State_Cs( BitStreamClass & packet );
 	virtual	void				Export_State_Cs( BitStreamClass & packet );
 	virtual	void				Post_Think();
-	WeaponClass	*				Get_Weapon( void );
+	SCRIPTS_API WeaponClass	*				Get_Weapon( void );
 	WeaponBagClass	*			Get_Weapon_Bag( void )						{ return WeaponBag; }
 	bool							Muzzle_Exists( int index = 0 );
 	virtual const Matrix3D &Get_Muzzle( int index = 0 );
diff -uwr sourceold/scripts/ArmedGameObjDef.h source/scripts/ArmedGameObjDef.h
--- sourceold/scripts/ArmedGameObjDef.h	2011-10-11 21:37:26.043945300 +0800
+++ source/scripts/ArmedGameObjDef.h	2012-05-06 16:37:04.974523400 +0800
@@ -18,6 +18,9 @@
 	ArmedGameObjDef( void );
 	virtual bool								Save( ChunkSaveClass &csave );
 	virtual bool								Load( ChunkLoadClass &cload );
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE(ArmedGameObjDef,PhysicalGameObjDef);
 protected:
 	//All of these floats are in radians (although leveledit shows degrees)
diff -uwr sourceold/scripts/ArmorWarheadManager.h source/scripts/ArmorWarheadManager.h
--- sourceold/scripts/ArmorWarheadManager.h	2011-10-11 21:57:50.799804600 +0800
+++ source/scripts/ArmorWarheadManager.h	2012-04-17 22:47:21.643554600 +0800
@@ -11,17 +11,20 @@
 */
 #ifndef TT_INCLUDE__ARMORWARHEADMANAGER_H
 #define TT_INCLUDE__ARMORWARHEADMANAGER_H
+#ifdef DDBEDIT
+#error cant use this in ddbedit
+#endif
 #include "engine_string.h"
 #include "datasafe.h"
-class ArmorWarheadManager
+class SCRIPTS_API ArmorWarheadManager
 {
 public:
 	static void	Init( void );
 	static void Shutdown( void );
 	static bool				Is_Armor_Soft( ArmorType armor );
 	static int			 	Get_Num_Armor_Types( void );
-	static ArmorType		SCRIPTS_API Get_Armor_Type( const char *name );
-	static const char SCRIPTS_API * 	Get_Armor_Name( ArmorType type );
+	static ArmorType		Get_Armor_Type( const char *name );
+	static const char * 	Get_Armor_Name( ArmorType type );
 	static int			 	Get_Num_Warhead_Types( void );
 	static WarheadType	Get_Warhead_Type( const char *name );
 	static const char *	Get_Warhead_Name( WarheadType type );
diff -uwr sourceold/scripts/AudibleSoundClass.h source/scripts/AudibleSoundClass.h
--- sourceold/scripts/AudibleSoundClass.h	2012-02-21 10:03:50.199218700 +0800
+++ source/scripts/AudibleSoundClass.h	2012-04-14 04:09:47.960937500 +0800
@@ -154,7 +154,7 @@
   virtual void                Free_Miles_Handle       ();
   virtual void                Initialize_Miles_Handle ();
   virtual void                Allocate_Miles_Handle   ();
-  virtual SoundBufferClass*   Get_Buffer              () const;
+  virtual SHADERS_API SoundBufferClass*   Get_Buffer              () const;
   virtual SoundBufferClass*   Peek_Buffer             () const;
   SHADERS_API virtual void                Set_Buffer              (SoundBufferClass* buffer);
   virtual void                Restart_Loop            ();
diff -uwr sourceold/scripts/AudibleSoundDefinitionClass.cpp source/scripts/AudibleSoundDefinitionClass.cpp
--- sourceold/scripts/AudibleSoundDefinitionClass.cpp	2011-10-11 23:04:16.190429600 +0800
+++ source/scripts/AudibleSoundDefinitionClass.cpp	2012-04-17 17:06:17.560546800 +0800
@@ -28,30 +28,30 @@
 AudibleSoundDefinitionClass::AudibleSoundDefinitionClass() : m_Priority(0.5), m_Volume(1), m_VolumeRandomizer(0), m_Pan(0.5), m_LoopCount(1), m_VirtualChannel(0), m_DropoffRadius(40), m_MaxVolRadius(20), m_Is3DSound(true), m_Type(1), m_StartOffset(0), m_PitchFactor(1), m_PitchFactorRandomizer(0), m_LogicalType(0), m_LogicalNotifDelay(2.0), m_LogicalDropoffRadius(-1.0), m_CreateLogicalSound(false), m_SphereColor(0,0.75,0.75)
 {
 #ifdef PARAM_EDITING_ON
-	NAMED_EDITABLE_PARAM(CNCModeSettingsDef,ParameterClass::TYPE_FILENAME,m_Filename,"Filename");
-	INT_EDITABLE_PARAM(CNCModeSettingsDef,m_Filename,0,100);
-	NAMED_EDITABLE_PARAM(CNCModeSettingsDef,ParameterClass::TYPE_FLOAT,m_DropoffRadius,"Drop-off Radius");
-	NAMED_EDITABLE_PARAM(CNCModeSettingsDef,ParameterClass::TYPE_FLOAT,m_MaxVolRadius,"Max-Vol Radius");
-	NAMED_EDITABLE_PARAM(CNCModeSettingsDef,ParameterClass::TYPE_BOOL,m_Is3DSound,"Is 3D Sound");
-	INT_EDITABLE_PARAM(CNCModeSettingsDef,m_LoopCount,0,1000000);
-	FLOAT_EDITABLE_PARAM(CNCModeSettingsDef,m_Volume,0,1.0);
-	FLOAT_UNITS_PARAM(CNCModeSettingsDef,m_VolumeRandomizer,0,1.0,"Volume Random (+/-)");
-	FLOAT_EDITABLE_PARAM(CNCModeSettingsDef,m_Pan,0,1.0);
-	FLOAT_EDITABLE_PARAM(CNCModeSettingsDef,m_Priority,0,1.0);
+	NAMED_EDITABLE_PARAM(AudibleSoundDefinitionClass,ParameterClass::TYPE_FILENAME,m_Filename,"Filename");
+	INT_EDITABLE_PARAM(AudibleSoundDefinitionClass,m_VirtualChannel,0,100);
+	NAMED_EDITABLE_PARAM(AudibleSoundDefinitionClass,ParameterClass::TYPE_FLOAT,m_DropoffRadius,"Drop-off Radius");
+	NAMED_EDITABLE_PARAM(AudibleSoundDefinitionClass,ParameterClass::TYPE_FLOAT,m_MaxVolRadius,"Max-Vol Radius");
+	NAMED_EDITABLE_PARAM(AudibleSoundDefinitionClass,ParameterClass::TYPE_BOOL,m_Is3DSound,"Is 3D Sound");
+	INT_EDITABLE_PARAM(AudibleSoundDefinitionClass,m_LoopCount,0,1000000);
+	FLOAT_EDITABLE_PARAM(AudibleSoundDefinitionClass,m_Volume,0,1.0);
+	FLOAT_UNITS_PARAM(AudibleSoundDefinitionClass,m_VolumeRandomizer,0,1.0,"Volume Random (+/-)");
+	FLOAT_EDITABLE_PARAM(AudibleSoundDefinitionClass,m_Pan,0,1.0);
+	FLOAT_EDITABLE_PARAM(AudibleSoundDefinitionClass,m_Priority,0,1.0);
 	EnumParameterClass * type = new EnumParameterClass(&m_Type);		
 	type->Set_Name ("m_Type");
 	type->Add_Value("Sound Effect",1);
 	type->Add_Value("Music",0);
 	type->Add_Value("Dialog",2);
 	type->Add_Value("Cinematic",3);
-	GENERIC_EDITABLE_PARAM( CNCModeSettingsDef, type);
-	FLOAT_EDITABLE_PARAM(CNCModeSettingsDef,m_StartOffset,0,1.0);
-	FLOAT_EDITABLE_PARAM(CNCModeSettingsDef,m_PitchFactor,0,1.0);
-	FLOAT_UNITS_PARAM(CNCModeSettingsDef,m_PitchFactorRandomizer,0,1.0,"Pitch Factor Random (+/-)");
-	NAMED_EDITABLE_PARAM(CNCModeSettingsDef,ParameterClass::TYPE_STRING,m_DisplayText,"Display Text");
-	NAMED_EDITABLE_PARAM(CNCModeSettingsDef,ParameterClass::TYPE_BOOL,m_CreateLogicalSound,"Create Logical Sound");
-	NAMED_EDITABLE_PARAM(CNCModeSettingsDef,ParameterClass::TYPE_FLOAT,m_LogicalDropoffRadius,"Logical Drop-off Radius");
-	NAMED_EDITABLE_PARAM(CNCModeSettingsDef,ParameterClass::TYPE_FLOAT,m_LogicalNotifDelay,"Logical Notif Delay");
+	GENERIC_EDITABLE_PARAM( AudibleSoundDefinitionClass, type);
+	FLOAT_EDITABLE_PARAM(AudibleSoundDefinitionClass,m_StartOffset,0,1.0);
+	FLOAT_EDITABLE_PARAM(AudibleSoundDefinitionClass,m_PitchFactor,0,1.0);
+	FLOAT_UNITS_PARAM(AudibleSoundDefinitionClass,m_PitchFactorRandomizer,0,1.0,"Pitch Factor Random (+/-)");
+	NAMED_EDITABLE_PARAM(AudibleSoundDefinitionClass,ParameterClass::TYPE_STRING,m_DisplayText,"Display Text");
+	NAMED_EDITABLE_PARAM(AudibleSoundDefinitionClass,ParameterClass::TYPE_BOOL,m_CreateLogicalSound,"Create Logical Sound");
+	NAMED_EDITABLE_PARAM(AudibleSoundDefinitionClass,ParameterClass::TYPE_FLOAT,m_LogicalDropoffRadius,"Logical Drop-off Radius");
+	NAMED_EDITABLE_PARAM(AudibleSoundDefinitionClass,ParameterClass::TYPE_FLOAT,m_LogicalNotifDelay,"Logical Notif Delay");
 	EnumParameterClass * logical = new EnumParameterClass(&m_LogicalType);		
 	logical->Set_Name ("Logical Type");
 	logical->Add_Value("None",0);
@@ -69,8 +69,8 @@
 	logical->Add_Value("Designer07",12);
 	logical->Add_Value("Designer08",13);
 	logical->Add_Value("Designer09",14);
-	GENERIC_EDITABLE_PARAM( CNCModeSettingsDef, logical);
-	NAMED_EDITABLE_PARAM(CNCModeSettingsDef,ParameterClass::TYPE_COLOR,m_SphereColor,"Sphere Color");
+	GENERIC_EDITABLE_PARAM( AudibleSoundDefinitionClass, logical);
+	NAMED_EDITABLE_PARAM(AudibleSoundDefinitionClass,ParameterClass::TYPE_COLOR,m_SphereColor,"Sphere Color");
 #endif
 }
 
@@ -264,3 +264,15 @@
 	m_SphereColor = that.m_SphereColor;
 	return *this;
 }
+
+#ifdef DDBEDIT
+void AudibleSoundDefinitionClass::Dump(FileClass &file)
+{
+	for (int i = 0;i < this->Get_Parameter_Count();i++)
+	{
+		ParameterClass *param = this->Lock_Parameter(i);
+		param->Dump(file);
+		this->Unlock_Parameter(i);
+	}
+}
+#endif
diff -uwr sourceold/scripts/AudibleSoundDefinitionClass.h source/scripts/AudibleSoundDefinitionClass.h
--- sourceold/scripts/AudibleSoundDefinitionClass.h	2011-10-11 21:57:45.827148400 +0800
+++ source/scripts/AudibleSoundDefinitionClass.h	2012-05-06 16:37:04.987218700 +0800
@@ -26,27 +26,6 @@
 class AudibleSoundDefinitionClass :
 	public DefinitionClass
 {
-	DECLARE_EDITABLE(AudibleSoundDefinitionClass,DefinitionClass);
-	float m_Priority; // 001C
-	float m_Volume; // 0020
-	float m_VolumeRandomizer; // 0024
-	float m_Pan; // 0028
-	int m_LoopCount; // 002C
-	int m_VirtualChannel; // 0030
-	float m_DropoffRadius; // 0034
-	float m_MaxVolRadius; // 0038
-	bool m_Is3DSound; // 003C
-	StringClass m_Filename; // 0040
-	int m_Type; // 0044
-	StringClass m_DisplayText; // 0048
-	float m_StartOffset; // 004C
-	float m_PitchFactor; // 0050
-	float m_PitchFactorRandomizer; // 0054
-	int m_LogicalType; // 0058
-	float m_LogicalNotifDelay; // 005C
-	float m_LogicalDropoffRadius; // 0060
-	bool m_CreateLogicalSound; // 0064
-	Vector3 m_SphereColor; // 0068
 public:
 	virtual ~AudibleSoundDefinitionClass();
 	virtual const PersistFactoryClass& Get_Factory() const;
@@ -80,6 +59,31 @@
 	bool Save_Variables(ChunkSaveClass&);
 	bool Load_Variables(ChunkLoadClass&);
 	const AudibleSoundDefinitionClass &operator=(AudibleSoundDefinitionClass const &that);
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
+	DECLARE_EDITABLE(AudibleSoundDefinitionClass,DefinitionClass);
+private:
+	float m_Priority; // 001C
+	float m_Volume; // 0020
+	float m_VolumeRandomizer; // 0024
+	float m_Pan; // 0028
+	int m_LoopCount; // 002C
+	int m_VirtualChannel; // 0030
+	float m_DropoffRadius; // 0034
+	float m_MaxVolRadius; // 0038
+	bool m_Is3DSound; // 003C
+	StringClass m_Filename; // 0040
+	int m_Type; // 0044
+	StringClass m_DisplayText; // 0048
+	float m_StartOffset; // 004C
+	float m_PitchFactor; // 0050
+	float m_PitchFactorRandomizer; // 0054
+	int m_LogicalType; // 0058
+	float m_LogicalNotifDelay; // 005C
+	float m_LogicalDropoffRadius; // 0060
+	bool m_CreateLogicalSound; // 0064
+	Vector3 m_SphereColor; // 0068
 	friend class PresetDump;
 };
 
diff -uwr sourceold/scripts/BaseControllerClass.h source/scripts/BaseControllerClass.h
--- sourceold/scripts/BaseControllerClass.h	2011-10-11 21:57:41.484375000 +0800
+++ source/scripts/BaseControllerClass.h	2012-05-23 08:29:05.815429600 +0800
@@ -82,6 +82,7 @@
 	bool Can_Build_Air();
 	bool Can_Build_Ground();
 	bool Can_Build_Naval();
+	void Check_Prerequisites();
 
 	bool Is_Base_Powered() const
 	{
@@ -119,6 +120,10 @@
 	{
 		return RadarEnabled;
 	}
+	DynamicVectorClass<BuildingGameObj*> &Get_Building_List()
+	{
+		return BuildingList;
+	}
 }; // 072C
 
 #endif
\ No newline at end of file
diff -uwr sourceold/scripts/BaseGameObjDef.h source/scripts/BaseGameObjDef.h
--- sourceold/scripts/BaseGameObjDef.h	2011-10-11 21:57:37.723632800 +0800
+++ source/scripts/BaseGameObjDef.h	2012-05-06 16:37:05.002843700 +0800
@@ -18,6 +18,9 @@
 public:
 	virtual bool								Save( ChunkSaveClass &csave );
 	virtual bool								Load( ChunkLoadClass &cload );
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	friend class PresetDump;
 }; // 001C
 
diff -uwr sourceold/scripts/BeaconGameObj.h source/scripts/BeaconGameObj.h
--- sourceold/scripts/BeaconGameObj.h	2011-10-11 21:57:36.038085900 +0800
+++ source/scripts/BeaconGameObj.h	2012-05-23 11:12:36.067382800 +0800
@@ -47,7 +47,7 @@
 	virtual const PersistFactoryClass& Get_Factory() const;
 	virtual void Init();
 	void Init(const BeaconGameObjDef &);
-	const BeaconGameObjDef & Get_Definition( void ) const ;
+	SCRIPTS_API const BeaconGameObjDef & Get_Definition( void ) const ;
 	void Init_Beacon(const WeaponDefinitionClass* definition, SoldierGameObj* owner, const Vector3& position);
 	virtual bool Save(ChunkSaveClass& chunks);
 	virtual bool Load(ChunkLoadClass& chunks);
diff -uwr sourceold/scripts/BeaconGameObjDef.h source/scripts/BeaconGameObjDef.h
--- sourceold/scripts/BeaconGameObjDef.h	2012-01-13 08:30:18.359375000 +0800
+++ source/scripts/BeaconGameObjDef.h	2012-05-06 16:37:05.014562500 +0800
@@ -24,6 +24,9 @@
 	uint32 Get_Class_ID() const;
 	PersistClass* Create() const;
 	bool Is_Nuke() const {return IsNuke;}
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE( BeaconGameObjDef, SimpleGameObjDef );
 private:
 	float BroadcastToAllTime; // 00AC
diff -uwr sourceold/scripts/BuildingGameObj.h source/scripts/BuildingGameObj.h
--- sourceold/scripts/BuildingGameObj.h	2011-10-11 21:57:29.629882800 +0800
+++ source/scripts/BuildingGameObj.h	2012-04-14 04:09:47.160156200 +0800
@@ -84,6 +84,8 @@
 	virtual void								On_Damaged (void);
 	bool											Is_Destroyed (void) const { return IsDestroyed; }
 	void Set_Is_Destroyed(const bool _IsDestroyed) { IsDestroyed = _IsDestroyed; }
+	bool											Is_Spy_Disabled() const { return IsSpyDisabled; }
+	void Set_Is_Spy_Disabled(const bool _IsSpyDisabled) {IsSpyDisabled = _IsSpyDisabled; }
 	virtual	void								Import_Rare (BitStreamClass &packet);
 	virtual	void								Export_Rare (BitStreamClass &packet);
 	virtual	void								Export_Creation (BitStreamClass &packet);
@@ -111,6 +113,7 @@
 	bool											IsDestroyed;
 	Vector3										Position;
 	bool											IsPowerOn;
+	bool											IsSpyDisabled;
 	int											CurrentState;						// derived from the health and IsPowerOn
 	AudibleSoundClass *						CurrentAnnouncement;
 	SphereClass									AnnouncementSphere;
diff -uwr sourceold/scripts/BuildingGameObjDef.h source/scripts/BuildingGameObjDef.h
--- sourceold/scripts/BuildingGameObjDef.h	2011-10-11 21:57:27.790039000 +0800
+++ source/scripts/BuildingGameObjDef.h	2012-05-06 16:37:05.027257800 +0800
@@ -60,6 +60,9 @@
 	virtual bool								Save( ChunkSaveClass &csave );
 	virtual bool								Load( ChunkLoadClass &cload );
 	virtual const PersistFactoryClass &	Get_Factory( void ) const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE( BuildingGameObjDef, DamageableGameObjDef );
 	void										Set_Type (BuildingConstants::BuildingType type) { Type = type; }
 	BuildingConstants::BuildingType				Get_Type (void) const	{ return Type; }
diff -uwr sourceold/scripts/C4GameObj.h source/scripts/C4GameObj.h
--- sourceold/scripts/C4GameObj.h	2011-10-11 21:57:26.085937500 +0800
+++ source/scripts/C4GameObj.h	2012-05-23 11:12:52.194335900 +0800
@@ -40,7 +40,7 @@
 	~C4GameObj();
 	void Init();
 	void Init(const C4GameObjDef &);
-	const C4GameObjDef & Get_Definition( void ) const ;
+	SCRIPTS_API const C4GameObjDef & Get_Definition( void ) const ;
 	void Init_C4(AmmoDefinitionClass const *ammoPreset, SoldierGameObj* owner, uint32 detonationMode, const Matrix3D& muzzle);
 	CollisionReactionType Collision_Occurred(const CollisionEventClass& collide);
 	bool Save(ChunkSaveClass &csave);
diff -uwr sourceold/scripts/C4GameObjDef.h source/scripts/C4GameObjDef.h
--- sourceold/scripts/C4GameObjDef.h	2011-10-11 21:57:24.221679600 +0800
+++ source/scripts/C4GameObjDef.h	2012-05-06 16:37:05.039953100 +0800
@@ -21,6 +21,9 @@
 	bool Load(ChunkLoadClass &cload);
 	uint32 Get_Class_ID() const;
 	PersistClass *Create() const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE( C4GameObjDef, SimpleGameObjDef );
 private:
 	float ThrowVelocity;
diff -uwr sourceold/scripts/CinematicGameObj.h source/scripts/CinematicGameObj.h
--- sourceold/scripts/CinematicGameObj.h	2011-10-11 21:57:10.641601500 +0800
+++ source/scripts/CinematicGameObj.h	2012-05-23 11:12:59.759765600 +0800
@@ -25,7 +25,7 @@
 	void Init();
 	void Init(const CinematicGameObjDef &);
 	void Cinematic_Init();
-	const CinematicGameObjDef & Get_Definition( void ) const ;
+	SCRIPTS_API const CinematicGameObjDef & Get_Definition( void ) const ;
 	bool Save(ChunkSaveClass &csave);
 	bool Load(ChunkLoadClass &cload);
 	void On_Post_Load();
diff -uwr sourceold/scripts/CinematicGameObjDef.h source/scripts/CinematicGameObjDef.h
--- sourceold/scripts/CinematicGameObjDef.h	2011-10-11 21:57:08.957031200 +0800
+++ source/scripts/CinematicGameObjDef.h	2012-05-06 16:37:05.053625000 +0800
@@ -21,6 +21,10 @@
 	bool Load(ChunkLoadClass &cload);
 	uint32 Get_Class_ID() const;
 	PersistClass *Create() const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+	virtual void                        DumpPhys (FileClass &file);
+#endif
 	DECLARE_EDITABLE( CinematicGameObjDef, ArmedGameObjDef );
 private:
 	int SoundDefID;
diff -uwr sourceold/scripts/ComCenterGameObj.h source/scripts/ComCenterGameObj.h
--- sourceold/scripts/ComCenterGameObj.h	2011-10-11 21:56:58.881835900 +0800
+++ source/scripts/ComCenterGameObj.h	2012-05-23 11:13:09.483398400 +0800
@@ -20,7 +20,7 @@
 	~ComCenterGameObj (void);
 	virtual	void					Init( void );
 	void								Init (const ComCenterGameObjDef & definition);
-	const ComCenterGameObjDef &	Get_Definition (void) const;
+	SCRIPTS_API const ComCenterGameObjDef &	Get_Definition (void) const;
 	ComCenterGameObj *				As_ComCenterGameObj (void)	{ return this; }
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
diff -uwr sourceold/scripts/ComCenterGameObjDef.h source/scripts/ComCenterGameObjDef.h
--- sourceold/scripts/ComCenterGameObjDef.h	2011-10-11 21:56:57.004882800 +0800
+++ source/scripts/ComCenterGameObjDef.h	2012-05-06 16:37:05.070226600 +0800
@@ -22,6 +22,9 @@
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
 	const PersistFactoryClass &	Get_Factory (void) const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE (ComCenterGameObjDef, BuildingGameObjDef);
 protected:
 	void					Load_Variables (ChunkLoadClass &cload);
diff -uwr sourceold/scripts/ConstructionYardGameObj.h source/scripts/ConstructionYardGameObj.h
--- sourceold/scripts/ConstructionYardGameObj.h	2011-10-11 21:56:47.152343700 +0800
+++ source/scripts/ConstructionYardGameObj.h	2012-05-23 11:13:18.676757800 +0800
@@ -22,7 +22,7 @@
 	~ConstructionYardGameObj (void);
 	virtual	void					Init( void );
 	void								Init (const ConstructionYardGameObjDef & definition);
-	const ConstructionYardGameObjDef &	Get_Definition (void) const;
+	SCRIPTS_API const ConstructionYardGameObjDef &	Get_Definition (void) const;
 	ConstructionYardGameObj *				As_ConstructionYardGameObj (void)	{ return this; }
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
diff -uwr sourceold/scripts/ConstructionYardGameObjDef.h source/scripts/ConstructionYardGameObjDef.h
--- sourceold/scripts/ConstructionYardGameObjDef.h	2011-10-11 21:56:45.261718700 +0800
+++ source/scripts/ConstructionYardGameObjDef.h	2012-05-06 16:37:05.081945300 +0800
@@ -22,6 +22,9 @@
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
 	const PersistFactoryClass &	Get_Factory (void) const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE (ConstructionYardGameObjDef, BuildingGameObjDef);
 protected:
 	void					Load_Variables (ChunkLoadClass &cload);
diff -uwr sourceold/scripts/DamageZoneGameObj.h source/scripts/DamageZoneGameObj.h
--- sourceold/scripts/DamageZoneGameObj.h	2011-10-11 21:56:28.727539000 +0800
+++ source/scripts/DamageZoneGameObj.h	2012-05-23 11:14:00.280273400 +0800
@@ -26,7 +26,7 @@
 	bool Load(ChunkLoadClass &cload);
 	void Init();
 	void Init(const DamageZoneGameObjDef &);
-	const DamageZoneGameObjDef & Get_Definition( void ) const ;
+	SCRIPTS_API const DamageZoneGameObjDef & Get_Definition( void ) const ;
 	void Think();
 	void Set_Bounding_Box(OBBoxClass &box) {BoundingBox = box;}
 	OBBoxClass &Get_Bounding_Box() {return BoundingBox;}
diff -uwr sourceold/scripts/DamageZoneGameObjDef.h source/scripts/DamageZoneGameObjDef.h
--- sourceold/scripts/DamageZoneGameObjDef.h	2011-10-11 21:56:26.795898400 +0800
+++ source/scripts/DamageZoneGameObjDef.h	2012-05-06 16:37:05.110265600 +0800
@@ -22,6 +22,9 @@
 	uint32 Get_Class_ID() const;
 	PersistClass *Create() const;
 	Vector3 &Get_Color() {return Color;}
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE(DamageZoneGameObjDef, BaseGameObjDef);
 private:
 	float DamageRate;
diff -uwr sourceold/scripts/DamageableGameObj.h source/scripts/DamageableGameObj.h
--- sourceold/scripts/DamageableGameObj.h	2011-10-11 21:56:32.453125000 +0800
+++ source/scripts/DamageableGameObj.h	2012-05-23 11:24:09.008789000 +0800
@@ -37,10 +37,10 @@
 	virtual	DamageableGameObj	*As_DamageableGameObj( void )	{ return this; }
 	virtual int Get_Player_Type(void) const {return PlayerType;}
 	virtual void Set_Player_Type(int type);
-	bool		Is_Team_Player(void);
+	SCRIPTS_API bool		Is_Team_Player(void);
 	Vector3		Get_Team_Color(void);
-	bool		Is_Teammate(DamageableGameObj * p_obj);
-	bool		Is_Enemy(DamageableGameObj * p_obj);
+	SCRIPTS_API bool		Is_Teammate(DamageableGameObj * p_obj);
+	SCRIPTS_API bool		Is_Enemy(DamageableGameObj * p_obj);
 	virtual	void								Import_Occasional( BitStreamClass &packet );
 	virtual	void								Export_Occasional( BitStreamClass &packet );
 	bool Is_Damaged()
diff -uwr sourceold/scripts/DamageableGameObjDef.h source/scripts/DamageableGameObjDef.h
--- sourceold/scripts/DamageableGameObjDef.h	2011-10-11 21:56:30.630859300 +0800
+++ source/scripts/DamageableGameObjDef.h	2012-05-06 16:37:05.098546900 +0800
@@ -26,6 +26,9 @@
 	DamageableGameObjDef( void );
 	virtual bool								Save( ChunkSaveClass &csave );
 	virtual bool								Load( ChunkLoadClass &cload );
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE( DamageableGameObjDef, ScriptableGameObjDef );
 	int											Get_Name_ID (void) const	{ return TranslatedNameID; }
 	int											Get_Encyclopedia_Type (void) const	{ return EncyclopediaType; }
diff -uwr sourceold/scripts/DecorationPhysDefClass.h source/scripts/DecorationPhysDefClass.h
--- sourceold/scripts/DecorationPhysDefClass.h	2011-10-11 21:56:12.504882800 +0800
+++ source/scripts/DecorationPhysDefClass.h	2012-05-06 16:37:05.122960900 +0800
@@ -26,6 +26,9 @@
 	virtual const PersistFactoryClass &	Get_Factory (void) const;
 	virtual bool								Save(ChunkSaveClass &csave);
 	virtual bool								Load(ChunkLoadClass &cload);
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE(DecorationPhysDefClass,DynamicPhysDefClass);
 protected:
 	friend class StaticPhysClass;
diff -uwr sourceold/scripts/Definition.h source/scripts/Definition.h
--- sourceold/scripts/Definition.h	2011-10-11 21:56:03.347656200 +0800
+++ source/scripts/Definition.h	2012-04-16 19:44:48.389648400 +0800
@@ -12,9 +12,9 @@
 #ifndef TT_INCLUDE_DEFINITION_H
 #define TT_INCLUDE_DEFINITION_H
 #include "Editable.h"
+class FileClass;
 class DefinitionClass : public EditableClass {
 public:
-	DECLARE_EDITABLE(DefinitionClass, EditableClass);
 	DefinitionClass (void);
 	virtual ~DefinitionClass (void);
 	virtual uint32						Get_Class_ID (void) const = 0;
@@ -30,6 +30,11 @@
 	void									Set_User_Data (uint32 data)	{ m_GenericUserData = data; }
 	bool									Is_Save_Enabled (void) const	{ return m_SaveEnabled; }
 	void									Enable_Save (bool onoff)		{ m_SaveEnabled = onoff; }
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+	virtual void                        DumpPhys (FileClass &file);
+#endif
+	DECLARE_EDITABLE(DefinitionClass, EditableClass);
 protected:
 	int											m_DefinitionMgrLink; // 0008
 private:
Only in source/scripts: Doxyfile
diff -uwr sourceold/scripts/DynamicPhysClass.h source/scripts/DynamicPhysClass.h
--- sourceold/scripts/DynamicPhysClass.h	2011-10-11 21:55:09.958984300 +0800
+++ source/scripts/DynamicPhysClass.h	2012-04-14 04:09:47.578125000 +0800
@@ -26,12 +26,10 @@
 	virtual void								Set_Model(RenderObjClass * model);
 	void											Update_Visibility_Status(void);
 	virtual int									Get_Vis_Object_ID(void);
-#ifndef TTLE_EXPORTS
 	virtual bool								Is_Simulation_Disabled(void)				{ return _DisableDynamicPhysSimulation; }
 	virtual bool								Is_Rendering_Disabled(void)				{ return _DisableDynamicPhysRendering; }
 	static void									Disable_All_Simulation(bool onoff)		{ _DisableDynamicPhysSimulation = onoff; }
 	static void									Disable_All_Rendering(bool onoff)		{ _DisableDynamicPhysRendering = onoff; }
-#endif
 	virtual bool								Save (ChunkSaveClass &csave);
 	virtual bool								Load (ChunkLoadClass &cload);
 	virtual void								On_Post_Load(void);
@@ -41,10 +39,8 @@
 	int											VisNodeID; // 007C  007C  0098  0094
 	unsigned int								VisStatusLastUpdated; // 0080  0080  009C  0098
 private:
-#ifndef TTLE_EXPORTS
-	static REF_DECL2(_DisableDynamicPhysSimulation,bool);
-	static REF_DECL2(_DisableDynamicPhysRendering,bool);
-#endif
+	static bool _DisableDynamicPhysSimulation;
+	static bool _DisableDynamicPhysRendering;
 	DynamicPhysClass(const DynamicPhysClass &);
 	DynamicPhysClass & operator = (const DynamicPhysClass &);
 }; // 0084  0084  00A0  009C
diff -uwr sourceold/scripts/DynamicPhysDefClass.h source/scripts/DynamicPhysDefClass.h
--- sourceold/scripts/DynamicPhysDefClass.h	2011-10-11 21:54:51.746093700 +0800
+++ source/scripts/DynamicPhysDefClass.h	2012-05-06 16:37:05.135656200 +0800
@@ -24,6 +24,9 @@
 	virtual const char *						Get_Type_Name(void)			{ return "DynamicPhysDef"; }
 	virtual bool								Is_Type(const char *);
 	virtual bool								Is_Valid_Config (StringClass &message);
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE(DynamicPhysDefClass,PhysDefClass);
 protected:
 	friend class DynamicPhysClass;
diff -uwr sourceold/scripts/GameObjManager.h source/scripts/GameObjManager.h
--- sourceold/scripts/GameObjManager.h	2012-02-13 13:28:20.240632800 +0800
+++ source/scripts/GameObjManager.h	2012-05-23 11:29:01.416015600 +0800
@@ -28,6 +28,7 @@
 class BuildingGameObj;
 class C4GameObj;
 class BeaconGameObj;
+class ScriptZoneGameObj;
 
 class GameObjManager
 {
@@ -42,6 +43,7 @@
 	static SHADERS_API SList<BeaconGameObj> BeaconGameObjList;
 	static SHADERS_API SList<SoldierGameObj> SoldierGameObjList;
 	static SHADERS_API SList<VehicleGameObj> VehicleGameObjList;
+	static SHADERS_API SList<ScriptZoneGameObj> ScriptZoneGameObjList;
 #ifndef TTLE_EXPORTS
 	static REF_DECL2(CinematicFreezeActive, bool);
 #endif
@@ -52,7 +54,7 @@
 	static void Think();
 	static void Post_Think();
 	static PhysicalGameObj* Find_PhysicalGameObj(int);
-	static SmartGameObj* Find_SmartGameObj(int);
+	SCRIPTS_API static SmartGameObj* Find_SmartGameObj(int);
 	static void Init();
 	static void Shutdown();
 	static bool Save(ChunkSaveClass&);
diff -uwr sourceold/scripts/HarvesterClass.h source/scripts/HarvesterClass.h
--- sourceold/scripts/HarvesterClass.h	2011-10-11 21:52:33.959960900 +0800
+++ source/scripts/HarvesterClass.h	2012-04-27 22:33:07.907226500 +0800
@@ -98,6 +98,7 @@
    {
 	   return harvester;
    }
+   State Get_State() {return state;}
    void            Harvest_Tiberium       ();
    void            Play_Harvest_Animation (bool play);
    void            Think                  ();
Only in source/scripts: LoopedAnimationController.cpp
Only in source/scripts: LoopedAnimationController.h
diff -uwr sourceold/scripts/Matrix3D.cpp source/scripts/Matrix3D.cpp
--- sourceold/scripts/Matrix3D.cpp	2011-10-11 23:05:52.368164000 +0800
+++ source/scripts/Matrix3D.cpp	2012-04-23 13:05:44.549046900 +0800
@@ -48,6 +48,19 @@
 }
 
 
+int Matrix3D::Is_Orthogonal(void) const
+{
+	Vector3 x(Row[0].X,Row[0].Y,Row[0].Z);
+	Vector3 y(Row[1].X,Row[1].Y,Row[1].Z);
+	Vector3 z(Row[2].X,Row[2].Y,Row[2].Z);
+	if (Vector3::Dot_Product(x,y) > WWMATH_EPSILON) return 0;
+	if (Vector3::Dot_Product(y,z) > WWMATH_EPSILON) return 0;
+	if (Vector3::Dot_Product(z,x) > WWMATH_EPSILON) return 0;
+	if (WWMath::Fabs(x.Length2() - 1.0f) > WWMATH_EPSILON) return 0;
+	if (WWMath::Fabs(y.Length2() - 1.0f) > WWMATH_EPSILON) return 0;
+	if (WWMath::Fabs(z.Length2() - 1.0f) > WWMATH_EPSILON) return 0;
+	return 1;
+}
 
 void Matrix3D::Get_Orthogonal_Inverse (Matrix3D& inv) const
 {
diff -uwr sourceold/scripts/Matrix3D.h source/scripts/Matrix3D.h
--- sourceold/scripts/Matrix3D.h	2011-10-11 21:50:23.392578100 +0800
+++ source/scripts/Matrix3D.h	2012-04-23 13:05:44.507054700 +0800
@@ -502,6 +502,7 @@
 		Row[1][2] = (float)(s*tmp1 + c*tmp2);
 	}
 
+	int	Is_Orthogonal(void) const; 
    Vector3  applyTo      (const Vector3& vector) const;
    Vector3  getPosition  () const;
    Matrix3  getRotation  () const;
diff -uwr sourceold/scripts/MoveablePhysDefClass.h source/scripts/MoveablePhysDefClass.h
--- sourceold/scripts/MoveablePhysDefClass.h	2011-10-11 21:49:58.500976500 +0800
+++ source/scripts/MoveablePhysDefClass.h	2012-05-06 16:37:05.148351600 +0800
@@ -27,6 +27,9 @@
 	float											Get_Grav_Scale(void)			{ return GravScale; }
 	void											Set_Mass(float new_mass)	{ Mass = new_mass; }
 	void											Set_Grav_Scale(float new_g){ GravScale = new_g; }
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE(MoveablePhysDefClass,DynamicPhysDefClass);
 protected:
 	float				Mass;
Only in source/scripts: NavalFactoryGameObj.h
Only in source/scripts: NavalFactoryGameObjDef.h
diff -uwr sourceold/scripts/Parameter.h source/scripts/Parameter.h
--- sourceold/scripts/Parameter.h	2011-10-11 21:49:22.120117100 +0800
+++ source/scripts/Parameter.h	2012-04-16 23:58:26.740234300 +0800
@@ -14,6 +14,7 @@
 #include "Engine_String.h"
 #include "Engine_Vector.h"
 class DefParameterClass;
+class FileClass;
 class ParameterClass
 {
 public:
@@ -64,6 +65,9 @@
 	virtual const char *		Get_Units_Name (void) const;
 	virtual void				Set_Units_Name (const char *units_name);
 	virtual void				Copy_Value (const ParameterClass &src) { };
+#ifdef DDBEDIT
+	virtual void                Dump(FileClass &file) = 0;
+#endif
 	static ParameterClass *	Construct (ParameterClass::Type type, void *data, const char *param_name);
 private:
 	bool				IsModified;
diff -uwr sourceold/scripts/PhysDefClass.h source/scripts/PhysDefClass.h
--- sourceold/scripts/PhysDefClass.h	2011-10-11 21:49:10.120117100 +0800
+++ source/scripts/PhysDefClass.h	2012-05-06 16:37:05.173742200 +0800
@@ -100,6 +100,9 @@
 	virtual bool					Is_Valid_Config (StringClass &message);
 	const StringClass &			Get_Model_Name()					{ return ModelName; }
 	bool								Get_Is_Pre_Lit()					{ return IsPreLit; }
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE(PhysDefClass,DefinitionClass);
 protected:
 	StringClass						ModelName;
diff -uwr sourceold/scripts/PhysicalGameObj.h source/scripts/PhysicalGameObj.h
--- sourceold/scripts/PhysicalGameObj.h	2012-02-17 16:57:48.055664000 +0800
+++ source/scripts/PhysicalGameObj.h	2012-05-23 11:24:07.594726500 +0800
@@ -47,7 +47,7 @@
 	void					Set_Position(const Vector3 & pos);
 	float					Get_Facing(void) const;
 	inline RenderObjClass	*	Peek_Model( void ) { return Peek_Physical_Object()->Peek_Model(); }
-	AnimControlClass*	Get_Anim_Control( void );
+	SCRIPTS_API AnimControlClass*	Get_Anim_Control( void );
 	void					Set_Anim_Control( AnimControlClass * anim_control );
 	virtual	void	Set_Animation( const char *animation_name, bool looping = true, float frame_offset = 0.0f );
 	virtual	void	Set_Animation_Frame ( const char *animation_name, int frame );
@@ -62,7 +62,7 @@
 	virtual	bool	Takes_Explosion_Damage( void )						{ return true; }
 	int	Get_Type()	const		{ return Get_Definition().Type; }
 	virtual	void	Post_Think();
-	void		Set_Collision_Group( int group );
+	void		SCRIPTS_API Set_Collision_Group( int group );
 	Collision_Group_Type Get_Collision_Group() const { return PhysObj->Get_Collision_Group(); }
 	virtual ExpirationReactionType	Object_Expired( PhysClass * observed_obj ) { Set_Delete_Pending(); return 1; }
 	virtual	PhysicalGameObj		*As_PhysicalGameObj( void )	{ return this; }
@@ -109,7 +109,7 @@
 	bool				Is_HUD_Pokable_Indicator_Enabled( void )		{ return HUDPokableIndicatorEnabled; } 
 	virtual void		Set_Player_Type(int type);
 	virtual void	Object_Shattered_Something(PhysClass * observed_obj, PhysClass * shattered_obj, int surface_type);
-	void                Clear_Animation() {if (AnimControl) {AnimControl->Set_Mode(ANIM_MODE_STOP,0);ClearAnimation = true;Set_Object_Dirty_Bit(NetworkObjectClass::BIT_RARE,true);}}
+	void                Clear_Animation() {if (AnimControl) {AnimControl->Set_Animation((const char*)NULL, 0, 0);AnimControl->Set_Mode(ANIM_MODE_STOP,0);ClearAnimation = true;Set_Object_Dirty_Bit(NetworkObjectClass::BIT_RARE,true);}}
 protected:
 	ActiveConversationClass *ActiveConversation;
 private:
diff -uwr sourceold/scripts/PhysicalGameObjDef.h source/scripts/PhysicalGameObjDef.h
--- sourceold/scripts/PhysicalGameObjDef.h	2011-10-11 21:49:01.494140600 +0800
+++ source/scripts/PhysicalGameObjDef.h	2012-05-06 16:37:05.186437500 +0800
@@ -21,6 +21,9 @@
 	virtual bool								Is_Valid_Config (StringClass &message);
 	int		Get_Phys_Def_ID( void ) const	{ return PhysDefID; }
 	int		Get_Orator_Type( void ) const	{ return OratorType; }
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE( PhysicalGameObjDef, DamageableGameObjDef );
 protected:
 	int											Type;					
diff -uwr sourceold/scripts/PhysicsSceneClass.h source/scripts/PhysicsSceneClass.h
--- sourceold/scripts/PhysicsSceneClass.h	2011-10-11 21:48:58.233398400 +0800
+++ source/scripts/PhysicsSceneClass.h	2012-04-14 04:09:46.643554600 +0800
@@ -112,6 +112,14 @@
 	SHADERS_API bool Intersection_Test(PhysMeshIntersectionTestClass & meshtest,bool use_collision_region = false);
 	SHADERS_API bool Intersection_Test(const AABoxClass & box,int collision_group,int collision_type,bool use_collision_region = false);
 	SHADERS_API bool Intersection_Test(const OBBoxClass & box,int collision_group,int collision_type,bool use_collision_region = false);
+	bool Real_Cast_Ray(PhysRayCollisionTestClass & raytest,bool use_collision_region = false);
+	bool Real_Cast_AABox(PhysAABoxCollisionTestClass & boxtest,bool use_collision_region = false);
+	bool Real_Cast_OBBox(PhysOBBoxCollisionTestClass & boxtest,bool use_collision_region = false);
+	bool Real_Intersection_Test1(PhysAABoxIntersectionTestClass & boxtest,bool use_collision_region = false);
+	bool Real_Intersection_Test2(PhysOBBoxIntersectionTestClass & boxtest,bool use_collision_region = false);
+	bool Real_Intersection_Test3(PhysMeshIntersectionTestClass & meshtest,bool use_collision_region = false);
+	bool Real_Intersection_Test4(const AABoxClass & box,int collision_group,int collision_type,bool use_collision_region = false);
+	bool Real_Intersection_Test5(const OBBoxClass & box,int collision_group,int collision_type,bool use_collision_region = false);
 	void Force_Dynamic_Objects_Awake(const AABoxClass & box);
 	void Collect_Objects(const Vector3 & point,bool static_objs, bool dynamic_objs,MultiListClass<PhysClass> * list);
 	void Collect_Objects(const AABoxClass & box,bool static_objs, bool dynamic_objs,MultiListClass<PhysClass> * list);
@@ -258,7 +266,7 @@
 	virtual void Destroy_Iterator(SceneIterator *) {}
 	virtual void Register(RenderObjClass * obj,RegType for_what);
 	virtual void Unregister(RenderObjClass * obj,RegType for_what);
-	void Get_Level_Extents (Vector3 &min, Vector3 &max);
+	SHADERS_API void Get_Level_Extents (Vector3 &min, Vector3 &max);
 	void Enable_Debug_Display(bool onoff) { DebugDisplayEnabled = onoff; }
 	bool Is_Debug_Display_Enabled(void) { return DebugDisplayEnabled; }
 	void Enable_Projector_Debug_Display(bool onoff) { ProjectorDebugDisplayEnabled = onoff; }
diff -uwr sourceold/scripts/PowerPlantGameObj.h source/scripts/PowerPlantGameObj.h
--- sourceold/scripts/PowerPlantGameObj.h	2011-10-11 21:48:42.026367100 +0800
+++ source/scripts/PowerPlantGameObj.h	2012-05-23 11:14:11.018554600 +0800
@@ -20,7 +20,7 @@
 	~PowerPlantGameObj (void);
 	virtual	void					Init( void );
 	void								Init (const PowerPlantGameObjDef & definition);
-	const PowerPlantGameObjDef &	Get_Definition (void) const;
+	SCRIPTS_API const PowerPlantGameObjDef &	Get_Definition (void) const;
 	PowerPlantGameObj *				As_PowerPlantGameObj (void)	{ return this; }
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
diff -uwr sourceold/scripts/PowerPlantGameObjDef.h source/scripts/PowerPlantGameObjDef.h
--- sourceold/scripts/PowerPlantGameObjDef.h	2011-10-11 21:48:40.079101500 +0800
+++ source/scripts/PowerPlantGameObjDef.h	2012-05-06 16:37:05.200109400 +0800
@@ -22,6 +22,9 @@
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
 	const PersistFactoryClass &	Get_Factory (void) const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE (PowerPlantGameObjDef, BuildingGameObjDef);
 protected:
 	void					Load_Variables (ChunkLoadClass &cload);
diff -uwr sourceold/scripts/PowerupGameObjDef.h source/scripts/PowerupGameObjDef.h
--- sourceold/scripts/PowerupGameObjDef.h	2011-10-11 21:48:36.038085900 +0800
+++ source/scripts/PowerupGameObjDef.h	2012-05-06 16:37:05.212804700 +0800
@@ -28,6 +28,9 @@
 	bool Is_Persistant() const {return Persistent;}
 	bool Is_Always_Allow_Grant() const {return AlwaysAllowGrant;}
 	int Get_Grant_Sound() const {return GrantSoundID;}
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE (PowerUpGameObjDef, SimpleGameObjDef);
 public:
 	int											GrantShieldType;
Only in source/scripts: PresetMgr.cpp
Only in source/scripts: PresetMgr.h
diff -uwr sourceold/scripts/PurchaseSettingsDefClass.h source/scripts/PurchaseSettingsDefClass.h
--- sourceold/scripts/PurchaseSettingsDefClass.h	2011-10-25 15:39:17.330078100 +0800
+++ source/scripts/PurchaseSettingsDefClass.h	2012-05-06 16:37:05.226476600 +0800
@@ -18,6 +18,8 @@
 #endif
 #include "NetworkObjectClass.h"
 #include "ExtendedNetworkObject.h"
+#include "BuildingGameObjDef.h"
+using namespace BuildingConstants;
 #define PTTEAM(t) (t?0:1) //Convert a normal team into a PT team
 class PurchaseSettingsDefClass abstract : public DefinitionClass, public NetworkObjectClass  {
 public:
@@ -46,6 +48,9 @@
 	uint32 Get_Class_ID() const;
 	PersistClass *Create() const;
 	static SCRIPTS_API PurchaseSettingsDefClass *Find_Definition(TYPE type,TEAM team);
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE(PurchaseSettingsDefClass,DefinitionClass);
 	void Delete(void)
 	{
@@ -95,6 +100,34 @@
 	{
 		return type;
 	}
+	int Get_Tech_Level(int index)
+	{
+		return TechLevel[index];
+	}
+	bool Get_Factory_Not_Required(int index)
+	{
+		return FactoryNotRequired[index];
+	}
+	BuildingType Get_Factory_Building(int index)
+	{
+		return Factory[index];
+	}
+	BuildingType Get_Tech_Building(int index)
+	{
+		return TechBuilding[index];
+	}
+	void Set_Tech_Level(int index,int level)
+	{
+		TechLevel[index] = level;
+	}
+	void Set_Factory_Building(int index,BuildingType type)
+	{
+		Factory[index] = type;
+	}
+	void Set_Tech_Building(int index,BuildingType type)
+	{
+		TechBuilding[index] = type;
+	}
 	bool Get_Hidden(int index)
 	{
 		return Hidden[index];
@@ -160,6 +193,10 @@
 	bool Hidden[10];
 	bool Disabled[10];
 	bool Busy[10];
+	int TechLevel[10];
+	BuildingType Factory[10];
+	BuildingType TechBuilding[10];
+	bool FactoryNotRequired[10];
 	int altpresetids[10][3];
 	StringClass alttextures[10][3];
 	bool PageHidden;
Only in source/scripts: Random2Class.cpp
diff -uwr sourceold/scripts/Random2Class.h source/scripts/Random2Class.h
--- sourceold/scripts/Random2Class.h	2011-10-11 21:48:09.370117100 +0800
+++ source/scripts/Random2Class.h	2012-05-01 21:00:32.585937500 +0800
@@ -103,6 +103,8 @@
 		int mti;
 };
 #ifndef TTLE_EXPORTS
+#ifndef TDBEDIT
 extern REF_DECL2(FreeRandom, CRandom);
 #endif
 #endif
+#endif
Only in source/scripts: Random3Class.cpp
Only in source/scripts: Random3Class.h
Only in source/scripts: RandomClass.cpp
Only in source/scripts: RandomClass.h
diff -uwr sourceold/scripts/RefineryGameObjDef.h source/scripts/RefineryGameObjDef.h
--- sourceold/scripts/RefineryGameObjDef.h	2011-10-11 21:47:47.846679600 +0800
+++ source/scripts/RefineryGameObjDef.h	2012-05-06 16:37:05.239171900 +0800
@@ -25,10 +25,9 @@
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
 	const PersistFactoryClass &	Get_Factory (void) const;
-	int Get_Harvester_ID() const
-	{
-		return HarvesterDefID;
-	}
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE (RefineryGameObjDef, BuildingGameObjDef);
 protected:
 	void					Load_Variables (ChunkLoadClass &cload);
diff -uwr sourceold/scripts/RepairBayGameObj.h source/scripts/RepairBayGameObj.h
--- sourceold/scripts/RepairBayGameObj.h	2011-10-11 21:44:44.096679600 +0800
+++ source/scripts/RepairBayGameObj.h	2012-05-23 11:14:19.778320300 +0800
@@ -26,7 +26,7 @@
 	~RepairBayGameObj (void);
 	virtual	void						Init( void );
 	void									Init (const RepairBayGameObjDef & definition);
-	const RepairBayGameObjDef &	Get_Definition (void) const;
+	SCRIPTS_API const RepairBayGameObjDef &	Get_Definition (void) const;
 	RepairBayGameObj *				As_RepairBayGameObj (void)	{ return this; }
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
diff -uwr sourceold/scripts/RepairBayGameObjDef.h source/scripts/RepairBayGameObjDef.h
--- sourceold/scripts/RepairBayGameObjDef.h	2011-10-11 21:44:42.151367100 +0800
+++ source/scripts/RepairBayGameObjDef.h	2012-05-06 16:37:05.252843700 +0800
@@ -26,6 +26,9 @@
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
 	const PersistFactoryClass &	Get_Factory (void) const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE (RepairBayGameObjDef, BuildingGameObjDef);
 protected:
 	void					Load_Variables (ChunkLoadClass &cload);
Only in source/scripts: SCAnnouncement.h
diff -uwr sourceold/scripts/SamSiteGameObj.h source/scripts/SamSiteGameObj.h
--- sourceold/scripts/SamSiteGameObj.h	2011-10-11 21:44:36.515625000 +0800
+++ source/scripts/SamSiteGameObj.h	2012-05-23 11:14:44.942382800 +0800
@@ -26,7 +26,7 @@
 	~SamSiteGameObj();
 	void Init();
 	void Init(const SamSiteGameObjDef &);
-	const SamSiteGameObjDef & Get_Definition( void ) const ;
+	SCRIPTS_API const SamSiteGameObjDef & Get_Definition( void ) const ;
 	bool Save(ChunkSaveClass &csave);
 	bool Load(ChunkLoadClass &cload);
 	void Export_Frequent(BitStreamClass &BitStream);
diff -uwr sourceold/scripts/SamSiteGameObjDef.h source/scripts/SamSiteGameObjDef.h
--- sourceold/scripts/SamSiteGameObjDef.h	2011-10-11 21:44:34.754882800 +0800
+++ source/scripts/SamSiteGameObjDef.h	2012-05-06 16:37:05.265539100 +0800
@@ -21,6 +21,10 @@
 	bool Load(ChunkLoadClass &cload);
 	uint32 Get_Class_ID() const;
 	PersistClass *Create() const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+	virtual void                        DumpPhys (FileClass &file);
+#endif
 	DECLARE_EDITABLE(SamSiteGameObjDef,SmartGameObjDef);
 	friend class PresetDump;
 };
diff -uwr sourceold/scripts/ScriptManager.h source/scripts/ScriptManager.h
--- sourceold/scripts/ScriptManager.h	2011-03-28 17:16:44.035156200 +0800
+++ source/scripts/ScriptManager.h	2012-05-02 02:01:20.366210900 +0800
@@ -1,3 +1,14 @@
+/*	Renegade Scripts.dll
+	Copyright 2011 Tiberian Technologies
+
+	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.
+*/
 #ifndef TT_INCLUDE_SCRIPTMANAGER_H
 #define TT_INCLUDE_SCRIPTMANAGER_H
 #include "engine_vector.h"
diff -uwr sourceold/scripts/ScriptZoneGameObjDef.h source/scripts/ScriptZoneGameObjDef.h
--- sourceold/scripts/ScriptZoneGameObjDef.h	2011-10-11 21:44:14.845703100 +0800
+++ source/scripts/ScriptZoneGameObjDef.h	2012-05-06 16:37:05.291906200 +0800
@@ -39,6 +39,9 @@
 	const Vector3 &Get_Color() const {return Color;}
 	ZoneConstants::ZoneType Get_Type() const {return ZoneType;}
 	int Get_Preset_ID() const {return PresetID;}
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE (ScriptZoneGameObjDef, ScriptableGameObjDef);
 protected:
 	ZoneConstants::ZoneType ZoneType;
diff -uwr sourceold/scripts/ScriptableGameObj.h source/scripts/ScriptableGameObj.h
--- sourceold/scripts/ScriptableGameObj.h	2011-10-11 21:44:26.625000000 +0800
+++ source/scripts/ScriptableGameObj.h	2012-05-12 19:48:12.908203100 +0800
@@ -64,7 +64,7 @@
 	virtual	void	Think();
 	virtual	void	Post_Think();
 	virtual	void		Get_Position(Vector3 * set_pos) const		= 0;
-	void Add_Observer( GameObjObserverClass * observer );
+	void SCRIPTS_API Add_Observer( GameObjObserverClass * observer );
 	void SCRIPTS_API Remove_Observer( GameObjObserverClass * observer );
 	void Remove_All_Observers(void);
 	void Start_Observers( void );
diff -uwr sourceold/scripts/ScriptableGameObjDef.h source/scripts/ScriptableGameObjDef.h
--- sourceold/scripts/ScriptableGameObjDef.h	2011-10-11 21:44:24.187500000 +0800
+++ source/scripts/ScriptableGameObjDef.h	2012-05-06 16:37:05.279210900 +0800
@@ -18,6 +18,9 @@
 	ScriptableGameObjDef( void );
 	virtual bool								Save( ChunkSaveClass &csave );
 	virtual bool								Load( ChunkLoadClass &cload );
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE( ScriptableGameObjDef, BaseGameObjDef );
 	DynamicVectorClass<StringClass>		ScriptNameList; // 001C
 	DynamicVectorClass<StringClass>		ScriptParameterList; // 0034
diff -uwr sourceold/scripts/SimpleGameObjDef.h source/scripts/SimpleGameObjDef.h
--- sourceold/scripts/SimpleGameObjDef.h	2011-10-11 21:43:54.694335900 +0800
+++ source/scripts/SimpleGameObjDef.h	2012-05-06 16:37:05.310460900 +0800
@@ -22,6 +22,10 @@
 	PersistClass *Create() const;
 	bool Get_Is_Editor_Object() const { return IsEditorObject; }
 	int Get_Player_Terminal_Type() const {return PlayerTerminalType;}
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+	virtual void                        DumpPhys (FileClass &file);
+#endif
 	DECLARE_EDITABLE( SimpleGameObjDef, PhysicalGameObjDef );
 protected:
 	bool IsEditorObject; // 00A5
diff -uwr sourceold/scripts/SmartGameObj.h source/scripts/SmartGameObj.h
--- sourceold/scripts/SmartGameObj.h	2011-10-11 21:43:45.486328100 +0800
+++ source/scripts/SmartGameObj.h	2012-05-23 11:29:02.688476500 +0800
@@ -58,8 +58,8 @@
 	virtual void Set_Control_Owner(int control_owner)		{ ControlOwner = control_owner; }
 	PlayerDataClass * Get_Player_Data( void )						{ return PlayerData; }
 	void Set_Player_Data( PlayerDataClass * player_data );
-	bool Has_Player(void);
-	bool Is_Human_Controlled(void);
+	SCRIPTS_API bool Has_Player(void);
+	SCRIPTS_API bool Is_Human_Controlled(void);
 	bool Is_Controlled_By_Me(void);
 	virtual	void	Apply_Control( void );
 	virtual	void		Think();
diff -uwr sourceold/scripts/SmartGameObjDef.h source/scripts/SmartGameObjDef.h
--- sourceold/scripts/SmartGameObjDef.h	2011-10-11 21:43:42.815429600 +0800
+++ source/scripts/SmartGameObjDef.h	2012-05-06 16:37:05.324132800 +0800
@@ -26,6 +26,9 @@
 	virtual bool								Save( ChunkSaveClass &csave );
 	virtual bool								Load( ChunkLoadClass &cload );
 	bool Is_Stealthed() const {return IsStealthUnit;}
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE( SmartGameObjDef, ArmedGameObjDef );
 protected:
 	float											SightRange;
diff -uwr sourceold/scripts/SoldierFactoryGameObj.h source/scripts/SoldierFactoryGameObj.h
--- sourceold/scripts/SoldierFactoryGameObj.h	2011-10-11 21:43:39.913085900 +0800
+++ source/scripts/SoldierFactoryGameObj.h	2012-05-23 11:15:03.379882800 +0800
@@ -20,7 +20,7 @@
 	~SoldierFactoryGameObj (void);
 	virtual	void					Init( void );
 	void								Init (const SoldierFactoryGameObjDef & definition);
-	const SoldierFactoryGameObjDef &	Get_Definition (void) const;
+	SCRIPTS_API const SoldierFactoryGameObjDef &	Get_Definition (void) const;
 	SoldierFactoryGameObj *				As_SoldierFactoryGameObj (void)	{ return this; }
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
diff -uwr sourceold/scripts/SoldierFactoryGameObjDef.h source/scripts/SoldierFactoryGameObjDef.h
--- sourceold/scripts/SoldierFactoryGameObjDef.h	2011-10-11 21:43:37.670898400 +0800
+++ source/scripts/SoldierFactoryGameObjDef.h	2012-05-06 16:37:05.337804700 +0800
@@ -22,6 +22,9 @@
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
 	const PersistFactoryClass &	Get_Factory (void) const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE (SoldierFactoryGameObjDef, BuildingGameObjDef);
 protected:
 	void					Load_Variables (ChunkLoadClass &cload);
diff -uwr sourceold/scripts/SoldierGameObj.h source/scripts/SoldierGameObj.h
--- sourceold/scripts/SoldierGameObj.h	2012-02-23 16:37:06.592773400 +0800
+++ source/scripts/SoldierGameObj.h	2012-05-23 11:25:50.666992100 +0800
@@ -17,13 +17,14 @@
 #include "SmartGameObj.h"
 #include "PhysClass.h"
 #include "ArmorWarheadManager.h"
+#include "TransitionGameObjDef.h"
 class TransitionInstanceClass;
 class RenderObjClass;
 class SimpleAnimControlClass;
 class TransitionCompletionDataStruct
 {
 public:
-	int Type;
+	TransitionDataClass::StyleType Type;
 	ReferencerClass Vehicle;
 	bool Save(ChunkSaveClass &csave);
 	bool Load(ChunkLoadClass &cload);
@@ -44,7 +45,7 @@
 	void	Init( const SoldierGameObjDef & definition );
 	void	Copy_Settings( const SoldierGameObjDef & definition );
 	void	SCRIPTS_API Re_Init( const SoldierGameObjDef & definition );
-	const SoldierGameObjDef & Get_Definition( void ) const ;
+	SCRIPTS_API const SoldierGameObjDef & Get_Definition( void ) const ;
 	virtual	bool	Save( ChunkSaveClass & csave );
 	virtual	bool	Load( ChunkLoadClass & cload );
 	virtual	void	On_Post_Load( void );
@@ -58,6 +59,12 @@
 	virtual	void	Apply_Damage( const OffenseObjectClass & damager, float scale = 1.0f, int alternate_skin = -1 );
    virtual	void	Apply_Damage_Extended( const OffenseObjectClass & offense, float scale = 1.0f,
 			const	Vector3 & direction = Vector3( 0,0,0 ), const char * collision_box_name = NULL );
+
+  /*! A clone of Apply_Damage() which ignores whether the soldier is currently in a vehicle - this
+  * is necessary for dp88_remoteControlConsole to kill the driver of a remote control vehicle when
+  * the 'dummy' version of the driver is killed. */
+  virtual void Apply_Damage_IgnoreVehicleCheck( const OffenseObjectClass & damager, float scale = 1.0f, int alternate_skin = -1 );
+
 	virtual	void	Completely_Damaged( const OffenseObjectClass & damager ) {}
 	virtual CollisionReactionType	Collision_Occurred( const CollisionEventClass & event );
 	virtual	Vector3	Get_Bullseye_Position( void );
@@ -81,7 +88,7 @@
 	void				Interpret_Sc_State_Data(HumanStateClass::HumanStateType state, 
 							int sub_state, LPCSTR trans_name, const Vector3 & velocity, const Vector3 & sc_position);
 	int				Tally_Vis_Visible_Soldiers(void);
-	bool				Is_In_Elevator(void);
+	SCRIPTS_API bool				Is_In_Elevator(void);
 	virtual void	Export_Creation( BitStreamClass &packet );
 	virtual void	Import_Creation( BitStreamClass &packet );
 	virtual void	Export_Rare( BitStreamClass &packet );
diff -uwr sourceold/scripts/SoldierGameObjDef.h source/scripts/SoldierGameObjDef.h
--- sourceold/scripts/SoldierGameObjDef.h	2012-02-13 17:49:26.127351500 +0800
+++ source/scripts/SoldierGameObjDef.h	2012-05-06 16:37:05.348546900 +0800
@@ -30,9 +30,13 @@
 	virtual bool								Load( ChunkLoadClass &cload );
 	virtual const PersistFactoryClass &	Get_Factory( void ) const;
 	DialogueClass *							Get_Dialog_List( void )			{ return DialogList; }
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+	virtual void                        DumpPhys (FileClass &file);
+#endif
 	DECLARE_EDITABLE( SoldierGameObjDef, SmartGameObjDef );
-	float Get_Skeleton_Height() {return SkeletonHeight;};
-	float Get_Skeleton_Width() {return SkeletonWidth;};
+	float Get_Skeleton_Height() const {return SkeletonHeight;};
+	float Get_Skeleton_Width() const {return SkeletonWidth;};
 	bool Is_Spy() const {return IsSpy;}
 protected:
 	float											TurnRate;
diff -uwr sourceold/scripts/SoundBufferClass.h source/scripts/SoundBufferClass.h
--- sourceold/scripts/SoundBufferClass.h	2011-10-11 21:43:30.267578100 +0800
+++ source/scripts/SoundBufferClass.h	2012-04-14 04:09:47.430664000 +0800
@@ -23,6 +23,9 @@
 	uint32 uBits;      // 52
 	uint32 uChannels;  // 56
 	uint32 uType;      // 60
+	unsigned int flag;
+	int cachecount;
+	SoundBufferClass();
 	virtual ~SoundBufferClass();
 	virtual bool        Load_From_File   (const char* cFile);
 	virtual bool        Load_From_File   (FileClass& xFile);
@@ -38,7 +41,19 @@
 	virtual uint32      Get_Type         () const;
 	virtual bool        Is_Streaming     () const;
 	virtual void        Free_Buffer      ();
-	virtual void        Determine_Stats  (char*);
+	virtual void        Determine_Stats  (char *stats);
+};
+
+class StreamSoundBufferClass : public SoundBufferClass {
+public:
+	StreamSoundBufferClass();
+	virtual ~StreamSoundBufferClass();
+	virtual bool        Load_From_File   (const char* cFile);
+	virtual bool        Load_From_File   (FileClass& xFile);
+	virtual bool        Load_From_Memory (const char* cBuffer, uint32 uLength);
+	virtual bool        Is_Streaming     () const;
+	virtual void        Free_Buffer      ();
+	virtual bool        Load_From_File(void *handle, uint32 u1, uint32 u2);
 };
 
 #endif
\ No newline at end of file
diff -uwr sourceold/scripts/SpecialEffectsGameObj.h source/scripts/SpecialEffectsGameObj.h
--- sourceold/scripts/SpecialEffectsGameObj.h	2011-10-11 21:43:25.304687500 +0800
+++ source/scripts/SpecialEffectsGameObj.h	2012-05-23 11:15:20.002929600 +0800
@@ -20,7 +20,7 @@
 	const PersistFactoryClass &Get_Factory() const;
 	void Init();
 	void Init(const SpecialEffectsGameObjDef &);
-	const SpecialEffectsGameObjDef & Get_Definition( void ) const ;
+	SCRIPTS_API const SpecialEffectsGameObjDef & Get_Definition( void ) const ;
 	bool Save(ChunkSaveClass &csave);
 	bool Load(ChunkLoadClass &cload);
 	void Do_Effect();
diff -uwr sourceold/scripts/SpecialEffectsGameObjDef.h source/scripts/SpecialEffectsGameObjDef.h
--- sourceold/scripts/SpecialEffectsGameObjDef.h	2011-10-11 21:43:23.110351500 +0800
+++ source/scripts/SpecialEffectsGameObjDef.h	2012-05-06 16:37:05.358312500 +0800
@@ -21,6 +21,10 @@
 	bool Load(ChunkLoadClass &cload);
 	uint32 Get_Class_ID() const;
 	PersistClass *Create() const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+	virtual void                        DumpPhys (FileClass &file);
+#endif
 	DECLARE_EDITABLE(SpecialEffectsGameObjDef,PhysicalGameObjDef);
 private:
 	void Save_Variables(ChunkSaveClass &csave);
diff -uwr sourceold/scripts/TeamPurchaseSettingsDefClass.h source/scripts/TeamPurchaseSettingsDefClass.h
--- sourceold/scripts/TeamPurchaseSettingsDefClass.h	2011-10-11 21:41:45.217773400 +0800
+++ source/scripts/TeamPurchaseSettingsDefClass.h	2012-05-06 16:37:05.368078100 +0800
@@ -35,6 +35,9 @@
 	uint32 Get_Class_ID() const;
 	virtual PersistClass *Create() const;
 	static SCRIPTS_API TeamPurchaseSettingsDefClass *Get_Definition(TEAM team);
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE(TeamPurchaseSettingsDefClass,DefinitionClass);
 	void Delete(void)
 	{
diff -uwr sourceold/scripts/TransitionGameObj.h source/scripts/TransitionGameObj.h
--- sourceold/scripts/TransitionGameObj.h	2011-10-11 21:41:35.694335900 +0800
+++ source/scripts/TransitionGameObj.h	2012-05-23 11:15:26.267578100 +0800
@@ -22,21 +22,24 @@
 	Matrix3D Transform;
 	int LadderIndex;
 public:
+	const PersistFactoryClass &Get_Factory() const;
 	TransitionGameObj();
 	~TransitionGameObj();
-	void On_Post_Load();
-	const PersistFactoryClass &Get_Factory() const;
-	bool Save(ChunkSaveClass &csave);
-	bool Load(ChunkLoadClass &cload);
 	void Init();
 	void Init(const TransitionGameObjDef &definition);
-	const TransitionGameObjDef & Get_Definition( void ) const ;
+	SCRIPTS_API const TransitionGameObjDef & Get_Definition( void ) const ;
+	bool Save(ChunkSaveClass &csave);
+	bool Load(ChunkLoadClass &cload);
+	void On_Post_Load();
 	void Set_Transform(const Matrix3D &tm);
 	const Matrix3D &Get_Transform() const;
-	DynamicVectorClass<TransitionInstanceClass *> &Get_Transitions() {return Transitions;}
-	const DynamicVectorClass<TransitionInstanceClass *> &Get_Transitions() const {return Transitions;}
 	void Create_Transitions();
 	void Destroy_Transitions();
+	void Update_Transitions();
+	void Set_Ladder_Index();
+	int Get_Transition_Count() {return Transitions.Count();};
+	TransitionInstanceClass *Get_Transition(int trans) {return Transitions[trans];}
+	int Get_Ladder_Index() {return LadderIndex;}
 };
 
 #endif
diff -uwr sourceold/scripts/TransitionGameObjDef.h source/scripts/TransitionGameObjDef.h
--- sourceold/scripts/TransitionGameObjDef.h	2011-10-11 21:41:33.498046800 +0800
+++ source/scripts/TransitionGameObjDef.h	2012-05-06 16:37:05.377843700 +0800
@@ -16,7 +16,7 @@
 class TransitionDataClass
 {
 public:
-	enum TriggerType {
+	enum StyleType {
 		LADDER_EXIT_TOP,
 		LADDER_EXIT_BOTTOM,
 		LADDER_ENTER_TOP,
@@ -28,11 +28,11 @@
 		VEHICLE_ENTER,
 		VEHICLE_EXIT,
 	};
-	TriggerType triggerType; // 0000
-	OBBoxClass triggerZone; // 0004
-	StringClass animationName; // 0040
-	Matrix3D characterTransform; // 0044
-	TransitionDataClass() : triggerType(LADDER_EXIT_TOP)
+	StyleType Type; // 0000
+	OBBoxClass TriggerZone; // 0004
+	StringClass AnimationName; // 0040
+	Matrix3D CharacterTransform; // 0044
+	TransitionDataClass() : Type(LADDER_EXIT_TOP)
 	{
 	}
 	bool Save(ChunkSaveClass &csave);
@@ -40,9 +40,6 @@
 }; // 0074
 
 class TransitionGameObjDef : public BaseGameObjDef {
-private:
-	DECLARE_EDITABLE(TransitionGameObjDef,BaseGameObjDef);
-	DynamicVectorClass<TransitionDataClass *> Transitions;
 public:
 	TransitionGameObjDef() {};
 	~TransitionGameObjDef();
@@ -52,6 +49,14 @@
 	uint32 Get_Class_ID() const;
 	PersistClass *Create() const;
 	void Free_Transition_List();
+	DynamicVectorClass<TransitionDataClass *> &Get_Transitions() {return Transitions;}
+	const DynamicVectorClass<TransitionDataClass *> &Get_Transitions() const {return Transitions;}
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
+	DECLARE_EDITABLE(TransitionGameObjDef,BaseGameObjDef);
+private:
+	DynamicVectorClass<TransitionDataClass *> Transitions;
 	friend class PresetDump;
 };
 
diff -uwr sourceold/scripts/TransitionInstanceClass.h source/scripts/TransitionInstanceClass.h
--- sourceold/scripts/TransitionInstanceClass.h	2011-10-11 21:41:30.524414000 +0800
+++ source/scripts/TransitionInstanceClass.h	2012-04-14 04:09:46.772460900 +0800
@@ -18,16 +18,24 @@
 #include "Matrix3D.h"
 #include "ReferencerClass.h"
 #include "TransitionGameObjDef.h"
+#include "VehicleGameObj.h"
 class TransitionInstanceClass
 {
-	Matrix3D characterTransform; // 0000
-	OBBoxClass triggerZone; // 0030
-	ReferencerClass vehicle; // 006C
-	TransitionDataClass* definition; // 007C
-	int ladderId; // 0080
+private:
+	Matrix3D CharacterTransform; // 0000
+	OBBoxClass TriggerZone; // 0030
+	ReferencerClass Vehicle; // 006C
+	TransitionDataClass* Definition; // 007C
+	int LadderId; // 0080
 public:
-	int Get_Type() {return definition->triggerType;}
+	TransitionInstanceClass();
+	~TransitionInstanceClass();
+	void Start(SoldierGameObj *soldier);
+	bool Check(SoldierGameObj *soldier, bool b);
 	static void End(SoldierGameObj *,TransitionCompletionDataStruct *);
+	void Set_Parent_Transform(Matrix3D const &tm);
+	TransitionDataClass::StyleType Get_Type() {return Definition->Type;}
+	void Set_Vehicle(VehicleGameObj *obj) {Vehicle = obj;}
 }; // 0084
 
 #endif
\ No newline at end of file
Only in source/scripts: TwiddlerClass.cpp
diff -uwr sourceold/scripts/TwiddlerClass.h source/scripts/TwiddlerClass.h
--- sourceold/scripts/TwiddlerClass.h	2011-10-11 21:41:14.732421800 +0800
+++ source/scripts/TwiddlerClass.h	2012-05-06 16:37:05.393468700 +0800
@@ -26,6 +26,9 @@
 	uint32 Get_Class_ID() const {return 57344;}
 	virtual uint32 Get_Indirect_Class_ID() const {return m_IndirectClassID;}
 	virtual void Set_Indirect_Class_ID(uint32 class_id) {m_IndirectClassID = class_id;}
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE( TwiddlerClass, DefinitionClass );
 private:
 	uint32 m_IndirectClassID;
diff -uwr sourceold/scripts/VehicleFactoryGameObj.h source/scripts/VehicleFactoryGameObj.h
--- sourceold/scripts/VehicleFactoryGameObj.h	2011-10-21 09:32:27.700195300 +0800
+++ source/scripts/VehicleFactoryGameObj.h	2012-05-23 15:31:23.082031200 +0800
@@ -23,7 +23,7 @@
 	~VehicleFactoryGameObj (void);
 	virtual	void							Init( void );
 	void										Init (const VehicleFactoryGameObjDef & definition);
-	const VehicleFactoryGameObjDef &	Get_Definition (void) const;
+	SCRIPTS_API const VehicleFactoryGameObjDef &	Get_Definition (void) const;
 	VehicleFactoryGameObj *			As_VehicleFactoryGameObj (void)	{ return this; }
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
@@ -44,6 +44,11 @@
 	void					Export_Rare (BitStreamClass &packet);
 	static void			Set_Max_Vehicles_Per_Team(int max)		{ MaxVehiclesPerTeam = max; }
 	static int			Get_Max_Vehicles_Per_Team(void)			{ return MaxVehiclesPerTeam; }
+	void Set_Busy(bool busy)
+	{
+		IsBusy = busy;
+		Set_Object_Dirty_Bit(NetworkObjectClass::BIT_RARE,true);
+	}
 protected:
 	void					Load_Variables (ChunkLoadClass &cload);
 	virtual void		Destroy_Blocking_Objects (void);
diff -uwr sourceold/scripts/VehicleFactoryGameObjDef.h source/scripts/VehicleFactoryGameObjDef.h
--- sourceold/scripts/VehicleFactoryGameObjDef.h	2011-10-11 21:40:57.450195300 +0800
+++ source/scripts/VehicleFactoryGameObjDef.h	2012-05-06 16:37:05.403234400 +0800
@@ -30,6 +30,9 @@
 	float									Get_Total_Building_Time(void) const { return TotalBuildingTime; }
 	bool									Get_Flying_Waypaths_Enabled() const { return EnableFlyingWaypaths; }
 	bool									Get_Build_Ground_Only() const { return BuildGroundOnly; }
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE (VehicleFactoryGameObjDef, BuildingGameObjDef);
 protected:
 	void					Load_Variables (ChunkLoadClass &cload);
diff -uwr sourceold/scripts/VehicleGameObjDef.h source/scripts/VehicleGameObjDef.h
--- sourceold/scripts/VehicleGameObjDef.h	2012-02-13 17:16:25.394929700 +0800
+++ source/scripts/VehicleGameObjDef.h	2012-05-06 16:37:05.414953100 +0800
@@ -43,7 +43,14 @@
 	virtual PersistClass *					Create( void ) const ;
 	virtual bool								Save( ChunkSaveClass &csave );
 	virtual bool								Load( ChunkLoadClass &cload );
+#ifdef TT_EXPORTS
+	virtual	void	On_Post_Load( void );
+#endif
 	virtual const PersistFactoryClass &	Get_Factory( void ) const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+	virtual void                        DumpPhys (FileClass &file);
+#endif
 	DECLARE_EDITABLE( VehicleGameObjDef, SmartGameObjDef );
 	DynamicVectorClass<TransitionDataClass*> *					Get_Transition_List( void ) { return &Transitions; }
 	const DynamicVectorClass<TransitionDataClass*> &			Get_Transition_List( void ) const { return Transitions; }
@@ -54,6 +61,7 @@
 	VehicleType Get_Type() const {return Type;}
 	const StringClass &Get_Fire0_Anim() const {return Fire0Anim;}
 	const StringClass &Get_Fire1_Anim() const {return Fire1Anim;}
+	bool Get_Build_At_Ground() const {return BuildAtGround;}
 protected:
 	VehicleType									Type;
 	StringClass									TypeName;
@@ -76,6 +84,8 @@
 	int NodDestroyReportID;
 	bool CanBeStolen;
 	bool AllowStealthWhileEmpty;
+	bool BuildAtGround;
+	bool DualAim;
 	friend	class								VehicleGameObj;
 	friend class PresetDump;
 }; // size: 324
diff -uwr sourceold/scripts/WWAudioClass.h source/scripts/WWAudioClass.h
--- sourceold/scripts/WWAudioClass.h	2012-02-17 15:02:45.624023400 +0800
+++ source/scripts/WWAudioClass.h	2012-04-14 04:09:47.830078100 +0800
@@ -36,6 +36,7 @@
 typedef void *HSAMPLE;
 typedef void *H3DSAMPLE;
 typedef void *H3DPOBJECT;
+typedef void *HSTREAM;
 typedef signed int HTIMER;
 typedef void (_stdcall  *LPFNSOSCALLBACK)		(SoundSceneObjClass *sound_obj, uint32 user_param);
 typedef void (_stdcall  *LPFNEOSCALLBACK)		(SoundSceneObjClass *sound_obj, uint32 user_param);
@@ -254,7 +255,7 @@
 	SoundBufferClass *	Get_Sound_Buffer (FileClass &file, const char *string_id, bool is_3d);
 	SoundBufferClass *	Get_Sound_Buffer (const char *filename, bool is_3d);
 	SoundBufferClass *	Find_Cached_Buffer (const char *string_id);
-	SoundBufferClass *	Create_Sound_Buffer (FileClass &file, const char *string_id, bool is_3d);
+	SHADERS_API SoundBufferClass *	Create_Sound_Buffer (FileClass &file, const char *string_id, bool is_3d);
 	SoundBufferClass *	Create_Sound_Buffer (unsigned char *file_image, unsigned long bytes, const char *string_id, bool is_3d);
 	SHADERS_API bool						Cache_Buffer (SoundBufferClass *buffer, const char *string_id);
 	bool						Free_Cache_Space (int bytes);
diff -uwr sourceold/scripts/WarFactoryGameObj.h source/scripts/WarFactoryGameObj.h
--- sourceold/scripts/WarFactoryGameObj.h	2011-10-11 21:40:43.303710900 +0800
+++ source/scripts/WarFactoryGameObj.h	2012-05-23 11:16:03.893554600 +0800
@@ -22,7 +22,7 @@
 	~WarFactoryGameObj (void);
 	virtual	void						Init( void );
 	void									Init (const WarFactoryGameObjDef & definition);
-	const WarFactoryGameObjDef &	Get_Definition (void) const;
+	SCRIPTS_API const WarFactoryGameObjDef &	Get_Definition (void) const;
 	WarFactoryGameObj *				As_WarFactoryGameObj (void)	{ return this; }
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
diff -uwr sourceold/scripts/WarFactoryGameObjDef.h source/scripts/WarFactoryGameObjDef.h
--- sourceold/scripts/WarFactoryGameObjDef.h	2011-10-11 21:40:40.850585900 +0800
+++ source/scripts/WarFactoryGameObjDef.h	2012-05-06 16:37:05.425695300 +0800
@@ -26,6 +26,9 @@
 	bool									Save (ChunkSaveClass &csave);
 	bool									Load (ChunkLoadClass &cload);
 	const PersistFactoryClass &	Get_Factory (void) const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE (WarFactoryGameObjDef, VehicleFactoryGameObjDef);
 protected:
 	void					Load_Variables (ChunkLoadClass &cload);
diff -uwr sourceold/scripts/WeaponClass.h source/scripts/WeaponClass.h
--- sourceold/scripts/WeaponClass.h	2011-11-22 14:49:49.184570300 +0800
+++ source/scripts/WeaponClass.h	2012-05-23 10:58:06.363281200 +0800
@@ -100,7 +100,7 @@
 	float				Get_Recoil_Time( void )		{ return Definition->RecoilTime; }
 	float				Get_Recoil_Scale( void )	{ return Definition->RecoilScale; }
 	void				Set_Total_Rounds( int num );
-	int				Get_Total_Rounds( void );
+	SCRIPTS_API int				Get_Total_Rounds( void );
 	void Import_Ammo_Info(int16 ammoInfo);
 	int16 Export_Ammo_Info();
 	void				Add_Rounds( int num );
@@ -117,7 +117,7 @@
 	bool				Is_Loaded( void )							{ return (ClipRounds != 0); }
 	bool				Is_Reload_OK( void );
 	bool				Is_Reload_Needed( void )				{ return !Is_Loaded() && Is_Reload_OK(); }
-	float				Get_Range( void );
+	SCRIPTS_API float				Get_Range( void );
 	bool				Is_Model_Update_Needed( void )	{ return (UpdateModel == WEAPON_MODEL_UPDATE_IS_NEEDED); }
 	void				Reset_Model_Update( void )			{ UpdateModel = WEAPON_MODEL_UPDATE_NOT_NEEDED; CurrentAnimState = (WeaponAnimState)-1; }
 	bool				Is_Anim_Update_Needed( void )		{ return ( NextAnimState != CurrentAnimState ); }
diff -uwr sourceold/scripts/anticheat.ini source/scripts/anticheat.ini
--- sourceold/scripts/anticheat.ini	2012-02-18 13:32:47.225585900 +0800
+++ source/scripts/anticheat.ini	2012-04-21 09:47:27.628906200 +0800
@@ -113,3 +113,11 @@
 909e932deec23ec75da3744306051b83=builtin_fxaa_sm3_hq.fxo
 1e7fca47542d374462af2fb81ec8a87c=builtin_fxaa_sm3_mq.fxo
 96d98d3a8dc579e76d9b57798a093936=builtin_fxaa_sm3_lq.fxo
+d0d6f19985a0423689531c7dee54b969=C&C_Canyon.lsd
+fad3a89c5605396475d9cd00a30ab1d4=C&C_Canyon.ldd
+f3875e9a955255b7cfb77c02f75fafd1=C&C_Canyon.lsd
+e57ab26c4790da800eb289e0518744df=C&C_Canyon.ldd
+2f760ea711b97cafa952bfbd5e990ab8=C&C_Canyon.mix
+18f1d1600b147d3ad8fdc91bc968ec95=tank_stealth_idle.wav
+9dc7f9fe39e97122f164dec1dbd1bdc4=tank_stealth_start.wav
+68cb626de41e5c24b0fc38879cc4ee1e=tank_stealth_stop.wav
Only in source/scripts: aow_intruders.cpp
Only in source/scripts: aow_intruders.h
Only in source/scripts: cNetEvent.h
diff -uwr sourceold/scripts/cPlayer.h source/scripts/cPlayer.h
--- sourceold/scripts/cPlayer.h	2011-10-11 21:56:41.257812500 +0800
+++ source/scripts/cPlayer.h	2012-05-23 11:03:51.978515600 +0800
@@ -68,8 +68,8 @@
 	void Get_Player_String(int id,WideStringClass &str,bool b);
 	void Increment_Kills();
 	void Increment_Deaths();
-	void Set_Kills(int kills);
-	void Set_Deaths(int deaths);
+	SCRIPTS_API void Set_Kills(int kills);
+	SCRIPTS_API void Set_Deaths(int deaths);
 
 	bool god; // 1876
 	WideStringClass PlayerName; // 1880
Only in source/scripts: cScTextObj.h
Only in source/scripts: cTeam.h
diff -uwr sourceold/scripts/definition.cpp source/scripts/definition.cpp
--- sourceold/scripts/definition.cpp	2011-10-11 23:03:55.115234300 +0800
+++ source/scripts/definition.cpp	2012-04-17 01:14:01.802734300 +0800
@@ -65,3 +65,19 @@
 	}
 	return true;
 }
+
+#ifdef DDBEDIT
+void DefinitionClass::Dump(FileClass &file)
+{
+	for (int i = 0;i < this->Get_Parameter_Count();i++)
+	{
+		ParameterClass *param = this->Lock_Parameter(i);
+		param->Dump(file);
+		this->Unlock_Parameter(i);
+	}
+}
+
+void DefinitionClass::DumpPhys(FileClass &phys)
+{
+}
+#endif
diff -uwr sourceold/scripts/dllmain.cpp source/scripts/dllmain.cpp
--- sourceold/scripts/dllmain.cpp	2012-02-27 12:49:54.797328100 +0800
+++ source/scripts/dllmain.cpp	2012-05-28 21:47:07.567382800 +0800
@@ -293,6 +293,7 @@
 	AddHostHook = (ahh)Address(tt,"AddHostHook");
 	AddRefillHook = (arh)Address(tt,"AddRefillHook");
 	AddLoadLevelHook = (allh)Address(tt,"AddLoadLevelHook");
+	AddPreLoadLevelHook = (allh)Address(tt,"AddPreLoadLevelHook");
 	AddGameOverHook = (allh)Address(tt,"AddGameOverHook");
 	AddThinkHook = (allh)Address(tt,"AddThinkHook");
 	AddPlayerJoinHook = (apjh)Address(tt,"AddPlayerJoinHook");
@@ -306,6 +307,8 @@
 	Get_Vehicle_Limit = (gvl)Address(tt,"Get_Vehicle_Limit");
 	Set_Air_Vehicle_Limit = (svl)Address(tt,"Set_Air_Vehicle_Limit");
 	Get_Air_Vehicle_Limit = (gvl)Address(tt,"Get_Air_Vehicle_Limit");
+	Set_Naval_Vehicle_Limit = (svl)Address(tt,"Set_Naval_Vehicle_Limit");
+	Get_Naval_Vehicle_Limit = (gvl)Address(tt,"Get_Naval_Vehicle_Limit");
 	Send_Message = (sm)Address(tt,"Send_Message");
 	Send_Message_Player = (smp)Address(tt,"Send_Message_Player");
 	Commands->Display_Health_Bar = (void(*)( GameObject * object, bool display ))Address(tt,"New_Display_Health_Bar");
@@ -347,6 +350,8 @@
 	GetExplosionObj = (geo)Address(tt,"GetExplosionObj");
 	SetExplosionObj = (seo)Address(tt,"SetExplosionObj");
 	Update_Network_Object = (uno)Address(tt,"Update_Network_Object");
+	Send_Client_Text = (sct)Address(tt,"Send_Client_Text");
+	Send_Client_Announcement = (sca)Address(tt,"Send_Client_Announcement");
 	gttv GetTTVersion = (gttv)Address(tt,"GetTTVersion");
 	Commands->Control_Enable = (void(*)( GameObject * obj, bool enable ))Address(tt,"New_Control_Enable");
 	AddShaderNotify = (asn)Address(tt,"AddShaderNotify");
@@ -391,6 +396,7 @@
 	Get_Team_Credits = (gtc)Address(tt,"Get_Team_Credits");
 	addConnectionAcceptanceFilter = (addConnectionAcceptanceFilterType)Address(tt, "addConnectionAcceptanceFilter");
 	removeConnectionAcceptanceFilter = (removeConnectionAcceptanceFilterType)Address(tt, "removeConnectionAcceptanceFilter");
+	Is_WOL_User = (iwu)Address(tt, "Is_WOL_User");
 	Evict_Client = (ec)Address(tt,"Evict_Client");
 	Get_Current_Map_Index = (gcmi)Address(tt,"Get_Current_Map_Index");
 	Get_Player_List = (gpl)Address(tt,"Get_Player_List");
@@ -399,6 +405,8 @@
 	Set_Map = (smx)Address(tt,"Set_Map");
 	Get_Game_Definitions = (ggd)Address(tt,"Get_Game_Definitions");
 	Get_Client_Serial_Hash = (gcsh)Address(tt,"Get_Client_Serial_Hash");
+	Get_Tech_Level = (gml)Address(tt,"Get_Tech_Level");
+	Set_Tech_Level = (sw)Address(tt,"Set_Tech_Level");
 	ssc ttssc = (ssc)Address(tt,"Set_Script_Commands");
 	ttssc(commands);
 #ifdef SSGM
diff -uwr sourceold/scripts/dp88_ar.cpp source/scripts/dp88_ar.cpp
--- sourceold/scripts/dp88_ar.cpp	2012-02-23 12:06:21.704101500 +0800
+++ source/scripts/dp88_ar.cpp	2012-05-23 10:32:15.882812500 +0800
@@ -21,6 +21,8 @@
 #include "VehicleGameObjDef.h"
 #include "MoveablePhysClass.h"
 #include "SList.h"
+#include "OffenseObjectClass.h"
+#include "WeaponBagClass.h"
 
 /*------------------------
 Game Controller
@@ -186,60 +188,6 @@
 		mirageTank_disguisePresets[2] = new char[strlen(mtDisguise)+1];
 		strcpy ( mirageTank_disguisePresets[2], mtDisguise );
 	}
-
-
-
-
-	// Disable VTOL units in non-flying maps
-	if ( !Is_Map_Flying() )
-	{
-		PurchaseSettingsDefClass* p = NULL;
-		DefinitionClass* d = NULL;
-
-		// Soviet - Vehicles
-		p = PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_VEHICLES,(PurchaseSettingsDefClass::TEAM)PTTEAM(0));
-		for ( int i = 0; p != NULL && i < 10; i++ )
-		{
-			d = Find_Definition(p->Get_Definition(i));
-			if ( d != NULL && d->Get_Class_ID() == (uint32)12304 && ((VehicleGameObjDef*)d)->Get_Type() == VEHICLE_TYPE_FLYING )
-			{
-				p->Set_Hidden(i,true);
-			}
-		}
-
-		// Allies - Vehicles
-		p = PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_VEHICLES,(PurchaseSettingsDefClass::TEAM)PTTEAM(1));
-		for ( int i = 0; p != NULL && i < 10; i++ )
-		{
-			d = Find_Definition(p->Get_Definition(i));
-			if ( d != NULL && d->Get_Class_ID() == (uint32)12304 && ((VehicleGameObjDef*)d)->Get_Type() == VEHICLE_TYPE_FLYING )
-			{
-				p->Set_Hidden(i,true);
-			}
-		}
-
-		// Soviet - Secret Vehicles
-		p = PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_SECRET_VEHICLES,(PurchaseSettingsDefClass::TEAM)PTTEAM(0));
-		for ( int i = 0; p != NULL && i < 10; i++ )
-		{
-			d = Find_Definition(p->Get_Definition(i));
-			if ( d != NULL && d->Get_Class_ID() == (uint32)12304 && ((VehicleGameObjDef*)d)->Get_Type() == VEHICLE_TYPE_FLYING )
-			{
-				p->Set_Hidden(i,true);
-			}
-		}
-
-		// Allies - Secret Vehicles
-		p = PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_SECRET_VEHICLES,(PurchaseSettingsDefClass::TEAM)PTTEAM(1));
-		for ( int i = 0; p != NULL && i < 10; i++ )
-		{
-			d = Find_Definition(p->Get_Definition(i));
-			if ( d != NULL && d->Get_Class_ID() == (uint32)12304 && ((VehicleGameObjDef*)d)->Get_Type() == VEHICLE_TYPE_FLYING )
-			{
-				p->Set_Hidden(i,true);
-			}
-		}
-	}
 }
 
 
@@ -595,7 +543,7 @@
 
 
 	// Install keyhook
-	if ( Is_Soldier ( obj ) && Get_Player_ID ( obj ) >= 0 )
+	if ( obj->As_SoldierGameObj() && Get_Player_ID ( obj ) >= 0 )
 		InstallHook( Get_Parameter("deployKeyhook"), obj );
 }
 
@@ -604,15 +552,17 @@
 {
 	// Find object
 	GameObject* obj = Commands->Find_Object ( objectID );
-	if ( !obj || Get_Vehicle(obj) || ((SoldierGameObj*)obj)->Is_On_Ladder() )
+	if ( !obj || Get_Vehicle(obj) || obj->As_SoldierGameObj()->Is_On_Ladder() || obj->As_SoldierGameObj()->Is_In_Elevator() )
 		return;
 
 	if ( deployed )
 	{
-		// If deployed for less than 4 seconds dont allow undeploy
-		if ( time(NULL) - lastDeploy < 4 )
+		// If deployed for less than undeployTime seconds dont allow undeploy
+		if ( time(NULL) - lastDeploy < Get_Float_Parameter("undeployTime") )
 		{
-			Send_Message_Player(obj,153,204,25,"You cannot undeploy yet, you must wait at least 4 seconds after deploying to undeploy.");
+			StringClass str;
+			str.Format("You cannot undeploy yet, you must wait at least %f seconds after deploying to undeploy.",Get_Float_Parameter("undeployTime"));
+			Send_Message_Player(obj,153,204,25,str);
 			return;
 		}
 
@@ -630,10 +580,12 @@
 	}
 	else
 	{
-		// If deployed for less than 8 seconds dont allow deploy
-		if ( time(NULL) - lastDeploy < 8 )
+		// If deployed for less than deployTime seconds dont allow deploy
+		if ( time(NULL) - lastDeploy < Get_Float_Parameter("deployTime") )
 		{
-			Send_Message_Player(obj,153,204,25,"You cannot deploy yet, you must wait at least 8 seconds after undeploying to deploy again.");
+			StringClass str;
+			str.Format("You cannot deploy yet, you must wait at least %f seconds after undeploying to deploy again.",Get_Float_Parameter("deployTime"));
+			Send_Message_Player(obj,153,204,25,str);
 			return;
 		}
 
@@ -1045,6 +997,7 @@
 	oreFieldValue = 0;
 	oreLoadLevel = 0;
 	oreValue = 0;
+	animating = false;
 
 	useAI = ( Get_Int_Parameter ( "enableAI" ) == 1 ) ? true : false;
 	aiState = MINER_AISTATE_IDLE;
@@ -1103,6 +1056,10 @@
 		// Unless we are already full increase our load level and the value of our load
 		if ( oreLoadLevel < Get_Int_Parameter("loadLevels") )
 		{
+      // Play the mining sound
+      if (strlen(Get_Parameter("miningSound")) > 0)
+        Commands->Create_Sound(Get_Parameter("miningSound"),Commands->Get_Position(obj),obj);
+
 			oreLoadLevel++;
 			oreValue += oreFieldValue*Get_Int_Parameter("orePerLoadLevel");
 		}
@@ -1111,8 +1068,16 @@
 		if ( oreLoadLevel < Get_Int_Parameter("loadLevels") )
 			Commands->Send_Custom_Event ( obj, obj, CUSTOM_MINER_INCREASE_ORE_LOAD, oreFieldRand, Get_Float_Parameter("timePerLoadLevel") );
 
-		// Otherwise we are full, if using the AI start driving to the refinery
-		else if ( useAI )
+
+    // Otherwise we are full of ore...
+    else
+    {
+      // Stop the mining animation
+      animating = false;
+      obj->As_PhysicalGameObj()->Clear_Animation();
+
+      // If using the AI start driving to the refinery
+      if ( useAI )
 		{
 			aiState = MINER_AISTATE_RETURN_TO_REFINERY;
 			ReturnToRefinery(obj);
@@ -1122,6 +1087,7 @@
 		else if ( Get_Vehicle_Driver(obj) != NULL )
 			Send_Message_Player ( Get_Vehicle_Driver(obj), 153, 204, 25, "Fully loaded with ore, dock at the Refinery to smelt the ore into credits" );
 	}
+  }
 
 
 	// Message from the ore dump zone notifying us that we have entered it. If
@@ -1206,14 +1172,24 @@
 	// If we are using AI then reset the action now that we have arrived
 	if ( useAI )
 		Commands->Action_Reset ( obj, 101.0f );
+
+  // Start the mining animation if it is not already running
+  if ((strlen(Get_Parameter("miningAnimation")) > 0) && !animating)
+  {
+    animating = true;
+    Commands->Set_Animation(obj,Get_Parameter("miningAnimation"),true,0,0,-1,false);
+  }
 }
 
 
 void dp88_AR_Miner::ExitedOreField ( GameObject *obj, GameObject* oreField )
 {
-	// If this is an AI miner and our state is still collecting ore then we
-	// were probably shoved out of the ore field by some bully in a vehicle
-	// so drive back in to finish mining
+  // Stop the mining animation
+  animating = false;
+  obj->As_PhysicalGameObj()->Clear_Animation();
+
+  // If this is an AI miner and our state is still collecting ore then we were probably shoved out
+  // of the ore field by some bully in a vehicle so drive back in to finish mining
 	if ( useAI && aiState == MINER_AISTATE_COLLECTING_ORE )
 		DriveToOreField(obj);
 }
@@ -1270,6 +1246,12 @@
 
 void dp88_AR_Miner::DockedAtRefinery ( GameObject *obj )
 {
+	// Start dock animation and sound
+	if (strlen(Get_Parameter("dockAnimation")) > 0)
+		Commands->Set_Animation(obj,Get_Parameter("dockAnimation"),false,0,0,-1,false);
+	if (strlen(Get_Parameter("dockSound")) > 0)
+		Commands->Create_Sound(Get_Parameter("dockSound"),Commands->Get_Position(obj),obj);
+
 	// If we are using AI then reset the action now that we have arrived
 	if (useAI)
 		Commands->Action_Reset ( obj, 101.0f );
@@ -1459,7 +1441,7 @@
 			// OK, got the closest... can we chronoshift there?
 
 			// Get physical game object and moveable phys class references (used to check if we can move to the zone)
-			MoveablePhysClass* mphys = ( As_PhysicalGameObj(obj) ) ? obj->As_PhysicalGameObj()->Peek_Physical_Object()->As_MoveablePhysClass() : NULL;
+			MoveablePhysClass* mphys = ( obj->As_PhysicalGameObj() ) ? obj->As_PhysicalGameObj()->Peek_Physical_Object()->As_MoveablePhysClass() : NULL;
 
 			// Can we move to this position without getting stuck?
 			if ( !mphys->Can_Teleport( Matrix3D( Commands->Get_Position(zone)) ) )
@@ -1787,9 +1769,9 @@
 
 
 
-/*------------------------
-Remote Control Console Script
---------------------------*/
+// -------------------------------------------------------------------------------------------------
+// Remote Control Console Script
+// -------------------------------------------------------------------------------------------------
 
 void dp88_RemoteControlConsole::Created ( GameObject *obj )
 {
@@ -1801,49 +1783,32 @@
 	m_bEnabled		= true;
 	m_nChargeTime	= Get_Int_Parameter ( "chargeTime" );
 
+  m_pLoopedAnimCtrl = new LoopedAnimationController(obj);
+
 	// Start charge tick timer if necessary and set initial animation frames
 	if ( m_nChargeTime > 0 )
 	{
 		Commands->Start_Timer( obj, this, 1.0f, TIMER_REMOTECONTROL_CHARGETICK);
-		animstate = 0;
-		Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameCharging1"), (float)Get_Int_Parameter("animFrameCharging2"), false );
+    m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("animationName"), Get_Int_Parameter("animFrameCharging1"), Get_Int_Parameter("animFrameCharging2") );
 	}
 	else
-	{
-		animstate = 1;
-		Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameAvailable1"), (float)Get_Int_Parameter("animFrameAvailable2"), false );
-	}
+    m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("animationName"), Get_Int_Parameter("animFrameAvailable1"), Get_Int_Parameter("animFrameAvailable2") );
 
 	Commands->Enable_HUD_Pokable_Indicator(obj, (m_nChargeTime == 0));
 }
 
-void dp88_RemoteControlConsole::Animation_Complete ( GameObject *obj, const char *animation_name )
+// -------------------------------------------------------------------------------------------------
+
+void dp88_RemoteControlConsole::Detach ( GameObject* obj )
 {
-	switch(animstate)
+	if (m_pLoopedAnimCtrl)
 	{
-	case 0:
-		obj->As_PhysicalGameObj()->Clear_Animation();
-		Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameCharging1"), (float)Get_Int_Parameter("animFrameCharging2"), false );
-		break;
-	case 1:
-		obj->As_PhysicalGameObj()->Clear_Animation();
-		Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameAvailable1"), (float)Get_Int_Parameter("animFrameAvailable2"), false );
-		break;
-	case 2:
-		obj->As_PhysicalGameObj()->Clear_Animation();
-		Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameActive1"), (float)Get_Int_Parameter("animFrameActive2"), false );
-		break;
-	case 3:
-		obj->As_PhysicalGameObj()->Clear_Animation();
-		Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameDisabled1"), (float)Get_Int_Parameter("animFrameDisabled2"), false );
-		break;
-	case 4:
-		obj->As_PhysicalGameObj()->Clear_Animation();
-		Commands->Set_Animation(obj, Get_Parameter("animFrameIdle1"), false, NULL, (float)Get_Int_Parameter("animFrameIdle2"), (float)Get_Int_Parameter("animFrameActive2"), false );
-		break;
+		delete m_pLoopedAnimCtrl;
 	}
 }
 
+// -------------------------------------------------------------------------------------------------
+
 void dp88_RemoteControlConsole::Poked ( GameObject *obj, GameObject *poker )
 {
 	//Console_Output ( "[%d:%s:%s] Poked\n", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), this->Get_Name() );
@@ -1933,6 +1898,7 @@
 	}
 }
 
+// -------------------------------------------------------------------------------------------------
 
 void dp88_RemoteControlConsole::Custom( GameObject *obj, int type, int param, GameObject *sender )
 {
@@ -1963,7 +1929,6 @@
 
 	else if ( type == CUSTOM_REMOTECONTROL_DRIVEREXIT )
 	{
-		//Console_Output ( "[%d:%s:%s] Driver exited, remote control unit now idle\n", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), this->Get_Name() );
 		DestroyDummy();
 		HandleDriverExit ( obj, Commands->Find_Object(pilotID), sender );
 		pilotID = NULL;
@@ -1975,6 +1940,14 @@
 
 		vehicleID = NULL;
 
+    // Make driver invisible and uncollidable so they can't be killed before they are teleported home
+    if ( GameObject* pilot = Commands->Find_Object(pilotID) )
+    {
+      Commands->Set_Is_Rendered ( pilot, false );
+      Commands->Disable_All_Collisions ( pilot );
+      Update_Network_Object(pilot);
+    }
+
 		// Start timer to return the pilot (if we do it immediately the game will crash...)
 		if ( pilotID != NULL )
 			Commands->Start_Timer ( obj, this, 0.5, TIMER_REMOTECONTROL_DRIVEREXIT );
@@ -1988,14 +1961,10 @@
 			if ( m_nChargeTime > 0 )
 			{
 				Commands->Start_Timer( obj, this, 1.0f, TIMER_REMOTECONTROL_CHARGETICK);
-				animstate = 0;
-				Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameCharging1"), (float)Get_Int_Parameter("animFrameCharging2"), false );
+        m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("animationName"), Get_Int_Parameter("animFrameCharging1"), Get_Int_Parameter("animFrameCharging2") );
 			}
 			else
-			{
-				animstate = 1;
-				Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameAvailable1"), (float)Get_Int_Parameter("animFrameAvailable2"), false );
-			}
+        m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("animationName"), Get_Int_Parameter("animFrameAvailable1"), Get_Int_Parameter("animFrameAvailable2") );
 		}
 
 		Commands->Enable_HUD_Pokable_Indicator(obj, (m_bEnabled && m_nChargeTime == 0));
@@ -2012,6 +1981,7 @@
 	}
 }
 
+// -------------------------------------------------------------------------------------------------
 
 void dp88_RemoteControlConsole::Timer_Expired ( GameObject *obj, int number )
 {
@@ -2050,8 +2020,7 @@
 			Create_2D_Sound_Player(pilot, Get_Parameter("connectionEstablishedSound") );
 
 			// Set animation frame
-			animstate = 2;
-			Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameActive1"), (float)Get_Int_Parameter("animFrameActive2"), false );
+      m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("animationName"), Get_Int_Parameter("animFrameActive1"), Get_Int_Parameter("animFrameActive2") );
 		}
 		else	// This should never actually happen... but just in case...
 		{
@@ -2083,14 +2052,15 @@
 				Commands->Start_Timer( obj, this, 1.0f, TIMER_REMOTECONTROL_CHARGETICK);
 			else
 			{
-				animstate = 1;
-				Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameAvailable1"), (float)Get_Int_Parameter("animFrameAvailable2"), false );
+        m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("animationName"), Get_Int_Parameter("animFrameAvailable1"), Get_Int_Parameter("animFrameAvailable2") );
 				Commands->Enable_HUD_Pokable_Indicator(obj, true);
 			}
 		}
 	}
 }
 
+// -------------------------------------------------------------------------------------------------
+
 void dp88_RemoteControlConsole::SetEnabled ( GameObject* obj, bool state )
 {
 	if ( state == m_bEnabled )
@@ -2106,6 +2076,13 @@
 		{
 			Soldier_Transition_Vehicle ( pilot );
 			Create_2D_Sound_Player(pilot, Get_Parameter("consoleOfflineSound") );
+
+      // Make driver invisible and uncollidable so they can't be killed before they are teleported home
+      Commands->Set_Is_Rendered ( pilot, false );
+      Commands->Disable_All_Collisions ( pilot );
+      Update_Network_Object(pilot);
+
+      // Can't do this instantly or the game crashes. Yay!
 			Commands->Start_Timer ( obj, this, 0.5, TIMER_REMOTECONTROL_DRIVEREXIT );
 		}
 	}
@@ -2115,26 +2092,23 @@
 
 	// Update the animation frame state
 	if ( !m_bEnabled )
-	{
-		animstate = 3;
-		Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameDisabled1"), (float)Get_Int_Parameter("animFrameDisabled2"), false );
-	}
+    m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("animationName"), Get_Int_Parameter("animFrameDisabled1"), Get_Int_Parameter("animFrameDisabled2") );
+
 	else if ( m_nChargeTime > 0 )
 	{
 		Commands->Start_Timer( obj, this, 1.0f, TIMER_REMOTECONTROL_CHARGETICK);
-		animstate = 0;
-		Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameCharging1"), (float)Get_Int_Parameter("animFrameCharging2"), false );
+    m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("animationName"), Get_Int_Parameter("animFrameCharging1"), Get_Int_Parameter("animFrameCharging2") );
 	}
+
 	else
-	{
-		animstate = 1;
-		Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameAvailable1"), (float)Get_Int_Parameter("animFrameAvailable2"), false );
-	}
+    m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("animationName"), Get_Int_Parameter("animFrameAvailable1"), Get_Int_Parameter("animFrameAvailable2") );
 }
 
+// -------------------------------------------------------------------------------------------------
+
 void dp88_RemoteControlConsole::CreateDummy ( GameObject* pilot, Vector3 position, float facing )
 {
-	GameObject* dummy = Commands->Create_Object ( "Invisible_Object", position );
+	GameObject* dummy = Commands->Create_Object ( "Invisible_Object_2", position );
 	if ( dummy )
 	{
 		m_pilotDummyID = Commands->Get_ID(dummy);
@@ -2159,6 +2133,8 @@
 	}
 }
 
+// -------------------------------------------------------------------------------------------------
+
 void dp88_RemoteControlConsole::DestroyDummy()
 {
 	if ( m_pilotDummyID != NULL )
@@ -2173,11 +2149,20 @@
 	}
 }
 
+// -------------------------------------------------------------------------------------------------
+
 void dp88_RemoteControlConsole::HandleDriverExit ( GameObject* obj, GameObject* pilot, GameObject* vehicle )
 {
 	if ( pilot )
+  {
 		Commands->Set_Position ( pilot, pilotDummyPos );
 
+    // Make driver visible and collidable again
+    Commands->Set_Is_Rendered ( pilot, true );
+    Commands->Enable_Collisions ( pilot );
+    Update_Network_Object(pilot);
+  }
+
 	// If the vehicle is still alive set it to its idle state
 	if ( vehicle )
 	{
@@ -2193,34 +2178,27 @@
 
 	// Set animation frame
 	if ( !m_bEnabled )
-	{
-		animstate = 3;
-		Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameDisabled1"), (float)Get_Int_Parameter("animFrameDisabled2"), false );
-	}
+    m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("animationName"), Get_Int_Parameter("animFrameDisabled1"), Get_Int_Parameter("animFrameDisabled2") );
+
 	else if ( vehicle )
-	{
-		animstate = 4;
-		Commands->Set_Animation(obj, Get_Parameter("animFrameIdle1"), false, NULL, (float)Get_Int_Parameter("animFrameIdle2"), (float)Get_Int_Parameter("animFrameActive2"), false );
-	}
+    m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("animationName"), Get_Int_Parameter("animFrameIdle2"), Get_Int_Parameter("animFrameActive2") );
+
 	else if ( m_nChargeTime > 0 )
 	{
 		Commands->Start_Timer( obj, this, 1.0f, TIMER_REMOTECONTROL_CHARGETICK);
-		animstate = 0;
-		Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameCharging1"), (float)Get_Int_Parameter("animFrameCharging2"), false );
+    m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("animationName"), Get_Int_Parameter("animFrameCharging1"), Get_Int_Parameter("animFrameCharging2") );
 	}
+
 	else
-	{
-		animstate = 1;
-		Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)Get_Int_Parameter("animFrameAvailable1"), (float)Get_Int_Parameter("animFrameAvailable2"), false );
-	}
+    m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("animationName"), Get_Int_Parameter("animFrameAvailable1"), Get_Int_Parameter("animFrameAvailable2") );
 }
 
 
 
 
-/*------------------------
-Remote Control Vehicle Script
---------------------------*/
+// -------------------------------------------------------------------------------------------------
+// Remote Control Vehicle Script
+// -------------------------------------------------------------------------------------------------
 
 void dp88_RemoteControlVehicle::Created ( GameObject *obj )
 {
@@ -2235,6 +2213,7 @@
 	Send_Custom_Event_To_Objects_With_Script(obj, "dp88_RemoteControlConsole", CUSTOM_REMOTECONTROL_CREATED, Get_Int_Parameter("remoteControlID"), 0 );
 }
 
+// -------------------------------------------------------------------------------------------------
 
 void dp88_RemoteControlVehicle::Custom( GameObject *obj, int type, int param, GameObject *sender )
 {
@@ -2268,6 +2247,7 @@
 	}
 }
 
+// -------------------------------------------------------------------------------------------------
 
 void dp88_RemoteControlVehicle::Killed ( GameObject* obj, GameObject* killer )
 {
@@ -2767,7 +2747,12 @@
 {
 	// Notify adjacent towers to stop assisting us if they were
 	for ( int i = 0; i < adjacentTowerCount; i++ )
+	{
+		if (Commands->Find_Object(adjacentTowers[i]) != obj)
+		{
 		Commands->Send_Custom_Event(obj,Commands->Find_Object(adjacentTowers[i]), CUSTOM_PRISMTOWER_STOP_CHARGING,0,0.0f);
+		}
+	}
 
 	// Deregister this tower
 	deregisterTower(Commands->Get_ID(obj));
@@ -2965,7 +2950,7 @@
 	// we are charging, if any
 	for ( int i = 0; i < adjacentTowerCount; ++i )
 	{
-		if ( adjacentTowers[i] != targetID )
+		if ( adjacentTowers[i] != targetID && Commands->Find_Object(adjacentTowers[i]) != obj)
 			Commands->Send_Custom_Event(obj, Commands->Find_Object(adjacentTowers[i]), CUSTOM_PRISMTOWER_REQUEST_CHARGING, (int)targetPriority, 0.0f );
 	}
 }
@@ -2977,8 +2962,13 @@
 {
 	// Send out end assistance notifications to all adjacent towers
 	for ( int i = 0; i < adjacentTowerCount; ++i )
+	{
+		if (Commands->Find_Object(adjacentTowers[i]) != obj)
+		{
 		Commands->Send_Custom_Event(obj, Commands->Find_Object(adjacentTowers[i]), CUSTOM_PRISMTOWER_STOP_CHARGING, 0, 0.0f );
 }
+	}
+}
 
 
 
@@ -3028,7 +3018,18 @@
 	// Destroy parent object if its still alive
 	GameObject* parent = Commands->Find_Object ( parentObjID );
 	if ( parent )
-		Commands->Apply_Damage ( parent, 5000.00, "Death", NULL );
+	{
+    // If the parent is a soldier in a vehicle we can't simply kill them because things go horribly wrong. Instead
+    // eject them from a vehicle and attach JFW_Timer_Destroy_Object to kill them as soon as possible.
+    if ( parent->As_SoldierGameObj() && parent->As_SoldierGameObj()->Is_In_Vehicle() )
+    {
+      Soldier_Transition_Vehicle ( parent );
+      Commands->Attach_Script ( parent, "JFW_Timer_Destroy_Object", "1.0,547859,5000.0,Death" );
+      Destroy_Script();   // Prevent equaliseHealth() getting called and trying to kill the driver
+    }
+		else
+		    Commands->Apply_Damage ( parent, 5000.00, "None", NULL );
+	}
 }
 
 void dp88_linkHealth::equaliseHealth ( GameObject* obj )
@@ -3043,8 +3044,15 @@
 	/* Work out difference in our health and armour since last check */
 	float difference = ((Commands->Get_Health(obj)-lastHealth)+(Commands->Get_Shield_Strength(obj)-lastArmour));
 
-	/* Apply damage to parent using 'None' warhead (this should be 1-1
-	ratio against all skin and shield types */
+	/* Apply damage to parent using 'None' warhead (this should be 1-1 ratio against all skin and
+  shield types. Special case scenario: if the target is a soldier in a vehicle we need to use a
+  special function to override the check that prevents damage to soldiers in a vehicle */
+  if ( parent->As_SoldierGameObj() && parent->As_SoldierGameObj()->Is_In_Vehicle() )
+  {
+    OffenseObjectClass offense(difference*-1.0f, ArmorWarheadManager::Get_Warhead_Type("None"), NULL);
+    parent->As_SoldierGameObj()->Apply_Damage_IgnoreVehicleCheck ( offense, 1, -1 );
+  }
+  else
 	Commands->Apply_Damage ( parent, difference*-1.0f, "None", NULL );
 
 	/* Update our health/armour from the parents new health/armour */
@@ -3100,9 +3108,9 @@
 // CLEG resistance script
 ScriptRegistrant<dp88_AR_CLEG_target> dp88_AR_CLEG_target_Registrant( "dp88_AR_CLEG_target", "resistance=20:int,clegEffectPreset=null:string" );
 
-// Ore Harvesting
-ScriptRegistrant<dp88_AR_Miner> dp88_AR_Miner_Registrant("dp88_AR_War_Miner","enableAI=1:int,loadLevels=10:int,orePerLoadLevel=100:int,timePerLoadLevel=2.0:float,unloadTime=8.0:float,aiStartDelay=10:int");
-ScriptRegistrant<dp88_AR_Chrono_Miner> dp88_AR_Chrono_Miner_Registrant("dp88_AR_Chrono_Miner","enableAI=1:int,chronoshift_time=2.5:float,chronoshift_out_effect_preset:string,chronoshift_out_effect_time:float,chronoshift_in_effect_preset:string,chronoshift_in_effect_time:float,chronoshiftKeyhook=VDeploy:string,loadLevels=10:int,orePerLoadLevel=50:int,timePerLoadLevel=1.00:float,unloadTime=4.0:float,emergencyChronoshiftHealthThreshold=30.0:float,aiStartDelay=10:int");
+// Ore Miners
+ScriptRegistrant<dp88_AR_Miner> dp88_AR_Miner_Registrant("dp88_AR_War_Miner","enableAI=1:int,loadLevels=10:int,orePerLoadLevel=100:int,timePerLoadLevel=2.0:float,unloadTime=8.0:float,aiStartDelay=10:int,dockAnimation:string,dockSound:string,miningAnimation:String,miningSound:string");
+ScriptRegistrant<dp88_AR_Chrono_Miner> dp88_AR_Chrono_Miner_Registrant("dp88_AR_Chrono_Miner","enableAI=1:int,chronoshift_time=2.5:float,chronoshift_out_effect_preset:string,chronoshift_out_effect_time:float,chronoshift_in_effect_preset:string,chronoshift_in_effect_time:float,chronoshiftKeyhook=VDeploy:string,loadLevels=10:int,orePerLoadLevel=50:int,timePerLoadLevel=1.00:float,unloadTime=4.0:float,emergencyChronoshiftHealthThreshold=30.0:float,aiStartDelay=10:int,dockAnimation:string,dockSound:string,miningAnimation:String,miningSound:string");
 ScriptRegistrant<dp88_AR_Chrono_Miner_Chronozone> dp88_AR_Chrono_Miner_Chronozone_Registrant("dp88_AR_Chrono_Miner_Chronozone","");
 ScriptRegistrant<dp88_AR_Ore_Field_Zone> dp88_AR_Ore_Field_Zone_Registrant("dp88_AR_Ore_Field_Zone","oreValue=1:int");
 ScriptRegistrant<dp88_AR_Ore_Deposit_Zone> dp88_AR_Ore_Deposit_Zone_Registrant("dp88_AR_Ore_Deposit_Zone","teamID=0:int");
diff -uwr sourceold/scripts/dp88_ar.h source/scripts/dp88_ar.h
--- sourceold/scripts/dp88_ar.h	2011-12-01 12:10:36.260742100 +0800
+++ source/scripts/dp88_ar.h	2012-05-23 10:33:45.797851500 +0800
@@ -183,12 +183,63 @@
 
 
 
-/*------------------------
-AR Miner Script - Base Class
+// -------------------------------------------------------------------------------------------------
 
-This base class is used by both the dp88_AR_Chrono_Miner and dp88_AR_War_Miner scripts
-and implements common functionality used by both scripts.
---------------------------*/
+/*!
+* \brief AR Miner Script
+* \author Daniel Paul (danpaul88@yahoo.co.uk)
+*
+* This class contains the basic logic for the ore miners used in Apocalypse Rising and supports both
+* AI and player controlled miners. A miner can collect ore from any ore fields defined by a script
+* zone with the dp88_AR_Ore_Field_Zone script attached to it, which determines the value of each ore
+* 'unit' in that field, thus implicitly supporting gem fields with the same scripts.
+*
+* The miner can hold up to a configurable number of ore units, each of which takes a configurable
+* amount of time to mine from the ore field. Mining is achieved by remaining inside an ore field
+* whilst ore units are 'collected'.
+*
+* Miners can deposit ore at any time as long as they have at least one unit mined, with the total
+* value of the deposit being based on the number of units collected and the value of each unit. Ore
+* deposits are achieved by entering a script zone with the dp88_AR_Ore_Deposit_Zone attached to it
+* with the team parameter matching that of the miner.
+*
+* When the AI is enabled the miner will use the pathfind grid to locate the nearest ore field and
+* drive to it to begin mining. Once it has collected a full load of ore it will locate the nearest
+* ore deposit zone and drive there to unload it's ore. This will be repeated ad-infinitum until the
+* miner is destroyed. If you have problems with the miner getting stuck on terrain or other objects
+* you should place pathfind blockers around the problematic areas and re-generate pathfind data to
+* make it route around those locations.
+*
+* \param enableAI
+*   Specifies that this miner should use its AI to mine autonomously. 1 to enable AI, 0 otherwise
+* \param loadLevels
+*   Specifies the total number of ore units this miner can hold at any time
+* \param orePerLoadLevel
+*   Amount of ore mined in each unit, this is multiplied by the oreValue parameter in the script
+*   attached to the ore field to calculate the credit value of each ore unit
+* \param timePerLoadLevel
+*   The amount of time, in seconds, it takes to mine one ore unit from an ore field
+* \param unloadtime
+*   The amount of time, in seconds, it takes to unload all ore units at an ore deposit zone
+* \param aiStartDelay
+*   If the miner AI is enabled this specifies the initial delay before starting the first AI action,
+*   which is required to avoid the original Renegade Harvester AI overriding this one.
+* \param dockAnimation
+*   An optional animation to be played when depositing ore at a refinery
+* \param dockSound
+*   An optional sound effect to be played when depositing ore at a refinery
+* \param miningAnimation
+*   An optional animation to be played in a loop whilst mining in an ore field
+* \param miningSound
+*   An optional sound effect to be played each time the ore load level increases
+*
+* \note
+*   Because this script is designed to act as a base class for both types of AR miner it is not
+*   named after either teams miner and does not appear as an available script in LevelEdit. However,
+*   because there is no additional logic required for the Soviet War Miner there isn't actually a
+*   derived script for that at this time, thus the dp88_AR_War_Miner script in LevelEdit is really
+*   an instance of this base class script.
+*/
 
 class dp88_AR_Miner : public JFW_Key_Hook_Base	// Inherit from keyhook base for chrono miner
 {
@@ -199,6 +250,7 @@
 	int oreValue;
 
 	bool useAI;				// Is AI enabled?
+	bool animating;         // Used to identify if the harvest animation is running so it doesn't start it a second time
 	int aiState;			// Current AI state
 
 public:
@@ -332,6 +384,9 @@
 
 
 /*!
+* \brief Remote Control Vehicle Console
+* \author Daniel Paul (danpaul88@yahoo.co.uk)
+*
 * This script is attached to consoles to allow players to take remote control of a drone vehicle
 * which is spawned by the console on demand. The vehicle preset which is spawned must have the
 * dp88_RemoteControlVehicle script attached with a matching remoteControlID parameter to work
@@ -385,11 +440,11 @@
 class dp88_RemoteControlConsole : public ScriptImpClass
 {
 	void Created( GameObject *obj );
+  void Detach ( GameObject* obj );
 	void Poked ( GameObject *obj, GameObject *poker );
 	void Custom( GameObject *obj, int type, int param, GameObject *sender );
 	void Timer_Expired( GameObject *obj, int number );
 	void SetEnabled ( GameObject* obj, bool state );
-	void Animation_Complete ( GameObject *obj, const char *animation_name );
 
 	int vehicleID;
 	int pilotID;
@@ -397,12 +452,15 @@
 	Vector3 pilotDummyPos;
 	bool m_bEnabled;
 	int m_nChargeTime;
-	int animstate;
-
 	void CreateDummy ( GameObject* pilot, Vector3 position, float facing );
 	void DestroyDummy();
 
 	void HandleDriverExit ( GameObject* obj, GameObject* pilot, GameObject* vehicle );
+
+protected:
+  LoopedAnimationController* m_pLoopedAnimCtrl;
+public:
+  dp88_RemoteControlConsole() : m_pLoopedAnimCtrl(0) {}
 };
 
 
@@ -548,8 +606,36 @@
 	void SendEndAssistanceNotifications(GameObject* obj);
 };
 
+// -------------------------------------------------------------------------------------------------
 
-// Script to link health / armour values of two objects together
+/*!
+* \brief Object health linking script
+* \author Daniel Paul (danpaul88@yahoo.co.uk)
+*
+* This is a simple script that links together the health and armour states of two different objects,
+* keeping them in constant sync. This is useful when an ingame entity is made up of two seperate
+* game objects, such as the AI controlled War Miner in Apocalypse Rising which spawns a seperate
+* gun turret to allow the logic for the turret and the miner to execute on seperate objects and
+* avoid conflicts between the attack and move-to actions.
+*
+* The script works on a parent/child basis, whereby the object this script is attached to is the
+* child and the parent is the object whose ID is specified in the script parameters. Upon creation
+* the script will inherit the maximum and current values of the parents health and armour states,
+* however it will maintain it's own skin and armour types, thus allowing for a child object to be
+* either more or less resistant to damage than it's parent, allowing the creation of strong or weak
+* points in the overall entities defences.
+*
+* This script is usually attached to dynamically created objects by other scripts and it's unlikely
+* to be attached to anything directly via LevelEdit.
+*
+* \param parentObjectId
+*   ID of the parent game object with which this objects health and armour will be linked
+*
+* \note
+*   You can link multiple child objects to a single parent object to create complex entities which
+*   consist of many parts, but you should always ensure the same object is designated as the parent
+*   to avoid conflicts between the scripts.
+*/
 class dp88_linkHealth : public ScriptImpClass
 {
 	void Created ( GameObject *obj );
@@ -562,6 +648,8 @@
 	float lastArmour;
 };
 
+// -------------------------------------------------------------------------------------------------
+
 
 
 
diff -uwr sourceold/scripts/dp88_ar_unitScripts.cpp source/scripts/dp88_ar_unitScripts.cpp
--- sourceold/scripts/dp88_ar_unitScripts.cpp	2012-02-02 17:58:48.974609300 +0800
+++ source/scripts/dp88_ar_unitScripts.cpp	2012-04-24 12:35:28.803710900 +0800
@@ -30,7 +30,7 @@
 	isDead = false;
 	lastDeploy = 0;
 
-	if ( Is_Soldier ( obj ) && Get_Player_ID ( obj ) >= 0 )
+	if ( obj->As_SoldierGameObj() && Get_Player_ID ( obj ) >= 0 )
 		InstallHook( Get_Parameter("Keyhook"), obj );
 	else
 		Destroy_Script();
diff -uwr sourceold/scripts/dp88_buildingScripts.cpp source/scripts/dp88_buildingScripts.cpp
--- sourceold/scripts/dp88_buildingScripts.cpp	2012-02-23 12:06:21.652343700 +0800
+++ source/scripts/dp88_buildingScripts.cpp	2012-05-23 10:20:24.692382800 +0800
@@ -19,9 +19,11 @@
 #include "BaseControllerClass.h"
 #include "WarFactoryGameObj.h"
 #include "AirFactoryGameObj.h"
+#include "NavalFactoryGameObj.h"
 #include "RefineryGameObj.h"
 #include "PurchaseSettingsDefClass.h"
 #include "PhysicalGameObj.h"
+#include "ArmorWarheadManager.h"
 
 /*------------------------
 Building Controller Script
@@ -100,7 +102,8 @@
 	{
 		// Get ID of child
 		int childId = Commands->Get_ID ( sender );
-
+		if (findChild(childId) == -1)
+		{
 		// Does child array exist?
 		if ( children != NULL )
 		{
@@ -128,6 +131,7 @@
 			children[0].type = param;
 		}
 	}
+	}
 
 
 
@@ -548,25 +552,11 @@
 Base Class For Generic Weakpoints
 --------------------------*/
 
-void MinorWeakpointScriptClass::Animation_Complete ( GameObject *obj, const char *animation_name )
-{
-	if (animstate == 0 && Get_Int_Parameter("animLoop"))
-	{
-		obj->As_PhysicalGameObj()->Clear_Animation();
-		Commands->Set_Animation ( obj, Get_Parameter("animName"), false, NULL, (float)Get_Int_Parameter("animStartFrame"), (float)Get_Int_Parameter("animEndFrame"), false );
-	}
-	if (animstate == 1 && Get_Int_Parameter("destroyedAnimLoop"))
-	{
-		obj->As_PhysicalGameObj()->Clear_Animation();
-		Commands->Set_Animation ( obj, Get_Parameter("destroyedAnimName"), false, NULL, (float)Get_Int_Parameter("destroyedAnimStartFrame"), (float)Get_Int_Parameter("destroyedAnimEndFrame"), false );
-	}
-}
-
 void MinorWeakpointScriptClass::Created ( GameObject *obj )
 {
 	// Set variables
 	isDestroyed = false;
-
+	m_pLoopedAnimCtrl = NULL;
 	// Find parent
 	GameObject* parent = Find_Object_By_Preset ( Get_Object_Type ( obj ), Get_Parameter("buildingControllerPreset") );
 	if ( parent != NULL )
@@ -575,12 +565,11 @@
 
 		// Send with 1 second delay to ensure parent has been initialized
 		Commands->Send_Custom_Event ( obj, parent, CUSTOM_BUILDINGSCRIPTS_REGISTERCHILD, BUILDING_CHILD_TYPE_MINOR_WEAKPOINT, 1.0f );
-
+		m_pLoopedAnimCtrl = new LoopedAnimationController(obj);
 		// Set animation
 		if ( strlen(Get_Parameter("animName")) > 0 )
 		{
-			animstate = 0;
-			Commands->Set_Animation ( obj, Get_Parameter("animName"), false, NULL, (float)Get_Int_Parameter("animStartFrame"), (float)Get_Int_Parameter("animEndFrame"), false );
+			m_pLoopedAnimCtrl->PlayAnimation(Get_Parameter("animName"),Get_Int_Parameter("animStartFrame"),Get_Int_Parameter("animEndFrame"),!Get_Int_Parameter("animLoop"));
 		}
 	}
 	else
@@ -609,8 +598,11 @@
 		// Set animation
 		if ( strlen(Get_Parameter("destroyedAnimName")) > 0 )
 		{
-			animstate = 1;
-			Commands->Set_Animation ( obj, Get_Parameter("destroyedAnimName"), false, NULL, (float)Get_Int_Parameter("destroyedAnimStartFrame"), (float)Get_Int_Parameter("destroyedAnimEndFrame"), false );
+			m_pLoopedAnimCtrl->PlayAnimation(Get_Parameter("destroyedAnimName"),Get_Int_Parameter("destroyedAnimStartFrame"),Get_Int_Parameter("destroyedAnimEndFrame"),!Get_Int_Parameter("destroyedAnimLoop"));
+		}
+		else
+		{
+			m_pLoopedAnimCtrl->StopAnimation();
 		}
 	}
 
@@ -631,8 +623,11 @@
 		// Set animation
 		if ( strlen(Get_Parameter("animName")) > 0 )
 		{
-			animstate = 0;
-			Commands->Set_Animation ( obj, Get_Parameter("animName"), false, NULL, (float)Get_Int_Parameter("animStartFrame"), (float)Get_Int_Parameter("animEndFrame"), false );
+			m_pLoopedAnimCtrl->PlayAnimation(Get_Parameter("animName"),Get_Int_Parameter("animStartFrame"),Get_Int_Parameter("animEndFrame"),!Get_Int_Parameter("animLoop"));
+		}
+		else
+		{
+			m_pLoopedAnimCtrl->StopAnimation();
 		}
 	}
 }
@@ -667,6 +662,13 @@
 		reverseEffect ( obj, parent );
 }
 
+void MinorWeakpointScriptClass::Detach ( GameObject *obj )
+{
+	if (m_pLoopedAnimCtrl)
+	{
+		delete m_pLoopedAnimCtrl;
+	}
+}
 
 
 
@@ -734,6 +736,27 @@
 	}
 }
 
+/*------------------------
+Weakpoint - Disable Naval Vehicle Purchase
+--------------------------*/
+
+void dp88_buildingScripts_weakpoint_disableNavalVehiclePurchase::applyEffect ( GameObject* obj, GameObject* parent )
+{
+	if (parent->As_BuildingGameObj() && parent->As_BuildingGameObj()->As_NavalFactoryGameObj())
+	{
+		parent->As_BuildingGameObj()->As_NavalFactoryGameObj()->Set_Disabled(true);
+		PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_NAVAL,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(parent)))->Set_Page_Disabled(true);
+	}
+}
+
+void dp88_buildingScripts_weakpoint_disableNavalVehiclePurchase::reverseEffect ( GameObject* obj, GameObject* parent )
+{
+	if (parent->As_BuildingGameObj() && parent->As_BuildingGameObj()->As_NavalFactoryGameObj())
+	{
+		parent->As_BuildingGameObj()->As_NavalFactoryGameObj()->Set_Disabled(false);
+		PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_NAVAL,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(parent)))->Set_Page_Disabled(false);
+	}
+}
 
 /*------------------------
 Weakpoint - Disable Base Power
@@ -817,12 +840,12 @@
 
 void dp88_buildingScripts_functionMoneyTrickle::Created ( GameObject *obj )
 {
+	isTimerRunning = false;
 	if ( Get_Object_Type(obj) == 0 || Get_Object_Type(obj) == 1 )
 	{
 		isTimerRunning = true;
 		Commands->Start_Timer(obj, this, 0.1f, TIMER_BUILDINGSCRIPTS_TRICKLEMONEY );
 	}
-	isTimerRunning = false;
 }
 
 void dp88_buildingScripts_functionMoneyTrickle::OnBuildingCaptured ( GameObject *obj, int team )
@@ -856,6 +879,38 @@
 }
 
 
+void dp88_buildingScripts_functionMoneyGrant::Created ( GameObject *obj )
+{
+	if ( Get_Object_Type(obj) == 0 || Get_Object_Type(obj) == 1 )
+	{
+		int team = Get_Object_Type(obj);
+		GameObject* pFirstPlayer = Find_First_Player(team);
+		if ( pFirstPlayer )
+		{
+			Commands->Give_Money(pFirstPlayer,Get_Float_Parameter("credits"),true);
+		}
+		if (Get_Int_Parameter("onceOnly") == 1)
+		{
+			Destroy_Script();
+		}
+	}
+}
+
+void dp88_buildingScripts_functionMoneyGrant::OnBuildingCaptured ( GameObject *obj, int team )
+{
+	if (team == 0 || team == 1)
+	{
+		GameObject* pFirstPlayer = Find_First_Player(team);
+		if ( pFirstPlayer )
+		{
+			Commands->Give_Money(pFirstPlayer,Get_Float_Parameter("credits"),true);
+		}
+		if (Get_Int_Parameter("onceOnly") == 1)
+		{
+			Destroy_Script();
+		}
+	}
+}
 
 
 /*------------------------
@@ -1064,7 +1119,7 @@
 
 		// Check parent is not a building (since changing the team of a BuildingGameObj results
 		// in some very strange behaviour that we really don't want)
-		if ( Is_Building(parent) )
+		if ( parent->As_BuildingGameObj() )
 		{
 			Console_Output ( "[%d:%s:%s] Critical Error: Building controller '%s' is of type BuildingGameObj, capturing is not possible. Destroying script...\n", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), this->Get_Name() );
 			Destroy_Script();
@@ -1095,14 +1150,18 @@
 }
 
 
+extern REF_DECL2(NodHouseColor, Vector3);
+extern REF_DECL2(GDIHouseColor, Vector3);
+extern REF_DECL2(PublicMessageColor, Vector3);
 void dp88_buildingScripts_capturePoint::Damaged( GameObject *obj, GameObject *damager, float amount )
 {
 	float health = Commands->Get_Health(obj);
 	float max = Commands->Get_Max_Health(obj);
 
-	// If the damager was on the Soviet team then decrease the health by 1 and
+	// If the damager was the soviet engineer then decrease the health by 1 and
 	// check if they have now captured the building
-	if ( Get_Object_Type(damager) == 0 )
+	unsigned int warhead = ArmorWarheadManager::Get_Warhead_Type(Get_Parameter("warhead"));
+	if (warhead == Get_Damage_Warhead() && Commands->Get_Player_Type(damager) == 0)
 	{
 		// Decrease health by 1.00 (unless we are already below 1.25 in which
 		// case we just set it to 0.25)
@@ -1113,6 +1172,33 @@
 		if ( health == 0.25f && currentTeam != 0 )
 		{
 			currentTeam = 0;
+			int red = (int)(NodHouseColor.X * 255);
+			int green = (int)(NodHouseColor.Y * 255);
+			int blue = (int)(NodHouseColor.Z * 255);
+			int stringall = Get_Int_Parameter("Sov_String_All");
+			if (stringall && Is_Valid_String_ID(stringall))
+			{
+				const char *str = Get_Translated_String(stringall);
+				Send_Message_Team(1,red,green,blue,str);
+				delete[] str;
+				int soundId = Get_String_Sound_ID(stringall);
+				if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000)
+				{
+					Create_2D_Sound_Team(Get_Definition_Name(soundId),1);
+				}
+			}
+			int stringsov = Get_Int_Parameter("Sov_String_Sov");
+			if (stringsov && Is_Valid_String_ID(stringsov))
+			{
+				const char *str = Get_Translated_String(stringsov);
+				Send_Message_Team(0,red,green,blue,str);
+				delete[] str;
+				int soundId = Get_String_Sound_ID(stringsov);
+				if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000)
+				{
+					Create_2D_Sound_Team(Get_Definition_Name(soundId),0);
+				}
+			}
 			Commands->Send_Custom_Event (obj, Commands->Find_Object(parentId), CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED, currentTeam, 0.0f );
 			Set_Object_Type(obj,currentTeam);
 		}
@@ -1120,6 +1206,33 @@
 		// OK, we didn't capture it, but did we manage to make it neutral?
 		else if ( currentTeam == 1 && health <= max/2.0f )
 		{
+			int red = (int)(PublicMessageColor.X * 255);
+			int green = (int)(PublicMessageColor.Y * 255);
+			int blue = (int)(PublicMessageColor.Z * 255);
+			int stringall = Get_Int_Parameter("Neutral_String_All");
+			if (stringall && Is_Valid_String_ID(stringall))
+			{
+				const char *str = Get_Translated_String(stringall);
+				Send_Message_Team(1,red,green,blue,str);
+				delete[] str;
+				int soundId = Get_String_Sound_ID(stringall);
+				if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000)
+				{
+					Create_2D_Sound_Team(Get_Definition_Name(soundId),1);
+				}
+			}
+			int stringsov = Get_Int_Parameter("Neutral_String_Sov");
+			if (stringsov && Is_Valid_String_ID(stringsov))
+			{
+				const char *str = Get_Translated_String(stringsov);
+				Send_Message_Team(0,red,green,blue,str);
+				delete[] str;
+				int soundId = Get_String_Sound_ID(stringsov);
+				if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000)
+				{
+					Create_2D_Sound_Team(Get_Definition_Name(soundId),0);
+				}
+			}
 			currentTeam = -2;
 			Commands->Send_Custom_Event (obj, Commands->Find_Object(parentId), CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED, currentTeam, 0.0f );
 			Set_Object_Type(obj,currentTeam);
@@ -1127,9 +1240,9 @@
 	}
 
 
-	// If the damager was on the Soviet team then increase the health by 1 and
+	// If the damager was the allied engineer then increase the health by 1 and
 	// check if they have now captured the building
-	else if ( Get_Object_Type(damager) == 1 )
+	else if (warhead == Get_Damage_Warhead() && Commands->Get_Player_Type(damager) == 1)
 	{
 		// Increase health by 1.00 (unless we are already less than 1.00 below the
 		// maximum in which case we just set it to the maximum)
@@ -1140,6 +1253,33 @@
 		if ( health == max && currentTeam != 1 )
 		{
 			currentTeam = 1;
+			int red = (int)(GDIHouseColor.X * 255);
+			int green = (int)(GDIHouseColor.Y * 255);
+			int blue = (int)(GDIHouseColor.Z * 255);
+			int stringall = Get_Int_Parameter("All_String_All");
+			if (stringall && Is_Valid_String_ID(stringall))
+			{
+				const char *str = Get_Translated_String(stringall);
+				Send_Message_Team(1,red,green,blue,str);
+				delete[] str;
+				int soundId = Get_String_Sound_ID(stringall);
+				if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000)
+				{
+					Create_2D_Sound_Team(Get_Definition_Name(soundId),1);
+				}
+			}
+			int stringsov = Get_Int_Parameter("All_String_Sov");
+			if (stringsov && Is_Valid_String_ID(stringsov))
+			{
+				const char *str = Get_Translated_String(stringsov);
+				Send_Message_Team(0,red,green,blue,str);
+				delete[] str;
+				int soundId = Get_String_Sound_ID(stringsov);
+				if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000)
+				{
+					Create_2D_Sound_Team(Get_Definition_Name(soundId),0);
+				}
+			}
 			Commands->Send_Custom_Event (obj, Commands->Find_Object(parentId), CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED, currentTeam, 0.0f );
 			Set_Object_Type(obj,currentTeam);
 		}
@@ -1147,6 +1287,33 @@
 		// OK, we didn't capture it, but did we manage to make it neutral?
 		else if ( currentTeam == 0 && health >= max/2.0f )
 		{
+			int red = (int)(PublicMessageColor.X * 255);
+			int green = (int)(PublicMessageColor.Y * 255);
+			int blue = (int)(PublicMessageColor.Z * 255);
+			int stringall = Get_Int_Parameter("Neutral_String_All");
+			if (stringall && Is_Valid_String_ID(stringall))
+			{
+				const char *str = Get_Translated_String(stringall);
+				Send_Message_Team(1,red,green,blue,str);
+				delete[] str;
+				int soundId = Get_String_Sound_ID(stringall);
+				if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000)
+				{
+					Create_2D_Sound_Team(Get_Definition_Name(soundId),1);
+				}
+			}
+			int stringsov = Get_Int_Parameter("Neutral_String_Sov");
+			if (stringsov && Is_Valid_String_ID(stringsov))
+			{
+				const char *str = Get_Translated_String(stringsov);
+				Send_Message_Team(0,red,green,blue,str);
+				delete[] str;
+				int soundId = Get_String_Sound_ID(stringsov);
+				if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000)
+				{
+					Create_2D_Sound_Team(Get_Definition_Name(soundId),0);
+				}
+			}
 			currentTeam = -2;
 			Commands->Send_Custom_Event (obj, Commands->Find_Object(parentId), CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED, currentTeam, 0.0f );
 			Set_Object_Type(obj,currentTeam);
@@ -1300,11 +1467,84 @@
 	partObjectId = NULL;
 }
 
+// -------------------------------------------------------------------------------------------------
+
+void dp88_buildingScripts_PT_Script::Created( GameObject *obj )
+{
+  m_pLoopedAnimCtrl = NULL;
+
+	// Find parent
+	GameObject* parent = Find_Object_By_Preset ( Get_Object_Type ( obj ), Get_Parameter("buildingControllerPreset") );
+	if ( parent != NULL )
+	{
+		parentId = Commands->Get_ID ( parent );
+
+		// Send with 1 second delay to ensure parent has been initialized
+		Commands->Send_Custom_Event ( obj, parent, CUSTOM_BUILDINGSCRIPTS_REGISTERCHILD, BUILDING_CHILD_TYPE_GENERIC, 1.0f );
+		Commands->Start_Timer(obj, this, 1.0f, TIMER_CHECK_BASE_POWER_STATE );
+		dead = false;
+		basePowerState = Is_Base_Powered(Get_Object_Type(obj));
+	    m_pLoopedAnimCtrl = new LoopedAnimationController(obj);
+		SetDamageAnimation(obj);
+	}
+	else
+	{
+		Console_Output ( "[%d:%s:%s] Critical Error: Building controller '%s' not found. Destroying script...\n", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), this->Get_Name(), Get_Parameter("buildingControllerPreset") );
+		Destroy_Script();
+	}
+}
+
+void dp88_buildingScripts_PT_Script::Detach ( GameObject *obj )
+{
+	if (m_pLoopedAnimCtrl)
+	{
+		delete m_pLoopedAnimCtrl;
+	}
+}
+
+void dp88_buildingScripts_PT_Script::Custom( GameObject *obj, int type, int param, GameObject *sender )
+{
+	if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGDESTROYED && Commands->Get_ID(sender) == parentId )
+	{
+		parentId = -1;
+		dead = true;
+		SetDamageAnimation(obj);
+	}
+}
 
+void dp88_buildingScripts_PT_Script::SetDamageAnimation ( GameObject* obj )
+{
+  int sFrame = 0;
+  int eFrame = 0;
 
+  if (basePowerState)
+  {
+    sFrame = (int)((dead) ? Get_Float_Parameter("DeadAnimationStartFrame") : Get_Float_Parameter("AliveAnimationStartFrame"));
+    eFrame = (int)((dead) ? Get_Float_Parameter("DeadAnimationEndFrame") : Get_Float_Parameter("AliveAnimationEndFrame"));
+  }
+  else
+  {
+    sFrame = (int)((dead) ? Get_Float_Parameter("LPDeadAnimationStartFrame") : Get_Float_Parameter("LPAliveAnimationStartFrame"));
+    eFrame = (int)((dead) ? Get_Float_Parameter("LPDeadAnimationEndFrame") : Get_Float_Parameter("LPAliveAnimationEndFrame"));
+  }
 
+  m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("Animation"), sFrame, eFrame );
+}
 
+void dp88_buildingScripts_PT_Script::Timer_Expired ( GameObject* obj, int number )
+{
+	if ( number == TIMER_CHECK_BASE_POWER_STATE )
+	{
+		if ( Is_Base_Powered(Get_Object_Type(obj)) != basePowerState )
+		{
+			basePowerState = !basePowerState;
+			SetDamageAnimation(obj);
+		}
 
+		// Restart timer
+		Commands->Start_Timer(obj, this, 1.0f, TIMER_CHECK_BASE_POWER_STATE );
+	}
+}
 
 ScriptRegistrant<dp88_buildingScripts_buildingController> dp88_buildingScripts_buildingController_Registrant( "dp88_buildingScripts_buildingController", "team0_buildingOfflineStringId=0:int,team1_buildingOfflineStringId=0:int,team0_buildingOnlineStringId=0:int,team1_buildingOnlineStringId=0:int" );
 
@@ -1315,15 +1555,18 @@
 ScriptRegistrant<dp88_buildingScripts_weakpoint_disableSoldierPurchase> dp88_buildingScripts_weakpoint_disableSoldierPurchase_Registrant( "dp88_buildingScripts_weakpoint_disableSoldierPurchase", "buildingControllerPreset:string,animName:string,animStartFrame=0:int,animEndFrame=0:int,animLoop=0:int,destroyedAnimName:string,destroyedAnimStartFrame=0:int,destroyedAnimEndFrame=0:int,destroyedAnimLoop=0:int" );
 ScriptRegistrant<dp88_buildingScripts_weakpoint_disableVehiclePurchase> dp88_buildingScripts_weakpoint_disableVehiclePurchase_Registrant( "dp88_buildingScripts_weakpoint_disableVehiclePurchase", "buildingControllerPreset:string,animName:string,animStartFrame=0:int,animEndFrame=0:int,animLoop=0:int,destroyedAnimName:string,destroyedAnimStartFrame=0:int,destroyedAnimEndFrame=0:int,destroyedAnimLoop=0:int" );
 ScriptRegistrant<dp88_buildingScripts_weakpoint_disableAirVehiclePurchase> dp88_buildingScripts_weakpoint_disableAirVehiclePurchase_Registrant( "dp88_buildingScripts_weakpoint_disableAirVehiclePurchase", "buildingControllerPreset:string,animName:string,animStartFrame=0:int,animEndFrame=0:int,animLoop=0:int,destroyedAnimName:string,destroyedAnimStartFrame=0:int,destroyedAnimEndFrame=0:int,destroyedAnimLoop=0:int" );
+ScriptRegistrant<dp88_buildingScripts_weakpoint_disableNavalVehiclePurchase> dp88_buildingScripts_weakpoint_disableNavalVehiclePurchase_Registrant( "dp88_buildingScripts_weakpoint_disableNavalVehiclePurchase", "buildingControllerPreset:string,animName:string,animStartFrame=0:int,animEndFrame=0:int,animLoop=0:int,destroyedAnimName:string,destroyedAnimStartFrame=0:int,destroyedAnimEndFrame=0:int,destroyedAnimLoop=0:int" );
 ScriptRegistrant<dp88_buildingScripts_weakpoint_disableBasePower> dp88_buildingScripts_weakpoint_disableBasePower_Registrant( "dp88_buildingScripts_weakpoint_disableBasePower", "buildingControllerPreset:string,animName:string,animStartFrame=0:int,animEndFrame=0:int,animLoop=0:int,destroyedAnimName:string,destroyedAnimStartFrame=0:int,destroyedAnimEndFrame=0:int,destroyedAnimLoop=0:int" );
 ScriptRegistrant<dp88_buildingScripts_weakpoint_disableRadar> dp88_buildingScripts_weakpoint_disableRadar_Registrant( "dp88_buildingScripts_weakpoint_disableRadar", "buildingControllerPreset:string,animName:string,animStartFrame=0:int,animEndFrame=0:int,animLoop=0:int,destroyedAnimName:string,destroyedAnimStartFrame=0:int,destroyedAnimEndFrame=0:int,destroyedAnimLoop=0:int" );
 ScriptRegistrant<dp88_buildingScripts_weakpoint_disableRefinery> dp88_buildingScripts_weakpoint_disableRefinery_Registrant( "dp88_buildingScripts_weakpoint_disableRefinery", "buildingControllerPreset:string,animName:string,animStartFrame=0:int,animEndFrame=0:int,animLoop=0:int,destroyedAnimName:string,destroyedAnimStartFrame=0:int,destroyedAnimEndFrame=0:int,destroyedAnimLoop=0:int" );
 
 ScriptRegistrant<dp88_buildingScripts_functionMoneyTrickle> dp88_buildingScripts_functionMoneyTrickle_Registrant( "dp88_buildingScripts_functionMoneyTrickle", "creditsPerSec=3.0:float" );
 ScriptRegistrant<dp88_buildingScripts_functionSpawnTeamZone> dp88_buildingScripts_functionSpawnTeamZone_Registrant( "dp88_buildingScripts_functionSpawnTeamZone", "scriptZonePreset_team0:string,scriptZonePreset_team1:string,scriptZonePreset_team2:string,scriptZoneBone:string,scriptZoneSize:vector3,destroyZoneWhenDisabled=1:int" );
+ScriptRegistrant<dp88_buildingScripts_functionMoneyGrant> dp88_buildingScripts_functionMoneyGrant_Registrant( "dp88_buildingScripts_functionMoneyGrant", "credits:float,onceOnly=1:int");
 
 ScriptRegistrant<dp88_buildingScripts_scriptZone> dp88_buildingScripts_scriptZone_Registrant( "dp88_buildingScripts_scriptZone", "buildingControllerPreset:string,scriptZonePreset:string,scriptZoneSize:vector3,destroyZoneWhenDisabled=1:int,destroyZoneWhenDestroyed=1:int" );
 
-ScriptRegistrant<dp88_buildingScripts_capturePoint> dp88_buildingScripts_capturePoint_Registrant( "dp88_buildingScripts_capturePoint", "buildingControllerPreset:string,dead_preset=null:string" );
+ScriptRegistrant<dp88_buildingScripts_capturePoint> dp88_buildingScripts_capturePoint_Registrant( "dp88_buildingScripts_capturePoint", "buildingControllerPreset:string,dead_preset=null:string,warhead:string,All_String_All:int,Sov_String_All:int,Neutral_String_All:int,All_String_Sov:int,Sov_String_Sov:int,Neutral_String_Sov:int");
 
 ScriptRegistrant<dp88_buildingScripts_spawnPart> dp88_buildingScripts_spawnPart_Registrant("dp88_buildingScripts_spawnPart","Building_Part_Preset:string,Spawn_At_Bone:string,IsDecorative=0:int");
\ No newline at end of file
+ScriptRegistrant<dp88_buildingScripts_PT_Script> dp88_buildingScripts_PT_Script_Registrant( "dp88_buildingScripts_PT_Script", "buildingControllerPreset:string,Animation:string,AliveAnimationStartFrame:float,AliveAnimationEndFrame:float,DeadAnimationStartFrame:float,DeadAnimationEndFrame:float,LPAliveAnimationStartFrame:float,LPAliveAnimationEndFrame:float,LPDeadAnimationStartFrame:float,LPDeadAnimationEndFrame:float");
diff -uwr sourceold/scripts/dp88_buildingScripts.h source/scripts/dp88_buildingScripts.h
--- sourceold/scripts/dp88_buildingScripts.h	2011-12-01 12:29:48.027343700 +0800
+++ source/scripts/dp88_buildingScripts.h	2012-05-23 10:33:45.716796800 +0800
@@ -9,8 +9,11 @@
 	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.
 */
+
 #pragma once
 
+#include "LoopedAnimationController.h"
+
 
 // Define building child types
 #define BUILDING_CHILD_TYPE_GENERIC				0
@@ -99,6 +102,24 @@
 	int parentId;
 };
 
+class dp88_buildingScripts_PT_Script : public ScriptImpClass
+{
+	void Created( GameObject *obj );
+  void Detach ( GameObject *obj );
+	void Custom( GameObject *obj, int type, int param, GameObject *sender );
+	void Timer_Expired ( GameObject* obj, int number );
+	void SetDamageAnimation ( GameObject* obj );
+
+	// ID of the building controller we belong to
+	int parentId;
+	bool dead;
+	bool basePowerState;
+
+protected:
+  LoopedAnimationController* m_pLoopedAnimCtrl;
+public:
+  dp88_buildingScripts_PT_Script() : m_pLoopedAnimCtrl(0) {}
+};
 
 
 
@@ -114,10 +135,10 @@
 class MinorWeakpointScriptClass : public ScriptImpClass
 {
 	void Created( GameObject *obj );
+  void Detach ( GameObject *obj );
 	void Damaged ( GameObject *obj, GameObject *damager, float amount );
 	void Killed( GameObject *obj, GameObject *killer );
 	void Custom( GameObject *obj, int type, int param, GameObject *sender );
-	void Animation_Complete ( GameObject *obj, const char *animation_name );
 
 	// ID of the building controller we belong to
 	int parentId;
@@ -125,11 +146,14 @@
 	// We use this to remember when we are in the destroyed state, so we know
 	// that when we next reach 100% health we need to trigger the repaired event
 	bool isDestroyed;
-	int animstate;
 
 	// Abstract functions
 	virtual void applyEffect ( GameObject *obj, GameObject *parent ) = 0;
 	virtual void reverseEffect ( GameObject *obj, GameObject *parent ) = 0;
+protected:
+  LoopedAnimationController* m_pLoopedAnimCtrl;
+public:
+  MinorWeakpointScriptClass() : m_pLoopedAnimCtrl(0) {}
 };
 
 
@@ -170,6 +194,16 @@
 };
 
 /*------------------------
+Weakpoint - Disable Naval Vehicle Purchase
+--------------------------*/
+
+class dp88_buildingScripts_weakpoint_disableNavalVehiclePurchase : public MinorWeakpointScriptClass
+{
+	void applyEffect ( GameObject *obj, GameObject *parent );
+	void reverseEffect ( GameObject *obj, GameObject *parent );
+};
+
+/*------------------------
 Weakpoint - Disable Base Power
 --------------------------*/
 
@@ -247,6 +281,12 @@
 };
 
 
+class dp88_buildingScripts_functionMoneyGrant : public dp88_BuildingEffectScript
+{
+	void Created ( GameObject* obj );
+	void OnBuildingCaptured ( GameObject* obj, int team );
+};
+
 // Spawn team zone - spawns a script zone depending on which team currently owns
 // the building
 class dp88_buildingScripts_functionSpawnTeamZone : public dp88_BuildingEffectScript
diff -uwr sourceold/scripts/dp88_customAI.cpp source/scripts/dp88_customAI.cpp
--- sourceold/scripts/dp88_customAI.cpp	2011-10-22 21:53:45.773437500 +0800
+++ source/scripts/dp88_customAI.cpp	2012-05-23 10:21:56.112304600 +0800
@@ -9,11 +9,13 @@
 	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 files
 #include "general.h"
 #include "scripts.h"
 #include "engine.h"
 #include "dp88_customAI.h"
+#include "dp88_custom_timer_defines.h"
 #include "VehicleGameObj.h"
 
 /*------------------------
@@ -113,7 +115,7 @@
 		return 0.0;
 	}
 
-	if ( Is_Vehicle(target) && !IsVehicleAIEnabled(target->As_VehicleGameObj()) && IsVehicleEmpty(target->As_VehicleGameObj()) )
+	if ( target->As_VehicleGameObj() && !IsVehicleAIEnabled(target->As_VehicleGameObj()) && IsVehicleEmpty(target->As_VehicleGameObj()) )
 	{
 		if ( debug ) fprintf ( debugFile, "Target %d is an empty, non-AI vehicle, ignoring\n", Commands->Get_ID(target));
 		return 0.0;
@@ -123,15 +125,15 @@
 
 
 	// Assign base priority
-	if ( Is_Soldier ( target ) && !Get_Fly_Mode(target) )
+	if ( target->As_SoldierGameObj() && !Get_Fly_Mode(target) )
 		priority = (float)priority_infantry;
-	else if ( Is_VTOLVehicle ( target ) || (Is_Soldier(target) && Get_Fly_Mode(target)) )
+	else if ( Get_Vehicle_Mode ( target ) == VEHICLE_TYPE_FLYING || (target->As_SoldierGameObj() && Get_Fly_Mode(target)) )
 		priority = (float)priority_VTOL;
-	else if ( Is_Vehicle ( target ) && Is_Script_Attached ( target, "dp88_AI_heavyVehicleMarker" ) )
+	else if ( target->As_VehicleGameObj() && Is_Script_Attached ( target, "dp88_AI_heavyVehicleMarker" ) )
 		priority = (float)priority_heavyVehicle;
-	else if ( Is_Vehicle ( target ) )
+	else if ( target->As_VehicleGameObj() )
 		priority = (float)priority_lightVehicle;
-	else if ( Is_Building ( target ) )
+	else if ( target->As_BuildingGameObj() )
 		priority = (float)priority_building;
 
 	// Return if our base priority for this target type is 0
@@ -146,7 +148,7 @@
 
 	// Apply target value modifier (add X priority for every 10 credits the target
 	// cost to purchase - not applicable to buildings)
-	if ( !Is_Building( target ) )
+	if ( !target->As_BuildingGameObj() )
 	{
 		int cost = Get_Team_Cost( Commands->Get_Preset_Name ( target ), Commands->Get_Player_Type ( target ) );
 		priority += ((float)cost/10.0f) * modifier_target_value;
@@ -195,13 +197,13 @@
 
 bool dp88_customAI::getPrimary ( GameObject *target )
 {
-	if ( Is_Soldier ( target ) )
+	if ( target->As_SoldierGameObj() )
 		return primary_infantry;
-	else if ( Is_VTOLVehicle ( target ) )
+	else if ( Get_Vehicle_Mode ( target ) == VEHICLE_TYPE_FLYING )
 		return primary_VTOL;
-	else if ( Is_Vehicle ( target ) )
+	else if ( target->As_VehicleGameObj() )
 		return (Is_Script_Attached(target,"dp88_AI_heavyVehicleMarker")) ? primary_heavyVehicle : primary_lightVehicle;
-	else if ( Is_Building ( target ) )
+	else if ( target->As_BuildingGameObj() )
 		return primary_building;
 	return true;
 }
@@ -486,7 +488,7 @@
 		targetPriority = enemyPriority;
 		primary_target = attackPrimary;
 
-		if ( splashInfantry && Is_Soldier(enemy) )
+		if ( splashInfantry && enemy->As_SoldierGameObj() )
 		{
 			if ( debug ) fprintf ( debugFile, "Using splash damage against this target\n" );
 			attackLocation(obj,Commands->Get_Position(enemy),primary_target);
@@ -505,13 +507,12 @@
 		if ( targetID != 0 )
 		{
 			GameObject *target = Commands->Find_Object ( targetID );
-
-			if ( !checkPowerState(obj)
+			if (!target || !checkPowerState(obj)
 				|| ( Commands->Get_Health ( target ) + Commands->Get_Shield_Strength ( target ) <= 0 )
 				|| !checkTeam ( obj, target )
 				|| !checkRange ( obj, target, primary_target )
 				|| (int)time(NULL) - targetLastSeen > 3
-				|| ( Is_Vehicle(target) && !IsVehicleAIEnabled(target->As_VehicleGameObj()) && IsVehicleEmpty(target->As_VehicleGameObj()) ) )
+				|| ( target->As_VehicleGameObj() && !IsVehicleAIEnabled(target->As_VehicleGameObj()) && IsVehicleEmpty(target->As_VehicleGameObj()) ))
 			{
 				if ( debug ) fprintf ( debugFile, "Target %d no longer valid, ceasing attack.\n", targetID);
 				targetID = 0;
@@ -522,7 +523,7 @@
 
 			// Otherwise we are OK to continue attacking... if this is an infantry unit
 			// and splash targetting is enabled then update targetting position
-			else if ( splashInfantry && Is_Soldier(target) )
+			else if ( splashInfantry && target->As_SoldierGameObj() )
 				attackLocation ( obj, Commands->Get_Position(target), primary_target );
 		}
 
@@ -636,12 +637,436 @@
 
 
 
-/*------------------------
-Script Registrants
---------------------------*/
+// -------------------------------------------------------------------------------------------------
+//  Popup Turret AI
+// -------------------------------------------------------------------------------------------------
 
-ScriptRegistrant<dp88_tankAI_Offensive> dp88_tankAI_Offensive_Registrant("dp88_tankAI_Offensive","Priority_Infantry=1:int,Weapon_Infantry=1:int,priority_lightVehicle=5:int,priority_heavyVehicle=7:int,Weapon_Vehicle=1:int,Priority_VTOL=5:int,Weapon_VTOL=1:int,Priority_Building=12:int,Weapon_Building=1:int,Max_Attack_Range=150:int,Min_Attack_Range=0:int,Preferred_Attack_Range=60:int,Max_Attack_Range_Secondary=150:int,Min_Attack_Range_Secondary=0:int,Preferred_Attack_Range_Secondary=60:int");
-ScriptRegistrant<dp88_AI_Turret> dp88_AI_Turret_Registrant("dp88_AI_Turret","Priority_Infantry=1.0:float,Weapon_Infantry=1:int,Splash_Infantry=0:int,Priority_Light_Vehicle=5.0:float,Weapon_Light_Vehicle=5:int,Priority_Heavy_Vehicle=7.0:float,Weapon_Heavy_Vehicle=1:int,Priority_VTOL=5.0:float,Weapon_VTOL=1:int,Min_Attack_Range=0:int,Max_Attack_Range=150:int,Min_Attack_Range_Secondary=0:int,Max_Attack_Range_Secondary=150:int,Modifier_Distance=0.25:float,Modifier_Target_Damage=0.1:float,Modifier_Target_Value=0.05:float,Requires_Power=0:int,Debug=0:int");
+void dp88_AI_PopupTurret::Created ( GameObject* pSelf )
+{
+  m_deploymentState = STATE_UNDEPLOYED;
+  m_spotterId = 0;
+
+  // Create our spotter turret
+  GameObject* pSpotter = Commands->Create_Object ( Get_Parameter("Spotter_Preset"), Commands->Get_Position(pSelf) );
+  if ( pSpotter )
+  {
+    m_spotterId = Commands->Get_ID(pSpotter);
+
+    // Set the spotter turret to match our configuration, but invisible
+    Commands->Set_Model ( pSpotter, Get_Model(pSelf) );
+    Commands->Set_Is_Rendered ( pSpotter, false );
+	Commands->Enable_Enemy_Seen ( pSpotter, true );
+    Commands->Disable_All_Collisions ( pSpotter );
+    Commands->Innate_Enable ( pSpotter );
+    Set_Skin ( pSpotter, "Blamo" );
+
+    // Attach the spotter script
+    char scriptParams[20];
+    sprintf_s ( scriptParams, sizeof(scriptParams), "%d", Commands->Get_ID(pSelf) );
+    Commands->Attach_Script ( pSpotter, "dp88_AI_PopupTurret_Spotter", scriptParams );
+
+    // 'Deploy' the spotter turret so it can see what we would be able to see whilst deployed
+    Commands->Set_Animation_Frame ( pSpotter, Get_Parameter("Deploy_Animation"), Get_Int_Parameter("Deploy_Animation_Frames") );
+
+	// Make sure the turret itself starts popped down
+	Commands->Set_Animation_Frame ( pSelf, Get_Parameter("Deploy_Animation"), 0 );
+  }
+
+  dp88_AI_Turret::Created(pSelf);
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_PopupTurret::Timer_Expired ( GameObject* pSelf, int number )
+{
+  // Piggy-back the undeploy timer logic on the existing target check timer since its always running
+  if ( number == TIMER_CHECK_TARGET && m_deploymentState == STATE_DEPLOYED )
+  {
+    // If we have no target and have reached the undeploy timeout then trigger undeployment
+    if ( targetID == 0 && time(NULL) > m_undeployTime )
+      Undeploy(pSelf);
+    
+    // Else, if we have an active target, update the undeployment timeout time
+    else if ( targetID != 0 )
+      m_undeployTime = time(NULL)+Get_Int_Parameter("Deploy_Timeout");
+  }
+
+  dp88_AI_Turret::Timer_Expired(pSelf, number);
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_PopupTurret::Custom ( GameObject* pSelf, int type, int param, GameObject* pSender )
+{
+  if ( m_spotterId == Commands->Get_ID(pSender) )
+  {
+    // Spotter only ever sends us one type of message... enemy spotted! Note that we don't simply
+    // deploy here because it might be a target we can't / shouldn't attack, let Enemy_Seen decide
+    // if we actually need to do anything
+    GameObject* pEnemy = Commands->Find_Object(param);
+    if ( pEnemy )
+      Enemy_Seen(pSelf, pEnemy);
+  }
+  else
+    dp88_AI_Turret::Custom(pSelf, type, param, pSender);
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_PopupTurret::Animation_Complete ( GameObject* pSelf, const char* animation_name )
+{
+  if ( m_deploymentState == STATE_DEPLOYING )
+  {
+    m_deploymentState = STATE_DEPLOYED;
+    m_undeployTime = time(NULL)+Get_Int_Parameter("Deploy_Timeout");
+
+    // Reset targetting parameters, otherwise the next Enemy_Seen call will think we are already attacking
+    // an enemy and not trigger the appropriate actions we are depending upon
+    targetID = 0;
+  }
+  else if ( m_deploymentState == STATE_UNDEPLOYING )
+    m_deploymentState = STATE_UNDEPLOYED;
+
+  dp88_AI_Turret::Animation_Complete(pSelf, animation_name);
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_PopupTurret::Destroyed ( GameObject* pSelf )
+{
+  if ( GameObject* pSpotter = Commands->Find_Object(m_spotterId) )
+    Commands->Destroy_Object(pSpotter);
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_PopupTurret::attackTarget ( GameObject* pSelf, GameObject* pTarget, bool primary )
+{
+  if ( m_deploymentState == STATE_DEPLOYED )
+    dp88_AI_Turret::attackTarget(pSelf, pTarget, primary);
+  else
+    Deploy(pSelf); // No need to remember what we are deploying to shoot, enemy seen will be re-triggered
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_PopupTurret::attackLocation ( GameObject* pSelf, Vector3 location, bool primary )
+{
+  if ( m_deploymentState == STATE_DEPLOYED )
+    dp88_AI_Turret::attackLocation(pSelf, location, primary);
+  else
+    Deploy(pSelf); // No need to remember what we are deploying to shoot, enemy seen will be re-triggered
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_PopupTurret::Deploy ( GameObject* pSelf )
+{
+  if ( m_deploymentState == STATE_UNDEPLOYED || m_deploymentState == STATE_UNDEPLOYING )
+  {
+    m_deploymentState = STATE_DEPLOYING;
+
+    Commands->Set_Animation(pSelf,Get_Parameter("Deploy_Animation"),false,0,Get_Animation_Frame(pSelf),(float)Get_Int_Parameter("Deploy_Animation_Frames"),false);
+
+    if (_stricmp(Get_Parameter("Deploy_Sound"),"0"))
+      Commands->Create_Sound(Get_Parameter("Deploy_Sound"),Commands->Get_Position(pSelf),pSelf);
+  }
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_PopupTurret::Undeploy ( GameObject* pSelf )
+{
+  if ( m_deploymentState == STATE_DEPLOYED )
+  {
+    m_deploymentState = STATE_UNDEPLOYING;
+
+    Commands->Set_Animation(pSelf,Get_Parameter("Deploy_Animation"),false,0,(float)Get_Int_Parameter("Deploy_Animation_Frames"),0, false);
+
+    if (_stricmp(Get_Parameter("Deploy_Sound"),"0"))
+      Commands->Create_Sound(Get_Parameter("Deploy_Sound"),Commands->Get_Position(pSelf),pSelf);
+  }
+}
+
+
+
+
+
+
+
+// ------------------------------------------------------------------------------------------------
+//  Popup Turret Spotter
+// ------------------------------------------------------------------------------------------------
+
+void dp88_AI_PopupTurret_Spotter::Enemy_Seen ( GameObject* pSelf, GameObject* pEnemy )
+{
+  if ( GameObject* pTurret = Commands->Find_Object(Get_Int_Parameter("tId")) )
+    Commands->Send_Custom_Event ( pSelf, pTurret, CUSTOM_TURRETAI_ENEMYSEEN, Commands->Get_ID(pEnemy), 0.0f );
+}
+
+
+
+
+
+
+
+// -------------------------------------------------------------------------------------------------
+//  Charged Turret AI
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_ChargedTurret::Created ( GameObject* pSelf )
+{
+  m_bIsCharging = false;
+  m_bIsDischarging = false;
+  m_chargeAnimObjId = NULL;
+
+  // If a seperate charge animation model has been specified then go ahead and spawn it
+  if ( strlen ( Get_Parameter("Animation_Model") ) > 0 )
+  {
+    GameObject* pChargeAnimObj = Commands->Create_Object ( "Invisible_Object", Commands->Get_Position(pSelf) );
+    if ( pChargeAnimObj )
+    {
+      m_chargeAnimObjId = Commands->Get_ID(pChargeAnimObj);
+      Commands->Set_Model ( pChargeAnimObj, Get_Parameter("Animation_Model") );
+      Commands->Attach_To_Object_Bone ( pChargeAnimObj, pSelf, Get_Parameter("Animation_Model_Bone") );
+
+      // Create the looped animation controller on the charge animation object
+      m_pLoopedAnimCtrl = new LoopedAnimationController ( pChargeAnimObj );
+
+      // Attach companion script so we get notified about animation complete events - we need to know
+      // about these so we know when the charged animation is complete.
+      //
+      // \todo Could this be done by simply attaching this script as a listener on the charged
+      //       animation object directly and checking the GameObject pointers we get on each
+      //       event to check which object they came from? Not sure which is cleaner...
+      char scriptParams[20];
+      sprintf_s ( scriptParams, sizeof(scriptParams), "%d", Commands->Get_ID(pSelf) );
+      Commands->Attach_Script ( pChargeAnimObj, "dp88_AI_ChargedTurret_Animation", scriptParams );
+    }
+  }
+
+  // If we don't have a charge animation object create the looped animation controller on ourselves
+  if ( m_chargeAnimObjId == NULL )
+    m_pLoopedAnimCtrl = new LoopedAnimationController ( pSelf );
+
+  m_bPowerState = checkPowerState(pSelf);
+  ApplyIdleAnimation(pSelf);
+
+  dp88_AI_Turret::Created(pSelf);
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_ChargedTurret::Timer_Expired ( GameObject* pSelf, int number )
+{
+  // Piggy-back the base power state checks on the existing target check timer since its always
+  // running anyway. If the base power state changes we need to update the idle animation (and
+  // abort any charge up in progress)
+  if ( number == TIMER_CHECK_TARGET && m_bPowerState != checkPowerState(pSelf) )
+  {
+    m_bPowerState = !m_bPowerState;
+
+    // Charging state must always become false now - either we were unpowered to begin with or
+    // we were powered and have now gone offline. Either way, we can't possibly be charging now.
+    m_bIsCharging = false;
+
+    // If we were discharging our weapon we need to stop now and trigger a reload so we don't
+    // fire a partial charge next time around
+    if ( m_bIsDischarging )
+    {
+      m_bIsDischarging = false;
+      stopAttacking(pSelf);
+      Set_Current_Bullets(pSelf, 0);
+    }
+
+    // Apply the appropriate idle animation
+    ApplyIdleAnimation(pSelf);
+  }
+
+
+  // We might as well piggy back the discharged checks on the same timer too whilst we are at it...
+  if ( number == TIMER_CHECK_TARGET && m_bIsDischarging )
+  {
+    // Have we unloaded our entire clip? If so then we can start charging for the next attack
+    if ( Get_Current_Bullets(pSelf) == 0 )
+    {
+      m_bIsDischarging = false;
+      stopAttacking(pSelf);   // Don't want to fire again before we are ready!
+      if ( targetID != NULL )
+        StartCharging(pSelf);
+      else
+        ApplyIdleAnimation(pSelf);
+    }
+
+    // Has our target already died or ran like a coward before we could empty our clip? If so then
+    // reset and trigger a reload (so we don't have a partial charge next time round)
+    else if ( targetID == NULL )
+    {
+      m_bIsDischarging = false;
+      Set_Current_Bullets(pSelf, 0);
+      ApplyIdleAnimation(pSelf);
+    }
+  }
+
+  dp88_AI_Turret::Timer_Expired(pSelf, number);
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_ChargedTurret::Animation_Complete ( GameObject* pSelf, const char* animation_name )
+{
+  if (!_stricmp(animation_name,Get_Parameter("Animation"))) //make sure we are running the right animation
+  {
+    // Were we charging up? If so we are now fully charged and can start shooting stuff, if we still
+    // have a valid target...
+    if ( m_bIsCharging )
+    {
+      m_bIsCharging = false;
+      m_bIsDischarging = true;
+  
+      // Got an enemy? Also double check power state whilst we are here, just to be sure
+      if ( targetID != NULL && checkPowerState(pSelf) )
+      {
+        if ( GameObject* pTarget = Commands->Find_Object(targetID) )
+        {
+  
+          // Call into the base class and let it do it's thing
+          if ( splashInfantry && pTarget->As_SoldierGameObj() )
+            dp88_AI_Turret::attackLocation(pSelf, Commands->Get_Position(pTarget), primary_target);
+          else
+            dp88_AI_Turret::attackTarget(pSelf, pTarget, primary_target);
+        }
+      }
+    }
+  }
+
+  dp88_AI_Turret::Animation_Complete(pSelf, animation_name);
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_ChargedTurret::Destroyed ( GameObject* pSelf )
+{
+  if (m_pLoopedAnimCtrl)
+  {
+	delete m_pLoopedAnimCtrl;
+  }
+  
+  if ( m_chargeAnimObjId )
+  {
+    if ( GameObject* pChargeAnimObj = Commands->Find_Object(m_chargeAnimObjId) )
+      Commands->Destroy_Object(pChargeAnimObj);
+  }
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_ChargedTurret::attackTarget ( GameObject* pSelf, GameObject* pTarget, bool primary )
+{
+  // Changing targets in the middle of discharging? Sure, why not...
+  if ( m_bIsDischarging )
+    dp88_AI_Turret::attackTarget ( pSelf, pTarget, primary );
+
+  // Otherwise call StartCharging and let it determine what to do...
+  StartCharging(pSelf);
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_ChargedTurret::attackLocation ( GameObject* pSelf, Vector3 location, bool primary )
+{
+  // Changing targets in the middle of discharging? Sure, why not...
+  if ( m_bIsDischarging )
+    dp88_AI_Turret::attackLocation ( pSelf, location, primary );
+
+  // Otherwise call StartCharging and let it determine what to do...
+  StartCharging(pSelf);
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_ChargedTurret::StartCharging ( GameObject* pSelf )
+{
+  // If we are not charging, not discharging, powered and have a target then we can start a new
+  // charging cycle
+  if ( !m_bIsCharging && !m_bIsDischarging && checkPowerState(pSelf) && targetID != NULL )
+  {
+    m_bIsCharging = true;
+
+    // Only play a single iteration of the charge up animation - if we need to keep attacking after
+    // the shot is fired this will get called again
+    m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("Animation"), Get_Int_Parameter("Animation_Charge_Start_Frame"), Get_Int_Parameter("Animation_Charge_End_Frame"), 1 );
+
+    if (_stricmp(Get_Parameter("Charge_Sound"),"0"))
+      Commands->Create_Sound(Get_Parameter("Charge_Sound"),Commands->Get_Position(pSelf),pSelf);
+
+    // Nothing to do but wait for the charging to complete... hum de dum...
+  }
+}
+
+// -------------------------------------------------------------------------------------------------
+
+GameObject* dp88_AI_ChargedTurret::GetAnimationObject ( GameObject* pSelf )
+{
+  if ( m_chargeAnimObjId != NULL )
+    return Commands->Find_Object(m_chargeAnimObjId);
+  return pSelf;
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_ChargedTurret::ApplyIdleAnimation ( GameObject* pSelf )
+{
+  // Apply the correct animation frames for the uncharged state dependant upon base power conditions,
+  // which should already have been updated before calling this function
+  if ( m_bPowerState )
+    m_pLoopedAnimCtrl->PlayAnimation(Get_Parameter("Animation"),Get_Int_Parameter("Animation_Idle_Start_Frame"),Get_Int_Parameter("Animation_Idle_End_Frame"));
+  else
+    m_pLoopedAnimCtrl->PlayAnimation(Get_Parameter("Animation"),Get_Int_Parameter("Animation_Unpowered_Start_Frame"),Get_Int_Parameter("Animation_Unpowered_End_Frame"));
+}
+
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_ChargedTurret::Custom ( GameObject* pSelf, int type, int param, GameObject* pSender )
+{
+  if ( pSelf != pSender && GetAnimationObject(pSelf) == pSender )
+    Animation_Complete(pSelf, Get_Parameter("Animation"));
+}
+
+
+
+
+
+
+
+
+
+// -------------------------------------------------------------------------------------------------
+//  Charged Turret AI - Animation Complete Notifier
+// -------------------------------------------------------------------------------------------------
+
+void dp88_AI_ChargedTurret_Animation::Animation_Complete ( GameObject* pSelf, const char* animation_name )
+{
+  if ( GameObject* pTurret = Commands->Find_Object(Get_Int_Parameter("tId")) )
+    Commands->Send_Custom_Event ( pSelf, pTurret, CUSTOM_TURRETAI_ANIMATIONCOMPLETE, 0, 0.0f );
+}
+
+
+
+
+
+
+
+// -------------------------------------------------------------------------------------------------
+//  Script Registrants
+// -------------------------------------------------------------------------------------------------
 
 // Heavy vehicle marker (dummy script)
 ScriptRegistrant<dp88_AI_heavyVehicleMarker> dp88_AI_heavyVehicleMarker_Registrant("dp88_AI_heavyVehicleMarker","");
\ No newline at end of file
+
+ScriptRegistrant<dp88_tankAI_Offensive> dp88_tankAI_Offensive_Registrant("dp88_tankAI_Offensive","Priority_Infantry=1:int,Weapon_Infantry=1:int,priority_lightVehicle=5:int,priority_heavyVehicle=7:int,Weapon_Vehicle=1:int,Priority_VTOL=5:int,Weapon_VTOL=1:int,Priority_Building=12:int,Weapon_Building=1:int,Max_Attack_Range=150:int,Min_Attack_Range=0:int,Preferred_Attack_Range=60:int,Max_Attack_Range_Secondary=150:int,Min_Attack_Range_Secondary=0:int,Preferred_Attack_Range_Secondary=60:int");
+ScriptRegistrant<dp88_AI_Turret> dp88_AI_Turret_Registrant("dp88_AI_Turret","Priority_Infantry=1.0:float,Weapon_Infantry=1:int,Splash_Infantry=0:int,Priority_Light_Vehicle=5.0:float,Weapon_Light_Vehicle=5:int,Priority_Heavy_Vehicle=7.0:float,Weapon_Heavy_Vehicle=1:int,Priority_VTOL=5.0:float,Weapon_VTOL=1:int,Min_Attack_Range=0:int,Max_Attack_Range=150:int,Min_Attack_Range_Secondary=0:int,Max_Attack_Range_Secondary=150:int,Modifier_Distance=0.25:float,Modifier_Target_Damage=0.1:float,Modifier_Target_Value=0.05:float,Requires_Power=0:int,Debug=0:int");
+ScriptRegistrant<dp88_AI_PopupTurret> dp88_AI_PopupTurret_Registrant("dp88_AI_PopupTurret","Priority_Infantry=1.0:float,Weapon_Infantry=1:int,Splash_Infantry=0:int,Priority_Light_Vehicle=5.0:float,Weapon_Light_Vehicle=5:int,Priority_Heavy_Vehicle=7.0:float,Weapon_Heavy_Vehicle=1:int,Priority_VTOL=5.0:float,Weapon_VTOL=1:int,Min_Attack_Range=0:int,Max_Attack_Range=150:int,Min_Attack_Range_Secondary=0:int,Max_Attack_Range_Secondary=150:int,Deploy_Animation:string,Deploy_Animation_Frames:int,Deploy_Sound:string,Deploy_Timeout:int,Spotter_Preset:string,Modifier_Distance=0.25:float,Modifier_Target_Damage=0.1:float,Modifier_Target_Value=0.05:float,Requires_Power=0:int,Debug=0:int");
+ScriptRegistrant<dp88_AI_PopupTurret_Spotter> dp88_AI_PopupTurret_Spotter_Registrant("dp88_AI_PopupTurret_Spotter","tId:int");
+ScriptRegistrant<dp88_AI_ChargedTurret> dp88_AI_ChargedTurret_Registrant("dp88_AI_ChargedTurret","Priority_Infantry=1.0:float,Weapon_Infantry=1:int,Splash_Infantry=0:int,Priority_Light_Vehicle=5.0:float,Weapon_Light_Vehicle=5:int,Priority_Heavy_Vehicle=7.0:float,Weapon_Heavy_Vehicle=1:int,Priority_VTOL=5.0:float,Weapon_VTOL=1:int,Min_Attack_Range=0:int,Max_Attack_Range=150:int,Min_Attack_Range_Secondary=0:int,Max_Attack_Range_Secondary=150:int,Animation_Model:string,Animation_Model_Bone:string,Animation:string,Animation_Idle_Start_Frame:int,Animation_Idle_End_Frame:int,Animation_Unpowered_Start_Frame:int,Animation_Unpowered_End_Frame:int,Animation_Charge_Start_Frame:int,Animation_Charge_End_Frame:int,Charge_Sound:string,Modifier_Distance=0.25:float,Modifier_Target_Damage=0.1:float,Modifier_Target_Value=0.05:float,Requires_Power=0:int,Debug=0:int");
+ScriptRegistrant<dp88_AI_ChargedTurret_Animation> dp88_AI_ChargedTurret_Animation_Registrant("dp88_AI_ChargedTurret_Animation","tId:int");
diff -uwr sourceold/scripts/dp88_customAI.h source/scripts/dp88_customAI.h
--- sourceold/scripts/dp88_customAI.h	2011-10-22 19:50:31.665039000 +0800
+++ source/scripts/dp88_customAI.h	2012-05-13 21:10:00.739101500 +0800
@@ -11,6 +11,7 @@
 */
 #pragma once
 
+#include "LoopedAnimationController.h"
 
 #define TIMER_CHECK_TARGET 100778801
 
@@ -19,6 +20,14 @@
 Base class for custom AI's
 --------------------------*/
 
+
+/*!
+* \brief danpaul88's Custom AI Core
+* \author Daniel Paul (danpaul88@yahoo.co.uk)
+*
+* This class contains the core logic used in custom AI scripts, such as the target prioritisation
+* mechanism. It is not an actual script in it's own right and cannot be used in LevelEdit directly.
+*/
 class dp88_customAI : public ScriptImpClass
 {
 public:
@@ -91,11 +100,27 @@
 	virtual bool IsVehicleAIEnabled( VehicleGameObj* vobj );
 };
 
+// -------------------------------------------------------------------------------------------------
 
-/*------------------------
-Offensive Tank AI
---------------------------*/
+/*!
+* \brief danpaul88's Custom AI Heavy Vehicle Marker
+* \author Daniel Paul (danpaul88@yahoo.co.uk)
+*
+* This is a dummy script with no functionality which can be attached to an object to indicate all of
+* my custom AI scripts should treat this as a heavy vehicle. Any vehicle without this script will be
+* considered to be a light vehicle.
+*/
+class dp88_AI_heavyVehicleMarker : public ScriptImpClass{};
+
+// -------------------------------------------------------------------------------------------------
 
+/*!
+* \brief Offensive Tank AI
+* \author Daniel Paul (danpaul88@yahoo.co.uk)
+*
+* This is a somewhat experimental AI for vehicles which can track targets over a predefined distance
+* and attack them. This script is not yet suitable for use in maps or mods and is subject to change.
+*/
 class dp88_tankAI_Offensive : public dp88_customAI
 {
 	/* ----
@@ -116,13 +141,73 @@
 	void Timer_Expired( GameObject *obj, int number );
 };
 
+// -------------------------------------------------------------------------------------------------
 
-
-/*------------------------
-Turret AI
-	Base class for turret type AI scripts
---------------------------*/
-
+/*!
+* \brief Turret AI
+* \author Daniel Paul (danpaul88@yahoo.co.uk)
+*
+* A custom designed turret AI code designed to allow maximum flexibility in implementation without
+* needing multiple versions of effectively the same code to target different enemies (ie: VTOL vs.
+* non-VTOL).
+*
+* The turret AI uses a priority based system to 'intelligently' pick targets based upon a range of
+* criteria such as the type of target, how far away it is, if it's already taken damage and how
+* valuable it is. All of these criteria can be fine tuned in the script parameters to give you a
+* high degree of control over which of several targets a turret will choose to shoot at. This also
+* has the effect of making multiple, closely placed, turrets with the same targetting parameters
+* concentrate their fire on a single target for maximum impact.
+*
+* \param Priority_Infantry
+*   Base targetting priority for infantry targets, or 0 to ignore infantry
+* \param Weapon_Infantry
+*   Weapon to use against infantry targets: 0 for primary fire, 1 for secondary fire
+* \param Splash_Infantry
+*   Determines if we should try to damage infantry with splash instead of hitting them directly.
+*   This is useful for slow / inaccurate weapons which do splash damage: 1 to enable, 0 to disable
+* \param Priority_Light_Vehicle
+*   Base targetting priority for light vehicle targets, or 0 to ignore light vehicles
+* \param Weapon_Light_Vehicle
+*   Weapon to use against light vehicle targets: 0 for primary fire, 1 for secondary fire
+* \param Priority_Heavy_Vehicle
+*   Base targetting priority for heavy vehicle targets, or 0 to ignore heavy vehicles
+* \param Weapon_Heavy_Vehicle
+*   Weapon to use against heavy vehicle targets: 0 for primary fire, 1 for secondary fire
+* \param Priority_VTOL
+*   Base targetting priority for flying targets, or 0 to ignore flying targets
+* \param Weapon_VTOL
+*   Weapon to use against flying targets: 0 for primary fire, 1 for secondary fire
+* \param Min_Attack_Range
+*   Minimum distance at which the turret can engage enemies when using primary fire
+* \param Max_Attack_Range
+*   Maximum distance at which the turret can engage enemies when using primary fire
+* \param Min_Attack_Range_Secondary
+*   Minimum distance at which the turret can engage enemies when using secondary fire
+* \param Max_Attack_Range_Secondary
+*   Maximum distance at which the turret can engage enemies when using secondary fire
+* \param Modifier_Distance
+*   Priority modification to apply based on distance to target. Higher values will favour targets
+*   which are closer to the turret, good for less accurate weapons
+* \param Modifier_Target_Damage
+*   Priority modification to apply based on damage a target has already sustained. Higher values
+*   will favour targets which have already been damaged in combat, picking them off first.
+* \param Modifier_Target_Value
+*   Priority modification to apply based on the value of the target. Higher values will favour
+*   targets with a higher purchase cost, good for hard hitting weapons.
+* \param Requires_Power
+*   Specify whether this turret requires base power to operate: 1 to require power, 0 to ignore
+* \param Debug
+*   Specify whether to produce a debug logfile about the turrets targetting decisions, this is
+*   useful for fine tuning your base priorities and modifiers: 1 to enable, 0 to disable.
+*
+* \note
+*   Vehicles are always classified as light vehicles unless they have the dp88_AI_heavyVehicleMarker
+*   script attached to them.
+*
+* \warning
+*   Never leave the Debug parameter enabled when releasing your mod, it will clog up everyones
+*   machines with useless text files everywhere... people usually don't like that :D
+*/
 class dp88_AI_Turret : public dp88_customAI
 {
 public:
@@ -166,12 +251,307 @@
 	virtual void stopAttacking ( GameObject* obj );
 };
 
+// -------------------------------------------------------------------------------------------------
+
+/*!
+* \brief Popup Turret AI
+* \author Daniel Paul (danpaul88@yahoo.co.uk)
+*
+* An overloaded version of my custom turret AI incorporating popup/deploy logic. This script requires
+* two LevelEdit presets to work correctly, which are as follows;
+* 
+* <b>Turret Preset</b>
+* As with any turret preset, this has all the weapons, health, armour, etc etc and should have an
+* instance of this script attached to it with the relevant parameters configured (see below).
+*
+* <b>Spotter Preset</b>
+* This is a dummy preset used to 'see' enemies whilst the real turret is undeployed. This should be
+* setup as a turret but only the sight range parameter needs to be configured properly. It's model
+* can be set to any valid model (or possibly left blank?) and it should NOT have ANY scripts. Note
+* this preset can be shared by multiple turret presets as long as the sight range is appropriate.
+*
+* \param Priority_Infantry
+*   Base targetting priority for infantry targets, or 0 to ignore infantry
+* \param Weapon_Infantry
+*   Weapon to use against infantry targets: 0 for primary fire, 1 for secondary fire
+* \param Splash_Infantry
+*   Determines if we should try to damage infantry with splash instead of hitting them directly.
+*   This is useful for slow / inaccurate weapons which do splash damage: 1 to enable, 0 to disable
+* \param Priority_Light_Vehicle
+*   Base targetting priority for light vehicle targets, or 0 to ignore light vehicles
+* \param Weapon_Light_Vehicle
+*   Weapon to use against light vehicle targets: 0 for primary fire, 1 for secondary fire
+* \param Priority_Heavy_Vehicle
+*   Base targetting priority for heavy vehicle targets, or 0 to ignore heavy vehicles
+* \param Weapon_Heavy_Vehicle
+*   Weapon to use against heavy vehicle targets: 0 for primary fire, 1 for secondary fire
+* \param Priority_VTOL
+*   Base targetting priority for flying targets, or 0 to ignore flying targets
+* \param Weapon_VTOL
+*   Weapon to use against flying targets: 0 for primary fire, 1 for secondary fire
+* \param Min_Attack_Range
+*   Minimum distance at which the turret can engage enemies when using primary fire
+* \param Max_Attack_Range
+*   Maximum distance at which the turret can engage enemies when using primary fire
+* \param Min_Attack_Range_Secondary
+*   Minimum distance at which the turret can engage enemies when using secondary fire
+* \param Max_Attack_Range_Secondary
+*   Maximum distance at which the turret can engage enemies when using secondary fire
+* \param Deploy_Animation
+*   Name of the animation to play when the turret deploys - this is played in reverse for undeploy
+* \param Deploy_Animation_Frames
+*   Number of animation frames in the deployment animation, which should start at frame 0
+* \param Deploy_Sound
+*   An optional sound effect to be played whilst the deployment occurs
+* \param Deploy_Timeout
+*   Time the turret will wait after it last saw an enemy before it undeploys, in seconds
+* \param Spotter_Preset
+*   Name of your Spotter Preset in LevelEdit
+* \param Modifier_Distance
+*   Priority modification to apply based on distance to target. Higher values will favour targets
+*   which are closer to the turret, good for less accurate weapons
+* \param Modifier_Target_Damage
+*   Priority modification to apply based on damage a target has already sustained. Higher values
+*   will favour targets which have already been damaged in combat, picking them off first.
+* \param Modifier_Target_Value
+*   Priority modification to apply based on the value of the target. Higher values will favour
+*   targets with a higher purchase cost, good for hard hitting weapons.
+* \param Requires_Power
+*   Specify whether this turret requires base power to operate: 1 to require power, 0 to ignore
+* \param Debug
+*   Specify whether to produce a debug logfile about the turrets targetting decisions, this is
+*   useful for fine tuning your base priorities and modifiers: 1 to enable, 0 to disable.
+*
+* \note
+*   Vehicles are always classified as light vehicles unless they have the dp88_AI_heavyVehicleMarker
+*   script attached to them.
+*
+* \warning
+*   Never leave the Debug parameter enabled when releasing your mod, it will clog up everyones
+*   machines with useless text files everywhere... people usually don't like that :D
+*/
+class dp88_AI_PopupTurret : public dp88_AI_Turret
+{
+public:
+  // Game events
+  virtual void Created ( GameObject* pSelf );
+  virtual void Timer_Expired ( GameObject* pSelf, int number );
+  virtual void Custom ( GameObject* pSelf, int type, int param, GameObject* pSender );
+  virtual void Animation_Complete ( GameObject* pSelf, const char* animation_name );
+  virtual void Destroyed( GameObject* pSelf );
+
 
+protected:
+  static const unsigned char    STATE_UNDEPLOYED  = 0x00;
+  static const unsigned char    STATE_DEPLOYING   = 0x01;
+  static const unsigned char    STATE_DEPLOYED    = 0x02;
+  static const unsigned char    STATE_UNDEPLOYING = 0x03;
 
-/*------------------------
-Heavy Vehicle Marker
-  Dummy script to mark a vehicle as being heavy
---------------------------*/
+  /*! Current deployment state */
+  unsigned char m_deploymentState;
+
+  /*! Time at which we will undeploy unless we see a target in the meantime */
+  time_t m_undeployTime;
+
+  /*! ID of the spotter turret we have created for ourselves */
+  int m_spotterId;
+
+
+  /*! Overloaded form of dp88_AI_Turret::attackTarget to check deployment state prior to initiating attack */
+  virtual void attackTarget ( GameObject* pSelf, GameObject* pTarget, bool primary );
+
+  /*! Overloaded form of dp88_AI_Turret::attackLocation to check deployment state prior to initiating attack */
+  virtual void attackLocation ( GameObject* pSelf, Vector3 location, bool primary );
+
+
+  /*! Function to initiate the deployment sequence if it is not already in process, this is called
+  when we want to start shooting things */
+  virtual void Deploy ( GameObject* pSelf );
+
+  /*! Function to initiate the undeployment sequence if it is not already in process, this is called
+  when we are bored because we haven't had anything to shoot at for a while...*/
+  virtual void Undeploy ( GameObject* pSelf );
+};
+
+// -------------------------------------------------------------------------------------------------
+
+/*!
+* \brief Popup Turret Spotter
+* \author Daniel Paul (danpaul88@yahoo.co.uk)
+*
+* A simple companion script for dp88_AI_PopupTurret which is attached to an invisible clone of the
+* turret to allow it to 'see' enemies when whilst the muzzle is underground. Simply fires off a
+* custom event to the parent turret each time it sees an enemy with the ID of that enemy.
+*/
+class dp88_AI_PopupTurret_Spotter : public ScriptImpClass
+{
+  void Enemy_Seen ( GameObject* pSelf, GameObject* pEnemy );
+};
+
+// -------------------------------------------------------------------------------------------------
+
+/*!
+* \brief Charged Turret AI
+* \author Daniel Paul (danpaul88@yahoo.co.uk)
+*
+* An overloaded version of my custom turret AI incorporating charge up logic, which causes an
+* animation sequence to be played prior to each clip fired by the turret. For maximum flexibility
+* the animation can be played on either the turrets own model or on a seperate preset which is
+* attached by this script to a specified bone on the turret model. This allows damage and charge
+* up animations to be used on a turret simultaneously.
+*
+* One notable feature is the ability to fire more than one shot each time the turret charges up,
+* allowing for greater flexibility in usage. When the turret is fully charged it will fire at the
+* enemy until it runs out of bullets and needs to reload, at which point it will restart the charge
+* up animation.
+*
+* \note
+*   The weapon reload time <b>must</b> be less than the duration of the charging animation
+*
+* \warning
+*   Currently there is a design limitation in the script which requires that the weapon reload time
+*   must be at least 1.1 seconds in duration to ensure correct detection of the discharged state. If
+*   this is problematic in future the limitation can be removed. If your reload time is less than 1
+*   second the turret could empty two or more complete clips of ammo before charging again.
+*
+* \param Priority_Infantry
+*   Base targetting priority for infantry targets, or 0 to ignore infantry
+* \param Weapon_Infantry
+*   Weapon to use against infantry targets: 0 for primary fire, 1 for secondary fire
+* \param Splash_Infantry
+*   Determines if we should try to damage infantry with splash instead of hitting them directly.
+*   This is useful for slow / inaccurate weapons which do splash damage: 1 to enable, 0 to disable
+* \param Priority_Light_Vehicle
+*   Base targetting priority for light vehicle targets, or 0 to ignore light vehicles
+* \param Weapon_Light_Vehicle
+*   Weapon to use against light vehicle targets: 0 for primary fire, 1 for secondary fire
+* \param Priority_Heavy_Vehicle
+*   Base targetting priority for heavy vehicle targets, or 0 to ignore heavy vehicles
+* \param Weapon_Heavy_Vehicle
+*   Weapon to use against heavy vehicle targets: 0 for primary fire, 1 for secondary fire
+* \param Priority_VTOL
+*   Base targetting priority for flying targets, or 0 to ignore flying targets
+* \param Weapon_VTOL
+*   Weapon to use against flying targets: 0 for primary fire, 1 for secondary fire
+* \param Min_Attack_Range
+*   Minimum distance at which the turret can engage enemies when using primary fire
+* \param Max_Attack_Range
+*   Maximum distance at which the turret can engage enemies when using primary fire
+* \param Min_Attack_Range_Secondary
+*   Minimum distance at which the turret can engage enemies when using secondary fire
+* \param Max_Attack_Range_Secondary
+*   Maximum distance at which the turret can engage enemies when using secondary fire
+* \param Animation_Model
+*   Optional name of a W3D model file to spawn and attach to the turret upon which the charge
+*   animations defined in this script will be applied. This allows the turret itself to be running
+*   a different set of animations, such as damage states via dp88_damageAnimation
+* \param Animation_Model_Bone
+*   If you specify an Animation_Model above then you must also specify the a bone on the parent
+*   to which that model should be attached. This allows the animation model to be moved by the
+*   animation set executing on the turret.
+* \param Animation
+*   Name of the animation which contains the frames for the various charge states
+* \param Animation_Idle_Start_Frame
+*   First frame number for the idle animation, which will loop continually whilst the turret is
+*   powered and not currently attacking a target
+* \param Animation_Idle_End_Frame
+*   Final frame number for the idle animation
+* \param Animation_Unpowered_Start_Frame
+*   First frame number for the unpowered animation, which will loop continually whilst the turret
+*   is in the unpowered state. This is not used if Requires_Power is disabled (see below).
+* \param Animation_Unpowered_End_Frame
+*   Final frame number for the unpowered animation
+* \param Animation_Charge_Start_Frame
+*   First frame number for the charging animation, which will be played once each time the turret
+*   reloads its weapon. Once this animation completes the turret will fire again, therefore the
+*   length of this animation must be greater than the weapon reload time.
+* \param Animation_Charge_End_Frame
+*   Final frame number for the charging animation
+* \param Charge_Sound
+*   Optional sound effect to be played each time the turret starts charging up
+* \param Modifier_Distance
+*   Priority modification to apply based on distance to target. Higher values will favour targets
+*   which are closer to the turret, good for less accurate weapons
+* \param Modifier_Target_Damage
+*   Priority modification to apply based on damage a target has already sustained. Higher values
+*   will favour targets which have already been damaged in combat, picking them off first.
+* \param Modifier_Target_Value
+*   Priority modification to apply based on the value of the target. Higher values will favour
+*   targets with a higher purchase cost, good for hard hitting weapons.
+* \param Requires_Power
+*   Specify whether this turret requires base power to operate: 1 to require power, 0 to ignore
+* \param Debug
+*   Specify whether to produce a debug logfile about the turrets targetting decisions, this is
+*   useful for fine tuning your base priorities and modifiers: 1 to enable, 0 to disable.
+*
+* \note
+*   Vehicles are always classified as light vehicles unless they have the dp88_AI_heavyVehicleMarker
+*   script attached to them.
+*
+* \warning
+*   Never leave the Debug parameter enabled when releasing your mod, it will clog up everyones
+*   machines with useless text files everywhere... people usually don't like that :D
+*/
+class dp88_AI_ChargedTurret : public dp88_AI_Turret
+{
+public:
+  // Game events
+  virtual void Created ( GameObject* pSelf );
+  virtual void Timer_Expired ( GameObject* pSelf, int number );
+  virtual void Custom ( GameObject* pSelf, int type, int param, GameObject* pSender );
+  virtual void Animation_Complete ( GameObject* pSelf, const char* animation_name );
+  virtual void Destroyed( GameObject* pSelf );
+
+
+protected:
+  /*! Are we currently charging ready for an attack? */
+  bool m_bIsCharging;
+
+  /*! Are we currently discharging (ie: attacking an enemy)? */
+  bool m_bIsDischarging;
+
+  /*! ID of the charge animation object we have created for ourselves */
+  int m_chargeAnimObjId;
+
+  /*! Power state last time it was checked - if this changes we need to update our animation */
+  bool m_bPowerState;
+
+  /*! A looped animation controller for the idle and low power state animations */
+  LoopedAnimationController* m_pLoopedAnimCtrl;
+
+
+  /*! Overloaded form of dp88_AI_Turret::attackTarget which initiates turret charging (if it is not
+  * currently in progress) rather than actually attacking anything */
+  virtual void attackTarget ( GameObject* pSelf, GameObject* pTarget, bool primary );
+
+  /*! Overloaded form of dp88_AI_Turret::attackLocation which initiates turret charging (if it is
+  * not currently in progress) rather than actually attacking anything */
+  virtual void attackLocation ( GameObject* pSelf, Vector3 location, bool primary );
+
+
+  /*! This function is called to initiate the charge up process, if it is not already in progress */
+  virtual void StartCharging ( GameObject* pSelf );
+
+
+  /*! Internal utility function to get a pointer to the object upon which the charge animation will
+  * be applied - this will either be the turret itself or the seperate charge animation object if
+  * one was specified in the script parameters */
+  virtual GameObject* GetAnimationObject ( GameObject* pSelf );
+
+  /*! Called when the turret is idle or unpowered to apply the correct animation frames */
+  virtual void ApplyIdleAnimation ( GameObject* pSelf );
+};
+
+/*!
+* \brief Chargeup Animation Detector
+* \author Daniel Paul (danpaul88@yahoo.co.uk)
+*
+* A script to allow detection of animations if the "separate object" feature is used
+*/
+class dp88_AI_ChargedTurret_Animation : public ScriptImpClass
+{
+  // Game events
+  virtual void Animation_Complete ( GameObject* pSelf, const char* animation_name );
+};
 
-class dp88_AI_heavyVehicleMarker : public ScriptImpClass
-{};
\ No newline at end of file
+// -------------------------------------------------------------------------------------------------
\ No newline at end of file
diff -uwr sourceold/scripts/dp88_custom_timer_defines.h source/scripts/dp88_custom_timer_defines.h
--- sourceold/scripts/dp88_custom_timer_defines.h	2011-10-25 07:50:47.753906200 +0800
+++ source/scripts/dp88_custom_timer_defines.h	2012-05-07 07:09:13.429789000 +0800
@@ -86,6 +86,9 @@
 #define CUSTOM_REMOTECONTROL_DISABLED				1144070006		// Send to a remote control console to disable it
 #define CUSTOM_REMOTECONTROL_ENABLED				1144070007		// Send to a remote control console to enable it
 
+// Customs for custom turret AI scripts
+#define CUSTOM_TURRETAI_ENEMYSEEN                     1144080001  // Sent from dp88_AI_PopupTurret_Spotter to dp88_AI_PopupTurret
+#define CUSTOM_TURRETAI_ANIMATIONCOMPLETE             1144080002  // Send from dp88_AI_ChargeTurret_Animation to dp88_AI_ChargeTurret
 
 
 
diff -uwr sourceold/scripts/dp88_misc.cpp source/scripts/dp88_misc.cpp
--- sourceold/scripts/dp88_misc.cpp	2012-02-23 12:06:21.224609300 +0800
+++ source/scripts/dp88_misc.cpp	2012-05-23 10:18:53.428710900 +0800
@@ -578,13 +578,14 @@
 
 
 
-/*------------------------
-Damage animation script
---------------------------*/
+// -------------------------------------------------------------------------------------------------
+// Damage animation script
+// -------------------------------------------------------------------------------------------------
 
 void dp88_damageAnimation::Created ( GameObject* obj )
 {
 	loopAnimation = (Get_Int_Parameter ( "loopAnimation" ) == 1);
+  m_pLoopedAnimCtrl = new LoopedAnimationController(obj);   // Can also do single-iteration loops :) 
 
 	/* Load settings */
 	damageLevelBoundaries[0] = 100;
@@ -643,14 +644,18 @@
 	}
 }
 
-void dp88_damageAnimation::Animation_Complete ( GameObject *obj, const char *animation_name )
+// -------------------------------------------------------------------------------------------------
+
+void dp88_damageAnimation::Detach ( GameObject* obj )
 {
-	if (loopAnimation)
+	if (m_pLoopedAnimCtrl)
 	{
-		SetDamageAnimation(obj);
+		delete m_pLoopedAnimCtrl;
 	}
 }
 
+// -------------------------------------------------------------------------------------------------
+
 void dp88_damageAnimation::Damaged( GameObject *obj, GameObject *damager, float amount )
 {
 	if ( amount >= 0 )
@@ -677,6 +682,8 @@
 	}
 }
 
+// -------------------------------------------------------------------------------------------------
+
 void dp88_damageAnimation::Timer_Expired ( GameObject* obj, int number )
 {
 	if ( number == TIMER_CHECK_BASE_POWER_STATE )
@@ -692,15 +699,17 @@
 	}
 }
 
+// -------------------------------------------------------------------------------------------------
+
 void dp88_damageAnimation::SetDamageAnimation ( GameObject* obj )
 {
-	obj->As_PhysicalGameObj()->Clear_Animation();
 	if ( basePowerState || damageLevelLowPowerStartFrames[currentDamageLevel] < 0 )
-		Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)damageLevelStartFrames[currentDamageLevel], (float)damageLevelEndFrames[currentDamageLevel], false );
+    m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("animationName"), damageLevelStartFrames[currentDamageLevel], damageLevelEndFrames[currentDamageLevel], (loopAnimation)?0:1 );
 	else
-		Commands->Set_Animation(obj, Get_Parameter("animationName"), false, NULL, (float)damageLevelLowPowerStartFrames[currentDamageLevel], (float)damageLevelLowPowerEndFrames[currentDamageLevel], false );
+    m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("animationName"), damageLevelLowPowerStartFrames[currentDamageLevel], damageLevelLowPowerEndFrames[currentDamageLevel], (loopAnimation)?0:1 );
 }
 
+// -------------------------------------------------------------------------------------------------
 
 ScriptRegistrant<dp88_damageAnimation> dp88_damageAnimation_Registrant(
 	"dp88_damageAnimation",
@@ -737,6 +746,8 @@
 	"damageBoundary5_endFrame_lowPower=-1:int"
 );
 
+// -------------------------------------------------------------------------------------------------
+
 
 
 
@@ -865,7 +876,7 @@
 	shifted_vehicle_object_id = NULL;
 
 	// Can only be used on vehicles
-	if ( !As_VehicleGameObj(obj) )
+	if ( !obj->As_VehicleGameObj() )
 	{
 		Console_Output ( "[%d:%s:%s] Critical Error: This script can only be used on vehicles! Destroying script...\n", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), this->Get_Name() );
 		Destroy_Script();
diff -uwr sourceold/scripts/dp88_misc.h source/scripts/dp88_misc.h
--- sourceold/scripts/dp88_misc.h	2011-12-01 11:52:12.871093700 +0800
+++ source/scripts/dp88_misc.h	2012-05-23 10:33:45.755859300 +0800
@@ -9,10 +9,12 @@
 	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.
 */
+
 #pragma once
 
 #include "scripts.h"
 #include "engine.h"
+#include "LoopedAnimationController.h"
 
 
 
@@ -104,16 +106,108 @@
 
 
 
-/*------------------------
-Damage animation script
---------------------------*/
+/*!
+* \brief Damage animation script
+* \author Daniel Paul (danpaul88@yahoo.co.uk)
+*
+* This is a generic damage animation script that allows you to choose the health thresholds at which
+* different damage states are applied, rather than being tied into the 25%, 50%, 75% etc permitted
+* by the damage bones mechanism.
+*
+* You can create up to six damage states using this script, with both powered and unpowered versions
+* of each state, however if you don't require all six states you can leave the extras unconfigured.
+*
+* The first state is considered to be the 'healthy' state and is used when the object is above the
+* first damage boundary. Each subsequent state is activated when the health of the object drops
+* below the specified boundary, which is a percentage of total health. So, for instance, if you set
+* boundary 1 to 70 and boundary 2 to 30 your object will animate as follows;
+*
+* Health 71% - 100%: Healthy animation
+* Health 31% - 70%: Damage animation 1
+* Health 1% - 0%: Damage animation 2
+*
+* \param animationName
+*   Name of the animation containing all the damage state frames
+* \param loopAnimation
+*   True if the damage animation should be played in a loop, false otherwise
+* \param healthy_startFrame
+*   First frame number for the healthy state animation
+* \param healthy_endFrame
+*   Last frame number for the healthy state animation
+* \param healthy_startFrame_lowPower
+*   First frame number for the healthy state animation when power is offline, or -1 to use the same
+*   value as healthy_startFrame
+* \param healthy_endFrame_lowPower
+*   Last frame number for the healthy state animation when power is offline, or -1 to use the same
+*   value as healthy_endFrame
+* \param damageBoundary1
+*   Damage percent boundary for the first damage state
+* \param damageBoundary1_startFrame
+*   First frame number for the first damage state animation
+* \param damageBoundary1_endFrame
+*   Last frame number for the first damage state animation
+* \param damageBoundary1_startFrame_lowPower
+*   First frame number for the first damage state animation when power is offline, or -1 to use the
+*   same value as damageBoundary1_startFrame
+* \param damageBoundary1_endFrame_lowPower
+*   Last frame number for the first damage state animation when power is offline, or -1 to use the
+*   same value as damageBoundary1_endFrame
+* \param damageBoundary2
+*   Damage percent boundary for the second damage state, or -1 to disable this state
+* \param damageBoundary2_startFrame
+*   second frame number for the second damage state animation
+* \param damageBoundary2_endFrame
+*   Last frame number for the second damage state animation
+* \param damageBoundary2_startFrame_lowPower
+*   second frame number for the second damage state animation when power is offline, or -1 to use
+*   the same value as damageBoundary2_startFrame
+* \param damageBoundary2_endFrame_lowPower
+*   Last frame number for the second damage state animation when power is offline, or -1 to use the
+*   same value as damageBoundary2_endFrame
+* \param damageBoundary3
+*   Damage percent boundary for the third damage state, or -1 to disable this state
+* \param damageBoundary3_startFrame
+*   third frame number for the third damage state animation
+* \param damageBoundary3_endFrame
+*   Last frame number for the third damage state animation
+* \param damageBoundary3_startFrame_lowPower
+*   third frame number for the third damage state animation when power is offline, or -1 to use
+*   the same value as damageBoundary3_startFrame
+* \param damageBoundary3_endFrame_lowPower
+*   Last frame number for the third damage state animation when power is offline, or -1 to use the
+*   same value as damageBoundary3_endFrame
+* \param damageBoundary4
+*   Damage percent boundary for the fourth damage state, or -1 to disable this state
+* \param damageBoundary4_startFrame
+*   fourth frame number for the fourth damage state animation
+* \param damageBoundary4_endFrame
+*   Last frame number for the fourth damage state animation
+* \param damageBoundary4_startFrame_lowPower
+*   fourth frame number for the fourth damage state animation when power is offline, or -1 to use
+*   the same value as damageBoundary4_startFrame
+* \param damageBoundary4_endFrame_lowPower
+*   Last frame number for the fourth damage state animation when power is offline, or -1 to use the
+*   same value as damageBoundary4_endFrame
+* \param damageBoundary5
+*   Damage percent boundary for the fifth damage state, or -1 to disable this state
+* \param damageBoundary5_startFrame
+*   fifth frame number for the fifth damage state animation
+* \param damageBoundary5_endFrame
+*   Last frame number for the fifth damage state animation
+* \param damageBoundary5_startFrame_lowPower
+*   fifth frame number for the fifth damage state animation when power is offline, or -1 to use
+*   the same value as damageBoundary5_startFrame
+* \param damageBoundary5_endFrame_lowPower
+*   Last frame number for the fifth damage state animation when power is offline, or -1 to use the
+*   same value as damageBoundary5_endFrame
+*/
 
 class dp88_damageAnimation : public ScriptImpClass
 {
 	void Created ( GameObject* obj );
+  void Detach ( GameObject* obj );
 	void Damaged( GameObject *obj, GameObject *damager, float amount );
 	void Timer_Expired ( GameObject* obj, int number );
-	void Animation_Complete ( GameObject *obj, const char *animation_name );
 
 	void SetDamageAnimation ( GameObject* obj );
 
@@ -125,6 +219,10 @@
 	int damageLevelLowPowerEndFrames[6];
 	bool loopAnimation;
 	bool basePowerState;
+protected:
+  LoopedAnimationController* m_pLoopedAnimCtrl;
+public:
+  dp88_damageAnimation() : m_pLoopedAnimCtrl(0) {}
 };
 
 
diff -uwr sourceold/scripts/dp88_securitySystem.cpp source/scripts/dp88_securitySystem.cpp
--- sourceold/scripts/dp88_securitySystem.cpp	2011-10-11 23:03:38.137695300 +0800
+++ source/scripts/dp88_securitySystem.cpp	2012-04-19 17:33:30.064453100 +0800
@@ -188,8 +188,8 @@
 
 	// Work out position for target box
 	Vector3 pos = Commands->Get_Position( obj );
-	pos.X = pos.X + 2 * cos (facing);
-	pos.Y = pos.Y + 2 * sin (facing);
+	pos.X = pos.X + 2 * cos (DEG_TO_RADF(facing));
+	pos.Y = pos.Y + 2 * sin (DEG_TO_RADF(facing));
 
 	// Move fake target
 	GameObject* fakeTarget = Commands->Find_Object ( fakeTargetId );
diff -uwr sourceold/scripts/dp88_veterancy.cpp source/scripts/dp88_veterancy.cpp
--- sourceold/scripts/dp88_veterancy.cpp	2011-10-23 09:34:51.542968900 +0800
+++ source/scripts/dp88_veterancy.cpp	2012-04-24 21:55:23.658203100 +0800
@@ -14,6 +14,7 @@
 #include "dp88_veterancy.h"
 #include "dp88_custom_timer_defines.h"
 #include "VehicleGameObjDef.h"		// For VEHICLE_TYPE_TURRET
+#include "ScriptableGameObj.h"
 
 /******************************
 Initialise static pointer lists to null
@@ -58,7 +59,7 @@
 
 
 	// If unit is a soldier...
-	if ( Is_Soldier ( obj ) )
+	if ( obj->As_SoldierGameObj() )
 	{
 		infantryVeteranRequirement = Get_Int_Parameter ( "veteran_pointsRequired" );
 		infantryEliteRequirement = Get_Int_Parameter ( "elite_pointsRequired" );
@@ -112,7 +113,7 @@
 
 
 	// Else if unit is a vehicle
-	else if ( Is_Vehicle ( obj ) )
+	else if ( obj->As_VehicleGameObj() )
 	{
 		vehicleVeteranRequirement = Get_Int_Parameter ( "veteran_pointsRequired" );
 		vehicleEliteRequirement = Get_Int_Parameter ( "elite_pointsRequired" );
@@ -168,7 +169,7 @@
 
 	Points given: 50% of ((pointsValue / total hit points) * damage repaired) */
 	else if ( amount < 0 && Get_Object_Type(damager) == Get_Object_Type(obj)
-		&& ( !Is_Vehicle(obj) || Get_Vehicle_Driver ( obj ) != NULL || Get_Vehicle_Mode(obj) == VEHICLE_TYPE_TURRET ) )
+		&& ( !obj->As_VehicleGameObj() || Get_Vehicle_Driver ( obj ) != NULL || Get_Vehicle_Mode(obj) == VEHICLE_TYPE_TURRET ) )
 	{
 		grantVeterancyPoints ( damager, ((pointsValue/totalHitPoints)*(amount*-1)) *0.50f );
 	}
@@ -384,7 +385,7 @@
 	if ( obj == NULL || dead )
 		return;
 
-	if ( Is_Soldier ( obj ) )
+	if ( obj->As_SoldierGameObj() )
 	{
 		// Generate name string for the unit promoted chevron
 		char promotionChevronPreset[27];
@@ -416,7 +417,7 @@
 
 
 
-	else if ( Is_Vehicle ( obj ) )
+	else if ( obj->As_VehicleGameObj() )
 	{
 		// Generate name string for the unit promoted chevron
 		char promotionChevronPreset[27];
@@ -474,7 +475,11 @@
 /* Find veterancy unit object */
 dp88_veterancyUnit* dp88_veterancyUnit::getVeterancyData( GameObject *obj )
 {
-	if ( Is_Soldier ( obj ) && Get_Player_ID ( obj ) != -1 )
+	if (!obj)
+	{
+		return NULL;
+	}
+	if ( obj->As_SoldierGameObj() && Get_Player_ID ( obj ) != -1 )
 		return playerData[Get_Player_ID ( obj )];
 	else
 	{
@@ -508,7 +513,7 @@
 		return;
 
 	// If unit is a soldier and is not driving a vehicle give infantry veterancy points
-	if ( Is_Soldier ( obj ) && Get_Vehicle ( obj ) == NULL )
+	if ( obj->As_SoldierGameObj() && Get_Vehicle ( obj ) == NULL )
 	{
 		infantryVeterancyPoints += points;
 
@@ -523,7 +528,7 @@
 
 
 	// If unit is a vehicle or is driving a vehicle give vehicle veterancy points
-	if ( Is_Vehicle ( obj ) || ( Is_Soldier ( obj ) && Get_Vehicle ( obj ) != NULL ) )
+	if ( obj->As_VehicleGameObj() || ( obj->As_SoldierGameObj() && Get_Vehicle ( obj ) != NULL ) )
 	{
 		vehicleVeterancyPoints += points;
 
@@ -531,7 +536,7 @@
 		if ( vehicleVeterancyPoints >= vehicleEliteRequirement && vehicleEliteRequirement > 0 )
 		{
 			// If unit is a vehicle promote self to elite
-			if ( currentLevel < 2 && Is_Vehicle ( obj ) )
+			if ( currentLevel < 2 && obj->As_VehicleGameObj() )
 				promoteToElite();
 
 			// Otherwise promote the vehicle this unit is driving to elite
@@ -547,7 +552,7 @@
 		else if ( vehicleVeterancyPoints >= vehicleVeteranRequirement && vehicleVeteranRequirement > 0 )
 		{
 			// If unit is a vehicle promote self to veteran
-			if ( currentLevel < 1 && Is_Vehicle ( obj ) )
+			if ( currentLevel < 1 && obj->As_VehicleGameObj() )
 				promoteToVeteran();
 
 			// Otherwise promote the vehicle this unit is driving to veteran
@@ -576,7 +581,7 @@
 	createChevrons ();
 
 	// Send page and promotion sound if unit is a player
-	if ( Is_Soldier ( obj ) && Get_Player_ID ( obj ) >= 0 )
+	if ( obj->As_SoldierGameObj() && Get_Player_ID ( obj ) >= 0 )
 	{
 		// Send page
 		char consoleInput[128];
@@ -592,7 +597,7 @@
 
 
 	// Send page and promotion sound if unit driver is a player
-	else if ( Is_Vehicle ( obj ) && Get_Vehicle_Driver ( obj ) != NULL && Get_Player_ID ( Get_Vehicle_Driver ( obj ) ) >= 0 )
+	else if ( obj->As_VehicleGameObj() && Get_Vehicle_Driver ( obj ) != NULL && Get_Player_ID ( Get_Vehicle_Driver ( obj ) ) >= 0 )
 	{
 		// Send page
 		char consoleInput[128];
@@ -623,7 +628,7 @@
 
 		/* If unit is an infantry unit remove old weapon - immediatly if not
 		currently selected or after a 0.1 second delay otherwise */
-		if ( Is_Soldier ( obj ) )
+		if ( obj->As_SoldierGameObj() )
 		{
 			if ( selectWeapon )
 			{
@@ -670,7 +675,7 @@
 	createChevrons();
 
 	// Send page and promotion sound if unit is a player
-	if ( Is_Soldier ( obj ) && Get_Player_ID ( obj ) >= 0 )
+	if ( obj->As_SoldierGameObj() && Get_Player_ID ( obj ) >= 0 )
 	{
 		// Send page
 		char consoleInput[128];
@@ -686,7 +691,7 @@
 
 
 	// Send page and promotion sound if unit driver is a player
-	else if ( Is_Vehicle ( obj ) && Get_Vehicle_Driver ( obj ) != NULL && Get_Player_ID ( Get_Vehicle_Driver ( obj ) ) >= 0 )
+	else if ( obj->As_VehicleGameObj() && Get_Vehicle_Driver ( obj ) != NULL && Get_Player_ID ( Get_Vehicle_Driver ( obj ) ) >= 0 )
 	{
 		// Send page
 		char consoleInput[128];
@@ -736,7 +741,7 @@
 
 		/* If unit is an infantry unit remove old weapon - immediatly if not
 		currently selected or after a 0.1 second delay otherwise */
-		if ( Is_Soldier ( obj ) )
+		if ( obj->As_SoldierGameObj() )
 		{
 			if ( selectWeapon )
 			{
diff -uwr sourceold/scripts/engine_3dre.h source/scripts/engine_3dre.h
--- sourceold/scripts/engine_3dre.h	2012-01-01 06:32:39.324226700 +0800
+++ source/scripts/engine_3dre.h	2012-04-14 04:09:48.077148400 +0800
@@ -478,11 +478,17 @@
 	virtual void OnShaderDatabaseUnload() {};
 };
 
+#ifndef TTLE_EXPORTS
 class TextureMapperClass : public RefCountClass, ShaderControllerObserver {
+#else
+class TextureMapperClass : public RefCountClass {
+#endif
 protected:
 	unsigned int Stage; // 0008  0020
+#ifndef TTLE_EXPORTS
 	ProgrammableShader *Shader; // 000C  0024
 	const char* ShaderName; // 0010  0028
+#endif
 public:
 	enum {
 		MAPPER_ID_UNKNOWN = 0x0,
@@ -513,12 +519,14 @@
 	TextureMapperClass(TextureMapperClass& src);
 	TextureMapperClass(unsigned int stage=0);
 	TextureMapperClass(INIClass& ini,char* section,unsigned int stage);
+#ifndef TTLE_EXPORTS
 	SHADERS_API void Set_Shader(const char* shader_name, ProgrammableShader* shader = nullptr);
 	ProgrammableShader *Peek_Shader()
 	{
 		return Shader;
 	}
 	ProgrammableShader *Get_Shader();
+#endif
 	virtual void Reset()
 	{
 	}
@@ -537,10 +545,12 @@
 		return false;
 	}
 	~TextureMapperClass();
+#ifndef TTLE_EXPORTS
 	virtual void ApplyToMatrix(Matrix4& mat,int uv_array_index) = 0;
 
 	virtual void OnShaderDatabaseLoad();
 	virtual void OnShaderDatabaseUnload();
+#endif
 }; // 0014  002C
 
 typedef void (*ScriptNotify) (int ID,int notify);
diff -uwr sourceold/scripts/engine_def.cpp source/scripts/engine_def.cpp
--- sourceold/scripts/engine_def.cpp	2011-10-11 23:03:32.718750000 +0800
+++ source/scripts/engine_def.cpp	2012-04-24 11:21:11.197265600 +0800
@@ -18,6 +18,7 @@
 #include "PhysClass.h"
 #include "DefinitionMgrClass.h"
 #include "BaseGameObjDef.h"
+#include "ScriptableGameObjDef.h"
 
 DefinitionClass SCRIPTS_API *Find_Definition(unsigned long id)
 {
@@ -57,22 +58,13 @@
 	return d->Get_ID();
 }
 
-const DefinitionClass SCRIPTS_API *Get_Definition(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	return (DefinitionClass *)&(((ScriptableGameObj *)obj)->Get_Definition());
-}
-
 DefinitionClass SCRIPTS_API *Get_Phys_Definition(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o = (PhysicalGameObj *)As_PhysicalGameObj(obj);
+	PhysicalGameObj *o = obj->As_PhysicalGameObj();
 	if (!o)
 	{
 		return 0;
diff -uwr sourceold/scripts/engine_def.h source/scripts/engine_def.h
--- sourceold/scripts/engine_def.h	2011-10-11 21:54:12.960937500 +0800
+++ source/scripts/engine_def.h	2012-04-24 11:21:11.134765600 +0800
@@ -19,7 +19,6 @@
 DefinitionClass SCRIPTS_API *Find_Named_Definition(const char *name); //Find a DefinitionClass given its name
 DefinitionClass SCRIPTS_API *Find_Definition(unsigned long id); //Find a DefinitionClass given its ID
 unsigned long SCRIPTS_API Get_Definition_Class_ID(const char *name); //get the class ID of a definition (matches the #defines above)
-const DefinitionClass SCRIPTS_API *Get_Definition(GameObject *obj); //Get a DefinitionClass given an object
 DefinitionClass SCRIPTS_API *Get_Phys_Definition(GameObject *obj); //Get a DefinitionClass for the physics class given a PhysicalGameObj
 bool SCRIPTS_API Is_Valid_Preset_ID(unsigned long ID); //Is this a valid preset id
 bool SCRIPTS_API Is_Valid_Preset(const char *Preset); //Is this a valid preset name
diff -uwr sourceold/scripts/engine_dmg.cpp source/scripts/engine_dmg.cpp
--- sourceold/scripts/engine_dmg.cpp	2011-10-11 23:03:31.418945300 +0800
+++ source/scripts/engine_dmg.cpp	2012-04-24 21:56:27.633789000 +0800
@@ -22,6 +22,14 @@
 #include "VehicleGameObjDef.h"
 #ifndef TT_EXPORTS
 RENEGADE_FUNCTION
+int ArmorWarheadManager::Get_Num_Armor_Types()
+AT3(0x00687730, 0x00686FD0, 0x00519180);
+
+RENEGADE_FUNCTION
+int ArmorWarheadManager::Get_Num_Warhead_Types()
+AT3(0x00687740, 0x00686FE0, 0x00519190);
+
+RENEGADE_FUNCTION
 const char *ArmorWarheadManager::Get_Armor_Name(ArmorType)
 AT3(0x006877D0, 0x00687070, 0x00519240);
 
@@ -36,6 +44,51 @@
 RENEGADE_FUNCTION
 const char *ArmorWarheadManager::Get_Warhead_Name(WarheadType)
 AT3(0x006877E0, 0x00687080, 0x005192A0);
+
+RENEGADE_FUNCTION
+float ArmorWarheadManager::Get_Damage_Multiplier(ArmorType, WarheadType)
+AT3(0x006877F0, 0x00687090, 0x00519300);
+
+RENEGADE_FUNCTION
+ArmorWarheadManager::SpecialDamageType	ArmorWarheadManager::Get_Special_Damage_Type( WarheadType type )
+AT3(0x00687E60, 0x00687700, 0x005194E0);
+
+RENEGADE_FUNCTION
+float	ArmorWarheadManager::Get_Shield_Absorbsion( ArmorType armor, WarheadType warhead )
+AT3(0x00687AE0,0x00687380,0x005193A0);
+
+RENEGADE_FUNCTION
+bool				ArmorWarheadManager::Is_Armor_Soft( ArmorType armor )
+AT3(0x00687DD0,0x00687670,0x00519440);
+
+RENEGADE_FUNCTION
+float	ArmorWarheadManager::Get_Special_Damage_Probability( WarheadType type )
+AT3(0x00687E70,0x00687710,0x00519540);
+
+RENEGADE_FUNCTION
+WarheadType ArmorWarheadManager::Get_Special_Damage_Warhead( SpecialDamageType type )
+AT3(0x00687E80,0x00687720,0x005195A0);
+
+RENEGADE_FUNCTION
+float	ArmorWarheadManager::Get_Special_Damage_Duration( SpecialDamageType type )
+AT3(0x00687E90,0x00687730,0x005195F0);
+
+RENEGADE_FUNCTION
+float	ArmorWarheadManager::Get_Special_Damage_Scale( SpecialDamageType type )
+AT3(0x00687EA0,0x00687740,0x00519640);
+
+RENEGADE_FUNCTION
+const char *	ArmorWarheadManager::Get_Special_Damage_Explosion( SpecialDamageType type )
+AT3(0x00687EB0,0x00687750,0x00519690);
+
+RENEGADE_FUNCTION
+float	ArmorWarheadManager::Get_Visceroid_Probability( WarheadType type )
+AT3(0x00687EC0,0x00687760,0x005196E0);
+
+RENEGADE_FUNCTION
+bool	ArmorWarheadManager::Is_Skin_Impervious( SpecialDamageType type, ArmorType skin )
+AT3(0x00687ED0,0x00687770,0x00519740);
+
 #endif
 #ifndef TTLE_EXPORTS
 #include "Engine_Game.h"
@@ -44,7 +97,7 @@
 	SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_BuildingGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if ((Get_Object_Type(o) == Team) || (Team == 2))
@@ -61,7 +114,7 @@
 	SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_BuildingGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if ((Get_Object_Type(o) == Team) && (Commands->Get_ID(o) != ConstructionYardID))
@@ -79,13 +132,13 @@
 
 void SCRIPTS_API Repair_All_Static_Vehicles_By_Team(int Team,int type)
 {
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<VehicleGameObj> *x = GameObjManager::VehicleGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_VehicleGameObj(x->Data());
+		VehicleGameObj *o = x->Data();
 		if (o)
 		{
-			if (Get_Object_Type(o) == Team && Is_DecorationPhys(o))
+			if (Get_Object_Type(o) == Team && o->Peek_Physical_Object() && o->Peek_Physical_Object()->As_DecorationPhysClass())
 			{
 				Commands->Send_Custom_Event(o,o,type,0,0);
 			}
@@ -96,7 +149,11 @@
 
 void SCRIPTS_API Set_Max_Health(GameObject *obj,float health)
 {
-	DamageableGameObj *o = (DamageableGameObj *)As_DamageableGameObj(obj);
+	if (!obj)
+	{
+		return;
+	}
+	DamageableGameObj *o = obj->As_DamageableGameObj();
 	if (!o)
 	{
 		return;
@@ -107,7 +164,11 @@
 
 void SCRIPTS_API Set_Max_Shield_Strength(GameObject *obj,float shieldstrength)
 {
-	DamageableGameObj *o = (DamageableGameObj *)As_DamageableGameObj(obj);
+	if (!obj)
+	{
+		return;
+	}
+	DamageableGameObj *o = obj->As_DamageableGameObj();
 	if (!o)
 	{
 		return;
@@ -118,7 +179,11 @@
 
 const char SCRIPTS_API *Get_Shield_Type(GameObject *obj)
 {
-	DamageableGameObj *o = (DamageableGameObj *)As_DamageableGameObj(obj);
+	if (!obj)
+	{
+		return "";
+	}
+	DamageableGameObj *o = obj->As_DamageableGameObj();
 	if (!o)
 	{
 		return "";
@@ -128,7 +193,11 @@
 
 const char SCRIPTS_API *Get_Skin(GameObject *obj)
 {
-	DamageableGameObj *o = (DamageableGameObj *)As_DamageableGameObj(obj);
+	if (!obj)
+	{
+		return "";
+	}
+	DamageableGameObj *o = obj->As_DamageableGameObj();
 	if (!o)
 	{
 		return "";
@@ -138,7 +207,11 @@
 
 void SCRIPTS_API Set_Skin(GameObject *obj,const char *Skintype)
 {
-	DamageableGameObj *o = (DamageableGameObj *)As_DamageableGameObj(obj);
+	if (!obj)
+	{
+		return;
+	}
+	DamageableGameObj *o = obj->As_DamageableGameObj();
 	if (!o)
 	{
 		return;
@@ -150,15 +223,15 @@
 
 void SCRIPTS_API Damage_All_Vehicles_Area(float Damage,const char *Warhead,const Vector3 &Position,float Distance,GameObject *Host,GameObject *Damager)
 {
-	if (!Commands->Get_ID(Host) || !Host)
+	if (!Host)
 	{
 		return;
 	}
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<VehicleGameObj> *x = GameObjManager::VehicleGameObjList.Head();
 	while (x)
 	{
 		GameObject *obj = x->Data();
-		if (obj && As_VehicleGameObj(obj)) 
+		if (obj) 
 		{
 			Vector3 ObjPosition = Commands->Get_Position(obj);
 			Vector3 TestPosition = Position;
@@ -175,23 +248,28 @@
 
 void SCRIPTS_API Damage_All_Objects_Area(float Damage,const char *Warhead,const Vector3 &Position,float Distance,GameObject *Host,GameObject *Damager) 
 {
-	if (!Commands->Get_ID(Host) || !Host)
+	if (!Host)
 	{
 		return;
 	}
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x) 
 	{
-		GameObject *obj = (GameObject *)x->Data();
-		if (obj && As_ScriptableGameObj(obj)) 
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
 		{
-			Vector3 ObjPosition = Commands->Get_Position(obj);
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
+		{
+			Vector3 ObjPosition = Commands->Get_Position(o2);
 			Vector3 TestPosition = Position;
 			ObjPosition.Z = 0;
 			TestPosition.Z = 0;
-			if ((Commands->Get_Distance(ObjPosition,TestPosition) <= Distance) && (Commands->Get_ID(obj) != Commands->Get_ID(Host)))
+			if ((Commands->Get_Distance(ObjPosition,TestPosition) <= Distance) && (Commands->Get_ID(o2) != Commands->Get_ID(Host)))
 			{
-				Commands->Apply_Damage(obj,Damage,Warhead,Damager);
+				Commands->Apply_Damage(o2,Damage,Warhead,Damager);
 			}
 		}
 		x = x->Next();
@@ -205,7 +283,7 @@
 		SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
 		while (x)
 		{
-			GameObject *o = As_BuildingGameObj(x->Data());
+			GameObject *o = x->Data();
 			if (o)
 			{
 				float health = Commands->Get_Health(o);
@@ -236,7 +314,7 @@
 		SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
 		while (x)
 		{
-			GameObject *o = As_BuildingGameObj(x->Data());
+			GameObject *o = x->Data();
 			if (o)
 			{
 				float health = Commands->Get_Health(o);
@@ -266,7 +344,7 @@
 		SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
 		while (x)
 		{
-			GameObject *o = As_BuildingGameObj(x->Data());
+			GameObject *o = x->Data();
 			if (o)
 			{
 				float health = Commands->Get_Health(o);
@@ -297,7 +375,7 @@
 		SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
 		while (x)
 		{
-			GameObject *o = As_BuildingGameObj(x->Data());
+			GameObject *o = x->Data();
 			if (o)
 			{
 				if ((Get_Object_Type(o) == Team) || (Team == 2))
@@ -329,7 +407,7 @@
 		SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
 		while (x)
 		{
-			GameObject *o = As_BuildingGameObj(x->Data());
+			GameObject *o = x->Data();
 			if (o)
 			{
 				if ((Get_Object_Type(o) == Team) || (Team == 2))
@@ -360,7 +438,7 @@
 		SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
 		while (x)
 		{
-			GameObject *o = As_BuildingGameObj(x->Data());
+			GameObject *o = x->Data();
 			if (o)
 			{
 				if ((Get_Object_Type(o) == Team) || (Team == 2))
@@ -393,12 +471,9 @@
 		GameObject *obj = z->Data();
 		if (obj)
 		{
-			if (As_SoldierGameObj(obj) || As_VehicleGameObj(obj))
-			{
 				float Health = Commands->Get_Max_Health(obj) + Commands->Get_Max_Shield_Strength(obj);
 				Commands->Apply_Damage(obj,(Health / 2),"None",0);
 			}
-		}
 		z = z->Next();
 	}
 }
@@ -407,22 +482,18 @@
 {
 	if (DamageRadius > 0)
 	{
-		SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+		SLNode<VehicleGameObj> *x = GameObjManager::VehicleGameObjList.Head();
 		while (x)
 		{
 			GameObject *o = x->Data();
 			if (o)
 			{
-				if (As_VehicleGameObj(o))
-				{
 					float health = Commands->Get_Health(o);
 					if (health > 0)
 					{
 						Vector3 pos1 = Commands->Get_Position(o);
 						Vector3 pos2 = Location;
-
 						float Distance = Commands->Get_Distance(pos1,pos2);
-
 						if (Distance <= DamageRadius)
 						{
 							float Max_Health = Commands->Get_Max_Health(o);
@@ -432,7 +503,6 @@
 						}
 					}
 				}
-			}
 			x = x->Next();
 		}
 	}
@@ -440,11 +510,11 @@
 
 void SCRIPTS_API Set_Damage_Points(GameObject *obj,float points)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	DamageableGameObj *o = (DamageableGameObj*)As_DamageableGameObj(obj);
+	DamageableGameObj *o = obj->As_DamageableGameObj();
 	if (!o)
 	{
 		return;
@@ -454,11 +524,11 @@
 
 void SCRIPTS_API Set_Death_Points(GameObject *obj,float points)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	DamageableGameObj *o = (DamageableGameObj*)As_DamageableGameObj(obj);
+	DamageableGameObj *o = obj->As_DamageableGameObj();
 	if (!o)
 	{
 		return;
@@ -472,7 +542,7 @@
 	SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_BuildingGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if ((Get_Object_Type(o) == Team) && (Commands->Get_ID(o) != ConstructionYardID))
@@ -496,10 +566,10 @@
 
 void SCRIPTS_API Repair_All_Turrets_By_Team(int team,float health)
 {
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<VehicleGameObj> *x = GameObjManager::VehicleGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_VehicleGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if (Get_Object_Type(o) == team && (Get_Vehicle_Mode(o) == VEHICLE_TYPE_TURRET))
@@ -522,19 +592,24 @@
 
 void SCRIPTS_API Damage_All_Objects_In_Zone(GameObject *Zone,float Damage,const char *Warhead,GameObject *Damager)
 {
-	if (!Commands->Get_ID(Zone) || !Zone)
+	if (!Zone)
 	{
 		return;
 	}
 	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
 		{
-			if (IsInsideZone(Zone,o))
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 			{
-				Commands->Apply_Damage(o,Damage,Warhead,Damager);
+			if (IsInsideZone(Zone,o2))
+			{
+				Commands->Apply_Damage(o2,Damage,Warhead,Damager);
 			}
 		}
 		x = x->Next();
@@ -543,11 +618,11 @@
 
 float SCRIPTS_API Get_Damage_Points(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	DamageableGameObj *o = (DamageableGameObj*)As_DamageableGameObj(obj);
+	DamageableGameObj *o = obj->As_DamageableGameObj();
 	if (!o)
 	{
 		return 0;
@@ -557,11 +632,11 @@
 
 float SCRIPTS_API Get_Death_Points(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	DamageableGameObj *o = (DamageableGameObj*)As_DamageableGameObj(obj);
+	DamageableGameObj *o = obj->As_DamageableGameObj();
 	if (!o)
 	{
 		return 0;
@@ -571,34 +646,34 @@
 
 void SCRIPTS_API Damage_Occupants(GameObject *obj,float Damage,const char *Warhead)
 {
-	if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+	if (!obj || !obj->As_VehicleGameObj())
 	{
 		return;
 	}
-	VehicleGameObj *o = (VehicleGameObj *)obj;
+	VehicleGameObj *o = obj->As_VehicleGameObj();
 	int x = o->Get_Definition().Get_Seat_Count();
 	for (int i = 0;i < x;i++)
 	{
 		if (o->Get_Occupant(i))
 		{
-			Commands->Apply_Damage((GameObject *)o->Get_Occupant(i),Damage,Warhead,0);
+			Commands->Apply_Damage(o->Get_Occupant(i),Damage,Warhead,0);
 		}
 	}
 }
 
 void SCRIPTS_API Kill_Occupants(GameObject *obj)
 {
-	if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+	if (!obj || !obj->As_VehicleGameObj())
 	{
 		return;
 	}
-	VehicleGameObj *o = (VehicleGameObj *)obj;
+	VehicleGameObj *o = obj->As_VehicleGameObj();
 	int x = o->Get_Definition().Get_Seat_Count();
 	for (int i = 0;i < x;i++)
 	{
 		if (o->Get_Occupant(i))
 		{
-			Commands->Apply_Damage((GameObject *)o->Get_Occupant(i),100,"Death",0);
+			Commands->Apply_Damage((GameObject *)o->Get_Occupant(i),99999,"Death",0);
 		}
 	}
 }
@@ -609,14 +684,12 @@
 	//does to all other vehicles. It can also force friendly fire
 	if (DamageRadius > 0)
 	{
-		SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+		SLNode<VehicleGameObj> *x = GameObjManager::VehicleGameObjList.Head();
 		while (x)
 		{
 			GameObject *o = x->Data();
 			if (o)
 			{
-				if (As_VehicleGameObj(o))
-				{
 					float health = Commands->Get_Health(o);
 					if (health > 0)
 					{
@@ -649,7 +722,6 @@
 							}
 						}
 					}
-				}
 			}
 			x = x->Next();
 		}
diff -uwr sourceold/scripts/engine_game.cpp source/scripts/engine_game.cpp
--- sourceold/scripts/engine_game.cpp	2011-10-22 19:44:00.545898400 +0800
+++ source/scripts/engine_game.cpp	2012-05-23 10:47:48.822265600 +0800
@@ -24,6 +24,7 @@
 #include "VehicleFactoryGameObj.h"
 #include "VehicleFactoryGameObjDef.h"
 #include "HarvesterClass.h"
+#include "DefinitionMgrClass.h"
 REF_DEF2(CombatManager::IAmServer, bool, 0x00855EC8, 0x008550B0);
 RENEGADE_FUNCTION
 void *Game_Mode_Find(const char *)
@@ -48,7 +49,7 @@
 VehicleGameObj *BaseControllerClass::Get_Harvester_Vehicle()
 {
 	BuildingGameObj* refinery = Find_Building(BuildingConstants::TYPE_REFINERY);
-	return refinery ? refinery->As_RefineryGameObj()->Get_Harvester_Vehicle() : nullptr;
+	return refinery && refinery->As_RefineryGameObj() ? refinery->As_RefineryGameObj()->Get_Harvester_Vehicle() : nullptr;
 }
 void BaseControllerClass::Set_Can_Generate_Soldiers(bool CanGenerate)
 {
@@ -201,12 +202,11 @@
 
 bool SCRIPTS_API Is_Harvester(GameObject *obj)
 {
-	if (!As_VehicleGameObj(obj))
+	if (!obj)
 	{
 		return false;
 	}
-	int ID = Commands->Get_ID(obj);
-	if (Commands->Get_ID(Find_Harvester(0)) == ID || Commands->Get_ID(Find_Harvester(1)) == ID)
+	if (Find_Harvester(0) == obj || Find_Harvester(1) == obj)
 	{
 		return true;
 	}
@@ -225,26 +225,26 @@
 
 int SCRIPTS_API Building_Type(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	GameObject *o = As_BuildingGameObj(obj);
+	BuildingGameObj *o = obj->As_BuildingGameObj();
 	if (!o)
 	{
 		return 0;
 	}
-	BuildingGameObjDef *d = (BuildingGameObjDef *)Get_Definition(obj);
-	return d->Get_Type();
+	const BuildingGameObjDef &d = o->Get_Definition();
+	return d.Get_Type();
 }
 
 bool SCRIPTS_API Is_Building_Dead(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	BuildingGameObj *o = (BuildingGameObj *)As_BuildingGameObj(obj);
+	BuildingGameObj *o = obj->As_BuildingGameObj();
 	if (!o)
 	{
 		return 0;
@@ -252,7 +252,7 @@
 	return o->Is_Destroyed();
 }
 
-GameObject SCRIPTS_API *Find_Building(int team,int type)
+GameObject SCRIPTS_API *Find_Building_By_Type(int team,int type)
 {
 	BaseControllerClass *c = BaseControllerClass::Find_Base(team);
 	if (c)
@@ -285,13 +285,17 @@
 		return 0;
 	}
 	GameObject *obj = (GameObject *)d->Create();
-	if (As_BuildingGameObj(obj))
+	
+	if (obj)
+	{
+		BuildingGameObj *c = obj->As_BuildingGameObj();
+		if (c)
 	{
-		BuildingGameObj *c = (BuildingGameObj *)obj;
 		c->Set_Position(Position);
 		c->Collect_Building_Components();
 		c->Start_Observers();
-		return obj;
+			return c;
+		}
 	}
 	return 0;
 }
@@ -322,7 +326,7 @@
 	GameObject *o = 0;
 	if (c)
 	{
-		o = (GameObject *)c->Get_Harvester_Vehicle();
+		o = c->Get_Harvester_Vehicle();
 	}
 	return o;
 }
@@ -347,22 +351,10 @@
 	return false;
 }
 
-bool SCRIPTS_API Can_Generate_Soliders(int team)
-{
-	BaseControllerClass *c = BaseControllerClass::Find_Base(team);
-	if (c)
+bool SCRIPTS_API Can_Generate_Soldiers(int team)
 	{
+	if ( BaseControllerClass *c = BaseControllerClass::Find_Base(team) )
 		return c->Can_Generate_Soldiers();
-	}
-	return false;
-}
-
-bool SCRIPTS_API Is_A_Building(GameObject *obj)
-{
-	if (As_BuildingGameObj(obj))
-	{
-		return true;
-	}
 	return false;
 }
 
@@ -372,7 +364,7 @@
 	int Count = 0;
 	while (x)
 	{
-		GameObject *o = As_BuildingGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o && Commands->Get_Health(o) > 0 && (Get_Object_Type(o) == Team || Team == 2))
 		{
 			Count++;
@@ -387,10 +379,10 @@
 	SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_BuildingGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
-			const DefinitionClass *d = Get_Definition(o);
+			const DefinitionClass *d = &o->Get_Definition();
 			if (d->Get_Class_ID() == Class_ID)
 			{
 				if ((Get_Object_Type(o) == Team) || (Team == 2))
@@ -406,47 +398,62 @@
 
 GameObject SCRIPTS_API *Find_Power_Plant(int Team)
 {
-	return Find_Building(Team,BuildingConstants::TYPE_POWER_PLANT);
+	return Find_Building_By_Type(Team,BuildingConstants::TYPE_POWER_PLANT);
 }
 
 GameObject SCRIPTS_API *Find_Construction_Yard(int Team)
 {
-	return Find_Building(Team,BuildingConstants::TYPE_CONYARD);
+	return Find_Building_By_Type(Team,BuildingConstants::TYPE_CONYARD);
 }
 
 GameObject SCRIPTS_API *Find_Refinery(int Team)
 {
-	return Find_Building(Team,BuildingConstants::TYPE_REFINERY);
+	return Find_Building_By_Type(Team,BuildingConstants::TYPE_REFINERY);
 }
 
 GameObject SCRIPTS_API *Find_Repair_Bay(int Team)
 {
-	return Find_Building(Team,BuildingConstants::TYPE_REPAIR_BAY);
+	return Find_Building_By_Type(Team,BuildingConstants::TYPE_REPAIR_BAY);
 }
 
 GameObject SCRIPTS_API *Find_Soldier_Factory(int Team)
 {
-	return Find_Building(Team,BuildingConstants::TYPE_SOLDIER_FACTORY);
+	return Find_Building_By_Type(Team,BuildingConstants::TYPE_SOLDIER_FACTORY);
 }
 
-GameObject SCRIPTS_API *Find_Airstrip(int Team)
+GameObject SCRIPTS_API *Find_Vehicle_Factory(int Team)
 {
-	return Find_Building_By_Class_ID(Team,0xD006);
+	return Find_Building_By_Type(Team,BuildingConstants::TYPE_VEHICLE_FACTORY);
 }
 
-GameObject SCRIPTS_API *Find_War_Factory(int Team)
+GameObject SCRIPTS_API *Find_Shrine(int Team)
 {
-	return Find_Building_By_Class_ID(Team,0xD007);
+	return Find_Building_By_Type(Team,BuildingConstants::TYPE_SHRINE);
 }
 
-GameObject SCRIPTS_API *Find_Vehicle_Factory(int Team)
+GameObject SCRIPTS_API *Find_Helipad(int Team)
+{
+	return Find_Building_By_Type(Team,BuildingConstants::TYPE_HELIPAD);
+}
+
+GameObject SCRIPTS_API *Find_Tech_Center(int Team)
 {
-	return Find_Building(Team,BuildingConstants::TYPE_VEHICLE_FACTORY);
+	return Find_Building_By_Type(Team,BuildingConstants::TYPE_TECH_CENTER);
+}
+
+GameObject SCRIPTS_API *Find_Naval_Factory(int Team)
+{
+	return Find_Building_By_Type(Team,BuildingConstants::TYPE_NAVAL_FACTORY);
+}
+
+GameObject SCRIPTS_API *Find_Special(int Team)
+{
+	return Find_Building_By_Type(Team,BuildingConstants::TYPE_SPECIAL);
 }
 
 GameObject SCRIPTS_API *Find_Com_Center(int Team)
 {
-	return Find_Building(Team,BuildingConstants::TYPE_COM_CENTER);
+	return Find_Building_By_Type(Team,BuildingConstants::TYPE_COM_CENTER);
 }
 
 GameObject SCRIPTS_API *Find_Building_By_Team(int Team)
@@ -454,7 +461,7 @@
 	SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_BuildingGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if (Get_Object_Type(o) == Team)
@@ -467,15 +474,15 @@
 	return 0;
 }
 
-GameObject SCRIPTS_API *Find_Building_By_Name(int Team,const char *Preset_Name)
+GameObject SCRIPTS_API *Find_Building_By_Preset(int Team,const char *Preset_Name)
 {
 	SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_BuildingGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
-			const DefinitionClass *d = Get_Definition(o);
+			const DefinitionClass *d = &o->Get_Definition();
 			if (!_stricmp(d->Get_Name(),Preset_Name))
 			{
 				if ((Get_Object_Type(o) == Team) || (Team == 2))
@@ -502,10 +509,10 @@
 	BaseControllerClass* base = BaseControllerClass::Find_Base(Get_Object_Type(building));
 	if (base) 
 	{
-		if (Is_SoldierFactory(building))
+		if (building->As_SoldierFactoryGameObj())
 			base->Set_Can_Generate_Soldiers(true);
 		
-		if (Is_VehicleFactory(building))
+		if (building->As_VehicleFactoryGameObj())
 			base->Set_Can_Generate_Vehicles(true);
 		
 		base->Set_Object_Dirty_Bit(NetworkObjectClass::BIT_RARE, true);
@@ -581,12 +588,16 @@
 
 int SCRIPTS_API Get_Harvester_Preset_ID(int Team)
 {
-	RefineryGameObj *Ref = (RefineryGameObj*)Find_Refinery(Team);
-	if (!Ref)
+	if (!Find_Refinery(Team))
 	{
 		return 0;
 	}
-	return Ref->Get_Definition().Get_Harvester_ID();
+	BuildingGameObj *Ref = Find_Refinery(Team)->As_BuildingGameObj();
+	if (!Ref || !Ref->As_RefineryGameObj())
+	{
+		return 0;
+	}
+	return Ref->As_RefineryGameObj()->Get_Harvester_Def_ID();
 }
 
 bool SCRIPTS_API Is_Harvester_Preset(GameObject *obj)
@@ -603,3 +614,57 @@
 {
 	return (const SimpleGameObjDef &)BaseGameObj::Get_Definition();
 }
+
+bool SCRIPTS_API Vehicle_Preset_Is_Air(int preset)
+{
+	DefinitionClass *def = DefinitionMgrClass::Find_Definition(preset,true);
+	if (!def)
+	{
+		return false;
+	}
+	if (def->Get_Class_ID() == 12304)
+	{
+		VehicleGameObjDef *def2 = (VehicleGameObjDef *)def;
+		if (def2->Get_Type() == VEHICLE_TYPE_FLYING && !def2->Get_Build_At_Ground())
+		{
+			return true;
+		}
+	}
+	return false;
+}
+bool SCRIPTS_API Vehicle_Preset_Is_Naval(int preset)
+{
+	DefinitionClass *def = DefinitionMgrClass::Find_Definition(preset,true);
+	if (!def)
+	{
+		return false;
+	}
+	if (def->Get_Class_ID() == 12304)
+	{
+		VehicleGameObjDef *def2 = (VehicleGameObjDef *)def;
+		if (def2->Get_Type() == VEHICLE_TYPE_BOAT || def2->Get_Type() == VEHICLE_TYPE_SUB)
+		{
+			return true;
+		}
+	}
+	return false;
+}
+
+Vector3 SCRIPTS_API Get_Base_Center(int Team)
+{
+		Vector3 ReturnPos(0.0f,0.0f,0.0f);
+		BaseControllerClass *Base = BaseControllerClass::Find_Base(Team);
+		if (Base)
+		{
+				int Num = 0;
+				for (Num = 0;Num < Base->Get_Building_List().Count();Num++)
+				{
+						ReturnPos += Commands->Get_Position(Base->Get_Building_List()[Num]);
+				}
+				if (Num)
+				{
+						ReturnPos /= (float)Num;
+				}
+		}
+		return ReturnPos;
+}
diff -uwr sourceold/scripts/engine_game.h source/scripts/engine_game.h
--- sourceold/scripts/engine_game.h	2011-10-11 21:54:02.241210900 +0800
+++ source/scripts/engine_game.h	2012-05-23 10:47:49.340820300 +0800
@@ -13,48 +13,488 @@
 #define SCRIPTS_INCLUDE__ENGINE_GAME_H
 #include "GameData.h"
 
-void SCRIPTS_API Power_Base(int team,bool powered); //Power a base up or down, correctly handles the doubled build time and costs
-void SCRIPTS_API Set_Can_Generate_Soldiers(int team,bool cangenerate); //Sets if soliders are purchasable
-void SCRIPTS_API Set_Can_Generate_Vehicles(int team,bool cangenerate); //Sets if vehicles are purchaseable
-void SCRIPTS_API Destroy_Base(int team); //Destroys a base completly
-void SCRIPTS_API Beacon_Destroyed_Base(int team, bool destroyed); //Sets if a base was destroyed by a beacon in the beacon zone
-void SCRIPTS_API Enable_Base_Radar(int team, bool enable); //Enables radar for a base, same thing as the communications center does
-bool SCRIPTS_API Is_Harvester(GameObject *obj); //Is this object one of the 2 team AI harvesters?
-bool SCRIPTS_API Is_Radar_Enabled(int team); //returns if the radar is enabled
-int SCRIPTS_API Building_Type(GameObject *obj); //returns the type of a BuildingGameObj
-bool SCRIPTS_API Is_Building_Dead(GameObject *obj); //Does the game consider the building dead
-GameObject SCRIPTS_API *Find_Building(int team,int type); //Find a building by team and type
-GameObject SCRIPTS_API *Find_Base_Defense(int team); //Find base defense for a team
-bool SCRIPTS_API Is_Map_Flying(); //Is the current map a flying map
+/*!
+* Enable or disable base power for a team, this correctly handles all the relavent stuff including base defences and purchase time/cost changes.
+*
+* \param[in] team
+*   ID of the team to set power state for
+*
+* \param[in] powered
+*   whether to enable or disable power
+*
+*/
+void SCRIPTS_API Power_Base(int team,bool powered);
+
+/*!
+* Enable or disable advanced infantry purchasability for a team
+*
+* \param[in] team
+*   ID of the team to set advanced infantry purchasability for
+*
+* \param[in] cangenerate
+*   whether to enable or disable generation
+*
+*/
+void SCRIPTS_API Set_Can_Generate_Soldiers(int team,bool cangenerate);
+
+/*!
+* Enable or disable vehicle purchasability for a team
+*
+* \param[in] team
+*   ID of the team to set vehicle purchasability for
+*
+* \param[in] cangenerate
+*   whether to enable or disable generation
+*
+*/
+void SCRIPTS_API Set_Can_Generate_Vehicles(int team,bool cangenerate);
+
+/*!
+* Destroy the base of a team
+*
+* \param[in] team
+*   ID of the team to destroy the base of
+*
+*/
+void SCRIPTS_API Destroy_Base(int team);
+
+/*!
+* Set or clear the "beacon destroyed base" flag for a team
+*
+* \param[in] team
+*   ID of the team to change the "beacon destroyed base" flag on
+*
+* \param[in] destroyed
+*   whether to enable or disable the "beacon destroyed base" flag
+*
+*/
+void SCRIPTS_API Beacon_Destroyed_Base(int team, bool destroyed);
+
+/*!
+* Enable or disable radar for a team
+*
+* \param[in] team
+*   ID of the team to set radar for
+*
+* \param[in] enable
+*   whether to enable or disable radar
+*
+*/
+void SCRIPTS_API Enable_Base_Radar(int team, bool enable);
+
+/*!
+* Check if an object is an AI harvester
+*
+* \param[in] obj
+*   object to check
+*
+* \return
+*   True if the object is an AI harvester, false otherwise
+*/
+bool SCRIPTS_API Is_Harvester(GameObject *obj);
+
+/*!
+* Check if a teams base radar is enabled
+*
+* \param[in] team
+*   ID of the team to check the radar of
+*
+* \return
+*   True if the specified teams radar is enabled, false otherwise
+*/
+bool SCRIPTS_API Is_Radar_Enabled(int team);
+
+/*!
+* Get the building type for a building
+*
+* \param[in] obj
+*   object to get type of
+*
+* \return
+*   building type of the building
+*/
+int SCRIPTS_API Building_Type(GameObject *obj);
+
+/*!
+* Check if a building is dead
+*
+* \param[in] obj
+*   object to check
+*
+* \return
+*   True if the building is dead, false otherwise
+*/
+bool SCRIPTS_API Is_Building_Dead(GameObject *obj);
+
+/*!
+* Find the first building of a given building type for this team
+*
+* \param[in] team
+*   ID of the team to find the building for
+*
+* \param[in] type
+*   type to find
+*
+* \return
+*   First building for this team of this type (if any)
+*/
+GameObject SCRIPTS_API *Find_Building_By_Type(int team,int type);
+
+/*!
+* Find the first base defense building for this team (if any)
+*
+* \param[in] Team
+*   ID of the team to find the base defense building for
+*
+* \return
+*   First base defense building for this team (if any)
+*/
+GameObject SCRIPTS_API *Find_Base_Defense(int team);
+
+/*!
+* Check if the current map is a flying map
+*
+* \return
+*   True if the map is a flying time map
+*/
+bool SCRIPTS_API Is_Map_Flying();
+
 GameObject SCRIPTS_API *Create_Building(const char *preset,const Vector3 & Position); //Create a building controller
-GameObject SCRIPTS_API *Find_Harvester(int team); //Find this teams current harvester, if any
-bool SCRIPTS_API Is_Base_Powered(int team); //Is this teams base powered
-bool SCRIPTS_API Can_Generate_Vehicles(int team); //Can this team buy vehicles
-bool SCRIPTS_API Can_Generate_Soliders(int team); //Can this team buy soldiers
-cGameData SCRIPTS_API *The_Game(); //get the cGameData
-cGameDataSkirmish SCRIPTS_API *The_Skirmish_Game(); //get the cGameDataSkirmish
-cGameDataCnc SCRIPTS_API *The_Cnc_Game(); //get the cGameDataCnc
-cGameDataSinglePlayer SCRIPTS_API *The_Single_Player_Game(); //get the cGameDataSinglePlayer
-bool SCRIPTS_API Is_A_Building(GameObject *obj); //is this object any building type
-int SCRIPTS_API Get_Building_Count_Team(int Team); //number of buildings a team has that are alive
-GameObject SCRIPTS_API *Find_Building_By_Team(int Team); //finds the first building of this team,0 = Nod,1 = GDI
-GameObject SCRIPTS_API *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
-GameObject SCRIPTS_API *Find_Power_Plant(int Team); //finds the first powerplant for Team,0 = Nod,1 = GDI,2 = either
-GameObject SCRIPTS_API *Find_Construction_Yard(int Team); //finds the first construction yard for Team,0 = Nod,1 = GDI,2 = either
-GameObject SCRIPTS_API *Find_Refinery(int Team); //finds the first refinery for Team,0 = Nod,1 = GDI,2 = either
-GameObject SCRIPTS_API *Find_Repair_Bay(int Team); //finds the first repair bay for Team,0 = Nod,1 = GDI,2 = either
-GameObject SCRIPTS_API *Find_Soldier_Factory(int Team); //finds the first soldier factory for Team,0 = Nod,1 = GDI,2 = either
-GameObject SCRIPTS_API *Find_Airstrip(int Team); //finds the first airstrip for Team,0 = Nod,1 = GDI,2 = either
-GameObject SCRIPTS_API *Find_War_Factory(int Team); //finds the first war factory for Team,0 = Nod,1 = GDI,2 = either
-GameObject SCRIPTS_API *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 SCRIPTS_API *Find_Com_Center(int Team); //finds the first communications center for Team,0 = Nod,1 = GDI,2 = either
+
+/*!
+* Find the AI harvester for a team (if any)
+*
+* \param[in] team
+*   ID of the team to find the harvester for
+*
+* \return
+*   AI harvester object
+*/
+GameObject SCRIPTS_API *Find_Harvester(int team);
+
+/*!
+* Check if a teams base is powered
+*
+* \param[in] team
+*   ID of the team to check the base power of
+*
+* \return
+*   True if the specified teams base is powered, false otherwise
+*/
+bool SCRIPTS_API Is_Base_Powered(int team);
+
+/*!
+* Check if a team can currently purchase vehicles
+*
+* \param[in] team
+*   ID of the team to check vehicle purchasability for
+*
+* \return
+*   True if the specified team can purchase vehicles, false otherwise
+*/
+bool SCRIPTS_API Can_Generate_Vehicles(int team);
+
+/*!
+* Check if a team can currently purchase advanced infantry characters
+*
+* \param[in] team
+*   ID of the team to check advanced infantry purchasability for
+*
+* \return
+*   True if the specified team can purchase advanced infantry characters, false otherwise
+*/
+bool SCRIPTS_API Can_Generate_Soldiers(int team);
+
+/*!
+* Get the current cGameData
+*
+* \return
+*   current cGameData
+*/
+cGameData SCRIPTS_API *The_Game();
+
+/*!
+* Get the current cGameDataSkirmish, if any
+*
+* \return
+*   current cGameDataSirmish, if any
+*/
+cGameDataSkirmish SCRIPTS_API *The_Skirmish_Game();
+
+/*!
+* Get the current cGameDataCnc, if any
+*
+* \return
+*   current cGameDataCnc, if any
+*/
+cGameDataCnc SCRIPTS_API *The_Cnc_Game();
+
+/*!
+* Get the current cGameDataSinglePlayer, if any
+*
+* \return
+*   current cGameDataSinglePlayer, if any
+*/
+cGameDataSinglePlayer SCRIPTS_API *The_Single_Player_Game();
+
+/*!
+* Get the count of how many buildings a given team has
+*
+* \param[in] Team
+*   ID of the team to count the buildings of
+*
+* \return
+*   count of the buildings for that team
+*/
+int SCRIPTS_API Get_Building_Count_Team(int Team);
+
+/*!
+* Find the first building for this team
+*
+* \param[in] Team
+*   ID of the team to find the building for
+*
+* \return
+*   First building for this team
+*/
+GameObject SCRIPTS_API *Find_Building_By_Team(int Team);
+
+/*!
+* Find the first building of a given preset type for this team
+*
+* \param[in] Team
+*   ID of the team to find the building for
+*
+* \param[in] Preset_Name
+*   preset name to find
+*
+* \return
+*   First building for this team of this preset (if any)
+*/
+GameObject SCRIPTS_API *Find_Building_By_Preset(int Team,const char *Preset_Name);
+
+/*!
+* Find the first power plant for this team (if any)
+*
+* \param[in] Team
+*   ID of the team to find the power plant for
+*
+* \return
+*   First power plant for this team (if any)
+*/
+GameObject SCRIPTS_API *Find_Power_Plant(int Team);
+
+/*!
+* Find the first construction yard for this team (if any)
+*
+* \param[in] Team
+*   ID of the team to find the construction yard for
+*
+* \return
+*   First construction yard for this team (if any)
+*/
+GameObject SCRIPTS_API *Find_Construction_Yard(int Team);
+
+/*!
+* Find the first refinery for this team (if any)
+*
+* \param[in] Team
+*   ID of the team to find the refinery for
+*
+* \return
+*   First refinery for this team (if any)
+*/
+GameObject SCRIPTS_API *Find_Refinery(int Team);
+
+/*!
+* Find the first repair bay for this team (if any)
+*
+* \param[in] Team
+*   ID of the team to find the repair bay for
+*
+* \return
+*   First repair bay for this team (if any)
+*/
+GameObject SCRIPTS_API *Find_Repair_Bay(int Team);
+
+/*!
+* Find the first soldier factory for this team (if any)
+*
+* \param[in] Team
+*   ID of the team to find the soldier factory for
+*
+* \return
+*   First soldier factory for this team (if any)
+*/
+GameObject SCRIPTS_API *Find_Soldier_Factory(int Team);
+
+/*!
+* Find the first vehicle factory for this team (if any)
+*
+* \param[in] Team
+*   ID of the team to find the vehicle factory for
+*
+* \return
+*   First vehicle factory for this team (if any)
+*/
+GameObject SCRIPTS_API *Find_Vehicle_Factory(int Team);
+
+/*!
+* Find the first com center for this team (if any)
+*
+* \param[in] Team
+*   ID of the team to find the com center for
+*
+* \return
+*   First com center for this team (if any)
+*/
+GameObject SCRIPTS_API *Find_Com_Center(int Team);
+
+/*!
+* Find the first special building for this team (if any)
+*
+* \param[in] Team
+*   ID of the team to find the special building for
+*
+* \return
+*   First special building for this team (if any)
+*/
+GameObject SCRIPTS_API *Find_Special(int Team);
+
+/*!
+* Find the first naval factory for this team (if any)
+*
+* \param[in] Team
+*   ID of the team to find the naval factory for
+*
+* \return
+*   First naval factory for this team (if any)
+*/
+GameObject SCRIPTS_API *Find_Naval_Factory(int Team);
+
+/*!
+* Find the first tech center for this team (if any)
+*
+* \param[in] Team
+*   ID of the team to find the tech center for
+*
+* \return
+*   First tech center for this team (if any)
+*/
+GameObject SCRIPTS_API *Find_Tech_Center(int Team);
+
+/*!
+* Find the first helipad for this team (if any)
+*
+* \param[in] Team
+*   ID of the team to find the helipad for
+*
+* \return
+*   First helipad for this team (if any)
+*/
+GameObject SCRIPTS_API *Find_Helipad(int Team);
+
+/*!
+* Find the first shrine for this team (if any)
+*
+* \param[in] Team
+*   ID of the team to find the shrine for
+*
+* \return
+*   First shrine for this team (if any)
+*/
+GameObject SCRIPTS_API *Find_Shrine(int Team);
+
 void SCRIPTS_API Restore_Building(GameObject* obj); //restores a building to life
-bool SCRIPTS_API Is_Gameplay_Permitted(); //is gameplay permitted
-bool SCRIPTS_API Is_Dedicated(); //returns false if game.exe, true if WFDS/LFDS
-unsigned int SCRIPTS_API 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.
+
+/*!
+* Check if gameplay is permitted
+*
+* \return
+*   True if gameplay is permitted
+*/
+bool SCRIPTS_API Is_Gameplay_Permitted();
+
+/*!
+* Check if running on the FDS
+*
+* \return
+*   True if running on the FDS
+*/
+bool SCRIPTS_API Is_Dedicated();
+
+/*!
+* Get current game mode, 0 = 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.
+*
+* \return
+*   Current game mode
+*/
+unsigned int SCRIPTS_API Get_Current_Game_Mode();
+
 void SCRIPTS_API Get_Private_Message_Color(unsigned int *red, unsigned int *green, unsigned int *blue); //get color for private messages
 void SCRIPTS_API Get_Public_Message_Color(unsigned int *red, unsigned int *green, unsigned int *blue); //get color for public messages
-int SCRIPTS_API Get_Harvester_Preset_ID(int Team); //Get the harvester preset ID for this team
-bool SCRIPTS_API Is_Harvester_Preset(GameObject *obj); //Checks if the object has the same preset used for the harvesters
-bool SHADERS_API Is_Night_Map(); //is the current map a nighttime map
+
+/*!
+* Get the AI harvester preset ID of a specific team
+*
+* \param[in] team
+*   ID of the team to get the harvester preset ID of
+*
+* \return
+*   ID of the AI harvester preset for this team
+*/
+int SCRIPTS_API Get_Harvester_Preset_ID(int Team);
+
+/*!
+* Check if a preset matches the AI harvester preset set in the refinery
+*
+* \param[in] preset
+*   ID of the preset to check
+*
+* \return
+*   True if the preset matches the AI harvester preset set in the refinery
+*/
+bool SCRIPTS_API Is_Harvester_Preset(GameObject *obj);
+
+/*!
+* Check if the current map is a night time map
+*
+* \return
+*   True if the map is a night time map
+*/
+bool SHADERS_API Is_Night_Map();
+
+/*!
+* Check if a preset is an air unit
+*
+* \param[in] preset
+*   ID of the preset to check
+*
+* \return
+*   True if the preset is an air unit (i.e. will be built at the air factory when its built)
+*/
+bool SCRIPTS_API Vehicle_Preset_Is_Air(int preset);
+
+/*!
+* Check if a preset is a naval unit
+*
+* \param[in] preset
+*   ID of the preset to check
+*
+* \return
+*   True if the preset is a naval unit (i.e. will be built at the naval factory when its built)
+*/
+bool SCRIPTS_API Vehicle_Preset_Is_Naval(int preset);
+
+/*!
+* Find the center point of a base
+*
+* \param[in] team
+*   ID of the team to use
+*
+* \return
+*   Center of that teams base
+*/
+Vector3 SCRIPTS_API Get_Base_Center(int Team);
 #endif
diff -uwr sourceold/scripts/engine_obj.cpp source/scripts/engine_obj.cpp
--- sourceold/scripts/engine_obj.cpp	2012-02-17 21:03:32.721679600 +0800
+++ source/scripts/engine_obj.cpp	2012-05-23 11:24:04.913085900 +0800
@@ -29,6 +29,8 @@
 #include "TransitionGameObjDef.h"
 #include "AirFactoryGameObjDef.h"
 #include "AirFactoryGameObj.h"
+#include "NavalFactoryGameObjDef.h"
+#include "NavalFactoryGameObj.h"
 #include "AirStripGameObjDef.h"
 #include "AirStripGameObj.h"
 #include "BeaconGameObjDef.h"
@@ -58,844 +60,269 @@
 #include "WarFactoryGameObjDef.h"
 #include "WarFactoryGameObj.h"
 
-const AirFactoryGameObjDef &
+SCRIPTS_API const AirFactoryGameObjDef &
 AirFactoryGameObj::Get_Definition (void) const
 {
 	return (const AirFactoryGameObjDef &)BaseGameObj::Get_Definition ();
 }
-const AirStripGameObjDef & AirStripGameObj::Get_Definition( void ) const
+SCRIPTS_API  const NavalFactoryGameObjDef &
+NavalFactoryGameObj::Get_Definition (void) const
+{
+	return (const NavalFactoryGameObjDef &)BaseGameObj::Get_Definition ();
+}
+SCRIPTS_API  const AirStripGameObjDef & AirStripGameObj::Get_Definition( void ) const
 {
 	return (const AirStripGameObjDef &)BaseGameObj::Get_Definition();
 }
-const ArmedGameObjDef & ArmedGameObj::Get_Definition( void ) const
+SCRIPTS_API  const ArmedGameObjDef & ArmedGameObj::Get_Definition( void ) const
 {
 	return (const ArmedGameObjDef &)BaseGameObj::Get_Definition();
 }
-const BeaconGameObjDef & BeaconGameObj::Get_Definition( void ) const
+SCRIPTS_API const BeaconGameObjDef & BeaconGameObj::Get_Definition( void ) const
 {
 	return (const BeaconGameObjDef &)BaseGameObj::Get_Definition();
 }
-const C4GameObjDef & C4GameObj::Get_Definition( void ) const
+SCRIPTS_API const C4GameObjDef & C4GameObj::Get_Definition( void ) const
 {
 	return (const C4GameObjDef &)BaseGameObj::Get_Definition();
 }
-const CinematicGameObjDef & CinematicGameObj::Get_Definition( void ) const
+SCRIPTS_API const CinematicGameObjDef & CinematicGameObj::Get_Definition( void ) const
 {
 	return (const CinematicGameObjDef &)BaseGameObj::Get_Definition();
 }
-const ComCenterGameObjDef &
+SCRIPTS_API const ComCenterGameObjDef &
 ComCenterGameObj::Get_Definition (void) const
 {
 	return (const ComCenterGameObjDef &)BaseGameObj::Get_Definition ();
 }
-const ConstructionYardGameObjDef &
+SCRIPTS_API const ConstructionYardGameObjDef &
 ConstructionYardGameObj::Get_Definition (void) const
 {
 	return (const ConstructionYardGameObjDef &)BaseGameObj::Get_Definition ();
 }
-const DamageZoneGameObjDef & DamageZoneGameObj::Get_Definition( void ) const
+SCRIPTS_API const DamageZoneGameObjDef & DamageZoneGameObj::Get_Definition( void ) const
 {
 	return (const DamageZoneGameObjDef &)BaseGameObj::Get_Definition();
 }
-const PowerPlantGameObjDef &
+SCRIPTS_API const PowerPlantGameObjDef &
 PowerPlantGameObj::Get_Definition (void) const
 {
 	return (const PowerPlantGameObjDef &)BaseGameObj::Get_Definition ();
 }
-const RepairBayGameObjDef &
+SCRIPTS_API const RepairBayGameObjDef &
 RepairBayGameObj::Get_Definition (void) const
 {
 	return (const RepairBayGameObjDef &)BaseGameObj::Get_Definition ();
 }
-const SamSiteGameObjDef & SamSiteGameObj::Get_Definition( void ) const
+SCRIPTS_API const SamSiteGameObjDef & SamSiteGameObj::Get_Definition( void ) const
 {
 	return (const SamSiteGameObjDef &)BaseGameObj::Get_Definition();
 }
-const SoldierGameObjDef & SoldierGameObj::Get_Definition( void ) const
+SCRIPTS_API const SoldierGameObjDef & SoldierGameObj::Get_Definition( void ) const
 {
 	return (const SoldierGameObjDef &)BaseGameObj::Get_Definition();
 }
-const SoldierFactoryGameObjDef &
+SCRIPTS_API const SoldierFactoryGameObjDef &
 SoldierFactoryGameObj::Get_Definition (void) const
 {
 	return (const SoldierFactoryGameObjDef &)BaseGameObj::Get_Definition ();
 }
-const SpecialEffectsGameObjDef & SpecialEffectsGameObj::Get_Definition( void ) const
-{
-	return (const SpecialEffectsGameObjDef &)BaseGameObj::Get_Definition();
-}
-const TransitionGameObjDef & TransitionGameObj::Get_Definition( void ) const
-{
-	return (const TransitionGameObjDef &)BaseGameObj::Get_Definition();
-}
-const WarFactoryGameObjDef &
-WarFactoryGameObj::Get_Definition (void) const
-{
-	return (const WarFactoryGameObjDef &)BaseGameObj::Get_Definition ();
-}
-
-const VehicleFactoryGameObjDef &
-VehicleFactoryGameObj::Get_Definition (void) const
-{
-	return (const VehicleFactoryGameObjDef &)BaseGameObj::Get_Definition ();
-}
-
-const ScriptZoneGameObjDef & ScriptZoneGameObj::Get_Definition( void ) const
-{
-	return (const ScriptZoneGameObjDef &)BaseGameObj::Get_Definition();
-}
-
-unsigned char NetworkObjectClass::Get_Object_Dirty_Bits(int clientId)
-{
-	return ClientStatus[clientId];
-}
-
-bool NetworkObjectClass::Get_Object_Dirty_Bit(int clientId, DIRTY_BIT level)
-{
-	return (ClientStatus[clientId] & level) == level;
-}
-
-void DefenseObjectClass::Set_Health_Max(float health)
-{
-	HealthMax = WWMath::Clamp(health, 0, MAX_MAX_HEALTH);
-	if (HealthMax < Health)
-	{
-		Health = HealthMax;
-	}
-	Mark_Owner_Dirty();
-}
-
-void	DefenseObjectClass::Set_Shield_Type( ArmorType type )	
-{ 
-	ShieldType = type; 
-	Mark_Owner_Dirty();
-}
-
-float DefenseObjectClass::Get_Health() const
-{
-	return this->Health;
-}
-
-
-
-float DefenseObjectClass::Get_Health_Max() const
-{
-	return this->HealthMax;
-}
-
-
-float DefenseObjectClass::Get_Shield_Strength() const
-{
-	return this->ShieldStrength;
-}
-
-
-
-float DefenseObjectClass::Get_Shield_Strength_Max() const
-{
-	return this->ShieldStrengthMax;
-}
-
-void DefenseObjectClass::Set_Shield_Strength_Max(float str)
-{
-	ShieldStrengthMax = WWMath::Clamp(str, 0, MAX_MAX_SHIELD_STRENGTH);
-	if (ShieldStrengthMax < ShieldStrength)
-	{
-		ShieldStrength = ShieldStrengthMax;
-	}
-	Mark_Owner_Dirty();
-}
-
-
-
-void DefenseObjectClass::Mark_Owner_Dirty()
-{
-	if (Get_Owner())
-	{
-		Get_Owner()->Set_Object_Dirty_Bit(NetworkObjectClass::BIT_OCCASIONAL, true);
-	}
-}
-
-SCRIPTS_API REF_DEF3(GameObjManager::BuildingGameObjList, SList<BuildingGameObj>, 0x00856FE8, 0x008561D0, 0x0085BED0);
-SCRIPTS_API REF_DEF3(GameObjManager::GameObjList, SList<BaseGameObj>, 0x00856FF8, 0x008561E0, 0x0085BEE0);
-SCRIPTS_API REF_DEF3(GameObjManager::StarGameObjList, SList<SoldierGameObj>, 0x00856FC8, 0x008561B0, 0x0085BEB0);
-SCRIPTS_API REF_DEF3(GameObjManager::SmartGameObjList, SList<SmartGameObj>, 0x00856FD8, 0x008561C0, 0x0085BEC0);
-
-#ifdef SHADERS_EXPORTS
-SHADERS_API SList<C4GameObj> GameObjManager::C4GameObjList;
-SHADERS_API SList<BeaconGameObj> GameObjManager::BeaconGameObjList;
-SHADERS_API SList<SoldierGameObj> GameObjManager::SoldierGameObjList;
-SHADERS_API SList<VehicleGameObj> GameObjManager::VehicleGameObjList;
-#endif
-
-const BaseGameObjDef &	BaseGameObj::Get_Definition( void ) const 
-{
-	return *Definition;
-};
-
-const DamageableGameObjDef & DamageableGameObj::Get_Definition( void ) const 
-{
-	return (const DamageableGameObjDef &)BaseGameObj::Get_Definition();
-}
-
-void ScriptableGameObj::Insert_Observer( GameObjObserverClass * observer )
-{
-	observer->Attach( this );
-	Observers.Add( observer );
-}
-
-void ScriptableGameObj::Remove_Observer( GameObjObserverClass * observer )
-{
-	Observers.Delete( observer );
-	observer->Detach( this );
-}
-
-const ScriptableGameObjDef & ScriptableGameObj::Get_Definition( void ) const
-{
-	return (const ScriptableGameObjDef &)BaseGameObj::Get_Definition();
-}
-
-const BuildingGameObjDef & BuildingGameObj::Get_Definition( void ) const
-{
-	return (const BuildingGameObjDef &)BaseGameObj::Get_Definition();
-}
-
-const RefineryGameObjDef & RefineryGameObj::Get_Definition( void ) const
-{
-	return (const RefineryGameObjDef &)BaseGameObj::Get_Definition();
-}
-
-#ifndef TTLE_EXPORTS
-#ifndef TT_EXPORTS
-RENEGADE_FUNCTION
-bool PowerUpGameObjDef::Grant(SmartGameObj *, PowerUpGameObj *, bool) const
-AT2(0x006F09F0,0x006EFFB0);
-#endif
-
-RENEGADE_FUNCTION
-Vector3 SCRIPTS_API Get_Color_For_Team(int teamId)
-AT2(0x006D99E0,0x006D9280);
-Vector3 DamageableGameObj::Get_Team_Color(void)
-{
-	return Get_Color_For_Team(PlayerType);
-}
-
-int SCRIPTS_API Get_Object_Type(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	ScriptableGameObj *o = ((BaseGameObj*)obj)->As_ScriptableGameObj();
-	if(!o)
-	{
-		return 0;
-	}
-	DamageableGameObj *o2 = o->As_DamageableGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return o2->Get_Player_Type();
-}
-
-void SCRIPTS_API Set_Object_Type(GameObject *obj,int type)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return;
-	}
-	ScriptableGameObj *o = ((BaseGameObj*)obj)->As_ScriptableGameObj();
-	if(!o)
-	{
-		return;
-	}
-	DamageableGameObj *o2 = o->As_DamageableGameObj();
-	if (!o2)
-	{
-		return;
-	}
-	o2->Set_Player_Type(type);
-}
-
-GameObject SCRIPTS_API *As_PowerUpGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	PhysicalGameObj *o2 = ((BaseGameObj *)obj)->As_PhysicalGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_PowerUpGameObj();
-}
-
-GameObject SCRIPTS_API *As_C4GameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	PhysicalGameObj *o2 = ((BaseGameObj *)obj)->As_PhysicalGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_C4GameObj();
-}
-
-GameObject SCRIPTS_API *As_BeaconGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	PhysicalGameObj *o2 = ((BaseGameObj *)obj)->As_PhysicalGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_BeaconGameObj();
-}
-
-GameObject SCRIPTS_API *As_ArmedGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	PhysicalGameObj *o2 = ((BaseGameObj *)obj)->As_PhysicalGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_ArmedGameObj();
-}
-
-GameObject SCRIPTS_API *As_SimpleGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	PhysicalGameObj *o2 = ((BaseGameObj *)obj)->As_PhysicalGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_SimpleGameObj();
-}
-
-GameObject SCRIPTS_API *As_PowerPlantGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	ScriptableGameObj *o = ((BaseGameObj*)obj)->As_ScriptableGameObj();
-	if(!o)
-	{
-		return 0;
-	}
-	BuildingGameObj *o2 = o->As_BuildingGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_PowerPlantGameObj();
-}
-
-GameObject SCRIPTS_API *As_ConstructionYardGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	ScriptableGameObj *o = ((BaseGameObj*)obj)->As_ScriptableGameObj();
-	if(!o)
-	{
-		return 0;
-	}
-	BuildingGameObj *o2 = o->As_BuildingGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_ConstructionYardGameObj();
-}
-
-GameObject SCRIPTS_API *As_SoldierFactoryGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	ScriptableGameObj *o = ((BaseGameObj*)obj)->As_ScriptableGameObj();
-	if(!o)
-	{
-		return 0;
-	}
-	BuildingGameObj *o2 = o->As_BuildingGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_SoldierFactoryGameObj();
-}
-
-GameObject SCRIPTS_API *As_VehicleFactoryGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	ScriptableGameObj *o = ((BaseGameObj*)obj)->As_ScriptableGameObj();
-	if(!o)
-	{
-		return 0;
-	}
-	BuildingGameObj *o2 = o->As_BuildingGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_VehicleFactoryGameObj();
-}
-
-GameObject SCRIPTS_API *As_AirstripGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	ScriptableGameObj *o = ((BaseGameObj*)obj)->As_ScriptableGameObj();
-	if(!o)
-	{
-		return 0;
-	}
-	BuildingGameObj *o2 = o->As_BuildingGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_AirStripGameObj();
-}
-
-GameObject SCRIPTS_API *As_WarFactoryGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	ScriptableGameObj *o = ((BaseGameObj*)obj)->As_ScriptableGameObj();
-	if(!o)
-	{
-		return 0;
-	}
-	BuildingGameObj *o2 = o->As_BuildingGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_WarFactoryGameObj();
-}
-
-GameObject SCRIPTS_API *As_RefineryGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	ScriptableGameObj *o = ((BaseGameObj*)obj)->As_ScriptableGameObj();
-	if(!o)
-	{
-		return 0;
-	}
-	BuildingGameObj *o2 = o->As_BuildingGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_RefineryGameObj();
-}
-
-GameObject SCRIPTS_API *As_ComCenterGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	ScriptableGameObj *o = ((BaseGameObj*)obj)->As_ScriptableGameObj();
-	if(!o)
-	{
-		return 0;
-	}
-	BuildingGameObj *o2 = o->As_BuildingGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_ComCenterGameObj();
-}
-
-GameObject SCRIPTS_API *As_RepairBayGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	ScriptableGameObj *o = ((BaseGameObj*)obj)->As_ScriptableGameObj();
-	if(!o)
-	{
-		return 0;
-	}
-	BuildingGameObj *o2 = o->As_BuildingGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_RepairBayGameObj();
-}
-
-GameObject SCRIPTS_API *As_ScriptableGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	return (GameObject *)((BaseGameObj *)obj)->As_ScriptableGameObj();
-}
-
-GameObject SCRIPTS_API *As_PhysicalGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	return (GameObject *)((BaseGameObj *)obj)->As_PhysicalGameObj();
-}
-
-GameObject SCRIPTS_API *As_CinematicGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	PhysicalGameObj *o2 = ((BaseGameObj *)obj)->As_PhysicalGameObj();
-	if (!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_CinematicGameObj();
-}
-
-GameObject SCRIPTS_API *As_VehicleGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	return (GameObject *)((BaseGameObj *)obj)->As_VehicleGameObj();
-}
-
-GameObject SCRIPTS_API *As_SmartGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	return (GameObject *)((BaseGameObj *)obj)->As_SmartGameObj();
-}
-
-GameObject SCRIPTS_API *As_DamageableGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	ScriptableGameObj* o2 = ((BaseGameObj *)obj)->As_ScriptableGameObj();
-	if(!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_DamageableGameObj();
-}
-
-GameObject SCRIPTS_API *As_SoldierGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	ScriptableGameObj* o2 = ((BaseGameObj *)obj)->As_ScriptableGameObj();
-	if(!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_SoldierGameObj();
-}
-
-GameObject SCRIPTS_API *As_ScriptZoneGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	ScriptableGameObj* o2 = ((BaseGameObj *)obj)->As_ScriptableGameObj();
-	if(!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_ScriptZoneGameObj();
-}
-
-GameObject SCRIPTS_API *As_BuildingGameObj(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	ScriptableGameObj* o2 = ((BaseGameObj *)obj)->As_ScriptableGameObj();
-	if(!o2)
-	{
-		return 0;
-	}
-	return (GameObject *)o2->As_BuildingGameObj();
-}
-
-bool SCRIPTS_API Is_Building(GameObject *obj)
-{
-	if (As_BuildingGameObj(obj))
-	{
-		return true;
-	}
-	return false;
-}
-
-bool SCRIPTS_API Is_Soldier(GameObject *obj)
-{
-	if (As_SoldierGameObj(obj))
-	{
-		return true;
-	}
-	return false;
-}
-
-bool SCRIPTS_API Is_Vehicle(GameObject *obj)
-{
-	if (As_VehicleGameObj(obj))
-	{
-		return true;
-	}
-	return false;
-}
-
-bool SCRIPTS_API Is_Cinematic(GameObject *obj)
-{
-	if (As_CinematicGameObj(obj))
-	{
-		return true;
-	}
-	return false;
-}
-
-bool SCRIPTS_API Is_ScriptZone(GameObject *obj)
+SCRIPTS_API const SpecialEffectsGameObjDef & SpecialEffectsGameObj::Get_Definition( void ) const
 {
-	if (As_ScriptZoneGameObj(obj))
+	return (const SpecialEffectsGameObjDef &)BaseGameObj::Get_Definition();
+}
+SCRIPTS_API const TransitionGameObjDef & TransitionGameObj::Get_Definition( void ) const
 	{
-		return true;
+	return (const TransitionGameObjDef &)BaseGameObj::Get_Definition();
 	}
-	return false;
+SCRIPTS_API const WarFactoryGameObjDef &
+WarFactoryGameObj::Get_Definition (void) const
+{
+	return (const WarFactoryGameObjDef &)BaseGameObj::Get_Definition ();
 }
 
-bool SCRIPTS_API Is_Powerup(GameObject *obj)
-{
-	if (As_PowerUpGameObj(obj))
+SCRIPTS_API const VehicleFactoryGameObjDef &
+VehicleFactoryGameObj::Get_Definition (void) const
 	{
-		return true;
-	}
-	return false;
+	return (const VehicleFactoryGameObjDef &)BaseGameObj::Get_Definition ();
 }
 
-bool SCRIPTS_API Is_C4(GameObject *obj)
+SCRIPTS_API const ScriptZoneGameObjDef & ScriptZoneGameObj::Get_Definition( void ) const
 {
-	if (As_C4GameObj(obj))
-	{
-		return true;
-	}
-	return false;
+	return (const ScriptZoneGameObjDef &)BaseGameObj::Get_Definition();
 }
 
-bool SCRIPTS_API Is_Scriptable(GameObject *obj)
-{
-	if (As_ScriptableGameObj(obj))
+unsigned char NetworkObjectClass::Get_Object_Dirty_Bits(int clientId)
 	{
-		return true;
-	}
-	return false;
+	return ClientStatus[clientId];
 }
 
-bool SCRIPTS_API Is_Beacon(GameObject *obj)
-{
-	if (As_BeaconGameObj(obj))
+bool NetworkObjectClass::Get_Object_Dirty_Bit(int clientId, DIRTY_BIT level)
 	{
-		return true;
-	}
-	return false;
+	return (ClientStatus[clientId] & level) == level;
 }
 
-bool SCRIPTS_API Is_Armed(GameObject *obj)
+void DefenseObjectClass::Set_Health_Max(float health)
 {
-	if (As_ArmedGameObj(obj))
+	HealthMax = WWMath::Clamp(health, 0, MAX_MAX_HEALTH);
+	if (HealthMax < Health)
 	{
-		return true;
+		Health = HealthMax;
 	}
-	return false;
+	Mark_Owner_Dirty();
 }
 
-bool SCRIPTS_API Is_Simple(GameObject *obj)
-{
-	if (As_SimpleGameObj(obj))
+void	DefenseObjectClass::Set_Shield_Type( ArmorType type )	
 	{
-		return true;
-	}
-	return false;
+	ShieldType = type; 
+	Mark_Owner_Dirty();
 }
 
-bool SCRIPTS_API Is_PowerPlant(GameObject *obj)
-{
-	if (As_PowerPlantGameObj(obj))
+float DefenseObjectClass::Get_Health() const
 	{
-		return true;
-	}
-	return false;
+	return this->Health;
 }
 
-bool SCRIPTS_API Is_ConstructionYard(GameObject *obj)
-{
-	if (As_ConstructionYardGameObj(obj))
+
+
+float DefenseObjectClass::Get_Health_Max() const
 	{
-		return true;
-	}
-	return false;
+	return this->HealthMax;
 }
 
-bool SCRIPTS_API Is_SoldierFactory(GameObject *obj)
-{
-	if (As_SoldierFactoryGameObj(obj))
+
+float DefenseObjectClass::Get_Shield_Strength() const
 	{
-		return true;
-	}
-	return false;
+	return this->ShieldStrength;
 }
 
-bool SCRIPTS_API Is_VehicleFactory(GameObject *obj)
-{
-	if (As_VehicleFactoryGameObj(obj))
+
+
+float DefenseObjectClass::Get_Shield_Strength_Max() const
 	{
-		return true;
-	}
-	return false;
+	return this->ShieldStrengthMax;
 }
 
-bool SCRIPTS_API Is_Airstrip(GameObject *obj)
+void DefenseObjectClass::Set_Shield_Strength_Max(float str)
 {
-	if (As_AirstripGameObj(obj))
+	ShieldStrengthMax = WWMath::Clamp(str, 0, MAX_MAX_SHIELD_STRENGTH);
+	if (ShieldStrengthMax < ShieldStrength)
 	{
-		return true;
+		ShieldStrength = ShieldStrengthMax;
 	}
-	return false;
+	Mark_Owner_Dirty();
 }
 
-bool SCRIPTS_API Is_WarFactory(GameObject *obj)
+
+
+void DefenseObjectClass::Mark_Owner_Dirty()
 {
-	if (As_WarFactoryGameObj(obj))
+	if (Get_Owner())
 	{
-		return true;
+		Get_Owner()->Set_Object_Dirty_Bit(NetworkObjectClass::BIT_OCCASIONAL, true);
 	}
-	return false;
 }
 
-bool SCRIPTS_API Is_Refinery(GameObject *obj)
+SCRIPTS_API REF_DEF3(GameObjManager::BuildingGameObjList, SList<BuildingGameObj>, 0x00856FE8, 0x008561D0, 0x0085BED0);
+SCRIPTS_API REF_DEF3(GameObjManager::GameObjList, SList<BaseGameObj>, 0x00856FF8, 0x008561E0, 0x0085BEE0);
+SCRIPTS_API REF_DEF3(GameObjManager::StarGameObjList, SList<SoldierGameObj>, 0x00856FC8, 0x008561B0, 0x0085BEB0);
+SCRIPTS_API REF_DEF3(GameObjManager::SmartGameObjList, SList<SmartGameObj>, 0x00856FD8, 0x008561C0, 0x0085BEC0);
+
+#ifdef SHADERS_EXPORTS
+SHADERS_API SList<C4GameObj> GameObjManager::C4GameObjList;
+SHADERS_API SList<BeaconGameObj> GameObjManager::BeaconGameObjList;
+SHADERS_API SList<SoldierGameObj> GameObjManager::SoldierGameObjList;
+SHADERS_API SList<VehicleGameObj> GameObjManager::VehicleGameObjList;
+SHADERS_API SList<ScriptZoneGameObj> GameObjManager::ScriptZoneGameObjList;
+#endif
+
+SCRIPTS_API const BaseGameObjDef &	BaseGameObj::Get_Definition( void ) const 
 {
-	if (As_RefineryGameObj(obj))
+	return *Definition;
+};
+
+SCRIPTS_API const DamageableGameObjDef & DamageableGameObj::Get_Definition( void ) const 
 	{
-		return true;
-	}
-	return false;
+	return (const DamageableGameObjDef &)BaseGameObj::Get_Definition();
 }
 
-bool SCRIPTS_API Is_ComCenter(GameObject *obj)
-{
-	if (As_ComCenterGameObj(obj))
+SCRIPTS_API void ScriptableGameObj::Insert_Observer( GameObjObserverClass * observer )
 	{
-		return true;
-	}
-	return false;
+	observer->Attach( this );
+	Observers.Add( observer );
 }
 
-bool SCRIPTS_API Is_RepairBay(GameObject *obj)
-{
-	if (As_RepairBayGameObj(obj))
+SCRIPTS_API void ScriptableGameObj::Remove_Observer( GameObjObserverClass * observer )
 	{
-		return true;
-	}
-	return false;
+	Observers.Delete( observer );
+	observer->Detach( this );
 }
 
-const char SCRIPTS_API *Get_Building_Type(GameObject *obj)
+SCRIPTS_API const ScriptableGameObjDef & ScriptableGameObj::Get_Definition( void ) const
 {
-	if (Is_PowerPlant(obj))
+	return (const ScriptableGameObjDef &)BaseGameObj::Get_Definition();
+}
+
+SCRIPTS_API const BuildingGameObjDef & BuildingGameObj::Get_Definition( void ) const
 	{
-		return "Is_PowerPlant";
+	return (const BuildingGameObjDef &)BaseGameObj::Get_Definition();
 	}
-	else if (Is_ConstructionYard(obj))
+
+SCRIPTS_API const RefineryGameObjDef & RefineryGameObj::Get_Definition( void ) const
 	{
-		return "Is_ConstructionYard";
+	return (const RefineryGameObjDef &)BaseGameObj::Get_Definition();
 	}
-	else if (Is_SoldierFactory(obj))
+
+#ifndef TTLE_EXPORTS
+#ifndef TT_EXPORTS
+RENEGADE_FUNCTION
+bool PowerUpGameObjDef::Grant(SmartGameObj *, PowerUpGameObj *, bool) const
+AT2(0x006F09F0,0x006EFFB0);
+#endif
+
+RENEGADE_FUNCTION
+Vector3 SCRIPTS_API Get_Color_For_Team(int teamId)
+AT2(0x006D99E0,0x006D9280);
+Vector3 DamageableGameObj::Get_Team_Color(void)
 	{
-		return "Is_SoldierFactory";
+	return Get_Color_For_Team(PlayerType);
 	}
-	else if (Is_VehicleFactory(obj))
+
+int SCRIPTS_API Get_Object_Type(GameObject *obj)
 	{
-		if (Is_Airstrip(obj))
+	if (!obj)
 		{
-			return "Is_Airstrip";
+		return 0;
 		}
-		else if (Is_WarFactory(obj))
+	DamageableGameObj *o2 = obj->As_DamageableGameObj();
+	if (!o2)
 		{
-			return "Is_WarFactory";
-		}
+		return 0;
 	}
-	else if (Is_Refinery(obj))
-	{
-		return "Is_Refinery";
+	return o2->Get_Player_Type();
 	}
-	else if (Is_ComCenter(obj))
+
+void SCRIPTS_API Set_Object_Type(GameObject *obj,int type)
 	{
-		return "Is_ComCenter";
-	}
-	else if (Is_RepairBay(obj))
+	if (!obj)
 	{
-		return "Is_RepairBay";
+		return;
 	}
-	else
+	DamageableGameObj *o2 = obj->As_DamageableGameObj();
+	if (!o2)
 	{
-		return "(null)";
+		return;
 	}
-	return "(null)";
+	o2->Set_Player_Type(type);
 }
 
 void SCRIPTS_API Get_Object_Color(GameObject *obj, unsigned int *red, unsigned int *green, unsigned int *blue)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	DamageableGameObj *o = (DamageableGameObj *)As_DamageableGameObj(obj);
+	DamageableGameObj *o = obj->As_DamageableGameObj();
 	if (!o)
 	{
 		return;
@@ -911,7 +338,7 @@
 	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_SmartGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if (Get_Object_Type(o) == Team)
@@ -929,12 +356,17 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			if (Get_Object_Type(o) == Team)
+			if (Get_Object_Type(o2) == Team)
 			{
-				return o;
+				return o2;
 			}
 		}
 		x = x->Next();
@@ -947,7 +379,7 @@
 	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_SmartGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if ((Get_Object_Type(o) == Team) && (!Commands->Is_A_Star(o)))
@@ -965,15 +397,20 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			const DefinitionClass *d = Get_Definition(o);
+			const DefinitionClass *d = &o2->Get_Definition();
 			if (!_stricmp(d->Get_Name(),Preset_Name))
 			{
-				if ((Get_Object_Type(o) == Team) || (Team == 2))
+				if ((Get_Object_Type(o2) == Team) || (Team == 2))
 				{
-					return o;
+					return o2;
 				}
 			}
 		}
@@ -989,17 +426,22 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			if ((Get_Object_Type(o) == Team) && !Is_Building(o))
+			if ((Get_Object_Type(o2) == Team) && !o2->As_BuildingGameObj())
 			{
-				Vector3 pos = Commands->Get_Position(o);
+				Vector3 pos = Commands->Get_Position(o2);
 				float dist = Commands->Get_Distance(pos,position);
 				if (dist < closestdist)
 				{
 					closestdist = dist;
-					closest = o;
+					closest = o2;
 				}
 			}
 		}
@@ -1015,16 +457,21 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
 		{
-			if ((Get_Object_Type(o) == Team || Team == 2) && !_stricmp(Commands->Get_Preset_Name(o),Preset))
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
+		{
+			if ((Get_Object_Type(o2) == Team || Team == 2) && !_stricmp(Commands->Get_Preset_Name(o2),Preset))
 			{
-				float dist = Commands->Get_Distance(Commands->Get_Position(o),pos);
+				float dist = Commands->Get_Distance(Commands->Get_Position(o2),pos);
 				if (dist < closestdist)
 				{
 					closestdist = dist;
-					closest = o;
+					closest = o2;
 				}
 			}
 		}
@@ -1039,12 +486,17 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
 		{
-			if ((Get_Object_Type(o) == Team || Team == 2) && !_stricmp(Commands->Get_Preset_Name(o),Preset))
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
+		{
+			if ((Get_Object_Type(o2) == Team || Team == 2) && !_stricmp(Commands->Get_Preset_Name(o2),Preset))
 			{
-				ObjList.Add(o);
+				ObjList.Add(o2);
 			}
 		}
 		x = x->Next();
@@ -1086,12 +538,17 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
 		{
-			if ((Get_Object_Type(o) == Team || Team == 2) && !_stricmp(Commands->Get_Preset_Name(o),Preset))
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
+		{
+			if ((Get_Object_Type(o2) == Team || Team == 2) && !_stricmp(Commands->Get_Preset_Name(o2),Preset))
 			{
-				ObjList->Add(o);
+				ObjList->Add(o2);
 			}
 		}
 		x = x->Next();
@@ -1105,23 +562,28 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			if (!_stricmp(Commands->Get_Preset_Name(o),preset))
+			if (!_stricmp(Commands->Get_Preset_Name(o2),preset))
 			{
 				if (object)
 				{
 					Vector3 obj_pos = Commands->Get_Position(object);
-					Vector3 o_pos = Commands->Get_Position(o);
+					Vector3 o_pos = Commands->Get_Position(o2);
 					if (Commands->Get_Distance(position, o_pos) < Commands->Get_Distance(position, obj_pos))
 					{
-						object = o;
+						object = o2;
 					}
 				}
 				else
 				{
-					object = o;
+					object = o2;
 				}
 			}
 		}
@@ -1137,12 +599,17 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (count > 0)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			if (!_stricmp(Commands->Get_Preset_Name(o),preset))
+			if (!_stricmp(Commands->Get_Preset_Name(o2),preset))
 			{
-				object = o;
+				object = o2;
 				count--;
 			}
 		}
@@ -1164,14 +631,14 @@
 
 void SCRIPTS_API Send_Custom_To_Team_Buildings(int Team,GameObject *sender,int type,int param,float delay)
 {
-	if (!Commands->Get_ID(sender) || !sender)
+	if (!sender)
 	{
 		return;
 	}
 	SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_BuildingGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if (Get_Object_Type(o) == Team)
@@ -1190,21 +657,26 @@
 
 void SCRIPTS_API Send_Custom_To_Team_Preset(int Team,const char *PresetName,GameObject *sender,int type,int param,float delay)
 {
-	if (!Commands->Get_ID(sender) || !sender)
+	if (!sender)
 	{
 		return;
 	}
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			if (Get_Object_Type(o) == Team)
+			if (Get_Object_Type(o2) == Team)
 			{
-				if (!_stricmp(Commands->Get_Preset_Name(o),PresetName))
+				if (!_stricmp(Commands->Get_Preset_Name(o2),PresetName))
 				{
-					Commands->Send_Custom_Event(sender,o,type,param,delay);
+					Commands->Send_Custom_Event(sender,o2,type,param,delay);
 				}
 			}
 		}
@@ -1214,25 +686,30 @@
 
 void SCRIPTS_API Send_Custom_All_Objects_Area(int type,const Vector3 &Position,float Distance,GameObject *sender,int team)
 {
-	if (!Commands->Get_ID(sender) || !sender)
+	if (!sender)
 	{
 		return;
 	}
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x) 
 	{
-		GameObject *obj = (GameObject *)x->Data();
-		if (obj && As_ScriptableGameObj(obj))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			Vector3 ObjPosition = Commands->Get_Position(obj);
+			Vector3 ObjPosition = Commands->Get_Position(o2);
 			Vector3 TestPosition = Position;
 			ObjPosition.Z = 0;
 			TestPosition.Z = 0;
 			if ((Commands->Get_Distance(ObjPosition,TestPosition) <= Distance))
 			{
-				if ((Get_Object_Type(obj) == team) || (team == 2))
+				if ((Get_Object_Type(o2) == team) || (team == 2))
 				{
-					Commands->Send_Custom_Event(sender,obj,type,0,0);
+					Commands->Send_Custom_Event(sender,o2,type,0,0);
 				}
 			}
 		}
@@ -1242,19 +719,24 @@
 
 void SCRIPTS_API Send_Custom_All_Objects(int type,GameObject *sender,int team)
 {
-	if (!Commands->Get_ID(sender) || !sender)
+	if (!sender)
 	{
 		return;
 	}
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x) 
 	{
-		GameObject *obj = (GameObject *)x->Data();
-		if (obj && As_ScriptableGameObj(obj))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			if ((Get_Object_Type(obj) == team) || (team == 2))
+			if ((Get_Object_Type(o2) == team) || (team == 2))
 			{
-				Commands->Send_Custom_Event(sender,obj,type,0,0);
+				Commands->Send_Custom_Event(sender,o2,type,0,0);
 			}
 		}
 		x = x->Next();
@@ -1263,20 +745,25 @@
 
 void SCRIPTS_API Send_Custom_Event_To_Object(GameObject *sender,const char *Preset,int type,int param,float delay)
 {
-	if (!Commands->Get_ID(sender) || !sender)
+	if (!sender)
 	{
 		return;
 	}
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			const DefinitionClass *d = Get_Definition(o);
+			const DefinitionClass *d = &o2->Get_Definition();
 			if (!_stricmp(d->Get_Name(),Preset))
 			{
-				Commands->Send_Custom_Event(sender,o,type,param,delay);
+				Commands->Send_Custom_Event(sender,o2,type,param,delay);
 			}
 		}
 		x = x->Next();
@@ -1288,19 +775,24 @@
 	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
 		{
-			if (Get_Object_Type(o) == team && !_stricmp(Commands->Get_Preset_Name(o),preset))
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
+		{
+			if (Get_Object_Type(o2) == team && !_stricmp(Commands->Get_Preset_Name(o2),preset))
 			{
-				Vector3 pos = Commands->Get_Position(o);
+				Vector3 pos = Commands->Get_Position(o2);
 				pos.Z = 0;
 				location.Z = 0;
 				if (Commands->Get_Distance(pos,location) <= range)
 				{
-					if (As_VehicleGameObj(o) && !empty)
+					if (o2->As_VehicleGameObj() && !empty)
 					{
-						if (o->As_VehicleGameObj()->Get_Occupant_Count() == 0)
+						if (o2->As_VehicleGameObj()->Get_Occupant_Count() == 0)
 						{
 							return false;
 						}
@@ -1323,45 +815,57 @@
 
 bool SCRIPTS_API Get_Is_Powerup_Persistant(GameObject *obj)
 {
-	PowerUpGameObj *o = (PowerUpGameObj *)As_PowerUpGameObj(obj);
+	if (obj->As_PhysicalGameObj())
+	{
+		PowerUpGameObj *o = obj->As_PhysicalGameObj()->As_PowerUpGameObj();
 	if (!o)
 	{
 		return 0;
 	}
 	return o->Get_Definition().Is_Persistant();
 }
+	return 0;
+}
 
 bool SCRIPTS_API Get_Powerup_Always_Allow_Grant(GameObject *obj)
 {
-	PowerUpGameObj *o = (PowerUpGameObj *)As_PowerUpGameObj(obj);
+	if (obj->As_PhysicalGameObj())
+	{
+		PowerUpGameObj *o = obj->As_PhysicalGameObj()->As_PowerUpGameObj();
 	if (!o)
 	{
 		return 0;
 	}
 	return o->Get_Definition().Is_Always_Allow_Grant();
 }
+	return 0;
+}
 
 int SCRIPTS_API Get_Powerup_Grant_Sound(GameObject *obj)
 {
-	PowerUpGameObj *o = (PowerUpGameObj *)As_PowerUpGameObj(obj);
+	if (obj->As_PhysicalGameObj())
+	{
+		PowerUpGameObj *o = obj->As_PhysicalGameObj()->As_PowerUpGameObj();
 	if (!o)
 	{
 		return 0;
 	}
 	return o->Get_Definition().Get_Grant_Sound();
 }
+	return 0;
+}
 
 void SCRIPTS_API Grant_Powerup(GameObject *obj,const char *Preset_Name)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	GameObject *o = As_SmartGameObj(obj);
+	SmartGameObj *o = obj->As_SmartGameObj();
 	if (o)
 	{
 		PowerUpGameObjDef *def = (PowerUpGameObjDef *)Find_Named_Definition(Preset_Name);
-		def->Grant((SmartGameObj *)o,0,true);
+		def->Grant(o,0,true);
 	}
 }
 
@@ -1426,17 +930,22 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o) && o != obj)
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o && o != obj)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			if ((team == 2 || Get_Object_Type(o) == team) && Is_Armed(o))
+			if ((team == 2 || Get_Object_Type(o2) == team) && o2->As_PhysicalGameObj() && o2->As_PhysicalGameObj()->As_ArmedGameObj())
 			{
-				Vector3 pos = Commands->Get_Position(o);
+				Vector3 pos = Commands->Get_Position(o2);
 				float dist = Commands->Get_Distance(pos,position);
 				if (dist < closestdist)
 				{
 					closestdist = dist;
-					closest = o;
+					closest = o2;
 				}
 			}
 		}
@@ -1445,27 +954,6 @@
 	return closest;
 }
 
-void SCRIPTS_API Set_Powerup_Always_Allow_Grant(GameObject *obj,bool Grant)
-{
-	if (!Commands->Get_ID(obj) || !obj)
-	{
-		return;
-	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
-	if (!o2)
-	{
-		return;
-	}
-	PowerUpGameObj *o3 = o2->As_PowerUpGameObj();
-	if (!o3)
-	{
-		return;
-	}
-	((PowerUpGameObjDef&)o3->Get_Definition()).AlwaysAllowGrant = Grant;
-}
-
-
-
 void PhysicalGameObj::Set_Transform(const Matrix3D& mat)
 {
 	PhysObj->Set_Transform(mat);
@@ -1484,7 +972,7 @@
 	PhysObj->Set_Transform(tm);
 }
 
-bool DamageableGameObj::Is_Teammate(DamageableGameObj * p_obj)
+SCRIPTS_API bool DamageableGameObj::Is_Teammate(DamageableGameObj * p_obj)
 {
 	return ((p_obj == this) || (Is_Team_Player() && Get_Player_Type() == p_obj->Get_Player_Type()));
 }
@@ -1516,13 +1004,13 @@
 	return NULL;
 }
 
-bool DamageableGameObj::Is_Team_Player(void) 
+SCRIPTS_API bool DamageableGameObj::Is_Team_Player(void) 
 {
 	int player_type = Get_Player_Type();
 	return player_type == PLAYERTYPE_NOD || player_type == PLAYERTYPE_GDI;
 }
 
-bool DamageableGameObj::Is_Enemy(DamageableGameObj *obj)
+SCRIPTS_API bool DamageableGameObj::Is_Enemy(DamageableGameObj *obj)
 {
 	bool enemy = false;
 	if (obj != this)
@@ -1548,7 +1036,7 @@
 	return enemy;
 }
 
-AnimControlClass *PhysicalGameObj::Get_Anim_Control()
+SCRIPTS_API AnimControlClass *PhysicalGameObj::Get_Anim_Control()
 {
 	return AnimControl;
 }
@@ -1558,12 +1046,12 @@
 	*Position = Peek_Physical_Object()->Get_Transform().Get_Translation();
 }
 
-const PowerUpGameObjDef & PowerUpGameObj::Get_Definition( void ) const
+SCRIPTS_API  const PowerUpGameObjDef & PowerUpGameObj::Get_Definition( void ) const
 {
 	return (const PowerUpGameObjDef &)BaseGameObj::Get_Definition();
 }
 
-const PhysicalGameObjDef & PhysicalGameObj::Get_Definition( void ) const
+SCRIPTS_API  const PhysicalGameObjDef & PhysicalGameObj::Get_Definition( void ) const
 {
 	return (const PhysicalGameObjDef &)BaseGameObj::Get_Definition();
 }
@@ -1583,4 +1071,28 @@
 	}
 	return false;
 }
+
+void SCRIPTS_API Set_Powerup_Always_Allow_Grant(GameObject *obj,bool Grant)
+{
+	if (!obj)
+	{
+		return;
+	}
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
+	if (!o2)
+	{
+		return;
+	}
+	PowerUpGameObj *o3 = o2->As_PowerUpGameObj();
+	if (!o3)
+	{
+		return;
+	}
+	((PowerUpGameObjDef&)o3->Get_Definition()).AlwaysAllowGrant = Grant;
+}
+
+void SCRIPTS_API PhysicalGameObj::Set_Collision_Group(int group)
+{
+	PhysObj->Set_Collision_Group((Collision_Group_Type)group);
+}
 #endif
\ No newline at end of file
diff -uwr sourceold/scripts/engine_obj.h source/scripts/engine_obj.h
--- sourceold/scripts/engine_obj.h	2011-10-11 21:54:59.320312500 +0800
+++ source/scripts/engine_obj.h	2012-04-24 13:38:29.723632800 +0800
@@ -50,39 +50,6 @@
 
 int SCRIPTS_API Get_Object_Type(GameObject *obj); //get the team of an object,0 = Nod,1 = GDI,2 = neutral,works on buildings
 void SCRIPTS_API Set_Object_Type(GameObject *obj,int type); //set the team of an object,0 = Nod,1 = GDI,2 = neutral,works on buildings
-GameObject SCRIPTS_API *As_ArmedGameObj(GameObject *obj); //Check if object is an ArmedGameObj
-GameObject SCRIPTS_API *As_BeaconGameObj(GameObject *obj); //Check if object is a BeaconGameObj
-GameObject SCRIPTS_API *As_C4GameObj(GameObject *obj); //Check if object is a C4GameObj
-GameObject SCRIPTS_API *As_ScriptableGameObj(GameObject *obj); //Check if object is a ScritableGameObj
-GameObject SCRIPTS_API *As_VehicleGameObj(GameObject *obj); //Check if object is a VehicleGameObj
-GameObject SCRIPTS_API *As_SoldierGameObj(GameObject *obj); //Check if object is a SoldierGameObj
-GameObject SCRIPTS_API *As_BuildingGameObj(GameObject *obj); //Check if object is a BuildingGameObj
-GameObject SCRIPTS_API *As_SmartGameObj(GameObject *obj); //Check if object is a SmartGameObj
-GameObject SCRIPTS_API *As_PhysicalGameObj(GameObject *obj); //Check if object is a PhysicalGameObj
-GameObject SCRIPTS_API *As_DamageableGameObj(GameObject *obj); //Check if object is a DamageableGameObj
-GameObject SCRIPTS_API *As_ScriptZoneGameObj(GameObject *obj); //Check if object is a ScriptZoneGameObj
-GameObject SCRIPTS_API *As_VehicleFactoryGameObj(GameObject *obj); //Check of object is a VehicleFactoryGameObj
-bool SCRIPTS_API Is_Building(GameObject *obj); //is a BuildingGameObj
-bool SCRIPTS_API Is_Soldier(GameObject *obj); //is a SoldierGameObj
-bool SCRIPTS_API Is_Vehicle(GameObject *obj); //is a VechicleGameObj
-bool SCRIPTS_API Is_Cinematic(GameObject *obj); //is a CinematicGameObj
-bool SCRIPTS_API Is_ScriptZone(GameObject *obj); //is a ScriptZoneGameObj
-bool SCRIPTS_API Is_Powerup(GameObject *obj); //is a PowerUpGameObj
-bool SCRIPTS_API Is_C4(GameObject *obj); //is a C4GameObj
-bool SCRIPTS_API Is_Beacon(GameObject *obj); //is a BeaconGameObj
-bool SCRIPTS_API Is_Armed(GameObject *obj); //is an ArmedGameObj
-bool SCRIPTS_API Is_Simple(GameObject *obj); //is a SimpleGameObj
-bool SCRIPTS_API Is_PowerPlant(GameObject *obj); //is a PowerPlantGameObj
-bool SCRIPTS_API Is_ConstructionYard(GameObject *obj); //is a ConstructionYardGameObj
-bool SCRIPTS_API Is_SoldierFactory(GameObject *obj); //is a SoldierFactoryGameObj
-bool SCRIPTS_API Is_VehicleFactory(GameObject *obj); //is a VehicleFactoryGameObj
-bool SCRIPTS_API Is_Airstrip(GameObject *obj); //is an AirstripGameObj
-bool SCRIPTS_API Is_WarFactory(GameObject *obj); //is a WarFactoryGameObj
-bool SCRIPTS_API Is_Refinery(GameObject *obj); //is a RefineryGameObj
-bool SCRIPTS_API Is_ComCenter(GameObject *obj); //is a ComCenterGameObj
-bool SCRIPTS_API Is_RepairBay(GameObject *obj); //is a RepairBayGameObj
-bool SCRIPTS_API Is_Scriptable(GameObject *obj); //is a ScriptableGameObj
-const char SCRIPTS_API *Get_Building_Type(GameObject *obj); //returns a string indicating the building type of an object
 void SCRIPTS_API Get_Object_Color(GameObject *obj, unsigned int *red, unsigned int *green, unsigned int *blue); //get color for a player
 GameObject SCRIPTS_API *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 SCRIPTS_API *Find_Object_By_Team(int Team); //will find the first object for the team,0 = Nod,1 = GDI
diff -uwr sourceold/scripts/engine_obj2.cpp source/scripts/engine_obj2.cpp
--- sourceold/scripts/engine_obj2.cpp	2012-02-13 18:26:42.375398400 +0800
+++ source/scripts/engine_obj2.cpp	2012-05-23 11:29:54.504882800 +0800
@@ -26,6 +26,7 @@
 #include "AirFactoryGameObj.h"
 #include "AirFactoryGameObjDef.h"
 #include "VehicleFactoryGameObjDef.h"
+#include "NavalFactoryGameObj.h"
 
 RENEGADE_FUNCTION
 GameObject *Create_Library_Object(const char *preset)
@@ -44,6 +45,22 @@
 bool AirFactoryGameObj::Is_Available_For_Purchase() const
 AT2(0x0070B6F0,0x0070ACB0);
 RENEGADE_FUNCTION
+SCRIPTS_API bool SoldierGameObj::Is_In_Elevator()
+AT2(0x006C9610,0x006C8EB0);
+RENEGADE_FUNCTION
+void NavalFactoryGameObj::Create_Vehicle(int defintion_id,SoldierGameObj * player)
+AT2(0x0073EE30,0x0073E6D0);
+RENEGADE_FUNCTION
+int NavalFactoryGameObj::Get_Team_Vehicle_Count() const
+AT2(0x0073FB80,0x0073F420);
+RENEGADE_FUNCTION
+bool NavalFactoryGameObj::Is_Available_For_Purchase() const
+AT2(0x007408E0,0x00740180);
+RENEGADE_FUNCTION
+bool NavalFactoryGameObj::Can_Spawn(int definition_id)
+AT2(0x007425B0,0x00741E50);
+
+RENEGADE_FUNCTION
 bool VehicleFactoryGameObj::Request_Vehicle(int defintion_id, float generation_time,SoldierGameObj * player)
 AT2(0x006EE1A0,0x006ED760);
 RENEGADE_FUNCTION
@@ -60,14 +77,9 @@
 {
 	float closest = 999999;
 	ScriptZoneGameObj *closestzone = 0;
-	for (SLNode<BaseGameObj>* node = GameObjManager::GameObjList.Head(); node; node = node->Next())
-	{
-		ScriptableGameObj* object = ((BaseGameObj *)node->Data())->As_ScriptableGameObj();
-		if (object)
-		{
-			ScriptZoneGameObj *zone = object->As_ScriptZoneGameObj();
-			if (zone)
+	for (SLNode<ScriptZoneGameObj>* node = GameObjManager::ScriptZoneGameObjList.Head(); node; node = node->Next())
 			{
+		ScriptZoneGameObj *zone = node->Data();
 				if (zone->Get_Definition().Get_Type() == Type)
 				{
 					float distance = Vector3::Distance(zone->Get_Bounding_Box().Center,Location);
@@ -78,8 +90,6 @@
 					}
 				}
 			}
-		}
-	}
 	return closestzone;
 }
 bool ScriptZoneGameObj::Inside_Me(PhysicalGameObj *obj)
@@ -100,23 +110,22 @@
 AT2(0x00470AC0,0x00470230);
 GameObject SCRIPTS_API *Find_Closest_Zone(Vector3 &location,unsigned int type)
 {
-	return (GameObject *)ScriptZoneGameObj::Find_Closest_Zone(location,(ZoneConstants::ZoneType)type);
+	return ScriptZoneGameObj::Find_Closest_Zone(location,(ZoneConstants::ZoneType)type);
 }
 
 GameObject SCRIPTS_API *Get_Vehicle(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	SoldierGameObj *o = (SoldierGameObj *)As_SoldierGameObj(obj);
+	SoldierGameObj *o = obj->As_SoldierGameObj();
 	if (o)
 	{
 		GameObject *vehicle = o->Get_Vehicle();
-		if (vehicle)
+		if (vehicle && vehicle->As_VehicleGameObj())
 		{
-			GameObject *v = As_VehicleGameObj(vehicle);
-			return v;
+			return vehicle;
 		}
 		return 0;
 	}
@@ -125,11 +134,11 @@
 
 void SCRIPTS_API Grant_Refill(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	GameObject *o = As_SoldierGameObj(obj);
+	GameObject *o = obj->As_SoldierGameObj();
 	if (o)
 	{
 		GrantSupplies(obj);
@@ -138,7 +147,7 @@
 
 bool SCRIPTS_API Change_Character(GameObject *obj,const char *Preset_Name)
 {
-	if (!Commands->Get_ID(obj) || !obj || Get_Vehicle(obj))
+	if (!obj || Get_Vehicle(obj))
 	{
 		return false;
 	}
@@ -171,6 +180,10 @@
 	{
 		return factory->As_BuildingGameObj()->As_AirFactoryGameObj()->Is_Available_For_Purchase();
 	}
+	else if (factory->As_BuildingGameObj() && factory->As_BuildingGameObj()->As_NavalFactoryGameObj())
+	{
+		return factory->As_BuildingGameObj()->As_NavalFactoryGameObj()->Is_Available_For_Purchase();
+	}
 	else
 	{
 		return false;
@@ -179,11 +192,11 @@
 
 void SCRIPTS_API Toggle_Fly_Mode(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	SoldierGameObj *o = (SoldierGameObj *)As_SoldierGameObj(obj);
+	SoldierGameObj *o = obj->As_SoldierGameObj();
 	if (o)
 	{
 		o->Toggle_Fly_Mode();
@@ -193,21 +206,21 @@
 
 int SCRIPTS_API Get_Vehicle_Occupant_Count(GameObject *obj)
 {
-	if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+	if (!obj || !obj->As_VehicleGameObj())
 	{
 		return 0;
 	}
-	VehicleGameObj *o = (VehicleGameObj *)obj;
+	VehicleGameObj *o = obj->As_VehicleGameObj();
 	return o->Get_Occupant_Count();
 }
 
 GameObject SCRIPTS_API *Get_Vehicle_Occupant(GameObject *obj,int seat)
 {
-	if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+	if (!obj || !obj->As_VehicleGameObj())
 	{
 		return 0;
 	}
-	VehicleGameObj *o = (VehicleGameObj *)obj;
+	VehicleGameObj *o = obj->As_VehicleGameObj();
 	if (seat >= o->Get_Definition().Get_Seat_Count())
 	{
 		return 0;
@@ -217,42 +230,42 @@
 
 GameObject SCRIPTS_API *Get_Vehicle_Driver(GameObject *obj)
 {
-	if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+	if (!obj || !obj->As_VehicleGameObj())
 	{
 		return 0;
 	}
-	VehicleGameObj *o = (VehicleGameObj *)obj;
+	VehicleGameObj *o = obj->As_VehicleGameObj();
 	return o->Get_Driver();
 }
 
 GameObject SCRIPTS_API *Get_Vehicle_Gunner_Pos(GameObject *obj)
 {
-	if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+	if (!obj || !obj->As_VehicleGameObj())
 	{
 		return 0;
 	}
-	VehicleGameObj *o = (VehicleGameObj *)obj;
+	VehicleGameObj *o = obj->As_VehicleGameObj();
 	return o->Get_Gunner();
 }
 
 GameObject SCRIPTS_API *Get_Vehicle_Gunner(GameObject *obj)
 {
-	if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+	if (!obj || !obj->As_VehicleGameObj())
 	{
 		return 0;
 	}
-	VehicleGameObj *o = (VehicleGameObj *)obj;
+	VehicleGameObj *o = obj->As_VehicleGameObj();
 	return o->Get_Actual_Gunner();
 }
 
 #ifndef SHADERS_EXPORTS
 void SCRIPTS_API Force_Occupant_Exit(GameObject *obj,int seat)
 {
-	if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+	if (!obj || !obj->As_VehicleGameObj())
 	{
 		return;
 	}
-	VehicleGameObj *o = (VehicleGameObj *)obj;
+	VehicleGameObj *o = obj->As_VehicleGameObj();
 	if (seat >= o->Get_Definition().Get_Seat_Count())
 	{
 		return;
@@ -267,11 +280,11 @@
 
 void SCRIPTS_API Force_Occupants_Exit(GameObject *obj)
 {
-	if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+	if (!obj || !obj->As_VehicleGameObj())
 	{
 		return;
 	}
-	VehicleGameObj *o = (VehicleGameObj *)obj;
+	VehicleGameObj *o = obj->As_VehicleGameObj();
 	int x = o->Get_Definition().Get_Seat_Count();
 	ActionParamsStruct params;
 	params.Set_Basic((long)0,100,39);
@@ -286,7 +299,7 @@
 
 void SCRIPTS_API Soldier_Transition_Vehicle(GameObject *obj)
 {
-	if (!Commands->Get_ID(obj) || !obj || !As_SoldierGameObj(obj))
+	if (!obj || !obj->As_SoldierGameObj())
 	{
 		return;
 	}
@@ -297,11 +310,11 @@
 
 void SCRIPTS_API Force_Occupants_Exit_Team(GameObject *obj,int team)
 {
-	if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+	if (!obj || !obj->As_VehicleGameObj())
 	{
 		return;
 	}
-	VehicleGameObj *o = (VehicleGameObj *)obj;
+	VehicleGameObj *o = obj->As_VehicleGameObj();
 	int x = o->Get_Definition().Get_Seat_Count();
 	ActionParamsStruct params;
 	params.Set_Basic((long)0,100,39);
@@ -317,18 +330,17 @@
 
 GameObject SCRIPTS_API *Get_Vehicle_Return(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return obj;
 	}
-	SoldierGameObj *o = (SoldierGameObj *)As_SoldierGameObj(obj);
+	SoldierGameObj *o = obj->As_SoldierGameObj();
 	if (o)
 	{
 		GameObject *vehicle = o->Get_Vehicle();
-		if (vehicle)
+		if (vehicle && vehicle->As_VehicleGameObj())
 		{
-			GameObject *v = As_VehicleGameObj(vehicle);
-			return v;
+			return vehicle;
 		}
 		return obj;
 	}
@@ -337,11 +349,11 @@
 
 bool SCRIPTS_API Get_Fly_Mode(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return false;
 	}
-	SoldierGameObj *o = (SoldierGameObj *)As_SoldierGameObj(obj);
+	SoldierGameObj *o = obj->As_SoldierGameObj();
 	if (!o)
 	{
 		return false;
@@ -351,11 +363,11 @@
 
 bool SCRIPTS_API Is_Stealth(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return false;
 	}
-	SmartGameObj *o = (SmartGameObj *)As_SmartGameObj(obj);
+	SmartGameObj *o = obj->As_SmartGameObj();
 	if (!o)
 	{
 		return false;
@@ -365,21 +377,21 @@
 
 int SCRIPTS_API Get_Vehicle_Seat_Count(GameObject *obj)
 {
-	if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+	if (!obj || !obj->As_VehicleGameObj())
 	{
 		return 0;
 	}
-	VehicleGameObj *o = (VehicleGameObj *)obj;
+	VehicleGameObj *o = obj->As_VehicleGameObj();
 	return o->Get_Definition().Get_Seat_Count();
 }
 
 unsigned int SCRIPTS_API Get_Vehicle_Mode(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	GameObject *o = As_VehicleGameObj(obj);
+	GameObject *o = obj->As_VehicleGameObj();
 	if (!o)
 	{
 		obj = Get_Vehicle(obj);
@@ -388,7 +400,7 @@
 			return 0;
 		}
 	}
-	VehicleGameObjDef *d = (VehicleGameObjDef *)Get_Definition(obj);
+	const VehicleGameObjDef *d = &obj->As_VehicleGameObj()->Get_Definition();
 	return (int)d->Get_Type();
 }
 
@@ -399,11 +411,11 @@
 
 GameObject SCRIPTS_API *Get_Vehicle_Owner(GameObject *obj)
 {	
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	VehicleGameObj *o = (VehicleGameObj *)obj;
+	VehicleGameObj *o = obj->As_VehicleGameObj();
 	return o->Get_Lock_Owner();
 }
 
@@ -416,11 +428,11 @@
 
 OBBoxClass SCRIPTS_API *Get_Zone_Box(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	ScriptZoneGameObj *o = (ScriptZoneGameObj*)As_ScriptZoneGameObj(obj);
+	ScriptZoneGameObj *o = obj->As_ScriptZoneGameObj();
 	if (!o)
 	{
 		return 0;
@@ -430,11 +442,11 @@
 
 bool SCRIPTS_API PointInZone(GameObject *obj,const Vector3 &v)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return false;
 	}
-	GameObject *o = As_ScriptZoneGameObj(obj);
+	GameObject *o = obj->As_ScriptZoneGameObj();
 	if (!o)
 	{
 		return false;
@@ -449,16 +461,16 @@
 
 bool SCRIPTS_API IsInsideZone(GameObject *zone,GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return false;
 	}
-	if (!Commands->Get_ID(zone) || !zone)
+	if (!zone)
 	{
 		return false;
 	}
-	GameObject *o = As_SmartGameObj(obj);
-	GameObject *o2 = As_ScriptZoneGameObj(zone);
+	GameObject *o = obj->As_SmartGameObj();
+	GameObject *o2 = zone->As_ScriptZoneGameObj();
 	if ((o) && (o2))
 	{
 		Vector3 v;
@@ -477,26 +489,26 @@
 
 unsigned int SCRIPTS_API Get_Zone_Type(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	GameObject *o = As_ScriptZoneGameObj(obj);
+	ScriptZoneGameObj *o = obj->As_ScriptZoneGameObj();
 	if (!o)
 	{
 		return 0;
 	}
-	ScriptZoneGameObjDef *d = (ScriptZoneGameObjDef *)Get_Definition(obj);
+	const ScriptZoneGameObjDef *d = &o->Get_Definition();
 	return d->Get_Type();
 }
 
 void SCRIPTS_API Set_Zone_Box(GameObject *obj,OBBoxClass &box)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	ScriptZoneGameObj *o = (ScriptZoneGameObj*)As_ScriptZoneGameObj(obj);
+	ScriptZoneGameObj *o = obj->As_ScriptZoneGameObj();
 	if (!o)
 	{
 		return;
@@ -508,27 +520,30 @@
 {
 	GameObject *obj = Create_Library_Object(preset);
 	Set_Zone_Box(obj,box);
-	((ScriptableGameObj *)obj)->Start_Observers();
+	obj->Start_Observers();
 	return obj;
 }
 
 void SCRIPTS_API Set_Vehicle_Is_Visible(GameObject *obj,bool visible)
 {
-	if(!Is_Vehicle(obj))
+	if(!obj)
 	{
 		return;
 	}
-	VehicleGameObj *b = (VehicleGameObj *)obj;
+	VehicleGameObj *b = obj->As_VehicleGameObj();
+	if (b)
+	{
 	b->Set_Is_Scripts_Visible(visible);
 }
+}
 
 void SCRIPTS_API Set_Vehicle_Gunner(GameObject *obj,int seat)
 {
-	if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+	if (!obj || !obj->As_VehicleGameObj())
 	{
 		return;
 	}
-	VehicleGameObj *o = (VehicleGameObj *)obj;
+	VehicleGameObj *o = obj->As_VehicleGameObj();
 	if (seat <= 1 || seat > o->Get_Definition().Get_Seat_Count())
 	{
 		return;
@@ -541,7 +556,7 @@
 	}
 }
 
-bool SmartGameObj::Is_Stealthed() const
+SCRIPTS_API bool SmartGameObj::Is_Stealthed() const
 {
    if (StealthEffect)
    {
@@ -553,7 +568,7 @@
    return false;
 }
 
-bool SmartGameObj::Is_Human_Controlled()
+SCRIPTS_API bool SmartGameObj::Is_Human_Controlled()
 {
    return (this->ControlOwner >= 0);
 }
@@ -583,34 +598,29 @@
 	return Get_Driver();
 }
 
-const VehicleGameObjDef & VehicleGameObj::Get_Definition( void ) const
+SCRIPTS_API const VehicleGameObjDef & VehicleGameObj::Get_Definition( void ) const
 {
 	return (const VehicleGameObjDef &)BaseGameObj::Get_Definition();
 }
 
 // 0x006802B0, 0x0067FB50, 0x, 0x0810D93A
-SmartGameObj* GameObjManager::Find_SmartGameObj
-   (int networkId)
+SCRIPTS_API SmartGameObj* GameObjManager::Find_SmartGameObj(int networkId)
 {
    if (!networkId)
       return 0;
-
    for (SLNode<SmartGameObj>* node = GameObjManager::SmartGameObjList.Head(); node; node = node->Next())
    {
 	  SmartGameObj* object = (SmartGameObj *)node->Data();
       if (object->Get_Network_ID() != networkId)
          continue;
-
 	  if (object->Is_Delete_Pending())
          return 0;
-
       return object;
    }
-
    return 0;
 }
 
-bool SmartGameObj::Has_Player()
+SCRIPTS_API bool SmartGameObj::Has_Player()
 {
 	return ControlOwner != SERVER_CONTROL_OWNER;
 }
@@ -620,7 +630,7 @@
 	return StealthEnabled;
 }
 
-bool SmartGameObj::Is_Obj_Visible(PhysicalGameObj* object)
+SCRIPTS_API bool SmartGameObj::Is_Obj_Visible(PhysicalGameObj* object)
 {
 	const Vector3 bullseyePosition = object->Get_Bullseye_Position();
 	const Matrix3D lookTransform = Get_Look_Transform();
@@ -650,7 +660,7 @@
 		collisionTest.CollidedPhysObj == object->Peek_Physical_Object();
 }
 
-const SmartGameObjDef & SmartGameObj::Get_Definition( void ) const
+SCRIPTS_API const SmartGameObjDef & SmartGameObj::Get_Definition( void ) const
 {
 	return (const SmartGameObjDef &)BaseGameObj::Get_Definition();
 }
@@ -662,11 +672,64 @@
 
 bool SCRIPTS_API Is_Spy(GameObject *obj)
 {
-	if (obj->As_SoldierGameObj())
+	if (obj && obj->As_SoldierGameObj())
 	{
 		return obj->As_SoldierGameObj()->Get_Definition().Is_Spy();
 	}
 	return false;
 }
 
+SCRIPTS_API bool Is_Stealth_Enabled(GameObject *obj)
+{
+	if (obj && obj->As_SoldierGameObj())
+	{
+		return obj->As_SoldierGameObj()->Is_Stealth_Enabled();
+	}
+	return false;
+}
+
+SCRIPTS_API int Get_Object_Count_In_Zone(GameObject *obj,int Team)
+{
+		if (!obj)
+		{
+				return 0;
+		}
+		ScriptZoneGameObj *Zone = obj->As_ScriptZoneGameObj();
+		if (!Zone)
+		{
+				return 0;
+		}
+		int Return = 0;
+		for (SLNode<SmartGameObj> *z = GameObjManager::SmartGameObjList.Head();z;z = z->Next())
+		{
+				if ((Get_Object_Type(z->Data()) == Team || Team == 2) && Zone->Inside_Me(z->Data()))
+				{
+						Return++;
+				}
+		}
+		return Return;
+}
+
+SCRIPTS_API int Get_Player_Count_In_Zone(GameObject *obj,int Team)
+{
+		if (!obj)
+		{
+				return 0;
+		}
+		ScriptZoneGameObj *Zone = obj->As_ScriptZoneGameObj();
+		if (!Zone)
+		{
+				return 0;
+		}
+		int Return = 0;
+		for (SLNode<SoldierGameObj> *z = GameObjManager::StarGameObjList.Head();z;z = z->Next())
+		{
+				if ((Get_Object_Type(z->Data()) == Team || Team == 2) && Zone->Inside_Me(z->Data()))
+				{
+						Return++;
+				}
+		}
+		return Return;
+}
+
 REF_DEF2(SmartGameObj::GlobalSightRangeScale,float,0x00811E64,0x0081103C);
diff -uwr sourceold/scripts/engine_obj2.h source/scripts/engine_obj2.h
--- sourceold/scripts/engine_obj2.h	2012-02-13 18:26:42.432039000 +0800
+++ source/scripts/engine_obj2.h	2012-05-23 11:26:18.001953100 +0800
@@ -48,4 +48,7 @@
 void SCRIPTS_API Set_Vehicle_Is_Visible(GameObject *obj,bool visible); //works like Set_Is_Visible but for vehicles, makes them be ignored by Enemy_Seen
 void SCRIPTS_API Set_Vehicle_Gunner(GameObject *obj,int seat); //set gunner for this vehicle
 bool SCRIPTS_API Is_Spy(GameObject *obj); //Is this soldier object a spy
+SCRIPTS_API int Get_Player_Count_In_Zone(GameObject *obj,int Team); //Get the player count in a zone
+SCRIPTS_API int Get_Object_Count_In_Zone(GameObject *obj,int Team); //Get the object count in a zone
+SCRIPTS_API bool Is_Stealth_Enabled(GameObject *obj); //Is stealth enabled
 #endif
diff -uwr sourceold/scripts/engine_phys.cpp source/scripts/engine_phys.cpp
--- sourceold/scripts/engine_phys.cpp	2011-10-22 20:22:09.932617100 +0800
+++ source/scripts/engine_phys.cpp	2012-05-12 19:20:40.911132800 +0800
@@ -26,11 +26,11 @@
 #include "VehicleGameObj.h"
 const char SCRIPTS_API *Get_Model(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return "DUMMY";
 	}
-	PhysicalGameObj *o = (PhysicalGameObj *)As_PhysicalGameObj(obj);
+	PhysicalGameObj *o = obj->As_PhysicalGameObj();
 	if (!o)
 	{
 		return "DUMMY";
@@ -38,522 +38,22 @@
 	return o->Peek_Physical_Object()->Peek_Model()->Get_Name();
 }
 
-bool SCRIPTS_API Is_TrackedVehicle(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x900C)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_VTOLVehicle(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x900D)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_WheeledVehicle(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x9006)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_Motorcycle(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x9002)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_Door(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x9080)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_Elevator(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x9081)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_DamageableStaticPhys(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x9082)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_AccessablePhys(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x9010)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_DecorationPhys(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x9000)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_HumanPhys(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x9001)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_MotorVehicle(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x9003)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_Phys3(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x9004)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_RigidBody(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x9005)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_ShakeableStatricPhys(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x900F)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_StaticAnimPhys(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x9008)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_StaticPhys(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x9007)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_TimedDecorationPhys(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x900A)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_VehiclePhys(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x900B)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_DynamicAnimPhys(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x900E)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_BuildingAggregate(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x9083)
-	{
-		return false;
-	}
-	return true;
-}
-
-bool SCRIPTS_API Is_Projectile(GameObject *obj)
-{
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return false;
-	}
-	GameObject *o = As_PhysicalGameObj(obj);
-	if (!o)
-	{
-		return false;
-	}
-	DefinitionClass* definition = Get_Phys_Definition(o);
-	if (!definition)
-	{
-		return false;
-	}
-	int Class_ID = definition->Get_Class_ID();
-	if (Class_ID != 0x9009)
-	{
-		return false;
-	}
-	return true;
-}
-
 //doesnt work for CinematicGameObjs
 float SCRIPTS_API Get_Animation_Frame(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o = obj->As_PhysicalGameObj();
 	if (!o)
 	{
 		return 0;
 	}
+	if (o->As_CinematicGameObj())
+	{
+		return 0;
+	}
 	unsigned char *x = (unsigned char *)o->Get_Anim_Control();
 	if (!x)
 	{
@@ -563,40 +63,18 @@
 	return a;
 }
 
-const char SCRIPTS_API *Get_Physics(GameObject *obj)
-{
-	if (Is_Door(obj)) return "Is_Door";
-	else if (Is_Elevator(obj)) return "Is_Elevator";
-	else if (Is_DamageableStaticPhys(obj)) return "Is_DamageableStaticPhys";
-	else if (Is_AccessablePhys(obj)) return "Is_AccessablePhys";
-	else if (Is_DecorationPhys(obj)) return "Is_DecorationPhys";
-	else if (Is_HumanPhys(obj)) return "Is_HumanPhys";
-	else if (Is_MotorVehicle(obj)) return "Is_MotorVehicle";
-	else if (Is_Phys3(obj)) return "Is_Phys3";
-	else if (Is_RigidBody(obj)) return "Is_RigidBody";
-	else if (Is_ShakeableStatricPhys(obj)) return "Is_ShakeableStatricPhys";
-	else if (Is_StaticAnimPhys(obj)) return "Is_StaticAnimPhys";
-	else if (Is_StaticPhys(obj)) return "Is_StaticPhys";
-	else if (Is_TimedDecorationPhys(obj)) return "Is_TimedDecorationPhys";
-	else if (Is_VehiclePhys(obj)) return "Is_VehiclePhys";
-	else if (Is_DynamicAnimPhys(obj)) return "Is_DynamicAnimPhys";
-	else if (Is_BuildingAggregate(obj)) return "Is_BuildingAggregate";
-	else if (Is_Projectile(obj)) return "Is_Projectile";
-	else return "(null)";
-}
-
 void SCRIPTS_API Copy_Transform(GameObject *in,GameObject *out)
 {
-	if (!Commands->Get_ID(in) || !in || !Commands->Get_ID(out) || !out)
+	if (!in || !out)
 	{
 		return;
 	}
-	PhysicalGameObj *i2 = ((ScriptableGameObj *)in)->As_PhysicalGameObj();
+	PhysicalGameObj *i2 = in->As_PhysicalGameObj();
 	if (!i2)
 	{
 		return;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)out)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = out->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return;
@@ -606,26 +84,30 @@
 
 float SCRIPTS_API Get_Mass(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o = (PhysicalGameObj *)As_PhysicalGameObj(obj);
+	PhysicalGameObj *o = obj->As_PhysicalGameObj();
 	if (!o)
 	{
 		return 0;
 	}
 	PhysClass *phys = o->Peek_Physical_Object();
+	if (phys && phys->As_MoveablePhysClass())
+	{
 	return phys->As_MoveablePhysClass()->Get_Mass();
 }
+	return 0;
+}
 
 const char SCRIPTS_API *Get_Htree_Name(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return "DUMMY";
 	}
-	PhysicalGameObj *o = (PhysicalGameObj *)As_PhysicalGameObj(obj);
+	PhysicalGameObj *o = obj->As_PhysicalGameObj();
 	if (!o)
 	{
 		return "DUMMY";
@@ -640,12 +122,10 @@
 
 void SCRIPTS_API Create_Effect_All_Stealthed_Objects_Area(const Vector3 &Position,float Distance,const char *object,const Vector3 &offset,int team)
 {
-	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
+	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 	while (x) 
 	{
-		GameObject *obj = (GameObject *)x->Data();
-		if (obj && As_ScriptableGameObj(obj))
-		{
+		SmartGameObj *obj = x->Data();
 			Vector3 ObjPosition = Commands->Get_Position(obj);
 			Vector3 TestPosition = Position;
 			ObjPosition.Z = 0;
@@ -666,7 +146,6 @@
 					}
 				}
 			}
-		}
 		x = x->Next();
 	}
 }
@@ -697,3 +176,16 @@
 		x = x->Next();
 	}
 }
+
+
+SCRIPTS_API const char* Get_Animation_Name ( GameObject* pObj )
+{
+  if (!pObj || !pObj->As_PhysicalGameObj() || pObj->As_PhysicalGameObj()->As_CinematicGameObj())
+    return NULL;
+
+  AnimControlClass* pAcc = pObj->As_PhysicalGameObj()->Get_Anim_Control();
+  if ( pAcc )
+    return pAcc->Get_Animation_Name();
+  else
+    return NULL;
+}
diff -uwr sourceold/scripts/engine_phys.h source/scripts/engine_phys.h
--- sourceold/scripts/engine_phys.h	2011-10-11 21:53:38.783203100 +0800
+++ source/scripts/engine_phys.h	2012-05-12 19:20:40.888671800 +0800
@@ -15,32 +15,26 @@
 
 const char SCRIPTS_API *Get_Model(GameObject *obj); //get the name of the 3d model used by an object,opposite of Set_Model
 float SCRIPTS_API Get_Animation_Frame(GameObject *obj); //gets the current animation frame for obj,may not work for all objects
-bool SCRIPTS_API Is_TrackedVehicle(GameObject *obj); //has TrackedVechicle physics
-bool SCRIPTS_API Is_VTOLVehicle(GameObject *obj); //has VTOLVechicle physics
-bool SCRIPTS_API Is_WheeledVehicle(GameObject *obj); //has WheeledVechicle physics
-bool SCRIPTS_API Is_Motorcycle(GameObject *obj); //has Morotcycle physics
-bool SCRIPTS_API Is_Door(GameObject *obj); //has Door physics
-bool SCRIPTS_API Is_Elevator(GameObject *obj); //has Elevator physics
-bool SCRIPTS_API Is_DamageableStaticPhys(GameObject *obj); //has DamageableStaticPhys physics
-bool SCRIPTS_API Is_AccessablePhys(GameObject *obj); //has AccessablePhys physics
-bool SCRIPTS_API Is_DecorationPhys(GameObject *obj); //has DecorationPhys physics
-bool SCRIPTS_API Is_HumanPhys(GameObject *obj); //has HumanPhys physics
-bool SCRIPTS_API Is_MotorVehicle(GameObject *obj); //has MotorVehicle physics
-bool SCRIPTS_API Is_Phys3(GameObject *obj); //has Phys3 physics
-bool SCRIPTS_API Is_RigidBody(GameObject *obj); //has RigidBody physics
-bool SCRIPTS_API Is_ShakeableStatricPhys(GameObject *obj); //has ShakeableStaticPhys physics
-bool SCRIPTS_API Is_StaticAnimPhys(GameObject *obj); //has StaticAnimPhys physics
-bool SCRIPTS_API Is_StaticPhys(GameObject *obj); //has StaticPhys physics
-bool SCRIPTS_API Is_TimedDecorationPhys(GameObject *obj); //has TimedDecorationPhys physics
-bool SCRIPTS_API Is_VehiclePhys(GameObject *obj); //has VechiclePhys physics
-bool SCRIPTS_API Is_DynamicAnimPhys(GameObject *obj); //has DenamicAnimPhys physics
-bool SCRIPTS_API Is_BuildingAggregate(GameObject *obj); //has BuildingAggregate physics
-bool SCRIPTS_API Is_Projectile(GameObject *obj); //has Projectile physics
-const char SCRIPTS_API *Get_Physics(GameObject *obj); //returns a string indicating the physics type of an object
 void SCRIPTS_API Copy_Transform(GameObject *in,GameObject *out); //copies the complete transform (including rotation) from one object to another
 float SCRIPTS_API Get_Mass(GameObject *obj); //returns the mass of an object
 const char SCRIPTS_API *Get_Htree_Name(GameObject *obj); //returns the Hierarchy Tree name for an object
 char SCRIPTS_API Get_Sex(GameObject *obj); //gets the character (e.g. "A" for male or "B" for female) for use with animations
 void SCRIPTS_API 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 SCRIPTS_API Create_Effect_All_Of_Preset(const char *object,const char *preset,float ZAdjust,bool ZSet); //Create an object above all objects of a given preset, also set the facing to match the object its being created over.
+
+/*!
+* \brief Get current object animation
+* \author Daniel Paul (danpaul88@yahoo.co.uk)
+*
+* Get the name of the animation currently playing on the specified object, if any
+*
+* \param[in] pObj
+*   Pointer to the GameObject for which to get the current animation name
+*
+* \return
+*   The name of the current animation playing on the specified object or NULL if the object doesn't
+*   support animations or is not currently playing one
+*/
+SCRIPTS_API const char* Get_Animation_Name ( GameObject* pObj );
+
 #endif
diff -uwr sourceold/scripts/engine_player.cpp source/scripts/engine_player.cpp
--- sourceold/scripts/engine_player.cpp	2012-01-18 06:45:15.295898400 +0800
+++ source/scripts/engine_player.cpp	2012-05-23 15:23:26.239257800 +0800
@@ -22,6 +22,7 @@
 #include "engine_game.h"
 #include "engine_tdb.h"
 #include "SysTimeClass.h"
+#include "cTeam.h"
 RENEGADE_FUNCTION
 int SCRIPTS_API Get_Player_Count()
 AT2(0x00417040,0x00417040);
@@ -59,7 +60,7 @@
 AT2(0x00415810,0x00415810);
 
 RENEGADE_FUNCTION
-char *Find_Team(int team)
+cTeam *Find_Team(int team)
 AT2(0x0041DA10,0x0041DA10);
 
 RENEGADE_FUNCTION
@@ -68,11 +69,11 @@
 
 const char SCRIPTS_API *Get_Player_Name(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return newstr("None");
 	}
-	SoldierGameObj *o = (SoldierGameObj *)As_SoldierGameObj(obj);
+	SoldierGameObj *o = obj->As_SoldierGameObj();
 	if (!o)
 	{
 		return newstr("None");
@@ -118,11 +119,11 @@
 
 void SCRIPTS_API Change_Team(GameObject *obj,int Team)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	SoldierGameObj *o = (SoldierGameObj *)As_SoldierGameObj(obj);
+	SoldierGameObj *o = obj->As_SoldierGameObj();
 	if (!o)
 	{
 		return;
@@ -137,11 +138,11 @@
 
 void SCRIPTS_API Change_Team_2(GameObject *obj,int Team)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	SoldierGameObj *o = (SoldierGameObj *)As_SoldierGameObj(obj);
+	SoldierGameObj *o = obj->As_SoldierGameObj();
 	if (!o)
 	{
 		return;
@@ -155,11 +156,11 @@
 
 long SCRIPTS_API Get_Player_ID(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return -1;
 	}
-	SoldierGameObj *o = (SoldierGameObj *)As_SoldierGameObj(obj);
+	SoldierGameObj *o = obj->As_SoldierGameObj();
 	if (!o)
 	{
 		return -1;
@@ -260,11 +261,11 @@
 
 bool SCRIPTS_API Purchase_Item(GameObject *obj,int cost)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return false;
 	}
-	SoldierGameObj *o = (SoldierGameObj *)As_SoldierGameObj(obj);
+	SoldierGameObj *o = obj->As_SoldierGameObj();
 	if (!o)
 	{
 		return false;
@@ -323,9 +324,12 @@
 
 float SCRIPTS_API Get_Team_Score(int team)
 {
-	char *teamdata = Find_Team(team);
-	teamdata += 0x6C0;
-	return *((float *)teamdata);
+	cTeam *teamdata = Find_Team(team);
+	if (teamdata)
+	{
+		return teamdata->Get_Score();
+	}
+	return 0;
 }
 
 void SCRIPTS_API Get_Team_Color(unsigned int team, unsigned int *red, unsigned int *green, unsigned int *blue)
@@ -338,11 +342,11 @@
 
 GameObject SCRIPTS_API *Find_First_Player(int Team)
 {
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
 	while (x)
 	{
 		GameObject *o = x->Data();
-		if (o && As_SoldierGameObj(o))
+		if (o && (o))
 		{
 			if (Commands->Is_A_Star(o))
 			{
@@ -359,7 +363,7 @@
 
 bool SCRIPTS_API Change_Player_Team(GameObject *obj,bool Retain_Score,bool Retain_Money,bool Show_Host_Message)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return false;
 	}
@@ -409,13 +413,13 @@
 
 GameObject SCRIPTS_API *Get_Part_Name(const char *name1)
 {
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
 	int count = 0;
 	GameObject *current = 0;
 	while (x)
 	{
 		GameObject *o = x->Data();
-		if (o && As_SoldierGameObj(o))
+		if (o)
 		{
 			const char *name = Get_Player_Name(o);
 			if (stristr(name,name1))
@@ -439,12 +443,12 @@
 
 int SCRIPTS_API Get_Part_Names(const char *name1)
 {
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
 	int count = 0;
 	while (x)
 	{
 		GameObject *o = x->Data();
-		if (o && As_SoldierGameObj(o))
+		if (o)
 		{
 			const char *name = Get_Player_Name(o);
 			if (stristr(name,name1))
@@ -461,11 +465,11 @@
 int SCRIPTS_API Get_Team_Player_Count(int Team)
 {
 	int Total = 0;
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
 	while (x)
 	{
 		GameObject *o = x->Data();
-		if (o && As_SoldierGameObj(o) && Get_Object_Type(o) == Team)
+		if (o && Get_Object_Type(o) == Team)
 		{
 			Total++;
 		}
@@ -476,11 +480,11 @@
 
 int SCRIPTS_API Get_Player_Type(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	SoldierGameObj *o = (SoldierGameObj *)As_SoldierGameObj(obj);
+	SoldierGameObj *o = obj->As_SoldierGameObj();
 	if (!o)
 	{
 		return 0;
@@ -494,11 +498,11 @@
 
 const wchar_t SCRIPTS_API *Get_Wide_Player_Name(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return L"None";
 	}
-	SoldierGameObj *o = (SoldierGameObj *)As_SoldierGameObj(obj);
+	SoldierGameObj *o = obj->As_SoldierGameObj();
 	if (!o)
 	{
 		return L"None";
@@ -610,3 +614,78 @@
 		GameSpyAuthStateEntryTimeMs = TIMEGETTIME();
 	}
 }
+
+SCRIPTS_API int Get_Player_Team(int PlayerID)
+{
+        cPlayer *x = Find_Player(PlayerID);
+        if (!x)
+		{
+                return 0;
+        }
+        return x->PlayerType;
+}
+
+SCRIPTS_API int Get_Player_ID_By_Name(const char *Name)
+{
+        cPlayer *Player = Find_Player(Name);
+        if (Player)
+		{
+                return Player->Get_Id();
+        }
+        return 0;
+}
+
+SCRIPTS_API bool Is_Active(int ID)
+{
+        cPlayer *Player = Find_Player(ID);
+        if (Player)
+		{
+                return Player->Get_Is_Active();
+        }
+        return false;
+}
+
+SCRIPTS_API void Set_Kills(int ID,int kills)
+{
+        cPlayer *Player = Find_Player(ID);
+        if (Player)
+		{
+			Player->Set_Kills(kills);
+		}
+}
+
+SCRIPTS_API void Set_Deaths(int ID,int deaths)
+{
+        cPlayer *Player = Find_Player(ID);
+        if (Player)
+		{
+			Player->Set_Deaths(deaths);
+		}
+}
+
+SCRIPTS_API void Set_Team_Score(int ID,float score)
+{
+	cTeam *teamdata = Find_Team(ID);
+	if (teamdata)
+	{
+		teamdata->Set_Score(score);
+	}
+}
+
+void cPlayer::Set_Kills(int kills)
+{
+	Kills = kills;
+	Set_Object_Dirty_Bit(BIT_OCCASIONAL,true);
+}
+
+void cPlayer::Set_Deaths(int deaths)
+{
+	Deaths = deaths;
+	Set_Object_Dirty_Bit(BIT_OCCASIONAL,true);
+}
+
+void cTeam::Set_Score(float _score)
+{
+	score = _score;
+	Set_Object_Dirty_Bit(NetworkObjectClass::BIT_OCCASIONAL, true);
+}
diff -uwr sourceold/scripts/engine_player.h source/scripts/engine_player.h
--- sourceold/scripts/engine_player.h	2011-10-11 21:54:40.969726500 +0800
+++ source/scripts/engine_player.h	2012-05-23 11:10:50.924804600 +0800
@@ -48,9 +48,13 @@
 void SCRIPTS_API Change_Team_2(GameObject *obj,int Team); //changes the team of a player given their GameObject without killing the player,passing anything other than 0 = Nod,1 = GDI will crash
 int SCRIPTS_API Get_Player_Type(GameObject *obj); //Get the player type of a player from the cPlayer
 const wchar_t SCRIPTS_API *Get_Wide_Player_Name(GameObject *obj); //Converts a GameObject into a player name
-Vector3 SCRIPTS_API Get_Color_For_Team(int teamId);
-
-SCRIPTS_API cPlayer *Find_Player(int playerId);
-SCRIPTS_API cPlayer *Find_Player(const WideStringClass& playerName);
-
+Vector3 SCRIPTS_API Get_Color_For_Team(int teamId); //Get the color values for a team
+SCRIPTS_API int Get_Player_Team(int PlayerID); //Get the team type of a player
+SCRIPTS_API cPlayer *Find_Player(int playerId); //Find a player by ID
+SCRIPTS_API cPlayer *Find_Player(const WideStringClass& playerName); //find a player by name
+SCRIPTS_API int Get_Player_ID_By_Name(const char *Name); //Get the ID of a player given a name
+SCRIPTS_API bool Is_Active(int ID); //Is a player active
+SCRIPTS_API void Set_Kills(int ID,int kills); //Set kills for a player
+SCRIPTS_API void Set_Deaths(int ID,int deaths); //Set deaths for a player
+SCRIPTS_API void Set_Team_Score(int ID,float score); //Set score for a team
 #endif
diff -uwr sourceold/scripts/engine_script.cpp source/scripts/engine_script.cpp
--- sourceold/scripts/engine_script.cpp	2011-10-11 23:03:17.410156200 +0800
+++ source/scripts/engine_script.cpp	2012-04-29 00:21:50.067382800 +0800
@@ -16,18 +16,20 @@
 #include "slist.h"
 #include "GameObjManager.h"
 #include "engine_obj.h"
+#include "engine_obj2.h"
 #include "engine_def.h"
 #include "Definition.h"
 #include "engine_phys.h"
 #include "engine_game.h"
 #include "BuildingGameObj.h"
+#include "VehicleGameObj.h"
 SCRIPTS_API void Remove_Script(GameObject *obj,const char *script)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	const SimpleDynVecClass<GameObjObserverClass *> *observers = &((ScriptableGameObj *)obj)->Get_Observers();
+	const SimpleDynVecClass<GameObjObserverClass *> *observers = &obj->Get_Observers();
 	int x = observers->Count();
 	for (int i = 0;i < x;i++)
 	{
@@ -40,11 +42,11 @@
 
 SCRIPTS_API void Remove_Duplicate_Script(GameObject *obj, const char *script)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	const SimpleDynVecClass<GameObjObserverClass *> *observers = &((ScriptableGameObj *)obj)->Get_Observers();
+	const SimpleDynVecClass<GameObjObserverClass *> *observers = &obj->Get_Observers();
 	bool Found = false;
 	for (int i = 0;i < observers->Count();i++)
 	{
@@ -67,15 +69,20 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			const DefinitionClass *d = Get_Definition(o);
+			const DefinitionClass *d = &o2->Get_Definition();
 			if (!_stricmp(d->Get_Name(),preset))
 			{
-				if ((Get_Object_Type(o) == team) || (team == 2))
+				if ((Get_Object_Type(o2) == team) || (team == 2))
 				{
-					Remove_Script(o,script);
+					Remove_Script(o2,script);
 				}
 			}
 		}
@@ -88,15 +95,20 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
 		{
-			const DefinitionClass *d = Get_Definition(o);
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
+		{
+			const DefinitionClass *d = &o2->Get_Definition();
 			if (d->Get_Class_ID() == type)
 			{
-				if ((Get_Object_Type(o) == team) || (team == 2))
+				if ((Get_Object_Type(o2) == team) || (team == 2))
 				{
-					Remove_Script(o,script);
+					Remove_Script(o2,script);
 				}
 			}
 		}
@@ -106,11 +118,11 @@
 
 SCRIPTS_API void Remove_All_Scripts(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	const SimpleDynVecClass<GameObjObserverClass *> *observers = &((ScriptableGameObj *)obj)->Get_Observers();
+	const SimpleDynVecClass<GameObjObserverClass *> *observers = &obj->Get_Observers();
 	int x = observers->Count();
 	for (int i = 0;i < x;i++)
 	{
@@ -126,15 +138,20 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			const DefinitionClass *d = Get_Definition(o);
+			const DefinitionClass *d = &o2->Get_Definition();
 			if (!_stricmp(d->Get_Name(),preset))
 			{
-				if ((Get_Object_Type(o) == team) || (team == 2))
+				if ((Get_Object_Type(o2) == team) || (team == 2))
 				{
-					Commands->Attach_Script(o,script,params);
+					Commands->Attach_Script(o2,script,params);
 				}
 			}
 		}
@@ -147,15 +164,20 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
 		{
-			const DefinitionClass *d = Get_Definition(o);
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
+		{
+			const DefinitionClass *d = &o2->Get_Definition();
 			if (d->Get_Class_ID() == type)
 			{
-				if ((Get_Object_Type(o) == team) || (team == 2))
+				if ((Get_Object_Type(o2) == team) || (team == 2))
 				{
-					Commands->Attach_Script(o,script,params);
+					Commands->Attach_Script(o2,script,params);
 				}
 			}
 		}
@@ -165,11 +187,11 @@
 
 SCRIPTS_API bool Is_Script_Attached(GameObject *obj,const char *script)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return false;
 	}
-	const SimpleDynVecClass<GameObjObserverClass *> *observers = &((ScriptableGameObj *)obj)->Get_Observers();
+	const SimpleDynVecClass<GameObjObserverClass *> *observers = &obj->Get_Observers();
 	int x = observers->Count();
 	for (int i = 0;i < x;i++)
 	{
@@ -183,7 +205,7 @@
 
 SCRIPTS_API void Attach_Script_Once(GameObject *obj,const char *script,const char *params)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
@@ -198,17 +220,22 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			const DefinitionClass *d = Get_Definition(o);
+			const DefinitionClass *d = &o2->Get_Definition();
 			if (!_stricmp(d->Get_Name(),preset))
 			{
-				if ((Get_Object_Type(o) == team) || (team == 2))
+				if ((Get_Object_Type(o2) == team) || (team == 2))
 				{
-					if (!Is_Script_Attached(o,script))
+					if (!Is_Script_Attached(o2,script))
 					{
-						Commands->Attach_Script(o,script,params);
+						Commands->Attach_Script(o2,script,params);
 					}
 				}
 			}
@@ -222,17 +249,22 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			const DefinitionClass *d = Get_Definition(o);
+			const DefinitionClass *d = &o2->Get_Definition();
 			if (d->Get_Class_ID() == type)
 			{
-				if ((Get_Object_Type(o) == team) || (team == 2))
+				if ((Get_Object_Type(o2) == team) || (team == 2))
 				{
-					if (!Is_Script_Attached(o,script))
+					if (!Is_Script_Attached(o2,script))
 					{
-						Commands->Attach_Script(o,script,params);
+						Commands->Attach_Script(o2,script,params);
 					}
 				}
 			}
@@ -243,15 +275,10 @@
 
 SCRIPTS_API void Attach_Script_Player_Once(const char *script,const char *params,int team)
 {
-	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
+	SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
-		{
-			const DefinitionClass *d = Get_Definition(o);
-			if (d->Get_Class_ID() == CID_Soldier)
-			{
+		SoldierGameObj *o = x->Data();
 				if ((Get_Object_Type(o) == team) || (team == 2))
 				{
 					if (!Is_Script_Attached(o,script))
@@ -259,8 +286,6 @@
 						Commands->Attach_Script(o,script,params);
 					}
 				}
-			}
-		}
 		x = x->Next();
 	}
 }
@@ -271,7 +296,7 @@
 	while (x)
 	{
 		GameObject *o = x->Data();
-		if ((o) && As_BuildingGameObj(o))
+		if (o)
 		{
 			if ((Get_Object_Type(o) == team) || (team == 2))
 			{
@@ -284,11 +309,11 @@
 
 SCRIPTS_API void Attach_Script_Is_Preset(GameObject *obj,const char *preset,const char *script,const char *params,int team)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	const DefinitionClass *d = Get_Definition(obj);
+	const DefinitionClass *d = &obj->Get_Definition();
 	if (!_stricmp(d->Get_Name(),preset))
 	{
 		if ((Get_Object_Type(obj) == team) || (team == 2))
@@ -300,11 +325,11 @@
 
 SCRIPTS_API void Attach_Script_Is_Type(GameObject *obj,unsigned long type,const char *script,const char *params,int team)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	const DefinitionClass *d = Get_Definition(obj);
+	const DefinitionClass *d = &obj->Get_Definition();
 	if (d->Get_Class_ID() == type)
 	{
 		if ((Get_Object_Type(obj) == team) || (team == 2))
@@ -319,7 +344,7 @@
 	SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_BuildingGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if (Get_Object_Type(o) == Team || Team == 2)
@@ -340,13 +365,11 @@
 
 SCRIPTS_API void Attach_Script_All_Turrets_Team(int Team,const char *Script,const char *Params,bool Once)
 {
-	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
+	SLNode<VehicleGameObj> *x = GameObjManager::VehicleGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o) && As_VehicleGameObj(o))
-		{
-			if (Is_DecorationPhys(o) && (Get_Object_Type(o) == Team || Team == 2))
+		VehicleGameObj *o = x->Data();
+		if (Get_Vehicle_Mode(o) == VEHICLE_TYPE_TURRET && (Get_Object_Type(o) == Team || Team == 2))
 			{
 				if (Once)
 				{
@@ -357,7 +380,6 @@
 					Commands->Attach_Script(o,Script,Params);
 				}
 			}
-		}
 		x = x->Next();
 	}
 }
@@ -385,12 +407,17 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			if (Is_Script_Attached(o, script))
+			if (Is_Script_Attached(o2, script))
 			{
-				return o;
+				return o2;
 			}
 		}
 		x = x->Next();
@@ -405,16 +432,21 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			if (Is_Script_Attached(o, script))
+			if (Is_Script_Attached(o2, script))
 			{
-				float dist = Commands->Get_Distance(Commands->Get_Position(o),pos);
+				float dist = Commands->Get_Distance(Commands->Get_Position(o2),pos);
 				if (closest == NULL || dist < closestdist)
 				{
 					closestdist = dist;
-					closest = o;
+					closest = o2;
 				}
 			}
 		}
@@ -430,12 +462,17 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
 		{
-			if (Is_Script_Attached(o, script))
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 			{
-				objects.Add_Tail(o);
+			if (Is_Script_Attached(o2, script))
+			{
+				objects.Add_Tail(o2);
 			}
 		}
 		x = x->Next();
@@ -444,20 +481,25 @@
 
 SCRIPTS_API void Send_Custom_Event_To_Objects_With_Script( GameObject *sender, const char *script, int message, int param, float delay )
 {
-	if (!sender || !Commands->Get_ID(sender) )
+	if (!sender)
 	{
 		return;
 	}
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			if ( Is_Script_Attached( o, script )
-				&& Commands->Get_ID ( sender ) != Commands->Get_ID ( o ) )
+			if ( Is_Script_Attached( o2, script )
+				&& Commands->Get_ID ( sender ) != Commands->Get_ID ( o2 ) )
 			{
-				Commands->Send_Custom_Event(sender,o,message,param,delay);
+				Commands->Send_Custom_Event(sender,o2,message,param,delay);
 			}
 		}
 		x = x->Next();
@@ -466,21 +508,26 @@
 
 SCRIPTS_API void Send_Custom_Event_To_Objects_With_Script_Ranged( GameObject *sender, const char *script, int message, int param, float delay, float range )
 {
-	if (!sender || !Commands->Get_ID(sender) )
+	if (!sender)
 	{
 		return;
 	}
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
-		if (o && As_ScriptableGameObj(o))
+		BaseGameObj *o = x->Data();
+		ScriptableGameObj *o2 = 0;
+		if (o)
+		{
+			o2 = o->As_ScriptableGameObj();
+		}
+		if (o2)
 		{
-			if ( Is_Script_Attached( o, script )
-				&& Commands->Get_ID ( sender ) != Commands->Get_ID ( o )
-				&& Commands->Get_Distance ( Commands->Get_Position ( sender ), Commands->Get_Position ( o ) ) <= range )
+			if ( Is_Script_Attached( o2, script )
+				&& Commands->Get_ID ( sender ) != Commands->Get_ID ( o2 )
+				&& Commands->Get_Distance ( Commands->Get_Position ( sender ), Commands->Get_Position ( o2 ) ) <= range )
 			{
-				Commands->Send_Custom_Event(sender,o,message,param,delay);
+				Commands->Send_Custom_Event(sender,o2,message,param,delay);
 			}
 		}
 		x = x->Next();
@@ -489,14 +536,11 @@
 
 SCRIPTS_API ScriptImpClass* Find_Script_On_Object(GameObject* obj, const char *script)
 {
-	if (!obj || !Commands->Get_ID(obj) )
+	if (!obj)
 	{
 		return NULL;
 	}
-
-	if ( As_ScriptableGameObj(obj) )
-	{
-		const SimpleDynVecClass<GameObjObserverClass *> *observers = &((ScriptableGameObj *)obj)->Get_Observers();
+	const SimpleDynVecClass<GameObjObserverClass *> *observers = &obj->Get_Observers();
 		int x = observers->Count();
 		for (int i = 0;i < x;i++)
 		{
@@ -505,7 +549,23 @@
 				return ((ScriptImpClass*)(*observers)[i]);
 			}
 		}
-	}
 
 	return NULL;
 }
+
+void SCRIPTS_API Attach_Script_Occupants(GameObject *obj,const char *script,const char *params)
+{
+	if (!obj || !obj->As_VehicleGameObj())
+	{
+		return;
+	}
+	VehicleGameObj *o = obj->As_VehicleGameObj();
+	int x = o->Get_Definition().Get_Seat_Count();
+	for (int i = 0;i < x;i++)
+	{
+		if (o->Get_Occupant(i))
+		{
+			Commands->Attach_Script(o->Get_Occupant(i),script,params);
+		}
+	}
+}
diff -uwr sourceold/scripts/engine_script.h source/scripts/engine_script.h
--- sourceold/scripts/engine_script.h	2011-10-11 21:53:56.809570300 +0800
+++ source/scripts/engine_script.h	2012-04-24 15:57:17.879882800 +0800
@@ -38,4 +38,5 @@
 SCRIPTS_API void Send_Custom_Event_To_Objects_With_Script( GameObject *sender, const char *script, int message, int param, float delay ); // Script to send a custom to all objects with a specific script
 SCRIPTS_API void Send_Custom_Event_To_Objects_With_Script_Ranged( GameObject *sender, const char *script, int message, int param, float delay, float range ); // Script to send a custom to all objects with a specific script in a specified range
 SCRIPTS_API ScriptImpClass* Find_Script_On_Object(GameObject* obj, const char *script); // Returns a pointer to the first instance of the named script on the given object, or NULL if not found
+SCRIPTS_API void Attach_Script_Occupants(GameObject *obj,const char *script,const char *params); //attaches a script to all occupants of a vehicle
 #endif
diff -uwr sourceold/scripts/engine_tdb.cpp source/scripts/engine_tdb.cpp
--- sourceold/scripts/engine_tdb.cpp	2011-10-11 23:03:14.446289000 +0800
+++ source/scripts/engine_tdb.cpp	2012-04-24 12:13:24.675781200 +0800
@@ -61,31 +61,36 @@
 
 SCRIPTS_API const char *Get_Translated_Preset_Name(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return newstr("");
 	}
-	GameObject *o = As_DamageableGameObj(obj);
+	DamageableGameObj *o = obj->As_DamageableGameObj();
 	if (!o)
 	{
 		return newstr("");
 	}
-	DamageableGameObjDef *d = (DamageableGameObjDef *)Get_Definition(obj);
+	const DamageableGameObjDef *d = &o->Get_Definition();
 	return Get_Translated_String(d->Get_Translated_Name_ID());
 }
 
 SCRIPTS_API const wchar_t *Get_Current_Wide_Translated_Weapon(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	GameObject *o = As_ArmedGameObj(obj);
+	PhysicalGameObj *o = obj->As_PhysicalGameObj();
 	if (!o)
 	{
 		return 0;
 	}
-	WeaponBagClass *w = ((ArmedGameObj *)o)->Get_Weapon_Bag();
+	ArmedGameObj *o2 = o->As_ArmedGameObj();
+	if (!o2)
+	{
+		return 0;
+	}
+	WeaponBagClass *w = o2->Get_Weapon_Bag();
 	if ((w->Get_Index()) && (w->Get_Index() < w->Get_Count()))
 	{
 		return Get_Wide_Translated_String(w->Peek_Weapon(w->Get_Index())->Get_Definition()->IconNameID);
@@ -100,21 +105,26 @@
 
 SCRIPTS_API const char *Get_Translated_Weapon(GameObject *obj,int position)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return newstr("");
 	}
-	GameObject *o = As_ArmedGameObj(obj);
+	PhysicalGameObj *o = obj->As_PhysicalGameObj();
 	if (!o)
 	{
 		return newstr("");
 	}
-	WeaponBagClass *w = ((ArmedGameObj *)o)->Get_Weapon_Bag();
+	ArmedGameObj *o2 = o->As_ArmedGameObj();
+	if (!o2)
+	{
+		return newstr("");
+	}
+	WeaponBagClass *w = o2->Get_Weapon_Bag();
 	if ((position) && (position < w->Get_Count()))
 	{
 		return Get_Translated_String(w->Peek_Weapon(position)->Get_Definition()->IconNameID);
 	}
-	return newstr("No String");
+	return newstr("");
 }
 
 SCRIPTS_API const char *Get_Team_Name(int Team)
@@ -132,11 +142,11 @@
 
 SCRIPTS_API const wchar_t *Get_Wide_Vehicle_Name(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return L"Vehicle";
 	}
-	VehicleGameObj *o = (VehicleGameObj *)As_VehicleGameObj(obj);
+	VehicleGameObj *o = obj->As_VehicleGameObj();
 	if (!o)
 	{
 		return L"Vehicle";
diff -uwr sourceold/scripts/engine_tt.cpp source/scripts/engine_tt.cpp
--- sourceold/scripts/engine_tt.cpp	2012-02-27 12:46:32.940882800 +0800
+++ source/scripts/engine_tt.cpp	2012-05-28 21:47:07.366210900 +0800
@@ -29,6 +29,9 @@
 #include "VehicleFactoryGameObjDef.h"
 #include "AirFactoryGameObj.h"
 #include "Iterator.h"
+#include "NavalFactoryGameObj.h"
+#include "SCAnnouncement.h"
+#include "cScTextObj.h"
 class WideStringClass;
 
 
@@ -68,6 +71,7 @@
 SCRIPTS_API ahh AddHostHook;
 SCRIPTS_API arh AddRefillHook;
 SCRIPTS_API allh AddLoadLevelHook;
+SCRIPTS_API allh AddPreLoadLevelHook;
 SCRIPTS_API allh AddGameOverHook;
 SCRIPTS_API allh AddThinkHook;
 SCRIPTS_API apjh AddPlayerJoinHook;
@@ -94,6 +98,8 @@
 SCRIPTS_API gvl Get_Vehicle_Limit;
 SCRIPTS_API svl Set_Air_Vehicle_Limit;
 SCRIPTS_API gvl Get_Air_Vehicle_Limit;
+SCRIPTS_API svl Set_Naval_Vehicle_Limit;
+SCRIPTS_API gvl Get_Naval_Vehicle_Limit;
 SCRIPTS_API sm Send_Message;
 SCRIPTS_API smp Send_Message_Player;
 SCRIPTS_API sw Set_Wireframe_Mode;
@@ -118,6 +124,8 @@
 SCRIPTS_API geo GetExplosionObj;
 SCRIPTS_API seo SetExplosionObj;
 SCRIPTS_API uno Update_Network_Object;
+SCRIPTS_API sct Send_Client_Text;
+SCRIPTS_API sca Send_Client_Announcement;
 SCRIPTS_API dod Do_Objectives_Dlg;
 SCRIPTS_API sl Set_Player_Limit;
 SCRIPTS_API gl Get_Player_Limit;
@@ -155,8 +163,11 @@
 SCRIPTS_API gtc Get_Team_Credits;
 SCRIPTS_API addConnectionAcceptanceFilterType addConnectionAcceptanceFilter;
 SCRIPTS_API removeConnectionAcceptanceFilterType removeConnectionAcceptanceFilter;
+SCRIPTS_API iwu Is_WOL_User;
 SCRIPTS_API ec Evict_Client;
 SCRIPTS_API gcsh Get_Client_Serial_Hash;
+SCRIPTS_API gml Get_Tech_Level;
+SCRIPTS_API sw Set_Tech_Level;
 
 SCRIPTS_API bool Can_Team_Build_Vehicle(int Team)
 {
@@ -188,10 +199,10 @@
 
 SCRIPTS_API void Send_Message_Team(int team,unsigned int red,unsigned int green,unsigned int blue,const char *msg)
 {
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_SmartGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if ((Get_Object_Type(o) == team) || (team == 2))
@@ -205,10 +216,10 @@
 
 SCRIPTS_API void Set_Obj_Radar_Blip_Shape_Team(int Team,GameObject *obj,int shape)
 {
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_SmartGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if ((Get_Object_Type(o) == Team) || (Team == 2))
@@ -222,10 +233,10 @@
 
 SCRIPTS_API void Set_Obj_Radar_Blip_Color_Team(int Team,GameObject *obj,int color)
 {
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_SmartGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if ((Get_Object_Type(o) == Team) || (Team == 2))
@@ -239,15 +250,15 @@
 
 SCRIPTS_API void Set_Occupants_Fade(GameObject *obj,float red,float green,float blue,float opacity)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	if (!As_VehicleGameObj(obj))
+	if (!obj->As_VehicleGameObj())
 	{
 		return;
 	}
-	VehicleGameObj *o = (VehicleGameObj *)obj;
+	VehicleGameObj *o = obj->As_VehicleGameObj();
 	int x = o->Get_Definition().Get_Seat_Count();
 	for (int i = 0;i < x;i++)
 	{
@@ -261,10 +272,10 @@
 
 SCRIPTS_API void Enable_Team_Radar(int Team,bool Enable)
 {
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_SmartGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if ((Get_Object_Type(o) == Team) || (Team == 2))
@@ -278,14 +289,14 @@
 
 SCRIPTS_API void Create_Sound_Team(const char *soundname,const Vector3 & position,GameObject *obj,int team)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_SmartGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if ((Get_Object_Type(o) == team) || (team == 2))
@@ -299,10 +310,10 @@
 
 SCRIPTS_API void Create_2D_Sound_Team(const char *soundname,int team)
 {
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_SmartGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if ((Get_Object_Type(o) == team) || (team == 2))
@@ -316,10 +327,10 @@
 
 SCRIPTS_API void Create_2D_WAV_Sound_Team(const char *soundname,int team)
 {
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_SmartGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if ((Get_Object_Type(o) == team) || (team == 2))
@@ -333,14 +344,14 @@
 
 SCRIPTS_API void Create_3D_WAV_Sound_At_Bone_Team(const char *soundname,GameObject *obj,const char *bonename,int team)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_SmartGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if ((Get_Object_Type(o) == team) || (team == 2))
@@ -354,14 +365,14 @@
 
 SCRIPTS_API void Create_3D_Sound_At_Bone_Team(const char *soundname,GameObject *obj,const char *bonename,int team)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<SoldierGameObj> *x = GameObjManager::StarGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_SmartGameObj(x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if ((Get_Object_Type(o) == team) || (team == 2))
@@ -820,27 +831,9 @@
 	Set_Special_Base_Destruction();
 }
 
-bool Vehicle_Preset_Is_Air(int preset)
-{
-	DefinitionClass *def = Find_Definition(preset);
-	if (!def)
-	{
-		return false;
-	}
-	if (def->Get_Class_ID() == 12304)
-	{
-		VehicleGameObjDef *def2 = (VehicleGameObjDef *)def;
-		if (def2->Get_Type() == VEHICLE_TYPE_FLYING)
-		{
-			return true;
-		}
-	}
-	return false;
-}
-
 bool SCRIPTS_API Create_Vehicle(const char *Preset_Name,float Delay,GameObject *Owner,int Team)
 {
-	if (Get_Vehicle(Owner))
+	if (Owner && Get_Vehicle(Owner))
 	{
 		return false;
 	}
@@ -857,27 +850,27 @@
 	{
 		vf = bg2->As_VehicleFactoryGameObj();
 	}
-	if (!vf && !Vehicle_Preset_Is_Air(preset))
+	if (!vf && !Vehicle_Preset_Is_Air(preset) && !Vehicle_Preset_Is_Naval(preset))
 	{
 		return false;
 	}
-	if (vf && ((vf->Is_Destroyed()) || (vf->Is_Busy())))
+	if (vf && ((!vf->Is_Available())))
 	{
-		if ((!Vehicle_Preset_Is_Air(preset)) || (!vf->Get_Definition().Get_Build_Ground_Only()))
+		if (((!Vehicle_Preset_Is_Air(preset)) || (!vf->Get_Definition().Get_Build_Ground_Only())) && !Vehicle_Preset_Is_Naval(preset))
 		{
 			return false;
 		}
 	}
-	if (vf && (!Vehicle_Preset_Is_Air(preset) || !vf->Get_Definition().Get_Build_Ground_Only()))
+	if (vf && (!Vehicle_Preset_Is_Air(preset) || !vf->Get_Definition().Get_Build_Ground_Only()) && !Vehicle_Preset_Is_Naval(preset))
 	{
 		float delay = 5.0;
 		if (!base->Is_Base_Powered())
 		{
 			delay *= Get_Build_Time_Multiplier(Team);
 		}
-		vf->Request_Vehicle(preset,delay,Owner->As_SoldierGameObj());
+		vf->Request_Vehicle(preset,delay,Owner ? Owner->As_SoldierGameObj() : 0);
 	}
-	else
+	else if (Vehicle_Preset_Is_Air(preset))
 	{
 		BuildingGameObj *bg = ((BuildingGameObj *)base->Find_Building(BuildingConstants::TYPE_HELIPAD));
 		AirFactoryGameObj *af = 0;
@@ -885,15 +878,32 @@
 		{
 			af = bg->As_AirFactoryGameObj();
 		}
-		if (af && !af->Is_Destroyed() && !af->Is_Busy() && Vehicle_Preset_Is_Air(preset))
+		if (af && af->Is_Available() && Vehicle_Preset_Is_Air(preset))
 		{
-			af->Create_Vehicle(preset,Owner->As_SoldierGameObj());
+			af->Create_Vehicle(preset,Owner ? Owner->As_SoldierGameObj() : 0);
 		}
 		else
 		{
 			return false;
 		}
 	}
+	else
+	{
+		BuildingGameObj *bg = ((BuildingGameObj *)base->Find_Building(BuildingConstants::TYPE_NAVAL_FACTORY));
+		NavalFactoryGameObj *af = 0;
+		if (bg)
+		{
+			af = bg->As_NavalFactoryGameObj();
+		}
+		if (!af || !af->Is_Available() || !af->Can_Spawn(preset) || !Vehicle_Preset_Is_Naval(preset))
+		{
+			return false;
+		}
+		else
+		{
+			af->Create_Vehicle(preset,Owner ? Owner->As_SoldierGameObj() : 0);
+		}
+	}
 	return true;
 }
 
@@ -909,10 +919,39 @@
 		{
 			if (strcmp(fname,name) == 0)
 			{
-				ConsoleFunctionList.Delete(consoleFunction);
+				ConsoleFunctionList.DeleteObj(*consoleFunction);
+			}
+		}
+	}
+}
+
+SCRIPTS_API void cScTextObj::Set_Dirty_Bit_For_Team(DIRTY_BIT value, int teamId)
+{
+	TT_FOREACH(player, *Get_Player_List())
+	{
+		if (player->IsActive && player->PlayerType == teamId)
+			Set_Object_Dirty_Bit(player->PlayerId, value, true);
+	}
+}
+
+SCRIPTS_API void cNetEvent::Set_Object_Dirty_Bit_For_Version(float version,DIRTY_BIT dirty_bit, bool onoff)
+{
+	for (int clientId = 1; clientId < 128; ++clientId)
+	{
+		if (Get_Client_Version(clientId) >= version)
+		{
+			Set_Object_Dirty_Bit(clientId,dirty_bit,onoff);
 			}
 		}
 	}
+
+SCRIPTS_API void SCAnnouncement::Set_Dirty_Bit_For_Team(DIRTY_BIT value, int teamId)
+{
+	TT_FOREACH(player, *Get_Player_List())
+	{
+		if (player->IsActive && player->PlayerType == teamId)
+			Set_Object_Dirty_Bit(player->PlayerId, value, true);
+	}
 }
 
 RENEGADE_FUNCTION
@@ -922,3 +961,7 @@
 RENEGADE_FUNCTION
 SCRIPTS_API void Verbose_Help_File()
 AT2(0x004284F0,0x00428670);
+
+RENEGADE_FUNCTION
+SCRIPTS_API void ScriptableGameObj::Add_Observer( GameObjObserverClass * observer )
+AT2(0x006B6C70,0x006B6510);
diff -uwr sourceold/scripts/engine_tt.h source/scripts/engine_tt.h
--- sourceold/scripts/engine_tt.h	2012-02-27 12:46:32.867640600 +0800
+++ source/scripts/engine_tt.h	2012-05-28 21:47:07.505859300 +0800
@@ -21,7 +21,8 @@
 #include "cPlayer.h"
 class ConnectionAcceptanceFilter;
 class WideStringClass;
-
+class cScTextObj;
+class SCAnnouncement;
 //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);
@@ -133,6 +134,9 @@
 typedef void (*ggd) (HashTemplateClass<StringClass, GameDefinition> &definitions);
 typedef SList<cPlayer> *(*gpl) ();
 typedef void (*uno) (NetworkObjectClass *obj);
+typedef cScTextObj *(*sct) (const WideStringClass& message, TextMessageEnum type, bool popup, int senderId, int receiverId, bool dodirtybit, bool doact);
+typedef SCAnnouncement *(*sca) (int _receiptientId, int _senderId, int _translationId, AnnouncementEnum _type, int _emoticonId, bool dodirtybit, bool doact);
+typedef bool (*iwu) (wchar_t *WideName);
 SCRIPTS_API extern gpl Get_Player_List;
 SCRIPTS_API extern gcmi Get_Current_Map_Index;
 SCRIPTS_API extern gm Get_Map;
@@ -165,6 +169,7 @@
 SCRIPTS_API extern rkh RemoveKeyHook;
 SCRIPTS_API extern gcmt GetCurrentMusicTrack;
 SCRIPTS_API extern allh AddLoadLevelHook;
+SCRIPTS_API extern allh AddPreLoadLevelHook;
 SCRIPTS_API extern allh AddGameOverHook;
 SCRIPTS_API extern allh AddThinkHook;
 SCRIPTS_API extern apjh AddPlayerJoinHook;
@@ -210,6 +215,8 @@
 SCRIPTS_API extern gvl Get_Vehicle_Limit;
 SCRIPTS_API extern svl Set_Air_Vehicle_Limit;
 SCRIPTS_API extern gvl Get_Air_Vehicle_Limit;
+SCRIPTS_API extern svl Set_Naval_Vehicle_Limit;
+SCRIPTS_API extern gvl Get_Naval_Vehicle_Limit;
 SCRIPTS_API extern sm Send_Message;
 SCRIPTS_API extern smp Send_Message_Player;
 SCRIPTS_API extern sw Set_Wireframe_Mode;
@@ -234,6 +241,8 @@
 SCRIPTS_API extern geo GetExplosionObj;
 SCRIPTS_API extern seo SetExplosionObj;
 SCRIPTS_API extern uno Update_Network_Object;
+SCRIPTS_API extern sct Send_Client_Text;
+SCRIPTS_API extern sca Send_Client_Announcement;
 SCRIPTS_API extern dod Do_Objectives_Dlg;
 SCRIPTS_API extern sl Set_Player_Limit;
 SCRIPTS_API extern gl Get_Player_Limit;
@@ -259,6 +268,9 @@
 SCRIPTS_API extern gdw Get_Damage_Warhead;
 SCRIPTS_API extern addConnectionAcceptanceFilterType addConnectionAcceptanceFilter;
 SCRIPTS_API extern removeConnectionAcceptanceFilterType removeConnectionAcceptanceFilter;
+SCRIPTS_API extern iwu Is_WOL_User;
+SCRIPTS_API extern gml Get_Tech_Level;
+SCRIPTS_API extern sw Set_Tech_Level;
 
 class SCRIPTS_API JFW_Key_Hook_Base : public ScriptImpClass {
 public:
diff -uwr sourceold/scripts/engine_ttdef.h source/scripts/engine_ttdef.h
--- sourceold/scripts/engine_ttdef.h	2012-02-18 09:50:34.036132800 +0800
+++ source/scripts/engine_ttdef.h	2012-04-14 04:09:47.176757800 +0800
@@ -24,6 +24,12 @@
 	TEXT_MESSAGE_PRIVATE,
 	TEXT_MESSAGE_TMSG, //special extra value for the TMSG console command
 };
+enum AnnouncementEnum
+{
+	ANNOUNCE_PUBLIC,
+	ANNOUNCE_TEAM,
+	ANNOUNCE_PRIVATE,
+};
 typedef bool (*ChatHook) (int PlayerID,TextMessageEnum Type,const wchar_t *Message,int recieverID);
 typedef bool (*HostHook) (int PlayerID,TextMessageEnum Type,const char *Message);
 typedef void (*ObjectCreateHook) (void *data,GameObject *obj);
@@ -34,7 +40,7 @@
 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);
 typedef bool (*RefillHook) (GameObject *purchaser);
-typedef bool (*RadioHook) (int PlayerType, int PlayerID, int AnnouncementID, int IconID, uint8 AnnouncementType);
+typedef bool (*RadioHook) (int PlayerType, int PlayerID, int AnnouncementID, int IconID, AnnouncementEnum AnnouncementType);
 typedef bool (*StockDamageHook) (PhysicalGameObj* damager, PhysicalGameObj* target, float damage, uint warheadId);
 typedef bool (*TtDamageHook) (PhysicalGameObj* damager, PhysicalGameObj* target, const AmmoDefinitionClass* ammo, const char* bone);
 
diff -uwr sourceold/scripts/engine_vector.h source/scripts/engine_vector.h
--- sourceold/scripts/engine_vector.h	2011-11-28 09:12:59.829890600 +0800
+++ source/scripts/engine_vector.h	2012-05-01 21:07:11.413085900 +0800
@@ -1122,7 +1122,7 @@
 		{
 			char buffer[256];
 			sprintf(buffer, "%d memory leaks found in " __FUNCTION__ "\n", TotalObjectCount - FreeObjectCount);
-			OutputDebugString(buffer);
+			OutputDebugStringA(buffer);
 			// TODO: There are quite a few mem leaks of this kind. Fix them.
 		}
 
diff -uwr sourceold/scripts/engine_weap.cpp source/scripts/engine_weap.cpp
--- sourceold/scripts/engine_weap.cpp	2011-10-11 23:03:09.419921800 +0800
+++ source/scripts/engine_weap.cpp	2012-05-23 10:59:15.286132800 +0800
@@ -44,18 +44,19 @@
 }
 
 
-
+#ifndef TT_EXPORTS
 RENEGADE_FUNCTION
 void C4GameObj::Defuse()
 AT2(0x0070D610,0x0070CBD0);
+#endif
 
 SCRIPTS_API int Get_Current_Bullets(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -81,7 +82,7 @@
 	int at = AmmoDef->AmmoType;
 	if (!Owner && Player && AmmoDef && (1 != at))
 	{
-		TT_FOREACH(object, (SList<SmartGameObj>&)GameObjManager::SmartGameObjList)
+		TT_FOREACH(object, GameObjManager::StarGameObjList)
 		{
 			if (object->Get_Player_Data() == Player)
 			{
@@ -104,11 +105,11 @@
 
 SCRIPTS_API int Get_Current_Clip_Bullets(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -129,11 +130,11 @@
 
 SCRIPTS_API int Get_Current_Total_Bullets(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -160,11 +161,11 @@
 
 SCRIPTS_API int Get_Position_Bullets(GameObject *obj,int position)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -185,11 +186,11 @@
 
 SCRIPTS_API int Get_Position_Clip_Bullets(GameObject *obj,int position)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -210,11 +211,11 @@
 
 SCRIPTS_API int Get_Position_Total_Bullets(GameObject *obj, int position)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -241,11 +242,11 @@
 
 SCRIPTS_API int Get_Bullets(GameObject *obj,const char *weapon)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -273,11 +274,11 @@
 
 SCRIPTS_API int Get_Clip_Bullets(GameObject *obj,const char *weapon)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -305,11 +306,11 @@
 
 SCRIPTS_API int Get_Total_Bullets(GameObject *obj,const char *weapon)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -343,11 +344,11 @@
 
 SCRIPTS_API int Get_Current_Max_Bullets(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -368,11 +369,11 @@
 
 SCRIPTS_API int Get_Current_Clip_Max_Bullets(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -393,11 +394,11 @@
 
 SCRIPTS_API int Get_Current_Total_Max_Bullets(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -424,11 +425,11 @@
 
 SCRIPTS_API int Get_Position_Max_Bullets(GameObject *obj, int position)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -449,11 +450,11 @@
 
 SCRIPTS_API int Get_Position_Clip_Max_Bullets(GameObject *obj, int position)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -474,11 +475,11 @@
 
 SCRIPTS_API int Get_Position_Total_Max_Bullets(GameObject *obj,int position)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -505,11 +506,11 @@
 
 SCRIPTS_API int Get_Max_Bullets(GameObject *obj,const char *weapon)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -537,11 +538,11 @@
 
 SCRIPTS_API int Get_Max_Clip_Bullets(GameObject *obj,const char *weapon)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -569,11 +570,11 @@
 
 SCRIPTS_API int Get_Max_Total_Bullets(GameObject *obj,const char *weapon)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -644,11 +645,11 @@
 
 SCRIPTS_API const WeaponDefinitionClass *Get_Current_Weapon_Definition(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -673,11 +674,11 @@
 
 SCRIPTS_API const WeaponDefinitionClass *Get_Position_Weapon_Definition(GameObject *obj,int position)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -702,7 +703,11 @@
 
 SCRIPTS_API const char *Get_Powerup_Weapon_By_Obj(GameObject *Powerup)
 {
-	const DefinitionClass *powerupdef = Get_Definition(Powerup);
+	if (!Powerup)
+	{
+		return "None";
+	}
+	const DefinitionClass *powerupdef = &Powerup->Get_Definition();
 	PowerUpGameObjDef *c = (PowerUpGameObjDef *)powerupdef;
 	if (!c)
 	{
@@ -718,11 +723,11 @@
 
 SCRIPTS_API int Get_Current_Weapon_Style(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -743,11 +748,11 @@
 
 SCRIPTS_API int Get_Position_Weapon_Style(GameObject *obj, int position)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -768,11 +773,11 @@
 
 SCRIPTS_API int Get_Weapon_Style(GameObject *obj,const char *weapon)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -800,11 +805,11 @@
 
 SCRIPTS_API void Disarm_Beacon(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return;
@@ -820,11 +825,11 @@
 
 SCRIPTS_API GameObject *Get_Beacon_Planter(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -855,7 +860,7 @@
 }
 
 
-BeaconGameObj* Find_Nearest_Beacon(const Vector3& position, int team)
+SCRIPTS_API BeaconGameObj* Find_Nearest_Beacon(const Vector3& position, int team)
 {
 	BeaconGameObj* beacon = nullptr;
 	float min_distance = std::numeric_limits<float>::infinity();
@@ -882,11 +887,11 @@
 
 SCRIPTS_API void Disarm_C4(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return;
@@ -981,35 +986,35 @@
 
 SCRIPTS_API const char *Get_Current_Weapon(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
-		return 0;
+		return "None";
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
-		return 0;
+		return "None";
 	}
 	ArmedGameObj *o3 = o2->As_ArmedGameObj();
 	if (!o3)
 	{
-		return 0;
+		return "None";
 	}
 	WeaponBagClass *w = o3->Get_Weapon_Bag();
 	if ((w->Get_Index()) && (w->Get_Index() < w->Get_Count()))
 	{
 		return w->Peek_Weapon(w->Get_Index())->Get_Name();
 	}
-	return 0;
+	return "None";
 }
 
 SCRIPTS_API int Get_Weapon_Count(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -1025,35 +1030,35 @@
 
 SCRIPTS_API const char *Get_Weapon(GameObject *obj,int position)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
-		return 0;
+		return "None";
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
-		return 0;
+		return "None";
 	}
 	ArmedGameObj *o3 = o2->As_ArmedGameObj();
 	if (!o3)
 	{
-		return 0;
+		return "None";
 	}
 	WeaponBagClass *w = o3->Get_Weapon_Bag();
 	if ((position) && (position < w->Get_Count()))
 	{
 		return (w->Peek_Weapon(position)->Get_Name());
 	}
-	return 0;
+	return "None";
 }
 
 SCRIPTS_API bool Has_Weapon(GameObject *obj,const char *weapon)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -1136,11 +1141,11 @@
 
 SCRIPTS_API int Get_C4_Mode(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -1155,11 +1160,11 @@
 
 SCRIPTS_API GameObject *Get_C4_Planter(GameObject *obj)
 {	
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -1175,11 +1180,11 @@
 
 SCRIPTS_API GameObject *Get_C4_Attached(GameObject *obj)
 {	
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2)
 	{
 		return 0;
@@ -1193,12 +1198,12 @@
 	return (GameObject *)o3->Get_Stuck_Object();
 }
 
-WeaponClass* ArmedGameObj::Get_Weapon()
+SCRIPTS_API WeaponClass* ArmedGameObj::Get_Weapon()
 {
 	return WeaponBag->Get_Weapon();
 }
 
-int	WeaponClass::Get_Total_Rounds()
+SCRIPTS_API int	WeaponClass::Get_Total_Rounds()
 {
 	if (InventoryRounds < 0)
 	{
@@ -1207,7 +1212,7 @@
 	return ClipRounds + InventoryRounds;
 }
 
-float WeaponClass::Get_Range( void )
+SCRIPTS_API float WeaponClass::Get_Range( void )
 {
 	return ( PrimaryAmmoDefinition != NULL ) ? PrimaryAmmoDefinition->Range : 0;
 }
diff -uwr sourceold/scripts/engine_weap.h source/scripts/engine_weap.h
--- sourceold/scripts/engine_weap.h	2011-10-11 21:53:12.073242100 +0800
+++ source/scripts/engine_weap.h	2012-05-23 11:32:21.548828100 +0800
@@ -15,7 +15,7 @@
 class AmmoDefinitionClass;
 class WeaponDefinitionClass;
 class ExplosionDefinitionClass;
-
+class BeaconGameObj;
 SCRIPTS_API int Get_Current_Bullets(GameObject *obj); //Get loaded bullets for an objects current gun
 SCRIPTS_API int Get_Current_Clip_Bullets(GameObject *obj); //Get clip/backpack bullets for an objects current gun
 SCRIPTS_API int Get_Current_Total_Bullets(GameObject *obj); //Get total bullets for an objects current gun
@@ -72,5 +72,5 @@
 SCRIPTS_API GameObject *Get_C4_Planter(GameObject *obj); //Gets the planter of a C4GameObj
 SCRIPTS_API GameObject *Get_C4_Attached(GameObject *obj); //Gets the object a C4GameObj is attached to (if any)
 SCRIPTS_API GameObject *Get_Beacon_Planter(GameObject *obj); //Gets the planter of a BeaconGameObj
-
+SCRIPTS_API BeaconGameObj* Find_Nearest_Beacon(const Vector3& position, int team); //Find the nearest beacon to a position
 #endif
diff -uwr sourceold/scripts/gmbuilding.cpp source/scripts/gmbuilding.cpp
--- sourceold/scripts/gmbuilding.cpp	2011-10-11 23:04:38.933593700 +0800
+++ source/scripts/gmbuilding.cpp	2012-04-24 13:34:24.211914000 +0800
@@ -85,7 +85,12 @@
 							Create_2D_WAV_Sound_Team("m00bnol_dsgn0008i1evan_snd.wav",team);
 							Commands->Start_Timer(obj,this,30.0f,22223);
 						}
-						else if (Is_VehicleFactory(obj))
+						else
+						{
+							BuildingGameObj *b = obj->As_BuildingGameObj();
+							if (b)
+							{
+								if (b->As_WarFactoryGameObj())
 						{
 							char repairmsg[250];
 							const char *bld = Get_Translated_Preset_Name_Ex(obj);
@@ -102,7 +107,7 @@
 							}
 							Commands->Start_Timer(obj,this,30.0f,22223);
 						}
-						else if (Is_SoldierFactory(obj))
+								else if (b->As_SoldierFactoryGameObj())
 						{
 							char repairmsg[250];
 							const char *bld = Get_Translated_Preset_Name_Ex(obj);
@@ -111,7 +116,7 @@
 							delete[] bld;
 							if (team == 0)
 							{
-								Create_2D_WAV_Sound_Team("m00bnhn_dsgn0016i1evan_snd.wav",team);
+										Create_2D_WAV_Sound_Team("m00bnhn_dsgn0015i1evag_snd.wav",team);
 							}
 							else if (team == 1)
 							{
@@ -119,7 +124,7 @@
 							}
 							Commands->Start_Timer(obj,this,30.0f,22223);
 						}
-						else if (Is_Refinery(obj))
+								else if (b->As_RefineryGameObj())
 						{
 							char repairmsg[250];
 							const char *bld = Get_Translated_Preset_Name_Ex(obj);
@@ -136,7 +141,7 @@
 							}
 							Commands->Start_Timer(obj,this,30.0f,22223);
 						}
-						else if (Is_PowerPlant(obj))
+								else if (b->As_PowerPlantGameObj())
 						{
 							char repairmsg[250];
 							const char *bld = Get_Translated_Preset_Name_Ex(obj);
@@ -159,6 +164,8 @@
 		}
 	}
 }
+	}
+}
 
 void SSGM_Building::Timer_Expired(GameObject *obj, int number)
 {
@@ -214,7 +221,7 @@
 	delete[] str;
 	delete[] str2;
 
-	if ( (Is_ConstructionYard(obj)) || (Is_Script_Attached(obj,"TDA_ConYard_Controller")) )
+	if ( ((obj->As_BuildingGameObj() && obj->As_BuildingGameObj()->As_ConstructionYardGameObj())) || (Is_Script_Attached(obj,"TDA_ConYard_Controller")) )
 	{
 		if (Get_Object_Type(obj) == 1)
 		{
@@ -227,7 +234,7 @@
 			Create_2D_WAV_Sound_Team("m00bncy_kill0002i1evag_snd.wav",1);
 		}
 	}
-	else if (Is_ComCenter(obj))
+	else if (obj->As_BuildingGameObj() && obj->As_BuildingGameObj()->As_ComCenterGameObj())
 	{
 		if (Get_Object_Type(obj) == 1)
 		{
@@ -240,7 +247,7 @@
 			Create_2D_WAV_Sound_Team("m00bncc_kill0002i1evag_snd.wav",1);
 		}
 	}
-	else if (Is_RepairBay(obj))
+	else if (obj->As_BuildingGameObj() && obj->As_BuildingGameObj()->As_RepairBayGameObj())
 	{
 		if (Get_Object_Type(obj) == 1)
 		{
diff -uwr sourceold/scripts/gmgame.cpp source/scripts/gmgame.cpp
--- sourceold/scripts/gmgame.cpp	2012-02-18 09:50:34.050781200 +0800
+++ source/scripts/gmgame.cpp	2012-05-16 00:26:42.453125000 +0800
@@ -97,13 +97,13 @@
 
 const char *Get_Translated_Preset_Name_Part(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return newstr("None");
 	}
 	const char *preset = Get_Translated_Preset_Name_Ini(obj);
 	StringClass preset2 = preset;
-	if (Is_Building(obj) || Is_DecorationPhys(obj) || Is_Harvester_Preset(obj))
+	if (obj->As_BuildingGameObj() || (obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->Peek_Physical_Object() && obj->As_PhysicalGameObj()->Peek_Physical_Object()->As_DecorationPhysClass()) || Is_Harvester_Preset(obj))
 	{
 		const char *str = Get_Team_Name(Get_Object_Type(obj));
 		if (!stristr(preset,str))
@@ -120,7 +120,11 @@
 
 SCRIPTS_API const char *Get_Translated_Preset_Name_Ini(GameObject *obj)
 {
-	if (Is_C4(obj))
+	if (!obj)
+	{
+		return newstr("");
+	}
+	if (obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->As_C4GameObj())
 	{
 		if (Get_C4_Mode(obj) == 1)
 		{
@@ -153,7 +157,7 @@
 
 SCRIPTS_API const char *Get_Translated_Preset_Name_Ex(GameObject *obj)
 {
-	if (!Commands->Get_ID(obj) || (!obj))
+	if (!obj)
 	{
 		return newstr("None");
 	}
@@ -245,6 +249,7 @@
 	h->hook = ObjectCreateHook;
 	AddObjectCreateHook(h);
 	AddLoadLevelHook(LoadLevelHook);
+	AddPreLoadLevelHook(PreLoadLevelHook);
 	AddGameOverHook(GameOverHook);
 	AddPlayerJoinHook(PlayerJoinHook);
 	AddPlayerLeaveHook(PlayerLeaveHook);
@@ -369,7 +374,7 @@
 	return true;
 }
 
-bool SSGMGameManager::RadioHook(int PlayerType, int PlayerID, int AnnouncementID, int IconID, uint8 AnnouncementType)
+bool SSGMGameManager::RadioHook(int PlayerType, int PlayerID, int AnnouncementID, int IconID, AnnouncementEnum AnnouncementType)
 {
 	for (int i = 0;i < RegisteredEvents[EVENT_RADIO_HOOK].Count();i++)
 	{
@@ -416,18 +421,18 @@
 			Commands->Apply_Damage(obj,99999,"Death",0);
 		}
 	}
-	else if (Is_Powerup(obj))
+	else if (obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->As_PowerUpGameObj())
 	{
 		if (PlayPowerupSounds)
 		{
 			Attach_Script_Once(obj,"SSGM_Powerup","");
 		}
 	}
-	else if (Is_Beacon(obj))
+	else if (obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->As_BeaconGameObj())
 	{
 		Attach_Script_Once(obj,"SSGM_Log_Beacon","");
 	}
-	else if (Is_C4(obj))
+	else if (obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->As_C4GameObj())
 	{
 		Attach_Script_Once(obj,"SSGM_Log_Mine","");
 	}
@@ -683,6 +688,14 @@
 	Release_INI(SSGMIni);
 }
 
+void SSGMGameManager::PreLoadLevelHook()
+{
+	for (int i = 0;i < RegisteredEvents[EVENT_PRE_LOAD_LEVEL_HOOK].Count();i++)
+	{
+		RegisteredEvents[EVENT_PRE_LOAD_LEVEL_HOOK][i]->OnPreLoadLevel();
+	}
+}
+
 void SSGMGameManager::LoadLevelHook()
 {
 	RawFileClass file("SSGM.ini");
@@ -710,23 +723,23 @@
 		BuildingGameObj *o = x->Data();
 		if (o)
 		{
-			if (DisablePowerPlants && o->As_PowerPlantGameObj())
+			if (DisablePowerPlants && o->Get_Definition().Get_Type() == BuildingConstants::TYPE_POWER_PLANT)
 			{
 				Commands->Apply_Damage(o,99999,"Death",0);
 			}
-			else if (DisableRefineries && o->As_RefineryGameObj())
+			else if (DisableSoldierFactories && o->Get_Definition().Get_Type() == BuildingConstants::TYPE_SOLDIER_FACTORY)
 			{
 				Commands->Apply_Damage(o,99999,"Death",0);
 			}
-			else if (DisableSoldierFactories && o->As_SoldierFactoryGameObj())
+			else if (DisableVehicleFactories && o->Get_Definition().Get_Type() == BuildingConstants::TYPE_VEHICLE_FACTORY)
 			{
 				Commands->Apply_Damage(o,99999,"Death",0);
 			}
-			else if (DisableVehicleFactories && o->As_VehicleFactoryGameObj())
+			else if (DisableRefineries && o->Get_Definition().Get_Type() == BuildingConstants::TYPE_REFINERY)
 			{
 				Commands->Apply_Damage(o,99999,"Death",0);
 			}
-			else if (DisableRepairPads && o->As_RepairBayGameObj())
+			else if (DisableCommCenters && o->Get_Definition().Get_Type() == BuildingConstants::TYPE_COM_CENTER)
 			{
 				Commands->Apply_Damage(o,99999,"Death",0);
 			}
@@ -734,11 +747,15 @@
 			{
 				Commands->Apply_Damage(o,99999,"Death",0);
 			}
-			else if (DisableCommCenters && o->As_ComCenterGameObj())
+			else if (DisableShrines && o->Get_Definition().Get_Type() == BuildingConstants::TYPE_SHRINE)
 			{
 				Commands->Apply_Damage(o,99999,"Death",0);
 			}
-			else if (DisableConstructionYards && o->As_ConstructionYardGameObj())
+			else if (DisableHelipads && o->Get_Definition().Get_Type() == BuildingConstants::TYPE_HELIPAD)
+			{
+				Commands->Apply_Damage(o,99999,"Death",0);
+			}
+			else if (DisableConstructionYards && o->Get_Definition().Get_Type() == BuildingConstants::TYPE_CONYARD)
 			{
 				Commands->Apply_Damage(o,99999,"Death",0);
 			}
@@ -746,11 +763,15 @@
 			{
 				Commands->Apply_Damage(o,99999,"Death",0);
 			}
-			else if (DisableShrines && o->Get_Definition().Get_Type() == BuildingConstants::TYPE_SHRINE)
+			else if (DisableTechCenters && o->Get_Definition().Get_Type() == BuildingConstants::TYPE_TECH_CENTER)
 			{
 				Commands->Apply_Damage(o,99999,"Death",0);
 			}
-			else if (DisableHelipads && o->Get_Definition().Get_Type() == BuildingConstants::TYPE_HELIPAD)
+			else if (DisableNavalFactories && o->Get_Definition().Get_Type() == BuildingConstants::TYPE_NAVAL_FACTORY)
+			{
+				Commands->Apply_Damage(o,99999,"Death",0);
+			}
+			else if (DisableSpecials && o->Get_Definition().Get_Type() == BuildingConstants::TYPE_SPECIAL)
 			{
 				Commands->Apply_Damage(o,99999,"Death",0);
 			}
@@ -761,15 +782,15 @@
 		}
 		x = x->Next();
 	}
-	SLNode<SmartGameObj> *x2 = GameObjManager::SmartGameObjList.Head();
+	SLNode<VehicleGameObj> *x2 = GameObjManager::VehicleGameObjList.Head();
 	while (x2)
 	{
-		SmartGameObj *o = x2->Data();
+		VehicleGameObj *o = x2->Data();
 		if (o)
 		{
-			if (o->As_VehicleGameObj())
+			if (o)
 			{
-				if (o->As_VehicleGameObj()->Is_Turret())
+				if (o->Is_Turret())
 				{
 					if (DisableBaseDefenses)
 					{
@@ -1101,6 +1122,8 @@
 
 void SSGM_Log_Mine::Created(GameObject *obj)
 {
+	WasDetonated = false;
+	WasDisarmed = false;
 	Vector3 pos = Commands->Get_Position(obj);
 	SSGMGameLog::Log_Gamelog("CREATED;OBJECT;%d;%s;%d;%d;%d;%d;%d;%d;%d;%d", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), int(pos.Y),int(pos.X),int(pos.Z), int(Commands->Get_Facing(obj)), int(Commands->Get_Max_Health(obj)), int(Commands->Get_Max_Shield_Strength(obj)), Get_Object_Type(obj),Commands->Get_ID(Get_C4_Planter(obj)));
 }
@@ -1110,6 +1133,12 @@
 	Vector3	pos = Commands->Get_Position(obj);
 	if (!WasDisarmed && WasDetonated)
 	{
+		StringClass str;
+		const char *str4 = Get_Team_Name(Get_Object_Type(obj));
+		const char *str5 = Get_Translated_Preset_Name_Ini(obj);
+		const char *str6 = Get_Translated_Preset_Name_Ini(Get_C4_Attached(obj));
+		str.Format("%s %s has detonated (Owner: %ls - Attached to: %s)",str4,str5,Get_Wide_Player_Name(Get_C4_Planter(obj)),str6);
+		SSGMGameLog::Log_Message(str,"_C4");
 		SSGMGameLog::Log_Gamelog("DETONATED;OBJECT;%d;%s;%d;%d;%d", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), int(pos.Y), int(pos.X), int(pos.Z));
 	}
 	SSGMGameLog::Log_Gamelog("DESTROYED;OBJECT;%d;%s;%d;%d;%d", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), int(pos.Y), int(pos.X), int(pos.Z));
@@ -1137,6 +1166,15 @@
 	const char *str = Get_Translated_Preset_Name_Ex(obj);
 	const char *str2 = Get_Translated_Preset_Name_Ex(killer);
 	SSGMGameLog::Log_Gamelog("KILLED;OBJECT;%d;%s;%d;%d;%d;%d;%d;%s;%d;%d;%d;%d;%s;%s;%s",Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), int(victimpos.Y), int(victimpos.X), int(victimpos.Z), int(Commands->Get_Facing(obj)), Commands->Get_ID(killer),	Commands->Get_Preset_Name(killer),	int(damagerpos.Y), int(damagerpos.X), int(damagerpos.Z), int(Commands->Get_Facing(killer)),Get_Current_Weapon(killer),str,str2);
+	StringClass str3;
+	const char *str4 = Get_Team_Name(Get_Object_Type(obj));
+	const char *str5 = Get_Translated_Preset_Name_Ini(obj);
+	const char *str6 = Get_Translated_Preset_Name_Ini(Get_C4_Attached(obj));
+	str3.Format("%s %s has been disarmed by %ls (Owner: %ls - Attached to: %s)",str4,str5,Get_Wide_Player_Name(killer),Get_Wide_Player_Name(Get_C4_Planter(obj)),str6);
+	delete[] str4;
+	delete[] str5;
+	delete[] str6;
+	SSGMGameLog::Log_Message(str3,"_C4");
 	delete[] str;
 	delete[] str2;
 
@@ -1145,13 +1183,17 @@
 		if (Commands->Get_Player_Type(killer) == 0)
 		{
 			char disarmer[250];
-			sprintf(disarmer,"%ls disarmed a %s",Get_Wide_Player_Name(killer),Get_Translated_Preset_Name_Ex(obj));
+			const char *s1 = Get_Translated_Preset_Name_Ex(obj);
+			sprintf(disarmer,"%ls disarmed a %s",Get_Wide_Player_Name(killer),s1);
+			delete[] s1;
 			Send_Message_Team(0,104,234,40,disarmer);
 		}
 		else if (Commands->Get_Player_Type(killer) == 1)
 		{
 			char disarmer[250];
-			sprintf(disarmer,"%ls disarmed a %s",Get_Wide_Player_Name(killer),Get_Translated_Preset_Name_Ex(obj));
+			const char *s1 = Get_Translated_Preset_Name_Ex(obj);
+			sprintf(disarmer,"%ls disarmed a %s",Get_Wide_Player_Name(killer),s1);
+			delete[] s1;
 			Send_Message_Team(1,104,234,40,disarmer);
 		}
 	}
@@ -1185,6 +1227,13 @@
 
 void SSGM_Log_Beacon::Damaged(GameObject *obj, GameObject *damager, float amount)
 {
+	if (amount == 0 && damager == Get_Beacon_Planter(obj))
+	{
+		StringClass str3;
+		const char *str4 = Get_Translated_Preset_Name_Ini(obj);
+		str3.Format("%s has detonated",str4);
+		SSGMGameLog::Log_Message(str3,"_BEACON");
+	}
 	if (amount != 0)
 	{
 		Vector3	victimpos =	Commands->Get_Position(obj);
@@ -1200,7 +1249,9 @@
 				triggerrepairing = false;
 				int team = Commands->Get_Player_Type(damager);
 				char disarmer[250];
-				sprintf(disarmer,"%ls is disarming a %s",Get_Wide_Player_Name(damager),Get_Translated_Preset_Name_Ex(obj));
+				const char *s1 = Get_Translated_Preset_Name_Ex(obj);
+				sprintf(disarmer,"%ls is disarming a %s",Get_Wide_Player_Name(damager),s1);
+				delete[] s1;
 				Send_Message_Team(team,104,234,40,disarmer);
 				Commands->Start_Timer(obj,this,15.0f,222222);
 			}
@@ -1217,15 +1268,35 @@
 	SSGMGameLog::Log_Gamelog("KILLED;OBJECT;%d;%s;%d;%d;%d;%d;%d;%s;%d;%d;%d;%d;%s;%s;%s",Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), int(victimpos.Y), int(victimpos.X), int(victimpos.Z), int(Commands->Get_Facing(obj)), Commands->Get_ID(killer),	Commands->Get_Preset_Name(killer),	int(damagerpos.Y), int(damagerpos.X), int(damagerpos.Z), int(Commands->Get_Facing(killer)),Get_Current_Weapon(killer),str,str2);
 	delete[] str;
 	delete[] str2;
+	StringClass str3;
+	const char *str4 = Get_Translated_Preset_Name_Ini(obj);
+	str3.Format("%ls disarmed a %s",Get_Wide_Player_Name(killer),str4);
+	SSGMGameLog::Log_Message(str3,"_BEACON");
+	delete[] str4;
 
 	if (ShowExtraMessages)
 	{
 		char disarmer[250];
-		sprintf(disarmer,"%ls disarmed a %s",Get_Wide_Player_Name(killer),Get_Translated_Preset_Name_Ex(obj));
+		const char *s1 = Get_Translated_Preset_Name_Ex(obj);
+		sprintf(disarmer,"%ls disarmed a %s",Get_Wide_Player_Name(killer),s1);
+		delete[] s1;
 		Send_Message(104,234,40,disarmer);
 	}
 }
 
+void SSGM_Log_Beacon::Custom(GameObject *obj, int message, int param, GameObject *sender)
+{
+	if (message == CUSTOM_EVENT_BEACON_DEPLOYED)
+	{
+		StringClass str3;
+		const char *str4 = Get_Translated_Preset_Name_Ini(obj);
+		str3.Format("%ls deployed a %s",Get_Wide_Player_Name(sender),str4);
+		SSGMGameLog::Log_Message(str3,"_BEACON");
+		delete[] str4;
+	}
+}
+
+
 void SSGM_Powerup_Expire::Created(GameObject *obj)
 {
 	Commands->Start_Timer(obj,this,PowerupExpireTime,100);
@@ -1241,7 +1312,7 @@
 
 void SSGM_Powerup::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		if (strstr(Commands->Get_Preset_Name(obj),"CnC_POW_MineRemote_02"))
 		{
@@ -1797,7 +1868,7 @@
 
 void SSGM_Powerup_SBH::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"CnC_Nod_FlameThrower_2SF");
 	}
@@ -1805,7 +1876,7 @@
 
 void SSGM_Powerup_Havoc::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		int RandomNum = Commands->Get_Random_Int(1,4);
 		if (RandomNum == 1)
@@ -1828,21 +1899,21 @@
 }
 void SSGM_Powerup_Deadeye::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"CnC_GDI_MiniGunner_2SF");
 	}
 }
 void SSGM_Powerup_BHSniper::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"CnC_Nod_Minigunner_2SF");
 	}
 }
 void SSGM_Powerup_Sakura::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		int RandomNum = Commands->Get_Random_Int(1,2);
 		if (RandomNum == 1)
@@ -1857,7 +1928,7 @@
 }
 void SSGM_Powerup_SydneyPower::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		int RandomNum = Commands->Get_Random_Int(1,2);
 		if (RandomNum == 1)
@@ -1872,7 +1943,7 @@
 }
 void SSGM_Powerup_Raveshaw::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		int RandomNum = Commands->Get_Random_Int(1,2);
 		if (RandomNum == 1)
@@ -1887,7 +1958,7 @@
 }
 void SSGM_Powerup_Mobius::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		int RandomNum = Commands->Get_Random_Int(1,2);
 		if (RandomNum == 1)
@@ -1902,7 +1973,7 @@
 }
 void SSGM_Powerup_Mendoza::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		int RandomNum = Commands->Get_Random_Int(1,2);
 		if (RandomNum == 1)
@@ -1917,42 +1988,42 @@
 }
 void SSGM_Powerup_Hotwire::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"CnC_GDI_Engineer_2SF");
 	}
 }
 void SSGM_Powerup_Technician::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"CnC_Nod_Technician_0");
 	}
 }
 void SSGM_Powerup_Gunner::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"CnC_GDI_RocketSoldier_2SF");
 	}
 }
 void SSGM_Powerup_LCG::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"CnC_Nod_RocketSoldier_2SF");
 	}
 }
 void SSGM_Powerup_Patch::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"CnC_GDI_Grenadier_2SF");
 	}
 }
 void SSGM_Powerup_Nod_Officer::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"CnC_Nod_Minigunner_1Off");
 	}
@@ -1960,7 +2031,7 @@
 
 void SSGM_Powerup_GDI_Officer::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"CnC_GDI_MiniGunner_1Off");
 	}
@@ -1968,7 +2039,7 @@
 
 void SSGM_Powerup_GDI_Sydney::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"CnC_Sydney");
 	}
@@ -1976,7 +2047,7 @@
 
 void SSGM_Powerup_Chemwar::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"CnC_Nod_FlameThrower_1Off");
 	}
@@ -1984,7 +2055,7 @@
 
 void SSGM_Powerup_GDI_RSoldier::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"CnC_GDI_RocketSoldier_1Off");
 	}
@@ -1992,7 +2063,7 @@
 
 void SSGM_Powerup_Nod_RSoldier::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"CnC_Nod_RocketSoldier_1Off");
 	}
diff -uwr sourceold/scripts/gmgame.h source/scripts/gmgame.h
--- sourceold/scripts/gmgame.h	2012-02-18 09:50:34.061523400 +0800
+++ source/scripts/gmgame.h	2012-05-16 00:26:41.498046800 +0800
@@ -12,14 +12,16 @@
 #ifndef TT_INCLUDE_GMGAME_H
 #define TT_INCLUDE_GMGAME_H
 #include "gmplugin.h"
+#include "engine_ttdef.h"
 class SSGMGameManager {
 public:
 	static void Init();
 	static void Shutdown();
 	static bool ChatHook(int PlayerID,TextMessageEnum Type,const wchar_t *Message,int recieverID);
-	static bool RadioHook(int PlayerType, int PlayerID, int AnnouncementID, int IconID, uint8 AnnouncementType);
+	static bool RadioHook(int PlayerType, int PlayerID, int AnnouncementID, int IconID, AnnouncementEnum AnnouncementType);
 	static void ObjectCreateHook(void *data,GameObject *obj);
 	static void LoadLevelHook();
+	static void PreLoadLevelHook();
 	static void GameOverHook();
 	static void ConsoleOutputHook(const char *output);
 	static void LogFileHook(const char *output);
@@ -54,6 +56,7 @@
 	void Destroyed(GameObject *obj);
 	void Killed(GameObject *obj, GameObject *shooter);
 	void Damaged(GameObject *obj, GameObject *damager, float damage);
+	void Custom(GameObject *obj, int message, int param, GameObject *sender);
 	void Timer_Expired(GameObject *obj, int number);
 	public: void Register_Auto_Save_Variables();
 	bool triggerrepairing;
diff -uwr sourceold/scripts/gmplugin.h source/scripts/gmplugin.h
--- sourceold/scripts/gmplugin.h	2012-02-18 09:50:34.054687500 +0800
+++ source/scripts/gmplugin.h	2012-05-16 00:27:18.326171800 +0800
@@ -32,6 +32,7 @@
 	EVENT_RADIO_HOOK,
 	EVENT_STOCK_DAMAGE_HOOK,
 	EVENT_TT_DAMAGE_HOOK,
+	EVENT_PRE_LOAD_LEVEL_HOOK,
 	EVENT_COUNT
 };
 
@@ -54,9 +55,10 @@
 	virtual int OnVehiclePurchase(BaseControllerClass *base,GameObject *purchaser,unsigned int cost,unsigned int preset,const char *data) {return -1;}; //called on vehicle purchase
 	virtual int OnCharacterPurchase(BaseControllerClass *base,GameObject *purchaser,unsigned int cost,unsigned int preset,const char *data) {return -1;}; //called on character purchase
 	virtual void OnThink() {}; //called once per frame
-	virtual bool OnRadioCommand(int PlayerType, int PlayerID, int AnnouncementID, int IconID, uint8 AnnouncementType) {return true;} //called on radio command
+	virtual bool OnRadioCommand(int PlayerType, int PlayerID, int AnnouncementID, int IconID, AnnouncementEnum AnnouncementType) {return true;} //called on radio command
 	virtual bool OnStockDamage(PhysicalGameObj* damager, PhysicalGameObj* target, float damage, uint warheadId) { return true; } //called on damage from clients with version <4.0
 	virtual bool OnTtDamage(PhysicalGameObj* damager, PhysicalGameObj* target, const AmmoDefinitionClass* ammo, const char* bone) { return true; } //called on damage from clients with version >=4.0
+	virtual void OnPreLoadLevel() {}; //called on level load but before the client is sent any network updates
 };
 
 typedef Plugin *(*Plugin_Init_Type) ();
diff -uwr sourceold/scripts/gmsoldier.cpp source/scripts/gmsoldier.cpp
--- sourceold/scripts/gmsoldier.cpp	2011-10-11 23:04:34.123046800 +0800
+++ source/scripts/gmsoldier.cpp	2012-05-23 10:18:54.079101500 +0800
@@ -127,7 +127,7 @@
 	delete[] str;
 }
 
-void SSGM_Soldier::Detatch(GameObject *obj)
+void SSGM_Soldier::Detach(GameObject *obj)
 {
 	Unbind_Vehicle(obj, true);
 }
diff -uwr sourceold/scripts/gmsoldier.h source/scripts/gmsoldier.h
--- sourceold/scripts/gmsoldier.h	2011-10-11 21:52:39.229492100 +0800
+++ source/scripts/gmsoldier.h	2012-05-23 10:18:54.011718700 +0800
@@ -16,7 +16,7 @@
 	unsigned int RefillTime;
 	void Created(GameObject *obj);
 	void Destroyed(GameObject *obj);
-	void Detatch(GameObject *obj);
+	void Detach(GameObject *obj);
 	void Damaged(GameObject *obj,GameObject *damager,float amount);
 	void Killed(GameObject *obj,GameObject *killer);
 	void Custom(GameObject *obj, int message, int param, GameObject *sender);
diff -uwr sourceold/scripts/gmvehicle.cpp source/scripts/gmvehicle.cpp
--- sourceold/scripts/gmvehicle.cpp	2012-02-17 17:47:52.633789000 +0800
+++ source/scripts/gmvehicle.cpp	2012-05-23 10:18:53.952148400 +0800
@@ -21,10 +21,10 @@
 #include "gmgame.h"
 SCRIPTS_API VehicleGameObj *Find_My_Vehicle(GameObject *obj)
 {
-	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
+	SLNode<VehicleGameObj> *x = GameObjManager::VehicleGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
+		VehicleGameObj *o = x->Data();
 		if (o)
 		{
 			SSGM_Vehicle *scr = (SSGM_Vehicle *)Find_Script_On_Object(o,"SSGM_Vehicle");
@@ -37,7 +37,7 @@
 				}
 				if (Commands->Find_Object(scr->OwnerID) == obj)
 				{
-					return o->As_VehicleGameObj();
+					return o;
 				}
 			}
 		}
@@ -237,9 +237,17 @@
 	triggerrepaired = true;
 	OwnerID = 0;
 	IconModelID = 0;
+	if (Get_Vehicle_Mode(obj) == VEHICLE_TYPE_TURRET)
+	{
+		Vector3	pos	= Commands->Get_Position(obj);
+		SSGMGameLog::Log_Gamelog("CREATED;BUILDING;%d;%s;%d;%d;%d;%d;%f;%f;%d", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj),	int(pos.Y),int(pos.X),int(pos.Z), int(Commands->Get_Facing(obj)), Commands->Get_Max_Health(obj),Commands->Get_Max_Shield_Strength(obj),Get_Object_Type(obj));
+	}
+	else
+	{
 	Vector3	pos	= Commands->Get_Position(obj);
 	SSGMGameLog::Log_Gamelog("CREATED;VEHICLE;%d;%s;%d;%d;%d;%d;%d;%d;%d",	Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), int(pos.Y),int(pos.X),int(pos.Z), int(Commands->Get_Facing(obj)), int(Commands->Get_Max_Health(obj)),int(Commands->Get_Max_Shield_Strength(obj)), Commands->Get_Player_Type(obj));
 }
+}
 
 void SSGM_Vehicle::Register_Auto_Save_Variables()
 {
@@ -379,6 +387,18 @@
 		delete[] str6;
 		SSGMGameLog::Log_Message(str,"_VEHKILL");
 	}
+	if (Get_Vehicle_Mode(obj) == VEHICLE_TYPE_TURRET)
+	{
+		Vector3	victimpos =	Commands->Get_Position(obj);
+		Vector3	damagerpos = Commands->Get_Position(killer);
+		const char *str = Get_Translated_Preset_Name_Ex(obj);
+		const char *str2 = Get_Translated_Preset_Name_Ex(killer);
+		SSGMGameLog::Log_Gamelog("KILLED;BUILDING;%d;%s;%d;%d;%d;%d;%d;%s;%d;%d;%d;%d;%s;%s;%s",Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), int(victimpos.Y), int(victimpos.X), int(victimpos.Z), int(Commands->Get_Facing(obj)), Commands->Get_ID(killer),	Commands->Get_Preset_Name(killer),	int(damagerpos.Y), int(damagerpos.X), int(damagerpos.Z), int(Commands->Get_Facing(killer)),Get_Current_Weapon(killer),str,str2);
+		delete[] str;
+		delete[] str2;
+	}
+	else
+	{
 	Vector3	victimpos =	Commands->Get_Position(obj);
 	Vector3	damagerpos = Commands->Get_Position(killer);
 	const char *str3 = Get_Translated_Preset_Name_Ex(obj);
@@ -387,6 +407,7 @@
 	delete[] str3;
 	delete[] str2;
 }
+}
 
 void SSGM_Vehicle::Destroyed(GameObject *obj)
 {
@@ -394,11 +415,19 @@
 	{
 		Commands->Destroy_Object(Commands->Find_Object(IconModelID));
 	}
+	if (Get_Vehicle_Mode(obj) == VEHICLE_TYPE_TURRET)
+	{
+		Vector3	pos	= Commands->Get_Position(obj);
+		SSGMGameLog::Log_Gamelog("DESTROYED;BUILDING;%d;%s;%d;%d;%d", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), int(pos.Y), int(pos.X), int(pos.Z));
+	}
+	else
+	{
 	Vector3	pos	= Commands->Get_Position(obj);
 	SSGMGameLog::Log_Gamelog("DESTROYED;VEHICLE;%d;%s;%d;%d;%d", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), int(pos.Y), int(pos.X), int(pos.Z));
 }
+}
 
-void SSGM_Vehicle::Detatch(GameObject *obj)
+void SSGM_Vehicle::Detach(GameObject *obj)
 {
 	if (Commands->Find_Object(IconModelID))
 	{
@@ -410,10 +439,19 @@
 {
 	if (amount != 0)
 	{
+		if (Get_Vehicle_Mode(obj) == VEHICLE_TYPE_TURRET)
+		{
+			Vector3	victimpos =	Commands->Get_Position(obj);
+			Vector3	damagerpos = Commands->Get_Position(damager);
+			SSGMGameLog::Log_Gamelog("DAMAGED;BUILDING;%d;%s;%d;%d;%d;%d;%d;%s;%d;%d;%d;%d;%f;%d;%d;%d", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), int(victimpos.Y), int(victimpos.X), int(victimpos.Z), int(Commands->Get_Facing(obj)), Commands->Get_ID(damager), Commands->Get_Preset_Name(damager), int(damagerpos.Y), int(damagerpos.X),	int(damagerpos.Z), int(Commands->Get_Facing(damager)), amount, int(Commands->Get_Health(obj)), int(Commands->Get_Shield_Strength(obj)),	int(Commands->Get_Points(obj)));
+		}
+		else
+		{
 		Vector3	victimpos =	Commands->Get_Position(obj);
 		Vector3	damagerpos = Commands->Get_Position(damager);
 		SSGMGameLog::Log_Gamelog("DAMAGED;VEHICLE;%d;%s;%d;%d;%d;%d;%d;%s;%d;%d;%d;%d;%f;%d;%d;%d", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj),	int(victimpos.Y), int(victimpos.X),	int(victimpos.Z), int(Commands->Get_Facing(obj)), Commands->Get_ID(damager), Commands->Get_Preset_Name(damager), int(damagerpos.Y),	int(damagerpos.X), int(damagerpos.Z), int(Commands->Get_Facing(damager)), amount, int(Commands->Get_Health(obj)), int(Commands->Get_Shield_Strength(obj)), int(Commands->Get_Points(damager)));
 	}
+	}
 	if (ShowExtraMessages)
 	{
 		if (triggerrepairing)
diff -uwr sourceold/scripts/gmvehicle.h source/scripts/gmvehicle.h
--- sourceold/scripts/gmvehicle.h	2011-10-11 21:52:37.589843700 +0800
+++ source/scripts/gmvehicle.h	2012-05-23 10:18:53.512695300 +0800
@@ -18,7 +18,7 @@
 	void Damaged(GameObject *obj,GameObject *damager,float amount);
 	void Killed(GameObject *obj,GameObject *killer);
 	void Destroyed(GameObject *obj);
-	void Detatch(GameObject *obj);
+	void Detach(GameObject *obj);
 	void Timer_Expired(GameObject *obj, int number);
 	bool triggerrepairing;
 	bool triggerrepaired;
diff -uwr sourceold/scripts/iran_scripts.cpp source/scripts/iran_scripts.cpp
--- sourceold/scripts/iran_scripts.cpp	2012-01-05 21:21:34.000000000 +0800
+++ source/scripts/iran_scripts.cpp	2012-04-24 12:40:48.691406200 +0800
@@ -83,7 +83,7 @@
 		saved = Commands->Get_ID(enter);
 		Commands->Start_Timer(obj,this,2.5f,1);
 	}
-	else if (Is_Vehicle(enter))
+	else if (enter->As_VehicleGameObj())
 	{
 		int type = Commands->Get_Player_Type(enter);
 		if ( type < 0 || type > 1 )
@@ -167,7 +167,7 @@
 		Commands->Start_Timer(obj,this,2.5f,1);
 	}
 
-	else if (Is_Vehicle(enter))
+	else if (enter->As_VehicleGameObj())
 	{
 		if (Get_Vehicle_Mode(enter) != VEHICLE_TYPE_FLYING)
 		{
@@ -187,7 +187,7 @@
 
 void Iran_Vehicle_Flying_Kill_Zone::Entered(GameObject *obj,GameObject *enter)
 {
-	if (Is_Vehicle(enter))
+	if (enter->As_VehicleGameObj())
 	{
 		if (Get_Vehicle_Mode(enter) == VEHICLE_TYPE_FLYING)
 		{
diff -uwr sourceold/scripts/jfwcine.cpp source/scripts/jfwcine.cpp
--- sourceold/scripts/jfwcine.cpp	2012-02-13 19:12:33.892000000 +0800
+++ source/scripts/jfwcine.cpp	2012-04-19 17:12:40.578125000 +0800
@@ -461,8 +461,8 @@
 {
 	float facing = Commands->Get_Facing(Owner());
 	Vector3 position = Commands->Get_Position(Owner());
-	position.X = (float)(cos(facing * 3.1415927 / 180) * 10 + position.X);
-	position.Y = (float)(sin(facing * 3.1415927 / 180) * 10 + position.Y);
+	position.X += cos(DEG_TO_RADF(facing)) * 10.0f;
+	position.Y += sin(DEG_TO_RADF(facing)) * 10.0f;
 	position.Z += 2.0;
 	ActionParamsStruct params;
 	params.Set_Basic(this,99,1);
diff -uwr sourceold/scripts/jfwdef.cpp source/scripts/jfwdef.cpp
--- sourceold/scripts/jfwdef.cpp	2011-10-11 23:05:19.216796800 +0800
+++ source/scripts/jfwdef.cpp	2012-04-24 12:41:09.166015600 +0800
@@ -1497,7 +1497,7 @@
 	}
 	if (!Is_VTOL(enemy))
 	{
-		SmartGameObj* obj1 = (SmartGameObj*)As_SmartGameObj(enemy);
+		SmartGameObj* obj1 = enemy->As_SmartGameObj();
 		if(!obj1 
 		|| !obj1->Is_Stealthed() 
 		|| Commands->Get_Distance(Commands->Get_Position(obj),Commands->Get_Position(enemy)) <= Get_Float_Parameter("MaxStealthAttackDistance"))
diff -uwr sourceold/scripts/jfwdmg.cpp source/scripts/jfwdmg.cpp
--- sourceold/scripts/jfwdmg.cpp	2012-02-13 19:32:56.397859400 +0800
+++ source/scripts/jfwdmg.cpp	2012-04-25 11:41:04.667968700 +0800
@@ -15,6 +15,7 @@
 #include "engine.h"
 #include "jfwdmg.h"
 #include "BuildingGameObj.h"
+#include "VehicleGameObjDef.h"
 
 void JFW_Spawn_Object_Death::Killed(GameObject *obj,GameObject *killer)
 {
@@ -1049,7 +1050,7 @@
 
 void JFW_Kill_Message_Display::Custom(GameObject *obj,int type,int param,GameObject *sender)
 {
-	if (!param)
+	if (!param || !Commands->Find_Object(param) ||!sender)
 	{
 		return;
 	}
@@ -1060,7 +1061,7 @@
 			KilledID = 0;
 			KilledPlayerID = Get_Player_ID(sender);
 		}
-		else if (Is_Vehicle(sender) && (Get_Vehicle_Driver(sender)))
+		else if (sender->As_VehicleGameObj() && (Get_Vehicle_Driver(sender)))
 		{
 			KilledID = Commands->Get_Preset_ID(sender);
 			KilledPlayerID = Get_Player_ID(Get_Vehicle_Driver(sender));
@@ -1071,8 +1072,12 @@
 			KilledPlayerID = 0;
 		}
 		GameObject *Killer = Commands->Find_Object(param);
+		GameObject *explosion = GetExplosionObj();
+		if (!explosion || (explosion->As_VehicleGameObj() && Get_Vehicle_Mode(explosion) != VEHICLE_TYPE_TURRET))
+		{
 		Killer = Get_Vehicle_Return(Killer);
-		if (Is_Soldier(Killer))
+		}
+		if (Killer->As_SoldierGameObj())
 		{
 			KillerTeam = Get_Object_Type(Killer);
 			if (Commands->Is_A_Star(Killer))
@@ -1084,7 +1089,6 @@
 			{
 				KillerPlayerID = 0;
 			}
-			GameObject *explosion = GetExplosionObj();
 			if (explosion)
 			{
 				KillerID = Commands->Get_Preset_ID(explosion);
@@ -1094,10 +1098,9 @@
 				KillerID = Get_Definition_ID(Get_Current_Weapon(Killer));
 			}
 		}
-		else if (Is_Vehicle(Killer))
+		else if (Killer->As_VehicleGameObj())
 		{
 			KillerID = Commands->Get_Preset_ID(Killer);
-			GameObject *explosion = GetExplosionObj();
 			if (explosion)
 			{
 				KillerID = Commands->Get_Preset_ID(explosion);
@@ -1258,6 +1261,18 @@
 	return -1;
 }
 
+void JFW_Spawn_Object_Repair::Damaged(GameObject *obj,GameObject *damager,float amount)
+{
+	if (Commands->Get_Health(obj) == Commands->Get_Max_Health(obj) && amount)
+	{
+		Vector3 pos = Commands->Get_Position(obj);
+		float facing = Commands->Get_Facing(obj);
+		Commands->Destroy_Object(obj);
+		GameObject *o = Commands->Create_Object(Get_Parameter("Object"),pos);
+		Commands->Set_Facing(o,facing);
+	}
+}
+
 ScriptRegistrant<JFW_Invulnerable_On_Create> JFW_Invulnerable_On_Create_Registrant("JFW_Invulnerable_On_Create","Time:float,TimerNum:int,InvulnerableArmour:string,NormalArmour:string");
 ScriptRegistrant<JFW_Destroy_Self_Timer> JFW_Destroy_Self_Timer_Registrant("JFW_Destroy_Self_Timer","Time:float,TimerNum:int");
 ScriptRegistrant<JFW_Change_Model_Health> JFW_Change_Model_Health_Registrant("JFW_Change_Model_Health","Model:string,Health:float");
@@ -1312,3 +1327,4 @@
 ScriptRegistrant<JFW_C4_Explode> JFW_C4_Explode_Registrant("JFW_C4_Explode","Preset:string,Explosion:string");
 ScriptRegistrant<JFW_Timer_Destroy_Object> JFW_Timer_Destroy_Object_Registrant("JFW_Timer_Destroy_Object","Time:float,TimerNum:int,Amount:float,Warhead:string");
 ScriptRegistrant<JFW_Beacon_Building> JFW_Beacon_Building_Registrant("JFW_Beacon_Building","");
+ScriptRegistrant<JFW_Spawn_Object_Repair> JFW_Spawn_Object_Repair_Registrant("JFW_Spawn_Object_Repair","Object:string");
diff -uwr sourceold/scripts/jfwdmg.h source/scripts/jfwdmg.h
--- sourceold/scripts/jfwdmg.h	2011-10-14 22:27:32.069335900 +0800
+++ source/scripts/jfwdmg.h	2012-04-14 04:09:46.730468700 +0800
@@ -322,3 +322,7 @@
 	JFW_Beacon_Building() {pos = 0;}
 	~JFW_Beacon_Building();
 };
+
+class JFW_Spawn_Object_Repair : public ScriptImpClass {
+	void Damaged(GameObject *obj,GameObject *damager,float amount);
+};
diff -uwr sourceold/scripts/jfwgame.cpp source/scripts/jfwgame.cpp
--- sourceold/scripts/jfwgame.cpp	2012-02-13 19:32:56.856843700 +0800
+++ source/scripts/jfwgame.cpp	2012-04-24 21:25:30.892578100 +0800
@@ -492,7 +492,7 @@
 		object = Commands->Find_Object(ID);
 		Commands->Send_Custom_Event(obj,object,Collected_Message,Cash,0);
 		pos = Commands->Get_Position(object);
-		angle = Commands->Get_Facing(object);
+		angle = DEG_TO_RADF(Commands->Get_Facing(object));
 		pos.X+=Collected_Preset_Distance*(float)cos(angle);
 		pos.Y+=Collected_Preset_Distance*(float)sin(angle);
 		Commands->Create_Object(Collected_Preset,pos);
@@ -703,7 +703,7 @@
 	{
 		return;
 	}
-	if (Is_Vehicle(enterer))
+	if (enterer->As_VehicleGameObj())
 	{
 		enabled = false;
 		timertime = Get_Float_Parameter("Time");
@@ -883,7 +883,7 @@
 	{
 		return;
 	}
-	if (Is_Vehicle(enterer))
+	if (enterer->As_VehicleGameObj())
 	{
 		enabled = false;
 		if (Get_Int_Parameter("CinematicPowerOff") == 1)
@@ -1747,7 +1747,6 @@
 		if (HarvyID)
 		{
 			Commands->Apply_Damage(Commands->Find_Object(HarvyID),99999,"Explosive",0);
-			if (!Commands->Get_ID(Commands->Find_Object(HarvyID))) Commands->Destroy_Object(Commands->Find_Object(HarvyID));
 			Commands->Destroy_Object(obj);
 		}
 	}
@@ -2295,6 +2294,8 @@
 {
 	if (number == Get_Int_Parameter("TimerNum"))
 	{
+		if (Is_Base_Powered(Get_Object_Type(obj)))
+		{
 		Vector3 v = Commands->Get_Position(Find_Object_By_Preset(2,Get_Definition_Name(Get_Int_Parameter("CenterID"))));
 		if (Is_Unit_In_Range(Get_Parameter("Preset"),Get_Float_Parameter("Range"),v,PTTEAM(Get_Object_Type(obj)),false))
 		{
@@ -2316,6 +2317,7 @@
 				Enable_Base_Radar(Get_Object_Type(obj),true);
 			}
 		}
+		}
 		Commands->Start_Timer(obj,this,Get_Float_Parameter("Time"),Get_Int_Parameter("TimerNum"));
 	}
 }
@@ -2342,11 +2344,14 @@
 {
 	if (number == Get_Int_Parameter("TimerNum"))
 	{
+		if (Is_Base_Powered(Get_Object_Type(obj)))
+		{
 		Vector3 v = Commands->Get_Position(Find_Object_By_Preset(2,Get_Definition_Name(Get_Int_Parameter("CenterID"))));
 		if (Is_Unit_In_Range(Get_Parameter("Preset"),Get_Float_Parameter("Range"),v,PTTEAM(Get_Object_Type(obj)),false))
 		{
 			Create_2D_Sound_Team(Get_Parameter("Sound"),Get_Object_Type(obj));
 		}
+		}
 		Commands->Start_Timer(obj,this,Get_Float_Parameter("Time"),Get_Int_Parameter("TimerNum"));
 	}
 }
@@ -2700,6 +2705,31 @@
 	}
 }
 
+void JFW_Low_Power_Sound::Created(GameObject *obj)
+{
+	lowpower = false;
+	Commands->Start_Timer(obj,this,1.0,1);
+}
+
+void JFW_Low_Power_Sound::Timer_Expired(GameObject *obj,int number)
+{
+	if (number == 1)
+	{
+		bool power = Is_Base_Powered(Commands->Get_Player_Type(obj));
+		if (power && lowpower)
+		{
+			lowpower = false;
+			Commands->Create_Sound(Get_Parameter("UpSound"),Commands->Get_Position(obj),obj);
+		}
+		if (!power && !lowpower)
+		{
+			lowpower = true;
+			Commands->Create_Sound(Get_Parameter("DownSound"),Commands->Get_Position(obj),obj);
+		}
+		Commands->Start_Timer(obj,this,1.0,1);
+	}
+}
+
 void JFW_Message_Send_Zone::Entered(GameObject *obj,GameObject *enterer)
 {
 	int team = Get_Int_Parameter("Player_Type");
@@ -3176,6 +3206,7 @@
 ScriptRegistrant<JFW_Stealth_Generator_Vehicle_Deploy> JFW_Stealth_Generator_Vehicle_Deploy_Registrant("JFW_Stealth_Generator_Vehicle_Deploy","Stealth_Range=50:int,Stealth_Controller:string");
 ScriptRegistrant<JFW_Stealth_Generator_Ignored> JFW_Stealth_Generator_Ignored_Registrant("JFW_Stealth_Generator_Ignored","");
 ScriptRegistrant<JFW_Low_Power_Message> JFW_Low_Power_Message_Registrant("JFW_Low_Power_Message","Message:string");
+ScriptRegistrant<JFW_Low_Power_Sound> JFW_Low_Power_Sound_Registrant("JFW_Low_Power_Sound","DownSound:string,UpSound:string");
 ScriptRegistrant<JFW_Message_Send_Zone> JFW_Message_Send_Zone_Registrant("JFW_Message_Send_Zone","Player_Type:int,Message:string,Red:int,Blue:int,Green:int,Sound:string,Delete:int");
 ScriptRegistrant<JFW_Message_Send_Zone_Team> JFW_Message_Send_Zone_Team_Registrant("JFW_Message_Send_Zone_Team","Player_Type:int,Message:string,Red:int,Blue:int,Green:int,Sound:string,Delete:int");
 ScriptRegistrant<JFW_Message_Send_Zone_Player> JFW_Message_Send_Zone_Player_Registrant("JFW_Message_Send_Zone_Player","Player_Type:int,Message:string,Red:int,Blue:int,Green:int,Sound:string,Delete:int");
diff -uwr sourceold/scripts/jfwgame.h source/scripts/jfwgame.h
--- sourceold/scripts/jfwgame.h	2012-02-13 18:26:32.682039000 +0800
+++ source/scripts/jfwgame.h	2012-04-14 04:09:46.572265600 +0800
@@ -342,6 +342,12 @@
 	void Timer_Expired(GameObject *obj,int number);
 };
 
+class JFW_Low_Power_Sound : public ScriptImpClass {
+	bool lowpower;
+	void Created(GameObject *obj);
+	void Timer_Expired(GameObject *obj,int number);
+};
+
 class JFW_Message_Send_Zone : public ScriptImpClass {
 	void Entered(GameObject *obj,GameObject *enterer);
 };
diff -uwr sourceold/scripts/jfwmisc.cpp source/scripts/jfwmisc.cpp
--- sourceold/scripts/jfwmisc.cpp	2012-02-13 19:32:56.703523400 +0800
+++ source/scripts/jfwmisc.cpp	2012-06-09 08:50:40.669921800 +0800
@@ -25,6 +25,7 @@
 #include "WeaponClass.h"
 #include "VehicleFactoryGameObj.h"
 #include "AirFactoryGameObj.h"
+#include "NavalFactoryGameObj.h"
 #include "PurchaseSettingsDefClass.h"
 
 void JFW_User_Settable_Parameters::Created(GameObject *obj)
@@ -914,7 +915,7 @@
 
 void JFW_Radar_Low_Power::Killed(GameObject *obj,GameObject *killer)
 {
-	GameObject *o = Find_Building(Get_Object_Type(obj),BuildingConstants::TYPE_COM_CENTER);
+	GameObject *o = Find_Building_By_Type(Get_Object_Type(obj),BuildingConstants::TYPE_COM_CENTER);
 	if (o && !Is_Building_Dead(o))
 	{
 		Enable_Base_Radar(Get_Object_Type(obj),false);
@@ -1247,6 +1248,41 @@
 	Destroy_Script();
 }
 
+void JFW_NavalFactory_Disable::Created(GameObject *obj)
+{
+	count = 0;
+}
+
+void JFW_NavalFactory_Disable::Custom(GameObject *obj,int type,int param,GameObject *sender)
+{
+	if (obj->As_BuildingGameObj() && obj->As_BuildingGameObj()->As_NavalFactoryGameObj())
+	{
+		if (type == Get_Int_Parameter("Disable_Custom"))
+		{
+			if (count == 0)
+			{
+				obj->As_BuildingGameObj()->As_NavalFactoryGameObj()->Set_Disabled(true);
+				PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_NAVAL,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(obj)))->Set_Page_Disabled(true);
+			}
+			count++;
+		}
+		if (type == Get_Int_Parameter("Enable_Custom"))
+		{
+			count--;
+			if (count == 0)
+			{
+				obj->As_BuildingGameObj()->As_NavalFactoryGameObj()->Set_Disabled(false);
+				PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_NAVAL,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(obj)))->Set_Page_Disabled(false);
+			}
+		}
+	}
+}
+
+void JFW_NavalFactory_Disable::Killed(GameObject *obj,GameObject *killer)
+{
+	Destroy_Script();
+}
+
 void JFW_Engineer_Hack::Created(GameObject *obj)
 {
 	Warhead = ArmorWarheadManager::Get_Warhead_Type(Get_Parameter("Hack_Warhead"));
@@ -1340,11 +1376,12 @@
 
 void JFW_EMP::Damaged(GameObject *obj,GameObject *damager,float amount)
 {
-	if (Warhead == Get_Damage_Warhead())
+	//if (Warhead == Get_Damage_Warhead())
 	{
 		VehicleGameObj *o = obj->As_VehicleGameObj();
 		if (o && o->Get_Is_Scripts_Visible() && !o->Is_Immovable())
 		{
+			Commands->Enable_Engine(obj,false);
 			o->Set_Immovable(true);
 			o->Set_Scripts_Can_Fire(false);
 			Commands->Start_Timer(obj,this,Get_Float_Parameter("Time"),1);
@@ -1360,6 +1397,7 @@
 	Commands->Set_Animation(obj,0,true,0,0,-1,false);
 	obj->Set_Object_Dirty_Bit(NetworkObjectClass::BIT_RARE,true);
 	o->Set_Immovable(false);
+	Commands->Enable_Engine(obj,true);
 	o->Set_Scripts_Can_Fire(true);
 }
 
@@ -1372,9 +1410,12 @@
 
 void JFW_EMP_Mine::Enemy_Seen(GameObject *obj, GameObject *enemy)
 {
+	if (enemy->As_VehicleGameObj())
+	{
 	Commands->Create_Explosion(Get_Parameter("Explosion"),Commands->Get_Position(obj),0);
 	Commands->Apply_Damage(obj,99999,"Death",0);
 }
+}
 
 void JFW_EMP_Mine::Destroyed(GameObject *obj)
 {
@@ -1401,7 +1442,14 @@
 			SoldierGameObj *s = sender->As_SoldierGameObj();
 			if (s)
 			{
-				GameObject *mine = Commands->Create_Object(Get_Parameter("Mine_Preset"),s->Get_Muzzle().Get_Translation());
+				Vector3 v = Commands->Get_Position(sender);
+				v.Z += Get_Float_Parameter("Mine_Z_Offset");
+				float len = Get_Float_Parameter("Mine_Distance");
+				float angle = DEG_TO_RADF(Commands->Get_Facing(sender));
+				v.X += cos(angle) * len;
+				v.Y += sin(angle) * len;
+				GameObject *mine = Commands->Create_Object(Get_Parameter("Mine_Preset"),v);
+				Commands->Set_Player_Type(mine,Commands->Get_Player_Type(sender));
 				PhysicalGameObj *p = mine->As_PhysicalGameObj();
 				p->Peek_Physical_Object()->Set_Collision_Group(TERRAIN_AND_BULLET_COLLISION_GROUP);
 			}
@@ -1532,6 +1580,10 @@
 	{
 		Destroy_Script();
 	}
+	if (min > max)
+	{
+		Destroy_Script();
+	}
 	float timer = Commands->Get_Random(min,max);
 	Commands->Start_Timer(obj,this,timer,1);
 }
@@ -1550,24 +1602,28 @@
 		{
 			Destroy_Script();
 		}
+		if (min > max)
+		{
+			Destroy_Script();
+		}
 		float timer = Commands->Get_Random(min,max);
 		Commands->Start_Timer(obj,this,timer,2);
 		Commands->Set_Lightning(Get_Float_Parameter("Lightning_Intensity"),Get_Float_Parameter("Lightning_Start_Distance"),Get_Float_Parameter("Lightning_End_Distance"),Get_Float_Parameter("Lightning_Heading"),Get_Float_Parameter("Lightning_Distribution"),0);
-		if (Find_Building(0,BuildingConstants::TYPE_COM_CENTER))
+		if (Find_Building_By_Type(0,BuildingConstants::TYPE_COM_CENTER))
 		{
-			Commands->Send_Custom_Event(obj,Find_Building(0,BuildingConstants::TYPE_COM_CENTER),Get_Int_Parameter("Disable_Custom"),0,0);
+			Commands->Send_Custom_Event(obj,Find_Building_By_Type(0,BuildingConstants::TYPE_COM_CENTER),Get_Int_Parameter("Disable_Custom"),0,0);
 		}
-		if (Find_Building(1,BuildingConstants::TYPE_COM_CENTER))
+		if (Find_Building_By_Type(1,BuildingConstants::TYPE_COM_CENTER))
 		{
-			Commands->Send_Custom_Event(obj,Find_Building(1,BuildingConstants::TYPE_COM_CENTER),Get_Int_Parameter("Disable_Custom"),0,0);
+			Commands->Send_Custom_Event(obj,Find_Building_By_Type(1,BuildingConstants::TYPE_COM_CENTER),Get_Int_Parameter("Disable_Custom"),0,0);
 		}
-		if (Find_Building(0,BuildingConstants::TYPE_POWER_PLANT))
+		if (Find_Building_By_Type(0,BuildingConstants::TYPE_POWER_PLANT))
 		{
-			Commands->Send_Custom_Event(obj,Find_Building(0,BuildingConstants::TYPE_POWER_PLANT),Get_Int_Parameter("Disable_Custom"),0,0);
+			Commands->Send_Custom_Event(obj,Find_Building_By_Type(0,BuildingConstants::TYPE_POWER_PLANT),Get_Int_Parameter("Disable_Custom"),0,0);
 		}
-		if (Find_Building(1,BuildingConstants::TYPE_POWER_PLANT))
+		if (Find_Building_By_Type(1,BuildingConstants::TYPE_POWER_PLANT))
 		{
-			Commands->Send_Custom_Event(obj,Find_Building(1,BuildingConstants::TYPE_POWER_PLANT),Get_Int_Parameter("Disable_Custom"),0,0);
+			Commands->Send_Custom_Event(obj,Find_Building_By_Type(1,BuildingConstants::TYPE_POWER_PLANT),Get_Int_Parameter("Disable_Custom"),0,0);
 		}
 		Timer_Expired(obj,3);
 		Create_2D_Sound_Team(Get_Parameter("Announcement_Sound_Nod"),0);
@@ -1582,21 +1638,21 @@
 	{
 		storm = false;
 		Commands->Set_Lightning(Get_Float_Parameter("Lightning_Off_Intensity"),Get_Float_Parameter("Lightning_Off_Start_Distance"),Get_Float_Parameter("Lightning_Off_End_Distance"),Get_Float_Parameter("Lightning_Off_Heading"),Get_Float_Parameter("Lightning_Off_Distribution"),0);
-		if (Find_Building(0,BuildingConstants::TYPE_COM_CENTER))
+		if (Find_Building_By_Type(0,BuildingConstants::TYPE_COM_CENTER))
 		{
-			Commands->Send_Custom_Event(obj,Find_Building(0,BuildingConstants::TYPE_COM_CENTER),Get_Int_Parameter("Enable_Custom"),0,0);
+			Commands->Send_Custom_Event(obj,Find_Building_By_Type(0,BuildingConstants::TYPE_COM_CENTER),Get_Int_Parameter("Enable_Custom"),0,0);
 		}
-		if (Find_Building(1,BuildingConstants::TYPE_COM_CENTER))
+		if (Find_Building_By_Type(1,BuildingConstants::TYPE_COM_CENTER))
 		{
-			Commands->Send_Custom_Event(obj,Find_Building(1,BuildingConstants::TYPE_COM_CENTER),Get_Int_Parameter("Enable_Custom"),0,0);
+			Commands->Send_Custom_Event(obj,Find_Building_By_Type(1,BuildingConstants::TYPE_COM_CENTER),Get_Int_Parameter("Enable_Custom"),0,0);
 		}
-		if (Find_Building(0,BuildingConstants::TYPE_POWER_PLANT))
+		if (Find_Building_By_Type(0,BuildingConstants::TYPE_POWER_PLANT))
 		{
-			Commands->Send_Custom_Event(obj,Find_Building(0,BuildingConstants::TYPE_POWER_PLANT),Get_Int_Parameter("Enable_Custom"),0,0);
+			Commands->Send_Custom_Event(obj,Find_Building_By_Type(0,BuildingConstants::TYPE_POWER_PLANT),Get_Int_Parameter("Enable_Custom"),0,0);
 		}
-		if (Find_Building(1,BuildingConstants::TYPE_POWER_PLANT))
+		if (Find_Building_By_Type(1,BuildingConstants::TYPE_POWER_PLANT))
 		{
-			Commands->Send_Custom_Event(obj,Find_Building(1,BuildingConstants::TYPE_POWER_PLANT),Get_Int_Parameter("Enable_Custom"),0,0);
+			Commands->Send_Custom_Event(obj,Find_Building_By_Type(1,BuildingConstants::TYPE_POWER_PLANT),Get_Int_Parameter("Enable_Custom"),0,0);
 		}
 		Create_2D_Sound_Team(Get_Parameter("End_Announcement_Sound_Nod"),0);
 		Create_2D_Sound_Team(Get_Parameter("End_Announcement_Sound_GDI"),1);
@@ -1615,6 +1671,10 @@
 		{
 			Destroy_Script();
 		}
+		if (min > max)
+		{
+			Destroy_Script();
+		}
 		float timer = Commands->Get_Random(min,max);
 		Commands->Start_Timer(obj,this,timer,1);
 	}
@@ -1628,6 +1688,181 @@
 	}
 }
 
+void JFW_Tech_Level_Custom::Custom(GameObject *obj,int type,int param,GameObject *sender)
+{
+	if (type == Get_Int_Parameter("Message"))
+	{
+		Set_Tech_Level(Get_Int_Parameter("Tech_Level"));
+		Destroy_Script();
+	}
+}
+
+void JFW_Tech_Level_Startup::Created(GameObject *obj)
+{
+	Set_Tech_Level(Get_Int_Parameter("Tech_Level"));
+	Destroy_Script();
+}
+
+void JFW_Tech_Level_Timer::Created(GameObject *obj)
+{
+	Commands->Start_Timer(obj,this,Get_Float_Parameter("Time"),1);
+}
+void JFW_Tech_Level_Timer::Timer_Expired(GameObject *obj,int number)
+{
+	if (number == 1)
+	{
+		Commands->Create_2D_Sound(Get_Parameter("Sound"));
+		Send_Message(Get_Int_Parameter("Red"),Get_Int_Parameter("Green"),Get_Int_Parameter("Blue"),Get_Parameter("Display_Message"));
+		Set_Tech_Level(Get_Int_Parameter("Tech_Level"));
+		Destroy_Script();
+	}
+}
+
+void JFW_Change_Character_Created::Created(GameObject *obj)
+{
+	Change_Character(obj,Get_Parameter("Character"));
+	Destroy_Script();
+}
+
+void JFW_Spawn_Object_Created::Created(GameObject *obj)
+{
+	Commands->Create_Object(Get_Parameter("Object"),Commands->Get_Position(obj));
+	Destroy_Script();
+}
+
+void JFW_Change_Model_Created::Created(GameObject *obj)
+{
+	const char *model = 0;
+	do
+	{
+		int rand = Commands->Get_Random_Int(0,6);
+		if (rand == 1)
+		{
+			model = Get_Parameter("Model1");
+		}
+		if (rand == 2)
+		{
+			model = Get_Parameter("Model2");
+		}
+		if (rand == 3)
+		{
+			model = Get_Parameter("Model3");
+		}
+		if (rand == 4)
+		{
+			model = Get_Parameter("Model4");
+		}
+		if (rand == 5)
+		{
+			model = Get_Parameter("Model5");
+		}
+	} while (!model || !model[0]);
+	Commands->Set_Model(obj,model);
+	Destroy_Script();
+}
+
+extern REF_DECL2(NodHouseColor, Vector3);
+extern REF_DECL2(GDIHouseColor, Vector3);
+extern REF_DECL2(PublicMessageColor, Vector3);
+void JFW_Killed_String_Sound::Killed(GameObject *obj,GameObject *killer)
+{
+	if (Get_Object_Type(obj) == 0)
+	{
+		int red = (int)(NodHouseColor.X * 255);
+		int green = (int)(NodHouseColor.Y * 255);
+		int blue = (int)(NodHouseColor.Z * 255);
+		int stringgdi = Get_Int_Parameter("Nod_String_GDI");
+		if (stringgdi && Is_Valid_String_ID(stringgdi))
+		{
+			const char *str = Get_Translated_String(stringgdi);
+			Send_Message_Team(1,red,green,blue,str);
+			delete[] str;
+			int soundId = Get_String_Sound_ID(stringgdi);
+			if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000)
+			{
+				Create_2D_Sound_Team(Get_Definition_Name(soundId),1);
+			}
+		}
+		int stringnod = Get_Int_Parameter("Nod_String_Nod");
+		if (stringnod && Is_Valid_String_ID(stringnod))
+		{
+			const char *str = Get_Translated_String(stringnod);
+			Send_Message_Team(0,red,green,blue,str);
+			delete[] str;
+			int soundId = Get_String_Sound_ID(stringnod);
+			if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000)
+			{
+				Create_2D_Sound_Team(Get_Definition_Name(soundId),0);
+			}
+		}
+	}
+	else if (Get_Object_Type(obj) == 1)
+	{
+		int red = (int)(GDIHouseColor.X * 255);
+		int green = (int)(GDIHouseColor.Y * 255);
+		int blue = (int)(GDIHouseColor.Z * 255);
+		int stringgdi = Get_Int_Parameter("GDI_String_GDI");
+		if (stringgdi && Is_Valid_String_ID(stringgdi))
+		{
+			const char *str = Get_Translated_String(stringgdi);
+			Send_Message_Team(1,red,green,blue,str);
+			delete[] str;
+			int soundId = Get_String_Sound_ID(stringgdi);
+			if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000)
+			{
+				Create_2D_Sound_Team(Get_Definition_Name(soundId),1);
+			}
+		}
+		int stringnod = Get_Int_Parameter("GDI_String_Nod");
+		if (stringnod && Is_Valid_String_ID(stringnod))
+		{
+			const char *str = Get_Translated_String(stringnod);
+			Send_Message_Team(0,red,green,blue,str);
+			delete[] str;
+			int soundId = Get_String_Sound_ID(stringnod);
+			if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000)
+			{
+				Create_2D_Sound_Team(Get_Definition_Name(soundId),0);
+			}
+		}
+	}
+	else
+	{
+		int red = (int)(PublicMessageColor.X * 255);
+		int green = (int)(PublicMessageColor.Y * 255);
+		int blue = (int)(PublicMessageColor.Z * 255);
+		int stringgdi = Get_Int_Parameter("Neutral_String_GDI");
+		if (stringgdi && Is_Valid_String_ID(stringgdi))
+		{
+			const char *str = Get_Translated_String(stringgdi);
+			Send_Message_Team(1,red,green,blue,str);
+			delete[] str;
+			int soundId = Get_String_Sound_ID(stringgdi);
+			if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000)
+			{
+				Create_2D_Sound_Team(Get_Definition_Name(soundId),1);
+			}
+		}
+		int stringnod = Get_Int_Parameter("Neutral_String_Nod");
+		if (stringnod && Is_Valid_String_ID(stringnod))
+		{
+			const char *str = Get_Translated_String(stringnod);
+			Send_Message_Team(0,red,green,blue,str);
+			delete[] str;
+			int soundId = Get_String_Sound_ID(stringnod);
+			if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000)
+			{
+				Create_2D_Sound_Team(Get_Definition_Name(soundId),0);
+			}
+		}
+	}
+}
+
+
+ScriptRegistrant<JFW_Tech_Level_Timer> JFW_Tech_Level_Timer_Registrant("JFW_Tech_Level_Timer","Display_Message:string,Red:int,Blue:int,Green:int,Sound:string,Time:float,Tech_Level:int");
+ScriptRegistrant<JFW_Tech_Level_Startup> JFW_Tech_Level_Startup_Registrant("JFW_Tech_Level_Startup","Tech_Level:int");
+ScriptRegistrant<JFW_Tech_Level_Custom> JFW_Tech_Level_Custom_Registrant("JFW_Tech_Level_Custom","Message:int,Tech_Level:int");
+
 ScriptRegistrant<JFW_Stealthable_Object> JFW_Stealthable_Object_Registrant("JFW_Stealthable_Object","Message:int");
 ScriptRegistrant<JFW_Object_Counter> JFW_Object_Counter_Registrant("JFW_Object_Counter","Count:int,IncrementMessage:int,DecrementMessage:int");
 ScriptRegistrant<JFW_Fog_Create> JFW_Fog_Create_Registrant("JFW_Fog_Create","Fog_Enable:int,Fog_Start_Distance=0.000:float,Fog_End_Distance=0.000:float,Delay=0.000:float,OnCreate=0:int,OnDestroy=0:int");
@@ -1691,9 +1926,10 @@
 ScriptRegistrant<JFW_Refinery_Disable> JFW_Refinery_Disable_Registrant("JFW_Refinery_Disable","Disable_Custom:int,Enable_Custom:int");
 ScriptRegistrant<JFW_VehicleFactory_Disable> JFW_VehicleFactory_Disable_Registrant("JFW_VehicleFactory_Disable","Disable_Custom:int,Enable_Custom:int");
 ScriptRegistrant<JFW_AirFactory_Disable> JFW_AirFactory_Disable_Registrant("JFW_AirFactory_Disable","Disable_Custom:int,Enable_Custom:int");
+ScriptRegistrant<JFW_NavalFactory_Disable> JFW_NavalFactory_Disable_Registrant("JFW_NavalFactory_Disable","Disable_Custom:int,Enable_Custom:int");
 ScriptRegistrant<JFW_EMP> JFW_EMP_Registrant("JFW_EMP","Warhead:string,Time:fload,Animation:string");
 ScriptRegistrant<JFW_EMP_Mine> JFW_EMP_Mine_Registrant("JFW_EMP_Mine","Mine_Manager_ID:int,Explosion:string");
-ScriptRegistrant<JFW_EMP_Mine_Manager> JFW_EMP_Mine_Manager_Registrant("JFW_EMP_Mine_Manager","Mine_Preset:string,Mine_Limit:int,Mine_Reload:string");
+ScriptRegistrant<JFW_EMP_Mine_Manager> JFW_EMP_Mine_Manager_Registrant("JFW_EMP_Mine_Manager","Mine_Preset:string,Mine_Limit:int,Mine_Reload:string,Mine_Z_Offset:float,Mine_Distance:float");
 ScriptRegistrant<JFW_EMP_Mine_Layer> JFW_EMP_Mine_Layer_Registrant("JFW_EMP_Mine_Layer","Mine_Manager_ID:int,Warhead:string");
 ScriptRegistrant<JFW_Radar_Disable_Death> JFW_Radar_Disable_Death_Registrant("JFW_Radar_Disable_Death","");
 ScriptRegistrant<JFW_Cyborg_Reaper> JFW_Cyborg_Reaper_Registrant("JFW_Cyborg_Reaper","");
@@ -1702,3 +1938,7 @@
 ScriptRegistrant<JFW_Death_Send_Custom_Self> JFW_Death_Send_Custom_Self_Registrant("JFW_Death_Send_Custom_Self","Message:int");
 ScriptRegistrant<JFW_Hunter_Seeker> JFW_Hunter_Seeker_Registrant("JFW_Hunter_Seeker","Key:string,Explosion:string");
 ScriptRegistrant<JFW_Ion_Storm> JFW_Ion_Storm_Registrant("JFW_Ion_Storm","Min_Delay:float,Max_Delay:float,Min_Time:float,Max_Time:float,Disable_Custom:int,Enable_Custom:int,Announcement_Sound_Nod:string,Announcement_Sound_GDI:string,Announcement_String:string,Red:int,Green:int,Blue:int,Ion_Effect_Sound:string,Ion_Effect_Time:float,Lightning_Intensity:float,Lightning_Start_Distance:float,Lightning_End_Distance:float,Lightning_Heading:float,Lightning_Distribution:float,Lightning_Off_Intensity:float,Lightning_Off_Start_Distance:float,Lightning_Off_End_Distance:float,Lightning_Off_Heading:float,Lightning_Off_Distribution:float,End_Announcement_Sound_Nod:string,End_Announcement_Sound_GDI:string,End_Announcement_String:string");
+ScriptRegistrant<JFW_Change_Character_Created> JFW_Change_Character_Created_Registrant("JFW_Change_Character_Created","Character:string");
+ScriptRegistrant<JFW_Change_Model_Created> JFW_Change_Model_Created_Registrant("JFW_Change_Model_Created","Model1:string,Model2:string,Model3:string,Model4:string,Model5:string");
+ScriptRegistrant<JFW_Spawn_Object_Created> JFW_Spawn_Object_Created_Registrant("JFW_Spawn_Object_Created","Object:string");
+ScriptRegistrant<JFW_Killed_String_Sound> JFW_Killed_String_Sound_Registrant("JFW_Killed_String_Sound","GDI_String_GDI:int,Nod_String_GDI:int,Neutral_String_GDI:int,GDI_String_Nod:int,Nod_String_Nod:int,Neutral_String_Nod:int");
diff -uwr sourceold/scripts/jfwmisc.h source/scripts/jfwmisc.h
--- sourceold/scripts/jfwmisc.h	2011-10-22 19:58:24.060546800 +0800
+++ source/scripts/jfwmisc.h	2012-04-24 10:06:13.417968700 +0800
@@ -327,6 +327,13 @@
 	unsigned int count;
 };
 
+class JFW_NavalFactory_Disable : public ScriptImpClass {
+	void Created(GameObject *obj);
+	void Custom(GameObject *obj,int type,int param,GameObject *sender);
+	void Killed(GameObject *obj,GameObject *killer);
+	unsigned int count;
+};
+
 class JFW_Engineer_Hack : public ScriptImpClass {
 	unsigned int Warhead;
 	int IndcatorID;
@@ -405,3 +412,32 @@
 	void Created(GameObject *obj);
 	void Timer_Expired(GameObject *obj,int number);
 };
+
+class JFW_Tech_Level_Custom : public ScriptImpClass {
+	void Custom(GameObject *obj,int type,int param,GameObject *sender);
+};
+
+class JFW_Tech_Level_Startup : public ScriptImpClass {
+	void Created(GameObject *obj);
+};
+
+class JFW_Tech_Level_Timer : public ScriptImpClass {
+	void Created(GameObject *obj);
+	void Timer_Expired(GameObject *obj,int number);
+};
+
+class JFW_Change_Character_Created : public ScriptImpClass {
+	void Created(GameObject *obj);
+};
+
+class JFW_Change_Model_Created : public ScriptImpClass {
+	void Created(GameObject *obj);
+};
+
+class JFW_Spawn_Object_Created : public ScriptImpClass {
+	void Created(GameObject *obj);
+};
+
+class JFW_Killed_String_Sound : public ScriptImpClass {
+	void Killed(GameObject *obj,GameObject *killer);
+};
diff -uwr sourceold/scripts/jfwsnd.cpp source/scripts/jfwsnd.cpp
--- sourceold/scripts/jfwsnd.cpp	2012-02-13 19:12:33.200593700 +0800
+++ source/scripts/jfwsnd.cpp	2012-05-28 09:47:05.897078200 +0800
@@ -218,7 +218,7 @@
 
 void JFW_2D_Sound_Damage_Range::Damaged(GameObject *obj,GameObject *damager,float amount)
 {
-	if ((Commands->Get_Health(obj) <= Get_Float_Parameter("MaxHealth")) && (Commands->Get_Health(obj) <= Get_Float_Parameter("MinHealth")))
+	if ((Commands->Get_Health(obj) <= Get_Float_Parameter("MaxHealth")) && (Commands->Get_Health(obj) >= Get_Float_Parameter("MinHealth")))
 	{
 		if (enabled)
 		{
@@ -237,6 +237,76 @@
 	Auto_Save_Variable(&enabled,1,1);
 }
 
+void JFW_2D_Sound_Damage_Range_Team::Created(GameObject *obj)
+{
+	enabled = true;
+}
+
+void JFW_2D_Sound_Damage_Range_Team::Damaged(GameObject *obj,GameObject *damager,float amount)
+{
+	if ((Commands->Get_Health(obj) <= Get_Float_Parameter("MaxHealth")) && (Commands->Get_Health(obj) >= Get_Float_Parameter("MinHealth")))
+	{
+		if (enabled)
+		{
+			enabled = false;
+			Create_2D_Sound_Team(Get_Parameter("Sound"),Get_Object_Type(obj));
+		}
+	}
+	else
+	{
+		enabled = true;
+	}
+}
+
+void JFW_2D_Sound_Damage_Range_Team_String::Register_Auto_Save_Variables()
+{
+	Auto_Save_Variable(&enabled,1,1);
+}
+
+void JFW_2D_Sound_Damage_Range_Team_String::Created(GameObject *obj)
+{
+	enabled = true;
+}
+
+extern REF_DECL2(NodHouseColor, Vector3);
+extern REF_DECL2(GDIHouseColor, Vector3);
+void JFW_2D_Sound_Damage_Range_Team_String::Damaged(GameObject *obj,GameObject *damager,float amount)
+{
+	if ((Commands->Get_Health(obj) <= Get_Float_Parameter("MaxHealth")) && (Commands->Get_Health(obj) >= Get_Float_Parameter("MinHealth")))
+	{
+		if (enabled)
+		{
+			enabled = false;
+			Create_2D_Sound_Team(Get_Parameter("Sound"),Get_Object_Type(obj));
+			int red = 0;
+			int blue = 0;
+			int green = 0;
+			if (Get_Object_Type(obj) == 0)
+			{
+				red = (int)(NodHouseColor.X * 255);
+				green = (int)(NodHouseColor.Y * 255);
+				blue = (int)(NodHouseColor.Z * 255);
+			}
+			else
+			{
+				red = (int)(GDIHouseColor.X * 255);
+				green = (int)(GDIHouseColor.Y * 255);
+				blue = (int)(GDIHouseColor.Z * 255);
+			}
+			Send_Message_Team(Get_Object_Type(obj),red,green,blue,Get_Parameter("String"));
+		}
+	}
+	else
+	{
+		enabled = true;
+	}
+}
+
+void JFW_2D_Sound_Damage_Range_Team::Register_Auto_Save_Variables()
+{
+	Auto_Save_Variable(&enabled,1,1);
+}
+
 void JFW_3D_Sound_Damage_Range::Created(GameObject *obj)
 {
 	enabled = true;
@@ -430,7 +500,7 @@
 	c = Get_Parameter("Sound");
 	if (number == timernumber)
 	{
-		if (Is_Vehicle(obj))
+		if (obj->As_VehicleGameObj())
 		{
 			if (Get_Vehicle_Occupant_Count(obj) >= Get_Vehicle_Seat_Count(obj))
 			{
@@ -514,6 +584,8 @@
 ScriptRegistrant<JFW_Fade_Background_Music_On_Enter> JFW_Fade_Background_Music_On_Enter_Registrant("JFW_Fade_Background_Music_On_Enter","Music:string,unk1:int,unk2:int");
 ScriptRegistrant<JFW_Stop_Background_Music_On_Enter> JFW_Stop_Background_Music_On_Enter_Registrant("JFW_Stop_Background_Music_On_Enter","");
 ScriptRegistrant<JFW_2D_Sound_Damage_Range> JFW_2D_Sound_Damage_Range_Registrant("JFW_2D_Sound_Damage_Range","Sound:string,MinHealth:float,MaxHealth:float");
+ScriptRegistrant<JFW_2D_Sound_Damage_Range_Team> JFW_2D_Sound_Damage_Range_Team_Registrant("JFW_2D_Sound_Damage_Range_Team","Sound:string,MinHealth:float,MaxHealth:float");
+ScriptRegistrant<JFW_2D_Sound_Damage_Range_Team_String> JFW_2D_Sound_Damage_Range_Team_String_Registrant("JFW_2D_Sound_Damage_Range_Team_String","Sound:string,MinHealth:float,MaxHealth:float,String:string");
 ScriptRegistrant<JFW_3D_Sound_Damage_Range> JFW_3D_Sound_Damage_Range_Registrant("JFW_3D_Sound_Damage_Range","Sound:string,MinHealth:float,MaxHealth:float,Offset:vector3");
 ScriptRegistrant<JFW_3D_Sound_Timer> JFW_3D_Sound_Timer_Registrant("JFW_3D_Sound_Timer","Time:float,TimerNum:int,Repeat:int,Sound:string,Offset:vector3");
 ScriptRegistrant<JFW_2D_Sound_Damage> JFW_2D_Sound_Damage_Registrant("JFW_2D_Sound_Damage","Sound:string,Health:float");
diff -uwr sourceold/scripts/jfwsnd.h source/scripts/jfwsnd.h
--- sourceold/scripts/jfwsnd.h	2011-10-14 22:27:31.957031200 +0800
+++ source/scripts/jfwsnd.h	2012-05-28 09:47:05.779890700 +0800
@@ -51,6 +51,20 @@
 	public: void Register_Auto_Save_Variables();
 };
 
+class JFW_2D_Sound_Damage_Range_Team : public ScriptImpClass {
+	bool enabled;
+	void Created(GameObject *obj);
+	void Damaged(GameObject *obj,GameObject *damager,float amount);
+	public: void Register_Auto_Save_Variables();
+};
+
+class JFW_2D_Sound_Damage_Range_Team_String : public ScriptImpClass {
+	bool enabled;
+	void Created(GameObject *obj);
+	void Damaged(GameObject *obj,GameObject *damager,float amount);
+	public: void Register_Auto_Save_Variables();
+};
+
 class JFW_3D_Sound_Damage_Range : public ScriptImpClass {
 	bool enabled;
 	void Created(GameObject *obj);
diff -uwr sourceold/scripts/jfwveh.cpp source/scripts/jfwveh.cpp
--- sourceold/scripts/jfwveh.cpp	2012-02-23 12:06:21.760742100 +0800
+++ source/scripts/jfwveh.cpp	2012-04-24 21:25:31.486328100 +0800
@@ -902,7 +902,7 @@
 		if (!active)
 		{
 			GameObject *vobj = 0;
-			if (Is_Vehicle(enterer))
+			if (enterer->As_VehicleGameObj())
 			{
 				vobj = enterer;
 			}
@@ -929,17 +929,22 @@
 	Vector3 pos2;
 	float distance;
 	GameObject *object = Commands->Find_Object(number);
+	if (!object)
+	{
+		return;
+	}
 	pos1 = Commands->Get_Position(obj);
 	pos2 = Commands->Get_Position(object);
 	distance = Commands->Get_Distance(pos1,pos2);
 	if (distance <= 10.0)
 	{
-		if (Is_Vehicle(object))
+		if (object->As_VehicleGameObj())
 		{
 			if (Get_Vehicle_Mode(object) == VEHICLE_TYPE_FLYING && Get_Vehicle_Driver(object))
 			{
 				Commands->Give_PowerUp(object,Get_Parameter("Reload_Powerup"),false);
 				Commands->Start_Timer(obj, this, Get_Float_Parameter("Reload_Interval"), number);
+				active = true;
 			}
 		}
 	}
diff -uwr sourceold/scripts/jfwzone.cpp source/scripts/jfwzone.cpp
--- sourceold/scripts/jfwzone.cpp	2012-02-23 12:11:58.802734300 +0800
+++ source/scripts/jfwzone.cpp	2012-05-28 09:47:05.711531300 +0800
@@ -23,6 +23,7 @@
 #include "BuildingGameObjDef.h"
 #include "dp88_custom_timer_defines.h"
 #include "PhysicalGameObj.h"
+#include "VehicleGameObj.h"
 
 void JFW_3D_Sound_Zone::Entered(GameObject *obj,GameObject *enterer)
 {
@@ -379,7 +380,7 @@
 	{
 		return;
 	}
-	if (Is_Vehicle(enterer))
+	if (enterer->As_VehicleGameObj())
 	{
 		Commands->Start_Timer(obj,this,1.0,Commands->Get_ID(enterer));
 	}
@@ -399,13 +400,20 @@
 		float Health = Commands->Get_Health(Commands->Find_Object(number));
 		float Max_Shield_Strength = Commands->Get_Max_Shield_Strength(Commands->Find_Object(number));
 		float Shield_Strength = Commands->Get_Shield_Strength(Commands->Find_Object(number));
+		bool repair = false;
 		if (Health < Max_Health)
 		{
 			Commands->Set_Health(Commands->Find_Object(number),Health + Get_Float_Parameter("Repair_Health"));
+			repair = true;
 		}
 		if (Shield_Strength < Max_Shield_Strength)
 		{
 			Commands->Set_Shield_Strength(Commands->Find_Object(number),Shield_Strength + Get_Float_Parameter("Repair_Health"));
+			repair = true;
+		}
+		if (repair && Commands->Find_Object(number)->As_VehicleGameObj())
+		{
+			Commands->Find_Object(number)->As_VehicleGameObj()->Damage_Meshes_Update(); //repair was done, update damage meshes
 		}
 		Commands->Start_Timer(obj,this,1.0,number);
 	}
@@ -420,7 +428,7 @@
 	}
 	if ((!_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset1"))) || (!_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset2"))) || (!_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset3"))) || (!_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset4"))) || (!_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset5"))) || (!_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset6"))) || (!_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset7"))) || (!_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset8"))))
 	{
-		if (Is_Vehicle(enterer))
+		if (enterer->As_VehicleGameObj())
 		{
 			Commands->Start_Timer(obj,this,1.0,Commands->Get_ID(enterer));
 		}
@@ -441,13 +449,20 @@
 		float Health = Commands->Get_Health(Commands->Find_Object(number));
 		float Max_Shield_Strength = Commands->Get_Max_Shield_Strength(Commands->Find_Object(number));
 		float Shield_Strength = Commands->Get_Shield_Strength(Commands->Find_Object(number));
+		bool repair = false;
 		if (Health < Max_Health)
 		{
 			Commands->Set_Health(Commands->Find_Object(number),Health + Get_Float_Parameter("Repair_Health"));
+			repair = true;
 		}
 		if (Shield_Strength < Max_Shield_Strength)
 		{
 			Commands->Set_Shield_Strength(Commands->Find_Object(number),Shield_Strength + Get_Float_Parameter("Repair_Health"));
+			repair = true;
+		}
+		if (repair && Commands->Find_Object(number)->As_VehicleGameObj())
+		{
+			Commands->Find_Object(number)->As_VehicleGameObj()->Damage_Meshes_Update(); //repair was done, update damage meshes
 		}
 		Commands->Start_Timer(obj,this,1.0,number);
 	}
@@ -462,7 +477,7 @@
 	}
 	if ((_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset1"))) && (_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset2"))) && (_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset3"))) && (_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset4"))) && (_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset5"))) && (_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset6"))) && (_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset7"))) && (_stricmp(Commands->Get_Preset_Name(enterer),Get_Parameter("Preset8"))))
 	{
-		if (Is_Vehicle(enterer))
+		if (enterer->As_VehicleGameObj())
 		{
 			Commands->Start_Timer(obj,this,1.0,Commands->Get_ID(enterer));
 		}
@@ -483,13 +498,20 @@
 		float Health = Commands->Get_Health(Commands->Find_Object(number));
 		float Max_Shield_Strength = Commands->Get_Max_Shield_Strength(Commands->Find_Object(number));
 		float Shield_Strength = Commands->Get_Shield_Strength(Commands->Find_Object(number));
+		bool repair = false;
 		if (Health < Max_Health)
 		{
 			Commands->Set_Health(Commands->Find_Object(number),Health + Get_Float_Parameter("Repair_Health"));
+			repair = true;
 		}
 		if (Shield_Strength < Max_Shield_Strength)
 		{
 			Commands->Set_Shield_Strength(Commands->Find_Object(number),Shield_Strength + Get_Float_Parameter("Repair_Health"));
+			repair = true;
+		}
+		if (repair && Commands->Find_Object(number)->As_VehicleGameObj())
+		{
+			Commands->Find_Object(number)->As_VehicleGameObj()->Damage_Meshes_Update(); //repair was done, update damage meshes
 		}
 		Commands->Start_Timer(obj,this,1.0,number);
 	}
@@ -630,7 +652,7 @@
 	{
 		return;
 	}
-	if (Is_Soldier(obj))
+	if (enterer->As_SoldierGameObj())
 	{
 		Commands->Start_Timer(obj,this,1.0,Commands->Get_ID(enterer));
 	}
@@ -703,7 +725,7 @@
 
 void JFW_Disable_Transitions_Zone::Entered(GameObject *obj,GameObject *enterer)
 {
-	if (Is_Vehicle(enterer))
+	if (enterer->As_VehicleGameObj())
 	{
 		Commands->Enable_Vehicle_Transitions(enterer,false);
 	}
@@ -711,7 +733,7 @@
 
 void JFW_Disable_Transitions_Zone::Exited(GameObject *obj,GameObject *exiter)
 {
-	if (Is_Vehicle(exiter))
+	if (exiter->As_VehicleGameObj())
 	{
 		Commands->Enable_Vehicle_Transitions(exiter,true);
 	}
@@ -729,7 +751,7 @@
 	}
 	pos = Commands->Get_Position(enterer);
 	pos.Z += Get_Float_Parameter("ZAmount");
-	angle = Commands->Get_Facing(obj);
+	angle = DEG_TO_RADF(Commands->Get_Facing(obj));
 	pos.X += Get_Float_Parameter("Amount")*(float)cos(angle);
 	pos.Y += Get_Float_Parameter("Amount")*(float)sin(angle);
 	Commands->Set_Position(enterer,pos);
@@ -767,7 +789,7 @@
 
 void JFW_Vechicle_Damage_Zone::Entered(GameObject *obj,GameObject *enterer)
 {
-	if (Is_Vehicle(enterer))
+	if (enterer->As_VehicleGameObj())
 	{
 		int Player_Type = Get_Int_Parameter("Player_Type");
 		if (CheckPlayerType(enterer,Player_Type))
@@ -899,7 +921,7 @@
 	{
 		return;
 	}
-	if (Is_Vehicle(enterer))
+	if (enterer->As_VehicleGameObj())
 	{
 		if (Get_Vehicle_Mode(enterer) == VEHICLE_TYPE_FLYING)
 		{
@@ -922,13 +944,20 @@
 		float Health = Commands->Get_Health(Commands->Find_Object(number));
 		float Max_Shield_Strength = Commands->Get_Max_Shield_Strength(Commands->Find_Object(number));
 		float Shield_Strength = Commands->Get_Shield_Strength(Commands->Find_Object(number));
+		bool repair = false;
 		if (Health < Max_Health)
 		{
 			Commands->Set_Health(Commands->Find_Object(number),Health + Get_Float_Parameter("Repair_Health"));
+			repair = true;
 		}
 		if (Shield_Strength < Max_Shield_Strength)
 		{
 			Commands->Set_Shield_Strength(Commands->Find_Object(number),Shield_Strength + Get_Float_Parameter("Repair_Health"));
+			repair = true;
+		}
+		if (repair && Commands->Find_Object(number)->As_VehicleGameObj())
+		{
+			Commands->Find_Object(number)->As_VehicleGameObj()->Damage_Meshes_Update(); //repair was done, update damage meshes
 		}
 		Commands->Start_Timer(obj,this,1.0,number);
 	}
@@ -941,7 +970,7 @@
 	{
 		return;
 	}
-	if (Is_Vehicle(enterer))
+	if (enterer->As_VehicleGameObj())
 	{
 		if (Get_Vehicle_Mode(enterer) != VEHICLE_TYPE_FLYING)
 		{
@@ -964,13 +993,20 @@
 		float Health = Commands->Get_Health(Commands->Find_Object(number));
 		float Max_Shield_Strength = Commands->Get_Max_Shield_Strength(Commands->Find_Object(number));
 		float Shield_Strength = Commands->Get_Shield_Strength(Commands->Find_Object(number));
+		bool repair = false;
 		if (Health < Max_Health)
 		{
 			Commands->Set_Health(Commands->Find_Object(number),Health + Get_Float_Parameter("Repair_Health"));
+			repair = true;
 		}
 		if (Shield_Strength < Max_Shield_Strength)
 		{
 			Commands->Set_Shield_Strength(Commands->Find_Object(number),Shield_Strength + Get_Float_Parameter("Repair_Health"));
+			repair = true;
+		}
+		if (repair && Commands->Find_Object(number)->As_VehicleGameObj())
+		{
+			Commands->Find_Object(number)->As_VehicleGameObj()->Damage_Meshes_Update(); //repair was done, update damage meshes
 		}
 		Commands->Start_Timer(obj,this,1.0,number);
 	}
@@ -1545,7 +1581,7 @@
 
 void JFW_Heavy_Vehicle_Damage_Zone::Entered(GameObject *obj,GameObject *enterer)
 {
-	if (Is_Vehicle(enterer))
+	if (enterer->As_VehicleGameObj())
 	{
 		int Player_Type = Get_Int_Parameter("Player_Type");
 		if ((CheckPlayerType(enterer,Player_Type)) || (Get_Mass(enterer) < Get_Float_Parameter("Mass")))
@@ -1577,7 +1613,7 @@
 
 void JFW_Light_Vehicle_Damage_Zone::Entered(GameObject *obj,GameObject *enterer)
 {
-	if (Is_Vehicle(enterer))
+	if (enterer->As_VehicleGameObj())
 	{
 		int Player_Type = Get_Int_Parameter("Player_Type");
 		if ((CheckPlayerType(enterer,Player_Type)) || (Get_Mass(enterer) > Get_Float_Parameter("Mass")))
@@ -1877,7 +1913,7 @@
 
 void JFW_Vehicle_Zone_Animation::Entered(GameObject *obj,GameObject *enterer)
 {
-	if (Is_Vehicle(enterer))
+	if (enterer->As_VehicleGameObj())
 	{
 		if (!refcount)
 		{
@@ -1918,7 +1954,7 @@
 
 void JFW_Vehicle_Zone_Animation::Exited(GameObject *obj,GameObject *exiter)
 {
-	if (Is_Vehicle(exiter))
+	if (exiter->As_VehicleGameObj())
 	{
 		refcount--;
 		if (!refcount)
@@ -2093,7 +2129,7 @@
 	{
 		return;
 	}
-	if ((Is_Building_Dead(Find_Com_Center(Commands->Get_Player_Type(enterer))) && (Is_Radar_Enabled(PTTEAM(Commands->Get_Player_Type(enterer))))))
+	if (Find_Com_Center(Commands->Get_Player_Type(enterer)) && (Is_Building_Dead(Find_Com_Center(Commands->Get_Player_Type(enterer))) && (Is_Radar_Enabled(PTTEAM(Commands->Get_Player_Type(enterer))))))
 	{
 		Create_2D_Sound_Team(Get_Parameter("Sound"),Commands->Get_Player_Type(enterer));
 		Enable_Base_Radar(Get_Object_Type(enterer),true);
@@ -2116,7 +2152,7 @@
 	{
 		return;
 	}
-	if ((Is_Building_Dead(Find_Com_Center(Commands->Get_Player_Type(enterer))) && (Is_Radar_Enabled(PTTEAM(Commands->Get_Player_Type(enterer))))))
+	if (Find_Com_Center(Commands->Get_Player_Type(enterer)) && (Is_Building_Dead(Find_Com_Center(Commands->Get_Player_Type(enterer))) && (Is_Radar_Enabled(PTTEAM(Commands->Get_Player_Type(enterer))))))
 	{
 		Create_2D_Sound_Team(Get_Parameter("Sound"),Commands->Get_Player_Type(enterer));
 		Enable_Base_Radar(Get_Object_Type(enterer),true);
@@ -2162,7 +2198,7 @@
 	{
 		return;
 	}
-	if (Is_Vehicle(enterer))
+	if (enterer->As_VehicleGameObj())
 	{
 		Create_2D_Sound_Player(Get_Vehicle_Driver(enterer),Get_Parameter("Sound"));
 		InstallHook("Repair",Get_Vehicle_Driver(enterer));
@@ -2207,6 +2243,10 @@
 				}
 				if (cost_scale > 0)
 				{
+					if (Commands->Find_Object(number)->As_VehicleGameObj())
+					{
+						Commands->Find_Object(number)->As_VehicleGameObj()->Damage_Meshes_Update(); //repair was done, update damage meshes
+					}
 					Commands->Give_Money(Get_Vehicle_Driver(Commands->Find_Object(number)),-cost * cost_scale,false);
 					Commands->Start_Timer(obj,this,1.0,number);
 					return;
@@ -2273,7 +2313,7 @@
 	{
 		return;
 	}
-	if (Is_Vehicle(enterer) && !Is_Script_Attached(enterer,"JFW_Boat"))
+	if (enterer->As_VehicleGameObj() && Get_Vehicle_Mode(enterer) != VEHICLE_TYPE_BOAT && Get_Vehicle_Mode(enterer) != VEHICLE_TYPE_SUB)
 	{
 		Create_2D_Sound_Player(Get_Vehicle_Driver(enterer),Get_Parameter("Sound"));
 		InstallHook("Repair",Get_Vehicle_Driver(enterer));
@@ -2318,6 +2358,10 @@
 				}
 				if (cost_scale > 0)
 				{
+					if (Commands->Find_Object(number)->As_VehicleGameObj())
+					{
+						Commands->Find_Object(number)->As_VehicleGameObj()->Damage_Meshes_Update(); //repair was done, update damage meshes
+					}
 					Commands->Give_Money(Get_Vehicle_Driver(Commands->Find_Object(number)),-cost * cost_scale,false);
 					Commands->Start_Timer(obj,this,1.0,number);
 					return;
@@ -2384,7 +2428,7 @@
 	{
 		return;
 	}
-	if (Is_Vehicle(enterer) && Is_Script_Attached(enterer,"JFW_Boat"))
+	if (enterer->As_VehicleGameObj() && (Get_Vehicle_Mode(enterer) == VEHICLE_TYPE_BOAT || Get_Vehicle_Mode(enterer) == VEHICLE_TYPE_SUB))
 	{
 		Create_2D_Sound_Player(Get_Vehicle_Driver(enterer),Get_Parameter("Sound"));
 		InstallHook("Repair",Get_Vehicle_Driver(enterer));
@@ -2429,6 +2473,10 @@
 				}
 				if (cost_scale > 0)
 				{
+					if (Commands->Find_Object(number)->As_VehicleGameObj())
+					{
+						Commands->Find_Object(number)->As_VehicleGameObj()->Damage_Meshes_Update(); //repair was done, update damage meshes
+					}
 					Commands->Give_Money(Get_Vehicle_Driver(Commands->Find_Object(number)),-cost * cost_scale,false);
 					Commands->Start_Timer(obj,this,1.0,number);
 					return;
@@ -2495,7 +2543,7 @@
 	{
 		return;
 	}
-	if (Is_Vehicle(enterer))
+	if (enterer->As_VehicleGameObj())
 	{
 		Create_2D_Sound_Player(Get_Vehicle_Driver(enterer),Get_Parameter("Sound"));
 		InstallHook("Sell",Get_Vehicle_Driver(enterer));
@@ -2525,7 +2573,7 @@
 		RemoveHook();
 		ID = 0;
 	}
-	if (Is_Vehicle(Commands->Find_Object(ID)))
+	if (Commands->Find_Object(ID)->As_VehicleGameObj())
 	{
 		if (Get_Vehicle_Driver(Commands->Find_Object(ID)))
 		{
@@ -3027,21 +3075,9 @@
 	if (object)
 	{
 		Vector3 v = Get_Vector3_Parameter("Size");
-		object->Get_Bounding_Box().Extent.X = v.X;
-		object->Get_Bounding_Box().Extent.Y = v.Y;
-		object->Get_Bounding_Box().Extent.Z = v.Z;
-		float z = Get_Float_Parameter("ZRotate");
-		float c = cos(z);
-		float s = sin(z);
-		object->Get_Bounding_Box().Basis[0].X = c;
-		object->Get_Bounding_Box().Basis[0].Y = -s;
-		object->Get_Bounding_Box().Basis[0].Z = 0;
-		object->Get_Bounding_Box().Basis[1].X = s;
-		object->Get_Bounding_Box().Basis[1].Y = c;
-		object->Get_Bounding_Box().Basis[1].Z = 0;
-		object->Get_Bounding_Box().Basis[2].X = 0;
-		object->Get_Bounding_Box().Basis[2].Y = 0;
-		object->Get_Bounding_Box().Basis[2].Z = 1;
+		object->Get_Bounding_Box().Extent = v;
+		float z = DEG_TO_RADF(Get_Float_Parameter("ZRotate"));
+		object->Get_Bounding_Box().Basis.Rotate_Z(z);
 	}
 	Destroy_Script();
 }
@@ -3136,11 +3172,11 @@
 		return;
 	}
 	team = Commands->Get_Player_Type(enterer);
-	if (Is_Base_Powered(PTTEAM(team)) && !reset && (!Is_Building_Dead(Find_Building(PTTEAM(team),BuildingConstants::TYPE_POWER_PLANT))))
+	if (Is_Base_Powered(PTTEAM(team)) && !reset && Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_POWER_PLANT) && (!Is_Building_Dead(Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_POWER_PLANT))))
 	{
 		Create_2D_Sound_Team(Get_Parameter("Sound"),team);
 		Power_Base(PTTEAM(team),false);
-		GameObject *o = Find_Building(PTTEAM(team),BuildingConstants::TYPE_COM_CENTER);
+		GameObject *o = Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_COM_CENTER);
 		if (o && !Is_Building_Dead(o))
 		{
 			Enable_Base_Radar(PTTEAM(team),false);
@@ -3151,11 +3187,11 @@
 
 void JFW_Power_Spy_Zone::Timer_Expired(GameObject *obj,int number)
 {
-	if ((number == 1) && (!Is_Building_Dead(Find_Building(PTTEAM(team),BuildingConstants::TYPE_POWER_PLANT))))
+	if ((number == 1) && Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_POWER_PLANT) && (!Is_Building_Dead(Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_POWER_PLANT))))
 	{
 		Create_2D_Sound_Team(Get_Parameter("Sound2"),PTTEAM(team));
 		Power_Base(PTTEAM(team),true);
-		GameObject *o = Find_Building(PTTEAM(team),BuildingConstants::TYPE_COM_CENTER);
+		GameObject *o = Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_COM_CENTER);
 		if (o && !Is_Building_Dead(o))
 		{
 			Enable_Base_Radar(PTTEAM(team),true);
@@ -3210,11 +3246,11 @@
 		return;
 	}
 	team = Commands->Get_Player_Type(enterer);
-	if (Is_Base_Powered(PTTEAM(team)) && !reset && (!Is_Building_Dead(Find_Building(PTTEAM(team),BuildingConstants::TYPE_POWER_PLANT))))
+	if (Is_Base_Powered(PTTEAM(team)) && !reset && Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_POWER_PLANT) && (!Is_Building_Dead(Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_POWER_PLANT))))
 	{
 		Create_2D_Sound_Team(Get_Parameter("Sound"),team);
 		Power_Base(PTTEAM(team),false);
-		GameObject *o = Find_Building(PTTEAM(team),BuildingConstants::TYPE_COM_CENTER);
+		GameObject *o = Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_COM_CENTER);
 		if (o && !Is_Building_Dead(o))
 		{
 			Enable_Base_Radar(PTTEAM(team),false);
@@ -3225,11 +3261,11 @@
 
 void JFW_Power_Spy_Zone_New::Timer_Expired(GameObject *obj,int number)
 {
-	if ((number == 1) && (!Is_Building_Dead(Find_Building(PTTEAM(team),BuildingConstants::TYPE_POWER_PLANT))))
+	if ((number == 1) && Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_POWER_PLANT) && (!Is_Building_Dead(Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_POWER_PLANT))))
 	{
 		Create_2D_Sound_Team(Get_Parameter("Sound2"),PTTEAM(team));
 		Power_Base(PTTEAM(team),true);
-		GameObject *o = Find_Building(PTTEAM(team),BuildingConstants::TYPE_COM_CENTER);
+		GameObject *o = Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_COM_CENTER);
 		if (o && !Is_Building_Dead(o))
 		{
 			Enable_Base_Radar(PTTEAM(team),true);
@@ -3255,23 +3291,23 @@
 	{
 		return;
 	}
-	int team = Commands->Get_Player_Type(enterer);
-	if (!cydisabled && !reset && (!Is_Building_Dead(Find_Building(PTTEAM(team),BuildingConstants::TYPE_CONYARD))))
+	team = Commands->Get_Player_Type(enterer);
+	if (!cydisabled && !reset && Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_CONYARD) && (!Is_Building_Dead(Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_CONYARD))))
 	{
 		Create_2D_Sound_Team(Get_Parameter("Sound"),team);
 		cydisabled = true;
-		Commands->Send_Custom_Event(obj,Find_Building(PTTEAM(team),BuildingConstants::TYPE_CONYARD),3000,320023,0);
+		Commands->Send_Custom_Event(obj,Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_CONYARD),3000,320023,0);
 		Commands->Start_Timer(obj,this,Get_Float_Parameter("Power_Time"),1);
 	}
 }
 
 void JFW_Conyard_Spy_Zone::Timer_Expired(GameObject *obj,int number)
 {
-	if ((number == 1) && (!Is_Building_Dead(Find_Building(PTTEAM(team),BuildingConstants::TYPE_CONYARD))))
+	if ((number == 1) && Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_CONYARD) && (!Is_Building_Dead(Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_CONYARD))))
 	{
 		Create_2D_Sound_Team(Get_Parameter("Sound2"),PTTEAM(team));
 		cydisabled = false;
-		Commands->Send_Custom_Event(obj,Find_Building(PTTEAM(team),BuildingConstants::TYPE_CONYARD),3000,230032,0);
+		Commands->Send_Custom_Event(obj,Find_Building_By_Type(PTTEAM(team),BuildingConstants::TYPE_CONYARD),3000,230032,0);
 		reset = true;
 		Commands->Start_Timer(obj,this,Get_Float_Parameter("Reset_Time"),2);
 	}
@@ -3293,8 +3329,8 @@
 	{
 		return;
 	}
-	int team = Commands->Get_Player_Type(enterer);
-	if (!cydisabled && !reset && (!Is_Building_Dead(Find_Construction_Yard(PTTEAM(team)))))
+	team = Commands->Get_Player_Type(enterer);
+	if (!cydisabled && !reset && Find_Construction_Yard(PTTEAM(team)) && (!Is_Building_Dead(Find_Construction_Yard(PTTEAM(team)))))
 	{
 		Create_2D_Sound_Team(Get_Parameter("Sound"),team);
 		cydisabled = true;
@@ -3306,7 +3342,7 @@
 
 void JFW_Conyard_Spy_Zone_2::Timer_Expired(GameObject *obj,int number)
 {
-	if ((number == 1) && (!Is_Building_Dead(Find_Building(PTTEAM(team),BuildingConstants::TYPE_CONYARD))))
+	if ((number == 1) && Find_Construction_Yard(PTTEAM(team)) && (!Is_Building_Dead(Find_Construction_Yard(PTTEAM(team)))))
 	{
 		Create_2D_Sound_Team(Get_Parameter("Sound2"),PTTEAM(team));
 		cydisabled = false;
@@ -3333,8 +3369,8 @@
 	{
 		return;
 	}
-	int team = Commands->Get_Player_Type(enterer);
-	if (!cydisabled && !reset && (!Is_Building_Dead(Find_Construction_Yard(PTTEAM(team)))))
+	team = Commands->Get_Player_Type(enterer);
+	if (!cydisabled && !reset && Find_Construction_Yard(PTTEAM(team)) && (!Is_Building_Dead(Find_Construction_Yard(PTTEAM(team)))))
 	{
 		Create_2D_Sound_Team(Get_Parameter("Sound"),team);
 		cydisabled = true;
@@ -3346,7 +3382,7 @@
 
 void JFW_Conyard_Spy_Zone_2_New::Timer_Expired(GameObject *obj,int number)
 {
-	if ((number == 1) && (!Is_Building_Dead(Find_Building(PTTEAM(team),BuildingConstants::TYPE_CONYARD))))
+	if ((number == 1) && Find_Construction_Yard(PTTEAM(team)) && (!Is_Building_Dead(Find_Construction_Yard(PTTEAM(team)))))
 	{
 		Create_2D_Sound_Team(Get_Parameter("Sound2"),PTTEAM(team));
 		cydisabled = false;
@@ -3361,6 +3397,15 @@
 	}
 }
 
+void JFW_Destroy_Vehicle_Zone::Entered(GameObject *obj,GameObject *enterer)
+{
+	if (enterer->As_VehicleGameObj())
+	{
+		Attach_Script_Occupants(enterer,"RA_DriverDeath", "0");
+	}
+	Commands->Apply_Damage(enterer,99999,"Death",0);
+}
+
 ScriptRegistrant<JFW_Look_At_Location_Entry> JFW_Look_At_Location_Entry("JFW_Look_At_Location_Entry","Player_Type:int,Location:vector3");
 ScriptRegistrant<JFW_Look_At_Object_Entry> JFW_Look_At_Object_Entry("JFW_Look_At_Object_Entry","Player_Type:int,ObjectID:int");
 ScriptRegistrant<JFW_Zone_PCT> JFW_Zone_PCT_Registrant("JFW_Zone_PCT","Player_Type:int");
@@ -3452,3 +3497,4 @@
 ScriptRegistrant<JFW_Custom_Spawn_Zone> JFW_Custom_Spawn_Zone_Registrant("JFW_Custom_Spawn_Zone","Position:vector3,Size:vector3,ZRotate:float,SpawnCustom:int,DestroyCustom:int,Preset:string");
 ScriptRegistrant<JFW_Spawn_Zone_Created> JFW_Spawn_Zone_Created_Registrant("JFW_Spawn_Zone_Created","Offset:vector3,Size:vector3,ZRotate:float,Preset:string");
 ScriptRegistrant<JFW_Boat> JFW_Boat_Registrant("JFW_Boat","");
+ScriptRegistrant<JFW_Destroy_Vehicle_Zone> JFW_Destroy_Vehicle_Zone_Registrant("JFW_Destroy_Vehicle_Zone","");
diff -uwr sourceold/scripts/jfwzone.h source/scripts/jfwzone.h
--- sourceold/scripts/jfwzone.h	2012-02-13 18:44:52.651765600 +0800
+++ source/scripts/jfwzone.h	2012-04-15 11:56:05.470093800 +0800
@@ -542,3 +542,7 @@
 
 class JFW_Boat : public ScriptImpClass {
 };
+
+class JFW_Destroy_Vehicle_Zone : public ScriptImpClass {
+	void Entered(GameObject *obj,GameObject *enterer);
+};
diff -uwr sourceold/scripts/jmgrp2.cpp source/scripts/jmgrp2.cpp
--- sourceold/scripts/jmgrp2.cpp	2011-10-11 23:05:24.216796800 +0800
+++ source/scripts/jmgrp2.cpp	2012-04-24 21:25:30.842773400 +0800
@@ -26,6 +26,10 @@
 #include <float.h>
 #include <time.h>
 #include "VehicleGameObj.h"
+#include "BuildingGameObj.h"
+#include "ScriptZoneGameObj.h"
+#include "ScriptableGameObj.h"
+#include "BeaconGameObj.h"
 #define VERSION "2.2.9:1.0 Alpha"
 char MAPVERSION[100] = "Not Available";
 #define PLUGINVERSIONNUMBER 3
@@ -1074,7 +1078,7 @@
 
 int Get_Gun_Position(GameObject *obj,const char *WeaponName)
 {
-	PhysicalGameObj *o2 = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
 	if (!o2){return 0;}
 	ArmedGameObj *o3 = o2->As_ArmedGameObj();
 	if (!o3){return 0;}
@@ -2848,42 +2852,42 @@
 	{
 		if (MyMissionNode->FailOnTrackedVehicle)
 		{
-			if (Is_TrackedVehicle(sender))
+			if (sender->As_PhysicalGameObj() && sender->As_PhysicalGameObj()->Peek_Physical_Object() && sender->As_PhysicalGameObj()->Peek_Physical_Object()->As_TrackedVehicleClass())
 			{
 				Scan_For_Vehicle_Conflicts(obj,MyMissionNode->FailOnTrackedVehicle);
 			}
 		}
 		if (MyMissionNode->FailOnMotorcycle)
 		{
-			if (Is_Motorcycle(sender))
+			if (sender->As_PhysicalGameObj() && sender->As_PhysicalGameObj()->Peek_Physical_Object() && sender->As_PhysicalGameObj()->Peek_Physical_Object()->As_MotorcycleClass())
 			{
 				Scan_For_Vehicle_Conflicts(obj,MyMissionNode->FailOnMotorcycle);
 			}
 		}
 		if (MyMissionNode->FailOnTurret)
 		{
-			if (Is_WheeledVehicle(sender))
+			if (sender->As_PhysicalGameObj() && sender->As_PhysicalGameObj()->Peek_Physical_Object() && sender->As_PhysicalGameObj()->Peek_Physical_Object()->As_WheeledVehicleClass())
 			{
 				Scan_For_Vehicle_Conflicts(obj,MyMissionNode->FailOnTurret);
 			}
 		}
 		if (MyMissionNode->FailOnWheeledVehicle)
 		{
-			if (Is_Phys3(sender))
+			if (sender->As_PhysicalGameObj() && sender->As_PhysicalGameObj()->Peek_Physical_Object() && sender->As_PhysicalGameObj()->Peek_Physical_Object()->As_Phys3Class())
 			{
 				Scan_For_Vehicle_Conflicts(obj,MyMissionNode->FailOnWheeledVehicle);
 			}
 		}
 		if (MyMissionNode->FailOnAircraft)
 		{
-			if (Is_VTOLVehicle(sender) && !Is_Script_Attached(sender,"JMG_Boat_To_High"))
+			if (sender->As_PhysicalGameObj() && sender->As_PhysicalGameObj()->Peek_Physical_Object() && sender->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass() && !Is_Script_Attached(sender,"JMG_Boat_To_High"))
 			{
 				Scan_For_Vehicle_Conflicts(obj,MyMissionNode->FailOnAircraft);
 			}
 		}
 		if (MyMissionNode->FailOnBoat)
 		{
-			if (Is_VTOLVehicle(sender) && Is_Script_Attached(sender,"JMG_Boat_To_High"))
+			if (sender->As_PhysicalGameObj() && sender->As_PhysicalGameObj()->Peek_Physical_Object() && sender->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass() && Is_Script_Attached(sender,"JMG_Boat_To_High"))
 			{
 				Scan_For_Vehicle_Conflicts(obj,MyMissionNode->FailOnBoat);
 			}	
@@ -4102,12 +4106,12 @@
 	if (41352349 == number)
 	{
 		Vector3 pos = Commands->Get_Position(obj);
-		if (Commands->Get_Position(obj).Z < Create_Height && As_PhysicalGameObj(obj))
+		if (Commands->Get_Position(obj).Z < Create_Height && obj->As_PhysicalGameObj())
 		{
 			Vector3 OldPos = pos;
 			pos.Z = Create_Height;
 			Commands->Set_Position(obj,pos);
-			PhysicalGameObj *objphys = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+			PhysicalGameObj *objphys = obj->As_PhysicalGameObj();
 			if (!objphys->Peek_Physical_Object()->As_MoveablePhysClass()->Can_Teleport(objphys->Get_Transform(),false))
 			{
 				Commands->Set_Position(obj,OldPos);
@@ -7332,11 +7336,11 @@
 void JMG_Real_Plane_Physics::Custom(GameObject *obj,int message,int param,GameObject *sender)
 {
 
-	if (message == 1000000028)
+	if (message == CUSTOM_EVENT_VEHICLE_ENTERED)
 	{
 		occupied++;
 	}
-	if (message == 1000000029)
+	if (message == CUSTOM_EVENT_VEHICLE_EXITED)
 	{
 		occupied--;
 		if (occupied == 0)
@@ -7500,7 +7504,7 @@
 
 void JMG_Keyboard_Vehicle_Input_Custom::Custom(GameObject *obj,int message,int param,GameObject *sender)
 {
-	if (message == 1000000029)
+	if (message == CUSTOM_EVENT_VEHICLE_EXITED)
 	{
 		int r, end = 0;
 		for(r = 0;r < 10 && end == 0;r++)
@@ -7516,7 +7520,7 @@
 		Attach_Script_Once(sender,"JMG_Keyboard_Input_Custom_ID_Veh",params);
 		Remove_Script(sender,"JMG_Keyboard_Input_Custom_ID_Veh");
 	}
-	if (message == 1000000028)
+	if (message == CUSTOM_EVENT_VEHICLE_ENTERED)
 	{
 		int r, end = 0, msg;
 		int SenderID = Commands->Get_ID(sender);
@@ -7620,7 +7624,7 @@
 void JMG_RP2_Teleport_Zone_Script::Entered(GameObject *obj,GameObject *enter)//For Doors
 {
 	char params[128];
-	if (Is_HumanPhys(enter) && !Get_Vehicle(enter) && Commands->Is_A_Star(enter))
+	if ((enter->As_PhysicalGameObj() && enter->As_PhysicalGameObj()->Peek_Physical_Object() && enter->As_PhysicalGameObj()->Peek_Physical_Object()->As_HumanPhysClass()) && !Get_Vehicle(enter) && Commands->Is_A_Star(enter))
 	{
 		sprintf(params,"%f,%f,%f,%f,%f,%s,%s,%s,%s,%s",Teleport_Pos.X,Teleport_Pos.Y,Teleport_Pos.Z,Get_Float_Parameter("Enter_Rotation"),Get_Float_Parameter("Exit_Rotation"),Get_Parameter("Enter_Animation"),Get_Parameter("Exit_Animation"),Get_Parameter("Enter_Path_Animation"),Get_Parameter("Exit_Path_Animation"),Get_Parameter("Bone_Attach_Name"));
 		Attach_Script_Once(enter,"JMG_RP2_Teleport_Zone_Script_Attach",params);
@@ -7669,7 +7673,7 @@
 		pos.Y = Get_Float_Parameter("Y");
 		pos.Z = Get_Float_Parameter("Z");
 		Vector3 ExitPos = pos;
-		PhysicalGameObj *objphys = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+		PhysicalGameObj *objphys = obj->As_PhysicalGameObj();
 		objphys->As_PhysicalGameObj()->Peek_Physical_Object()->As_MoveablePhysClass()->Find_Teleport_Location(pos,1.0f,&ExitPos);
 		Commands->Set_Position(obj,ExitPos);
 		Set_Screen_Fade_Opacity_Player(obj,1.0f,0.1f);
@@ -7757,7 +7761,7 @@
 
 void JMG_RP2_Renhalo_Vortex::Enemy_Seen(GameObject *obj,GameObject *seen)
 {
-	if (Is_Soldier(seen) == 1)
+	if (seen->As_SoldierGameObj())
 	{
 		if (Commands->Is_A_Star(seen))
 		{
@@ -8009,7 +8013,7 @@
 	if (Node)
 	{
 		Vector3 Pos = Node->Telepos;
-		if (Is_Vehicle(enter))
+		if (enter->As_VehicleGameObj())
 		{
 			Pos.Z += 5.0f;
 			Commands->Send_Custom_Event(obj,Get_Vehicle_Driver(enter),PHONEAquiredSignal,1,0);
@@ -8179,7 +8183,7 @@
 void JMG_Set_Ammo_On_Enter_Reset_On_Exit::Entered(GameObject *obj,GameObject *enter)
 {
 	int x, end,y = 0;
-	if (Is_Vehicle(enter) == 0)
+	if (!enter->As_VehicleGameObj())
 	{
 		end = 0;
 		for (x = 0;x < 125 && end == 0;x++)
@@ -8199,7 +8203,7 @@
 			}
 		}
 	}
-	if (Is_Vehicle(enter) == 1)
+	if (enter->As_VehicleGameObj())
 	{
 		while (y <= Get_Vehicle_Seat_Count(enter))
 		{
@@ -8240,7 +8244,7 @@
 void JMG_Set_Ammo_On_Enter_Reset_On_Exit::Exited(GameObject *obj,GameObject *exit)
 {
 	int x, end,y = 0;
-	if (Is_Vehicle(exit) == 0)
+	if (!exit->As_VehicleGameObj())
 	{
 		end = 0;
 		for (x = 0;x < 125 && end == 0;x++)
@@ -8254,7 +8258,7 @@
 			}
 		}
 	}
-	if (Is_Vehicle(exit) == 1)
+	if (exit->As_VehicleGameObj())
 	{
 		y = 0;
 		while (y < Get_Vehicle_Seat_Count(exit))
@@ -8303,7 +8307,7 @@
 	int x, end,y = 0;
 	if (message == Get_Int_Parameter("Set_Ammo_Message"))
 	{
-		if (Is_Vehicle(Commands->Find_Object(param)) == 0)
+		if (!Commands->Find_Object(param)->As_VehicleGameObj())
 		{
 			end = 0;
 			for (x = 0;x < 125 && end == 0;x++)
@@ -8330,7 +8334,7 @@
 				}
 			}
 		}
-		if (Is_Vehicle(Commands->Find_Object(param)) == 1)
+		if (Commands->Find_Object(param)->As_VehicleGameObj())
 		{
 			while (y <= Get_Vehicle_Seat_Count(Commands->Find_Object(param)))
 			{
@@ -8372,7 +8376,7 @@
 	}
 	if (message == Get_Int_Parameter("Reset_Ammo_Message"))
 	{
-		if (Is_Vehicle(Commands->Find_Object(param)) == 0)
+		if (!Commands->Find_Object(param)->As_VehicleGameObj())
 		{
 			end = 0;
 			for (x = 0;x < 125 && end == 0;x++)
@@ -8386,7 +8390,7 @@
 				}
 			}
 		}
-		if (Is_Vehicle(Commands->Find_Object(param)) == 1)
+		if (Commands->Find_Object(param)->As_VehicleGameObj())
 		{
 			y = 0;
 			while (y < Get_Vehicle_Seat_Count(Commands->Find_Object(param)))
@@ -9702,7 +9706,7 @@
 
 void JMG_Advanced_Visible_Driver::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000028)
+	if (message == CUSTOM_EVENT_VEHICLE_ENTERED)
 	{
 		int r, end = 0,sc = Get_Vehicle_Seat_Count(obj);
 		for(r = 0;r < sc && end == 0;r++)
@@ -9730,7 +9734,7 @@
 			}
 		}
 	}
-	if (message == 1000000029)
+	if (message == CUSTOM_EVENT_VEHICLE_EXITED)
 	{
 		int r, end = 0,sc = Get_Vehicle_Seat_Count(obj);
 		for(r = 0;r < sc && end == 0;r++)
@@ -9897,7 +9901,7 @@
 	Vector3 Pos = Commands->Get_Position(TargetSpot);
 	Vector3 ExitPos = Pos;
 	float Facing = Commands->Get_Facing(TargetSpot);
-	PhysicalGameObj *objphys = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *objphys = obj->As_PhysicalGameObj();
 	objphys->As_PhysicalGameObj()->Peek_Physical_Object()->As_MoveablePhysClass()->Find_Teleport_Location(Pos,1.0f,&ExitPos);
 	Commands->Set_Position(obj,ExitPos);
 	Vector3 pos = Commands->Get_Bone_Position(obj,"c head");
@@ -11705,7 +11709,7 @@
 	SLNode<BuildingGameObj> *ABuildingLL = GameObjManager::BuildingGameObjList.Head();
 	while (ABuildingLL)
 	{
-		GameObject *TheBuilding = (GameObject *)ABuildingLL->Data();
+		GameObject *TheBuilding = ABuildingLL->Data();
 		if (TheBuilding)
 		{
 			if (Building_Type(TheBuilding) == 9)
@@ -11954,7 +11958,7 @@
 
 void JMG_RP2_Submarine_Script::Custom(GameObject *obj,int message,int param,GameObject *sender)
 {
-	if (message == 1000000028)
+	if (message == CUSTOM_EVENT_VEHICLE_ENTERED)
 	{
 		int r, end = 0;
 		for(r = 0;r < 10 && end == 0;r++)
@@ -11977,7 +11981,7 @@
 			Commands->Send_Custom_Event(sender,Commands->Find_Object(133700),987123546,1,0);
 		}
 	}
-	if (message == 1000000029)
+	if (message == CUSTOM_EVENT_VEHICLE_EXITED)
 	{
 		int r, end = 0;
 		for(r = 0;r < 10 && end == 0;r++)
@@ -12477,7 +12481,7 @@
 {
 	float Angle;
 	enemydistance = Commands->Get_Distance(Commands->Get_Position(seen),Commands->Get_Position(obj));
-	if (enemydistance < maxdistance && !Is_VTOLVehicle(seen))
+	if (enemydistance < maxdistance && !(seen->As_PhysicalGameObj() && seen->As_PhysicalGameObj()->Peek_Physical_Object() && seen->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()))
 	{
 		Commands->Select_Weapon(obj,Get_Parameter("Dummy_Weapon"));
 		ActionParamsStruct params;
@@ -13280,7 +13284,7 @@
 
 void JMG_Vehicle_Occupant_Visible_And_Damageable::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000028)
+	if (message == CUSTOM_EVENT_VEHICLE_ENTERED)
 	{
 		int sc = Get_Vehicle_Seat_Count(obj);
 		for (int r = 0,end = 0;r < sc && (end == 0 || Get_Int_Parameter("Debug"));r++)
@@ -13331,7 +13335,7 @@
 			}
 		}
 	}
-	if (message == 1000000029)
+	if (message == CUSTOM_EVENT_VEHICLE_EXITED)
 	{
 		int sc = Get_Vehicle_Seat_Count(obj);
 		for (int r = 0, end = 0;r < sc && (end == 0 || Get_Int_Parameter("Debug"));r++)
@@ -13419,7 +13423,7 @@
 			ObjectID[x] = d;
 		}
 	}
-	if (message == 1000000028)
+	if (message == CUSTOM_EVENT_VEHICLE_ENTERED)
 	{
 		if (Get_Int_Parameter("ObjectCount") == 0 && ObjectID[0] == 0)
 		{
@@ -13442,7 +13446,7 @@
 			}
 		}
 	}
-	if (message == 1000000029 && Get_Vehicle_Occupant_Count(obj) == 0)
+	if (message == CUSTOM_EVENT_VEHICLE_EXITED && Get_Vehicle_Occupant_Count(obj) == 0)
 	{
 		for (int x = 0;x < 10;x++)
 		{
@@ -13477,7 +13481,7 @@
 
 void JMG_Repair_Zone::Entered(GameObject *obj,GameObject *enter)
 {
-	if (!Is_Script_Attached(enter,"JMG_Repair_Zone_Attach_Script") && Is_Vehicle(enter))
+	if (!Is_Script_Attached(enter,"JMG_Repair_Zone_Attach_Script") && enter->As_VehicleGameObj())
 	{
 		char params[4000];
 		sprintf(params,"%f,%d,%d,%d,%d,%d,%f,%f,%s,%s",Get_Float_Parameter("Repair_Delay"),Get_Int_Parameter("Damage_Halt_Repair_Time"),Get_Int_Parameter("Add_Health"),Get_Int_Parameter("Add_Armor"),Get_Int_Parameter("Heath_Repair_Cost"),Get_Int_Parameter("Armor_Repair_Cost"),Get_Float_Parameter("Health_Repair_Sound_Time"),Get_Float_Parameter("Armor_Repair_Sound_Time"),Get_Parameter("Health_Repair_Sound"),Get_Parameter("Armor_Repair_Sound"));
@@ -13640,10 +13644,10 @@
 		SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 		while (x)
 		{
-			GameObject *preset = (GameObject *)x->Data();
-			if (preset && As_ScriptableGameObj(preset))
+			ScriptableGameObj *preset = x->Data()->As_ScriptableGameObj();
+			if (preset)
 			{
-				const DefinitionClass *def = Get_Definition(preset);
+				const DefinitionClass *def = &preset->Get_Definition();
 				if (!_stricmp(def->Get_Name(),Get_Parameter("Preset")))
 				{
 					if (!Is_Script_Attached(preset,Get_Parameter("Script")))
@@ -13864,13 +13868,13 @@
 	}
 	Commands->Enable_Vehicle_Transitions(obj,true);
 	int j = 0;
-	if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+	if (!obj || !obj->As_VehicleGameObj())
 	{
 		return;
 	}
 	while (Get_Vehicle_Occupant_Count(obj) > 0 && j < 5)
 	{
-		if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+		if (!obj || !obj->As_VehicleGameObj())
 		{
 			return;
 		}
@@ -13911,7 +13915,7 @@
 
 void JMG_Vehicle_Sell_Zone::Entered(GameObject *obj,GameObject *enter)
 {
-	if (!Is_Script_Attached(enter,"JMG_Sell_Vehicle_On_Custom") && Is_Vehicle(enter))
+	if (!Is_Script_Attached(enter,"JMG_Sell_Vehicle_On_Custom") && enter->As_VehicleGameObj())
 	{
 		char params[4000];
 		sprintf(params,"%d,%d,%d,%s,%f,%f,%f,%s",Get_Int_Parameter("SellKeyMessage"),Get_Int_Parameter("CostRequestMessage"),Get_Int_Parameter("PriceReturnedMessage"),Get_Parameter("SellSound"),Get_Float_Parameter("HealthValueRatio"),Get_Float_Parameter("ArmorValueRatio"),Get_Float_Parameter("MinimumSellCondition"),Get_Parameter("Sell_Explosion"));
@@ -14051,7 +14055,7 @@
 	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if (Commands->Get_Distance(Commands->Get_Position(obj),Commands->Get_Position(o)) <= Get_Float_Parameter("DamageRange") && o != obj)
@@ -14069,7 +14073,7 @@
 	int kill = 0;
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
+		GameObject *o = x->Data();
 		if (o)
 		{
 			Vector3 objpos = Commands->Get_Position(obj),opos = Commands->Get_Position(o);
@@ -14111,7 +14115,7 @@
 				SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 				while (x)
 				{
-					GameObject *o = (GameObject *)x->Data();
+					GameObject *o = x->Data();
 					if (o)
 					{
 						if (!_stricmp(Commands->Get_Preset_Name(o),Get_Parameter("ObjectName")))
@@ -14213,7 +14217,7 @@
 	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_SmartGameObj((GameObject *)x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if ((Get_Object_Type(o) != Team && Commands->Get_ID(obj) != Commands->Get_ID(o)))
@@ -14286,7 +14290,7 @@
 	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 	while (x) 
 	{
-		GameObject *o = As_SmartGameObj((GameObject *)x->Data());
+		GameObject *o = x->Data();
 		if (obj)
 		{
 			if (obj != o)
@@ -14323,14 +14327,14 @@
 
 int JMG_Motion_Mine_Script::Usable_Target(GameObject *obj)
 {
-	if (Is_Vehicle(obj))
+	if (obj->As_VehicleGameObj())
 	{
-		if ((Is_VTOLVehicle(obj) || Is_TrackedVehicle(obj) || Is_WheeledVehicle(obj) || Is_Motorcycle(obj) || Is_HumanPhys(obj)))
+		if (((obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->Peek_Physical_Object() && obj->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()) || (obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->Peek_Physical_Object() && obj->As_PhysicalGameObj()->Peek_Physical_Object()->As_TrackedVehicleClass()) || (obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->Peek_Physical_Object() && obj->As_PhysicalGameObj()->Peek_Physical_Object()->As_WheeledVehicleClass()) || (obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->Peek_Physical_Object() && obj->As_PhysicalGameObj()->Peek_Physical_Object()->As_MotorcycleClass()) || (obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->Peek_Physical_Object() && obj->As_PhysicalGameObj()->Peek_Physical_Object()->As_HumanPhysClass())))
 		{
 			return 1;
 		}
 	}
-	if (Is_Soldier(obj))
+	if (obj->As_SoldierGameObj())
 	{
 		return 1;
 	}
@@ -18437,7 +18441,7 @@
 		HJROWP = 0;// Added in so you won't glitch and swim under the water as easily
 		Vector3 ExitPos,StartPos;//Small bit of code to try to prevent you getting stuck in the ground
 		StartPos = ExitPos = Commands->Get_Position(obj);
-		PhysicalGameObj *objphys = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+		PhysicalGameObj *objphys = obj->As_PhysicalGameObj();
 		objphys->As_PhysicalGameObj()->Peek_Physical_Object()->As_MoveablePhysClass()->Find_Teleport_Location(StartPos,1.0f,&ExitPos);
 		Commands->Set_Position(obj,StartPos);
 	}
@@ -19021,13 +19025,11 @@
 	GameObject *Zone = NULL;
 	Vector3 Pos = Commands->Get_Position(obj);
 	float HighestPoint = 0;
-	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
+	SLNode<ScriptZoneGameObj> *x = GameObjManager::ScriptZoneGameObjList.Head();
 	while (x)
 	{
-		GameObject *TempZone = (GameObject *)x->Data();
-		if (TempZone && As_ScriptableGameObj(TempZone))
-		{
-			if (Is_ScriptZone(TempZone))
+		GameObject *TempZone = x->Data();
+		if (TempZone)
 			{
 				if (Is_Script_Attached(TempZone,"JMG_New_Swimming_Zone"))
 				{
@@ -19053,7 +19055,6 @@
 					}
 				}
 			}
-		}
 		x = x->Next();
 	}
 	WaterZoneHeight(Zone);
@@ -19066,13 +19067,11 @@
 	if (obj && Head)
 	{
 		int UWZC = 0;
-		SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
+		SLNode<ScriptZoneGameObj> *x = GameObjManager::ScriptZoneGameObjList.Head();
 		while (x)
 		{
-			GameObject *TempZone = (GameObject *)x->Data();
-			if (TempZone && As_ScriptableGameObj(TempZone))
-			{
-				if (Is_ScriptZone(TempZone))
+			GameObject *TempZone = x->Data();
+			if (TempZone)
 				{
 					if (Is_Script_Attached(TempZone,"JMG_New_Swimming_Zone"))
 					{
@@ -19082,7 +19081,6 @@
 						}
 					}
 				}
-			}
 			x = x->Next();
 		}
 		if (underwater != UWZC)
@@ -19210,13 +19208,11 @@
 	GameObject *Zone = NULL;
 	Vector3 Pos = Commands->Get_Position(obj);
 	float HighestPoint = 0;
-	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
+	SLNode<ScriptZoneGameObj> *x = GameObjManager::ScriptZoneGameObjList.Head();
 	while (x)
 	{
-		GameObject *TempZone = (GameObject *)x->Data();
-		if (TempZone && As_ScriptableGameObj(TempZone))
-		{
-			if (Is_ScriptZone(TempZone))
+		GameObject *TempZone = x->Data();
+		if (TempZone)
 			{
 				if (Is_Script_Attached(TempZone,"JMG_New_Swimming_Zone"))
 				{
@@ -19242,7 +19238,6 @@
 					}
 				}
 			}
-		}
 		x = x->Next();
 	}
 	/**///Swimming_Trace("Complete - FindCurrentWaterZone",-1);
@@ -19977,7 +19972,7 @@
 	{
 		DamageEffectIDs[set] = 0;
 	}
-	if (Is_VTOLVehicle(obj) == 1)
+	if ((obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->Peek_Physical_Object() && obj->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()))
 	{
 		if (Get_Int_Parameter("Create_Clouds") == 1 || Get_Int_Parameter("Create_Clouds") == -2)
 		{
@@ -20022,7 +20017,7 @@
 			}
 		}
 	}
-	if (message == 1000000028)
+	if (message == CUSTOM_EVENT_VEHICLE_ENTERED)
 	{
 		if (enginedisabled == 1 && Is_In_Water == 0)
 		{
@@ -20086,7 +20081,7 @@
 			RP2_Set_Fog_And_Screen_Color_To_Level_Default(sender);
 		}
 	}
-	if (message == 1000000029)
+	if (message == CUSTOM_EVENT_VEHICLE_EXITED)
 	{
 		int r, end = 0;
 		for(r = 0;r < 10 && end == 0;r++)
@@ -20123,7 +20118,7 @@
 		{
 			Commands->Set_Player_Type(obj,-1);
 		}
-		if (As_PhysicalGameObj(sender))//Function below is for vehicle exit damage
+		if (sender->As_PhysicalGameObj())//Function below is for vehicle exit damage
 		{
 			Vector3 Pos = Commands->Get_Position(sender),OldPos;
 			OldPos = Pos;
@@ -20188,7 +20183,7 @@
 			}
 		}
 		// Back to original Swimming Script Stuff
-		if (Is_VTOLVehicle(obj) == 1 && Get_Int_Parameter("Create_Clouds") >= 0)
+		if ((obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->Peek_Physical_Object() && obj->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()) && Get_Int_Parameter("Create_Clouds") >= 0)
 		{
 			enginedisabled = 1;
 			if (Commands->Get_Health(obj) == Commands->Get_Max_Health(obj))
@@ -20275,7 +20270,7 @@
 			else
 			{
 				Commands->Enable_Engine(obj,0);
-				if (!Is_VTOLVehicle(obj))
+				if (!(obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->Peek_Physical_Object() && obj->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()))
 				{
 					JMG_Force_Occupants_Exit(obj);
 				}
@@ -20428,7 +20423,7 @@
 	int j = 0;
 	while (Get_Vehicle_Occupant_Count(obj) > 0 && j < 5)
 	{
-		if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+		if (!obj || !obj->As_VehicleGameObj())
 		{
 			return;
 		}
@@ -20623,7 +20618,7 @@
 		Send_Message_Player(sender,200,200,125,"Vehicle Special Key:");
 		Send_Message_Player(sender,200,200,125,"H - Toggle Sonar");
 	}
-	if (message == 1000000028)
+	if (message == CUSTOM_EVENT_VEHICLE_ENTERED)
 	{
 		Commands->Send_Custom_Event(obj,sender,90000028,-1,0);
 		int sc = Get_Vehicle_Seat_Count(obj);
@@ -20658,7 +20653,7 @@
 			}
 		}
 	}
-	if (message == 1000000029)
+	if (message == CUSTOM_EVENT_VEHICLE_EXITED)
 	{
 		int r, end = 0;
 		for(r = 0;r < 10 && end == 0;r++)
@@ -21075,7 +21070,7 @@
 
 void JMG_RP2_Submarine_Script_Advanced::PingSound(GameObject *Sub)
 {
-	if (!Commands->Get_ID(Sub) || !Sub)
+	if (!Sub)
 	{
 		return;
 	}
@@ -21083,7 +21078,7 @@
 	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = As_SmartGameObj((GameObject *)x->Data());
+		GameObject *o = x->Data();
 		if (o)
 		{
 			if (Commands->Is_A_Star(o))
@@ -21211,7 +21206,7 @@
 	{
 		aco2 = 1;
 	}
-	if (Is_Vehicle(damager))
+	if (damager->As_VehicleGameObj())
 	{
 		if (!Get_Vehicle_Occupant_Count(damager) && Get_Vehicle_Seat_Count(damager))
 		{
@@ -22932,8 +22927,8 @@
 			SLNode<BaseGameObj> *Current = GameObjManager::GameObjList.Head();
 			while (Current)
 			{
-				GameObject *Object = (GameObject *)Current->Data();
-				if (Object && As_ScriptableGameObj(Object) && Object != obj)
+				GameObject *Object = Current->Data()->As_ScriptableGameObj();
+				if (Object && Object != obj)
 				{
 					if (Commands->Is_A_Star(Object))
 					{
@@ -23041,12 +23036,12 @@
 
 void JMG_Turret_Attach::Custom(GameObject *obj,int message,int param,GameObject *sender)
 {
-	if (message == 1000000028)
+	if (message == CUSTOM_EVENT_VEHICLE_ENTERED)
 	{
 		GameObject *object = Commands->Find_Object(ObjectID);
 		Commands->Set_Player_Type(object,Commands->Get_Player_Type(sender));
 	}
-	if (message == 1000000029)
+	if (message == CUSTOM_EVENT_VEHICLE_EXITED)
 	{
 		GameObject *object = Commands->Find_Object(ObjectID);
 		Commands->Set_Player_Type(object,Commands->Get_Player_Type(sender));
@@ -23086,10 +23081,10 @@
 		SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 		while (x)
 		{
-			GameObject *o = (GameObject *)x->Data();
+			GameObject *o = x->Data();
 			if (o)
 			{
-				if (!Commands->Is_A_Star(o) && Is_Soldier(o) && o != obj && !Is_Script_Attached(obj,Get_Parameter("Script")))
+				if (!Commands->Is_A_Star(o) && o->As_SoldierGameObj() && o != obj && !Is_Script_Attached(obj,Get_Parameter("Script")))
 				{
 					Commands->Attach_Script(o,Get_Parameter("Script"),params);
 				}
@@ -23104,10 +23099,10 @@
 	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
+		GameObject *o = x->Data();
 		if (o)
 		{
-			if (!Commands->Is_A_Star(o) && Is_Soldier(o) && o != obj)
+			if (!Commands->Is_A_Star(o) && o->As_SoldierGameObj() && o != obj)
 			{
 				Commands->Destroy_Object(o);
 			}
@@ -23121,10 +23116,10 @@
 	SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 	while (x)
 	{
-		GameObject *o = (GameObject *)x->Data();
+		GameObject *o = x->Data();
 		if (o)
 		{
-			if (Is_Soldier(o) && o != obj)
+			if (o->As_SoldierGameObj() && o != obj)
 			{
 				Commands->Destroy_Object(o);
 			}
@@ -23142,7 +23137,7 @@
 		SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 		while (x)
 		{
-			GameObject *o = (GameObject *)x->Data();
+			GameObject *o = x->Data();
 			if (o)
 			{
 				if (Is_Script_Attached(o,"Data/RolePlay2/JMG_RP2_Please_Record_Vehicle"))
@@ -23151,9 +23146,9 @@
 					fprintf(filev,"%s %.3f %.3f %.3f %.3f %.2f %.2f;\n",Commands->Get_Preset_Name(o),pos.X,pos.Y,pos.Z,Commands->Get_Facing(o),Commands->Get_Health(o),Commands->Get_Shield_Strength(o));	
 					fflush(filev);
 				}
-				else if (Is_Vehicle(o))
+				else if (o->As_VehicleGameObj())
 				{
-					if (Is_VTOLVehicle(o) || Is_TrackedVehicle(o) || Is_WheeledVehicle(o) || Is_Motorcycle(o))
+					if ((o->As_PhysicalGameObj() && o->As_PhysicalGameObj()->Peek_Physical_Object() && o->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()) || (o->As_PhysicalGameObj() && o->As_PhysicalGameObj()->Peek_Physical_Object() && o->As_PhysicalGameObj()->Peek_Physical_Object()->As_TrackedVehicleClass()) || (o->As_PhysicalGameObj() && o->As_PhysicalGameObj()->Peek_Physical_Object() && o->As_PhysicalGameObj()->Peek_Physical_Object()->As_WheeledVehicleClass()) || (o->As_PhysicalGameObj() && o->As_PhysicalGameObj()->Peek_Physical_Object() && o->As_PhysicalGameObj()->Peek_Physical_Object()->As_MotorcycleClass()))
 					{
 						if (!(Is_Script_Attached(o,"Data/RolePlay2/JMG_RP2_Do_Not_Record_Vehicle")))
 						{
@@ -25024,16 +25019,11 @@
 
 unsigned long JMG_RP2_Housing_Weapons_Cupboard_WLS::Get_Translated_Weapon_ID(GameObject *obj,int position)
 {
-	if (!obj || !Commands->Get_ID(obj))
-	{
-		return 0;
-	}
-	GameObject *o = As_ArmedGameObj(obj);
-	if (!o)
-	{
-		return 0;
-	}
-	WeaponBagClass *w = ((ArmedGameObj *)o)->Get_Weapon_Bag();
+	PhysicalGameObj *o2 = obj->As_PhysicalGameObj();
+	if (!o2){return 0;}
+	ArmedGameObj *o3 = o2->As_ArmedGameObj();
+	if (!o3){return 0;}
+	WeaponBagClass *w = o3->Get_Weapon_Bag();
 	if ((position) && (position < w->Get_Count()))
 	{
 		return (w->Peek_Weapon(position)->Get_Definition()->IconNameID);
@@ -25489,7 +25479,7 @@
 			return;
 		}
 	}
-	if (!Is_Projectile(seen))
+	if (!(seen->As_PhysicalGameObj() && seen->As_PhysicalGameObj()->Peek_Physical_Object() && seen->As_PhysicalGameObj()->Peek_Physical_Object()->As_ProjectileClass()))
 	{
 		float Distance = Commands->Get_Distance(Commands->Get_Position(obj),Commands->Get_Position(seen));
 		if (Distance <= Get_Float_Parameter("Max_Range") && Distance > Get_Float_Parameter("Min_Range"))
@@ -25523,7 +25513,7 @@
 {
 	if (damager && damage && _stricmp(Get_Skin(damager),"Blamo") && _stricmp(Get_Shield_Type(damager),"Blamo"))
 	{
-		if ((Is_VTOLVehicle(damager) || Is_TrackedVehicle(damager) || Is_WheeledVehicle(damager) || Is_Motorcycle(damager) || Is_HumanPhys(damager)) && !EnemyID && MyGrid != -1)
+		if (((damager->As_PhysicalGameObj() && damager->As_PhysicalGameObj()->Peek_Physical_Object() && damager->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()) || (damager->As_PhysicalGameObj() && damager->As_PhysicalGameObj()->Peek_Physical_Object() && damager->As_PhysicalGameObj()->Peek_Physical_Object()->As_TrackedVehicleClass()) || (damager->As_PhysicalGameObj() && damager->As_PhysicalGameObj()->Peek_Physical_Object() && damager->As_PhysicalGameObj()->Peek_Physical_Object()->As_WheeledVehicleClass()) || (damager->As_PhysicalGameObj() && damager->As_PhysicalGameObj()->Peek_Physical_Object() && damager->As_PhysicalGameObj()->Peek_Physical_Object()->As_MotorcycleClass()) || (damager->As_PhysicalGameObj() && damager->As_PhysicalGameObj()->Peek_Physical_Object() && damager->As_PhysicalGameObj()->Peek_Physical_Object()->As_HumanPhysClass())) && !EnemyID && MyGrid != -1)
 		{
 				GiveToGrid(damager);
 				AGTargetID = Commands->Get_ID(damager);
@@ -25803,7 +25793,7 @@
 				return;
 			}
 	}
-	if (!Commands->Has_Key(seen,Get_Int_Parameter("House_Address")) && !Commands->Has_Key(seen,(0-Get_Int_Parameter("House_Address"))) && !Is_Projectile(seen))
+	if (!Commands->Has_Key(seen,Get_Int_Parameter("House_Address")) && !Commands->Has_Key(seen,(0-Get_Int_Parameter("House_Address"))) && !(seen->As_PhysicalGameObj() && seen->As_PhysicalGameObj()->Peek_Physical_Object() && seen->As_PhysicalGameObj()->Peek_Physical_Object()->As_ProjectileClass()))
 	{
 		float Distance = Commands->Get_Distance(Commands->Get_Position(obj),Commands->Get_Position(seen));
 		if (Distance <= Get_Float_Parameter("Max_Range") && Distance > Get_Float_Parameter("Min_Range"))
@@ -25837,7 +25827,7 @@
 {
 	if (damager && damage && _stricmp(Get_Skin(damager),"Blamo") && _stricmp(Get_Shield_Type(damager),"Blamo"))
 	{
-		if (!Commands->Has_Key(damager,Get_Int_Parameter("House_Address")) && !Commands->Has_Key(damager,(0-Get_Int_Parameter("House_Address"))) && (Is_VTOLVehicle(damager) || Is_TrackedVehicle(damager) || Is_WheeledVehicle(damager) || Is_Motorcycle(damager) || Is_HumanPhys(damager)) && !EnemyID && MyGrid != -1)
+		if (!Commands->Has_Key(damager,Get_Int_Parameter("House_Address")) && !Commands->Has_Key(damager,(0-Get_Int_Parameter("House_Address"))) && ((damager->As_PhysicalGameObj() && damager->As_PhysicalGameObj()->Peek_Physical_Object() && damager->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()) || (damager->As_PhysicalGameObj() && damager->As_PhysicalGameObj()->Peek_Physical_Object() && damager->As_PhysicalGameObj()->Peek_Physical_Object()->As_TrackedVehicleClass()) || (damager->As_PhysicalGameObj() && damager->As_PhysicalGameObj()->Peek_Physical_Object() && damager->As_PhysicalGameObj()->Peek_Physical_Object()->As_WheeledVehicleClass()) || (damager->As_PhysicalGameObj() && damager->As_PhysicalGameObj()->Peek_Physical_Object() && damager->As_PhysicalGameObj()->Peek_Physical_Object()->As_MotorcycleClass()) || (damager->As_PhysicalGameObj() && damager->As_PhysicalGameObj()->Peek_Physical_Object() && damager->As_PhysicalGameObj()->Peek_Physical_Object()->As_HumanPhysClass())) && !EnemyID && MyGrid != -1)
 		{
 			GiveToGrid(damager);
 			AGTargetID = Commands->Get_ID(damager);
@@ -26634,7 +26624,7 @@
 		return;
 	}
 	GameObject *Driver = Commands->Find_Object(DriverID);
-	if (!Is_Projectile(seen) && Commands->Get_Health(seen) && ADS && Driver != seen && Get_Vehicle(Driver) != seen && (ADS != 2 || (ADS == 2 && !Commands->Is_A_Star(seen)) && !Commands->Is_A_Star(Get_Vehicle_Driver(seen))))
+	if (!(seen->As_PhysicalGameObj() && seen->As_PhysicalGameObj()->Peek_Physical_Object() && seen->As_PhysicalGameObj()->Peek_Physical_Object()->As_ProjectileClass()) && Commands->Get_Health(seen) && ADS && Driver != seen && Get_Vehicle(Driver) != seen && (ADS != 2 || (ADS == 2 && !Commands->Is_A_Star(seen)) && !Commands->Is_A_Star(Get_Vehicle_Driver(seen))))
 	{
 		float Distance = Commands->Get_Distance(Commands->Get_Position(obj),Commands->Get_Position(seen));
 		if (Distance <= 600)
@@ -26870,7 +26860,7 @@
 	IsMoving = 0;
 	if (Enemy)
 	{
-		if (((DistanceE > 200) || (DistanceE > 150 && Is_VTOLVehicle(Enemy))) && (Primary == true || LongRange == false))
+		if (((DistanceE > 200) || (DistanceE > 150 && (Enemy->As_PhysicalGameObj() && Enemy->As_PhysicalGameObj()->Peek_Physical_Object() && Enemy->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()))) && (Primary == true || LongRange == false))
 		{
 			Primary = false;
 			LongRange = true;
@@ -27725,7 +27715,7 @@
 	SLNode<SmartGameObj> *Current = GameObjManager::SmartGameObjList.Head();
 	while (Current) 
 	{
-		GameObject *o = As_SmartGameObj((GameObject *)Current->Data());
+		GameObject *o = Current->Data();
 		if (obj && obj != o)
 		{
 			if (Commands->Is_A_Star(o))
@@ -27786,7 +27776,7 @@
 	SLNode<SmartGameObj> *Current = GameObjManager::SmartGameObjList.Head();
 	while (Current) 
 	{
-		GameObject *o = As_SmartGameObj((GameObject *)Current->Data());
+		GameObject *o = Current->Data();
 		if (obj && obj != o)
 		{
 			if (Commands->Is_A_Star(o))
@@ -27926,7 +27916,7 @@
 		{
 			return;
 		}
-		if (As_PhysicalGameObj(seen))//Check if infantry is at least 3m above the ground
+		if (seen->As_PhysicalGameObj())//Check if infantry is at least 3m above the ground
 		{
 			Vector3 Pos = Commands->Get_Position(seen),OldPos;
 			OldPos = Pos;
@@ -27954,7 +27944,7 @@
 	{
 		seen = TempV;
 	}
-	if (Is_Projectile(seen))
+	if ((seen->As_PhysicalGameObj() && seen->As_PhysicalGameObj()->Peek_Physical_Object() && seen->As_PhysicalGameObj()->Peek_Physical_Object()->As_ProjectileClass()))
 	{
 		return;
 	}
@@ -28020,7 +28010,6 @@
 		{
 			FVehicle = damager;
 		}
-		//if (ValidTarget && Is_VTOLVehicle(FVehicle))
 		{
 			if (!EnemyID && MyGrid != -1)
 			{
@@ -28311,7 +28300,7 @@
 			}
 			return false;
 		}
-		if (Is_Vehicle(TVehicle))
+		if (TVehicle->As_VehicleGameObj())
 		{
 			bool Visible;
 			bool *b = (bool *)TVehicle;
@@ -28363,7 +28352,7 @@
 				return;
 			}
 	}
-	if (!Is_Projectile(seen))
+	if (!(seen->As_PhysicalGameObj() && seen->As_PhysicalGameObj()->Peek_Physical_Object() && seen->As_PhysicalGameObj()->Peek_Physical_Object()->As_ProjectileClass()))
 	{
 		float Distance = Commands->Get_Distance(Commands->Get_Position(obj),Commands->Get_Position(seen));
 		if (Distance <= Get_Float_Parameter("Max_Range") && Distance > Get_Float_Parameter("Min_Range"))
@@ -28691,7 +28680,7 @@
 			}
 			return false;
 		}
-		if (Is_Vehicle(TVehicle))
+		if (TVehicle->As_VehicleGameObj())
 		{
 			bool Visible;
 			bool *b = (bool *)TVehicle;
@@ -28705,7 +28694,7 @@
 
 void JMG_Grant_Powerup_To_Beacon_Planter::Created(GameObject *obj)
 {
-	if (As_BeaconGameObj(obj))
+	if (obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->As_BeaconGameObj())
 	{
 		GameObject *Planter = Get_Beacon_Planter(obj);
 		if (Planter)
@@ -28729,7 +28718,7 @@
 
 int JMG_Grant_Powerup_To_Beacon_Planter::Find_Nearest_Beacon_ID(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
@@ -28739,7 +28728,7 @@
 	SLNode<BeaconGameObj> *Current = GameObjManager::BeaconGameObjList.Head();
 	while (Current)
 	{
-		GameObject *ObjectNode = (GameObject *)Current->Data();
+		GameObject *ObjectNode = Current->Data();
 		if (ObjectNode)
 		{
 			Vector3 Pos = Commands->Get_Position(ObjectNode);
@@ -28762,7 +28751,7 @@
 
 void JMG_Send_Custom_To_Beacon_Planter::Created(GameObject *obj)
 {
-	if (As_BeaconGameObj(obj))
+	if (obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->As_BeaconGameObj())
 	{
 		GameObject *Planter = Get_Beacon_Planter(obj);
 		if (Planter)
@@ -28786,7 +28775,7 @@
 
 int JMG_Send_Custom_To_Beacon_Planter::Find_Nearest_Beacon_ID(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
@@ -28796,7 +28785,7 @@
 	SLNode<BeaconGameObj> *Current = GameObjManager::BeaconGameObjList.Head();
 	while (Current)
 	{
-		GameObject *ObjectNode = (GameObject *)Current->Data();
+		GameObject *ObjectNode = Current->Data();
 		if (ObjectNode)
 		{
 			Vector3 Pos = Commands->Get_Position(ObjectNode);
@@ -29877,10 +29866,10 @@
 			EnterV = enter;
 		}
 		Vector3 Detection = Get_Vector3_Parameter("Detect[Human|Vehicle|Aircraft]");
-		if (Detection.X && ((!Is_Soldier(EnterV) && !Detection.Y && !Detection.Z) || (!Is_Soldier(EnterV) && (Detection.Y || Detection.Z))))
+		if (Detection.X && ((!EnterV->As_SoldierGameObj() && !Detection.Y && !Detection.Z) || (!EnterV->As_SoldierGameObj() && (Detection.Y || Detection.Z))))
 		{
 			// Only Attach to the one type of vehicle that isn't detected
-			if (!((Detection.Y && !Is_VTOLVehicle(EnterV) && Is_Vehicle(EnterV)) || Detection.Z && Is_VTOLVehicle(EnterV)))
+			if (!((Detection.Y && !(EnterV->As_PhysicalGameObj() && EnterV->As_PhysicalGameObj()->Peek_Physical_Object() && EnterV->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()) && EnterV->As_VehicleGameObj()) || Detection.Z && (EnterV->As_PhysicalGameObj() && EnterV->As_PhysicalGameObj()->Peek_Physical_Object() && EnterV->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass())))
 			{
 				char params[2000];
 				sprintf(params,"%d,%d,%d",Commands->Get_ID(obj),Get_Int_Parameter("Mission_Type"),Get_Int_Parameter("Objective_Number"));
@@ -29894,7 +29883,7 @@
 				Commands->Attach_Script(EnterV,"JMG_RP2_MS_Mission_Objective_Enter_Attach_Script",params);
 			}
 		}
-		if ((Detection.X && Is_Soldier(EnterV)) || (Detection.Y && !Is_VTOLVehicle(EnterV) && Is_Vehicle(EnterV)) || Detection.Z && Is_VTOLVehicle(EnterV))
+		if ((Detection.X && EnterV->As_SoldierGameObj()) || (Detection.Y && !(EnterV->As_PhysicalGameObj() && EnterV->As_PhysicalGameObj()->Peek_Physical_Object() && EnterV->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()) && EnterV->As_VehicleGameObj()) || Detection.Z && (EnterV->As_PhysicalGameObj() && EnterV->As_PhysicalGameObj()->Peek_Physical_Object() && EnterV->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()))
 		{
 			if (!ISSELECTINGSPAWN[Get_Player_ID(enter)])
 			{
@@ -30296,13 +30285,13 @@
 	}
 	Commands->Enable_Vehicle_Transitions(obj,true);
 	int j = 0;
-	if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+	if (!obj || !obj->As_VehicleGameObj())
 	{
 		return;
 	}
 	while (Get_Vehicle_Occupant_Count(obj) > 0 && j < 5)
 	{
-		if (!Commands->Get_ID(obj) || !obj || !As_VehicleGameObj(obj))
+		if (!obj || !obj->As_VehicleGameObj())
 		{
 			return;
 		}
@@ -32406,7 +32395,7 @@
 	}
 	if (message == 7745473)
 	{
-		if (!obj || !Commands->Get_ID(obj))
+		if (!obj)
 		{
 			return;
 		}
@@ -33687,7 +33676,7 @@
 		else
 		{
 			GameObject *TargetV = Commands->Find_Object(HasVehicleID);
-			if (As_PhysicalGameObj(TargetV))
+			if (TargetV->As_PhysicalGameObj())
 			{
 				Vector3 Pos = Commands->Get_Position(TargetV);
 				PhysicalGameObj *objphys = ((ScriptableGameObj *)TargetV)->As_PhysicalGameObj();
@@ -33713,7 +33702,7 @@
 				Commands->Enable_Collisions(obj);
 			}
 			DropZ = Commands->Get_Position(obj).Z;
-			if (As_PhysicalGameObj(TargetV))
+			if (TargetV->As_PhysicalGameObj())
 			{
 				Commands->Attach_Script(TargetV,"JMG_RP2_Enable_Collisions_When_Safe","");
 			}
@@ -33770,11 +33759,11 @@
 
 void JMG_RP2_Carryall::Vehicle_Wheel_Bone(GameObject *CarryV)
 {
-	if (Is_Motorcycle(CarryV))
+	if ((CarryV->As_PhysicalGameObj() && CarryV->As_PhysicalGameObj()->Peek_Physical_Object() && CarryV->As_PhysicalGameObj()->Peek_Physical_Object()->As_MotorcycleClass()))
 	{
 		sprintf(WheelName,"WheelP01S");
 	}
-	if (Is_WheeledVehicle(CarryV))
+	if ((CarryV->As_PhysicalGameObj() && CarryV->As_PhysicalGameObj()->Peek_Physical_Object() && CarryV->As_PhysicalGameObj()->Peek_Physical_Object()->As_WheeledVehicleClass()))
 	{
 		Vector3 OriginPos = Commands->Get_Bone_Position(CarryV,"DNE");
 		if (Commands->Get_Distance(OriginPos,Commands->Get_Bone_Position(CarryV,"WheelP01S")) >= 0.0)
@@ -33794,7 +33783,7 @@
 			sprintf(WheelName,"WheelP01E");
 		}
 	}
-	if (Is_TrackedVehicle(CarryV))
+	if ((CarryV->As_PhysicalGameObj() && CarryV->As_PhysicalGameObj()->Peek_Physical_Object() && CarryV->As_PhysicalGameObj()->Peek_Physical_Object()->As_TrackedVehicleClass()))
 	{
 		if (Commands->Get_Distance(Commands->Get_Bone_Position(CarryV,"WheelP00E"),Commands->Get_Bone_Position(CarryV,"DNE")) >= 0.0)
 		{
@@ -33814,10 +33803,10 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *TempVehicle = (GameObject *)x->Data();
-		if (TempVehicle && As_ScriptableGameObj(TempVehicle))
+		GameObject *TempVehicle = x->Data()->As_ScriptableGameObj();
+		if (TempVehicle)
 		{
-			if (Is_Motorcycle(TempVehicle) || Is_WheeledVehicle(TempVehicle) || Is_TrackedVehicle(TempVehicle))
+			if ((TempVehicle->As_PhysicalGameObj() && TempVehicle->As_PhysicalGameObj()->Peek_Physical_Object() && TempVehicle->As_PhysicalGameObj()->Peek_Physical_Object()->As_MotorcycleClass()) || (TempVehicle->As_PhysicalGameObj() && TempVehicle->As_PhysicalGameObj()->Peek_Physical_Object() && TempVehicle->As_PhysicalGameObj()->Peek_Physical_Object()->As_WheeledVehicleClass()) || (TempVehicle->As_PhysicalGameObj() && TempVehicle->As_PhysicalGameObj()->Peek_Physical_Object() && TempVehicle->As_PhysicalGameObj()->Peek_Physical_Object()->As_TrackedVehicleClass()))
 			{
 				if (TargetVehicle)
 				{
@@ -35089,7 +35078,7 @@
 		Pos.X += Vector.X;
 		Pos.Y += Vector.Y;
 		Pos.Z += Vector.Z;
-		PhysicalGameObj *objphys = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+		PhysicalGameObj *objphys = obj->As_PhysicalGameObj();
 		Commands->Set_Position(obj,Pos);
 		if (!objphys->Peek_Physical_Object()->As_MoveablePhysClass()->Can_Teleport(objphys->Get_Transform(),false))
 		{
@@ -35157,7 +35146,7 @@
 		Pos.Y = Calculations(ZoneCenter.Y,Pos.Y,SpeedC.Y);
 		Pos.Z = Calculations(ZoneCenter.Z,Pos.Z,SpeedC.Z);
 		Commands->Set_Position(obj,Pos);
-		PhysicalGameObj *objphys = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+		PhysicalGameObj *objphys = obj->As_PhysicalGameObj();
 		if (!objphys->Peek_Physical_Object()->As_MoveablePhysClass()->Can_Teleport(objphys->Get_Transform(),false))
 		{
 			Commands->Set_Position(obj,OldPos);	
@@ -35223,7 +35212,7 @@
 			return;
 		}
 	}
-	if (!Is_Projectile(seen))
+	if (!(seen->As_PhysicalGameObj() && seen->As_PhysicalGameObj()->Peek_Physical_Object() && seen->As_PhysicalGameObj()->Peek_Physical_Object()->As_ProjectileClass()))
 	{
 		float Distance = Commands->Get_Distance(Commands->Get_Position(obj),Commands->Get_Position(seen));
 		if (Distance <= Get_Float_Parameter("Max_Range") && Distance > Get_Float_Parameter("Min_Range"))
@@ -35566,7 +35555,7 @@
 		SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 		while (x)
 		{
-			GameObject *o = (GameObject *)x->Data();
+			GameObject *o = x->Data();
 			if (o)
 			{
 				count++;
@@ -35718,15 +35707,15 @@
 	}
 	if (message == Get_Int_Parameter("Message") + 1)
 	{
-		if (!Commands->Get_ID(sender) || !sender)
+		if (!sender)
 		{
 			return;
 		}
 		SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 		while (x)
 		{
-			GameObject *o = (GameObject *)x->Data();
-			if (o && As_ScriptableGameObj(o))
+			GameObject *o = x->Data()->As_ScriptableGameObj();
+			if (o)
 			{
 				if (!_stricmp(Commands->Get_Preset_Name(o),PLAYERANTIMISSILESYSTEM))
 				{
@@ -36484,10 +36473,10 @@
 	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
 	while (x)
 	{
-		GameObject *TempVehicle = (GameObject *)x->Data();
-		if (TempVehicle && As_ScriptableGameObj(TempVehicle))
+		GameObject *TempVehicle = x->Data()->As_ScriptableGameObj();
+		if (TempVehicle)
 		{
-			if (Is_VTOLVehicle(TempVehicle))
+			if ((TempVehicle->As_PhysicalGameObj() && TempVehicle->As_PhysicalGameObj()->Peek_Physical_Object() && TempVehicle->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()))
 			{
 				if (Commands->Get_Distance(Pos,Commands->Get_Position(TempVehicle)) <= SCHOOLRADIUS)
 				{
@@ -36734,13 +36723,11 @@
 Vector3 JMG_RP2_Fishing_Random_School_Generator::Find_Zone_For_Fish()
 {
 	int TooLong = 0;
-	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
+	SLNode<ScriptZoneGameObj> *x = GameObjManager::ScriptZoneGameObjList.Head();
 	while (x)
 	{
-		GameObject *TempZone = (GameObject *)x->Data();
-		if (TempZone && As_ScriptableGameObj(TempZone))
-		{
-			if (Is_ScriptZone(TempZone))
+		GameObject *TempZone = x->Data();
+		if (TempZone)
 			{
 				if (Is_Script_Attached(TempZone,"JMG_New_Swimming_Zone") && !Is_Script_Attached(TempZone,"JMG_RP2_Fishing_No_Fish_Zone"))
 				{
@@ -36759,11 +36746,10 @@
 					}
 				}
 			}
-		}
 		x = x->Next();
 		if (!x)
 		{
-			x = GameObjManager::GameObjList.Head();
+			x = GameObjManager::ScriptZoneGameObjList.Head();
 		}
 	}
 	return Vector3(0,0,0);
@@ -36771,20 +36757,17 @@
 
 int JMG_RP2_Fishing_Random_School_Generator::Check_For_Zones()
 {
-	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
+	SLNode<ScriptZoneGameObj> *x = GameObjManager::ScriptZoneGameObjList.Head();
 	while (x)
 	{
-		GameObject *TempZone = (GameObject *)x->Data();
-		if (TempZone && As_ScriptableGameObj(TempZone))
-		{
-			if (Is_ScriptZone(TempZone))
+		GameObject *TempZone = x->Data();
+		if (TempZone)
 			{
 				if (Is_Script_Attached(TempZone,"JMG_New_Swimming_Zone") && !Is_Script_Attached(TempZone,"JMG_RP2_Fishing_No_Fish_Zone"))
 				{
 					return 1;
 				}
 			}
-		}
 		x = x->Next();
 	}
 	return 0;
@@ -36842,7 +36825,7 @@
 
 void JMG_RP2_Fishing_Unload_Zone::Entered(GameObject *obj,GameObject *enter)
 {
-	if (Is_VTOLVehicle(enter))
+	if ((enter->As_PhysicalGameObj() && enter->As_PhysicalGameObj()->Peek_Physical_Object() && enter->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()))
 	{
 		Commands->Send_Custom_Event(obj,enter,7154146,0,0);
 	}
@@ -37032,7 +37015,7 @@
 
 int JMG_RP2_Tactical_Nuke_Phone_Triggered::Find_Nearest_Beacon_ID(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
@@ -37042,7 +37025,7 @@
 	SLNode<BeaconGameObj> *Current = GameObjManager::BeaconGameObjList.Head();
 	while (Current)
 	{
-		GameObject *ObjectNode = (GameObject *)Current->Data();
+		GameObject *ObjectNode = Current->Data()->As_ScriptableGameObj();
 		if (ObjectNode)
 		{
 			Vector3 Pos = Commands->Get_Position(ObjectNode);
@@ -37087,7 +37070,7 @@
 
 void JMG_RP2_Tactical_Nuke_Phone_Triggered::Trigger_Vehicle_EMP(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return;
 	}
@@ -37095,10 +37078,10 @@
 	SLNode<BaseGameObj> *Current = GameObjManager::GameObjList.Head();
 	while (Current)
 	{
-		GameObject *Object = (GameObject *)Current->Data();
-		if (Object && As_ScriptableGameObj(Object))
+		GameObject *Object = Current->Data()->As_ScriptableGameObj();
+		if (Object)
 		{
-			if (Is_Vehicle(Object))
+			if (Object->As_VehicleGameObj())
 			{
 				if (Commands->Get_Distance(Pos,Commands->Get_Position(Object)) <= (float)EMPRANGE)
 				{
@@ -37131,7 +37114,7 @@
 
 int JMG_RP2_Tactical_Nuke_Phone_Beacon::Find_Nearest_Beacon_ID(GameObject *obj)
 {
-	if (!obj || !Commands->Get_ID(obj))
+	if (!obj)
 	{
 		return 0;
 	}
@@ -37141,7 +37124,7 @@
 	SLNode<BeaconGameObj> *Current = GameObjManager::BeaconGameObjList.Head();
 	while (Current)
 	{
-		GameObject *ObjectNode = (GameObject *)Current->Data();
+		GameObject *ObjectNode = Current->Data()->As_ScriptableGameObj();
 		if (ObjectNode)
 		{
 			Vector3 Pos = Commands->Get_Position(ObjectNode);
@@ -38488,28 +38471,21 @@
 		SLNode<BaseGameObj> *y = GameObjManager::GameObjList.Head();
 		while (y)
 		{
-			GameObject *o = (GameObject *)y->Data();
+			GameObject *o = y->Data()->As_ScriptableGameObj();
 			if (o)
 			{
 				count++;
-				if (As_ScriptableGameObj(o))
-				{
-					if (Is_Simple(o)){SimpleObjectCount++;}
-					else if (Is_Vehicle(o)){VehicleCount++;}
-					else if (Is_Soldier(o)){if (Is_Script_Attached(o,"JMG_RP2_Street_Sign_Crushable")){StreetSign++;}else{HumanCount++;}}
+				if (o->As_PhysicalGameObj() && o->As_PhysicalGameObj()->As_PhysicalGameObj()){SimpleObjectCount++;}
+				else if (o->As_VehicleGameObj()){VehicleCount++;}
+				else if (o->As_SoldierGameObj()){if (Is_Script_Attached(o,"JMG_RP2_Street_Sign_Crushable")){StreetSign++;}else{HumanCount++;}}
 					//else if (Is_Powerup(o)){PowerupCount++;}
-					else if (Is_ScriptZone(o)){ScriptZoneCount++;}
+				else if (o->As_ScriptZoneGameObj()){ScriptZoneCount++;}
 					//else if (Is_Beacon(o)){BeaconCount++;}
 					//else if (Is_Cinematic(o)){CinematicCount++;}
 					//else if (Is_C4(o)){C4Count++;}
 					//else if (Is_Armed(o)){ArmedCount++;}
 					else {MiscCount++;}
 				}
-				else
-				{
-					MiscCount++;
-				}
-			}
 			y = y->Next();
 		}
 		char ObjectCount[256];
@@ -38518,7 +38494,7 @@
 		SLNode<BuildingGameObj> *z = GameObjManager::BuildingGameObjList.Head();
 		while (z)
 		{
-			GameObject *o = (GameObject *)z->Data();
+			GameObject *o = z->Data();
 			if (o)
 			{
 				BuildingCount++;
@@ -38528,11 +38504,9 @@
 		SLNode<BaseGameObj> *j = GameObjManager::GameObjList.Head();
 		while (j)
 		{
-			GameObject *o = (GameObject *)j->Data();
+			GameObject *o = j->Data()->As_ScriptableGameObj();
 			if (o)
 			{
-				if (As_ScriptableGameObj(o))
-				{
 					const SimpleDynVecClass<GameObjObserverClass *> *observers = &((ScriptableGameObj *)o)->Get_Observers();
 					int TempSC = observers->Count();
 					ScriptCount += TempSC;
@@ -38542,13 +38516,12 @@
 						MostScriptsID = Commands->Get_ID(o);
 					}
 				}
-			}
 			j = j->Next();
 		}
 		SLNode<SmartGameObj> *x = GameObjManager::SmartGameObjList.Head();
 		while (x)
 		{
-			GameObject *o = (GameObject *)x->Data();
+			GameObject *o = x->Data();
 			if (o)
 			{
 				count++;
@@ -38978,7 +38951,7 @@
 void JMG_RP2_Renhalo_Vehicle_Passenger::Custom(GameObject *obj,int message,int param,GameObject *sender)
 {
 	// I just recreate the gunner object each time now, stops the crashing that way (crash occured when you would get out change weapons and get back in at random
-	/*if (message == 1000000028)
+	/*if (message == CUSTOM_EVENT_VEHICLE_ENTERED)
 	{
 		const char *Weapon2 = Get_Current_Weapon(obj);
 		if (Weapon2)
@@ -39014,7 +38987,7 @@
 		else{Select_Empty_Hands(obj);}
 		Commands->Set_Position(sender,Commands->Get_Position(obj));
 	}
-	if (message == 1000000029)
+	if (message == CUSTOM_EVENT_VEHICLE_EXITED)
 	{
 		if (!Commands->Get_Health(sender))
 		{
@@ -39032,7 +39005,7 @@
 			}
 		}
 	}*/
-	if (message == 1000000028)
+	if (message == CUSTOM_EVENT_VEHICLE_ENTERED)
 	{
 		const char *Weapon = Get_Current_Weapon(sender);
 		if (Weapon)
@@ -39055,7 +39028,7 @@
 			Select_Empty_Hands(obj);
 		}
 	}
-	if (message == 1000000029)
+	if (message == CUSTOM_EVENT_VEHICLE_EXITED)
 	{
 		if (!Commands->Get_Health(sender))
 		{
@@ -39099,7 +39072,7 @@
 {
 	Vector3 ExitPos,StartPos;
 	StartPos = ExitPos = Commands->Get_Position(obj);
-	PhysicalGameObj *objphys = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *objphys = obj->As_PhysicalGameObj();
 	objphys->As_PhysicalGameObj()->Peek_Physical_Object()->As_MoveablePhysClass()->Find_Teleport_Location(StartPos,25.0f,&ExitPos);
 	Commands->Set_Position(obj,ExitPos);
 	if (Is_Script_Attached(obj,"JMG_RP2_Create_Vehicle_At_Safe_Location"))
@@ -39119,7 +39092,7 @@
 	{
 		Vector3 ExitPos,StartPos;
 		StartPos = ExitPos = Commands->Get_Position(obj);
-		PhysicalGameObj *objphys = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+		PhysicalGameObj *objphys = obj->As_PhysicalGameObj();
 		objphys->As_PhysicalGameObj()->Peek_Physical_Object()->As_MoveablePhysClass()->Find_Teleport_Location(StartPos,5.0f,&ExitPos);
 		Commands->Set_Position(obj,ExitPos);
 		if (Is_Script_Attached(obj,"JMG_RP2_Create_Vehicle_At_Safe_Location"))
@@ -39160,7 +39133,7 @@
 			{// In same spot, try finding a random spot
 				LastUpdatePos.Z -= 0.5f;
 				Commands->Set_Position(obj,LastUpdatePos);
-				PhysicalGameObj *objphys = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+				PhysicalGameObj *objphys = obj->As_PhysicalGameObj();
 				objphys->As_PhysicalGameObj()->Peek_Physical_Object()->As_MoveablePhysClass()->Find_Teleport_Location(LastUpdatePos,3.0f,&LastUpdatePos);
 				Commands->Set_Position(obj,LastUpdatePos);
 				return;
@@ -39553,7 +39526,7 @@
 		return;
 	}
 	GameObject *MyVehicle = Get_Vehicle(obj);
-	if (Is_Vehicle(seen))
+	if (seen->As_VehicleGameObj())
 	{
 		Vector3 MyPos = Commands->Get_Position(obj);
 		if (!Get_Vehicle_Occupant_Count(seen) && Commands->Get_Distance(MyPos,Commands->Get_Position(Commands->Get_A_Star(MyPos))) > 100.0f)// Ignore empty vehicles unless a soldier is less than 100m away
@@ -39561,7 +39534,7 @@
 			return;
 		}
 	}
-	if (Is_Vehicle(seen) && !MyVehicle)
+	if (seen->As_VehicleGameObj() && !MyVehicle)
 	{
 		if (!Get_Vehicle_Seat_Count(seen))// Don't attack vehicles that can't be used
 		{
@@ -39585,7 +39558,7 @@
 		if (Get_Int_Parameter("Can_Use_Rockets") && !MyVehicle)// Not in a vehicle
 		{
 			const char *MyWeapon = Get_Current_Weapon(obj);
-			if (MyWeapon && (Is_TrackedVehicle(seen) || (Is_VTOLVehicle(seen) && Get_Current_Weapon(seen))))//Weapon Choice
+			if (MyWeapon && ((seen->As_PhysicalGameObj() && seen->As_PhysicalGameObj()->Peek_Physical_Object() && seen->As_PhysicalGameObj()->Peek_Physical_Object()->As_TrackedVehicleClass()) || ((seen->As_PhysicalGameObj() && seen->As_PhysicalGameObj()->Peek_Physical_Object() && seen->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()) && Get_Current_Weapon(seen))))//Weapon Choice
 			{
 				if (_stricmp("Weapon_M72_LAW",MyWeapon))
 				{
@@ -39821,7 +39794,7 @@
 			obj = MyVehicle;
 			AttackRange = 295.0f;
 			params.MoveBackup=Backward;
-			if (Is_VTOLVehicle(MyVehicle))
+			if ((MyVehicle->As_PhysicalGameObj() && MyVehicle->As_PhysicalGameObj()->Peek_Physical_Object() && MyVehicle->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()))
 			{
 				Pathfind = false;
 			}
@@ -39867,7 +39840,7 @@
 	{
 		obj = MyVehicle;
 		params.MoveBackup=Backward;
-		if (Is_VTOLVehicle(MyVehicle))
+		if ((MyVehicle->As_PhysicalGameObj() && MyVehicle->As_PhysicalGameObj()->Peek_Physical_Object() && MyVehicle->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()))
 		{
 			//TargetLocation.Z = Commands->Get_Safe_Flight_Height(TargetLocation.X,TargetLocation.Y);
 			params.MovePathfind=false;
@@ -40170,7 +40143,7 @@
 
 void JMG_Renhalo_Mindless_Hunt_And_Attack::VehicleRandomAction(GameObject *obj,float *Time,GameObject *MyVehicle)
 {
-	if (!Is_TrackedVehicle(MyVehicle))
+	if (!(MyVehicle->As_PhysicalGameObj() && MyVehicle->As_PhysicalGameObj()->Peek_Physical_Object() && MyVehicle->As_PhysicalGameObj()->Peek_Physical_Object()->As_TrackedVehicleClass()))
 	{
 		NewVehicleAction--;
 		if (NewVehicleAction <= 0)
@@ -40410,7 +40383,7 @@
 	Set_Skin(AI,"Blamo");
 	Commands->Attach_Script(AI,"JMG_Change_HP_Shields_On_Timer",params);
 	Commands->Attach_Script(AI,"M00_No_Falling_Damage_DME","0");
-	if (As_PhysicalGameObj(AI))
+	if (AI->As_PhysicalGameObj())
 	{
 		Vector3 pos = Location;
 		Vector3 ExitPos = pos;
@@ -40543,7 +40516,7 @@
 			Set_Skin(AI,"Blamo");
 			Commands->Attach_Script(AI,"JMG_Change_HP_Shields_On_Timer",params);
 			Commands->Attach_Script(AI,"M00_No_Falling_Damage_DME","0");
-			if (As_PhysicalGameObj(AI))
+			if (AI->As_PhysicalGameObj())
 			{
 				Vector3 pos = Pos;
 				Vector3 ExitPos = pos;
@@ -40657,7 +40630,7 @@
 	Set_Skin(AI,"Blamo");
 	Commands->Attach_Script(AI,"JMG_Change_HP_Shields_On_Timer",params);
 	Commands->Attach_Script(AI,"M00_No_Falling_Damage_DME","0");
-	if (As_PhysicalGameObj(AI))
+	if (AI->As_PhysicalGameObj())
 	{
 		Vector3 pos = Location;
 		Vector3 ExitPos = pos;
@@ -40777,7 +40750,7 @@
 			Commands->Attach_Script(Blocker,"SUR_Timed_Death","0.5,9999.0,blamokiller");
 			return;
 		}
-		if (Is_HumanPhys(enter) && !Get_Vehicle(enter))
+		if ((enter->As_PhysicalGameObj() && enter->As_PhysicalGameObj()->Peek_Physical_Object() && enter->As_PhysicalGameObj()->Peek_Physical_Object()->As_HumanPhysClass()) && !Get_Vehicle(enter))
 		{
 			if (Get_Int_Parameter("Object_ID") > 0)
 			{
@@ -42400,7 +42373,7 @@
 	{
 		return;
 	}
-	if (!Is_Projectile(seen))
+	if (!(seen->As_PhysicalGameObj() && seen->As_PhysicalGameObj()->Peek_Physical_Object() && seen->As_PhysicalGameObj()->Peek_Physical_Object()->As_ProjectileClass()))
 	{
 		float Distance = Commands->Get_Distance(Commands->Get_Position(obj),Commands->Get_Position(seen));
 		if (Distance <= Get_Float_Parameter("Max_Range") && Distance > Get_Float_Parameter("Min_Range"))
@@ -42720,7 +42693,7 @@
 		sprintf(MyName,"Unnamed Object (Object ID:%d/PresetName:%s",Commands->Get_ID(obj),Commands->Get_Preset_Name(obj));
 	}
 	delete[] preset;
-	if (Is_Vehicle(obj))
+	if (obj->As_VehicleGameObj())
 	{
 		GameObject *Driver = Get_Vehicle_Driver(obj);
 		if (Driver && Commands->Is_A_Star(Driver))
@@ -42761,7 +42734,7 @@
 			}
 			else if (killer == obj)
 			{// killed itself
-				if (Is_VTOLVehicle(obj))
+				if ((obj->As_PhysicalGameObj() && obj->As_PhysicalGameObj()->Peek_Physical_Object() && obj->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()))
 				{
 					const char *str = Get_Player_Name(Driver);
 					sprintf(Message,"%s's %s crashed.",str,MyName);
@@ -42807,10 +42780,13 @@
 		return;
 	}
 	char KilledOrDestroyed[128];
-	switch (Is_Soldier(obj))
+	if (obj->As_SoldierGameObj())
 	{// Decide if the word killed, or the word destroyed should be used in the phrase
-		case 1:sprintf(KilledOrDestroyed,"killed");break;
-		default:sprintf(KilledOrDestroyed,"destroyed");break;
+		sprintf(KilledOrDestroyed,"killed");
+	}
+	else
+	{
+		sprintf(KilledOrDestroyed,"destroyed");
 	}
 	if (Commands->Is_A_Star(killer))
 	{// Killed by player
@@ -42834,7 +42810,7 @@
 	}
 	else if (killer == obj)
 	{// Killed Itself
-		if (Is_Soldier(obj))
+		if (obj->As_SoldierGameObj())
 		{
 			if (Get_Sex(obj) == 'B')
 			{
@@ -42867,10 +42843,13 @@
 	}
 	else
 	{// Just diedSpontaneously combusted
-		switch (Is_Soldier(obj))
+		if (obj->As_SoldierGameObj())
 		{// Decide if the word killed, or the word destroyed should be used in the phrase
-			case 1:sprintf(Message,"A %s died.",MyName);break;
-			default:sprintf(Message,"A %s spontaneously combusted.",MyName);break;
+			sprintf(Message,"A %s died.",MyName);
+		}
+		else
+		{
+			sprintf(Message,"A %s spontaneously combusted.",MyName);
 		}
 	}
 	for (int x = 1;x < 128;x++)
@@ -42975,7 +42954,7 @@
 		else
 		{
 			float Curframe = Get_Animation_Frame(obj);
-			if (Is_Vehicle(TheVehicle))
+			if (TheVehicle->As_VehicleGameObj())
 			{
 				if (Curframe < 180)
 				{
@@ -44576,7 +44555,7 @@
 	Vector3 Pos = Commands->Get_Position(TargetSpot);
 	Vector3 ExitPos = Pos;
 	float Facing = Commands->Get_Facing(TargetSpot);
-	PhysicalGameObj *objphys = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+	PhysicalGameObj *objphys = obj->As_PhysicalGameObj();
 	objphys->As_PhysicalGameObj()->Peek_Physical_Object()->As_MoveablePhysClass()->Find_Teleport_Location(Pos,1.0f,&ExitPos);
 	Commands->Set_Position(obj,ExitPos);
 	Vector3 pos = Commands->Get_Bone_Position(obj,"c head");
@@ -44648,12 +44627,12 @@
 {
 	if (1453453 == number)
 	{
-		if (!As_PhysicalGameObj(obj) && Is_Script_Attached(obj,"JMG_RP2_Enable_Collisions_When_Safe"))
+		if (!obj->As_PhysicalGameObj() && Is_Script_Attached(obj,"JMG_RP2_Enable_Collisions_When_Safe"))
 		{
 			Remove_Script(obj,"JMG_RP2_Enable_Collisions_When_Safe");
 			return;
 		}
-		PhysicalGameObj *objphys = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+		PhysicalGameObj *objphys = obj->As_PhysicalGameObj();
 		Commands->Enable_Collisions(obj);
 		if (!objphys->Peek_Physical_Object()->As_MoveablePhysClass()->Can_Teleport(objphys->Get_Transform(),false))
 		{// Failed, try again
@@ -44808,7 +44787,7 @@
 		CalculateAnimation(obj);
 		Vector3 MyPos = Commands->Get_Position(obj);
 		Vector3 OriginalPos = MyPos;
-		PhysicalGameObj *objphys = ((ScriptableGameObj *)obj)->As_PhysicalGameObj();
+		PhysicalGameObj *objphys = obj->As_PhysicalGameObj();
 		int MaxGroundSafty = 1;
 		if (MyNode->MPH < 25)
 		{
@@ -45008,7 +44987,7 @@
 
 void JMG_RP2_Jet_Reload_Zone::Entered(GameObject *obj,GameObject *enter)
 {
-	if (Is_VTOLVehicle(enter))
+	if ((enter->As_PhysicalGameObj() && enter->As_PhysicalGameObj()->Peek_Physical_Object() && enter->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()))
 	{
 		Commands->Send_Custom_Event(obj,enter,543412,1,0.0f);
 	}
@@ -45016,7 +44995,7 @@
 
 void JMG_RP2_Jet_Reload_Zone::Exited(GameObject *obj,GameObject *exiter)
 {
-	if (Is_VTOLVehicle(exiter))
+	if ((exiter->As_PhysicalGameObj() && exiter->As_PhysicalGameObj()->Peek_Physical_Object() && exiter->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()))
 	{
 		Commands->Send_Custom_Event(obj,exiter,543412,0,0.0f);
 	}
@@ -45056,8 +45035,8 @@
 		SLNode<BaseGameObj> *Current = GameObjManager::GameObjList.Head();
 		while (Current)
 		{
-			GameObject *Object = (GameObject *)Current->Data();
-			if (Object && As_ScriptableGameObj(Object) && Object != obj)
+			GameObject *Object = Current->Data()->As_ScriptableGameObj();
+			if (Object && Object != obj)
 			{
 				if (Is_Script_Attached(Object,"JMG_RP2_WLS_Buy_Weapon_Poker") || Is_Script_Attached(Object,"JMG_Buy_Preset_On_Poke"))
 				{
@@ -45571,7 +45550,7 @@
 			obj = MyVehicle;
 			AttackRange = 295.0f;
 			params.MoveBackup=Backward;
-			if (Is_VTOLVehicle(MyVehicle)){Pathfind = false;}
+			if ((MyVehicle->As_PhysicalGameObj() && MyVehicle->As_PhysicalGameObj()->Peek_Physical_Object() && MyVehicle->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass())){Pathfind = false;}
 		}
 		else{params.MoveBackup=0;}
 		params.MovePathfind=Pathfind;
@@ -45597,7 +45576,7 @@
 	{
 		obj = MyVehicle;
 		params.MoveBackup=Backward;
-		if (Is_VTOLVehicle(MyVehicle))
+		if ((MyVehicle->As_PhysicalGameObj() && MyVehicle->As_PhysicalGameObj()->Peek_Physical_Object() && MyVehicle->As_PhysicalGameObj()->Peek_Physical_Object()->As_VTOLVehicleClass()))
 		{
 			params.MovePathfind=false;
 			ArriveDistance = 0.0f;
@@ -45756,7 +45735,7 @@
 
 void JMG_RP2_Smart_AI::VehicleRandomAction(GameObject *obj,float *Time,GameObject *MyVehicle)
 {
-	if (!Is_TrackedVehicle(MyVehicle))
+	if (!(MyVehicle->As_PhysicalGameObj() && MyVehicle->As_PhysicalGameObj()->Peek_Physical_Object() && MyVehicle->As_PhysicalGameObj()->Peek_Physical_Object()->As_TrackedVehicleClass()))
 	{
 		GiveUpTime--;
 		if (GiveUpTime <= 0)
diff -uwr sourceold/scripts/jmgrp2.h source/scripts/jmgrp2.h
--- sourceold/scripts/jmgrp2.h	2011-10-14 22:27:32.057617100 +0800
+++ source/scripts/jmgrp2.h	2012-05-23 10:34:38.099609300 +0800
@@ -587,10 +587,18 @@
 	void Timer_Expired(GameObject *obj,int number);
 	void Damaged(GameObject *obj,GameObject *damager,float damage);
 	void Killed(GameObject *obj, GameObject *damager);
+public:
+	JMG_Prostitute_Script()
+	{
+		name = 0;
+	}
 	~JMG_Prostitute_Script()
 	{
+		if (name)
+		{
 		delete[] name;
 	}
+	}
 };
 
 class JMG_Keyboard_Input_Custom : public JFW_Key_Hook_Base {
diff -uwr sourceold/scripts/kak.cpp source/scripts/kak.cpp
--- sourceold/scripts/kak.cpp	2011-10-11 23:05:59.489257800 +0800
+++ source/scripts/kak.cpp	2012-04-24 21:25:35.342773400 +0800
@@ -471,7 +471,6 @@
 		if (HarvyID)
 		{
 			Commands->Apply_Damage(Commands->Find_Object(HarvyID),99999,"Explosive",0);
-			if (!Commands->Get_ID(Commands->Find_Object(HarvyID))) Commands->Destroy_Object(Commands->Find_Object(HarvyID));
 			Commands->Destroy_Object(obj);
 		}
 	}
diff -uwr sourceold/scripts/mdb.cpp source/scripts/mdb.cpp
--- sourceold/scripts/mdb.cpp	2012-02-13 19:12:33.842195300 +0800
+++ source/scripts/mdb.cpp	2012-04-24 13:23:00.471679600 +0800
@@ -205,7 +205,7 @@
 			{
 				if (Verify_Preset_Limit(2, Get_Int_Parameter("Limit"), Definitions, 4))
 				{
-					if (ExpVehFac[team] && ExpVehFac[team]->Loaded && Is_Vehicle(obj))
+					if (ExpVehFac[team] && ExpVehFac[team]->Loaded && obj->As_VehicleGameObj())
 					{
 						UnitInfo* info = ExpVehFac[team]->Get_Unit_Info(def_id);
 						info->DMode = (info->DMode == DISABLED_EVF) ? DISABLED_BOTH : DISABLED_UNIT;
@@ -258,7 +258,7 @@
 			
 			bool enable_preset = true;
 			int evf_team = !Team;
-			if (ExpVehFac[evf_team] && ExpVehFac[evf_team]->Loaded && Is_Vehicle(obj))
+			if (ExpVehFac[evf_team] && ExpVehFac[evf_team]->Loaded && obj->As_VehicleGameObj())
 			{
 				UnitInfo* info = ExpVehFac[evf_team]->Get_Unit_Info(Commands->Get_Preset_ID(obj));
 				if (info)
diff -uwr sourceold/scripts/mdbdef.cpp source/scripts/mdbdef.cpp
--- sourceold/scripts/mdbdef.cpp	2011-10-11 23:05:47.966796800 +0800
+++ source/scripts/mdbdef.cpp	2012-04-24 13:23:39.488281200 +0800
@@ -76,7 +76,7 @@
 		{
 			ActionParamsStruct params;
 			params.Set_Basic(this,100,1);
-			if (AdjustInf && Is_Soldier(enemy))
+			if (AdjustInf && enemy->As_SoldierGameObj())
 			{
 				params.Set_Attack(Commands->Get_Bone_Position(enemy,"c R Foot"),MaxDis,0.0,true);
 				params.AttackCheckBlocked = true;
@@ -170,7 +170,7 @@
 	}
 	if (!Is_VTOL(enemy) && State == 3)
 	{
-		SmartGameObj* obj1 = (SmartGameObj*)As_SmartGameObj(enemy);
+		SmartGameObj* obj1 = enemy->As_SmartGameObj();
 		if(!obj1 
 		|| !obj1->Is_Stealthed() 
 		|| Commands->Get_Distance(Commands->Get_Position(obj), Commands->Get_Position(enemy)) <= Get_Float_Parameter("MaxStealthAttackDistance"))
@@ -179,7 +179,7 @@
 			{
 				ActionParamsStruct params;
 				params.Set_Basic(this,100,1);
-				if (AdjustInf && Is_Soldier(enemy))
+				if (AdjustInf && enemy->As_SoldierGameObj())
 				{
 					params.Set_Attack(Commands->Get_Bone_Position(enemy,"c R Foot"),MaxDis,0.0,true);
 					params.AttackCheckBlocked = true;
@@ -393,7 +393,7 @@
 		{
 			ActionParamsStruct params;
 			params.Set_Basic(this,100,1);
-			if (AdjustInf && Is_Soldier(enemy))
+			if (AdjustInf && enemy->As_SoldierGameObj())
 			{
 				params.Set_Attack(Commands->Get_Bone_Position(enemy,"c R Foot"),MaxDis,0.0,true);
 				params.AttackCheckBlocked = true;
@@ -514,7 +514,7 @@
 	}
 	ActionParamsStruct params;
 	params.Set_Basic(this,100,1);
-	if (AdjustInf && Is_Soldier(enemy))
+	if (AdjustInf && enemy->As_SoldierGameObj())
 	{
 		params.Set_Attack(Commands->Get_Bone_Position(enemy,"c R Foot"),MaxDis,0.0,true);
 		params.AttackCheckBlocked = true;
@@ -612,7 +612,7 @@
 	{
 		ActionParamsStruct params;
 		params.Set_Basic(this,100,1);
-		if (AdjustInf && Is_Soldier(enemy))
+		if (AdjustInf && enemy->As_SoldierGameObj())
 		{
 			params.Set_Attack(Commands->Get_Bone_Position(enemy,"c R Foot"),MaxDis,0.0,true);
 			params.AttackCheckBlocked = true;
diff -uwr sourceold/scripts/mdbevf.cpp source/scripts/mdbevf.cpp
--- sourceold/scripts/mdbevf.cpp	2011-10-11 23:05:46.441406200 +0800
+++ source/scripts/mdbevf.cpp	2012-04-24 13:23:55.576171800 +0800
@@ -1046,7 +1046,7 @@
 }
 void ExpVehFacClass::Object_Hook(void *,GameObject *obj)
 {
-	if (Is_Vehicle(obj))
+	if (obj->As_VehicleGameObj())
 	{
 		int Team = Get_Object_Type(obj);
 		if (ExpVehFac[Team] && ExpVehFac[Team]->Loaded)
diff -uwr sourceold/scripts/neo.cpp source/scripts/neo.cpp
--- sourceold/scripts/neo.cpp	2011-10-11 23:05:42.591796800 +0800
+++ source/scripts/neo.cpp	2012-04-24 13:25:21.594726500 +0800
@@ -15,6 +15,7 @@
 #include "engine.h"
 #include "neo.h"
 #include "VehicleGameObjDef.h"
+#include "SoldierGameObj.h"
 
 //**************Script Functions*****************
 
@@ -432,13 +433,13 @@
 						else
 						{
 							//new is a player(in tank),old is not
-							if (Is_Soldier(old))
+							if (old->As_SoldierGameObj())
 							{
 								//old is a soldier
 								//switch to new target,old not worth it
 								selected = target;
 							}
-							else if (Is_Vehicle(old))
+							else if (old->As_VehicleGameObj())
 							{
 								//old is a vehicle,new is a player in tank
 								//switch based on distance
@@ -473,13 +474,13 @@
 						else
 						{
 							//new is a player on foot,old is not a player
-							if (Is_Soldier(old))
+							if (old->As_SoldierGameObj())
 							{
 								//old is a soldier
 								//switch to new target,old not worth it
 								selected = target;
 							}
-							else if (Is_Vehicle(old))
+							else if (old->As_VehicleGameObj())
 							{
 								//old is a vehicle
 								//switch if old out of range and new is close
@@ -501,13 +502,13 @@
 					if (vehicle) //is the old in a vehicle?
 					{
 						//old in vehicle
-						if (Is_Soldier(target))
+						if (target->As_SoldierGameObj())
 						{
 							//new is a soldier,old is player in a tank
 							//Perhaps an out of range check here?
 							selected = 0; //keep old					
 						}
-						else if (Is_Vehicle(target))
+						else if (target->As_VehicleGameObj())
 						{
 							//new is a vehicle,old is player in a tank
 							//switch if new closer
@@ -516,12 +517,12 @@
 					}
 					else //old on foot
 					{
-						if (Is_Soldier(target))
+						if (target->As_SoldierGameObj())
 						{
 							//new is a soldier
 							selected = Get_Closest(obj,target,old);
 						}
-						else if (Is_Vehicle(target))
+						else if (target->As_VehicleGameObj())
 						{
 							//new is a vehicle,old just a player
 							selected = target;
@@ -619,7 +620,7 @@
 
 	if (target)//Just to be on the safe side
 	{
-		if (Is_Soldier(target)) //is the target a soldier?
+		if (target->As_SoldierGameObj()) //is the target a soldier?
 		{
 			if (Get_Int_Parameter("vsSoldier")) 
 				return true; //Use Primary
@@ -627,7 +628,7 @@
 				return false; //Use Secondary
 		}
 
-		if (Is_Vehicle(target))
+		if (target->As_VehicleGameObj())
 		{
 			if (Get_Vehicle_Mode(target) != VEHICLE_TYPE_FLYING)
 			{
diff -uwr sourceold/scripts/renalert.cpp source/scripts/renalert.cpp
--- sourceold/scripts/renalert.cpp	2012-02-13 19:12:33.152742200 +0800
+++ source/scripts/renalert.cpp	2012-04-25 12:11:13.884765600 +0800
@@ -256,12 +256,13 @@
 	*/
 	if (AP_mine) //Is this mine anti-personnel?
 	{
-		if (Is_Soldier(enemy))//using newer, more specific code
+		if (enemy->As_SoldierGameObj())//using newer, more specific code
 		{
 			GameObject *damager = Get_GameObj(ownerID);
 			int objID = Commands->Get_Player_Type(obj);
 			int ownerID = Commands->Get_Player_Type(damager);
 			Commands->Set_Player_Type(obj, 2); //Change teams to avoid friendly fire
+			SetExplosionObj(obj);
 			if (objID != ownerID) //Did the owner switch teams?
 			{
 				Commands->Apply_Damage(obj,Get_Float_Parameter("Trigger_Damage"),Get_Parameter("Trigger_Warhead"),0); //Die Infidel!
@@ -270,17 +271,19 @@
 			{
 				Commands->Apply_Damage(obj,Get_Float_Parameter("Trigger_Damage"),Get_Parameter("Trigger_Warhead"),damager); //Die Infidel!
 			}
+			SetExplosionObj(0);
 			return; //the mine is dead, end now
 		}
 	}
 	if (AT_mine) //Is this mine anti-tank?
 	{
-		if (Is_Vehicle(enemy))//using newer, more specific code
+		if (enemy->As_VehicleGameObj())//using newer, more specific code
 		{
 			GameObject *damager = Get_GameObj(ownerID);
 			int objID = Commands->Get_Player_Type(obj);
 			int ownerID = Commands->Get_Player_Type(damager);
 			Commands->Set_Player_Type(obj, 2); //Change teams to avoid friendly fire
+			SetExplosionObj(obj);
 			if (objID != ownerID) //Did the owner switch teams?
 			{
 				Commands->Apply_Damage(obj,Get_Float_Parameter("Trigger_Damage"),Get_Parameter("Trigger_Warhead"), 0); //Good-bye cruel world!
@@ -289,6 +292,7 @@
 			{
 				Commands->Apply_Damage(obj,Get_Float_Parameter("Trigger_Damage"),Get_Parameter("Trigger_Warhead"), damager); //Good-bye cruel world!
 			}
+			SetExplosionObj(0);
 			return; //the mine is dead, end now
 		}
 	}
@@ -1474,11 +1478,11 @@
 	switch(toggle)
 	{
 	case 0: //Case 0 prioritizes vehicles over infantry
-		if (Is_Soldier(old) && !(Is_Soldier(target)))
+		if (old->As_SoldierGameObj() && !(target->As_SoldierGameObj()))
 		{
 			return target; //new target is a vehicle
 		}
-		else if (!(Is_Soldier(old)) && Is_Soldier(target))
+		else if (!(old->As_SoldierGameObj()) && target->As_SoldierGameObj())
 		{
 			return old; //old target is a vehicle
 		}
@@ -1488,7 +1492,7 @@
 		}
 		break;//just to be safe
 	case 1: //Case 1 prioritizes infantry over vehicles
-		if (Is_Soldier(old) && !(Is_Soldier(target)))
+		if (old->As_SoldierGameObj() && !(target->As_SoldierGameObj()))
 		{
 			if (Get_Vehicle(old))// Did the old target get in a vehicle?
 			{
@@ -1499,7 +1503,7 @@
 				return old; //old soldier
 			}
 		}
-		else if (!(Is_Soldier(old)) && Is_Soldier(target))
+		else if (!(old->As_SoldierGameObj()) && target->As_SoldierGameObj())
 		{
 			if (Get_Vehicle(target))// Did the new target get in a vehicle? 
 			{
@@ -1684,7 +1688,7 @@
 {
 	if (Get_Int_Parameter("AdjustAim"))
 	{
-		if (Is_Soldier(target))
+		if (target->As_SoldierGameObj())
 		{
 			return true;
 		}
@@ -2006,11 +2010,11 @@
 	switch(toggle)
 	{
 	case 0: //Case 0 prioritizes vehicles over infantry
-		if (Is_Soldier(old) && !(Is_Soldier(target)))
+		if (old->As_SoldierGameObj() && !(target->As_SoldierGameObj()))
 		{
 			return target; //new target is a vehicle
 		}
-		else if (!(Is_Soldier(old)) && Is_Soldier(target))
+		else if (!(old->As_SoldierGameObj()) && target->As_SoldierGameObj())
 		{
 			return old; //old target is a vehicle
 		}
@@ -2020,7 +2024,7 @@
 		}
 		break;//just to be safe
 	case 1: //Case 1 prioritizes infantry over vehicles
-		if (Is_Soldier(old) && !(Is_Soldier(target)))
+		if (old->As_SoldierGameObj() && !(target->As_SoldierGameObj()))
 		{
 			if (Get_Vehicle(old))// Did the old target get in a vehicle?
 			{
@@ -2031,7 +2035,7 @@
 				return old; //old soldier
 			}
 		}
-		else if (!(Is_Soldier(old)) && Is_Soldier(target))
+		else if (!(old->As_SoldierGameObj()) && target->As_SoldierGameObj())
 		{
 			if (Get_Vehicle(target))// Did the new target get in a vehicle? 
 			{
@@ -2216,7 +2220,7 @@
 {
 	if (Get_Int_Parameter("AdjustAim"))
 	{
-		if (Is_Soldier(target))
+		if (target->As_SoldierGameObj())
 		{
 			return true;
 		}
@@ -2553,11 +2557,11 @@
 	switch(toggle)
 	{
 	case 0: //Case 0 prioritizes vehicles over infantry
-		if (Is_Soldier(old) && !(Is_Soldier(target)))
+		if (old->As_SoldierGameObj() && !(target->As_SoldierGameObj()))
 		{
 			return target; //new target is a vehicle
 		}
-		else if (!(Is_Soldier(old)) && Is_Soldier(target))
+		else if (!(old->As_SoldierGameObj()) && target->As_SoldierGameObj())
 		{
 			return old; //old target is a vehicle
 		}
@@ -2567,7 +2571,7 @@
 		}
 		break;//just to be safe
 	case 1: //Case 1 prioritizes infantry over vehicles
-		if (Is_Soldier(old) && !(Is_Soldier(target)))
+		if (old->As_SoldierGameObj() && !(target->As_SoldierGameObj()))
 		{
 			if (Get_Vehicle(old))// Did the old target get in a vehicle?
 			{
@@ -2578,7 +2582,7 @@
 				return old; //old soldier
 			}
 		}
-		else if (!(Is_Soldier(old)) && Is_Soldier(target))
+		else if (!(old->As_SoldierGameObj()) && target->As_SoldierGameObj())
 		{
 			if (Get_Vehicle(target))// Did the new target get in a vehicle? 
 			{
@@ -2763,7 +2767,7 @@
 {
 	if (Get_Int_Parameter("AdjustAim"))
 	{
-		if (Is_Soldier(target))
+		if (target->As_SoldierGameObj())
 		{
 			return true;
 		}
@@ -3000,7 +3004,7 @@
 			msg.Format("%s dumped some Ore at the refinary, giving the %s %d additional credits each.", str, str2, (int)value);
 			delete[] str2;
 			delete[] str;
-			SSGMGameLog::Log_Message(msg,"_ORE");
+			SSGMGameLog::Log_Message(msg,"_OREDUMP");
 			msg.Format("ppage %d Well done soldier, you have given your team mates an extra %d credits each", PlayerID, (int)value);
 			Console_Input(msg);
 			Commands->Give_Points(driver, reward, false);
@@ -3133,7 +3137,7 @@
 			msg.Format("%s dumped some Ore at the refinary, giving the %s %d additional credits each.", str, str2, (int)value);
 			delete[] str2;
 			delete[] str;
-			SSGMGameLog::Log_Message(msg,"_ORE");
+			SSGMGameLog::Log_Message(msg,"_OREDUMP");
 			msg.Format("ppage %d Well done soldier, you have given your team mates an extra %d credits each", PlayerID, (int)value);
 			Console_Input(msg);
 			Commands->Give_Points(driver, reward, false);
@@ -3820,8 +3824,11 @@
 {
 	Vector3 pos;
 	pos = Commands->Get_Position(obj);
-	int testID;
+	int testID = 0;
+	if (killer)
+	{
 	testID = Commands->Get_ID(killer);
+	}
 	const char *explosion = Get_Parameter("Explosion");
 	const char *warhead = Get_Parameter("Warhead");
 	float damage = Get_Float_Parameter("DamageStrength");
@@ -3916,8 +3923,10 @@
 			const char *warhead = Get_Parameter("Warhead");
 			float range = Get_Float_Parameter("DamageRadius");
 			//Time to break a few windows
+			SetExplosionObj(obj);
 			Ranged_Percentage_Damage_To_Buildings(Epercentage, warhead, Commands->Get_Position(obj), range, Get_GameObj(ownerID));
 			Ranged_Variable_Percent_Vehicle_Damage(Epercentage, Fpercentage, FF, warhead, Commands->Get_Position(obj), range, Get_GameObj(ownerID)); 
+			SetExplosionObj(0);
 		}
 		//Kill MAD Tank 
 		//'0' Damager used so owner won't get points for tank itself
diff -uwr sourceold/scripts/scripts.cpp source/scripts/scripts.cpp
--- sourceold/scripts/scripts.cpp	2011-10-11 23:06:22.983398400 +0800
+++ source/scripts/scripts.cpp	2012-05-10 21:50:14.808593700 +0800
@@ -315,7 +315,7 @@
 	FILE *f = fopen(path,"at");
 	if (f)
 	{
-		fprintf(f,"Critical Scripts.dll error,parameter is %s\n",parameterName);
+		fprintf(f,"Critical error the name is %s parameter is %s the map is %s\n",this->Get_Name(),parameterName,The_Game()->Get_Map_Name());
 		fclose(f);
 	}
 	return -1;
diff -uwr sourceold/scripts/scripts.h source/scripts/scripts.h
--- sourceold/scripts/scripts.h	2011-10-11 21:44:21.639648400 +0800
+++ source/scripts/scripts.h	2012-05-13 21:46:14.438320300 +0800
@@ -142,19 +142,117 @@
 	void	Auto_Save_Variable( void * data_ptr, int data_size, int id );
 	virtual ~ScriptImpClass();
 	const char* Get_Name(void);
-	void Created(GameObject *obj) {} //triggers on script creation
-	void Destroyed(GameObject *obj) {} //triggers on script shutdown
-	void Killed(GameObject *obj,GameObject *killer) {} //triggers when the object script is attached to dies
-	void Damaged(GameObject *obj,GameObject *damager,float amount) {} //triggers when the object script is attached to is damaged. The damager is always the gunner,not the vechicle.
-	void Custom(GameObject *obj,int type,int param,GameObject *sender) {} //triggers when the script is sent a custom (aka message). Several system events are triggered by Customs as well,see the #defines below
-	void Sound_Heard(GameObject *obj,const CombatSound & sound) {} //something to do with sound,I think it triggers when the object the script is attached to hears a sound)
-	void Enemy_Seen(GameObject *obj,GameObject *enemy) {} //triggers when the object script is attached to spots an enemy
-	void Action_Complete(GameObject *obj,int action_id,ActionCompleteReason complete_reason) {} //triggers when an action on the object the script is attached to completes
-	void Timer_Expired(GameObject *obj,int number) {} //triggers when a timer goes off
-	void Animation_Complete(GameObject *obj,const char *animation_name) {} //triggers when an animation on the object the script is attached to completes
-	void Poked(GameObject *obj,GameObject *poker) {} //triggers when the object that this scripts is attached to is poked (i.e. player pushes the action key while this object is active),this doesnt work in MP unless you have tt.dll
-	void Entered(GameObject *obj,GameObject *entererererer) {} //triggers when the zone this script is attached to is entered
-	void Exited(GameObject *obj,GameObject *exiterererer) {} //triggers when the zone this script is attached to is exited
+
+  /*! Script event that is triggered when this script is created
+  *
+  * \param[in] obj Pointer to the GameObject this script is attached to
+  */
+  void Created(GameObject *obj) {}
+
+  /*! Script event that is triggered when the object gets destroyed. Note that when a player changes
+  * character this event does *not* get triggered, if you need to react to this scenario overload
+  * Detach() instead
+  *
+  * \param[in] obj Pointer to the GameObject this script is attached to
+  */
+  void Destroyed(GameObject *obj) {}
+
+  /*! Script event that is triggered when the object is killed. Note that this event will not be
+  * triggered if the object is destroyed without being killed via loss of health, such as by another
+  * script calling ScriptCommands::Destroy_Object()
+  *
+  * \param[in] obj Pointer to the GameObject this script is attached to
+  * \param[in] killer Pointer to the GameObject that killed our object. NULL for environment damage
+  */
+  void Killed(GameObject *obj,GameObject *killer) {}
+
+  /*! Script event that is triggered when the object takes damage
+  *
+  * \param[in] obj Pointer to the GameObject this script is attached to
+  * \param[in] damager
+  *    Pointer to the GameObject that damaged our object, which will be the shooter and not the
+  *    vehicle they are driving (if any). NULL for environment damage
+  * \param[in] amount The amount of damage that was done to the object
+  */
+  void Damaged(GameObject *obj,GameObject *damager,float amount) {}
+  
+  /*! Script event that is triggered when the object recieves a custom, which could have been sent
+  * by another script or be triggered by a system event.
+  *
+  * \param[in] obj Pointer to the GameObject this script is attached to
+  * \param[in] type The type of custom that has been recieved
+  * \param[in] param The parameter that was attached to the custom by the sender
+  * \param[in] sender Pointer to the GameObject from which this custom was sent
+  */
+  void Custom(GameObject *obj,int type,int param,GameObject *sender) {}
+
+  /*! Script event that is triggered when the object hears a sound. Not currently well understood.
+  * Presumably requires innate AI to be enabled and for the object to have a listener scale of >0
+  * defined in it's preset definition.
+  *
+  * \param[in] obj Pointer to the GameObject this script is attached to
+  * \param[in] sound Information about the sound that has been heard
+  */
+  void Sound_Heard(GameObject *obj,const CombatSound & sound) {}
+
+  /*! Script event that is triggered when the object sees an enemy. This requires innate AI to be
+  * enabled and for the object to have a sight range of >0 defined in its preset definition.
+  *
+  * \param[in] obj Pointer to the GameObject this script is attached to
+  * \param[in] enemy Pointer to the enemy GameObject that was seen by the object
+  */
+  void Enemy_Seen(GameObject *obj,GameObject *enemy) {}
+
+  /*! Script event that is triggered when the object completes an action that this script is
+  * defined as the observer for.
+  *
+  * \see ActionParamsStruct
+  *
+  * \param[in] obj Pointer to the GameObject this script is attached to
+  * \param[in] action_id ID of the action that was completed
+  * \param[in] complete_reason The reason the action was marked as complete
+  */
+  void Action_Complete(GameObject *obj,int action_id,ActionCompleteReason complete_reason) {}
+
+  /*! Script event that is triggered when a script defined timer expires
+  *
+  * \see ScriptCommands::Start_Timer()
+  *
+  * \param[in] obj Pointer to the GameObject this script is attached to
+  * \param[in] number IF of the timer that expired
+  */
+  void Timer_Expired(GameObject *obj,int number) {}
+
+
+  /*! Script event that is triggered when the object completes an animation
+  *
+  * \param[in] obj Pointer to the GameObject this script is attached to
+  * \param[in] animation_name Name of the animation that was completed
+  */
+  void Animation_Complete(GameObject *obj,const char *animation_name) {}
+
+  /*! Script event that is triggered when the object has been poked by a player. Requires tt.dll
+  * to work correctly in multiplayer mode.
+  *
+  * \param[in] obj Pointer to the GameObject this script is attached to
+  * \param[in] poker Pointer to the GameObject of the player that poked this object
+  */
+  void Poked(GameObject *obj,GameObject *poker) {}
+
+  /*! Script event that is triggered on a script zone when an object enters its defined area
+  *
+  * \param[in] obj Pointer to the GameObject this script is attached to
+  * \param[in] enterer Pointer to the GameObject of the object that entered this zone
+  */
+  void Entered(GameObject *obj,GameObject *enterer) {}
+  
+  /*! Script event that is triggered on a script zone when an object leaves its defined area
+  *
+  * \param[in] obj Pointer to the GameObject this script is attached to
+  * \param[in] exiter Pointer to the GameObject of the object that left this zone
+  */
+  void Exited(GameObject *obj,GameObject *exiter) {}
+
 	GameObject* Owner()
 	{
 		return mOwner;
@@ -230,29 +328,36 @@
 	void Join_Conversation( int active_conversation_id )	{ ActiveConversationID = active_conversation_id; }
 	void Start_Conversation( const char * name )			{ ConversationName = name; }
 	void Dock_Vehicle( const Vector3 &dock_location, const Vector3 &dock_entrance ) { DockLocation = dock_location; DockEntrance = dock_entrance; }
+
+  /*! Priority for this action, this determines if it will override an existing action on the target
+  * object. If the priority of the existing action is lower, or there is no existing action, this
+  * action will be executed. If the priority is lower than that of the existing action it will be
+  * ignored. */
 	int Priority;
-	int ActionID;
-	long ObserverID;
+  int ActionID;                 //!< An identifier for this action, passed to ScriptImpClass::Action_Complete
+  long ObserverID;              //!< UID of a script to recieve notifications about this action, such as ScriptImpClass::Action_Complete
 	Vector3 LookLocation;
 	GameObject *LookObject;
 	float LookDuration;
-	Vector3 MoveLocation;
+  Vector3 MoveLocation;         //!< A target location for this object to attempt to reach
 	GameObject *MoveObject;
 	Vector3 MoveObjectOffset;
 	float MoveSpeed;
-	float MoveArrivedDistance;
-	bool MoveBackup;
+  float MoveArrivedDistance;    //!< How close to the target location the object must get to be considered as arrived
+  bool MoveBackup;              //!< True to drive in reverse, false to drive forwards
 	bool MoveFollow;
 	bool MoveCrouched;
+  /*! True to use the global pathfind data to assist in route planning, false to ignore it
+  * (presumably only useful if you specify a waypath to follow) */
 	bool MovePathfind;
-	bool ShutdownEngineOnArrival;
-	float AttackRange;
-	float AttackError;
+  bool ShutdownEngineOnArrival; //!< True to shutdown engine sounds upon arrival, false to leave them enabled
+  float AttackRange;            //!< The maximum range at which the object should attack an enemy
+  float AttackError;            //!< Apply up to this much error to the turret aim. If this is 0 the aim will be perfect
 	bool AttackErrorOverride;
-	GameObject *AttackObject;
+  GameObject *AttackObject;     //!< An object to track the movement of and fire at (if within range)
 	bool AttackPrimaryFire;
 	bool AttackCrouched;
-	Vector3 AttackLocation;
+  Vector3 AttackLocation;       //!< A location to fire at, presumably ignored if AttackObject is not NULL
 	bool AttackCheckBlocked;
 	bool AttackActive;
 	bool AttackWanderAllowed;
@@ -343,25 +448,26 @@
 
 enum {
 	CUSTOM_EVENT_SYSTEM_FIRST = 1000000000,
-	CUSTOM_EVENT_SOUND_ENDED, //sent when sound has ended
-	CUSTOM_EVENT_BUILDING_POWER_CHANGED, //sent when building power changes
-	CUSTOM_EVENT_DOCK_BACKING_IN, //sent when vehicle arrives at dock
-	CUSTOM_EVENT_CINEMATIC_SET_FIRST_SLOT, //sent to set cinematic slot
-	CUSTOM_EVENT_CINEMATIC_SET_LAST_SLOT = CUSTOM_EVENT_CINEMATIC_SET_FIRST_SLOT + 20, //sent to set cinematic slot
-	CUSTOM_EVENT_POWERUP_GRANTED, //sent when powerup is granted
-	CUSTOM_EVENT_BUILDING_DAMAGED, //sent when building is damaged
-	CUSTOM_EVENT_BUILDING_REPAIRED, //sent when building is repaired
-	CUSTOM_EVENT_VEHICLE_ENTERED, //sent when vehicle is entered
-	CUSTOM_EVENT_VEHICLE_EXITED, //sent when vehicle is exited
-	CUSTOM_EVENT_ATTACK_ARRIVED, //sent on attack arrived
-	CUSTOM_EVENT_CONVERSATION_BEGAN, //sent on conversation begin
-	CUSTOM_EVENT_CONVERSATION_REMARK_STARTED, //sent on conversation remark started
-	CUSTOM_EVENT_CONVERSATION_REMARK_ENDED, //sent on conversation remark ended
-	CUSTOM_EVENT_LADDER_OCCUPIED, //sent on ladder occupied
-	CUSTOM_EVENT_FALLING_DAMAGE, //sent on falling damage
-	CUSTOM_EVENT_VEHICLE_OWNER, //Special custom one sent by the new ownership code in tt.dll and by the scripts in mdbevf.cpp
-	CUSTOM_EVENT_VEHICLE_DRIVER, //Special custom one sent to vehicles where the driver/owner gets out to trigger it to find out its driver
-	CUSTOM_EVENT_VHEICLE_DRIVER_ID, //Response to CUSTOM_EVENT_VEHICLE_DRIVER, passes the owner GameObjects ID as the param
+	CUSTOM_EVENT_SOUND_ENDED,                                                           //!< Sent when sound has ended
+	CUSTOM_EVENT_BUILDING_POWER_CHANGED,                                                //!< Sent when building power changes
+	CUSTOM_EVENT_DOCK_BACKING_IN,                                                       //!< Sent when vehicle arrives at dock
+	CUSTOM_EVENT_CINEMATIC_SET_FIRST_SLOT = 10000,                                      //!< Sent to set cinematic slot
+	CUSTOM_EVENT_CINEMATIC_SET_LAST_SLOT = CUSTOM_EVENT_CINEMATIC_SET_FIRST_SLOT + 39,  //!< Sent to set cinematic slot
+	CUSTOM_EVENT_POWERUP_GRANTED = 1000000025,                                          //!< Sent when powerup is granted
+	CUSTOM_EVENT_BUILDING_DAMAGED,                                                      //!< Sent when building is damaged
+	CUSTOM_EVENT_BUILDING_REPAIRED,                                                     //!< Sent when building is repaired
+	CUSTOM_EVENT_VEHICLE_ENTERED,                                                       //!< Sent when vehicle is entered
+	CUSTOM_EVENT_VEHICLE_EXITED,                                                        //!< Sent when vehicle is exited
+	CUSTOM_EVENT_ATTACK_ARRIVED,                                                        //!< Sent on attack arrived
+	CUSTOM_EVENT_CONVERSATION_BEGAN,                                                    //!< Sent on conversation begin
+	CUSTOM_EVENT_CONVERSATION_REMARK_STARTED,                                           //!< Sent on conversation remark started
+	CUSTOM_EVENT_CONVERSATION_REMARK_ENDED,                                             //!< Sent on conversation remark ended
+	CUSTOM_EVENT_LADDER_OCCUPIED,                                                       //!< Sent on ladder occupied
+	CUSTOM_EVENT_FALLING_DAMAGE,                                                        //!< Sent on falling damage
+	CUSTOM_EVENT_VEHICLE_OWNER,                                                         //!< Special custom one sent by the new ownership code in tt.dll and by the scripts in mdbevf.cpp
+	CUSTOM_EVENT_VEHICLE_DRIVER,                                                        //!< Special custom one sent to vehicles where the driver/owner gets out to trigger it to find out its driver
+	CUSTOM_EVENT_VHEICLE_DRIVER_ID,                                                     //!< Response to CUSTOM_EVENT_VEHICLE_DRIVER, passes the owner GameObjects ID as the param
+	CUSTOM_EVENT_BEACON_DEPLOYED,                                                       //!< Sent when a beacon is deployed
 };
 
 enum {
@@ -478,6 +584,34 @@
 	int	( * Get_Random_Int )( int min, int max ); 
 	GameObject * ( * Find_Random_Simple_Object )( const char *preset_name );
 	void	( * Set_Model )( GameObject * obj, const char * model_name );
+
+  /*!
+  * Plays an animation upon the target game object, or a sub-object of that game object
+  *
+  * \param obj
+  *   Game object upon which to play the animation, this must be a PhysicalGameObj
+  * \param anim_name
+  *   Name of the animation to play upon the game object, in the form model.animation
+  * \param looping
+  *   Set to true to make the entire animation play repeatedly in an infinite loop from start to
+  *   end. Cannot be used in conjunction with the start_frame and end_frame parameters
+  * \param sub_obj_name
+  *   Not really sure what this is for... to be documented later :)
+  * \param start_frame
+  *   First frame number from the animation to be played
+  * \param end_frame
+  *   Last frame number from the animation to be played
+  * \param is_blended
+  *   Set to true to blend the animation with the current bone positions of the game object, this
+  *   only works on instances of SoldierGameObj.
+  *
+  * \note
+  *   Whilst this function does not allow you to create a looping animation from a subset of the
+  *   frames within the overall animation you can still do this by restarting the animation when
+  *   ScriptImpClass::Animation_Complete() is called. Alternatively you could use the new
+  *   LoopedAnimationController class to handle this for you, leaving your script code free of
+  *   the extra logic required to implement this functionality.
+  */
 	void	( * Set_Animation )( GameObject * obj, const char * anim_name, bool looping, const char * sub_obj_name, float start_frame, float end_frame, bool is_blended);
 	void	( * Set_Animation_Frame )( GameObject * obj, const char * anim_name, int frame );
 	int	( * Create_Sound )( const char * sound_preset_name, const Vector3 & position, GameObject * creator );
diff -uwr sourceold/scripts/scripts.vcxproj source/scripts/scripts.vcxproj
--- sourceold/scripts/scripts.vcxproj	2012-03-06 21:47:37.583984300 +0800
+++ source/scripts/scripts.vcxproj	2012-06-09 08:11:12.138671800 +0800
@@ -261,7 +261,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
@@ -338,7 +338,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
@@ -387,6 +387,7 @@
     </PostBuildEvent>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="aow_intruders.cpp" />
     <ClCompile Include="cAMpaScripts.cpp" />
     <ClCompile Include="CommandLineParser.cpp" />
     <ClCompile Include="Crc32.cpp" />
@@ -463,6 +464,7 @@
     <ClCompile Include="jmgrp2.cpp" />
     <ClCompile Include="kak.cpp" />
     <ClCompile Include="kamuix.cpp" />
+    <ClCompile Include="LoopedAnimationController.cpp" />
     <ClCompile Include="mdb.cpp" />
     <ClCompile Include="mdbdef.cpp" />
     <ClCompile Include="mdbevf.cpp" />
@@ -493,21 +495,30 @@
     <ClCompile Include="tcw_coop_cruising.cpp" />
     <ClCompile Include="tcw_defence.cpp" />
     <ClCompile Include="tcw_domination.cpp" />
+    <ClCompile Include="tcw_frost.cpp" />
+    <ClCompile Include="tcw_functions.cpp" />
     <ClCompile Include="tcw_game.cpp" />
+    <ClCompile Include="tcw_general.cpp" />
+    <ClCompile Include="tcw_mcv_escort.cpp" />
     <ClCompile Include="tcw_player.cpp" />
     <ClCompile Include="tcw_powerup.cpp" />
+    <ClCompile Include="tcw_raid_at_dawn.cpp" />
     <ClCompile Include="tcw_superweapons.cpp" />
+    <ClCompile Include="tcw_TCWSoldierObj.cpp" />
     <ClCompile Include="tcw_technology.cpp" />
+    <ClCompile Include="tcw_tiberium.cpp" />
     <ClCompile Include="tcw_vehicle.cpp" />
     <ClCompile Include="tcw_zone.cpp" />
     <ClCompile Include="tda.cpp" />
     <ClCompile Include="tfx.cpp" />
     <ClCompile Include="ThreadClass.cpp" />
     <ClCompile Include="z.cpp" />
+    <ClCompile Include="z_airraid.cpp" />
     <ClCompile Include="z_am01.cpp" />
     <ClCompile Include="z_am02.cpp" />
     <ClCompile Include="z_buildingrevive.cpp" />
     <ClCompile Include="z_cargo.cpp" />
+    <ClCompile Include="z_center_point.cpp" />
     <ClCompile Include="z_cold_fever.cpp" />
     <ClCompile Include="z_coop.cpp" />
     <ClCompile Include="z_darkdawn.cpp" />
@@ -546,10 +557,14 @@
     <ClCompile Include="z_lockdown.cpp" />
     <ClCompile Include="z_m00.cpp" />
     <ClCompile Include="z_m01.cpp" />
+    <ClCompile Include="z_mediterranean.cpp" />
+    <ClCompile Include="z_misc.cpp" />
     <ClCompile Include="z_nod_invasion.cpp" />
+    <ClCompile Include="z_prototype.cpp" />
     <ClCompile Include="z_reconnaissance.cpp" />
     <ClCompile Include="z_ship.cpp" />
     <ClCompile Include="z_siege.cpp" />
+    <ClCompile Include="z_tropical.cpp" />
     <ClCompile Include="z_uberaow.cpp" />
     <ClCompile Include="z_zones.cpp" />
   </ItemGroup>
@@ -563,6 +578,7 @@
     <ClInclude Include="AirFactoryGameObjDef.h" />
     <ClInclude Include="AirStripGameObj.h" />
     <ClInclude Include="AirStripGameObjDef.h" />
+    <ClInclude Include="aow_intruders.h" />
     <ClInclude Include="ArmedGameObj.h" />
     <ClInclude Include="ArmedGameObjDef.h" />
     <ClInclude Include="ArmorWarheadManager.h" />
@@ -580,6 +596,7 @@
     <ClInclude Include="cAMpaScripts.h" />
     <ClInclude Include="CinematicGameObj.h" />
     <ClInclude Include="CinematicGameObjDef.h" />
+    <ClInclude Include="cNetEvent.h" />
     <ClInclude Include="CollisionMath.h" />
     <ClInclude Include="coltest.h" />
     <ClInclude Include="coltype.h" />
@@ -592,6 +609,8 @@
     <ClInclude Include="ConPublic.h" />
     <ClInclude Include="cPlayer.h" />
     <ClInclude Include="Crc32.h" />
+    <ClInclude Include="cScTextObj.h" />
+    <ClInclude Include="cTeam.h" />
     <ClInclude Include="CullSystemClass.h" />
     <ClInclude Include="DamageableGameObj.h" />
     <ClInclude Include="DamageableGameObjDef.h" />
@@ -690,11 +709,14 @@
     <ClInclude Include="jmgrp2.h" />
     <ClInclude Include="kak.h" />
     <ClInclude Include="kamuix.h" />
+    <ClInclude Include="LoopedAnimationController.h" />
     <ClInclude Include="mdb.h" />
     <ClInclude Include="mdbdef.h" />
     <ClInclude Include="mdbevf.h" />
     <ClInclude Include="MixFileFactoryClass.h" />
     <ClInclude Include="MoveablePhysDefClass.h" />
+    <ClInclude Include="NavalFactoryGameObj.h" />
+    <ClInclude Include="NavalFactoryGameObjDef.h" />
     <ClInclude Include="neo.h" />
     <ClInclude Include="NetworkObjectClass.h" />
     <ClInclude Include="nh.h" />
@@ -734,6 +756,7 @@
     <ClInclude Include="SamSiteGameObjDef.h" />
     <ClInclude Include="SaveLoadSubSystemClass.h" />
     <ClInclude Include="SaveLoadSystemClass.h" />
+    <ClInclude Include="SCAnnouncement.h" />
     <ClInclude Include="SceneClass.h" />
     <ClInclude Include="ScriptableGameObj.h" />
     <ClInclude Include="ScriptableGameObjDef.h" />
@@ -765,11 +788,18 @@
     <ClInclude Include="tcw_coop_cruising.h" />
     <ClInclude Include="tcw_defence.h" />
     <ClInclude Include="tcw_domination.h" />
+    <ClInclude Include="tcw_frost.h" />
+    <ClInclude Include="tcw_functions.h" />
     <ClInclude Include="tcw_game.h" />
+    <ClInclude Include="tcw_general.h" />
+    <ClInclude Include="tcw_mcv_escort.h" />
     <ClInclude Include="tcw_player.h" />
     <ClInclude Include="tcw_powerup.h" />
+    <ClInclude Include="tcw_raid_at_dawn.h" />
     <ClInclude Include="tcw_superweapons.h" />
+    <ClInclude Include="tcw_TCWSoldierObj.h" />
     <ClInclude Include="tcw_technology.h" />
+    <ClInclude Include="tcw_tiberium.h" />
     <ClInclude Include="tcw_vehicle.h" />
     <ClInclude Include="tcw_zone.h" />
     <ClInclude Include="tda.h" />
@@ -792,10 +822,12 @@
     <ClInclude Include="WidgetUserClass.h" />
     <ClInclude Include="WWAudioClass.h" />
     <ClInclude Include="z.h" />
+    <ClInclude Include="z_airraid.h" />
     <ClInclude Include="z_am01.h" />
     <ClInclude Include="z_am02.h" />
     <ClInclude Include="z_buildingrevive.h" />
     <ClInclude Include="z_cargo.h" />
+    <ClInclude Include="z_center_point.h" />
     <ClInclude Include="z_cold_fever.h" />
     <ClInclude Include="z_coop.h" />
     <ClInclude Include="z_darkdawn.h" />
@@ -886,10 +918,14 @@
     <ClInclude Include="z_lockdown.h" />
     <ClInclude Include="z_m00.h" />
     <ClInclude Include="z_m01.h" />
+    <ClInclude Include="z_mediterranean.h" />
+    <ClInclude Include="z_misc.h" />
     <ClInclude Include="z_nod_invasion.h" />
+    <ClInclude Include="z_prototype.h" />
     <ClInclude Include="z_reconnaissance.h" />
     <ClInclude Include="z_ship.h" />
     <ClInclude Include="z_siege.h" />
+    <ClInclude Include="z_tropical.h" />
     <ClInclude Include="z_uberaow.h" />
     <ClInclude Include="z_zones.h" />
   </ItemGroup>
diff -uwr sourceold/scripts/scripts.vcxproj.filters source/scripts/scripts.vcxproj.filters
--- sourceold/scripts/scripts.vcxproj.filters	2012-03-06 21:47:37.586914000 +0800
+++ source/scripts/scripts.vcxproj.filters	2012-06-09 08:11:12.155273400 +0800
@@ -458,9 +458,6 @@
     <ClCompile Include="tcw_coop_cruising.cpp">
       <Filter>01. Sources\Tib. Crystal War</Filter>
     </ClCompile>
-    <ClCompile Include="tcw_defence.cpp">
-      <Filter>01. Sources\Tib. Crystal War</Filter>
-    </ClCompile>
     <ClCompile Include="tcw_zone.cpp">
       <Filter>01. Sources\Tib. Crystal War</Filter>
     </ClCompile>
@@ -473,6 +470,54 @@
     <ClCompile Include="z_domination.cpp">
       <Filter>01. Sources</Filter>
     </ClCompile>
+    <ClCompile Include="z_mediterranean.cpp">
+      <Filter>01. Sources</Filter>
+    </ClCompile>
+    <ClCompile Include="z_tropical.cpp">
+      <Filter>01. Sources</Filter>
+    </ClCompile>
+    <ClCompile Include="z_prototype.cpp">
+      <Filter>01. Sources</Filter>
+    </ClCompile>
+    <ClCompile Include="z_center_point.cpp">
+      <Filter>01. Sources</Filter>
+    </ClCompile>
+    <ClCompile Include="z_airraid.cpp">
+      <Filter>01. Sources</Filter>
+    </ClCompile>
+    <ClCompile Include="z_misc.cpp">
+      <Filter>01. Sources</Filter>
+    </ClCompile>
+    <ClCompile Include="aow_intruders.cpp">
+      <Filter>01. Sources\UberAOW</Filter>
+    </ClCompile>
+    <ClCompile Include="tcw_frost.cpp">
+      <Filter>01. Sources\Tib. Crystal War</Filter>
+    </ClCompile>
+    <ClCompile Include="tcw_functions.cpp">
+      <Filter>01. Sources\Tib. Crystal War</Filter>
+    </ClCompile>
+    <ClCompile Include="tcw_general.cpp">
+      <Filter>01. Sources\Tib. Crystal War</Filter>
+    </ClCompile>
+    <ClCompile Include="tcw_TCWSoldierObj.cpp">
+      <Filter>01. Sources\Tib. Crystal War</Filter>
+    </ClCompile>
+    <ClCompile Include="tcw_tiberium.cpp">
+      <Filter>01. Sources\Tib. Crystal War</Filter>
+    </ClCompile>
+    <ClCompile Include="tcw_raid_at_dawn.cpp">
+      <Filter>01. Sources\Tib. Crystal War</Filter>
+    </ClCompile>
+    <ClCompile Include="tcw_defence.cpp">
+      <Filter>01. Sources\Tib. Crystal War</Filter>
+    </ClCompile>
+    <ClCompile Include="LoopedAnimationController.cpp">
+      <Filter>01. Sources</Filter>
+    </ClCompile>
+    <ClCompile Include="tcw_mcv_escort.cpp">
+      <Filter>01. Sources\Tib. Crystal War</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="scripts.rc">
@@ -1416,9 +1461,6 @@
     <ClInclude Include="tcw_coop_cruising.h">
       <Filter>02. Headers\Tib. Crystal War</Filter>
     </ClInclude>
-    <ClInclude Include="tcw_defence.h">
-      <Filter>02. Headers\Tib. Crystal War</Filter>
-    </ClInclude>
     <ClInclude Include="ScriptManager.h">
       <Filter>03. New Sources</Filter>
     </ClInclude>
@@ -1431,6 +1473,72 @@
     <ClInclude Include="z_domination.h">
       <Filter>02. Headers</Filter>
     </ClInclude>
+    <ClInclude Include="NavalFactoryGameObjDef.h">
+      <Filter>03. New Sources</Filter>
+    </ClInclude>
+    <ClInclude Include="NavalFactoryGameObj.h">
+      <Filter>03. New Sources</Filter>
+    </ClInclude>
+    <ClInclude Include="z_mediterranean.h">
+      <Filter>02. Headers</Filter>
+    </ClInclude>
+    <ClInclude Include="z_tropical.h">
+      <Filter>02. Headers</Filter>
+    </ClInclude>
+    <ClInclude Include="z_prototype.h">
+      <Filter>02. Headers</Filter>
+    </ClInclude>
+    <ClInclude Include="z_center_point.h">
+      <Filter>02. Headers</Filter>
+    </ClInclude>
+    <ClInclude Include="z_airraid.h">
+      <Filter>02. Headers</Filter>
+    </ClInclude>
+    <ClInclude Include="z_misc.h">
+      <Filter>02. Headers</Filter>
+    </ClInclude>
+    <ClInclude Include="aow_intruders.h">
+      <Filter>02. Headers\UberAOW</Filter>
+    </ClInclude>
+    <ClInclude Include="SCAnnouncement.h">
+      <Filter>02. Headers</Filter>
+    </ClInclude>
+    <ClInclude Include="cNetEvent.h">
+      <Filter>02. Headers</Filter>
+    </ClInclude>
+    <ClInclude Include="cScTextObj.h">
+      <Filter>02. Headers</Filter>
+    </ClInclude>
+    <ClInclude Include="tcw_frost.h">
+      <Filter>02. Headers\Tib. Crystal War</Filter>
+    </ClInclude>
+    <ClInclude Include="tcw_functions.h">
+      <Filter>02. Headers\Tib. Crystal War</Filter>
+    </ClInclude>
+    <ClInclude Include="tcw_general.h">
+      <Filter>02. Headers\Tib. Crystal War</Filter>
+    </ClInclude>
+    <ClInclude Include="tcw_raid_at_dawn.h">
+      <Filter>02. Headers\Tib. Crystal War</Filter>
+    </ClInclude>
+    <ClInclude Include="tcw_TCWSoldierObj.h">
+      <Filter>02. Headers\Tib. Crystal War</Filter>
+    </ClInclude>
+    <ClInclude Include="tcw_tiberium.h">
+      <Filter>02. Headers\Tib. Crystal War</Filter>
+    </ClInclude>
+    <ClInclude Include="tcw_defence.h">
+      <Filter>02. Headers\Tib. Crystal War</Filter>
+    </ClInclude>
+    <ClInclude Include="LoopedAnimationController.h">
+      <Filter>02. Headers</Filter>
+    </ClInclude>
+    <ClInclude Include="cTeam.h">
+      <Filter>03. New Sources</Filter>
+    </ClInclude>
+    <ClInclude Include="tcw_mcv_escort.h">
+      <Filter>02. Headers\Tib. Crystal War</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="console.txt">
diff -uwr sourceold/scripts/sh_blocker.cpp source/scripts/sh_blocker.cpp
--- sourceold/scripts/sh_blocker.cpp	2011-10-11 23:06:19.515625000 +0800
+++ source/scripts/sh_blocker.cpp	2012-05-23 10:24:00.880859300 +0800
@@ -51,6 +51,8 @@
 		// base implementation
 		ScriptImpClass::Detach(obj);
 
+		if (Exe != 4) //make sure we dont try things in LE that may cause issues
+		{
 		// pull out the physical_obj
 		PhysicalGameObj* physical_obj = obj->As_PhysicalGameObj();
 
@@ -65,6 +67,7 @@
 
 		// inform netcode of the dirty things we've done with the phys
 		physical_obj->Set_Object_Dirty_Bit(NetworkObjectClass::BIT_RARE, true);
+		}
 	};
 };
 
diff -uwr sourceold/scripts/sh_underground.cpp source/scripts/sh_underground.cpp
--- sourceold/scripts/sh_underground.cpp	2011-10-11 23:06:17.741210900 +0800
+++ source/scripts/sh_underground.cpp	2012-05-23 10:23:59.060546800 +0800
@@ -257,8 +257,11 @@
 
 	void Detach(GameObject* obj)
 	{
+		if (Exe != 4) //make sure we dont try things in LE that may cause issues
+		{
 		// force exit of underground (don't want any objects stuck underground)
 		ExitUndergroundMode(true);
+		}
 
 		// base implementation
 		ScriptImpClass::Detach(obj);
Only in source/scripts: tcw_TCWSoldierObj.cpp
Only in source/scripts: tcw_TCWSoldierObj.h
diff -uwr sourceold/scripts/tcw_building.cpp source/scripts/tcw_building.cpp
--- sourceold/scripts/tcw_building.cpp	2012-02-02 09:44:43.142578100 +0800
+++ source/scripts/tcw_building.cpp	2012-06-09 08:11:12.324218700 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -14,6 +14,7 @@
 #include "general.h"
 #include "scripts.h"
 #include "engine.h"
+#include "buildinggameobj.h"
 #include "tcw_building.h"
 
 void tcw_building::Created(GameObject *obj)
@@ -23,6 +24,7 @@
 	if (strcmp(Commands->Get_Preset_Name(obj),"TCW_GDI_Command_Post") == 0)
 	{
 		Commands->Set_Animation(obj,"V_GDI_CPOST.V_GDI_CPOST",true,0,1,-1,0);
+		Commands->Start_Timer(obj,this,300.0f,111222);//radar scan
 	}
 }
 void tcw_building::Killed(GameObject *obj, GameObject *shooter)
@@ -48,9 +50,9 @@
 	}
 	else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_Nod_War_Factory") == 0)
 	{
-		Create_2D_WAV_Sound_Team("nod_warfactory_destroyed_nod.wav",1);
+		Create_2D_WAV_Sound_Team("nod_warfactory_destroyed_gdi.wav",1);
 		Create_2D_WAV_Sound_Team("nod_warfactory_destroyed_nod.wav",0);
-		Send_Message(255,255,255,"Nod Weapons Factory destroyed.");
+		Send_Message(255,255,255,"Nod War Factory destroyed.");
 	}
 	else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_Hand_Of_Nod") == 0)
 	{
@@ -76,7 +78,7 @@
 		Create_2D_WAV_Sound_Team("nod_powerplant_destroyed_nod.wav",0);
 		Send_Message_Team(1,255,255,255,"Nod Power Plant destroyed.");
 		Send_Message_Team(0,255,255,255,"Nod Power Plant destroyed.");
-		if (Find_Building_By_Name(0,"TCW_Nod_Oper_Centre"))
+		if (Find_Building_By_Preset(0,"TCW_Nod_Oper_Centre"))
 		{
 			Enable_Base_Radar(0,false);
 			Create_2D_WAV_Sound_Team("radar_off.wav",0);
@@ -88,11 +90,13 @@
 		Create_2D_WAV_Sound_Team("gdi_powerplant_destroyed_nod.wav",0);
 		Send_Message_Team(1,255,255,255,"GDI Power Plant destroyed.");
 		Send_Message_Team(0,255,255,255,"GDI Power Plant destroyed.");
-		if (Find_Building_By_Name(1,"TCW_GDI_Command_Post"))
+		if (Find_Building_By_Preset(1,"TCW_GDI_Command_Post"))
 		{
 			Enable_Base_Radar(1,false);
 			Create_2D_WAV_Sound_Team("radar_off.wav",1);
+			Send_Message_Team(1,255,255,255,"Command Post Radar Scans cancelled");
 		}
+		Send_Message_Team(1,255,255,255,"Vehicle Factory Unit build times tripled");
 	}
 	else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_Nod_Airfield") == 0)
 	{
@@ -107,6 +111,9 @@
 		Commands->Set_Animation(obj,"V_GDI_CPOST.V_GDI_CPOST",true,0,1,1,0);
 		Enable_Base_Radar(1,false);
 		Create_2D_WAV_Sound_Team("radar_off.wav",1);
+		Create_2D_WAV_Sound_Team("gdi_command_post_destroyed_nod.wav",0);
+		Create_2D_WAV_Sound_Team("gdi_command_post_destroyed_gdi.wav",1);
+		Send_Message(255,255,255,"Command Post Radar Scans cancelled");
 	}
 	else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_VehBld_Nod_OpCtr") == 0)
 	{
@@ -118,10 +125,12 @@
 	else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_VehBld_GDI_Armory") == 0)
 	{
 		Send_Message(255,255,255,"GDI Armory destroyed.");
+		Create_2D_WAV_Sound_Team("gdi_armory_destroyed_gdi.wav",1);
 	}
 	else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_VehBld_Nod_Silo") == 0)
 	{
 		Create_2D_WAV_Sound_Team("nod_tiberium_silo_destroyed_nod.wav",0);
+		Create_2D_WAV_Sound_Team("nod_tiberium_silo_destroyed_gdi.wav",1);
 		Send_Message(255,255,255,"Nod Tiberium Silo destroyed.");
 	}
 	else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_VehBld_GDI_Silo") == 0)
@@ -140,6 +149,10 @@
 		Create_2D_WAV_Sound_Team("nod_temple_destroyed_nod.wav",0);
 		Create_2D_WAV_Sound_Team("nod_temple_destroyed_gdi.wav",1);
 	}
+	else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_VehBld_Nod_Shrine") == 0)
+	{
+		Send_Message(255,255,255,"Shrine of Nod destroyed.");
+	}
 }
 void tcw_building::Damaged(GameObject *obj, GameObject *damager, float damage)
 {
@@ -174,10 +187,10 @@
 				}
 				else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_Nod_War_Factory") == 0)
 				{
-					Create_2D_WAV_Sound_Team("nod_warfactory_under_attack_nod.wav",1);
+					Create_2D_WAV_Sound_Team("nod_warfactory_under_attack_gdi.wav",1);
 					Create_2D_WAV_Sound_Team("nod_warfactory_under_attack_nod.wav",0);
-					Send_Message_Team(0,255,255,255,"Warning Nod Weapons Factory under attack.");
-					Send_Message_Team(1,255,255,255,"Nod Weapons Factory under attack.");
+					Send_Message_Team(0,255,255,255,"Warning Nod War Factory under attack.");
+					Send_Message_Team(1,255,255,255,"Nod War Factory under attack.");
 				}
 				else if ( (strcmp(Commands->Get_Preset_Name(obj),"TCW_Nod_Refinery") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"TCW_Nod_Refinery_Blue") == 0) )
 				{
@@ -228,16 +241,25 @@
 					Send_Message_Team(0,255,255,255,"Warning Nod Air Control Tower under attack.");
 					Send_Message_Team(1,255,255,255,"Nod Airfield under attack.");
 				}
-				else if ( (strcmp(Commands->Get_Preset_Name(obj),"TCW_VehBld_GDI_Armory") == 0) ||
-					(strcmp(Commands->Get_Preset_Name(obj),"TCW_VehBld_GDI_Silo") == 0) )
+				else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_VehBld_GDI_Armory") == 0)
+				{
+					Create_2D_WAV_Sound_Team("gdi_armory_under_attack_gdi.wav",1);
+					Send_Message_Team(1,255,255,255,"Warning GDI Armory under attack.");
+					Send_Message_Team(0,255,255,255,"GDI Armory under attack.");
+				}
+				else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_VehBld_GDI_Silo") == 0)
 				{
 					Create_2D_WAV_Sound_Team("gdi_our_base_under_attack.wav",1);
-					Send_Message_Team(1,255,255,255,"Our Base is under attack.");
+					Send_Message_Team(1,255,255,255,"Our Base is under attack. (Tiberium Silo)");
+					Send_Message_Team(0,255,255,255,"GDI Tiberium Silo under attack.");
 				}
 				else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_VehBld_GDI_CmdPost") == 0)
 				{
+					Create_2D_WAV_Sound_Team("gdi_command_post_under_attack_nod.wav",0);
+					Send_Message_Team(0,255,255,255,"GDI Command Post under attack.");
 					Create_2D_WAV_Sound_Team("gdi_command_post_under_attack_gdi.wav",1);
 					Send_Message_Team(1,255,255,255,"Warning GDI Command Post under attack.");
+					
 				}
 				else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_VehBld_Nod_OpCtr") == 0)
 				{
@@ -253,11 +275,6 @@
 					Create_2D_WAV_Sound_Team("nod_shrine_under_attack_gdi.wav",1);
 					Send_Message_Team(1,255,255,255,"Shrine of Nod under attack.");
 				}
-				else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_VehBld_Nod_Silo") == 0)
-				{
-					Create_2D_WAV_Sound_Team("nod_tiberium_silo_under_attack_nod.wav",0);
-					Send_Message_Team(0,255,255,255,"Warning Nod Tiberium Silo under attack.");
-				}
 				else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_VehBld_GDI_IonCtr") == 0)
 				{
 					Create_2D_WAV_Sound_Team("gdi_ion_center_under_attack_nod.wav",0);
@@ -272,6 +289,13 @@
 					Create_2D_WAV_Sound_Team("nod_temple_under_attack_gdi.wav",1);
 					Send_Message_Team(1,255,255,255,"Temple of Nod under attack.");
 				}
+				else if (strcmp(Commands->Get_Preset_Name(obj),"TCW_VehBld_Nod_Silo") == 0)
+				{
+					Create_2D_WAV_Sound_Team("nod_tiberium_silo_under_attack_nod.wav",0);
+					Send_Message_Team(0,255,255,255,"Warning Nod Tiberium Silo under attack.");
+					Create_2D_WAV_Sound_Team("nod_tiberium_silo_under_attack_gdi.wav",1);
+					Send_Message_Team(1,255,255,255,"Nod Tiberium Silo under attack.");
+				}
 			}
 		}
 	}
@@ -285,6 +309,29 @@
 			playdamage = true;
 		}
 	}
+	else if (number == 111222)
+	{
+		if (alive)
+		{
+			if (Is_Base_Powered(1))
+			{
+				Send_Custom_Event_To_Object(obj,"TCW_Nod_Shadow",1004,1,0);
+				Send_Custom_Event_To_Object(obj,"TCW_Nod_Shadow_Low",1004,1,0);
+				Send_Custom_Event_To_Object(obj,"TCW_Nod_Stealth_Tank",1004,1,0);
+				Send_Custom_Event_To_Object(obj,"TCW_GDI_Stealth_Tank",1004,1,0);
+				Send_Custom_Event_To_Object(obj,"TCW_Nod_Harvester",1004,1,0);
+				Send_Custom_Event_To_Object(obj,"TCW_Nod_Harvester_Player",1004,1,0);
+				Send_Custom_Event_To_Object(obj,"TCW_GDI_Nod_Harvester_Player",1004,1,0);
+				Send_Custom_Event_To_Object(obj,"TCW_GDI_Sniper",1004,1,0);
+				Send_Custom_Event_To_Object(obj,"TCW_GDI_Sniper_Low",1004,1,0);
+				Send_Custom_Event_To_Object(obj,"TCW_Nod_Commando",1004,1,0);
+				Send_Custom_Event_To_Object(obj,"TCW_Nod_Commando_Low",1004,1,0);
+				Commands->Start_Timer(obj,this,300.0f,111222);//radar scan repeat
+				Send_Message(255,255,255,"GDI Command Post Radar Scan Initiated");
+				Commands->Create_2D_WAV_Sound("radarscan.wav");
+			}
+		}
+	}
 }
 void tcw_building::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
@@ -292,7 +339,7 @@
 	{ 
 		if (param == 1)
 		{
-			if (Is_ComCenter(obj))
+			if (obj && obj->As_BuildingGameObj() && obj->As_BuildingGameObj()->As_ComCenterGameObj())
 			{
 				Restore_Building(obj);
 				Commands->Set_Health(obj,Commands->Get_Max_Health(obj));
diff -uwr sourceold/scripts/tcw_building.h source/scripts/tcw_building.h
--- sourceold/scripts/tcw_building.h	2012-02-02 09:44:43.155273400 +0800
+++ source/scripts/tcw_building.h	2012-06-09 08:11:12.158203100 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
diff -uwr sourceold/scripts/tcw_center_point.cpp source/scripts/tcw_center_point.cpp
--- sourceold/scripts/tcw_center_point.cpp	2012-02-02 09:44:43.169921800 +0800
+++ source/scripts/tcw_center_point.cpp	2012-06-09 08:11:12.362304600 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -20,28 +20,68 @@
 #include "SoldierGameObj.h"
 #include "VehicleGameObj.h"
 
+//0=nod 1=gdi 2=neu current animations for spawnpads
+
 void tcw_cp_cruiser_countdown_point::Created(GameObject *obj)
 {
+	Commands->Set_Animation(obj,"DOM_NODE.DOM_NODE",false,0,2,2,false);
+	spawnpad1 = Get_Int_Parameter("SpawnPad1ID");
+	if (Commands->Find_Object(spawnpad1))
+	{
+		Commands->Set_Animation(Commands->Find_Object(spawnpad1),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+	}
+	spawnpad2 = Get_Int_Parameter("SpawnPad2ID");
+	if (Commands->Find_Object(spawnpad2))
+	{
+		Commands->Set_Animation(Commands->Find_Object(spawnpad2),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+	}
+	spawnpad3 = Get_Int_Parameter("SpawnPad3ID");
+	if (Commands->Find_Object(spawnpad3))
+	{
+		Commands->Set_Animation(Commands->Find_Object(spawnpad3),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+	}
+	spawnpad4 = Get_Int_Parameter("SpawnPad4ID");
+	if (Commands->Find_Object(spawnpad4))
+	{
+		Commands->Set_Animation(Commands->Find_Object(spawnpad4),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+	}
 	nod_bar_turret_id = 100065; nod_ref_turret_id = 100067; gdi_hand_turret_id = 100068; gdi_ref_turret_id = 100070;	
 	nodveh1id = 0; nodveh2id = 0; gdiveh1id = 0; gdiveh2id = 0;
 	Commands->Set_Player_Type(obj,-2);
 	Commands->Set_Health(obj,2.0f);
 	create_cruiser_countdown_object = true;
+	trigger_neutral_damage = true;
 }
 void tcw_cp_cruiser_countdown_point::Damaged(GameObject *obj, GameObject *damager, float damage)
 {
 	if (Commands->Is_A_Star(damager))//is it a player?
 	{
-		if (damage < 0.0f)//if damage is less than 0 it must being repaired...
+		if ((damage < 0.0f) && (Commands->Get_Player_Type(obj) == -2))
+		{
+			if (Commands->Get_Health(obj) == Commands->Get_Max_Health(obj))//if fully repaired
+			{
+				if (Commands->Get_Player_Type(damager) == 0)
 		{
-			if (Commands->Get_Player_Type(obj) == -2)//unteamed
+					trigger_neutral_damage = true;
+					Commands->Set_Player_Type(obj,0);
+					Commands->Set_Animation(obj,"DOM_NODE.DOM_NODE",false,0,0,0,false);
+					if (Commands->Find_Object(spawnpad1))
 			{
-				Commands->Set_Player_Type(obj,Commands->Get_Player_Type(damager));//if someone is repairing it then set it to their team
+						Commands->Set_Animation(Commands->Find_Object(spawnpad1),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,0,0,false);
 			}
-			if (Commands->Get_Player_Type(obj) == 0) //if it is nods
+					if (Commands->Find_Object(spawnpad2))
 			{
-				if (Commands->Get_Health(obj) == Commands->Get_Max_Health(obj))//if fully repaired
+						Commands->Set_Animation(Commands->Find_Object(spawnpad2),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,0,0,false);
+					}
+					if (Commands->Find_Object(spawnpad3))
+					{
+						Commands->Set_Animation(Commands->Find_Object(spawnpad3),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,0,0,false);
+					}
+					if (Commands->Find_Object(spawnpad4))
 				{
+						Commands->Set_Animation(Commands->Find_Object(spawnpad4),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,0,0,false);
+					}
+
 					if (create_cruiser_countdown_object)//if the cruisercountdown object may be created
 					{
 						Send_Message(255,255,255,"Nod has captured the Countdown Control Point. One Minute for Cruiser Attacks.");
@@ -88,11 +128,28 @@
 						}
 					}
 				}
+				else if (Commands->Get_Player_Type(damager) == 1)
+				{
+					trigger_neutral_damage = true;
+					Commands->Set_Player_Type(obj,1);
+					Commands->Set_Animation(obj,"DOM_NODE.DOM_NODE",false,0,1,1,false);
+					if (Commands->Find_Object(spawnpad1))
+					{
+						Commands->Set_Animation(Commands->Find_Object(spawnpad1),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,1,1,false);
+					}
+					if (Commands->Find_Object(spawnpad2))
+					{
+						Commands->Set_Animation(Commands->Find_Object(spawnpad2),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,1,1,false);
 			}
-			else if (Commands->Get_Player_Type(obj) == 1)//if its gdi's
+					if (Commands->Find_Object(spawnpad3))
 			{
-				if (Commands->Get_Health(obj) == Commands->Get_Max_Health(obj))//if fully repaired
+						Commands->Set_Animation(Commands->Find_Object(spawnpad3),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,1,1,false);
+					}
+					if (Commands->Find_Object(spawnpad4))
 				{
+						Commands->Set_Animation(Commands->Find_Object(spawnpad4),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,1,1,false);
+					}
+
 					if (create_cruiser_countdown_object)
 					{
 						Send_Message(255,255,255,"GDI has captured the Countdown Control Point. One Minute for Cruiser Attacks.");
@@ -143,14 +200,19 @@
 		}
 		else if (damage > 0.0f)
 		{
-			if (Commands->Get_Player_Type(obj) == -2)
-			{
-				Commands->Set_Health(obj,2.0f);
-			}
-			else if (Commands->Get_Player_Type(damager) == 1)//if its gdi attacking it
+			if (Commands->Get_Player_Type(damager) == 1)//if its gdi attacking it
 			{
 				if (damage >= Commands->Get_Health(obj))//point is destroyed
 				{
+					Commands->Set_Player_Type(obj,-2);//it now belongs to gdi because they fully destroyed it
+					Commands->Set_Health(obj,2.0f);//we cant allow them to REALLY destroy it, otherwise the script halts and stuff....
+					if (trigger_neutral_damage)
+					{
+						Commands->Set_Animation(obj,"DOM_NODE.DOM_NODE",false,0,2,2,false);
+						Commands->Set_Animation(Commands->Find_Object(spawnpad1),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+						Commands->Set_Animation(Commands->Find_Object(spawnpad2),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+						Commands->Set_Animation(Commands->Find_Object(spawnpad3),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+						Commands->Set_Animation(Commands->Find_Object(spawnpad4),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
 					Send_Message(255,255,255,"Cruiser Attacks on GDI halted. Countdown Point destroyed.");
 					Vector3 tur1pos = Commands->Get_Position(Commands->Find_Object(nod_bar_turret_id));//bar attacking turret for nod
 					Vector3 tur2pos = Commands->Get_Position(Commands->Find_Object(nod_ref_turret_id));//ref attacking turret for nod
@@ -166,10 +228,8 @@
 					Commands->Set_Player_Type(tur2,0);
 					nod_bar_turret_id = Commands->Get_ID(tur1);//this is the new bar attacking turret for nod
 					nod_ref_turret_id = Commands->Get_ID(tur2);//this is the new ref attacking turret for nod
-					Commands->Set_Player_Type(obj,1);//it now belongs to gdi because they fully destroyed it
-					Commands->Set_Health(obj,2.0f);//we cant allow them to REALLY destroy it, otherwise the script halts and stuff....
 					create_cruiser_countdown_object = true;
-
+						Create_2D_WAV_Sound_Team("ControlPointLost_Nod.wav",0);
 					//destroy the spawned vehicles
 					if ( (Commands->Find_Object(nodveh1id)) && (!Get_Vehicle_Driver(Commands->Find_Object(nodveh1id))) )
 					{
@@ -179,12 +239,23 @@
 					{
 						Commands->Apply_Damage(Commands->Find_Object(nodveh2id),999999.0f,"Steel",obj);		nodveh2id = 0;
 					}
+						trigger_neutral_damage = false;
+					}
 				}
 			}
 			else if (Commands->Get_Player_Type(damager) == 0)//if its nod attacking it
 			{
 				if (damage >= Commands->Get_Health(obj))//point is destroyed
 				{
+					Commands->Set_Player_Type(obj,-2);//it now belongs to nod because they fully destroyed it
+					Commands->Set_Health(obj,2.0f);//we cant allow them to REALLY destroy it, otherwise the script halts and stuff....
+					if (trigger_neutral_damage)
+					{
+						Commands->Set_Animation(obj,"DOM_NODE.DOM_NODE",false,0,2,2,false);
+						Commands->Set_Animation(Commands->Find_Object(spawnpad1),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+						Commands->Set_Animation(Commands->Find_Object(spawnpad2),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+						Commands->Set_Animation(Commands->Find_Object(spawnpad3),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+						Commands->Set_Animation(Commands->Find_Object(spawnpad4),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
 					Send_Message(255,255,255,"Cruiser Attacks on Nod halted. Countdown Point destroyed.");
 					Vector3 tur1pos = Commands->Get_Position(Commands->Find_Object(gdi_hand_turret_id));//hon attacking turret for gdi
 					Vector3 tur2pos = Commands->Get_Position(Commands->Find_Object(gdi_ref_turret_id));//ref attacking turret for gdi
@@ -200,9 +271,8 @@
 					Commands->Set_Player_Type(tur2,1);
 					gdi_hand_turret_id = Commands->Get_ID(tur1);//this is the new hand attacking turret for gdi
 					gdi_ref_turret_id = Commands->Get_ID(tur2);//this is the new ref attacking turret for gdi
-					Commands->Set_Player_Type(obj,0);//it now belongs to nod because they fully destroyed it
-					Commands->Set_Health(obj,2.0f);//we cant allow them to REALLY destroy it, otherwise the script halts and stuff....
 					create_cruiser_countdown_object = true;
+						Create_2D_WAV_Sound_Team("ControlPointLost_GDI.wav",1);
 
 					//destroy the spawned vehicles
 					if ( (Commands->Find_Object(gdiveh1id)) && (!Get_Vehicle_Driver(Commands->Find_Object(gdiveh1id))) )
@@ -213,6 +283,8 @@
 					{
 						Commands->Apply_Damage(Commands->Find_Object(gdiveh2id),999999.0f,"Death",obj);		gdiveh2id = 0;
 					}
+						trigger_neutral_damage = false;
+					}
 				}
 			}
 		}
@@ -225,6 +297,7 @@
 	Auto_Save_Variable(&nodveh2id,sizeof(nodveh2id),3);
 	Auto_Save_Variable(&gdiveh1id,sizeof(gdiveh1id),4);
 	Auto_Save_Variable(&gdiveh2id,sizeof(gdiveh2id),5);
+	Auto_Save_Variable(&trigger_neutral_damage,sizeof(trigger_neutral_damage),6);
 }
 
 void tcw_cp_cruiser_countdown::Created(GameObject *obj)
@@ -294,4 +367,4 @@
 
 ScriptRegistrant<tcw_cp_cruiser_attack> tcw_cp_cruiser_attack_Registrant("tcw_cp_cruiser_attack","Attack_ID=1111:int,TurretID=0:int");
 ScriptRegistrant<tcw_cp_cruiser_countdown> tcw_cp_cruiser_countdown_Registrant("tcw_cp_cruiser_countdown","Team=0:int,NodTurretBar_ID=1:int,NodTurretRef_ID=1:int,GDITurretHon_ID=1:int,GDITurretRef_ID=1:int");
-ScriptRegistrant<tcw_cp_cruiser_countdown_point> tcw_cp_cruiser_countdown_point_Registrant("tcw_cp_cruiser_countdown_point","NodVeh1=asdf:string,NodVeh1Pos=0:vector3,NodVeh1Facing=0:float,NodVeh2=asdf:string,NodVeh2Pos=0:vector3,NodVeh2Facing=0:float,GDIVeh1=asdf:string,GDIVeh1Pos=0:vector3,GDIVeh1Facing=0:float,GDIVeh2=asdf:string,GDIVeh2Pos=0:vector3,GDIVeh2Facing=0:float");
\ No newline at end of file
+ScriptRegistrant<tcw_cp_cruiser_countdown_point> tcw_cp_cruiser_countdown_point_Registrant("tcw_cp_cruiser_countdown_point","NodVeh1=asdf:string,NodVeh1Pos=0:vector3,NodVeh1Facing=0:float,NodVeh2=asdf:string,NodVeh2Pos=0:vector3,NodVeh2Facing=0:float,GDIVeh1=asdf:string,GDIVeh1Pos=0:vector3,GDIVeh1Facing=0:float,GDIVeh2=asdf:string,GDIVeh2Pos=0:vector3,GDIVeh2Facing=0:float,SpawnPad1ID=0:int,SpawnPad2ID=0:int,SpawnPad3ID=0:int,SpawnPad4ID=0:int");
\ No newline at end of file
diff -uwr sourceold/scripts/tcw_center_point.h source/scripts/tcw_center_point.h
--- sourceold/scripts/tcw_center_point.h	2012-02-02 09:44:43.139648400 +0800
+++ source/scripts/tcw_center_point.h	2012-06-09 08:11:12.314453100 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -18,8 +18,10 @@
 	void Damaged(GameObject *obj, GameObject *damager, float damage);
 	public: void Register_Auto_Save_Variables();
 	bool create_cruiser_countdown_object;
+	bool trigger_neutral_damage;
 	int gdiveh1id; int gdiveh2id; int nodveh1id; int nodveh2id;
 	int nod_bar_turret_id; 	int nod_ref_turret_id; 	int gdi_hand_turret_id; int gdi_ref_turret_id;
+	int spawnpad1;	int spawnpad2;	int spawnpad3;	int spawnpad4;
 }; 
 
 class tcw_cp_cruiser_countdown : public ScriptImpClass {
diff -uwr sourceold/scripts/tcw_coop.cpp source/scripts/tcw_coop.cpp
--- sourceold/scripts/tcw_coop.cpp	2012-02-02 09:44:43.115234300 +0800
+++ source/scripts/tcw_coop.cpp	2012-06-09 08:11:12.123046800 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -16,6 +16,8 @@
 #include "engine.h"
 #include "tcw_coop.h"
 
+//The_Game()->Get_Game_Duration_S() to get elapsed time in seconds for some missions maybe
+
 void tcw_i_am_a_bot::Created(GameObject *obj)
 {
 	//lol
diff -uwr sourceold/scripts/tcw_coop.h source/scripts/tcw_coop.h
--- sourceold/scripts/tcw_coop.h	2012-02-02 09:44:43.180664000 +0800
+++ source/scripts/tcw_coop.h	2012-06-09 08:11:12.191406200 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
diff -uwr sourceold/scripts/tcw_coop_cruising.cpp source/scripts/tcw_coop_cruising.cpp
--- sourceold/scripts/tcw_coop_cruising.cpp	2012-02-02 09:44:43.161132800 +0800
+++ source/scripts/tcw_coop_cruising.cpp	2012-06-09 08:11:12.352539000 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -232,7 +232,7 @@
 	{
 		if (attack)
 		{
-			if (Commands->Get_Health(Find_Building(0,BuildingConstants::TYPE_REFINERY)) > 1.0f)//if the refinery is alive
+			if (Commands->Get_Health(Find_Building_By_Type(0,BuildingConstants::TYPE_REFINERY)) > 1.0f)//if the refinery is alive
 			{
 				ActionParamsStruct params;
 				int priority = 100;		float range = 1500.0f;		float deviation = 0.0f;		int primary = 1;
@@ -249,7 +249,7 @@
 					Commands->Action_Reset(obj,100);//stop attacking mode
 				}
 			}
-			else if (Commands->Get_Health(Find_Building(0,BuildingConstants::TYPE_SOLDIER_FACTORY)) > 1.0f)//if the hand is alive
+			else if (Commands->Get_Health(Find_Building_By_Type(0,BuildingConstants::TYPE_SOLDIER_FACTORY)) > 1.0f)//if the hand is alive
 			{
 				ActionParamsStruct params;
 				int priority = 100;		float range = 1500.0f;		float deviation = 0.0f;		int primary = 1;
diff -uwr sourceold/scripts/tcw_coop_cruising.h source/scripts/tcw_coop_cruising.h
--- sourceold/scripts/tcw_coop_cruising.h	2012-02-02 09:44:43.183593700 +0800
+++ source/scripts/tcw_coop_cruising.h	2012-06-09 08:11:12.381835900 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
diff -uwr sourceold/scripts/tcw_defence.cpp source/scripts/tcw_defence.cpp
--- sourceold/scripts/tcw_defence.cpp	2012-02-02 09:44:43.149414000 +0800
+++ source/scripts/tcw_defence.cpp	2012-06-09 08:11:12.334960900 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -313,11 +313,13 @@
 	switch(toggle)
 	{
 	case 0: //Case 0 prioritizes vehicles over infantry
-		if (Is_Soldier(old) && !(Is_Soldier(target)))
+		//if (Is_Soldier(old) && !(Is_Soldier(target)))
+		if ((old && old->As_SoldierGameObj()) && (target && !target->As_SoldierGameObj()))
 		{
 			return target; //new target is a vehicle
 		}
-		else if (!(Is_Soldier(old)) && Is_Soldier(target))
+		//else if (!(Is_Soldier(old)) && Is_Soldier(target))
+		else if (!(old && old->As_SoldierGameObj()) && (target && target->As_SoldierGameObj()))
 		{
 			return old; //old target is a vehicle
 		}
@@ -327,7 +329,8 @@
 		}
 		break;//just to be safe
 	case 1: //Case 1 prioritizes infantry over vehicles
-		if (Is_Soldier(old) && !(Is_Soldier(target)))
+		//if (Is_Soldier(old) && !(Is_Soldier(target)))
+		if ((old && old->As_SoldierGameObj()) && !(target && target->As_SoldierGameObj()))
 		{
 			if (Get_Vehicle(old))// Did the old target get in a vehicle?
 			{
@@ -338,7 +341,7 @@
 				return old; //old soldier
 			}
 		}
-		else if (!(Is_Soldier(old)) && Is_Soldier(target))
+		else if (!(old && old->As_SoldierGameObj()) && (target && target->As_SoldierGameObj()))
 		{
 			if (Get_Vehicle(target))// Did the new target get in a vehicle? 
 			{
@@ -523,7 +526,7 @@
 {
 	if (Get_Int_Parameter("AdjustAim"))
 	{
-		if (Is_Soldier(target))
+		if (target && target->As_SoldierGameObj())
 		{
 			return true;
 		}
@@ -531,4 +534,4 @@
 	return false;
 }
 
-ScriptRegistrant<tcw_Base_Defense> tcw_Base_Defense_Registrant("tcw_Base_Defense","MinRange=0.0:float,MaxRange=100.0:float,AntiAir=0:int,AntiGround=1:int,AdjustAim=0:int,TargetMode=0:int");
\ No newline at end of file
+ScriptRegistrant<tcw_Base_Defense> tcw_Base_Defense_Registrant("tcw_Base_Defense","MinRange=0.0:float,MaxRange=100.0:float,AntiAir=0:int,AntiGround=1:int,AdjustAim=0:int,TargetMode=0:int,Team=0:int");
\ No newline at end of file
diff -uwr sourceold/scripts/tcw_defence.h source/scripts/tcw_defence.h
--- sourceold/scripts/tcw_defence.h	2012-02-02 09:44:43.190429600 +0800
+++ source/scripts/tcw_defence.h	2012-06-09 08:11:12.215820300 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
diff -uwr sourceold/scripts/tcw_domination.cpp source/scripts/tcw_domination.cpp
--- sourceold/scripts/tcw_domination.cpp	2012-02-02 09:44:43.144531200 +0800
+++ source/scripts/tcw_domination.cpp	2012-06-09 08:11:12.146484300 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -20,6 +20,7 @@
 #include "SoldierGameObj.h"
 #include "VehicleGameObj.h"
 
+//0=nod 1=gdi 2=neu current animations for spawnpads
 
 void tcw_domination_control::Created(GameObject *obj)
 {
@@ -151,26 +152,67 @@
 
 void tcw_domination_node::Created(GameObject *obj)
 {
+	Commands->Set_Animation(obj,"DOM_NODE.DOM_NODE",false,0,2,2,false);
+	spawnpad1 = Get_Int_Parameter("SpawnPad1ID");
+	if (Commands->Find_Object(spawnpad1))
+	{
+		Commands->Set_Animation(Commands->Find_Object(spawnpad1),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+	}
+	spawnpad2 = Get_Int_Parameter("SpawnPad2ID");
+	if (Commands->Find_Object(spawnpad2))
+	{
+		Commands->Set_Animation(Commands->Find_Object(spawnpad2),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+	}
+	spawnpad3 = Get_Int_Parameter("SpawnPad3ID");
+	if (Commands->Find_Object(spawnpad3))
+	{
+		Commands->Set_Animation(Commands->Find_Object(spawnpad3),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+	}
+	spawnpad4 = Get_Int_Parameter("SpawnPad4ID");
+	if (Commands->Find_Object(spawnpad4))
+	{
+		Commands->Set_Animation(Commands->Find_Object(spawnpad4),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+	}
 	nodename = Get_Parameter("Node_Name");
 	owner = -2;
 	nodveh1id = 0;	nodveh2id = 0; nodveh3id = 0;	nodveh4id = 0; nodveh5id = 0;
 	gdiveh1id = 0;	gdiveh2id = 0; gdiveh3id = 0;	gdiveh4id = 0; gdiveh5id = 0;
+	trigger_neutral_damage = true;
+	Commands->Start_Timer(obj,this,60.0f,200200);//recheck spawns for nod
+	Commands->Start_Timer(obj,this,60.0f,200201);//recheck spawns for gdi
 }
 void tcw_domination_node::Damaged(GameObject *obj, GameObject *damager, float damage)
 {
-	if (damage < 0.0f)
+	if ((damage < 0.0f) && (Commands->Get_Player_Type(obj) == -2))
 	{
-		if (owner == -2)
+		if (Commands->Get_Health(obj) == Commands->Get_Max_Health(obj))//if node fully repaired
 		{
-			owner = Commands->Get_Player_Type(damager);
-			Commands->Set_Player_Type(obj,Commands->Get_Player_Type(damager));
+			trigger_neutral_damage = true;
+			int team = Commands->Get_Player_Type(damager);
+			if (team == 0)
+			{
+				char params[250]; sprintf(params,"%d",team);
+				Attach_Script_Once(obj,"tcw_domination_pointgen",params);
+				owner = 0;
+				Commands->Set_Player_Type(obj,0);
+
+				Commands->Set_Animation(obj,"DOM_NODE.DOM_NODE",false,0,0,0,false);
+				if (Commands->Find_Object(spawnpad1))
+				{
+					Commands->Set_Animation(Commands->Find_Object(spawnpad1),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,0,0,false);
 		}
-		else if (owner == 0)
+				if (Commands->Find_Object(spawnpad2))
 		{
-			//owner = Commands->Get_Player_Type(damager);
-			if (Commands->Get_Health(obj) == Commands->Get_Max_Health(obj))//if node fully repaired
+					Commands->Set_Animation(Commands->Find_Object(spawnpad2),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,0,0,false);
+				}
+				if (Commands->Find_Object(spawnpad3))
 			{
-				Attach_Script_Once(obj,"tcw_domination_pointgen","0");
+					Commands->Set_Animation(Commands->Find_Object(spawnpad3),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,0,0,false);
+				}
+				if (Commands->Find_Object(spawnpad4))
+				{
+					Commands->Set_Animation(Commands->Find_Object(spawnpad4),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,0,0,false);
+				}
 
 				if (!Commands->Find_Object(nodveh1id))
 				{
@@ -235,19 +277,35 @@
 
 				char capturemsg[250];	sprintf(capturemsg,"Nod captured the %s Control Point.",nodename);	Send_Message(255,255,255,capturemsg);
 				Create_2D_WAV_Sound_Team("ControlPointCaptured_Nod.wav",0); 
-				Create_2D_WAV_Sound_Team("ControlPointLost_GDI.wav",1);
 				if (Commands->Get_Player_Type(damager) == Commands->Get_Player_Type(obj))
 				{
 					Commands->Give_Money(damager,500.0f,true);
 				}
 			}
+			else if (team == 1)
+			{
+				char params[250]; sprintf(params,"%d",team);
+				Attach_Script_Once(obj,"tcw_domination_pointgen",params);
+				owner = 1;
+				Commands->Set_Player_Type(obj,1);
+
+				Commands->Set_Animation(obj,"DOM_NODE.DOM_NODE",false,0,1,1,false);
+				if (Commands->Find_Object(spawnpad1))
+				{
+					Commands->Set_Animation(Commands->Find_Object(spawnpad1),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,1,1,false);
 		}
-		else if (owner == 1)
+				if (Commands->Find_Object(spawnpad2))
 		{
-			//owner = Commands->Get_Player_Type(damager);
-			if (Commands->Get_Health(obj) == Commands->Get_Max_Health(obj))//if node fully repaired
+					Commands->Set_Animation(Commands->Find_Object(spawnpad2),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,1,1,false);
+				}
+				if (Commands->Find_Object(spawnpad3))
+				{
+					Commands->Set_Animation(Commands->Find_Object(spawnpad3),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,1,1,false);
+				}
+				if (Commands->Find_Object(spawnpad4))
 			{
-				Attach_Script_Once(obj,"tcw_domination_pointgen","1");
+					Commands->Set_Animation(Commands->Find_Object(spawnpad4),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,1,1,false);
+				}
 
 				if (!Commands->Find_Object(gdiveh1id))
 				{
@@ -312,7 +370,6 @@
 
 				char capturemsg[250];	sprintf(capturemsg,"GDI captured the %s Control Point.",nodename);	Send_Message(255,255,255,capturemsg);
 				Create_2D_WAV_Sound_Team("ControlPointCaptured_GDI.wav",1); 
-				Create_2D_WAV_Sound_Team("ControlPointLost_Nod.wav",0);
 				if (Commands->Get_Player_Type(damager) == Commands->Get_Player_Type(obj))
 				{
 					Commands->Give_Money(damager,500.0f,true);
@@ -320,23 +377,25 @@
 			}
 		}
 	}
-	else if (damage > 0.0f)
+	else if (damage > 0.0f)//it is being attacked by enemy
 	{
 		if (damage > Commands->Get_Health(obj))//if node fully destroyed
 		{
-			Remove_Script(obj,"tcw_domination_pointgen");
-			if (owner == -2)
-			{
-				Commands->Set_Player_Type(obj,-2);
 				Commands->Set_Health(obj,1.1f);
-			}
-			else
+			Commands->Set_Player_Type(obj,-2);
+			if (trigger_neutral_damage)
 			{
-				Commands->Set_Health(obj,1.1f);
-				Commands->Set_Player_Type(obj,Commands->Get_Player_Type(damager));
+				trigger_neutral_damage = false;
+				Commands->Set_Animation(Commands->Find_Object(spawnpad1),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+				Commands->Set_Animation(Commands->Find_Object(spawnpad2),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+				Commands->Set_Animation(Commands->Find_Object(spawnpad3),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+				Commands->Set_Animation(Commands->Find_Object(spawnpad4),"NEU_PLATFRM_2.NEU_PLATFRM_2",false,0,2,2,false);
+				Remove_Script(obj,"tcw_domination_pointgen");
+				Commands->Set_Animation(obj,"DOM_NODE.DOM_NODE",false,0,2,2,false);
 
 				if (owner == 0)
 				{
+					Create_2D_WAV_Sound_Team("ControlPointLost_Nod.wav",0);
 					if ( (Commands->Find_Object(nodveh1id)) && (!Get_Vehicle_Driver(Commands->Find_Object(nodveh1id))) )
 					{
 						Commands->Apply_Damage(Commands->Find_Object(nodveh1id),99999.0f,"Steel",obj);		nodveh1id = 0;
@@ -360,6 +419,7 @@
 				}
 				else if (owner == 1)
 				{
+					Create_2D_WAV_Sound_Team("ControlPointLost_GDI.wav",1);
 					if ( (Commands->Find_Object(gdiveh1id)) && (!Get_Vehicle_Driver(Commands->Find_Object(gdiveh1id))) )
 					{
 						Commands->Apply_Damage(Commands->Find_Object(gdiveh1id),99999.0f,"Steel",obj);		gdiveh1id = 0;
@@ -381,10 +441,146 @@
 						Commands->Apply_Damage(Commands->Find_Object(gdiveh5id),99999.0f,"Steel",obj);		gdiveh5id = 0;
 					}
 				}
-
-				owner = Commands->Get_Player_Type(damager);
+				owner = -2;
+			}
+		}
+	}
+}
+void tcw_domination_node::Timer_Expired(GameObject *obj, int number)
+{
+	if (number == 200200)
+	{
+		if (owner == 0)
+		{
+			if (!Commands->Find_Object(nodveh1id))
+			{
+				if (strcmp(Get_Parameter("NodVeh1"), "0") != 0)
+				{
+					Vector3 nodveh1pos = Get_Vector3_Parameter("NodVeh1Pos");
+					float nodveh1fac = Get_Float_Parameter("NodVeh1Facing");
+					GameObject *nodveh1 = Commands->Create_Object(Get_Parameter("NodVeh1"),nodveh1pos);
+					Commands->Set_Facing(nodveh1,nodveh1fac);
+					nodveh1id = Commands->Get_ID(nodveh1);
+					Attach_Script_Once(nodveh1,"tcw_domination_vehicle","0");
+				}
+			}
+			if (!Commands->Find_Object(nodveh2id))
+			{
+				if (strcmp(Get_Parameter("NodVeh2"), "0") != 0)
+				{
+					Vector3 nodveh2pos = Get_Vector3_Parameter("NodVeh2Pos");
+					float nodveh2fac = Get_Float_Parameter("NodVeh2Facing");
+					GameObject *nodveh2 = Commands->Create_Object(Get_Parameter("NodVeh2"),nodveh2pos);
+					Commands->Set_Facing(nodveh2,nodveh2fac);
+					nodveh2id = Commands->Get_ID(nodveh2);
+					Attach_Script_Once(nodveh2,"tcw_domination_vehicle","0");
+				}
+			}
+			if (!Commands->Find_Object(nodveh3id))
+			{
+				if (strcmp(Get_Parameter("NodVeh3"), "0") != 0)
+				{
+					Vector3 nodveh3pos = Get_Vector3_Parameter("NodVeh3Pos");
+					float nodveh3fac = Get_Float_Parameter("NodVeh3Facing");
+					GameObject *nodveh3 = Commands->Create_Object(Get_Parameter("NodVeh3"),nodveh3pos);
+					Commands->Set_Facing(nodveh3,nodveh3fac);
+					nodveh3id = Commands->Get_ID(nodveh3);
+					Attach_Script_Once(nodveh3,"tcw_domination_vehicle","0");
+				}
+			}
+			if (!Commands->Find_Object(nodveh4id))
+			{
+				if (strcmp(Get_Parameter("NodVeh4"), "0") != 0)
+				{
+					Vector3 nodveh4pos = Get_Vector3_Parameter("NodVeh4Pos");
+					float nodveh4fac = Get_Float_Parameter("NodVeh4Facing");
+					GameObject *nodveh4 = Commands->Create_Object(Get_Parameter("NodVeh4"),nodveh4pos);
+					Commands->Set_Facing(nodveh4,nodveh4fac);
+					nodveh4id = Commands->Get_ID(nodveh4);
+					Attach_Script_Once(nodveh4,"tcw_domination_vehicle","0");
+				}
+			}
+			if (!Commands->Find_Object(nodveh5id))
+			{
+				if (strcmp(Get_Parameter("NodVeh5"), "0") != 0)
+				{
+					Vector3 nodveh5pos = Get_Vector3_Parameter("NodVeh5Pos");
+					float nodveh5fac = Get_Float_Parameter("NodVeh5Facing");
+					GameObject *nodveh5 = Commands->Create_Object(Get_Parameter("NodVeh5"),nodveh5pos);
+					Commands->Set_Facing(nodveh5,nodveh5fac);
+					nodveh5id = Commands->Get_ID(nodveh5);
+					Attach_Script_Once(nodveh5,"tcw_domination_vehicle","0");
+				}
+			}
+		}
+		Commands->Start_Timer(obj,this,60.0f,200200);//recheck spawns
+	}
+	else if (number == 200201)
+	{
+		if (owner == 1)
+		{
+			if (!Commands->Find_Object(gdiveh1id))
+			{
+				if (strcmp(Get_Parameter("GDIVeh1"), "0") != 0)
+				{
+					Vector3 gdiveh1pos = Get_Vector3_Parameter("GDIVeh1Pos");
+					float gdiveh1fac = Get_Float_Parameter("GDIVeh1Facing");
+					GameObject *gdiveh1 = Commands->Create_Object(Get_Parameter("GDIVeh1"),gdiveh1pos);
+					Commands->Set_Facing(gdiveh1,gdiveh1fac);
+					gdiveh1id = Commands->Get_ID(gdiveh1);
+					Attach_Script_Once(gdiveh1,"tcw_domination_vehicle","1");
+				}
+			}
+			if (!Commands->Find_Object(gdiveh2id))
+			{
+				if (strcmp(Get_Parameter("GDIVeh2"), "0") != 0)
+				{
+					Vector3 gdiveh2pos = Get_Vector3_Parameter("GDIVeh2Pos");
+					float gdiveh2fac = Get_Float_Parameter("GDIVeh2Facing");
+					GameObject *gdiveh2 = Commands->Create_Object(Get_Parameter("GDIVeh2"),gdiveh2pos);
+					Commands->Set_Facing(gdiveh2,gdiveh2fac);
+					gdiveh2id = Commands->Get_ID(gdiveh2);
+					Attach_Script_Once(gdiveh2,"tcw_domination_vehicle","1");
+				}
+			}
+			if (!Commands->Find_Object(gdiveh3id))
+			{
+				if (strcmp(Get_Parameter("GDIVeh3"), "0") != 0)
+				{
+					Vector3 gdiveh3pos = Get_Vector3_Parameter("GDIVeh3Pos");
+					float gdiveh3fac = Get_Float_Parameter("GDIVeh3Facing");
+					GameObject *gdiveh3 = Commands->Create_Object(Get_Parameter("GDIVeh3"),gdiveh3pos);
+					Commands->Set_Facing(gdiveh3,gdiveh3fac);
+					gdiveh3id = Commands->Get_ID(gdiveh3);
+					Attach_Script_Once(gdiveh3,"tcw_domination_vehicle","1");
+				}
+			}
+			if (!Commands->Find_Object(gdiveh4id))
+			{
+				if (strcmp(Get_Parameter("GDIVeh4"), "0") != 0)
+				{
+					Vector3 gdiveh4pos = Get_Vector3_Parameter("GDIVeh4Pos");
+					float gdiveh4fac = Get_Float_Parameter("GDIVeh4Facing");
+					GameObject *gdiveh4 = Commands->Create_Object(Get_Parameter("GDIVeh4"),gdiveh4pos);
+					Commands->Set_Facing(gdiveh4,gdiveh4fac);
+					gdiveh4id = Commands->Get_ID(gdiveh4);
+					Attach_Script_Once(gdiveh4,"tcw_domination_vehicle","1");
+				}
+			}
+			if (!Commands->Find_Object(gdiveh5id))
+			{
+				if (strcmp(Get_Parameter("GDIVeh5"), "0") != 0)
+				{
+					Vector3 gdiveh5pos = Get_Vector3_Parameter("GDIVeh5Pos");
+					float gdiveh5fac = Get_Float_Parameter("GDIVeh5Facing");
+					GameObject *gdiveh5 = Commands->Create_Object(Get_Parameter("GDIVeh5"),gdiveh5pos);
+					Commands->Set_Facing(gdiveh5,gdiveh5fac);
+					gdiveh5id = Commands->Get_ID(gdiveh5);
+					Attach_Script_Once(gdiveh5,"tcw_domination_vehicle","1");
+				}
 			}
 		}
+		Commands->Start_Timer(obj,this,60.0f,200201);//recheck spawns
 	}
 }
 void tcw_domination_node::Register_Auto_Save_Variables()
@@ -401,6 +597,10 @@
 	Auto_Save_Variable(&gdiveh3id,sizeof(gdiveh3id),10);
 	Auto_Save_Variable(&gdiveh4id,sizeof(gdiveh4id),11);
 	Auto_Save_Variable(&gdiveh5id,sizeof(gdiveh5id),12);
+	Auto_Save_Variable(&spawnpad1,sizeof(spawnpad1),13);
+	Auto_Save_Variable(&spawnpad2,sizeof(spawnpad2),14);
+	Auto_Save_Variable(&spawnpad3,sizeof(spawnpad3),15);
+	Auto_Save_Variable(&spawnpad4,sizeof(spawnpad4),16);
 }
 
 void tcw_domination_vehicle::Custom(GameObject *obj, int message, int param, GameObject *sender)
@@ -472,27 +672,27 @@
 					if (!Find_Object_With_Script("tcw_wmd_strike"))//if there is no existing strike
 					{
 						//gdi buildings attacks:
-						if ( (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_SOLDIER_FACTORY))) && (Find_Building(1,BuildingConstants::TYPE_SOLDIER_FACTORY)) )//if bar is alive, target it....
+						if ( (!Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_SOLDIER_FACTORY))) && (Find_Building_By_Type(1,BuildingConstants::TYPE_SOLDIER_FACTORY)) )//if bar is alive, target it....
 						{
-							Vector3 ionarrowpos = Commands->Get_Position(Find_Building(1,BuildingConstants::TYPE_SOLDIER_FACTORY));
+							Vector3 ionarrowpos = Commands->Get_Position(Find_Building_By_Type(1,BuildingConstants::TYPE_SOLDIER_FACTORY));
 							GameObject *ionarrow = Commands->Create_Object("Invisible_Object",ionarrowpos);
 							Attach_Script_Once(ionarrow,"tcw_wmd_strike","4");//pass 4 for bar
 						}
-						else if ( (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_VEHICLE_FACTORY))) && (Find_Building(1,BuildingConstants::TYPE_VEHICLE_FACTORY)) )//if gwf is alive, target it....
+						else if ( (!Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_VEHICLE_FACTORY))) && (Find_Building_By_Type(1,BuildingConstants::TYPE_VEHICLE_FACTORY)) )//if gwf is alive, target it....
 						{
-							Vector3 ionarrowpos = Commands->Get_Position(Find_Building(1,BuildingConstants::TYPE_VEHICLE_FACTORY));
+							Vector3 ionarrowpos = Commands->Get_Position(Find_Building_By_Type(1,BuildingConstants::TYPE_VEHICLE_FACTORY));
 							GameObject *ionarrow = Commands->Create_Object("Invisible_Object",ionarrowpos);
 							Attach_Script_Once(ionarrow,"tcw_wmd_strike","5");//pass 5 for gwf
 						}
-						else if ( (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_REFINERY))) && (Find_Building(1,BuildingConstants::TYPE_REFINERY)) )//if grf is alive, target it....
+						else if ( (!Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_REFINERY))) && (Find_Building_By_Type(1,BuildingConstants::TYPE_REFINERY)) )//if grf is alive, target it....
 						{
-							Vector3 ionarrowpos = Commands->Get_Position(Find_Building(1,BuildingConstants::TYPE_REFINERY));
+							Vector3 ionarrowpos = Commands->Get_Position(Find_Building_By_Type(1,BuildingConstants::TYPE_REFINERY));
 							GameObject *ionarrow = Commands->Create_Object("Invisible_Object",ionarrowpos);
 							Attach_Script_Once(ionarrow,"tcw_wmd_strike","6");//pass 6 for grf
 						}
-						else if ( (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_POWER_PLANT))) && (Find_Building(1,BuildingConstants::TYPE_POWER_PLANT)) )//if gpp is alive, target it....
+						else if ( (!Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_POWER_PLANT))) && (Find_Building_By_Type(1,BuildingConstants::TYPE_POWER_PLANT)) )//if gpp is alive, target it....
 						{
-							Vector3 ionarrowpos = Commands->Get_Position(Find_Building(1,BuildingConstants::TYPE_POWER_PLANT));
+							Vector3 ionarrowpos = Commands->Get_Position(Find_Building_By_Type(1,BuildingConstants::TYPE_POWER_PLANT));
 							GameObject *ionarrow = Commands->Create_Object("Invisible_Object",ionarrowpos);
 							Attach_Script_Once(ionarrow,"tcw_wmd_strike","7");//pass 7 for gpp
 						}
@@ -568,27 +768,27 @@
 					if (!Find_Object_With_Script("tcw_wmd_strike"))//if there is no existing strike
 					{
 						//nod buildings attacks:
-						if ( (!Is_Building_Dead(Find_Building(0,BuildingConstants::TYPE_SOLDIER_FACTORY))) && (Find_Building(0,BuildingConstants::TYPE_SOLDIER_FACTORY)) )//if hand is alive, target it....
+						if ( (!Is_Building_Dead(Find_Building_By_Type(0,BuildingConstants::TYPE_SOLDIER_FACTORY))) && (Find_Building_By_Type(0,BuildingConstants::TYPE_SOLDIER_FACTORY)) )//if hand is alive, target it....
 						{
-							Vector3 ionarrowpos = Commands->Get_Position(Find_Building(0,BuildingConstants::TYPE_SOLDIER_FACTORY));
+							Vector3 ionarrowpos = Commands->Get_Position(Find_Building_By_Type(0,BuildingConstants::TYPE_SOLDIER_FACTORY));
 							GameObject *ionarrow = Commands->Create_Object("Invisible_Object",ionarrowpos);
 							Attach_Script_Once(ionarrow,"tcw_wmd_strike","0");//pass 0 for hand
 						}
-						else if ( (!Is_Building_Dead(Find_Building(0,BuildingConstants::TYPE_VEHICLE_FACTORY))) && (Find_Building(0,BuildingConstants::TYPE_VEHICLE_FACTORY)) )//if nwf is alive, target it....
+						else if ( (!Is_Building_Dead(Find_Building_By_Type(0,BuildingConstants::TYPE_VEHICLE_FACTORY))) && (Find_Building_By_Type(0,BuildingConstants::TYPE_VEHICLE_FACTORY)) )//if nwf is alive, target it....
 						{
-							Vector3 ionarrowpos = Commands->Get_Position(Find_Building(0,BuildingConstants::TYPE_VEHICLE_FACTORY));
+							Vector3 ionarrowpos = Commands->Get_Position(Find_Building_By_Type(0,BuildingConstants::TYPE_VEHICLE_FACTORY));
 							GameObject *ionarrow = Commands->Create_Object("Invisible_Object",ionarrowpos);
 							Attach_Script_Once(ionarrow,"tcw_wmd_strike","1");//pass 1 for nwf
 						}
-						else if ( (!Is_Building_Dead(Find_Building(0,BuildingConstants::TYPE_REFINERY))) && (Find_Building(0,BuildingConstants::TYPE_REFINERY)) )//if nrf is alive, target it....
+						else if ( (!Is_Building_Dead(Find_Building_By_Type(0,BuildingConstants::TYPE_REFINERY))) && (Find_Building_By_Type(0,BuildingConstants::TYPE_REFINERY)) )//if nrf is alive, target it....
 						{
-							Vector3 ionarrowpos = Commands->Get_Position(Find_Building(0,BuildingConstants::TYPE_REFINERY));
+							Vector3 ionarrowpos = Commands->Get_Position(Find_Building_By_Type(0,BuildingConstants::TYPE_REFINERY));
 							GameObject *ionarrow = Commands->Create_Object("Invisible_Object",ionarrowpos);
 							Attach_Script_Once(ionarrow,"tcw_wmd_strike","2");//pass 2 for nrf
 						}
-						else if ( (!Is_Building_Dead(Find_Building(0,BuildingConstants::TYPE_POWER_PLANT))) && (Find_Building(0,BuildingConstants::TYPE_POWER_PLANT)) )//if npp is alive, target it....
+						else if ( (!Is_Building_Dead(Find_Building_By_Type(0,BuildingConstants::TYPE_POWER_PLANT))) && (Find_Building_By_Type(0,BuildingConstants::TYPE_POWER_PLANT)) )//if npp is alive, target it....
 						{
-							Vector3 ionarrowpos = Commands->Get_Position(Find_Building(0,BuildingConstants::TYPE_POWER_PLANT));
+							Vector3 ionarrowpos = Commands->Get_Position(Find_Building_By_Type(0,BuildingConstants::TYPE_POWER_PLANT));
 							GameObject *ionarrow = Commands->Create_Object("Invisible_Object",ionarrowpos);
 							Attach_Script_Once(ionarrow,"tcw_wmd_strike","3");//pass 3 for npp
 						}
@@ -818,14 +1018,14 @@
 	{
 		Commands->Send_Custom_Event(obj,Find_Object_With_Script("tcw_wmd_countdown_node"),1111,1,0);//reset the capture point
 		Commands->Start_Timer(obj,this,10.5f,201);//initate after party
-		Vector3 nukepos; Commands->Get_Position(Find_Building(0,BuildingConstants::TYPE_SOLDIER_FACTORY));
+		Vector3 nukepos; Commands->Get_Position(Find_Building_By_Type(0,BuildingConstants::TYPE_SOLDIER_FACTORY));
 		GameObject *nuke = Commands->Create_Object("Pre Ion Strike",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 	}
 	else if (number == 201)//kill hand and play afterparty
 	{
-		Commands->Apply_Damage(Find_Building(0,BuildingConstants::TYPE_SOLDIER_FACTORY),99999.0f,"Steel",obj);//kill the hand
-		Vector3 nukepos; Commands->Get_Position(Find_Building(0,BuildingConstants::TYPE_SOLDIER_FACTORY));
+		Commands->Apply_Damage(Find_Building_By_Type(0,BuildingConstants::TYPE_SOLDIER_FACTORY),99999.0f,"Steel",obj);//kill the hand
+		Vector3 nukepos; Commands->Get_Position(Find_Building_By_Type(0,BuildingConstants::TYPE_SOLDIER_FACTORY));
 		GameObject *nuke = Commands->Create_Object("Post Ion Strike",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 		Destroy_Script();
@@ -835,14 +1035,14 @@
 	{
 		Commands->Send_Custom_Event(obj,Find_Object_With_Script("tcw_wmd_countdown_node"),1111,1,0);//reset the capture point
 		Commands->Start_Timer(obj,this,10.5f,211);//initate after party
-		Vector3 nukepos = Commands->Get_Position(Find_Building(0,BuildingConstants::TYPE_VEHICLE_FACTORY));
+		Vector3 nukepos = Commands->Get_Position(Find_Building_By_Type(0,BuildingConstants::TYPE_VEHICLE_FACTORY));
 		GameObject *nuke = Commands->Create_Object("Pre Ion Strike",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 	}
 	else if (number == 211)//kill hand and play afterparty
 	{
-		Commands->Apply_Damage(Find_Building(0,BuildingConstants::TYPE_VEHICLE_FACTORY),999999.0f,"Steel",obj);//kill the hand
-		Vector3 nukepos = Commands->Get_Position(Find_Building(0,BuildingConstants::TYPE_VEHICLE_FACTORY));
+		Commands->Apply_Damage(Find_Building_By_Type(0,BuildingConstants::TYPE_VEHICLE_FACTORY),999999.0f,"Steel",obj);//kill the hand
+		Vector3 nukepos = Commands->Get_Position(Find_Building_By_Type(0,BuildingConstants::TYPE_VEHICLE_FACTORY));
 		GameObject *nuke = Commands->Create_Object("Post Ion Strike",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 		Destroy_Script();
@@ -852,14 +1052,14 @@
 	{
 		Commands->Send_Custom_Event(obj,Find_Object_With_Script("tcw_wmd_countdown_node"),1111,1,0);//reset the capture point
 		Commands->Start_Timer(obj,this,10.5f,221);//initate after party
-		Vector3 nukepos = Commands->Get_Position(Find_Building(0,BuildingConstants::TYPE_REFINERY));
+		Vector3 nukepos = Commands->Get_Position(Find_Building_By_Type(0,BuildingConstants::TYPE_REFINERY));
 		GameObject *nuke = Commands->Create_Object("Pre Ion Strike",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 	}
 	else if (number == 221)//kill nrf and play afterparty
 	{
-		Commands->Apply_Damage(Find_Building(0,BuildingConstants::TYPE_REFINERY),999999.0f,"Steel",obj);//kill the nrf
-		Vector3 nukepos = Commands->Get_Position(Find_Building(0,BuildingConstants::TYPE_REFINERY));
+		Commands->Apply_Damage(Find_Building_By_Type(0,BuildingConstants::TYPE_REFINERY),999999.0f,"Steel",obj);//kill the nrf
+		Vector3 nukepos = Commands->Get_Position(Find_Building_By_Type(0,BuildingConstants::TYPE_REFINERY));
 		GameObject *nuke = Commands->Create_Object("Post Ion Strike",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 		Destroy_Script();
@@ -869,14 +1069,14 @@
 	{
 		Commands->Send_Custom_Event(obj,Find_Object_With_Script("tcw_wmd_countdown_node"),1111,1,0);//reset the capture point
 		Commands->Start_Timer(obj,this,10.5f,231);//initate after party
-		Vector3 nukepos = Commands->Get_Position(Find_Building(0,BuildingConstants::TYPE_POWER_PLANT));
+		Vector3 nukepos = Commands->Get_Position(Find_Building_By_Type(0,BuildingConstants::TYPE_POWER_PLANT));
 		GameObject *nuke = Commands->Create_Object("Pre Ion Strike",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 	}
 	else if (number == 231)//kill npp and play afterparty
 	{
-		Commands->Apply_Damage(Find_Building(0,BuildingConstants::TYPE_POWER_PLANT),99999.0f,"Steel",obj);//kill the npp
-		Vector3 nukepos = Commands->Get_Position(Find_Building(0,BuildingConstants::TYPE_POWER_PLANT));
+		Commands->Apply_Damage(Find_Building_By_Type(0,BuildingConstants::TYPE_POWER_PLANT),99999.0f,"Steel",obj);//kill the npp
+		Vector3 nukepos = Commands->Get_Position(Find_Building_By_Type(0,BuildingConstants::TYPE_POWER_PLANT));
 		GameObject *nuke = Commands->Create_Object("Post Ion Strike",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 		Destroy_Script();
@@ -887,14 +1087,14 @@
 	{
 		Commands->Send_Custom_Event(obj,Find_Object_With_Script("tcw_wmd_countdown_node"),1111,1,0);//reset the capture point
 		Commands->Start_Timer(obj,this,10.5f,241);//initate after party
-		Vector3 nukepos; Commands->Get_Position(Find_Building(1,BuildingConstants::TYPE_SOLDIER_FACTORY));
+		Vector3 nukepos; Commands->Get_Position(Find_Building_By_Type(1,BuildingConstants::TYPE_SOLDIER_FACTORY));
 		GameObject *nuke = Commands->Create_Object("Nuke_Strike_Pre",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 	}
 	else if (number == 241)//kill bar and play afterparty
 	{
-		Commands->Apply_Damage(Find_Building(1,BuildingConstants::TYPE_SOLDIER_FACTORY),99999.0f,"Steel",obj);//kill the bar
-		Vector3 nukepos; Commands->Get_Position(Find_Building(1,BuildingConstants::TYPE_SOLDIER_FACTORY));
+		Commands->Apply_Damage(Find_Building_By_Type(1,BuildingConstants::TYPE_SOLDIER_FACTORY),99999.0f,"Steel",obj);//kill the bar
+		Vector3 nukepos; Commands->Get_Position(Find_Building_By_Type(1,BuildingConstants::TYPE_SOLDIER_FACTORY));
 		GameObject *nuke = Commands->Create_Object("Nuke_Strike_Post",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 		Commands->Start_Timer(obj,this,5.0f,300);
@@ -904,14 +1104,14 @@
 	{
 		Commands->Send_Custom_Event(obj,Find_Object_With_Script("tcw_wmd_countdown_node"),1111,1,0);//reset the capture point
 		Commands->Start_Timer(obj,this,10.5f,251);//initate after party
-		Vector3 nukepos = Commands->Get_Position(Find_Building(1,BuildingConstants::TYPE_VEHICLE_FACTORY));
+		Vector3 nukepos = Commands->Get_Position(Find_Building_By_Type(1,BuildingConstants::TYPE_VEHICLE_FACTORY));
 		GameObject *nuke = Commands->Create_Object("Nuke_Strike_Pre",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 	}
 	else if (number == 251)//kill hand and play afterparty
 	{
-		Commands->Apply_Damage(Find_Building(1,BuildingConstants::TYPE_VEHICLE_FACTORY),999999.0f,"Steel",obj);//kill the wf
-		Vector3 nukepos = Commands->Get_Position(Find_Building(1,BuildingConstants::TYPE_VEHICLE_FACTORY));
+		Commands->Apply_Damage(Find_Building_By_Type(1,BuildingConstants::TYPE_VEHICLE_FACTORY),999999.0f,"Steel",obj);//kill the wf
+		Vector3 nukepos = Commands->Get_Position(Find_Building_By_Type(1,BuildingConstants::TYPE_VEHICLE_FACTORY));
 		GameObject *nuke = Commands->Create_Object("Nuke_Strike_Post",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 		Commands->Start_Timer(obj,this,5.0f,300);
@@ -921,14 +1121,14 @@
 	{
 		Commands->Send_Custom_Event(obj,Find_Object_With_Script("tcw_wmd_countdown_node"),1111,1,0);//reset the capture point
 		Commands->Start_Timer(obj,this,10.5f,261);//initate after party
-		Vector3 nukepos = Commands->Get_Position(Find_Building(1,BuildingConstants::TYPE_REFINERY));
+		Vector3 nukepos = Commands->Get_Position(Find_Building_By_Type(1,BuildingConstants::TYPE_REFINERY));
 		GameObject *nuke = Commands->Create_Object("Nuke_Strike_Pre",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 	}
 	else if (number == 261)//kill gref and play afterparty
 	{
-		Commands->Apply_Damage(Find_Building(1,BuildingConstants::TYPE_REFINERY),999999.0f,"Steel",obj);//kill the gref
-		Vector3 nukepos = Commands->Get_Position(Find_Building(1,BuildingConstants::TYPE_REFINERY));
+		Commands->Apply_Damage(Find_Building_By_Type(1,BuildingConstants::TYPE_REFINERY),999999.0f,"Steel",obj);//kill the gref
+		Vector3 nukepos = Commands->Get_Position(Find_Building_By_Type(1,BuildingConstants::TYPE_REFINERY));
 		GameObject *nuke = Commands->Create_Object("Nuke_Strike_Post",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 		Commands->Start_Timer(obj,this,5.0f,300);
@@ -938,14 +1138,14 @@
 	{
 		Commands->Send_Custom_Event(obj,Find_Object_With_Script("tcw_wmd_countdown_node"),1111,1,0);//reset the capture point
 		Commands->Start_Timer(obj,this,10.5f,271);//initate after party
-		Vector3 nukepos = Commands->Get_Position(Find_Building(1,BuildingConstants::TYPE_POWER_PLANT));
+		Vector3 nukepos = Commands->Get_Position(Find_Building_By_Type(1,BuildingConstants::TYPE_POWER_PLANT));
 		GameObject *nuke = Commands->Create_Object("Nuke_Strike_Pre",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 	}
 	else if (number == 271)//kill gpp and play afterparty
 	{
-		Commands->Apply_Damage(Find_Building(1,BuildingConstants::TYPE_POWER_PLANT),99999.0f,"Steel",obj);//kill the gpp
-		Vector3 nukepos = Commands->Get_Position(Find_Building(1,BuildingConstants::TYPE_POWER_PLANT));
+		Commands->Apply_Damage(Find_Building_By_Type(1,BuildingConstants::TYPE_POWER_PLANT),99999.0f,"Steel",obj);//kill the gpp
+		Vector3 nukepos = Commands->Get_Position(Find_Building_By_Type(1,BuildingConstants::TYPE_POWER_PLANT));
 		GameObject *nuke = Commands->Create_Object("Nuke_Strike_Post",nukepos);
 		Commands->Set_Facing(nuke,0.0f);
 		Commands->Start_Timer(obj,this,5.0f,300);
@@ -962,6 +1162,6 @@
 ScriptRegistrant<tcw_wmd_strike> tcw_wmd_strike_Registrant("tcw_wmd_strike","StrikeAgainst=0:int");
 ScriptRegistrant<tcw_wmd_countdown_node> tcw_wmd_countdown_node_Registrant("tcw_wmd_countdown_node","Node_Name=North:string,NodVeh1=bla:string,NodVeh1Pos=0:vector3,NodVeh1Facing=0:float,NodVeh2=bla:string,NodVeh2Pos=0:vector3,NodVeh2Facing=0:float,NodVeh3=bla:string,NodVeh3Pos=0:vector3,NodVeh3Facing=0:float,NodVeh4=bla:string,NodVeh4Pos=0:vector3,NodVeh4Facing=0:float,NodVeh5=bla:string,NodVeh5Pos=0:vector3,NodVeh5Facing=0:float,GDIVeh1=bla:string,GDIVeh1Pos=0:vector3,GDIVeh1Facing=0:float,GDIVeh2=bla:string,GDIVeh2Pos=0:vector3,GDIVeh2Facing=0:float,GDIVeh3=bla:string,GDIVeh3Pos=0:vector3,GDIVeh3Facing=0:float,GDIVeh4=bla:string,GDIVeh4Pos=0:vector3,GDIVeh4Facing=0:float,GDIVeh5=bla:string,GDIVeh5Pos=0:vector3,GDIVeh5Facing=0:float");
 ScriptRegistrant<tcw_domination_vehicle> tcw_domination_vehicle_Registrant("tcw_domination_vehicle","Team=0:int");
-ScriptRegistrant<tcw_domination_node> tcw_domination_node_Registrant("tcw_domination_node","Node_Name=North:string,NodVeh1=bla:string,NodVeh1Pos=0:vector3,NodVeh1Facing=0:float,NodVeh2=bla:string,NodVeh2Pos=0:vector3,NodVeh2Facing=0:float,NodVeh3=bla:string,NodVeh3Pos=0:vector3,NodVeh3Facing=0:float,NodVeh4=bla:string,NodVeh4Pos=0:vector3,NodVeh4Facing=0:float,NodVeh5=bla:string,NodVeh5Pos=0:vector3,NodVeh5Facing=0:float,GDIVeh1=bla:string,GDIVeh1Pos=0:vector3,GDIVeh1Facing=0:float,GDIVeh2=bla:string,GDIVeh2Pos=0:vector3,GDIVeh2Facing=0:float,GDIVeh3=bla:string,GDIVeh3Pos=0:vector3,GDIVeh3Facing=0:float,GDIVeh4=bla:string,GDIVeh4Pos=0:vector3,GDIVeh4Facing=0:float,GDIVeh5=bla:string,GDIVeh5Pos=0:vector3,GDIVeh5Facing=0:float");
+ScriptRegistrant<tcw_domination_node> tcw_domination_node_Registrant("tcw_domination_node","Node_Name=North:string,NodVeh1=bla:string,NodVeh1Pos=0:vector3,NodVeh1Facing=0:float,NodVeh2=bla:string,NodVeh2Pos=0:vector3,NodVeh2Facing=0:float,NodVeh3=bla:string,NodVeh3Pos=0:vector3,NodVeh3Facing=0:float,NodVeh4=bla:string,NodVeh4Pos=0:vector3,NodVeh4Facing=0:float,NodVeh5=bla:string,NodVeh5Pos=0:vector3,NodVeh5Facing=0:float,GDIVeh1=bla:string,GDIVeh1Pos=0:vector3,GDIVeh1Facing=0:float,GDIVeh2=bla:string,GDIVeh2Pos=0:vector3,GDIVeh2Facing=0:float,GDIVeh3=bla:string,GDIVeh3Pos=0:vector3,GDIVeh3Facing=0:float,GDIVeh4=bla:string,GDIVeh4Pos=0:vector3,GDIVeh4Facing=0:float,GDIVeh5=bla:string,GDIVeh5Pos=0:vector3,GDIVeh5Facing=0:float,SpawnPad1ID=0:int,SpawnPad2ID=0:int,SpawnPad3ID=0:int,SpawnPad4ID=0:int");
 ScriptRegistrant<tcw_domination_pointgen> tcw_domination_pointgen_Registrant("tcw_domination_pointgen","Team=0:int");
 ScriptRegistrant<tcw_domination_control> tcw_domination_control_Registrant("tcw_domination_control","Points_Max=10:int");
\ No newline at end of file
diff -uwr sourceold/scripts/tcw_domination.h source/scripts/tcw_domination.h
--- sourceold/scripts/tcw_domination.h	2012-02-02 09:44:43.185546800 +0800
+++ source/scripts/tcw_domination.h	2012-06-09 08:11:12.196289000 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -35,10 +35,13 @@
 class tcw_domination_node : public ScriptImpClass {
 	void Created(GameObject *obj);
 	void Damaged(GameObject *obj, GameObject *damager, float damage);
+	void Timer_Expired(GameObject *obj, int number);
 	public: void Register_Auto_Save_Variables();
 	int owner;
+	bool trigger_neutral_damage;
 	int nodveh1id; int nodveh2id; int nodveh3id; int nodveh4id; int nodveh5id;
 	int gdiveh1id; int gdiveh2id; int gdiveh3id; int gdiveh4id; int gdiveh5id; 
+	int spawnpad1;	int spawnpad2;	int spawnpad3;	int spawnpad4;
 	const char *nodename;
 }; 
 
Only in source/scripts: tcw_frost.cpp
Only in source/scripts: tcw_frost.h
Only in source/scripts: tcw_functions.cpp
Only in source/scripts: tcw_functions.h
diff -uwr sourceold/scripts/tcw_game.cpp source/scripts/tcw_game.cpp
--- sourceold/scripts/tcw_game.cpp	2012-02-08 00:15:43.935546800 +0800
+++ source/scripts/tcw_game.cpp	2012-06-09 08:11:12.311523400 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -11,396 +11,16 @@
 	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 "General.h"
 #include "scripts.h"
-#include "engine.h"
-#include "BuildingGameObj.h"
 #include "tcw_game.h"
-#include "GameObjManager.h"
-#include "SoldierGameObj.h"
+#include "tcw_general.h"
+#include "tcw_functions.h"
 #include "VehicleGameObj.h"
-
-void tcw_Tiberium_Harvester::Created(GameObject *obj)
-{
-	team = 0;
-	driver = 0;
-	cash = 0;
-	ID = 0;
-	if ( (strcmp(Commands->Get_Preset_Name(obj),"TCW_Nod_Harvester") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"TCW_Nod_Harvester_Player") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"TCW_GDI_Nod_Harvester_Player") == 0) ) 
-	{
-		VehicleGameObj* harvester = obj->As_VehicleGameObj();
-		if (!harvester) return;
-		harvester->Set_Allow_Stealth_While_Empty(true);
-	}
-}
-void tcw_Tiberium_Harvester::Custom(GameObject *obj,int type,int param,GameObject *sender)
-{
-	int Collected_Message = Get_Int_Parameter("Collected_Message");
-	int Refinery_Message = Get_Int_Parameter("Refinery_Message");
-	int Cash_Limit = Get_Int_Parameter("Cash_Limit");
-	int Cash_Type = Get_Int_Parameter("Cash_Type");
-	int Entire_Team = Get_Int_Parameter("Entire_Team");
-	if (type == CUSTOM_EVENT_VEHICLE_ENTERED)
-	{
-		team = Commands->Get_Player_Type(sender);
-		driver = Commands->Get_ID(sender);
-		int OldID;
-		OldID = ID;
-		ID = Commands->Get_ID(sender);
-		if (!Cash_Type)
-		{
-			cash = 0;
-		}
-		if ((Cash_Type == 1) && (ID != OldID))
-		{
-			cash = 0;
-		}
-		if (team == 0)
-		{
-			Send_Message_Player(Commands->Find_Object(driver),255,0,0,"Drive to the Tiberium Field to harvest Tiberium.");
-			Create_2D_WAV_Sound_Player(Commands->Find_Object(driver),"incmsg.wav");
-		}
-		else if (team == 1)
-		{
-			Send_Message_Player(Commands->Find_Object(driver),255,204,0,"Drive to the Tiberium Field to harvest Tiberium.");
-			Create_2D_WAV_Sound_Player(Commands->Find_Object(driver),"incmsg.wav");
-		}
-	}
-	if (type == CUSTOM_EVENT_VEHICLE_EXITED)
-	{
-		driver = 0;
-	}
-	if (type == Collected_Message)
-	{
-		if (Cash_Type == 3)
-		{
-			cash = 0;
-		}
-		cash += param;
-		if ((cash > Cash_Limit) && (Cash_Limit))
-		{
-			cash = Cash_Limit;
-		}
-		if (team == 0)
-		{
-			Send_Message_Player(Commands->Find_Object(driver),255,0,0,"Tiberium harvesting has completed, return to the Refinery.");
-			Create_2D_WAV_Sound_Player(Commands->Find_Object(driver),"incmsg.wav");
-		}
-		else if (team == 1)
-		{
-			Send_Message_Player(Commands->Find_Object(driver),255,204,0,"Tiberium harvesting has completed, return to the Refinery.");
-			Create_2D_WAV_Sound_Player(Commands->Find_Object(driver),"incmsg.wav");
-		}
-	}
-	if (type == Refinery_Message)
-	{
-		if (cash > 0)
-		{
-			int team = Commands->Get_Player_Type(obj);
-			if (!Is_Building_Dead(Find_Building(team,BuildingConstants::TYPE_REFINERY)))
-			{
-				Commands->Give_Money(Commands->Find_Object(ID),(float)cash,Entire_Team);
-				Commands->Give_Points(Commands->Find_Object(ID),50.0f,0);//50 points for the effort ;)
-				if (team == 0)
-				{
-					char dumpmsg[250];
-					sprintf(dumpmsg,"%s deposited Tiberium funding Nod with %g additional credits.",Get_Player_Name(Commands->Find_Object(driver)),cash);
-					Send_Message_Team(0,255,0,0,dumpmsg);
-					Create_2D_WAV_Sound_Team("creditsacquired.wav",0);
-				}
-				else if (team == 1)
-				{
-					char dumpmsg[250];
-					sprintf(dumpmsg,"%s deposited Tiberium funding GDI with %g additional credits.",Get_Player_Name(Commands->Find_Object(driver)),cash);
-					Send_Message_Team(1,255,204,0,dumpmsg);
-					Create_2D_WAV_Sound_Team("creditsacquired.wav",1);
-				}
-			}
-		}
-
-		cash = 0;
-	}
-}
-void tcw_Tiberium_Harvester::Register_Auto_Save_Variables()
-{
-	Auto_Save_Variable(&cash,sizeof(cash),1);
-	Auto_Save_Variable(&ID,sizeof(ID),2);
-	Auto_Save_Variable(&driver,sizeof(driver),3);
-	Auto_Save_Variable(&team,sizeof(team),4);
-}
-
-
-void tcw_tiberium_spike::Created(GameObject *obj)
-{
-	firstcapture = true;
-	Commands->Set_Health(obj,1.0f);
-	//Commands->Set_Animation(obj,"V_NEU_SPIKE.V_NEU_SPIKE",true,0,1,-1,0); //unteamed spikes dont animate
-}
-void tcw_tiberium_spike::Damaged(GameObject *obj, GameObject *damager, float damage)
-{
-	if (damage > 0.0f)
-	{
-		if (damage > Commands->Get_Health(obj))//destroyed
-		{
-			Commands->Set_Health(obj,1.0f);
-			Remove_Script(obj,"tcw_Credit_Trickle");
-			Commands->Set_Player_Type(obj,-2);//unteam it again
-			Commands->Set_Animation(obj,"V_NEU_SPIKE.V_NEU_SPIKE",true,0,1,1,0); //stop animate when uncaptured
-		}
-	}
-}
-void tcw_tiberium_spike::Custom(GameObject *obj, int message, int param, GameObject *sender)
-{
-	if (message == 1000)
-	{
-		if (param == 0)
-		{
-			Commands->Set_Player_Type(obj,0);
-			if (firstcapture)
-			{
-				firstcapture = false;
-				Commands->Give_Money(obj,250.0f,1);
-				Attach_Script_Once(obj,"tcw_Credit_Trickle","5,1");
-				Commands->Set_Animation(obj,"V_NEU_SPIKE.V_NEU_SPIKE",true,0,1,-1,0); //start animate when captured
-				Commands->Set_Health(obj,Commands->Get_Max_Health(obj)); //captured repair it
-			}
-			else
-			{
-				Attach_Script_Once(obj,"tcw_Credit_Trickle","5,1");
-				Commands->Set_Animation(obj,"V_NEU_SPIKE.V_NEU_SPIKE",true,0,1,-1,0); //start animate when captured
-				Commands->Set_Health(obj,Commands->Get_Max_Health(obj)); //captured repair it
-			}
-		}
-		else if (param == 1)
-		{
-			Commands->Set_Player_Type(obj,1);
-			if (firstcapture)
-			{
-				firstcapture = false;
-				Commands->Give_Money(obj,250.0f,1);
-				Attach_Script_Once(obj,"tcw_Credit_Trickle","5,1");
-				Commands->Set_Animation(obj,"V_NEU_SPIKE.V_NEU_SPIKE",true,0,1,-1,0); //start animate when captured
-				Commands->Set_Health(obj,Commands->Get_Max_Health(obj)); //captured repair it
-			}
-			else
-			{
-				Attach_Script_Once(obj,"tcw_Credit_Trickle","5,1");
-				Commands->Set_Animation(obj,"V_NEU_SPIKE.V_NEU_SPIKE",true,0,1,-1,0); //start animate when captured
-				Commands->Set_Health(obj,Commands->Get_Max_Health(obj)); //captured repair it
-			}
-		}
-	}
-	else if (message == 1001)//needed for settings the spike team without granting the 'firstcapture' money
-	{
-		if (param == 0)
-		{
-			Commands->Set_Player_Type(obj,0);
-			if (firstcapture)
-			{
-				firstcapture = false;
-				Attach_Script_Once(obj,"tcw_Credit_Trickle","5,1");
-				Commands->Set_Health(obj,Commands->Get_Max_Health(obj)); //captured repair it
-				Commands->Set_Animation(obj,"V_NEU_SPIKE.V_NEU_SPIKE",true,0,1,-1,0); //start animate when captured
-			}
-			else
-			{
-				Attach_Script_Once(obj,"tcw_Credit_Trickle","5,1");
-				Commands->Set_Health(obj,Commands->Get_Max_Health(obj)); //captured repair it
-				Commands->Set_Animation(obj,"V_NEU_SPIKE.V_NEU_SPIKE",true,0,1,-1,0); //start animate when captured
-			}
-		}
-		else if (param == 1)
-		{
-			Commands->Set_Player_Type(obj,1);
-			if (firstcapture)
-			{
-				firstcapture = false;
-				Attach_Script_Once(obj,"tcw_Credit_Trickle","5,1");
-				Commands->Set_Health(obj,Commands->Get_Max_Health(obj)); //captured repair it
-				Commands->Set_Animation(obj,"V_NEU_SPIKE.V_NEU_SPIKE",true,0,1,-1,0); //start animate when captured
-			}
-			else
-			{
-				Attach_Script_Once(obj,"tcw_Credit_Trickle","5,1");
-				Commands->Set_Health(obj,Commands->Get_Max_Health(obj)); //captured repair it
-				Commands->Set_Animation(obj,"V_NEU_SPIKE.V_NEU_SPIKE",true,0,1,-1,0); //start animate when captured
-			}
-		}
-	}
-}
-void tcw_tiberium_spike::Register_Auto_Save_Variables()
-{
-	Auto_Save_Variable(&firstcapture,sizeof(firstcapture),1);
-}
-
-void tcw_tiberium_spike_capture::Created(GameObject *obj)
-{
-	capturer = 0;
-	capturing = false;
-}
-void tcw_tiberium_spike_capture::Entered(GameObject *obj, GameObject *enter)
-{
-	if (Commands->Is_A_Star(enter))
-	{
-		if ( (Is_Script_Attached(enter,"tcw_i_can_capture_spike")) && (!Get_Vehicle(enter)) )
-		{
-			if (!Commands->Find_Object(capturer))
-			{
-				if (!capturing)
-				{
-					if ( (Commands->Get_Player_Type(Commands->Find_Object(Get_Int_Parameter("Spike_ID"))) == 0) && (Commands->Get_Player_Type(enter) == 0) )
-					{
-						Send_Message_Player(enter,255,0,0,"Your team already controls this Tiberium Spike.");
-					}
-					else if ( (Commands->Get_Player_Type(Commands->Find_Object(Get_Int_Parameter("Spike_ID"))) == 1) && (Commands->Get_Player_Type(enter) == 1) )
-					{
-						Send_Message_Player(enter,255,204,0,"Your team already controls this Tiberium Spike.");
-					}
-					else
-					{
-						capturer = Commands->Get_ID(enter);
-						capturing = true;
-						if (Commands->Get_Player_Type(Commands->Find_Object(capturer)) == 0)
-						{
-							Commands->Start_Timer(obj,this,20.0f,100);
-						}
-						else if (Commands->Get_Player_Type(Commands->Find_Object(capturer)) == 1)
-						{
-							Commands->Start_Timer(obj,this,20.0f,101);
-						}
-						if (Commands->Find_Object(capturer))
-						{
-							if (Commands->Get_Player_Type(Commands->Find_Object(capturer)) == 0)
-							{
-								char capturerd[250];
-								sprintf(capturerd,"%s is capturing a Tiberium Spike.",Get_Player_Name(Commands->Find_Object(capturer)));
-								Send_Message_Team(0,255,0,0,capturerd);
-								Create_2D_WAV_Sound_Team("building_capture.wav",0);
-							}
-							else if (Commands->Get_Player_Type(Commands->Find_Object(capturer)) == 1)
-							{
-								char capturerd[250];
-								sprintf(capturerd,"%s is capturing a Tiberium Spike.",Get_Player_Name(Commands->Find_Object(capturer)));
-								Send_Message_Team(1,255,204,0,capturerd);
-								Create_2D_WAV_Sound_Team("building_capture.wav",1);
-							}
-						}
-					}
-				}
-				else
-				{
-					Send_Message_Player(enter,255,255,255,"Capturing in progress, please try again in 30 seconds.");
-				}
-			}
-		}
-	}
-}
-void tcw_tiberium_spike_capture::Exited(GameObject *obj, GameObject *exit)
-{
-	if (Commands->Is_A_Star(exit))
-	{
-		if (Commands->Get_ID(exit) == capturer)
-		{
-			capturer = 0;
-			capturing = false;
-		}
-	}
-}
-void tcw_tiberium_spike_capture::Timer_Expired(GameObject *obj, int number)
-{
-	if (number == 100)
-	{
-		if (capturing)
-		{
-			if (Commands->Find_Object(capturer))
-			{
-				int oldspiketeam = Commands->Get_Player_Type(Commands->Find_Object(Get_Int_Parameter("Spike_ID")));	
-				Commands->Send_Custom_Event(obj,Commands->Find_Object(Get_Int_Parameter("Spike_ID")),1000,0,0);
-				char good[250];
-				sprintf(good,"%s captured a Tiberium Spike.",Get_Player_Name(Commands->Find_Object(capturer)));
-				Send_Message(255,255,255,good);
-
-				if (oldspiketeam == 1)
-				{
-					Create_2D_WAV_Sound_Team("nod_building_captured.wav",0);
-					Send_Message_Team(0,255,0,0,"Building captured.");
-					Create_2D_WAV_Sound_Team("gdi_building_captured_our.wav",1);
-					Send_Message_Team(1,255,204,0,"Our building has been captured.");
-				}
-				else
-				{
-					Create_2D_WAV_Sound_Team("nod_building_captured.wav",0);
-					Send_Message_Team(0,255,0,0,"Building captured.");
-				}
-				Commands->Give_Points(Commands->Find_Object(capturer),250.0f,0);
-				Remove_Script(Commands->Find_Object(capturer),"tcw_i_can_capture_spike");
-				capturing = false;
-				capturer = 0;
-			}
-			else
-			{
-				capturing = false;
-				capturer = 0;
-			}
-		}
-		else 
-		{
-			capturing = false;
-			capturer = 0;
-		}
-	}
-	if (number == 101)
-	{
-		if (capturing)
-		{
-			if (Commands->Find_Object(capturer))
-			{
-				int oldspiketeam = Commands->Get_Player_Type(Commands->Find_Object(Get_Int_Parameter("Spike_ID")));	
-				Commands->Send_Custom_Event(obj,Commands->Find_Object(Get_Int_Parameter("Spike_ID")),1000,1,0);
-				char good[250];
-				sprintf(good,"%s captured a Tiberium Spike.",Get_Player_Name(Commands->Find_Object(capturer)));
-				Send_Message(255,255,255,good);
-
-				if (oldspiketeam == 0)
-				{
-					Create_2D_WAV_Sound_Team("gdi_building_captured.wav",1);
-					Send_Message_Team(1,255,204,0,"Building captured.");
-					Create_2D_WAV_Sound_Team("nod_building_captured_our.wav",0);
-					Send_Message_Team(0,255,0,0,"Our building has been captured.");
-				}
-				else
-				{
-					Create_2D_WAV_Sound_Team("gdi_building_captured.wav",1);
-					Send_Message_Team(1,255,204,0,"Building captured.");
-				}
-				Commands->Give_Points(Commands->Find_Object(capturer),250.0f,0);
-				Remove_Script(Commands->Find_Object(capturer),"tcw_i_can_capture_spike");
-				capturing = false;
-				capturer = 0;
-			}
-			else
-			{
-				capturing = false;
-				capturer = 0;
-			}
-		}
-		else 
-		{
-			capturing = false;
-			capturer = 0;
-		}
-	}
-}
-void tcw_tiberium_spike_capture::Register_Auto_Save_Variables()
-{
-	Auto_Save_Variable(&capturer,sizeof(capturer),1);
-	Auto_Save_Variable(&capturing,sizeof(capturing),2);
-}
-
-void tcw_i_can_capture_spike::Created(GameObject *obj)
-{
-	//checkscript for allowing capturing of spikes
-}
+#include "engine.h"
+#include "GameObjManager.h"
+#include "BuildingGameObj.h"
 
 void tcw_Credit_Trickle::Created(GameObject *obj)
 {
@@ -420,153 +40,6 @@
 	}
 }
 
-void tcw_Tiberium_Field::Created(GameObject *obj)
-{
-	ID = 0;
-}
-
-void tcw_Tiberium_Field::Entered(GameObject *obj,GameObject *enter)
-{
-	const char *Preset = Commands->Get_Preset_Name(enter);
-	const char *Nod_PresetGreen = Get_Parameter("Nod_Preset_Green");
-	const char *GDI_PresetGreen = Get_Parameter("GDI_Preset_Green");
-	const char *Nod_PresetBlue = Get_Parameter("Nod_Preset_Blue");
-	const char *GDI_PresetBlue = Get_Parameter("GDI_Preset_Blue");
-	if (!ID)
-	{
-		if ( (!_stricmp(Preset,Nod_PresetGreen)) || (!_stricmp(Preset,GDI_PresetGreen)) || (!_stricmp(Preset,Nod_PresetBlue)) || (!_stricmp(Preset,GDI_PresetBlue)) )
-		{
-			ID = Commands->Get_ID(enter);
-			Commands->Start_Timer(obj,this,Get_Float_Parameter("Time"),Get_Int_Parameter("TimerNum"));
-			Commands->Send_Custom_Event(obj,enter,Get_Int_Parameter("StartHarvest"),0,0);
-		}
-	}
-}
-
-void tcw_Tiberium_Field::Exited(GameObject *obj,GameObject *exit)
-{
-	if (Commands->Get_ID(exit) == ID)
-	{
-		ID = 0;
-		Commands->Send_Custom_Event(obj,exit,Get_Int_Parameter("StopHarvest"),0,0);
-	}
-}
-
-void tcw_Tiberium_Field::Timer_Expired(GameObject *obj,int number)
-{
-	int Cash = Get_Int_Parameter("Cash");
-	int Collected_Message = Get_Int_Parameter("Collected_Message");
-	Vector3 pos;
-	float angle;
-	GameObject *object;
-	const char *Collected_Preset = Get_Parameter("Collected_Preset");
-	float Collected_Preset_Distance = Get_Float_Parameter("Collected_Preset_Distance");
-	if (ID)
-	{
-		object = Commands->Find_Object(ID);
-		Commands->Send_Custom_Event(obj,object,Collected_Message,Cash,0);
-		pos = Commands->Get_Position(object);
-		angle = Commands->Get_Facing(object);
-		pos.X+=Collected_Preset_Distance*(float)cos(angle);
-		pos.Y+=Collected_Preset_Distance*(float)sin(angle);
-		Commands->Create_Object(Collected_Preset,pos);
-		Commands->Send_Custom_Event(obj,object,Get_Int_Parameter("StopHarvest"),0,0);
-	}
-}
-
-void tcw_Tiberium_Field::Register_Auto_Save_Variables()
-{
-	Auto_Save_Variable(&ID,sizeof(ID),1);
-}
-
-void tcw_Tiberium_Deposit::Entered(GameObject *obj,GameObject *enter)
-{
-	int Deposit_Message = Get_Int_Parameter("Deposit_Message");
-	Commands->Send_Custom_Event(obj,enter,Deposit_Message,0,0);
-}
-
-void tcw_tiberium_spike_points::Created(GameObject *obj)
-{
-	firstcapture = true;
-	Commands->Set_Animation(obj,"V_NEU_SPIKE.V_NEU_SPIKE",true,0,1,-1,0);
-}
-void tcw_tiberium_spike_points::Custom(GameObject *obj, int message, int param, GameObject *sender)
-{
-	if (message == 1000)
-	{
-		if (param == 0)
-		{
-			Commands->Set_Player_Type(obj,0);
-			if (firstcapture)
-			{
-				firstcapture = false;
-				Commands->Give_Money(obj,250.0f,true);
-				Attach_Script_Once(obj,"tcw_Point_Trickle","5,1");
-			}
-			else
-			{
-				Attach_Script_Once(obj,"tcw_Point_Trickle","5,1");
-			}
-		}
-		else if (param == 1)
-		{
-			Commands->Set_Player_Type(obj,1);
-			if (firstcapture)
-			{
-				firstcapture = false;
-				Commands->Give_Money(obj,250.0f,true);
-				Attach_Script_Once(obj,"tcw_Point_Trickle","5,1");
-			}
-			else
-			{
-				Attach_Script_Once(obj,"tcw_Point_Trickle","5,1");
-			}
-		}
-	}
-}
-void tcw_tiberium_spike_points::Register_Auto_Save_Variables()
-{
-	Auto_Save_Variable(&firstcapture,sizeof(firstcapture),1);
-}
-
-void tcw_Point_Trickle::Created(GameObject *obj)
-{
-	display = true;
-	float delay;
-	delay = Get_Float_Parameter("Delay");
-	Commands->Start_Timer(obj,this,delay,667);
-}
-
-void tcw_Point_Trickle::Timer_Expired(GameObject *obj,int number)
-{
-	if (number == 667)
-	{
-		Commands->Give_Money(obj,(float)Get_Int_Parameter("Points"),true);
-		if (Get_Team_Credits(Get_Object_Type(obj)) >= 50000)
-		{
-			if (display)
-			{
-				display = false;
-				if (Get_Object_Type(obj) == 0)
-				{
-					Commands->Send_Custom_Event(obj,Find_Object_With_Script("tcw_Custom_Win_Game_Credits"),1000,0,1);
-				}
-				else if (Get_Object_Type(obj) == 1)
-				{
-					Commands->Send_Custom_Event(obj,Find_Object_With_Script("tcw_Custom_Win_Game_Credits"),1000,1,1);
-				}
-			}
-		}
-		float delay;
-		delay = Get_Float_Parameter("Delay");
-		Commands->Start_Timer(obj,this,delay,667);
-	}
-}
-void tcw_Point_Trickle::Register_Auto_Save_Variables()
-{
-	Auto_Save_Variable(&display,sizeof(display),1);
-}
-
 void tcw_Custom_Win_Game_Credits::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
 	if (message == 1000)
@@ -595,12 +68,6 @@
 	}
 }
 
-void tcw_Set_Spike_Team_Created::Created(GameObject *obj)
-{
-	int team = Get_Int_Parameter("Team");
-	Commands->Send_Custom_Event(obj,obj,1001,team,1);
-}
-
 void tcw_Map_Intro::Created(GameObject *obj)
 {
 	Commands->Start_Timer(obj,this,10.0f,251);
@@ -658,251 +125,6 @@
 	}
 }
 
-void tcw_Tiberium_Field_New::Created(GameObject *obj)
-{
-	zonetype = Get_Int_Parameter("Zonetype");//0=green 1=blue
-}
-void tcw_Tiberium_Field_New::Entered(GameObject *obj, GameObject *enter)
-{
-	if ( (strcmp(Commands->Get_Preset_Name(enter),"TCW_GDI_Harvester_Player") == 0) || 
-		 (strcmp(Commands->Get_Preset_Name(enter),"TCW_Nod_GDI_Harvester_Player") == 0) || 
-		 (strcmp(Commands->Get_Preset_Name(enter),"TCW_GDI_Nod_Harvester_Player") == 0) || 
-		 (strcmp(Commands->Get_Preset_Name(enter),"TCW_Nod_Harvester_Player") == 0) )
-	{
-		if (zonetype == 0)//green
-		{
-			Commands->Send_Custom_Event(obj,enter,10500,0,0);//tell harv a green zone entered
-		}
-		else if (zonetype == 1)//blue
-		{
-			Commands->Send_Custom_Event(obj,enter,10500,1,0);//tell harv a blue zone entered
-		}
-	}
-}
-void tcw_Tiberium_Field_New::Exited(GameObject *obj, GameObject *exit)
-{
-	if ( (strcmp(Commands->Get_Preset_Name(exit),"TCW_GDI_Harvester_Player") == 0) || 
-		 (strcmp(Commands->Get_Preset_Name(exit),"TCW_Nod_GDI_Harvester_Player") == 0) || 
-		 (strcmp(Commands->Get_Preset_Name(exit),"TCW_GDI_Nod_Harvester_Player") == 0) || 
-		 (strcmp(Commands->Get_Preset_Name(exit),"TCW_Nod_Harvester_Player") == 0) )
-	{
-		Commands->Send_Custom_Event(obj,exit,10500,3,0);//tell harv left zone
-	}
-}
-void tcw_Tiberium_Field_New::Register_Auto_Save_Variables()
-{
-	Auto_Save_Variable(&zonetype,sizeof(zonetype),1);
-}
-
-void tcw_Tiberium_Harvester_New::Created(GameObject *obj)
-{
-	harvesting = false;
-	tiberiumvalue = 0.0f;
-	hasgreen = false;
-	hasblue = false;
-	team = -1;
-	driverid = 0;
-	if ( (strcmp(Commands->Get_Preset_Name(obj),"TCW_Nod_Harvester") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"TCW_GDI_Nod_Harvester_Player") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"TCW_Nod_Harvester_Player") == 0) )
-	{
-		VehicleGameObj* harvester = obj->As_VehicleGameObj();
-		if (!harvester) return;
-		harvester->Set_Allow_Stealth_While_Empty(true);
-	}
-}
-void tcw_Tiberium_Harvester_New::Custom(GameObject *obj, int message, int param, GameObject *sender)
-{
-	if (message == CUSTOM_EVENT_VEHICLE_ENTERED)
-	{
-		team = Commands->Get_Player_Type(sender);
-		driverid = Commands->Get_ID(sender);
-		if (team == 0)
-		{
-			Send_Message_Player(Commands->Find_Object(driverid),255,0,0,"Drive to a Tiberium Field to harvest Tiberium.");
-			Create_2D_WAV_Sound_Player(Commands->Find_Object(driverid),"incmsg.wav");
-		}
-		else if (team == 1)
-		{
-			Send_Message_Player(Commands->Find_Object(driverid),255,204,0,"Drive to a Tiberium Field to harvest Tiberium.");
-			Create_2D_WAV_Sound_Player(Commands->Find_Object(driverid),"incmsg.wav");
-		}
-	}
-	else if (message == CUSTOM_EVENT_VEHICLE_EXITED)
-	{
-		harvesting = false;
-		driverid = 0;
-		team = -1;
-	}
-	else if (message == 10500)
-	{
-		if (param == 0)//green tib entered
-		{
-			if (Commands->Find_Object(driverid))
-			{
-				if (!hasblue)
-				{
-					hasgreen = true;
-					harvesting = true;
-					Commands->Start_Timer(obj,this,1.0f,10500);
-				}
-			}
-		}
-		else if (param == 1)//blue tib entered
-		{
-			if (Commands->Find_Object(driverid))
-			{
-				if (!hasgreen)
-				{
-					hasblue = true;
-					harvesting = true;
-					Commands->Start_Timer(obj,this,1.0f,10501);
-				}
-			}
-		}
-		else if (param == 3)//harv left the zone
-		{
-			harvesting = false;
-		}
-		else if (param == 4)//deposit
-		{
-			if (tiberiumvalue > 0.0f)
-			{
-				if (Commands->Find_Object(driverid))
-				{
-					if (!Is_Building_Dead(Find_Building(team,BuildingConstants::TYPE_REFINERY)))
-					{
-						Commands->Give_Money(Commands->Find_Object(driverid),tiberiumvalue,true);
-						if (hasgreen)
-						{
-							Commands->Give_Points(Commands->Find_Object(driverid),50.0f,0);
-						}
-						if (hasblue)
-						{
-							Commands->Give_Points(Commands->Find_Object(driverid),75.0f,0);
-						}
-						if (team == 0)
-						{
-							char dumpmsg[250];
-							sprintf(dumpmsg,"%s deposited Tiberium funding Nod with %g additional credits.",Get_Player_Name(Commands->Find_Object(driverid)),tiberiumvalue);
-							Send_Message_Team(0,255,0,0,dumpmsg);
-							Create_2D_WAV_Sound_Team("creditsacquired_nod.wav",0);
-						}
-						else if (team == 1)
-						{
-							char dumpmsg[250];
-							sprintf(dumpmsg,"%s deposited Tiberium funding GDI with %g additional credits.",Get_Player_Name(Commands->Find_Object(driverid)),tiberiumvalue);
-							Send_Message_Team(1,255,204,0,dumpmsg);
-							Create_2D_WAV_Sound_Team("creditsacquired_gdi.wav",1);
-						}
-						tiberiumvalue = 0.0f;
-						hasblue = false;
-						hasgreen = false;
-					}
-				}
-			}
-		}
-	}
-}
-void tcw_Tiberium_Harvester_New::Timer_Expired(GameObject *obj, int number)
-{
-	if (number == 10500)//green
-	{
-		if (harvesting)
-		{
-			if (tiberiumvalue < 800.0f)
-			{
-				Commands->Start_Timer(obj,this,1.0f,10500);
-				tiberiumvalue = tiberiumvalue+100.0f;
-
-				if (team == 0)
-				{
-					char amount[250];
-					sprintf(amount,"You harvested $%g worth of Tiberium Crystals.",tiberiumvalue);
-					Send_Message_Player(Commands->Find_Object(driverid),255,0,0,amount);
-				}
-				else if (team == 1)
-				{
-					char amount[250];
-					sprintf(amount,"You harvested $%g worth of Tiberium Crystals.",tiberiumvalue);
-					Send_Message_Player(Commands->Find_Object(driverid),255,204,0,amount);
-				}
-
-				if (tiberiumvalue == 800.0f)
-				{
-					if (team == 0)
-					{
-						Send_Message_Player(Commands->Find_Object(driverid),255,0,0,"Tiberium harvesting has completed, return to the Refinery.");
-						Create_2D_WAV_Sound_Player(Commands->Find_Object(driverid),"incmsg.wav");
-					}
-					else if (team == 1)
-					{
-						Send_Message_Player(Commands->Find_Object(driverid),255,204,0,"Tiberium harvesting has completed, return to the Refinery.");
-						Create_2D_WAV_Sound_Player(Commands->Find_Object(driverid),"incmsg.wav");
-					}
-					harvesting = false;
-				}
-			}
-		}
-	}
-	else if (number == 10501)//blue
-	{
-		if (harvesting)
-		{
-			if (tiberiumvalue < 1600.0f)
-			{
-				Commands->Start_Timer(obj,this,1.0f,10501);
-				tiberiumvalue = tiberiumvalue+200.0f;
-
-				if (team == 0)
-				{
-					char amount[250];
-					sprintf(amount,"You harvested $%g worth of Tiberium Crystals.",tiberiumvalue);
-					Send_Message_Player(Commands->Find_Object(driverid),255,0,0,amount);
-				}
-				else if (team == 1)
-				{
-					char amount[250];
-					sprintf(amount,"You harvested $%g worth of Tiberium Crystals.",tiberiumvalue);
-					Send_Message_Player(Commands->Find_Object(driverid),255,204,0,amount);
-				}
-
-				if (tiberiumvalue == 1600.0f)
-				{
-					if (team == 0)
-					{
-						Send_Message_Player(Commands->Find_Object(driverid),255,0,0,"Tiberium harvesting has completed, return to the Refinery.");
-						Create_2D_WAV_Sound_Player(Commands->Find_Object(driverid),"incmsg.wav");
-					}
-					else if (team == 1)
-					{
-						Send_Message_Player(Commands->Find_Object(driverid),255,204,0,"Tiberium harvesting has completed, return to the Refinery.");
-						Create_2D_WAV_Sound_Player(Commands->Find_Object(driverid),"incmsg.wav");
-					}
-				}
-			}
-		}
-	}
-}
-void tcw_Tiberium_Harvester_New::Register_Auto_Save_Variables()
-{
-	Auto_Save_Variable(&harvesting,sizeof(harvesting),1);
-	Auto_Save_Variable(&tiberiumvalue,sizeof(tiberiumvalue),2);
-	Auto_Save_Variable(&hasgreen,sizeof(hasgreen),3);
-	Auto_Save_Variable(&hasblue,sizeof(hasblue),4);
-	Auto_Save_Variable(&team,sizeof(team),5);
-	Auto_Save_Variable(&driverid,sizeof(driverid),6);
-}
-
-void tcw_Tiberium_Deposit_New::Entered(GameObject *obj, GameObject *enter)
-{
-	if ( (strcmp(Commands->Get_Preset_Name(enter),"TCW_GDI_Harvester_Player") == 0) || 
-		 (strcmp(Commands->Get_Preset_Name(enter),"TCW_Nod_GDI_Harvester_Player") == 0) || 
-		 (strcmp(Commands->Get_Preset_Name(enter),"TCW_GDI_Nod_Harvester_Player") == 0) ||
-		 (strcmp(Commands->Get_Preset_Name(enter),"TCW_Nod_Harvester_Player") == 0) )
-	{
-		Commands->Send_Custom_Event(obj,enter,10500,4,0);//tell harv deposit tib
-	}
-}
-
 void tcw_There_Must_Be_Engineer::Created(GameObject *obj)
 {
 	SList<SoldierGameObj> *player_list = &GameObjManager::StarGameObjList;
@@ -914,7 +136,7 @@
 		{
 			if (Commands->Get_Player_Type(soldier) == 0)
 			{
-				if (!Is_Building_Dead(Find_Building(0,BuildingConstants::TYPE_SOLDIER_FACTORY)))
+				if (!Is_Building_Dead(Find_Building_By_Type(0,BuildingConstants::TYPE_SOLDIER_FACTORY)))
 				{
 					if (strcmp(Commands->Get_Preset_Name(soldier),"CnC_Nod_Minigunner_0") == 0)
 					{
@@ -934,7 +156,7 @@
 			}
 			else if (Commands->Get_Player_Type(soldier) == 1)
 			{
-				if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_SOLDIER_FACTORY)))
+				if (!Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_SOLDIER_FACTORY)))
 				{
 					if (strcmp(Commands->Get_Preset_Name(soldier),"CnC_GDI_MiniGunner_0") == 0)
 					{
@@ -956,123 +178,6 @@
 	}
 }
 
-void tcw_Enable_Refill::Created(GameObject *obj)
-{
-	//
-}
-
-void tcw_Buy_Beacon_Ion::Created(GameObject *obj)
-{
-	type = Get_Int_Parameter("Type");//1=10s 2=60s beacon
-	allowpoke = true; Commands->Enable_HUD_Pokable_Indicator(obj, true);
-	ionholder = 0;
-	ready = false;
-	charging = true; Commands->Start_Timer(obj,this,30.0f,100100);//commence charging of the ion
-}
-void tcw_Buy_Beacon_Ion::Register_Auto_Save_Variables()
-{
-	Auto_Save_Variable(&type,sizeof(type),1);
-	Auto_Save_Variable(&allowpoke,sizeof(allowpoke),2);
-	Auto_Save_Variable(&ionholder,sizeof(ionholder),3);
-	Auto_Save_Variable(&ready,sizeof(ready),4);
-	Auto_Save_Variable(&charging,sizeof(charging),5);
-}
-void tcw_Buy_Beacon_Ion::Timer_Expired(GameObject *obj, int number)
-{
-	if (number == 100100)
-	{
-		if (!Is_Building_Dead(Find_Object_By_Preset(1,"GDI_Ion_Control_Center")))
-		{
-			if (charging)
-			{
-				ready = true;
-				charging = false;
-				Create_2D_WAV_Sound_Team("gdi_ion_cannon_ready.wav",1);
-				Send_Message_Team(1,255,204,0,"Ion Cannon Ready.");
-			}
-		}
-	}
-	else if (number == 100101)
-	{
-		if (!Is_Building_Dead(Find_Object_By_Preset(1,"GDI_Ion_Control_Center")))
-		{
-			allowpoke = true; Commands->Enable_HUD_Pokable_Indicator(obj, true);
-		}
-	}
-}
-void tcw_Buy_Beacon_Ion::Poked(GameObject *obj, GameObject *poker)
-{
-	if (allowpoke)
-	{
-		if (Commands->Get_Player_Type(poker) == 1)
-		{
-			if (ready)
-			{
-				if (!ionholder)
-				{
-					ionholder = Commands->Get_ID(poker);
-					char ionguymsg[250];
-					sprintf(ionguymsg,"%s please select the Ion Cannon Target.",Get_Player_Name(Commands->Find_Object(ionholder)));
-					Send_Message_Team(1,255,204,0,ionguymsg);
-					Commands->Create_2D_WAV_Sound("gdi_ion_select_target.wav");
-					if (type == 1)//if the mapper decided to grant 10 sec beacons
-					{
-						Commands->Give_PowerUp(Commands->Find_Object(ionholder),"TCW_POW_Beacon_Nuke_10Sec",false);
-					}
-					else if (type == 2)//if the mapper decided to grant 60 sec beacons
-					{
-						Commands->Give_PowerUp(Commands->Find_Object(ionholder),"TCW_POW_Beacon_Nuke_60Sec",false);
-					}
-					Attach_Script_Once(Commands->Find_Object(ionholder),"tcw_I_Have_Ion_Cannon_Beacon","");
-				}
-			}
-		}
-		allowpoke = false; Commands->Enable_HUD_Pokable_Indicator(obj, false); Commands->Start_Timer(obj,this,10.0f,100101);//allow true set
-	}
-}
-void tcw_Buy_Beacon_Ion::Custom(GameObject *obj, int message, int param, GameObject *sender)
-{
-	if (message == 100100)//the ion building was destroyed
-	{
-		if (param == 1)
-		{
-			ready = false;		charging = false;		allowpoke = false;
-			if (ionholder)
-			{
-				Remove_Weapon(Commands->Find_Object(ionholder),"TCW_Weapon_IonCannon_10Sec");
-				Remove_Weapon(Commands->Find_Object(ionholder),"TCW_Weapon_IonCannon_60Sec");
-			}
-		}
-	}
-	else if (message == 100101)//the guy died or left game, whatever
-	{
-		if (param == 1)
-		{
-			if (!Is_Building_Dead(Find_Object_By_Preset(1,"GDI_Ion_Control_Center")))
-			{
-				if (ready)
-				{
-					ionholder = 0;
-					allowpoke = true; Commands->Enable_HUD_Pokable_Indicator(obj, true);
-				}
-			}
-		}
-	}
-	else if (message == 100102)//successful ion strike done
-	{
-		if (param == 1)
-		{
-			if (!Is_Building_Dead(Find_Object_By_Preset(1,"GDI_Ion_Control_Center")))
-			{
-				ready = false;
-				ionholder = 0;
-				charging = true; Commands->Start_Timer(obj,this,30.0f,100100);
-				allowpoke = true; Commands->Enable_HUD_Pokable_Indicator(obj, true);
-			}
-		}
-	}
-}
-
 void tcw_Spikemap_Get_CaptureGuy::Created(GameObject *obj)
 {
 	// This script is for buying a Engineer or Saboteur for free on maps that have only spikes
@@ -1086,7 +191,7 @@
 	{
 		if (type == 0)
 		{
-			if (!Is_Building_Dead(Find_Building(0,BuildingConstants::TYPE_SOLDIER_FACTORY)))
+			if (!Is_Building_Dead(Find_Building_By_Type(0,BuildingConstants::TYPE_SOLDIER_FACTORY)))
 			{
 				if (Commands->Get_Player_Type(poker) == type)
 				{
@@ -1099,7 +204,7 @@
 		}
 		else if (type == 1)
 		{
-			if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_SOLDIER_FACTORY)))
+			if (!Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_SOLDIER_FACTORY)))
 			{
 				if (Commands->Get_Player_Type(poker) == type)
 				{
@@ -1130,7 +235,7 @@
 {
 	int type = Get_Int_Parameter("Type");
 	const char *building = Get_Parameter("Building_Name");
-	Commands->Apply_Damage(Find_Building_By_Name(type,building),99999.0f,"C4",shooter);
+	Commands->Apply_Damage(Find_Building_By_Preset(type,building),99999.0f,"C4",shooter);
 }
 
 void tcw_zone_teleport_random_id::Created(GameObject *obj)
@@ -1216,13 +321,19 @@
 	Commands->Send_Custom_Event(obj,Commands->Find_Object(id),msg,prm,0);
 }
 
-void tcw_test::Created(GameObject *obj)
+void tcw_Spawner_Enable_Timer::Created(GameObject *obj)
 {
-	Console_Input("msg script created");
+	Commands->Start_Timer(obj,this,Get_Float_Parameter("Enable_After_Seconds"),1001);
+}
+void tcw_Spawner_Enable_Timer::Timer_Expired(GameObject *obj, int number)
+{
+	if (number == 1001)
+	{
+		Commands->Enable_Spawner(Get_Int_Parameter("SpawnerID"),true);
+	}
 }
 
-
-ScriptRegistrant<tcw_test> tcw_test_Registrant("tcw_test","");
+ScriptRegistrant<tcw_Spawner_Enable_Timer> tcw_Spawner_Enable_Timer_Registrant("tcw_Spawner_Enable_Timer","Enable_After_Seconds=1000:float,SpawnerID=0:int");
 ScriptRegistrant<tcw_destroyed_send_custom> tcw_destroyed_send_custom_Registrant("tcw_destroyed_send_custom","Message=1000:int,SendID=1000:int,Param=1:int");
 ScriptRegistrant<tcw_dm_map_tech1> tcw_dm_map_tech1_Registrant("tcw_dm_map_tech1","");
 ScriptRegistrant<tcw_dm_map_tech2> tcw_dm_map_tech2_Registrant("tcw_dm_map_tech2","");
@@ -1230,21 +341,7 @@
 ScriptRegistrant<tcw_zone_teleport_random_id> tcw_zone_teleport_random_id_Registrant("tcw_zone_teleport_random_id","ID1=1:int,ID2=2:int,ID3=3:int");
 ScriptRegistrant<tcw_Death_Blowup_Building> tcw_Death_Blowup_Building_Registrant("tcw_Death_Blowup_Building","Type=0:int,Building_Name=TCW:string");
 ScriptRegistrant<tcw_Spikemap_Get_CaptureGuy> tcw_Spikemap_Get_CaptureGuy_Registrant("tcw_Spikemap_Get_CaptureGuy","Type=0:int");
-ScriptRegistrant<tcw_Buy_Beacon_Ion> tcw_Buy_Beacon_Ion_Registrant("tcw_Buy_Beacon_Ion","Type=2:int");
-ScriptRegistrant<tcw_Enable_Refill> tcw_Enable_Refill_Registrant("tcw_Enable_Refill","");
 ScriptRegistrant<tcw_There_Must_Be_Engineer> tcw_There_Must_Be_Engineer_Registrant("tcw_There_Must_Be_Engineer","");
-ScriptRegistrant<tcw_Tiberium_Deposit_New> tcw_Tiberium_Deposit_New_Registrant("tcw_Tiberium_Deposit_New","");
-ScriptRegistrant<tcw_Tiberium_Harvester_New> tcw_Tiberium_Harvester_New_Registrant("tcw_Tiberium_Harvester_New","");
-ScriptRegistrant<tcw_Tiberium_Field_New> tcw_Tiberium_Field_New_Registrant("tcw_Tiberium_Field_New","Zonetype=0:int");
 ScriptRegistrant<tcw_Map_Intro> tcw_Map_Intro_Registrant("tcw_Map_Intro","Red=1:int,Green=1:int,Blue=1:int,Intro1=Line1:string,Intro2=Line2:string,Intro3=Line3:string,Intro4=Line4:string,Intro5=Line5:string");
-ScriptRegistrant<tcw_Set_Spike_Team_Created> tcw_Set_Spike_Team_Created_Registrant("tcw_Set_Spike_Team_Created","Team=0:int");
 ScriptRegistrant<tcw_Custom_Win_Game_Credits> tcw_Custom_Win_Game_Credits_Registrant("tcw_Custom_Win_Game_Credits","");
-ScriptRegistrant<tcw_Point_Trickle> tcw_Point_Trickle_Registrant("tcw_Point_Trickle","Points=1:int,Delay=2.0:float");
-ScriptRegistrant<tcw_tiberium_spike_points> tcw_tiberium_spike_points_Registrant("tcw_tiberium_spike_points","");
-ScriptRegistrant<tcw_Tiberium_Deposit> tcw_Tiberium_Deposit_Registrant("tcw_Tiberium_Deposit","Deposit_Message:int");
-ScriptRegistrant<tcw_Tiberium_Field> tcw_Tiberium_Field_Registrant("tcw_Tiberium_Field","Cash:int,Time:float,TimerNum:int,Collected_Preset:string,Collected_Preset_Distance:float,Collected_Message:int,Nod_Preset_Green=TCW_Nod_Harvester_Player_Green:string,GDI_Preset_Green=TCW_GDI_Harvester_Player_Green:string,Nod_Preset_Blue=TCW_Nod_Harvester_Player_Blue:string,GDI_Preset_Blue=TCW_GDI_Harvester_Player_Blue:string,StartHarvest:int,StopHarvest:int");
 ScriptRegistrant<tcw_Credit_Trickle> tcw_Credit_Trickle_Registrant("tcw_Credit_Trickle","Credits=1:int,Delay=2.0:float");
-ScriptRegistrant<tcw_i_can_capture_spike> tcw_i_can_capture_spike_Registrant("tcw_i_can_capture_spike","");
-ScriptRegistrant<tcw_tiberium_spike_capture> tcw_tiberium_spike_capture_Registrant("tcw_tiberium_spike_capture","Spike_ID=123:int");
-ScriptRegistrant<tcw_tiberium_spike> tcw_tiberium_spike_Registrant("tcw_tiberium_spike","");
-ScriptRegistrant<tcw_Tiberium_Harvester> tcw_Tiberium_Harvester_Registrant("tcw_Tiberium_Harvester","Collected_Message:int,Refinery_Message:int,Cash_Limit:int,Cash_Type:int,Entire_Team:int");
\ No newline at end of file
diff -uwr sourceold/scripts/tcw_game.h source/scripts/tcw_game.h
--- sourceold/scripts/tcw_game.h	2012-02-08 00:15:44.309570300 +0800
+++ source/scripts/tcw_game.h	2012-06-09 08:11:12.182617100 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -11,140 +11,27 @@
 	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.
 */
-#pragma once
-
-class tcw_Tiberium_Harvester : public ScriptImpClass {
-	int driver;
-	int team;
-	int cash;
-	int ID;
-	void Created(GameObject *obj);
-	void Custom(GameObject *obj,int type,int param,GameObject *sender);
-	public: void Register_Auto_Save_Variables();
-};
-
-class tcw_tiberium_spike : public ScriptImpClass {
-	void Created(GameObject *obj);
-	void Custom(GameObject *obj,int type,int param,GameObject *sender);
-	public: void Register_Auto_Save_Variables();
-	void Damaged(GameObject *obj, GameObject *damager, float damage);
-	bool firstcapture;
-};
-
-class tcw_tiberium_spike_capture : public ScriptImpClass {
-	void Created(GameObject *obj);
-	void Entered(GameObject *obj, GameObject *enter);
-	void Exited(GameObject *obj, GameObject *exit);
-	void Timer_Expired(GameObject *obj, int number);
-	public: void Register_Auto_Save_Variables();
-	int capturer;
-	bool capturing;
-};
-
-class tcw_i_can_capture_spike : public ScriptImpClass {
-	void Created(GameObject *obj);
-};
 
-class tcw_Player_Attach_Dropweapons : public JFW_Object_Created_Hook_Base {
-	void ObjectCreateHook(GameObject *obj);
-	void Timer_Expired(GameObject *obj, int number);
-};
-
-class tcw_Player_Dropweapons : public ScriptImpClass {
-	void Destroyed(GameObject *obj);
-};
+#pragma once
 
 class tcw_Credit_Trickle : public ScriptImpClass {
 	void Created(GameObject *obj);
 	void Timer_Expired(GameObject *obj,int number);
 };
 
-class tcw_Tiberium_Field : public ScriptImpClass {
-	int ID;
-	void Created(GameObject *obj);
-	void Entered(GameObject *obj,GameObject *enter);
-	void Exited(GameObject *obj,GameObject *exit);
-	void Timer_Expired(GameObject *obj,int number);
-	public: void Register_Auto_Save_Variables();
-};
-
-class tcw_Tiberium_Deposit : public ScriptImpClass {
-	void Entered(GameObject *obj,GameObject *enter);
-};
-
-class tcw_tiberium_spike_points : public ScriptImpClass {
-	void Created(GameObject *obj);
-	void Custom(GameObject *obj,int type,int param,GameObject *sender);
-	public: void Register_Auto_Save_Variables();
-	bool firstcapture;
-};
-
-class tcw_Point_Trickle : public ScriptImpClass {
-	void Created(GameObject *obj);
-	void Timer_Expired(GameObject *obj,int number);
-	public: void Register_Auto_Save_Variables();
-	bool display;
-};
-
 class tcw_Custom_Win_Game_Credits : public ScriptImpClass {
 	void Custom(GameObject *obj,int type,int param,GameObject *sender);
 };
 
-class tcw_Set_Spike_Team_Created : public ScriptImpClass {
-	void Created(GameObject *obj);
-};
-
 class tcw_Map_Intro : public ScriptImpClass {
 	void Created(GameObject *obj);
 	void Timer_Expired(GameObject *obj, int number);
 };
 
-class tcw_Tiberium_Field_New : public ScriptImpClass {
-	void Created(GameObject *obj);
-	void Entered(GameObject *obj, GameObject *enter);
-	void Exited(GameObject *obj, GameObject *exit);
-	public: void Register_Auto_Save_Variables();
-	int zonetype;
-};
-
-class tcw_Tiberium_Harvester_New : public ScriptImpClass {
-	void Created(GameObject *obj);
-	void Custom(GameObject *obj, int message, int param, GameObject *sender);
-	void Timer_Expired(GameObject *obj, int number);
-	public: void Register_Auto_Save_Variables();
-	float tiberiumvalue;
-	bool harvesting;
-	bool hasgreen;
-	bool hasblue;
-	int driverid;
-	int team;
-};
-
-class tcw_Tiberium_Deposit_New : public ScriptImpClass {
-	void Entered(GameObject *obj, GameObject *enter);
-};
-
 class tcw_There_Must_Be_Engineer : public ScriptImpClass {
 	void Created(GameObject *obj);
 }; 
 
-class tcw_Enable_Refill : public ScriptImpClass {
-	void Created(GameObject *obj);
-}; 
-
-class tcw_Buy_Beacon_Ion : public ScriptImpClass {
-	void Created(GameObject *obj);
-	void Timer_Expired(GameObject *obj, int number);
-	void Poked(GameObject *obj, GameObject *poker);
-	void Custom(GameObject *obj, int message, int param, GameObject *sender);
-	public: void Register_Auto_Save_Variables();
-	bool charging;
-	bool ready;
-	bool allowpoke;
-	int ionholder;
-	int type;
-}; 
-
 class tcw_Spikemap_Get_CaptureGuy : public ScriptImpClass {
 	void Created(GameObject *obj);
 	void Poked(GameObject *obj, GameObject *poker);
@@ -185,14 +72,12 @@
 	void Destroyed(GameObject *obj);
 }; 
 
-class tcw_test : public ScriptImpClass {
+class tcw_Spawner_Enable_Timer : public ScriptImpClass {
 	void Created(GameObject *obj);
+	void Timer_Expired(GameObject *obj, int number);
 };
 
 
 
-
-
-
 
 
Only in source/scripts: tcw_general.cpp
Only in source/scripts: tcw_general.h
Only in source/scripts: tcw_mcv_escort.cpp
Only in source/scripts: tcw_mcv_escort.h
diff -uwr sourceold/scripts/tcw_player.cpp source/scripts/tcw_player.cpp
--- sourceold/scripts/tcw_player.cpp	2012-02-02 09:44:43.153320300 +0800
+++ source/scripts/tcw_player.cpp	2012-06-09 08:11:12.339843700 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -19,7 +19,6 @@
 #include "gmgame.h"
 #endif
 
-
 void tcw_Grant_Powerup_Created::Created(GameObject *obj)//with this script we can do to players what we want easily
 {
 	map_low_grav = false;	map_dm_tech1 = false;	map_dm_tech2 = false;	map_dm_tech3 = false;	map_coop_gdi = false;	map_coop_nod = false;	
@@ -214,10 +213,9 @@
 		}
 	}
 
-	Commands->Start_Timer(obj,this,1.5f,1003);//give MapCredits
-
-	upgrade_composit_armor_available = false;
+	upgrade_composit_armor_available = false; upgrade_powerpacks_available = false;
 	if (Find_Object_By_Preset(2,"TCW_Tech_Composit_Armor_Available")) {	upgrade_composit_armor_available = true; }
+	if (Find_Object_By_Preset(2,"TCW_Tech_Power_Packs_Available")) { upgrade_powerpacks_available = true; }
 
 	int sniperlimit = 2;
 
@@ -357,7 +355,7 @@
 			else if (random == 2)
 			{
 				Create_2D_WAV_Sound_Team("purchase_gdi_rifle_squad_2.wav",1);
-				char player[250]; sprintf(player,"%s: Rifle squad ready.",Get_Player_Name(obj));
+				char player[250]; sprintf(player,"%s: Reporting in.",Get_Player_Name(obj));
 				Send_Message_Team(1,255,204,0,player);
 			}
 			else if (random == 3)
@@ -637,7 +635,7 @@
 				else if (random == 2)
 				{
 					Create_2D_WAV_Sound_Team("purchase_gdi_sniper_2.wav",1);
-					char player[250]; sprintf(player,"%s: Sniper team ready.",Get_Player_Name(obj));
+					char player[250]; sprintf(player,"%s: I got'm in my scope.",Get_Player_Name(obj));
 					Send_Message_Team(1,255,204,0,player);
 				}
 				else if (random == 3)
@@ -684,6 +682,11 @@
 	{
 		if (Commands->Get_Player_Type(obj) == 1)
 		{
+			if (upgrade_powerpacks_available) 
+			{ 
+				Commands->Start_Timer(obj,this,3.0f,1007); //powerpacks check move
+				commandocurrpos = Commands->Get_Position(obj);//using this for checking the distance travel on zonetrooper as well
+			}
 			if (random == 1)
 			{
 				Create_2D_WAV_Sound_Team("purchase_gdi_zonetrooper_1.wav",1);
@@ -693,7 +696,7 @@
 			else if (random == 2)
 			{
 				Create_2D_WAV_Sound_Team("purchase_gdi_zonetrooper_2.wav",1);
-				char player[250]; sprintf(player,"%s: Troopers ready for action.",Get_Player_Name(obj));
+				char player[250]; sprintf(player,"%s: Shut this party down.",Get_Player_Name(obj));
 				Send_Message_Team(1,255,204,0,player);
 			}
 			else if (random == 3)
@@ -785,8 +788,8 @@
 				}
 				else if (random == 3)
 				{
-					Create_2D_WAV_Sound_Team("purchase_nod_commando_2.wav",1);
-					char player[250]; sprintf(player,"%s: Ready for assignment.",Get_Player_Name(obj));
+					Create_2D_WAV_Sound_Team("purchase_nod_commando_3.wav",1);
+					char player[250]; sprintf(player,"%s: It's play time.",Get_Player_Name(obj));
 					Send_Message_Team(1,255,204,0,player);
 				}
 			}
@@ -872,13 +875,13 @@
 			else if (rnd == 2)
 			{
 				Create_2D_WAV_Sound_Team("purchase_nod_blackhand_flame_2.wav",0);
-				char player[250]; sprintf(player,"%s: Purifier ready.",Get_Player_Name(obj));
+				char player[250]; sprintf(player,"%s: Exterminate the weak.",Get_Player_Name(obj));
 				Send_Message_Team(0,255,0,0,player);
 			}
 			else if (rnd == 3)
 			{
 				Create_2D_WAV_Sound_Team("purchase_nod_blackhand_flame_3.wav",0);
-				char player[250]; sprintf(player,"%s: The flame shall purify.",Get_Player_Name(obj));
+				char player[250]; sprintf(player,"%s: They cannot hide from the Black Hand.",Get_Player_Name(obj));
 				Send_Message_Team(0,255,0,0,player);
 			}
 			else if (rnd == 4)
@@ -1080,6 +1083,30 @@
 			Commands->Start_Timer(obj,this,1.0f,1006);
 		}
 	}
+	else if (number == 1007)//used for zonetrooper repair powerpacks
+	{
+		commandonewpos = Commands->Get_Position(obj);
+		float commandotraveldistance = Commands->Get_Distance(commandocurrpos,commandonewpos);
+		if (commandotraveldistance <= 0.1f)	// not moved...
+		{
+			if ( (strcmp(Commands->Get_Preset_Name(obj),"TCW_GDI_Zonetrooper") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"TCW_GDI_Zonetrooper_Low") == 0) && (Commands->Get_Player_Type(obj) == 1))
+			{
+				float maxhp = Commands->Get_Max_Health(obj);
+				float maxap = Commands->Get_Max_Shield_Strength(obj);
+				float curhp = Commands->Get_Health(obj);
+				float curap = Commands->Get_Shield_Strength(obj);
+				if (curhp < maxhp)
+				{
+					Commands->Set_Health(obj,curhp+5.0f);
+				}
+				if (curap < maxap)
+				{
+					Commands->Set_Health(obj,curap+5.0f);
+				}
+				Commands->Start_Timer(obj,this,3.0f,1007);
+			}
+		}
+	}
 }
 void tcw_Grant_Powerup_Created::Killed(GameObject *obj, GameObject *shooter)
 {
@@ -1157,6 +1184,35 @@
 	{ 
 		if (param == 1)
 		{
+			if (strcmp(Commands->Get_Preset_Name(sender),"TCW_GDI_Command_Post") == 0)
+			{
+				if (Commands->Get_Player_Type(obj) == 0)//only check nod units when the command post checks
+				{
+					if (!revealed)
+					{
+						Commands->Enable_Stealth(obj, false);
+						Commands->Start_Timer(obj,this,2.0f,1004);//enable stealh again
+						if (playdetected)
+						{
+							if (Commands->Get_Player_Type(obj) == 0)
+							{
+								Create_2D_WAV_Sound_Team("stealth_unit_detected_gdi.wav",1);
+								Send_Message_Team(1,255,204,0,"Stealth unit detected.");
+							}
+							else if (Commands->Get_Player_Type(obj) == 1)
+							{
+								Create_2D_WAV_Sound_Team("stealth_unit_detected_nod.wav",0);
+								Send_Message_Team(0,255,0,0,"Stealth unit detected.");
+							}
+							playdetected = false;
+							Commands->Start_Timer(obj,this,10.0f,1005);//playdetected true
+						}	
+						revealed = true;
+					}
+				}
+			}
+			else
+			{
 			if (Commands->Get_Player_Type(sender) != Commands->Get_Player_Type(obj))
 			{
 				Vector3 mypos = Commands->Get_Position(obj);
@@ -1190,6 +1246,7 @@
 			}
 		}
 	}
+	}
 	else if (message == 1005)//Tech Composit Armor Upgrade complete
 	{
 		if (param == 1)
@@ -1206,6 +1263,15 @@
 			Send_Message_Player(obj,255,204,0,"Unit Upgraded: Composite Armor.");
 		}
 	}
+	else if (message == 1006)//Tech Powerpacks Upgrade complete
+	{
+		if (param == 1)
+		{
+			Commands->Start_Timer(obj,this,1.0f,1007);//start regeneration if not moved
+			Create_2D_WAV_Sound_Player(obj,"gdi_tech_unit_upgraded.wav");
+			Send_Message_Player(obj,255,204,0,"Unit Upgraded: Power Packs.");
+		}
+	}
 }
 void tcw_Grant_Powerup_Created::Register_Auto_Save_Variables()
 {
@@ -1222,11 +1288,4 @@
 	Auto_Save_Variable(&map_coop_nod,sizeof(map_coop_nod),11);
 }
 
-void tcw_I_Have_Ion_Cannon_Beacon::Destroyed(GameObject *obj)
-{
-	Commands->Send_Custom_Event(obj,Find_Object_With_Script("tcw_Buy_Beacon_Ion"),100101,1,0);
-}
-
-
-ScriptRegistrant<tcw_I_Have_Ion_Cannon_Beacon> tcw_I_Have_Ion_Cannon_Beacon_Registrant("tcw_I_Have_Ion_Cannon_Beacon","");
 ScriptRegistrant<tcw_Grant_Powerup_Created> tcw_Grant_Powerup_Created_Registrant("tcw_Grant_Powerup_Created","Weapon1=TCW_POW_Knife:string,Weapon2=0:string,Weapon3=0:string,Weapon4=0:string,Weapon5=0:string");
\ No newline at end of file
diff -uwr sourceold/scripts/tcw_player.h source/scripts/tcw_player.h
--- sourceold/scripts/tcw_player.h	2012-02-02 09:44:43.163085900 +0800
+++ source/scripts/tcw_player.h	2012-06-09 08:11:12.169921800 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -24,6 +24,7 @@
 	bool revealed;
 	bool playdetected;
 	bool upgrade_composit_armor_available;
+	bool upgrade_powerpacks_available;
 	bool map_low_grav;
 	bool map_dm_tech1;
 	bool map_dm_tech2;
@@ -33,7 +34,3 @@
 	Vector3 commandocurrpos;
 	Vector3 commandonewpos;
 };
-
-class tcw_I_Have_Ion_Cannon_Beacon : public ScriptImpClass {
-	void Destroyed(GameObject *obj);
-};
\ No newline at end of file
diff -uwr sourceold/scripts/tcw_powerup.cpp source/scripts/tcw_powerup.cpp
--- sourceold/scripts/tcw_powerup.cpp	2012-02-02 09:44:43.112304600 +0800
+++ source/scripts/tcw_powerup.cpp	2012-06-09 08:11:12.222656200 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -18,7 +18,7 @@
 
 void tcw_POW_PickupSounds::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		if (strstr(Commands->Get_Preset_Name(obj),"TCW_POW_RemoteC4"))
 		{
diff -uwr sourceold/scripts/tcw_powerup.h source/scripts/tcw_powerup.h
--- sourceold/scripts/tcw_powerup.h	2012-02-02 09:44:43.167968700 +0800
+++ source/scripts/tcw_powerup.h	2012-06-09 08:11:12.355468700 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
Only in source/scripts: tcw_raid_at_dawn.cpp
Only in source/scripts: tcw_raid_at_dawn.h
diff -uwr sourceold/scripts/tcw_superweapons.cpp source/scripts/tcw_superweapons.cpp
--- sourceold/scripts/tcw_superweapons.cpp	2012-02-02 09:44:43.160156200 +0800
+++ source/scripts/tcw_superweapons.cpp	2012-06-09 08:11:12.347656200 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -80,7 +80,7 @@
 			}
 			else
 			{
-				if (Is_Building_Dead(Find_Building_By_Name(1,"TCW_GDI_Ion_Center")))
+				if (Is_Building_Dead(Find_Building_By_Preset(1,"TCW_GDI_Ion_Center")))
 				{
 					Send_Message_Player(poker,255,255,255,"Your Ion Cannon Center is destroyed. The Ion Cannon is unavailable.");
 				}
@@ -213,7 +213,7 @@
 			}
 			else 
 			{
-				if (Is_Building_Dead(Find_Building_By_Name(1,"TCW_Temple_of_Nod")))
+				if (Is_Building_Dead(Find_Building_By_Preset(1,"TCW_Temple_of_Nod")))
 				{
 					Send_Message_Player(poker,255,255,255,"Your Temple of Nod is destroyed. The Nuclear Missile is unavailable.");
 				}
@@ -276,9 +276,9 @@
 			GameObject *nukefire = Commands->Create_Object("TCW_Nuclear_Missile_Launch",launchpos);
 			launchnuke = Commands->Get_ID(nukefire);
 			Commands->Set_Facing(nukefire,facing);
-			Commands->Set_Animation(nukefire,"V_MISSLE_FIRE.V_MISSLE_FIRE",false,0,0,39,false);//fire missile animation starts
+			Commands->Set_Animation(nukefire,"V_MISSLE_FIRE.V_MISSLE_FIRE",false,0,0,184,false);//fire missile animation starts
 			Commands->Destroy_Object(Commands->Find_Object(launchready));//remove the nuke idle animation
-			Commands->Start_Timer(obj,this,5.0f,100100);//remove nuke fire thingy
+			Commands->Start_Timer(obj,this,10.0f,100100);//remove nuke fire thingy	
 		}
 		else if (param == 1)
 		{
@@ -320,29 +320,6 @@
 	Auto_Save_Variable(&launchnuke,sizeof(launchnuke),2);
 }
 
-void tcw_nuke_ready::Created(GameObject *obj)
-{
-	//
-}
-void tcw_nuke_ready::Custom(GameObject *obj, int message, int param, GameObject *sender)
-{
-	if (message == 1000)
-	{
-		if (param == 1)//launch the nuke and remove the idle animation
-		{
-			//
-		}
-	}
-}
-
-void tcw_nuke_launch::Created(GameObject *obj)
-{
-	//
-}
-
-ScriptRegistrant<tcw_nuke_ready> tcw_nuke_ready_Registrant("tcw_nuke_ready","");
-ScriptRegistrant<tcw_nuke_launch> tcw_nuke_launch_Registrant("tcw_nuke_launch","");
-
 ScriptRegistrant<tcw_nod_nuke_building> tcw_nod_nuke_building_Registrant("tcw_nod_nuke_building","");
 ScriptRegistrant<tcw_pt_nuke> tcw_pt_nuke_Registrant("tcw_pt_nuke","");
 ScriptRegistrant<tcw_i_have_nuke_beacon> tcw_i_have_nuke_beacon_Registrant("tcw_i_have_nuke_beacon","");
diff -uwr sourceold/scripts/tcw_superweapons.h source/scripts/tcw_superweapons.h
--- sourceold/scripts/tcw_superweapons.h	2012-02-02 09:44:43.178710900 +0800
+++ source/scripts/tcw_superweapons.h	2012-06-09 08:11:12.188476500 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -60,11 +60,3 @@
 int launchnuke;
 };
 
-class tcw_nuke_ready : public ScriptImpClass {
-	void Created(GameObject *obj);
-	void Custom(GameObject *obj, int message, int param, GameObject *sender);
-};
-
-class tcw_nuke_launch : public ScriptImpClass {
-	void Created(GameObject *obj);
-};
\ No newline at end of file
diff -uwr sourceold/scripts/tcw_technology.cpp source/scripts/tcw_technology.cpp
--- sourceold/scripts/tcw_technology.cpp	2012-02-02 09:44:43.147460900 +0800
+++ source/scripts/tcw_technology.cpp	2012-06-09 08:11:12.150390600 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -31,7 +31,7 @@
 	{
 		if (Commands->Get_Player_Type(poker) == 1)
 		{
-			if (!Is_Building_Dead(Find_Building_By_Name(1,"TCW_GDI_Armory_Building")))
+			if (!Is_Building_Dead(Find_Building_By_Preset(1,"TCW_GDI_Armory_Building")))
 			{
 				if (!researching_composit_armor_upgrade)
 				{
@@ -87,7 +87,7 @@
 {
 	if (number == 10001)
 	{
-		if (!Is_Building_Dead(Find_Building_By_Name(1,"TCW_GDI_Armory_Building")))
+		if (!Is_Building_Dead(Find_Building_By_Preset(1,"TCW_GDI_Armory_Building")))
 		{
 			Vector3 pos; pos.Z = 999.0f; pos.Y = 999.0f; pos.X = 999.0f;
 			GameObject *compositarmor = Commands->Create_Object("TCW_Tech_Composit_Armor_Available",pos);
@@ -164,7 +164,7 @@
 
 void tcw_steal_tech_zone_gwf::Entered(GameObject *obj, GameObject *enter)
 {
-	if (!Is_Building_Dead(Find_Building_By_Name(1,"TCW_GDI_War_Factory")))
+	if (!Is_Building_Dead(Find_Building_By_Preset(1,"TCW_GDI_War_Factory")))
 	{
 		if ( (Commands->Is_A_Star(enter)) && (Commands->Get_Player_Type(enter) == 0) )
 		{
@@ -193,7 +193,7 @@
 
 void tcw_steal_tech_zone_nwf::Entered(GameObject *obj, GameObject *enter)
 {
-	if (!Is_Building_Dead(Find_Building_By_Name(0,"TCW_Nod_War_Factory")))
+	if (!Is_Building_Dead(Find_Building_By_Preset(0,"TCW_Nod_War_Factory")))
 	{
 		if ( (Commands->Is_A_Star(enter)) && (Commands->Get_Player_Type(enter) == 1) )
 		{
@@ -222,7 +222,7 @@
 
 void tcw_steal_tech_zone_nhon::Entered(GameObject *obj, GameObject *enter)
 {
-	if (!Is_Building_Dead(Find_Building_By_Name(0,"TCW_Hand_Of_Nod")))
+	if (!Is_Building_Dead(Find_Building_By_Preset(0,"TCW_Hand_Of_Nod")))
 	{
 		if ( (Commands->Is_A_Star(enter)) && (Commands->Get_Player_Type(enter) == 1) )
 		{
@@ -251,7 +251,7 @@
 
 void tcw_steal_tech_zone_gbar::Entered(GameObject *obj, GameObject *enter)
 {
-	if (!Is_Building_Dead(Find_Building_By_Name(1,"TCW_GDI_Barracks")))
+	if (!Is_Building_Dead(Find_Building_By_Preset(1,"TCW_GDI_Barracks")))
 	{
 		if ( (Commands->Is_A_Star(enter)) && (Commands->Get_Player_Type(enter) == 0) )
 		{
@@ -320,7 +320,7 @@
 {
 	if (number == 779901)//nod stole tech from gdi wf
 	{
-		if (!Is_Building_Dead(Find_Building_By_Name(1,"TCW_GDI_War_Factory")))
+		if (!Is_Building_Dead(Find_Building_By_Preset(1,"TCW_GDI_War_Factory")))
 		{
 			if (Get_Total_Bullets(obj,"TCW_Weapon_Repairgun_Advanced") == 5)//full repairgun = successful stealing
 			{
@@ -348,7 +348,7 @@
 	}
 	else if (number == 779902)//gdi stole tech from nod wf
 	{
-		if (!Is_Building_Dead(Find_Building_By_Name(0,"TCW_Nod_War_Factory")))
+		if (!Is_Building_Dead(Find_Building_By_Preset(0,"TCW_Nod_War_Factory")))
 		{
 			if (Get_Total_Bullets(obj,"TCW_Weapon_Repairgun_Advanced") == 5)//full repairgun = successful stealing
 			{
@@ -377,7 +377,7 @@
 	}
 	else if (number == 779903)//gdi stole tech from nod hand
 	{
-		if (!Is_Building_Dead(Find_Building_By_Name(0,"TCW_Hand_Of_Nod")))
+		if (!Is_Building_Dead(Find_Building_By_Preset(0,"TCW_Hand_Of_Nod")))
 		{
 			if (Get_Total_Bullets(obj,"TCW_Weapon_Repairgun_Advanced") == 5)//full repairgun = successful stealing
 			{
@@ -406,7 +406,7 @@
 	}
 	else if (number == 779904)//nod stole tech from gdi barracks
 	{
-		if (!Is_Building_Dead(Find_Building_By_Name(1,"TCW_GDI_Barracks")))
+		if (!Is_Building_Dead(Find_Building_By_Preset(1,"TCW_GDI_Barracks")))
 		{
 			if (Get_Total_Bullets(obj,"TCW_Weapon_Repairgun_Advanced") == 5)//full repairgun = successful stealing
 			{
@@ -436,7 +436,111 @@
 	}
 }
 
+void tcw_Research_Powerpacks::Created(GameObject *obj)
+{
+	Commands->Enable_HUD_Pokable_Indicator(obj, true);
+	allowpokegdi = true;
+	researching_powerpacks_upgrade = false;
+	researched_powerpacks_upgrade = false;
+	research_powerpacks_cost = 2000.0f;
+	research_powerpacks_fund = 0.0f;
+}
+void tcw_Research_Powerpacks::Poked(GameObject *obj, GameObject *poker)
+{
+	if (allowpokegdi)
+	{
+		if (Commands->Get_Player_Type(poker) == 1)
+		{
+			if (!Is_Building_Dead(Find_Building_By_Preset(1,"TCW_GDI_Armory_Building")))
+			{
+				if (!researching_powerpacks_upgrade)
+				{
+					if (!researched_powerpacks_upgrade)
+					{
+						if (research_powerpacks_fund < 2000.0f)
+						{
+							if (Commands->Get_Money(poker) >= 250.0f)
+							{
+								research_powerpacks_fund += 250.0f;
+								Commands->Give_Money(poker,-250.0f,false);
+								char addedfunds[250];
+								sprintf(addedfunds,"%s added $250 to the Power Packs Upgrade. Current Funds: %g/%g",Get_Player_Name(poker),research_powerpacks_fund,research_powerpacks_cost);
+								Send_Message_Team(1,255,204,0,addedfunds);
+								
+								if (research_powerpacks_fund == 2000.0f)
+								{
+									researching_powerpacks_upgrade = true;
+									Commands->Start_Timer(obj,this,60.0f,10001);
+									Create_2D_WAV_Sound_Team("gdi_tech_upgrade_in_progress.wav",1);
+									Send_Message_Team(1,255,204,0,"Upgrade in progress: Power Packs.");
+									allowpokegdi = false;
+								}
+							}
+							else
+							{
+								Send_Message_Player(poker,255,204,0,"Insufficient funds.");
+								Create_2D_WAV_Sound_Player(poker,"gdi_insufficient_funds.wav");
+							}
+						}
+					}
+					else
+					{
+						Create_2D_WAV_Sound_Player(poker,"incmsg.wav");
+						Send_Message_Player(poker,255,204,0,"Upgrade already performed.");						
+					}
+				}
+				else
+				{
+					Create_2D_WAV_Sound_Player(poker,"gdi_tech_upgrade_in_progress.wav");
+					Send_Message_Player(poker,255,204,0,"Upgrade in progress.");
+				}
+			}
+			else
+			{
+				Create_2D_WAV_Sound_Player(poker,"incmsg.wav");
+				Send_Message_Player(poker,255,204,0,"Sorry, your Armory structure has been destroyed.");
+			}
+		}
+	}
+}
+void tcw_Research_Powerpacks::Timer_Expired(GameObject *obj, int number)
+{
+	if (number == 10001)
+	{
+		if (!Is_Building_Dead(Find_Building_By_Preset(1,"TCW_GDI_Armory_Building")))
+		{
+			Vector3 pos; pos.Z = 999.0f; pos.Y = 999.0f; pos.X = 999.0f;
+			GameObject *powerpacks = Commands->Create_Object("TCW_Tech_Power_Packs_Available",pos);
+			Commands->Set_Facing(powerpacks,0.0f);
+			Send_Message_Team(1,255,204,0,"Upgrade Complete: Power Packs.");
+			Create_2D_WAV_Sound_Team("gdi_tech_upgrade_complete.wav",1);
+			researched_powerpacks_upgrade = true;
+			researching_powerpacks_upgrade = false;
+			Commands->Enable_HUD_Pokable_Indicator(obj, false);
+			Send_Custom_Event_To_Object(obj,"TCW_GDI_Zonetrooper",1006,1,2);
+			Send_Custom_Event_To_Object(obj,"TCW_GDI_Zonetrooper_Low",1006,1,2);
+		}
+		else
+		{
+			Send_Message_Team(1,255,204,0,"Upgrading of Power Packs has failed. Structure lost.");
+			Create_2D_WAV_Sound_Team("incmsg.wav",1);
+		}
+	}
+	else if (number == 10002)
+	{
+		allowpokegdi = true;
+	}
+}
+void tcw_Research_Powerpacks::Register_Auto_Save_Variables()
+{
+	Auto_Save_Variable(&researched_powerpacks_upgrade,sizeof(researched_powerpacks_upgrade),1);
+	Auto_Save_Variable(&research_powerpacks_cost,sizeof(research_powerpacks_cost),2);
+	Auto_Save_Variable(&research_powerpacks_fund,sizeof(research_powerpacks_fund),3);
+	Auto_Save_Variable(&researching_powerpacks_upgrade,sizeof(researching_powerpacks_upgrade),4);	
+	Auto_Save_Variable(&allowpokegdi,sizeof(allowpokegdi),5);
+}
 
+ScriptRegistrant<tcw_Research_Powerpacks> tcw_Research_Powerpacks_Registrant("tcw_Research_Powerpacks","");
 ScriptRegistrant<tcw_steal_tech_zone_gbar> tcw_steal_tech_zone_gbar_Registrant("tcw_steal_tech_zone_gbar","");
 ScriptRegistrant<tcw_steal_tech_zone_nhon> tcw_steal_tech_zone_nhon_Registrant("tcw_steal_tech_zone_nhon","");
 ScriptRegistrant<tcw_steal_tech_zone_nwf> tcw_steal_tech_zone_nwf_Registrant("tcw_steal_tech_zone_nwf","");
diff -uwr sourceold/scripts/tcw_technology.h source/scripts/tcw_technology.h
--- sourceold/scripts/tcw_technology.h	2012-02-02 09:44:43.172851500 +0800
+++ source/scripts/tcw_technology.h	2012-06-09 08:11:12.371093700 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -29,7 +29,6 @@
 	void Created(GameObject *obj);
 };
 
-
 class tcw_steal_tech_zone_gwf : public ScriptImpClass {
 	void Entered(GameObject *obj, GameObject *enter);
 	void Exited(GameObject *obj, GameObject *exit);
@@ -54,3 +53,15 @@
 	void Created(GameObject *obj);
 	void Timer_Expired(GameObject *obj, int number);
 };
\ No newline at end of file
+
+class tcw_Research_Powerpacks : public ScriptImpClass {
+	void Created(GameObject *obj);
+	void Poked(GameObject *obj, GameObject *poker);
+	public: void Register_Auto_Save_Variables();
+	void Timer_Expired(GameObject *obj, int number);
+	bool allowpokegdi;
+	bool researched_powerpacks_upgrade;
+	bool researching_powerpacks_upgrade;
+	float research_powerpacks_cost;
+	float research_powerpacks_fund;
+};
\ No newline at end of file
Only in source/scripts: tcw_tiberium.cpp
Only in source/scripts: tcw_tiberium.h
diff -uwr sourceold/scripts/tcw_vehicle.cpp source/scripts/tcw_vehicle.cpp
--- sourceold/scripts/tcw_vehicle.cpp	2012-02-02 09:44:43.121093700 +0800
+++ source/scripts/tcw_vehicle.cpp	2012-06-09 08:11:12.133789000 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -446,8 +446,8 @@
 {
 	if (message == CUSTOM_EVENT_VEHICLE_ENTERED)
 	{
-		if ( (strcmp(Commands->Get_Preset_Name(sender),"TCW_GDI_Commando") == 0) || (strcmp(Commands->Get_Preset_Name(sender),"TCW_GDI_Commando_Low") == 0) || 
-			 (strcmp(Commands->Get_Preset_Name(sender),"TCW_Nod_Commando") == 0) || (strcmp(Commands->Get_Preset_Name(sender),"TCW_Nod_Commando_Low") == 0) )
+		if ( (strcmp(Commands->Get_Preset_Name(Get_Vehicle_Driver(obj)),"TCW_GDI_Commando") == 0) || (strcmp(Commands->Get_Preset_Name(Get_Vehicle_Driver(obj)),"TCW_GDI_Commando_Low") == 0) || 
+			 (strcmp(Commands->Get_Preset_Name(Get_Vehicle_Driver(obj)),"TCW_Nod_Commando") == 0) || (strcmp(Commands->Get_Preset_Name(Get_Vehicle_Driver(obj)),"TCW_Nod_Commando_Low") == 0) )
 		{
 			Commands->Start_Timer(obj,this,0.5f,100100);
 		}
@@ -458,6 +458,11 @@
 		}
 		else if ( (strcmp(Commands->Get_Preset_Name(obj),"TCW_GDI_APC") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"TCW_Nod_APC") == 0) )
 		{
+			if (Get_Vehicle_Occupant_Count(obj) == 2)
+			{
+				Create_2D_WAV_Sound_Player(Get_Vehicle_Driver(obj),"apc_full.wav");
+				Create_2D_WAV_Sound_Player(Get_Vehicle_Occupant(obj,1),"apc_full.wav");
+			}
 			if (Get_Vehicle_Occupant(obj,1))//if there is a passenger
 			{
 				if ( (strcmp(Commands->Get_Preset_Name(Get_Vehicle_Occupant(obj,1)),"TCW_GDI_Missile_Squad") == 0) || (strcmp(Commands->Get_Preset_Name(Get_Vehicle_Occupant(obj,1)),"TCW_Nod_RocketGuy") == 0) || (strcmp(Commands->Get_Preset_Name(Get_Vehicle_Occupant(obj,1)),"TCW_Nod_RocketGuy_Low") == 0) || (strcmp(Commands->Get_Preset_Name(Get_Vehicle_Occupant(obj,1)),"TCW_GDI_Missile_Squad_Low") == 0) )
@@ -477,6 +482,17 @@
 				}
 			}
 		}
+		else if ( (strcmp(Commands->Get_Preset_Name(obj),"TCW_GDI_Chinook") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"TCW_Nod_Chinook") == 0) )
+		{
+			if (Get_Vehicle_Occupant_Count(obj) == 5)
+			{
+				Create_2D_WAV_Sound_Player(Get_Vehicle_Driver(obj),"apc_full.wav");
+				Create_2D_WAV_Sound_Player(Get_Vehicle_Occupant(obj,1),"apc_full.wav");
+				Create_2D_WAV_Sound_Player(Get_Vehicle_Occupant(obj,2),"apc_full.wav");
+				Create_2D_WAV_Sound_Player(Get_Vehicle_Occupant(obj,3),"apc_full.wav");
+				Create_2D_WAV_Sound_Player(Get_Vehicle_Occupant(obj,4),"apc_full.wav");
+			}
+		}
 	}
 	else if (message == CUSTOM_EVENT_VEHICLE_EXITED)
 	{
@@ -504,6 +520,32 @@
 	{ 
 		if (param == 1)
 		{
+			if (strcmp(Commands->Get_Preset_Name(sender),"TCW_GDI_Command_Post") == 0)
+			{
+				if (!revealed)
+				{
+					Commands->Enable_Stealth(obj, false);
+					Commands->Start_Timer(obj,this,2.0f,1005);//enable stealh again
+					if (playdetected)
+					{
+						if (Commands->Get_Player_Type(obj) == 0)
+						{
+							Create_2D_WAV_Sound_Team("stealth_unit_detected_gdi.wav",1);
+							Send_Message_Team(1,255,204,0,"Stealth unit detected.");
+						}
+						else if (Commands->Get_Player_Type(obj) == 1)
+						{
+							Create_2D_WAV_Sound_Team("stealth_unit_detected_nod.wav",0);
+							Send_Message_Team(0,255,0,0,"Stealth unit detected.");
+						}
+						playdetected = false;
+						Commands->Start_Timer(obj,this,10.0f,1006);//playdetected true
+					}	
+					revealed = true;
+				}
+			}
+			else
+			{
 			if (Commands->Get_Player_Type(obj) != Commands->Get_Player_Type(sender))
 			{
 				Vector3 mypos = Commands->Get_Position(obj);
@@ -535,6 +577,7 @@
 					}
 				}
 			}
+			}
 		}
 	}
 }
diff -uwr sourceold/scripts/tcw_vehicle.h source/scripts/tcw_vehicle.h
--- sourceold/scripts/tcw_vehicle.h	2012-02-02 09:44:43.187500000 +0800
+++ source/scripts/tcw_vehicle.h	2012-06-09 08:11:12.201171800 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
diff -uwr sourceold/scripts/tcw_zone.cpp source/scripts/tcw_zone.cpp
--- sourceold/scripts/tcw_zone.cpp	2012-02-02 09:44:43.118164000 +0800
+++ source/scripts/tcw_zone.cpp	2012-06-09 08:11:12.308593700 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
@@ -29,7 +29,7 @@
 			if (Is_VTOL(enter))
 			{
 				GameObject *vobj = 0;
-				if (Is_Vehicle(enter))
+				if (enter && enter->As_VehicleGameObj())
 				{
 					vobj = Get_Vehicle(enter);
 				}
diff -uwr sourceold/scripts/tcw_zone.h source/scripts/tcw_zone.h
--- sourceold/scripts/tcw_zone.h	2012-02-02 09:44:43.158203100 +0800
+++ source/scripts/tcw_zone.h	2012-06-09 08:11:12.164062500 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Scripts by zunnie - http://www.tiberiumcrystalwar.com
+	Scripts from - http://www.tiberiumcrystalwar.com
 	Copyright 2011-2012 MPF
 
 	This file is part of the Renegade scripts.dll
diff -uwr sourceold/scripts/weaponmgr.h source/scripts/weaponmgr.h
--- sourceold/scripts/weaponmgr.h	2011-10-11 21:40:30.001953100 +0800
+++ source/scripts/weaponmgr.h	2012-05-06 16:37:05.435460900 +0800
@@ -29,6 +29,9 @@
 	virtual bool								Save( ChunkSaveClass &csave );
 	virtual bool								Load( ChunkLoadClass &cload );
 	virtual const PersistFactoryClass &	Get_Factory( void ) const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+#endif
 	DECLARE_EDITABLE( AmmoDefinitionClass, DefinitionClass );
 	bool operator == ( const AmmoDefinitionClass & vector) const { return false; }
 	bool operator != ( const AmmoDefinitionClass & vector) const	{ return true; }
@@ -101,6 +104,10 @@
 	virtual bool								Save( ChunkSaveClass &csave );
 	virtual bool								Load( ChunkLoadClass &cload );
 	virtual const PersistFactoryClass &	Get_Factory( void ) const;
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+	virtual void                        DumpPhys (FileClass &file);
+#endif
 	DECLARE_EDITABLE( WeaponDefinitionClass, DefinitionClass );
 	bool operator == ( const WeaponDefinitionClass & vector) const  { return false; }
 	bool operator != ( const WeaponDefinitionClass & vector) const  { return true; }
@@ -149,8 +156,12 @@
 
 class ExplosionDefinitionClass : public DefinitionClass {
 public:
+#ifdef DDBEDIT
+	virtual void                        Dump (FileClass &file);
+	virtual void                        DumpPhys (FileClass &file);
+#endif
 	DECLARE_EDITABLE(ExplosionDefinitionClass,DefinitionClass);
-	uint32 PhysDefID;
+	int PhysDefID;
 	uint32 SoundDefID;
 	float DamageRadius;
 	float DamageStrength;
diff -uwr sourceold/scripts/wwmath.cpp source/scripts/wwmath.cpp
--- sourceold/scripts/wwmath.cpp	2011-10-11 23:13:07.331054600 +0800
+++ source/scripts/wwmath.cpp	2012-04-14 04:09:46.957031200 +0800
@@ -12,10 +12,10 @@
 #include "General.h"
 #include "wwmath.h"
 #include <stdlib.h>
-SCRIPTS_API REF_ARR_DEF2(_FastAcosTable,float,ARC_TABLE_SIZE,0x00852FB0,0x00852198);
-SCRIPTS_API REF_ARR_DEF2(_FastAsinTable,float,ARC_TABLE_SIZE,0x00850FB0,0x00850198);
-SCRIPTS_API REF_ARR_DEF2(_FastSinTable,float,SIN_TABLE_SIZE,0x0084FFB0,0x0084F198);
-SCRIPTS_API REF_ARR_DEF2(_FastInvSinTable,float,SIN_TABLE_SIZE,0x00851FB0,0x00851198);
+SCRIPTS_API REF_ARR_DEF3(_FastAcosTable,float,ARC_TABLE_SIZE,0x00852FB0,0x00852198,0x0087145C);
+SCRIPTS_API REF_ARR_DEF3(_FastAsinTable,float,ARC_TABLE_SIZE,0x00850FB0,0x00850198,0x0086F45C);
+SCRIPTS_API REF_ARR_DEF3(_FastSinTable,float,SIN_TABLE_SIZE,0x0084FFB0,0x0084F198,0x0086E45C);
+SCRIPTS_API REF_ARR_DEF3(_FastInvSinTable,float,SIN_TABLE_SIZE,0x00851FB0,0x00851198,0x0087045C);
 void WWMath::Init(void)
 {
 	for (int a=0;a<ARC_TABLE_SIZE;++a) {
diff -uwr sourceold/scripts/wwmath.h source/scripts/wwmath.h
--- sourceold/scripts/wwmath.h	2011-11-22 14:49:49.161132800 +0800
+++ source/scripts/wwmath.h	2012-04-14 04:09:46.381835900 +0800
@@ -37,13 +37,11 @@
 #endif
 const int ARC_TABLE_SIZE=1024;
 const int SIN_TABLE_SIZE=1024;
-#ifndef TTLE_EXPORTS
 #ifndef EXTERNAL
-SCRIPTS_API extern REF_ARR_DECL2(_FastAcosTable,float,ARC_TABLE_SIZE);
-SCRIPTS_API extern REF_ARR_DECL2(_FastAsinTable,float,ARC_TABLE_SIZE);
-SCRIPTS_API extern REF_ARR_DECL2(_FastSinTable,float,SIN_TABLE_SIZE);
-SCRIPTS_API extern REF_ARR_DECL2(_FastInvSinTable,float,SIN_TABLE_SIZE);
-#endif
+SCRIPTS_API extern REF_ARR_DECL3(_FastAcosTable,float,ARC_TABLE_SIZE);
+SCRIPTS_API extern REF_ARR_DECL3(_FastAsinTable,float,ARC_TABLE_SIZE);
+SCRIPTS_API extern REF_ARR_DECL3(_FastSinTable,float,SIN_TABLE_SIZE);
+SCRIPTS_API extern REF_ARR_DECL3(_FastInvSinTable,float,SIN_TABLE_SIZE);
 #endif
 class SCRIPTS_API WWMath
 {
@@ -63,14 +61,12 @@
 	static TT_INLINE float Sqrt(float val);
 	static float __fastcall Inv_Sqrt(float a);
 	static TT_INLINE long	 Float_To_Long(float f);
-#ifndef TTLE_EXPORTS
 	static TT_INLINE float Fast_Sin(float val);
 	static TT_INLINE float Fast_Inv_Sin(float val);
 	static TT_INLINE float Fast_Cos(float val);
 	static TT_INLINE float Fast_Inv_Cos(float val);
 	static TT_INLINE float Fast_Acos(float val);
 	static TT_INLINE float Fast_Asin(float val);
-#endif
 	static TT_INLINE float Acos(float val);
 	static TT_INLINE float Asin(float val);
 	static float Atan(float x) { return static_cast<float>(atan(x)); }
@@ -252,7 +248,6 @@
 	return retval;
 }
 
-#ifndef TTLE_EXPORTS
 #ifndef EXTERNAL
 TT_INLINE float WWMath::Fast_Sin(float val)
 {
@@ -303,13 +298,11 @@
 	return (1.0f - frac) * _FastAcosTable[idx0] + frac * _FastAcosTable[idx1];
 }
 #endif
-#endif
 TT_INLINE float WWMath::Acos(float val)
 {
 	return (float)acos(val);
 }
 
-#ifndef TTLE_EXPORTS
 #ifndef EXTERNAL
 TT_INLINE float WWMath::Fast_Asin(float val)
 {
@@ -327,7 +320,6 @@
 	return (1.0f - frac) * _FastAsinTable[idx0] + frac * _FastAsinTable[idx1];
 }
 #endif
-#endif
 TT_INLINE float WWMath::Asin(float val)
 {
 	return (float)asin(val);
diff -uwr sourceold/scripts/z.cpp source/scripts/z.cpp
--- sourceold/scripts/z.cpp	2011-10-11 23:14:30.261718700 +0800
+++ source/scripts/z.cpp	2012-04-24 21:25:31.657226500 +0800
@@ -15,6 +15,10 @@
 #include "z.h"
 #include "BuildingGameObjDef.h"
 #include "VehicleGameObjDef.h"
+#include "ScriptableGameObj.h"
+#ifdef SSGM
+#include "gmgame.h"
+#endif
 
 
 void z_I_May_Not_Place_Defenses::Created(GameObject *obj)
@@ -422,7 +426,7 @@
 
 void z_Teleport_Powerup::Custom(GameObject *obj,int message,int param,GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Vector3 spawn_position;
 		spawn_position = Get_Vector3_Parameter("Location");
@@ -458,7 +462,7 @@
 
 void z_ChangeTeamPowerup::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		char pick[256];
 		char cht[200];
@@ -1071,7 +1075,7 @@
 void z_Pup_Allied_Tanya::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
 	int RandomNum = Commands->Get_Random_Int(1,3);
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		char snd[100];
 		Change_Character(sender,"Allied_Tanya");
@@ -1093,7 +1097,7 @@
 
 void z_Pup_Allied_RocketGuy::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"Allied_Rocket_Soldier");
 	}
@@ -1101,7 +1105,7 @@
 
 void z_Pup_Allied_Medic::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"Allied_Medic");
 	}
@@ -1109,7 +1113,7 @@
 
 void z_Pup_Allied_Medic_Coop::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"Allied_Medic_Coop");
 	}
@@ -1117,21 +1121,21 @@
 
 void z_Pup_Allied_Sniper::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"Allied_Sniper");
 	}
 }
 void z_Pup_Allied_Spy::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"Allied_Spy_Coop");
 	}
 }
 void z_Pup_Allied_Officer::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"Allied_Captain");
 	}
@@ -1139,7 +1143,7 @@
 
 void z_Pup_Allied_Mechanic::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"Allied_Mechanic");
 	}
@@ -1147,7 +1151,7 @@
 
 void z_Pup_Allied_Sniper_Coop::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"Allied_Sniper_Coop");
 	}
@@ -1908,7 +1912,7 @@
 
 void z_Pickup_Send_Custom::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Commands->Send_Custom_Event(obj,Commands->Find_Object(Get_Int_Parameter("ID")),Get_Int_Parameter("Message"),Get_Int_Parameter("Param"),Get_Float_Parameter("Delay"));
 	}
@@ -1991,12 +1995,16 @@
 	Vector3 pos2;
 	float distance;
 	GameObject *object = Commands->Find_Object(number);
+	if (!object)
+	{
+		return;
+	}
 	pos1 = Commands->Get_Position(obj);
 	pos2 = Commands->Get_Position(object);
 	distance = Commands->Get_Distance(pos1,pos2);
 	if (distance <= 10.0)
 	{
-		if (Is_Vehicle(object))
+		if (object->As_VehicleGameObj())
 		{
 			if (Get_Vehicle_Mode(object) == VEHICLE_TYPE_FLYING)
 			{
@@ -2025,12 +2033,16 @@
 	Vector3 pos2;
 	float distance;
 	GameObject *object = Commands->Find_Object(number);
+	if (!object)
+	{
+		return;
+	}
 	pos1 = Commands->Get_Position(obj);
 	pos2 = Commands->Get_Position(object);
 	distance = Commands->Get_Distance(pos1,pos2);
 	if (distance <= 10.0)
 	{
-		if (Is_Vehicle(object))
+		if (object->As_VehicleGameObj())
 		{
 			if (Get_Vehicle_Mode(object) == VEHICLE_TYPE_FLYING)
 			{
@@ -2404,13 +2416,13 @@
 						else
 						{
 							//new is a player(in tank),old is not
-							if (Is_Soldier(old))
+							if (old->As_SoldierGameObj())
 							{
 								//old is a soldier
 								//switch to new target,old not worth it
 								selected = target;
 							}
-							else if (Is_Vehicle(old))
+							else if (old->As_VehicleGameObj())
 							{
 								//old is a vehicle,new is a player in tank
 								//switch based on distance
@@ -2445,13 +2457,13 @@
 						else
 						{
 							//new is a player on foot,old is not a player
-							if (Is_Soldier(old))
+							if (old->As_SoldierGameObj())
 							{
 								//old is a soldier
 								//switch to new target,old not worth it
 								selected = target;
 							}
-							else if (Is_Vehicle(old))
+							else if (old->As_VehicleGameObj())
 							{
 								//old is a vehicle
 								//switch if old out of range and new is close
@@ -2473,13 +2485,13 @@
 					if (vehicle) //is the old in a vehicle?
 					{
 						//old in vehicle
-						if (Is_Soldier(target))
+						if (target->As_SoldierGameObj())
 						{
 							//new is a soldier,old is player in a tank
 							//Perhaps an out of range check here?
 							selected = 0; //keep old					
 						}
-						else if (Is_Vehicle(target))
+						else if (target->As_VehicleGameObj())
 						{
 							//new is a vehicle,old is player in a tank
 							//switch if new closer
@@ -2488,12 +2500,12 @@
 					}
 					else //old on foot
 					{
-						if (Is_Soldier(target))
+						if (target->As_SoldierGameObj())
 						{
 							//new is a soldier
 							selected = Get_Closest(obj,target,old);
 						}
-						else if (Is_Vehicle(target))
+						else if (target->As_VehicleGameObj())
 						{
 							//new is a vehicle,old just a player
 							selected = target;
@@ -2591,7 +2603,7 @@
 
 	if (target)//Just to be on the safe side
 	{
-		if (Is_Soldier(target)) //is the target a soldier?
+		if (target->As_SoldierGameObj()) //is the target a soldier?
 		{
 			if (Get_Int_Parameter("vsSoldier")) 
 				return true; //Use Primary
@@ -2599,7 +2611,7 @@
 				return false; //Use Secondary
 		}
 
-		if (Is_Vehicle(target))
+		if (target->As_VehicleGameObj())
 		{
 			if (Get_Vehicle_Mode(target) != VEHICLE_TYPE_FLYING)
 			{
@@ -2657,12 +2669,16 @@
 	Vector3 pos2;
 	float distance;
 	GameObject *object = Commands->Find_Object(number);
+	if (!object)
+	{
+		return;
+	}
 	pos1 = Commands->Get_Position(obj);
 	pos2 = Commands->Get_Position(object);
 	distance = Commands->Get_Distance(pos1,pos2);
 	if (distance <= 10.0)
 	{
-		if (Is_Vehicle(object))
+		if (object->As_VehicleGameObj())
 		{
 			if (Get_Vehicle_Mode(object) == VEHICLE_TYPE_FLYING)
 			{
@@ -2781,7 +2797,7 @@
 {
 	/* This code was moved to the ssgm.ini under [General] as "PlayPowerupSounds"
 
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		if (strstr(Commands->Get_Preset_Name(obj),"CnC_POW_MineRemote_02"))
 		{
@@ -3584,7 +3600,7 @@
 	{
 		return;
 	}
-	if ((Is_Vehicle(enterer)) && (Is_VTOL(enterer)))
+	if ((enterer->As_VehicleGameObj()) && (Is_VTOL(enterer)))
 	{
 		Commands->Start_Timer(obj,this,1.0,Commands->Get_ID(enterer));
 	}
diff -uwr sourceold/scripts/z.h source/scripts/z.h
--- sourceold/scripts/z.h	2011-10-14 22:27:32.097656200 +0800
+++ source/scripts/z.h	2012-04-14 04:09:46.828125000 +0800
@@ -599,12 +599,3 @@
 
 
 
-
-
-
-
-
-
-
-
-
Only in source/scripts: z_airraid.cpp
Only in source/scripts: z_airraid.h
diff -uwr sourceold/scripts/z_buildingrevive.cpp source/scripts/z_buildingrevive.cpp
--- sourceold/scripts/z_buildingrevive.cpp	2011-10-11 23:14:19.441406200 +0800
+++ source/scripts/z_buildingrevive.cpp	2012-04-28 02:04:08.709960900 +0800
@@ -58,11 +58,13 @@
 {
 	if (allowpoke)
 	{
-		if (Find_Building(1,BuildingConstants::TYPE_CONYARD))
+		if (Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD))
 		{
-			if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_CONYARD)))
+			if (!Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD)))
 			{
-				if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_SOLDIER_FACTORY)))
+				if (Find_Building_By_Type(1,BuildingConstants::TYPE_SOLDIER_FACTORY))
+				{
+					if (!Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_SOLDIER_FACTORY)))
 				{
 					//lolalive
 				}
@@ -79,7 +81,7 @@
 						currentamount = currentamount + pokecost;
 						if (currentamount == buildingcost)
 						{
-							GameObject *abar = Find_Building(1,BuildingConstants::TYPE_SOLDIER_FACTORY);
+								GameObject *abar = Find_Building_By_Type(1,BuildingConstants::TYPE_SOLDIER_FACTORY);
 							Restore_Building(abar);
 							Commands->Set_Health(abar,Commands->Get_Max_Health(obj));
 							Commands->Create_2D_WAV_Sound("eva_newconst.wav");
@@ -88,6 +90,7 @@
 					}
 				}
 			}
+			}
 			else
 			{
 				Send_Message_Player(poker,255,255,255,"Access Denied. Your Construction Yard is dead.");
@@ -122,59 +125,86 @@
 	int team = Get_Int_Parameter("Team");
 	if (type == 1)
 	{
-		GameObject *bing = Find_Building(team,BuildingConstants::TYPE_BASE_DEFENSE);
+		GameObject *bing = Find_Building_By_Type(team,BuildingConstants::TYPE_BASE_DEFENSE);
+		if (bing)
+		{
 		Restore_Building(bing);
 		Commands->Set_Health(bing,Commands->Get_Max_Health(obj));
 	}
+	}
 	else if (type == 2)
 	{
-		GameObject *bing = Find_Building(team,BuildingConstants::TYPE_COM_CENTER);
+		GameObject *bing = Find_Building_By_Type(team,BuildingConstants::TYPE_COM_CENTER);
+		if (bing)
+		{
 		Restore_Building(bing);
 		Commands->Set_Health(bing,Commands->Get_Max_Health(obj));
 	}
+	}
 	else if (type == 3)
 	{
-		GameObject *bing = Find_Building(team,BuildingConstants::TYPE_CONYARD);
+		GameObject *bing = Find_Building_By_Type(team,BuildingConstants::TYPE_CONYARD);
+		if (bing)
+		{
 		Restore_Building(bing);
 		Commands->Set_Health(bing,Commands->Get_Max_Health(obj));
 	}
+	}
 	else if (type == 4)
 	{
-		GameObject *bing = Find_Building(team,BuildingConstants::TYPE_HELIPAD);
+		GameObject *bing = Find_Building_By_Type(team,BuildingConstants::TYPE_HELIPAD);
+		if (bing)
+		{
 		Restore_Building(bing);
 		Commands->Set_Health(bing,Commands->Get_Max_Health(obj));
 	}
+	}
 	else if (type == 5)
 	{
-		GameObject *bing = Find_Building(team,BuildingConstants::TYPE_POWER_PLANT);
+		GameObject *bing = Find_Building_By_Type(team,BuildingConstants::TYPE_POWER_PLANT);
+		if (bing)
+		{
 		Restore_Building(bing);
 		Commands->Set_Health(bing,Commands->Get_Max_Health(obj));
 	}
+	}
 	else if (type == 6)
 	{
-		GameObject *bing = Find_Building(team,BuildingConstants::TYPE_REFINERY);
+		GameObject *bing = Find_Building_By_Type(team,BuildingConstants::TYPE_REFINERY);
+		if (bing)
+		{
 		Restore_Building(bing);
 		Commands->Set_Health(bing,Commands->Get_Max_Health(obj));
 	}
+	}
 	else if (type == 7)
 	{
-		GameObject *bing = Find_Building(team,BuildingConstants::TYPE_SOLDIER_FACTORY);
+		GameObject *bing = Find_Building_By_Type(team,BuildingConstants::TYPE_SOLDIER_FACTORY);
+		if (bing)
+		{
 		Restore_Building(bing);
 		Commands->Set_Health(bing,Commands->Get_Max_Health(obj));
 	}
+	}
 	else if (type == 8)
 	{
-		GameObject *bing = Find_Building(team,BuildingConstants::TYPE_VEHICLE_FACTORY);
+		GameObject *bing = Find_Building_By_Type(team,BuildingConstants::TYPE_VEHICLE_FACTORY);
+		if (bing)
+		{
 		Restore_Building(bing);
 		Commands->Set_Health(bing,Commands->Get_Max_Health(obj));
 	}
+	}
 	else if (type == 9)
 	{
-		GameObject *bing = Find_Building_By_Name(team,Get_Parameter("BuildingPreset"));
+		GameObject *bing = Find_Building_By_Preset(team,Get_Parameter("BuildingPreset"));
+		if (bing)
+		{
 		Restore_Building(bing);
 		Commands->Set_Health(bing,Commands->Get_Max_Health(obj));
 	}
 }
+}
 
 
 ScriptRegistrant<z_Poke_Restore_Building> z_Poke_Restore_Building_Registrant("z_Poke_Restore_Building","Team=1:int,Type=1:int,BuildingPreset=bla:string");
diff -uwr sourceold/scripts/z_cargo.cpp source/scripts/z_cargo.cpp
--- sourceold/scripts/z_cargo.cpp	2011-10-11 23:14:17.298828100 +0800
+++ source/scripts/z_cargo.cpp	2012-04-15 15:10:53.384156300 +0800
@@ -19,7 +19,7 @@
 
 void z_Pup_Soviet_Shocky::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"Soviet_Shock_Trooper");
 	}
@@ -27,7 +27,7 @@
 
 void z_Pup_Soviet_Officer::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"Soviet_Rifle_Infantry_Officer");
 	}
@@ -35,7 +35,7 @@
 
 void z_Pup_Soviet_Sniper::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"Soviet_Sniper_Coop");
 	}
@@ -43,7 +43,7 @@
 
 void z_Pup_Soviet_Flamer::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"Soviet_Flamethrower_Infantry");
 	}
@@ -51,7 +51,7 @@
 
 void z_Pup_Soviet_Volkov::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message == 1000000025)
+	if (message == CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Change_Character(sender,"Soviet_Volkov");
 	}
Only in source/scripts: z_center_point.cpp
Only in source/scripts: z_center_point.h
diff -uwr sourceold/scripts/z_coop.cpp source/scripts/z_coop.cpp
--- sourceold/scripts/z_coop.cpp	2011-10-11 23:14:11.353515600 +0800
+++ source/scripts/z_coop.cpp	2012-04-24 12:31:12.207031200 +0800
@@ -15,7 +15,7 @@
 #include "z_coop.h"
 #include "BuildingGameObjDef.h"
 #include "VehicleGameObjDef.h"
-
+#include "ScriptableGameObj.h"
 //Just having a script thats attached to all player type characters
 //in case i think of something that i want to do to players globally...
 
@@ -165,7 +165,7 @@
 {
 	if (!Commands->Is_A_Star(obj))
 	{
-		if (As_SoldierGameObj(obj))
+		if (obj->As_SoldierGameObj())
 		{
 			Attach_Script_Once(obj,"z_AI_Bot_Dropweapons","");
 		}
@@ -178,7 +178,7 @@
 	{
 		if (!Commands->Is_A_Star(obj))
 		{
-			if (As_SoldierGameObj(obj))
+			if (obj->As_SoldierGameObj())
 			{
 				Attach_Script_Once(obj,"z_AI_Bot_Dropweapons","");
 				Commands->Start_Timer(obj,this,45.0f,123454321);
diff -uwr sourceold/scripts/z_endgame.cpp source/scripts/z_endgame.cpp
--- sourceold/scripts/z_endgame.cpp	2011-10-11 23:14:13.342773400 +0800
+++ source/scripts/z_endgame.cpp	2012-04-28 01:57:41.618164000 +0800
@@ -123,7 +123,7 @@
 {
 	if (strcmp(Commands->Get_Preset_Name(enter),"CnC_Allied_Demolition_Truck") == 0)
 	{
-		if (Commands->Get_Health(Find_Building(1,BuildingConstants::TYPE_VEHICLE_FACTORY)) >= 1.0f)//only enable the extra tanks if wf is present and alive
+		if (Find_Building_By_Type(1,BuildingConstants::TYPE_VEHICLE_FACTORY) && Commands->Get_Health(Find_Building_By_Type(1,BuildingConstants::TYPE_VEHICLE_FACTORY)) >= 1.0f)//only enable the extra tanks if wf is present and alive
 		{
 			Commands->Enable_Spawner(100528,1);
 			Commands->Enable_Spawner(100529,1);
diff -uwr sourceold/scripts/z_joipa.cpp source/scripts/z_joipa.cpp
--- sourceold/scripts/z_joipa.cpp	2011-10-11 23:13:50.153320300 +0800
+++ source/scripts/z_joipa.cpp	2012-04-28 01:57:12.354492100 +0800
@@ -100,7 +100,7 @@
 	{
 		if (param == 1)
 		{
-			if (Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_CONYARD)))
+			if (Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD) && Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD)))
 			{
 				Commands->Start_Timer(obj,this,5.0f,100);
 				Commands->Start_Timer(obj,this,10.0f,101);
@@ -219,7 +219,7 @@
 	{
 		if (param == 1)
 		{
-			if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_CONYARD)))
+			if (Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD) && !Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD)))
 			{
 				Commands->Start_Timer(obj,this,5.0f,101);//building
 				Commands->Start_Timer(obj,this,36.0f,102);//update
@@ -237,7 +237,7 @@
 {
 	if (number == 101)
 	{
-		if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_CONYARD)))
+		if (Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD) && !Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD)))
 		{
 			Commands->Create_2D_WAV_Sound("building.wav");
 			Send_Message(255,255,255,"Building of the GDI Power Plant has commenced.");
@@ -250,7 +250,7 @@
 	}
 	else if (number == 102)
 	{
-		if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_CONYARD)))
+		if (Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD) && !Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD)))
 		{
 			Commands->Create_2D_WAV_Sound("updatecomplete.wav");
 			Send_Message(255,255,255,"Update on the GDI Power Plant has been completed.");
@@ -263,9 +263,11 @@
 	}
 	else if (number == 103)
 	{
-		if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_CONYARD)))
+		if (Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD) && !Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD)))
+		{
+			GameObject *pp = Find_Building_By_Type(1,BuildingConstants::TYPE_POWER_PLANT);
+			if (pp)
 		{
-			GameObject *pp = Find_Building(1,BuildingConstants::TYPE_POWER_PLANT);
 			Commands->Create_2D_WAV_Sound("gdipponline.wav");
 			Send_Message(255,255,255,"GDI Base Power is Online.");
 			Restore_Building(pp);
@@ -273,6 +275,7 @@
 			Power_Base(1,true);
 			Commands->Set_Building_Power(pp,true);
 		}
+		}
 		else
 		{
 			Commands->Create_2D_WAV_Sound("cancelled.wav");
@@ -287,7 +290,7 @@
 	{
 		if (param == 1)
 		{
-			if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_CONYARD)))
+			if (Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD) && !Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD)))
 			{
 				Commands->Start_Timer(obj,this,6.0f,101);//building
 				Commands->Start_Timer(obj,this,36.0f,102);//update
@@ -305,7 +308,7 @@
 {
 	if (number == 101)
 	{
-		if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_CONYARD)))
+		if (Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD) && !Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD)))
 		{
 			Commands->Create_2D_WAV_Sound("building.wav");
 			Send_Message(255,255,255,"Building of the GDI Weapons Factory has commenced.");
@@ -318,7 +321,7 @@
 	}
 	else if (number == 102)
 	{
-		if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_CONYARD)))
+		if (Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD) && !Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD)))
 		{
 			Commands->Create_2D_WAV_Sound("updatecomplete.wav");
 			Send_Message(255,255,255,"Update on the GDI Weapons Factory has been completed.");
@@ -331,9 +334,11 @@
 	}
 	else if (number == 103)
 	{
-		if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_CONYARD)))
+		if (Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD) && !Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD)))
+		{
+			GameObject *wf = Find_Building_By_Type(1,BuildingConstants::TYPE_VEHICLE_FACTORY);
+			if (wf)
 		{
-			GameObject *wf = Find_Building(1,BuildingConstants::TYPE_VEHICLE_FACTORY);
 			Commands->Create_2D_WAV_Sound("newconstroptions.wav");
 			Send_Message(255,255,255,"New construction options. GDI Weapons Factory is online.");
 			Restore_Building(wf);
@@ -348,6 +353,7 @@
 				Commands->Set_Building_Power(wf,false);
 			}
 		}
+		}
 		else
 		{
 			Commands->Create_2D_WAV_Sound("cancelled.wav");
@@ -362,7 +368,7 @@
 	{
 		if (param == 1)
 		{
-			if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_CONYARD)))
+			if (Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD) && !Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD)))
 			{
 				Commands->Start_Timer(obj,this,6.0f,101);//building
 				Commands->Start_Timer(obj,this,36.0f,102);//update
@@ -380,7 +386,7 @@
 {
 	if (number == 101)
 	{
-		if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_CONYARD)))
+		if (Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD) && !Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD)))
 		{
 			Commands->Create_2D_WAV_Sound("building.wav");
 			Send_Message(255,255,255,"Building of the GDI Tiberium Refinery has commenced.");
@@ -393,7 +399,7 @@
 	}
 	else if (number == 102)
 	{
-		if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_CONYARD)))
+		if (Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD) && !Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD)))
 		{
 			Commands->Create_2D_WAV_Sound("updatecomplete.wav");
 			Send_Message(255,255,255,"Update on the GDI Tiberium Refinery has been completed.");
@@ -406,9 +412,11 @@
 	}
 	else if (number == 103)
 	{
-		if (!Is_Building_Dead(Find_Building(1,BuildingConstants::TYPE_CONYARD)))
+		if (Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD) && !Is_Building_Dead(Find_Building_By_Type(1,BuildingConstants::TYPE_CONYARD)))
+		{
+			GameObject *refinery = Find_Building_By_Type(1,BuildingConstants::TYPE_REFINERY);
+			if (refinery)
 		{
-			GameObject *refinery = Find_Building(1,BuildingConstants::TYPE_REFINERY);
 			Commands->Create_2D_WAV_Sound("gdirefonline.wav");
 			Send_Message(255,255,255,"Primary pressing center operating at optimal efficiency. GDI Tiberium Refinery is online.");
 			Restore_Building(refinery);
@@ -422,6 +430,7 @@
 				Commands->Set_Building_Power(refinery,false);
 			}
 		}
+		}
 		else
 		{
 			Commands->Create_2D_WAV_Sound("cancelled.wav");
Only in source/scripts: z_mediterranean.cpp
Only in source/scripts: z_mediterranean.h
Only in source/scripts: z_misc.cpp
Only in source/scripts: z_misc.h
diff -uwr sourceold/scripts/z_nod_invasion.cpp source/scripts/z_nod_invasion.cpp
--- sourceold/scripts/z_nod_invasion.cpp	2011-10-11 23:14:27.805664000 +0800
+++ source/scripts/z_nod_invasion.cpp	2012-04-14 04:09:46.894531200 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Copyright 2011 Tiberian Technologies
+	Copyright 2012 UltraAOW.COM
 
 	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
@@ -9,714 +9,2639 @@
 	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 "General.h"
 #include "scripts.h"
-#include "engine_tt.h"
 #include "engine.h"
+#include "z_nod_invasion.h"
 #include "BuildingGameObjDef.h"
 #include "VehicleGameObjDef.h"
-#include "z_nod_invasion.h"
-#include "BaseControllerClass.h"
-#include "GameObjManager.h"
-//255,204,0 = gdi yellow
-
-
-void z_ninv_MissionStart::Created(GameObject *obj)
-{
-	play = false;
-	Commands->Start_Timer(obj,this,25.0f,101);
-	Commands->Start_Timer(obj,this,30.0f,102);
-	Commands->Start_Timer(obj,this,35.0f,103);
-	Commands->Start_Timer(obj,this,40.0f,104);
-	Commands->Start_Timer(obj,this,45.0f,105);
-	Commands->Start_Timer(obj,this,50.0f,106);
-	Commands->Start_Timer(obj,this,420.0f,107);//initialize mission timers, play=true
-}
-void z_ninv_MissionStart::Timer_Expired(GameObject *obj, int number)
-{
-	if (number == 101)
-	{
-		Send_Message(255,204,0,"Good afternoon Commanders");
-		Commands->Create_2D_WAV_Sound("incmsg.wav");
-	}
-	else if (number == 102)
-	{
-		Send_Message(255,204,0,"The Brotherhood of Nod is inbound!");
-		Commands->Create_2D_WAV_Sound("incmsg.wav");
-	}
-	else if (number == 103)
-	{
-		Send_Message(255,204,0,"We have exactly 7 minutes to protect our base by setting up defenses.");
-		Commands->Create_2D_WAV_Sound("incmsg.wav");
-	}
-	else if (number == 104)
-	{
-		Send_Message(255,204,0,"Protect the civilians at all cost!");
-		Commands->Create_2D_WAV_Sound("incmsg.wav");
-	}
-	else if (number == 105)
-	{
-		Send_Message(255,204,0,"Survive for 45 minutes, then we will send in reinforcements.");
-		Commands->Create_2D_WAV_Sound("incmsg.wav");
-	}
-	else if (number == 106)
-	{
-		Send_Message(255,204,0,"Good luck Commanders.");
-		Commands->Create_2D_WAV_Sound("incmsg.wav");
-	}
-
-	else if (number == 107)//init mission timers
-	{
-		play = true;
-		Send_Message(255,204,0,"Mission Timer Initializing: 45 minutes remaining.");
-		Commands->Create_2D_WAV_Sound("beep.wav");
-		Commands->Start_Timer(obj,this,2700.0f,201);//end all spawners + start endgame checks
-		Commands->Start_Timer(obj,this,2400.0f,202);//5 mins remaining
-		Commands->Start_Timer(obj,this,2100.0f,203);//10 mins remaining
-		Commands->Start_Timer(obj,this,1800.0f,204);//15 mins remaining
-		Commands->Start_Timer(obj,this,1500.0f,205);//20 mins remaining
-		Commands->Start_Timer(obj,this,1200.0f,206);//25 mins remaining
-		Commands->Start_Timer(obj,this,900.0f,207);//30 mins remaining
-		Commands->Start_Timer(obj,this,600.0f,208);//35 mins remaining
-		Commands->Start_Timer(obj,this,300.0f,209);//40 mins remaining
-		
-		//lol enable bots:
-		Commands->Enable_Spawner(100113,1);
-		Commands->Enable_Spawner(100119,1);
-		Commands->Enable_Spawner(100114,1);
-		Commands->Enable_Spawner(100115,1);
-		Commands->Enable_Spawner(100117,1);
-		Commands->Enable_Spawner(100123,1);
-		Commands->Enable_Spawner(100124,1);
-		Commands->Enable_Spawner(100125,1);
-		Commands->Enable_Spawner(100130,1);
-		Commands->Enable_Spawner(100086,1);
-		Commands->Enable_Spawner(100087,1);
-		Commands->Enable_Spawner(100088,1);
-		Commands->Enable_Spawner(100089,1);
-		Commands->Enable_Spawner(100090,1);
-		Commands->Enable_Spawner(100092,1);
-		Commands->Enable_Spawner(100091,1);
-		Commands->Enable_Spawner(100093,1);
-		Commands->Enable_Spawner(100094,1);
-		Commands->Enable_Spawner(100095,1);
-		Commands->Enable_Spawner(100096,1);
-		Commands->Enable_Spawner(100097,1);
-		Commands->Enable_Spawner(100098,1);
-		Commands->Enable_Spawner(100099,1);
-		Commands->Enable_Spawner(100100,1);
-		Commands->Enable_Spawner(100101,1);
-		Commands->Enable_Spawner(100102,1);
-		Commands->Enable_Spawner(100103,1);
-		Commands->Enable_Spawner(100104,1);
-		Commands->Enable_Spawner(100105,1);
-		Commands->Enable_Spawner(100106,1);
-		Commands->Enable_Spawner(100107,1);
-		Commands->Enable_Spawner(100108,1);
-		Commands->Enable_Spawner(100109,1);
-		Commands->Enable_Spawner(100110,1);
-		Commands->Enable_Spawner(100126,1);
-		Commands->Enable_Spawner(100127,1);
-		Commands->Enable_Spawner(100131,1);
-		Commands->Enable_Spawner(100132,1);
-		Commands->Enable_Spawner(100133,1);
-		Commands->Enable_Spawner(100134,1);
-		Commands->Enable_Spawner(100135,1);
-		Commands->Enable_Spawner(100122,1);
-		Commands->Enable_Spawner(100129,1);
-		Commands->Enable_Spawner(100116,1);
-		Commands->Enable_Spawner(100120,1);
-		Commands->Enable_Spawner(100128,1);
-		Commands->Enable_Spawner(100118,1);
-		Commands->Enable_Spawner(100121,1);
-
-		if (play)
-		{
-			Commands->Start_Timer(obj,this,333.0f,301);
-			Commands->Start_Timer(obj,this,338.0f,302);
-			Commands->Start_Timer(obj,this,335.0f,303);
-			Commands->Start_Timer(obj,this,331.0f,304);
-		}
-	}
-	else if (number == 301)
-	{
-		if (play)
-		{
-			if (The_Game()->Get_Current_Players() > 1)
-			{
-				//south
-				GameObject *dropobj1 = Commands->Find_Object(100154);
-				Vector3 pos1 = Commands->Get_Position(dropobj1);
-				GameObject *object1 = Commands->Create_Object("Invisible_Object",pos1);
-				Commands->Set_Facing(object1,70.000f);
-				Commands->Attach_Script(object1,"JFW_Cinematic","z_ninv_noddrop_01.txt");
-
-				GameObject *dropobj2 = Commands->Find_Object(100155);
-				Vector3 pos2 = Commands->Get_Position(dropobj2);
-				GameObject *object2 = Commands->Create_Object("Invisible_Object",pos2);
-				Commands->Set_Facing(object2,10.000f);
-				Commands->Attach_Script(object2,"JFW_Cinematic","z_ninv_noddrop_04.txt");
-
-				GameObject *dropobj3 = Commands->Find_Object(100156);
-				Vector3 pos3 = Commands->Get_Position(dropobj3);
-				GameObject *object3 = Commands->Create_Object("Invisible_Object",pos3);
-				Commands->Set_Facing(object3,90.000f);
-				Commands->Attach_Script(object3,"JFW_Cinematic","z_ninv_noddrop_06.txt");
-
-				GameObject *dropobj4 = Commands->Find_Object(100157);
-				Vector3 pos4 = Commands->Get_Position(dropobj4);
-				GameObject *object4 = Commands->Create_Object("Invisible_Object",pos4);
-				Commands->Set_Facing(object4,120.000f);
-				Commands->Attach_Script(object4,"JFW_Cinematic","z_ninv_noddrop_05.txt");
-
-				GameObject *dropobj5 = Commands->Find_Object(100158);
-				Vector3 pos5 = Commands->Get_Position(dropobj5);
-				GameObject *object5 = Commands->Create_Object("Invisible_Object",pos5);
-				Commands->Set_Facing(object5,120.000f);
-				Commands->Attach_Script(object5,"JFW_Cinematic","z_ninv_noddrop_02.txt");
-
-				GameObject *dropobj6 = Commands->Find_Object(100159);
-				Vector3 pos6 = Commands->Get_Position(dropobj6);
-				GameObject *object6 = Commands->Create_Object("Invisible_Object",pos6);
-				Commands->Set_Facing(object6,120.000f);
-				Commands->Attach_Script(object6,"JFW_Cinematic","z_ninv_noddrop_03.txt");
+
+bool Invasion_Botcount_Nod(int count)
+{
+	int Total_Flamerguys = Get_Object_Count(0,"Bot_Nod_Flamerguy");
+	int Total_Chemwarriors = Get_Object_Count(0,"Bot_Nod_Chemwarrior");
+	int Total_SBHs = Get_Object_Count(0,"Bot_Nod_SBH");
+	int Total_Mendoza = Get_Object_Count(0,"Bot_Nod_Mendoza");
+	int Total_Mendoza2 = Get_Object_Count(0,"Bot_Nod_Mendoza_ALT2");
+	int Total_Minigunners = Get_Object_Count(0,"Bot_Nod_Minigunner");
+	int Total_Officers = Get_Object_Count(0,"Bot_Nod_Officer");
+	int Total_Snipers = Get_Object_Count(0,"Bot_Nod_Sniper");
+	int Total_Sakuras = Get_Object_Count(0,"Bot_Nod_Sakura");
+	int Total_Sakuras2 = Get_Object_Count(0,"Bot_Nod_Sakura_ALT2");
+	int Total_Shotgunners = Get_Object_Count(0,"Bot_Nod_Shotgunner");
+	int Total_Rocketguys = Get_Object_Count(0,"Bot_Nod_Rocket");
+	int Total_LCGs = Get_Object_Count(0,"Bot_Nod_Laserchaingunner");
+	int Total_Raves = Get_Object_Count(0,"Bot_Nod_Raveshaw");
+	if(Total_Flamerguys+Total_Chemwarriors+Total_SBHs+Total_Mendoza+Total_Mendoza2+Total_Minigunners+Total_Officers+Total_Snipers+Total_Sakuras+Total_Sakuras2+Total_Shotgunners+Total_Rocketguys+Total_LCGs+Total_Raves <= count)
+	{
+		return true;
+	}
+	else return false;
+}
+
+void z_Poke_Play_Cinematic::Created(GameObject *obj)
+{
+	allowpoke = true;
+	Commands->Enable_HUD_Pokable_Indicator(obj,true);
+}
+void z_Poke_Play_Cinematic::Poked(GameObject *obj, GameObject *poker)
+{
+	if (allowpoke)
+	{
+		allowpoke = false;
+		Commands->Enable_HUD_Pokable_Indicator(obj,false);
+		Commands->Start_Timer(obj,this,2.0f,1000);//do cinematic
+	}
+}
+void z_Poke_Play_Cinematic::Timer_Expired(GameObject *obj, int number)
+{
+	if (number == 1000)
+	{
+		allowpoke = true;
+		Commands->Enable_HUD_Pokable_Indicator(obj,true);
+		const char *Cinematic = Get_Parameter("Cinematic");
+		int dropid = Get_Int_Parameter("DropID");
+		Vector3 pos = Commands->Get_Position(Commands->Find_Object(dropid));
+		float fac = Get_Float_Parameter("Facing");
+		GameObject *dropoff = Commands->Create_Object("Invisible_Object",pos);
+		Commands->Set_Facing(dropoff,fac);
+		Commands->Attach_Script(dropoff,"Test_Cinematic",Cinematic);
 				Commands->Create_2D_WAV_Sound("airraid.wav");
-				Send_Message(255,255,255,"Incoming Nod Aircraft");
 			}
-			Commands->Start_Timer(obj,this,180.0f,301);
 		}
+void z_Poke_Play_Cinematic::Register_Auto_Save_Variables()
+{
+	Auto_Save_Variable(&allowpoke,sizeof(allowpoke),1);
+}
+
+void z_Invasion_Hostage::Created(GameObject *obj)
+{
+	FollowID = 0;
+	playpoke = true;
+	playpain = true;
+	hostypokesound = 0;
+	Commands->Enable_HUD_Pokable_Indicator(obj,true);
+	hostyname = Get_Parameter("Hostage_Name");
+
+}
+void z_Invasion_Hostage::Poked(GameObject *obj, GameObject *poker)
+{
+	if (playpoke)
+	{
+		playpoke = false;	Commands->Start_Timer(obj,this,10.0f,1000);
+		char hostymsg[512];
+		int random = Commands->Get_Random_Int(1,6);
+		if (random == 1) {				sprintf(hostymsg,"Hostage %s: Let's get the hell outta here",hostyname);		hostypokesound = "hgetouttahere.wav";	}
+		else if (random == 2) {			sprintf(hostymsg,"Hostage %s: Okay i'll follow you",hostyname);	hostypokesound = "hillfollow.wav";		}
+		else if (random == 3) {			sprintf(hostymsg,"Hostage %s: Let's go",hostyname);	hostypokesound = "hletsgo.wav";		}
+		else if (random == 4) {			sprintf(hostymsg,"Hostage %s: Okay let's hurry",hostyname);	hostypokesound = "hletshurry.wav";		}
+		else if (random == 5) {			sprintf(hostymsg,"Hostage %s: Right let's move",hostyname);	hostypokesound = "hletsmove.wav";		}
+		else {							sprintf(hostymsg,"Hostage %s: Okay let's go",hostyname);	hostypokesound = "hokletsgo.wav";		}
+		Send_Message_Player(poker,255,204,0,hostymsg);
+		Create_2D_WAV_Sound_Player(poker,hostypokesound);
+		Commands->Enable_HUD_Pokable_Indicator(obj,false);
+	}
+}
+void z_Invasion_Hostage::Timer_Expired(GameObject *obj, int number)
+{
+	if (number == 1000)
+	{
+		playpoke = true;
+		Commands->Enable_HUD_Pokable_Indicator(obj,true);
+	}
+	else if (number == 1001)
+	{
+		playpain = true;
+	}
+}
+void z_Invasion_Hostage::Damaged(GameObject *obj, GameObject *damager, float damage)
+{
+	if (damage > 0.0f)
+	{
+		if (playpain)
+		{
+			const char *painsnd = "0";
+			playpain = false; Commands->Start_Timer(obj,this,5.0f,1001);
+			int lol = Commands->Get_Random_Int(1,8);
+			if (lol == 1) { painsnd = "hpain1.wav"; }
+			else if (lol == 2)  { painsnd = "hpain2.wav"; }
+			else if (lol == 3)  { painsnd = "hpain3.wav"; }
+			else if (lol == 4)  { painsnd = "hpain4.wav"; }
+			else if (lol == 5)  { painsnd = "hpain5.wav"; }
+			else				{ painsnd = "hpain6.wav"; }
+			Commands->Create_2D_WAV_Sound(painsnd);
+		}
+	}
+}
+void z_Invasion_Hostage::Destroyed(GameObject *obj)
+{
+	Commands->Create_2D_WAV_Sound("hostydown.wav");
+	char killmsg[512];	sprintf(killmsg,"Hostage down: %s",hostyname);	Send_Message(255,204,0,killmsg);
+	GameObject *receiver = Find_Object_With_Script("z_Invasion_Hostage_Count");
+	Commands->Send_Custom_Event(obj,receiver,1000,1,0);
+}
+void z_Invasion_Hostage::Register_Auto_Save_Variables()
+{
+	Auto_Save_Variable(&playpoke,sizeof(playpoke),1);
+	Auto_Save_Variable(&playpain,sizeof(playpain),2);
+	Auto_Save_Variable(&hostyname,sizeof(hostyname),3);
+	Auto_Save_Variable(&hostypokesound,sizeof(hostypokesound),4);
+	Auto_Save_Variable(&FollowID,sizeof(FollowID),5);
+}
+
+void z_Invasion_Hostage_Count::Created(GameObject *obj)
+{
+	deaths = 0;
+	Send_Message(255,204,0,"Protect the Hostages at all costs");
+	Commands->Start_Timer(obj,this,90.0f,2003);
+}
+void z_Invasion_Hostage_Count::Custom(GameObject *obj, int message, int param, GameObject *sender)
+{
+	if (message == 1000)
+	{
+		if (param == 1)
+		{
+			deaths++;
+			if (deaths == 4)
+			{
+				Commands->Start_Timer(obj,this,3.0f,2000);
+			}
+		}
+	}
+}
+void z_Invasion_Hostage_Count::Timer_Expired(GameObject *obj, int number)
+{
+	if (number == 2000)
+	{
+		Console_Input("amsg Mission Failed: All hostages were terminated");
+		Commands->Start_Timer(obj,this,5.0f,2001);
+	}
+	else if (number == 2001)
+	{
+		Send_Message(255,204,0,"Your mission is a failure");
+		Commands->Create_2D_WAV_Sound("00-n100e.wav");
+		Commands->Start_Timer(obj,this,2.0f,2002);
+		for (SLNode<cPlayer>* PlayerIter = Get_Player_List()->Head(); (PlayerIter != NULL); PlayerIter = PlayerIter->Next())
+		{
+			cPlayer *p = PlayerIter->Data();
+			if (p->IsActive)
+			{		
+				int id = p->PlayerId;
+				if (Get_Team(id) == 1)
+				{
+					GameObject *player = Get_GameObj(id);
+					if (Commands->Is_A_Star(player))
+					{
+						Commands->Apply_Damage(player,99999.0f,"Death",0);
+					}
+				}
+			}
+		}
+	}
+	else if (number == 2002)
+	{
+		Console_Input("win 0");
+	}
+	else if (number == 2003)
+	{
+		Send_Message(255,204,0,"Protect the Hostages at all costs");
+		Commands->Start_Timer(obj,this,90.0f,2003);
+	}
+}
+void z_Invasion_Hostage_Count::Register_Auto_Save_Variables()
+{
+	Auto_Save_Variable(&deaths,sizeof(deaths),1);
+}
+
+void z_Invasion_Bot_Counter::Created(GameObject *obj)
+{
+	botcount = 0;
+	endgame = false;
+}
+void z_Invasion_Bot_Counter::Custom(GameObject *obj, int message, int param, GameObject *sender)
+{
+	if (message == 1000)//bot created
+	{
+		if (param == 1)
+		{
+			botcount++;
+		}
+	}
+	else if (message == 2000)//bot died
+	{
+		if (param == 1)
+		{
+			botcount--;
+			if (botcount == 0)
+			{
+				if (endgame)
+				{
+					Commands->Start_Timer(obj,this,1.0f,1000);
+				}
+				else Commands->Start_Timer(obj,this,1.0f,1001);
+			}
+		}
+	}
+	else if (message == 3000)//planedrop done
+	{
+		if (param == 1)
+		{
+			endgame = true;
+		}
+	}
+}
+void z_Invasion_Bot_Counter::Timer_Expired(GameObject *obj, int number)
+{
+	if (number == 1000)
+	{
+		Console_Input("amsg Mission accomplished");
+		Console_Input("win 1");
+	}
+	else if (number == 1001)
+	{
+		if (botcount == 0)
+		{
+			if (endgame)
+			{
+				Commands->Start_Timer(obj,this,1.0f,1000);
+			}
+			else Commands->Start_Timer(obj,this,5.0f,1001);
+		}
+	}
+}
+void z_Invasion_Bot_Counter::Register_Auto_Save_Variables()
+{
+	Auto_Save_Variable(&botcount,sizeof(botcount),1);
+	Auto_Save_Variable(&endgame,sizeof(endgame),2);
+}
+
+void z_Invasion_Enemy::Created(GameObject *obj)
+{
+	GameObject *recr = Find_Object_With_Script("z_Invasion_Bot_Counter");
+	Commands->Send_Custom_Event(obj,recr,1000,1,0);
+}
+void z_Invasion_Enemy::Destroyed(GameObject *obj)
+{
+	GameObject *recvr = Find_Object_With_Script("z_Invasion_Bot_Counter");
+	Commands->Send_Custom_Event(obj,recvr,2000,1,0);
+
+	int random = Commands->Get_Random_Int(1,13);
+	if (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Engineer_Stationary") == 0)
+	{
+		if (random == 1)
+		{
+			GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_MineRemote_Player",pos);
+			Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+			GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("CnC_POW_MineRemote_02",pos);
+			Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+			GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_RepairGun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+			GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Flamerguy") == 0)
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_Flamethrower_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Flamethrower_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Flamethrower_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if (strcmp(Commands->Get_Preset_Name(obj),"Bot_GDI_Grenadier") == 0)
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_GrenadeLauncher_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_GrenadeLauncher_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_GrenadeLauncher_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if ((strcmp(Commands->Get_Preset_Name(obj),"Bot_GDI_Hotwire") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Bot_GDI_Hotwire_Stationary") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Joi_Hotwire_Repair_PP") == 0))
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("CnC_POW_RepairGun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("CnC_POW_MineRemote_02",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("CnC_MineProximity_05",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Chemwarrior") == 0)
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_ChemSprayer_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_ChemSprayer_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_ChemSprayer_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_SBH") == 0)
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_LaserRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_LaserRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_LaserRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if ( (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Mendoza") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Mendoza_ALT2") == 0) )
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("CnC_POW_VoltAutoRifle_Player_Nod",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("CnC_POW_VoltAutoRifle_Player_Nod",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("CnC_POW_VoltAutoRifle_Player_Nod",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if (strcmp(Commands->Get_Preset_Name(obj),"Bot_GDI_Patch") == 0)
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_TiberiumFlechetteGun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_TiberiumFlechetteGun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_TiberiumFlechetteGun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if (strcmp(Commands->Get_Preset_Name(obj),"Bot_GDI_Minigunner") == 0)
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_AutoRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_AutoRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_AutoRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if (strcmp(Commands->Get_Preset_Name(obj),"Bot_GDI_Officer") == 0)
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_Chaingun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Chaingun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Chaingun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if ((strcmp(Commands->Get_Preset_Name(obj),"Bot_GDI_Sniper") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Bot_GDI_Sniper_Stationary") == 0))
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_SniperRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_SniperRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_SniperRifle_Player_Nod",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if (strcmp(Commands->Get_Preset_Name(obj),"Bot_GDI_Shotgunner") == 0)
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_Shotgun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Shotgun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Shotgun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if ((strcmp(Commands->Get_Preset_Name(obj),"Bot_GDI_Rocketsoldier") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Bot_GDI_Rocketsoldier_Stationary") == 0))
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_RocketLauncher_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_RocketLauncher_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_RocketLauncher_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if ((strcmp(Commands->Get_Preset_Name(obj),"Bot_GDI_Gunner") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Bot_GDI_Gunner_Stationary") == 0))
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("CnC_POW_RocketLauncher_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("CnC_POW_RocketLauncher_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("CnC_POW_RocketLauncher_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if (strcmp(Commands->Get_Preset_Name(obj),"Bot_GDI_Sydney") == 0)
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_TiberiumAutoRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_TiberiumAutoRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_TiberiumAutoRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if ( (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Minigunner") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Minigunner_Star") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"M01_Minigunr") == 0) )
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_AutoRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_AutoRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_AutoRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 	}
-	else if (number == 302)
+		else if (random == 4)
 	{
-		if (play)
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
 		{
-			if (The_Game()->Get_Current_Players() > 1)
-			{
-				//west
-				GameObject *dropobj7 = Commands->Find_Object(100160);
-				Vector3 pos7 = Commands->Get_Position(dropobj7);
-				GameObject *object7 = Commands->Create_Object("Invisible_Object",pos7);
-				Commands->Set_Facing(object7,10.000f);
-				Commands->Attach_Script(object7,"JFW_Cinematic","z_ninv_noddrop_01.txt");
-
-				GameObject *dropobj8 = Commands->Find_Object(100161);
-				Vector3 pos8 = Commands->Get_Position(dropobj8);
-				GameObject *object8 = Commands->Create_Object("Invisible_Object",pos8);
-				Commands->Set_Facing(object8,76.000f);
-				Commands->Attach_Script(object8,"JFW_Cinematic","z_ninv_noddrop_04.txt");
-
-				GameObject *dropobj9 = Commands->Find_Object(100162);
-				Vector3 pos9 = Commands->Get_Position(dropobj9);
-				GameObject *object9 = Commands->Create_Object("Invisible_Object",pos9);
-				Commands->Set_Facing(object9,90.000f);
-				Commands->Attach_Script(object9,"JFW_Cinematic","z_ninv_noddrop_06.txt");
-
-				GameObject *dropobj10 = Commands->Find_Object(100163);
-				Vector3 pos10 = Commands->Get_Position(dropobj10);
-				GameObject *object10 = Commands->Create_Object("Invisible_Object",pos10);
-				Commands->Set_Facing(object10,220.000f);
-				Commands->Attach_Script(object10,"JFW_Cinematic","z_ninv_noddrop_05.txt");
-
-				GameObject *dropobj11 = Commands->Find_Object(100164);
-				Vector3 pos11 = Commands->Get_Position(dropobj11);
-				GameObject *object11 = Commands->Create_Object("Invisible_Object",pos11);
-				Commands->Set_Facing(object11,125.000f);
-				Commands->Attach_Script(object11,"JFW_Cinematic","z_ninv_noddrop_02.txt");
-
-				GameObject *dropobj12 = Commands->Find_Object(100165);
-				Vector3 pos12 = Commands->Get_Position(dropobj12);
-				GameObject *object12 = Commands->Create_Object("Invisible_Object",pos12);
-				Commands->Set_Facing(object12,180.000f);
-				Commands->Attach_Script(object12,"JFW_Cinematic","z_ninv_noddrop_03.txt");
-				Commands->Create_2D_WAV_Sound("airraid.wav");
-				Send_Message(255,255,255,"Incoming Nod Aircraft");
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 			}
-			Commands->Start_Timer(obj,this,180.0f,302);
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 	}
-	else if (number == 303)
+		else if (random == 8)
 	{
-		if (play)
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
 		{
-			if (The_Game()->Get_Current_Players() > 1)
-			{
-				//north
-				GameObject *dropobj1 = Commands->Find_Object(100166);
-				Vector3 pos1 = Commands->Get_Position(dropobj1);
-				GameObject *object1 = Commands->Create_Object("Invisible_Object",pos1);
-				Commands->Set_Facing(object1,330.000f);
-				Commands->Attach_Script(object1,"JFW_Cinematic","z_ninv_noddrop_01.txt");
-
-				GameObject *dropobj2 = Commands->Find_Object(100167);
-				Vector3 pos2 = Commands->Get_Position(dropobj2);
-				GameObject *object2 = Commands->Create_Object("Invisible_Object",pos2);
-				Commands->Set_Facing(object2,140.000f);
-				Commands->Attach_Script(object2,"JFW_Cinematic","z_ninv_noddrop_04.txt");
-
-				GameObject *dropobj3 = Commands->Find_Object(100168);
-				Vector3 pos3 = Commands->Get_Position(dropobj3);
-				GameObject *object3 = Commands->Create_Object("Invisible_Object",pos3);
-				Commands->Set_Facing(object3,180.000f);
-				Commands->Attach_Script(object3,"JFW_Cinematic","z_ninv_noddrop_06.txt");
-
-				GameObject *dropobj4 = Commands->Find_Object(100169);
-				Vector3 pos4 = Commands->Get_Position(dropobj4);
-				GameObject *object4 = Commands->Create_Object("Invisible_Object",pos4);
-				Commands->Set_Facing(object4,170.000f);
-				Commands->Attach_Script(object4,"JFW_Cinematic","z_ninv_noddrop_05.txt");
-
-				GameObject *dropobj5 = Commands->Find_Object(100170);
-				Vector3 pos5 = Commands->Get_Position(dropobj5);
-				GameObject *object5 = Commands->Create_Object("Invisible_Object",pos5);
-				Commands->Set_Facing(object5,190.000f);
-				Commands->Attach_Script(object5,"JFW_Cinematic","z_ninv_noddrop_02.txt");
-
-				GameObject *dropobj6 = Commands->Find_Object(100171);
-				Vector3 pos6 = Commands->Get_Position(dropobj6);
-				GameObject *object6 = Commands->Create_Object("Invisible_Object",pos6);
-				Commands->Set_Facing(object6,180.000f);
-				Commands->Attach_Script(object6,"JFW_Cinematic","z_ninv_noddrop_03.txt");
-				Commands->Create_2D_WAV_Sound("airraid.wav");
-				Send_Message(255,255,255,"Incoming Nod Aircraft");
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 			}
-			Commands->Start_Timer(obj,this,120.0f,303);
+		else
+		{
+			Destroy_Script();
 		}
 	}
-	else if (number == 304)
+
+	else if ( (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Officer") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Officer_Star") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"M00_NodOfficer") == 0) || 
+		      (strcmp(Commands->Get_Preset_Name(obj),"M01_NodOfficer") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"M01_NodOfficerStat") == 0)  )
 	{
-		if (play)
+		if (random == 1)
 		{
-			if (The_Game()->Get_Current_Players() > 1)
-			{
-				//east
-				GameObject *dropobj1 = Commands->Find_Object(100172);
-				Vector3 pos1 = Commands->Get_Position(dropobj1);
-				GameObject *object1 = Commands->Create_Object("Invisible_Object",pos1);
-				Commands->Set_Facing(object1,359.000f);
-				Commands->Attach_Script(object1,"JFW_Cinematic","z_ninv_noddrop_01.txt");
-
-				GameObject *dropobj2 = Commands->Find_Object(100173);
-				Vector3 pos2 = Commands->Get_Position(dropobj2);
-				GameObject *object2 = Commands->Create_Object("Invisible_Object",pos2);
-				Commands->Set_Facing(object2,110.000f);
-				Commands->Attach_Script(object2,"JFW_Cinematic","z_ninv_noddrop_04.txt");
-
-				GameObject *dropobj3 = Commands->Find_Object(100174);
-				Vector3 pos3 = Commands->Get_Position(dropobj3);
-				GameObject *object3 = Commands->Create_Object("Invisible_Object",pos3);
-				Commands->Set_Facing(object3,230.000f);
-				Commands->Attach_Script(object3,"JFW_Cinematic","z_ninv_noddrop_06.txt");
-
-				GameObject *dropobj4 = Commands->Find_Object(100175);
-				Vector3 pos4 = Commands->Get_Position(dropobj4);
-				GameObject *object4 = Commands->Create_Object("Invisible_Object",pos4);
-				Commands->Set_Facing(object4,190.000f);
-				Commands->Attach_Script(object4,"JFW_Cinematic","z_ninv_noddrop_05.txt");
-
-				GameObject *dropobj5 = Commands->Find_Object(100176);
-				Vector3 pos5 = Commands->Get_Position(dropobj5);
-				GameObject *object5 = Commands->Create_Object("Invisible_Object",pos5);
-				Commands->Set_Facing(object5,10.000f);
-				Commands->Attach_Script(object5,"JFW_Cinematic","z_ninv_noddrop_02.txt");
-
-				GameObject *dropobj6 = Commands->Find_Object(100177);
-				Vector3 pos6 = Commands->Get_Position(dropobj6);
-				GameObject *object6 = Commands->Create_Object("Invisible_Object",pos6);
-				Commands->Set_Facing(object6,120.000f);
-				Commands->Attach_Script(object6,"JFW_Cinematic","z_ninv_noddrop_03.txt");
-				Commands->Create_2D_WAV_Sound("airraid.wav");
-				Send_Message(255,255,255,"Incoming Nod Aircraft");
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_Chaingun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Chaingun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 			}
-			Commands->Start_Timer(obj,this,180.0f,304);
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Chaingun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
 		}
 	}
 
-	else if (number == 200)
+	else if ( (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Sniper_Stationary") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Sniper") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"M01_Nod_SniperStat") == 0) )
 	{
-		Console_Input("amsg Mission Accomplished");
-		Console_Input("win 1");
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_SniperRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_SniperRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_SniperRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 	}
-	else if (number == 201)
+		else
 	{
-		play = false;
-		//lol disable bots:
-		Commands->Enable_Spawner(100113,0);
-		Commands->Enable_Spawner(100119,0);
-		Commands->Enable_Spawner(100114,0);
-		Commands->Enable_Spawner(100115,0);
-		Commands->Enable_Spawner(100117,0);
-		Commands->Enable_Spawner(100123,0);
-		Commands->Enable_Spawner(100124,0);
-		Commands->Enable_Spawner(100125,0);
-		Commands->Enable_Spawner(100130,0);
-		Commands->Enable_Spawner(100086,0);
-		Commands->Enable_Spawner(100087,0);
-		Commands->Enable_Spawner(100088,0);
-		Commands->Enable_Spawner(100089,0);
-		Commands->Enable_Spawner(100090,0);
-		Commands->Enable_Spawner(100092,0);
-		Commands->Enable_Spawner(100091,0);
-		Commands->Enable_Spawner(100093,0);
-		Commands->Enable_Spawner(100094,0);
-		Commands->Enable_Spawner(100095,0);
-		Commands->Enable_Spawner(100096,0);
-		Commands->Enable_Spawner(100097,0);
-		Commands->Enable_Spawner(100098,0);
-		Commands->Enable_Spawner(100099,0);
-		Commands->Enable_Spawner(100100,0);
-		Commands->Enable_Spawner(100101,0);
-		Commands->Enable_Spawner(100102,0);
-		Commands->Enable_Spawner(100103,0);
-		Commands->Enable_Spawner(100104,0);
-		Commands->Enable_Spawner(100105,0);
-		Commands->Enable_Spawner(100106,0);
-		Commands->Enable_Spawner(100107,0);
-		Commands->Enable_Spawner(100108,0);
-		Commands->Enable_Spawner(100109,0);
-		Commands->Enable_Spawner(100110,0);
-		Commands->Enable_Spawner(100126,0);
-		Commands->Enable_Spawner(100127,0);
-		Commands->Enable_Spawner(100131,0);
-		Commands->Enable_Spawner(100132,0);
-		Commands->Enable_Spawner(100133,0);
-		Commands->Enable_Spawner(100134,0);
-		Commands->Enable_Spawner(100135,0);
-		Commands->Enable_Spawner(100122,0);
-		Commands->Enable_Spawner(100129,0);
-		Commands->Enable_Spawner(100116,0);
-		Commands->Enable_Spawner(100120,0);
-		Commands->Enable_Spawner(100128,0);
-		Commands->Enable_Spawner(100118,0);
-		Commands->Enable_Spawner(100121,0);
-		Send_Message(255,204,0,"Well done commanders. We survived!");
-		Commands->Create_2D_WAV_Sound("beep.wav");
-		Commands->Start_Timer(obj,this,120.0f,200);//end win in 2mins endgame
-	}
-	else if (number == 202)
-	{
-		Send_Message(255,204,0,"Warning: 5 minutes remaining.");
-		Commands->Create_2D_WAV_Sound("beep.wav");
-	}
-	else if (number == 203)
-	{
-		Send_Message(255,204,0,"Warning: 10 minutes remaining.");
-		Commands->Create_2D_WAV_Sound("beep.wav");
-	}
-	else if (number == 204)
-	{
-		Send_Message(255,204,0,"Warning: 15 minutes remaining.");
-		Commands->Create_2D_WAV_Sound("beep.wav");
-	}
-	else if (number == 205)
-	{
-		Send_Message(255,204,0,"Warning: 20 minutes remaining.");
-		Commands->Create_2D_WAV_Sound("beep.wav");
-	}
-	else if (number == 206)
-	{
-		Send_Message(255,204,0,"Warning: 25 minutes remaining.");
-		Commands->Create_2D_WAV_Sound("beep.wav");
-	}
-	else if (number == 207)
-	{
-		Send_Message(255,204,0,"Warning: 30 minutes remaining.");
-		Commands->Create_2D_WAV_Sound("beep.wav");
-	}
-	else if (number == 208)
-	{
-		Send_Message(255,204,0,"Warning: 35 minutes remaining.");
-		Commands->Create_2D_WAV_Sound("beep.wav");
-	}
-	else if (number == 209)
-	{
-		Send_Message(255,204,0,"Warning: 40 minutes remaining.");
-		Commands->Create_2D_WAV_Sound("beep.wav");
-	}
-}
-
-void z_ninv_Civilian::Killed(GameObject *obj, GameObject *shooter)
-{
-	Commands->Create_2D_WAV_Sound("civkilled.wav");
-	Send_Message(255,255,255,"Civilian Killed");
+			Destroy_Script();
+		}
 }
 
-void z_ninv_CivCount::Created(GameObject *obj)
+	else if ( (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Shotgunner") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Shotgunner_Star") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"M01_Nod_Shotty") == 0) )
 {
-	alive = Get_Int_Parameter("Civs");
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_Shotgun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 }
-void z_ninv_CivCount::Custom(GameObject *obj, int message, int param, GameObject *sender)
+		else if (random == 2)
 {
-	if (message == 1000)
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Shotgun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
 	{
-		if (param == 1)
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Shotgun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
 		{
-			alive--;
-			if (alive == 1)
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
 			{
-				Send_Message(255,204,0,"Be careful. Civilians are being killed. If the last one dies you will lose!");
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 			}
-			else if (alive == 0)
+		else if (random == 8)
 			{
-				Console_Input("amsg Mission Failed. All Civilians were killed.");
-				Commands->Start_Timer(obj,this,5.0f,100);//fail
-				Commands->Start_Timer(obj,this,7.5f,101);//end
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 			}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 		}
+		else
+		{
+			Destroy_Script();
 	}
 }
-void z_ninv_CivCount::Timer_Expired(GameObject *obj, int number)
+
+	else if ( (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Sakura") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Sakura_ALT2") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"M01_SakuraBot") == 0) )
 {
-	if (number == 100)
+		if (random == 1)
 	{
-		Send_Message(255,255,255,"Your mission is a failure.");
-		Commands->Create_2D_WAV_Sound("missionfailed.wav");
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_RamjetRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 	}
-	else if (number == 101)
+		else if (random == 2)
 	{
-		Console_Input("win 0");
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_RamjetRifle_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 	}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 }
-void z_ninv_CivCount::Register_Auto_Save_Variables()
+		else
 {
-	Auto_Save_Variable(&alive,5,1);
+			Destroy_Script();
+		}
 }
 
-void z_ninv_Buy_SamsiteSW::Created(GameObject *obj)
+	else if ( (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Rocket") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Rocketguy_Star") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Rocketguy_Stationary") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"M00_Nod_RocketGuy") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"M01_NodRocketGuy") == 0) )
 {
-	funds = 0;
-	Commands->Enable_HUD_Pokable_Indicator(obj,true);
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_RocketLauncher_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 }
-void z_ninv_Buy_SamsiteSW::Poked(GameObject *obj, GameObject *poker)
+		else if (random == 2)
 {
-	if (funds < 2500.0f)
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_RocketLauncher_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
 	{
-		if (Commands->Get_Money(poker) >= 500.0f)
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("CnC_POW_RocketLauncher_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
 		{
-			funds = funds + 500.0f;
-			char fundadded[250];
-			const char *str = Get_Player_Name(poker);
-			sprintf(fundadded,"%s added $500 to the South West Samsites fundpool. (Current: %g / %g)",str,funds,2500.0f);
-			delete[] str;
-			Send_Message(255,255,255,fundadded);
-			Commands->Give_Money(poker,-500.0f,false);
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+
+	else if ( (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Laserchaingunner_Star") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Laserchaingunner") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"M00_Nod_LCG") == 0) )
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_LaserChaingun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_LaserChaingun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_LaserChaingun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else
+		{
+			Destroy_Script();
+		}
+	}
+	
+	else if (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Raveshaw") == 0)
+	{
+		if (random == 1)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("POW_Railgun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Railgun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Railgun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 8)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 9)
+		{
+						GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 		}
-		else if (Commands->Get_Money(poker) < 500.0f)
+		else
 		{
-			char nomoney[100]; 
-			sprintf(nomoney,"ppage %d Sorry you do not have enough money ($500) to add to the Samsites fundpool.",Get_Player_ID(poker));
-			Console_Input(nomoney);
+			Destroy_Script();
+		}
 		}
 
-		if (funds == 2500.0f)
+	else if ( (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Tech_Repair") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Technician") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"Bot_Nod_Tech_Stationary") == 0) ||
+		(strcmp(Commands->Get_Preset_Name(obj),"M01_Nod_Techie") == 0) || (strcmp(Commands->Get_Preset_Name(obj),"M01_Nod_Techie_Repair") == 0) )
+	{
+		if (random == 1)
+		{
+			GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			 powerup = Commands->Create_Object("CnC_POW_RepairGun_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 2)
+		{
+			GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("CnC_POW_MineRemote_02",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 3)
+		{
+			GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_MineRemote_Player",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 4)
+		{
+			GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("CnC_MineProximity_05",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 5)
+		{
+			GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 6)
+		{
+			GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Armor_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
+		}
+		else if (random == 7)
 		{
-			Commands->Create_2D_WAV_Sound("building.wav");
-			Commands->Start_Timer(obj,this,3.0f,166);
+			GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_025",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 		}
+		else if (random == 8)
+		{
+			GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_050",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 	}
+		else if (random == 9)
+		{
+			GameObject *powerup;
+			Vector3 pos = Commands->Get_Position(obj);
+			pos.Z += 0.25f;
+			powerup = Commands->Create_Object("POW_Health_100",pos);	Attach_Script_Once(powerup,"z_POW_PickupSounds","");	Attach_Script_Once(powerup,"M00_Powerup_Destroy","");
 }
-void z_ninv_Buy_SamsiteSW::Timer_Expired(GameObject *obj, int number)
+		else
 {
-	if (number == 166)
+			Destroy_Script();
+		}
+	}
+}
+
+void z_Invasion_Drop_Harvester::Killed(GameObject *obj, GameObject *shooter)
 	{
-		Vector3 pos1;		pos1.X = -33.731f;		pos1.Y = -53.145f;		pos1.Z = 8.546f;
-		float facing1 = 0.0f;
-		GameObject *ss1 = Commands->Create_Object("z_GDI_Sam_Site",pos1);
-		Commands->Set_Facing(ss1,facing1);
+	Vector3 loc; loc.X = 44.034f; loc.Y = -19.332f; loc.Z = 2.442f;	float facing = 63.327f;
+	const char *Cinematic = "nod_inv_harvdrop.txt";
+	GameObject *dropoff = Commands->Create_Object("Invisible_Object",loc);
+	Commands->Set_Facing(dropoff,facing);
+	Commands->Attach_Script(dropoff,"Test_Cinematic",Cinematic);
+	Commands->Create_2D_WAV_Sound("m00evag_dsgn0060i1evag_snd.wav");
+	Send_Message(255,204,0,"Reinforcements are enroute");
+}
 
-		Vector3 pos2;		pos2.X = -30.532f;		pos2.Y = -47.349f;		pos2.Z = 8.497f;
-		float facing2 = 0.0f;
-		GameObject *ss2 = Commands->Create_Object("z_GDI_Sam_Site",pos2);
-		Commands->Set_Facing(ss2,facing2);
+void z_Invasion_Loop_Badgerdrop::Created(GameObject *obj)
+{
+	Commands->Start_Timer(obj,this,30.0f,999);
+	Commands->Start_Timer(obj,this,60.0f,999);
+	Commands->Start_Timer(obj,this,300.0f,1000);
+	count = 0;
+}
+void z_Invasion_Loop_Badgerdrop::Timer_Expired(GameObject *obj, int number)
+{
+	if (number == 999)
+	{
+		Send_Message(255,204,0,"You have 5 minutes to build your defenses");
+		Send_Message(255,204,0,"You have 5 minutes to build your defenses");
+		Send_Message(255,204,0,"You have 5 minutes to build your defenses");
+		Send_Message(255,204,0,"You have 5 minutes to build your defenses");
+	}
+	else if (number == 1000)
+	{
+		Commands->Start_Timer(obj,this,200.0f,1000);
+		if (Invasion_Botcount_Nod(55))
+		{
+			const char *cinematic = "paradrop.txt";
+			int dropid1 = 100016; int dropid2 = 100017; int dropid3 = 100018;
+			Vector3 pos1 = Commands->Get_Position(Commands->Find_Object(dropid1));
+			Vector3 pos2 = Commands->Get_Position(Commands->Find_Object(dropid2));
+			Vector3 pos3 = Commands->Get_Position(Commands->Find_Object(dropid3));
+			float fac1 = 0.0f; float fac2 = 90.0f; float fac3 = 180.0f;
+			GameObject *dropoff1 = Commands->Create_Object("Invisible_Object",pos1);
+			GameObject *dropoff2 = Commands->Create_Object("Invisible_Object",pos2);
+			GameObject *dropoff3 = Commands->Create_Object("Invisible_Object",pos3);
+			Commands->Set_Facing(dropoff1,fac1);
+			Commands->Set_Facing(dropoff2,fac2);
+			Commands->Set_Facing(dropoff3,fac3);
+			Commands->Attach_Script(dropoff1,"Test_Cinematic",cinematic);
+			Commands->Attach_Script(dropoff2,"Test_Cinematic",cinematic);
+			Commands->Attach_Script(dropoff3,"Test_Cinematic",cinematic);
+			Commands->Create_2D_WAV_Sound("airraid.wav");
+			Commands->Create_2D_WAV_Sound("airraid.wav");
+			count++;
+			if (count > 1)
+			{
+				char countmsg[512];
+				sprintf(countmsg,"Wave %d of 15",count);
+				Send_Message(255,204,0,countmsg);
+				Send_Message(255,204,0,countmsg);
+				Send_Message(255,204,0,countmsg);
+				Send_Message(255,204,0,countmsg);
+			}
+			if (count == 3)
+			{
+				Commands->Enable_Spawner(100102,true);
+				Commands->Enable_Spawner(100105,true);
+				Commands->Enable_Spawner(100157,true);
+				Commands->Enable_Spawner(100158,true);
+				Commands->Enable_Spawner(100159,true);
+				Commands->Enable_Spawner(100160,true);
+				Commands->Enable_Spawner(100161,true);
+				Commands->Enable_Spawner(100162,true);
+				Commands->Enable_Spawner(100163,true);
+				Commands->Enable_Spawner(100164,true);
+				Commands->Enable_Spawner(100165,true);
+				Commands->Enable_Spawner(100166,true);
+				Commands->Enable_Spawner(100167,true);
+				Commands->Enable_Spawner(100168,true);
+				Commands->Enable_Spawner(100169,true);
+				Commands->Enable_Spawner(100170,true);
+				Commands->Enable_Spawner(100171,true);
+				Commands->Enable_Spawner(100172,true);
+				Commands->Enable_Spawner(100173,true);
+				Commands->Enable_Spawner(100174,true);
+				Commands->Enable_Spawner(100175,true);
+			}
+			else if (count == 5)
+			{
+				Commands->Enable_Spawner(100108,true);
+				Commands->Enable_Spawner(100139,true);
+				Commands->Enable_Spawner(100140,true);
+				Commands->Enable_Spawner(100141,true);
+				Commands->Enable_Spawner(100142,true);
+				Commands->Enable_Spawner(100143,true);
+				Commands->Enable_Spawner(100144,true);
+				Commands->Enable_Spawner(100145,true);
+				Commands->Enable_Spawner(100146,true);
+				Commands->Enable_Spawner(100147,true);
+				Commands->Enable_Spawner(100148,true);
+				Commands->Enable_Spawner(100149,true);
+				Commands->Enable_Spawner(100150,true);
+				Commands->Enable_Spawner(100151,true);
+				Commands->Enable_Spawner(100152,true);
+				Commands->Enable_Spawner(100153,true);
+				Commands->Enable_Spawner(100154,true);
+				Commands->Enable_Spawner(100155,true);
+				Commands->Enable_Spawner(100156,true);			
+			}
+			else if (count == 7)
+			{
+				Commands->Enable_Spawner(100112,true);
+				Commands->Enable_Spawner(100113,true);
+				Commands->Enable_Spawner(100125,true);
+				Commands->Enable_Spawner(100126,true);
+				Commands->Enable_Spawner(100127,true);
+				Commands->Enable_Spawner(100128,true);
+				Commands->Enable_Spawner(100129,true);
+				Commands->Enable_Spawner(100130,true);
+				Commands->Enable_Spawner(100131,true);
+				Commands->Enable_Spawner(100132,true);
+				Commands->Enable_Spawner(100133,true);
+				Commands->Enable_Spawner(100134,true);
+				Commands->Enable_Spawner(100135,true);
+				Commands->Enable_Spawner(100136,true);
+				Commands->Enable_Spawner(100137,true);
+				Commands->Enable_Spawner(100138,true);
+			}
+			else if (count == 9)
+			{
+				Commands->Enable_Spawner(100114,true);
+				Commands->Enable_Spawner(100115,true);
+				Commands->Enable_Spawner(100116,true);
+				Commands->Enable_Spawner(100117,true);
+				Commands->Enable_Spawner(100118,true);
+				Commands->Enable_Spawner(100119,true);
+				Commands->Enable_Spawner(100120,true);
+				Commands->Enable_Spawner(100121,true);
+				Commands->Enable_Spawner(100122,true);
+				Commands->Enable_Spawner(100123,true);
+				Commands->Enable_Spawner(100124,true);
+			}
+			else if (count == 15)
+			{
+				GameObject *ctrl = Find_Object_With_Script("z_Invasion_Bot_Counter");
+				Commands->Send_Custom_Event(obj,ctrl,3000,1,0);//endgame true
+				Commands->Destroy_Object(Commands->Find_Object(100099));//chinook loops
+				Commands->Enable_Spawner(100102,false);
+				Commands->Enable_Spawner(100105,false);
+				Commands->Enable_Spawner(100114,false);
+				Commands->Enable_Spawner(100115,false);
+				Commands->Enable_Spawner(100116,false);
+				Commands->Enable_Spawner(100117,false);
+				Commands->Enable_Spawner(100118,false);
+				Commands->Enable_Spawner(100119,false);
+				Commands->Enable_Spawner(100120,false);
+				Commands->Enable_Spawner(100121,false);
+				Commands->Enable_Spawner(100122,false);
+				Commands->Enable_Spawner(100123,false);
+				Commands->Enable_Spawner(100124,false);
+				Commands->Enable_Spawner(100112,false);
+				Commands->Enable_Spawner(100113,false);
+				Commands->Enable_Spawner(100125,false);
+				Commands->Enable_Spawner(100126,false);
+				Commands->Enable_Spawner(100127,false);
+				Commands->Enable_Spawner(100128,false);
+				Commands->Enable_Spawner(100129,false);
+				Commands->Enable_Spawner(100130,false);
+				Commands->Enable_Spawner(100131,false);
+				Commands->Enable_Spawner(100132,false);
+				Commands->Enable_Spawner(100133,false);
+				Commands->Enable_Spawner(100134,false);
+				Commands->Enable_Spawner(100135,false);
+				Commands->Enable_Spawner(100136,false);
+				Commands->Enable_Spawner(100137,false);
+				Commands->Enable_Spawner(100138,false);
+				Commands->Enable_Spawner(100108,false);
+				Commands->Enable_Spawner(100139,false);
+				Commands->Enable_Spawner(100140,false);
+				Commands->Enable_Spawner(100141,false);
+				Commands->Enable_Spawner(100142,false);
+				Commands->Enable_Spawner(100143,false);
+				Commands->Enable_Spawner(100144,false);
+				Commands->Enable_Spawner(100145,false);
+				Commands->Enable_Spawner(100146,false);
+				Commands->Enable_Spawner(100147,false);
+				Commands->Enable_Spawner(100148,false);
+				Commands->Enable_Spawner(100149,false);
+				Commands->Enable_Spawner(100150,false);
+				Commands->Enable_Spawner(100151,false);
+				Commands->Enable_Spawner(100152,false);
+				Commands->Enable_Spawner(100153,false);
+				Commands->Enable_Spawner(100154,false);
+				Commands->Enable_Spawner(100155,false);
+				Commands->Enable_Spawner(100156,false);
+				Commands->Enable_Spawner(100157,false);
+				Commands->Enable_Spawner(100158,false);
+				Commands->Enable_Spawner(100159,false);
+				Commands->Enable_Spawner(100160,false);
+				Commands->Enable_Spawner(100161,false);
+				Commands->Enable_Spawner(100162,false);
+				Commands->Enable_Spawner(100163,false);
+				Commands->Enable_Spawner(100164,false);
+				Commands->Enable_Spawner(100165,false);
+				Commands->Enable_Spawner(100166,false);
+				Commands->Enable_Spawner(100167,false);
+				Commands->Enable_Spawner(100168,false);
+				Commands->Enable_Spawner(100169,false);
+				Commands->Enable_Spawner(100170,false);
+				Commands->Enable_Spawner(100171,false);
+				Commands->Enable_Spawner(100172,false);
+				Commands->Enable_Spawner(100173,false);
+				Commands->Enable_Spawner(100174,false);
+				Commands->Enable_Spawner(100175,false);	
+				Commands->Destroy_Object(obj);
+			}
+		}
+	}
+}
+void z_Invasion_Loop_Badgerdrop::Register_Auto_Save_Variables()
+{
+	Auto_Save_Variable(&count,sizeof(count),1);
+}
 
-		char msg[250];
-		sprintf(msg,"The %s Samsites are now operational.","South West");
-		Send_Message(255,255,255,msg);
+void z_Invasion_Drop_Hummvee1::Killed(GameObject *obj, GameObject *shooter)
+{
+	Vector3 loc; loc.X = -46.938f; loc.Y = -64.767f; loc.Z = 2.018f;	float facing = 0.0f;
+	const char *Cinematic = "nod_inv_hummdrop1.txt";
+	GameObject *dropoff = Commands->Create_Object("Invisible_Object",loc);
+	Commands->Set_Facing(dropoff,facing);
+	Commands->Attach_Script(dropoff,"Test_Cinematic",Cinematic);
+	Commands->Create_2D_WAV_Sound("m00evag_dsgn0060i1evag_snd.wav");
+	Send_Message(255,204,0,"Reinforcements are enroute");
+}
+
+void z_Invasion_Drop_Hummvee2::Killed(GameObject *obj, GameObject *shooter)
+{
+	Vector3 loc; loc.X = 75.122f; loc.Y = 38.777f; loc.Z = 2.118f;	float facing = -180.0f;
+	const char *Cinematic = "nod_inv_hummdrop2.txt";
+	GameObject *dropoff = Commands->Create_Object("Invisible_Object",loc);
+	Commands->Set_Facing(dropoff,facing);
+	Commands->Attach_Script(dropoff,"Test_Cinematic",Cinematic);
+	Commands->Create_2D_WAV_Sound("m00evag_dsgn0060i1evag_snd.wav");
+	Send_Message(255,204,0,"Reinforcements are enroute");
+}
+
+void z_Invasion_Loop_Chinooks_GDIBase::Created(GameObject *obj)
+{
+	Commands->Start_Timer(obj,this,311.0f,1001);
+	Commands->Start_Timer(obj,this,314.0f,1002);
+	Commands->Start_Timer(obj,this,318.0f,1003);
+	Commands->Start_Timer(obj,this,320.0f,1004);
+}
+void z_Invasion_Loop_Chinooks_GDIBase::Timer_Expired(GameObject *obj, int number)
+{
+	if (number == 1001)
+	{
+		const char *cinematic1 = "nod_inv_infantry1.txt";
+		int dropid1 = 100095;
+		Vector3 pos1 = Commands->Get_Position(Commands->Find_Object(dropid1));
+		float fac1 = 0.000f;
+		GameObject *dropoff1 = Commands->Create_Object("Invisible_Object",pos1);
+		Commands->Set_Facing(dropoff1,fac1);
+		Commands->Attach_Script(dropoff1,"Test_Cinematic",cinematic1);
+		Commands->Start_Timer(obj,this,101.0f,1001);
+	}
+	else if (number == 1002)
+	{
+		const char *cinematic2 = "nod_inv_infantry2.txt";
+		int dropid2 = 100096;
+		Vector3 pos2 = Commands->Get_Position(Commands->Find_Object(dropid2));
+		float fac2 = -90.000f;
+		GameObject *dropoff2 = Commands->Create_Object("Invisible_Object",pos2);
+		Commands->Set_Facing(dropoff2,fac2);
+		Commands->Attach_Script(dropoff2,"Test_Cinematic",cinematic2);
+		Commands->Start_Timer(obj,this,104.0f,1002);
+	}
+	else if (number == 1003)
+	{
+		const char *cinematic3 = "nod_inv_infantry3.txt";
+		int dropid3 = 100097;
+		Vector3 pos3 = Commands->Get_Position(Commands->Find_Object(dropid3));
+		float fac3 = -180.000f;
+		GameObject *dropoff3 = Commands->Create_Object("Invisible_Object",pos3);
+		Commands->Set_Facing(dropoff3,fac3);
+		Commands->Attach_Script(dropoff3,"Test_Cinematic",cinematic3);
+		Commands->Start_Timer(obj,this,106.0f,1003);
+		Commands->Create_2D_WAV_Sound("airraid.wav");
+	}
+	if (number == 1004)
+	{
+		const char *cinematic4 = "nod_inv_infantry4.txt";
+		int dropid4 = 100098;
+		Vector3 pos4 = Commands->Get_Position(Commands->Find_Object(dropid4));
+		float fac4 = 90.000f;
+		GameObject *dropoff4 = Commands->Create_Object("Invisible_Object",pos4);
+		Commands->Set_Facing(dropoff4,fac4);
+		Commands->Attach_Script(dropoff4,"Test_Cinematic",cinematic4);
+		Commands->Start_Timer(obj,this,109.0f,1004);
+		count++;
+		if (count == 100)
+		{
 		Commands->Destroy_Object(obj);
 	}
 }
-void z_ninv_Buy_SamsiteSW::Register_Auto_Save_Variables()
+}
+void z_Invasion_Loop_Chinooks_GDIBase::Register_Auto_Save_Variables()
 {
-	Auto_Save_Variable(&funds,5,1);
+	Auto_Save_Variable(&count,sizeof(count),1);
 }
 
-void z_ninv_Buy_SamsiteNE::Created(GameObject *obj)
+void z_Invasion_Buy_Guntower_North::Created(GameObject *obj)
 {
+	pos.X = -7.462f;	pos.Y = 57.794f;	pos.Z = 7.042f;
+	pos2.X = 23.309f;	pos2.Y = 57.112f;	pos2.Z = 7.070f;
 	funds = 0;
+	totalcost = 2500.0f;
+	allowpoke = true;
 	Commands->Enable_HUD_Pokable_Indicator(obj,true);
 }
-void z_ninv_Buy_SamsiteNE::Poked(GameObject *obj, GameObject *poker)
+void z_Invasion_Buy_Guntower_North::Poked(GameObject *obj, GameObject *poker)
+{
+	if (allowpoke)
 {
-	if (funds < 2500.0f)
+		if (funds < totalcost)
 	{
 		if (Commands->Get_Money(poker) >= 500.0f)
 		{
-			funds = funds + 500.0f;
-			char fundadded[250];
-			const char *str = Get_Player_Name(poker);
-			sprintf(fundadded,"%s added $500 to the North East Samsites fundpool. (Current: %g / %g)",str,funds,2500.0f);
-			delete[] str;
-			Send_Message(255,255,255,fundadded);
 			Commands->Give_Money(poker,-500.0f,false);
+				funds+=500.0f;
+				char fundstatus[512];
+				sprintf(fundstatus,"%s added $500 to the North Guntowers fund. Current: %g of %g",Get_Player_Name(poker),funds,totalcost);
+				Send_Message(255,204,0,fundstatus);
+				if (funds == totalcost)
+				{
+					Commands->Enable_HUD_Pokable_Indicator(obj,false);
+					Commands->Start_Timer(obj,this,1.0f,20001);//please standby
+					Commands->Start_Timer(obj,this,3.0f,20002);//access granted
+					Commands->Start_Timer(obj,this,6.0f,20003);//building
+					Commands->Start_Timer(obj,this,8.0f,20004);//make the guntower appear
+				}
 		}
-		else if (Commands->Get_Money(poker) < 500.0f)
+			else
 		{
-			char nomoney[100]; 
-			sprintf(nomoney,"ppage %d Sorry you do not have enough money ($500) to add to the Samsites fundpool.",Get_Player_ID(poker));
-			Console_Input(nomoney);
+				Create_2D_WAV_Sound_Player(poker,"m00evag_dsgn0028i1evag_snd.wav");
+				Send_Message_Player(poker,255,204,0,"Insufficient funds. You do not have $500");
 		}
-
-		if (funds == 2500.0f)
+		}
+		else
 		{
-			Commands->Create_2D_WAV_Sound("building.wav");
-			Commands->Start_Timer(obj,this,3.0f,166);
+			Commands->Create_2D_WAV_Sound("m00evag_dsgn0012i1evag_snd.wav");
+			Send_Message(255,204,0,"Unable to comply building in progress: North Guntowers");
+			allowpoke = false;
 		}
 	}
 }
-void z_ninv_Buy_SamsiteNE::Timer_Expired(GameObject *obj, int number)
+void z_Invasion_Buy_Guntower_North::Timer_Expired(GameObject *obj, int number)
 {
-	if (number == 166)
+	if (number == 20001)
 	{
-		Vector3 pos1;		pos1.X = 54.800f;		pos1.Y = 41.703f;		pos1.Z = 8.693f;
-		float facing1 = 0.0f;
-		GameObject *ss1 = Commands->Create_Object("z_GDI_Sam_Site",pos1);
-		Commands->Set_Facing(ss1,facing1);
-
-		Vector3 pos2;		pos2.X = 51.580f;		pos2.Y = 35.846f;		pos2.Z = 8.713f;
-		float facing2 = 0.0f;
-		GameObject *ss2 = Commands->Create_Object("z_GDI_Sam_Site",pos2);
-		Commands->Set_Facing(ss2,facing2);
-
-		char msg[250];
-		sprintf(msg,"The %s Samsites are now operational.","North East");
-		Send_Message(255,255,255,msg);
+		Commands->Create_2D_WAV_Sound("m00evag_dsgn0030i1evag_snd.wav");
+		Send_Message(255,204,0,"Please standby");
+	}
+	else if (number == 20002)
+	{
+		Commands->Create_2D_WAV_Sound("m00evag_dsgn0045i1evag_snd.wav");
+		Send_Message(255,204,0,"Access granted");
+	}
+	else if (number == 20003)
+	{
+		Commands->Create_2D_WAV_Sound("m00evag_dsgn0004i1evag_snd.wav");
+		Send_Message(255,204,0,"Building: North Guntowers");
+	}
+	else if (number == 20004)
+	{
+		GameObject *guntower = Commands->Create_Object("GDI_Guntower",pos);
+		GameObject *guntower2 = Commands->Create_Object("GDI_Guntower",pos2);
+		Commands->Set_Facing(guntower,0.000f);
+		Commands->Disable_Physical_Collisions(guntower);
+		Commands->Set_Facing(guntower2,0.000f);
+		Commands->Disable_Physical_Collisions(guntower2);
 		Commands->Destroy_Object(obj);
 	}
 }
-void z_ninv_Buy_SamsiteNE::Register_Auto_Save_Variables()
+void z_Invasion_Buy_Guntower_North::Register_Auto_Save_Variables()
 {
-	Auto_Save_Variable(&funds,5,1);
+	Auto_Save_Variable(&pos,sizeof(pos),1);
+	Auto_Save_Variable(&totalcost,sizeof(totalcost),2);
+	Auto_Save_Variable(&funds,sizeof(funds),3);
+	Auto_Save_Variable(&allowpoke,sizeof(allowpoke),4);
+	Auto_Save_Variable(&pos2,sizeof(pos2),5);
 }
 
-void z_ninv_Buy_GuardtowerNE::Created(GameObject *obj)
+void z_Invasion_Buy_Guntower_West::Created(GameObject *obj)
 {
+	pos.X = -64.574f;	pos.Y = -46.444f;	pos.Z = 7.042f;//west
+	pos2.X = -64.051f;	pos2.Y = -11.443f;	pos2.Z = 7.010f;
 	funds = 0;
+	totalcost = 2500.0f;
+	allowpoke = true;
 	Commands->Enable_HUD_Pokable_Indicator(obj,true);
 }
-void z_ninv_Buy_GuardtowerNE::Poked(GameObject *obj, GameObject *poker)
+void z_Invasion_Buy_Guntower_West::Poked(GameObject *obj, GameObject *poker)
 {
-	if (funds < 2500.0f)
+	if (allowpoke)
+	{
+		if (funds < totalcost)
 	{
 		if (Commands->Get_Money(poker) >= 500.0f)
 		{
-			funds = funds + 500.0f;
-			char fundadded[250];
-			const char *str = Get_Player_Name(poker);
-			sprintf(fundadded,"%s added $500 to the North East Guard Tower fundpool. (Current: %g / %g)",str,funds,2500.0f);
-			delete[] str;
-			Send_Message(255,255,255,fundadded);
 			Commands->Give_Money(poker,-500.0f,false);
+				funds+=500.0f;
+				char fundstatus[512];
+				sprintf(fundstatus,"%s added $500 to the West Guntowers fund. Current: %g of %g",Get_Player_Name(poker),funds,totalcost);
+				Send_Message(255,204,0,fundstatus);
+				if (funds == totalcost)
+				{
+					Commands->Enable_HUD_Pokable_Indicator(obj,false);
+					Commands->Start_Timer(obj,this,1.0f,20001);//please standby
+					Commands->Start_Timer(obj,this,3.0f,20002);//access granted
+					Commands->Start_Timer(obj,this,6.0f,20003);//building
+					Commands->Start_Timer(obj,this,8.0f,20004);//make the guntower appear
 		}
-		else if (Commands->Get_Money(poker) < 500.0f)
+			}
+			else
 		{
-			char nomoney[100]; 
-			sprintf(nomoney,"ppage %d Sorry you do not have enough money ($500) to add to the Guard Tower fundpool.",Get_Player_ID(poker));
-			Console_Input(nomoney);
+				Create_2D_WAV_Sound_Player(poker,"m00evag_dsgn0028i1evag_snd.wav");
+				Send_Message_Player(poker,255,204,0,"Insufficient funds. You do not have $500");
 		}
-
-		if (funds == 2500.0f)
+		}
+		else
 		{
-			Commands->Create_2D_WAV_Sound("building.wav");
-			Commands->Start_Timer(obj,this,3.0f,166);
+			Commands->Create_2D_WAV_Sound("m00evag_dsgn0012i1evag_snd.wav");
+			Send_Message(255,204,0,"Unable to comply building in progress: West Guntowers");
+			allowpoke = false;
 		}
 	}
 }
-void z_ninv_Buy_GuardtowerNE::Timer_Expired(GameObject *obj, int number)
+void z_Invasion_Buy_Guntower_West::Timer_Expired(GameObject *obj, int number)
 {
-	if (number == 166)
+	if (number == 20001)
 	{
-		Vector3 pos1;		pos1.X = 66.869f;		pos1.Y = 39.652f;		pos1.Z = 7.172f;
-		float facing1 = 0.0f;
-		GameObject *ss1 = Commands->Create_Object("z_GDI_GuardTower",pos1);
-		Commands->Set_Facing(ss1,facing1);
-
-		Vector3 pos2;		pos2.X = 54.206f;		pos2.Y = 49.450f;		pos2.Z = 7.172f;
-		float facing2 = 0.0f;
-		GameObject *ss2 = Commands->Create_Object("z_GDI_GuardTower",pos2);
-		Commands->Set_Facing(ss2,facing2);
-
-		char msg[250];
-		sprintf(msg,"The %s Guard Towers are now operational.","North East");
-		Send_Message(255,255,255,msg);
+		Commands->Create_2D_WAV_Sound("m00evag_dsgn0030i1evag_snd.wav");
+		Send_Message(255,204,0,"Please standby");
+	}
+	else if (number == 20002)
+	{
+		Commands->Create_2D_WAV_Sound("m00evag_dsgn0045i1evag_snd.wav");
+		Send_Message(255,204,0,"Access granted");
+	}
+	else if (number == 20003)
+	{
+		Commands->Create_2D_WAV_Sound("m00evag_dsgn0004i1evag_snd.wav");
+		Send_Message(255,204,0,"Building: West Guntowers");
+	}
+	else if (number == 20004)
+	{
+		GameObject *guntower = Commands->Create_Object("GDI_Guntower",pos);
+		GameObject *guntower2 = Commands->Create_Object("GDI_Guntower",pos2);
+		Commands->Set_Facing(guntower,0.000f);
+		Commands->Disable_Physical_Collisions(guntower);
+		Commands->Set_Facing(guntower2,0.000f);
+		Commands->Disable_Physical_Collisions(guntower2);
 		Commands->Destroy_Object(obj);
 	}
 }
-void z_ninv_Buy_GuardtowerNE::Register_Auto_Save_Variables()
+void z_Invasion_Buy_Guntower_West::Register_Auto_Save_Variables()
 {
-	Auto_Save_Variable(&funds,5,1);
+	Auto_Save_Variable(&pos,sizeof(pos),1);
+	Auto_Save_Variable(&totalcost,sizeof(totalcost),2);
+	Auto_Save_Variable(&funds,sizeof(funds),3);
+	Auto_Save_Variable(&allowpoke,sizeof(allowpoke),4);
+	Auto_Save_Variable(&pos2,sizeof(pos2),5);
 }
 
-void z_ninv_Buy_GuardtowerSW::Created(GameObject *obj)
+void z_Invasion_Buy_Guntower_South::Created(GameObject *obj)
 {
+	pos.X = 21.602f;	pos.Y = -81.324f;	pos.Z = 7.042f;
+	pos2.X = -20.775f;	pos2.Y = -80.544f;	pos2.Z = 7.027f;
 	funds = 0;
+	totalcost = 2500.0f;
+	allowpoke = true;
 	Commands->Enable_HUD_Pokable_Indicator(obj,true);
 }
-void z_ninv_Buy_GuardtowerSW::Poked(GameObject *obj, GameObject *poker)
+void z_Invasion_Buy_Guntower_South::Poked(GameObject *obj, GameObject *poker)
+{
+	if (allowpoke)
 {
-	if (funds < 2500.0f)
+		if (funds < totalcost)
 	{
 		if (Commands->Get_Money(poker) >= 500.0f)
 		{
-			funds = funds + 500.0f;
-			char fundadded[250];
-			const char *str = Get_Player_Name(poker);
-			sprintf(fundadded,"%s added $500 to the South West Guard Tower fundpool. (Current: %g / %g)",str,funds,2500.0f);
-			delete[] str;
-			Send_Message(255,255,255,fundadded);
 			Commands->Give_Money(poker,-500.0f,false);
+				funds+=500.0f;
+				char fundstatus[512];
+				sprintf(fundstatus,"%s added $500 to the South Guntowers fund. Current: %g of %g",Get_Player_Name(poker),funds,totalcost);
+				Send_Message(255,204,0,fundstatus);
+				if (funds == totalcost)
+				{
+					Commands->Enable_HUD_Pokable_Indicator(obj,false);
+					Commands->Start_Timer(obj,this,1.0f,20001);//please standby
+					Commands->Start_Timer(obj,this,3.0f,20002);//access granted
+					Commands->Start_Timer(obj,this,6.0f,20003);//building
+					Commands->Start_Timer(obj,this,8.0f,20004);//make the guntower appear
+				}
 		}
-		else if (Commands->Get_Money(poker) < 500.0f)
+			else
 		{
-			char nomoney[100]; 
-			sprintf(nomoney,"ppage %d Sorry you do not have enough money ($500) to add to the Guard Tower fundpool.",Get_Player_ID(poker));
-			Console_Input(nomoney);
+				Create_2D_WAV_Sound_Player(poker,"m00evag_dsgn0028i1evag_snd.wav");
+				Send_Message_Player(poker,255,204,0,"Insufficient funds. You do not have $500");
 		}
-
-		if (funds == 2500.0f)
+		}
+		else
 		{
-			Commands->Create_2D_WAV_Sound("building.wav");
-			Commands->Start_Timer(obj,this,3.0f,166);
+			Commands->Create_2D_WAV_Sound("m00evag_dsgn0012i1evag_snd.wav");
+			Send_Message(255,204,0,"Unable to comply building in progress: South Guntowers");
+			allowpoke = false;
 		}
 	}
 }
-void z_ninv_Buy_GuardtowerSW::Timer_Expired(GameObject *obj, int number)
+void z_Invasion_Buy_Guntower_South::Timer_Expired(GameObject *obj, int number)
 {
-	if (number == 166)
+	if (number == 20001)
 	{
-		Vector3 pos1;		pos1.X = -32.288f;		pos1.Y = -60.183f;		pos1.Z = 7.096f;
-		float facing1 = 0.0f;
-		GameObject *ss1 = Commands->Create_Object("z_GDI_GuardTower",pos1);
-		Commands->Set_Facing(ss1,facing1);
-
-		Vector3 pos2;		pos2.X = -44.195f;		pos2.Y = -49.544f;		pos2.Z = 7.096f;
-		float facing2 = 0.0f;
-		GameObject *ss2 = Commands->Create_Object("z_GDI_GuardTower",pos2);
-		Commands->Set_Facing(ss2,facing2);
-
-		char msg[250];
-		sprintf(msg,"The %s Guard Towers are now operational.","South West");
-		Send_Message(255,255,255,msg);
+		Commands->Create_2D_WAV_Sound("m00evag_dsgn0030i1evag_snd.wav");
+		Send_Message(255,204,0,"Please standby");
+	}
+	else if (number == 20002)
+	{
+		Commands->Create_2D_WAV_Sound("m00evag_dsgn0045i1evag_snd.wav");
+		Send_Message(255,204,0,"Access granted");
+	}
+	else if (number == 20003)
+	{
+		Commands->Create_2D_WAV_Sound("m00evag_dsgn0004i1evag_snd.wav");
+		Send_Message(255,204,0,"Building: South Guntowers");
+	}
+	else if (number == 20004)
+	{
+		GameObject *guntower = Commands->Create_Object("GDI_Guntower",pos);
+		GameObject *guntower2 = Commands->Create_Object("GDI_Guntower",pos2);
+		Commands->Set_Facing(guntower,0.000f);
+		Commands->Disable_Physical_Collisions(guntower);
+		Commands->Set_Facing(guntower2,0.000f);
+		Commands->Disable_Physical_Collisions(guntower2);
 		Commands->Destroy_Object(obj);
 	}
 }
-void z_ninv_Buy_GuardtowerSW::Register_Auto_Save_Variables()
+void z_Invasion_Buy_Guntower_South::Register_Auto_Save_Variables()
 {
-	Auto_Save_Variable(&funds,5,1);
+	Auto_Save_Variable(&pos,sizeof(pos),1);
+	Auto_Save_Variable(&totalcost,sizeof(totalcost),2);
+	Auto_Save_Variable(&funds,sizeof(funds),3);
+	Auto_Save_Variable(&allowpoke,sizeof(allowpoke),4);
+	Auto_Save_Variable(&pos2,sizeof(pos2),5);
 }
 
-ScriptRegistrant<z_ninv_Buy_GuardtowerSW> z_ninv_Buy_GuardtowerSW_Registrant("z_ninv_Buy_GuardtowerSW","");
-ScriptRegistrant<z_ninv_Buy_GuardtowerNE> z_ninv_Buy_GuardtowerNE_Registrant("z_ninv_Buy_GuardtowerNE","");
-ScriptRegistrant<z_ninv_Buy_SamsiteNE> z_ninv_Buy_SamsiteNE_Registrant("z_ninv_Buy_SamsiteNE","");
-ScriptRegistrant<z_ninv_Buy_SamsiteSW> z_ninv_Buy_SamsiteSW_Registrant("z_ninv_Buy_SamsiteSW","");
-ScriptRegistrant<z_ninv_CivCount> z_ninv_CivCount_Registrant("z_ninv_CivCount","Civs=6:int");
-ScriptRegistrant<z_ninv_Civilian> z_ninv_Civilian_Registrant("z_ninv_Civilian","");
-ScriptRegistrant<z_ninv_MissionStart> z_ninv_MissionStart_Registrant("z_ninv_MissionStart","");
\ No newline at end of file
+void z_Invasion_Buy_Guntower_East::Created(GameObject *obj)
+{
+	pos.X = 91.753f;	pos.Y = 21.550f;	pos.Z = 7.042f;//east
+	pos2.X = 90.502f;	pos2.Y = -12.639f;	pos2.Z = 6.933f;
+	funds = 0;
+	totalcost = 2500.0f;
+	allowpoke = true;
+	Commands->Enable_HUD_Pokable_Indicator(obj,true);
+}
+void z_Invasion_Buy_Guntower_East::Poked(GameObject *obj, GameObject *poker)
+{
+	if (allowpoke)
+	{
+		if (funds < totalcost)
+		{
+			if (Commands->Get_Money(poker) >= 500.0f)
+			{
+				Commands->Give_Money(poker,-500.0f,false);
+				funds+=500.0f;
+				char fundstatus[512];
+				sprintf(fundstatus,"%s added $500 to the East Guntowers fund. Current: %g of %g",Get_Player_Name(poker),funds,totalcost);
+				Send_Message(255,204,0,fundstatus);
+				if (funds == totalcost)
+				{
+					Commands->Enable_HUD_Pokable_Indicator(obj,false);
+					Commands->Start_Timer(obj,this,1.0f,20001);//please standby
+					Commands->Start_Timer(obj,this,3.0f,20002);//access granted
+					Commands->Start_Timer(obj,this,6.0f,20003);//building
+					Commands->Start_Timer(obj,this,8.0f,20004);//make the guntower appear
+				}
+			}
+			else
+			{
+				Create_2D_WAV_Sound_Player(poker,"m00evag_dsgn0028i1evag_snd.wav");
+				Send_Message_Player(poker,255,204,0,"Insufficient funds. You do not have $500");
+			}
+		}
+		else
+		{
+			Commands->Create_2D_WAV_Sound("m00evag_dsgn0012i1evag_snd.wav");
+			Send_Message(255,204,0,"Unable to comply building in progress: East Guntowers");
+			allowpoke = false;
+		}
+	}
+}
+void z_Invasion_Buy_Guntower_East::Timer_Expired(GameObject *obj, int number)
+{
+	if (number == 20001)
+	{
+		Commands->Create_2D_WAV_Sound("m00evag_dsgn0030i1evag_snd.wav");
+		Send_Message(255,204,0,"Please standby");
+	}
+	else if (number == 20002)
+	{
+		Commands->Create_2D_WAV_Sound("m00evag_dsgn0045i1evag_snd.wav");
+		Send_Message(255,204,0,"Access granted");
+	}
+	else if (number == 20003)
+	{
+		Commands->Create_2D_WAV_Sound("m00evag_dsgn0004i1evag_snd.wav");
+		Send_Message(255,204,0,"Building: East Guntowers");
+	}
+	else if (number == 20004)
+	{
+		GameObject *guntower = Commands->Create_Object("GDI_Guntower",pos);
+		GameObject *guntower2 = Commands->Create_Object("GDI_Guntower",pos2);
+		Commands->Set_Facing(guntower,0.000f);
+		Commands->Disable_Physical_Collisions(guntower);
+		Commands->Set_Facing(guntower2,0.000f);
+		Commands->Disable_Physical_Collisions(guntower2);
+		Commands->Destroy_Object(obj);
+	}
+}
+void z_Invasion_Buy_Guntower_East::Register_Auto_Save_Variables()
+{
+	Auto_Save_Variable(&pos,sizeof(pos),1);
+	Auto_Save_Variable(&totalcost,sizeof(totalcost),2);
+	Auto_Save_Variable(&funds,sizeof(funds),3);
+	Auto_Save_Variable(&allowpoke,sizeof(allowpoke),4);
+	Auto_Save_Variable(&pos2,sizeof(pos2),5);
+}
+
+ScriptRegistrant<z_Invasion_Buy_Guntower_East> z_Invasion_Buy_Guntower_East_Registrant("z_Invasion_Buy_Guntower_East","");
+ScriptRegistrant<z_Invasion_Buy_Guntower_South> z_Invasion_Buy_Guntower_South_Registrant("z_Invasion_Buy_Guntower_South","");
+ScriptRegistrant<z_Invasion_Buy_Guntower_West> z_Invasion_Buy_Guntower_West_Registrant("z_Invasion_Buy_Guntower_West","");
+ScriptRegistrant<z_Invasion_Buy_Guntower_North> z_Invasion_Buy_Guntower_North_Registrant("z_Invasion_Buy_Guntower_North","");
+ScriptRegistrant<z_Invasion_Loop_Chinooks_GDIBase> z_Invasion_Loop_Chinooks_GDIBase_Registrant("z_Invasion_Loop_Chinooks_GDIBase","");
+ScriptRegistrant<z_Invasion_Drop_Hummvee2> z_Invasion_Drop_Hummvee2_Registrant("z_Invasion_Drop_Hummvee2","");
+ScriptRegistrant<z_Invasion_Drop_Hummvee1> z_Invasion_Drop_Hummvee1_Registrant("z_Invasion_Drop_Hummvee1","");
+ScriptRegistrant<z_Invasion_Loop_Badgerdrop> z_Invasion_Loop_Badgerdrop_Registrant("z_Invasion_Loop_Badgerdrop","");
+ScriptRegistrant<z_Invasion_Drop_Harvester> z_Invasion_Drop_Harvester_Registrant("z_Invasion_Drop_Harvester","");
+ScriptRegistrant<z_Invasion_Enemy> z_Invasion_Enemy_Registrant("z_Invasion_Enemy","");
+ScriptRegistrant<z_Invasion_Bot_Counter> z_Invasion_Bot_Counter_Registrant("z_Invasion_Bot_Counter","");
+ScriptRegistrant<z_Invasion_Hostage_Count> z_Invasion_Hostage_Count_Registrant("z_Invasion_Hostage_Count","");
+ScriptRegistrant<z_Invasion_Hostage> z_Invasion_Hostage_Registrant("z_Invasion_Hostage","Hostage_Name=zunnie:string");
+ScriptRegistrant<z_Poke_Play_Cinematic> z_Poke_Play_Cinematic_Registrant("z_Poke_Play_Cinematic","Cinematic=bla:string,DropID=0:int,Facing=0:float");
\ No newline at end of file
diff -uwr sourceold/scripts/z_nod_invasion.h source/scripts/z_nod_invasion.h
--- sourceold/scripts/z_nod_invasion.h	2011-10-14 22:27:31.970703100 +0800
+++ source/scripts/z_nod_invasion.h	2012-04-14 04:09:47.353515600 +0800
@@ -1,5 +1,5 @@
 /*	Renegade Scripts.dll
-	Copyright 2011 Tiberian Technologies
+	Copyright 2012 UltraAOW.COM
 
 	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
@@ -9,55 +9,124 @@
 	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.
 */
+
+
 #pragma once
 
-class z_ninv_MissionStart : public ScriptImpClass {
+class z_Poke_Play_Cinematic : public ScriptImpClass {
 	void Created(GameObject *obj);
+	void Poked(GameObject *obj, GameObject *poker);
 	void Timer_Expired(GameObject *obj, int number);
-	bool play;
+	public: void Register_Auto_Save_Variables();
+	bool allowpoke;
 };
 
-class z_ninv_Civilian : public ScriptImpClass {
-	void Killed(GameObject *obj, GameObject *shooter);
+class z_Invasion_Hostage : public ScriptImpClass {
+	void Created(GameObject *obj);
+	void Poked(GameObject *obj, GameObject *poker);
+	void Timer_Expired(GameObject *obj, int number);
+	void Destroyed(GameObject *obj);
+	void Damaged(GameObject *obj, GameObject *damager, float damage);
+	public: void Register_Auto_Save_Variables();
+	bool playpoke;
+	bool playpain;
+	const char *hostyname;
+	const char *hostypokesound;
+	int FollowID;
 };
 
-class z_ninv_CivCount : public ScriptImpClass {
+class z_Invasion_Hostage_Count : public ScriptImpClass {
 	void Created(GameObject *obj);
 	void Custom(GameObject *obj, int message, int param, GameObject *sender);
 	void Timer_Expired(GameObject *obj, int number);
 	public: void Register_Auto_Save_Variables();
-	int alive;
+	int deaths;
+};
+
+class z_Invasion_Bot_Counter : public ScriptImpClass {
+	void Created(GameObject *obj);
+	void Custom(GameObject *obj, int message, int param, GameObject *sender);
+	void Timer_Expired(GameObject *obj, int number);
+	public: void Register_Auto_Save_Variables();
+	int botcount;
+	bool endgame;
+};
+
+class z_Invasion_Enemy : public ScriptImpClass {
+	void Created(GameObject *obj);
+	void Destroyed(GameObject *obj);
+};
+
+class z_Invasion_Drop_Harvester : public ScriptImpClass {
+	void Killed(GameObject *obj, GameObject *shooter);
+};
+
+class z_Invasion_Loop_Badgerdrop : public ScriptImpClass {
+	void Created(GameObject *obj);
+	void Timer_Expired(GameObject *obj, int number);
+	public: void Register_Auto_Save_Variables();
+	int count;
+};
+
+class z_Invasion_Drop_Hummvee1 : public ScriptImpClass {
+	void Killed(GameObject *obj, GameObject *shooter);
 };
 
-class z_ninv_Buy_SamsiteSW : public ScriptImpClass {
+class z_Invasion_Drop_Hummvee2 : public ScriptImpClass {
+	void Killed(GameObject *obj, GameObject *shooter);
+};
+
+class z_Invasion_Loop_Chinooks_GDIBase : public ScriptImpClass {
+	void Created(GameObject *obj);
+	void Timer_Expired(GameObject *obj, int number);
+	public: void Register_Auto_Save_Variables();
+	int count;
+};
+
+class z_Invasion_Buy_Guntower_North : public ScriptImpClass {
 	void Created(GameObject *obj);
 	void Poked(GameObject *obj, GameObject *poker);
 	void Timer_Expired(GameObject *obj, int number);
 	public: void Register_Auto_Save_Variables();
 	float funds;
+	float totalcost;
+	Vector3 pos;
+	Vector3 pos2;
+	bool allowpoke;
 };
 
-class z_ninv_Buy_SamsiteNE : public ScriptImpClass {
+class z_Invasion_Buy_Guntower_West : public ScriptImpClass {
 	void Created(GameObject *obj);
 	void Poked(GameObject *obj, GameObject *poker);
 	void Timer_Expired(GameObject *obj, int number);
 	public: void Register_Auto_Save_Variables();
 	float funds;
+	float totalcost;
+	Vector3 pos;
+	Vector3 pos2;
+	bool allowpoke;
 };
 
-class z_ninv_Buy_GuardtowerNE : public ScriptImpClass {
+class z_Invasion_Buy_Guntower_South : public ScriptImpClass {
 	void Created(GameObject *obj);
 	void Poked(GameObject *obj, GameObject *poker);
 	void Timer_Expired(GameObject *obj, int number);
 	public: void Register_Auto_Save_Variables();
 	float funds;
+	float totalcost;
+	Vector3 pos;
+	Vector3 pos2;
+	bool allowpoke;
 };
 
-class z_ninv_Buy_GuardtowerSW : public ScriptImpClass {
+class z_Invasion_Buy_Guntower_East : public ScriptImpClass {
 	void Created(GameObject *obj);
 	void Poked(GameObject *obj, GameObject *poker);
 	void Timer_Expired(GameObject *obj, int number);
 	public: void Register_Auto_Save_Variables();
 	float funds;
+	float totalcost;
+	Vector3 pos;
+	Vector3 pos2;
+	bool allowpoke;
 };
-
Only in source/scripts: z_prototype.cpp
Only in source/scripts: z_prototype.h
diff -uwr sourceold/scripts/z_siege.cpp source/scripts/z_siege.cpp
--- sourceold/scripts/z_siege.cpp	2011-10-11 23:13:42.152343700 +0800
+++ source/scripts/z_siege.cpp	2012-04-28 01:56:47.412109300 +0800
@@ -86,14 +86,14 @@
 {
 	if (Commands->Is_A_Star(enter))
 	{
-		if (Commands->Get_Health(Find_Building(0,BuildingConstants::TYPE_SOLDIER_FACTORY)) >= 1.0f)//only enable if bar is alive
+		if (Find_Building_By_Type(0,BuildingConstants::TYPE_SOLDIER_FACTORY) && Commands->Get_Health(Find_Building_By_Type(0,BuildingConstants::TYPE_SOLDIER_FACTORY)) >= 1.0f)//only enable if bar is alive
 		{
 			Commands->Enable_Spawner(100732,true);
 			Commands->Enable_Spawner(100732,true);
 			Commands->Enable_Spawner(100732,true);
 			Commands->Enable_Spawner(100732,true);
 		}
-		if (Commands->Get_Health(Find_Building(0,BuildingConstants::TYPE_VEHICLE_FACTORY)) >= 1.0f)//only enable if wf is alive
+		if (Find_Building_By_Type(0,BuildingConstants::TYPE_VEHICLE_FACTORY) && Commands->Get_Health(Find_Building_By_Type(0,BuildingConstants::TYPE_VEHICLE_FACTORY)) >= 1.0f)//only enable if wf is alive
 		{
 			Commands->Enable_Spawner(100732,true);
 			Commands->Enable_Spawner(100732,true);
@@ -108,14 +108,14 @@
 {
 	if (Commands->Is_A_Star(enter))
 	{
-		if (Commands->Get_Health(Find_Building(0,BuildingConstants::TYPE_SOLDIER_FACTORY)) >= 1.0f)//only enable if bar is alive
+		if (Find_Building_By_Type(0,BuildingConstants::TYPE_SOLDIER_FACTORY) && Commands->Get_Health(Find_Building_By_Type(0,BuildingConstants::TYPE_SOLDIER_FACTORY)) >= 1.0f)//only enable if bar is alive
 		{
 			Commands->Enable_Spawner(100732,true);
 			Commands->Enable_Spawner(100732,true);
 			Commands->Enable_Spawner(100732,true);
 			Commands->Enable_Spawner(100732,true);
 		}
-		if (Commands->Get_Health(Find_Building(0,BuildingConstants::TYPE_VEHICLE_FACTORY)) >= 1.0f)//only enable if wf is alive
+		if (Find_Building_By_Type(0,BuildingConstants::TYPE_VEHICLE_FACTORY) && Commands->Get_Health(Find_Building_By_Type(0,BuildingConstants::TYPE_VEHICLE_FACTORY)) >= 1.0f)//only enable if wf is alive
 		{
 			Commands->Enable_Spawner(100732,true);
 			Commands->Enable_Spawner(100732,true);
Only in source/scripts: z_tropical.cpp
Only in source/scripts: z_tropical.h
diff -uwr sourceold/scripts/z_uberaow.cpp source/scripts/z_uberaow.cpp
--- sourceold/scripts/z_uberaow.cpp	2011-10-11 23:13:40.107421800 +0800
+++ source/scripts/z_uberaow.cpp	2012-04-28 01:56:21.067382800 +0800
@@ -88,7 +88,7 @@
 			{
 				if (Commands->Get_Player_Type(obj) == 0)
 				{
-					if (Commands->Get_Health(Find_Building(0,BuildingConstants::TYPE_REFINERY)) > 1.0f)
+					if (Find_Building_By_Type(0,BuildingConstants::TYPE_REFINERY) && Commands->Get_Health(Find_Building_By_Type(0,BuildingConstants::TYPE_REFINERY)) > 1.0f)
 					{
 						Commands->Give_Money(obj,500.0f,true);
 						Commands->Give_Points(Get_GameObj(plid),50.0f,false);
@@ -101,7 +101,7 @@
 				}
 				else if (Commands->Get_Player_Type(obj) == 1)
 				{
-					if (Commands->Get_Health(Find_Building(1,BuildingConstants::TYPE_REFINERY)) > 1.0f)
+					if (Find_Building_By_Type(1,BuildingConstants::TYPE_REFINERY) && Commands->Get_Health(Find_Building_By_Type(1,BuildingConstants::TYPE_REFINERY)) > 1.0f)
 					{
 						Commands->Give_Money(obj,500.0f,true);
 						Commands->Give_Points(Get_GameObj(plid),50.0f,false);
@@ -230,7 +230,7 @@
 
 void z_POW_ObiGun::Custom(GameObject *obj, int message, int param, GameObject *sender)
 {
-	if (message	== 1000000025)
+	if (message	== CUSTOM_EVENT_POWERUP_GRANTED)
 	{
 		Send_Message_Player(sender,104,234,40,"You lucky ass you got the Obelisk Weapon!");
 		Commands->Send_Custom_Event(obj,sender,1000,1,1);//start obi revoke timer
diff -uwr sourceold/scripts/z_zones.cpp source/scripts/z_zones.cpp
--- sourceold/scripts/z_zones.cpp	2011-10-11 23:14:32.120117100 +0800
+++ source/scripts/z_zones.cpp	2012-06-09 08:11:12.287109300 +0800
@@ -17,7 +17,7 @@
 #include "VehicleGameObjDef.h"
 #include "z_zones.h"
 #include "BaseControllerClass.h"
-
+#include "ScriptableGameObj.h"
 
 void z_Sell_Zone::Entered(GameObject *obj,GameObject *enterer)
 {
@@ -30,7 +30,7 @@
 	{
 		
 		int Player_Type = Get_Int_Parameter("Player_Type");
-		if (!Is_Building_Dead(Find_Building(Player_Type,BuildingConstants::TYPE_REPAIR_BAY)))
+		if (Find_Building_By_Type(Player_Type,BuildingConstants::TYPE_REPAIR_BAY) && !Is_Building_Dead(Find_Building_By_Type(Player_Type,BuildingConstants::TYPE_REPAIR_BAY)))
 		{
 			if (CheckPlayerType(enterer,Player_Type))
 			{
@@ -45,7 +45,7 @@
 			{
 				return;
 			}
-			if (Is_Vehicle(enterer))
+			if (enterer->As_VehicleGameObj())
 			{
 				Create_2D_Sound_Player(Get_Vehicle_Driver(enterer),Get_Parameter("Sound"));
 				InstallHook("Sell",Get_Vehicle_Driver(enterer));
@@ -78,7 +78,7 @@
 		RemoveHook();
 		ID = 0;
 	}
-	if (Is_Vehicle(Commands->Find_Object(ID)))
+	if (Commands->Find_Object(ID)->As_VehicleGameObj())
 	{
 		if (Get_Vehicle_Driver(Commands->Find_Object(ID)))
 		{
@@ -110,14 +110,14 @@
 
 void z_Aircraft_Refill::Entered(GameObject *obj, GameObject *enterer)
 {
-	if (!Is_Building_Dead(Find_Building(Get_Int_Parameter("TeamSelection"),BuildingConstants::TYPE_HELIPAD)))
+	if (Find_Building_By_Type(Get_Int_Parameter("TeamSelection"),BuildingConstants::TYPE_HELIPAD) && !Is_Building_Dead(Find_Building_By_Type(Get_Int_Parameter("TeamSelection"),BuildingConstants::TYPE_HELIPAD)))
 	{
 		if (Commands->Get_Player_Type(enterer) == Get_Int_Parameter("TeamSelection"))
 		{
 			if (!active)
 			{
 				GameObject *vobj = 0;
-				if (Is_Vehicle(enterer))
+				if (enterer->As_VehicleGameObj())
 				{
 					vobj = enterer;
 				}
@@ -148,12 +148,16 @@
 	Vector3 pos2;
 	float distance;
 	GameObject *object = Commands->Find_Object(number);
+	if (!object)
+	{
+		return;
+	}
 	pos1 = Commands->Get_Position(obj);
 	pos2 = Commands->Get_Position(object);
 	distance = Commands->Get_Distance(pos1,pos2);
 	if (distance <= 10.0)
 	{
-		if (Is_Vehicle(object))
+		if (object->As_VehicleGameObj())
 		{
 			if (Get_Vehicle_Mode(object) == VEHICLE_TYPE_FLYING && Get_Vehicle_Driver(object))
 			{
@@ -168,8 +172,8 @@
 void z_Repair_Zone_No_Boats::Entered(GameObject *obj,GameObject *enterer)
 {
 	int Player_Type = Get_Int_Parameter("Player_Type");
-	//if (!Is_Building_Dead(Find_Building(Get_Int_Parameter("TeamSelection"),BuildingConstants::TYPE_HELIPAD)))
-	if (!Is_Building_Dead(Find_Building_By_Name(Player_Type,"mp_Allied_Naval_Yard")))
+	//if (!Is_Building_Dead(Find_Building_By_Type(Get_Int_Parameter("TeamSelection"),BuildingConstants::TYPE_HELIPAD)))
+	if (Find_Building_By_Preset(Player_Type,"mp_Allied_Naval_Yard") && !Is_Building_Dead(Find_Building_By_Preset(Player_Type,"mp_Allied_Naval_Yard")))
 	{
 		if (CheckPlayerType(enterer,Player_Type))
 		{
@@ -184,7 +188,7 @@
 		{
 			return;
 		}
-		if (Is_Vehicle(enterer) && !Is_Script_Attached(enterer,"JFW_Boat"))
+		if (enterer->As_VehicleGameObj() && !Is_Script_Attached(enterer,"JFW_Boat"))
 		{
 			Create_2D_Sound_Player(Get_Vehicle_Driver(enterer),Get_Parameter("Sound"));
 			InstallHook("Repair",Get_Vehicle_Driver(enterer));
@@ -282,7 +286,7 @@
 
 void z_Helipad_Zone::Entered(GameObject *obj, GameObject *enterer)
 {
-	if (!Is_Building_Dead(Find_Building(Get_Int_Parameter("TeamSelection"),BuildingConstants::TYPE_HELIPAD)))
+	if (Find_Building_By_Type(Get_Int_Parameter("TeamSelection"),BuildingConstants::TYPE_HELIPAD) && !Is_Building_Dead(Find_Building_By_Type(Get_Int_Parameter("TeamSelection"),BuildingConstants::TYPE_HELIPAD)))
 	{
 		if (Commands->Get_Player_Type(enterer) == Get_Int_Parameter("TeamSelection"))
 		{
@@ -321,7 +325,7 @@
 {
 	if (Is_Script_Attached(enterer, "RA_Ore_Truck")) //Is this an Ore Truck?
 	{
-		if (!Is_Building_Dead(Find_Building(Get_Int_Parameter("Team"),BuildingConstants::TYPE_REFINERY)))
+		if (Find_Building_By_Type(Get_Int_Parameter("Team"),BuildingConstants::TYPE_REFINERY) && !Is_Building_Dead(Find_Building_By_Type(Get_Int_Parameter("Team"),BuildingConstants::TYPE_REFINERY)))
 		{
 			if (Commands->Get_Player_Type(enterer) == Get_Int_Parameter("Team")) //Is it a friendly truck?
 			{
@@ -348,7 +352,7 @@
 	{
 		return;
 	}
-	if (Is_Vehicle(enterer) && Is_Script_Attached(enterer,"JFW_Boat"))
+	if (enterer->As_VehicleGameObj() && Is_Script_Attached(enterer,"JFW_Boat"))
 	{
 		Create_2D_Sound_Player(Get_Vehicle_Driver(enterer),Get_Parameter("Sound"));
 		InstallHook("Repair",Get_Vehicle_Driver(enterer));
diff -uwr sourceold/swap/Swap.vcxproj source/swap/Swap.vcxproj
--- sourceold/swap/Swap.vcxproj	2011-11-26 13:18:00.907226500 +0800
+++ source/swap/Swap.vcxproj	2012-05-28 13:38:16.335554800 +0800
@@ -153,7 +153,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
diff -uwr sourceold/tdbedit/Search.cpp source/tdbedit/Search.cpp
--- sourceold/tdbedit/Search.cpp	2011-10-11 23:02:47.273437500 +0800
+++ source/tdbedit/Search.cpp	2012-05-02 02:18:04.281250000 +0800
@@ -18,6 +18,9 @@
 #include "tdbedit.h"
 #include "resource.h"
 #include "search.h"
+#include "PresetMgr.h"
+#include "AudibleSoundDefinitionClass.h"
+#include "DefinitionMgrClass.h"
 
 HWND g_List = NULL;
 HWND g_Results = NULL;
@@ -369,6 +372,7 @@
 
 #pragma warning (disable : 4311 4312)
 
+extern bool presetloaded;
 void StoreInfo(HWND hDlg, TDBObjClass *obj)
 {
 	char temp[1000];
@@ -426,13 +430,33 @@
 		}
 	}
 	obj->Set_String(TranslateDBClass::Get_Current_Language(),newstr);
+	if (presetloaded)
+	{
+		char lBuf[256];
+		GetDlgItemTextA(hDlg, IDC_SOUND_ID, lBuf, 256);
+		DefinitionClass *definition = DefinitionMgrClass::Find_Named_Definition(lBuf,false);
+		if (definition)
+		{
+			obj->Set_Sound_ID(definition->Get_ID());
+		}
+		else
+		{
+			obj->Set_Sound_ID(0);
+		}
+	}
+	else
+	{
 	int snd = GetDlgItemInt(hDlg,IDC_SOUND_ID,&b,true);
 	if (b)
 	{
 		obj->Set_Sound_ID(snd);
 	}
+		else
+		{
+			obj->Set_Sound_ID(0);
+		}
+	}
 }
-
 void DoInfo(HWND hDlg, TDBObjClass *obj)
 {
 	unsigned long ID = obj->Get_Sound_ID();
@@ -477,8 +501,203 @@
 		}
 		SetDlgItemText(hDlg, IDC_TEXT, newstr);
 	}
+	if (presetloaded)
+	{
+		PresetClass *preset = PresetMgrClass::Find_Preset(ID);
+		if (preset && preset->Get_Definition() && preset->Get_Definition()->Get_Name())
+		{
+			SetDlgItemTextA(hDlg, IDC_SOUND_ID, preset->Get_Definition()->Get_Name());
+			EnableWindow(GetDlgItem(hDlg,IDC_SOUND_ID),false);
+		}
+	}
+	else
+	{
+		EnableWindow(GetDlgItem(hDlg,IDSOUND),false);
 	SetDlgItemInt(hDlg, IDC_SOUND_ID, ID, true);
 }
+}
+
+HTREEITEM TreeViewInsertItem(HWND tree,const char *text,HTREEITEM parent,HTREEITEM insertafter)
+{
+	TVINSERTSTRUCTA str;
+	str.hParent = parent;
+	str.hInsertAfter = insertafter;
+	str.item.mask = TVIF_TEXT;
+	str.item.pszText = (LPSTR)text;
+	return (HTREEITEM)SendMessage(tree,TVM_INSERTITEMA,0,(LPARAM)&str);
+}
+struct TreeItemData
+{
+	int type;
+	void *ptr;
+};
+void TreeViewSetData(HWND tree,HTREEITEM item,void *data,int type)
+{
+	TVITEM tv;
+	tv.mask = TVIF_PARAM;
+	tv.hItem = item;
+	SendMessage(tree,TVM_GETITEM,0,(LPARAM)&tv);
+	if (!tv.lParam)
+	{
+		TreeItemData *data2 = new TreeItemData;
+		data2->type = type;
+		data2->ptr = data;
+		tv.mask = TVIF_PARAM;
+		tv.hItem = item;
+		tv.lParam = (LPARAM)data2;
+		SendMessage(tree,TVM_SETITEM,0,(LPARAM)&tv);
+	}
+}
+
+void *TreeViewGetData(HWND tree,HTREEITEM item,int type)
+{
+	if (item)
+	{
+		TVITEM tv;
+		tv.mask = TVIF_PARAM;
+		tv.hItem = item;
+		SendMessage(tree,TVM_GETITEM,0,(LPARAM)&tv);
+		TreeItemData *data = (TreeItemData *)tv.lParam;
+		if (data != 0)
+		{
+			if (data->type == type)
+			{
+				return data->ptr;
+			}
+		}
+	}
+	return 0;
+}
+
+void Sort_Tree(HWND tree,HTREEITEM item)
+{
+	for (HTREEITEM i = (HTREEITEM)SendMessage(tree,TVM_GETNEXTITEM,TVGN_CHILD,(LPARAM)item);i;i = (HTREEITEM)SendMessage(tree,TVM_GETNEXTITEM,TVGN_NEXT,(LPARAM)i))
+	{
+		SendMessage(tree,TVM_SORTCHILDREN,0,(LPARAM)i);
+		TVITEM tv;
+		tv.mask = TVIF_CHILDREN;
+		tv.hItem = i;
+		SendMessage(tree,TVM_GETITEM,0,(LPARAM)&tv);
+		if (tv.cChildren)
+		{
+			Sort_Tree(tree,i);
+		}
+	}
+}
+HTREEITEM Selection;
+PresetClass *selpreset;
+void Populate_Children(HWND tree,HTREEITEM item,uint32 id)
+{
+	PresetClass *preset2 = PresetMgrClass::Find_Preset(id);
+	for (int i = 0;i < preset2->Get_Child_Count();i++)
+	{
+		PresetClass *preset = preset2->Get_Child(i);
+		const char *str = 0;
+		if (preset->Get_Definition())
+		{
+			str = preset->Get_Definition()->Get_Name();
+		}
+		HTREEITEM newitem = TreeViewInsertItem(tree,str,item,TVI_LAST);
+		if (newitem)
+		{
+			if (selpreset == preset)
+			{
+				Selection = newitem;
+			}
+			TreeViewSetData(tree,newitem,preset,1);
+			if (preset->Get_Definition())
+			{
+				preset->Set_Definition_ID(preset->Get_Definition()->Get_ID());
+			}
+			Populate_Children(tree,newitem,preset->Get_Definition_ID());
+		}
+	}
+}
+
+INT_PTR CALLBACK Dlg_Sound(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+	switch (uMsg)
+	{
+		case WM_INITDIALOG:
+			{
+				Selection = 0;
+				selpreset = (PresetClass *)lParam;
+				HWND tree = GetDlgItem(hDlg,IDC_TREE);
+				SendMessage(tree,WM_SETREDRAW,0,0);
+				SendMessage(tree,TVM_SELECTITEM,TVGN_CARET,0);
+				SendMessage(tree,TVM_DELETEITEM,0,(LPARAM)TVI_ROOT);
+				for (PresetClass *i = PresetMgrClass::Find_First_Preset(20480,1,true);i;i = PresetMgrClass::Find_Next_Preset(i,20480,1,true))
+				{
+					if (!i->Get_Parent() || i->Get_Definition()->Get_Class_ID() == 57344)
+					{
+						const char *str = 0;
+						if (i->Get_Definition())
+						{
+							str = i->Get_Definition()->Get_Name();
+						}
+						HTREEITEM newitem = TreeViewInsertItem(tree,str,TVI_ROOT,TVI_LAST);
+						if (newitem)
+						{
+							if (selpreset == i)
+							{
+								Selection = newitem;
+							}
+							TreeViewSetData(tree,newitem,i,1);
+							if (i->Get_Definition())
+							{
+								i->Set_Definition_ID(i->Get_Definition()->Get_ID());
+							}
+							Populate_Children(tree,newitem,i->Get_Definition_ID());
+						}
+					}
+				}
+				HTREEITEM none = TreeViewInsertItem(tree,"<None>",TVI_ROOT,TVI_FIRST);
+				SendMessage(tree,TVM_SORTCHILDREN,0,(LPARAM)TVI_ROOT);
+				Sort_Tree(tree,TVI_ROOT);
+				SendMessage(tree,WM_SETREDRAW,1,0);
+				if (Selection)
+				{
+					SendMessage(tree,TVM_ENSUREVISIBLE,0,(LPARAM)Selection);
+					SendMessage(tree,TVM_SELECTITEM,TVGN_CARET,(LPARAM)Selection);
+				}
+				else
+				{
+					SendMessage(tree,TVM_SELECTITEM,TVGN_CARET,(LPARAM)none);
+				}
+			}
+			return TRUE;
+			break;
+		case WM_CLOSE:
+			return EndDialog(hDlg, -1);
+			break;
+		case WM_COMMAND:
+			switch (LOWORD(wParam))
+			{
+			case IDCANCEL:
+				return EndDialog(hDlg, -1);
+			case IDOK:
+				{
+					HWND tree = GetDlgItem(hDlg,IDC_TREE);
+					HTREEITEM i = (HTREEITEM)SendMessage(tree,TVM_GETNEXTITEM,TVGN_CARET,0);
+					PresetClass *preset = (PresetClass *)TreeViewGetData(tree,i,1);
+					if (preset)
+					{
+						return EndDialog(hDlg, preset->Get_Definition_ID());
+					}
+					else
+					{
+						return EndDialog(hDlg, 0);
+					}
+				}
+			default:
+				break;
+			}
+			break;
+		default:
+			break;
+	}
+	return FALSE;
+}
 
 TDBObjClass *obj;
 INT_PTR CALLBACK Dlg_Info(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -504,6 +723,31 @@
 				StoreInfo(hDlg, obj);
 				SetFocus(g_List);
 				return EndDialog(hDlg, 1);
+			case IDSOUND:
+				{
+					char lBuf[256];
+					GetDlgItemTextA(hDlg, IDC_SOUND_ID, lBuf, 256);
+					DefinitionClass *definition = DefinitionMgrClass::Find_Named_Definition(lBuf,false);
+					PresetClass *preset = 0;
+					if (definition)
+					{
+						preset = PresetMgrClass::Find_Preset(definition->Get_ID());
+					}
+					int ID = DialogBoxParam(g_hInstance, (LPWSTR)IDD_SOUNDLIST, hDlg, Dlg_Sound,(LPARAM)preset);
+					if (ID != -1)
+					{
+						PresetClass *preset = PresetMgrClass::Find_Preset(ID);
+						if (preset && preset->Get_Definition() && preset->Get_Definition()->Get_Name())
+						{
+							SetDlgItemTextA(hDlg, IDC_SOUND_ID, preset->Get_Definition()->Get_Name());
+						}
+						else
+						{
+							SetDlgItemTextA(hDlg, IDC_SOUND_ID, "");
+						}
+					}
+				}
+				return TRUE;
 			default:
 				break;
 			}
@@ -515,7 +759,6 @@
 }
 
 #pragma warning (default : 4311 4312)
-
 int TDBEdit(TDBObjClass *obj2)
 {
 	int i = DialogBoxParam(g_hInstance, (LPWSTR)IDD_Info, g_MainWnd, Dlg_Info, (LPARAM)obj2);
diff -uwr sourceold/tdbedit/resource.h source/tdbedit/resource.h
--- sourceold/tdbedit/resource.h	2009-12-25 08:41:14.202307800 +0800
+++ source/tdbedit/resource.h	2012-05-01 23:29:40.621093700 +0800
@@ -2,6 +2,7 @@
 // Microsoft Visual C++ generated include file.
 // Used by tdbedit.rc
 //
+#define IDSOUND                         3
 #define IDR_MAIN                        101
 #define IDD_Goto                        102
 #define IDD_Find_ID                     103
@@ -11,6 +12,7 @@
 #define IDD_Info                        107
 #define IDD_New_Category                108
 #define IDI_MAIN                        110
+#define IDD_SOUNDLIST                   111
 #define IDC_TEXT                        1001
 #define IDC_GOTO_INT                    1004
 #define IDC_FIND_STRING                 1005
@@ -27,6 +29,7 @@
 #define IDC_ENG_STRING                  1015
 #define IDC_CATEGORY                    1015
 #define IDC_ID_N                        1016
+#define IDC_TREE                        1183
 #define ID_NEW                          40020
 #define ID_OPEN                         40021
 #define ID_SAVE                         40023
@@ -50,14 +53,16 @@
 #define ID_REMOVECATEGORY               40054
 #define ID_EXPORT_TABLE                 40055
 #define ID_IMPORT_TABLE                 40056
+#define ID_FILE_OPENDDB                 40057
+#define ID_OPEN_DDB                     40058
 #define IDC_STATIC                      -1
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        111
-#define _APS_NEXT_COMMAND_VALUE         40057
+#define _APS_NEXT_RESOURCE_VALUE        112
+#define _APS_NEXT_COMMAND_VALUE         40059
 #define _APS_NEXT_CONTROL_VALUE         1016
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
diff -uwr sourceold/tdbedit/tdbedit.cpp source/tdbedit/tdbedit.cpp
--- sourceold/tdbedit/tdbedit.cpp	2011-10-11 23:02:44.485351500 +0800
+++ source/tdbedit/tdbedit.cpp	2012-05-02 01:23:03.404296800 +0800
@@ -20,6 +20,10 @@
 #include "search.h"
 #include "RawFileClass.h"
 #include "SaveLoadSystemClass.h"
+#include "SList.h"
+#include "PresetMgr.h"
+#include "DefinitionMgrClass.h"
+#include "AudibleSoundDefinitionClass.h"
 
 #define CLASS_NAME L"TDB_WND"
 #define WND_TITLE L"Advanced string editor"
@@ -189,7 +193,46 @@
 	SetWindowText(g_MainWnd, lBuf);
 	return true;
 }
+bool presetloaded = false;
+bool OpenDDBFile()
+{
+	wchar_t lBuf[MAX_PATH] = L"";
+	OPENFILENAME of;
+
+	memset(&of, 0, sizeof(OPENFILENAME));
+
+	of.lStructSize = sizeof(OPENFILENAME);
+	of.hwndOwner = g_MainWnd;
+	of.hInstance = NULL;
+	of.lpstrFilter = L"Preset Database\0*.ddb\0\0";
+	of.lpstrCustomFilter = NULL;
+	of.nMaxCustFilter = 0;
+	of.nFilterIndex = 0;
+	of.lpstrFile = lBuf;
+	of.nMaxFile = MAX_PATH;
+	of.lpstrFileTitle = NULL;
+	of.nMaxFileTitle = 0;
+	of.lpstrInitialDir = NULL;
+	of.lpstrTitle = NULL;
+	of.Flags = OFN_FILEMUSTEXIST;
+	of.nFileOffset = 0;
+	of.nFileExtension = 0;
+	of.lpstrDefExt = NULL;
+	of.lCustData = NULL;
+	of.lpfnHook = NULL;
+	of.lpTemplateName = NULL;	
 
+	if (!GetOpenFileName(&of)) return false;
+	char fn[MAX_PATH] = "";
+	wcstombs(fn,of.lpstrFile,MAX_PATH);
+	RawFileClass file(fn);
+	file.Open(1);
+	ChunkLoadClass chunkLoader(&file);
+	SaveLoadSystemClass::Load(chunkLoader, true);
+	file.Close();
+	presetloaded = true;
+	return true;
+}
 
 bool SaveFile(wchar_t *buf, int bufsize, int *FileOffset, int *ExtensionOffset)
 {
@@ -496,8 +539,23 @@
 		unsigned int id = o->Get_Sound_ID();
 		if (id != 0xFFFFFFFF)
 		{
+			if (presetloaded)
+			{
+				PresetClass *preset = PresetMgrClass::Find_Preset(id);
+				if (preset && preset->Get_Definition() && preset->Get_Definition()->Get_Name())
+				{
+					_snwprintf(lBuf, 256, L"%S", preset->Get_Definition()->Get_Name());
+				}
+				else
+				{
+					_snwprintf(lBuf, 256, L"%s", L"");
+				}
+			}
+			else
+			{
 			_snwprintf(lBuf, 256, L"%d", id);
 		}
+		}
 		else
 		{
 			_snwprintf(lBuf, 256, L"%s", L"");
@@ -541,11 +599,11 @@
 	col.pszText = L"ID (numeric)";
 	SendMessage(g_StringList, LVM_INSERTCOLUMN, (WPARAM)1, (LPARAM)&col);
 
-	col.cx = 100;
+	col.cx = 200;
 	col.pszText = L"Sound ID";
 	SendMessage(g_StringList, LVM_INSERTCOLUMN, (WPARAM)2, (LPARAM)&col);
 
-	col.cx = 450;
+	col.cx = 500;
 	col.pszText = L"English text";
 	SendMessage(g_StringList, LVM_INSERTCOLUMN, (WPARAM)3, (LPARAM)&col);
 	TCITEM item;
@@ -634,6 +692,10 @@
 			case ID_OPEN:
 				Do_Open();
 				break;
+			case ID_OPEN_DDB:
+				OpenDDBFile();
+				Handle_Tab_Change((int)SendMessage(g_Tabs, TCM_GETCURSEL, 0, 0));
+				break;
 			case ID_SAVE:
 				if (filename)
 				{
@@ -908,7 +970,7 @@
 	atm = RegisterClassEx(&wcls);
 
 	g_MainWnd = CreateWindowEx(0, CLASS_NAME, WND_TITLE, 
-		WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, 
+		WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 1024, 768, NULL, 
 		NULL, g_hInstance, NULL);
 
 	if (g_MainWnd)
@@ -934,17 +996,26 @@
 bool SaveLoadSystemClass::Load(ChunkLoadClass& chunkLoader, bool auto_post_load)
 {
 	SaveLoadSystemClass::PointerRemapper.Reset();
+
 	bool allSucceeded = true;
+
 	for (; chunkLoader.Open_Chunk(); chunkLoader.Close_Chunk())
 	{
+		// DEPRECATED: SaveLoadStatus::Inc_Status_Count();
 		SaveLoadSubSystemClass* subSystem = SaveLoadSystemClass::Find_Sub_System (chunkLoader.Cur_Chunk_ID());
 		if (subSystem)
 		{
+		   // SaveLoadStatus::Set_Status_Text (subSystem->Name(), 1);
 		   allSucceeded = allSucceeded && subSystem->Load (chunkLoader);
 		}
 	}
+
 	SaveLoadSystemClass::PointerRemapper.Process();
 	SaveLoadSystemClass::PointerRemapper.Reset();
+
+   if (auto_post_load)
+      SaveLoadSystemClass::Post_Load_Processing (0);
+
 	return allSucceeded;
 }
 
@@ -959,3 +1030,23 @@
 	}
 	return false;
 }
+
+SList<PostLoadableClass> PostLoadList;
+
+void SaveLoadSystemClass::Post_Load_Processing(void(*func)())
+{
+	for (PostLoadableClass *post = PostLoadList.Remove_Head();post;post = PostLoadList.Remove_Head())
+	{
+		post->On_Post_Load();
+		post->Set_Post_Load_Registered(false);
+	}
+}
+
+void SaveLoadSystemClass::Register_Post_Load_Callback(PostLoadableClass *post)
+{
+	if (!post->Is_Post_Load_Registered())
+	{
+		post->Set_Post_Load_Registered(true);
+		PostLoadList.Add_Head(post);
+	}
+}
diff -uwr sourceold/tdbedit/tdbedit.rc source/tdbedit/tdbedit.rc
--- sourceold/tdbedit/tdbedit.rc	2009-12-25 08:41:14.171057800 +0800
+++ source/tdbedit/tdbedit.rc	2012-05-01 23:28:59.558593700 +0800
@@ -16,10 +16,8 @@
 // German (Germany) resources
 
 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
-#ifdef _WIN32
 LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
 #pragma code_page(1252)
-#endif //_WIN32
 
 #ifdef APSTUDIO_INVOKED
 /////////////////////////////////////////////////////////////////////////////
@@ -64,6 +62,7 @@
         MENUITEM "Export C Header",             ID_EXPORT_HEADER, GRAYED
         MENUITEM "Import Table",                ID_IMPORT_TABLE
         MENUITEM "Export Table",                ID_EXPORT_TABLE, GRAYED
+        MENUITEM "Open DDB",                    ID_OPEN_DDB
         MENUITEM SEPARATOR
         MENUITEM "Exit",                        ID_EXIT
     END
@@ -155,7 +154,7 @@
     LTEXT           "ID",IDC_STATIC,6,6,36,12
     EDITTEXT        IDC_ANIMATION,42,24,300,12,ES_AUTOHSCROLL | NOT WS_BORDER,WS_EX_STATICEDGE
     LTEXT           "Animation",IDC_STATIC,6,24,36,12
-    EDITTEXT        IDC_SOUND_ID,42,42,300,12,ES_AUTOHSCROLL | NOT WS_BORDER,WS_EX_STATICEDGE
+    EDITTEXT        IDC_SOUND_ID,42,42,244,12,ES_AUTOHSCROLL | NOT WS_BORDER,WS_EX_STATICEDGE
     LTEXT           "Sound",IDC_STATIC,6,42,36,12
     EDITTEXT        IDC_TEXT,42,78,300,42,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | NOT WS_BORDER | WS_VSCROLL,WS_EX_STATICEDGE
     LTEXT           "Text",IDC_STATIC,6,78,36,12
@@ -164,6 +163,7 @@
     LTEXT           "Eng. string",IDC_STATIC,6,60,36,12
     EDITTEXT        IDC_ID_N,264,6,78,12,ES_AUTOHSCROLL | NOT WS_BORDER,WS_EX_STATICEDGE
     PUSHBUTTON      "Cancel",IDCANCEL,60,126,50,14,BS_FLAT
+    PUSHBUTTON      "&Sound",IDSOUND,289,41,50,14,BS_FLAT
 END
 
 IDD_New_Category DIALOGEX 0, 0, 148, 42
@@ -250,10 +250,39 @@
 // English (Australia) resources
 
 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA)
-#ifdef _WIN32
 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS
 #pragma code_page(1252)
-#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_SOUNDLIST DIALOGEX 0, 0, 243, 266
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Dialog"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+    CONTROL         "",IDC_TREE,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,7,42,229,198
+    DEFPUSHBUTTON   "OK",IDOK,34,245,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,97,245,50,14
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+    IDD_SOUNDLIST, DIALOG
+    BEGIN
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
 
 /////////////////////////////////////////////////////////////////////////////
 //
diff -uwr sourceold/tdbedit/tdbedit.vcxproj source/tdbedit/tdbedit.vcxproj
--- sourceold/tdbedit/tdbedit.vcxproj	2011-11-26 13:17:41.689453100 +0800
+++ source/tdbedit/tdbedit.vcxproj	2012-05-28 13:38:15.372664100 +0800
@@ -123,7 +123,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
@@ -185,7 +185,13 @@
     <ClCompile Include="..\scripts\engine_string.cpp" />
     <ClCompile Include="..\scripts\PersistFactoryClass.cpp" />
     <ClCompile Include="..\scripts\PointerRemapClass.cpp" />
+    <ClCompile Include="..\scripts\PresetMgr.cpp" />
+    <ClCompile Include="..\scripts\Random2Class.cpp" />
+    <ClCompile Include="..\scripts\Random3Class.cpp" />
+    <ClCompile Include="..\scripts\RandomClass.cpp" />
+    <ClCompile Include="..\scripts\SysTimeClass.cpp" />
     <ClCompile Include="..\scripts\TDBObjClass.cpp" />
+    <ClCompile Include="..\scripts\TwiddlerClass.cpp" />
     <ClCompile Include="general.cpp">
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
       <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">General.h</PrecompiledHeaderFile>
@@ -205,6 +211,7 @@
     <ResourceCompile Include="tdbedit.rc" />
   </ItemGroup>
   <ItemGroup>
+    <ClInclude Include="..\scripts\PresetMgr.h" />
     <ClInclude Include="general.h" />
     <ClInclude Include="resource.h" />
   </ItemGroup>
diff -uwr sourceold/tdbedit/tdbedit.vcxproj.filters source/tdbedit/tdbedit.vcxproj.filters
--- sourceold/tdbedit/tdbedit.vcxproj.filters	2010-12-11 11:30:06.640625000 +0800
+++ source/tdbedit/tdbedit.vcxproj.filters	2012-05-01 21:44:08.549804600 +0800
@@ -65,6 +65,24 @@
     <ClCompile Include="..\scripts\TDBObjClass.cpp">
       <Filter>01. Sources</Filter>
     </ClCompile>
+    <ClCompile Include="..\scripts\TwiddlerClass.cpp">
+      <Filter>01. Sources</Filter>
+    </ClCompile>
+    <ClCompile Include="..\scripts\PresetMgr.cpp">
+      <Filter>01. Sources</Filter>
+    </ClCompile>
+    <ClCompile Include="..\scripts\SysTimeClass.cpp">
+      <Filter>01. Sources</Filter>
+    </ClCompile>
+    <ClCompile Include="..\scripts\RandomClass.cpp">
+      <Filter>01. Sources</Filter>
+    </ClCompile>
+    <ClCompile Include="..\scripts\Random2Class.cpp">
+      <Filter>01. Sources</Filter>
+    </ClCompile>
+    <ClCompile Include="..\scripts\Random3Class.cpp">
+      <Filter>01. Sources</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <None Include="icon.ico">
@@ -83,5 +101,8 @@
     <ClInclude Include="resource.h">
       <Filter>Include Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\scripts\PresetMgr.h">
+      <Filter>01. Sources</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>
\ No newline at end of file
diff -uwr sourceold/teamspeak/teamspeak.vcxproj source/teamspeak/teamspeak.vcxproj
--- sourceold/teamspeak/teamspeak.vcxproj	2011-11-26 13:17:35.861328100 +0800
+++ source/teamspeak/teamspeak.vcxproj	2012-05-28 13:38:15.093367300 +0800
@@ -153,7 +153,7 @@
       <MinimalRebuild>false</MinimalRebuild>
       <ExceptionHandling>
       </ExceptionHandling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
