change event handlers in might nad magic 678 merge

The role-playing games (I-X) that started it all and the various spin-offs (including Dark Messiah).
Driego
Leprechaun
Leprechaun
Posts: 11
Joined: 27 Aug 2022

change event handlers in might nad magic 678 merge

Unread postby Driego » 19 Jul 2023, 18:23

I am trying to modify event.

On special nervy arcomage game event (Have I won here , have I not won here , wheer are tavern i had not won ...)
Wanted to do a script with check or easiest way to check it with MM console.

For the manual way in a console I created this post.
https://www.celestialheavens.com/forum/10/17742

the better idea was on start or end of game to show textmessage "you had won in this taverm" or "you had not won in this tavern".

I thought the lost ending event (triggered on pressing <ESC>) could be a good option to implement addition text output.

I can implement code easy in the win handler but entry handler or lost handler was not able to do that.

i think this assembler code will do the stuff. itried to change some of the jmp comand but failing. I am not really know what ia doing with calculation of jump adresses.

Code: Select all

NewCode = mem.asmproc([[
	push eax
	push ecx
	call absolute ]] .. GetCurHouseIndexByType .. [[;
	nop; memhook here.
	nop;
	nop;
	nop;
	nop;
	cmp eax, 0x0
	je @end2
	cmp eax, ]] .. OldTavCount .. [[;
	jg @end2
	pop ecx
	pop eax
	cmp byte [ds:ecx], 0x0
	jnz absolute 0x40e868
	jmp absolute 0x40e80f
	@end2:
	pop eax
	pop ecx
	jmp absolute 0x40e868]])
	mem.asmpatch(0x40e80a, "jmp absolute " .. NewCode)
	mem.hook(NewCode+7, function(d)
		local t = {House = mem.u4[CurHouseID], result = mem.u4[0x516e1c], Handled = false}
		events.call("ArcomageMatchEnd", t)
		if t.Handled then
			d.eax = 0x0
		end
	end)

Can someone help how I can integrate here code before starting the game or if you lost the game(I think really lossing is tthe same code as pressing <ESC>) ?

Return to “Might and Magic”

Who is online

Users browsing this forum: No registered users and 15 guests