Party modding ??: add skills and traits to party creation

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!
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Party modding ??: add skills and traits to party creatio

Post by akroma222 »

Falkenwrath wrote:Ok got my own class to show up and everything thank you. Now I have to try and figure out how to modify the amount of starting skill points and traits if possible. I want to give humans 3 skill points at first level instead of 2 / and to give farmers three traits instead of two.

EDIT::
is it possible to completely replace the premade classes with your own so they don't show up?
I dont believe you can increase either starting skill points or trait picks over 2

Here is an example of over writing a class... but as has been explained, you dont need to... just dont import all standard assets initially, just import your classes.lua (wherever you have defined them)
change of fighter to Pit Fighter (some of it is custom stuff requiring other scripts - dont worry, this is just an example - some traits can be added into the Class Trait def OR can be added through scripts immediately when you start up the mod - there may be a simpler and easier way to manage this)
SpoilerShow

Code: Select all

-----------------------------PIT FIGHTER

defineCharClass{
	name = "fighter",
	uiName = "Pit Fighter",
	traits = { "melee_specialist"}, 
	optionalTraits = 1,
	skillPoints = 1,
}

defineTrait{
	name = "fighter",
	uiName = "Pit Fighter",
	icon = 96,
	description = "A Pit Fighter from the Rapax Fire Pits, you are a master of melee combat and survive with brutal and swift efficiency. No other profession can match your skill in wielding a wide variety of close combat weaponary.",
	gameEffect = [[
	) Health 70 (+8 per level), Energy 35 (+4 per level).
	) Strength +1 or Dexterity +1 / Lvl.
	) Melee weapon Special Attack build up times reduced 50% & costs reduced 25%.
	) (Weaponeer) Light & Heavy Weapons skills advance equally.
	) (Endurance) Max Load increased 15% & food consumption reduced 15%.
	) (Non-caster) You start with no Spellbooks.]],
	onRecomputeStats = function(champion, level)
		if level > 0 then
			local lvl = champion:getLevel()
			champion:addStatModifier("max_health", 70 + (lvl-1) * 8)
			champion:addStatModifier("max_energy", 35 + (lvl-1) * 4)
		end
	end,
}
Isaac wrote:
minmay wrote:Yes. The scripting reference explains how to define custom races, classes, skills, and traits under "Asset definitions". You can also download the asset pack to look at the definitions for all the standard races, classes, skills, and traits. The new items will appear on the party creation screen by default. There is also no need to keep all the standard races/classes/skills/traits in your mod, although you'll get a lot of console spam in the editor if you exclude default skills.
That's pretty cool, and unexpected. I'm genuinely surprised at that change in design. I'll have to examine that then. 8-)

Just tried it out and it works marvelously. [New tricks :D ]
Image
Isaac, is that a custom Naga race inventory background I see??? ;)
Last edited by akroma222 on Sat Jul 15, 2017 10:39 am, edited 1 time in total.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Party modding ??: add skills and traits to party creatio

Post by Isaac »

akroma222 wrote:Isaac, is that a custom Naga race inventory background I see??? ;)
A quick one for the test, yes. ;)
(Both now flipped, so that bracelet/cuffs can be seen as tail accessories; and that the glove slot doesn't look crowded.)
Image
Falkenwrath
Posts: 15
Joined: Tue Aug 04, 2015 6:32 am

Re: Party modding ??: add skills and traits to party creatio

Post by Falkenwrath »

ok heres my new problem. my practice class is set up like so.


defineTrait{
name = "fighter",
uiName = "Warrior",
icon = 96,
description = "As a Warrior you are a master of close combat. You are trained to use a wide variety of weapons",
gameEffect = [[
- Health 70 (+7 per level), Energy 45 (+4 per level)
- Special attacks with melee weapons take half the time to build up and cost 25% less energy.]],
onRecomputeStats = function(champion, level)
if level > 0 then
level = champion:getLevel()
champion:addTrait("weapon_specialization")
champion:addStatModifier("max_health", 70 + (level-1) * 7)
champion:addStatModifier("max_energy", 40 + (level-1) * 4)
end
end,
}

I have other classes with added abilities too. setup exactly the same. However ""weapon_specialization"" is added to every character in the party while they retain their own added trait to themselves. I am confused as hell, at first it didn't do this. but I had char_classes.lua
as follows.

defineCharClass{
name = "fighter",
uiName = "Warrior",
traits = { "melee_specialist", "weapon_specialization = true"},
optionalTraits = 2.,
}
This worked for awhile yesterday until I added traits for other classes.
With out both scripts looking like this, when I did char creator, I could select and pick the trait I was adding as part of the class free thus wastin a trait on accident. when I put = true in char_classes.lua. it darkened martial training like I wanted so it wasn't an option on creation.

but after I add to other classes, it gets applied to everyone -.- ggrrrr
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Party modding ??: add skills and traits to party creatio

Post by minmay »

The code you are posting is nonsense... there is no trait called "weapon_specialization = true" unless you defined one. Why do you want to call Champion:addTrait() inside an onRecomputeStats hook? Those hooks get called every frame!
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.
Falkenwrath
Posts: 15
Joined: Tue Aug 04, 2015 6:32 am

Re: Party modding ??: add skills and traits to party creatio

Post by Falkenwrath »

'''onRecomputeStats = function(champion, level)
if level > 0 then
local lvl = champion:getLevel()
champion:addTrait("endurance")
champion:addTrait("weaponeer")
champion:addTrait("non_caster")
champion:addStatModifier("max_health", 70 + (lvl-1) * 8)
champion:addStatModifier("max_energy", 35 + (lvl-1) * 4)
end'''

from akroma's post

add traits are listed
so I want it

champion:addStat ect... ect..
end
champion:addTrait ("weapon_specialization") <---- after onRecomputeStat
end
}

I had it like this but it still applied it to everyone. this works for everyone else but my first defineTrait/class. all other instances work. Akroma's code also works fine with the other defined classes.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Party modding ??: add skills and traits to party creatio

Post by minmay »

There is no reason to call addTrait in an onRecomputeStats hook. I don't know why akroma wants to do this and I don't know why you want to do this. If you want to start a class or race with the trait, just start them with the trait by adding it to their traits table. If you want to add shield_expert to battle mage, for example, just do this:

Code: Select all

defineCharClass{
	name = "battle_mage",	
	uiName = "Battle Mage",
	traits = { "hand_caster", "armor_expert", "staff_defence", "shield_expert" },
	optionalTraits = 2,
}
onRecomputeStats is called (almost) every frame and not in any well-defined order. That is why addStatModifier is normally the only state change that you make in it; it's specifically designed to be called from onRecomputeStats hooks.
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.
Falkenwrath
Posts: 15
Joined: Tue Aug 04, 2015 6:32 am

Re: Party modding ??: add skills and traits to party creatio

Post by Falkenwrath »

minmay wrote:There is no reason to call addTrait in an onRecomputeStats hook. I don't know why akroma wants to do this and I don't know why you want to do this. If you want to start a class or race with the trait, just start them with the trait by adding it to their traits table. If you want to add shield_expert to battle mage, for example, just do this:

Code: Select all

defineCharClass{
	name = "battle_mage",	
	uiName = "Battle Mage",
	traits = { "hand_caster", "armor_expert", "staff_defence", "shield_expert" },
	optionalTraits = 2,
}
onRecomputeStats is called (almost) every frame and not in any well-defined order. That is why addStatModifier is normally the only state change that you make in it; it's specifically designed to be called from onRecomputeStats hooks.
ok I have it like you do but the trait doesn't show up in the character sheet in game. it only shows up if I champion:addTrait(ext.) otherwise it works but doesn't show up on the character sheet. I get the benefit from ("weapon_specialization") but if I want it on screen if possible.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Party modding ??: add skills and traits to party creatio

Post by Isaac »

Strange thing I have gotten.

When I've defined a new class, the game crashes when I display the traits tab of (and only of) the new classed PC.

This happens when I pasted the following into Objects.lua.

Code: Select all


defineCharClass{
	name = "battle_mage",	
	uiName = "Battle Mage",
	traits = { "hand_caster", "armor_expert", "staff_defence" },
	optionalTraits = 2,
}

defineCharClass{
	name = "bottle_mage",	
	uiName = "Bottle Mage",
	traits = { "hand_caster", "armor_expert", "staff_defence" },
	optionalTraits = 2,
}

With this, Bottle Mages crash the game when you open their traits tab.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Party modding ??: add skills and traits to party creatio

Post by akroma222 »

Isaac, I think you have to add the rest of the Class definition (including Class trait)
SpoilerShow

Code: Select all

defineCharClass{
       name = "bottle_mage",   
       uiName = "Bottle Mage",
       traits = { "hand_caster", "armor_expert", "staff_defence" },
       optionalTraits = 2,
    }

    defineTrait{
	name = "bottle_mage",
	uiName = "Bottle Mage",
	icon = 98,
	description = "........................................................",
	gameEffect = [[
	) Health 50 (+5 per level), Energy 60 (+7 per level)
	) Willpower +1 or Protection +1 / Lvl.
	) Staff and Wand skill +1.
	) (Armour Expert) Armour Weight is reduced 50%.
	) (Staff Defense) PRO & Resist All +10 if Stave or Runewand equipped.
	) (Hand Caster) You can cast without Runewands.]],
 	onRecomputeStats = function(champion, level)
		if level > 0 then
			local lvl = champion:getLevel()
			champion:addStatModifier("max_health", 50 + (lvl-1) * 5)
			champion:addStatModifier("max_energy", 60 + (lvl-1) * 7)
		end
	end,
}
onDrawSkills/Traits is crashing because Bottle mage isnt original asset (no Bottle mage trait) - I think....

Ive had other crashes with traits, at Character Gen screen but this is because I was calling silly things in onRecomputeStats
(like referencing a weapon in the first line of onRecomputeStats, before the game has even started = crash obviously)
minmay wrote:There is no reason to call addTrait in an onRecomputeStats hook. I don't know why akroma wants to do this and I don't know why you want to do this. If you want to start a class or race with the trait, just start them with the trait by adding it to their traits table. If you want to add shield_expert to battle mage, for example, just do this:

Code: Select all

defineCharClass{
	name = "battle_mage",	
	uiName = "Battle Mage",
	traits = { "hand_caster", "armor_expert", "staff_defence", "shield_expert" },
	optionalTraits = 2,
}
onRecomputeStats is called (almost) every frame and not in any well-defined order. That is why addStatModifier is normally the only state change that you make in it; it's specifically designed to be called from onRecomputeStats hooks.


Falkenwrath, minmay is right, dont add traits from onRecomputeStats.
Totally my bad there, it seems to work but infact it can get very messy and annoying.
I have to go through and change my class traits now hehehe
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Party modding ??: add skills and traits to party creatio

Post by Isaac »

That was it. 8-)
(Thanks)
Post Reply