The "server" API Set

This API set encapsulates general game attribues and global operations. I will only list new API's that were added in D2Hackit 2.00. API's those exist since older versions of D2Hackit are assumed well known.

General Game Attributes

Inter-Module Communication

Information Printing Functions

Unit Functions

Item Functions

Pathing Functions

Misc Functions


DWORD GetPing();

Return Value

The function returns current ping value.

Remarks

Retrieve current network ping value. Ping values are used for detecting lag, the higher the ping, the worse the lag.


LPCSTR GetRealmName();

Return Value

If suceeded, the function returns pointer to a null-terminated string which contains realm name, otherwise it returns zero.

Remarks

Retrieve realm name.


LPCSTR GetGameIP();

Return Value

If suceeded, the function returns pointer to a null-terminated string which contains game IP, otherwise it returns zero.

Remarks

Retrieve current game server IP.


LPCSTR GetGameName();

Return Value

If suceeded, the function returns pointer to a null-terminated string which contains game name, otherwise it returns zero.

Remarks

Retrieve current game name.


LPCSTR GetGamePassword();

Return Value

If suceeded, the function returns pointer to a null-terminated string which contains game password, otherwise it returns zero.

Remarks

Retrieve current game password.


LPCSTR GetModuleDirectory();

Return Value

The function returens pointer to a null-terminated string which contains module directory.

Remarks

Retrieve directory where D2Hackit resides.


BOOL IsClientLoaded(LPCSTR lpszClientName);

Return Value

The function returns non-zero if the d2h module was loaded, zero otherwise.

Parameters

lpszClientName

Pointer to a null-terminated string which contains name of the module to be examed. Note that module file extension, usually ".d2h", shall not be included in lpszClientName.

Remarks

Determine whether a pariticular module was loaded.


BOOL GameInfof(LPCSTR lpszFormat, ...);
BOOL GameErrorf(LPCSTR
lpszFormat, ...);
BOOL GameStringf(LPCSTR
lpszFormat, ...);
BOOL GameCommandf(LPCSTR
lpszFormat, ...);

Return Value

The functions return non-zero if succeeds, zero otherwise.

Parameters

lpszFormat

Pointer to a null-terminated string which contains the format specifications.

Remarks

These functions will first format a given string, then call GamePrintInfo, GamePrintError, GamePrintString, GameCommandLine and pass in the formatted string. For example, if you want to print an integer value to the screen, you no longer need to declare a string buffer, then format the string using sprintf, then print it, instead, you can simply call server->GameInfof("My value is: %d", nValue); for significant code length reduction.


BOOL GamePrintPacket(BOOL bReceived, const BYTE *aPacket, DWORD aLen);

Return Value

The function returns non-zero if succeeds, zero otherwise.

Parameters

bReceived

Specifies whether the packet is received or sent.

aPacket

Packet data block.

aLen

Specifies the packet length, in bytes.

Remarks

Print packet contents to screen.


BOOL IsGameReady();

Return Value

The function returns non-zero if the game is ready to be operated, zero otherwise.

Remarks

When the player joins a game, the game doesn't become ready immediately, there will be a few seconds of delay until all necessary data are received or loaded by the game client. Your modules should not operate the player until the game is ready.


BOOL EnumUnits(DWORD dwUnitType, fnEnumUnitProc lpfnEnumUnitProc, LPARAM lParam = 0);

Return Value

The function returns non-zero if succeeds, zero otherwise.

Parameters

dwUnitType

Specifies type of the game units that are to be enumerated. Please check Unit Types for a complete list of game unit types.

lpfnEnumUnitProc

Pointer to a fnEnumUnitProc function which will receive unit data.

lParam

A 32-bit application defined value.

Remarks

Enumerate all existing game units whose unit type equal to dwUnitType.


typedef BOOL (CALLBACK *fnEnumUnitProc)(LPCGAMEUNIT lpUnit, LPARAM lParam)

Return Value

Return zero to abort unit enumeration, return non-zero to continue.

Parameters

lpUnit

Pointer to a GAMEUNIT struct.

lParam

A 32-bit application defined value.

Remarks

Process each unit data passed from EnumUnit.


BOOL VerifyUnit(LPCGAMEUNIT lpUnit);

Return Value

The function returns non-zero if the unit data is valid, zero otherwise.

Parameters

lpUnit

Pointer to a GAMEUNIT struct.

Remarks

Verify an unit data, if the unit does not exist or is invalid, this function will fail.


BOOL FindUnitByClassID(DWORD dwUnitClassID, DWORD dwUnitType, LPGAMEUNIT lpBuffer);

Return Value

The function returns non-zero if the unit has been found, zero otherwise.

Parameters

dwUnitClassID

Specifies unit class ID. If there are multiple units with same class ID, the first matched unit in the game unit chain will be used.

dwUnitType

Specifies type of the game unit that is to be found. Please check Unit Types for a complete list of game unit types.

lpBuffer

Pointer to a GAMEUNIT struct which will receive the unit's data if the unit is found.

Remarks

Find a game unit whose class ID equals to dwUnitClassID and unit type equals to dwUnitType. Class ID's identify units' base types.


BOOL FindUnitByName(LPCSTR lpszUnitName, DWORD dwUnitType, LPGAMEUNIT lpBuffer);

Return Value

The function returns non-zero if the unit has been found, zero otherwise.

Parameters

lpszUnitName

Pointer to a null-terminated string which contains name of the unit to be found. If there are multiple units with same name, the first matched unit in the game unit chain will be used.

dwUnitType

Specifies type of the game unit that is to be found. Please check Unit Types for a complete list of game unit types.

lpBuffer

Pointer to a GAMEUNIT struct which will receive the unit's data if the unit is found.

Remarks

Find a game unit whose name matches lpszUnitName and unit type equals to dwUnitType. Unit names are case-insensitive.


POINT GetUnitPosition(LPCGAMEUNIT lpUnit);

Return Value

The function returns the unit's map position if the unit is found, otherwise it returns {0,0}.

Parameters

lpUnit

Pointer to a GAMEUNIT struct.

Remarks

Retrieves map position of a pariticular game unit.


DWORD GetUnitName(LPCGAMEUNIT lpUnit, LPSTR lpszBuffer, DWORD dwMaxChars);

Return Value

If succeeded, the function returns length of the unit name, otherwise it returns zero.

Parameters

lpUnit

Pointer to a GAMEUNIT struct.

lpszBuffer

Pointer to a null-terminated string which will receive the unit's name.

dwMaxChars

Specifies the maximum buffer size, in char's. 

Remarks

Retrieves name of a particular game unit.


DWORD GetUnitOwnerID(LPCGAMEUNIT lpUnit);

Return Value

The function returns ID of the unit's owner if succeeds, -1 otherwise.

Parameters

lpUnit

Pointer to a GAMEUNIT struct.

Remarks

Retrieves ID of the unit owner, only works for monsters. This can be used to determine whether a mercenary belongs to a player. Global units that do not have any owner will have -1(0xffffffff) as owner ID.


DWORD GetUnitClassID(LPCGAMEUNIT lpUnit);

Return Value

The function returns class ID of the unit if succeeds, zero otherwise.

Parameters

lpUnit

Pointer to a GAMEUNIT struct.

Remarks

Retrieve class ID of a particular game unit. Class ID's identify units' base types.


BYTE GetUnitHPPercent(LPCGAMEUNIT lpUnit);

Return Value

The function returns unit's remaining life percent.

Parameters

lpUnit

Pointer to a GAMEUNIT struct.

Remarks

Retrieve life percent of a particular game unit, return value ranges from 0 to 100.


DWORD GetUnitStat(LPCGAMEUNIT lpUnit, int nStatID);

Return Value

The function returns unit's stat value specified by nStatID.

Parameters

lpUnit

Pointer to a GAMEUNIT struct.

nStatID

ID of the stat to return. Please check Unit Stat Definition for a complete list of unit stat ID's.

Remarks

Retrieve a particular stat value of the unit. This function can be used to retrieve any unit stats such as HP, max HP, mana, max mana, magic find, IAS, fast run, fast cast, resists, absorbs, etc. You may even use this function to retrieve stats of other players, but do not abuse it and ruin the PVP!


BOOL GetUnitAffection(LPCGAMEUNIT lpUnit, int nAffectionID);

Return Value

The function returns non-zero if the unit is affected by the affection specified by nAffectionID, zero otherwise.

Parameters

lpUnit

Pointer to a GAMEUNIT struct.

nAffectionID

ID of the affection. Please check Unit Affection Definition for a complete list of unit affection ID's.

Remarks

Check whether the unit is affected by a particular affection. Affections are states that can affect game units, such as poisoned, chilled, all passive skills, auras, etc.


DWORD GetAffectionName(BYTE iAffectionID, LPTSTR lpszBuffer, DWORD dwMaxChars);

Return Value

If succeeded, the function returns length of the affection name, otherwise it returns zero.

Parameters

nAffectionID

ID of the affection. Please check Unit Affection Definition for a complete list of unit affection ID's.

lpszBuffer

Pointer to a null-terminated string which will receive the affection name.

dwMaxChars

Specifies the maximum buffer size, in char's. 

Remarks

Convert an affection into its string representation.


BOOL AffectionIsAura(BYTE iAffectionID);

Return Value

The function returns non-zero if the affection is an aura, zero otherwise.

Parameters

nAffectionID

ID of the affection. Please check Unit Affection Definition for a complete list of unit affection ID's.

Remarks

Check whether an affection is an aura.


DWORD IsMercUnit(LPCGAMEUNIT lpUnit);

Return Value

If succeeded, the function returns class ID of the merc, otherwise it returns zero.

Parameters

lpUnit

Pointer to a GAMEUNIT struct.

Remarks

Determine whether a game unit is a merc and which merc type it is. Please check Merc Class ID for a complete list of merc types.


int GetMonsterType(LPCGAMEUNIT lpUnit);

Return Value

The function returns monster type of the unit if succeeds, zero otherwise.

Parameters

lpUnit

Pointer to a GAMEUNIT struct.

Remarks

Determine monster type of a particular unit, e.g. champion, minor, boss, etc. Please check Monster Types for a complete list of monster types.


DWORD GetMonsterAttributes(LPCGAMEUNIT lpUnit);

Return Value

If succeeded, the function returns a combination of the monster attributes, otherwise it returns zero.

Parameters

lpUnit

Pointer to a GAMEUNIT struct.

Remarks

Retrieve monster attributes, including boss enchantments, boss auras, immunities. The return value will never be zero if the monster exists even if it does not have any relevant attributes. You may exam each attribute using the bit "&" operator. Please check Monster Attributes for a complete list of monster attribute values.

Code Sample

//////////////////////////////////////////////////////////////
// We will be displaying Pindleskin's attributes on screen
//////////////////////////////////////////////////////////////

GAMEUNIT gu = {0};
server->FindUnitByName(szName, UNIT_TYPE_MONSTER, &gu); // Find Pindleskin
const DWORD ATTR = server->GetMonsterAttributes(&gu); // Get its attributes
assert(ATTR); // ATTR will not be zero if Pindleskin exists

////////////////////////////////////////////////////
// Enchantments
////////////////////////////////////////////////////

if (ATTR & MA_FIRE_ENCHANTED)
    server->GamePrintInfo("Fire enchanted");

if (ATTR & MA_LIGHTNING_ENCHANTED)
    server->GamePrintInfo("Lightning enchanted");

// Other enchantments...

////////////////////////////////////////////////////
// Auras
////////////////////////////////////////////////////

if (ATTR & MA_MIGHT)
    server->GamePrintInfo("Might");

if (ATTR & MA_CONVICTION)
    server->GamePrintInfo("Conviction");

if (ATTR & MA_FANATICISM)
    server->GamePrintInfo("Fanaticism");

// Other auras...

////////////////////////////////////////////////////
// Immunities
////////////////////////////////////////////////////

if (ATTR & MA_IMMUNE_FIRE)
    server->GamePrintInfo("Immune to fire");

if (ATTR & MA_IMMUNE_PHYSICAL)
    server->GamePrintInfo("Immune to physical");

// Other immunities...


DWORD GetDistance(WORD x1, WORD y1, WORD x2, WORD y2);

Return Value

The function returns distance, in yards, between two map positions.

Parameters

x1, y1

Specifies the first map position.

x2, y2

Specifies the second map position.

Remarks

Calculate map position distance, in yards.


BOOL SendKey(BYTE iVKCode);

Return Value

The function returns non-zero if succeeds, zero otherwise.

Parameters

iVKCode

Virtual key code of the key which is being sent.

Remarks

Simulate a key press event in the game.


DWORD GetSpellName(WORD wSpell, LPSTR lpszBuffer, DWORD dwMaxChars);

Return Value

If succeeded, the function returns length of the spell name, otherwise it returns zero.

Parameters

wSpell

Specifies the spell ID. Please check Spell Definition for a complete list of spell ID's.

lpszBuffer

Pointer to a null-terminated string which will receive the spell name.

dwMaxChars

Specifies the maximum buffer size, in char's. 

Remarks

Retrieve name of a spell.


DWORD GetMapName(BYTE iMapID, LPTSTR lpszBuffer, DWORD dwMaxChars);

Return Value

If succeeded, the function returns length of the map name, otherwise it returns zero.

Parameters

iMapID

Specifies the map ID. Please check Map definition for a complete list of map ID's.

lpszBuffer

Pointer to a null-terminated string which will receive the map name.

dwMaxChars

Specifies the maximum buffer size, in char's. 

Remarks

Retrieve name of a map.


BOOL MapIsTown(BYTE iMapID);

Return Value

The function returns non-zero if the map is a town, zero otherwise.

Parameters

iMapID

Specifies the map ID. Please check Map definition for a complete list of map ID's.

Remarks

Check whether a map is a town.


BYTE GetTownMap(BYTE iAct);

Return Value

The function returns a map ID if succeeds, zero otherwise.

Parameters

iAct

Specifies the act, act number is zero-based, so 0 represents act 1, 1 represents act 2, and so on.

Remarks

Retrieve the town map ID of an act.


BYTE GetActFromMap(BYTE iMapID);

Return Value

The function returns act number of the given map.

Parameters

iMapID

Specifies the map ID. Please check Map definition for a complete list of map ID's.

Remarks

Determine which act the particular map belongs to.


SIZE GetItemSize(LPCSTR lpszItemCode);

Return Value

The function returns size of an item.

Parameters

lpszItemCode

Pointer to a null-terminated string which represents the 3-letter item code.

Remarks

Determine size of an item.


DWORD GetD2WindowTitle(LPSTR lpszBuffer, DWORD dwMaxChars);

Return Value

If succeeded, the function returns number of characters copied to the buffer, otherwise it returns zero.

Parameters

lpszBuffer

Pointer to a null-terminated string which will receive the window title.

dwMaxChars

Specifies the maximum buffer size, in char's. 

Remarks

Retrieve D2 game window title.


DWORD GetInGameTime();

Return Value

The function returns total elapsed time, in milliseconds, since the player joined the game.

Remarks

Retrieve current game length.


int GetGameDifficulty();

Return Value

If succeeded, the function returns difficulty of current game, otherwise it returns zero.

Remarks

Retrieve game difficulty, if succeeded, the return value can be 1(normal), 2(nightmare), or 3(hell).


BOOL EnumPresetUnits(fnEnumPresetUnitProc lpfnEnumPresetUnitProc, LPARAM lParam = 0);

Return Value

The function returns non-zero if succeeds, zero otherwise.

Parameters

lpfnEnumPresetUnitProc

Pointer to a fnEnumPresetUnitProc function which will received preset-unit data.

lParam

A 32-bit application defined value.

Remarks

Enumerate all preset-units on current map.


typedef BOOL (CALLBACK *fnEnumPresetUnitProc)(LPCPRESETUNIT lpPresetUnit, LPARAM lParam);

Return Value

Return zero to abort preset-unit enumeration, return non-zero to continue.

Parameters

lpPresetUnit

Pointer to a PRESETUNIT struct which will receive the preset-unit data.

lParam

A 32-bit application defined value.

Remarks

Process each preset-unit data passed from EnumPresetUnit.


DWORD CalculateTeleportPath(WORD x, WORD y, LPPOINT lpBuffer, DWORD dwMaxCount);

Return Value

If succeeded, the function returns number of path node calculated, otherwise it returns zero.

Parameters

x, y

Specifies the destination map position.

lpBuffer

Pointer to an array of POINT structures which will receive the calculated path nodes.

dwMaxCount

Specifies the maximum number of path nodes that lpBuffer can hold.

Remarks

Calculate all required steps from the player's current map position to the destination map position specified by x and y. This function can be extremely handy for finding a path from one position to another, for example, finding the path from Durance of hate level 2 waypoint to the Durance of hate level 3 entrance, whose map position can be obtained by a previous call to EnumPresetUnit.

Please note that path calculated by this function does not take into account obstacle(monsters, chests, closed doorways, etc), so it is recommended to be used for players with the Teleport spell.

Code Sample

/////////////////////////////////////////////////////////////////////
// Calculate a path and teleport there
/////////////////////////////////////////////////////////////////////

// Suppose we have already obtained a PRESETUNIT named "pu" from a previous call to EnumPresetUnit

PATH path = { 0 };
POINT aPath[255];
DWORD dwCount = server->CalculateTeleportPath(pu.x, pu.y, aPath, 255);
if (dwCount == 0)
{
    server->GamePrintError("Failed to calculate path!");
}
else
{
    for (DWORD i = 0; i < dwCount; i++)
        me->TeleportTo(aPath[i].x, aPath[i].y, TRUE);
}

// Now wait for the PM_MOVECOMPLETE message...


DWORD CalculateWalkPath(WORD x, WORD y, LPPOINT lpBuffer, DWORD dwMaxCount);

Return Value

If succeeded, the function returns number of path node calculated, otherwise it returns zero.

Parameters

x, y

Specifies the destination map position.

lpBuffer

Pointer to an array of POINT structures which will receive the calculated path nodes.

dwMaxCount

Specifies the maximum number of path nodes that lpBuffer can hold.

Remarks

Calculate all required steps from the player's current map position to the destination map position specified by x and y. This function is similar to CalculateTeleportPath except for that it takes into acount map obstacles and collisions. Usually used for town walking.


BOOL GetItemCode(DWORD dwItemID, LPSTR lpszBuffer, DWORD dwMaxChars);

Return Value

The function returns non-zero if succeeds, zero otherwise.

Parameters

dwItemID

Specifies the item ID.

lpszBuffer

Pointer to a null-terminated buffer which will receive the item code.

dwMaxChars

Specifies the maximum number of characters that can be copied to lpszBuffer. The value shall be no less than 4.

Remarks

Retrieve the 3-letter item code of the item specified by dwItemID.


BOOL LeftClick(long x, long y);
BOOL RightClick(long
x, long y);

Return Value

The function returns non-zero if succeeds, zero otherwise.

Parameters

x, y

Specifies the client coordinates where the mouse click shall occur.

Remarks

Simulate a mouse-click on the game client area.


DWORD QueryModuleData(LPCSTR lpszModuleName, DWORD dwDataID, LPVOID lpBuffer, DWORD dwMaxLength, LPARAM lParam = 0);

Return Value

If succeeded, the function returns number of bytes that were actually copied to lpBuffer, otherwise it returns zero.

Parameters

lpszModuleName

Specifies name of the target module. Module extension is not included, for example, if you want to query data from the module "pickit.d2h", you must specify "pickit" as the target module name.

dwDataID

Specifies the iddentity of the data to be queried. This value must had been defined in the target module.

lpBuffer

Pointer to a memory block, to where the target module will write the data if the query is successful.

dwMaxLength

Specify maximum data length, in bytes, that can be written to lpBuffer. The return value of this function will never exceed dwMaxLength.

lParam 

Specifies additional information to the target module on how the data should be queried. Assuming the caller and the target module have already made agreement on how lParam is defined.

Remarks

Retrieve some particular data or information from the target module specified by lpszModuleName. This function fails if any of the following conditions are true:


DWORD GetKeyName(BYTE iKeyCode, LPSTR lpszBuffer, DWORD dwMaxChars);

Return Value

If succeeded, the function returns length of the key name, otherwise it returns zero.

Parameters

iKeyCode

Specifies the virtual key code.

lpszBuffer

Pointer to a null-terminated string which will receive the key name.

dwMaxChars

Specifies the maximum buffer size, in char's. 

Remarks

Retrieve name of a key whose virtual key code value is specified by iKeyCode.


BOOL IsQuestItem(LPCSTR lpszItemCode);

Return Value

The function returns non-zero if the specified item is a quest item, zero otherwise.

Parameters

lpszItemCode

Specifies the item code.

Remarks

Check whether the specified item is a quest item.


SIZE GetScreenSize(); 

Return Value

The function returns size of the game window client area.

Remarks

Calculate size of the game window client area, the return value will be either {800, 600} or {640, 480}. No other sizes are defined.


void ScreenToMapCoords(POINT& rScreenCoords);

Parameters

rScreenCoords

Reference to a POINT structure which specifies the screen coordinates and receives translated map position.

Remarks

Translate a screen coordinates into an absolute game map position.


void MapToScreenCoords(POINT& rMapPosition);

Parameters

rMapPosition

Reference to a POINT structure which specifies the absolute map position and receives translated screen coordinates.

Remarks

Translate an absolute game map position into a screen coordinates.


POINT GetMousePosition();

Return Value

The function returns current mouse position.

Remarks

Retrieve current mouse position in the game client area.


POINT GetRandomPosition(int nRadiusMin, int nRadiusMax, int nAngleMin = 0, int nAngleMax = 360, const LPPOINT lpOrigin = NULL);

Return Value

The function returns the calculated result.

Parameters

nRadiusMin, nRadiusMax

Specify the minimum and maximum radius, in yards, from the origin point.

nAngleMin, nAngleMax

Specify the angles, in degrees, from the origin point. Angles values may range from 0 to 360.

lpOrigin 

Pointer to a POINT struct specifies the origin point from where a random position is to be calculated. If this parameter is null, the player's current position will be used as the origin point.

Remarks

Calculates for a random position within the specified radius and angles. Please note that if the origin point specified by lpOrigin is not a valid map position, then the return value will not be a valie map position, either. However, even if this is the case, the function will not fail since it merely performs a mathematical calculation.

This function could be extremely useful in some circumstances, for example, D2Hackit uses this function in its internal motion-queue to detour around small obstacles.


int GetAngle(WORD x1, WORD y1, WORD x2, WORD y2);

Return Value

The function returns calculated angle value(0-360).

Parameters

 x1, y1

Specifiy the starting position.

x2, y2

Specifiy the ending position.

Remarks

Calculates the angle value(0-360) between the starting position and the ending position.


BOOL CreateCollisionMap();

Return Value

The function returns non-zero if the collision map was created successfully, zero otherwise.

Remarks

Create a collision map against current map. A collision map is treated as an 1000*1000 two-dimensional array which stores all collision data of current map.

If the collision map of current map was already created period to this call, the function returns non-zero immediately without recreating it.

Collision map will be destroyed automatically as soon as current map is changed(the player enters a new area) and D2Hackit will not recreate it, you need to manually call this function at least once after every map change in order to be able to access collision data of the new map.


WORD GetCollisionData(long x, long y, BOOL bAbsolute);

Return Value

Is succeeded, the function returns the specified collision data, otherwise it returns -1.

Parameters

 x, y

Specifiy the location, at which the collision data is to e retrieved.

bAbsolute

Specifies whether the location specified by x and y is an absolute game map position or a relative index.

Remarks

Retrieves the collision data at a particular position.

If bAbsolute is non-zero, x and y are treated as an absolute game map position. If bAbsolute is zero, x and y are treated as a relative index, in this case values of x and y must be in range of 0 to 999, since the collision map is an 1000*1000 two-dimensional array.


BOOL DumpCollisionMap(LPCSTR lpszFilePath, const LPPOINT lpTokens = NULL, DWORD dwTokenCount = 0);

Return Value

The function returns non-zero if succeeds, zero otherwise.

Parameters

 lpszFilePath

Pointer to a null-terminated character string which specifiy full path of the file. If the file does not exist, it is created.

lpTokens 

Pointer to an array of POINT structures which contain tokens to be printed to the file. If this parameter is zero, no tokens are printed.

dwTokenCount 

Specifies number of elements contained in lpTokens.

Remarks

Prints the collision map data to a text file, you may view the file using your text editor with "word-wrap" disabled. 

All reachable areas are printed as blank, non-reachable areas are printed as 'X', and the player's current location is printed as 'P'. If lpTokens contains elements, the first element of lpTokens is printed as 'S', the last element of lpTokens is printed as 'E', and all intermediate elements are printed as '*'.

Please be adviced that collision map data are huge in size (could be easily over hundreds of KB) and writing the map data to disk files are time consuming, you should only use this function for internal debug purpose, the release versions of your modules shall never contain this function.


DWORD GetItemPrice(DWORD dwItemID, DWORD dwNpcClassID, BOOL bBuyOrSell);

Return Value

If succeeded, the function returns price of the specified item, otherwise it returns zero.

Parameters

 dwItemID

Specifiy ID of the item which is to be checked.

dwNpcClassID

Specifies class ID of the npc against whom the item price is to be checked. And yes, you guessed it right, different npc's may return different prices on same item.

bBuyOrSell

If this parameter is non-zero, the function returns buying price of the item, otherwise the function returns selling price of the item. Buying prices of items are usually much higher than selling prices. 

Remarks

Retrieves buying/selling prices of a particular item.


DWORD GetItemAttributes(DWORD dwItemID);

Return Value

Is succeeded, the function returns attributes of the item, otherwise it returns 0.

Parameters

dwItemID

Specifiy ID of the item which is to be checked.

Remarks

Retrieves attributes of a particular item. Please check "Item Attributes" for a complete list of item attribute values.


BYTE GetItemSockets(DWORD dwItemID);

Return Value

Is succeeded, the function returns number of sockets on the item, otherwise it returns 0.

Parameters

dwItemID

Specifiy ID of the item which is to be checked.

Remarks

Retrieves number of sockets on a particular item.


BOOL UnitOverhead(LPCGAMEUNIT lpUnit, LPCSTR lpszText, DWORD dwDuration = 8000);

Return Value

The function returns non-zero if succeeds, zero otherwise.

Parameters

lpUnit

Pointer to a GAMEUNIT struct which specifies the unit that will display the overhead message.

lpszText

Pointer to a null-terminated character string which will be displayed. If this parameter is null or empty, the existing overhead message of the unit will be immediately removed.

dwDuration 

Specifies the duration, in milliseconds, for how long the overhead message will be displayed. The message will be automatically removed after the duration has elapsed. If this parameter is -1, the message will not be automatically removed.

Remarks

Makes any kind of game units display overhead messages just like what players can do, you may use this function to make npc's, chests, items, monsters, etc, to display overhead messages. Overhead message of a unit will be automatically removed if the duration specified by dwDuration has elapsed, or the unit is out of the player's awareness.

To immediate remove overhead message of an unit, simply specify null as lpszText value.


DWORD GetItemProperties(DWORD dwItemID, LPITEMPROPERTY lpBuffer, DWORD dwMaxCount);

Return Value

Is succeeded, the function returns number of properties copied to the buffer, otherwise it returns 0.

Parameters

dwItemID

Specifiy ID of the item whose properties are to be retrieved.

lpBuffer

Pointer to an array of ITEMPROPERTY structures which will receive the item property data.

dwMaxCount

Specifies the maximum number of properties the buffer can store.

Remarks

Retrieves a list of item properties, AKA, item magical mods.


POINT FindPresetUnit(DWORD dwUnitID, DWORD dwUnitType);

Return Value

Is succeeded, the function returns position of the found preset-unit, otherwise it returns {0,0}.

Parameters

dwUnitID

Specifiy ID of the preset-unit that is to be found.

dwUnitType

Specifies type of the preset-unit that is to be found. Please check Unit Types for a complete list of game unit types.

Remarks

Searchs for a particular preset-unit on current map and returns its position.


BOOL GetHighlightUnit(LPGAMEUNIT lpBuffer);

Return Value

The function returns non-zero if there is a highlighted unit, zero otherwise.

Parameters

lpUnit

Pointer to a GAMEUNIT struct which will receive the highlighted unit data.

Remarks

Retrieves the currently highlighted game unit. A game unit is highlighted when the player's mouse cursor hovers over it, the highlighted unit is drawn with different brightness by the game and its brief description is usually shown overhead.


int GetItemQuality(DWORD dwItemID);

Return Value

If succeeded, the function returns quality value of the item, otherwise it returns zero.

Parameters

dwItemID

Specifies ID of the item to be checked.

Remarks

Retrieves the item quality value. Please check "Item Quality" for a complete list of item quality values.


BOOL GetItemPrefixSuffix(DWORD dwItemID, WORD* pPrefix, WORD* pSuffix);

Return Value

The function returns non-zero if succeeds, zero otherwise.

Parameters

dwItemID

Specifies ID of the item to be checked.

pPrefix

Pointer to a WORD which will receive the item prefix value.

pPrefix

Pointer to a WORD which will receive the item suffix value.

Remarks

Retrieves the prefix and suffix values of a magical item.


DWORD GetPrefixSuffixName(WORD wPrefixOrSuffix, LPSTR lpszBuffer, DWORD dwMaxChars);

Return Value

If succeeded, the function returns number of characters copied to the buffer, otherwise it returns zero.

Parameters

wPrefixOrSuffix

Specifies the prefix or suffix value to be translated into its string representation.

lpszBuffer

Pointer to a null-terminated character string which will receive the translated text.

dwMaxChars

Specifies the maximum number of characters that can be copied to lpszBuffer .

Remarks

Translate a magical prefix or suffix value into its string representation.


DWORD GetUnitMode(LPCGAMEUNIT lpUnit);

Return Value

If succeeded, the function returns the unit's mode value, otherwise it returns zero.

Parameters

lpUnit

Pointer to a GAMEUNIT struct whose mode value is to be retrieved.

Remarks

Retrieves mode value of the specified unit. Meanings of mode values depend on the unit type, please check "Unit Modes" for a complete list of mode values for all unit types.

New Diablo 2 Event

http://newd2event.net