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!
User avatar
Zo Kath Ra
Posts: 932
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

kelly1111 wrote:Quick Qestion: Has anyone ever converted the scripts for the "bouncing chakram" from grimrock 1, and if so, are they willing to share their code?
Thanks for letting me know that this exists :)
viewtopic.php?f=14&t=4798

Have you asked the creator if he's willing to port it to LoG2?
User avatar
Zo Kath Ra
Posts: 932
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

THOM wrote:
kelly1111 wrote:Quick Qestion: Has anyone ever converted the scripts for the "bouncing chakram" from grimrock 1, and if so, are they willing to share their code?
I have never encountered a coverted version. And AFAIK the code of it was never bug free.

But maybe someone did a new version secretly?
What kinds of bugs?
I've tried the latest version, and it seems to work fine.
(please answer in the Bouncing Chakram thread)
minmay
Posts: 2770
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

CrEaToXx wrote:
onRecomputeStats is called every frame, so the champion to whom this applies will have their skill points set to 2 or 3 every frame.
Then why doesn't this happen for stats as well?
It does happen for stats as well.
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.
CrEaToXx
Posts: 25
Joined: Thu Jan 19, 2017 9:58 pm

Re: Ask a simple question, get a simple answer

Post by CrEaToXx »

minmay wrote:
CrEaToXx wrote:
onRecomputeStats is called every frame, so the champion to whom this applies will have their skill points set to 2 or 3 every frame.
Then why doesn't this happen for stats as well?
It does happen for stats as well.
Ok, I got the checker bug fixed. But isn't there a solution for giving skill extra points during character creation? Something like addSkillModifier?
minmay
Posts: 2770
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

I think you fundamentally misunderstand what addStatModifier does.
All stats have both a "base" value and a "current" value. Every time stats are recomputed (which is basically once every frame), the "current" value is reset to the "base" value. Then onRecomputeStats hooks are called and addStatModifier adds to the "current" value, and bonuses from equipment, rage, etc. are also added to the "current" value. The "base" value is unaffected by this.
There's no equivalent system for skill points - skill points are just one number.

If you want to add extra skill points during character creation, it's possible but you'll need to do something very hacky and unpleasant - e.g. keep track of a separate variable that notes whether you've given the skill point(s) or not, and you'll have to remember to take the extra skill points away if the player changes the character's race, and you have to decide what to do if they change race after already spending the skill point, etc...
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.
CrEaToXx
Posts: 25
Joined: Thu Jan 19, 2017 9:58 pm

Re: Ask a simple question, get a simple answer

Post by CrEaToXx »

minmay wrote:I think you fundamentally misunderstand what addStatModifier does.
All stats have both a "base" value and a "current" value. Every time stats are recomputed (which is basically once every frame), the "current" value is reset to the "base" value. Then onRecomputeStats hooks are called and addStatModifier adds to the "current" value, and bonuses from equipment, rage, etc. are also added to the "current" value. The "base" value is unaffected by this.
There's no equivalent system for skill points - skill points are just one number.

If you want to add extra skill points during character creation, it's possible but you'll need to do something very hacky and unpleasant - e.g. keep track of a separate variable that notes whether you've given the skill point(s) or not, and you'll have to remember to take the extra skill points away if the player changes the character's race, and you have to decide what to do if they change race after already spending the skill point, etc...
Is it possible to add a hidden characterclass via race selection during character creation then? This way I could use the CC as hack in order to applie the skill point.
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

May I suggest an alternative?
Instead of adding the skill point on the character creation screen, you could use the description of the race to tell the player they will get an extra skill point when the game begins.
When the game begins, have a loop run through all the heroes, check for their race, and increment it by 1.
Sure, the player won't be able to invest that point directly from the party creation screen, but its a small price to pay.
My asset pack [v1.10]
Features a bit of everything! :D
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

The bonus effect of this method would be that this skill point can be used to start with a rank 2 skill :)
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

AndakRainor wrote:The bonus effect of this method would be that this skill point can be used to start with a rank 2 skill :)
True, didn't think of that.
Nothing wrong with that in my opinion.
My asset pack [v1.10]
Features a bit of everything! :D
CrEaToXx
Posts: 25
Joined: Thu Jan 19, 2017 9:58 pm

Re: Ask a simple question, get a simple answer

Post by CrEaToXx »

Ok, so I made a script entity placed besides the starting cage and connected it to a wall button for testing purpose, but pressing the button gives me a "invalid script blablabla function" in console when testing in game. Here's the code:

---wrong code removed---

Edit:

Ha, fixed. There was a mistake in syntax. Code needs to look like this, and it does work on level 1 as well...

Code: Select all

function extraSkillPoints()
	for i = 1,4 do
		local cChampion = party.party:getChampion(i)
		hudPrint(tostring(cChampion:getName()))
    	local cRace = cChampion:getRace()
		hudPrint(tostring(cChampion:getRace()))	
		if cRace == "dwarf" then
			cChampion:addSkillPoints(1)			
		end
	end	
end
Now I just need to find a way to initialize the script without the press of a button. Counter? Connect the script to opening the cage gate? Any other suggestions?

Edit 2: A timer did the trick. Here are some screenshots to proof of concept...:)
SpoilerShow
Image
Image
Edit 3: Btw., before I break my head again. During CC, would it be possible to restrict certain races, if another race is already in your party?
Post Reply