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
raekuul
Marksman
Marksman
Posts: 424
Joined: 05 Jul 2019

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

Unread postby raekuul » 11 Jul 2022, 13:40

Eksekk wrote: 11 Jul 2022, 12:59 You can modify the monsters directly after loading the map. To do this, create a file with map file name and ".lua" extension in Scripts/Maps, for example oute3.lua, and inside put this code:
To be clear: what I'm looking to do is to substitute certain monster IDs for other monster IDs on a given map load, replacing entirely one monster for another. Adjusting monster parameters/attributes/abilities isn't what I'm looking to do.

It's trivial enough to do what I want by editing lodfiles, but that's not the correct solution for my needs (since lodfile changes would get clobbered by the randomizer in patched lods mode).
BTW, it didn't work because without parentheses lua applied not to var (not returns only true or false, so the result will never be nil). If you wrote `if not (var == nil)` it would work too. For future reference, for learning basic syntax you can use programming in lua course, one version of which is available online for free or, if you don't have that much time, most basic language/syntax concepts are explained by lua cheatsheets, like this one (I'm not promoting it, this was my first google result for "lua cheat sheet").
I thought it looked weird the way I did it before (I'm out of practice with lua; I used to know that but got roped into languages that don't do that)

Tomsod
Demon
Demon
Posts: 344
Joined: 31 Jul 2020

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

Unread postby Tomsod » 11 Jul 2022, 18:47

So you basically want to change MapStats.txt, but don't want to replace the text file? Then put a script in the General directory that edits Game.MapStats instead. It's essentially MapStats.txt as parsed by the game, and you can change specific fields while leaving the rest the same.

User avatar
raekuul
Marksman
Marksman
Posts: 424
Joined: 05 Jul 2019

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

Unread postby raekuul » 24 Aug 2022, 19:06

MM6 again. If I want to have the characters regenerate an additional 1 SP per tick regardless of other factors, how would I do that? I looked at how MMMerge does it but the event they hook into isn't actually listed in the online MMExt reference manual, and just copying the code outright does nothing per tick.

EDIT: I got it adding SP per tick, but it's adding 4x the amount I'm telling it to add and I can't grok why (a gain of 1 recovers 4 SP per update, a gain of 10 recovers 40 SP per update):

Code: Select all

-- Add a bit of sp regeneration by meditation skill
function calculateMeditationSPRegen(mastery, fullSP)
	output = math.ceil(fullSP * mastery / 100)
	return math.max(output, mastery)
end

function events.Regeneration()
	for k,v in Party do
		r,m = SplitSkill(v.Skills[const.Skills.Meditation])
		cap = v:GetFullSP()
		cur = v.SpellPoints
		gain = calculateMeditationSPRegen(m, cap)
		v.SpellPoints = math.min(cap,cur+gain)
	end
end
Last edited by raekuul on 24 Aug 2022, 19:55, edited 1 time in total.

Eksekk
Assassin
Assassin
Posts: 259
Joined: 19 Jul 2016

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

Unread postby Eksekk » 24 Aug 2022, 19:52

raekuul wrote: 24 Aug 2022, 19:06 MM6 again. If I want to have the characters regenerate an additional 1 SP per tick regardless of other factors, how would I do that? I looked at how MMMerge does it but the event they hook into isn't actually listed in the online MMExt reference manual, and just copying the code outright does nothing per tick.

EDIT: I got it adding SP per tick, but it's adding 4x the amount I'm telling it to add and I can't grok why.

Code: Select all

-- Add a bit of sp regeneration by meditation skill
function calculateMeditationSPRegen(mastery, fullSP)
	output = math.ceil(fullSP * mastery / 100)
	return math.max(output, mastery)
end

function events.Regeneration()
	for k,v in Party do
		r,m = SplitSkill(v.Skills[const.Skills.Meditation])
		cap = v:GetFullSP()
		cur = v.SpellPoints
		gain = calculateMeditationSPRegen(m, cap)
		v.SpellPoints = math.min(cap,cur+gain)
	end
end
events.Regeneration(t) provides argument t, which is a table containing fields HP, Player, PlayerIndex, SP. Since you apply the effect to full party at once, your code applies it 4x for each player in party. Also MMMerge uses a ton of custom events, that's why it isn't in MMExt reference.
Unfinished mod by me: MM7 Rev4 mod, MMMerge version.

User avatar
floydnexus
Leprechaun
Leprechaun
Posts: 8
Joined: 24 Aug 2022

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

Unread postby floydnexus » 25 Aug 2022, 06:45

Hi :)
I don't know if it's the right place to post this (I'm new around) but I wanted to know if what I try to do is possible.
In the merge, mandate of heavan, and the snergle silver mine I can't open the cell door where ghim hammond is because the key disapeared from my inventory. Don't know if I sold it making a mistake or something like that so I tried to use the console command/level editor to help me fix that.
So I tried different things trying to use the mmextension help to see if I could find a way to summon the key (I found it "cell key"on the item.ext), or the npc Ghim hammond. I couldn't find an evt (like summon object or give item) that make a reference to something in item.ext.
I tried the level editor too without any luck. I tried mm8che too, but there is no cell key in the item you can add to your inventory ( probably because it's not a mm8 item). Any idea?

User avatar
raekuul
Marksman
Marksman
Posts: 424
Joined: 05 Jul 2019

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

Unread postby raekuul » 25 Aug 2022, 12:24

There are many name collisions between the keys - are you sure you grabbed the Dwarven Jail Key and not the Tsantsa Jail Key? They're both called "Cell Key" by default.

Eksekk
Assassin
Assassin
Posts: 259
Joined: 19 Jul 2016

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

Unread postby Eksekk » 25 Aug 2022, 13:13

floydnexus wrote: 25 Aug 2022, 06:45 Hi :)
I don't know if it's the right place to post this (I'm new around) but I wanted to know if what I try to do is possible.
In the merge, mandate of heavan, and the snergle silver mine I can't open the cell door where ghim hammond is because the key disapeared from my inventory. Don't know if I sold it making a mistake or something like that so I tried to use the console command/level editor to help me fix that.
So I tried different things trying to use the mmextension help to see if I could find a way to summon the key (I found it "cell key"on the item.ext), or the npc Ghim hammond. I couldn't find an evt (like summon object or give item) that make a reference to something in item.ext.
I tried the level editor too without any luck. I tried mm8che too, but there is no cell key in the item you can add to your inventory ( probably because it's not a mm8 item). Any idea?

Code: Select all

evt.Add("Inventory", itemId)
or

Code: Select all

evt.GiveItem{Id = itemId}
are the commands for adding items. Also like raekuul mentioned, make sure it's the correct key.
Unfinished mod by me: MM7 Rev4 mod, MMMerge version.

User avatar
floydnexus
Leprechaun
Leprechaun
Posts: 8
Joined: 24 Aug 2022

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

Unread postby floydnexus » 26 Aug 2022, 05:43

Evt.add works, thank you very much :)
To help those who have the same problem the right key is obtained by using:
evt.Add("Inventory", 2192)

User avatar
raekuul
Marksman
Marksman
Posts: 424
Joined: 05 Jul 2019

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

Unread postby raekuul » 29 Aug 2022, 00:12

Got a new one for y'all

I'm trying to implement a "fully" random monsters mode in lua (the extant randomizer is limited to only swapping monster sets around, while this project is not - you could get High Kreegan and Rats in the same map with mine); I have it working, but it's vulnerable to quit-and-reload abuse: if you close the game entirely before loading a map for the first time (or more likely, when a map is ready for Respawning) you can reroll the monster set.

The solution to this is to give each new game a seed value to do the randomizations from (which I will need to do for later projects anyway), but I've run into two issues:
  1. I can encode a starting seed into the save file by setting vars["Seed"] by hooking into BeforeSaveGame(), but I can't get it to stick to vars if I try to hook it into {Before,After}NewGameAutosave(), and there's no vars table to read/write during GameInitialized2. When's the earliest during the NewGame process that I can read/write to vars?
  2. The randomization is currently being done at GameInitialized2, which is before vars is available for read/write. While this is "good enough" for a first pass, I need to be able to move this step to some time after vars["Seed"] is set. When exactly in the map loading process does the game say "this map reads from this line of MapStats"?

Eksekk
Assassin
Assassin
Posts: 259
Joined: 19 Jul 2016

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

Unread postby Eksekk » 31 Aug 2022, 20:12

How do I correctly import/export indoor map from MMEditor to Blender (3.2.2) so no console error pops up, textures aren't nulled, portals work as intended, properties of untouched faces (event, trigger on click, scroll up etc.) are preserved?

More information: the map imports fine, but if I export it as .obj and import in MMEditor, either console error happens (complaining about portals, I narrowed the issue down to checkbox "Write Materials" when exporting, but if I disable it portals are messed up) or something isn't right (textures are all bricky, portals change texture/disappear, faces lose all their properties).

Someone suggested to use Blender 2.7, but I'd rather not because it will probably be much harder to make any changes, but as a last resort I'll do it.
Unfinished mod by me: MM7 Rev4 mod, MMMerge version.

Mareneusz002
Leprechaun
Leprechaun
Posts: 36
Joined: 29 Mar 2019

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

Unread postby Mareneusz002 » 01 Sep 2022, 01:03

Hello i need some help with modding Thief profession please :)

GrayFace wrote: 28 Jan 2022, 08:18
Mareneusz002 wrote: 22 Jan 2022, 23:42 too bad its not easy to change tripple damage ;l
i really like Thief profession, but the tripple damage isnt really so strong compared to for example Knight profession which is strongest melee dps and tank at once. changing it to 10x damage or even more could balance Thief i think. maybe GrayFace can help with it in some next updates :) :P
You could improve it in some other way. Say, +2/skill on GM. Or chance to do +100 damage equal to skill on GM (same effect on average).


GrayFace wrote: 15 Feb 2022, 08:43 Making GM Dagger do +2 damage/skill instead of +1

Code: Select all

function events.CalcStatBonusBySkills(t)
	if t.Result ~= 0 and t.Stat == const.Stats.MeleeDamageBase then  -- t.Result ~= 0 is for speedup
		local sk, mas = SplitSkill(t.Player.Skills[const.Skills.Dagger])
		if mas >= const.GM then
			local it = t.Player:GetActiveItem(const.ItemSlot.MainHand)
			if it and it:T().Skill == const.Skills.Dagger then
				t.Result = t.Result + sk
			end
		end
	end
end








when i put this script so there are 2 errors:
1 when opens inventory "stats" to see damage of my Thief:


https://imgur.com/a/TTfRoj4



and second error when i try to hit mob with Thief:


https://imgur.com/a/aG86olH






any solution how to fix it?

or better would be to make second option if possible please = "chance to do +100 damage equal to skill on GM"

or if its possible so for example
chance to do +50 damage equal to skill on Master
and
chance to do +125 damage equal to skill on GM



Thank you for help!

Eksekk
Assassin
Assassin
Posts: 259
Joined: 19 Jul 2016

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

Unread postby Eksekk » 01 Sep 2022, 15:27

Mareneusz002 wrote: 01 Sep 2022, 01:03 Hello i need some help with modding Thief profession please :)

when i put this script so there are 2 errors:
1 when opens inventory "stats" to see damage of my Thief:

and second error when i try to hit mob with Thief:

any solution how to fix it?

or better would be to make second option if possible please = "chance to do +100 damage equal to skill on GM"

or if its possible so for example
chance to do +50 damage equal to skill on Master
and
chance to do +125 damage equal to skill on GM

Thank you for help!
Reinstall MMExtension (delete scripts folder and put in fresh one), you have core script either missing or corrupted. About other ideas, both of required hooks don't have a way of checking player's skills, so it would be needed to hook before them and get player manually. You are running MM7, right?

Also update to my editor problem, turns out the map I used (mdr02) was the culprit, because other map (mdt05) exports and imports fine, even with changes (adding chest) (Here's "corrupted" map object if someone wants to take a look. I've also provided my "original" dungeon file (I've modified it from vanilla). And of course they are for merge, in MM7 might have broken textures). Also, turns out even multiple objects are supported, I thought dungeons are constrained to be one big object. Any guidelines on when to import multiple object, when single, and when import as rooms? The editor documentation is lacking.

And I still haven't found a solution for retaining facet properties and doors when importing modified object. Could a hacky script writing original data before modification, then restoring it based on vertexes making up a face be the solution?
Unfinished mod by me: MM7 Rev4 mod, MMMerge version.

Mareneusz002
Leprechaun
Leprechaun
Posts: 36
Joined: 29 Mar 2019

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

Unread postby Mareneusz002 » 03 Sep 2022, 00:20

Eksekk wrote: 01 Sep 2022, 15:27
Mareneusz002 wrote: 01 Sep 2022, 01:03 Hello i need some help with modding Thief profession please :)

when i put this script so there are 2 errors:
1 when opens inventory "stats" to see damage of my Thief:

and second error when i try to hit mob with Thief:

any solution how to fix it?

or better would be to make second option if possible please = "chance to do +100 damage equal to skill on GM"

or if its possible so for example
chance to do +50 damage equal to skill on Master
and
chance to do +125 damage equal to skill on GM

Thank you for help!
Reinstall MMExtension (delete scripts folder and put in fresh one), you have core script either missing or corrupted. About other ideas, both of required hooks don't have a way of checking player's skills, so it would be needed to hook before them and get player manually. You are running MM7, right?

Hello,

thanks for answer!

sadly reinstalling mmextension doesnt help.
i think the script might be bugged ;l because other scripts from Grayface site like "increase spell damage of flame arrow" or "learn all spells" works excellent

yes im running MM7

the script is made by Grayface because i asked if he can help with making Thief profession a bit stronger
GrayFace wrote: ↑Jan 28 2022, 9:18
Mareneusz002 wrote: ↑Jan 23 2022, 0:42
too bad its not easy to change tripple damage ;l
i really like Thief profession, but the tripple damage isnt really so strong compared to for example Knight profession which is strongest melee dps and tank at once. changing it to 10x damage or even more could balance Thief i think. maybe GrayFace can help with it in some next updates :) :P
You could improve it in some other way. Say, +2/skill on GM. Or chance to do +100 damage equal to skill on GM (same effect on average).
to be honest i would prefer the second option = "chance to do +100 damage equal to skill on GM"
because it will look like some good critical hit, because now the critical hit is really so poor ;l
but i understand its more difficult to make this script

sadly im really total noob in modding, so +2/skill on GM will be also nice! just need the error to dissapear :P

thanks!!

Eksekk
Assassin
Assassin
Posts: 259
Joined: 19 Jul 2016

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

Unread postby Eksekk » 03 Sep 2022, 08:03

That's really strange. Can you send me your entire scripts directory, just to make sure nothing interferes? And I'm gonna do +100 damage later today.
Unfinished mod by me: MM7 Rev4 mod, MMMerge version.

Mareneusz002
Leprechaun
Leprechaun
Posts: 36
Joined: 29 Mar 2019

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

Unread postby Mareneusz002 » 03 Sep 2022, 22:05

Eksekk wrote: 03 Sep 2022, 08:03 That's really strange. Can you send me your entire scripts directory, just to make sure nothing interferes? And I'm gonna do +100 damage later today.
Hello,

dont really know how to send whole folders at forum
so i have put it in drive google:
https://drive.google.com/drive/folders/ ... sp=sharing

or maybe i can send it to your email

but generally there are some .lua files at Core, General and Structs.
other folders are empty.
Global folder is the one i have put the script.
the script in Global folder is called 123

file 123.lua is copied from some file from General folder. i have just renamed it and put scripts there = "Thief damage" and "learn all spells"
Learn all spells works
but Thief not ;l


Eksekk wrote: 03 Sep 2022, 08:03 And I'm gonna do +100 damage later today.
Thank you for help!! really appreciate it!

and would it be possible to make:
chance to do +50 damage equal to skill on Master
and
chance to do +125 damage equal to skill on GM?

thanks!!

Eksekk
Assassin
Assassin
Posts: 259
Joined: 19 Jul 2016

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

Unread postby Eksekk » 04 Sep 2022, 19:02

Okay, as it turns out Grayface simply used features which are in newest mmext but not the version "for public" as of now. That's why you got an error.

Anyway, here's your script. Default damage is 50 on master, 125 on GM as requested and you can change it by editing line

Code: Select all

local masteryDamageAdd = {0, 0, 50, 125}
, each number here corresponds to damage on next mastery starting with novice and ending on GM. I've also included critical hit messages, if you'd like to remove them, delete line 22 (crit = true). And the script needs to go into Scripts/General.

Have fun! :)
Unfinished mod by me: MM7 Rev4 mod, MMMerge version.

Mareneusz002
Leprechaun
Leprechaun
Posts: 36
Joined: 29 Mar 2019

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

Unread postby Mareneusz002 » 04 Sep 2022, 22:34

Eksekk wrote: 04 Sep 2022, 19:02 Okay, as it turns out Grayface simply used features which are in newest mmext but not the version "for public" as of now. That's why you got an error.

Anyway, here's your script. Default damage is 50 on master, 125 on GM as requested and you can change it by editing line

Code: Select all

local masteryDamageAdd = {0, 0, 50, 125}
, each number here corresponds to damage on next mastery starting with novice and ending on GM. I've also included critical hit messages, if you'd like to remove them, delete line 22 (crit = true). And the script needs to go into Scripts/General.

Have fun! :)

Thanks!! the message with critical hit is really helpful! now it shows the power of Thief ;]

The critical hit works also! but, now, there are 2 critical hits.
the old one, for example = critical hit for 13 damage, critical hit for 27 , 50 , 72 damage
and sometimes the new one = critical which adds 125damage, for example = critical hit for 198 , critical hit for 221

the thing is that the Old critical hit is really more often than the New one, so Thief is only stronger by a bit now, because New critical hit is quite rare

for example, if i have 20 skill in dagger GM. so i have 20% chance to hit critical hit right? so critical hit should be around every 5 hit. and probably it is, but Old criticals are really more often than New one. the New critical hits are like 2 times less often than Old criticals.

so my question is,
is it possible to delete the Old critical hits? or somehow reduce their frequency?

thanks!!

Eksekk
Assassin
Assassin
Posts: 259
Joined: 19 Jul 2016

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

Unread postby Eksekk » 05 Sep 2022, 18:12

Obviously. To delete them just add the following to the script:

Code: Select all

-- disable dagger master bonus
-- main hand
mem.asmpatch(0x48CEDA, "jmp short " .. 0x48CF15 - 0x48CEDA)
-- offhand
mem.asmpatch(0x48D005, "jmp short " .. 0x48D043 - 0x48D005)
But they don't affect frequency of other crits.
Unfinished mod by me: MM7 Rev4 mod, MMMerge version.

Mareneusz002
Leprechaun
Leprechaun
Posts: 36
Joined: 29 Mar 2019

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

Unread postby Mareneusz002 » 06 Sep 2022, 06:04

Eksekk wrote: 05 Sep 2022, 18:12 Obviously. To delete them just add the following to the script:

Code: Select all

-- disable dagger master bonus
-- main hand
mem.asmpatch(0x48CEDA, "jmp short " .. 0x48CF15 - 0x48CEDA)
-- offhand
mem.asmpatch(0x48D005, "jmp short " .. 0x48D043 - 0x48D005)
sadly it didnt work ;l
i put it into buffdaggers.lua but nothing changed. there are still Old critical hits

do i make something wrong?


Eksekk wrote: 05 Sep 2022, 18:12 But they don't affect frequency of other crits.
are you sure? i have 20 skill in dagger and i can see Old critical hits quite often, but New criticals are really rare. like 1 crit in maybe 15 hits. and the Old crits are like 1 in about 5 hits.

maybe when there are 2 crits at once = Old and New, so Old critical hit takes places before New critical, so New crit cant be done?

i thought maybe its bugged and when message says:
Critical hit for 24 damage so there are 2 criticals at once = Old and New, and message just shows 1 of these

but its not ;l
was looking at hp of the mob and it was really 24 damage


thanks!

Eksekk
Assassin
Assassin
Posts: 259
Joined: 19 Jul 2016

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

Unread postby Eksekk » 06 Sep 2022, 11:41

Dumb question, did you save the file after pasting it? Also did you make any other modifications to game files? I used vanilla MM7 with Grayface patch and MMExtension when making this script, nothing else.

How do you determine you've got old critical hit? Remember, only basic dagger damage is multiplied (only "2d2 + 4" stuff, so for example from 7 you get 21), not enchantments or GM bonuses. Second, mobs have physical resistance, which can greatly reduce the damage and make new crit look like old. Make sure you're testing it on mobs without it (I found adventurers on emerald island are a good target, just do "for k, v in Map.Monsters do v.HP = 20000 end" (ctrl + f1, paste, ctrl + enter to execute) so mobs have a ton of hp and don't die immediately). When I did that, every time critical hit message popped up the damage was visibly increased. I didn't notice any old critical hits.

Oh, and to make yourself not die and be able to test easily execute "for _, pl in Party do pl.Skills[const.Skills.Dagger] = JoinSkill(60, const.GM); pl.HP = 20000 end; for i = 1, 20 do evt.GiveItem{Type = const.ItemType.Dagger} end", that will give you daggers, 60GM dagger skill and a ton of HP.
Unfinished mod by me: MM7 Rev4 mod, MMMerge version.


Return to “Might and Magic”

Who is online

Users browsing this forum: No registered users and 6 guests