//--------------------------------------------------------- //--------------------------------------------------------- void CNPC_Fisherman::HandleAnimEvent( animevent_t *pEvent ) { if ( pEvent->event == NPC_EVENT_LEFTFOOT ) { EmitSound( "NPC_Fisherman.FootstepLeft", pEvent->eventtime ); } else if ( pEvent->event == NPC_EVENT_RIGHTFOOT ) { EmitSound( "NPC_Fisherman.FootstepRight", pEvent->eventtime ); } else if ( pEvent->event == AE_FISHERMAN_HAT_UP ) { if (m_iHatLayer != -1) { RemoveLayer( m_iHatLayer, 0.2, 0.2 ); m_iHatLayer = -1; } m_iHatState = ACT_FISHERMAN_HAT_UP; m_iHatLayer = AddGesture( (Activity)m_iHatState, false ); } else if ( pEvent->event == AE_FISHERMAN_HAT_DOWN ) { if (m_iHatLayer != -1) { RemoveLayer( m_iHatLayer, 0.2, 0.2 ); m_iHatLayer = -1; } m_iHatState = ACT_FISHERMAN_HAT_DOWN; m_iHatLayer = AddGesture( (Activity)m_iHatState, false ); } else if ( pEvent->event == AE_FISHERMAN_HAT_ON ) { m_iHatLayer = AddGesture( (Activity)m_iHatState, false ); } else if ( pEvent->event == AE_FISHERMAN_HAT_OFF ) { if (m_iHatLayer != -1) { RemoveLayer( m_iHatLayer, 0.2, 0.2 ); m_iHatLayer = -1; } } else { BaseClass::HandleAnimEvent( pEvent ); } }
int CBaseAnimatingOverlay::AddGesture( Activity activity, float flDuration, bool autokill /*= true*/ ) { int iLayer = AddGesture( activity, autokill ); SetLayerDuration( iLayer, flDuration ); return iLayer; }
void CNPC_Zombine::ReleaseGrenade( Vector vPhysgunPos ) { if ( HasGrenade() == false ) return; Vector vDir = vPhysgunPos - m_hGrenade->GetAbsOrigin(); VectorNormalize( vDir ); Activity aActivity; Vector vForward, vRight; GetVectors( &vForward, &vRight, NULL ); float flDotForward = DotProduct( vForward, vDir ); float flDotRight = DotProduct( vRight, vDir ); bool bNegativeForward = false; bool bNegativeRight = false; if ( flDotForward < 0.0f ) { bNegativeForward = true; flDotForward = flDotForward * -1; } if ( flDotRight < 0.0f ) { bNegativeRight = true; flDotRight = flDotRight * -1; } if ( flDotRight > flDotForward ) { if ( bNegativeRight == true ) aActivity = (Activity)ACT_ZOMBINE_GRENADE_FLINCH_WEST; else aActivity = (Activity)ACT_ZOMBINE_GRENADE_FLINCH_EAST; } else { if ( bNegativeForward == true ) aActivity = (Activity)ACT_ZOMBINE_GRENADE_FLINCH_BACK; else aActivity = (Activity)ACT_ZOMBINE_GRENADE_FLINCH_FRONT; } AddGesture( aActivity ); DropGrenade( vec3_origin ); if ( IsSprinting() ) { StopSprint(); } else { Sprint(); } }
virtual void Activate() { BaseClass::Activate(); if (m_iHatState == -1) { m_iHatState = ACT_FISHERMAN_HAT_DOWN; } // allocate layer, start with the hat down m_iHatLayer = AddGesture( (Activity)m_iHatState, false ); }
void CNPC_Infected::StartTask( const Task_t *pTask ) { switch( pTask->iTask ) { case TASK_MELEE_ATTACK1: { SetLastAttackTime( gpGlobals->curtime ); m_iAttackLayer = AddGesture( ACT_TERROR_ATTACK ); break; } default: BaseClass::StartTask( pTask ); break; } }
//----------------------------------------------------------------------------- // Purpose: // Input : activity - //----------------------------------------------------------------------------- void CBaseAnimatingOverlay::RestartGesture( Activity activity, bool addifmissing /*=true*/, bool autokill /*=true*/ ) { int idx = FindGestureLayer( activity ); if ( idx == -1 ) { if ( addifmissing ) { AddGesture( activity, autokill ); } return; } m_AnimOverlay[ idx ].m_flCycle = 0.0f; m_AnimOverlay[ idx ].m_flPrevCycle = 0; }
//--------------------------------------------------------- //--------------------------------------------------------- int CRebelZombie::OnTakeDamage_Alive( const CTakeDamageInfo &inputInfo ) { #ifndef HL2_EPISODIC if ( inputInfo.GetDamageType() & DMG_BUCKSHOT ) { if( inputInfo.GetDamage() > (m_iMaxHealth/3) ) { // Always flinch if damaged a lot by buckshot, even if not shot in the head. // The reason for making sure we did at least 1/3rd of the zombie's max health // is so the zombie doesn't flinch every time the odd shotgun pellet hits them, // and so the maximum number of times you'll see a zombie flinch like this is 2.(sjb) AddGesture( ACT_GESTURE_FLINCH_HEAD ); } } #endif // HL2_EPISODIC return BaseClass::OnTakeDamage_Alive( inputInfo ); }
BOOL CDynGestServer::LoadGestureBase(const char *filename) { CleanAll(); FILE* file; file = fopen( filename, "r" ); if (!file ) return FALSE; char gesture_name[256]; //read main file while ( fscanf( file, "%s\n", gesture_name )!=EOF ) { CDynGesture* gesture = new CDynGesture( m_num_states, m_num_mix ); gesture->SetName( gesture_name ); gesture->LoadParams( gesture_name ); //try to load hmm if ( ! _chdir( gesture->GetName() ) ) { if ( gesture->LoadHMM(gesture->GetName() + ".hmm") ) { gesture->m_trained = TRUE; //change value of m_hmmParams control CStereoGRApp* app = (CStereoGRApp*)AfxGetApp(); app->m_hmmParams->m_num_states = gesture->GetHMM()->num_states; app->m_hmmParams->m_num_mix = gesture->GetHMM()->u.state->num_mix; SetHMMParams( app->m_hmmParams->m_num_states, app->m_hmmParams->m_num_mix ); } _chdir( "..\\" ); } AddGesture( gesture ); } fclose( file ); m_loaded_base = filename; return TRUE; }
//--------------------------------------------------------- //--------------------------------------------------------- int CASW_Zombie::OnTakeDamage_Alive( const CTakeDamageInfo &info ) { #ifndef HL2_EPISODIC if ( info.GetDamageType() & DMG_BUCKSHOT ) { if( !m_fIsTorso && info.GetDamage() > (m_iMaxHealth/3) ) { // Always flinch if damaged a lot by buckshot, even if not shot in the head. // The reason for making sure we did at least 1/3rd of the zombie's max health // is so the zombie doesn't flinch every time the odd shotgun pellet hits them, // and so the maximum number of times you'll see a zombie flinch like this is 2.(sjb) AddGesture( ACT_GESTURE_FLINCH_HEAD ); } } #endif // HL2_EPISODIC // catching on fire int result = 0; // scale burning damage up if (dynamic_cast<CEntityFlame*>(info.GetAttacker())) { CTakeDamageInfo newDamage = info; newDamage.ScaleDamage(asw_fire_zombie_damage_scale.GetFloat()); result = BaseClass::OnTakeDamage_Alive(newDamage); } else { result = BaseClass::OnTakeDamage_Alive(info); } // if we take fire damage, catch on fire if (result > 0 && (info.GetDamageType() & DMG_BURN)) ASW_Ignite(30.0f, 0, info.GetAttacker()); //CASW_Marine* pMarine = dynamic_cast<CASW_Marine*>(info.GetAttacker()); //if (pMarine) //pMarine->HurtAlien(this); return BaseClass::OnTakeDamage_Alive( info ); }
//----------------------------------------------------------------------------- // Fire on our target //----------------------------------------------------------------------------- bool CObjectSentrygun::Fire() { //NDebugOverlay::Cross3D( m_hEnemy->WorldSpaceCenter(), 10, 255, 0, 0, false, 0.1 ); Vector vecAimDir; // Level 3 Turrets fire rockets every 3 seconds if ( m_iUpgradeLevel == 3 && m_iAmmoRockets > 0 && m_flNextRocketAttack < gpGlobals->curtime ) { Vector vecSrc; QAngle vecAng; // alternate between the 2 rocket launcher ports. if ( m_iAmmoRockets & 1 ) { GetAttachment( m_iAttachments[SENTRYGUN_ATTACHMENT_ROCKET_L], vecSrc, vecAng ); } else { GetAttachment( m_iAttachments[SENTRYGUN_ATTACHMENT_ROCKET_R], vecSrc, vecAng ); } vecAimDir = m_hEnemy->WorldSpaceCenter() - vecSrc; vecAimDir.NormalizeInPlace(); // NOTE: vecAng is not actually set by GetAttachment!!! QAngle angDir; VectorAngles( vecAimDir, angDir ); EmitSound( "Building_Sentrygun.FireRocket" ); AddGesture( ACT_RANGE_ATTACK2 ); QAngle angAimDir; VectorAngles( vecAimDir, angAimDir ); CTFProjectile_SentryRocket *pProjectile = CTFProjectile_SentryRocket::Create( vecSrc, angAimDir, this, GetBuilder() ); if ( pProjectile ) { pProjectile->SetDamage( 100 ); } // Setup next rocket shot m_flNextRocketAttack = gpGlobals->curtime + 3; if ( !tf_sentrygun_ammocheat.GetBool() && !HasSpawnFlags( SF_SENTRY_INFINITE_AMMO ) ) { m_iAmmoRockets--; } if (m_iAmmoRockets == 10) ClientPrint( GetBuilder(), HUD_PRINTNOTIFY, "#Sentry_rocketslow"); if (m_iAmmoRockets == 0) ClientPrint( GetBuilder(), HUD_PRINTNOTIFY, "#Sentry_rocketsout"); } // All turrets fire shells if ( m_iAmmoShells > 0) { if ( !IsPlayingGesture( ACT_RANGE_ATTACK1 ) ) { RemoveGesture( ACT_RANGE_ATTACK1_LOW ); AddGesture( ACT_RANGE_ATTACK1 ); } Vector vecSrc; QAngle vecAng; int iAttachment; if ( m_iUpgradeLevel > 1 && (m_iAmmoShells & 1) ) { // level 2 and 3 turrets alternate muzzles each time they fizzy fizzy fire. iAttachment = m_iAttachments[SENTRYGUN_ATTACHMENT_MUZZLE_ALT]; } else { iAttachment = m_iAttachments[SENTRYGUN_ATTACHMENT_MUZZLE]; } GetAttachment( iAttachment, vecSrc, vecAng ); Vector vecMidEnemy = m_hEnemy->WorldSpaceCenter(); // If we cannot see their WorldSpaceCenter ( possible, as we do our target finding based // on the eye position of the target ) then fire at the eye position trace_t tr; UTIL_TraceLine( vecSrc, vecMidEnemy, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr); if ( !tr.m_pEnt || tr.m_pEnt->IsWorld() ) { // Hack it lower a little bit.. // The eye position is not always within the hitboxes for a standing TF Player vecMidEnemy = m_hEnemy->EyePosition() + Vector(0,0,-5); } vecAimDir = vecMidEnemy - vecSrc; float flDistToTarget = vecAimDir.Length(); vecAimDir.NormalizeInPlace(); //NDebugOverlay::Cross3D( vecSrc, 10, 255, 0, 0, false, 0.1 ); FireBulletsInfo_t info; info.m_vecSrc = vecSrc; info.m_vecDirShooting = vecAimDir; info.m_iTracerFreq = 1; info.m_iShots = 1; info.m_pAttacker = GetBuilder(); info.m_vecSpread = vec3_origin; info.m_flDistance = flDistToTarget + 100; info.m_iAmmoType = m_iAmmoType; info.m_flDamage = tf_sentrygun_damage.GetFloat(); FireBullets( info ); //NDebugOverlay::Line( vecSrc, vecSrc + vecAimDir * 1000, 255, 0, 0, false, 0.1 ); CEffectData data; data.m_nEntIndex = entindex(); data.m_nAttachmentIndex = iAttachment; data.m_fFlags = m_iUpgradeLevel; data.m_vOrigin = vecSrc; DispatchEffect( "TF_3rdPersonMuzzleFlash_SentryGun", data ); switch( m_iUpgradeLevel ) { case 1: default: EmitSound( "Building_Sentrygun.Fire" ); break; case 2: EmitSound( "Building_Sentrygun.Fire2" ); break; case 3: EmitSound( "Building_Sentrygun.Fire3" ); break; } if ( !tf_sentrygun_ammocheat.GetBool() && !HasSpawnFlags( SF_SENTRY_INFINITE_AMMO ) ) { m_iAmmoShells--; } } else { if ( m_iUpgradeLevel > 1 ) { if ( !IsPlayingGesture( ACT_RANGE_ATTACK1_LOW ) ) { RemoveGesture( ACT_RANGE_ATTACK1 ); AddGesture( ACT_RANGE_ATTACK1_LOW ); } } // Out of ammo, play a click EmitSound( "Building_Sentrygun.Empty" ); m_flNextAttack = gpGlobals->curtime + 0.2; } return true; }
bool CIdentify::Load(CString filename) { CFile f; CString image,str,name,description,commands,symbols,compatibility; bool disable=false; int nEnableGesture=0; int i=0; if(!f.Open(filename,CFile::modeRead))return false; int length=(int)f.GetLength(); f.Read(image.GetBuffer(length),length); f.Close(); image.ReleaseBuffer(length); TCHAR ch=0; m_nGestures=0; m_Gestures.RemoveAll(); m_Gestures.SetSize(100,50); for(i=0;i<length;i++) { ch=image.GetAt(i); if((ch==13)||(ch==10)||(i+1==length)) { if(!str.IsEmpty()) { long p=0; if(p=str.Find(_T("description["))==0) { description=str.Mid(12,str.GetLength()-12-1); } if(p=str.Find(_T("name["))==0) { name=str.Mid(5,str.GetLength()-5-1); } if(p=str.Find(_T("commands["))==0) { commands=str.Mid(9,str.GetLength()-9-1); } if(p=str.Find(_T("compatibility["))==0) { compatibility=str.Mid(14,str.GetLength()-14-1); } if(p=str.Find(_T("disable["))==0) { disable=true; } if(p=str.Find(_T("symbols["))==0) { symbols=str.Mid(8,str.GetLength()-8-1); if(!disable)nEnableGesture++; if((!theProperties.bRegistred)&&(nEnableGesture>UNREGISTRED_VERSION_GESTURE_LIMIT))disable=true; AddGesture(0,name,description,commands,symbols,compatibility,disable); } if(p=str.Find(_T("opengroup["))==0) { name=str.Mid(10,str.GetLength()-10-1); AddGesture(1,name,description,commands,symbols,compatibility,disable); } if(p=str.Find(_T("closegroup["))==0) { AddGesture(2,name,description,commands,symbols,compatibility,disable); } str.Empty(); } } else str+=ch; } return true; }