[Bug]Champion:setStatMax(stat,value)

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
Lollgramoth
Posts: 35
Joined: Fri Jun 15, 2012 7:31 am
Location: Germany

[Bug]Champion:setStatMax(stat,value)

Post by Lollgramoth »

Hi there,

I encountered a bug. I am making a Summoning-Spell and there for I was toying with the Stats. All the resistance-maxima will not change the maximum of the resistance.

I gave the Summoned thing maximum of 32 to all attributes and all resistances. Then set all Attributes to 32 and the resistance is 100.

To spare the hacking of the code:
SpoilerShow

Code: Select all

function smnGolem(caster,skill,golemtyp) --golemtyp not used yet
		local freeSpot = getFreeSpot()
		if(freeSpot) then
			local golem = party:getChampion(1)
			--setChampionToBuild(freeSpot,skill,golemtyp)
			
			golem:setName("Stone Golem")
			golem:setRace("Human")
			golem:setSex("male")
			golem:setClass("Fighter")
			
			golem:setStatMax("health", 180)
			golem:setStatMax("energy", 90)
			golem:setStatMax("strength", 32)
			golem:setStatMax("dexterity", 32)
			golem:setStatMax("vitality", 32)
			golem:setStatMax("willpower", 32)
			golem:setStatMax("protection", 32)
			golem:setStatMax("evasion", 32)
			golem:setStatMax("resist_fire", 32)
			golem:setStatMax("resist_cold", 32)
			golem:setStatMax("resist_poison", 32)
			golem:setStatMax("resist_shock", 32)
			
			golem:setStat("health", 180)
			golem:setStat("energy", 90)
			golem:setStat("strength", 32)
			golem:setStat("dexterity", 32)
			golem:setStat("vitality", 32)
			golem:setStat("willpower", 32)
			party:getChampion(freeSpot):setEnabled(true)
		else
			hudPrint("Your party is full, there is no way.")
		end
	end
Szragodesca
Posts: 59
Joined: Sun Oct 14, 2012 7:13 am

Re: [Bug]Champion:setStatMax(stat,value)

Post by Szragodesca »

iirc, the Vitality and Dexterity stats increase resistances. . . If you set the resist caps to 32 after setting the stats, does it then lower the resists properly? (just a thought) :)
Lollgramoth
Posts: 35
Joined: Fri Jun 15, 2012 7:31 am
Location: Germany

Re: [Bug]Champion:setStatMax(stat,value)

Post by Lollgramoth »

Nope, befor or after the strength, dexterity and so on...
The Attributes are more powerful than the maximum of ones capabilities ^^
And this one I think i can't fix with own code. I mean, what if my timer comes a tick to late. I just don't know how to sync my Clock with the GameClock in order to get a trustable code.
Szragodesca
Posts: 59
Joined: Sun Oct 14, 2012 7:13 am

Re: [Bug]Champion:setStatMax(stat,value)

Post by Szragodesca »

Have you changed your code at all from the original post? I see you setting statMax, but not the actual resist stat. Also, doubt it's the cause, but your code there shows "human" and "fighter" capitalized, which may not be what it's looking for since most base code here is all lowercase.

And you're saying that even after you set the stat, the actual value is much higher? I'm guessing it shows up naked, since I don't see anything in there about spawning gear and equipping it, which would negate the theory of gear adding to the resists.

I have a suggestion, and that is to put a button on the wall which, when pressed, changes the stats of the default party. See what happens to an already active and enabled group. (hiding suggestions in spoilers to save space) Mind you, these are all to see if you even can actually change the stat on a regular champ, since I don't know.

Checking resist changes and effects:
SpoilerShow
Can you set all resists to 0?
What if you set it to 0, then equip something with resists? (Fire Torc comes to mind)
If you have said resist item on and press it again, does it negate that bonus? (doubtful, but I'm a tester like that)
Playing with Resist Caps:
SpoilerShow
What if you set the resists to 35, then set the cap to 32? Does it reduce the stat?
What if you set the resist to 5 below your intended cap, set the cap, then put on a resist item? Does it overcap?
What if you do the first suggestion in reverse? Set the cap, then try to set the stat above it?
A couple thoughts:
SpoilerShow
1: Resists may be hardcoded into the races and, even though the code is in the library, it may be buggy. If so, see if you can find out where the base stats of the races are, and see of there's a way to "clone" or "define" a race. Then if you set the base resists of the golem to 32, and set its race to golem, I'm sure you could find a script to prevent it from equipping specific items (such as a fire torc). I have my doubts though, since the code is there to change the max.
2: Try enabling him before changing his stats? The bug may be in setting the resists of a disabled champion, as opposed to the code in all.
Hope that was all clear and I'm not just talking out my you-know-where. :roll:
Magus
Posts: 56
Joined: Wed Sep 12, 2012 6:05 pm

Re: [Bug]Champion:setStatMax(stat,value)

Post by Magus »

I had the same problem with the sdp back then but it worked fine on the champion when i changed from "Champion:setStatMax(stat, value)" to "Champion:setStat(stat, value)", somehow there is a problem when you try to change the max stat of the resistances.
Post Reply