本文整理汇总了C++中CGrenade类的典型用法代码示例。如果您正苦于以下问题:C++ CGrenade类的具体用法?C++ CGrenade怎么用?C++ CGrenade使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CGrenade类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShootSatchelCharge
CGrenade * CGrenade :: ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity )
{
CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );
pGrenade->pev->movetype = MOVETYPE_BOUNCE;
pGrenade->pev->classname = MAKE_STRING( "grenade" );
pGrenade->pev->solid = SOLID_BBOX;
SET_MODEL(ENT(pGrenade->pev), "models/grenade.mdl"); // Change this to satchel charge model
UTIL_SetSize(pGrenade->pev, Vector( 0, 0, 0), Vector(0, 0, 0));
pGrenade->pev->dmg = 200;
UTIL_SetOrigin( pGrenade->pev, vecStart );
pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = g_vecZero;
pGrenade->pev->owner = ENT(pevOwner);
// Detonate in "time" seconds
pGrenade->SetThink( &CGrenade::SUB_DoNothing );
pGrenade->SetUse( &CGrenade::DetonateUse );
pGrenade->SetTouch( &CGrenade::SlideTouch );
pGrenade->pev->spawnflags = SF_DETONATE;
pGrenade->pev->friction = 0.9;
return pGrenade;
}
示例2: Update_GrenadeView
void CHitMarker::Update_GrenadeView( Fvector& pos_actor )
{
GRENADEMARKS::iterator it_b = m_GrenadeMarks.begin();
GRENADEMARKS::iterator it_e = m_GrenadeMarks.end();
for ( ; it_b != it_e; ++it_b )
{
if ( (*it_b)->removed_grenade ) continue;
CGrenade* grn = (*it_b)->p_grenade;
if( grn->IsExploding() )
{
(*it_b)->removed_grenade = true;
continue;
}
Fvector pos_grn, dir;
grn->Center( pos_grn );
dir.sub( pos_grn, pos_actor );
//dir.sub( pos_actor, pos_grn );
dir.normalize();
(*it_b)->Update( dir.getH() );
}
}
示例3: GetClassPtr
CGrenade *CGrenade::ShootTimed(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time)
{
CGrenade *pGrenade = GetClassPtr((CGrenade *)NULL);
pGrenade->Spawn();
UTIL_SetOrigin(pGrenade->pev, vecStart);
pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = pevOwner->angles;
pGrenade->pev->owner = ENT(pevOwner);
pGrenade->SetTouch(&CGrenade::BounceTouch);
pGrenade->pev->dmgtime = gpGlobals->time + time;
pGrenade->SetThink(&CGrenade::TumbleThink);
pGrenade->pev->nextthink = gpGlobals->time + 0.1;
if (time < 0.1)
{
pGrenade->pev->nextthink = gpGlobals->time;
pGrenade->pev->velocity = Vector(0, 0, 0);
}
pGrenade->pev->sequence = RANDOM_LONG(3, 6);
pGrenade->pev->framerate = 1;
pGrenade->m_bJustBlew = true;
pGrenade->pev->gravity = 0.5;
pGrenade->pev->friction = 0.8;
SET_MODEL(ENT(pGrenade->pev), "models/w_flashbang.mdl");
pGrenade->pev->dmg = 35;
return pGrenade;
}
示例4: Throw
void CGrenade::Throw()
{
if (!m_fake_missile || m_thrown)
return;
CGrenade *pGrenade = smart_cast<CGrenade*>(m_fake_missile);
VERIFY (pGrenade);
if (pGrenade) {
pGrenade->set_destroy_time(m_dwDestroyTimeMax);
//установить ID того кто кинул гранату
pGrenade->SetInitiator( H_Parent()->ID() );
}
inherited::Throw ();
m_fake_missile->processing_activate();//@sliph
m_thrown = true;
// Real Wolf.Start.18.12.14
auto parent = smart_cast<CGameObject*>(H_Parent());
auto obj = smart_cast<CGameObject*>(m_fake_missile);
if (parent && obj)
{
parent->callback(GameObject::eOnThrowGrenade)(obj->lua_game_object());
}
// Real Wolf.End.18.12.14
}
示例5: ShootExplosiveTimed
CGrenade* CGrenade::ShootExplosiveTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, int inDamageType)
{
CGrenade *pGrenade = CGrenade::ShootTimed(pevOwner, vecStart, vecVelocity, time);
pGrenade->SetDamageType(inDamageType);
pGrenade->SetTouch(&CGrenade::ExplosiveBounceTouch);
return pGrenade;
}
示例6: GetClassPtr
CGrenade* CGrenade::ShootTimed2( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, int team, unsigned short usEvent )
{
CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );
pGrenade->Spawn();
UTIL_SetOrigin( pGrenade->pev, vecStart );
pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = pevOwner->angles;
pGrenade->pev->owner = ENT( pevOwner );
pGrenade->m_usEvent = usEvent;
pGrenade->SetTouch( &CGrenade::BounceTouch );
pGrenade->SetThink( &CGrenade::TumbleThink );
pGrenade->pev->dmgtime = gpGlobals->time + time;
pGrenade->pev->nextthink= gpGlobals->time + 0.1;
pGrenade->pev->sequence = RANDOM_LONG( 3, 6 );
pGrenade->pev->framerate= 1.0;
pGrenade->m_fJustBlew = TRUE;
pGrenade->m_iTeam = team;
pGrenade->pev->gravity = 0.55;
pGrenade->pev->friction = 0.70;
pGrenade->pev->dmg = 100;
SET_MODEL( ENT( pGrenade->pev ), "models/w_hegrenade.mdl" );
return pGrenade;
}
示例7: GetClassPtr
CGrenade *CGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity )
{
CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );
pGrenade->Spawn();
// contact grenades arc lower
pGrenade->pev->gravity = 0.5;// lower gravity since grenade is aerodynamic and engine doesn't know it.
UTIL_SetOrigin( pGrenade->pev, vecStart );
pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = UTIL_VecToAngles (pGrenade->pev->velocity);
pGrenade->pev->owner = ENT(pevOwner);
// make monsters afaid of it while in the air
pGrenade->SetThink( &CGrenade::DangerSoundThink );
pGrenade->pev->nextthink = gpGlobals->time;
// Tumble in air
pGrenade->pev->avelocity.x = RANDOM_FLOAT ( -100, -500 );
// Explode on contact
pGrenade->SetTouch( &CGrenade::ExplodeTouch );
pGrenade->pev->dmg = gSkillData.plrDmgM203Grenade;
return pGrenade;
}
示例8: switch
bool CGrenade::Action(s32 cmd, u32 flags)
{
if(inherited::Action(cmd, flags)) return true;
switch(cmd)
{
//переключение типа гранаты
case kWPN_NEXT:
{
if(flags&CMD_START)
{
if(m_pCurrentInventory)
{
TIItemContainer::iterator it = m_pCurrentInventory->m_ruck.begin();
TIItemContainer::iterator it_e = m_pCurrentInventory->m_ruck.end();
for(;it!=it_e;++it)
{
CGrenade *pGrenade = smart_cast<CGrenade*>(*it);
if(pGrenade && xr_strcmp(pGrenade->cNameSect(), cNameSect()))
{
m_pCurrentInventory->Ruck(this);
m_pCurrentInventory->SetActiveSlot(NO_ACTIVE_SLOT);
m_pCurrentInventory->Slot(pGrenade);
return true;
}
}
return true;
}
}
return true;
};
}
return false;
}
示例9: GetClassPtr
CGrenade *CGrenade::ShootSatchelCharge(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity) // Last check: 2013, May 28
{
CGrenade *pGrenade = GetClassPtr((CGrenade*)NULL);
pGrenade->pev->movetype = MOVETYPE_TOSS;
pGrenade->pev->solid = SOLID_BBOX;
if (pGrenade->pev->classname)
RemoveEntityHashValue(pGrenade->pev, STRING(pGrenade->pev->classname), CLASSNAME);
pGrenade->pev->classname = MAKE_STRING("grenade");
AddEntityHashValue(pGrenade->pev, STRING(pGrenade->pev->classname), CLASSNAME);
SET_MODEL(ENT(pGrenade->pev), "models/w_c4.mdl");
UTIL_SetSize(pGrenade->pev, Vector(3, 6, 8), Vector(-3, -6, 0));
UTIL_SetOrigin(pGrenade->pev, vecStart);
pGrenade->pev->dmg = 100;
pGrenade->pev->angles = vecVelocity;
pGrenade->pev->velocity = g_vecZero;
pGrenade->pev->owner = ENT(pevOwner);
pGrenade->SetThink(&CGrenade::C4Think);
pGrenade->SetTouch(&CGrenade::C4Touch);
pGrenade->pev->spawnflags = SF_DETONATE;
pGrenade->pev->nextthink = gpGlobals->time + 0.1;
pGrenade->m_flC4Blow = gpGlobals->time + g_pGameRules->m_iC4Timer;
pGrenade->m_flNextFreqInterval = g_pGameRules->m_iC4Timer / 4;
pGrenade->m_flNextFreq = gpGlobals->time;
pGrenade->m_flNextBeep = gpGlobals->time + 0.5;
pGrenade->m_flNextBlink = gpGlobals->time + 2.0;
pGrenade->m_iCurWave = 0;
pGrenade->m_fAttenu = 0;
pGrenade->m_sBeepName = NULL;
pGrenade->m_fNextDefuse = 0;
pGrenade->m_bIsC4 = true;
pGrenade->m_bStartDefuse= false;
pGrenade->m_bJustBlew = false;
pGrenade->pev->friction = 0.9;
if (!FNullEnt(pevOwner))
{
CBasePlayer *pPlayer = (CBasePlayer*)Instance(pevOwner);
if (pPlayer->IsPlayer())
pGrenade->m_pentCurBombTarget = pPlayer->m_pentCurBombTarget;
}
else
pGrenade->m_pentCurBombTarget = NULL;
return pGrenade;
}
示例10: ShootTimed
CGrenade * CGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time )
{
CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );
pGrenade->Spawn();
UTIL_SetOrigin( pGrenade->pev, vecStart );
pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity);
pGrenade->pev->owner = ENT(pevOwner);
pGrenade->SetTouch( &CGrenade::BounceTouch ); // Bounce if touched
#ifdef DEBUG
if(ns_cvar_float(&avh_bulletcam))
{
SET_VIEW(ENT(pevOwner), ENT(pGrenade->pev));
}
#endif
// Take one second off of the desired detonation time and set the think to PreDetonate. PreDetonate
// will insert a DANGER sound into the world sound list and delay detonation for one second so that
// the grenade explodes after the exact amount of time specified in the call to ShootTimed().
pGrenade->pev->dmgtime = gpGlobals->time + time;
pGrenade->SetThink( &CGrenade::TumbleThink );
pGrenade->pev->nextthink = gpGlobals->time + 0.1;
if (time < 0.1)
{
pGrenade->pev->nextthink = gpGlobals->time;
pGrenade->pev->velocity = Vector( 0, 0, 0 );
}
pGrenade->pev->sequence = 0;//RANDOM_LONG( 3, 6 );
pGrenade->pev->framerate = 1.0;
// Tumble through the air
pGrenade->pev->avelocity.x = RANDOM_LONG(-800, -300);
// Also explode on contact
//pGrenade->SetTouch( ExplodeTouch );
pGrenade->pev->gravity = 0.5;
pGrenade->pev->friction = 0.8;
SET_MODEL(ENT(pGrenade->pev), "models/w_grenade.mdl");
return pGrenade;
}
示例11: Activate
/*
bool CGrenade::Activate()
{
Show ();
return true;
}
void CGrenade::Deactivate()
{
Hide ();
}
*/
void CGrenade::Throw()
{
if (!m_fake_missile)
return;
CGrenade *pGrenade = smart_cast<CGrenade*>(m_fake_missile);
VERIFY (pGrenade);
if (pGrenade) {
pGrenade->set_destroy_time(m_dwDestroyTimeMax);
//установить ID того кто кинул гранату
pGrenade->SetInitiator( H_Parent()->ID() );
}
inherited::Throw ();
m_fake_missile->processing_activate();//@sliph
m_thrown = true;
}
示例12: Chatter
void CHostageImprov::UpdateGrenadeReactions()
{
if (m_coughTimer.IsElapsed())
{
if (TheBots->IsInsideSmokeCloud(&GetCentroid()))
{
m_coughTimer.Start(RANDOM_FLOAT(1, 3));
Chatter(HOSTAGE_CHATTER_COUGH);
Frighten(SCARED);
}
}
if (m_grenadeTimer.IsElapsed())
{
CBaseEntity *entity = NULL;
const float watchGrenadeRadius = 500.0f;
m_grenadeTimer.Start(RANDOM_FLOAT(0.4f, 0.6f));
while ((entity = UTIL_FindEntityInSphere(entity, GetCentroid(), watchGrenadeRadius)) != NULL)
{
CGrenade *grenade = static_cast<CGrenade *>(entity);
if (!FClassnameIs(grenade->pev, "grenade") || grenade->m_SGSmoke > 1)
continue;
if (IsVisible(grenade->Center()))
{
Chatter(HOSTAGE_CHATTER_SAW_HE_GRENADE);
if (grenade->pev->dmg > 50.0f)
{
m_idleState.OnInjury();
Frighten(TERRIFIED);
}
else
Frighten(SCARED);
m_grenadeTimer.Start(10);
break;
}
}
}
}
示例13: Center
void CActor::Feel_Grenade_Update( float rad )
{
if ( !IsGameTypeSingle() )
{
return;
}
// Find all nearest objects
Fvector pos_actor;
Center( pos_actor );
q_nearest.clear_not_free();
g_pGameLevel->ObjectSpace.GetNearest( q_nearest, pos_actor, rad, NULL );
xr_vector<CObject*>::iterator it_b = q_nearest.begin();
xr_vector<CObject*>::iterator it_e = q_nearest.end();
// select only grenade
for ( ; it_b != it_e; ++it_b )
{
if ( (*it_b)->getDestroy() ) continue; // Don't touch candidates for destroy
CGrenade* grn = smart_cast<CGrenade*>( *it_b );
if( !grn || grn->Initiator() == ID() || grn->Useful() )
{
continue;
}
if ( grn->time_from_begin_throw() < m_fFeelGrenadeTime )
{
continue;
}
if ( HUD().AddGrenade_ForMark( grn ) )
{
//. Msg("__ __ Add new grenade! id = %d ", grn->ID() );
}
}// for it
HUD().Update_GrenadeView( pos_actor );
}
示例14: Msg
void CGrenade::PutNextToSlot()
{
if (OnClient()) return;
VERIFY (!getDestroy());
//выкинуть гранату из инвентар¤
NET_Packet P;
if (m_pInventory)
{
m_pInventory->Ruck (this);
this->u_EventGen (P, GEG_PLAYER_ITEM2RUCK, this->H_Parent()->ID());
P.w_u16 (this->ID());
this->u_EventSend (P);
}
else
Msg ("! PutNextToSlot : m_pInventory = NULL [%d][%d]", ID(), Device.dwFrame);
if (smart_cast<CInventoryOwner*>(H_Parent()) && m_pInventory)
{
CGrenade *pNext = smart_cast<CGrenade*>( m_pInventory->Same(this,true) );
if(!pNext) pNext = smart_cast<CGrenade*>( m_pInventory->SameSlot(GRENADE_SLOT, this, true) );
VERIFY (pNext != this);
if(pNext && m_pInventory->Slot(pNext->BaseSlot(),pNext) )
{
pNext->u_EventGen (P, GEG_PLAYER_ITEM2SLOT, pNext->H_Parent()->ID());
P.w_u16 (pNext->ID());
P.w_u16 (pNext->BaseSlot());
pNext->u_EventSend (P);
m_pInventory->SetActiveSlot (pNext->BaseSlot());
}else
{
CActor* pActor = smart_cast<CActor*>( m_pInventory->GetOwner());
if(pActor)
pActor->OnPrevWeaponSlot();
}
m_thrown = false;
}
}
示例15: ShootFrag
CGrenade * CGrenade :: ShootFrag( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, int mode )
{
CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );
pGrenade->Spawn();
UTIL_SetOrigin( pGrenade->pev, vecStart );
pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity);
pGrenade->pev->owner = ENT(pevOwner);
pGrenade->pev->solid = SOLID_BBOX;
if ( mode == 1 )
{
SET_MODEL(ENT(pGrenade->pev), "models/w_fgrenade.mdl");
pGrenade->SetTouch( FragTouch );
pGrenade->SetThink( FragThink );
pGrenade->pev->nextthink = gpGlobals->time + 0.1;
}
else
{
SET_MODEL(ENT(pGrenade->pev), "models/w_frag.mdl");
pGrenade->SetThink( Detonate );
pGrenade->pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 2,3 );
pGrenade->pev->solid = SOLID_NOT;
}
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_BEAMFOLLOW );
WRITE_SHORT(pGrenade->entindex()); // entity
WRITE_SHORT(iFgTrail ); // model
WRITE_BYTE( 10 ); // life
WRITE_BYTE( 1.5 ); // width
WRITE_BYTE( 240 ); // r, g, b
WRITE_BYTE( 215 ); // r, g, b
WRITE_BYTE( 80 ); // r, g, b
WRITE_BYTE( 200 ); // brightness
MESSAGE_END();
pGrenade->pev->sequence = 4;
pGrenade->pev->framerate = 6;
pGrenade->pev->gravity = 0.35;
pGrenade->pev->friction = 0.9;
pGrenade->pev->dmg = 100;
return pGrenade;
}