Ejemplo 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;
}
Ejemplo n.º 2
0
void CScriptedSentence::DelayThink( void )
{
	m_active = true;
	if( !HasTargetname() )
		pev->nextthink = gpGlobals->time + 0.1;
	SetThink( &CScriptedSentence::FindThink );
}
Ejemplo n.º 3
0
void CFuncTrain::Activate( void )
{
	// Not yet active, so teleport to first target
	if( !m_activated )
	{
		m_activated = true;

		CBaseEntity* pTarg = UTIL_FindEntityByTargetname( nullptr, GetTarget() );

		//Use the world if no target was found. Replicates SDK behavior. - Solokiller
		if( !pTarg )
		{
			pTarg = CWorld::GetInstance();
		}

		pev->target = MAKE_STRING( pTarg->GetTarget() );
		//TODO change to EHANDLE - Solokiller
		m_pevCurrentTarget = pTarg->pev;// keep track of this since path corners change our target for us.

		SetAbsOrigin( pTarg->GetAbsOrigin() - ( pev->mins + pev->maxs ) * 0.5 );

		if( !HasTargetname() )
		{	// not triggered, so start immediately
			pev->nextthink = pev->ltime + 0.1;
			SetThink( &CFuncTrain::Next );
		}
		else
			pev->spawnflags |= SF_TRAIN_WAIT_RETRIGGER;
	}
}
Ejemplo n.º 4
0
//
// Doors not tied to anything (e.g. button, another door) can be touched, to make them activate.
//
void CBaseDoor::DoorTouch( CBaseEntity *pOther )
{
	// Ignore touches by anything but players
	if( !pOther->IsPlayer() )
		return;

	// If door has master, and it's not ready to trigger, 
	// play 'locked' sound

	if( m_sMaster && !UTIL_IsMasterTriggered( m_sMaster, pOther ) )
		PlayLockSounds( this, &m_ls, true, false );

	// If door is somebody's target, then touching does nothing.
	// You have to activate the owner (e.g. button).

	if( HasTargetname() )
	{
		// play locked sound
		PlayLockSounds( this, &m_ls, true, false );
		return;
	}

	m_hActivator = pOther;// remember who activated the door

	if( DoorActivate() )
		SetTouch( NULL ); // Temporarily disable the touch function, until movement is finished.
}
Ejemplo n.º 5
0
// find all the cinematic entities with my targetname and stop them from playing
void CCineMonster::CancelScript( void )
{
	ALERT( at_aiconsole, "Cancelling script: %s\n", STRING( m_iszPlay ) );

	if( !HasTargetname() )
	{
		ScriptEntityCancel( this );
		return;
	}

	CBaseEntity* pCineTarget = nullptr;

	while( ( pCineTarget = UTIL_FindEntityByTargetname( pCineTarget, GetTargetname() ) ) != nullptr )
	{
		ScriptEntityCancel( pCineTarget );
	}
}
Ejemplo n.º 6
0
void CMonsterMaker :: Spawn( )
{
	pev->solid = SOLID_NOT;

	m_cLiveChildren = 0;
	Precache();
	if ( HasTargetname() )
	{
		if ( pev->spawnflags & SF_MONSTERMAKER_CYCLIC )
		{
			SetUse ( &CMonsterMaker::CyclicUse );// drop one monster each time we fire
		}
		else
		{
			SetUse ( &CMonsterMaker::ToggleUse );// so can be turned on/off
		}

		if ( FBitSet ( pev->spawnflags, SF_MONSTERMAKER_START_ON ) )
		{// start making monsters as soon as monstermaker spawns
			m_fActive = true;
			SetThink ( &CMonsterMaker::MakerThink );
		}
		else
		{// wait to be activated.
			m_fActive = false;
			SetThink ( &CMonsterMaker::SUB_DoNothing );
		}
	}
	else
	{// no targetname, just start.
			pev->nextthink = gpGlobals->time + m_flDelay;
			m_fActive = true;
			SetThink ( &CMonsterMaker::MakerThink );
	}

	if ( m_cNumMonsters == 1 )
	{
		m_fFadeChildren = false;
	}
	else
	{
		m_fFadeChildren = true;
	}

	m_flGround = 0;
}
Ejemplo n.º 7
0
void CFuncPlat::Spawn()
{
	Setup();

	Precache();

	// If this platform is the target of some button, it starts at the TOP position,
	// and is brought down by that button.  Otherwise, it starts at BOTTOM.
	if( HasTargetname() )
	{
		SetAbsOrigin( m_vecPosition1 );
		m_toggle_state = TS_AT_TOP;
		SetUse( &CFuncPlat::PlatUse );
	}
	else
	{
		SetAbsOrigin( m_vecPosition2 );
		m_toggle_state = TS_AT_BOTTOM;
	}
}
Ejemplo n.º 8
0
void CSprite::Spawn( void )
{
	pev->solid = SOLID_NOT;
	pev->movetype = MOVETYPE_NONE;
	pev->effects = 0;
	pev->frame = 0;

	Precache();
	SetModel( STRING( pev->model ) );

	m_maxFrame = ( float ) MODEL_FRAMES( pev->modelindex ) - 1;
	if( HasTargetname() && !( pev->spawnflags & SF_SPRITE_STARTON ) )
		TurnOff();
	else
		TurnOn();

	// Worldcraft only sets y rotation, copy to Z
	if( pev->angles.y != 0 && pev->angles.z == 0 )
	{
		pev->angles.z = pev->angles.y;
		pev->angles.y = 0;
	}
}
Ejemplo n.º 9
0
void CScriptedSentence::Spawn( void )
{
	pev->solid = SOLID_NOT;

	m_active = true;
	// if no targetname, start now
	if( !HasTargetname() )
	{
		SetThink( &CScriptedSentence::FindThink );
		pev->nextthink = gpGlobals->time + 1.0;
	}

	switch( static_cast<SoundRadius>( pev->impulse ) )
	{
	case SoundRadius::MEDIUM:			// Medium radius
		m_flAttenuation = ATTN_STATIC;
		break;

	case SoundRadius::LARGE:			// Large radius
		m_flAttenuation = ATTN_NORM;
		break;

	case SoundRadius::PLAY_EVERYWHERE:	//EVERYWHERE
		m_flAttenuation = ATTN_NONE;
		break;

	default:
	case SoundRadius::SMALL:			// Small radius
		m_flAttenuation = ATTN_IDLE;
		break;
	}
	pev->impulse = 0;

	// No volume, use normal
	if( m_flVolume <= 0 )
		m_flVolume = 1.0;
}
Ejemplo n.º 10
0
void CBaseDoor::Blocked( CBaseEntity *pOther )
{
	CBaseDoor	*pDoor = NULL;


	// Hurt the blocker a little.
	if( GetDamage() )
		pOther->TakeDamage( this, this, GetDamage(), DMG_CRUSH );

	// if a door has a negative wait, it would never come back if blocked,
	// so let it just squash the object to death real fast

	if( m_flWait >= 0 )
	{
		if( m_toggle_state == TS_GOING_DOWN )
		{
			DoorGoUp();
		}
		else
		{
			DoorGoDown();
		}
	}

	// Block all door pieces with the same targetname here.
	if( HasTargetname() )
	{
		CBaseEntity* pTarget = nullptr;
		while( ( pTarget = UTIL_FindEntityByTargetname( pTarget, GetTargetname() ) ) != nullptr )
		{
			if( pTarget != this )
			{
				if( pTarget->ClassnameIs( "func_door" ) || pTarget->ClassnameIs( "func_door_rotating" ) )
				{
					pDoor = static_cast<CBaseDoor*>( pTarget );

					if( pDoor->m_flWait >= 0 )
					{
						//TODO: comparing avel with vel is probably wrong - Solokiller
						if( pDoor->GetAbsVelocity() == GetAbsVelocity() && pDoor->GetAngularVelocity() == GetAbsVelocity() )
						{
							// this is the most hacked, evil, bastardized thing I've ever seen. kjb
							if( pTarget->ClassnameIs( "func_door" ) )
							{// set origin to realign normal doors
								pDoor->SetAbsOrigin( GetAbsOrigin() );
								pDoor->SetAbsVelocity( g_vecZero );// stop!
							}
							else
							{// set angles to realign rotating doors
								pDoor->SetAbsAngles( GetAbsAngles() );
								pDoor->SetAngularVelocity( g_vecZero );
							}
						}

						if( !GetSpawnFlags().Any( SF_DOOR_SILENT ) )
							STOP_SOUND( this, CHAN_STATIC, ( char* ) STRING( pev->noiseMoving ) );

						if( pDoor->m_toggle_state == TS_GOING_DOWN )
							pDoor->DoorGoUp();
						else
							pDoor->DoorGoDown();
					}
				}
			}
		}
	}
}
Ejemplo n.º 11
0
//=========================================================
//=========================================================
void CBasePlayer::CheatImpulseCommands( int iImpulse )
{
	if( !UTIL_CheatsAllowed() )
	{
		return;
	}

	switch( iImpulse )
	{
	case 76:
		{
			if( !g_bPrecacheGrunt )
			{
				g_bPrecacheGrunt = true;
				ALERT( at_console, "You must now restart to use Grunt-o-matic.\n" );
			}
			else
			{
				UTIL_MakeVectors( Vector( 0, GetViewAngle().y, 0 ) );
				Create( "monster_human_grunt", GetAbsOrigin() + gpGlobals->v_forward * 128, GetAbsAngles() );
			}
			break;
		}

	case 101:
		{
			gEvilImpulse101 = true;
			GiveNamedItem( "item_suit" );
			GiveNamedItem( "item_battery" );
			GiveNamedItem( "weapon_crowbar" );
			GiveNamedItem( "weapon_9mmhandgun" );
			GiveNamedItem( "ammo_9mmclip" );
			GiveNamedItem( "weapon_shotgun" );
			GiveNamedItem( "ammo_buckshot" );
			GiveNamedItem( "weapon_9mmAR" );
			GiveNamedItem( "ammo_9mmAR" );
			GiveNamedItem( "ammo_ARgrenades" );
			GiveNamedItem( "weapon_handgrenade" );
			GiveNamedItem( "weapon_tripmine" );

			GiveNamedItem( "weapon_357" );
			GiveNamedItem( "ammo_357" );
			GiveNamedItem( "weapon_crossbow" );
			GiveNamedItem( "ammo_crossbow" );
			GiveNamedItem( "weapon_egon" );
			GiveNamedItem( "weapon_gauss" );
			GiveNamedItem( "ammo_gaussclip" );
			GiveNamedItem( "weapon_rpg" );
			GiveNamedItem( "ammo_rpgclip" );
			GiveNamedItem( "weapon_satchel" );
			GiveNamedItem( "weapon_snark" );
			GiveNamedItem( "weapon_hornetgun" );

#if USE_OPFOR
			GiveNamedItem( "weapon_knife" );
			GiveNamedItem( "weapon_pipewrench" );
			GiveNamedItem( "weapon_grapple" );
			GiveNamedItem( "weapon_eagle" );
			GiveNamedItem( "weapon_m249" );
			GiveNamedItem( "weapon_displacer" );
			GiveNamedItem( "weapon_sniperrifle" );
			GiveNamedItem( "weapon_sporelauncher" );
			GiveNamedItem( "weapon_shockrifle" );
			GiveNamedItem( "ammo_556" );
			GiveNamedItem( "ammo_762" );
#endif

			gEvilImpulse101 = false;
			break;
		}

	case 102:
		{
			// Gibbage!!!
			CGib::SpawnRandomGibs( this, 1, 1 );
			break;
		}

	case 103:
		{
			// What the hell are you doing?
			auto pEntity = UTIL_FindEntityForward( this );
			if( pEntity )
			{
				CBaseMonster *pMonster = pEntity->MyMonsterPointer();
				if( pMonster )
					pMonster->ReportAIState();
			}
			break;
		}

	case 104:
		{
			// Dump all of the global state varaibles (and global entity names)
			gGlobalState.DumpGlobals();
			break;
		}

	case	105:// player makes no sound for monsters to hear.
		{
			if( m_fNoPlayerSound )
			{
				ALERT( at_console, "Player is audible\n" );
				m_fNoPlayerSound = false;
			}
			else
			{
				ALERT( at_console, "Player is silent\n" );
				m_fNoPlayerSound = true;
			}
			break;
		}

	case 106:
		{
			// Give me the classname and targetname of this entity.
			auto pEntity = UTIL_FindEntityForward( this );
			if( pEntity )
			{
				ALERT( at_console, "Classname: %s", pEntity->GetClassname() );

				if( pEntity->HasTargetname() )
				{
					ALERT( at_console, " - Targetname: %s\n", pEntity->GetTargetname() );
				}
				else
				{
					ALERT( at_console, " - TargetName: No Targetname\n" );
				}

				ALERT( at_console, "Model: %s\n", pEntity->GetModelName() );
				if( HasGlobalName() )
					ALERT( at_console, "Globalname: %s\n", pEntity->GetGlobalName() );
			}

			break;
		}

	case 107:
		{
			TraceResult tr;

			CBaseEntity* pWorld = CWorld::GetInstance();

			Vector start = GetAbsOrigin() + GetViewOffset();
			Vector end = start + gpGlobals->v_forward * 1024;
			UTIL_TraceLine( start, end, ignore_monsters, edict(), &tr );
			if( tr.pHit )
				pWorld = CBaseEntity::Instance( tr.pHit );
			const texture_t* pTexture = UTIL_TraceTexture( pWorld, start, end );
			if( pTexture )
				ALERT( at_console, "Texture: %s\n", pTexture->name );
			break;
		}

	case	195:// show shortest paths for entire level to nearest node
		{
			Create( "node_viewer_fly", GetAbsOrigin(), GetAbsAngles() );
			break;
		}

	case	196:// show shortest paths for entire level to nearest node
		{
			Create( "node_viewer_large", GetAbsOrigin(), GetAbsAngles() );
			break;
		}

	case	197:// show shortest paths for entire level to nearest node
		{
			Create( "node_viewer_human", GetAbsOrigin(), GetAbsAngles() );
			break;
		}

	case	199:// show nearest node and all connections
		{
			ALERT( at_console, "%d\n", WorldGraph.FindNearestNode( GetAbsOrigin(), bits_NODE_GROUP_REALM ) );
			WorldGraph.ShowNodeConnections( WorldGraph.FindNearestNode( GetAbsOrigin(), bits_NODE_GROUP_REALM ) );

			break;
		}
		
	case	202:// Random blood splatter
		{
			UTIL_MakeVectors( GetViewAngle() );
			TraceResult tr;
			UTIL_TraceLine( GetAbsOrigin() + GetViewOffset(), GetAbsOrigin() + GetViewOffset() + gpGlobals->v_forward * 128, ignore_monsters, ENT( pev ), &tr );

			if( tr.flFraction != 1.0 )
			{// line hit something, so paint a decal
				auto pBlood = static_cast< CBloodSplat* >( UTIL_CreateNamedEntity( "blood_splat" ) );
				pBlood->CreateSplat( this );
			}
			break;
		}

	case	203:// remove creature.
		{
			auto pEntity = UTIL_FindEntityForward( this );
			if( pEntity )
			{
				if( pEntity->GetTakeDamageMode() != DAMAGE_NO )
					pEntity->SetThink( &CBaseEntity::SUB_Remove );
			}
			break;
		}
	}
}