Jump to content

Function for skill checks - built into CK ?


csbx

Recommended Posts

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 by csbx
Link to comment
Share on other sites

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 by lofgren
Link to comment
Share on other sites

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 by csbx
Link to comment
Share on other sites

 

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 by azraelb
Link to comment
Share on other sites

@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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...