예제 #1
0
int CNPC_Bullsquid::RangeAttack1Conditions( float flDot, float flDist )
{
	if ( IsMoving() && flDist >= 512 )
	{
		// squid will far too far behind if he stops running to spit at this distance from the enemy.
		return ( COND_NONE );
	}

	if ( flDist > 85 && flDist <= 784 && flDot >= 0.5 && gpGlobals->curtime >= m_flNextSpitTime )
	{
		if ( GetEnemy() != NULL )
		{
			if ( fabs( GetAbsOrigin().z - GetEnemy()->GetAbsOrigin().z ) > 256 )
			{
				// don't try to spit at someone up really high or down really low.
				return( COND_NONE );
			}
		}

		if ( IsMoving() )
		{
			// don't spit again for a long time, resume chasing enemy.
			m_flNextSpitTime = gpGlobals->curtime + 5;
		}
		else
		{
			// not moving, so spit again pretty soon.
			m_flNextSpitTime = gpGlobals->curtime + 0.5;
		}

		return( COND_CAN_RANGE_ATTACK1 );
	}

	return( COND_NONE );
}
예제 #2
0
//=========================================================
// CheckRangeAttack1
//=========================================================
BOOL CBullsquid :: CheckRangeAttack1 ( float flDot, float flDist )
{
	if ( IsMoving() && flDist >= 512 )
	{
		// squid will far too far behind if he stops running to spit at this distance from the enemy.
		return FALSE;
	}

	if ( flDist > 64 && flDist <= 784 && flDot >= 0.5 && gpGlobals->time >= m_flNextSpitTime )
	{
		if ( m_hEnemy != NULL )
		{
			if ( fabs( pev->origin.z - m_hEnemy->pev->origin.z ) > 256 )
			{
				// don't try to spit at someone up really high or down really low.
				return FALSE;
			}
		}

		if ( IsMoving() )
		{
			// don't spit again for a long time, resume chasing enemy.
			m_flNextSpitTime = gpGlobals->time + 5;
		}
		else
		{
			// not moving, so spit again pretty soon.
			m_flNextSpitTime = gpGlobals->time + 0.5;
		}

		return TRUE;
	}

	return FALSE;
}
예제 #3
0
// Update
void Game_Player::Update() {
	bool last_moving = IsMoving();

	if (!IsMoving() && !Game_Map::GetInterpreter().IsRunning()
		/*move_route_forcing || Game_Temp::message_window_showing*/) {
		switch (Input::dir4) {
			case 2:
				MoveDown();
				break;
			case 4:
				MoveLeft();
				break;
			case 6:
				MoveRight();
				break;
			case 8:
				MoveUp();
		}
	}

	int last_real_x = real_x;
	int last_real_y = real_y;

	Game_Character::Update();

	UpdateScroll(last_real_x, last_real_y);

	UpdateNonMoving(last_moving);
}
예제 #4
0
void Game_Event::Setup(RPG::EventPage* new_page) {
	bool from_null = page == NULL;
	page = new_page;

	// Free resources if needed
	if (interpreter) {
		// If the new page is null and the interpreter is running, it should
		// carry on executing its command list during this frame
		if (page)
			interpreter->Clear();
		Game_Map::ReserveInterpreterDeletion(interpreter);
		interpreter.reset();
	}

	if (page == NULL) {
		tile_id = 0;
		SetSpriteName("");
		SetSpriteIndex(0);
		SetDirection(RPG::EventPage::Direction_down);
		//move_type = 0;
		trigger = -1;
		list.clear();
		return;
	}
	SetSpriteName(page->character_name);
	SetSpriteIndex(page->character_index);

	tile_id = page->character_name.empty() ? page->character_index : 0;

	if (original_pattern != page->character_pattern) {
		pattern = page->character_pattern;
		original_pattern = pattern;
	}

	move_type = page->move_type;
	SetMoveSpeed(page->move_speed);
	SetMoveFrequency(page->move_frequency);
	max_stop_count = (GetMoveFrequency() > 7) ? 0 : (int)pow(2.0, 8 - GetMoveFrequency());
	original_move_frequency = page->move_frequency;
	original_move_route = page->move_route;
	SetOriginalMoveRouteIndex(0);

	bool last_direction_fixed = IsDirectionFixed() || IsFacingLocked();
	animation_type = page->animation_type;

	if (from_null || !(last_direction_fixed || IsMoving()) || IsDirectionFixed())
		SetSpriteDirection(page->character_direction);
	if (!IsMoving())
		SetDirection(page->character_direction);

	SetOpacity(page->translucent ? 160 : 255);
	SetLayer(page->layer);
	data.overlap_forbidden = page->overlap_forbidden;
	trigger = page->trigger;
	list = page->event_commands;

	if (trigger == RPG::EventPage::Trigger_parallel) {
		interpreter.reset(new Game_Interpreter_Map());
	}
}
예제 #5
0
void Game_Player::Update() {
	bool last_moving = IsMoving();

	if (!IsMoving() && !Game_Map::GetInterpreter().IsRunning() 
		&& !IsMoveRouteOverwritten() && !Game_Message::message_waiting) {
		switch (Input::dir4) {
			case 2:
				MoveDown();
				break;
			case 4:
				MoveLeft();
				break;
			case 6:
				MoveRight();
				break;
			case 8:
				MoveUp();
		}
	}

	int last_real_x = real_x;
	int last_real_y = real_y;

	Game_Character::Update();

	UpdateScroll(last_real_x, last_real_y);

	UpdateNonMoving(last_moving);
}
예제 #6
0
//=========================================================
// TakeDamage - overridden for bullsquid so we can keep track
// of how much time has passed since it was last injured
//=========================================================
int CBullsquid :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{
	float flDist;
	Vector vecApex;

	// if the squid is running, has an enemy, was hurt by the enemy, hasn't been hurt in the last 3 seconds, and isn't too close to the enemy,
	// it will swerve. (whew).
	if ( m_hEnemy != NULL && IsMoving() && pevAttacker == m_hEnemy->pev && gpGlobals->time - m_flLastHurtTime > 3 )
	{
		flDist = ( pev->origin - m_hEnemy->pev->origin ).Length2D();

		if ( flDist > SQUID_SPRINT_DIST )
		{
			flDist = ( pev->origin - m_Route[ m_iRouteIndex ].vecLocation ).Length2D();// reusing flDist.

			if ( FTriangulate( pev->origin, m_Route[ m_iRouteIndex ].vecLocation, flDist * 0.5, m_hEnemy, &vecApex ) )
			{
				InsertWaypoint( vecApex, bits_MF_TO_DETOUR | bits_MF_DONT_SIMPLIFY );
			}
		}
	}

	if ( !FClassnameIs ( pevAttacker, "monster_headcrab" ) )
	{
		// don't forget about headcrabs if it was a headcrab that hurt the squid.
		m_flLastHurtTime = gpGlobals->time;
	}

	return CBaseMonster :: TakeDamage ( pevInflictor, pevAttacker, flDamage, bitsDamageType );
}
예제 #7
0
// ------------------------------------------------------------------------------------------------
Uint32 ProjectileBase :: WriteToPacket(Uint32 dataWritePos, Uint8 data[])
{
	Uint32 sendId = Id();
	ProjectileType sendType = Type();
    Vector2df sendPos = Pos();
    Uint32 sendHeadingDeg = HeadingDeg();
    float sendSpeed = Speed();
    Uint32 sendOwnerPlayerId = OwnerPlayerId();
    float sendLife = Life();
    Uint32 sendHealth = Health();
    bool sendIsMoving = IsMoving();

    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_ID], &sendId, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_TYPE], &sendType, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_POSX], &sendPos.x, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_POSY], &sendPos.y, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_HEADING], &sendHeadingDeg, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_SPEED], &sendSpeed, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_LIFE], &sendLife, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_HEALTH], &sendHealth, 4);
    memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_PLAYER_ID], &sendOwnerPlayerId, 4);
	memcpy(&data[dataWritePos + PACKET_WRITE_PROJECTILE_ISMOVING], &sendIsMoving, 1);

    return PACKET_WRITE_PROJECTILE_LENGTH;
} // ----------------------------------------------------------------------------------------------
예제 #8
0
void SmoothFollowProcess::VUpdate(unsigned int elapsedTime)
{
	float diffX = m_posX - m_pImage->GetPosX();
	float diffY = m_posY - m_pImage->GetPosY();
	
	float deltaX = diffX*m_speed*elapsedTime;
	float deltaY = diffY*m_speed*elapsedTime;
	
	if(fabs(deltaX) > fabs(diffX))
		deltaX = diffX;
	
	if(fabs(deltaY) > fabs(diffY))
		deltaY = diffY;
	
	m_pImage->Translate(deltaX, deltaY);
	
	double diffAngle = m_angle - m_pImage->GetAngle();
		
	if(diffAngle < -180)
		diffAngle += 360;
	else if(diffAngle > 180)
		diffAngle -= 360;
		
	double deltaAngle = diffAngle*m_speed*elapsedTime;
	
	if(fabs(deltaAngle) > fabs(diffAngle))
		deltaAngle = diffAngle;
		
	m_pImage->SetAngle(m_pImage->GetAngle() + deltaAngle);
	
	if(!IsMoving(0.5f) && m_bEndIfStatic)
		Success();
}
예제 #9
0
void CEntity::UpdateMovement(Ogre::Real ElapsedTime)
{
	//Also update walk/idle animation?
	if( IsMoving() ){
		Ogre::Real LenghtLeftToGo = (GetDestination() - GetPosition()).length();
		Ogre::Vector3 Movement = GetMovement();
		Ogre::Vector3 CorrectedMovement = ( Movement * ElapsedTime );

		//Set the right angle for the entity
		mNode->lookAt( GetDestination(), Ogre::Node::TS_WORLD );

		if( CorrectedMovement.length() < LenghtLeftToGo ){ //Not at destination yet, just move
			mNode->translate( CorrectedMovement );
		}else{ //Arrived at destination
			mNode->setPosition( GetDestination() );
			ReachedDestination();
			//TODO: If there is a next destination then go there with the frametime left of this movement.
			//(Loop till all frametime is used for movement)
			//Example: if there are 3 destinations left, and the first 2 will be reached
			//in 2 seconds.
			//If the user has a slow computer that updates the frame every 2,5 seconds,
			//then it should first use x seconds to reach destination one, then check
			//for how many seconds left, and use those to go to the next node and so on.
		}
	}
}
예제 #10
0
void CAI_PlayerAlly::RunTask( const Task_t *pTask )
{
	switch( pTask->iTask )
	{
	case TASK_TALKER_CLIENT_STARE:
	case TASK_TALKER_LOOK_AT_CLIENT:

		if ( pTask->iTask == TASK_TALKER_CLIENT_STARE )
		{
			// Get edict for one player
			CBasePlayer *pPlayer = (CBasePlayer *)CBaseEntity::Instance( engine->PEntityOfEntIndex( 1 ) );
			Assert( pPlayer );

			// fail out if the player looks away or moves away.
			if ( ( pPlayer->GetLocalOrigin() - GetLocalOrigin() ).Length2D() > TLK_STARE_DIST )
			{
				// player moved away.
				TaskFail("Player moved away");
			}

			Vector forward;
			AngleVectors( pPlayer->GetLocalAngles(), &forward );
			if ( UTIL_DotPoints( pPlayer->GetLocalOrigin(), GetLocalOrigin(), forward ) < m_flFieldOfView )
			{
				// player looked away
				TaskFail("Player looked away");
			}
		}

		if ( gpGlobals->curtime > m_flWaitFinished )
		{
			TaskComplete();
		}
		break;

	case TASK_TALKER_EYECONTACT:
		if (IsMoving() || !GetExpresser()->IsSpeaking() || GetSpeechTarget() == NULL)
		{
			TaskComplete();
		}
		break;

	case TASK_WAIT_FOR_MOVEMENT:
		if (!GetExpresser()->IsSpeaking() || GetSpeechTarget() == NULL)
		{
			// override so that during walk, a scientist may talk and greet player
			FIdleHello();
			if (random->RandomInt(0,m_nSpeak * 20) == 0)
			{
				FIdleSpeak();
			}
		}

		BaseClass::RunTask( pTask );
		break;

	default:
		BaseClass::RunTask( pTask );
	}
}
예제 #11
0
void CObject::Move ( const CVector& vecPosition, const CVector& vecRotation, unsigned long ulTime )
{
    // Are we already moving?
    if ( IsMoving () )
    {
        // Stop our current movement
        StopMoving ();
    }

    // If it's more than 0 milliseconds
    if ( ulTime > 0 )
    {
        // Setup our move data
        m_moveData.vecStartPosition = GetPosition ();
        m_moveData.vecStopPosition = vecPosition;
        GetRotation ( m_moveData.vecStartRotation );
        m_moveData.vecStopRotation = vecRotation;
        m_moveData.ulTime = ulTime;
        m_moveData.ulTimeStart = GetTime ();
        m_moveData.ulTimeStop = m_moveData.ulTimeStart + ulTime;
        m_moveData.bActive = true;
    }
    // If we have a time of 0, move there now
    else
    {
        SetPosition ( vecPosition );
        CVector vecTemp;
        GetRotation ( vecTemp );
        SetRotation ( vecTemp + vecRotation );
    }
}
void CSyncCoreObjectMediator::DisbindConnection()
{	
	if( !m_pConn )
		return;

	if(!IsActive())
		StopFollowing();
	if(IsMoving())
		StopMoving();
	
	m_bDisbindingConn = false;

	GetScene()->DelFromMulticast( m_pConn );

	m_fDirKnownMaxSpeed = 0;
	//cout<<"DisbindConnection DestroyObjForConnection "<<GetGlobalID()<<endl;
	DestroyObjForConnection( m_pConn );

	m_pConn->SetMediator(NULL);
	
	AddConnBlockCount();
	//关联某个连接,必须最后将m_pConn设置为NULL
	IntSetConnection(NULL);

	(new CCoreObjOnConnectionDisbindedResult(GetGlobalID()))->Add();
}
예제 #13
0
bool Game_Vehicle::IsMovable() {
	if (!IsInUse())
		return false;
	if (type == Airship && (IsAscending() || IsDescending()))
		return false;
	return !IsMoving();
}
예제 #14
0
const CVector& CObject::GetPosition ( void )
{
    // Are we attached to something?
    if ( m_pAttachedTo )
    {
        m_vecPosition = m_pAttachedTo->GetPosition ();
        m_vecPosition += m_vecAttachedPosition;
    }
    // Are we moving?
    else if ( IsMoving () )
    {
        // Calculate our current Position
        unsigned long ulCurrentTime = GetTime ();

        // Grab the difference between start and finish
        CVector vecJourney = m_moveData.vecStopPosition - m_moveData.vecStartPosition;

        // Grab the duration the object takes to move
        float fDuration = static_cast < float > ( m_moveData.ulTime );
        // Grab the time that has passed since we started moving
        float fTimePassed = static_cast < float > ( ulCurrentTime - m_moveData.ulTimeStart );

        // How far along our journey should we be?
        vecJourney /= fDuration;
        vecJourney *= fTimePassed;

        // Update our stored position
        m_vecPosition = m_moveData.vecStartPosition + vecJourney;
    }

    // Finally, return it
    return m_vecPosition;
}
예제 #15
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CNPC_Monster::PrescheduleThink( void )
{
	bool bNearEnemy = false;
	if ( GetEnemy() != NULL )
	{
		float flDist = (GetEnemy()->GetAbsOrigin() - GetAbsOrigin()).Length();
		if ( flDist < ZOMBIE_ENEMY_BREATHE_DIST )
		{
			bNearEnemy = true;
		}
	}

	if ( bNearEnemy )
	{
		if ( !m_bNearEnemy )
		{
			m_bNearEnemy = true;
		}
	}
	else if ( m_bNearEnemy )
	{
		m_bNearEnemy = false;
	}

	BaseClass::PrescheduleThink();

	// We're chopped off! And we're moving! Add some blood trail...
	if (m_fIsTorso && IsMoving() && (m_flLastBloodTrail < gpGlobals->curtime))
	{
		m_flLastBloodTrail = gpGlobals->curtime + 1.0f; // We don't want to spam blood all over the place.
		trace_t tr;
		UTIL_TraceLine((GetAbsOrigin() + Vector(0, 0, 50)), (GetAbsOrigin() + Vector(0, 0, -300)), MASK_ALL, this, COLLISION_GROUP_NONE, &tr);
		UTIL_DecalTrace(&tr, "Blood");
	}
}
예제 #16
0
void PhysicalObj::UpdatePosition()
{
  // No ghost allowed here !
  if (IsGhost()) {
    return;
  }

  if (m_collides_with_ground) {
    // object is not moving
    if (!IsMoving()) {
      // and has no reason to move
      if (!FootsInVacuum()) {
        if (!IsInWater()) {
          return;
        }
      } else {
        // it should fall !
        StartMoving();
      }
    }
  }

  // Compute new position.
  RunPhysicalEngine();

  if (IsGhost()) {
    return;
  }

  // Classical object sometimes sinks in water and sometimes goes out of water!
  if (m_collides_with_ground) {
    if (IsInWater() && m_alive!=DROWNED && m_alive!=DEAD) Drown();
    else if (!IsInWater() && m_alive==DROWNED) GoOutOfWater();
  }
}
예제 #17
0
void Game_Player::Update() {
	bool last_moving = IsMoving() || IsJumping();

	if (IsMovable() && !Game_Map::GetInterpreter().IsRunning()) {
		switch (Input::dir4) {
			case 2:
				Move(Down);
				break;
			case 4:
				Move(Left);
				break;
			case 6:
				Move(Right);
				break;
			case 8:
				Move(Up);
		}
	}

	UpdateScroll();
	Game_Character::Update();

	if (location.aboard)
		GetVehicle()->SyncWithPlayer();

	UpdateNonMoving(last_moving);
}
예제 #18
0
void DiscoGrenade::Refresh()
{
  WeaponProjectile::Refresh();

#ifdef HAVE_A_REALLY_BIG_CPU
  if(IsMoving()) {
    Double norme,angle;
    GetSpeed(norme,angle);
    for (int i = -3; i<4 ; i++)
      smoke_engine.AddNow(GetPosition(), 1, particle_MAGIC_STAR, false,
                          angle+(i*QUARTER_PI/3.0)+HALF_PI, 2.0);
  } else {
      smoke_engine.AddNow(GetPosition(), 1, particle_MAGIC_STAR, false,
                          ((Double)(GameTime::GetInstance()->Read()%500)-250.0) * PI / 250.0, 3.0);
  }
#else //  :-P
  smoke_engine.AddPeriodic(GetPosition(), particle_MAGIC_STAR, false);
#endif //HAVE_A_REALLY_BIG_CPU

  int tmp_time = GetMSSinceTimeoutStart();
  // Ah ! Ah ! Ah ! Staying Alive, staying alive ...
  if (GetTotalTimeout() >= 2 && tmp_time > (1000 * GetTotalTimeout() - 2000) && !have_played_music) {
    //JukeBox::GetInstance()->Play("default","weapon/alleluia") ;
    have_played_music = true;
  }
  image->SetRotation_rad(GetSpeedAngle());
}
예제 #19
0
void CHostageImprov::Afraid()
{
	char animInto[32];
	char animLoop[32];
	char animExit[32];

	if (IsCrouching())
		return;

	if (m_animateState.GetPerformance() == HostageAnimateState::Flinching ||
		m_animateState.GetPerformance() == HostageAnimateState::Afraid)
		return;

	if (!IsMoving())
	{
		m_animateState.Reset();
		m_animateState.SetPerformance(HostageAnimateState::Afraid);

		int which = RANDOM_LONG(0, 100) % 3 + 1;

		Q_sprintf(animInto, "cower_into_%d", which);
		Q_sprintf(animLoop, "cower_loop_%d", which);
		Q_sprintf(animExit, "cower_exit_%d", which);

		m_animateState.AddSequence(this, animInto);
		m_animateState.AddSequence(this, animLoop, RANDOM_FLOAT(3, 10));
		m_animateState.AddSequence(this, animExit);
	}
}
예제 #20
0
void CObject::GetRotation ( CVector & vecRotation )
{
    vecRotation = m_vecRotation;

    // Are we attached to something?
    if ( m_pAttachedTo ) vecRotation += m_vecAttachedRotation;

    // Are we moving?
    else if ( IsMoving () )
    {
        // Calculate our current rotation
        unsigned long ulCurrentTime = GetTime ();

        // Grab the difference between start and finish
        CVector vecJourney = m_moveData.vecStopRotation - m_moveData.vecStartRotation;

        // Grab the duration the object takes to move
        float fDuration = static_cast < float > ( m_moveData.ulTime );
        // Grab the time that has passed since we started moving
        float fTimePassed = static_cast < float > ( ulCurrentTime - m_moveData.ulTimeStart );

        // How far along our journey should we be?
        vecJourney /= fDuration;
        vecJourney *= fTimePassed;

        // Update our stored rotation
        vecRotation = m_vecRotation = m_moveData.vecStartRotation + vecJourney;
    }
}
예제 #21
0
파일: Feature.cpp 프로젝트: AMDmi3/spring
void CFeature::SetVelocity(const float3& v)
{
	CWorldObject::SetVelocity(v);
	UpdatePhysicalStateBit(CSolidObject::PSTATE_BIT_MOVING, v != ZeroVector);

	if (IsMoving()) {
		featureHandler->SetFeatureUpdateable(this, true);
	}
}
예제 #22
0
파일: footbomb.cpp 프로젝트: fluxer/warmux
void FootBomb::Refresh()
{
  WeaponProjectile::Refresh();
//  image->SetRotation_rad(GetSpeedAngle());
  if (IsMoving()) {
#define ROTATIONS_PER_SECOND  4
    image->SetRotation_rad((ROTATIONS_PER_SECOND*GetMSSinceTimeoutStart()*2) * PI / 1000 );
  }
}
예제 #23
0
/// Gibt die Position zurück, wo wir uns hinbewegen (selbe Position, wenn Schiff steht)
MapPoint noMovable::GetDestinationForCurrentMove() const
{
    // Bewegt sich das Ding gerade?
    if(IsMoving())
        // Dann unsere Zielrichtung zur Berechnung verwenden
        return MapPoint(gwg->GetNeighbour(pos, curMoveDir));

    return pos;
}
예제 #24
0
void Game_Character::Update() {
	if (IsJumping()) {
		UpdateJump();
		if (IsSpinning())
			anime_count++;
	} else if (IsMoving()) {
		remaining_step -= 1 << (1 + GetMoveSpeed());
		if (IsSpinning() || (animation_type != RPG::EventPage::AnimType_fixed_graphic && walk_animation))
			anime_count++;
	} else {
		stop_count++;
		if (IsSpinning() || IsContinuous() || pattern != original_pattern)
			anime_count++;
	}

	if (anime_count >= GetSteppingSpeed()) {
		if (IsSpinning()) {
			SetSpriteDirection((GetSpriteDirection() + 1) % 4);
		} else if (!IsContinuous() && IsStopping()) {
			pattern = original_pattern;
			last_pattern = last_pattern == RPG::EventPage::Frame_left ? RPG::EventPage::Frame_right : RPG::EventPage::Frame_left;
		} else {
			if (last_pattern == RPG::EventPage::Frame_left) {
				if (pattern == RPG::EventPage::Frame_right) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_right;
				} else {
					pattern = RPG::EventPage::Frame_right;
				}
			} else {
				if (pattern == RPG::EventPage::Frame_left) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_left;
				} else {
					pattern = RPG::EventPage::Frame_left;
				}
			}
		}

		anime_count = 0;
	}

	if (wait_count > 0) {
		wait_count -= 1;
		return;
	}

	if (stop_count >= max_stop_count) {
		if (IsMoveRouteOverwritten()) {
			MoveTypeCustom();
		} else {
			// Only events
			UpdateSelfMovement();
		}
	}
}
예제 #25
0
void CNPCSimpleTalker::RunTask( const Task_t *pTask )
{
	switch( pTask->iTask )
	{
	case TASK_TALKER_WAIT_FOR_SEMAPHORE:
		if ( GetExpresser()->SemaphoreIsAvailable( this ) )
			TaskComplete();
		break;

	case TASK_TALKER_CLIENT_STARE:
	case TASK_TALKER_LOOK_AT_CLIENT:

		if ( pTask->iTask == TASK_TALKER_CLIENT_STARE && AI_IsSinglePlayer() )
		{
			// Get edict for one player
			CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
			Assert( pPlayer );

			// fail out if the player looks away or moves away.
			if ( ( pPlayer->GetAbsOrigin() - GetAbsOrigin() ).Length2D() > TALKER_STARE_DIST )
			{
				// player moved away.
				TaskFail("Player moved away");
			}

			Vector forward;
			AngleVectors( pPlayer->GetLocalAngles(), &forward );
			if ( UTIL_DotPoints( pPlayer->GetAbsOrigin(), GetAbsOrigin(), forward ) < m_flFieldOfView )
			{
				// player looked away
				TaskFail("Player looked away");
			}
		}

		if ( IsWaitFinished() )
		{
			TaskComplete();
		}
		break;

	case TASK_TALKER_EYECONTACT:
		if (IsMoving() || !GetExpresser()->IsSpeaking() || GetSpeechTarget() == NULL)
		{
			TaskComplete();
		}
		break;

	case TASK_WAIT_FOR_MOVEMENT:
		FIdleSpeakWhileMoving();
		BaseClass::RunTask( pTask );
		break;

	default:
		BaseClass::RunTask( pTask );
	}
}
예제 #26
0
bool CASW_Alien_Jumper::AllowedToBePushed( void )
{
	if ( IsMoving() == false 
		 && GetNavType() != NAV_JUMP && m_flNextJumpPushTime <= gpGlobals->curtime )
	{
		return true;
	}

	return false;
}
예제 #27
0
void SegmentServo::StartMovement(uint8_t angleDeg, float speedFactor, bool infinite, bool forced)
{
    if (IsMoving() && !forced)
        return;

    SetTargetAngle(angleDeg);
    _speedFactor = speedFactor > 0.0f ? speedFactor : 1.0f;
    _moveStatus = MOVE_STATUS_MOVING;
    _infiniteMovement = infinite;
}
예제 #28
0
void Game_Character::Update() {
	if (IsJumping()) {
		UpdateJump();
		anime_count += (IsSpinning() ? 1.0 : 0);
	} else if (IsContinuous() || IsSpinning()) {
		UpdateMove();
		UpdateStop();
	} else {
		if (IsMoving()) {
			UpdateMove();
		} else {
			UpdateStop();
		}
	}

	if (anime_count > 36.0/(GetMoveSpeed()+1)) {
		if (IsSpinning()) {
			SetPrelockDirection((GetPrelockDirection() + 1) % 4);
		} else if (!IsContinuous() && IsStopping()) {
			pattern = original_pattern;
			last_pattern = last_pattern == RPG::EventPage::Frame_left ? RPG::EventPage::Frame_right : RPG::EventPage::Frame_left;
		} else {
			if (last_pattern == RPG::EventPage::Frame_left) {
				if (pattern == RPG::EventPage::Frame_right) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_right;
				} else {
					pattern = RPG::EventPage::Frame_right;
				}
			} else {
				if (pattern == RPG::EventPage::Frame_left) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_left;
				} else {
					pattern = RPG::EventPage::Frame_left;
				}
			}
		}

		anime_count = 0;
	}

	if (wait_count > 0) {
		wait_count -= 1;
		return;
	}

	if (stop_count >= ((GetMoveFrequency() > 7) ? 0 : pow(2.0, 9 - GetMoveFrequency()))) {
		if (IsMoveRouteOverwritten()) {
			MoveTypeCustom();
		} else if (Game_Message::GetContinueEvents() || !Game_Message::message_waiting) {
			UpdateSelfMovement();
		}
	}
}
예제 #29
0
void MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
                   const wxPoint& aOffset )
{
    if( (m_Flags & DO_NOT_DRAW) || (IsMoving()) )
        return;

    for( D_PAD* pad = m_Pads;  pad;  pad = pad->Next() )
    {
        if( pad->IsMoving() )
            continue;

        pad->Draw( aPanel, aDC, aDrawMode, aOffset );
    }

    BOARD* brd = GetBoard();

    // Draws footprint anchor
    DrawAncre( aPanel, aDC, aOffset, DIM_ANCRE_MODULE, aDrawMode );

    // Draw graphic items
    if( brd->IsElementVisible( MOD_REFERENCES_VISIBLE ) )
    {
        if( !(m_Reference->IsMoving()) )
            m_Reference->Draw( aPanel, aDC, aDrawMode, aOffset );
    }

    if( brd->IsElementVisible( MOD_VALUES_VISIBLE ) )
    {
        if( !(m_Value->IsMoving()) )
            m_Value->Draw( aPanel, aDC, aDrawMode, aOffset );
    }

    for( BOARD_ITEM* item = m_Drawings;  item;  item = item->Next() )
    {
        if( item->IsMoving() )
            continue;

        switch( item->Type() )
        {
        case PCB_MODULE_TEXT_T:
        case PCB_MODULE_EDGE_T:
            item->Draw( aPanel, aDC, aDrawMode, aOffset );
            break;

        default:
            break;
        }
    }

    // Enable these line to draw m_BoundaryBox (debug tests purposes only)
#if 0
    GRRect( aPanel->GetClipBox(), aDC, m_BoundaryBox, 0, BROWN );
#endif

}
예제 #30
0
 const CPositionRotationAnimation* CObject::GetMoveAnimation ( )
 {
     if ( IsMoving () ) //Call IsMoving since it will make sure the anim is stopped if it's finished
     {        
         return m_pMoveAnimation;
     }
     else
     {
         return NULL;
     }
}