Esempio n. 1
0
void RedIsolationPickupAutonomous()
{
  SensorValue[Gyroscope] = 0;
  StartTask(KeepArmInPosition);

  armPosition = minArm;
  Intake(127);
  Forward(45, 125, "none");
  StopMoving();


  Backward(127, 90, "none");
  Intake(0);
  StopMoving();

  TurnLeftDegrees(40);

  armPosition = midGoalHeight;
  wait10Msec(70);
  Intake(127);
  Forward(100, 60, "none");
  StopMoving();
  armPosition = midGoalHeight - 100;
  wait10Msec(50);
  StopTask(KeepArmInPosition);

  StopArm();

  StartTask(StayInPosition);
  wait10Msec(500);
  Intake(0);
  wait10Msec(1000);
  StopTask(StayInPosition);
}
Esempio n. 2
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 );
    }
}
Esempio n. 3
0
void test(string input)
{
  if (strcmp(input, "forward") == 0)
  {
    StopMoving();
  }
}
Esempio n. 4
0
//////////////////////////////////////////////////////////////////////////////////////
//                                                                                  //
//                                 Autony Mouses                                    //
//                                                                                  //
//////////////////////////////////////////////////////////////////////////////////////
void InteractionInterceptionAutonomous()
{
  SensorValue[Gyroscope] = 0;
  Intake(127);
  Backward(127, 90, "none");
  StopMoving();
  Intake(0);
  StartTask(StayInPosition);
	wait10Msec(1500);
	StopTask(StayInPosition);
	Backward(127, 25, "none");
	StopMoving();
	StartTask(StayInPosition);
	wait10Msec(500);
	StopTask(StayInPosition);
}
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();
}
Esempio n. 6
0
void Creature::setDeathState(DeathState s)
{
    if(s == JUST_DIED)
    {
        m_deathTimer = m_corpseDelay*1000;

        // always save boss respawn time at death to prevent crash cheating
        if(sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY) || isWorldBoss())
            SaveRespawnTime();

        if(!IsStopped()) StopMoving();
    }
    Unit::setDeathState(s);

    if(s == JUST_DIED)
    {
        SetUInt32Value(UNIT_NPC_FLAGS, 0);
        if(!isPet() && GetCreatureInfo()->SkinLootId)
        {
            LootStore skinStore = LootTemplates_Skinning;
            LootStore::iterator tab = skinStore.find(GetCreatureInfo()->SkinLootId);
            if ( tab != skinStore.end() )
                SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
        }
        Unit::setDeathState(CORPSE);
    }
}
Esempio n. 7
0
bool CSDKBot::ThinkReload_End() {
	m_curCmd.buttons &= ~IN_RELOAD;
	m_flEndRetreatTime = FLT_MAX;
	m_flNextStrafeTime = FLT_MAX;
	StopMoving();
	return true;
}
Esempio n. 8
0
bool CSDKBot::ThinkFlag() {
	CFlag* pFlag = m_PlayerSearchInfo.CloseEnemyFlagVisible();

	if (IsCapturingEnemyFlagAttempt()) {
		if (!m_bLastThinkWasInFlag) {
			m_bLastThinkWasInFlag = true;
			if (bot_randfloat() < 0.4f && ShouldReload()) {
				m_curCmd.buttons |= IN_RELOAD;
			}
			m_flNextStrafeTime = gpGlobals->curtime;
		}

		CBasePlayer* pEnemy = m_PlayerSearchInfo.CloseEnemy();
		if (pEnemy) {
			LookAt(pEnemy->Weapon_ShootPosition(), 0.7f, 3);
			if (pFlag)
				DanceAround(pFlag->GetAbsOrigin(), pFlag->m_flCaptureRadius);
			if (bot_randfloat() < 0.3f)
				m_flNextFireTime = gpGlobals->curtime;
		}
		else {
			StopMoving();
		}
	} else {
		m_bLastThinkWasInFlag = false;

		if (pFlag) {
			m_curCmd.buttons |= IN_FORWARD;
			LookAt(pFlag->GetAbsOrigin() + g_vUpFromFlag, 0.8f, 5);
		}
		TeammateGoAround(true);
	}
	return true;
}
Esempio n. 9
0
void BulletParticle::SignalRebound()
{
  PhysicalObj::SignalRebound();
  //SetCollisionModel(false, false, false);
  StopMoving();
  start_to_fade = Time::GetInstance()->Read();
}
Esempio n. 10
0
void NPC::TakeAction(BasicAction action, int timeElapsedMs)
{
	//TODO: terrible code, consider using references
	switch (action)	{
	case eAttack: {
		StopMoving();
		StartAttack(); //TODO: might need to override
		break;
	}	
	case eMove: { //compiler mistook this for the Move() method..
		// reset speed to normal
		if (m_flags[eAffectedByGravity] && !m_flags[eJumping] && !m_flags[eFalling]) {
			m_speeds[eXSpeed] = m_speedX;
			m_speeds[eYSpeed] = m_speedY;
		}
		StartMoving(GetDirection());
		break;
	}	
	case eFlee: {
		// reset speed to normal
		if (m_flags[eAffectedByGravity] && !m_flags[eJumping] && !m_flags[eFalling]) {
			m_speeds[eXSpeed] = m_speedX;
			m_speeds[eYSpeed] = m_speedY;
		}
		//avoid colliding with the character
		//TODO: WHAT? This makes no sense (even before refactor)
		StartMoving(m_direction == eLeft ? eRight : eLeft);
		break;
	}	
	case eJump: {
		StartJump();
		break;
	}
	case eShoot: {
		Shoot(m_attackType);
		break;
	}
	default: {
		StopMoving();
		if (!m_flags[eAffectedByGravity]) {
			m_speeds[eXSpeed] = 0;
			m_speeds[eYSpeed] = 0;
		}
		break;
	}
	}
}
Esempio n. 11
0
void NewRoom(int nrnum) {
    if (nrnum < 0)
        quitprintf("!NewRoom: room change requested to invalid room number %d.", nrnum);

    if (displayed_room < 0) {
        // called from game_start; change the room where the game will start
        playerchar->room = nrnum;
        return;
    }


    DEBUG_CONSOLE("Room change requested to room %d", nrnum);
    EndSkippingUntilCharStops();

    can_run_delayed_command();

    if (play.stop_dialog_at_end != DIALOG_NONE) {
        if (play.stop_dialog_at_end == DIALOG_RUNNING)
            play.stop_dialog_at_end = DIALOG_NEWROOM + nrnum;
        else {
            quitprintf("!NewRoom: two NewRoom/RunDialog/StopDialog requests within dialog; last was called in \"%s\", line %d",
                last_in_dialog_request_script_pos.Section.GetCStr(), last_in_dialog_request_script_pos.Line);
        }
        return;
    }

    get_script_position(last_in_dialog_request_script_pos);

    if (in_leaves_screen >= 0) {
        // NewRoom called from the Player Leaves Screen event -- just
        // change which room it will go to
        in_leaves_screen = nrnum;
    }
    else if (in_enters_screen) {
        setevent(EV_NEWROOM,nrnum);
        return;
    }
    else if (in_inv_screen) {
        inv_screen_newroom = nrnum;
        return;
    }
    else if ((inside_script==0) & (in_graph_script==0)) {
        new_room(nrnum,playerchar);
        return;
    }
    else if (inside_script) {
        curscript->queue_action(ePSANewRoom, nrnum, "NewRoom");
        // we might be within a MoveCharacterBlocking -- the room
        // change should abort it
        if ((playerchar->walking > 0) && (playerchar->walking < TURNING_AROUND)) {
            // nasty hack - make sure it doesn't move the character
            // to a walkable area
            mls[playerchar->walking].direct = 1;
            StopMoving(game.playercharacter);
        }
    }
    else if (in_graph_script)
        gs_to_newroom = nrnum;
}
Esempio n. 12
0
void PhysicalObj::Init()
{
  if (m_alive != ALIVE)
    MSG_DEBUG("physic.state", "%s - Init.", GetName().c_str());
  m_alive = ALIVE;
  SetOverlappingObject(NULL);
  StopMoving();
}
Esempio n. 13
0
void InteractionAntiWallBot1Autonomous()
{
  SensorValue[Gyroscope] = 0;
  Forward(127, 140, "none");
  StopMoving();
  StartTask(StayInPosition);
	wait10Msec(2000);
	StopTask(StayInPosition);
}
Esempio n. 14
0
void Character::UpdatePos()
{
    float Dtime = Delta.GetTime();
    Delta.Start();
    //if(Dtime > 0) Log << Dtime << std::endl;

    if(Input->GetKeyState(SDLK_UP) == true) Move(s_Motion::UP, Dtime);
    if(Input->GetKeyState(SDLK_UP) == false) StopMoving(s_Motion::UP, Dtime);

    if(Input->GetKeyState(SDLK_LEFT) == true) Move(s_Motion::LEFT, Dtime);
    if(Input->GetKeyState(SDLK_LEFT) == false) StopMoving(s_Motion::LEFT, Dtime);

    if(Input->GetKeyState(SDLK_RIGHT) == true) Move(s_Motion::RIGHT, Dtime);
    if(Input->GetKeyState(SDLK_RIGHT) == false) StopMoving(s_Motion::RIGHT, Dtime);

    if(Input->GetKeyState(SDLK_DOWN) == true) Move(s_Motion::DOWN, Dtime);
    if(Input->GetKeyState(SDLK_DOWN) == false) StopMoving(s_Motion::DOWN, Dtime);
}
Esempio n. 15
0
void Player::OnKeyUp(const CL_InputEvent &key, const CL_InputState &state)
{
	if (m_flags[eDead]) {
		return;
	}

	//TODO: can this be turned into a switch-case without breaking logic?
	
	if (key.id == m_moveLeftKey) {
		m_moveLeftKeyPressed = false;

		//Handle case where both left and right are pressed before releasing left key
		if (m_moveRightKeyPressed) {
			StartMoving(eRight);			
		} else {
			StopMoving();
		}
	}
	
	if (key.id == m_moveRightKey) {
		m_moveRightKeyPressed = false;

		//Handle case where both left and right are pressed before releasing right key
		if (m_moveLeftKeyPressed) {
			StartMoving(eLeft);
		} else {
			StopMoving();
		}
			
	}

	if (key.id == m_jumpKey) {
		m_jumpKeyPressed = false;
		m_stats[eJumpTime] = m_stats[eMaxJumpTime];
	}

	if (key.id == m_attackKey) {
		m_attackKeyPressed = false;
	}
}
Esempio n. 16
0
void RedInteractionAntiWallBot2Autonomous()
{
  SensorValue[Gyroscope] = 0;
  StartTask(KeepArmInPosition);
  Intake(127);
  Forward(127, 20, "none");
  Intake(0);
  StopMoving();

  armPosition = 1200;
  VariableMove(127, -10, 90);
  StopMoving();

  turnLeft(127);
  wait10Msec(20);
  Forward(127, 40, "none");
  StopMoving();
  StartTask(StayInPosition);
  wait10Msec(2000);
  StopTask(StayInPosition);
  StopTask(KeepArmInPosition);
}
Esempio n. 17
0
void RedInteractionCurvyAutonomous()
{
  Intake(127);
  Forward(127, 40, "none");
  Intake(0);
  VariableMove(20, 127, 80);
  SensorValue[Gyroscope] = 0;
  Forward(127, 80, "none");
  StopMoving();
  StartTask(StayInPosition);
  wait10Msec(1500);
  StopTask(StayInPosition);
}
Esempio n. 18
0
void IsolationScoringAutonomous()
{
  SensorValue[Gyroscope] = 0;
	StartTask(KeepArmInPosition);

  armPosition = minArm;
  Intake(127);
  Forward(45, 135, "none");
  Backward(127, 35, "none");
  Intake(0);
  armPosition = midGoalHeight+50;
  Backward(127, 80, "none");
  StopMoving();

  while (SensorValue[Bump] == 0) {}

  Forward(65, 60, "none");
  StopMoving();
  wait10Msec(20);
  Intake(-127);
  wait10Msec(90);
  Intake(70);
  Backward(35, 30, "none");
  StopMoving();
  Intake(-127);
  wait10Msec(120);
  Intake(0);

  //VariableMove(-70, -20, 80);
  Backward(45, 20, "none");
  armPosition = minArm;
  Backward(45, 20, "none");
  StopMoving();
  wait10Msec(200);

  StopTask(KeepArmInPosition);

  StopArm();
}
Esempio n. 19
0
void Unit::Order_NukeUnit()
{
    if (target)
    {
        order_target_pos = target->sprite->position;
        Order_NukeGround();
    }
    else
    {
        StopMoving(this);
        OrderDone();
    }
}
Esempio n. 20
0
void PhysicalObj::Ghost()
{
  if (m_alive == GHOST)
    return;

  bool was_dead = IsDead();
  m_alive = GHOST;
  MSG_DEBUG("physic.state", "%s - Ghost, was_dead = %d", GetName().c_str(), was_dead);

  // The object became a gost
  StopMoving();

  SignalGhostState(was_dead);
}
Esempio n. 21
0
//-------------------------------------------------------------------------------------------------
// Purpose: This runs while reloading. Bot either retreats to teammate, retreats from enemy, or follows navpoints
//		Or stands still if at flag
//		@updates m_flEndRetreatTime - to ensure we don't leave before we've started reloading
//-------------------------------------------------------------------------------------------------
bool CSDKBot::ThinkReload_Begin() {
	SendBotVcommContext(BotContext::DEFAULT);
	m_curCmd.buttons |= IN_RELOAD;
	StopMoving();
	m_PlayerSearchInfo.UpdateNavpointFirst();

	//this is used to switch between looking away/toward enemy
	m_flNextStrafeTime = gpGlobals->curtime;

	//give us some time before we could even finish reloading
	m_flEndRetreatTime = gpGlobals->curtime + 3.0f;

	return true;
}
Esempio n. 22
0
void Unit::Order_NukeGround()
{
    unk_move_waypoint = order_target_pos;
    int sight_range = GetSightRange(false) * 32;
    int dist = Distance(exact_position, Point32(order_target_pos) * 256 + Point32(128, 128)) / 256;
    if (ai && dist <= sight_range * 3)
        Ai_Cloak();
    if (dist > sight_range)
    {
        if (move_target_update_timer == 0)
            ChangeMovementTarget(order_target_pos); // What, it is not moving?
    }
    else
    {
        StopMoving(this);
        if (position != unk_move_waypoint)
        {
            int diff = facing_direction - GetFacingDirection(sprite->position.x, sprite->position.y, unk_move_waypoint.x, unk_move_waypoint.y);
            if (diff < -1 || diff > 1)
                return;
        }
        Unit *silo = nullptr;
        for (Unit *unit : bw::first_player_unit[player])
        {
            if (unit->unit_id == NuclearSilo && unit->silo.has_nuke)
            {
                silo = unit;
                break;
            }
        }
        if (!silo)
        {
            OrderDone();
            return;
        }
        Unit *nuke = silo->silo.nuke;
        silo->silo.nuke = nullptr;
        silo->silo.has_nuke = 0;
        PlaySound(Sound::NukeLaser, this, 1, 0);
        IssueOrderTargetingGround(nuke, Order::NukeLaunch, order_target_pos.x, order_target_pos.y);
        related = nuke;
        nuke->related = this;
        nuke->sprite->SetDirection32(0);
        ShowUnit(nuke);
        IssueOrderTargetingGround(this, Order::NukeTrack, sprite->position.x, sprite->position.y);
        if (!IsDisabled() || units_dat_flags[unit_id] & UnitFlags::Building) // Huh?
            buttons = 0xed;
        RefreshUi();
    }
}
Esempio n. 23
0
bool CObject::IsMoving ( void )
{
    // Are we currently moving?
    if ( m_moveData.bActive )
    {
        // Should we have stopped moving by now?
        if ( GetTime () >= m_moveData.ulTimeStop )
        {
            // Stop our movement
            StopMoving ();
        }
    }
    // Are we still moving after the above check?
    return ( m_moveData.bActive );
}
Esempio n. 24
0
bool CObject::IsMoving ( void )
{
    // Are we currently moving?
    if ( m_pMoveAnimation != NULL )
    {
        // Should we have stopped moving by now?
        if ( !m_pMoveAnimation->IsRunning() )
        {
            // Stop our movement
            StopMoving ();
        }
    }
    // Are we still moving after the above check?
    return ( m_pMoveAnimation != NULL );
}
Esempio n. 25
0
bool CSDKBot::ThinkReload() {
	//Spam the reload button - the reload only happens when the button changes
	ToggleButton(IN_RELOAD);

	//if we're capturing a flag, don't do anything
	if (m_PlayerSearchInfo.CloseFriend() && IsCapturingEnemyFlagAttempt()) {
		StopMoving();
	} else if (m_PlayerSearchInfo.CloseEnemy() && m_PlayerSearchInfo.OutNumbered() > 0.35) {
		MoveAwayFromEnemy();
	} else if (m_PlayerSearchInfo.CloseFriend() && !m_PlayerSearchInfo.CloseFriend()->Weapon_InReload()) {
		MoveToNearestTeammate();
	} else {
		MoveToWaypoint();
	}
	return true;
}
Esempio n. 26
0
/******************************************************************************
 * Function Name: Reset();
 * Parameters: None
 * Returns: Boolean value based on if reseting is done.
 * - true: if the function is done reseting the tower.
 * - false: if the function is not done reseting the tower.
 * Descritpion: This function will move the tower back down to where it started
 * when the tower instance was created.
 ******************************************************************************/
bool Tower_Class::Reset()
{
	if(railClimbLimit->Get() == RELEASED)
	{
		ResetReach();
		ResetClimb();
		liftMotor->Set(MOTOR_CLIMB_VELOCITY);
		return false;
	}
	else
	{
		StopMoving();
		liftEncoder->Reset();
		return true;
	}
}
Esempio n. 27
0
void PhysicalObj::CheckRebound()
{
  // If we bounce twice in a row at the same place, stop bouncing
  // cause it's almost sure this object is stuck bouncing indefinitely
  if (m_rebound_position != Point2i(-1, -1)) {
    // allow infinite rebounds for Pendulum objects (e.g. characters on rope)
    // FIXME: test that nothing bad happens because of this
    if (Pendulum!=GetMotionType() && m_rebound_position==GetPosition()) {
      MSG_DEBUG("physic.state", "%s seems to be stuck in ground. Stop moving!",
                GetName().c_str());
      m_rebound_position = Point2i(-1, -1);
      StopMoving();
      return;
    }
  }
  m_rebound_position = GetPosition();
}
bool CSyncCoreObjectMediator::SetConnection( CSynConnServer* pConn )
{
	if( m_bDisbindingConn )
		return false;

	if( pConn == m_pConn )
		return true;

	if( !IsActive() )
	{
		StopFollowing();
	}

	if( IsMoving() )
		StopMoving();

	if( pConn )
	{
		if( pConn->GetObjectMediator() )
			GenErr( "CSyncCoreObjectMediator::SetConnnection failed, MediatorObject already binded on the connection." );
		
		if( m_pConn )
			GenErr( "CSyncCoreObjectMediator::SetConnectino failed, connection already binded." );

		IntSetConnection(pConn);
		m_pConn->SetMediator(this);
		
		SetClientMainScene();

		m_uAoiBlockCount++;
		IntPostMsgToSelf(new CAoiDecBlockCountCmd);

		CSyncCoreObjectServer::SetEyeSight( m_fZeroDimEyeSight,0 );
	}
	else
	{
		Ver( SetDisbindConnState() );

		IntPostMsgToSelf(new CAoiDisbindConnCmd);
	}

	return true;
}
Esempio n. 29
0
void TurnRightDegrees(float degrees)
{
  SensorValue[Gyroscope] = 0;
  while(abs(SensorValue[Gyroscope]) < abs(degrees) * 10 * 0.935)
  {
    if (abs(degrees) * 10 - abs(SensorValue[Gyroscope]) < 300)
      TurnRight(30);
    else if (abs(degrees) * 10 - abs(SensorValue[Gyroscope]) < 500)
      TurnRight(40);
    else if (abs(degrees) * 10 - abs(SensorValue[Gyroscope]) < 700)
      TurnRight(50);
    else
      TurnRight(60);

    if (stopEventFunction("none"))
      break;
  }
  StopMoving();
}
Esempio n. 30
0
void CObject::GetRotation ( CVector & vecRotation )
{
    vecRotation = m_vecRotation;

    // Are we attached to something?
    if ( m_pAttachedTo ) GetAttachedRotation ( vecRotation );

    // Are we moving?
    else if ( IsMoving () )
    {
        SPositionRotation positionRotation;
        bool bStillRunning = m_pMoveAnimation->GetValue ( positionRotation );
        m_vecRotation = positionRotation.m_vecRotation;
        if ( !bStillRunning )
        {
            StopMoving ();
        }
        vecRotation = m_vecRotation;
    }
}