Advertisement

Human Bot Control (4 lazy ppl)

Started by August 02, 2003 01:18 PM
2 comments, last by T2k 21 years, 1 month ago
copy and paste this codepart into the Update Function of a new Bot to get usercontroll:
#define KeyDown(x) (GetAsyncKeyState(x) & 0x8000 ? 1 : 0)

	if(KeyDown(VK_SPACE))
		g_pCore->Fire();
	if(KeyDown(VK_UP))
		if(KeyDown(VK_SHIFT))
			g_pCore->SetSpeed(SET_HIGH_SPEED);
		else
			g_pCore->SetSpeed(SET_NORMAL_SPEED);
	else
		if(KeyDown(VK_DOWN))
			g_pCore->SetSpeed(SET_REVERSE_SPEED);
		else
			g_pCore->SetSpeed(SET_NO_SPEED);

	if(KeyDown(VK_LEFT))
		if(KeyDown(VK_CONTROL))
			if(KeyDown(VK_SHIFT))
				g_pCore->TurnLeft(TURN_FAST);
			else
				g_pCore->TurnLeft(TURN_SLOW);
		else
			g_pCore->Strafe(STRAFE_LEFT);
	if(KeyDown(VK_RIGHT))
		if(KeyDown(VK_CONTROL))
			if(KeyDown(VK_SHIFT))
				g_pCore->TurnRight(TURN_FAST);
			else
				g_pCore->TurnRight(TURN_SLOW);
		else
		g_pCore->Strafe(STRAFE_RIGHT);

	if(KeyDown('1'))
		g_pCore->SelectWeapon(WEAPON_GUN);
	if(KeyDown('2'))
		g_pCore->SelectWeapon(WEAPON_COCKTAIL);
usage: '1'= Laser '2'= Grenade Space Fire Cursor Controls Bot with Strafe, holding down STRG changes strafe to rotate, holding down shift changes speed to fast versions no grenadeange, bcuz i dont know limits of the angles... T2k [edited by - T2k on August 2, 2003 2:19:45 PM]
Heh. And here I was thinking I was going to have to write some directinput implementation or something.
Advertisement
Thanks. I just finished writing one EXACTLY like that

[twitter]warrenm[/twitter]

This is pretty cool.. I would just create a function, though. No need to have a massive Update(). And yes, you can create classes inside your bot and call those classes from the Update(). You can do whatever you want in that respect.

Admin for GameDev.net.

This topic is closed to new replies.

Advertisement