CapabilitiesAdd

From Valve Developer Community
Jump to: navigation, search
Wikipedia - Letter.png
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)
Dead End - Icon.png
This article has no links to other VDC articles. Please help improve this article by adding links that are relevant to the context within the existing text.
January 2024

CapabilitiesAdd()

Tested on Source SDK 2013 Singleplayer

CapabilitiesAdd allows the programmer to add capabilities to npc's

if your npc's Spawn function you can add capabilities like so:

void CNPC_YourNPC::Spawn(void){

	Precache(); // Runs your npc's Precache function

	SetModel(STRING(GetModelName())); // Sets the model
	SetHullType(HULL_HUMAN);// Sets body type
	SetHullSizeNormal(); // Sets body size

	SetSolid(SOLID_BBOX); // Set collision type
	AddSolidFlags(FSOLID_NOT_STANDABLE); 
	SetMoveType(MOVETYPE_STEP); // Sets move type
	SetBloodColor(BLOOD_COLOR_RED); // Sets blood colour

	m_flFieldOfView = 0.5; // Unknown, sorry :(
	m_NPCState = NPC_STATE_NONE; // Sets NPC state

	// Remove all capabilities so we can add our own
	CapabilitiesClear();

	// Add capabilities
	CapabilitiesAdd(bits_CAP_MOVE_GROUND);	// NPC can walk/run
	CapabilitiesAdd(bits_CAP_MOVE_JUMP);	// NPC can jump/leap
	CapabilitiesAdd(bits_CAP_MOVE_CLIMB);	// NPC can climb ladders
	CapabilitiesAdd(bits_CAP_MOVE_SHOOT);	// NPC can shoot weapon while moving
	CapabilitiesAdd(bits_CAP_USE);			// NPC can open doors/push buttons/pull levers
	CapabilitiesAdd(bits_CAP_OPEN_DOORS);	// NPC can open manual doors
	CapabilitiesAdd(bits_CAP_AUTO_DOORS);	// NPC can trigger auto doors
	CapabilitiesAdd(bits_CAP_TURN_HEAD);	// NPC can turn head, always bone controller 0
	CapabilitiesAdd(bits_CAP_USE_WEAPONS);	// NPC can use weapons (non-innate attacks)
	CapabilitiesAdd(bits_CAP_AIM_GUN);		// NPC can use arms to aim gun, not just body
	CapabilitiesAdd(bits_CAP_DUCK);			// NPC can cover and reload ducking
	CapabilitiesAdd(bits_CAP_WEAPON_MELEE_ATTACK1 || bits_CAP_WEAPON_MELEE_ATTACK2);	// NPC can do weapon melee attack 1 & 2
	CapabilitiesAdd(bits_CAP_INNATE_MELEE_ATTACK1 || bits_CAP_INNATE_MELEE_ATTACK2);	// NPC can innate melee attack 1 & 2
	CapabilitiesAdd(bits_CAP_WEAPON_RANGE_ATTACK1 || bits_CAP_WEAPON_RANGE_ATTACK2);	// NPC can do weapon range attack 1 & 2
	CapabilitiesAdd(bits_CAP_INNATE_RANGE_ATTACK1 || bits_CAP_INNATE_RANGE_ATTACK2);	// NPC can innate range attack 1 & 2

	SetMoveType(MOVETYPE_STEP); // gravity, special edge handling -- monsters use this
	NPCInit();

}

Here is a list of capabilities in Source SDK 2013

located in basecombatcharacter.h

enum Capability_t 
{
	bits_CAP_MOVE_GROUND			= 0x00000001, // walk/run
	bits_CAP_MOVE_JUMP				= 0x00000002, // jump/leap
	bits_CAP_MOVE_FLY				= 0x00000004, // can fly, move all around
	bits_CAP_MOVE_CLIMB				= 0x00000008, // climb ladders
	bits_CAP_MOVE_SWIM				= 0x00000010, // navigate in water			// UNDONE - not yet implemented
	bits_CAP_MOVE_CRAWL				= 0x00000020, // crawl						// UNDONE - not yet implemented
	bits_CAP_MOVE_SHOOT				= 0x00000040, // tries to shoot weapon while moving
	bits_CAP_SKIP_NAV_GROUND_CHECK	= 0x00000080, // optimization - skips ground tests while computing navigation
	bits_CAP_USE					= 0x00000100, // open doors/push buttons/pull levers
	//bits_CAP_HEAR					= 0x00000200, // can hear forced sounds
	bits_CAP_AUTO_DOORS				= 0x00000400, // can trigger auto doors
	bits_CAP_OPEN_DOORS				= 0x00000800, // can open manual doors
	bits_CAP_TURN_HEAD				= 0x00001000, // can turn head, always bone controller 0
	bits_CAP_WEAPON_RANGE_ATTACK1	= 0x00002000, // can do a weapon range attack 1
	bits_CAP_WEAPON_RANGE_ATTACK2	= 0x00004000, // can do a weapon range attack 2
	bits_CAP_WEAPON_MELEE_ATTACK1	= 0x00008000, // can do a weapon melee attack 1
	bits_CAP_WEAPON_MELEE_ATTACK2	= 0x00010000, // can do a weapon melee attack 2
	bits_CAP_INNATE_RANGE_ATTACK1	= 0x00020000, // can do a innate range attack 1
	bits_CAP_INNATE_RANGE_ATTACK2	= 0x00040000, // can do a innate range attack 1
	bits_CAP_INNATE_MELEE_ATTACK1	= 0x00080000, // can do a innate melee attack 1
	bits_CAP_INNATE_MELEE_ATTACK2	= 0x00100000, // can do a innate melee attack 1
	bits_CAP_USE_WEAPONS			= 0x00200000, // can use weapons (non-innate attacks)
	//bits_CAP_STRAFE					= 0x00400000, // strafe ( walk/run sideways)
	bits_CAP_ANIMATEDFACE			= 0x00800000, // has animated eyes/face
	bits_CAP_USE_SHOT_REGULATOR		= 0x01000000, // Uses the shot regulator for range attack1
	bits_CAP_FRIENDLY_DMG_IMMUNE	= 0x02000000, // don't take damage from npc's that are D_LI
	bits_CAP_SQUAD					= 0x04000000, // can form squads
	bits_CAP_DUCK					= 0x08000000, // cover and reload ducking
	bits_CAP_NO_HIT_PLAYER			= 0x10000000, // don't hit players
	bits_CAP_AIM_GUN				= 0x20000000, // Use arms to aim gun, not just body
	bits_CAP_NO_HIT_SQUADMATES		= 0x40000000, // none
	bits_CAP_SIMPLE_RADIUS_DAMAGE	= 0x80000000, // Do not use robust radius damage model on this character.
};

#define bits_CAP_DOORS_GROUP    (bits_CAP_AUTO_DOORS | bits_CAP_OPEN_DOORS)
#define bits_CAP_RANGE_ATTACK_GROUP	(bits_CAP_WEAPON_RANGE_ATTACK1 | bits_CAP_WEAPON_RANGE_ATTACK2)
#define bits_CAP_MELEE_ATTACK_GROUP	(bits_CAP_WEAPON_MELEE_ATTACK1 | bits_CAP_WEAPON_MELEE_ATTACK2)