scripting new skill / class

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
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: scripting new skill / class

Post by petri »

I would guess you aren't running beta 2.1.15 or later?
User avatar
Leki
Posts: 550
Joined: Wed Sep 12, 2012 3:49 pm

Re: scripting new skill / class

Post by Leki »

petri wrote:I would guess you aren't running beta 2.1.15 or later?
I have 2.1.16

... and ingame console command

Code: Select all

party.party:getChampion(1):setClass("my_custom_class")
works.[/color]
I'm the Gate I'm the Key.
Dawn of Lore
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: scripting new skill / class

Post by petri »

Then you should be good to go. You probably have an error in the scripts. Here's something to get you up to speed:

Code: Select all

defineRace{
	name = "hobbit",
	uiName = "Hobbit",
	inventoryBackground = "assets/textures/gui/inventory_backgrounds/human_$sex.tga",
}

defineTrait{
	name = "hobbit",
	uiName = "Hobbit",
	icon = 0,
	--iconAtlas = "mod_assets/textures/skills.tga",
	description = "As a hobbit you are really short.",
	onRecomputeStats = function(champion, level)
		if level > 0 then
			champion:addStatModifier("dexterity", 10)
		end
	end,	
}

defineCharClass{
	name = "king",
	uiName = "King",
}

defineTrait{
	name = "king",
	uiName = "King",
	icon = 1,
	--iconAtlas = "mod_assets/textures/skills.tga",
	description = "...",
	gameEffect = [[- Health 60 (+7 per level), Energy 30 (+3 per level)]],
	onRecomputeStats = function(champion, level)
		if level > 0 then
			level = champion:getLevel()
			champion:addStatModifier("max_health", 60 + (level-1) * 7)
			champion:addStatModifier("max_energy", 30 + (level-1) * 3)
		end
	end,
}
User avatar
Leki
Posts: 550
Joined: Wed Sep 12, 2012 3:49 pm

Re: scripting new skill / class

Post by Leki »

Hobbit / King is there, so conclusion is we really need assetpack :twisted:
Thanks for your help!
I'm the Gate I'm the Key.
Dawn of Lore
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: scripting new skill / class

Post by petri »

Sweet! Hobbit Kings will rule the world!
User avatar
Leki
Posts: 550
Joined: Wed Sep 12, 2012 3:49 pm

Re: scripting new skill / class

Post by Leki »

Comparing my definition and hobbits: the only difference is, that 'onRecomputeStats' probably is not optional as scripting definitions says. Adding that took my custom class to work.
Last edited by Leki on Fri Nov 07, 2014 4:13 pm, edited 1 time in total.
I'm the Gate I'm the Key.
Dawn of Lore
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: scripting new skill / class

Post by petri »

Leki wrote:comparing my script and hobbit the only difference is, that onRecomputeStats probably is not optional as scripting definitions says
It is optional. There must be something else.

EDIT: well, sort of "optional", without it you get very little health!
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: scripting new skill / class

Post by akroma222 »

Petri and Leki - thank you both of you!!
Those examples were a great help :D
User avatar
Leki
Posts: 550
Joined: Wed Sep 12, 2012 3:49 pm

Re: scripting new skill / class

Post by Leki »

Well... You were right petri, looking for the reason of this mess, I went through system and here is the true story:
I made definition, It was ok, but the game wasnot updated! Looking for solution, after crashes I restarted game very first - and it happened few times. After last crash I started to type my post, but during this time, steam decided that it's 'good time' to update the game to 2.1.16. You wrote reply fast so when you asked for version, I checked it and it was 2.1.16 and my next try with script was with your's hobbit and it worked of course - as My custom class as well...
and all this happened because I use my notebook right now and instead of my desktop where LoG is allways updated, this one was not - so some times shit happens, haha, have a nice day man!
I'm the Gate I'm the Key.
Dawn of Lore
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: scripting new skill / class

Post by petri »

Oh, sometimes things like these happen. Great that you got it working! Have fun!
Post Reply