Exemplo n.º 1
0
LTBOOL SecurityCamera::InitialUpdate()
{
    SetNextUpdate(UPDATE_NEXT_FRAME);

	g_pLTServer->GetObjectPos(m_hObject, &m_vPos);

	// Create the light...

	CreateLight();
	
	// Setup the damage types that affect us...

	DamageFlags nCanDamageFlags = 0;
	m_damage.SetCantDamageFlags( ~nCanDamageFlags );

	nCanDamageFlags = DamageTypeToFlag( DT_BULLET ) | DamageTypeToFlag( DT_EXPLODE );
	m_damage.ClearCantDamageFlags( nCanDamageFlags );

    return LTTRUE;
}
CProjectile::CProjectile() : GameBase(OT_MODEL)
{
	AddAggregate(&m_damage);

    m_hObject               = LTNULL;
	m_fVelocity				= 0.0f;
	m_fInstDamage			= 0.0f;
	m_fProgDamage			= 0.0f;
	m_fMass					= INFINITE_MASS; //0.0f;
	m_fLifeTime				= 5.0f;
	m_fRange				= 10000.0f;
    m_bSilenced             = LTFALSE;

	m_vDims.Init(1.0f, 1.0f, 1.0f);
	m_vFirePos.Init();
	m_vFlashPos.Init();

    m_hFiredFrom            = LTNULL;
	m_eInstDamageType		= DT_BULLET;
	m_eProgDamageType		= DT_UNSPECIFIED;
	m_nWeaponId				= 0;
	m_nAmmoId				= 0;

	m_fStartTime			= 0.0f;
    m_bObjectRemoved        = LTFALSE;

    m_bDetonated            = LTFALSE;

	m_dwFlags = FLAG_FORCECLIENTUPDATE | FLAG_POINTCOLLIDE | FLAG_NOSLIDING |
		FLAG_TOUCH_NOTIFY | FLAG_NOLIGHT | FLAG_RAYHIT;

	// Make sure we can't be damaged by any of the progressive/volumebrush
	// damage types...
	m_dwCantDamageTypes		= (DamageTypeToFlag(DT_STUN) | DamageTypeToFlag(DT_SLEEPING) |
		DamageTypeToFlag(DT_BURN) | DamageTypeToFlag(DT_FREEZE) | DamageTypeToFlag(DT_ELECTROCUTE) |
		DamageTypeToFlag(DT_POISON) | DamageTypeToFlag(DT_ENDLESS_FALL));

    m_pAmmoData         = LTNULL;
    m_pWeaponData       = LTNULL;

	m_bProcessInvImpact = LTFALSE;
	m_vInvisVel.Init();
	m_vInvisNewPos.Init();

	m_bNumCallsToAddImpact = 0;
}
Exemplo n.º 3
0
void Body::Init(const BODYINITSTRUCT& bi)
{
	if (!bi.pCharacter || !bi.pCharacter->m_hObject) return;

	// Get the death type etc

	m_eDeathType		= bi.pCharacter->GetDeathType();
	m_eModelId			= bi.pCharacter->GetModelId();
	m_eModelSkeleton    = bi.pCharacter->GetModelSkeleton();
	m_eModelStyle		= bi.pCharacter->GetModelStyle();

	// Get the body lifetime

	m_fLifetime		= bi.fLifetime;

	// Create the SFX

	BODYCREATESTRUCT bcs;
	bcs.eBodyState = bi.eBodyState;
	if (IsPlayer(bi.pCharacter->m_hObject))
	{
		CPlayerObj* pPlayer = (CPlayerObj*) bi.pCharacter;
		bcs.nClientId = (uint8) g_pLTServer->GetClientID(pPlayer->GetClient());
	}

    HMESSAGEWRITE hMessage = g_pLTServer->StartSpecialEffectMessage(this);
    g_pLTServer->WriteToMessageByte(hMessage, SFX_BODY_ID);
    bcs.Write(g_pLTServer, hMessage);
    g_pLTServer->EndMessage(hMessage);


	// Create the death scene

	CreateDeathScene(bi.pCharacter);

	// We'll handle creating the necessary debris...

	m_damage.m_bCreatedDebris = LTTRUE;

	m_damage.SetCanDamage(LTFALSE);//bi.pCharacter->CanDamageBody());
	m_damage.SetApplyDamagePhysics(LTFALSE);//bi.pCharacter->CanDamageBody());
	m_damage.SetMass(g_pModelButeMgr->GetModelMass(m_eModelId));

	// Let us get hit by decay powder

	m_damage.ClearCantDamageTypes(DamageTypeToFlag(DT_GADGET_DECAYPOWDER));

	switch ( g_pModelButeMgr->GetModelType(m_eModelId) )
	{
		case eModelTypeVehicle:
		{
			m_eDeathType = CD_GIB;
		}
		break;
	}

	CDestructible* pDest = bi.pCharacter->GetDestructible();
	if (pDest)
	{
		m_eDamageType = pDest->GetDeathType();
		VEC_COPY(m_vDeathDir, pDest->GetDeathDir());
		VEC_NORM(m_vDeathDir);
		VEC_MULSCALAR(m_vDeathDir, m_vDeathDir, 1.0f + (pDest->GetDeathDamage() / pDest->GetMaxHitPoints()));
	}

	LTFLOAT fHitPts = pDest->GetMaxHitPoints();
	m_damage.Reset(fHitPts, 0.0f);
	m_damage.SetHitPoints(fHitPts);
	m_damage.SetMaxHitPoints(fHitPts);
	m_damage.SetArmorPoints(0.0f);
	m_damage.SetMaxArmorPoints(0.0f);

	// Copy our user flags over, setting our surface type to flesh

    uint32 dwUsrFlags = g_pLTServer->GetObjectUserFlags(m_hObject) | USRFLG_NIGHT_INFRARED;
	dwUsrFlags |= SurfaceToUserFlag(ST_FLESH);
    g_pLTServer->SetObjectUserFlags(m_hObject, dwUsrFlags);

	// Make sure model doesn't slide all over the place...

    g_pLTServer->SetFrictionCoefficient(m_hObject, 500.0f);

	LTVector vDims;
    g_pLTServer->GetObjectDims(bi.pCharacter->m_hObject, &vDims);

	// Set the dims.  If we can't set the dims that big, set them
	// as big as possible...

    if (g_pLTServer->SetObjectDims2(m_hObject, &vDims) == LT_ERROR)
	{
        g_pLTServer->SetObjectDims2(m_hObject, &vDims);
	}


	// Create the box used for weapon impact detection...

	CreateHitBox(bi);


	LTFLOAT r, g, b, a;
    g_pLTServer->GetObjectColor(bi.pCharacter->m_hObject, &r, &g, &b, &a);
    g_pLTServer->SetObjectColor(m_hObject, r, g, b, a);

	LTVector vScale;
    g_pLTServer->GetObjectScale(bi.pCharacter->m_hObject, &vScale);
    g_pLTServer->ScaleObject(m_hObject, &vScale);

	// Copy our animation over

    HMODELANIM hAni = g_pLTServer->GetModelAnimation(bi.pCharacter->m_hObject);
    g_pLTServer->SetModelAnimation(m_hObject, hAni);
    g_pLTServer->SetModelLooping(m_hObject, LTFALSE);

	// Copy the flags from the character to us

	uint32 dwFlags = g_pLTServer->GetObjectFlags(bi.pCharacter->m_hObject);
	m_dwFlags |= FLAG_REMOVEIFOUTSIDE;
    g_pLTServer->SetObjectFlags(m_hObject, dwFlags);

	// Move the attachments aggregate from the char to us...

	if (!m_pAttachments && bi.eBodyState != eBodyStateLaser)
	{
		m_hWeaponItem = bi.pCharacter->TransferWeapon(m_hObject);

		// Make sure we're playing the correct ani...

		if (m_hWeaponItem)
		{
			uint32 dwAni = g_pLTServer->GetAnimIndex(m_hWeaponItem, "Hand");
		 	if (dwAni != INVALID_ANI)
			{
				g_pLTServer->SetModelAnimation(m_hWeaponItem, dwAni);
				g_pLTServer->SetModelLooping(m_hWeaponItem, LTFALSE);
			}
		}
	}

	if (!m_pAttachments)
	{
		m_pAttachments = bi.pCharacter->TransferAttachments();

		if (m_pAttachments)
		{
			AddAggregate(m_pAttachments);
			m_pAttachments->ReInit(m_hObject);
		}
	}

	// Set up the spears

	bi.pCharacter->TransferSpears(this);

	// Set our state

	SetState(bi.eBodyState);
}
Exemplo n.º 4
0
LTBOOL Lock::InitialUpdate()
{
    SetNextUpdate(0.0);

	// Setup up our destructible object...

	m_damage.SetHitPoints(m_fUnlockHitPts);

    uint32 dwCanDamageTypes = 0;

	// Set it up so nothing can damage us...

	m_damage.SetCantDamageTypes(~dwCanDamageTypes);

	// See if we are affected by the welder or the lockpick...

	if (m_bWeldable)
	{
		m_dwUsrFlgs	|= USRFLG_GADGET_WELDER;

		dwCanDamageTypes = (DamageTypeToFlag(DT_GADGET_WELDER) |
			DamageTypeToFlag(DT_EXPLODE) | DamageTypeToFlag(DT_BULLET) |
			DamageTypeToFlag(DT_BURN));
	}
	else if (m_bLightable)
	{
		m_dwUsrFlgs	|= USRFLG_GADGET_LIGHTER;

		dwCanDamageTypes |= (DamageTypeToFlag(DT_GADGET_LIGHTER) |
			DamageTypeToFlag(DT_EXPLODE) | DamageTypeToFlag(DT_BULLET) |
			DamageTypeToFlag(DT_BURN));
	}
	else // Lockpick
	{
		m_dwUsrFlgs	|= USRFLG_GADGET_LOCK_PICK;

		dwCanDamageTypes |= (DamageTypeToFlag(DT_GADGET_LOCK_PICK) |
			DamageTypeToFlag(DT_EXPLODE) | DamageTypeToFlag(DT_BULLET) |
			DamageTypeToFlag(DT_BURN));
	}

	// Okay, now clear the types we want to damage us...

	m_damage.ClearCantDamageTypes(dwCanDamageTypes);


	// Make sure we can be activated even if we are non-solid...

    uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject);
    g_pLTServer->SetObjectFlags(m_hObject, dwFlags | FLAG_RAYHIT);

    return LTTRUE;
}