Page 1 of 4

New modder, need help (Default party, custom class)

Posted: Sat Jul 29, 2017 1:08 pm
by bazuso
Hello. As the title states, I'm new to trying to mod Grimrock 2, with my only experience being an understanding of the map editor. I've searched for answers elsewhere, primarily on this forum, however most of the information I got was not explained particularly well and I ended up very confused. My programming knowledge is extremely limited, so if what I'm asking is very basic then I apologize. I have downloaded the latest asset pack already and I've looked at some of the files, so I have an idea of how it's all structured.

My first issue is the default party that's created upon starting a custom campaign. I am not sure where exactly I need to be writing the "champion" objects, and how. I tried making a .lua file, entering the objects inside, then adding an entry for said file to the "init" lua file, but that causes an error upon playtesting. I then wrote some champion objects on a script object in the map editor that was connected to an invisible trigger where the party spawns, however only the name and class were affected. I could not get the portrait to change to the one I had entered, and I am not sure how to get a "clean slate" character that I can then assign stats and points to, because the default existing party already has their own set of stats and skills I don't know how to undo. Also, just to be sure, when I'm entering a champion object it should look something like ' (party.party:getChampion(1):setPortrait("human_male_11.tga") ', correct?

Second, is it possible to have unarmed damage increase as one class levels up? I want to make a hand-to-hand focused class but I am not sure how to go about this. My current idea is just to have their unarmed damage increase by some percentage for every time they level up, or maybe even have gloves become a factor as well. I'm also wondering if it's possible to have them "dual wield" their fists so that they can attack with one after the other, rather than just hit once and only be able to attack again after the cooldown. The light weapon mastery trait doesn't affect this because fists aren't considered light weapons.

I would be really grateful for any help or information that anyone could share. If I get deeper into the modding then I imagine I'll likely have more questions later as well. Thanks in advance

Re: New modder, need help (Default party, custom class)

Posted: Sat Jul 29, 2017 1:36 pm
by Isaac
Welcome to the forum bazuso. 8-)

The custom party question does come up often. Here is a link to where it was asked in the "Ask a Simple Question" thread:
viewtopic.php?f=22&t=7951&p=110854&hili ... ty#p110852

IIRC... unarmed combat behavior is mostly hardcoded; (or just lacking much modding support). It's handled differently than melee weapons. It's not something I have delved a lot into. I think what you want might be somewhat possible in a (very) round-about sort of way, using convoluted scripting... but that it might only ever be a fragile hack, that at best—kinda-almost works most of the time.

*But there are others here that have looked into it further, and might know differently. :ugeek:
bazuso wrote: Also, just to be sure, when I'm entering a champion object it should look something like ' (party.party:getChampion(1):setPortrait("human_male_11.tga") ', correct?
The setPortrait function expects the full path of the image. If it's a default asset, the path is that of the virtual file system within the game; ie. the same as that of the asset pack, starting with the assets folder. Note that the paths use forward-slashes; back-slash characters have a special meaning in strings, use forward slashes in path strings.

Code: Select all

party.party:getChampion(1):setPortrait("assets/textures/portraits/human_female_03.tga")
When it's a custom asset (as with "human_male_11.tga"), the path uses the mod_assets folder, in your project directory; where the file has to be. That path is arbitrary as you see fit, but always starting with "mod_assets/..."

Code: Select all

party.party:getChampion(1):setPortrait("mod_assets/textures/portraits/human_male_11.tga")

Re: New modder, need help (Default party, custom class)

Posted: Sat Jul 29, 2017 9:46 pm
by bazuso
Isaac wrote:The custom party question does come up often. Here is a link to where it was asked in the "Ask a Simple Question" thread:
viewtopic.php?f=22&t=7951&p=110854&hilit=default+party#p110852
I had seen that post before but I wasn't exactly sure how to proceed with writing the champion objects, but after some additional time I got it working. Also I was not aware of the additional path required for the portraits. Thank you.

I came up with two ideas regarding hand to hand as well but I am not sure how viable either of them are.
  • 1. Permanently locking a custom equipped weapon to the class. I could make a new undroppable "fist" weapon then have it scale higher than normal to make up for the lack of base damage it would have compared to other weapons.
    2. Add a new weapon class or have one replace heavy/light weapons.

Re: New modder, need help (Default party, custom class)

Posted: Sun Jul 30, 2017 1:03 am
by Isaac
...You could have an iron-fist... that really is one; a prosthetic fist shaped mace attached to the arm.

The hands are used by the characters for more than just combat. If the PC has a locked hand—weapon, they cannot equip food or drink from flasks; they also cannot hold torches. It means that for that character the player must open the inventory to interact with items; (even during combat).

From personal experience... the hand shaped weapon is opening a tangled can-of-worms; the game doesn't really support it. It can be done (or nearly so), but you will have to detect and handle all item interaction with the hands—and face, since the portrait doubles as a backpack target for items.

**I do not know of a way to distinguish items dropped on the hand, from items dropped on the portrait, from items manually dropped into inventory.

Re: New modder, need help (Default party, custom class)

Posted: Sun Jul 30, 2017 2:36 am
by bazuso
I have another issue now. The custom portraits appear fine while playtesting in the editor, but when exporting and starting the dungeon, it reverts back to the default ones. The names and anything else adjusted stays the same however.

Re: New modder, need help (Default party, custom class)

Posted: Sun Jul 30, 2017 2:42 am
by Isaac
bazuso wrote:I have another issue now. The custom portraits appear fine while playtesting in the editor, but when exporting and starting the dungeon, it reverts back to the default ones. The names and anything else adjusted stays the same however.
Try setting the portraits using a script_entity placed on the map, and triggered by a hidden floor_trigger, under the starting_location.

Code: Select all

function setPortraits()
	local images = {
				   	"minotaur_female_02",
					"insectoid_male_03",
					"ratling_female_04",
					"human_male_05"
				   }
	for x = 1, #images do
		local champ = party.party:getChampion(x)
		local path = "assets/textures/portraits/"
		local file = images[x]..".tga"
		if champ:getEnabled() then 
			champ:setPortrait(path..file)
		end	
	end
end
setPortraits()	

Re: New modder, need help (Default party, custom class)

Posted: Sun Jul 30, 2017 2:55 am
by bazuso
Isaac wrote:Try setting the portraits using a script_entity placed on the map, and triggered by a hidden floor_trigger, under the starting_location.
I should have specified that's how I have it set now. This is the same script entity that is altering the player names and races as well if that makes a difference.

Re: New modder, need help (Default party, custom class)

Posted: Sun Jul 30, 2017 3:03 am
by Isaac
Check your script for inaccurate letter case, in the file paths. Lua is case sensitive; Windows is not.

Or...
Swap out for the script above (to test). This works in the game for me.

Re: New modder, need help (Default party, custom class)

Posted: Sun Jul 30, 2017 3:11 am
by bazuso
Isaac wrote:Check your script for inaccurate letter case, in the file paths. Lua is case sensitive; Windows is not.

Or...
Swap out for the script above. This works in the game for me.
I erased the old script I was using and tried that one, however the issue persists. I also tried changing "assets/textures/portraits/" to "mod_assets/textures/portraits/" to see if that would work but it didn't.

Re: New modder, need help (Default party, custom class)

Posted: Sun Jul 30, 2017 3:28 am
by Isaac
That means it ~seems~ to work for me, and not for you. What happens if you start a new project, and add my script & floor_trigger? (Test it in-game using the custom map.)

* Check the About Box in the editor's Help menu. Ensure that the editor version is 2.2.4.