コード例 #1
0
IFXRESULT IFXMotionMixerImpl::GetRelativeTransform(U32 boneID,F32 *pMatrix16)
	{
	IFXVector3 location;
	IFXQuaternion rotation;
	IFXVector3 scale;

	IFXRESULT iResult=GetBonePosition(boneID,&location,&rotation,&scale);
	if(!IFXSUCCESS(iResult))
		IFXRETURN(iResult);

	IFXMatrix4x4 matrix=rotation;
	matrix.SetTranslation(location);
	matrix.Scale3x4(scale);

	I32 m;
	for(m=0;m<16;m++)
		pMatrix16[m]=matrix[m];

	return IFX_OK;
	}
コード例 #2
0
ファイル: Scripted.cpp プロジェクト: Sh1ft0x0EF/HLSDKRevamp
BOOL CBaseMonster::CineCleanup()
{
	CCineMonster *pOldCine = m_pCine;

	// am I linked to a cinematic?
	if(m_pCine)
	{
		// okay, reset me to what it thought I was before
		m_pCine->m_hTargetEnt = NULL;
		pev->movetype         = m_pCine->m_saved_movetype;
		pev->solid            = m_pCine->m_saved_solid;
		pev->effects          = m_pCine->m_saved_effects;
	}
	else
	{
		// arg, punt
		pev->movetype = MOVETYPE_STEP; // this is evil
		pev->solid    = SOLID_SLIDEBOX;
	}
	m_pCine      = NULL;
	m_hTargetEnt = NULL;
	m_pGoalEnt   = NULL;
	if(pev->deadflag == DEAD_DYING)
	{
		// last frame of death animation?
		pev->health    = 0;
		pev->framerate = 0.0;
		pev->solid     = SOLID_NOT;
		SetState(MONSTERSTATE_DEAD);
		pev->deadflag = DEAD_DEAD;
		UTIL_SetSize(pev, pev->mins, Vector(pev->maxs.x, pev->maxs.y, pev->mins.z + 2));

		if(pOldCine && FBitSet(pOldCine->pev->spawnflags, SF_SCRIPT_LEAVECORPSE))
		{
			SetUse(NULL);   // BUGBUG -- This doesn't call Killed()
			SetThink(NULL); // This will probably break some stuff
			SetTouch(NULL);
		}
		else
			SUB_StartFadeOut(); // SetThink( SUB_DoNothing );
		// This turns off animation & physics in case their origin ends up stuck in the world or something
		StopAnimation();
		pev->movetype = MOVETYPE_NONE;
		pev->effects |= EF_NOINTERP; // Don't interpolate either, assume the corpse is positioned in its final resting place
		return FALSE;
	}

	// If we actually played a sequence
	if(pOldCine && pOldCine->m_iszPlay)
	{
		if(!(pOldCine->pev->spawnflags & SF_SCRIPT_NOSCRIPTMOVEMENT))
		{
			// reset position
			Vector new_origin, new_angle;
			GetBonePosition(0, new_origin, new_angle);

			// Figure out how far they have moved
			// We can't really solve this problem because we can't query the movement of the origin relative
			// to the sequence.  We can get the root bone's position as we do here, but there are
			// cases where the root bone is in a different relative position to the entity's origin
			// before/after the sequence plays.  So we are stuck doing this:

			// !!!HACKHACK: Float the origin up and drop to floor because some sequences have
			// irregular motion that can't be properly accounted for.

			// UNDONE: THIS SHOULD ONLY HAPPEN IF WE ACTUALLY PLAYED THE SEQUENCE.
			Vector oldOrigin = pev->origin;

			// UNDONE: ugly hack.  Don't move monster if they don't "seem" to move
			// this really needs to be done with the AX,AY,etc. flags, but that aren't consistantly
			// being set, so animations that really do move won't be caught.
			if((oldOrigin - new_origin).Length2D() < 8.0)
				new_origin = oldOrigin;

			pev->origin.x = new_origin.x;
			pev->origin.y = new_origin.y;
			pev->origin.z += 1;

			pev->flags |= FL_ONGROUND;
			int drop = DROP_TO_FLOOR(ENT(pev));

			// Origin in solid?  Set to org at the end of the sequence
			if(drop < 0)
				pev->origin = oldOrigin;
			else if(drop == 0) // Hanging in air?
			{
				pev->origin.z = new_origin.z;
				pev->flags &= ~FL_ONGROUND;
			}
			// else entity hit floor, leave there

			// pEntity->pev->origin.z = new_origin.z + 5.0; // damn, got to fix this

			UTIL_SetOrigin(pev, pev->origin);
			pev->effects |= EF_NOINTERP;
		}

		// We should have some animation to put these guys in, but for now it's idle.
		// Due to NOINTERP above, there won't be any blending between this anim & the sequence
		m_Activity = ACT_RESET;
	}
	// set them back into a normal state
	pev->enemy = NULL;
	if(pev->health > 0)
		m_IdealMonsterState = MONSTERSTATE_IDLE; // m_previousState;
	else
	{
		// Dropping out because he got killed
		// Can't call killed() no attacker and weirdness (late gibbing) may result
		m_IdealMonsterState = MONSTERSTATE_DEAD;
		SetConditions(bits_COND_LIGHT_DAMAGE);
		pev->deadflag = DEAD_DYING;
		FCheckAITrigger();
		pev->deadflag = DEAD_NO;
	}

	//	SetAnimation( m_MonsterState );
	ClearBits(pev->spawnflags, SF_MONSTER_WAIT_FOR_SCRIPT);

	return TRUE;
}
コード例 #3
0
ファイル: WinCpp.cpp プロジェクト: mathijs0587/WinCpp
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPTSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
	HWND hWnd;
	WNDCLASSEX wc;

	ZeroMemory(&wc, sizeof(WNDCLASSEX));

	wc.cbSize = sizeof(WNDCLASSEX);
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = WndProc;
	wc.hInstance = hInstance;
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)RGB(0, 0, 0);
	wc.lpszClassName = "WindowClass";

	RegisterClassEx(&wc);	

		hWnd = CreateWindowEx(NULL,
			"WindowClass",
			"DirectX Test",
			WS_EX_TOPMOST | WS_POPUP,
			0, 0,
			SCREEN_WIDTH, SCREEN_HEIGHT,
			NULL,
			NULL,
			hInstance,
			NULL);


	SetWindowLong(hWnd, GWL_EXSTYLE, (int)GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED | WS_EX_TRANSPARENT);
	//SetLayeredWindowAttributes(hWnd, RGB(0, 0, 0), 0, ULW_COLORKEY);
	SetLayeredWindowAttributes(hWnd, RGB(0, 0, 0), 255, LWA_ALPHA);

	ShowWindow(hWnd, nCmdShow);

	// set up and initialize Direct3D
	initD3D(hWnd);	

	DWORD   dwThreadIdArray[MAX_THREADS];
	HANDLE  hThreadArray[MAX_THREADS];
	
	for (int i = 0; i < MAX_THREADS; i++)
	{
		hThreadArray[i] = CreateThread(
			NULL,
			0,
			(LPTHREAD_START_ROUTINE)mainThread,
			NULL,
			0,
			&dwThreadIdArray[i]);
	}
	
	m_Rect.left = 0;
	m_Rect.top = 0;
	m_Rect.right = SCREEN_WIDTH;
	m_Rect.bottom = SCREEN_HEIGHT;

	D3DXCreateFont(d3ddev, 10, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &pFont);
	// enter the main loop:
	MSG msg;
	::SetWindowPos(FindWindow(NULL, LGameWindow), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
	while (TRUE)
	{		
		Sleep(10);		
		::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL);		
		
		while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

		if (msg.message == WM_QUIT)
			break;

		HWND hGameWindow = NULL;
		HANDLE hProcHandle = NULL;
		float vPunchX = NULL;
		float vPunchY = NULL;
		float vPunchZ = NULL;

		if (GetAsyncKeyState(VK_OEM_PLUS))
		{
			RectSize += 0.1f;
		}

		if (GetAsyncKeyState(VK_OEM_MINUS))
		{
			if (RectSize > 1)
			{
				RectSize -= 0.1f;
			}
		}

		if (GetAsyncKeyState(VK_NUMPAD7))
		{
			aimbotSize += 1;
		}
		if (GetAsyncKeyState(VK_NUMPAD8))
		{
			aimbotSize -= 1;
		}

		if (GetAsyncKeyState(VK_NUMPAD5))
		{
			readBone += 1;
			Sleep(200);
		}
		if (GetAsyncKeyState(VK_NUMPAD6) && readBone != 0)
		{
			readBone -= 1;
			Sleep(200);
		}

		hGameWindow = FindWindow(NULL, LGameWindow);
		if (hGameWindow)
		{
			GetWindowThreadProcessId(hGameWindow, &dwProcID);
			if (dwProcID != 0)
			{
				hProcHandle = OpenProcess(PROCESS_ALL_ACCESS, false, dwProcID);
				if (hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL)
				{
					IsGameAvail = false;
				}
				else
				{
					IsGameAvail = true;
				}
			}
		}

		if (IsGameAvail)
		{
			GetWindowRect(FindWindow(NULL, LGameWindow), &m_Rect);

			if (GetAsyncKeyState(VK_NUMPAD9))
			{
				toggle = false;
				radar = false;
				trigger = false;
				norecoil = false;
			}

			if (GetAsyncKeyState(VK_NUMPAD1))
			{
				toggle = true;
			}

			if (GetAsyncKeyState(VK_NUMPAD2))
			{
				radar = true;
			}

			if (GetAsyncKeyState(VK_NUMPAD3))
			{
				trigger = true;
			}

			if (GetAsyncKeyState(VK_NUMPAD4))
			{
				norecoil = true;
			}

			if (toggle)
			{

				DWORD ClientBase = Module("client.dll");
				DWORD temp1 = ClientBase + LocalPlayer;
				ReadProcessMemory(hProcHandle, (LPCVOID)temp1, &dwLocalPlayer, 4, NULL);

				/* Reads the value of InCross */
				DWORD inCross = dwLocalPlayer + InCrosshair;
				DWORD ReadInCross = inCross;

				DWORD Lpitch = dwLocalPlayer + viewOffsetX;
				DWORD Lyaw = dwLocalPlayer + viewOffsetY;

				ReadProcessMemory(hProcHandle, (LPCVOID)Lpitch, &localPlayerStruct.pitch, sizeof(localPlayerStruct.viewAng), 0);
				ReadProcessMemory(hProcHandle, (LPCVOID)Lyaw, &localPlayerStruct.yaw, sizeof(localPlayerStruct.yaw), 0);

				ReadProcessMemory(hProcHandle, (LPCVOID)ReadInCross, &vInCross, sizeof(vInCross), 0);

				/* Read the value of LocalPlayer-TeamNum */
				DWORD LTeamNum = dwLocalPlayer + teamNumber;
				DWORD ReadLTeamNum = LTeamNum;
				
				ReadProcessMemory(hProcHandle, (LPCVOID)ReadLTeamNum, &vLTeamNum, sizeof(vLTeamNum), 0);

				DWORD LPosX = dwLocalPlayer + PositionX;
				DWORD LPosY = dwLocalPlayer + PositionY;
				DWORD LPosZ = dwLocalPlayer + PositionZ;

				ReadProcessMemory(hProcHandle, (LPCVOID)LPosX, &localPlayerStruct.Position[0], sizeof(localPlayerStruct.Position[0]), 0);
				ReadProcessMemory(hProcHandle, (LPCVOID)LPosY, &localPlayerStruct.Position[1], sizeof(localPlayerStruct.Position[1]), 0);
				ReadProcessMemory(hProcHandle, (LPCVOID)LPosZ, &localPlayerStruct.Position[2], sizeof(localPlayerStruct.Position[2]), 0);

				localPlayerStruct.teamNum = vLTeamNum;


				DWORD temp51 = ClientBase + ViewMatrix;
				ReadProcessMemory(hProcHandle, (LPCVOID)temp51, &localPlayerStruct.WorldToScreenMatrix, sizeof(localPlayerStruct.WorldToScreenMatrix), 0);

				TargetsInfo* targetsInfo = new TargetsInfo[64];

				DWORD temp100 = Module("client.dll") + 0x4A3554C + 0x50;
				DWORD temp101;

				ReadProcessMemory(hProcHandle, (LPCVOID)temp100, &temp101, sizeof(temp101), NULL);

				int targetLoop = 0;
				/* Read the Value of EnityList-TeamNum */
				for (int i = 0; i < 64; i++)
				{
					DWORD temp2 = ClientBase + EntityList + (i * EntitySize);
					ReadProcessMemory(hProcHandle, (LPCVOID)temp2, &playersInfo[i].playerAddress, sizeof(playersInfo[i].playerAddress), NULL);
					DWORD temp3 = playersInfo[i].playerAddress + teamNumber;
					ReadProcessMemory(hProcHandle, (LPCVOID)temp3, &playersInfo[i].teamNum, sizeof(playersInfo[i].teamNum), NULL);

					DWORD posX = playersInfo[i].playerAddress + PositionX;
					DWORD posY = playersInfo[i].playerAddress + PositionY;
					DWORD posZ = playersInfo[i].playerAddress + PositionZ;

					DWORD temp102 = temp101 + 0x1E0 * i;

					DWORD temp103 = temp102 + 0x24;

					ReadProcessMemory(hProcHandle, (LPCVOID)temp103, &playersInfo[i].Name, sizeof(playersInfo[i].Name), NULL);

					ReadProcessMemory(hProcHandle, (LPCVOID)posX, &playersInfo[i].Position[0], sizeof(playersInfo[i].Position[0]), NULL);
					ReadProcessMemory(hProcHandle, (LPCVOID)posY, &playersInfo[i].Position[1], sizeof(playersInfo[i].Position[1]), NULL);
					ReadProcessMemory(hProcHandle, (LPCVOID)posZ, &playersInfo[i].Position[2], sizeof(playersInfo[i].Position[2]), NULL);

					DWORD LifeState = playersInfo[i].playerAddress + LifeStatus;

					ReadProcessMemory(hProcHandle, (LPCVOID)LifeState, &playersInfo[i].lifeState, sizeof(playersInfo[i].lifeState), NULL);

					DWORD boneAddress = playersInfo[i].playerAddress + BoneMatrix;

					ReadProcessMemory(hProcHandle, (LPCVOID)boneAddress, &playersInfo[i].boneMatrixAddress, sizeof(playersInfo[i].boneMatrixAddress), NULL);

					GetBonePosition(readBone, i, hProcHandle);

					// Read the value of Health
					DWORD LHealth = playersInfo[i].playerAddress + HealthOff;
					DWORD ReadLHealth = LHealth;
					ReadProcessMemory(hProcHandle, (LPCVOID)ReadLHealth, &vLHealth, sizeof(vLHealth), 0);
					playersInfo[i].Health = vLHealth;

					playersInfo[i].distance = Get3dDistance(localPlayerStruct.Position, playersInfo[i].Position);

					float width = (ESPwidth / playersInfo[i].distance) * 0.5;
					float height = (ESPheight / playersInfo[i].distance) * 0.65;

					if (playersInfo[i].teamNum == localPlayerStruct.teamNum)
						continue;

					if (playersInfo[i].Health < 1)
						continue;

					if (playersInfo[i].lifeState == 0)
						continue;

					if (!WorldToScreen(playersInfo[i].boneXYZ, BoneXY))
						continue;

					if (BoneXY[0] < (SCREEN_WIDTH / 2) - aimbotSize || BoneXY[0] > (SCREEN_WIDTH / 2) + aimbotSize)
						continue;

					if (BoneXY[1] < (SCREEN_HEIGHT / 2) - aimbotSize || BoneXY[1] > (SCREEN_HEIGHT / 2) + aimbotSize)
						continue;

					targetsInfo[targetLoop] = TargetsInfo(localPlayerStruct.Position, playersInfo[i].Position, BoneXY);
					

					targetLoop++;

					
				}
				
				if (targetLoop > 0)
				{
					std::sort(targetsInfo, targetsInfo + targetLoop, CompareTargetEnArray());

					if (GetAsyncKeyState(0x45))
					{
						mouse_event(MOUSEEVENTF_ABSOLUTE, targetsInfo[0].AimXY[0] - (m_Rect.right / 2),
							targetsInfo[0].AimXY[1] - (m_Rect.bottom / 2), 0, 0);
					}
				}

				targetLoop = 0;

				delete [] targetsInfo;

				if (vInCross < 64 && vInCross > 0)
				{
					if (vLTeamNum != playersInfo[vInCross - 1].teamNum
						&& playersInfo[vInCross - 1].lifeState != 0
						&& !GetAsyncKeyState(0x01)
						&& trigger)
					{
						mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
						mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
					}
				}
				/*
				if (GetAsyncKeyState(0x01) && norecoil)
				{
					DWORD Lpitch = dwLocalPlayer + viewOffsetX;
					DWORD Lyaw = dwLocalPlayer + viewOffsetY;

					ReadProcessMemory(hProcHandle, (LPCVOID)Lpitch, &localPlayerStruct.pitch, sizeof(localPlayerStruct.viewAng), 0);
					ReadProcessMemory(hProcHandle, (LPCVOID)Lyaw, &localPlayerStruct.yaw, sizeof(localPlayerStruct.yaw), 0);

					DWORD anglePunchX = dwLocalPlayer + PunchX;
					DWORD anglePunchY = dwLocalPlayer + PunchY;

					float aPunchX;
					float aPunchY;

					ReadProcessMemory(hProcHandle, (LPCVOID)anglePunchX, &aPunchX, sizeof(aPunchX), NULL);
					ReadProcessMemory(hProcHandle, (LPCVOID)anglePunchY, &aPunchY, sizeof(aPunchY), NULL);

					DWORD temp40 = Module("engine.dll") + EPointer;
					DWORD temp41;
					
					ReadProcessMemory(hProcHandle, (LPCVOID)temp40, &temp41, sizeof(temp41), NULL);

					DWORD temp42 = temp41 + 0x4C90;
					DWORD temp43 = temp41 + 0x4C94;

					if (aPunchX < 0.001f && aPunchY < 0.001f)
						continue;

					localPlayerStruct.pitch -= aPunchX * 2.0f;
					localPlayerStruct.yaw -= aPunchY * 2.0f;
					WriteProcessMemory(hProcHandle, (LPVOID)temp42, &localPlayerStruct.pitch, sizeof(localPlayerStruct.pitch), NULL);
					WriteProcessMemory(hProcHandle, (LPVOID)temp43, &localPlayerStruct.yaw, sizeof(localPlayerStruct.yaw), NULL);
					
				}*/
			}
		}
	}

	// clean up DirectX and COM
	cleanD3D();
}
コード例 #4
0
ファイル: Entity.cpp プロジェクト: A5-/CSGO-External
void Entity::CheckVisible( int bone )
{	
	std::future<bool> ret = std::async( std::launch::async, &BSPMap::Visible, g_pBSP, LocalEntity.GetEyePosition(), GetBonePosition( bone ) );
	m_bVisible = ret.get(); // Spawns an async thread then return value to m_bVisible
}
コード例 #5
0
bool CStatueProp::CreateVPhysicsFromHitBoxes( CBaseAnimating *pInitBaseAnimating )
{
	if ( !pInitBaseAnimating )
		return false;

	// Use the current animation sequence and cycle
	CopyAnimationDataFrom( pInitBaseAnimating );

	// Copy over any render color
	color24 colorRender = pInitBaseAnimating->GetRenderColor();
	SetRenderColor( colorRender.r, colorRender.g, colorRender.b );
	SetRenderAlpha( pInitBaseAnimating->GetRenderAlpha() );

	// Get hitbox data
	CStudioHdr *pStudioHdr = GetModelPtr();
	if ( !pStudioHdr )
		return false;

	mstudiohitboxset_t *set = pStudioHdr->pHitboxSet( m_nHitboxSet );
	if ( !set )
		return false;

	Vector position;
	QAngle angles;

	// Make enough pointers to convexes for each hitbox
	CPhysConvex **ppConvex = new (CPhysConvex*[ set->numhitboxes ]);

	float flTotalVolume = 0.0f;
	float flTotalSurfaceArea = 0.0f;

	for ( int i = 0; i < set->numhitboxes; i++ )
	{
		// Get the hitbox info
		mstudiobbox_t *pbox = set->pHitbox( i );
		GetBonePosition( pbox->bone, position, angles );

		// Accumulate volume and area
		Vector flDimentions = pbox->bbmax - pbox->bbmin;
		flTotalVolume += flDimentions.x * flDimentions.y * flDimentions.z;
		flTotalSurfaceArea += 2.0f * ( flDimentions.x * flDimentions.y + flDimentions.x * flDimentions.z + flDimentions.y * flDimentions.z );

		// Get angled min and max extents
		Vector vecMins, vecMaxs;
		VectorRotate( pbox->bbmin, angles, vecMins );
		VectorRotate( pbox->bbmax, angles, vecMaxs );

		// Get the corners in world space
		Vector vecMinCorner = position + vecMins;
		Vector vecMaxCorner = position + vecMaxs;

		// Get the normals of the hitbox in world space
		Vector vecForward, vecRight, vecUp;
		AngleVectors( angles, &vecForward, &vecRight, &vecUp );
		vecRight = -vecRight;

		// Convert corners and normals to local space
		Vector vecCornerLocal[ 2 ];
		Vector vecNormalLocal[ 3 ];

		matrix3x4_t matToWorld = EntityToWorldTransform();
		VectorITransform( vecMaxCorner, matToWorld, vecCornerLocal[ 0 ] );
		VectorITransform( vecMinCorner, matToWorld, vecCornerLocal[ 1 ] );
		VectorIRotate( vecForward, matToWorld, vecNormalLocal[ 0 ] );
		VectorIRotate( vecRight, matToWorld, vecNormalLocal[ 1 ] );
		VectorIRotate( vecUp, matToWorld, vecNormalLocal[ 2 ] );

		// Create 6 planes from the local oriented hit box data
		float pPlanes[ 4 * 6 ];

		for ( int iPlane = 0; iPlane < 6; ++iPlane )
		{
			int iPlaneMod2 = iPlane % 2;
			int iPlaneDiv2 = iPlane / 2;
			bool bOdd = ( iPlaneMod2 == 1 );

			// Plane Normal
			pPlanes[ iPlane * 4 + 0 ] = vecNormalLocal[ iPlaneDiv2 ].x * ( bOdd ? -1.0f : 1.0f );
			pPlanes[ iPlane * 4 + 1 ] = vecNormalLocal[ iPlaneDiv2 ].y * ( bOdd ? -1.0f : 1.0f );
			pPlanes[ iPlane * 4 + 2 ] = vecNormalLocal[ iPlaneDiv2 ].z * ( bOdd ? -1.0f : 1.0f );

			// Plane D
			pPlanes[ iPlane * 4 + 3 ] = ( vecCornerLocal[ iPlaneMod2 ].x * vecNormalLocal[ iPlaneDiv2 ].x + 
				vecCornerLocal[ iPlaneMod2 ].y * vecNormalLocal[ iPlaneDiv2 ].y + 
				vecCornerLocal[ iPlaneMod2 ].z * vecNormalLocal[ iPlaneDiv2 ].z ) * ( bOdd ? -1.0f : 1.0f );
		}

		// Create convex from the intersection of these planes
		ppConvex[ i ] = physcollision->ConvexFromPlanes( pPlanes, 6, 0.0f );
	}

	// Make a single collide out of the group of convex boxes
	CPhysCollide *pPhysCollide = physcollision->ConvertConvexToCollide( ppConvex, set->numhitboxes );

	delete[] ppConvex;

	// Create the physics object
	objectparams_t params = g_PhysDefaultObjectParams;
	params.pGameData = static_cast<void *>( this );

	int nMaterialIndex = physprops->GetSurfaceIndex( "ice" );	// use ice material

	IPhysicsObject* p = physenv->CreatePolyObject( pPhysCollide, nMaterialIndex, GetAbsOrigin(), GetAbsAngles(), &params );
	Assert( p != NULL );

	// Set velocity
	Vector vecInitialVelocity = pInitBaseAnimating->GetAbsVelocity();
	p->SetVelocity( &vecInitialVelocity, NULL );

	// Compute mass
	float flMass;
	float flDensity, flThickness;
	physprops->GetPhysicsProperties( nMaterialIndex, &flDensity, &flThickness, NULL, NULL );

	// Make it more hollow
	flThickness = MIN ( 1.0f, flThickness + 0.5f );

	if ( flThickness > 0.0f )
	{
		flMass = flTotalSurfaceArea * flThickness * CUBIC_METERS_PER_CUBIC_INCH * flDensity;
	}
	else
	{
		// density is in kg/m^3, volume is in in^3
		flMass = flTotalVolume * CUBIC_METERS_PER_CUBIC_INCH * flDensity;
	}

	// Mass is somewhere between the original and if it was all ice
	p->SetMass( flMass );

	// Yes, gravity
	p->EnableGravity( true );

	// Use this as our vphysics
	VPhysicsSetObject( p );

	SetSolid( SOLID_VPHYSICS );
	AddSolidFlags( FSOLID_CUSTOMRAYTEST | FSOLID_CUSTOMBOXTEST );

	SetMoveType( MOVETYPE_VPHYSICS );

	if ( pInitBaseAnimating != this )
	{
		// Transfer children from the init base animating
		TransferChildren( pInitBaseAnimating, this );

		CBaseEntity *pChild = FirstMoveChild();

		while ( pChild )
		{
			CEntityFreezing *pFreezing = dynamic_cast<CEntityFreezing*>( pChild );
			if ( pFreezing )
			{
				pFreezing->FinishFreezing();
			}

			pChild = pChild->NextMovePeer();
		}
	}

	return true;
}