Skip to main content
GameDev.net gamedev.net
🔒 Locked

Human Bot Control (4 lazy ppl)

Started by T2k Aug 2, 2003 at 1:18 PM 2 replies 1k views
Original Post
T2k
T2k
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]
Xgkkp
Xgkkp
Heh. And here I was thinking I was going to have to write some directinput implementation or something.
zealouselixir
zealouselixir
Thanks. I just finished writing one EXACTLY like that
[twitter]warrenm[/twitter]
khawk
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.