D2BS
Functions

Global functions

Functions

Unit getUnit (int type=-1, String name="", uint32_t mode=(uint32_t)-1, uint32_t nUnitId=(uint32_t)-1)
 Get a unit by type, name, mode and nUnitId.
Unit getUnit (int type=-1, uint32_t classId=(uint32_t)-1, uint32_t mode=(uint32_t)-1, uint32_t nUnitId=(uint32_t)-1)
 Get a unit by type, classId, mode and nUnitId.
object[] getPath (uint32_t Area, uint32_t srcX, uint32_t srcY, uint32_t dstX, int dstY, uint32_t reductionType=0, uint32_t Radius=20)
 Creates a path (walking or teleporting) from the source to the destination.
object[] getPath (uint32_t Area, uint32_t srcX, uint32_t srcY, uint32_t dstX, int dstY, uint32_t reductionType, uint32_t Radius, bool(*reject)(int32_t x, int32_t y), bool(*reduce)(object curPt, int i, object[] pts), int32_t[](*mutate)(int32_t x, int32_t y))
 Creates a path (walking or teleporting) from the source to the destination.
unsigned short getCollision (uint32_t nLevelId, int32_t nX, int32_t nY)
 Get the collision flags at a given point in a given area.
int getMercHP ()
 Get the health points of the controlled unit's merc.
int getCursorType ()
 Get the cursor type from p_D2CLIENT_RegularCursorType.
int getCursorType (int nType)
 Get the cursor type from p_D2CLIENT_RegularCursorType if nType != 1, from p_D2CLIENT_ShopCursorType if nType == 1.
int getSkillByName (String skillName)
 Get skill ID by name.
String getSkillById (int skillId)
 Get skill name by ID.
String getLocaleString (uint16_t localeId)
 Get the String in the current locale that corresponds to the given id.
int[] getTextSize (String string, int font, bool asObject=false)
 Get the width and height of the given text in the given font.
int getThreadPriority ()
 Get the priority of the current thread.
bool getUIFlag (int nUIId)
 Get whether or not a UI flag is set.
int getTradeInfo (int nMode)
 Get the TradeFlag or RecentTradeId.
bool getWaypoint (int nWaypointId)
 Get whether the controlled unit has the given waypoint.
D2BSScript getScript (bool currentScript)
 Get the current or first context.
D2BSScript getScript (int threadId)
 Get a script by thread id.
D2BSScript getScript (String name)
 Get a script by filename.
D2BSScript getScript ()
 Get the first script.
Room getRoom (uint32_t levelId)
 Get the first room in area given by level id.
Room getRoom (uint32_t levelId, int x, int y)
 Get the room that the given point is in from the given level id.
Room getRoom (int x, int y)
 Get the room that the given point is in.
Room getRoom ()
 Get the first room in the current area.
Party getParty ()
 Get the first party.
Party getParty (String name)
 Get the party line for the player with the given name.
Party getParty (uint32_t playerId)
 Get the party line for the player with the given player id.
Party getParty (Unit player)
 Get the party line that corresponds to the given unit.
PresetUnit getPresetUnit (uint32_t levelId, int nType=0, int nClassId=0)
 Get the first PresetUnit of the given type and class id.
PresetUnit[] getPresetUnits (uint32_t levelId, int nType=0, int nClassId=0)
 Get an array of PresetUnit s of the given type and class id.
Area getArea ()
 Get the Area where the controlled unit currently resides.
Area getArea (int32_t nArea)
 Get the Area for area ID nArea.
String getBaseStat (String szTableName, int32_t nClassId, String szStatName)
 Get the base stat from the given table with the given class ID and stat name.
String getBaseStat (int32_t nBaseStat, int32_t nClassId, String szStatName)
 Get the base stat from the given table with the given class ID and stat name.
String getBaseStat (String szTableName, int32_t nClassId, int32_t nStat)
 Get the base stat from the given table with the given class ID and stat ID.
String getBaseStat (int32_t nBaseStat, int32_t nClassId, int32_t nStat)
 Get the base stat from the given table with the given class ID and stat ID.
Control getControl (int32_t nType=-1, int32_t nX=-1, int32_t nY=-1, int32_t nXSize=-1, int32_t nYSize=-1)
 Get the control specified by type, location and size.
bool getPlayerFlag (int nFirstUnitId, int nSecondUnitId, int nFlag)
 Get the relation between two units.
int getTickCount ()
 Get the tick count.
Unit getInteractedNPC ()
 Get the Unit that the controlled Unit is currently interacting with.
void print (...)
 Print the String representation of the arguments to the console.
void delay (uint32_t nDelay)
 Delay for nDelay milliseconds.
D2BSScript load (String file,...)
 Load file and create a thread with it's main function.
bool isIncluded (String file)
 Determine whether a file has been included yet or not.
bool include (String file)
 Include file from the scriptDir\libs directory.
void stop (int stop=0)
 Conditionally stop current script.
void stop (bool stop)
 Conditionnaly stop current script.
int rand (int32_t low, int32_t high)
 Return a random number between low and high.
void copy (String txt)
 Copy txt to clipboard.
int sendCopyData (String windowClassName, String windowName, int32_t nModeId, String data)
 Send data to another window by means of the WM_COPYDATA message.
int sendCopyData (HWND hWnd, String dummy, int32_t nModeId, String data)
 Send data to another window by means of the WM_COPYDATA message.
String sendDDE (int32_t mode, String pszDDEServer, String pszTopic, String pszItem)
 Send data to a DDE server by means of DdeClientTransaction.
bool keystate (int vKey)
 Get whether or not a key is pressed.
void addEventListener (String event, Function eventHandler)
 Add an event handler to the list of listeners for the given event.
void removeEventListener (String event, Function eventHandler)
 Removes a previously added event from the listener list.
void clearEvent (String event)
 Clear the event handler list for given event.
void clearAllEvents ()
 Clear all event handlers (from all events).
bool js_strict ()
 Get whether or not the JSOPTION_STRICT flag is set.
void js_strict (bool setStrictFlag)
 Set or clear the JSOPTION_STRICT flag.
String version ()
 Get the D2BS version string.
String vcRevString ()
 Get the D2BS version control string.
int32_t vcRevNumber ()
 Get the D2BS version control revision number.
void version (int a)
 Print the D2BS version string.
void scriptBroadcast (...)
 Broadcast a message to all other scripts.
String sqlite_version ()
 Get the sqlite version string (from sqlite3_version).
double sqlite_memusage ()
 Return the sqlite memory usage.
Folder dopen (String name)
 Get the Folder object for the directory scriptPath\name.
void debugLog (...)
 Log the String representation of the arguments.
void showConsole ()
 Show the console.
void hideConsole ()
 Hide the console.
void login ()
 Loads the default (either from config or copydata or DDE) profile from d2bs.ini and gets to the lobby (for battle.net chars) or into a game (for single player characters).
void login (String profile)
 Loads the profile from d2bs.ini and gets to the lobby (for battle.net chars) or into a game (for single player characters).
bool selectCharacter (String profile)
 Select the character from the given profile.
void createGame (String name, String pass="", int32_t diff=3)
 Create a game with the given name and password in the given difficulty.
void joinGame (String name, String pass="")
 Join a game with the given name and password.
void addProfile (String profile, String mode, String gateway, String username, String password, String charname, int spDifficulty=3)
 Create a profile with the given profile name, mode, gateway, username, password, character name and single player difficulty.
int getLocation ()
 Get the current OOG location.
void loadMpq (String path)
 Load an mpq file.
bool submitItem ()
 Submit the item on the cursor to the open screen (like the add sockets screen).
int[] getMouseCoords (bool nFlag=false, bool nReturn=false)
 Get the mouse coordinates (in screen or map space) and return as an array.
Unit copyUnit (Unit other)
 Copy the cached data associated with given unit.
bool clickMap (uint16_t nClickType, uint16_t nShift, Unit toClick)
 Click on the map with the given click type and possibly shift at the given unit.
bool clickMap (uint16_t nClickType, bool nShift, Unit toClick)
 Click on the map with the given click type and possibly shift at the given unit.
bool clickMap (uint16_t nClickType, uint16_t nShift, uint16_t nX, uint16_t nY)
 Click on the map with the given click type and possibly shift at the given point.
bool clickMap (uint16_t nClickType, bool nShift, uint16_t nX, uint16_t nY)
 Click on the map with the given click type and possibly shift at the given point.
bool acceptTrade (int action)
 Get or do something to do with accepting trade.
bool acceptTrade ()
 Accept a trade if not already accepted, cancel a trade if already accepted.
void tradeOk ()
 Hit the OK button to open the trade window.
object[] getDialogLines ()
 Get the lines of dialog of whatever you're talking to.
void beep (int nBeepId=0)
 Beep with beep ID nBeepId.
void clickItem (Unit item)
 Click an item.
void clickItem (int nClickType, int nBodyLoc)
 Click on a body location with a certain click type.
void clickItem (int nClickType, Unit item)
 Click on a given item with the given click type.
void clickItem (int nClickType, int nX, int nY, int nLoc)
 Click an item location with the given click type.
double getDistance (Unit a)
 Get the euclidean distance from me to a.
double getDistance (Unit a, Unit b)
 Get the euclidean distance from a to b.
double getDistance (Unit a, int32_t bx, int32_t by)
 Get the euclidean distance from a to b.
double getDistance (int32_t ax, int32_t ay)
 Get the euclidean distance from me to a.
double getDistance (int32_t ax, int32_t ay, Unit b)
 Get the euclidean distance from a to b.
double getDistance (int32_t ax, int32_t ay, int32_t bx, int32_t by)
 Get the euclidean distance from a to b.
void gold (int nGold=0, int nMode=1)
 Do something with some gold.
int checkCollision (Unit a, Unit b, int nBitMask)
 Check if two units collide.
bool playSound (int nSoundId)
 Play d2 sound by id.
void quit ()
 Quit the game.
void quitGame ()
 Quit Diablo II.
bool say (...)
 Say the string equivalent of the each of the arguments.
bool clickParty (Party player, int nMode)
 Click one of the buttons in the party screen for the given player.
int weaponSwitch (int32_t dummy)
 Get which weapon switch is being used.
void transmute ()
 Hit the transmute button.
void useStatPoint (uint16_t statType, uint32_t count=1)
 Use a stat point.
void useSkillPoint (uint16_t skill, uint32_t count=1)
 Use a skill point.
void takeScreenshot ()
 Take a screenshot.
Object screenToAutomap (Object arg)
 Convert a point from screen coordinates to automap coordinates.
Object screenToAutomap (int ix, int iy)
 Convert a point from screen coordinates to automap coordinates.
Object automapToScreen (Object arg)
 Convert a point from automap coordinates to screen coordinates.
Object automapToScreen (int ix, int iy)
 Convert a point from automap coordinates to screen coordinates.
String md5 (String str)
 Takes the md5 hash.
String sha1 (String str)
 Takes the sha1 hash.
String sha256 (String str)
 Takes the sha256 hash.
String sha384 (String str)
 Takes the sha384 hash.
String sha512 (String str)
 Takes the sha512 hash.
String md5_file (String file)
 Take the md5 hash of a file.
String sha1_file (String file)
 Take the sha1 hash of a file.
String sha256_file (String file)
 Take the sha256 hash of a file.
String sha384_file (String file)
 Take the sha384 hash of a file.
String sha512_file (String file)
 Take the sha512 hash of a file.

Function Documentation

bool acceptTrade ( int  action)

Get or do something to do with accepting trade.

Parameters:
actionWhat action to perform.

1 - Get whether trade we've accepted trade already or not.

2 - Get the trade flag ...

3 - Get whether the check is red or not.

Returns:
The flag specified by action.
bool acceptTrade ( )

Accept a trade if not already accepted, cancel a trade if already accepted.

Todo:
Verify that I understand this correctly.
Returns:
Whether or not trade was accepted.
void addEventListener ( String  event,
Function  eventHandler 
)

Add an event handler to the list of listeners for the given event.

Parameters:
eventThe name of the event. Can be:

melife (uint32_t dwLife)

memana (uint32_t dwMana)

keyup (uint32_t key)

keydown (uint32_t key)

bool keyupblock (uint32_t key) - Returns true to block event from Diablo II

bool keydownblock (uint32_t key) - Returns true to block event from Diablo II

playerassign (uint32_t unitId)

mouseclick (uint32_t button, uint32_t x, uint32_t y, bool bUp)

mousemove (uint32_t x, uint32_t y)

scriptmsg (...)

golddrop (uint32_t gId, uint32_t Mode)

chatmsg (String lpszNick, String lpszMsg)

bool chatmsgblocker (String lpszNick, String lpszMsg) - Returns true to block event from Diablo II

whispermsg (String lpszNick, String lpszMsg)

bool whispermsgblocker (String lpszNick, String lpszMsg) - Returns true to block event from Diablo II

copydata (int32_t dwMode, String lpszMsg)

itemaction (uint32_t gId, uint32_t mode, String code, Bool global)

gameevent (BYTE mode, DWORD param1, DWORD param2, String name1, String name2)

From http://www.blizzhackers.cc/viewtopic.php?t=392307 Dark_Mage-

mode:

0x00 - "%Name1(%Name2) dropped due to time out." 0x01 - "%Name1(%Name2) dropped due to errors." 0x02 - "%Name1(%Name2) joined our world. Diablo's minions grow stronger." 0x03 - "%Name1(%Name2) left our world. Diablo's minions weaken." 0x04 - "%Name1 is not in the game." 0x05 - "%Name1 is not logged in."

0x06 - "%Name1 was Slain by %Name2" BYTE Param2 = Unit Type of Slayer (0x00 = Player, 0x01 = NPC) if Type = Player, Name2 = Slayer Character Name & DWORD Param1 = Slayer Character Type if Type = NPC, DWORD Param1 = Monster Id Code from MPQ (points to string for Name2) if Type = NPC & Monster is Unique, Name2 = Unique Monster Id

0x07 - Player Relations (Bottom Left Text) DWORD Param1 = Player Id Player Id = Pointer to Character Name BYTE Param2 = Action Taken Actions: 0x01 - "%Player permits you to loot his corpse." 0x02 - "%Player permits you to loot her corpse." 0x03 - "%Player has declared hostility towards you." 0x04 - "%Player is no longer hostile towards you." 0x05 - "%Player invites you to ally against the forces of evil." 0x06 - "%Player has canceled party invite." 0x07 - "%Player has joined your party to fight the forces of evil." 0x08 - "You are now allied with %Player." 0x09 - "%Player has left your party." 0x0a - "%Player no longer allows you to access his corpse." 0x0b - "%Player no longer allows you to access her corpse."

0x08 - "%Name1 is busy." 0x09 - "You must wait a short time to trade with that player."

0x0a - "%Name1 has items in his box." if Name1 = 0x00, "You have items in your box."

0x0b - <Unknown> 0x0c - <Unknown> 0x0d - "%Name1 is not listening to you." 0x0e - Received on 'Not enough mana' speech. 0x0f - "Realm going down in %Param1 minutes." 0x10 - "You must wait a short time to declare hostility with that player." 0x11 - "%Param1 Stones of Jordan Sold to Merchants" 0x12 - "Diablo Walks the Earth"

Parameters:
eventHandlerA function with the signature listed above that handles the event.
void addProfile ( String  profile,
String  mode,
String  gateway,
String  username,
String  password,
String  charname,
int  spDifficulty = 3 
)

Create a profile with the given profile name, mode, gateway, username, password, character name and single player difficulty.

Parameters:
profileThe profile name.
modeThe mode (single player/battle.net/etc).
gatewayThe realm gateway.
usernameAccount username.
passwordAccount password.
charnameCharacter name (case sensitive).
spDifficultyThe difficulty to create games for a single player character.
Object automapToScreen ( Object  arg)

Convert a point from automap coordinates to screen coordinates.

Parameters:
argAn object with x and y parameters specifying the point.
Returns:
An object with x and y, containing the screen coordinate.
Object automapToScreen ( int  ix,
int  iy 
)

Convert a point from automap coordinates to screen coordinates.

Parameters:
ixThe x coordinate.
iyThe y coordinate.
Returns:
An object with x and y, containing the screen coordinate.
void beep ( int  nBeepId = 0)

Beep with beep ID nBeepId.

Parameters:
nBeepIdID of the beep to make. See: http://msdn.microsoft.com/en-us/library/ms680356%28VS.85%29.aspx .
int checkCollision ( Unit  a,
Unit  b,
int  nBitMask 
)

Check if two units collide.

Parameters:
aUnit a.
bUnit b.
nBitMaskBit mask to check collision of a and b with.
void clearEvent ( String  event)

Clear the event handler list for given event.

Parameters:
eventThe name of the event to clear the handler list for.
void clickItem ( Unit  item)

Click an item.

Parameters:
itemThe item to click on.
void clickItem ( int  nClickType,
int  nBodyLoc 
)

Click on a body location with a certain click type.

Parameters:
nClickTypeThe click type. {0 - left click, 4 - left click merc body locations}
nBodyLocThe body location.

0 - Not equipped

1 - Helmet

2 - Amulet

3 - Armor

4 - Right hand slot 1

5 - Left hand slot 1

6 - Right ring

7 - Left ring

8 - Belt

9 - Boots

10 - Gloves

11 - Right hand slot 2

12 - Left hand slot 2

void clickItem ( int  nClickType,
Unit  item 
)

Click on a given item with the given click type.

Parameters:
nClickTypeThe click type. {0 - left click, 1 - right click, 4 - left click merc location}
itemThe item to click.
nClickType
void clickItem ( int  nClickType,
int  nX,
int  nY,
int  nLoc 
)

Click an item location with the given click type.

Parameters:
nClickTypeThe click type. {0 - left click, 1 - right click, 2 - shift left click, 4 - left click merc location}
nXThe x coordinate of the location to click.
nYThe y coordinate of the location to click.
nLocThe game location of the item.

2 - Belt

3 - Inventory

4 - Player trade

6 - Cube

7 - Stash

bool clickMap ( uint16_t  nClickType,
uint16_t  nShift,
Unit  toClick 
)

Click on the map with the given click type and possibly shift at the given unit.

Parameters:
nClickTypeThe click type to do.
nShiftWhether or not to be holding down shift. 0 - Don't hold shift, 1 - hold shift.
toClickThe unit to click on.
Todo:
Get a reference for nClickType.
Returns:
Whether or not the click was successful.
bool clickMap ( uint16_t  nClickType,
bool  nShift,
uint16_t  nX,
uint16_t  nY 
)

Click on the map with the given click type and possibly shift at the given point.

Parameters:
nClickTypeThe click type to do.
nShiftWhether or not to be holding down shift.
nXThe x coordinate to click at.
nYThe y coordinate to click at.
Todo:
Get a reference for nClickType.
Returns:
Whether or not the click was successful.
bool clickMap ( uint16_t  nClickType,
bool  nShift,
Unit  toClick 
)

Click on the map with the given click type and possibly shift at the given unit.

Parameters:
nClickTypeThe click type to do.
nShiftWhether or not to be holding down shift.
toClickThe unit to click on.
Todo:
Get a reference for nClickType.
Returns:
Whether or not the click was successful.
bool clickMap ( uint16_t  nClickType,
uint16_t  nShift,
uint16_t  nX,
uint16_t  nY 
)

Click on the map with the given click type and possibly shift at the given point.

Parameters:
nClickTypeThe click type to do.
nShiftWhether or not to be holding down shift. 0 - Don't hold shift, 1 - hold shift.
nXThe x coordinate to click at.
nYThe y coordinate to click at.
Todo:
Get a reference for nClickType.
Returns:
Whether or not the click was successful.
bool clickParty ( Party  player,
int  nMode 
)

Click one of the buttons in the party screen for the given player.

Parameters:
playerThe player who's button you wish to click.
nModeWhich button to click.

0 - Allow loot corpse

1 - Hostile player

2 - Join party

3 - Leave party (doesn't matter which party is passed in)

void copy ( String  txt)

Copy txt to clipboard.

Parameters:
txtText to copy to the clipboard.
Unit copyUnit ( Unit  other)

Copy the cached data associated with given unit.

This is things like type and unit id.

Todo:
Figure out why anyone would want to copy a unit.
Returns:
The new copy of the unit.
void createGame ( String  name,
String  pass = "",
int32_t  diff = 3 
)

Create a game with the given name and password in the given difficulty.

Parameters:
nameThe game name.
passThe game password.
diffThe game difficulty. 0 - normal, 1 - nightmare, 2 - hell, 3 - hardest difficulty available.
void delay ( uint32_t  nDelay)

Delay for nDelay milliseconds.

This is done by suspending the context, sleeping, then resuming the context for short (<50 ms) delays. For longer delays the context is suspended, 50ms are slept away, the context is resumed, sequence repeats until time slept is greater then nDelay ms.

Parameters:
nDelayMilliseconds to sleep.
Folder dopen ( String  name)

Get the Folder object for the directory scriptPath\name.

Parameters:
nameThe name of the Folder to open.
Returns:
A Folder object representing the Folder name.
Area getArea ( )

Get the Area where the controlled unit currently resides.

Returns:
An Area object for the current object.
Area getArea ( int32_t  nArea)

Get the Area for area ID nArea.

Parameters:
nAreaThe area ID.
Returns:
An Area object.
double getBaseStat ( int32_t  nBaseStat,
int32_t  nClassId,
String  szStatName 
)

Get the base stat from the given table with the given class ID and stat name.

Parameters:
nBaseStatThe stat to look up.
nClassIdThe class ID of the ...
szStatNameThe stat name.
Todo:
Determine what these tables are.
Returns:
The stat.
Parameters:
nBaseStatThe stat to look up.
nClassIdThe class ID of the ...
szStatNameThe stat name.
Todo:
Determine what these tables are.
Returns:
The stat.
Parameters:
nBaseStatThe stat to look up.
nClassIdThe class ID of the ...
szStatNameThe stat name.
Todo:
Determine what these tables are.
Returns:
The stat.
Parameters:
nBaseStatThe stat to look up.
nClassIdThe class ID of the ...
szStatNameThe stat name.
Todo:
Determine what these tables are.
Returns:
The stat.
double getBaseStat ( String  szTableName,
int32_t  nClassId,
String  szStatName 
)

Get the base stat from the given table with the given class ID and stat name.

Parameters:
szTableNameThe name of the table to look in.
nClassIdThe class ID of the ...
szStatNameThe stat name.
Todo:
Determine what these tables are.
Returns:
The stat.
Parameters:
szTableNameThe name of the table to look in.
nClassIdThe class ID of the ...
szStatNameThe stat name.
Todo:
Determine what these tables are.
Returns:
The stat.
Parameters:
szTableNameThe name of the table to look in.
nClassIdThe class ID of the ...
szStatNameThe stat name.
Todo:
Determine what these tables are.
Returns:
The stat.
Parameters:
szTableNameThe name of the table to look in.
nClassIdThe class ID of the ...
szStatNameThe stat name.
Todo:
Determine what these tables are.
Returns:
The stat.
double getBaseStat ( String  szTableName,
int32_t  nClassId,
int32_t  nStat 
)

Get the base stat from the given table with the given class ID and stat ID.

Parameters:
szTableNameThe name of the table to look in.
nClassIdThe class ID of the ...
nStatThe stat ID.
Todo:
Determine what these tables are.
Returns:
The stat.
Parameters:
szTableNameThe name of the table to look in.
nClassIdThe class ID of the ...
nStatThe stat ID.
Todo:
Determine what these tables are.
Returns:
The stat.
Parameters:
szTableNameThe name of the table to look in.
nClassIdThe class ID of the ...
nStatThe stat ID.
Todo:
Determine what these tables are.
Returns:
The stat.
Parameters:
szTableNameThe name of the table to look in.
nClassIdThe class ID of the ...
nStatThe stat ID.
Todo:
Determine what these tables are.
Returns:
The stat.
double getBaseStat ( int32_t  nBaseStat,
int32_t  nClassId,
int32_t  nStat 
)

Get the base stat from the given table with the given class ID and stat ID.

Parameters:
nBaseStatThe stat to look up.
nClassIdThe class ID of the ...
nStatThe stat ID.
Todo:
Determine what these tables are.
Returns:
The stat.
Parameters:
nBaseStatThe stat to look up.
nClassIdThe class ID of the ...
nStatThe stat ID.
Todo:
Determine what these tables are.
Returns:
The stat.
Parameters:
nBaseStatThe stat to look up.
nClassIdThe class ID of the ...
nStatThe stat ID.
Todo:
Determine what these tables are.
Returns:
The stat.
Parameters:
nBaseStatThe stat to look up.
nClassIdThe class ID of the ...
nStatThe stat ID.
Todo:
Determine what these tables are.
Returns:
The stat.
unsigned short getCollision ( uint32_t  nLevelId,
int32_t  nX,
int32_t  nY 
)

Get the collision flags at a given point in a given area.

Parameters:
nLevelIdThe level id of the area in question.
nXThe x coordinate of the point in question.
nYThe y coordinate of the point in question.
Returns:
The collision flags. For details see: http://forums.d2botnet.org/viewtopic.php?f=18&t=1212 .
Control getControl ( int32_t  nType = -1,
int32_t  nX = -1,
int32_t  nY = -1,
int32_t  nXSize = -1,
int32_t  nYSize = -1 
)

Get the control specified by type, location and size.

-1 indicates parameter not to be matched against.

Parameters:
nTypeThe type of control (button, text box, etc.)
nXThe x coordinate of the control of the control to find.
nYThe y coordinate of the control of the control to find.
nXSizeThe width of the control.
nYSizeThe height of the control.
Todo:
Get a reference for nType
Returns:
A Control object representing the Control found.
int getCursorType ( int  nType)

Get the cursor type from p_D2CLIENT_RegularCursorType if nType != 1, from p_D2CLIENT_ShopCursorType if nType == 1.

Parameters:
nTypeWhat type of cursor to get. 1 - ShopCursorType, other - RegularCursorType.
Todo:
Determine what the return value means.
Returns:
The cursor type.
int getCursorType ( )

Get the cursor type from p_D2CLIENT_RegularCursorType.

Todo:
Determine what the return value means.
Returns:
The regular cursor type.
object [] getDialogLines ( )

Get the lines of dialog of whatever you're talking to.

Each object has a text property which gives the text, a selectable property which is a boolean as to whether you can click on that line or not, and a handler function which does the action clicking on the line would perform.

Returns:
An array of objects of the lines, or undefined if no dialog up.
double getDistance ( Unit  a)

Get the euclidean distance from me to a.

Parameters:
aThe second Unit.
Returns:
The euclidean distance from a.
double getDistance ( Unit  a,
int32_t  bx,
int32_t  by 
)

Get the euclidean distance from a to b.

Parameters:
aThe first Unit.
bxThe x coordinate of point b.
byThe y coordinate of point b.
Returns:
The euclidean distance from a to b.
double getDistance ( int32_t  ax,
int32_t  ay 
)

Get the euclidean distance from me to a.

Parameters:
axThe x coordinate of point a.
ayThe y coordinate of point a.
Returns:
The euclidean distance from me to a.
double getDistance ( int32_t  ax,
int32_t  ay,
Unit  b 
)

Get the euclidean distance from a to b.

Parameters:
axThe x coordinate of point a.
ayThe y coordinate of point a.
bThe second Unit.
Returns:
The euclidean distance from a to b.
double getDistance ( Unit  a,
Unit  b 
)

Get the euclidean distance from a to b.

Parameters:
aThe first Unit.
bThe second Unit.
Returns:
The euclidean distance from a to b.
double getDistance ( int32_t  ax,
int32_t  ay,
int32_t  bx,
int32_t  by 
)

Get the euclidean distance from a to b.

Parameters:
axThe x coordinate of point a.
ayThe y coordinate of point a.
bxThe x coordinate of point b.
byThe y coordinate of point b.
Returns:
The euclidean distance from a to b.
Unit getInteractedNPC ( )

Get the Unit that the controlled Unit is currently interacting with.

Returns:
The Unit currently being interacted with.
String getLocaleString ( uint16_t  localeId)

Get the String in the current locale that corresponds to the given id.

Parameters:
localeIdThe id of the String.
Returns:
The String in the current locale.
int getLocation ( )

Get the current OOG location.

Todo:
Create a reference for the return values.
Returns:
The current OOG location.
int getMercHP ( )

Get the health points of the controlled unit's merc.

Returns:
The health points.
Object getMouseCoords ( bool  nFlag = false,
bool  nReturn = false 
)

Get the mouse coordinates (in screen or map space) and return as an array.

Get the mouse coordinates (in screen or map space) and return as an Object.

Parameters:
nFlagWhether to return in map space (true) or screen space (false).
nReturnWhether to return as an array or as an Object, false for array format.
Returns:
The mouse coordinates in an array. 0 - x, 1 - y.
Parameters:
nFlagWhether to return in map space (true) or screen space (false).
nReturnWhether to return as an array or as an Object, true for Object format.
Returns:
The mouse coordinates in an array. Has properties .x and .y.
Party getParty ( )

Get the first party.

Returns:
The first party.
Party getParty ( String  name)

Get the party line for the player with the given name.

Parameters:
nameThe name of the player to search for
Returns:
The party line
Party getParty ( uint32_t  playerId)

Get the party line for the player with the given player id.

Parameters:
playerId
Returns:
The party line
Party getParty ( Unit  player)

Get the party line that corresponds to the given unit.

Parameters:
playerUnit
Returns:
The party line
object [] getPath ( uint32_t  Area,
uint32_t  srcX,
uint32_t  srcY,
uint32_t  dstX,
int  dstY,
uint32_t  reductionType = 0,
uint32_t  Radius = 20 
)

Creates a path (walking or teleporting) from the source to the destination.

Returns an array of points that form a path from the source to the destination. Takes Area ID(s), source and destination points, walking or teleporting and range as parameters.

Parameters:
AreaThe Area ID to path through.
srcXThe source X coordinate.
srcYThe source Y coordinate.
dstXThe destination X coordinate.
dstYThe destination Y coordinate.
reductionTypeThe type of reduction: {0 - walking, 1 - teleport, 2 - none}
RadiusThe distance between each point.
Returns:
The path as an array of objects with x and y properties.
object [] getPath ( uint32_t  Area,
uint32_t  srcX,
uint32_t  srcY,
uint32_t  dstX,
int  dstY,
uint32_t  reductionType,
uint32_t  Radius,
bool(*)(int32_t x, int32_t y)  reject,
bool(*)(object curPt, int i, object[] pts)  reduce,
int32_t(*)(int32_t x, int32_t y)  mutate[] 
)

Creates a path (walking or teleporting) from the source to the destination.

Returns an array of points that form a path from the source to the destination. Takes Area ID, source and destination points, walking or teleporting, range and reduction or not as parameters.

Parameters:
AreaThe Area ID to path through.
srcXThe source X coordinate.
srcYThe source Y coordinate.
dstXThe destination X coordinate.
dstYThe destination Y coordinate.
reductionTypeThe type of reduction: {0 - walking, 1 - teleport, 2 - none, 3 - user specified}
RadiusThe distance between each point.
rejectCalled on start and end to determine if point is valid.
reduceFunction to determine whether to keep point. Returns true if point should be kept, false if point should be eliminated.
mutateCalled on the start/end if it isn't/is rejected respectively. This is done before path generation.
Returns:
The path as an array of objects with x and y properties.
bool getPlayerFlag ( int  nFirstUnitId,
int  nSecondUnitId,
int  nFlag 
)

Get the relation between two units.

Parameters:
nFirstUnitIdThe unit id for the unit making the relationship.
nSecondUnitIdThe unit id for the unit receiving the relationship.
nFlagThe relationship.
Todo:
Determine what the flags are.
Todo:
Should this return bool instead of int? (i.e. change the d2bs code).
Returns:
Whether or not the relationship is of the type specified.
PresetUnit getPresetUnit ( uint32_t  levelId,
int  nType = 0,
int  nClassId = 0 
)

Get the first PresetUnit of the given type and class id.

Parameters:
levelIdThe area id of the level to look for a PresetUnit in.
nTypeThe type of the PresetUnit. See getUnit for type codes.
nClassIdThe class id to find. See: http://forums.d2botnet.org/viewtopic.php?f=18&t=986 and http://forums.d2botnet.org/viewtopic.php?f=18&t=985 .
Returns:
The first PresetUnit found of type nType and class ID nClassId.
PresetUnit [] getPresetUnits ( uint32_t  levelId,
int  nType = 0,
int  nClassId = 0 
)

Get an array of PresetUnit s of the given type and class id.

Parameters:
levelIdThe area id of the level to look for PresetUnit s in.
nTypeThe type of the PresetUnit. See getUnit for type codes.
nClassIdThe class id to find. See: http://forums.d2botnet.org/viewtopic.php?f=18&t=986 and http://forums.d2botnet.org/viewtopic.php?f=18&t=985 .
Returns:
An array of PresetUnit s found of type nType and class ID nClassId.
Room getRoom ( )

Get the first room in the current area.

Returns:
The first room in the current area.
Room getRoom ( uint32_t  levelId)

Get the first room in area given by level id.

Parameters:
levelIdThe id of the area to get the room from, or 0 to get the room the controlled unit is in.
Returns:
The first room in the area.
Room getRoom ( uint32_t  levelId,
int  x,
int  y 
)

Get the room that the given point is in from the given level id.

Parameters:
levelIdThe level id to look in.
xThe x coordinate to find a room for.
yThe y coordinate to find a room for.
Returns:
The room at the given point.
Room getRoom ( int  x,
int  y 
)

Get the room that the given point is in.

Parameters:
xThe x coordinate to find a room for.
yThe y coordinate to find a room for.
Returns:
The room at the given point.
D2BSScript getScript ( bool  currentScript)

Get the current or first context.

Parameters:
currentScriptWhether to get the current script (true) or the first (false).
Returns:
A D2BSScript object for the request script.
D2BSScript getScript ( int  threadId)

Get a script by thread id.

Parameters:
threadIdThe thread id of the script to get.
Returns:
A D2BSScript object for the script from the given thread.
D2BSScript getScript ( String  name)

Get a script by filename.

Parameters:
nameThe filename of the script to find.
Returns:
A D2BSScript object for the script.
D2BSScript getScript ( )

Get the first script.

Returns:
A D2BSScript representing the first script in the runtime.
String getSkillById ( int  skillId)

Get skill name by ID.

Parameters:
skillIdThe skill ID.
Returns:
The skill name.
int getSkillByName ( String  skillName)

Get skill ID by name.

Parameters:
skillNameThe skill name.
Returns:
The skill ID.
Object getTextSize ( String  string,
int  font,
bool  asObject = false 
)

Get the width and height of the given text in the given font.

Parameters:
stringThe string to get the size of.
fontThe font to use.
asObjectFalse to return as an array.
Returns:
The width and height of the text. 0 - width, 1 - height.
Parameters:
stringThe string to get the size of.
fontThe font to use.
asObjectTrue to return as an object.
Returns:
The width and height of the text. Has properties .width and .height.
int getThreadPriority ( )

Get the priority of the current thread.

Returns:
The priority.
int getTickCount ( )

Get the tick count.

Returns GetTickCount().

Returns:
The tick count.
String getTradeInfo ( int  nMode)

Get the TradeFlag or RecentTradeId.

Get the RecentTradeName.

Todo:
Determine what this means.
Parameters:
nModeWhat to return. 0 - TradeFlag, 2 - RecentTradeId.
Returns:
The TradeFlag or RecentTradeId.

Currently broken, returns null.

Todo:
Determine what these are.
Parameters:
nModeWhat to return. 1 - RecentTradeName.
Returns:
The RecentTradeName.
bool getUIFlag ( int  nUIId)

Get whether or not a UI flag is set.

Todo:
Get a reference for the UI IDs.
Parameters:
nUIIdThe ID of the UI in question.
Returns:
Whether or not the flag is set.
Unit getUnit ( int  type = -1,
uint32_t  classId = (uint32_t)-1,
uint32_t  mode = (uint32_t)-1,
uint32_t  nUnitId = (uint32_t)-1 
)

Get a unit by type, classId, mode and nUnitId.

Parameters:
typeThe type of the unit. Set to -1 to get any unit. 100 gets the cursor item, 101 gets the selected unit.
classIdThe class id of the unit.
modeEither the mode being searched for, or a bitmask with bit 29 set and bits 0-28 corresponding to modes of units being searched for.
nUnitIdThe unique id of the unit.
Returns:
The first unit found that matches the description.
Unit getUnit ( int  type = -1,
String  name = "",
uint32_t  mode = (uint32_t)-1,
uint32_t  nUnitId = (uint32_t)-1 
)

Get a unit by type, name, mode and nUnitId.

Parameters:
typeThe type of the unit. Set to -1 to get any unit. 100 gets the cursor item, 101 gets the selected unit.
nameThe name of the unit to look for.
modeEither the mode being searched for, or a bitmask with bit 29 set and bits 0-28 corresponding to modes of units being searched for.
nUnitIdThe unique id of the unit.
Returns:
The first unit found that matches the description.
bool getWaypoint ( int  nWaypointId)

Get whether the controlled unit has the given waypoint.

Parameters:
nWaypointIdThe area id of the waypoint in question.
Returns:
Whether or not the controlled unit has the waypoint.
void gold ( int  nGold = 0,
int  nMode = 1 
)

Do something with some gold.

Todo:
Determine what the values for nMode are.
Parameters:
nGoldThe amount of gold to move around.
nModeWhat to do with the gold.
bool include ( String  file)

Include file from the scriptDir\libs directory.

Parameters:
fileFilename of the file to include.
Returns:
Whether the inclusion was successful.
bool isIncluded ( String  file)

Determine whether a file has been included yet or not.

File taken from scriptDir\libs\file

Parameters:
fileFilename of the file that might have been included.
Returns:
Whether or not the file has been included.
void joinGame ( String  name,
String  pass = "" 
)

Join a game with the given name and password.

Parameters:
nameThe game name.
passThe game password.
bool js_strict ( )

Get whether or not the JSOPTION_STRICT flag is set.

Returns:
Whether or not the strict flag is set.
void js_strict ( bool  setStrictFlag)

Set or clear the JSOPTION_STRICT flag.

Parameters:
setStrictFlagThe new JSOPTION_STRICT state.
bool keystate ( int  vKey)

Get whether or not a key is pressed.

Returns the value of GetAsyncKeyState.

Parameters:
vKeyThe virtual key code for the key in question. See: http://msdn.microsoft.com/en-us/library/dd375731%28v=VS.85%29.aspx
Returns:
Whether not the key is pressed.
D2BSScript load ( String  file,
  ... 
)

Load file and create a thread with it's main function.

File taken from scriptDir\file. All remaining parameters are passed to the script.

Parameters:
fileThe filename of the script.
Returns:
If successful returns the new script object representing the thread of the thread. Otherwise it returns null.
void loadMpq ( String  path)

Load an mpq file.

Parameters:
pathThe mpq file to load
void login ( String  profile)

Loads the profile from d2bs.ini and gets to the lobby (for battle.net chars) or into a game (for single player characters).

Parameters:
profileThe profile to load.
Exceptions:
StringMay throw one of the following:

"invalid character name" - If it fails to select the character.

"Failed to click the Single button?" - If it fails to click the single player button.

"Failed to click the 'Battle.net' button?" - If it fails to click the battle.net button.

"Failed to click the 'Other Multiplayer' button?" - If it fails to click the Other Multiplayer button.

"Failed to click the 'Open Battle.net' button?" - If it fails to click the Open battle.net button.

"Failed to click the exit button?" - If it is login and fails to click the exit button.

"Failed to set the 'Username' text-edit box.' - If it can't find the username control.

"Failed to set the 'Password' text-edit box." - If it can't find the password control.

"Failed to click the 'Log in' button?" - If it can't click the login button.

"Failed to click the 'Normal Difficulty' button?" - If it can't click the normal button in single player game creation.

"Failed to click the 'Nightmare Difficulty' button?" - If it can't click the nightmare button in single player game creation.

"Failed to click the 'Hell Difficulty' button?" - If it can't click the hell button in single player game creation.

"Invalid single player difficulty level specified!" - If the difficulty level is invalid.

"Unable to connect" - If the unable to connect screen is shown.

"CD-Key in use" - If the cdkey in use screen is shown.

"Bad account or password" - If the username/password wrong screen is shown.

"Realm Down" - If the realm down message is shown.

"Unhandled login location" - If the game is in an unsupported location.

void login ( )

Loads the default (either from config or copydata or DDE) profile from d2bs.ini and gets to the lobby (for battle.net chars) or into a game (for single player characters).

Exceptions:
StringMay throw one of the following:

"invalid character name" - If it fails to select the character.

"Failed to click the Single button?" - If it fails to click the single player button.

"Failed to click the 'Battle.net' button?" - If it fails to click the battle.net button.

"Failed to click the 'Other Multiplayer' button?" - If it fails to click the Other Multiplayer button.

"Failed to click the 'Open Battle.net' button?" - If it fails to click the Open battle.net button.

"Failed to click the 'TCP/IP' button?" - If it fails to click the TCP/IP button.

"Failed to click the 'Host Game' button?" - If it fails to click the Host Game (TCP/IP) button.

"Failed to click the 'Join Game' button?" - If it fails to click the Join Game (TCP/IP) button.

"Failed to click the OK button" - If it fails to click the OK button (TCP/IP enter IP address).

"Failed to find the 'Host IP Address' text-edit box." - If it can't find the host IP address (TCP/IP) text box.

"Could not get the IP address from the profile in the d2bs.ini file." - If the user failed to specify the IP address in the d2bs.ini file.

"Failed to click the exit button?" - If it is login and fails to click the exit button.

"Failed to set the 'Username' text-edit box.' - If it can't find the username control.

"Failed to set the 'Password' text-edit box." - If it can't find the password control.

"Failed to click the 'Log in' button?" - If it can't click the login button.

"Failed to click the 'Normal Difficulty' button?" - If it can't click the normal button in single player game creation.

"Failed to click the 'Nightmare Difficulty' button?" - If it can't click the nightmare button in single player game creation.

"Failed to click the 'Hell Difficulty' button?" - If it can't click the hell button in single player game creation.

"Invalid single player difficulty level specified!" - If the difficulty level is invalid.

"Unable to connect" - If the unable to connect screen is shown.

"CD-Key in use" - If the cdkey in use screen is shown.

"Bad account or password" - If the username/password wrong screen is shown.

"Realm Down" - If the realm down message is shown.

"Unhandled login location" - If the game is in an unsupported location.

String md5 ( String  str)

Takes the md5 hash.

Parameters:
strThe string to hash.
Returns:
The md5 hash of the string.
String md5_file ( String  file)

Take the md5 hash of a file.

Parameters:
fileFilename relative to script path.
Returns:
The md5 hash of the file.
bool playSound ( int  nSoundId)

Play d2 sound by id.

Returns:
true
void quitGame ( )

Quit Diablo II.

Allows the core to shutdown, than terminates the process.

int rand ( int32_t  low,
int32_t  high 
)

Return a random number between low and high.

Uses C rand() when out of game, and D2GAME_D2Rand with the game seed while in game.

Parameters:
lowThe lowest possible integer to return.
highThe highest possible integer to return.
Returns:
A random integer in the range [low,high].
void removeEventListener ( String  event,
Function  eventHandler 
)

Removes a previously added event from the listener list.

Parameters:
eventThe event name (the one used to add the event).
eventHandlerThe handler to remove.
bool say (   ...)

Say the string equivalent of the each of the arguments.

Returns:
true if at least one parameter was sent in.
Object screenToAutomap ( Object  arg)

Convert a point from screen coordinates to automap coordinates.

Parameters:
argAn object with x and y parameters specifying the point.
Returns:
An object with x and y, containing the automap coordinate.
Object screenToAutomap ( int  ix,
int  iy 
)

Convert a point from screen coordinates to automap coordinates.

Parameters:
ixThe x coordinate.
iyThe y coordinate.
Returns:
An object with x and y, containing the automap coordinate.
void scriptBroadcast (   ...)

Broadcast a message to all other scripts.

D2BS calls each scripts scriptmsg event listeners with the messages passed in.

bool selectCharacter ( String  profile)

Select the character from the given profile.

Keeps all details except the character name from old profile.

Parameters:
profileThe profile to get the character name from.
Returns:
Whether or not character swap was successful.
int sendCopyData ( String  windowClassName,
String  windowName,
int32_t  nModeId,
String  data 
)

Send data to another window by means of the WM_COPYDATA message.

Uses FindWindow to get the HWND and SendMessage to send the message.

Parameters:
windowClassNameThe class name of the receiving window.
windowNameThe window name of the receiving window.
nModeIdData to be sent as the dwData member of the copy data.
dataData to be send as the lpData member of the copy data.
Returns:
The result of SendMessage.
int sendCopyData ( HWND  hWnd,
String  dummy,
int32_t  nModeId,
String  data 
)

Send data to another window by means of the WM_COPYDATA message.

Uses SendMessage to send the message to hWnd.

Parameters:
hWndThe handle to the receiving window.
dummyIgnored.
nModeIdData to be sent as the dwData member of the copy data.
dataData to be send as the lpData member of the copy data.
Returns:
The result of SendMessage.
String sendDDE ( int32_t  mode,
String  pszDDEServer,
String  pszTopic,
String  pszItem 
)

Send data to a DDE server by means of DdeClientTransaction.

Parameters:
modeThe mode of transaction to use.

0 - Do command given by pszItem with an XTYP_REQUEST and get the resulting data.

1 - Do command given by pszItem with an XTYP_POKE sending ""

2 - Do command with an XTYP_EXECUTE sending ""

Parameters:
pszDDEServerThe service name of the DDE server to connect to.
pszTopicThe topic with which to start the connection.
pszItemData to be sent.
Returns:
Result data if mode was 0.
String sha1 ( String  str)

Takes the sha1 hash.

Parameters:
strThe string to hash.
Returns:
The sha1 hash of the string.
String sha1_file ( String  file)

Take the sha1 hash of a file.

Parameters:
fileFilename relative to script path.
Returns:
The sha1 hash of the file.
String sha256 ( String  str)

Takes the sha256 hash.

Parameters:
strThe string to hash.
Returns:
The sha256 hash of the string.
String sha256_file ( String  file)

Take the sha256 hash of a file.

Parameters:
fileFilename relative to script path.
Returns:
The sha256 hash of the file.
String sha384 ( String  str)

Takes the sha384 hash.

Parameters:
strThe string to hash.
Returns:
The sha384 hash of the string.
String sha384_file ( String  file)

Take the sha384 hash of a file.

Parameters:
fileFilename relative to script path.
Returns:
The sha384 hash of the file.
String sha512 ( String  str)

Takes the sha512 hash.

Parameters:
strThe string to hash.
Returns:
The sha512 hash of the string.
String sha512_file ( String  file)

Take the sha512 hash of a file.

Parameters:
fileFilename relative to script path.
Returns:
The sha512 hash of the file.
String sqlite_version ( )

Get the sqlite version string (from sqlite3_version).

Returns:
The sqlite version string.
void stop ( bool  stop)

Conditionnaly stop current script.

Parameters:
stopTrue if current script should be stopped.
void stop ( int  stop = 0)

Conditionally stop current script.

Parameters:
stop1 if current script should be stopped.
bool submitItem ( )

Submit the item on the cursor to the open screen (like the add sockets screen).

Returns:
Whether or not it was successful.
void takeScreenshot ( )

Take a screenshot.

Performs the action that pressing print screen (by default) would do

void tradeOk ( )

Hit the OK button to open the trade window.

Throws an error if client not in a proper state to click ok.

void useSkillPoint ( uint16_t  skill,
uint32_t  count = 1 
)

Use a skill point.

BE CAREFUL! This function directly sends packets without checks. If you call this function and do not have the points, or specify an invalid skill, you might get flagged/banned.

Todo:
Come up with a reference for the skill values
Parameters:
skillThe skill to add the points to
countThe number points to spend
void useStatPoint ( uint16_t  statType,
uint32_t  count = 1 
)

Use a stat point.

BE CAREFUL! This function directly sends packets without checks. If you call this function and do not have the points, or specify an invalid stat, you might get flagged/banned.

Todo:
Come up with a reference for the statType values
Parameters:
statTypeThe type of stat to add the points to
countThe number of points to add
int32_t vcRevNumber ( )

Get the D2BS version control revision number.

Returns the svn revision number.

Returns:
The D2BS version control revision number.
String vcRevString ( )

Get the D2BS version control string.

Returns "SVN revision rxxxx" (where xxxx is the revision).

Returns:
The D2BS version control string.
String version ( )

Get the D2BS version string.

Returns:
The D2BS version string.
bool weaponSwitch ( int32_t  dummy)

Get which weapon switch is being used.

Switch the weapons.

Parameters:
dummyAny int other than 0.
Returns:
Which weapon switch is active.
Parameters:
dummy0 to use this mode.
Returns:
true