コード例 #1
0
ファイル: PMotion.cpp プロジェクト: dogshoes/map-n-zap
void CPMotion::ZigZag(short Velocity, short Delay, short Iterations)
{
    //OK
    m_Robot->SetMaxSpeed(360);
    double OriginalHeading = m_Robot->GetHeading();
    double Angle1 =  pi / 12;
    double Angle2 = -pi / 6;
    double Angle3 = pi / 6;

    TurnToAngle(Velocity, OriginalHeading, Angle1);
    SWait(1);

    for (int i = 1; i < Iterations; i++)
    {
        MoveForwardNS(Velocity, 2);
        TurnToAngle(Velocity, OriginalHeading, Angle2);
        MoveForwardNS(Velocity, 2);
        TurnToAngle(Velocity, OriginalHeading, Angle3);
    }

    MoveForward(Velocity, 1);
    m_Robot->SetHeadingDestination(OriginalHeading, Velocity, 2);
    SWait(Delay);
    m_Robot->Stop();

}
コード例 #2
0
ファイル: BOT.C プロジェクト: ioan-chera/AutoWolf-DOS
void DoCombatAI(int angle, int distance)
{
	int dangle = CentreAngle(angle, player->angle);
	static int inc;
	objtype* check;
	WRITELOG((logfile, "DoCombatAI: angle=%d player->angle=%d dangle=%d\n", angle, player->angle, dangle))
	TurnToAngle(dangle);
	check = GunSightTarget();
	++inc;
	if(check)
	{
		if(distance <= DISTANCE_SHOOT)
			if(gamestate.weapon <= wp_pistol)
				buttonstate[bt_attack] = (boolean)(inc % 2);
			else
				buttonstate[bt_attack] = true;
		if(distance > DISTANCE_CHARGE || gamestate.weapon == wp_knife)
			controly = -RUNMOVE * tics;
	}
}
コード例 #3
0
ファイル: DriveTrain.cpp プロジェクト: nzbzny/Stronghold
void DriveTrain::TurnToRelativeAngle(float angle) {
	TurnToAngle(angle + position->GetAngle());
}
コード例 #4
0
ファイル: BOT.C プロジェクト: ioan-chera/AutoWolf-DOS
void DoNonCombatAI(void)
{
	static boolean waitpwall;
	word nowon, nexton, mypos, nx, ny;
	fixed nxd, nyd;
	byte tile;
	int tangle, dangle;
	boolean tryuse;
	objtype* check;
	static int inc;
	inc++;

	if(!destination)
		destination = FindShortestPath();
	if(!destination)
		return;
	if(pwallstate)
		waitpwall = true;
	mypos = TILE_ENCODE(player->tilex, player->tiley);
	nowon = nexton = WORD_MAX;
	for(nowon = destination; nowon != WORD_MAX;
	    nexton = nowon, nowon = path_prev[nowon])
	{
		if(nowon == mypos)
			break;
	}
	if(nowon == WORD_MAX || (!pwallstate && waitpwall))
	{
		waitpwall = false;
		destination = 0;
		return;
	}
	if(nexton == WORD_MAX)
	{
//		prevon = path_prev[nowon];
		destination = 0;
		nx = pushtargetx;
		ny = pushtargety;
	}
	else
	{
		nx = TILE_DECODE_X(nexton);
		ny = TILE_DECODE_Y(nexton);
		tile = tilemap[nx][ny];
		if(tile & 0x80)
		{
			tile &= ~0x80;
			if(!CanGoThruLockedDoor(tile))
			{
				destination = 0;
				return;
			}
			tryuse = (doorobjlist[tile].action == dr_closed
			       || doorobjlist[tile].action == dr_closing);
		}
	}
	tangle = DirAngle(player->x, player->y, ((fixed)nx << TILESHIFT)
	    + TILEGLOBAL/2, ((fixed)ny << TILESHIFT) + TILEGLOBAL / 2);
	dangle = CentreAngle(tangle, player->angle);
	if(dangle > -ANGLE_FOV && dangle < ANGLE_FOV)
	{
		controly = -RUNMOVE * tics;
		if(tryuse)
		{
			check = actorat[nx][ny];
			if(check && check < objlist && inc % 2)
				buttonstate[bt_use] = true;
		}
	}
	TurnToAngle(dangle);
}