csbx Posted September 25, 2016 Share Posted September 25, 2016 (edited) I'm potentially adding skill checks with a random chance of failure that depends on the two obvious variables: 1) Player's actor value for given skill 2) Required skill to meet check. Is there a built in function for this already that simply takes in these variables and spits out a 0 or 1 ? Edited September 25, 2016 by csbx Link to comment Share on other sites More sharing options...
iXenite Posted September 25, 2016 Share Posted September 25, 2016 Maybe this is what you're looking for? My apologies if it is not helpful. Tutorial: Dialogue Speech Checkshttp://www.creationkit.com/index.php?title=Tutorial:_Dialogue_Speech_Checks Link to comment Share on other sites More sharing options...
csbx Posted September 25, 2016 Author Share Posted September 25, 2016 Maybe this is what you're looking for? My apologies if it is not helpful. Tutorial: Dialogue Speech Checkshttp://www.creationkit.com/index.php?title=Tutorial:_Dialogue_Speech_Checks^Yeah, I was just looking at that. It will be helpful, but I was hoping for a more generic function that I could use for any kind of skill check. I'll keep hunting ! Link to comment Share on other sites More sharing options...
iXenite Posted September 25, 2016 Share Posted September 25, 2016 Something more like an IF function would certainly be a lot simpler I suppose, and applicable to a wider range of skills. Oh well, good luck in the search. Hope something turns up that makes it all work out for you. Link to comment Share on other sites More sharing options...
lofgren Posted September 25, 2016 Share Posted September 25, 2016 (edited) There is a function for checking a skill, and then all you have to do to compare it to a given number. bool AlchemySkillCheck = (PlayerREF.GetActorValue("Alchemy") >= 50) as bool ;returns true if alchemy is greater than or equal to 50. Edited September 25, 2016 by lofgren Link to comment Share on other sites More sharing options...
lofgren Posted September 25, 2016 Share Posted September 25, 2016 Obviously you could write such a function pretty easily. bool function SkillCheck(string sSkill, int nDifficulty) global bool returnValue = (game.GetPlayer()).GetActorValue(sSkill) >= nDifficulty) as bool return returnValue endFunction Link to comment Share on other sites More sharing options...
csbx Posted September 25, 2016 Author Share Posted September 25, 2016 (edited) This would be a straight up skill check with no chance of failure, though(when value >= requirement). What I'm looking for is the following: Requirement = 50, Player has 50: 90% of success. Player has 60: 93% of success. Player has 30: 15% of success.It's like a logarithmic curve, but I'm not smart enough to figure out what mathematical function would approximate the model I give plot points for above and how to use the random function in this context. Ie. even if you do / don't meet the check in terms of raw numbers, there is an element of chance that could result in your passing / failing. I think Fallout New Vegas works in this way IIRC. There is a function for checking a skill, and then all you have to do to compare it to a given number. bool AlchemySkillCheck = (PlayerREF.GetActorValue("Alchemy") >= 50) as bool ;returns true if alchemy is greater than or equal to 50. Edited September 25, 2016 by csbx Link to comment Share on other sites More sharing options...
azraelb Posted September 26, 2016 Share Posted September 26, 2016 (edited) This would be a straight up skill check with no chance of failure, though(when value >= requirement). What I'm looking for is the following: Requirement = 50, Player has 50: 90% of success. Player has 60: 93% of success. Player has 30: 15% of success.It's like a logarithmic curve, but I'm not smart enough to figure out what mathematical function would approximate the model I give plot points for above and how to use the random function in this context. Ie. even if you do / don't meet the check in terms of raw numbers, there is an element of chance that could result in your passing / failing. I think Fallout New Vegas works in this way IIRC. Well I don't really get why it has to be logarithmic. Imho this is really hard to make it transparent to the player. However, I thought about it and might have a solution.There probably is some better way to do that as I am no math genius, but at least it should work. Note that this isnt a fully working papyrus script and you'll have to set up the properties and maybe even replace some operators with the right papyrus syntax.Maybe you also want to add some exception handling (like handle divide by zero errors or NULL-checks)... ; Properties ; increase maxPower and/or base to get a steeper curve maxPwrToRaise == 6.0 baseToRaise == 2.0 ; skillCheckMax PlayerREF skillValue == PlayerREF.GetActorValue(skillToCheck) if skillValue < skillCheckMax floatToRaise == maxPwrToRaise * (skillValue / skillCheckMax) ; max value of your curve logMax == pow(baseToRaise, maxPwrToRaise) ; current value of your curve logValue == pow(baseToRaise, floatToRaise) ; calculate chance - value range: 0.01 -> 0.99 chanceToPass == logValue / logMax ;generate random float from 0.0 to 1.0 if Utility.RandomFloat() <= chanceToPass //Check passed else //Check not passed endif else //Check passed endif example (skillCheckMax = 50, baseToRaise = 2, maxPwrToRaise = 6): - with a skill of 46, the player still has 72% chance to pass the check - with a skill of 40, the player still has 44% chance to pass the check - with a skill of 30, the player still has 18% chance to pass the check - with a skill of 15, the player still has 5% chance to pass the check You also should check how good/random the RandomFloat() function really is - no idea about that.I also dont know what GetActorValue() returns if you have made a skill legendary after reaching 100... Edited September 27, 2016 by azraelb Link to comment Share on other sites More sharing options...
csbx Posted September 27, 2016 Author Share Posted September 27, 2016 @azarelb - woah - thanks a lot for looking into this ! Just to clarify--I didn't mean to suggest I was sure it was logarithmic (it's probably more like arctan(x)), just that it wasn't quite linear. The values for the sample case you provide look pretty good to me. I'm going to have a full look at this and get back if I have any issues. Thanks again ! Link to comment Share on other sites More sharing options...
Recommended Posts