Thread: HL2DM bots...
View Single Post
Re: HL2DM bots...
Old
  (#99)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Re: HL2DM bots... - 29-12-2008

Can I ask how to gain access to this interface? (Is it made by valve ?)

Edit:

Actually no need,

see here:

http://wiki.alliedmods.net/Entity_Pr...es#Enumeration

use :

"CBasePlayer" and "m_iAmmo" for (int*) Ammo List

TF2 Ammo lists:

starting values in round brackets
ammo list index in square brackets

Code:
Scout
[1] Scatter gun (32)
[2] Pistol (36)
[3] ? (100)

Sniper
[1] Sniper Rifle (25)
[2] Auto Rifle (75)
[3] ? (100)

Soldier
[1] Rockets (16)
[2] Shotgun (32)
[3] ? (100) 

Demoman
[1] Grenades (16)
[2] Stickies (24)
[3] ? (100)

Medic
[1] ?Syringe Gun? (150)
[2] ?Syringe Gun? (150)
[3] ? (100)

HWGuy
[1] Minigun (200)
[2] Shotgun (32)
[3] ? (100)

Pyro
[1] Flame (200)
[2] Shotgun (32)
[3] (100)?

Spy
[1] ?  (20)
[2] Pistol (24)
[3] ? (100)

Engineer
[1] Shotgun (32)
[2] Pistol ? (200)
[3] Wrench ? (200)
e.g.

Code:
int *CClassInterface :: getAmmoList ( edict_t *edict )
{
	static unsigned int offset = 0;
 
	if (!offset)
		offset = findOffset("m_iAmmo","CBasePlayer");
	
	if (!offset)
		return NULL;
 
	IServerUnknown *pUnknown = (IServerUnknown *)edict->GetUnknown();

	if (!pUnknown)
	{
		return NULL;
	}
 
	CBaseEntity *pEntity = pUnknown->GetBaseEntity();

	return (int *)((char *)pEntity + offset);
}

unsigned int CClassInterface :: findOffset(const char *szType,const char *szClass)
{
	ServerClass *sc = UTIL_FindServerClass(szClass);
	SendProp *pProp = UTIL_FindSendProp(sc->m_pTable, szType);

	if ( pProp )
		return pProp->GetOffset();

	return 0;
}
use

"CBaseEntity" and "m_iTeamNum"

to get the team index (int)

Last edited by Cheeseh; 30-12-2008 at 02:24..
  
Reply With Quote