本文整理汇总了C++中SetTouch函数的典型用法代码示例。如果您正苦于以下问题:C++ SetTouch函数的具体用法?C++ SetTouch怎么用?C++ SetTouch使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetTouch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SUB_UseTargets
void CItem::ItemTouch(CBaseEntity *pOther)
{
if (!pOther->IsPlayer())
return;
CBasePlayer *pPlayer = (CBasePlayer *)pOther;
if (!g_pGameRules->CanHaveItem(pPlayer, this))
return;
if (MyTouch(pPlayer))
{
SUB_UseTargets(pOther, USE_TOGGLE, 0);
SetTouch(NULL);
g_pGameRules->PlayerGotItem(pPlayer, this);
if (g_pGameRules->ItemShouldRespawn(this) == GR_ITEM_RESPAWN_YES)
Respawn();
else
UTIL_Remove(this);
}
else if (gEvilImpulse101)
UTIL_Remove(this);
}
示例2: Precache
void CGERocket::Spawn( void )
{
Precache();
BaseClass::Spawn();
m_takedamage = DAMAGE_YES;
m_iHealth = 1;
m_bHitPlayer = false;
// Default Damages they should be modified by the thrower
SetDamage( 512 );
SetDamageRadius( 125 );
SetModel( "models/weapons/rocket_launcher/w_rocket.mdl" );
// Init our physics definition
SetSolid( SOLID_VPHYSICS );
SetMoveType( MOVETYPE_FLY );
// So NPC's can "see" us
AddFlag( FL_OBJECT );
// UTIL_SetSize( this, Vector(-10,-5,-5), Vector(10,5,5) );
SetCollisionGroup( COLLISION_GROUP_GRENADE );
SetThink( &CGERocket::IgniteThink );
SetNextThink( gpGlobals->curtime );
m_flSpawnTime = gpGlobals->curtime;
// Explode if we hit anything solid
SetTouch( &CGERocket::ExplodeTouch );
AddSolidFlags( FSOLID_NOT_STANDABLE );
}
示例3: SetTouch
void CItemSoda::CanTouch ( CBaseEntity *pOther )
{
if ( !pOther->IsPlayer() )
{
return;
}
// spoit sound here
pOther->TakeHealth( 1, DMG_GENERIC );// a bit of health.
if ( !FNullEnt( pev->owner ) )
{
// tell the machine the can was taken
pev->owner->v.frags = 0;
}
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NONE;
pev->effects = EF_NODRAW;
SetTouch ( NULL );
SetThink ( SUB_Remove );
pev->nextthink = gpGlobals->time;
}
示例4: SetMoveType
void CBaseGrenadeConcussion::Spawn( void )
{
// point sized, solid, bouncing
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
SetSolid( SOLID_BBOX );
SetCollisionGroup( COLLISION_GROUP_PROJECTILE );
SetModel( "models/weapons/w_grenade.mdl" ); // BUG: wrong model
UTIL_SetSize(this, vec3_origin, vec3_origin);
// contact grenades arc lower
SetGravity( UTIL_ScaleForGravity( 400 ) ); // use a lower gravity for grenades to make them easier to see
QAngle angles;
VectorAngles(GetAbsVelocity(), angles );
SetLocalAngles( angles );
m_nRenderFX = kRenderFxGlowShell;
SetRenderColor( 200, 200, 20 );
SetRenderAlpha( 255 );
// make NPCs afaid of it while in the air
SetThink( &CBaseGrenadeConcussion::FallThink );
SetNextThink( gpGlobals->curtime );
// Tumble in air
QAngle vecAngVel( random->RandomFloat ( -100, -500 ), 0, 0 );
SetLocalAngularVelocity( vecAngVel );
// Explode on contact
SetTouch( &CBaseGrenadeConcussion::ExplodeConcussion );
m_flDamage = 80;
// Allow player to blow this puppy up in the air
m_takedamage = DAMAGE_YES;
}
示例5: STOP_SOUND
//
// The door has reached the "up" position. Either go back down, or wait for another activation.
//
void CBaseDoor::DoorHitTop( void )
{
if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) )
{
STOP_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving) );
EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseArrived), 1, ATTN_NORM);
}
ASSERT(m_toggle_state == TS_GOING_UP);
m_toggle_state = TS_AT_TOP;
// toggle-doors don't come down automatically, they wait for refire.
if (FBitSet(pev->spawnflags, SF_DOOR_NO_AUTO_RETURN))
{
// Re-instate touch method, movement is complete
if ( !FBitSet ( pev->spawnflags, SF_DOOR_USE_ONLY ) )
SetTouch( DoorTouch );
}
else
{
// In flWait seconds, DoorGoDown will fire, unless wait is -1, then door stays open
pev->nextthink = pev->ltime + m_flWait;
SetThink( DoorGoDown );
if ( m_flWait == -1 )
{
pev->nextthink = -1;
}
}
// Fire the close target (if startopen is set, then "top" is closed) - netname is the close target
if ( pev->netname && (pev->spawnflags & SF_DOOR_START_OPEN) )
FireTargets( STRING(pev->netname), m_hActivator, this, USE_TOGGLE, 0 );
SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); // this isn't finished
}
示例6: SetMoveType
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CShieldGrenade::Spawn( void )
{
BaseClass::Spawn();
m_LastCollision.Init( 0, 0, 0 );
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
SetSolid( SOLID_BBOX );
SetGravity( 1.0 );
SetFriction( 0.9 );
SetModel( "models/weapons/w_grenade.mdl");
UTIL_SetSize(this, Vector( -4, -4, -4), Vector(4, 4, 4));
m_IsEMPed = false;
m_IsDeployed = false;
m_flEMPDamageEndTime = 0.0f;
SetTouch( StickyTouch );
SetCollisionGroup( TFCOLLISION_GROUP_GRENADE );
// Create a green light
m_pLiveSprite = CSprite::SpriteCreate( "sprites/redglow1.vmt", GetLocalOrigin() + Vector(0,0,1), false );
m_pLiveSprite->SetTransparency( kRenderGlow, 0, 0, 255, 128, kRenderFxNoDissipation );
m_pLiveSprite->SetScale( 1 );
m_pLiveSprite->SetAttachment( this, 0 );
}
示例7: Spawn
void CSqueakGrenade :: Spawn( void )
{
Precache( );
// motor
pev->movetype = MOVETYPE_BOUNCE;
pev->solid = SOLID_BBOX;
SET_MODEL(ENT(pev), "models/w_squeak.mdl");
UTIL_SetSize(pev, Vector( -4, -4, 0), Vector(4, 4, 8));
UTIL_SetOrigin( pev, pev->origin );
SetTouch( SuperBounceTouch );
SetThink( HuntThink );
pev->nextthink = gpGlobals->time + 0.1;
m_flNextHunt = gpGlobals->time + 1E6;
pev->flags |= FL_MONSTER;
pev->takedamage = DAMAGE_AIM;
pev->health = gSkillData.snarkHealth;
pev->gravity = 0.5;
pev->friction = 0.5;
pev->dmg = gSkillData.snarkDmgPop;
m_flDie = gpGlobals->time + SQUEEK_DETONATE_DELAY;
m_flFieldOfView = 0; // 180 degrees
if ( pev->owner )
m_hOwner = Instance( pev->owner );
m_flNextBounceSoundTime = gpGlobals->time;// reset each time a snark is spawned.
pev->sequence = WSQUEAK_RUN;
ResetSequenceInfo( );
}
示例8: SetTouch
CBaseEntity* CItem::Respawn( void )
{
SetTouch( NULL );
AddEffects( EF_NODRAW );
VPhysicsDestroyObject();
SetMoveType( MOVETYPE_NONE );
SetSolid( SOLID_BBOX );
AddSolidFlags( FSOLID_TRIGGER );
UTIL_SetOrigin( this, g_pGameRules->VecItemRespawnSpot( this ) );// blip to whereever you should respawn.
SetAbsAngles( g_pGameRules->VecItemRespawnAngles( this ) );// set the angles.
#if !defined( TF_DLL )
UTIL_DropToFloor( this, MASK_SOLID );
#endif
RemoveAllDecals(); //remove any decals
SetThink ( &CItem::Materialize );
SetNextThink( gpGlobals->curtime + g_pGameRules->FlItemRespawnTime( this ) );
return this;
}
示例9: ALERT
void CGrappleHook::Killed(entvars_t *pev, int gib)
{
ALERT( at_console, "^2HLU -> ^3weapon_grapple ^2-> Tongue was killed.\n");
// Fograin92: Clear player
myowner->pev->movetype = MOVETYPE_WALK; //Re-apply gravity
myowner->m_afPhysicsFlags &= ~PFLAG_ON_GRAPPLE; //Remove "on grapple" flag
myowner->m_iGrappleExists = 0;
myowner->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0;
// Fograin92: Clear monster
if( (m_iHitMonster == 2) && (myHitMonster->IsAlive()) )
myHitMonster->pev->movetype = MOVETYPE_STEP; // Re-apply gravity to the pulled monster, if it's alive
// Fograin92: Clear tongue leftovers
bPullBack = false;
UTIL_Remove( m_pTongue );
m_pTongue = NULL;
m_iHitMonster = 0;
SetThink(NULL);
SetTouch(NULL);
SUB_Remove( );
}
示例10: Spawn
//
// Throw a chunk
//
void CGib :: Spawn( const char *szGibModel )
{
pev->movetype = MOVETYPE_BOUNCE;
pev->friction = 0.55; // deading the bounce a bit
// sometimes an entity inherits the edict from a former piece of glass,
// and will spawn using the same render FX or rendermode! bad!
pev->renderamt = 255;
pev->rendermode = kRenderNormal;
pev->renderfx = kRenderFxNone;
pev->solid = SOLID_SLIDEBOX;/// hopefully this will fix the VELOCITY TOO LOW crap
pev->classname = MAKE_STRING("gib");
SET_MODEL(ENT(pev), szGibModel);
UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0));
pev->nextthink = gpGlobals->time + 4;
m_lifeTime = 25;
SetThink ( &CGib::WaitTillLand );
SetTouch ( &CGib::BounceGibTouch );
m_material = matNone;
m_cBloodDecals = 5;// how many blood decals this gib can place (1 per bounce until none remain).
}
示例11: RANDOM_LONG
//=========================================================
// Randomly decide what powerup to be
void CDiscwarPowerup::ChoosePowerupThink(void)
{
int iPowerup = RANDOM_LONG(0, NUM_POWERUPS - 1);
m_iPowerupType = (1 << iPowerup);
SET_MODEL(ENT(pev), szPowerupModels[iPowerup]);
pev->effects &= ~EF_NODRAW;
SetTouch(&CDiscwarPowerup::PowerupTouch);
// Start Animating
pev->sequence = 0;
pev->frame = 0;
ResetSequenceInfo();
SetThink(&CDiscwarPowerup::AnimateThink);
pev->nextthink = gpGlobals->time + 0.1;
pev->rendermode = kRenderTransAdd;
pev->renderamt = 150;
// Play the powerup appear sound
EMIT_SOUND_DYN(edict(), CHAN_STATIC, "pspawn.wav", 1.0, ATTN_NORM, 0, 98 + RANDOM_LONG(0, 3));
}
示例12: Spawn
void CApache :: Spawn( void )
{
Precache( );
// motor
pev->movetype = MOVETYPE_FLY;
pev->solid = SOLID_BBOX;
SET_MODEL(ENT(pev), "models/apache.mdl");
UTIL_SetSize( pev, Vector( -32, -32, -64 ), Vector( 32, 32, 0 ) );
UTIL_SetOrigin( pev, pev->origin );
pev->flags |= FL_MONSTER;
pev->takedamage = DAMAGE_AIM;
pev->health = gSkillData.apacheHealth;
m_flFieldOfView = -0.707; // 270 degrees
pev->sequence = 0;
ResetSequenceInfo( );
pev->frame = RANDOM_LONG(0, 0xFF);
InitBoneControllers();
if (pev->spawnflags & SF_WAITFORTRIGGER)
{
SetUse( &CApache::StartupUse );
}
else
{
SetThink( &CApache::HuntThink );
SetTouch( &CApache::FlyTouch );
pev->nextthink = gpGlobals->time + 1.0;
}
m_iRockets = 10;
}
示例13: Spawn
void CSatchelCharge :: Spawn( void )
{
Precache( );
// motor
pev->movetype = MOVETYPE_BOUNCE;
pev->solid = SOLID_BBOX;
SET_MODEL(ENT(pev), "models/w_satchel.mdl");
//UTIL_SetSize(pev, Vector( -16, -16, -4), Vector(16, 16, 32)); // Old box -- size of headcrab monsters/players get blocked by this
UTIL_SetSize(pev, Vector( -4, -4, -4), Vector(4, 4, 4)); // Uses point-sized, and can be stepped over
UTIL_SetOrigin( pev, pev->origin );
SetTouch(&CSatchelCharge::SatchelSlide );
SetUse(&CGrenade::DetonateUse );
SetThink(&CSatchelCharge::SatchelThink );
pev->nextthink = gpGlobals->time + 0.1;
pev->gravity = 0.5;
pev->friction = 0.8;
pev->dmg = gSkillData.plrDmgSatchel;
// ResetSequenceInfo( );
pev->sequence = 1;
}
示例14: SetTouch
void CBasePlayerItem::Kill( void )
{
SetTouch( NULL );
SetThink(SUB_Remove);
pev->nextthink = gpGlobals->time + .1;
}
示例15: MaxAmmoCarry
//=========================================================
// CWeaponBox - Touch: try to add my contents to the toucher
// if the toucher is a player.
//=========================================================
void CWeaponBox::Touch( CBaseEntity *pOther )
{
if ( !(pev->flags & FL_ONGROUND ) )
{
return;
}
if ( !pOther->IsPlayer() )
{
// only players may touch a weaponbox.
return;
}
if ( !pOther->IsAlive() )
{
// no dead guys.
return;
}
CBasePlayer *pPlayer = (CBasePlayer *)pOther;
int i;
// dole out ammo
for ( i = 0 ; i < MAX_AMMO_SLOTS ; i++ )
{
if ( !FStringNull( m_rgiszAmmo[ i ] ) )
{
// there's some ammo of this type.
pPlayer->GiveAmmo( m_rgAmmo[ i ], (char *)STRING( m_rgiszAmmo[ i ] ), MaxAmmoCarry( m_rgiszAmmo[ i ] ) );
//ALERT ( at_console, "Gave %d rounds of %s\n", m_rgAmmo[i], STRING(m_rgiszAmmo[i]) );
// now empty the ammo from the weaponbox since we just gave it to the player
m_rgiszAmmo[ i ] = iStringNull;
m_rgAmmo[ i ] = 0;
}
}
// go through my weapons and try to give the usable ones to the player.
// it's important the the player be given ammo first, so the weapons code doesn't refuse
// to deploy a better weapon that the player may pick up because he has no ammo for it.
for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ )
{
if ( m_rgpPlayerItems[ i ] )
{
CBasePlayerItem *pItem;
// have at least one weapon in this slot
while ( m_rgpPlayerItems[ i ] )
{
//ALERT ( at_console, "trying to give %s\n", STRING( m_rgpPlayerItems[ i ]->pev->classname ) );
pItem = m_rgpPlayerItems[ i ];
m_rgpPlayerItems[ i ] = m_rgpPlayerItems[ i ]->m_pNext;// unlink this weapon from the box
if ( pPlayer->AddPlayerItem( pItem ) )
{
pItem->AttachToPlayer( pPlayer );
}
}
}
}
EMIT_SOUND( pOther->edict(), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM );
SetTouch(NULL);
UTIL_Remove(this);
}