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; }
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() ); } }
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; }
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 }
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; }
CGrenade *CGrenade::ShootSmokeGrenade(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, 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->m_bLightSmoke = false; pGrenade->m_bDetonated = false; pGrenade->SetTouch(&CGrenade::BounceTouch); pGrenade->pev->dmgtime = gpGlobals->time + time; pGrenade->SetThink(&CGrenade::SG_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; pGrenade->m_SGSmoke = 0; SET_MODEL(ENT(pGrenade->pev), "models/w_smokegrenade.mdl"); pGrenade->pev->dmg = 35; return pGrenade; }
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; }
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; }
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; }
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; }
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; }
/* 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; }
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; } } } }
CGrenade *CGrenade::ShootContact(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity) { CGrenade *pGrenade = GetClassPtr((CGrenade *)NULL); pGrenade->Spawn(); pGrenade->pev->gravity = 0.5; UTIL_SetOrigin(pGrenade->pev, vecStart); pGrenade->pev->velocity = vecVelocity; pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity); pGrenade->pev->owner = ENT(pevOwner); pGrenade->SetThink(&CGrenade::DangerSoundThink); pGrenade->pev->nextthink = gpGlobals->time; pGrenade->pev->avelocity.x = RANDOM_FLOAT(-100, -500); pGrenade->SetTouch(&CGrenade::ExplodeTouch); pGrenade->pev->dmg = gSkillData.plrDmgM203Grenade; pGrenade->m_bJustBlew = true; return pGrenade; }
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 ); }
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; } }
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; }
void CGrenade::PutNextToSlot() { if (OnClient()) return; VERIFY (!getDestroy()); //выкинуть гранату из инвентар¤ if (m_pCurrentInventory) { NET_Packet P; m_pCurrentInventory->Ruck (this); #if defined(GRENADE_FROM_BELT) this->u_EventGen (P, GEG_PLAYER_ITEM2BELT, this->H_Parent()->ID()); #else this->u_EventGen (P, GEG_PLAYER_ITEM2RUCK, this->H_Parent()->ID()); #endif P.w_u16 (this->ID()); this->u_EventSend (P); #if defined(GRENADE_FROM_BELT) CGrenade *pNext = smart_cast<CGrenade*>( m_pCurrentInventory->Same(this,false) ); if(!pNext) pNext = smart_cast<CGrenade*>( m_pCurrentInventory->SameSlot(GRENADE_SLOT, this, false) ); #else CGrenade *pNext = smart_cast<CGrenade*>( m_pCurrentInventory->Same(this,true) ); if(!pNext) pNext = smart_cast<CGrenade*>( m_pCurrentInventory->SameSlot(GRENADE_SLOT, this, true) ); #endif VERIFY (pNext != this); if(pNext && m_pCurrentInventory->Slot(pNext) ) { pNext->u_EventGen (P, GEG_PLAYER_ITEM2SLOT, pNext->H_Parent()->ID()); P.w_u16 (pNext->ID()); pNext->u_EventSend (P); m_pCurrentInventory->SetActiveSlot(pNext->GetSlot()); } ///// m_thrown = false; } }
void CGrenade::PutNextToSlot() { if (OnClient()) return; // Msg ("* PutNextToSlot : %d", ID()); VERIFY (!getDestroy()); //выкинуть гранату из инвентар¤ NET_Packet P; if (m_pInventory) { m_pInventory->Ruck (this); //. m_pInventory->SetActiveSlot (NO_ACTIVE_SLOT); 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 = 0"); 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(this,true) ); VERIFY (pNext != this); if(pNext && m_pInventory->Slot(pNext) ){ pNext->u_EventGen (P, GEG_PLAYER_ITEM2SLOT, pNext->H_Parent()->ID()); P.w_u16 (pNext->ID()); pNext->u_EventSend (P); // if(IsGameTypeSingle()) m_pInventory->SetActiveSlot (pNext->GetSlot()); } m_thrown = false; } }
/* <18b835> ../cstrike/dlls/training_gamerules.cpp:300 */ void CBaseGrenCatch::__MAKE_VHOOK(Think)() { CGrenade *pGrenade; bool m_fSmokeTouchingLastFrame; CBaseEntity *pTrigger; Vector vMax, vMin; m_fSmokeTouchingLastFrame = m_fSmokeTouching; m_fSmokeTouching = false; pGrenade = NULL; while (pGrenade = (CGrenade *)UTIL_FindEntityByClassname(pGrenade, "grenade")) { vMin = pGrenade->pev->mins; vMax = pGrenade->pev->maxs; UTIL_SetSize(pGrenade->pev, Vector(-8, -8, 0), Vector(8, 8, 0)); if (pGrenade->Intersects(this) && Q_strstr(STRING(pGrenade->pev->model), "smoke") != NULL) { if (pGrenade->pev->velocity.Length() == 0) m_fSmokeTouching = true; } pGrenade->pev->mins = vMin; pGrenade->pev->maxs = vMax; } if ((m_NeedGrenadeType == GRENADETYPE_SMOKE && m_fSmokeTouching && !m_fSmokeTouchingLastFrame) || (m_NeedGrenadeType == GRENADETYPE_FLASH && m_fFlashTouched)) { FireTargets(STRING(sTriggerOnGrenade), this, this, USE_TOGGLE, 0); if (m_NeedGrenadeType == GRENADETYPE_SMOKE) { pTrigger = NULL; while ((pTrigger = UTIL_FindEntityByTargetname(pTrigger, STRING(sDisableOnGrenade))) != NULL) { // save solid pTrigger->pev->team = pTrigger->pev->solid; pTrigger->pev->solid = SOLID_NOT; } } else if (m_NeedGrenadeType == GRENADETYPE_FLASH) pev->flags |= FL_KILLME; } if (m_fSmokeTouchingLastFrame && !m_fSmokeTouching) { pTrigger = NULL; while (pTrigger = UTIL_FindEntityByTargetname(pTrigger, STRING(sDisableOnGrenade))) { // restore solid pTrigger->pev->solid = pTrigger->pev->team; pTrigger->pev->team = 0; UTIL_SetOrigin(pTrigger->pev, pTrigger->pev->origin); } } pev->nextthink = gpGlobals->time + 0.1f; }
CGrenade* CGrenade::ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ) { CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL ); pGrenade->pev->movetype = MOVETYPE_BOUNCE; pGrenade->pev->solid = SOLID_BBOX; // TODO: Implements me. // if( pev->classname ) // this->RemoveEntityHashValue( STRING( pev->classname ) ); pGrenade->pev->classname = MAKE_STRING( "grenade" ); // TODO: Implements me. // this->AddEntityHashValue( STRING( pev->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_flC4DetonateDelay; pGrenade->m_flNextFreqInterval = g_pGameRules->m_flC4DetonateDelay / 4; pGrenade->m_flNextFreq = gpGlobals->time; pGrenade->m_flNextBeep = gpGlobals->time + 0.5; pGrenade->m_flNextBlink = gpGlobals->time + 2.0; pGrenade->m_iC4Beep = 0; pGrenade->m_flAttenu = 0; pGrenade->m_sBeepName = NULL; pGrenade->m_flNextDefuseTime = 0; pGrenade->m_fPlantedC4 = TRUE; pGrenade->m_fStartDefuse= FALSE; pGrenade->m_fJustBlew = FALSE; pGrenade->pev->friction = 0.9; if( !FNullEnt( pevOwner ) ) { CBasePlayer *pPlayer = (CBasePlayer *)Instance( pevOwner ); pGrenade->m_pentCurBombTarget = pPlayer->m_pentBombTarget; } else pGrenade->m_pentCurBombTarget = NULL; return pGrenade; }
CGrenade * CGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time ) { CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL ); pGrenade->Spawn(); UTIL_SetOrigin( pGrenade, vecStart ); pGrenade->SetAbsVelocity( vecVelocity ); pGrenade->SetLocalAngles( UTIL_VecToAngles( pGrenade->GetAbsVelocity( ))); pGrenade->pev->owner = ENT( pevOwner ); pGrenade->SetTouch( &CGrenade::BounceTouch ); // Bounce if touched // 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->SetNextThink( 0.1 ); if( time < 0.1 ) { pGrenade->SetNextThink( 0 ); pGrenade->SetLocalVelocity( g_vecZero ); } pGrenade->pev->sequence = RANDOM_LONG( 3, 6 ); pGrenade->pev->framerate = 1.0; pGrenade->pev->gravity = 0.5; pGrenade->pev->friction = 0.8; SET_MODEL( pGrenade->edict(), "models/w_grenade.mdl" ); pGrenade->pev->dmg = 100; return pGrenade; }
void CActor::PickupModeUpdate_COD () { if (Level().CurrentViewEntity() != this || !g_b_COD_PickUpMode) return; if (!g_Alive() || eacFirstEye != cam_active) { CurrentGameUI()->UIMainIngameWnd->SetPickUpItem(NULL); return; }; CFrustum frustum; frustum.CreateFromMatrix (Device.mFullTransform, FRUSTUM_P_LRTB|FRUSTUM_P_FAR); ISpatialResult.clear_not_free (); g_SpatialSpace->q_frustum (ISpatialResult, 0, STYPE_COLLIDEABLE, frustum); float maxlen = 1000.0f; CInventoryItem* pNearestItem = NULL; for (u32 o_it=0; o_it<ISpatialResult.size(); o_it++) { ISpatial* spatial = ISpatialResult[o_it]; CInventoryItem* pIItem = smart_cast<CInventoryItem*> (spatial->dcast_CObject ()); if (0 == pIItem) continue; if (pIItem->object().H_Parent() != NULL) continue; if (!pIItem->CanTake()) continue; if ( smart_cast<CExplosiveRocket*>( &pIItem->object() ) ) continue; CGrenade* pGrenade = smart_cast<CGrenade*> (spatial->dcast_CObject ()); if (pGrenade && !pGrenade->Useful()) continue; CMissile* pMissile = smart_cast<CMissile*> (spatial->dcast_CObject ()); if (pMissile && !pMissile->Useful()) continue; Fvector A, B, tmp; pIItem->object().Center (A); if (A.distance_to_sqr(Position())>4) continue; tmp.sub(A, cam_Active()->vPosition); B.mad(cam_Active()->vPosition, cam_Active()->vDirection, tmp.dotproduct(cam_Active()->vDirection)); float len = B.distance_to_sqr(A); if (len > 1) continue; if (maxlen>len && !pIItem->object().getDestroy()) { maxlen = len; pNearestItem = pIItem; }; } if(pNearestItem) { CFrustum frustum; frustum.CreateFromMatrix (Device.mFullTransform,FRUSTUM_P_LRTB|FRUSTUM_P_FAR); if (!CanPickItem(frustum, Device.vCameraPosition, &pNearestItem->object())) pNearestItem = NULL; } if (pNearestItem && pNearestItem->cast_game_object()) { if (Level().m_feel_deny.is_object_denied(pNearestItem->cast_game_object())) pNearestItem = NULL; } if (pNearestItem && pNearestItem->cast_game_object()) { if(!pNearestItem->cast_game_object()->getVisible()) pNearestItem = NULL; } CurrentGameUI()->UIMainIngameWnd->SetPickUpItem(pNearestItem); if (pNearestItem && m_bPickupMode) { CUsableScriptObject* pUsableObject = smart_cast<CUsableScriptObject*>(pNearestItem); if(pUsableObject && (!m_pUsableObject)) pUsableObject->use(this); //подбирание объекта Game().SendPickUpEvent(ID(), pNearestItem->object().ID()); } };