can anybody tell me whats wrong w/ this

New Member
Joined
Nov 28, 2002
Messages
11
Best answers
0
void CBot::BotFindItem( void )
{
CBaseEntity *pEntity = NULL;
CBasePlayerItem *pItem = NULL;
float radius = 100;

while ((pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, radius )) != NULL)
{
// check to make sure that the entity is visible and in field of view...
if (FVisible( pEntity ) && FInViewCone( pEntity ))
{
// check if entity is a weapon...
if (strncmp("weapon_", STRING(pEntity->pev->classname), 7) == 0)
{
CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)pEntity;

if ((pWeapon->m_pPlayer) || (pWeapon->pev->effects & EF_NODRAW))
{
// someone owns this weapon or it hasn't respawned yet
continue;
}

if (g_pGameRules->CanHavePlayerItem( this, pWeapon ))
{
// let's head off toward that item...
Vector v_item = pEntity->pev->origin - pev->origin;
pev->v_angle = UTIL_VecToAngles( v_item );
}
}

// check if entity is ammo...
if (strncmp("ammo_", STRING(pEntity->pev->classname), 5) == 0)
{
CBasePlayerAmmo *pAmmo = (CBasePlayerAmmo *)pEntity;
char ammo_name[40];
int i;
BOOL can_pickup = FALSE;

// check if the item is not visible (i.e. has not respawned)
if (pAmmo->pev->effects & EF_NODRAW)
continue;

strcpy(ammo_name, STRING(pEntity->pev->classname));

i = 0;
while (ammo_check.ammo_name[1])
{
if (strcmp(ammo_check.ammo_name, ammo_name) == 0)
{
// see if we can pick up this item...
if (g_pGameRules->CanHaveAmmo( this,
ammo_check.weapon_name, ammo_check.max_carry))
{
can_pickup = TRUE;
break;
}
}

i++;
}

if (can_pickup)
{
// let's head off toward that item...
Vector v_item = pEntity->pev->origin - pev->origin;
pev->v_angle = UTIL_VecToAngles( v_item );
}
}

// check if entity is a battery...
if (strcmp("item_battery", STRING(pEntity->pev->classname)) == 0)
{
CItem *pBattery = (CItem *)pEntity;

// check if the item is not visible (i.e. has not respawned)
if (pBattery->pev->effects & EF_NODRAW)
continue;

// check if the bot can use this item...
if ((pev->armorvalue < MAX_NORMAL_BATTERY) &&
(pev->weapons & (1<< WEAPON_SUIT)))
{
// let's head off toward that item...
Vector v_item = pEntity->pev->origin - pev->origin;
pev->v_angle = UTIL_VecToAngles( v_item );
}
}

// check if entity is a healthkit...
if (strcmp("item_healthkit", STRING(pEntity->pev->classname)) == 0)
{
CItem *pHealthKit = (CItem *)pEntity;

// check if the item is not visible (i.e. has not respawned)
if (pHealthKit->pev->effects & EF_NODRAW)
continue;

// check if the bot can use this item...
if (pev->health <= 90)
{
// let's head off toward that item...
Vector v_item = pEntity->pev->origin - pev->origin;
pev->v_angle = UTIL_VecToAngles( v_item );
}
}

// check if entity is a packed up weapons box...
if (strcmp("weaponbox", STRING(pEntity->pev->classname)) == 0)
{
// let's head off toward that item...
Vector v_item = pEntity->pev->origin - pev->origin;
pev->v_angle = UTIL_VecToAngles( v_item );
}
}
}
}
 
New Member
Joined
Nov 28, 2002
Messages
11
Best answers
0
all four errors come up on that one line
C:\SIERRA\Half-Life\SDK\Multiplayer Source\dlls\bot.cpp(573) : error C2065: 'ammo_check' : undeclared identifier
C:\SIERRA\Half-Life\SDK\Multiplayer Source\dlls\bot.cpp(573) : error C2109: subscript requires array or pointer type
C:\SIERRA\Half-Life\SDK\Multiplayer Source\dlls\bot.cpp(573) : error C2228: left of '.ammo_name' must have class/struct/union type
C:\SIERRA\Half-Life\SDK\Multiplayer Source\dlls\bot.cpp(573) : fatal error C1903: unable to recover from previous error(s); stopping compilation
 
New Member
Joined
Nov 24, 2001
Messages
692
Best answers
0
Well, i don't know. What kinda type is ammo_check? And not to be rude or anything, but you might wanna learn C++ before messing with the SDK....
 

Users who are viewing this thread

Top Bottom