Exemplo n.º 1
0
void CCineMonster::Spawn( void )
{
	// SetSolidType( SOLID_TRIGGER );
	// SetSize( Vector(-8, -8, -8), Vector(8, 8, 8));
	SetSolidType( SOLID_NOT );


	// REMOVE: The old side-effect
#if 0
	if( m_iszIdle )
		m_fMoveTo = 4;
#endif

	// if no targetname, start now
	if( !HasTargetname() || !FStringNull( m_iszIdle ) )
	{
		SetThink( &CCineMonster::CineThink );
		SetNextThink( gpGlobals->time + 1.0 );
		// Wait to be used?
		if( HasTargetname() )
			m_startTime = gpGlobals->time + 1E6;
	}
	if( GetSpawnFlags().Any( SF_SCRIPT_NOINTERRUPT ) )
		m_interruptable = false;
	else
		m_interruptable = true;
}
Exemplo n.º 2
0
void CTriggerVolume::Spawn( void )
{
	SetSolidType( SOLID_NOT );
	SetMoveType( MOVETYPE_NONE );
	SetModel( GetModelName() );    // set size and link into world
	SetModelName( iStringNull );
	SetModelIndex( 0 );
}
Exemplo n.º 3
0
void CBaseDoor::Spawn()
{
	Precache();
	SetMovedir( this );

	if( GetSkin() == 0 )
	{//normal door
		if( GetSpawnFlags().Any( SF_DOOR_PASSABLE ) )
			SetSolidType( SOLID_NOT );
		else
			SetSolidType( SOLID_BSP );
	}
	else
	{// special contents
		SetSolidType( SOLID_NOT );
		GetSpawnFlags().AddFlags( SF_DOOR_SILENT );	// water is silent for now
	}

	SetMoveType( MOVETYPE_PUSH );
	SetAbsOrigin( GetAbsOrigin() );
	SetModel( GetModelName() );

	if( GetSpeed() == 0 )
		SetSpeed( 100 );

	m_vecPosition1 = GetAbsOrigin();
	// Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big
	m_vecPosition2 = m_vecPosition1 + ( GetMoveDir() * ( fabs( GetMoveDir().x * ( GetBounds().x - 2 ) ) + fabs( GetMoveDir().y * ( GetBounds().y - 2 ) ) + fabs( GetMoveDir().z * ( GetBounds().z - 2 ) ) - m_flLip ) );
	ASSERTSZ( m_vecPosition1 != m_vecPosition2, "door start/end positions are equal" );
	if( GetSpawnFlags().Any( SF_DOOR_START_OPEN ) )
	{	// swap pos1 and pos2, put door at pos2
		SetAbsOrigin( m_vecPosition2 );
		m_vecPosition2 = m_vecPosition1;
		m_vecPosition1 = GetAbsOrigin();
	}

	m_toggle_state = TS_AT_BOTTOM;

	// if the door is flagged for USE button activation only, use NULL touch function
	if( GetSpawnFlags().Any( SF_DOOR_USE_ONLY ) )
	{
		SetTouch( NULL );
	}
	else // touchable button
		SetTouch( &CBaseDoor::DoorTouch );
}
Exemplo n.º 4
0
void CBasePlayerAmmo::Spawn()
{
	SetMoveType( MOVETYPE_TOSS );
	SetSolidType( SOLID_TRIGGER );
	SetSize( Vector( -16, -16, 0 ), Vector( 16, 16, 16 ) );
	SetAbsOrigin( GetAbsOrigin() );

	SetTouch( &CBasePlayerAmmo::DefaultTouch );
}
Exemplo n.º 5
0
void CMultiSource::Spawn()
{
	// set up think for later registration

	SetSolidType( SOLID_NOT );
	SetMoveType( MOVETYPE_NONE );
	SetNextThink( gpGlobals->time + 0.1 );
	GetSpawnFlags() |= SF_MULTI_INIT;	// Until it's initialized
	SetThink( &CMultiSource::Register );
}
Exemplo n.º 6
0
void CWallHealth::Spawn()
{
	Precache( );

	SetSolidType( SOLID_BSP );
	SetMoveType( MOVETYPE_PUSH );

	SetAbsOrigin( GetAbsOrigin());		// set size and link into world
	SetSize( GetRelMin(), GetRelMax() );
	SetModel( GetModelName() );
	m_iJuice = gSkillData.GetHealthChargerCapacity();
	SetFrame( 0 );
}
Exemplo n.º 7
0
void CFuncTankControls::Spawn( void )
{
	SetSolidType( SOLID_TRIGGER );
	SetMoveType( MOVETYPE_NONE );
	GetEffects() |= EF_NODRAW;
	SetModel( GetModelName() );

	SetSize( GetRelMin(), GetRelMax() );
	SetAbsOrigin( GetAbsOrigin() );

	SetNextThink( gpGlobals->time + 0.3 );	// After all the func_tank's have spawned

	CBaseEntity::Spawn();
}
Exemplo n.º 8
0
void CCyclerSprite::Spawn( void )
{
	SetSolidType( SOLID_SLIDEBOX );
	SetMoveType( MOVETYPE_NONE );
	SetTakeDamageMode( DAMAGE_YES );
	GetEffects().ClearAll();

	SetFrame( 0 );
	SetNextThink( gpGlobals->time + 0.1 );
	m_animate = 1;
	m_lastTime = gpGlobals->time;

	PRECACHE_MODEL( GetModelName() );
	SetModel( GetModelName() );

	m_maxFrame = ( float ) MODEL_FRAMES( GetModelIndex() ) - 1;
}
Exemplo n.º 9
0
void CRat :: Spawn()
{
	Precache( );

	SetModel( "models/bigrat.mdl");
	SetSize( Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) );

	SetSolidType( SOLID_SLIDEBOX );
	SetMoveType( MOVETYPE_STEP );
	m_bloodColor		= BLOOD_COLOR_RED;
	SetHealth( 8 );
	SetViewOffset( Vector ( 0, 0, 6 ) );// position of the eyes relative to monster's origin.
	m_flFieldOfView		= 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result )
	m_MonsterState		= MONSTERSTATE_NONE;

	MonsterInit();
}
Exemplo n.º 10
0
void CController :: Spawn()
{
	Precache( );

	SetModel( "models/controller.mdl");
	SetSize( Vector( -32, -32, 0 ), Vector( 32, 32, 64 ));

	SetSolidType( SOLID_SLIDEBOX );
	SetMoveType( MOVETYPE_FLY );
	GetFlags() |= FL_FLY;
	m_bloodColor		= BLOOD_COLOR_GREEN;
	SetHealth( gSkillData.GetControllerHealth() );
	SetViewOffset( Vector( 0, 0, -2 ) );// position of the eyes relative to monster's origin.
	m_flFieldOfView		= VIEW_FIELD_FULL;// indicates the width of this monster's forward view cone ( as a dotproduct result )
	m_MonsterState		= MONSTERSTATE_NONE;

	MonsterInit();
}
Exemplo n.º 11
0
void CAirtank::Spawn()
{
	Precache( );
	// motor
	SetMoveType( MOVETYPE_FLY );
	SetSolidType( SOLID_BBOX );

	SetModel( "models/w_oxygen.mdl");
	SetSize( Vector( -16, -16, 0), Vector(16, 16, 36) );
	SetAbsOrigin( GetAbsOrigin() );

	SetTouch( &CAirtank::TankTouch );
	SetThink( &CAirtank::TankThink );

	GetFlags() |= FL_MONSTER;
	SetTakeDamageMode( DAMAGE_YES );
	SetHealth( 20 );
	SetDamage( 50 );
	m_bState = true;
}
Exemplo n.º 12
0
void CTriggerPush::Spawn()
{
	Vector vecAngles = GetAbsAngles();

	if( vecAngles == g_vecZero )
	{
		vecAngles.y = 360;
		SetAbsAngles( vecAngles );
	}

	InitTrigger();

	if( GetSpeed() == 0 )
		SetSpeed( 100 );

	if( GetSpawnFlags().Any( SF_TRIGGER_PUSH_START_OFF ) )// if flagged to Start Turned Off, make trigger nonsolid.
		SetSolidType( SOLID_NOT );

	SetUse( &CTriggerPush::ToggleUse );

	SetAbsOrigin( GetAbsOrigin() );		// Link into the list
}
Exemplo n.º 13
0
void CShower::Spawn( void )
{
	Vector vecVelocity = RANDOM_FLOAT( 200, 300 ) * GetAbsAngles();
	vecVelocity.x += RANDOM_FLOAT( -100.f, 100.f );
	vecVelocity.y += RANDOM_FLOAT( -100.f, 100.f );
	if( vecVelocity.z >= 0 )
		vecVelocity.z += 200;
	else
		vecVelocity.z -= 200;

	SetAbsVelocity( vecVelocity );

	SetMoveType( MOVETYPE_BOUNCE );
	SetGravity( 0.5 );
	SetNextThink( gpGlobals->time + 0.1 );
	SetSolidType( SOLID_NOT );
	SetModel( "models/grenade.mdl" );	// Need a model, just use the grenade, we don't draw it anyway
	SetSize( g_vecZero, g_vecZero );
	GetEffects() |= EF_NODRAW;
	SetSpeed( RANDOM_FLOAT( 0.5, 1.5 ) );

	SetAbsAngles( g_vecZero );
}
Exemplo n.º 14
0
void CBubbling::Spawn( void )
{
	Precache();
	SetModel( GetModelName() );		// Set size

	SetSolidType( SOLID_NOT );							// Remove model & collisions
	SetRenderAmount( 0 );								// The engine won't draw this model if this is set to 0 and blending is on
	SetRenderMode( kRenderTransTexture );
	int speed = fabs( GetSpeed() );

	// HACKHACK!!! - Speed in rendercolor
	SetRenderColor( Vector( speed >> 8, speed & 255, ( GetSpeed() < 0 ) ? 1 : 0 ) );


	if( !GetSpawnFlags().Any( SF_BUBBLES_STARTOFF ) )
	{
		SetThink( &CBubbling::FizzThink );
		SetNextThink( gpGlobals->time + 2.0 );
		m_state = true;
	}
	else
		m_state = false;
}
Exemplo n.º 15
0
void CGargantua :: Spawn()
{
	Precache( );

	SetModel( "models/garg.mdl");
	SetSize( Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) );

	SetSolidType( SOLID_SLIDEBOX );
	SetMoveType( MOVETYPE_STEP );
	m_bloodColor		= BLOOD_COLOR_GREEN;
	SetHealth( gSkillData.GetGargantuaHealth() );
	//SetViewOffset( Vector ( 0, 0, 96 ) );// taken from mdl file
	m_flFieldOfView		= -0.2;// width of forward view cone ( as a dotproduct result )
	m_MonsterState		= MONSTERSTATE_NONE;

	MonsterInit();

	m_pEyeGlow = CSprite::SpriteCreate( GARG_EYE_SPRITE_NAME, GetAbsOrigin(), false );
	m_pEyeGlow->SetTransparency( kRenderGlow, 255, 255, 255, 0, kRenderFxNoDissipation );
	m_pEyeGlow->SetAttachment( this, 1 );
	EyeOff();
	m_seeTime = gpGlobals->time + 5;
	m_flameTime = gpGlobals->time + 2;
}
Exemplo n.º 16
0
void CBasePlayer::PreThink()
{
	const int buttonsChanged = ( m_afButtonLast ^ GetButtons().Get() );	// These buttons have changed this frame

	// Debounced button codes for pressed/released
	// UNDONE: Do we need auto-repeat?
	m_afButtonPressed = buttonsChanged & GetButtons().Get();		// The changed ones still down are "pressed"
	m_afButtonReleased = buttonsChanged & ( ~GetButtons().Get() );	// The ones not down are "released"

	g_pGameRules->PlayerThink( this );

	bool bCheckVehicles = true;

#if USE_ANGELSCRIPT
	uint32_t uiFlags = PreThinkFlag::NONE;

	CallGlobalEvent( g_PlayerPreThinkEvent, CallFlag::NONE, this, &uiFlags );

	bCheckVehicles = !( uiFlags & PreThinkFlag::SKIP_VEHICLES );
#endif

	if( g_fGameOver )
		return;         // intermission or finale

	UTIL_MakeVectors( GetViewAngle() );             // is this still used?

	ItemPreFrame();
	WaterMove();

	if( g_pGameRules && g_pGameRules->FAllowFlashlight() )
		m_iHideHUD &= ~HIDEHUD_FLASHLIGHT;
	else
		m_iHideHUD |= HIDEHUD_FLASHLIGHT;


	// JOHN: checks if new client data (for HUD and view control) needs to be sent to the client
	UpdateClientData();

	CheckTimeBasedDamage();

	CheckSuitUpdate();

	// Observer Button Handling
	if( IsObserver() )
	{
		Observer_HandleButtons();
		Observer_CheckTarget();
		Observer_CheckProperties();
		SetImpulse( 0 );
		return;
	}

	if( GetDeadFlag() >= DEAD_DYING )
	{
		PlayerDeathThink();
		return;
	}

	// So the correct flags get sent to client asap.
	//
	if( m_afPhysicsFlags & PFLAG_ONTRAIN )
		GetFlags() |= FL_ONTRAIN;
	else
		GetFlags().ClearFlags( FL_ONTRAIN );

	if( bCheckVehicles )
	{
#if USE_OPFOR
	//We're on a rope. - Solokiller
	if( m_afPhysicsFlags & PFLAG_ONROPE && m_pRope )
	{
		SetAbsVelocity( g_vecZero );

		const Vector vecAttachPos = m_pRope->GetAttachedObjectsPosition();

		SetAbsOrigin( vecAttachPos );

		Vector vecForce;

		/*
		//TODO: This causes sideways acceleration that doesn't occur in Op4. - Solokiller
		//TODO: should be IN_MOVERIGHT and IN_MOVELEFT - Solokiller
		if( GetButtons().Any( IN_DUCK ) )
		{
			vecForce.x = gpGlobals->v_right.x;
			vecForce.y = gpGlobals->v_right.y;
			vecForce.z = 0;
			
			m_pRope->ApplyForceFromPlayer( vecForce );
		}

		if( GetButtons().Any( IN_JUMP ) )
		{
			vecForce.x = -gpGlobals->v_right.x;
			vecForce.y = -gpGlobals->v_right.y;
			vecForce.z = 0;
			m_pRope->ApplyForceFromPlayer( vecForce );
		}
		*/

		//Determine if any force should be applied to the rope, or if we should move around. - Solokiller
		if( GetButtons().Any( IN_BACK | IN_FORWARD ) )
		{
			if( ( gpGlobals->v_forward.x * gpGlobals->v_forward.x + 
				gpGlobals->v_forward.y * gpGlobals->v_forward.y - 
				gpGlobals->v_forward.z * gpGlobals->v_forward.z ) <= 0.0 )
			{
				if( m_bIsClimbing )
				{
					const float flDelta = gpGlobals->time - m_flLastClimbTime;
					m_flLastClimbTime = gpGlobals->time;
					if( GetButtons().Any( IN_FORWARD ) )
					{
						if( gpGlobals->v_forward.z < 0.0 )
						{
							if( !m_pRope->MoveDown( flDelta ) )
							{
								//Let go of the rope, detach. - Solokiller
								SetMoveType( MOVETYPE_WALK );
								SetSolidType( SOLID_SLIDEBOX );

								m_afPhysicsFlags &= ~PFLAG_ONROPE;
								m_pRope->DetachObject();
								m_pRope = nullptr;
								m_bIsClimbing = false;
							}
						}
						else
						{
							m_pRope->MoveUp( flDelta );
						}
					}
					if( GetButtons().Any( IN_BACK ) )
					{
						if( gpGlobals->v_forward.z < 0.0 )
						{
							m_pRope->MoveUp( flDelta );
						}
						else if( !m_pRope->MoveDown( flDelta ) )
						{
							//Let go of the rope, detach. - Solokiller
							SetMoveType( MOVETYPE_WALK );
							SetSolidType( SOLID_SLIDEBOX );
							m_afPhysicsFlags &= ~PFLAG_ONROPE;
							m_pRope->DetachObject();
							m_pRope = nullptr;
							m_bIsClimbing = false;
						}
					}
				}
				else
				{
					m_bIsClimbing = true;
					m_flLastClimbTime = gpGlobals->time;
				}
			}
			else
			{
				vecForce.x = gpGlobals->v_forward.x;
				vecForce.y = gpGlobals->v_forward.y;
				vecForce.z = 0.0;
				if( GetButtons().Any( IN_BACK ) )
				{
					vecForce.x = -gpGlobals->v_forward.x;
					vecForce.y = -gpGlobals->v_forward.y;
					vecForce.z = 0;
				}
				m_pRope->ApplyForceFromPlayer( vecForce );
				m_bIsClimbing = false;
			}
		}
		else
		{
			m_bIsClimbing = false;
		}

		if( m_afButtonPressed & IN_JUMP )
		{
			//We've jumped off the rope, give us some momentum - Solokiller
			SetMoveType( MOVETYPE_WALK );
			SetSolidType( SOLID_SLIDEBOX );
			this->m_afPhysicsFlags &= ~PFLAG_ONROPE;

			Vector vecDir = gpGlobals->v_up * 165.0 + gpGlobals->v_forward * 150.0;

			Vector vecVelocity = m_pRope->GetAttachedObjectsVelocity() * 2;

			vecVelocity.NormalizeInPlace();

			vecVelocity = vecVelocity * 200;

			SetAbsVelocity( vecVelocity + vecDir );

			m_pRope->DetachObject();
			m_pRope = nullptr;
			m_bIsClimbing = false;
		}
		return;
	}
#endif

		// Train speed control
		if( m_afPhysicsFlags & PFLAG_ONTRAIN )
		{
			CBaseEntity *pTrain = GetGroundEntity();

			//To match original behavior, Instance returns the world if entity is null - Solokiller
			if( !pTrain )
				pTrain = CWorld::GetInstance();

			float vel;

			if( !pTrain )
			{
				TraceResult trainTrace;
				// Maybe this is on the other side of a level transition
				UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + Vector( 0, 0, -38 ), ignore_monsters, ENT( pev ), &trainTrace );

				// HACKHACK - Just look for the func_tracktrain classname
				if( trainTrace.flFraction != 1.0 && trainTrace.pHit )
					pTrain = CBaseEntity::Instance( trainTrace.pHit );


				if( !pTrain || !( pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE ) || !pTrain->OnControls( this ) )
				{
					//ALERT( at_error, "In train mode with no train!\n" );
					m_afPhysicsFlags &= ~PFLAG_ONTRAIN;
					m_iTrain = TRAIN_NEW | TRAIN_OFF;
					return;
				}
			}
			else if( !GetFlags().Any( FL_ONGROUND ) || pTrain->GetSpawnFlags().Any( SF_TRACKTRAIN_NOCONTROL ) || ( GetButtons().Any( IN_MOVELEFT | IN_MOVERIGHT ) ) )
			{
				// Turn off the train if you jump, strafe, or the train controls go dead
				m_afPhysicsFlags &= ~PFLAG_ONTRAIN;
				m_iTrain = TRAIN_NEW | TRAIN_OFF;
				return;
			}

			SetAbsVelocity( g_vecZero );
			vel = 0;
			if( m_afButtonPressed & IN_FORWARD )
			{
				vel = 1;
				pTrain->Use( this, this, USE_SET, ( float ) vel );
			}
			else if( m_afButtonPressed & IN_BACK )
			{
				vel = -1;
				pTrain->Use( this, this, USE_SET, ( float ) vel );
			}

			if( vel )
			{
				m_iTrain = TrainSpeed( pTrain->GetSpeed(), pTrain->GetImpulse() );
				m_iTrain |= TRAIN_ACTIVE | TRAIN_NEW;
			}

		}
		else if( m_iTrain & TRAIN_ACTIVE )
			m_iTrain = TRAIN_NEW; // turn off train
	}

	if( GetButtons().Any( IN_JUMP ) )
	{
		// If on a ladder, jump off the ladder
		// else Jump
		Jump();
	}


	// If trying to duck, already ducked, or in the process of ducking
	if( GetButtons().Any( IN_DUCK ) || GetFlags().Any( FL_DUCKING ) || ( m_afPhysicsFlags & PFLAG_DUCKING ) )
		Duck();

	if( !GetFlags().Any( FL_ONGROUND ) )
	{
		m_flFallVelocity = -GetAbsVelocity().z;
	}

	// StudioFrameAdvance( );//!!!HACKHACK!!! Can't be hit by traceline when not animating?

	// Clear out ladder pointer
	m_hEnemy = NULL;

	if( m_afPhysicsFlags & PFLAG_ONBARNACLE )
	{
		SetAbsVelocity( g_vecZero );
	}
}
Exemplo n.º 17
0
void CShockBeam::Spawn()
{
	Precache();

	SetMoveType( MOVETYPE_FLY );
	SetSolidType( SOLID_BBOX );

	SetModel( "models/shock_effect.mdl" );

	SetAbsOrigin( GetAbsOrigin() );

	SetSize( Vector( -4, -4, -4 ), Vector( 4, 4, 4 ) );

	SetTouch( &CShockBeam::BallTouch );
	SetThink( &CShockBeam::FlyThink );

	m_pSprite = CSprite::SpriteCreate( 
		"sprites/flare3.spr", 
		GetAbsOrigin(), 
		false );

	m_pSprite->SetRenderMode( kRenderTransAdd );
	m_pSprite->SetRenderColor( Vector( 255, 255, 255 ) );
	m_pSprite->SetRenderAmount( 255 );
	m_pSprite->SetRenderFX( kRenderFxDistort );

	m_pSprite->SetScale( 0.35 );

	m_pSprite->SetAttachment( edict(), 0 );

	m_pBeam1 = CBeam::BeamCreate( "sprites/lgtning.spr", 60 );

	if( m_pBeam1 )
	{
		m_pBeam1->SetAbsOrigin( GetAbsOrigin() );

		m_pBeam1->EntsInit( entindex(), entindex() );

		m_pBeam1->SetStartAttachment( 1 );
		m_pBeam1->SetEndAttachment( 2 );

		m_pBeam1->SetRenderColor( Vector( 0, 253, 253 ) );

		m_pBeam1->SetFlags( BEAM_FSHADEOUT );
		m_pBeam1->SetBrightness( 180 );
		m_pBeam1->SetNoise( 0 );

		m_pBeam1->SetScrollRate( 10 );

		if( bIsMultiplayer() )
		{
			SetNextThink( gpGlobals->time + 0.01 );
			return;
		}

		m_pBeam2 = CBeam::BeamCreate( "sprites/lgtning.spr", 20 );

		if( m_pBeam2 )
		{
			m_pBeam2->SetAbsOrigin( GetAbsOrigin() );

			m_pBeam2->EntsInit( entindex(), entindex() );

			m_pBeam2->SetStartAttachment( 1 );
			m_pBeam2->SetEndAttachment( 2 );

			m_pBeam2->SetRenderColor( Vector( 255, 255, 157 ) );

			m_pBeam2->SetFlags( BEAM_FSHADEOUT );
			m_pBeam2->SetBrightness( 180 );
			m_pBeam2->SetNoise( 30 );

			m_pBeam2->SetScrollRate( 30 );

			SetNextThink( gpGlobals->time + 0.01 );
		}
	}
}