Ask a simple question, get a simple answer

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
minmay
Posts: 2747
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay » Wed Sep 14, 2022 5:36 am

Instead of an obstacle, return false from the PartyComponent.onMove hook, this will immediately set the party to the idle state. The same trick works with PartyComponent:turn() and the onTurn hook.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.

User avatar
Adrageron
Posts: 201
Joined: Thu Nov 08, 2012 1:22 pm

Re: Ask a simple question, get a simple answer

Post by Adrageron » Wed Sep 14, 2022 8:30 am

minmay wrote:
Wed Sep 14, 2022 5:36 am
Instead of an obstacle, return false from the PartyComponent.onMove hook, this will immediately set the party to the idle state. The same trick works with PartyComponent:turn() and the onTurn hook.
Thank you, I will try this!

User avatar
Adrageron
Posts: 201
Joined: Thu Nov 08, 2012 1:22 pm

Re: Ask a simple question, get a simple answer

Post by Adrageron » Wed Oct 19, 2022 5:03 pm

Is there any (not too complicated :mrgreen: ) way to change health bar color for custom conditions?

minmay
Posts: 2747
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay » Sun Oct 23, 2022 4:05 am

That's indeed a complicated thing to do without umods. You'd need to draw the health bar with your own code, which would be easy enough to copy from the vanilla source code for it, but there are a few problems:
1. You can't draw it at the proper time: the blood splash when a champion gets hit should appear in front of the health bar, but onDrawAttackPanel (and any other onDraw hook) will draw things in front of the blood splash. There are probably other depth sorting issues too.
2. Accounting for the visual effect of healing potions will be a huge pain.

Would an overlay like the one used for the shield conditions (fire shield, shock shield, etc.) be appropriate for your condition? The code for that is a lot easier.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.

User avatar
Adrageron
Posts: 201
Joined: Thu Nov 08, 2012 1:22 pm

Re: Ask a simple question, get a simple answer

Post by Adrageron » Sun Oct 23, 2022 7:43 am

Thank you for reply, minmay! I had a faint hope that there was some hidden parameter in the condition declaration responsible for this. If we are talking about manual redrawing of the interface, I will not undertake it. I have a huge bunch of other tasks in "to do list" :)

User avatar
Adrageron
Posts: 201
Joined: Thu Nov 08, 2012 1:22 pm

Re: Ask a simple question, get a simple answer

Post by Adrageron » Mon Oct 31, 2022 9:12 am

Hi! Just encountered a new problem: the game crashes when you try to import a party with custom classes (to the same mod where the save file was created).

Code: Select all

[string "Champion.lua"]:0: invalid class: sharpshooter
stack traceback:
	[C]: in function 'assert'
	[string "Champion.lua"]: in function 'setClass'
	[string "Champion.lua"]: in function 'loadState'
	[string "GameMode.lua"]: in function 'loadChampions'
	[string "NewGameMenu.lua"]: in function 'importChampions'
	[string "SaveGameMenu.lua"]: in function 'select'
	[string "SaveGameMenu.lua"]: in function 'update'
	[string "GameMode.lua"]: in function 'update'
	[string "Grimrock.lua"]: in function 'display'
	[string "Grimrock.lua"]: in main chunk
I've checked this issue with Falagar mod (created a party there and tried to import it to the new Falagar run). And got the same crash, but for a custom race.
Is there a way to fix this?

minmay
Posts: 2747
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay » Mon Oct 31, 2022 10:06 am

There's nothing you can do in your custom dungeon to allow importing non-standard class/race names into it; that crash happens before your custom dungeon is even loaded, so you have no opportunity to run any code at all, not even your init.lua.

You can of course prevent your dungeon from creating new save files that have this issue, by only using the standard race and class names (they're never displayed to the player, only the uiName, so you don't need to change the names the player sees), but that only works if your dungeon uses 8 or fewer classes and 5 or fewer races.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.

User avatar
Adrageron
Posts: 201
Joined: Thu Nov 08, 2012 1:22 pm

Re: Ask a simple question, get a simple answer

Post by Adrageron » Mon Oct 31, 2022 10:32 am

Thank you for advice, minmay. I've used all standard names that I can, but there are 2 classes with undesired hardcoded mechanics - alcemist and farmer. Are there any means to disable their unique properties?

minmay
Posts: 2747
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay » Tue Nov 01, 2022 10:06 am

Not remotely conveniently; Alchemist's herb reproduction is tied to the defined names of the 6 standard herbs, but CraftPotionComponent also relies on those names, so just changing them won't work. And while you can kill Farmer's xp-from-food with onUseItem hooks on food, getting it to gain xp from monster kills is much harder.

It's probably not worth worrying about this bug at all. I'd imagine it's very rare for someone to want to import a party with custom classes in the first place, and if someone does want to, they can always just use the console to give a new party with the stats they want instead.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.

User avatar
Adrageron
Posts: 201
Joined: Thu Nov 08, 2012 1:22 pm

Re: Ask a simple question, get a simple answer

Post by Adrageron » Tue Nov 01, 2022 10:42 am

Thank you for the info, minmay! Less work for me then :mrgreen: Just to write a warning in the mod's description :ugeek:

Post Reply