Example #1
1
void CEntHost::PostThink()
{
    m_bIsBot = (GetBotController()) ? true : false;

    if ( IsAlive() && IsActive() ) {
        UpdateComponents();
        UpdateAttributes();

        m_bOnCombat = (m_CombatTimer.HasStarted() && m_CombatTimer.IsLessThen( 10.0f ));
        m_bUnderAttack = (m_UnderAttackTimer.HasStarted() && m_UnderAttackTimer.IsLessThen( 5.0f ));

        if ( m_bIsBot && !m_bOnCombat ) {
            m_bOnCombat = GetBotController()->IsAlerted() || GetBotController()->IsCombating();
        }
    }

    if ( GetAnimationSystem() ) {
        GetAnimationSystem()->Update();
    }
}
Example #2
0
void Totem::Update(uint32 time)
{
    if (!GetOwner()->IsAlive() || !IsAlive())
    {
        UnSummon();                                         // remove self
        return;
    }

    if (m_duration <= time)
    {
        UnSummon();                                         // remove self
        return;
    }
    else
        m_duration -= time;

    Creature::Update(time);
}
Example #3
0
bool C_CFPlayer::ShouldDraw( void )
{
	// If we're dead, our ragdoll will be drawn for us instead.
	if ( !IsAlive() && !IsKnockedOut() )
		return false;

	if( GetTeamNumber() == TEAM_SPECTATOR )
		return false;

	if( IsLocalPlayer() && IsRagdoll() )
		return true;

	if (m_hCameraCinematic != NULL)
		return false;

	// Skip C_BasePlayer::ShouldDraw() because it has a bunch of logic we don't care for.
	return C_BaseCombatCharacter::ShouldDraw();
}
Example #4
0
void SpawnerParticle::SpawnParticle() {
	if (particles != NULL && IsAlive()) {
		Vector2 pos((float)(rand() % this->width), (float)(rand() % this->height));
		pos += this->position - Vector2(this->width / 2.0f, this->height / 2.0f);

		Color color(this->color.Hue, 1.0f, 1.0f);

		float size = rand() % 4 + 4.0f;		 // Give a varied size
		if (rand() % 100 == 0)				 // 1% chance of an even bigger particle
			size += 12.0f;

		Vector2 initialSpeed = Vector2(0.0f, 20.0f); // Particles have some initial speed
		Vector2 force = Vector2(0.0f, 15.0f); // Particles move downwards

		Particle *p = new Particle(pos, color, size, initialSpeed, force);
		particles->Add(p);
	}
}
Example #5
0
int CMTalkMonster :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType)
{
	if ( IsAlive() )
	{
		// if player damaged this entity, have other friends talk about it
		if (pevAttacker && m_MonsterState != MONSTERSTATE_PRONE && FBitSet(pevAttacker->flags, FL_CLIENT))
		{
			edict_t *pFriend = FindNearestFriend(FALSE);

			if (pFriend && UTIL_IsAlive(pFriend))
			{
				// only if not dead or dying!
				CMTalkMonster *pTalkMonster = (CMTalkMonster *)pFriend;
				pTalkMonster->ChangeSchedule( slIdleStopShooting );
			}
		}
	}
	return CMBaseMonster::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType);
}
Example #6
0
bool CPlayerMySelf::ToggleAttackContinous()
{
	if(!IsAlive()) return false;

	if(false == m_bAttackContinous) // 타겟이 있는지 본다..
	{
		CPlayerNPC* pTarget = s_pOPMgr->CharacterGetByID(m_iIDTarget, true);
		if(pTarget) //  && !IsOutOfAttackRange(pTarget)) // 타겟이 있고 공격 가능한 범위에 있을때만
		{
			this->m_bAttackContinous = true;
		}
	}
	else
	{
		m_bAttackContinous = false;
	}

	return m_bAttackContinous;
}
Example #7
0
void CZombie::OnTakeDamage( const CTakeDamageInfo& info )
{
	CTakeDamageInfo newInfo = info;

	// Take 30% damage from bullets
	if ( newInfo.GetDamageTypes() == DMG_BULLET )
	{
		Vector vecDir = GetAbsOrigin() - ( newInfo.GetInflictor()->pev->absmin + newInfo.GetInflictor()->pev->absmax) * 0.5;
		vecDir = vecDir.Normalize();
		float flForce = DamageForce( newInfo.GetDamage() );
		pev->velocity = pev->velocity + vecDir * flForce;
		newInfo.GetMutableDamage() *= 0.3;
	}

	// HACK HACK -- until we fix this.
	if ( IsAlive() )
		PainSound();
	CBaseMonster::OnTakeDamage( newInfo );
}
/*
* Sets the states for particles
*
* @author Michael McQuarrie
*
* @return void
*/
bool
CFlagParticleEmitter::CheckAlive()
{
    for(std::vector<TParticle>::iterator iter = m_vecParticles.begin();
            iter != m_vecParticles.end(); ++iter)
    {
        if(iter->bAlive)
        {
            SetAlive(true);
            break;
        }
        else
        {
            SetAlive(false);
        }
    }

    return(IsAlive());
}
Example #9
0
void CTalkMonster::OnTakeDamage( const CTakeDamageInfo& info )
{
	if ( IsAlive() )
	{
		// if player damaged this entity, have other friends talk about it
		if (info.GetAttacker() && m_MonsterState != MONSTERSTATE_PRONE && info.GetAttacker()->GetFlags().Any( FL_CLIENT ) )
		{
			CBaseEntity *pFriend = FindNearestFriend( false );

			if (pFriend && pFriend->IsAlive())
			{
				// only if not dead or dying!
				CTalkMonster *pTalkMonster = (CTalkMonster *)pFriend;
				pTalkMonster->ChangeSchedule( slIdleStopShooting );
			}
		}
	}
	CBaseMonster::OnTakeDamage( info );
}
Example #10
0
void CZombie::FrozenStart()
{
	if ( GetTask()->iTask == TASK_AWAKE_FROM_DEAD )
		return;

	m_fEndfrozen = gpGlobals->time + FREEZE_DURATION;
	pev->renderfx = kRenderFxGlowShell;
	pev->rendercolor = Vector(0,90,250);
	Create( "fx_spawner_freeze", pev->origin, pev->origin, edict());

	if (IsAlive())
	{
		pev->sequence = 0;
		pev->framerate = 0;
		m_MonsterState = MONSTERSTATE_IDLE;
		Stop();
	}
	pev->velocity = pev->avelocity = g_vecZero;
}
Example #11
0
void Totem::Update(uint32 update_diff, uint32 time)
{
    Unit* owner = GetOwner();
    if (!owner || !owner->IsAlive() || !IsAlive())
    {
        UnSummon();                                         // remove self
        return;
    }

    if (m_duration <= update_diff)
    {
        UnSummon();                                         // remove self
        return;
    }
    else
        { m_duration -= update_diff; }

    Creature::Update(update_diff, time);
}
Example #12
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CBasePlayer::UpdateUnderwaterState( void )
{
	if ( GetWaterLevel() == WL_Eyes )
	{
		if ( IsPlayerUnderwater() == false )
		{
			SetPlayerUnderwater( true );
		}
		return;
	}

	if ( IsPlayerUnderwater() )
	{
		SetPlayerUnderwater( false );
	}

	if ( GetWaterLevel() == 0 )
	{
		if ( GetFlags() & FL_INWATER )
		{
#ifndef CLIENT_DLL
			if ( m_iHealth > 0 && IsAlive() )
			{
				EmitSound( "Player.Wade" );
			}
#endif
			RemoveFlag( FL_INWATER );
		}
	}
	else if ( !(GetFlags() & FL_INWATER) )
	{
#ifndef CLIENT_DLL
		// player enter water sound
		if (GetWaterType() == CONTENTS_WATER)
		{
			EmitSound( "Player.Wade" );
		}
#endif

		AddFlag( FL_INWATER );
	}
}
Example #13
0
void Totem::UnSummon()
{
    SendObjectDeSpawnAnim(GetGUID());

    CombatStop();
    RemoveAurasDueToSpell(GetSpell());

    // clear owner's totem slot
    for (int i = SUMMON_SLOT_TOTEM; i < MAX_TOTEM_SLOT; ++i)
    {
        if (m_owner->m_SummonSlot[i] == GetGUID())
        {
            m_owner->m_SummonSlot[i] = 0;
            break;
        }
    }

    m_owner->RemoveAurasDueToSpell(GetSpell());

    //remove aura all party members too
    Group* pGroup = NULL;
    if (m_owner->GetTypeId() == TYPEID_PLAYER)
    {
        // Not only the player can summon the totem (scripted AI)
        pGroup = m_owner->ToPlayer()->GetGroup();
        if (pGroup)
        {
            for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
            {
                Player* Target = itr->GetSource();
                if (Target && pGroup->SameSubGroup(m_owner->ToPlayer(), Target))
                    Target->RemoveAurasDueToSpell(GetSpell());
            }
        }
    }

    // any totem unsummon look like as totem kill, req. for proper animation
    if (IsAlive())
        setDeathState(DEAD);

    AddObjectToRemoveList();
}
Example #14
0
void isdf07Mission::SendEnemies(int type, Handle target) {
	switch (type) {
		case 0: //tank
			if (!IsAlive(enemy1)) {
				enemy1 = BuildObject("fvtank", comp_team, spawn1);
				Attack(enemy1, target, 1);
			}
			break;
		case 1: //rocket
			if (!IsAlive(enemy1)) {
				enemy1 = BuildObject("fvsent", comp_team, spawn1);
				Attack(enemy1, target, 1);
			}
			if (!IsAlive(enemy2)) {
				enemy2 = BuildObject("fvsent", comp_team, spawn2);
				Attack(enemy2, target, 1);
			}
			break;
		case 2: //constructor
			if (!IsAlive(enemy1)) {
				enemy1 = BuildObject("fvtank", comp_team, spawn1);
				Attack(enemy1, target, 1);
			}
			break;
		case 3: //turret
			if (!IsAlive(enemy1)) {
				enemy1 = BuildObject("fvarch", 2, spawn1);
				Attack(enemy1, target, 1);
			}
			if (!IsAlive(enemy2)) {
				enemy2 = BuildObject("fvarch", 2, spawn2);
				Attack(enemy2, target, 1);
			}
			break;
		case 4: //gun tower
			SetIndependence(enemy1, 0);
			SetIndependence(enemy2, 0);
			enemy1 = BuildObject("fvtank", 2, spawn1);
			enemy2 = BuildObject("fvtank", 2, spawn2);
			enemy3 = BuildObject("fvsent", 2, spawn3);
			Attack(enemy1, target, 1);
			Attack(enemy2, target, 1);
			Defend2(enemy3, enemy1, 1);
			break;
	}
	// so we transform them later
	enemy1deployed=false;
	enemy2deployed=false;
}
Example #15
0
void CBasePlayer::AvoidPhysicsProps( CUserCmd *pCmd )
{
#ifndef _XBOX
	// Don't avoid if noclipping or in movetype none
	switch ( GetMoveType() )
	{
	case MOVETYPE_NOCLIP:
	case MOVETYPE_NONE:
	case MOVETYPE_OBSERVER:
		return;
	default:
		break;
	}

	if ( GetObserverMode() != OBS_MODE_NONE || !IsAlive() )
		return;

	AvoidPushawayProps( this, pCmd );
#endif
}
Example #16
0
bool Unit::FireWeapon(GameObject* Target)
{
	if (!IsAlive())
		return false;

	if ( gCurrentWeapon )
	{
		if (gWeaponState == Aim && !PlayingAnimation(GetAnimation("Draw")))
		{
			if (gCurrentWeapon->Fire( this, Target, gMultipliers[1] ))
			{
				PlayAnimation(GetAnimation("Shoot"));
				PlayAnimationAfter(GetAnimation("Shoot"), GetAnimation("Aim"));

				return true;
			}
		}
	}
	return false;
}
Example #17
0
Actor* Game::GetPC(unsigned int slot, bool onlyalive)
{
	if (slot >= PCs.size()) {
		return NULL;
	}
	if (onlyalive) {
		unsigned int i=0;
		while(i<PCs.size() ) {
			Actor *ac = PCs[i++];

			if (IsAlive(ac) ) {
				if (!slot--) {
					return ac;
				}
			}
		}
		return NULL;
	}
	return PCs[slot];
}
//---------------------------------------------------------
// Zombies should scream continuously while burning, so long
// as they are alive... but NOT IN GERMANY!
//---------------------------------------------------------
void CRebelZombie::Ignite( float flFlameLifetime, bool bNPCOnly, float flSize, bool bCalledByLevelDesigner )
{
 	if( !IsOnFire() && IsAlive() )
	{
		BaseClass::Ignite( flFlameLifetime, bNPCOnly, flSize, bCalledByLevelDesigner );

		if ( !UTIL_IsLowViolence() )
		{
			RemoveSpawnFlags( SF_NPC_GAG );

			MoanSound( envRebelZombieMoanIgnited, ARRAYSIZE( envRebelZombieMoanIgnited ) );

			if ( m_pMoanSound )
			{
				ENVELOPE_CONTROLLER.SoundChangePitch( m_pMoanSound, 120, 1.0 );
				ENVELOPE_CONTROLLER.SoundChangeVolume( m_pMoanSound, 1, 1.0 );
			}
		}
	}
}
Example #19
0
void CNPC_Gargantua::TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr )
{
	CTakeDamageInfo subInfo = info;

	if ( !IsAlive() )
	{
		BaseClass::TraceAttack( subInfo, vecDir, ptr );
		return;
	}

	// UNDONE: Hit group specific damage?
	if ( subInfo.GetDamageType() & ( GARG_DAMAGE | DMG_BLAST ) )
	{
		if ( m_painSoundTime < gpGlobals->curtime )
		{
			CPASAttenuationFilter filter( this );
			EmitSound( filter, entindex(), "Garg.Pain" );

			m_painSoundTime = gpGlobals->curtime + random->RandomFloat( 2.5, 4 );
		}
	}

	int bitsDamageType = subInfo.GetDamageType();

	bitsDamageType &= GARG_DAMAGE;

	subInfo.SetDamageType( bitsDamageType );

	if ( subInfo.GetDamageType() == 0 )
	{
		if ( m_flDmgTime != gpGlobals->curtime || (random->RandomInt( 0, 100 ) < 20) )
		{
			g_pEffects->Ricochet(ptr->endpos, -vecDir );
			m_flDmgTime = gpGlobals->curtime;
		}

		subInfo.SetDamage( 0 );
	}

	BaseClass::TraceAttack( subInfo, vecDir, ptr );
}
//=========================================================
// RunAI
//=========================================================
void CNPC_Controller::RunAI( void )
{
	BaseClass::RunAI();

	Vector vecStart;
	QAngle angleGun;

	//some kind of hack in hl1 ?
//	if ( HasMemory( bits_MEMORY_KILLED ) )
	//use this instead
	if( !IsAlive() )
		return;

	for (int i = 0; i < 2; i++)
	{
		if (m_pBall[i] == NULL)
		{
			m_pBall[i] = CSprite::SpriteCreate( "sprites/xspark4.vmt", GetAbsOrigin(), TRUE );
			m_pBall[i]->SetTransparency( kRenderGlow, 255, 255, 255, 255, kRenderFxNoDissipation );
			m_pBall[i]->SetAttachment( this, (i + 3) );
			m_pBall[i]->SetScale( 1.0 );
		}

		float t = m_iBallTime[i] - gpGlobals->curtime;
		if (t > 0.1)
			t = 0.1 / t;
		else
			t = 1.0;

		m_iBallCurrent[i] += (m_iBall[i] - m_iBallCurrent[i]) * t;

		m_pBall[i]->SetBrightness( m_iBallCurrent[i] );

		GetAttachment( i + 2, vecStart, angleGun );
		m_pBall[i]->SetAbsOrigin( vecStart );

		CBroadcastRecipientFilter filter;
		GetAttachment( i + 3, vecStart, angleGun );
		te->DynamicLight( filter, 0.0, &vecStart, 255, 192, 64, 0/*exponent*/, m_iBallCurrent[i] / 8 /*radius*/, 0.5, 0 );
	}
}
Example #21
0
void WinProcessImpl::Cleanup()
{
    // Under windows, the reader thread is detached
    if ( m_thr ) {
        // Stop the reader thread
        m_thr->Stop();
        delete m_thr;
    }
    m_thr = NULL;

    // terminate the process
    if (IsAlive()) {
        std::map<unsigned long, bool> tree;
        ProcUtils::GetProcTree(tree, GetPid());

        std::map<unsigned long, bool>::iterator iter = tree.begin();
        for(; iter != tree.end(); iter++) {
            wxKillError rc;
            wxKill(iter->first, wxSIGKILL, &rc);
        }
        TerminateProcess(piProcInfo.hProcess, 255);
    }

    CloseHandle( hChildStdinRd);
    CloseHandle( hChildStdinWrDup );
    CloseHandle( hChildStdoutWr);
    CloseHandle( hChildStdoutRdDup );
    CloseHandle( hChildStderrWr);
    CloseHandle( hChildStderrRdDup );
    CloseHandle( piProcInfo.hProcess );
    CloseHandle( piProcInfo.hThread );

    hChildStdinRd       = NULL;
    hChildStdoutWr      = NULL;
    hChildStdinWrDup    = NULL;
    hChildStdoutRdDup   = NULL;
    hChildStderrWr      = NULL;
    hChildStderrRdDup   = NULL;
    piProcInfo.hProcess = NULL;
    piProcInfo.hThread  = NULL;
}
int CNPC_Gargantua::OnTakeDamage_Alive( const CTakeDamageInfo &info )
{
	CTakeDamageInfo subInfo = info;

	float flDamage = subInfo.GetDamage();

	if ( IsAlive() )
	{
		if ( !(subInfo.GetDamageType() & GARG_DAMAGE) )
		{
			 flDamage *= 0.01;
			 subInfo.SetDamage( flDamage );
		}
		if ( subInfo.GetDamageType() & DMG_BLAST )
		{
			SetCondition( COND_LIGHT_DAMAGE );
		}
	}

	return BaseClass::OnTakeDamage_Alive( subInfo );
}
// =======================================================
// Separate the blocks with colors.
// -------------
int PPCDebugInterface::GetColor(unsigned int address)
{
  if (!IsAlive())
    return 0xFFFFFF;
  if (!PowerPC::HostIsRAMAddress(address))
    return 0xeeeeee;
  static const int colors[6] = {
      0xd0FFFF,  // light cyan
      0xFFd0d0,  // light red
      0xd8d8FF,  // light blue
      0xFFd0FF,  // light purple
      0xd0FFd0,  // light green
      0xFFFFd0,  // light yellow
  };
  Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
  if (!symbol)
    return 0xFFFFFF;
  if (symbol->type != Symbol::Type::Function)
    return 0xEEEEFF;
  return colors[symbol->index % 6];
}
s32 sceKernelDeleteThread(s32 threadId)
{
	sceLibKernel.Warning("sceKernelDeleteThread(threadId=0x%x)", threadId);

	const auto t = Emu.GetCPU().GetThread(threadId, CPU_THREAD_ARMv7);

	if (!t)
	{
		RETURN_ERROR(SCE_KERNEL_ERROR_INVALID_UID);
	}

	// thread should be in DORMANT state, but it's not possible to check it correctly atm

	if (t->IsAlive())
	{
		RETURN_ERROR(SCE_KERNEL_ERROR_NOT_DORMANT);
	}

	Emu.GetCPU().RemoveThread(threadId);
	return SCE_OK;
}
Example #25
0
void NPC::SetEnemy(edict_t *entity)
{
	if (FNullEnt(entity) || !IsAlive(entity))
	{
		m_enemy = null;
		m_task &= ~TASK_ENEMY;
		m_enemyUpdateTime = -1.0f;
		return;
	}

	SetMoveTarget(null);

	m_enemy = entity;
	m_task |= TASK_ENEMY;

	if (m_attackDistance <= 120.0f)
		m_enemyUpdateTime = gpGlobals->time + 3.0f;
	else
		m_enemyUpdateTime = gpGlobals->time + 1.2f;

}
Example #26
0
void CASW_Parasite::StartInfestation()
{
	if ( !IsAlive() )
	{
		return;
	}

	CASW_Marine* pMarine = CASW_Marine::AsMarine( m_hPrepareToInfest.Get() );
	if ( pMarine )
	{
		InfestMarine( pMarine );
	}
	else
	{
		CASW_Colonist *pColonist = dynamic_cast<CASW_Colonist*>( m_hPrepareToInfest.Get() );
		if ( pColonist )
		{
			InfestColonist( pColonist );
		}
	}
}
Example #27
0
Thread::Thread(GLFWthreadfun pFunction, void * pArgument, std::string sName)
	: m_bCanStart(false),
	  m_bShouldBeRunning(true),
	  m_bThreadEnded(false),
	  m_sName(sName),
	  ///m_pFpsCounter(FpsCounter::CreateCounter(sName))
	  m_pArguments(),
	  m_oThread(-1)
{
	m_pArguments[0] = this;
	m_pArguments[1] = pArgument;
	m_oThread = glfwCreateThread(pFunction, m_pArguments);
	if (IsAlive())
		printf("%s thread (tid = %d) created.\n", m_sName.c_str(), m_oThread);
	else {
		printf("Couldn't create %s thread.\n", m_sName.c_str());
		throw 0;
	}

	//m_bCanStart = true;		// Allow the thread to start
}
Example #28
0
void CMessageDlg::OnButtonSend() 
{
    CString msg;
    m_richMessage.GetWindowText(msg);

    if(IsAlive() && msg.GetLength()>0)
    {
        m_richMessage.SetWindowText(_T(""));

        TextMessage usermsg;
        usermsg.nMsgType = MSGTYPE_USER;
        usermsg.nFromUserID = m_myself.nUserID;
        usermsg.nToUserID = m_user.nUserID;
        _tcsncpy(usermsg.szMessage, msg.GetBuffer(), TT_STRLEN - 1);

        if( TT_DoTextMessage(ttInst, &usermsg)>0)
            AppendMessage(usermsg, TRUE);
        else
            AfxMessageBox(_T("Failed to send message!"));
    }
}
Example #29
0
void CGargantua::TraceAttack( const CTakeDamageInfo& info, Vector vecDir, TraceResult& tr )
{
	ALERT( at_aiconsole, "CGargantua::TraceAttack\n");

	if ( !IsAlive() )
	{
		CBaseMonster::TraceAttack( info, vecDir, tr );
		return;
	}

	CTakeDamageInfo newInfo = info;

	// UNDONE: Hit group specific damage?
	if ( newInfo.GetDamageTypes() & (GARG_DAMAGE|DMG_BLAST) )
	{
		if ( m_painSoundTime < gpGlobals->time )
		{
			EMIT_SOUND_DYN( this, CHAN_VOICE, pPainSounds[ RANDOM_LONG(0,ARRAYSIZE(pPainSounds)-1) ], 1.0, ATTN_GARG, 0, PITCH_NORM );
			m_painSoundTime = gpGlobals->time + RANDOM_FLOAT( 2.5, 4 );
		}
	}

	newInfo.GetMutableDamageTypes() &= GARG_DAMAGE;

	if ( newInfo.GetDamageTypes() == 0)
	{
		if ( GetDamageTime() != gpGlobals->time || (RANDOM_LONG(0,100) < 20) )
		{
			UTIL_Ricochet( tr.vecEndPos, RANDOM_FLOAT(0.5,1.5) );
			SetDamageTime( gpGlobals->time );
//			if ( RANDOM_LONG(0,100) < 25 )
//				EMIT_SOUND_DYN( this, CHAN_BODY, pRicSounds[ RANDOM_LONG(0,ARRAYSIZE(pRicSounds)-1) ], 1.0, ATTN_NORM, 0, PITCH_NORM );
		}
		newInfo.GetMutableDamage() = 0;
	}

	CBaseMonster::TraceAttack( newInfo, vecDir, tr );

}
Example #30
0
void TThread::Start() {
    TLock Lck(CriticalSection);

    if (IsAlive()) {
        printf("Tried to start a thread that is already alive! Ignoring ...\n");
        return;
    }
    if (IsCancelled()) {
        return;
    }

    Status = STATUS_STARTED;

    // create new thread
    int code = pthread_create(
                   &ThreadHandle,	// Handle
                   NULL,			// Attributes
                   EntryPoint,		// Thread func
                   this			// Arg
               );
    EAssert(code == 0);
}