Index: /Trunk/src/LuaEngine/GameobjectFunctions.h
===================================================================
--- /Trunk/src/LuaEngine/GameobjectFunctions.h (revision 1136)
+++ /Trunk/src/LuaEngine/GameobjectFunctions.h (revision 1144)
@@ -261,51 +261,5 @@
 	int SpawnCreature(lua_State * L, GameObject * ptr)
 	{
-		if (ptr == NULL) return 0;
-		uint32 entry_id = luaL_checkint(L, 1);
-		float x = CHECK_FLOAT(L, 2);
-		float y = CHECK_FLOAT(L, 3);
-		float z = CHECK_FLOAT(L, 4);
-		float o = CHECK_FLOAT(L, 5);
-		uint32 faction = luaL_checkint(L, 6);
-		uint32 duration = luaL_checkint(L, 7);
-
-		if (!entry_id || !faction) //Shady: is it really required?
-		{
-			lua_pushnil(L);
-			return 1;
-		}
-		CreatureProto *p = CreatureProtoStorage.LookupEntry(entry_id);
-	    
-		if (p == NULL)
-		  return 0;
-
-		Creature *pCreature = ptr->GetMapMgr()->CreateCreature(entry_id);
-		if(pCreature == NULL)
-		{
-			lua_pushnil(L);
-			return 1;
-		}
-		pCreature->spawnid = 0;
-		pCreature->m_spawn = 0;
-		pCreature->Load(p,x,y,z);
-		if (faction)
-			pCreature->SetFaction(faction);
-		pCreature->_setFaction();
-		pCreature->SetMapId(ptr->GetMapId());
-		pCreature->SetOrientation(o);
-		pCreature->Despawn(duration, 0);
-		pCreature->SetInstanceID(ptr->GetInstanceID());
-		pCreature->PushToWorld(ptr->GetMapMgr());
-		if (duration)
-		{
-			pCreature->Despawn(duration,0);
-		}
-		PUSH_UNIT(L,pCreature);
-		return 1;
-	}
-
-	int SpawnGameObject(lua_State * L, GameObject * ptr)
-	{
-		if (ptr == NULL) return 0;
+		CHECK_TYPEID_RETNIL(TYPEID_GAMEOBJECT);
 		uint32 entry_id = CHECK_ULONG(L,1);
 		float x = CHECK_FLOAT(L, 2);
@@ -313,36 +267,80 @@
 		float z = CHECK_FLOAT(L, 4);
 		float o = CHECK_FLOAT(L, 5);
-		uint32 duration = luaL_checkint(L, 6);
-		float scale = (float)luaL_optnumber(L,7,1.0f);
-		if (!entry_id || !duration)
+		uint32 faction = CHECK_ULONG(L,6);
+		uint32 duration = CHECK_ULONG(L,7);
+		uint32 equip1 = luaL_optint(L, 8, 1);
+		uint32 equip2 = luaL_optint(L, 9, 1);
+		uint32 equip3 = luaL_optint(L, 10, 1);
+		uint32 phase = luaL_optint(L, 11, ptr->m_phase); 
+		bool save = luaL_optint(L, 12, 0) ? true : false; 
+
+		if(!entry_id)
 		{
 			lua_pushnil(L);
 			return 1;
 		}
-
-		GameObjectInfo *goi = GameObjectNameStorage.LookupEntry(entry_id);
-		if (goi == NULL)
-		{
-			dropWarning("Invalid GameObject ID specified: %u", entry_id);
-			lua_error(L);
-			return 0;
-		}
-		GameObject *pC = ptr->GetMapMgr()->CreateGameObject(entry_id);
-		if(pC == NULL)
+		CreatureProto *p = CreatureProtoStorage.LookupEntry(entry_id);
+	    
+		if(p == NULL) 
 		{
 			lua_pushnil(L);
 			return 1;
 		}
-		pC->m_spawn=0;
-		pC->CreateFromProto(entry_id, ptr->GetMapId(), (float)x, (float)y, (float)z, (float)o);
-		pC->SetMapId(ptr->GetMapId());
-		pC->SetInstanceID(ptr->GetInstanceID());
-		pC->SetFloatValue(OBJECT_FIELD_SCALE_X, scale);
-		pC->Spawn(ptr->GetMapMgr());
-		if(duration)
-		{
-			sEventMgr.AddEvent(pC, &GameObject::ExpireAndDelete, EVENT_GAMEOBJECT_UPDATE, duration, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
-		}
-		PUSH_GO(L,pC);
+		Creature * pCreature = ptr->GetMapMgr()->GetInterface()->SpawnCreature(entry_id,x,y,z,o,true,true,0,0,phase);
+		if(pCreature == NULL)
+		{
+			lua_pushnil(L);
+			return 1;
+		}
+		if(faction)
+		{
+			pCreature->SetFaction(faction);
+			pCreature->_setFaction();
+		}
+		pCreature->SetInstanceID(ptr->GetInstanceID());
+		pCreature->SetMapId(ptr->GetMapId());
+		pCreature->SetEquippedItem(MELEE,equip1);
+		pCreature->SetEquippedItem(OFFHAND,equip2);
+		pCreature->SetEquippedItem(RANGED,equip3);
+		if (duration)
+			pCreature->Despawn(duration,0);
+		if (save)
+			pCreature->SaveToDB();
+		PUSH_UNIT(L,pCreature);
+		return 1;
+	}
+
+	int SpawnGameObject(lua_State * L, GameObject * ptr)
+	{
+		CHECK_TYPEID_RETNIL(TYPEID_GAMEOBJECT);
+		uint32 entry_id = CHECK_ULONG(L,1);
+		float x = CHECK_FLOAT(L, 2);
+		float y = CHECK_FLOAT(L, 3);
+		float z = CHECK_FLOAT(L, 4);
+		float o = CHECK_FLOAT(L, 5);
+		uint32 duration = CHECK_ULONG(L, 6);
+		float scale = (float)(luaL_optint(L, 7, 100)/100); 
+		uint32 phase = luaL_optint(L, 8, ptr->m_phase);
+		bool save = luaL_optint(L, 9, 0) ? true : false; 
+		if (entry_id)
+		{
+			GameObject* pC = ptr->GetMapMgr()->GetInterface()->SpawnGameObject(entry_id,x,y,z,o,false,0,0,phase);
+			if(pC == NULL)
+			{
+				lua_pushnil(L);
+				return 1;
+			}
+			pC->SetInstanceID(ptr->GetInstanceID());
+			pC->SetMapId(ptr->GetMapId());
+			pC->SetFloatValue(OBJECT_FIELD_SCALE_X, scale);  
+			pC->Spawn(ptr->GetMapMgr());
+			if (duration)
+				sEventMgr.AddEvent(pC,&GameObject::ExpireAndDelete,EVENT_GAMEOBJECT_UPDATE,duration,1,EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
+			if (save)
+				pC->SaveToDB();
+			PUSH_GO(L,pC);
+		}
+		else
+			lua_pushnil(L);
 		return 1;
 	}
@@ -350,5 +348,5 @@
 	int GetSpawnX(lua_State * L, GameObject * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT);
+		CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT);
 		lua_pushnumber(L,ptr->GetSpawnX());
 		return 1;
@@ -357,5 +355,5 @@
 	int GetSpawnY(lua_State * L, GameObject * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT);
+		CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT);
 		lua_pushnumber(L,ptr->GetSpawnY());
 		return 1;
@@ -364,5 +362,5 @@
 	int GetSpawnZ(lua_State * L, GameObject * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT);
+		CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT);
 		lua_pushnumber(L,ptr->GetSpawnZ());
 		return 1;
@@ -371,5 +369,5 @@
 	int GetSpawnO(lua_State * L, GameObject * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT);
+		CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT);
 		lua_pushnumber(L,ptr->GetSpawnO());
 		return 1;
@@ -378,5 +376,5 @@
 	int GetX(lua_State * L, GameObject * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT);
+		CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT);
 		lua_pushnumber(L,ptr->GetPositionX());
 		return 1;
@@ -385,5 +383,5 @@
 	int GetY(lua_State * L, GameObject * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT);
+		CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT);
 		lua_pushnumber(L,ptr->GetPositionY());
 		return 1;
@@ -392,5 +390,5 @@
 	int GetZ(lua_State * L, GameObject * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT);if(ptr)
+		CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT);if(ptr)
 		lua_pushnumber(L,ptr->GetPositionZ());
 		return 1;
@@ -399,5 +397,5 @@
 	int GetO(lua_State * L, GameObject * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT);
+		CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT);
 		lua_pushnumber(L,ptr->GetOrientation());
 		return 1;
@@ -406,5 +404,5 @@
 	int GetInRangePlayersCount(lua_State * L, GameObject * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT);
+		CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT);
 		lua_pushnumber(L,ptr->GetInRangePlayersCount());
 		return 1;
@@ -413,5 +411,5 @@
 	int GetEntry(lua_State * L, GameObject * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT);
+		CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT);
 		lua_pushnumber(L,ptr->GetEntry());
 		return 1;
@@ -600,22 +598,12 @@
 		CHECK_TYPEID(TYPEID_GAMEOBJECT);
 		uint32 sp = CHECK_ULONG(L,1);
-		if (!sp) return 0;
-		Spell * spp = new Spell(ptr,dbcSpell.LookupEntry(sp),true,NULL);
-		SpellCastTargets tar(ptr->GetGUID());
-		spp->prepare(&tar);
-		return 0;
-	}
-
-	int FullCastSpell(lua_State * L, GameObject * ptr)
-	{
-		CHECK_TYPEID(TYPEID_GAMEOBJECT);
-		uint32 sp = CHECK_ULONG(L,1);
-		if (!sp) return 0;
-		Spell * spp = new Spell(ptr,dbcSpell.LookupEntry(sp),false,NULL);
-		SpellCastTargets tar(ptr->GetGUID());
-		spp->prepare(&tar);
-		return 0;
-	}
-
+		if(sp)
+		{
+			Spell * tSpell = new Spell(ptr,dbcSpell.LookupEntry(sp),true,NULL);
+			SpellCastTargets tar(ptr->GetGUID());
+			tSpell->prepare(&tar);
+		}
+		return 0;
+	}
 	int CastSpellOnTarget(lua_State * L, GameObject * ptr)
 	{
@@ -623,12 +611,10 @@
 		uint32 sp = CHECK_ULONG(L,1);
 		Unit * target = CHECK_UNIT(L,2);
-		if (!sp || target==NULL) return 0;
-		Spell * spp = new Spell(ptr,dbcSpell.LookupEntry(sp),true,NULL);
-		spp->m_targets.m_unitTarget = target->GetGUID();
-		//prepare digest
-		SpellCastTargets tar(target->GetGUID());
-		spp->m_targets = tar;
-		spp->SendSpellStart();
-		spp->cast(false);
+		if(sp && target != NULL)
+		{
+			Spell * tSpell = new Spell(ptr,dbcSpell.LookupEntry(sp),true,NULL);
+			SpellCastTargets sp(target->GetGUID());
+			tSpell->prepare(&sp);
+		}
 		return 0;
 	}
@@ -827,17 +813,4 @@
 		return 0;
 	}
-
-	int FullCastSpellOnTarget(lua_State * L, GameObject * ptr)
-	{
-		CHECK_TYPEID(TYPEID_GAMEOBJECT);
-		uint32 sp = CHECK_ULONG(L,1);
-		Unit * target = CHECK_UNIT(L,2);
-		if (!sp) return 0;
-		Spell * spp = new Spell(ptr,dbcSpell.LookupEntry(sp),false,NULL);
-		SpellCastTargets tar(target->GetGUID());
-		spp->prepare(&tar);
-		return 0;
-	}
-
 	int GetGUID(lua_State * L, GameObject* ptr)
 	{
@@ -862,6 +835,7 @@
 	{
 		CHECK_TYPEID_RET(TYPEID_GAMEOBJECT);
-		lua_pushboolean(L, (ptr->IsActive() ? 1 : 0));
-		return 1;
+		if(ptr->GetByte(GAMEOBJECT_BYTES_1,0))
+			RET_BOOL(true);
+		RET_BOOL(false);
 	}
 
@@ -869,13 +843,10 @@
 	{
 		CHECK_TYPEID_RET(TYPEID_GAMEOBJECT);
-		if (ptr->GetUInt32Value(GAMEOBJECT_DYNAMIC) == 1)
-		{
-			ptr->SetUInt32Value(GAMEOBJECT_DYNAMIC, 0);
-		} 
-		else
-		{
-			ptr->SetUInt32Value(GAMEOBJECT_DYNAMIC, 1);
-		}
-		return 1;
+		if(ptr->GetByte(GAMEOBJECT_BYTES_1, 0) == 1)
+			ptr->SetByte(GAMEOBJECT_BYTES_1, 0, 0);
+		else 
+			ptr->SetByte(GAMEOBJECT_BYTES_1, 0, 1);
+		ptr->SetUInt32Value(GAMEOBJECT_FLAGS, (ptr->GetUInt32Value(GAMEOBJECT_FLAGS) & ~1));
+		RET_BOOL(true);
 	}
 	
@@ -960,24 +931,4 @@
 		return 1;
 	}
-
-	int SetByteValue(lua_State * L, GameObject * ptr)
-	{
-		if (!ptr) return 0;
-		uint32 index = luaL_checkint(L,1);
-		uint32 index1 = luaL_checkint(L,2);
-		uint8 value = luaL_checkint(L,3);
-		ptr->SetByte(index,index1,value);
-		return 0;
-	}
-
-	int GetByteValue(lua_State * L, GameObject * ptr)
-	{
-		CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT);
-		uint32 index = luaL_checkint(L,1);
-		uint32 index1 = luaL_checkint(L,2);
-		lua_pushinteger(L,ptr->GetByte(index,index1));
-		return 1;
-	}
-
 	int HasFlag(lua_State * L, GameObject * ptr)
 	{
@@ -999,5 +950,5 @@
 	int GetSpawnId(lua_State * L, GameObject * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT);
+		CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT);
 		lua_pushnumber(L, ptr->m_spawn != NULL ? ptr->m_spawn->id : 0);
 		return 1;
@@ -1006,5 +957,5 @@
 	int GetAreaId(lua_State * L, GameObject * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_GAMEOBJECT);
+		CHECK_TYPEID_RETINT(TYPEID_GAMEOBJECT);
 		lua_pushnumber(L, ( ptr->GetMapMgr()->GetAreaID(ptr->GetPositionX(), ptr->GetPositionY()) ) );
 		return 1;
@@ -1013,5 +964,5 @@
 	int SetPosition(lua_State * L, GameObject * ptr)
 	{
-		if (!ptr) return 0;
+		CHECK_TYPEID_RET(TYPEID_GAMEOBJECT)
 		uint32 NewGuid = ptr->GetMapMgr()->GenerateGameobjectGuid();
         ptr->RemoveFromWorld(true);
@@ -1023,16 +974,82 @@
 		ptr->SetPosition(x, y, z, o);
 		ptr->AddToWorld();
-		return 0;
+		RET_BOOL(true);
 	}
 
 	int GetObjectType(lua_State * L, GameObject * ptr)
 	{
-		if (!ptr) 
-		{ 
-			lua_pushnil(L); 
-			return 1; 
-		}
-		lua_pushstring(L, "GameObject");
-		return 1;
+		CHECK_TYPEID_RETNIL(TYPEID_GAMEOBJECT);
+		RET_STRING("GameObject");
+	}
+	int ChangeScale(lua_State * L, GameObject * ptr)
+	{
+		CHECK_TYPEID_RET(TYPEID_GAMEOBJECT)
+		float nScale = CHECK_FLOAT(L,1);
+		bool updateNow = CHECK_BOOL(L,2);
+		nScale = (nScale <= 0) ? 1 : nScale;
+		ptr->SetScale(nScale);
+		if(updateNow)
+		{
+			uint32 nguid = ptr->GetMapMgr()->GenerateGameobjectGuid();
+			ptr->RemoveFromWorld(true);
+			ptr->SetNewGuid(nguid);
+			ptr->AddToWorld();
+		}
+		RET_BOOL(true);
+	}
+	int GetByte(lua_State * L, GameObject * ptr)
+	{
+		CHECK_TYPEID_RETNIL(TYPEID_GAMEOBJECT);
+		uint32 index = luaL_checkint(L,1);
+		uint32 index2 = luaL_checkint(L,2);
+		uint8 value = ptr->GetByte(index,index2);
+		RET_INT(value);
+	}
+	int SetByte(lua_State * L, GameObject * ptr)
+	{
+		CHECK_TYPEID_RET(TYPEID_GAMEOBJECT);
+		int index = luaL_checkint(L,1);
+		int index2 = luaL_checkint(L,2);
+		uint8 value = luaL_checkint(L,3);
+		ptr->SetByte(index,index2,value);
+		RET_BOOL(true);
+	}
+	int FullCastSpellOnTarget(lua_State * L, GameObject * ptr)
+	{
+		CHECK_TYPEID(TYPEID_GAMEOBJECT);
+		uint32 sp = CHECK_ULONG(L,1);
+		Unit * target = CHECK_UNIT(L,2);
+		if(sp && target != NULL)
+		{
+			Spell * tSpell = new Spell(ptr,dbcSpell.LookupEntry(sp),false,NULL);
+			SpellCastTargets sct(target->GetGUID());
+			tSpell->prepare(&sct);
+		}
+		return 0;
+	}
+	int FullCastSpell(lua_State * L, GameObject * ptr)
+	{
+		CHECK_TYPEID(TYPEID_GAMEOBJECT);
+		uint32 sp = CHECK_ULONG(L,1);
+		if(sp)
+		{
+			Spell * tSpell = new Spell(ptr,dbcSpell.LookupEntry(sp),false,NULL);
+			SpellCastTargets sct(ptr->GetGUID());
+			tSpell->prepare(&sct);
+		}
+		return 0;
+	}
+	int CustomAnimate(lua_State * L, GameObject * ptr)
+	{
+		uint32 aindex = CHECK_ULONG(L,1);
+		if(aindex < 2 && ptr != NULL)
+		{
+			WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM,12);
+			data << ptr->GetGUID();
+			data << aindex;
+			ptr->SendMessageToSet(&data,false);
+			RET_BOOL(true);
+		}
+		RET_BOOL(false);
 	}
 }
Index: /Trunk/src/LuaEngine/FunctionTables.h
===================================================================
--- /Trunk/src/LuaEngine/FunctionTables.h (revision 1142)
+++ /Trunk/src/LuaEngine/FunctionTables.h (revision 1144)
@@ -80,6 +80,4 @@
 	{ "SetMovementType", &luaUnit::SetMovementType },
 	{ "CastSpell", &luaUnit::CastSpell },
-	{ "FullCastSpell", &luaUnit::FullCastSpell },
-	{ "FullCastSpellOnTarget", &luaUnit::FullCastSpellOnTarget },
 	{ "SpawnCreature", &luaUnit::SpawnCreature },
 	{ "SpawnGameObject", &luaUnit::SpawnGameObject },
@@ -128,9 +126,9 @@
 	{ "MoveToWaypoint", &luaUnit::MoveToWaypoint },
 	{ "DestroyCustomWaypointMap", &luaUnit::DestroyCustomWaypointMap },
-	{ "SetCombatCapable", &luaUnit::SetCombatCapable },
-	{ "SetCombatMeleeCapable", &luaUnit::SetCombatMeleeCapable },
-	{ "SetCombatRangedCapable", &luaUnit::SetCombatRangedCapable },
-	{ "SetCombatSpellCapable", &luaUnit::SetCombatSpellCapable },
-	{ "SetCombatTargetingCapable", &luaUnit::SetCombatTargetingCapable },
+	{ "SetCombatCapable", &luaUnit::DisableCombat },
+	{ "SetCombatMeleeCapable", &luaUnit::DisableMelee },
+	{ "SetCombatRangedCapable", &luaUnit::DisableRanged },
+	{ "SetCombatSpellCapable", &luaUnit::DisableSpells },
+	{ "SetCombatTargetingCapable", &luaUnit::DisableTargeting },
 	{ "SetNPCFlags", &luaUnit::SetNPCFlags },
 	{ "SetModel", &luaUnit::SetModel },
@@ -313,5 +311,4 @@
 	{ "ResetAllTalents", &luaUnit::ResetAllTalents },
 	{ "GetAccountName", &luaUnit::GetAccountName },
-//NA:	{ "GetGamemasterLevel", &luaUnit::GetGamemasterLevel },
 	{ "SavePlayer", &luaUnit::SavePlayer },
 	{ "HasQuest", &luaUnit::HasQuest },
@@ -341,179 +338,186 @@
     { "GetNativeDisplay", &luaUnit::GetNativeDisplay },
 	{ "IsMounted", &luaUnit::IsMounted },
-		//hypersniper added commands
-		{ "GetGameTime", &luaUnit::GetGameTime },
-		{ "PlaySoundToPlayer", &luaUnit::PlaySoundToPlayer },
-		{ "GetDuelState", &luaUnit::GetDuelState }, 
-		{ "SetPosition", &luaUnit::SetPosition},
-		{ "CastSpellOnTarget", &luaUnit::CastSpellOnTarget},
-		{ "GetLandHeight", &luaUnit::GetLandHeight},
-		{ "QuestAddStarter", &luaUnit::QuestAddStarter},
-		{ "QuestAddFinisher", &luaUnit::QuestAddFinisher},
-		{ "SetPlayerSpeed", &luaUnit::SetPlayerSpeed},
-		{ "GiveHonor", &luaUnit::GiveHonor},
-		{ "SetBindPoint", &luaUnit::SetBindPoint},
-		{ "SoftDisconnect", &luaUnit::SoftDisconnect},
-		{ "SetZoneWeather", &luaUnit::SetZoneWeather},
-		{ "SetPlayerWeather", &luaUnit::SetPlayerWeather},
-		{ "SendPacketToPlayer", &luaUnit::SendPacketToPlayer},
-		{ "SendPacketToZone", &luaUnit::SendPacketToZone},
-		{ "SendPacketToWorld", &luaUnit::SendPacketToWorld},
-		{ "SendPacketToInstance", &luaUnit::SendPacketToInstance},
-		{ "PlayerSendChatMessage", &luaUnit::PlayerSendChatMessage},
-		{ "GetDistanceYards", &luaUnit::GetDistanceYards},
-		{ "VendorAddItem", &luaUnit::VendorAddItem},
-		{ "VendorRemoveItem", &luaUnit::VendorRemoveItem},
-		{ "VendorRemoveAllItems", &luaUnit::VendorRemoveAllItems},
-		{ "CreatureHasQuest", &luaUnit::CreatureHasQuest},
-		{ "SendVendorWindow", &luaUnit::SendVendorWindow},
-		{ "SendTrainerWindow", &luaUnit::SendTrainerWindow},
-		{ "SendInnkeeperWindow", &luaUnit::SendInnkeeperWindow},
-		{ "SendBankWindow", &luaUnit::SendBankWindow},
-		{ "SendAuctionWindow", &luaUnit::SendAuctionWindow},
-		{ "SendBattlegroundWindow", &luaUnit::SendBattlegroundWindow},
-		{ "GetInventoryItem", &luaUnit::GetInventoryItem},
-		{ "GetInventoryItemById", &luaUnit::GetInventoryItemById},
-		{ "PhaseSet", &luaUnit::PhaseSet},
-		{ "PhaseAdd", &luaUnit::PhaseAdd},
-		{ "PhaseDelete", &luaUnit::PhaseDelete},
-		{ "GetPhase", &luaUnit::GetPhase},
-		{ "AggroWithInRangeFriends", &luaUnit::AggroWithInRangeFriends},
-		{ "GetPrimaryCombatTarget", &luaUnit::GetPrimaryCombatTarget},
-		{ "MoveRandomArea", &luaUnit::MoveRandomArea},
-		{ "SendLootWindow", &luaUnit::SendLootWindow},
-		{ "AddLoot", &luaUnit::AddLoot},
-		{ "SetPacified", &luaUnit::SetPacified},
-		{ "SpawnVehicle", &luaUnit::SpawnVehicle},
-		{ "SetVehicle", &luaUnit::SetVehicle},
-		{ "GetVehicle", &luaUnit::GetVehicle},
-		{ "RemoveFromVehicle", &luaUnit::RemoveFromVehicle},
-		{ "GetVehicleSeat", &luaUnit::GetVehicleSeat},
-		{ "IsVehicle", &luaUnit::IsVehicle},
-		{ "GetPassengerCount", &luaUnit::GetPassengerCount},
-		{ "MoveVehicle", &luaUnit::MoveVehicle},
-		{ "SetPlayerLock", &luaUnit::SetPlayerLock},
-		//3004 ends here
-		{ "GetGroupPlayers", &luaUnit::GetGroupPlayers},
-		{ "IsGm", &luaUnit::IsGm},
-		{ "GetDungeonDifficulty", &luaUnit::GetDungeonDifficulty},
-		{ "GetGroupLeader", &luaUnit::GetGroupLeader},
-		{ "SetGroupLeader", &luaUnit::SetGroupLeader},
-		{ "AddGroupMember", &luaUnit::AddGroupMember},
-		{ "SetDungeonDifficulty", &luaUnit::SetDungeonDifficulty},
-		{ "ExpandToRaid", &luaUnit::ExpandToRaid},
-		{ "SendPacketToGroup", &luaUnit::SendPacketToGroup},
-		{ "IsGroupFull", &luaUnit::IsGroupFull},
-		//next 9 credit: Alvanaar
-		{ "IsGroupedWith", &luaUnit::IsGroupedWith},
-		{ "GetTotalHonor", &luaUnit::GetTotalHonor},
-		{ "GetHonorToday", &luaUnit::GetHonorToday},
-		{ "GetHonorYesterday", &luaUnit::GetHonorYesterday},
-		{ "GetArenaPoints", &luaUnit::GetArenaPoints},
-		{ "AddArenaPoints", &luaUnit::AddArenaPoints},
-		{ "AddLifetimeKills", &luaUnit::AddLifetimeKills},
-		{ "GetGender", &luaUnit::GetGender}, //9
-		{ "SetGender", &luaUnit::SetGender},
-		{ "GetGroupType", &luaUnit::GetGroupType},
-		//next 5: cred alvanaar
-		{ "SendPacketToGuild", &luaUnit::SendPacketToGuild },
-		{ "GetGuildId", &luaUnit::GetGuildId },
-		{ "GetGuildRank", &luaUnit::GetGuildRank },
-		{ "SetGuildRank", &luaUnit::SetGuildRank },
-		{ "IsInGuild", &luaUnit::IsInGuild }, //5
-		{ "SendGuildInvite", &luaUnit::SendGuildInvite },
-		{ "DemoteGuildMember", &luaUnit::DemoteGuildMember },
-		{ "PromoteGuildMember", &luaUnit::PromoteGuildMember },
-		{ "SetGuildMotd", &luaUnit::SetGuildMotd },
-		{ "GetGuildMotd", &luaUnit::GetGuildMotd },
-		{ "SetGuildInformation", &luaUnit::SetGuildInformation },
-		{ "AddGuildMember", &luaUnit::AddGuildMember },
-		{ "RemoveGuildMember", &luaUnit::RemoveGuildMember },
-		{ "SetPublicNote", &luaUnit::SetPublicNote },
-		{ "SetOfficerNote", &luaUnit::SetOfficerNote },
-		{ "DisbandGuild", &luaUnit::DisbandGuild },
-		{ "ChangeGuildMaster", &luaUnit::ChangeGuildMaster },
-		{ "SendGuildChatMessage", &luaUnit::SendGuildChatMessage },
-		{ "SendGuildLog", &luaUnit::SendGuildLog },
-		{ "GuildBankDepositMoney", &luaUnit::GuildBankDepositMoney },
-		{ "GuildBankWithdrawMoney", &luaUnit::GuildBankWithdrawMoney },
-		{ "GetInstanceOwner", &luaUnit::GetInstanceOwner },
-		{ "GetGmRank", &luaUnit::GetGmRank },
-		{ "SetByteValue", &luaUnit::SetByteValue },
-		{ "GetByteValue", &luaUnit::GetByteValue },
-		{ "IsPvPFlagged", &luaUnit::IsPvPFlagged },
-		{ "IsFFAPvPFlagged", &luaUnit::IsFFAPvPFlagged },
-		{ "GetGuildLeader", &luaUnit::GetGuildLeader },
-		{ "GetGuildMemberCount", &luaUnit::GetGuildMemberCount },
-		{ "CanAttack", &luaUnit::CanAttack },
-		{ "GetInRangeUnits", &luaUnit::GetInRangeUnits },
-		{ "GetInRangeEnemies", &luaUnit::GetInRangeEnemies },
-		{ "IsFriendly", &luaUnit::IsFriendly },
-		{ "MovePlayerTo", &luaUnit::MovePlayerTo },
-		// next 15 - Alvanaar
-		//{ "IsInChannel", &luaUnit::IsInChannel },
-		//{ "JoinChannel", &luaUnit::JoinChannel },
-		//{ "LeaveChannel", &luaUnit::LeaveChannel },
-		//{ "SetChannelOwner", &luaUnit::SetChannelOwner },
-		//{ "GetChannelOwner", &luaUnit::GetChannelOwner },
-		//{ "SendPacketToChannel", &luaUnit::SendPacketToChannel },
-		//{ "SetChannelName", &luaUnit::SetChannelName },
-		//{ "SetChannelPassword", &luaUnit::SetChannelPassword },
-		//{ "GetChannelPassword", &luaUnit::GetChannelPassword },
-		//{ "GetChannelOwner", &luaUnit::GetChannelOwner },
-		//{ "KickFromChannel", &luaUnit::KickFromChannel },
-		//{ "BanFromChannel", &luaUnit::BanFromChannel },
-		//{ "UnbanFromChannel", &luaUnit::UnbanFromChannel },
-		//{ "GetChannelMemberCount", &luaUnit::GetChannelMemberCount },
-		//{ "GetChannelMembers", &luaUnit::GetChannelMembers },
-		{ "GetPlayerMovementVector", &luaUnit::GetPlayerMovementVector},
-		{ "UnsetKnownTitle", &luaUnit::UnsetKnownTitle},
-		{ "IsInPhase", &luaUnit::IsInPhase},
-		{ "HasFlag", &luaUnit::HasFlag },
-		{ "Repop", &luaUnit::Repop },
-		{ "SetMovementFlags", &luaUnit::SetMovementFlags },
-		{ "GetSpawnId", &luaUnit::GetSpawnId },
-		{ "ResetTalents", &luaUnit::ResetTalents },
-		{ "SetTalentPoints", &luaUnit::SetTalentPoints },
-		{ "GetTalentPoints", &luaUnit::GetTalentPoints },
-		{ "EventChat", &luaUnit::EventChat },
-		{ "GetEquippedItemBySlot", &luaUnit::GetEquippedItemBySlot },
-		{ "GetGuildMembers", &luaUnit::GetGuildMembers },
-		{ "AddAchievement", &luaUnit::AddAchievement },
-		{ "RemoveAchievement", &luaUnit::RemoveAchievement },
-		{ "HasAchievement", &luaUnit::HasAchievement },
-		{ "RemoveArenaPoints", &luaUnit::RemoveArenaPoints},
-		{ "TakeHonor", &luaUnit::TakeHonor},
-		{ "SetPhase", &luaUnit::PhaseSet},
-		{ "DeletePhase", &luaUnit::PhaseDelete},
-		{ "AddToPhase", &luaUnit::PhaseAdd},
-		{ "GetAreaId", &luaUnit::GetAreaId},
-		{ "ResetPetTalents", &luaUnit::ResetPetTalents},
-		{ "IsDazed", &luaUnit::IsDazed },
-		{ "GetAura", &luaUnit::GetAura },
-		{ "IsRooted", &luaUnit::IsRooted },
-		{ "HasAuraWithMechanic", &luaUnit::HasAuraWithMechanic },
-		{ "HasNegativeAura", &luaUnit::HasNegativeAura },
-		{ "HasPositiveAura", &luaUnit::HasPositiveAura },
-		{ "SetActionBar", &luaUnit::SetActionBar },
-		{ "GetClosestEnemy", &luaUnit::GetClosestEnemy },
-		{ "GetClosestFriend", &luaUnit::GetClosestFriend },
-		{ "IsOnTaxi", &luaUnit::IsOnTaxi },
-		{ "GetTaxi", &luaUnit::GetTaxi },
-		{ "GetObjectType", &luaUnit::GetObjectType },
-		{ "CreateCustomWaypoint", &luaUnit::CreateCustomWaypoint },
-		{ "DeleteWaypoints", &luaUnit::DeleteAllWaypoints },
-		{ "GiveXp", &luaUnit::GiveXp },
-		{ "GetPower", &luaUnit::GetPower },
-		{ "GetPowerPct", &luaUnit::GetPowerPct },
-		{ "GetMaxPower", &luaUnit::GetMaxPower },
-		{ "SetPower", &luaUnit::SetPower },
-		{ "SetPowerPct", &luaUnit::SetPowerPct },
-		{ "SetMaxPower", &luaUnit::SetMaxPower },
-		{ "LearnSpells", &luaUnit::LearnSpells },
-		{ NULL, NULL },
+	//hypersniper added commands
+	{ "GetGameTime", &luaUnit::GetGameTime },
+	{ "PlaySoundToPlayer", &luaUnit::PlaySoundToPlayer },
+	{ "GetDuelState", &luaUnit::GetDuelState }, 
+	{ "SetPosition", &luaUnit::SetPosition},
+	{ "CastSpellOnTarget", &luaUnit::CastSpellOnTarget},
+	{ "GetLandHeight", &luaUnit::GetLandHeight},
+	{ "QuestAddStarter", &luaUnit::QuestAddStarter},
+	{ "QuestAddFinisher", &luaUnit::QuestAddFinisher},
+	{ "SetPlayerSpeed", &luaUnit::SetPlayerSpeed},
+	{ "GiveHonor", &luaUnit::GiveHonor},
+	{ "SetBindPoint", &luaUnit::SetBindPoint},
+	{ "SoftDisconnect", &luaUnit::SoftDisconnect},
+	{ "SetZoneWeather", &luaUnit::SetZoneWeather},
+	{ "SetPlayerWeather", &luaUnit::SetPlayerWeather},
+	{ "SendPacketToPlayer", &luaUnit::SendPacketToPlayer},
+	{ "SendPacketToZone", &luaUnit::SendPacketToZone},
+	{ "SendPacketToWorld", &luaUnit::SendPacketToWorld},
+	{ "SendPacketToInstance", &luaUnit::SendPacketToInstance},
+	{ "PlayerSendChatMessage", &luaUnit::PlayerSendChatMessage},
+	{ "GetDistanceYards", &luaUnit::GetDistanceYards},
+	{ "VendorAddItem", &luaUnit::VendorAddItem},
+	{ "VendorRemoveItem", &luaUnit::VendorRemoveItem},
+	{ "VendorRemoveAllItems", &luaUnit::VendorRemoveAllItems},
+	{ "CreatureHasQuest", &luaUnit::CreatureHasQuest},
+	{ "SendVendorWindow", &luaUnit::SendVendorWindow},
+	{ "SendTrainerWindow", &luaUnit::SendTrainerWindow},
+	{ "SendInnkeeperWindow", &luaUnit::SendInnkeeperWindow},
+	{ "SendBankWindow", &luaUnit::SendBankWindow},
+	{ "SendAuctionWindow", &luaUnit::SendAuctionWindow},
+	{ "SendBattlegroundWindow", &luaUnit::SendBattlegroundWindow},
+	{ "GetInventoryItem", &luaUnit::GetInventoryItem},
+	{ "GetInventoryItemById", &luaUnit::GetInventoryItemById},
+	{ "PhaseSet", &luaUnit::PhaseSet},
+	{ "PhaseAdd", &luaUnit::PhaseAdd},
+	{ "PhaseDelete", &luaUnit::PhaseDelete},
+	{ "GetPhase", &luaUnit::GetPhase},
+	{ "AggroWithInRangeFriends", &luaUnit::AggroWithInRangeFriends},
+	{ "GetPrimaryCombatTarget", &luaUnit::GetPrimaryCombatTarget},
+	{ "MoveRandomArea", &luaUnit::MoveRandomArea},
+	{ "SendLootWindow", &luaUnit::SendLootWindow},
+	{ "AddLoot", &luaUnit::AddLoot},
+	{ "SetPacified", &luaUnit::SetPacified},
+	{ "SpawnVehicle", &luaUnit::SpawnVehicle},
+	{ "SetVehicle", &luaUnit::SetVehicle},
+	{ "GetVehicle", &luaUnit::GetVehicle},
+	{ "RemoveFromVehicle", &luaUnit::RemoveFromVehicle},
+	{ "GetVehicleSeat", &luaUnit::GetVehicleSeat},
+	{ "IsVehicle", &luaUnit::IsVehicle},
+	{ "GetPassengerCount", &luaUnit::GetPassengerCount},
+	{ "MoveVehicle", &luaUnit::MoveVehicle},
+	{ "SetPlayerLock", &luaUnit::SetPlayerLock},
+	//3004 ends here
+	{ "GetGroupPlayers", &luaUnit::GetGroupPlayers},
+	{ "IsGm", &luaUnit::IsGm},
+	{ "GetDungeonDifficulty", &luaUnit::GetDungeonDifficulty},
+	{ "GetGroupLeader", &luaUnit::GetGroupLeader},
+	{ "SetGroupLeader", &luaUnit::SetGroupLeader},
+	{ "AddGroupMember", &luaUnit::AddGroupMember},
+	{ "SetDungeonDifficulty", &luaUnit::SetDungeonDifficulty},
+	{ "ExpandToRaid", &luaUnit::ExpandToRaid},
+	{ "SendPacketToGroup", &luaUnit::SendPacketToGroup},
+	{ "IsGroupFull", &luaUnit::IsGroupFull},
+	//next 9 credit: Alvanaar
+	{ "IsGroupedWith", &luaUnit::IsGroupedWith},
+	{ "GetTotalHonor", &luaUnit::GetTotalHonor},
+	{ "GetHonorToday", &luaUnit::GetHonorToday},
+	{ "GetHonorYesterday", &luaUnit::GetHonorYesterday},
+	{ "GetArenaPoints", &luaUnit::GetArenaPoints},
+	{ "AddArenaPoints", &luaUnit::AddArenaPoints},
+	{ "AddLifetimeKills", &luaUnit::AddLifetimeKills},
+	{ "GetGender", &luaUnit::GetGender}, //9
+	{ "SetGender", &luaUnit::SetGender},
+	{ "GetGroupType", &luaUnit::GetGroupType},
+	//next 5: cred alvanaar
+	{ "SendPacketToGuild", &luaUnit::SendPacketToGuild },
+	{ "GetGuildId", &luaUnit::GetGuildId },
+	{ "GetGuildRank", &luaUnit::GetGuildRank },
+	{ "SetGuildRank", &luaUnit::SetGuildRank },
+	{ "IsInGuild", &luaUnit::IsInGuild }, //5
+	{ "SendGuildInvite", &luaUnit::SendGuildInvite },
+	{ "DemoteGuildMember", &luaUnit::DemoteGuildMember },
+	{ "PromoteGuildMember", &luaUnit::PromoteGuildMember },
+	{ "SetGuildMotd", &luaUnit::SetGuildMotd },
+	{ "GetGuildMotd", &luaUnit::GetGuildMotd },
+	{ "SetGuildInformation", &luaUnit::SetGuildInformation },
+	{ "AddGuildMember", &luaUnit::AddGuildMember },
+	{ "RemoveGuildMember", &luaUnit::RemoveGuildMember },
+	{ "SetPublicNote", &luaUnit::SetPublicNote },
+	{ "SetOfficerNote", &luaUnit::SetOfficerNote },
+	{ "DisbandGuild", &luaUnit::DisbandGuild },
+	{ "ChangeGuildMaster", &luaUnit::ChangeGuildMaster },
+	{ "SendGuildChatMessage", &luaUnit::SendGuildChatMessage },
+	{ "SendGuildLog", &luaUnit::SendGuildLog },
+	{ "GuildBankDepositMoney", &luaUnit::GuildBankDepositMoney },
+	{ "GuildBankWithdrawMoney", &luaUnit::GuildBankWithdrawMoney },
+	{ "GetInstanceOwner", &luaUnit::GetInstanceOwner },
+	{ "GetGmRank", &luaUnit::GetGmRank },
+	{ "SetByteValue", &luaUnit::SetByteValue },
+	{ "GetByteValue", &luaUnit::GetByteValue },
+	{ "IsPvPFlagged", &luaUnit::IsPvPFlagged },
+	{ "IsFFAPvPFlagged", &luaUnit::IsFFAPvPFlagged },
+	{ "GetGuildLeader", &luaUnit::GetGuildLeader },
+	{ "GetGuildMemberCount", &luaUnit::GetGuildMemberCount },
+	{ "CanAttack", &luaUnit::CanAttack },
+	{ "GetInRangeUnits", &luaUnit::GetInRangeUnits },
+	{ "GetInRangeEnemies", &luaUnit::GetInRangeEnemies },
+	{ "IsFriendly", &luaUnit::IsFriendly },
+	{ "MovePlayerTo", &luaUnit::MovePlayerTo },
+	// next 15 - Alvanaar
+	//{ "IsInChannel", &luaUnit::IsInChannel },
+	//{ "JoinChannel", &luaUnit::JoinChannel },
+	//{ "LeaveChannel", &luaUnit::LeaveChannel },
+	//{ "SetChannelOwner", &luaUnit::SetChannelOwner },
+	//{ "GetChannelOwner", &luaUnit::GetChannelOwner },
+	//{ "SendPacketToChannel", &luaUnit::SendPacketToChannel },
+	//{ "SetChannelName", &luaUnit::SetChannelName },
+	//{ "SetChannelPassword", &luaUnit::SetChannelPassword },
+	//{ "GetChannelPassword", &luaUnit::GetChannelPassword },
+	//{ "GetChannelOwner", &luaUnit::GetChannelOwner },
+	//{ "KickFromChannel", &luaUnit::KickFromChannel },
+	//{ "BanFromChannel", &luaUnit::BanFromChannel },
+	//{ "UnbanFromChannel", &luaUnit::UnbanFromChannel },
+	//{ "GetChannelMemberCount", &luaUnit::GetChannelMemberCount },
+	//{ "GetChannelMembers", &luaUnit::GetChannelMembers },
+	{ "GetPlayerMovementVector", &luaUnit::GetPlayerMovementVector},
+	{ "UnsetKnownTitle", &luaUnit::UnsetKnownTitle},
+	{ "IsInPhase", &luaUnit::IsInPhase},
+	{ "HasFlag", &luaUnit::HasFlag },
+	{ "Repop", &luaUnit::Repop },
+	{ "SetMovementFlags", &luaUnit::SetMovementFlags },
+	{ "GetSpawnId", &luaUnit::GetSpawnId },
+	{ "ResetTalents", &luaUnit::ResetTalents },
+	{ "SetTalentPoints", &luaUnit::SetTalentPoints },
+	{ "GetTalentPoints", &luaUnit::GetTalentPoints },
+	{ "EventChat", &luaUnit::EventChat },
+	{ "GetEquippedItemBySlot", &luaUnit::GetEquippedItemBySlot },
+	{ "GetGuildMembers", &luaUnit::GetGuildMembers },
+	//{ "AddAchievement", &luaUnit::AddAchievement },
+	//{ "RemoveAchievement", &luaUnit::RemoveAchievement },
+	//{ "HasAchievement", &luaUnit::HasAchievement },
+	{ "RemoveArenaPoints", &luaUnit::RemoveArenaPoints},
+	{ "TakeHonor", &luaUnit::TakeHonor},
+	{ "SetPhase", &luaUnit::PhaseSet},
+	{ "DeletePhase", &luaUnit::PhaseDelete},
+	{ "AddToPhase", &luaUnit::PhaseAdd},
+	{ "GetAreaId", &luaUnit::GetAreaId},
+	{ "ResetPetTalents", &luaUnit::ResetPetTalents},
+	{ "IsDazed", &luaUnit::IsDazed },
+	{ "GetAura", &luaUnit::GetAura },
+	{ "IsRooted", &luaUnit::IsRooted },
+	{ "HasAuraWithMechanic", &luaUnit::HasAuraWithMechanic },
+	{ "HasNegativeAura", &luaUnit::HasNegativeAura },
+	{ "HasPositiveAura", &luaUnit::HasPositiveAura },
+	{ "SetActionBar", &luaUnit::SetActionBar },
+	{ "GetClosestEnemy", &luaUnit::GetClosestEnemy },
+	{ "GetClosestFriend", &luaUnit::GetClosestFriend },
+	{ "IsOnTaxi", &luaUnit::IsOnTaxi },
+	{ "GetTaxi", &luaUnit::GetTaxi },
+	{ "GetObjectType", &luaUnit::GetObjectType },
+	{ "CreateCustomWaypoint", &luaUnit::CreateCustomWaypoint },
+	{ "DeleteWaypoints", &luaUnit::DeleteAllWaypoints },
+	{ "GiveXp", &luaUnit::GiveXp },
+	{ "GetPower", &luaUnit::GetPower },
+	{ "GetPowerPct", &luaUnit::GetPowerPct },
+	{ "GetMaxPower", &luaUnit::GetMaxPower },
+	{ "SetPower", &luaUnit::SetPower },
+	{ "SetPowerPct", &luaUnit::SetPowerPct },
+	{ "SetMaxPower", &luaUnit::SetMaxPower },
+	{ "LearnSpells", &luaUnit::LearnSpells },
+	{ "GetCurrentWaypoint", &luaUnit::GetCurrentWaypoint },
+	{ "GetSelectedGO", &luaUnit::GetSelectedGO },
+	{ "FullCastSpell", &luaUnit::FullCastSpell },
+	{ "FullCastSpellOnTarget", &luaUnit::FullCastSpellOnTarget },
+	{ "DisableMelee", &luaUnit::DisableMelee },
+	{ "DisableRanged", &luaUnit::DisableRanged },
+	{ "DisableSpells", &luaUnit::DisableSpells },
+	{ "DisableCombat", &luaUnit::DisableCombat },
+	{ "DisableTargeting", &luaUnit::DisableTargeting },
+	{ "IsInGroup", &luaUnit::IsInGroup },
+	{ NULL, NULL },
 };
-
-
-
 
 RegType<GameObject> GOMethods[] = {
@@ -556,7 +560,5 @@
 	{ "ModUInt32Value", &luaGameObject::ModUInt32Value },
 	{ "CastSpell", &luaGameObject::CastSpell },
-	{ "FullCastSpell", &luaGameObject::FullCastSpell },
 	{ "CastSpellOnTarget", &luaGameObject::CastSpellOnTarget },
-	{ "FullCastSpellOnTarget", &luaGameObject::FullCastSpellOnTarget },
 	{ "GossipObjectCreateMenu", &luaGameObject::GossipCreateMenu },
 	{ "GossipObjectMenuAddItem", &luaGameObject::GossipMenuAddItem }, 
@@ -564,5 +566,4 @@
 	{ "GossipObjectComplete", &luaGameObject::GossipComplete },
 	{ "GossipObjectSendPOI", &luaGameObject::GossipSendPOI },
-	//{ "EventCastSpell", &luaGameObject::EventCastSpell },
 	{ "RegisterAIUpdateEvent", &luaGameObject::RegisterAIUpdate },
 	{ "ModifyAIUpdateEvent", &luaGameObject::ModAIUpdate },
@@ -577,28 +578,26 @@
 	{ "DespawnObject", &luaGameObject::DespawnObject },
 	//hypersniper's
-		{ "GetGameTime", &luaGameObject::GetGameTime },
-		{ "GetLandHeight", &luaGameObject::GetLandHeight},
-		{ "SetZoneWeather", &luaGameObject::SetZoneWeather},
-		{ "PhaseSet", &luaGameObject::PhaseSet},
-		{ "PhaseAdd", &luaGameObject::PhaseAdd},
-		{ "PhaseDelete", &luaGameObject::PhaseDelete},
-		{ "GetPhase", &luaGameObject::GetPhase},
+	{ "GetGameTime", &luaGameObject::GetGameTime },
+	{ "GetLandHeight", &luaGameObject::GetLandHeight},
+	{ "SetZoneWeather", &luaGameObject::SetZoneWeather},
+	{ "PhaseSet", &luaGameObject::PhaseSet},
+	{ "PhaseAdd", &luaGameObject::PhaseAdd},
+	{ "PhaseDelete", &luaGameObject::PhaseDelete},
+	{ "GetPhase", &luaGameObject::GetPhase},
 	{ "SendPacket", luaGameObject::SendPacket },
-		{ "SendPacketToZone", &luaGameObject::SendPacketToZone},
-		{ "SendPacketToWorld", &luaGameObject::SendPacketToWorld},
-		{ "SendPacketToInstance", &luaGameObject::SendPacketToInstance},
-		{ "AddLoot", &luaGameObject::AddLoot},
-		//3004 ends here
-		{ "Update", &luaGameObject::Update}, //sadikum
-		{ "GetInstanceOwner", &luaGameObject::GetInstanceOwner },
-		{ "GetDungeonDifficulty", &luaGameObject::GetDungeonDifficulty },
-		{ "SetDungeonDifficulty", &luaGameObject::SetDungeonDifficulty },
-		{ "SetByteValue", &luaGameObject::SetByteValue },
-		{ "GetByteValue", &luaGameObject::GetByteValue },
-		{ "HasFlag", &luaGameObject::HasFlag },
-		{ "IsInPhase", &luaGameObject::IsInPhase},
-		{ "SetPhase", &luaGameObject::PhaseSet},
-		{ "DeletePhase", &luaGameObject::PhaseDelete},
-		{ "AddToPhase", &luaGameObject::PhaseAdd},
+	{ "SendPacketToZone", &luaGameObject::SendPacketToZone},
+	{ "SendPacketToWorld", &luaGameObject::SendPacketToWorld},
+	{ "SendPacketToInstance", &luaGameObject::SendPacketToInstance},
+	{ "AddLoot", &luaGameObject::AddLoot},
+	//3004 ends here
+	{ "Update", &luaGameObject::Update}, //sadikum
+	{ "GetInstanceOwner", &luaGameObject::GetInstanceOwner },
+	{ "GetDungeonDifficulty", &luaGameObject::GetDungeonDifficulty },
+	{ "SetDungeonDifficulty", &luaGameObject::SetDungeonDifficulty },
+	{ "HasFlag", &luaGameObject::HasFlag },
+	{ "IsInPhase", &luaGameObject::IsInPhase},
+	{ "SetPhase", &luaGameObject::PhaseSet},
+	{ "DeletePhase", &luaGameObject::PhaseDelete},
+	{ "AddToPhase", &luaGameObject::PhaseAdd},
 	{ "GetAreaId", &luaGameObject::GetAreaId},
 	{ "SetPosition", &luaGameObject::SetPosition},
@@ -608,4 +607,12 @@
 	{ "GetDistanceYards", &luaGameObject::GetDistanceYards },
 	{ "GetSpawnId", &luaGameObject::GetSpawnId },
+	{ "ChangeScale", &luaGameObject::ChangeScale },
+	{ "GetByte", &luaGameObject::GetByte },
+	{ "GetByteValue", &luaGameObject::GetByte },
+	{ "SetByte", &luaGameObject::SetByte },
+	{ "SetByteValue", &luaGameObject::SetByte },
+	{ "FullCastSpell", &luaGameObject::FullCastSpell },
+	{ "FullCastSpellOnTarget", &luaGameObject::FullCastSpellOnTarget },
+	{ "CustomAnimate", &luaGameObject::CustomAnimate },
 	{ NULL, NULL },
 };
Index: /Trunk/src/LuaEngine/LUAEngine.cpp
===================================================================
--- /Trunk/src/LuaEngine/LUAEngine.cpp (revision 1135)
+++ /Trunk/src/LuaEngine/LUAEngine.cpp (revision 1144)
@@ -949,5 +949,5 @@
 	if(ref == LUA_REFNIL || ref == LUA_NOREF)
 		return luaL_error(L,"Error in SuspendLuaThread! Failed to create a valid reference.");
-	TimedEvent * evt = TimedEvent::Allocate(thread,new CallbackP2<LuaEngine,lua_State*,int>(&g_luaMgr,&LuaEngine::ResumeLuaThread,thread,ref),0,waitime,1);
+	TimedEvent * evt = TimedEvent::Allocate(thread,new CallbackP1<LuaEngine,int>(&g_luaMgr,&LuaEngine::ResumeLuaThread,ref),0,waitime,1);
 	sWorld.event_AddEvent(evt);
 	lua_remove(L,1); // remove thread object
@@ -955,5 +955,5 @@
 	//All that remains now are the extra arguments passed to this function.
 	lua_xmove(L,thread,lua_gettop(L));
-	g_luaMgr.getPendingThreadSet().insert(thread);
+	g_luaMgr.getThreadRefs().insert(ref);
 	return lua_yield(thread,lua_gettop(L));
 }
@@ -1541,5 +1541,18 @@
 public:
 	LuaCreature(Creature* creature) : CreatureAIScript(creature) {};
-	~LuaCreature() {};
+	~LuaCreature()
+	{
+		typedef std::multimap<uint32,LuaCreature*> CMAP;
+		CMAP & cMap = sLuaMgr.getLuCreatureMap();
+		CMAP::iterator itr = cMap.find(_unit->GetEntry());
+		CMAP::iterator itend = cMap.upper_bound(_unit->GetEntry());
+		CMAP::iterator it;
+		for(;itr != cMap.end() && itr != itend;)
+		{
+			it = itr++;
+			if(it->second != NULL && it->second == this)
+				cMap.erase(it);
+		}
+	}
 	ARCEMU_INLINE void SetUnit(Creature * ncrc) { _unit = ncrc; }
 	void OnCombatStart(Unit* mTarget)
@@ -1933,20 +1946,4 @@
 		sLuaMgr.ExecuteCall(args);
 		RELEASE_LOCK
-	}
-
-	void Destroy()
-	{
-		typedef std::multimap<uint32,LuaCreature*> CMAP;
-		CMAP & cMap = sLuaMgr.getLuCreatureMap();
-		CMAP::iterator itr = cMap.find(_unit->GetEntry());
-		CMAP::iterator itend = cMap.upper_bound(_unit->GetEntry());
-		CMAP::iterator it;
-		for(;itr != cMap.end() && itr != itend;)
-		{
-			it = itr++;
-			if(it->second != NULL && it->second == this)
-				cMap.erase(it);
-		}
-		delete this;
 	}
 	LuaUnitBinding * m_binding;
@@ -2388,5 +2385,5 @@
 			CRCMAP::iterator itr = cMap.find(id);
 			CRCMAP::iterator itend = cMap.upper_bound(id);
-			for(; itr != itend; ++itr)
+			for(; itr != cMap.end() && itr != itend; ++itr)
 			{
 				//grab the 1st and initalize
@@ -2425,5 +2422,5 @@
 			GMAP::iterator itr = gMap.find(id);
 			GMAP::iterator itend = gMap.upper_bound(id);
-			for(; itr != itend; ++itr)
+			for(; itr != gMap.end() && itr != itend; ++itr)
 			{
 				if(itr->second != NULL && itr->second->getGO() != NULL && itr->second->getGO()->GetGUID() == guid)
@@ -2798,5 +2795,5 @@
 void LuaEngine::Unload()
 {
-	lua_close(lu); // clean up the engine of any existing defined variables
+	// clean up the engine of any existing defined variables
 	{
 		UnitBindingMap::iterator itr = this->m_unitBinding.begin();
@@ -2886,6 +2883,12 @@
 		}
 	}
-
-	m_pendingThreads.clear();
+	set<int>::iterator itr = m_pendingThreads.begin();
+	for(; itr != m_pendingThreads.end(); ++itr)
+	{
+		lua_unref(lu,(*itr));
+	}
+	m_pendingThreads.erase(m_pendingThreads.begin(),m_pendingThreads.end());
+
+	lua_close(lu);
 }
 void LuaEngine::Restart()
@@ -3065,18 +3068,16 @@
 }
 
-void LuaEngine::ResumeLuaThread(lua_State * thread,int ref) {
+void LuaEngine::ResumeLuaThread(int ref) {
 	getcoLock().Acquire();
 	lua_State * expectedThread = NULL;
-	lua_State * foundthread = NULL;
 	lua_rawgeti(lu,LUA_REGISTRYINDEX,ref);
 	if(lua_isthread(lu,-1) )
 		expectedThread = lua_tothread(lu,-1);
-	foundthread = getPendingThread(thread);
-	if(expectedThread != NULL && foundthread != NULL) 
+	if(expectedThread != NULL) 
 	{
 		//push ourself on the stack
-		lua_pushthread(foundthread);
+		lua_pushthread(expectedThread);
 		//move the thread to the main lu state(and pop it off)
-		lua_xmove(foundthread,lu,1);
+		lua_xmove(expectedThread,lu,1);
 		if(lua_rawequal(lu,-1,-2) )
 		{
@@ -3099,6 +3100,11 @@
 #define CHECK_TYPEID(expected_type) if(!ptr || !ptr->IsInWorld() || ptr->GetTypeId() != expected_type) { return 0; }
 #define CHECK_TYPEID_RET(expected_type) if(!ptr || !ptr->IsInWorld() || ptr->GetTypeId() != expected_type) { lua_pushboolean(L,0); return 1; }
-#define CHECK_TYPEID_RET_INT(expected_type) if(!ptr || !ptr->IsInWorld() || ptr->GetTypeId() != expected_type) { lua_pushinteger(L,0); return 1; }
-#define CHECK_TYPEID_RET_NIL(expected_type) if(!ptr || !ptr->isInWorld() || ptr->GetTypeId() != expected_type) { lua_pushnil(L); return 1; }
+#define CHECK_TYPEID_RETINT(expected_type) if(!ptr || !ptr->IsInWorld() || ptr->GetTypeId() != expected_type) { lua_pushinteger(L,0); return 1; }
+#define CHECK_TYPEID_RETNIL(expected_type) if(!ptr || !ptr->IsInWorld() || ptr->GetTypeId() != expected_type) { lua_pushnil(L); return 1; } (void*)0
+#define RET_NIL { lua_pushnil(L); return 1; } (void*)0
+#define RET_BOOL(exp) { (exp) ? lua_pushboolean(L,1) : lua_pushboolean(L,0); return 1; } (void*)0
+#define RET_STRING(str) { lua_pushstring(L,(str)); return 1; } (void*)0
+#define RET_NUMBER(number) { lua_pushnumber(L,(number)); return 1; } (void*)0
+#define RET_INT(integer) { lua_pushinteger(L,(integer)); return 1; } (void*)0
 
 // Simplicity macros.
Index: /Trunk/src/LuaEngine/LUAEngine.h
===================================================================
--- /Trunk/src/LuaEngine/LUAEngine.h (revision 1122)
+++ /Trunk/src/LuaEngine/LUAEngine.h (revision 1144)
@@ -221,5 +221,5 @@
 	typedef HM_NAMESPACE::hash_map<uint32, LuaItemGossipBinding> GossipItemScriptsBindingMap;
 	typedef HM_NAMESPACE::hash_map<uint32, LuaGOGossipBinding> GossipGOScriptsBindingMap;
-	std::set<lua_State * > m_pendingThreads;
+	std::set<int> m_pendingThreads;
 
 	//maps to creature, & go script interfaces
@@ -253,5 +253,5 @@
 
 	void RegisterEvent(uint8 regtype, uint32 id, uint32 evt, const char * func);
-	void ResumeLuaThread(lua_State *, int);
+	void ResumeLuaThread(int);
 	bool BeginCall(const char * func);
 	void HyperCallFunction(const char * FuncName, int ref);
@@ -375,8 +375,8 @@
 		return (itr == m_qAIScripts.end()) ? NULL: itr->second;
 	}
-	lua_State* getPendingThread(lua_State * threadtosearch) {
+	/*int getPendingThread(lua_State * threadtosearch) {
 		set<lua_State*>::iterator itr = m_pendingThreads.find(threadtosearch);
 		return (itr == m_pendingThreads.end() )? NULL : (*itr);
-	}
+	}*/
 	LuaGossip * getUnitGossipInterface(uint32 id) 
 	{
@@ -400,5 +400,5 @@
 	ARCEMU_INLINE HM_NAMESPACE::hash_map<uint32, LuaGossip*> & getItemGossipInterfaceMap() { return m_itemgAIScripts; }
 	ARCEMU_INLINE HM_NAMESPACE::hash_map<uint32, LuaGossip*> & getGameObjectGossipInterfaceMap() { return m_gogAIScripts; }
-	ARCEMU_INLINE set<lua_State * > & getPendingThreadSet() { return m_pendingThreads; }
+	ARCEMU_INLINE set<int> & getThreadRefs() { return m_pendingThreads; }
 
 	struct _ENGINEHOOKINFO { 
Index: /Trunk/src/LuaEngine/UnitFunctions.h
===================================================================
--- /Trunk/src/LuaEngine/UnitFunctions.h (revision 1142)
+++ /Trunk/src/LuaEngine/UnitFunctions.h (revision 1144)
@@ -445,5 +445,4 @@
 	int CastSpell(lua_State * L, Unit * ptr)
 	{
-		//CHECK_TYPEID(TYPEID_UNIT || TYPEID_PLAYER);
 		uint32 sp = CHECK_ULONG(L,1);
 		if (sp && ptr)
@@ -454,5 +453,4 @@
 	int FullCastSpell(lua_State * L, Unit * ptr)
 	{
-		//CHECK_TYPEID(TYPEID_UNIT || TYPEID_PLAYER);
 		uint32 sp = CHECK_ULONG(L,1);
 		if (sp && ptr)
@@ -460,4 +458,15 @@
 		return 0;
 	}
+	int FullCastSpellOnTarget(lua_State * L, Unit * ptr)
+	{
+		if(ptr != NULL)
+		{
+			uint32 sp = CHECK_ULONG(L,1);
+			Unit * target = CHECK_UNIT(L,2);
+			if(sp && target != NULL)
+				ptr->CastSpell(target->GetGUID(),sp,false);
+		}
+		return 0;
+	}
 	int CastSpellOnTarget(lua_State * L, Unit * ptr)
 	{
@@ -465,25 +474,5 @@
 		Unit * target = CHECK_UNIT(L,2);
 		if(ptr != NULL && sp && target != NULL)
-		{
-			Spell * spp = new Spell(ptr,dbcSpell.LookupEntry(sp),true,NULL);
-			spp->m_targets.m_unitTarget = target->GetGUID();
-			//prepare digest
-			SpellCastTargets tar(target->GetGUID());
-			spp->m_targets = tar;
-			spp->SendSpellStart();
-			spp->cast(false);
-		}
-		return 0;
-	}
-
-	int FullCastSpellOnTarget(lua_State * L, Unit * ptr)
-	{
-		//CHECK_TYPEID(TYPEID_UNIT || TYPEID_PLAYER);
-		uint32 sp = CHECK_ULONG(L,1);
-		Unit * target = CHECK_UNIT(L, 2);
-
-		if (!sp || !target || !ptr)
-			return 0;
-		ptr->CastSpell(target,dbcSpell.LookupEntry(sp),false);
+			ptr->CastSpell(target,sp,true);
 		return 0;
 	}
@@ -504,5 +493,5 @@
 		bool save = luaL_optint(L, 12, 0) ? true : false; 
 
-		if(!entry_id || !faction)
+		if(!entry_id)
 		{
 			lua_pushnil(L);
@@ -521,6 +510,9 @@
 			return 1;
 		}
-		pCreature->SetFaction(faction);
-		pCreature->_setFaction();
+		if(faction)
+		{
+			pCreature->SetFaction(faction);
+			pCreature->_setFaction();
+		}
 		pCreature->SetInstanceID(ptr->GetInstanceID());
 		pCreature->SetMapId(ptr->GetMapId());
@@ -528,4 +520,5 @@
 		pCreature->SetEquippedItem(OFFHAND,equip2);
 		pCreature->SetEquippedItem(RANGED,equip3);
+		pCreature->m_noRespawn = true;
 		if (duration)
 			pCreature->Despawn(duration,0);
@@ -568,6 +561,4 @@
 			lua_pushnil(L);
 		return 1;
-
-
 	}
 
@@ -622,6 +613,6 @@
 	int IsInCombat(lua_State * L, Unit * ptr)
 	{
-		if (!ptr)
-			return 0;
+		if(ptr == NULL || !ptr->IsInWorld() )
+			RET_NIL;
 		if(ptr->CombatStatus.IsInCombat())
 			lua_pushboolean(L, 1);
@@ -633,19 +624,20 @@
 	int SetScale(lua_State * L, Unit * ptr)
 	{
-		//CHECK_TYPEID(TYPEID_UNIT);
 		float scale = CHECK_FLOAT(L,1);
 		if (scale && ptr)
 			ptr->SetFloatValue(OBJECT_FIELD_SCALE_X,(float)scale);
-		return 0;
+		else
+			RET_BOOL(false);
+		RET_BOOL(true);
 	}
 
 	int SetModel(lua_State * L, Unit * ptr)
 	{
-		int modelid = luaL_checkint(L,1);
-		if(ptr != NULL) 
-		{
-			ptr->SetDisplayId(modelid);
-		}
-		return 0;
+		uint32 model = CHECK_ULONG(L,1);
+		if(ptr != NULL)
+			ptr->SetDisplayId(model);
+		else
+			RET_BOOL(false);
+		RET_BOOL(true);
 	}
 
@@ -658,45 +650,4 @@
 		return 0;
 	}
-
-	int SetCombatCapable(lua_State * L, Unit * ptr)
-	{
-		CHECK_TYPEID(TYPEID_UNIT);
-		bool enabled = CHECK_BOOL(L,1);
-		ptr->GetAIInterface()->disable_combat = enabled;
-		return 0;
-	}
-
-	int SetCombatMeleeCapable(lua_State * L, Unit * ptr)
-	{
-		CHECK_TYPEID(TYPEID_UNIT);
-		bool enabled = CHECK_BOOL(L,1);
-		ptr->GetAIInterface()->disable_melee = enabled;
-		return 0;
-	}
-
-	int SetCombatRangedCapable(lua_State * L, Unit * ptr)
-	{
-		CHECK_TYPEID(TYPEID_UNIT);
-		bool enabled = CHECK_BOOL(L,1);
-		ptr->GetAIInterface()->disable_ranged = enabled;
-		return 0;
-	}
-
-	int SetCombatSpellCapable(lua_State * L, Unit * ptr)
-	{
-		CHECK_TYPEID(TYPEID_UNIT);
-		bool enabled = CHECK_BOOL(L,1);
-		ptr->GetAIInterface()->disable_spell = enabled;
-		return 0;
-	}
-
-	int SetCombatTargetingCapable(lua_State * L, Unit * ptr)
-	{
-		CHECK_TYPEID(TYPEID_UNIT);
-		bool enabled = CHECK_BOOL(L,1);
-		ptr->GetAIInterface()->disable_targeting = enabled;
-		return 0;
-	}
-
 	int SetMount(lua_State * L, Unit * ptr)
 	{
@@ -1088,5 +1039,5 @@
 				uint32 count = 0;
 				Unit* mt = ptr->GetAIInterface()->GetMostHated();
-				if (!mt->IsPlayer())
+				if (mt == NULL || !mt->IsPlayer())
 					return 0;
 
@@ -1498,5 +1449,5 @@
 	int GetItemCount(lua_State * L, Unit * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_PLAYER);
+		CHECK_TYPEID_RETINT(TYPEID_PLAYER);
 		int itemid = luaL_checkint(L,1);
 		lua_pushinteger(L, TO_PLAYER(ptr)->GetItemInterface()->GetItemCount(itemid,false));
@@ -1519,5 +1470,5 @@
 	int GetMainTank(lua_State * L, Unit * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_UNIT);
+		CHECK_TYPEID_RETINT(TYPEID_UNIT);
 		Unit* ret = ptr->GetAIInterface()->GetMostHated();
 		if (!ret)
@@ -1530,5 +1481,5 @@
 	int GetAddTank(lua_State * L, Unit * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_UNIT);
+		CHECK_TYPEID_RETINT(TYPEID_UNIT);
 		Unit* ret = ptr->GetAIInterface()->GetSecondHated();
 		if(ret==NULL)
@@ -1541,5 +1492,5 @@
 	int ClearThreatList(lua_State * L, Unit * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_UNIT);
+		CHECK_TYPEID_RETINT(TYPEID_UNIT);
 		ptr->ClearHateList();
 		return 0;
@@ -1895,5 +1846,5 @@
 	int WipeHateList(lua_State * L, Unit * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_UNIT);
+		CHECK_TYPEID_RETINT(TYPEID_UNIT);
 		ptr->WipeHateList();
 		return 0;
@@ -1902,5 +1853,5 @@
 	int WipeTargetList(lua_State * L, Unit * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_UNIT);
+		CHECK_TYPEID_RETINT(TYPEID_UNIT);
 		ptr->GetAIInterface()->WipeTargetList();
 		return 0;
@@ -1909,5 +1860,5 @@
 	int WipeCurrentTarget(lua_State * L, Unit * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_UNIT);
+		CHECK_TYPEID_RETINT(TYPEID_UNIT);
 		ptr->GetAIInterface()->WipeCurrentTarget();
 		return 0;
@@ -1967,5 +1918,5 @@
 	int ClearHateList(lua_State * L, Unit * ptr)
 	{
-		CHECK_TYPEID_RET_INT(TYPEID_UNIT);
+		CHECK_TYPEID_RETINT(TYPEID_UNIT);
 		ptr->ClearHateList();
 		return 0;
@@ -4083,5 +4034,5 @@
 	int GetSelection(lua_State * L, Unit * ptr)
 	{
-		CHECK_TYPEID(TYPEID_PLAYER);
+		CHECK_TYPEID_RETNIL(TYPEID_PLAYER);
 		Player * plr = TO_PLAYER(ptr);
 		Unit * selection = plr->GetMapMgr()->GetUnit(plr->GetSelection());
@@ -4092,8 +4043,15 @@
 		return 1;
 	}
+	int GetSelectedGO(lua_State * L, Unit * ptr)
+	{
+		CHECK_TYPEID_RETNIL(TYPEID_PLAYER);
+		Player * plr = TO_PLAYER(ptr);
+		PUSH_GO(L,plr->GetSelectedGo());
+		return 1;
+	}
 
 	int RepairAllPlayerItems(lua_State * L, Unit * ptr)
 	{
-		CHECK_TYPEID(TYPEID_PLAYER);
+		CHECK_TYPEID_RET(TYPEID_PLAYER);
 		Player * plr = TO_PLAYER(ptr);
 		Item * pItem = NULL;
@@ -5907,4 +5865,51 @@
 		return 1;
 	}
+	int GetCurrentWaypoint(lua_State * L, Unit * ptr)
+	{
+		CHECK_TYPEID_RETNIL(TYPEID_UNIT);
+		RET_NUMBER(ptr->GetAIInterface()->getCurrentWaypoint());
+	}
+	int DisableMelee(lua_State * L, Unit * ptr)
+	{
+		CHECK_TYPEID_RET(TYPEID_UNIT)
+		bool disable = CHECK_BOOL(L,1);
+		TO_CREATURE(ptr)->GetAIInterface()->disable_melee = disable;
+		RET_BOOL(true);
+	}
+	int DisableSpells(lua_State * L, Unit * ptr)
+	{
+		CHECK_TYPEID_RET(TYPEID_UNIT)
+		bool disable = CHECK_BOOL(L,1);
+		TO_CREATURE(ptr)->GetAIInterface()->disable_spell = disable;
+		RET_BOOL(true);
+	}
+	int DisableRanged(lua_State * L, Unit * ptr)
+	{
+		CHECK_TYPEID_RET(TYPEID_UNIT)
+		bool disable = CHECK_BOOL(L,1);
+		TO_CREATURE(ptr)->GetAIInterface()->disable_ranged = disable;
+		RET_BOOL(true);
+	}
+	int DisableCombat(lua_State * L, Unit * ptr)
+	{
+		CHECK_TYPEID_RET(TYPEID_UNIT)
+		bool disable = CHECK_BOOL(L,1);
+		TO_CREATURE(ptr)->GetAIInterface()->disable_combat = disable;
+		RET_BOOL(true);
+	}
+	int DisableTargeting(lua_State * L, Unit * ptr)
+	{
+		CHECK_TYPEID_RET(TYPEID_UNIT)
+		bool disable = CHECK_BOOL(L,1);
+		TO_CREATURE(ptr)->GetAIInterface()->disable_targeting = disable;
+		RET_BOOL(true);
+	}
+	int IsInGroup(lua_State * L, Unit * ptr)
+	{
+		CHECK_TYPEID_RET(TYPEID_PLAYER)
+		if(TO_PLAYER(ptr)->InGroup() )
+			RET_BOOL(true);
+		RET_BOOL(false);
+	}
 }
 #endif
