D2BS
Public Member Functions | Public Attributes

Me Class Reference

The class that represents the controlled unit. More...

List of all members.

Public Member Functions

bool getNext ()
 Get the next unit that matches the originally given name or class id and originally specified mode.
bool getNext (String szName)
 Get the next unit that matches the given name and originally specified mode.
bool getNext (int dwClassId)
 Get the next unit that matches the given class id and originally specified mode.
bool getNext (String szName, int dwMode)
 Get the next unit that matches the given name and mode.
bool getNext (int dwClassId, int dwMode)
 Get the next unit that matches the given class id and mode.
void cancel ()
 Cancel some form of interaction.
bool repair ()
 Try to repair.
bool useMenu (int menuItem)
 Use an NPC menu.
bool interact ()
 Interact with the unit.
bool interact (int destId)
 Interact with a waypoint.
Unit getItem (String name, uint32_t mode=(uint32_t)-1, uint32_t nUnitId=(uint32_t)-1)
 Get an item from inventory by name, mode and nUnitId.
Unit getItem (uint32_t classId=(uint32_t)-1, uint32_t mode=(uint32_t)-1, uint32_t nUnitId=(uint32_t)-1)
 Get an item from inventory by classId, mode and nUnitId.
Unit[] getItems ()
 Get all items from inventory.
Unit getMerc ()
 Get a player's merc.
int getMercHP ()
 Get the merc's HP.
String getSkill (int hand)
 Get skill name from hand.
int getSkill (int hand)
 Get skill id from hand.
int[][] getSkill (int dummy)
 Get all skills.
int getSkill (int nSkillId, int nExt)
 Calls D2COMMON_GetSkillLevel and returns the result.
Unit getParent ()
 Gets the parent of a unit.
String getParent ()
 Gets the parent of a unit.
void overhead (Object message)
 Puts the string equivalent of message over the unit.
void revive ()
 Revive the character.
int getFlags ()
 Returns the item flags.
double getStat (int nStat, int nSubIndex=0)
 Get a stat by stat id and sub index.
int getStat (int nStat, int nSubIndex=0)
 Get a stat by stat id and sub index.
int[][] getStat (int nStat, int nSubIndex=0)
 Get an array of all the stats of the item.
bool getState (int nState)
 TODO: Handle getStat(-2);.
int getPrice (Unit npc, int buysell=0)
 Get the price of the item at a given npc, with choice of buying or selling, in the current difficulty.
int getPrice (int npcId=148, int buysell=0)
 Get the price of the item at a given npc (by id), which choice of buying or selling, in the current difficulty.
int getPrice (Unit npc, int buysell, int difficulty)
 Get the price of the item at a given npc, with choice of buying or selling, in a given difficulty.
int getPrice (int npcId, int buysell, int difficulty)
 Get the price of the item at a given npc (by id), with choice of buying or selling, in a given difficulty.
bool getEnchant (int nEnchant)
 Determine whether or not a unit has a given enchant.
bool shop (int dwMode)
 Shop with a given npc, either buying or selling.
bool setSkill (String skillName, int nHand)
 Set the skill on the given hand to be skill with name skillName.
bool setSkill (int nSkillId, int nHand)
 Set the skill on the given hand to be skill with id nSkillId.
bool setSkill (String skillName, int nHand, Unit item)
 Set the skill on the given hand to be skill with name skillName.
bool setSkill (int nSkillId, int nHand, Unit item)
 Set the skill on the given hand to be skill with id nSkillId.
void move (int x, int y)
 Move to the given location.
void move ()
 Move to this unit.
int getQuest (int nAct, int nQuest)
 Get the quest flag for a quest specified by act and quest number.
int getMinionCount (int nType)
 Get the number of minions of a certain type.
int getRepairCost (int nNpcClassId=154)
 Get price to repair this unit at the current npc given by nNpcClassId.
int getItemCost (int nMode, Unit npc)
 Get the cost to do something (buy, sell, repair) with the given item, at the given npc.
int getItemCost (int nMode, Unit npc, int nDifficulty)
 Get the cost to do something (buy, sell, repair) with the given item, at the given npc, in the given difficulty.
int getItemCost (int nMode, int nNpcClassId=154)
 Get the cost to do something (buy, sell, repair) with the given item, at the given npc.
int getItemCost (int nMode, int nNpcClassId, int nDifficulty)
 Get the cost to do something (buy, sell, repair) with the given item, at the given npc, in the given difficulty.

Public Attributes

int type
 The type of the unit.
int classId
 The class id of the object.
int mode
 The mode of the unit.
String name
 The name of the unit.
int mapid
 The seed used to create the map.
int act
 The act where the unit is currently located.
int gid
 The unit unique id.
int x
 The x location of the unit.
int y
 The y location of the unit.
int targetx
 The target x location of the unit.
int targety
 The target y location of the unit.
int area
 The id of the area (level) the unit is located in.
int hp
 The unit's current health.
int hpmax
 The unit's maximum health.
int mp
 The unit's current mana.
int mpmax
 The unit's maximum mana.
int stamina
 The unit's current stamina.
int staminamax
 The unit's maximum stamina.
int charlvl
 The character level.
int itemcount
 The number of items in inventory.
double owner
 The unit id of the owner of the unit.
int ownertype
 The type of owner.
int spectype
 The special type of the unit.
int direction
 The direction of the unit.
String code
 The three digit code for an item.
String prefix
 The magic prefix of the item.
String suffix
 The magic suffix of the item.
int prefixnum
 The id code for the magic prefix.
int suffixnum
 The id code for the magic suffix.
String fname
 The full name of an item.
int quality
 The item quality.
int node
 No clue.
int location
 The location of the item (ground, inventory, stash, etc.).
int sizex
 The x size of the item.
int sizey
 The y size of the item.
int itemType
 The type of the item.
String description
 The description of the item.
int bodylocation
 The equipped location of the item.
int ilvl
 Item level.
int runwalk
 Whether the controlled character is in the always run mode or not.
int weaponswitch
 Set the weapon switch.
String account
 The account name used to log on to the account.
String charname
 The character name.
int diff
 The difficulty of the game.
int maxdiff
 The maximum difficulty available.
String gamename
 The name of the game.
String gamepassword
 The password of the game.
String gameserverip
 A string representation of the IPv4 address of the game server.
double gamestarttime
 Some sort of representation of the start time of the game.
int gametype
 The game type, expansion or not.
bool itemoncursor
 Whether or not there is an item on the cursor.
bool ladder
 Whether or not the game is a ladder game.
int ping
 The ping in milliseconds.
int fps
 The frame rate.
int playertype
 Whether or not the gametype is hardcore.
String realm
 The realm name.
String realmshort
 The short realm name.
int mercrevivecost
 The cost to revive the merc.
int chickenhp
 The health at which to chicken if the character drops below.
int chickenmp
 The mana at which to chicken if the character drops below.
bool quitonhostile
 Whether to chicken if another player hostiles the controlled character.
bool blockKeys
 Block keys...
bool blockMouse
 Block mouse...
bool gameReady
 Whether or not the game window is in the game.
String profile
 The profile currently being used.
bool nopickup
 Whether the game is set to not pick up items or not.
double pid
 The process id of Diablo II.
int screensize
 The window size.
String windowtitle
 The window title.
bool ingame
 True if the game is not at menu.
bool quitonerror
 Whether or not to quit when there's an error.
int maxgametime
 The max time in milliseconds to stay in game before the game auto-quits.

Detailed Description

The class that represents the controlled unit.

Technically, also called Unit, but since C++ doesn't support class overloading, called it Me here instead.


Member Function Documentation

void Me::cancel ( )

Cancel some form of interaction.

If there is scrolling text, cancel it. If you are interacting with an NPC, stop interacting. If you have an item on your cursor, drop it. Otherwise call D2CLIENT_CloseInteract.

bool Me::getEnchant ( int  nEnchant)

Determine whether or not a unit has a given enchant.

Parameters:
nEnchantEnchantment id.
Returns:
Whether or not the unit has the enchantment.
int Me::getFlags ( )

Returns the item flags.

Returns:
Item flags:

0x00000001 - Equipped

0x00000008 - In socket

0x00000010 - Identified

0x00000040 - Weapon/shield is in the active weapon switch

0x00000080 - Weapon/shield is in the inactive weapon switch

0x00000100 - Item is broken

0x00000400 - Full rejuv

0x00000800 - Socketed

0x00002000 - In the trade or gamble screen

0x00004000 - Not in a socket

0x00010000 - Is an ear

0x00020000 - A starting item (worth only 1 gold)

0x00200000 - Rune, or potion, or mephisto's soulstone

0x00400000 - Ethereal

0x00800000 - Is an item

0x01000000 - Personalized

0x04000000 - Runeword

Source: http://subversion.assembla.com/svn/d2bs/scripts/YAMB/libs/YAMB/common/YAM-Common.dbl r1086

Unit Me::getItem ( String  name,
uint32_t  mode = (uint32_t)-1,
uint32_t  nUnitId = (uint32_t)-1 
)

Get an item from inventory by name, mode and nUnitId.

Parameters:
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 item found that matches the description.
Unit Me::getItem ( uint32_t  classId = (uint32_t)-1,
uint32_t  mode = (uint32_t)-1,
uint32_t  nUnitId = (uint32_t)-1 
)

Get an item from inventory by classId, mode and nUnitId.

Parameters:
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 item found that matches the description.
int Me::getItemCost ( int  nMode,
int  nNpcClassId,
int  nDifficulty 
)

Get the cost to do something (buy, sell, repair) with the given item, at the given npc, in the given difficulty.

Parameters:
nModeWhat to do: 0 - buy, 1 - sell, 2 - repair.
nNpcClassIdThe class id of the npc to check the price with.
nDifficultyThe difficulty to check the price in.
Returns:
The price.
int Me::getItemCost ( int  nMode,
Unit  npc 
)

Get the cost to do something (buy, sell, repair) with the given item, at the given npc.

Parameters:
nModeWhat to do: 0 - buy, 1 - sell, 2 - repair.
npcThe npc to check the price with.
Returns:
The price.
int Me::getItemCost ( int  nMode,
Unit  npc,
int  nDifficulty 
)

Get the cost to do something (buy, sell, repair) with the given item, at the given npc, in the given difficulty.

Parameters:
nModeWhat to do: 0 - buy, 1 - sell, 2 - repair.
npcThe npc to check the price with.
nDifficultyThe difficulty to check the price in.
Returns:
The price.
int Me::getItemCost ( int  nMode,
int  nNpcClassId = 154 
)

Get the cost to do something (buy, sell, repair) with the given item, at the given npc.

Parameters:
nModeWhat to do: 0 - buy, 1 - sell, 2 - repair.
nNpcClassIdThe class id of the npc to check the price with.
Returns:
The price.
Unit [] Me::getItems ( )

Get all items from inventory.

Returns:
An array of all the items from inventory.
Unit Me::getMerc ( )

Get a player's merc.

The unit being operated on should be a player.

Returns:
The merc if there is one, null otherwise.
int Me::getMercHP ( )

Get the merc's HP.

The reported HP is a percentage.

Returns:
The merc's HP percentage.
int Me::getMinionCount ( int  nType)

Get the number of minions of a certain type.

Parameters:
nTypeThe type of the minions.
Returns:
The number of minions of the specified type.
bool Me::getNext ( int  dwClassId,
int  dwMode 
)

Get the next unit that matches the given class id and mode.

Parameters:
dwClassIdThe class id to look for.
dwModeEither the mode being searched for, or a bitmask with bit 29 set and bits 0-28 corresponding to modes of units being searched for.
Returns:
Whether another unit was found.
bool Me::getNext ( String  szName,
int  dwMode 
)

Get the next unit that matches the given name and mode.

Parameters:
szNameThe name to look for.
dwModeEither the mode being searched for, or a bitmask with bit 29 set and bits 0-28 corresponding to modes of units being searched for.
Returns:
Whether another unit was found.
bool Me::getNext ( String  szName)

Get the next unit that matches the given name and originally specified mode.

Parameters:
szNameThe name to look for.
Returns:
Whether another unit was found.
bool Me::getNext ( int  dwClassId)

Get the next unit that matches the given class id and originally specified mode.

Parameters:
dwClassIdThe class id to look for.
Returns:
Whether another unit was found.
bool Me::getNext ( )

Get the next unit that matches the originally given name or class id and originally specified mode.

Returns:
Whether another unit was found.
Unit Me::getParent ( )

Gets the parent of a unit.

This function is used for monster and item units.

Returns:
The parent unit.
String Me::getParent ( )

Gets the parent of a unit.

This function is used for object units.

Returns:
The parent's name.
int Me::getPrice ( int  npcId,
int  buysell,
int  difficulty 
)

Get the price of the item at a given npc (by id), with choice of buying or selling, in a given difficulty.

Deprecated:
Use getItemCost instead.
Todo:
Determine the meaning of "buysell".
Parameters:
npcIdThe id of the npc to determine the price at.
buysellUnknown
difficultyThe difficulty of interest: 0 - normal, 1 - nightmare, 2 - hell
Returns:
The price requested.
int Me::getPrice ( Unit  npc,
int  buysell,
int  difficulty 
)

Get the price of the item at a given npc, with choice of buying or selling, in a given difficulty.

Deprecated:
Use getItemCost instead.
Todo:
Determine the meaning of "buysell".
Parameters:
npcThe npc to determine the price at.
buysellUnknown
difficultyThe difficulty of interest: 0 - normal, 1 - nightmare, 2 - hell
Returns:
The price requested.
int Me::getPrice ( Unit  npc,
int  buysell = 0 
)

Get the price of the item at a given npc, with choice of buying or selling, in the current difficulty.

Deprecated:
Use getItemCost instead.
Todo:
Determine the meaning of "buysell".
Parameters:
npcThe npc to determine the price at.
buysellUnknown
Returns:
The price requested.
int Me::getPrice ( int  npcId = 148,
int  buysell = 0 
)

Get the price of the item at a given npc (by id), which choice of buying or selling, in the current difficulty.

Deprecated:
Use getItemCost instead.
Todo:
Determine the meaning of "buysell".
Parameters:
npcIdThe id of the npc to determine the price at.
buysellUnknown
Returns:
The price requested.
int Me::getQuest ( int  nAct,
int  nQuest 
)

Get the quest flag for a quest specified by act and quest number.

Parameters:
nActThe act of the quest.
nQuestThe quest number.
Returns:
The quest flag for the specified quest.
int Me::getRepairCost ( int  nNpcClassId = 154)

Get price to repair this unit at the current npc given by nNpcClassId.

Parameters:
nNpcClassIdThe class id of the npc to get the price for repair at.
Returns:
The price to repair the given unit.
String Me::getSkill ( int  hand)

Get skill name from hand.

Parameters:
handHand to get the skill name off.

0 - Right hand

1 - Left hand

Returns:
Skill name.
int Me::getSkill ( int  hand)

Get skill id from hand.

Parameters:
handHand to get the skill id off.

2 - Right hand

3 - Left hand

Returns:
Skill id.
int [][] Me::getSkill ( int  dummy)

Get all skills.

Gets all skill ids, along with corresponding base and total skill levels.

Parameters:
dummyShould be 4.
Returns:
An array of arrays of integers. Inside the inner array the 0th index is the skill id, the 1st index is the base skill level and the 2nd index is the total skill level. Only the first 256 skills are read.
int Me::getSkill ( int  nSkillId,
int  nExt 
)

Calls D2COMMON_GetSkillLevel and returns the result.

Todo:
Figure out what D2COMMON_GetSkillLevel does.
Returns:
Whatever D2COMMON_GetSkillLevel returns.
double Me::getStat ( int  nStat,
int  nSubIndex = 0 
)

Get a stat by stat id and sub index.

Used for every stat except 6-11.

Parameters:
nStatThe stat type. See http://forums.d2botnet.org/viewtopic.php?f=18&t=989
nSubIndexA subindex to a certain type of stat. For instance a specific skill for the +1 to skill tab stat.
Returns:
The stat value.
int Me::getStat ( int  nStat,
int  nSubIndex = 0 
)

Get a stat by stat id and sub index.

Used for stats 6-11.

Parameters:
nStatThe stat type. See http://forums.d2botnet.org/viewtopic.php?f=18&t=989
nSubIndexA subindex to a certain type of stat. For instance a specific skill for the +1 to skill tab stat.
Returns:
The stat value.
int [][] Me::getStat ( int  nStat,
int  nSubIndex = 0 
)

Get an array of all the stats of the item.

Parameters:
nStatSet to -1.
nSubIndexIgnored.
Returns:
An array of the first 64 stats. The indices of the inner array are: 0 - nStat, 1 - nSubIndex, 2 - nValue.
bool Me::getState ( int  nState)

TODO: Handle getStat(-2);.

Return whether or not the unit has a given state.

Parameters:
nStateThe state id.
Returns:
Whether or not the unit has the state.
bool Me::interact ( )

Interact with the unit.

If the unit is an item in inventory pick it up. Otherwise click it on the map.

bool Me::interact ( int  destId)

Interact with a waypoint.

If the unit is an object, assume it's a waypoint, and take it.

Parameters:
destIdThe area id of the destination to select.
void Me::move ( int  x,
int  y 
)

Move to the given location.

Parameters:
xThe x location.
yThe y location.
bool Me::repair ( )

Try to repair.

Need to be able to find unit that you're trying to repair with. That means the unit needs to still be in the server unit hash table.

Returns:
true if successful.
void Me::revive ( )

Revive the character.

BE CAREFUL! This function directly sends packets without checks. If you call this function and are not dead, you might get flagged/banned.

bool Me::setSkill ( String  skillName,
int  nHand 
)

Set the skill on the given hand to be skill with name skillName.

Waits up to one second for the skill to be set.

Todo:
Fix argc < 1, should be argc < 2
Parameters:
skillNameName of the skill to put up.
nHandHand to put the skill on. non-zero left, 0 - right.
Returns:
Whether operation was successful.
bool Me::setSkill ( int  nSkillId,
int  nHand 
)

Set the skill on the given hand to be skill with id nSkillId.

Waits up to one second for the skill to be set.

Todo:
Fix argc < 1, should be argc < 2
Parameters:
nSkillIdId of the skill to put up.
nHandHand to put the skill on. non-zero left, 0 - right.
Returns:
Whether operation was successful.
bool Me::setSkill ( int  nSkillId,
int  nHand,
Unit  item 
)

Set the skill on the given hand to be skill with id nSkillId.

Waits up to one second for the skill to be set.

Todo:
Fix argc < 1, should be argc < 2
Parameters:
nSkillIdId of the skill to put up.
nHandHand to put the skill on. non-zero left, 0 - right.
itemThe item that the skill is attached to.
Returns:
Whether operation was successful.
bool Me::setSkill ( String  skillName,
int  nHand,
Unit  item 
)

Set the skill on the given hand to be skill with name skillName.

Waits up to one second for the skill to be set.

Todo:
Fix argc < 1, should be argc < 2
Parameters:
skillNameName of the skill to put up.
nHandHand to put the skill on. non-zero left, 0 - right.
itemThe item that the skill is attached to.
Returns:
Whether operation was successful.
bool Me::shop ( int  dwMode)

Shop with a given npc, either buying or selling.

Parameters:
dwModeWhat to do with the item. 1 - Sell, 2 - Buy, 6 - ?
Returns:
Whether or not the shop went through.
bool Me::useMenu ( int  menuItem)

Use an NPC menu.

Need to be able to find unit that you're trying to repair with. That means the unit needs to still be in the server unit hash table.

Parameters:
menuItemIndex of the menu item to click.
Returns:
true if menu was found.

Member Data Documentation

Block keys...

Todo:
Determine what this means.

Block mouse...

Todo:
Determine what this means.

The equipped location of the item.

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

The character level.

The level that determines stat points, skill levels, etc.

String Me::code

The three digit code for an item.

See: http://forums.d2botnet.org/viewtopic.php?f=18&t=991

The difficulty of the game.

0 - Normal

1 - Nightmare

2 - Hell

The direction of the unit.

Todo:
Figure out what the direction is.

Some sort of representation of the start time of the game.

Todo:
Figure out what this represents.

The game type, expansion or not.

Todo:
Determine what the values are.

The unit unique id.

Referred to simply as the unit id. Used along with the unit type to uniquely identify the unit.

Item level.

Used for things like item stat rolling.

bool Me::ingame

True if the game is not at menu.

Todo:
Determine when this is different from gameReady. Maybe when going between acts for instance.

The type of the item.

Todo:
Put together a reference for item type.

The location of the item (ground, inventory, stash, etc.).

0 - Ground

1 - Equipped

2 - Belt

3 - Inventory

4 - Store

5 - Trade

6 - Cube

7 - Stash

The maximum difficulty available.

See Me::diff for details.

No clue.

Todo:
Get a clue.

The type of owner.

type

The item quality.

1 - Low quality

2 - Normal

3 - Superior

4 - Magic

5 - Set

6 - Rare

7 - Unique

8 - Crafted

Source: botNET

Whether or not to quit when there's an error.

Todo:
Figure out if this means js errors.

The short realm name.

Todo:
Determine the difference between this and realm.

Whether the controlled character is in the always run mode or not.

0 - Walk unless directed to run 1 - Always run

The window size.

Todo:
Determine what the numbers mean.

The special type of the unit.

Represents things like unique, minion, boss, etc.

1 - "Normal" Boss 2 - Champion 4 - Boss 8 - Minion

The target x location of the unit.

Where the game is taking the unit.

The target y location of the unit.

Where the game is taking the unit.

The type of the unit.

0 - Player

1 - NPC

2 - Object

3 - Missile

4 - Item

5 - Warp

Source: botNET