# cNPC Class Reference

Inheritance diagram for cNPC:

List of all members.

## Public Member Functions

| cNPC (DWORD dwGUID, DWORD dwNPCModelID, char *szName, WORD wGender, cLocation *pcLoc=NULL, DWORD dwSellCategories=0x00000000)
void | Assess (cClient *pcAssesser)
cMessage | CreatePacket ()
void | Action (cClient *who)
void | GiveItem (cClient *who, DWORD itemid, DWORD npcid)
void | BuyItem (cClient *who, DWORD VendorID, DWORD ItemID)
void | ApproachVendor (cClient *who)
void | SetMode (DWORD mode)
void | SetModel (WORD wNPCModel)
void | SetNumMessages (int num)
int | GetNumMessages ()
DWORD | GetMode ()
void | SetIsVendor (int vend)
int | GetIsVendor ()
void | Set_npc_id (int npcid)
int | Get_npc_id ()
void | SetString (std::string str, int index)
void | AddInventory (cObject *pcObject)
void | RemoveInventory (cObject *pcObject)
cObject * | FindInventory (DWORD dwGUID)
void | DeleteFromInventory (cObject *pcObject)

## Public Attributes

DWORD | m_dwNPCModelID
cObjStats | m_NPCStats
DWORD | m_qitem_id1
DWORD | m_npc_target_id
DWORD | v_guids [255]
std::list< cNPC * > | npc_ids

## Friends

class | cClient

## Constructor & Destructor Documentation

cNPC::cNPC | ( | DWORD | dwGUID,
|  | DWORD | dwNPCModelID,
|  | char * | szName,
|  | WORD | wGender,
|  | cLocation * | pcLoc = `NULL`,
|  | DWORD | dwSellCategories = `0x00000000` |
| ) |  |  |

A constructor.

Called whenever an NPC object is initialized.

Handles the creation of NPCs.

Called whenever an NPC object should be initialized.

## Member Function Documentation

void cNPC::Action | ( | cClient * | who | ) | `[virtual]`

Handles the actions of NPC objects.

This function is called whenever an NPC is used or should perform an general action.

Author: Cubem0j0

Implements cObject.

void cNPC::ApproachVendor | ( | cClient * | who | ) |

Handles trade interaction with vendor NPCs.

This function is called whenever a player approaches a vendor.

Parameters:

  | *who | - A pointer to the client whose avatar approaching the vendor.

void cNPC::Assess | ( | cClient * | pcAssesser | ) | `[virtual]`

Handles the assessment of NPC objects.

This function is called whenever an NPC is assessed by a client. Returns a Game Event (0x0000F7B0) server message of type Identify Object (0x000000C9).

Reimplemented from cObject.

void cNPC::BuyItem | ( | cClient * | pcClient,
|  | DWORD | VendorID,
|  | DWORD | ItemID |
| ) |  |  |

Handles the purchasing of items from NPC objects.

This function is called whenever a player buys an item from an NPC.

Parameters:

  | *pcClient | - A pointer to the client whose avatar is purchasing the item.
  | VenderID | - A the GUID of the vendor.
  | ItemID | - The GUID of the object to buy.

cMessage cNPC::CreatePacket | ( |  | ) | `[virtual]`

Handles the message sent for the creation of NPCs.

This function is called whenever an NPC should be created for a client.

Returns:
  cMessage - Returns a Create Object (0x0000F745) server message.

Implements cObject.

void cNPC::GiveItem | ( | cClient * | who,
|  | DWORD | npcid,
|  | DWORD | itemid |
| ) |  |  |

Handles the giving of items to NPCs.

This function is called whenever a player gives an NPC an item. If the NPC is a Town Crier, the NPC should access the item. Other NPCs should only accept particular items or types of items.

Parameters:

  | *who | - A pointer to the client whose avatar is giving the item.
  | itemid | - The GUID of the item being given.

The documentation for this class was generated from the following files:

- E:/uas2/Server/Object.h
- E:/uas2/Server/cNPC.cpp