Hey All,
I'm using Grayfaces MMExtension to mod the game. I know I can go into Monsters.txt and mod Monster stats but I want to be able to change them only on certain maps. He gave an example to change their hostility (see below) and it works fine.
As you can see I used the common female villager. I then try to increase her Hit Points, I used the commands Grayface has listed in his MMExtension help, I tried both variations, I also tried getting her to fly, no luck.
Now the villager will come and attack me, but her HP stay the same. Do I have the command wrong? If so, does anyone have a list of the commands that work, the commands on the Help Page do not seem to be correct. Thanks.
function events.BeforeLoadMap()
if Game.Map.Name == "outc2.odm" then
LocalMonstersTxt()
Game.MonstersTxt[121].HostileType = 4 -- PeasantF1A
Game.MonstersTxt[122].HostileType = 4 -- PeasantF1B
Game.MonstersTxt[123].HostileType = 4 -- PeasantF1C
Game.MonstersTxt[121].Hitpoints = 100 -- PeasantF1A
Game.MonstersTxt[122].Hitpoints = 200 -- PeasantF1B
Game.MonstersTxt[123].Hitpoints = 300 -- PeasantF1C
end
end
*************************2nd Try
function events.BeforeLoadMap()
if Game.Map.Name == "outc2.odm" then
LocalMonstersTxt()
Game.MonstersTxt[121].HP = 100 -- PeasantF1A
Game.MonstersTxt[122].HP = 200 -- PeasantF1B
Game.MonstersTxt[123].HP = 300 -- PeasantF1C
end
end
**********************Flying
function events.BeforeLoadMap()
if Game.Map.Name == "outc2.odm" then
LocalMonstersTxt()
Game.MonstersTxt[121].Fly = Y -- PeasantF1A
Game.MonstersTxt[122].Fly = Y -- PeasantF1B
Game.MonstersTxt[123].Fly = Y -- PeasantF1C
end
end
Using Lua to mod Monster stats? UPDATE: Solved the HP Issue!!!!
-
- Leprechaun
- Posts: 30
- Joined: 04 Feb 2017
Using Lua to mod Monster stats? UPDATE: Solved the HP Issue!!!!
Last edited by motter25420 on 02 Oct 2017, 18:30, edited 3 times in total.
Re: Using Lua to mod Monster stats?
Hello. Those fields you changing are wrong. Check manual: https://sites.google.com/site/sergroj/m ... ersTxtItem
"Game.MonstersTxt[121].Hitpoints = 100" - MonstersTxt item does not contain "Hitpoints" field, you must change "FullHP" or "FullHitpoints" fields.
"Game.MonstersTxt[121].Fly = Y" - "Fly" is boolean value, "Game.MonstersTxt[121].Fly = true" will work.
"Game.MonstersTxt[121].Hitpoints = 100" - MonstersTxt item does not contain "Hitpoints" field, you must change "FullHP" or "FullHitpoints" fields.
"Game.MonstersTxt[121].Fly = Y" - "Fly" is boolean value, "Game.MonstersTxt[121].Fly = true" will work.
Last edited by Rodril on 23 Sep 2017, 12:35, edited 1 time in total.
-
- Leprechaun
- Posts: 30
- Joined: 04 Feb 2017
Re: Using Lua to mod Monster stats?
OK, thanks, I had thought I tried using both "FullHP" and "FullHitpoints" and neither worked, but maybe I am wrong, will try again.
As for the "fly" I used "Y" because that is what was used in the monsters.txt file, but I'll try it with "true".
This will help a lot, thank you very much for the reply.
As for the "fly" I used "Y" because that is what was used in the monsters.txt file, but I'll try it with "true".
This will help a lot, thank you very much for the reply.
-
- Leprechaun
- Posts: 30
- Joined: 04 Feb 2017
Re: Using Lua to mod Monster stats?
Hi Rodril. I appreciate your response however I tried those commands and it still does not work. Pics below, not sure what I'm doing wrong. Have you gotten this to work?Rodril wrote:Hello. Those fields you changing are wrong. Check manual: https://sites.google.com/site/sergroj/m ... ersTxtItem
"Game.MonstersTxt[121].Hitpoints = 100" - MonstersTxt item does not contain "Hitpoints" field, you must change "FullHP" or "FullHitpoints" fields.
"Game.MonstersTxt[121].Fly = Y" - "Fly" is boolean value, "Game.MonstersTxt[121].Fly = true" will work.
https://imgur.com/a/lvDxB
Re: Using Lua to mod Monster stats?
Hi motter25420
I haven't tried modding but I have some experience in software development and one issue I can see is that you use "FullHitpoints" where the manual states "FullHitPoints" with a capital 'P' and in your image you have "True" often booleans are lower cases so try "true".
Good luck - hope that it can help a bit...
Regards
Troels
I haven't tried modding but I have some experience in software development and one issue I can see is that you use "FullHitpoints" where the manual states "FullHitPoints" with a capital 'P' and in your image you have "True" often booleans are lower cases so try "true".
Good luck - hope that it can help a bit...
Regards
Troels
Re: Using Lua to mod Monster stats?
As Troller stated, lines are case-sensitive, but also one thing i did not understand at once: changes in Game.MonstersTxt affecting only monsters who were spawned durning gameplay. Peasants at "oute3.odm" are predefined, they were placed at map-editing stage, and their "Fly", "HP" properties are already set, to change them use that kind of code in addition:motter25420 wrote:https://imgur.com/a/lvDxB
Code: Select all
function events.LoadMap()
if Map.Name == "oute3.odm" and Map.Refilled then
for i,v in Map.Monsters do
if v.Id == 121 then
v.Fly = true
v.FullHP = 100
v.HP = 100
elseif v.Id == 122 then
v.Fly = true
v.FullHP = 200
v.HP = 200
elseif v.Id == 123 then
v.Fly = true
v.FullHP = 300
v.HP = 300
end
end
end
end
-
- Leprechaun
- Posts: 30
- Joined: 04 Feb 2017
Re: Using Lua to mod Monster stats?
Hey guys. I really do appreciate your help. I tried what you suggested, I copy and pasted it exactly and still nothing worked except the Hostile.
Just an FYI, I'm not really wanting to mod the FPeasant for my finished mod, I was just using her as the test Monster because she is right there at game start.
I understand what you meant about Monsters being spawned vs Monsters preset in the map file.
I tried all of these scripts on the Goblins in New Scorpigal who are spawned by "Mapstats" and got the same results, I can control their hostility but nothing else.
I do know some basics of programming and I am wondering why you did your "for" loop as you did. Don't you normally have to define "i" ex:
for i = 0, i < 10, i++
I am lost as to what the script is defining as "i" and also "v".
Did you try this script and it worked? What "Scripts" folder did you put it in and did you give it a certain name? Thanks again for the assistance.
Just an FYI, I'm not really wanting to mod the FPeasant for my finished mod, I was just using her as the test Monster because she is right there at game start.
I understand what you meant about Monsters being spawned vs Monsters preset in the map file.
I tried all of these scripts on the Goblins in New Scorpigal who are spawned by "Mapstats" and got the same results, I can control their hostility but nothing else.
I do know some basics of programming and I am wondering why you did your "for" loop as you did. Don't you normally have to define "i" ex:
for i = 0, i < 10, i++
I am lost as to what the script is defining as "i" and also "v".
Did you try this script and it worked? What "Scripts" folder did you put it in and did you give it a certain name? Thanks again for the assistance.
Re: Using Lua to mod Monster stats?
I can help clarify this part.motter25420 wrote:I do know some basics of programming and I am wondering why you did your "for" loop as you did. Don't you normally have to define "i" ex:
for i = 0, i < 10, i++
I am lost as to what the script is defining as "i" and also "v".
To understand the statement
Code: Select all
for i,v in Map.Monsters do
This for statement lets you traverse the data structure giving you the identifier and the value in the variables you entered.
You could rename them
Code: Select all
for identifier,value in Map.Monsters do
Code: Select all
for identifier,monster in Map.Monsters do
I hope that helped a bit.
Regards,
Troller
Last edited by Troller on 28 Sep 2017, 07:17, edited 2 times in total.
-
- Leprechaun
- Posts: 30
- Joined: 04 Feb 2017
Re: Using Lua to mod Monster stats?
Yeah, I think I understand the loop now, but still can't get the stats to change. Oh well, I have to work around it. Thanks again!
****EDIT: I got it to work finally!!! I realized even the map names are case sensitive as well. All this time and frustration just because I was using a capital "O" for the "oute3.odm".
Now the only problem I have is figuring out the "Attack" Syntax.
****EDIT: I got it to work finally!!! I realized even the map names are case sensitive as well. All this time and frustration just because I was using a capital "O" for the "oute3.odm".
Now the only problem I have is figuring out the "Attack" Syntax.
Last edited by motter25420 on 02 Oct 2017, 18:01, edited 1 time in total.
Re: Using Lua to mod Monster stats?
The data structure you're talking about is the basic building block of Lua, it's called just "table" in Lua. My arrays, such as "Map.Monsters" are made to be traversed with that syntax, unlike regular tables that are traversed by for k, v in pairs(t) do or for k, v in ipairs(t) do.Troller wrote:The data structure "Map" is important to know. It is used to map identifiers (i) to the values (v) or objects store in the map. It is often optimized to very efficiently retrieve the value given the identifier. There is probably also a syntax that lets you get a specific monster from the map without having to go thru all of them.
My patches: MM6 MM7 MM8. MMExtension. Tools. Also, I love Knytt Stories and Knytt Underground. I'm also known as sergroj.
Re: Using Lua to mod Monster stats?
Good to know - how are the complexity then - often maps have a hash map implementation underneath with an O(1) retrieval complexity and an insert that is very dependent on the implementation O(1) -> O(N). I know I'm a geek when it comes to data structures :-)GrayFace wrote:The data structure you're talking about is the basic building block of Lua, it's called just "table" in Lua. My arrays, such as "Map.Monsters" are made to be traversed with that syntax, unlike regular tables that are traversed by for k, v in pairs(t) do or for k, v in ipairs(t) do.
Last edited by Troller on 04 Oct 2017, 09:12, edited 1 time in total.
-
- Leprechaun
- Posts: 30
- Joined: 04 Feb 2017
Re: Using Lua to mod Monster stats?
-Can I use MMExtension to mod maps? I'm not trying to make new maps, just want to remove some things like the pyramid in "Dragonsand", I also want to move one of the buildings in MM8 to another map.GrayFace wrote:The data structure you're talking about is the basic building block of Lua, it's called just "table" in Lua. My arrays, such as "Map.Monsters" are made to be traversed with that syntax, unlike regular tables that are traversed by for k, v in pairs(t) do or for k, v in ipairs(t) do.Troller wrote:The data structure "Map" is important to know. It is used to map identifiers (i) to the values (v) or objects store in the map. It is often optimized to very efficiently retrieve the value given the identifier. There is probably also a syntax that lets you get a specific monster from the map without having to go thru all of them.
-BDJ had taught how to hex it, but I don't like to hex if I don't have to, you're Extension is so much easier, plus as I say I hardly remember most of the stuff from 7yrs ago.
-One last thing, in MM6 in the Character Portraits there is a face for the Diseased condition but it doesn't show in the game, they just get the same pic as when they're poisoned, I've searched all the files and can't find where this is controlled.
Thanks as always. I'll be sure to post my mods when I'm done, I'll give you all the credit you're due.
Who is online
Users browsing this forum: No registered users and 0 guests