D2 Message System
กก
The "D2Message System" is similar to "Windows message system" on Win32 plateforms, D2 messages will be sent to your application(d2h modules) when something happens in the game. This mechanism establishes an "Event Driving" interface between the game and your application. There are two types of D2 messages: "Unit Messages" and "This-Player Messages". "Unit Messages" are sent when game-unit related events happen, and "This-Player Messages" are sent when player-related events happen.
To be able to receive and process "Unit Messages", the "OnUnitMessage" function must be implemented in your module. The "OnUnitMessage" function shall be defined as the following:
VOID EXPORT OnUnitMessage(UINT nMessage, LPCGAMEUNIT lpUnit, WPARAM wParam, LPARAM lParam);
Parameters
nMessage
Specifies the message. Please check Unit Messages for a complete list of unit-related messages.
lpUnit
Pointer to a GAMEUNIT struct which contains the game unit information.
wParam
Specifies additional message information. The contents of this parameter depend on the value of the nMessage parameter.
lParam
Specifies additional message information. The contents of this parameter depend on the value of the nMessage parameter.
Remarks
This function will be automatically called by D2Hackit to receive unit-related messages.
To be able to receive and process "This-Player Messages", the "OnThisPlayerMessage" function must be implemented in your module. The "OnThisPlayerMessage" function shall be defined as the following:
VOID EXPORT OnThisPlayerMessage(UINT nMessage, WPARAM wParam, LPARAM lParam);
Parameters
nMessage
Specifies the message. Please check This-Player Messages for a complete list of player-related messages.
wParam
Specifies additional message information. The contents of this parameter depend on the value of the nMessage parameter.
lParam
Specifies additional message information. The contents of this parameter depend on the value of the nMessage parameter.
Remarks
This function will be automatically called by D2Hackit to receive player-related messages.
Message | Description | wParam | lParam |
---|---|---|---|
UM_SPAWN | Unit spawned. |
- |
The lower-order WORD contains the unit's map position x. The higher-order WORD contains the unit's map position y. |
UM_DESTROY | Unit was gone from player's awareness. |
- |
- |
UM_AFFECT | Unit was affected by an affection. Please check Unit Affection Definition for a complete list of unit affection ID's. | 0-Initiative. 1-Passive. | Affection ID. |
UM_DISAFFECT | Unit was no longer affected by an affection. Please check Unit Affection Definition for a complete list of unit affection ID's. | 0-Initiative. 1-Passive. | Affection ID. |
UM_STARTMOVE | Unit started to move. |
- |
The lower-order WORD contains the destination map position x. The higher-order WORD contains the destination map position y. |
UM_ENDMOVE | Unit ended moving. |
- |
The lower-order WORD contains the unit's map position x. The higher-order WORD contains the unit's map position y. |
UM_HPPERCENT | Unit(monster) life percent changed. | Current life percent. |
- |
UM_ATTACK | Unit attacked another unit. | Pointer to a GAMEUNIT struct which contains the victim's unit information. | The lower-order WORD contains the unit's map position x. The higher-order WORD contains the unit's map position y. |
UM_UNDERATTACK | Unit was attacked by another unit. | Pointer to a GAMEUNIT struct which contains the attacker's unit information. | The lower-order WORD contains the unit's map position x. The higher-order WORD contains the unit's map position y. |
UM_DEATH | Unit died. |
- |
- |
UM_CORPSE | Unit corpse appeared. |
- |
The lower-order WORD contains the unit's map position x. The higher-order WORD contains the unit's map position y. |
UM_REVIVED | Unit was revived. i.e., "Fallen" by "Fallen Shaman". | 0-Revived by itself. 1-Revived by another unit. | The lower-order WORD contains the unit's map position x. The higher-order WORD contains the unit's map position y. |
UM_CAVENOTIFY | A cave unit(cave, entrance, stairs, etc) spawned. | Cave type. | The lower-order WORD contains the unit's map position x. The higher-order WORD contains the unit's map position y. |
Message | Description | wParam | lParam |
---|---|---|---|
PM_AFFECT | Player was affected by an affection. Please check Unit Affection Definition for a complete list of unit affection ID's. | 0-Initiative. 1-Passive. | Affection ID. |
PM_DISAFFECT | Player was no longer affected by an affection. Please check Unit Affection Definition for a complete list of unit affection ID's. | 0-Initiative. 1-Passive. | Affection ID. |
PM_SPELLCHARGES | Player's chargeable spell updated. Please check Spell Definition for a complete list of spell ID's. | Spell ID. | Number of charges left. |
PM_SPELLSELECT | Player selected a spell. Please check Spell Definition for a complete list of spell ID's. | 0-Right hand. 1-Left hand. | Spell ID. |
PM_LEVEL | Player's character level changed. |
- |
Current character level. |
PM_HPUP | Player's life increased. | Original life amount. | Current life amount. |
PM_HPDOWN | Player's life decreased. | Original life amount. | Current life amount. |
PM_MANAUP | Player's mana increased. | Original mana amount. | Current mana amount. |
PM_MANADOWN | Player's mana decreased. | Original mana amount. | Current mana amount. |
PM_DEATH | Player died. |
- |
- |
PM_CORPSE | Player corpse appeared. | Corpse ID. | The lower-order WORD contains the corpse's map position x. The higher-order WORD contains the corpse's map position y. |
PM_CORPSEPICKEDUP | Player picked up the corpse. |
- |
- |
PM_HOSTILE | Player was hostiled by another player. | ID of the player who hostiled this player. | Number of players who have expressed hostility to this player. |
PM_UNHOSTILE | Player was unhostiled by another player. | ID of the player who unhostiled this player. | Number of players who have expressed hostility to this player. |
PM_NPCSESSION | Reflects the results of a previous call to "StartNpcSession". | 0-Failed. 1-Succeeded. | ID of the npc unit. |
PM_MAPBLINK | Player's map blinked due to use of waypoint, town portal, teleport spell, etc. | Current act. | The lower-order WORD contains the player's map position x. The higher-order WORD contains the player's map position y. |
PM_MAPCHANGE | Player entered a new map. Please check Map definition for a complete list of map ID's. | Original map ID. | New map ID. |
PM_ENTERTOWN | Player entered town. | Original map ID. | New map ID. |
PM_LEAVETOWN | Player left town. | Original map ID. | New map ID. |
PM_ACTCHANGE | Player entered a new act. | Original act. | New act. |
PM_MOVECOMPLETE | Player completed a job queue. | 0-Failed. 1-Succeeded. |
- |
PM_WEAPONSWITCH | Player performed a weapon switching. |
- |
- |
PM_TOWNFAIL | A previous "Back to town" operation failed. |
- |
- |
PM_INVENTORYFULL | Player's inventory is full. |
- |
- |
PM_EQUIPEVENT | Player equipped/unequipped and item. | Event type. | Pointer to an ITEM struct which contains the item information. |
PM_WPOPEN | Player opened a waypoint. | Current act. | Current map ID. |
PM_STASHOPEN | Player opened the stash. | Current act. |
- |
PM_GAMEREADY | The game is ready. |
- |
- |
PM_INVITATION | Player received a party invitation. | ID of the player who sent the invitation. |
- |
PM_JOINPARTY | Player joined a party. | ID of the player who sent the invitation. |
- |
PM_UICLOSED | All game UI's have been closed by a previous call to me->CloseAllUIs. |
- |
- |