MMExtension v2.2 + MMEditor v2.1 Level Editor [June 4, 2019]

The role-playing games (I-X) that started it all and the various spin-offs (including Dark Messiah).
User avatar
BTB
Peasant
Peasant
Posts: 93
Joined: 21 Aug 2011
Location: Houston, TX
Contact:

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby BTB » 08 Mar 2019, 16:44

Hey, all... glad to see everything is going well around here. Hopefully will be able to actually get back around to this now that my other projects are taken care of for the moment.
Rodril wrote:Seems, file host has not handle the video, i've uploaded it to Youtube: https://youtu.be/lipriutf3SI .
I've forgot to mention, this script works only with MM8.
Script generates few new tables in "...Data\Tables folder", one of them is "Potion settings.txt", something can be edit there.
Also there is new array in game - evt.PotionEffects . It consist of functions, indexed according to "Pot Id" column of TXT file. How it works: when player uses potion (drink it or uses on other item), if evt.PotionEffects have function at index of this potion, function will be executed, if function returns "true" original behaivor of potion is bypassed.
Here is example, effect is senseless, just to see it in action:

Code: Select all

-- According to "Potion settings.txt", 1 is item 221 - catalyst potion
evt.PotionEffects[1] = function(IsDrunk, Target, Power)
 -- IsDrunk - true if player drinks potion, false - if potion used on item
 -- Target - Player structure if IsDrunk == true, otherwise Item structure
 -- Power - number - power of potion
	if IsDrunk then
		Target.HP = Target.HP/2
	else
		Item.Broken = true -- note, first you have to allow potion to be used on items in "Potion settings.txt"
	end
	
	return true -- don't execute usual effect
end
More detailed explanation is in video, i'm sure it is possible to watch it now.
So... just for example, let's say that I wanted to swap the effects of Blue and Green potions so that Blue is awaken and Green is restore magic. From what I see in this video, it looks like what I'd need to do is just add two new ones? Or is there something more obvious that I'm missing?
"You don't have to be a vampire to die like one... bitch." -Simon Belmont

Rodril
Swordsman
Swordsman
Posts: 556
Joined: 18 Nov 2016

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby Rodril » 08 Mar 2019, 17:18

MrHarmondale1184 wrote:The thing is, I would like to know how (if possible) can I make the summoned 'monster' to stand passively around, just like the Castle Harmondale guards for example. As the default behavior is that the summoned 'monster' moves around.
Yes, use:

Code: Select all

mon.AIType = 3
mon.MoveType = 3
But in outdoor maps it works weird, if you start shout at friendly monster.
BTB wrote:So... just for example, let's say that I wanted to swap the effects of Blue and Green potions so that Blue is awaken and Green is restore magic. From what I see in this video, it looks like what I'd need to do is just add two new ones? Or is there something more obvious that I'm missing?
Not necessary to add new potions, you can rescript effects of existing ones. Example:

Code: Select all

evt.PotionEffects[3] = function(IsDrunk, Target, Power) -- Magic Potion
	if IsDrunk then
		-- Remove asleep condition
		Target.Conditions[const.Condition.Asleep] = 0
		return true -- don't execute original behaivor
	end
end

evt.PotionEffects[7] = function(IsDrunk, Target, Power) -- Awaken
	if IsDrunk then
		-- Add 10 + potion's power SP
		Target.SP = math.min(Target:GetFullSP(), Target.SP + Power + 10)
		return true -- don't execute original behaivor
	end
end

User avatar
BTB
Peasant
Peasant
Posts: 93
Joined: 21 Aug 2011
Location: Houston, TX
Contact:

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby BTB » 08 Mar 2019, 18:23

Sweeeeeeeeeeeeet. You seem to have a really good idea of what you're doing and I hope you don't mind if I pump you for more information. I have a lot I want to do, but as long as I have some basic examples to learn from, I shouldn't need too much in the way of guidance.

The potion example makes perfect sense only thing I can't figure out is which PotionEffects.evt corresponds to which potion. Is there a reference you can point me toward where I can find this? Nothing in the MME GitHub seems to tell me.

I remember you mentioning last year that you haven't managed to suss out how to change skill levels for spells and/or their effects (i.e. setting Charm from expert level to basic or turning Stun into a Mind spell instead of Earth)... I'm guessing that much is still true?

The other major ticket items I have at the moment are editing the base recovery rates for weapons and armor and skill level bonuses.
Last edited by BTB on 08 Mar 2019, 18:29, edited 1 time in total.
"You don't have to be a vampire to die like one... bitch." -Simon Belmont

Rodril
Swordsman
Swordsman
Posts: 556
Joined: 18 Nov 2016

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby Rodril » 09 Mar 2019, 10:45

BTB wrote:The potion example makes perfect sense only thing I can't figure out is which PotionEffects.evt corresponds to which potion. Is there a reference you can point me toward where I can find this? Nothing in the MME GitHub seems to tell me.
Check "Potion settings.txt" in "...Data\Tables" folder, "RemoveItemLimits.lua" will generate it.
BTB wrote:I remember you mentioning last year that you haven't managed to suss out how to change skill levels for spells and/or their effects (i.e. setting Charm from expert level to basic or turning Stun into a Mind spell instead of Earth)... I'm guessing that much is still true?
Yes.
BTB wrote:The other major ticket items I have at the moment are editing the base recovery rates for weapons and armor and skill level bonuses.
As far as i know, there is no convenient way to change these values yet. For weapon delays you can use template:

Code: Select all

mem.u4[0x4fdf88] = 100 -- Staff
mem.u2[0x4fdf88+2] = 90 -- Sword
mem.u2[0x4fdf88+4] = 60 -- Dagger
mem.u2[0x4fdf88+6] = 100 -- Axe
mem.u2[0x4fdf88+8] = 80 -- Spear
mem.u2[0x4fdf88+10] = 100 -- Bow
mem.u2[0x4fdf88+12] = 80 -- Mace
mem.u2[0x4fdf88+14] = 30 -- Blaster
For rest - i don't know.

User avatar
BTB
Peasant
Peasant
Posts: 93
Joined: 21 Aug 2011
Location: Houston, TX
Contact:

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby BTB » 09 Mar 2019, 13:54

Editing skill bonuses is definitely possible - at least if you're using existing bonuses. I just recall Greyface telling me awhile back that he hadn't added hooks yet. Guess I'll have to defer to him.

Something you may be able to tell me, though... artifacts and relics. I see examples on GitHub of how to ADD effects to them, but how would I go about removing them do you know?

(Thank you, by the way. You've been a great help.)
Last edited by BTB on 09 Mar 2019, 13:55, edited 1 time in total.
"You don't have to be a vampire to die like one... bitch." -Simon Belmont

Rodril
Swordsman
Swordsman
Posts: 556
Joined: 18 Nov 2016

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby Rodril » 10 Mar 2019, 17:14

BTB wrote:Something you may be able to tell me, though... artifacts and relics. I see examples on GitHub of how to ADD effects to them, but how would I go about removing them do you know?
These effects are hardcoded, only way to remove them is editing .exe file. If you familiar with disassembly, you can use these functions https://grayface.github.io/mm/ext/ref/#Core-RSMem.lua to change game code upon game launching. Most of mechanics are binded to item index, searching for constants equal to item index will probably lead you to needed algorythms.
Last edited by Rodril on 10 Mar 2019, 17:14, edited 1 time in total.

MrHarmondale1184
Leprechaun
Leprechaun
Posts: 2
Joined: 05 Mar 2019

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby MrHarmondale1184 » 10 Mar 2019, 18:42

Thank you Rodril!

User avatar
BTB
Peasant
Peasant
Posts: 93
Joined: 21 Aug 2011
Location: Houston, TX
Contact:

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby BTB » 22 Mar 2019, 06:40

Rodril wrote:
BTB wrote:Something you may be able to tell me, though... artifacts and relics. I see examples on GitHub of how to ADD effects to them, but how would I go about removing them do you know?
These effects are hardcoded, only way to remove them is editing .exe file. If you familiar with disassembly, you can use these functions https://grayface.github.io/mm/ext/ref/#Core-RSMem.lua to change game code upon game launching. Most of mechanics are binded to item index, searching for constants equal to item index will probably lead you to needed algorythms.
I'm sensing that I'm likely going to have to learn some coding to really dig into what I'm after with a few things like this and changing spell effects. And I think I'm getting a little ahead of myself because I'm still not familiar with some of the basics.

So let me make sure I understand this...

I place the Potions.lua you provided in my scripts folder and that will generate a text file which I can use to customize potions with code that looks like this:

Code: Select all

evt.PotionEffects[3] = function(IsDrunk, Target, Power) -- Magic Potion
   if IsDrunk then
      -- Remove asleep condition
      Target.Conditions[const.Condition.Asleep] = 0
      return true -- don't execute original behaivor
   end
end
So, where exactly does that code GO? I'm assuming based on my past experience here that I create a new .lua file with just that code in it and place it in the scripts folder? Or do I append it to the Potions.lua script you gave me?
"You don't have to be a vampire to die like one... bitch." -Simon Belmont

Queegon
Leprechaun
Leprechaun
Posts: 2
Joined: 20 Mar 2019

Re:

Unread postby Queegon » 22 Mar 2019, 09:35

GrayFace wrote:Untested script to change stats effect breakpoints table in MM7 (for MM6 and MM8 other addresses would be needed):

Code: Select all

local vals = {
	500, 30,
	400, 25,
	350, 20,
	300, 19,
	275, 18,
	250, 17,
	225, 16,
	200, 15,
	175, 14,
	150, 13,
	125, 12,
	100, 11,
	75, 10,
	50, 9,
	40, 8,
	35, 7,
	30, 6,
	25, 5,
	21, 4,
	19, 3,
	17, 2,
	15, 1,
	13, 0,
	11, -1,
	9, -2,
	7, -3,
	5, -4,
	3, -5,
	0, -6
}

for i = 0, #vals - 2, 2 do
	mem.i2[0x4EDEA4 + i] = vals[i + 1]
	mem.i1[0x4EDEE0 + i/2] = vals[i + 2]
end
Place it into Scripts\General folder and tweak the 'vals' table as you like.
Hey there, any chance to share the addresses for MM8? Or where can I find them myself? Thanks in advance.

Rodril
Swordsman
Swordsman
Posts: 556
Joined: 18 Nov 2016

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby Rodril » 23 Mar 2019, 09:33

BTB wrote:I place the Potions.lua you provided in my scripts folder and that will generate a text file which I can use to customize potions with code that looks like this:
Not exactly. Script "RemoveItemsLimits.lua" have to be placed into "...Scripts\Structs" folder. It will generate text table with basic properties for reagents and potions in "...Data\Tables" folder ("Potion settings.txt" and "Reagent settings.txt"). Then you have to create your own lua scripts in "...Scripts\Global" folder, where you can change effects of potions using "evt.PotionEffects" list.
To make example work, all actions you have to do are:
1. Put "RemoveItemsLimits.lua" into "...Scripts\Structs" folder.
2. Create "Example.lua" in "...Scripts\Global", open it with any text editor and paste code there.

User avatar
BTB
Peasant
Peasant
Posts: 93
Joined: 21 Aug 2011
Location: Houston, TX
Contact:

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby BTB » 24 Mar 2019, 00:51

Ok, so possibly stupid follow-up question, then... is the Potions.lua file in the structs folder required beyond that point, or does it exist solely to generate the text table?

...ok, yeah, that is a stupid question. There's no way that Potions.lua isn't required.
Last edited by BTB on 24 Mar 2019, 00:54, edited 1 time in total.
"You don't have to be a vampire to die like one... bitch." -Simon Belmont

User avatar
BTB
Peasant
Peasant
Posts: 93
Joined: 21 Aug 2011
Location: Houston, TX
Contact:

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby BTB » 27 Mar 2019, 01:59

Rodril wrote:To make example work, all actions you have to do are:
1. Put "RemoveItemsLimits.lua" into "...Scripts\Structs" folder.
2. Create "Example.lua" in "...Scripts\Global", open it with any text editor and paste code there.
So, I place the RemoveItemsLimits.lua into the Structs folder, but nothing is being generated in Data/Tables. Anything I can check?

EDIT: think I figured it out... the very first lines of the .lua script were checking for MM8 and returning on false. Removed those and I got what I needed.

EDIT 2: ...except now it just crashes the game. Any way I can verify I'm using the right script?
Last edited by BTB on 27 Mar 2019, 02:23, edited 3 times in total.
"You don't have to be a vampire to die like one... bitch." -Simon Belmont

Rodril
Swordsman
Swordsman
Posts: 556
Joined: 18 Nov 2016

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby Rodril » 27 Mar 2019, 12:05

BTB wrote:EDIT: think I figured it out... the very first lines of the .lua script were checking for MM8 and returning on false. Removed those and I got what I needed.
Hey, this line is important because this script is only for MM8, it will crash other games. With which one do you use the script?

User avatar
BTB
Peasant
Peasant
Posts: 93
Joined: 21 Aug 2011
Location: Houston, TX
Contact:

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby BTB » 27 Mar 2019, 12:34

I've been talking about Might & Magic VII this whole time... have you not been?

(Oh, i just saw the bit where you mentioned that this only works with MM8... not sure how I missed that)

So... how much of what we've been talking about is invalid now?
Last edited by BTB on 27 Mar 2019, 12:38, edited 2 times in total.
"You don't have to be a vampire to die like one... bitch." -Simon Belmont

Rodril
Swordsman
Swordsman
Posts: 556
Joined: 18 Nov 2016

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby Rodril » 30 Mar 2019, 06:02

I'm afraid, everything. These features working in merge mod though. You could look into it's scripts for examples and modify it.

User avatar
BTB
Peasant
Peasant
Posts: 93
Joined: 21 Aug 2011
Location: Houston, TX
Contact:

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby BTB » 31 Mar 2019, 03:42

I take it "merge mod" is that other major thread I see up there?

I guess... starting just with the potion effects as an example, how much of it is really just taking that code you provided and looking for a different offset? It really doesn't seem like much actually CHANGED in MM8 otherwise, yeah? I have a hex editor, but I really don't have anything I know I need to look for, and without a lead to go on it's all just gibberish.

Part of me feels like I should probably just move on with the parts of what I want to do that I know I can with MME's existing capabilities and worry about what I can't do with it once that all gets taken care of. If nothing else, I clearly (CLEARLY) need to become more familiar with the code involved.

So... just to get an example to work with... the barrel code:

Code: Select all

event 389  -- "Purple Barrel"
  0:  StatusText  {Str = 588}         -- "+2 Speed permanent"
  1:  Add  {"BaseSpeed", Value = 2}
  2:  Set  {"AutonotesBits", Value = 38}         -- "Purple liquid grants Speed."
  3:  ChangeEvent  {NewEvent = 383}         -- "Empty Barrel"
end
How would I write a .lua script to modify this event? Can said script check the race of the character drinking and branch accordingly? I.e., a Goblin would receive a greater speed bonus from drinking purple liquid than, say, a dwarf would. I can just look at the decompiled script and get an idea of how it would look, but not how the .lua script to alter it would.
"You don't have to be a vampire to die like one... bitch." -Simon Belmont

Rodril
Swordsman
Swordsman
Posts: 556
Joined: 18 Nov 2016

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby Rodril » 02 Apr 2019, 15:31

BTB wrote:So... just to get an example to work with... the barrel code:
The simpliest solution would be:

Code: Select all

evt.Global[389] = function()
 	local CurrentPlayer = math.max(Game.CurrentPlayer, 0) -- select first player, in case if there is no active
 	if Party[CurrentPlayer]:GetRace() == const.Race.Goblin then
		evt.Add{"BaseSpeed", 2} -- add extra two points
	end
end
functions in evt.Global[389] are executed in additional to original script's behaivor. If you want to delete original script lines, use:

Code: Select all

Game.GlobalEvtLines:RemoveEvent(389)
Then only functions from evt.Global will be executed.
Unfortunately, sprites with events are not that basic thing, in merge mod i had to entirely remove original handler and rescript it via lua.

User avatar
BTB
Peasant
Peasant
Posts: 93
Joined: 21 Aug 2011
Location: Houston, TX
Contact:

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby BTB » 03 Apr 2019, 13:15

So..... basically, I have two options. It looks like the simpler one is just to do this:

Code: Select all

evt.Global[389] = function()
	local CurrentPlayer = math.max(Game.CurrentPlayer, 0)
	if Party[CurrentPlayer]:GetRace() == const.Race.Goblin then
		evt.Add{"BaseSpeed", 1} -- (if Goblin, +3 Speed)
	elseif Party[CurrentPlayer]:GetRace() == const.Race.Dwarf then
		evt.Add{"BaseSpeed", -1} -- (if Dwarf, +1 Speed)
	end
end
Which pretty much does what I'm after, assuming I just remove the now-inaccurate "+2" from the event string. Option 2 would be to rewrite the event entirely, which seems like the better idea overall, except I'd need to add more event strings for accuracy.

Code: Select all

Game.GlobalEvtLines:RemoveEvent(389)
evt.Global[389] = function()
	local CurrentPlayer = math.max(Game.CurrentPlayer, 0)
	if Party[CurrentPlayer]:GetRace() == const.Race.Goblin then
		evt.Add{"BaseSpeed", 3}
		evt.StatusText(588)         -- "+2 Speed permanent"
	elseif Party[CurrentPlayer]:GetRace() == const.Race.Dwarf then
		evt.Add{"BaseSpeed", 1}
		evt.StatusText(588)         -- "+2 Speed permanent"
	else
		evt.Add{"BaseSpeed", 2}
		evt.StatusText(588)         -- "+2 Speed permanent"
	end
	evt.ChangeEvent(383)         -- "Empty Barrel"
	evt.Set("AutonotesBits", 38)         -- "Purple liquid grants Speed."
end
In either case, I can't seem to find where these event strings are located... any help? Also, where should this script be placed and is there anything functionally wrong with anything I just posted?
Last edited by BTB on 03 Apr 2019, 13:52, edited 6 times in total.
"You don't have to be a vampire to die like one... bitch." -Simon Belmont

Rodril
Swordsman
Swordsman
Posts: 556
Joined: 18 Nov 2016

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby Rodril » 03 Apr 2019, 15:18

BTB wrote:In either case, I can't seem to find where these event strings are located... any help? Also, where should this script be placed and is there anything functionally wrong with anything I just posted?
These strings should be located in "NPCText.txt" from events.lod, you can open it with MMArchive.
This script should be placed into "...Scripts\Global" folder.
And yes, there's "trap". Second option won't work as intended, barrel will keep giving stat bonus even after one of characters drinks liquid. That's the problem with events of sprites, original script have "ChangeEvent" line, i'm not sure if it works in lua scripts.

User avatar
BTB
Peasant
Peasant
Posts: 93
Joined: 21 Aug 2011
Location: Houston, TX
Contact:

Re: MMExtension v2.1 + MMEditor v2.1 Level Editor [Apr 22, 2016]

Unread postby BTB » 03 Apr 2019, 15:35

NPCText, damn, I looked RIGHT past that! Am I able to add strings to this as necessary, or am I limited to only the blank spots that I have?

And ok, that's what you meant by sprite events not working... fair enough, I can use option one with little difficulty. And now that I have an understanding of how this works, it really opens up a lot for me.

It's also making me want to go back and look a the RemoveItemsLimits.lua script again and see if I can learn anything from it... except it no longer seems to be available on Dropbox (very likely because you've since put up a new version). Any chance you can re-post it?

(Another question... Grayface had also mentioned that it should be easy to get white barrels to randomly show up alongside the others, but he never mentioned how. Is this something you know how to implement? Similarly, for the various contests I want to *remove* the random factor and simply have each one be set so that you're guaranteed to run across one of each. Is THAT doable?)

(EDIT: ok, another question, further to the above. I intend to make the contests winnable only once, period, instead of once by each character. Obviously there's a few ways I can go about this, but it seems like the simplest would be to add evt.ForPlayer("All") before the command to set playerbits upon victory. One, would that work, and two, is there an easier solution that you'd suggest?
Last edited by BTB on 03 Apr 2019, 17:29, edited 3 times in total.
"You don't have to be a vampire to die like one... bitch." -Simon Belmont


Return to “Might and Magic”

Who is online

Users browsing this forum: No registered users and 65 guests