character 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!
benito82
Posts: 12
Joined: Sun Jan 03, 2016 10:12 pm

character creation

Post by benito82 »

custom characters.
defineCharClass{
name = "cruisader",
uiName = "Cruisader",
traits = { "armor_expert", "shield_expert", "hand_caster", "staff_defence", "cruisader"},
skillpoints = 10
optionalTraits = 2,
}
defineTrait{
name = "cruisader",
uiName = "Cruisader",
icon = 97,
description = "As a Cruisader you believe that good preparation is the key to triumph in combat. You are specialized in wielding armor and using the shield.",
gameEffect = [[
- Health 60 (+7 per level), Energy 45 (+4 per level)
- Protection +1 per level.
- You can cast spells with bare hands.
- Weight of equipped armor is reduced by 50%.
- Evasion bonus of equipped shields is increased by 50%.
- you gain 1 strength.
- you gain 1 vitality.
- you gain 1 willpower.]],
onRecomputeStats = function(champion, level)
if level > 0 then
level = champion:getLevel()
champion:addStatModifier("strength", 1)
champion:addStatModifier("vitality", 1)
champion:addStatModifier("willpower", 1)
champion:addStatModifier("max_health", 60 + (level-1) * 7)
champion:addStatModifier("max_energy", 45 + (level-1) * 4)
end
end,
}

--cruisader traits
defineTrait{
name = "cruisader",
uiName = "Cruisader",
priority = 300,
icon = 29,
charGen = true,
hidden = false,
requiredRace = "human"
description = "You are holy incarnite, gain +3 accuracy with melee weapons. At level 11 you gain +7 protection, +1 strength, +1 willpower, +1 vitality",
onComputeAccuracy = function(champion, weapon, attack, attackType, level)
if level > 0 and attackType == "melee" then return 3 end
end,
onRecomputeStats = function(champion , level, class)
if level > 0 then
class =champion:getClass()
level = champion:getLevel()
if class = "cruisader" then
Champion:hasTrait(cruisader),and level > 10
-- is this where I can set level additions for improvments // like setting at level 2 and 18 certain levels are able to be casted?
-- question 1
Champion:hasTrait(cruisader_mastery) end
end,
onRecomputeStats = function(champion, level)
if level > 10 then
champion:addStatModifier("strength", 1)
champion:addStatModifier("vitality", 1)
champion:addStatModifier("willpower", 1)
champion:addStatModifier("protection", 7)
end
end,
traits = { [5] = "cruisader_mastery",
}


so with spell sets its just refined as a defnied class Boolean and value is true for the 3 classes? can use the nil value for monsters to cast this.
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: character creation

Post by zimberzimber »

First of all, your code is a mess and has a lot of mistakes that will crash the game. I hope this helps:

Code: Select all

	onRecomputeStats = function(champion , level, class)
		if level > 0 then
			class = champion:getClass()	-- *1
			level = champion:getLevel()	-- *1
			if class = "cruisader" then		-- *2
				Champion:hasTrait(cruisader),and level > 10	-- *3
				-- is this where I can set level additions for improvments // like setting at level 2 and 18 certain levels are able to be casted?
				-- question 1
				Champion:hasTrait(cruisader_mastery)		--*3
			end	-- *4
	end,
*1 - Since the function already receives level and class, you don't have to redefine them, because they already have a value stored in them. The same value you gave them.
*2 - When using if and comparing one thing to another, you must always use ==. = is for setting a value.
*3 - These aren't part of anything. They will return a value when called, but have no where to store it, or nothing to check it. (if)
If you want them to be part of "if class = "cruisader" then", you should replace "then" with "and", and add "then" when you're done adding extra things to check.
*4 - Needs another end to close the second "if" line.

Code: Select all

	traits = { [5] = "cruisader_mastery",
Traits don't have a traits field. And you forgot to close it.

Stat additions per level are added to the onRecomputeStats function. Like in what you posted -

Code: Select all

	onRecomputeStats = function(champion, level)
		if level > 10 then
			champion:addStatModifier("strength", 1)
			champion:addStatModifier("vitality", 1)
			champion:addStatModifier("willpower", 1)
			champion:addStatModifier("protection", 7)
		end
	end,
When can a spell be cast and what it requires is defined withing the spell definition. For example:

Code: Select all

defineSpell{
	name = "cold",
	uiName = "Cold",
	gesture = 9,
	manaCost = 25,
	skill = "water_magic",
--	requirements = { "water_magic", 1},
	icon = 60,
	spellIcon = 1,
	description = "Cold",
	
	onCast = function(champion, x, y, direction, skill)
		if champion:hasTrait("wizard") then
			print("wizard")
		elseif champion:hasTrait("crusader") then
			print("crusader")
		else
			print("not a wizard or a crusader")
			champion:regainEnergy(25)
		end
	end,
}
Hope this answered your question.
My asset pack [v1.10]
Features a bit of everything! :D
benito82
Posts: 12
Joined: Sun Jan 03, 2016 10:12 pm

Re: character creation

Post by benito82 »

some of what you are suggesting as changes are direct counter to what log defined assets are using.
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: character creation

Post by zimberzimber »

benito82 wrote:some of what you are suggesting as changes are direct counter to what log defined assets are using.
How exactly?
Can you specify what counter what?
My asset pack [v1.10]
Features a bit of everything! :D
benito82
Posts: 12
Joined: Sun Jan 03, 2016 10:12 pm

Re: character creation

Post by benito82 »

defineTrait{
name = "poison_resistant",
uiName = "Poison Resistant",
icon = 79,
charGen = true,
description = "You are naturally resistant to poisons. Resist Poison +25",
onRecomputeStats = function(champion, level)
if level > 0 then
champion:addStatModifier("resist_poison", 25)
end
end,
}
--now this example was to add in the gui gold. but the trait is still defined with its own stats and modifier

defineTrait{
name = "pack_mule",
uiName = "Pack Mule",
icon = 109,
description = "Your max carrying capacity is increased by 15 kg.",
onRecomputeStats = function(champion, level)
if level > 0 then
champion:addStatModifier("max_load", 15)
end
end,
}
--since this is a playable "class" as I was defining it I did it partially together. I have some other parts for the whole 3 classes i'm trying to add. cruisader, cleric, and ranger type. i'm hoping to be able to script it in so that it works with the orginal games and you can add it into log 1 and 2 for playability and then it would all cross over into the overall assets so it can be added to mods on start, I don't know about in progress.

straight from assets.
benito82
Posts: 12
Joined: Sun Jan 03, 2016 10:12 pm

Re: character creation

Post by benito82 »

also here is the cleaned up code. i'm still iffy about the implementation. has anyone else worked on a way to play the game with created classes and possibly races?

defineCharClass{
name = "cruisader",
uiName = "Cruisader",
traits = { "armor_expert", "shield_expert", "hand_caster", "staff_defence", "cruisader"},
skillpoints = 10
optionalTraits = 2,
}
defineTrait{
name = "cruisader",
uiName = "Cruisader",
icon = 97,
description = "As a Cruisader you believe that good preparation is the key to triumph in combat. You are specialized in wielding armor and using the shield.",
gameEffect = [[
- Health 60 (+7 per level), Energy 45 (+4 per level)
- You can cast spells with bare hands.
- Weight of equipped armor is reduced by 50%.
- Evasion bonus of equipped shields is increased by 50%.
- you gain 1 strength.
- you gain 1 vitality.
- you gain 1 willpower.]],
onRecomputeStats = function(champion, level)
if level > 0 then
level = champion:getLevel()
champion:addStatModifier("strength", 1)
champion:addStatModifier("vitality", 1)
champion:addStatModifier("willpower", 1)
champion:addStatModifier("max_health", 60 + (level-1) * 7)
champion:addStatModifier("max_energy", 45 + (level-1) * 4)
end,
end,
}

--cruisader traits
defineTrait{
name = "cruisader",
uiName = "Cruisader",
priority = 300, --scroll down
icon = 29,
charGen = true,
hidden = false,
requiredRace = "human"
description = "You are holy incarnite, gain +3 accuracy with blunt weapons weapons. At level 11 you gain +7 protection, +1 strength, +1 willpower, +1 vitality",

onComputeAccuracy = function(champion, weapon, attack, attackType, level, class)
if level > 0 and attackType == "mace" then return 3 end
end,
if level > 0 then
class =champion:getClass()
level = champion:getLevel()
if class = "cruisader" then
Champion:hasTrait(cruisader),and level > 10
Champion:hasTrait(cruisader_mastery) end,
end,

defineTrait{
name = "cruisader_mastery",
uiName = "Cruisader Mastery",
icon = 9999
description = "You are a master of good!"

onRecomputeStats = function(champion, level)
if level > 10 then
champion:addStatModifier("strength", 1)
champion:addStatModifier("vitality", 1)
champion:addStatModifier("willpower", 1)
champion:addStatModifier("protection", 7)
end,
end,
}
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: character creation

Post by akroma222 »

Hey!
Cleaned up code (sort of...):
SpoilerShow

Code: Select all

defineCharClass{
	name = "cruisader",
	uiName = "Cruisader",
	--traits = { "armor_expert", "shield_expert", "hand_caster", "staff_defence", "cruisader"},
	skillpoints = 10
	optionalTraits = 2,
}
defineTrait{
name = "cruisader",
uiName = "Cruisader",
icon = 97,
description = "As a Cruisader you believe that good preparation is the key to triumph in combat. You are specialized in wielding armor and using the shield.",
gameEffect = [[
- Health 60 (+7 per level), Energy 45 (+4 per level)
- You can cast spells with bare hands.
- Weight of equipped armor is reduced by 50%.
- Evasion bonus of equipped shields is increased by 50%.
- you gain 1 strength.
- you gain 1 vitality.
- you gain 1 willpower.]],
onRecomputeStats = function(champion, level)
	if level > 0 then
		level = champion:getLevel()
		champion:addStatModifier("strength", 1)
		champion:addStatModifier("vitality", 1)
		champion:addStatModifier("willpower", 1)
		champion:addStatModifier("max_health", 60 + (level-1) * 7)
		champion:addStatModifier("max_energy", 45 + (level-1) * 4)
	end
end,
}

--cruisader traits
defineTrait{
	name = "cruisader",
	uiName = "Cruisader",
	priority = 300, --scroll down
	icon = 29,
	charGen = true,
	hidden = false,
	--requiredRace = "human"
	description = "You are holy incarnite, gain +3 accuracy with blunt weapons weapons. At level 11 you gain +7 protection, +1 strength, +1 willpower, +1 vitality",
	onComputeAccuracy = function(champion, weapon, attack, attackType, level, class)
		if level > 0 then 
			if attack and attackType == "mace" 
				return 3 
			end
		end
	end,
	onRecomputeStats = function(champion, level)
		if level > 0 then
			level = champion:getLevel()
			if class = "cruisader" and level > 10 then
				champion:addTrait(cruisader_mastery) 
			end
		end
	end,

defineTrait{
	name = "cruisader_mastery",
	uiName = "Cruisader Mastery",
	icon = 9999
	description = "You are a master of good!"
	onRecomputeStats = function(champion, level)
		if level > 10 then
			champion:addStatModifier("strength", 1)
			champion:addStatModifier("vitality", 1)
			champion:addStatModifier("willpower", 1)
			champion:addStatModifier("protection", 7)
		end
	end,
}
You have a Class & a non-class Trait with the same name.... 'cruisader'
Also not sure what one of your onRecomputeStats hooks is trying to do

Regarding the adding of traits to Race and Class - the method you have used is troublesome.
SpoilerShow

Code: Select all

defineCharClass{
	name = "cruisader",
	uiName = "Cruisader",
--------------------------------------------------------------------------------------------------
traits = { "armor_expert", "shield_expert", "hand_caster", "staff_defence", "cruisader"},
-----------------------------------------------------------------------------------------------------------------
	skillpoints = 10
	optionalTraits = 2,
}
It is also strongly recommended you DONT add traits through the onRecomputeStats hook ! :o
Best to create a Script that runs immediately on starting the game - check for Race and Class and then add Traits accordingly

Have a read through this thread and see if it clears anything up for you
viewtopic.php?f=22&t=14541

Akroma
benito82
Posts: 12
Joined: Sun Jan 03, 2016 10:12 pm

Re: character creation

Post by benito82 »

how does this look. sorry took some real time to clean it up and look at the implementation.
SpoilerShow
defineCharClass{
name = "cruisader",
uiName = "Cruisader",
traits = { "armor_expert", "shield_expert", "hand_caster", "cruisader"},
skillpoints = 10
optionalTraits = 2,
}
defineTrait{
name = "cruisader",
uiName = "Cruisader",
icon = 97,
charGen = true,
hidden = false,
requiredRace = "human"
description = "As a Cruisader you believe that good preparation is the key to triumph in combat. You are specialized in wielding armor and using the shield.",
description = "You are holy incarnite, gain +3 accuracy with blunt weapons weapons. At level 11 you gain +7 protection, +1 strength, +1 willpower, +1 vitality",
gameEffect = [[
- Health 60 (+7 per level), Energy 45 (+4 per level)
- You can cast spells with bare hands.
- Weight of equipped armor is reduced by 50%.
- Evasion bonus of equipped shields is increased by 50%.
- you gain 1 strength.
- you gain 1 vitality.
- you gain 1 willpower.]],
onComputeAccuracy = function(champion, weapon, attack, attackType, level, class)
if level > 0 and attackType == "mace" then return 3 end
end,
if level > 10 then
description = "You are a master of good!"
onRecomputeStats = function(champion, level)
if level > 10 then
champion:addStatModifier("strength", 1)
champion:addStatModifier("vitality", 1)
champion:addStatModifier("willpower", 1)
champion:addStatModifier("protection", 7)
end,
end,
if level > 0 then
level = champion:getLevel()
champion:addStatModifier("strength", 1)
champion:addStatModifier("vitality", 1)
champion:addStatModifier("willpower", 1)
champion:addStatModifier("max_health", 60 + (level-1) * 7)
champion:addStatModifier("max_energy", 45 + (level-1) * 4)
end,
}
Last edited by benito82 on Mon Oct 03, 2016 12:41 am, edited 1 time in total.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: character creation

Post by akroma222 »

Hey! still some changes to make here, pls read the comments included :)
Also, if you want to place code in spoiler sections (as below) - just click on spoiler button, then Code button, then paste code in the middle
SpoilerShow

Code: Select all

defineCharClass{
	name = "cruisader",
	uiName = "Cruisader",
	--traits = { "armor_expert", "shield_expert", "hand_caster", "cruisader"},	--add these in a script that starts when you begin the game
	skillpoints = 10
	optionalTraits = 2,
}

defineTrait{
	name = "cruisader",
	uiName = "Cruisader",
	icon = 97,
	--charGen = true,			--you dont need charGen, hidden and def not requiredRace - these are for normal traits - not Race or Class traits
	--hidden = false,
	--requiredRace = "human"
	--description = "As a Cruisader you believe that good preparation is the key to triumph in combat. You are specialized in wielding armor and using the shield.",
	description = "You are holy incarnite, gain +3 accuracy with blunt weapons weapons. At level 11 you gain +7 protection, +1 strength, +1 willpower, +1 vitality",	--you have 2 descriptions here - choose 1
	gameEffect = [[
- Health 60 (+7 per level), Energy 45 (+4 per level)
- You can cast spells with bare hands.
- Weight of equipped armor is reduced by 50%.
- Evasion bonus of equipped shields is increased by 50%.
- you gain 1 strength.
- you gain 1 vitality.
- you gain 1 willpower.]],
	onRecomputeStats = function(champion, level)
		if level > 0 then
			lvl = champion:getLevel()
			champion:addStatModifier("strength", 1)
			champion:addStatModifier("vitality", 1)
			champion:addStatModifier("willpower", 1)
			champion:addStatModifier("max_health", 60 + (lvl-1) * 7)
			champion:addStatModifier("max_energy", 45 + (lvl-1) * 4)

			if level > 10 then
				champion:addStatModifier("strength", 1)
				champion:addStatModifier("vitality", 1)
				champion:addStatModifier("willpower", 1)
				champion:addStatModifier("protection", 7)
			end
		end
	end,
	onComputeAccuracy = function(champion, weapon, attack, attackType, level, class)
		if level > 0 then
			if attack and attackType == "melee" then 
				if weapon and weapon:hasTrait("mace") then
					return 3
				end
			end
		end
		if level > 10 then
			description = "You are a master of good!"	
			--are you trying to change the traits description once the champ gets to level 10 ?? 
			--if so, Im not sure how - or even if it can be done .....
		end
	end,
}
I feel like you may be getting definitions for Traits (like Aura or Strong mind) mixed up with defining your custom races / Classes
Here is a quick example of how to set up a Class definition:
SpoilerShow

Code: Select all

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

defineTrait{
	name = "fighter",
	uiName = "Pit Fighter",
	iconAtlas = "mod_assets/textures/legacy_custom_icons1.tga",
	icon = 12,
	description = "Pit Fighters carve through enemies with swift and deadly efficiency............. blah blah blah",
	gameEffect = [[
- Health 60 (+7 per level), Energy 45 (+4 per level)
- You can cast spells with bare hands.
- Weight of equipped armor is reduced by 50%.
- Evasion bonus of equipped shields is increased by 50%.
- you gain 1 strength.
- you gain 1 vitality.
- you gain 1 willpower.]],
	onRecomputeStats = function(champion, level)
		if level > 0 then
			local lvl = champion:getLevel()
			champion:addStatModifier("resist_fire", lvl)
			champion:addStatModifier("max_health", 65 + (lvl-1) * 7)	
			champion:addStatModifier("max_energy", 35 + (lvl-1) * 3)
		end
	end,
	onReceiveCondition = function(champion, cond, level)
		if level > 0 then
			if cond and cond == "weakened" and math.random() <= 0.25 then
				return false
			end
			if cond and cond == "starving" then
				return false
			end
		end
	end,
}	
benito82
Posts: 12
Joined: Sun Jan 03, 2016 10:12 pm

Re: character creation

Post by benito82 »

for the level 10, its a trait addition, like water magic leads to watermagic_matery ... so that like when a cleric becomes level 8 she can turn undead ? and into the additions of being able to have summoned class weapons.
Post Reply