Skip to content

[feature] Add Lua mod infrastructure (OnMonsterDeath, OnItemUse hooks)#8478

Draft
yuripourre wants to merge 1 commit intodiasurgical:masterfrom
yuripourre:lua-monsters-hook
Draft

[feature] Add Lua mod infrastructure (OnMonsterDeath, OnItemUse hooks)#8478
yuripourre wants to merge 1 commit intodiasurgical:masterfrom
yuripourre:lua-monsters-hook

Conversation

@yuripourre
Copy link
Copy Markdown
Collaborator

Provides the C++ bindings and Lua events needed to implement the soulstone mod

New events (assets/lua/devilutionx/events.lua):

  • OnMonsterDeath(monster, deathFrame) - fires every death-animation frame
  • OnItemUse(player, item) -> bool - cancellable item-use event
  • CreateCancellableEvent() helper

New devilutionx.game module:

  • game.prepDoEnding() - trigger the win-screen sequence
  • game.isQuestDone(questId) - check quest completion state
  • game.isMultiplayer() - multiplayer detection

Extended devilutionx.monsters:

  • monster.typeId - integer type ID
  • monster.name - display name

Extended devilutionx.player:

  • player:isOnLevel(n) - dungeon-level check
  • player:say(speech) - hero speech
  • player.isMyPlayer - local-player flag
  • player.level - current dungeon level
  • player.HeroSpeech - enum

Extended devilutionx.items:

  • items.spawnQuestItem(itemIdx, x, y, sendmsg) - spawn with network sync

C++ hooks (no-ops when no Lua mod is registered):

  • LuaEvent("OnMonsterDeath", ...) in MonsterDeath(), before the vanilla Diablo death sequence.
  • LuaEventCancellable("OnItemUse", ...) in UseInventoryItem(), after all existing guards and before the default item-processing path.

@Trihedraf
Copy link
Copy Markdown
Collaborator

This looks good and a big chunk of really useful hooks 👍

@yuripourre
Copy link
Copy Markdown
Collaborator Author

This looks good and a big chunk of really useful hooks 👍

Yeah, I am eager to revive the soulstone mod! Dreaming with an "Act 2" mod. 🤩

@yuripourre
Copy link
Copy Markdown
Collaborator Author

@Trihedraf thanks for reviewing!

@yuripourre yuripourre changed the title feat: Add Lua mod infrastructure (OnMonsterDeath, OnItemUse hooks) [feature] Add Lua mod infrastructure (OnMonsterDeath, OnItemUse hooks) Feb 21, 2026
@yuripourre yuripourre added the enhancement New feature or request label Feb 21, 2026
@yuripourre
Copy link
Copy Markdown
Collaborator Author

This PR can be simiplified, I will refactor this and re-activate when done.

@yuripourre yuripourre marked this pull request as draft May 2, 2026 18:32
@yuripourre yuripourre added the pr size:large Pull Requests that add more than 100 lines label May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request pr size:large Pull Requests that add more than 100 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants