Home » MODDING HQ 1.13 » v1.13 Modding, Customising, Editing » v1.13 Time Capsule (How-to Library) » "How does it work?" Part 8: Skill Checks
 "How does it work?" Part 8: Skill Checks Wed, 08 October 2008 15:40
 Headrock Messages:1781 Registered:March 2006 Location: Jerusalem
GENERAL SKILL CHECKS[/b]</font>

While our skills and attributes are used in a ton of different places in the code, some of the most basic actions we perform often require a skill check. Stuff like picking a lock, or planting a bomb, requires us to test our skills and see if we were successful.

This article discusses those Skill Checks and the circumstances in which they occur. Once again, the article will use Pseudo-Code, a rough translation from computer language to plain English (ok, as plain English as I can manage). You do not need to have any background in programming to understand this. A high-school education will be enough

---------------------------------

Skill checks are very simple procedures, and they are all very similar to one another in terms of the calculation. Still, they fall into two main groups:

A) Skills involved in interaction with a locked door
Skills... not involved in interaction with a locked door

But before we actually see which skill checks the game contains, let's explain what a skill check is, and how it's calculated.

The SkillCheck function will test a certain "grouping" of one or more skills, for the purpose of determining whether an action is a success or a failure. We tell the function which ACTION we want to undertake, and it will run the calculations based on a different set of skills for each function. We also tell the function how difficult the action is, based on external parameters, and that will figure into the final result.

When the function is done calculating our required skills (a number called your "BASE_CHANCE" of success), it will roll a random number between 0 and 99, and compare it to the BASE_CHANCE. It subtracts the random number from the BASE_CHANCE value, and returns the result to whatever part of the code called for a skill check. That part of the code later determines whether the result was good enough for us to succeed in the action. Most actions require a result of 0 or more to succeed, while some allow a "partial" success with results that are less than 0. But 0 is seen as the minimum for a "full success" in carrying out the action.

Let's examine the basic structure of the skillcheck function. Later on, when we look at the actions themselves, we'll see get more specific details on how each action works.

<div class="pre][pre]
SKILLCHECK FUNCTION
-------------------

1. Calculate a BASE_CHANCE which is based on a certain set of skills. Each action requires a different combination of skills.
2. Apply a penalty to BASE_CHANCE due to fatigue
3. Apply an "external modifier" to BASE_CHANCE, which we provide depending on the action we're trying to perform.
4. Some types of skill checks are harder, and for them we do this:
If by now BASE_CHANCE is still less than 30, there's no chance to fulfill the action (BASE_CHANCE=0). This makes some actions impossible to perform by amateurs. If this happens, ignore step 5 (morale modifier).
5. Apply a modifier to BASE_CHANCE based on our merc's morale.
6. Make sure BASE_CHANCE is somewhere between 0 and 99.
7. Finally, roll a random number between 0 and 99.
8. Subtract RANDOM_NUMBER from BASE_CHANCE, and return the result
[/code]

Again, several parts of this formula will change based on the circumstances and the spcific action we're doing. The basis should be clear enough though.

---------------------------------

<font size="">DOOR-INTERACTION SKILL CHECKS

I guess the best place to start would be doors and containers. Both are handled in exactly the same way, so for this entire article a "DOOR" is interchangeable with a "CONTAINER" of any sort.

---------------------------------

DETECTING TRAPS ON FIRST ENCOUNTER WITH A DOOR

First off, there's a basic algorithm that decides whether we have any special occurances when approaching the door. If the door is closed, unlocked and untrapped, it will simply be opened. Otherwise, if the door is trapped, the program will determine whether or not we notice that trap. Note, this code runs when our character reaches the door (after being ordered to open it!), but before they actually try to open it. It really only determines whether we should get the "door interaction" menu, or open the door immediately, or notify us of a trap.

If Door is Opened, then
If Door is Trapped and the player hasn't yet spotted (or failed to spot) this trap in the past, then
If Trap_Detection >= Trap_Level, then
If Player failed to find trap (or no trap there), then
Pull up Door-Interaction menu (to close the door)
Else
Close the door automatically.

If Door is Closed, then
If Door is Locked, then
If Door is Trapped and the player hasn't yet spotted (or failed to spot) this trap in the past, then
If Trap_Detection >= Trap_Level, then
If Player failed to find trap (or no trap there), then
If we're in "auto-bandage" mode, then
Attempt to unlock this door automatically.
Else
Else (trap found)
Do nothing.
Else (Door unlocked)
Open the door automatically.

What this basically does is to determine whether the door is locked or trapped. Unlocked doors will be opened automatically, and locked doors will bring up a menu. If a trap is present and the player hasn't yet found (or missed) that trap earlier, the program checks to see if the trap's spotted now - if so, it'll say a quote to warn you, and you have to click the door again to interact with it further. I'm not sure how a door can be trapped if it's already open, but apparently the code knows how to handle this. I'm not sure what exactly happens in Autobandange mode either - what happens if the character fails to unlock the door? What happens if they unlock a trapped door? I have no idea, I don't think either of these things have ever happened to me.

Also note that if the first character who approached the door does NOT notice the trap, then no one else will, until you actually EXAMINE THE DOOR FOR TRAPS (or, trigger the trap accidentally).

----------------------------------------------

NOTICING TRAPPED DOORS

This is the skill check that's triggered when a character attempts to interact with a trapped door or container. The result here is compared against the trap level to determine whether the trap has been detected (see above). The same exact calculation will run when we're actually looking for traps (more about that later).

Please note that this is NOT a regular skill check, it's a special check which is used only for trap detection. That's why it's not similar to the formula of skill checks outlined earlier in this article.

Experience_Bonus = Merc's_Effective_Experience_Level
Explosives_Bonus = Merc's_Effective_Explosives_Skill / 40
Wisdom_Penalty = (100 - Merc's_Effective_Wisdom) / 20

Detection_Level = Experience_Bonus + Explosives_Bonus - Wisdom_Penalty

The detection level is based mainly on the character's effective experience level. It is then increased by 1 point for every 40 levels of the Explosives skill, and finally reduced by 1 point for every 20 points of wisdom below 100.

So, starting with our Experience Level as a base value, Explosives level 40 gives us a +1 bonus; Explosives 80 gives us a +2 bonus; Wisdom 80 gives us -1; Wisdom 20 gives us -4.
Trap detection level can go as high as 12 (10 experience level, plus 2 points for explosive skill of 80 or higher, and no penalty for wisdom 81 or higher).

"Effective" here means that the skill check also takes into account the character's drunkness. I've explained drunkness in previous articles, but to sum it up, if you're really plastered you get 50% less "effective" skill than your actual merc's skill (As displayed on the merc's profile). There are 4 levels of drunkness, from Sober to Drunk, and a fifth level called "Hung-over". Simply put, don't handle explosives while drunk, kids.

Effective_Experience_Level is also affected by other, more esoteric occurances, having to do with the character's personality quirks. For instance, claustrophobic characters will get a -1 Experience Level penalty in underground sectors.

If we're LOOKING FOR TRAPS, then
Maximum_Random_Bonus = (Detection_Level / 3) + 1
Random_Bonus = any number between 0 and Maximum_Random_Bonus
Detection_Level is increased by Random_Bonus


"Looking for traps" means that we've selected the option to look for traps in the door interaction menu (that's the magnifying glass icon). It uses this same calculation, as we'll see later on in this article. Looking for traps may add a certain bonus to our Detection_Level, but doesn't always.

If Merc has more than 20 points of bleeding wounds, or is in shock (from being hit), then
Random_Penalty = any number between 0 and 2
Detection_Level is decreased by Random_Penalty


Characters who are seriously wounded, or still suffering from shock of being hit in combat, may receive a penalty to their trap detection level. Note that injuries here pertain only to UNBANDAGED wounds.

If Detection_Level < 1, then
Detection_Level = 1

Nice. If the trap level is 1 (a lousy trap), then anyone will be able to detect it!

------------------------------

Let's move on to the Door Interaction menu. We've got several options for interaction with doors:

• We can try to open it.
• We can try to close it.
• We can examine for traps
• We can try to disarm traps (whether we know a trap is there or not)
• We can try to pick the lock
• We can try to lock the door
• We can try to use a key
• We can blast the door open with a shaped charge
• We can kick the door open
• We can pry the door open with a crowbar

-----------------------------

EXAMINING A DOOR FOR TRAPS

If Door is Trapped, then
If Detect_Level < Trap_Level, then
Tell player that the door is untrapped.
Else
Tell player that the door is trapped, and what type of trap it is.


Very simple. The "Detect_Level" is calculated the same as explained above, with Experience Level, Explosives Skill and Wisdom playing the most important parts. Note that you may get a small bonus to your detect level because you're specifically searching for traps. For more on this, read the formula two sections up. You'll also notice that if you examine for traps, the game will tell you what type of trap this is. If the sector is clear of enemies, you can go ahead and open any siren-trapped doors.

----------------------------

DISARMING TRAPS

This section deals with disarming traps on DOORS. Disarming mines and planted bombs is handled a bit differently (we'll get to that later).

PLEASE NOTE: Any attempt to disarm a door will automatically detect the trap (if there is one), regardless of whether or not it has actually been detected previously. So if you think you've failed to discover a trap, have your explosives expert try to disarm anyway.

If Trap_Type is EXPLOSIVE, then
Result = DISARM_TRAP_CHECK with a modifier of (7 * Trap_Level)
Else
Result = DISARM_ELECTRONIC_TRAP_CHECK with a modifier of (7 * Trap_Level)

If Result >= 0, then
Remove trap.
Else
Activate trap.
If Trap is set to trigger only once, then
Remove trap.


Please note that there's something wrong here, but I'll explain it in a minute. This is just the basic algorithm, we're going to want to see how the disarm check itself actually goes.

This is a true SKILL CHECK, and uses the SKILL CHECK calculation that was outlined earlier in this article.

DISARM_TRAP AND ELECTRONIC_TRAP SKILL CHECK
-------------------------------------

If DISARM_TRAP_CHECK (a regular, explosive trap), then
Explosives_Bonus = Merc's_Effective_Explosives_Skill * 7
Experience_Bonus = Merc's_Effective_Experience_LeveL * 10

Base_Chance = Explosives_Bonus + Experience_Bonus
Base_Chance is divided by 10

Wisdom_Penalty = (100 - Merc's_Effective_Wisdom) / 5
Base_Chance is reduced by Wisdom_Penalty

If Explosives_Bonus = 0, then
Base_Chance = 0

If DISARM_ELECTRONIC_TRAP_CHECK (Siren and electric traps), then
Skill_Bonus = Merc's_Effective_Mechanical_Skill, OR Merc's_Effective_Explosives_Skill, whichever is higher!
Skill_Bonus multiplied by 7

Dexterity_Bonus = Merc's_Effective_Dexterity * 2
Experience_Bonus = Merc's_Effective_Experience_Level * 10

Base_Chance = Skill_Bonus + Dexterity_Bonus + Experience_Bonus
Base_Chance is divided by 10

Wisdom_Penalty = (100 - Merc's_Effective_Wisdom) / 5
Base_Chance is reduced by Wisdom_Penalty

If Merc doesn't have the ELECTRONICS trait, then
Base_Chance is reduced by 25%

If Skill_Bonus = 0, then
Base_Chance = 0

Base_Chance is reduced by Fatigue Penalty

Base_Chance is increased by the External_Modifier (in both cases, it equals Trap_Level * 7)

Base_Chance is modified by Morale_Modifier

If Base_Chance > 99, then
Base_Chance = 99
If Base_Chance < 0, then
Base_Chance = 0

Random_Number = anywhere between 0 and 99
Result = Base_Chance - Random_Number

It's not a terribly complicated formula, although there's a little surprise there.

Basically, disarming an explosive trap requires good explosives skill, experience level, and Wisdom. Without an explosives skill, your chance will be a big fat 0.
Electronic traps are a bit easier to disarm because you can use either a high explosives skill or a high mechanical skill, and dexterity also helps you. Of course, without the ELECTRONICS trait, you suffer a 25% penalty to your chance. If you have 0 mechanical skill and 0 explosives skill, you will fail an electronic trap check automatically.

As to Fatigue and Morale modifiers, they will be calculated every time we run a skill check, so I'll cover them here. They are similar to the modifiers used when firing weapons (explained in my previous articles).

Fatigue_Penalty is based on your current stamina (the blue bar)

• If Stamina is between 85 and 100, then Fatigue_Penalty = 0
• If Stamina is between 70 and 84, then Fatigue_Penalty = 10
• If Stamina is between 50 and 69, then Fatigue_Penalty = 25
• If Stamina is between 30 and 49, then Fatigue_Penalty = 50
• If Stamina is between 15 and 29, then Fatigue_Penalty = 75
• If Stamina is between 1 and 14, then Fatigue_Penalty = 90 (but you're probably passed out, anyway)
• If Stamina is 0, then Fatigue_Penalty = 100 (you're out cold)

Naturally, the higher your fatigue penalty, the worse.

Let's see how this is calculated against our skill:

Fatigue_Penalty = ((Base_Chance * Fatigue_Penalty) / 100) / 2
Base_Chance is reduced by Fatigue_Penalty

Now let's have a look at morale modifiers:

If Merc's_Morale is greater than 50, then
Morale_Modifier = (Merc's_Morale - 45) / 10
else
Morale_Modifier = ( (Merc's Morale - 50) * 2) / 5

Not difficult maths. The result is that at 55 morale you get a +1 bonus, and another +1 for every 10 points of morale above that. Conversely, as your morale drops, you get -1 penalty for every 2-3 morale points below 50. This is applied DIRECTLY to your Base_Chance for the skill check.

Now remember I was talking about a surprise? It has to do with the External_Modifier we applied much earlier. Let's remind you:

Base_Chance is increased by the External_Modifier (in both cases, it equals Trap_Level * 7)

The modifier is 7 times the Trap's Difficulty Level. The weird thing is, this modifier acts as a BONUS to your skill check! So in fact, the higher the level of the trap, the EASIER it is to disarm! It's completely ridiculous!!! Baaaaaad programming! I need a drink.

---------------------------------

LOCKPICKING

Another fine formula which I'm sure you'll all be interested in. Also far simpler than disarming.

If Lock can't be picked
Automatic failure
If Lock_Type = Keycard or Electronic lock, then
Result = ELECTRONIC_LOCKPICKING_CHECK with an external modifier of (-1) * Lock_Difficulty
Else
Result = LOCKPICKING_CHECK with an external modifier of (-1) * Lock_Difficulty

If Result >= 0, then
Lock is picked!
Open the door automatically.


Now let's have a look at the skill check itself. It's very similar to disarming. No surprises here though, external modifier will be a penalty as it should be.

Mechanical_Bonus = Merc's_Effective_Mechanical_Skill
Wisdom_Bonus = ( Merc's_Effective_Wisdom + 100 ) / 200
Dexterity_Bonus = ( Merc's_Effective_Dexterity + 100 ) / 200
Experience_Bonus = Merc's Effective_Experience_LeveL * 3

Base_Chance = ( Mechanical_Bonus * Wisdom_Bonus * Dexterity_Bonus ) + Experience_Bonus

First off, we see that the Mechanical skill is the most important one here. We use it as a base for the rest of the calculation. Without any mechanical skill, you simply cannot pick locks.

Dexterity and Wisdom serve as multipliers. Simply put, if you have 50 wisdom, you get a 25% reduction to your chance. At 100 wisdom, the chance is untouched. Funny, but at 0 wisdom you get only a 50% reduction to your chance, so you can still pick locks if your merc is a complete idiot. Same goes for Dexterity. Experience level also helps - each level will add 3 points to your chance, up to a maximum of 30 points (EXP level 10).

If Merc has the LOCKPICKING trait, then
Base_Chance is increased by 25 for each level of the LOCKPICKING trait
If Lock is an electronic lock or Keycard lock, then
If Character does not have the ELECTRONICS skill, then
Base_Chance is reduced by 50%!

The lockpicking trait helps to defeat any lock. It will add 25 points to your chance, and if you're an expert at lockpicking you get a cool 50 points. That's really really helpful.
If the lock is electronic, however, you absolutely must have the Electronics trait, otherwise your chance is cut by 50%!

If Merc doesn't have a lockpick, then
Base_Chance = 0
Else
Base_Chance is multiplied by Lockpick's_Condition / 100

Unlike disarming, lockpicking requires a tool - your trusty lockpick or similar item (in 1.13, utility knives can do it too). The condition of the item serves as a direct percentage modifier to your chance, so keep your lockpick in good condition!!

If Mechanical_Bonus = 0, then
Base_Chance = 0.

Just making sure you have some mechanical skill. Otherwise, forget about it.

Calculate Fatigue_Penalty (Explained earlier in this article)
Base_Chance is reduced by Fatigue_Penalty

Fatigue penalty applies here (it's explained in the Disarming section of this article). However, morale does not affect lockpicking.

Base_Chance is reduced by External_Modifier, which is (-1) * Lock Difficulty

The external modifier here is (-1) * Lock Difficulty, which means that the harder the lock, the harder it will be to pick. Lock difficulty can be anywhere between 1 and 100, I think. A lock with 100 difficulty can only be opened by a merc with 100 mechanical, 100 wisdom, 100 dexterity, and experience level 10, which gives you a total Base_Chance of 130. That's because you need a Base_Chance that's at least 30 points higher than the lock's difficulty, if you want to have any sort of chance to pick this lock (read the next line).

If Base_Chance < 30, then
Base_Chance = 0

If your chance by now is less than 30%, you will automatically fail. This is done to prevent amateurs from picking complicated locks by sheer chance.

Calculate Morale Modifier (read about this later)
Base_Chance is modified by Morale_Modifier

if Base_Chance > 99, then
Base_Chance = 99

Random_Number = anywhere between 0 and 99
Result = Base_Chance - Random_Number

Finally, we add a morale modifier, make sure that the chance is within the boundaries, and then roll a random number against it. If the result is 0 or more, the lock will be picked!

------------------------------

BLOWING A DOOR OPEN WITH A SHAPED CHARGE

Way more fun than lockpicking. The algorithm is, again, relatively simple.

If Merc doesn't have a Shaped-Charge, then
Failure. Duh.


Naturally, you're going to need a shaped charge. Some MODs (like UC, if I remember correctly) made any bomb useable as a shaped charge. So it doesn't really matter what item you use, as long as it's flagged as a "SHAPED-CHARGE" in items.xml. Naturally, if the item isn't an explosive, the whole thing will fail miserably, probably with a crash to desktop. But modders are advised to watch out for these things anyway.

Result = PLANTING_BOMB_CHECK. No external modifier.

The skill check is done with no special modifiers.

If Result >= -20, then
Current_Lock_Damage increased by (Explosion_Strength * 2)
If Current_Lock_Damage is greater than Lock's_Damage_Capacity, then
Lock is blown open!
Else
Merc is blown open! Whoops!


The result needs to be anything more than -20, which is makes this easier and safer than regular bomb-planting.

The damage dealt to the lock equals twice the amount of damage this bomb would do to a person (if it can be used as a regular explosive at all... in 1.13 Shaped Charges can only be placed on doors anyway).

A lock can only tolerate so much damage, and if the explosion (plus any previous damage to this lock) has already exceeded the lock's resilience, then the lock is blown open.

If the skill check returned a result of -21 or less, then the explosive goes off prematurely, injuring the merc instead. In this case, it triggers a regular explosion of the item, with regular damage values, and can potentially also hurt other mercs in the vicinity (based on the properties of the explosive item).

Now let's have a look at the skill check itself. Note that this is the same skill check used for planting explosives anywhere else, except we can get a result of down to -20 and still succeed in blowing the lock. Please note that the same skill check will later be used for planting explosives anywhere, not just on doors. We'll get to that later.

Explosives_Bonus = Merc's_Effective_Explosives_Skill * 7
Wisdom_Bonus = Merc's_Effective_Wisdom * 2
Experience_Bonus = Merc's_Effective_Experience_Level * 10

Base_Chance = (Explosives_Bonus + Wisdom_Bonus + Experience_Bonus) / 10


So far so good. Explosives skill is the most important factor (7/10 of the final result), followed by wisdom, and finally experience level (1 point of chance per experience level). But the numbers make it so that most mercs would find it pretty hard to plant a bomb without having a very good chance of blowing themselves up, so novice demolitionists would be blown to bits way too often. To fix this, the program "skews" the values a bit with this complicated calculation:

Base_Chance = (Base_Chance + 100 * (Base_Chance / 25) ) / (Base_Chance / 25 + 1)

Don't ask me how this works, it's too messy for me. But the result is that we get some bonus to our chance. If the Base_Chance was average (around 50), we get a whopping 30 point bonus. The higher base_Chance goes above or below that, the less bonus we get. The lower it goes, the less bonus we get, so at 22 Base_Chance we receive no bonus. At least that's what the comments in the code say. Apparently, some mercs are just too stupid to plant a bomb correctly.

Calculate Fatigue_Penalty
Base_Chance is reduced by Fatigue Penalty

Base_Chance is increased by External_Modifier...

Which is 0 at the moment. Ok, no worries.

Calculate Morale_Modifier
Base_Chance is modified by Morale_Modifier

If Chance > 99, then
Chance = 99
If Chance < 0, then
Chance = 0

Staying within the acceptable boundaries.

Random_Number = anywhere between 0 and 99
Result = Base_Chance - Random_Number

Remember, we need at least -20 here! Sounds pretty damn easy. I doubt anyone could fail planting a shaped-charge, even if they tried to fail. Just kidding, it's still dangerous, so watch out.

--------------------------------

USE THE FORCE, LUKE

Well, you don't actually have to use the force, kicking the door down would also work, in case you don't have enough midi-cholera or whatever. Once again, the procedure is very simple.

Make some noise, regardless of success.
If no lock exists, or door is unlocked, then
Automatically open the door and make it unlockable in the future. No need for further calculations

If Lock cannot be broken, then
Abort this attempt. It's an automatic failure. No need for further calculations.

Result = SMASH_DOOR_CHECK, with an external modifier of (-1) * ( Lock's_Smash_Difficulty - Current_Lock_Damage )

If Result >= 0, then
Success!
If Result is between -10 and -1, then
Current_Lock_Damage is increased by (10 + Result)
If Result is between -40 and -11, then
Failure, but award a tiny bit of experience in the STRENGTH attribute
Else (Result =< -40)
You're just a failure.


Pretty simple, we make all the usual checks, including a skill check with an interesting External_Modifier. The harder the lock, the
more difficult it will be to kick open, although any damage the lock has already sustained will help offset this penalty.

Finally, we see that a positive result will break the lock, but if we get a result of just below 0, we'll still make some lock damage (anywhere between 1 and 10 lock damage, depending on how badly we failed our skill check). Anything below that is a failure, although if we got more than -40 we still get a token chance to increase our strength, as a consolation prize.
Please note that damage to the lock helps, so if you've hit the lock but didn't break open the door (the game will say "LOCK HIT"), the next attempt will be somewhat easier.

Now the skill check:

Base_Chance = Merc's_Effective_Strength

Calculate Fatigue_Penalty
Base_Chance is reduced by Fatigue_Penalty

Base_Chance is reduced by the External_Modifier, which equals (-1) * ( Lock's_Smashing_Difficulty - Current_Lock_Damage )

If Chance < 30, then
Chance = 0

Calculate Morale_Modifier
Base_Chance is modified by Morale_Modifier

If Chance > 99, then
Chance = 0

Random Number = anywhere between 0 and 99
Result = Base_Chance - Random_Number

I wish they were all this simple! Would save me a ton of typing!

In any case, you can see that it's basically Strength that decides our success rate. However, if you fail to reach a Base_Chance of 30 by the end of the formula, you'll get 0 chance, just like with lockpicking. Of course, remember that we can accept down to -10 result here, as that will still damage the lock and make the next kick more likely to succeed.

PLEASE NOTE: A merc's "Effective Strength" is calculated differently from other "Effective" skills. Strength is not altered by drunkness, but it DOES depend on your character's current health. Any bandaged and non-bandaged damage to your character will reduce your effective strength. The maximum which can be reduced is about 50% strength, when you're just barely alive.

--------------------------------------

PRYING A LOCK OPEN (AKA THE "CARRY A BIG STICK" APPROACH)

As you'll see, the Crowbar formula is strikingly similar to kicking in a door. Of course, it wouldn't be the crowbar formula without some big nasty item to help you out.

If no crowbar is found, then
Forget it, you shouldn't even be running this formula!

Make some noise, regardless of success or failure.

If no lock exists, or door is unlocked, then
Automatically open the door and make it unlockable in the future. No need for further calculations

If Lock cannot be broken, then
Abort this attempt. It's an automatic failure. No need for further calculations.

Metal_Fatigue = Merc's_Effective_Strength, OR ( Lock's_Smashing_Difficulty + 30 ), whichever is LOWEST
Random_Number = Anywhere between 1 and Metal_Fatigue.
Do damage to the crowbar, equalling Metal_Fatigue

Result = OPEN_WITH_CROWBAR Skill check, with an external_Modifier of (-1) * ( Lock's_Smashing_Difficulty - Current_Lock_Damage )

If Result >= 0, then
Break the lock.
If Result is between -10 and -1, then
Current_Lock_Damage is increased by (10 + Result)
If Result is between -40 and -11, then
Failure, but award a tiny bit of experience in the STRENGTH attribute
Else (Result =< -40)
You're just a failure.

Almost the same as kicking a door down. You'll notice that some damage will be done to the crowbar before we even check for success. If the merc is weaker, less damage will be done to the crowbar, but then you have less chance of breaking the lock . Also, lock difficulty may affect how much damage is done.

Finally, like with kicking doors, a result between -10 and -1 will still allow us to damage the lock, making it easier to pry in our next attempt.

Skill check:

Base_Chance = Merc's_Effective_Strength + 20
... blah blah blah same thing as kicking down a door, I'm not going to repeat it all over again. The difference should already be obvious.


Apparently, all a crowbar does is add a flat +20 bonus to your base chance. Nothing more, nothing less. The crowbar's condition doesn't even matter. If it's still a piece of metal, however twisted it might be, you can still pry locks with it. Everything else is EXACTLY the same as the Door Kicking skill check.

Again, remember that Effective Strength doesn't rely on drunkness level, but rather on how healthy your character is compared to his maximum health (I.E. any damage and bandaged damage will count against your effective strength).

---------------------------

UNLOCK DOOR

Ok, it looks through your inventory and your keychain, and if it finds the right key it unlocks the door. Seriously, what did you expect, complex formulae? Ok, yeah, I expected something more interesting here, but seriously, that's all it does.

---------------------------

LOCK DOOR

It's... The same.

---------------------------

TAMPERING WITH A DOOR

Part of the door handling formula deals with any attempt to open a door that may trigger a trap inadvertantly. This only happens if:

A) The player isn't examining the door for traps. That can't trigger the trap, it seems.
The player isn't disarming a trap. You can blow the trap if you fail the disarm check, but that's irrelevant here.
C) The player isn't unlocking the door. If you've got a key, the trap doesn't trigger.

So basically, any attempt to open a trapped lock without first disarming it may end up in an explosion. The program will check whether we notice a trap in the last second though. Note that this part of the function runs BEFORE we get a chance to do whatever it was we wanted to do to the door.

If Door is Locked and has a Trap on it, then


We assume that everything beyond this point answers to this condition, obviously.

   Calculate Merc's_Trap_Detection_Level


We did this very early in this article when approaching a door for the first time. See the section at the top of this thread called "NOTICING TRAPPED DOORS".

   If Merc's_Trap_Detection_Level < Trap's_Difficulty, then
KABOOOOOOMMMMMMMM! ... Or, WEEOOOOWEEEOOOOWEEEOOOO well whatever the trap's supposed to do. In other words, set the trap off.
Stop our Merc from executing whatever he was trying to do to the door.
If the trap is supposed to go off only once, then
Disable the trap
Else (succeeded in trap detection)
If we didn't know there was a trap here already (or failed to find one by examining the door...), then
Notify the player that this door is trapped.
Else (You already know the lock is trapped)
KAAAAABOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMM. The game assumes you were trying to set the trap off intentionally.
Stop our Merc from executing whatever he was trying to do to the door.
If the trap is supposed to go off only once, then
Disable the trap


So basically, watch out - if a merc's already spotted a trap on this door earlier, you're not going to get a second warning... Try to lockpick the door or something similar, and the trap WILL trigger. This also happens if the merc who previously checked the door failed to find the trap, and so you got careless and your merc is now getting blown to bits.

--------------------------------------------------------------------------------------------------------

(Continued in next post...)

[Updated on: Mon, 27 April 2015 23:46] by Moderator

 Re: "How does it work?" Part 8: Skill Checks Wed, 08 October 2008 15:42
 Headrock Messages:1781 Registered:March 2006 Location: Jerusalem
SKILL CHECKS NOT RELATED TO DOOR INTERACTION

Several skill checks have nothing to do with doors. The most common check is probably the Gun-Unjamming check, but there are many others that will be shown here. The skill check itself works exactly the same as before.

---------------------------

PLANTING A MINE

The skill check itself is the same as setting a shaped charge on a door to blow the lock. However, the action is different, and the result is very important. Also note that this only works with MINES, I.E. bombs that have an integral detonator and are pressure-activated.

Result = PLATING_BOMB_SKILL_CHECK with no External_Modifier
If Result >= 0, then
Bomb planted successfully
If Result is between -20 and -1, then
Bomb plating failed
If Result < -20, then
Bomb planting failed MISERABLY,
KABOOOOOOOOOOOOOOOOOOOM.


Simple enough. We obviously want a result above 0, but so long as we don't get less than -20 we'll survive.

-----------------------------------------

PLANTING A BOMB

This refers to all explosives which must have a detonator attached to them. The skill checks depend on the type of detonator.

If using a TIMED DETONATOR, then
Result = PLANTING_REMOVE_BOMB_SKILL_CHECK with no External_Modifier
If using a REMOTE DETONATOR, then
Result = PLANTING_BOMB_SKILL_CHECK with no External_Modifier

If Result >= 0, then
Bomb planted successfully
If Result is between -20 and 0, then
Bomb plating failed partially
Random_Number = Anywhere between -1 and 1
New setting (Timer setting, or Remote Detonation Frequency) = Original Setting + Random_Number
If Result < -20, then
Bomb planting failed MISERABLY,
KABOOOOOOOOOOOOOOOOOOOM.


We've already seen how the bomb-planting skill check works (see far above, "BLOWING A LOCK WITH A SHAPED CHARGE"). But before we get to the Remote Detonated Bomb Skill Check, let's explain what happens here at the bottom. If we've failed to set the bomb, but not by much (down to -20), we'll still set the bomb, but with the wrong settings. With a timed explosive, this will change the amount of turns before the bomb explodes by +1, 0, or -1 (could cause it to explode immediately...). If this was a remote bomb, then the frequency of the bomb is changed (less dangerous, but could be very inconvenient).

Right, here's the skill check for remote bombs. It's almost the same as for other bombs, but with a twist.

Explosives_Bonus = Merc's_Effective_Explosives_Skill * 7
Wisdom_Bonus = Merc's_Effective_Wisdom * 2
Experience_Bonus = Merc's_Experience_Level * 10
Base_Chance = ( Explosives_Bonus + Wisdom_Bonus + Experience_Bonus ) / 10

If Merc doesn't have the ELECTRONICS trait, then
Base_Chance is reduced by 25%

(... Rest is the same as the regular bomb planting formula)


So for remote bombs, we're really going to want to have the ELECTRONICS skill, but it's not a must (mainly due to the bomb planting's Skew towards better results... for more on this read "BLOWING A DOOR OPEN WITH A SHAPED CHARGE").

------------------------------------

DISARMING A PLANTED MINE, BOMB, or BOOBYTRAPPED OBJECT

Similar to the check for disarming a door-based trap, but with a difference - it matters WHO placed the bomb here!

If Bomb was placed by the same Merc trying to disarm it, then
Result = DISARM_TRAP Skill Check, with an external modifier of 40
If Bomb was placed by a teammate, then
Result = DISARM_TRAP Skill check, with an external modifier of 20
Else,
Result = DISARM_TRAP Skill check, with an external modifier of 0

If Result >= 0, then
Sucess!
Else,
Boom.


This is fairly simple, and again the skill check itself is explained near the top of this article in the section about disarming trapped doors. However you can see that the external modifier depends on whoever set that bomb. If it's us, then the bomb will be easier to disarm.

--------------------------------

LYING TO THE QUEEN

Honestly, I've never ever done this, so it's mainly based on guesses and what little I care to check in this code. I think this happens when the queen interrogates a captured merc? Kill me, I have no idea.

Result = LIE_TO_QUEEN Skill Check, with no external modifier

If Result >= 0, then
Success!
Else
Failure


And the skill check:

Base_Chance = 50 * ( Merc's_Effective_Wisom + Merc's_Effective_Leadership ) / ( Queen's_Wisdom + Queen's_Leadership )

Calculate Fatigue_Penalty
Base_Chance is reduced by Fatigue Penalty

Calculate Morale_Modifier
Base_Chance is modified by Morale_Modifier

Random_Number = anywhere between 0 and 99
Result = Base_Chance - Random_Number

Please note that this reads the queen's Wisdom and Leadership - I don't know what those values are, you can probably check them in PROEDIT.

Also, please note that Effective_Leadership is calculated differently from other "effective" stats. Quite simply, if your character is "Slightly drunk", he gains a 20% bonus to his leadership. Other drunkness level have no effect whatsoever.

--------------------------------------

UNJAMMING GUNS

One of the most common skill checks in the game. Guns tend to jam, and we've got to unjam them. Here's how the whole thing goes:

Result = UNJAM_GUN Skill Check, with an external_modifier of (Gun's_Reliability + Ammo's_Reliability) * 4

If Result >= 0, then
Success!
Else
Failure


Gun and ammo reliability values affect how likely the gun is to jam with each shot you take (also how likely the gun is to degrade with each shot). And apparently, they also control the difficulty of unjamming the gun. Of course, if either or both reliability values are negative, they can make the skill check harder. A reliable gun however will be much easier to unjam, if it even gets jammed in the first place.

Here's the skill check:

Base_Chance = 30 + (Merc's_Effective_Mechanical_Skill / 2)

Calculate Fatigue_Penalty
Base_Chance is reduced by Fatigue_Penalty

Base_Chance is increased by External_Modifier, which equals (Gun's_Reliability + Ammo's_Reliability) * 4

Calculate Morale_Modifier
Base_Chance is modified by Morale_Modifier

If Base_Chance > 99, then
Base_chance = 99
If Base_Chance < 0, then
Base_chance = 0

Random_Number = anywhere between 0 and 99
Result = Base_Chance - Random_Number


We get a free 30 points to our Base_Chance, even if we've got no mechanical skill. Weird - even with 100% mechanical skill, your base_chance is still unlikely to go up to 99 - you'll need a very reliable weapon and very good morale for that...

Please note that this same formula is used in manual unjamming (I.E. during tactical combat) as well as when repairing guns as a mechanic.

---------------------------------

NOTICING DART-GUN FIRE

Dart guns are the most silent weapons in the game. They don't produce a muzzle flash, they have 0 loudness, and above all that, the target needs to succeed a skill check to notice being shot at by darts. The formula surrounding this check is kind of complex. For instance, I'm not sure if it fires only if the dart MISSED the target, and I don't know if noticing the dart means that the target immediately sees where you are.

Result = NOTICE_DART Skill Check, with no external modifier

If Result >= 0, then
Noticed dart-fire
Else,
Not noticed. Due to the silenced nature of the dart gun, this probably means the target doesn't even realize that someone is shooting at it. I'm not 100% sure about this!!!


And the skill check:

Wisdom Bonus = Target's_Effective_Wisdom / 10
Experience Bonus = Target's_Effective_Experience_Level

Base_Chance = Wisdom_Bonus + Experience_Bonus

Calculate Fatigue_Penalty
Base_Chance is reduced by Fatigue_Penalty

Calculate Morale_Modifier
Base_Chance is modified by Morale_Modifier

If Base_Chance > 99, then
Base_chance = 99
If Base_Chance < 0, then
Base_chance = 0

Random_Number = anywhere between 0 and 99
Result = Base_Chance - Random_Number


Since we use 1/10th of our wisdom, and do not modify our effective experience level, the Base_Chance is amazingly low - it can only reach 20 before fatigue and morale modifiers, and that's only if the target has a whopping 100 wisdom and 10 experience level! That means (at best) a 1 in 5 chance to notice dart-fire!! Most targets will be even less likely to notice it.

--------------------------------

ITEM-ATTACHMENT AND ITEM-MERGE SKILL CHECKS

I've left this bit for last, for a good reason.

When we attach items to one another, or merge items together to create new items, we might have to run a skill check. Due to the great work of our 1.13 XML externalizers, it has become possible for modders to decide WHAT SKILL CHECK TO RUN for each such attachment/merge! The data is drawn directly from XML, and there are many possibilities to choose from. So it's important that we've already gone through most of the skill checks in the game already, previously in this article, because a modder could use any of them as checks for item attachments. Don't worry, I'll explain this promptly.

--------------------------------

ATTACHING ITEMS

The "Attach Item" action happens when we try to attach one item to another item, like we do with gun scopes, with bomb detonators, and many other such combinations. This does NOT refer to merges (I.E. attaching two objects to make a new object). We'll get to merges next.

If an item can be attached to another item, there must be an entry in Attachments.XML that tells the game that these two items can fit together. That entry tells the game that the attachment is possible, and also how many APs it will cost.

Most such attachments require no skill check at all. However, some items are inherently more difficult to attach than other items. If so, they will have an entry in "AttachmentInfo.XML". This entry will tell us what skill check to use, and what External_Modifier to apply.

Let's make this simpler by showing you a small bit from AttachmentInfo.XML:

-
8
223
512
3
0



All XML crap aside, only three lines are interesting to us:

usItem : 223
bAttachmentSkillCheck : 3
bAttachmentSkillCheckMod : 0


The first line tells us what item we're talking about. In this case, it's item #319, which is a regular bomb detonator. We can attach it to a wide variety of bombs, but we'll always run the same skill check for that.
The skill check is of type 3. In the program, type 3 means an "ATTACH_DETONATOR_SKILL_CHECK" (How surprising, hehehehe). Of course, we can edit this XML and change it, say, to type 8, or "SMASH_LOCK_SKILL_CHECK". In that case, the skill check we use to determine whether we managed to attach the detonator would be the same skill check as kicking down a door! We can use ANY of the game's available skill checks, if we wanted to.
Finally, the third line tells us that there's no special modifier. We could, if we wanted to, make some detonators harder to attach than others, by giving a negative modifier here (say, -20).

Here's the list of all possible skill check types. You'll notice that we've seen most of these skill checks earlier in this article. Some, however, are reserved for item attachments/merges, and we'll cover those types soon. But for now, here's a list of all possible skill checks:

	0 = NO_CHECK,
1 = LOCKPICKING_CHECK,
2 = ELECTRONIC_LOCKPICKING_CHECK,
3 = ATTACHING_DETONATOR_CHECK,
4 = ATTACHING_REMOTE_DETONATOR_CHECK,
5 = PLANTING_BOMB_CHECK,
6 = PLANTING_REMOTE_BOMB_CHECK,
7 = OPEN_WITH_CROWBAR,
8 = SMASH_DOOR_CHECK,
9 = DISARM_TRAP_CHECK,
10 = UNJAM_GUN_CHECK,
11 = NOTICE_DART_CHECK,
12 = LIE_TO_QUEEN_CHECK,
13 = ATTACHING_SPECIAL_ITEM_CHECK,
14 = ATTACHING_SPECIAL_ELECTRONIC_ITEM_CHECK,
15 = DISARM_ELECTRONIC_TRAP_CHECK,


"NO_CHECK" is the default, and it's just what it is - No Check. If an attachment item doesn't have its own AttachmentInfo.XML entry, then it's assumed to require no check at all. Actually, some items DO have an attachmentInfo.XML entry, with the skill check type set to 0. I have no idea why they even have entries there at all, but I'm guessing they could simply be removed without causing any problems. The game will simply assume they don't require any check anyway, so it doesn't matter if they have an entry or not. Oh well.

In any case, failure to attach an item can cause damage to both the attachment and the item it was being attached to. Here's how it works:

Result = Whatever skill check we're required to perform for this attachment item, with the External_modifier if any

If Result < 0, then
Item_Damage = 0 - Result
Cause an amount of damage to the Attachment Item, equal to Item_Damage
Cause an amount of damage to the Item we're attaching to, equal to Item_Damage


So the lower we go below 0, the more damage we cause to both items!

What about the skill check itself? Well, we've already seen that it could be any of 15 different skill checks. Most of these checks have already been explained in this article, so I won't repeat them here. But since some are exclusive to item attachments, let's cover them now.

ATTACH_DETONATOR_CHECK and ATTACH_REMOTE_DETONATOR_CHECK

(At the moment, this is used only for the Detonator and Remote Detonator items)

Explosives_Bonus = Merc's_Effective_Explosives_Skill * 3
Dexterity_Bonus = Merc's_Effective_Dexterity

Base_Chance = ( Explosives_Bonus + Dexterity_Bonus ) / 4

If this is an ATTACH_REMOTE_DETONATOR_CHECK, then
If the merc doesn't have the ELECTRONICS trait, then
Base_Chance is reduced by 50%!

If Explosives_Bonus = 0, then
Forget it, you're inept. Automatic failure. Stop here.

Calculate Fatigue_Penalty
Base_Chance is reduced by Fatigue_Penalty

Base_Chance is increased by External_Modifier, if there is one.

Calculate Morale_Modifier
Base_Chance is modified by Morale_Modifier

If Base_Chance > 99, then
Base_chance = 99
If Base_Chance < 0, then
Base_chance = 0

Random_Number = anywhere between 0 and 99
Result = Base_Chance - Random_Number

We require at least SOME explosive skill for either type of detonator attachment. Dexterity helps too, but only accounts for 1/4th of the base_chance. For remote detonators, the base_Chance seriously depends on whether or not we've got the ELECTRONICS skill.

ATTACH_SPECIAL_ITEM_CHECK and ATTACH_SPECIAL_ELECTRONIC_ITEM_CHECK

(This is sort of a general skill check for items that are difficult to attach)

Mechanical_Bonus = Merc's_Effective_Mechanical_Skill
Wisdom_Bonus = (Merc's_Effective_Wisdom + 100) / 200
Dexterity_Bonus = (Merc's_Effective_Dexterity + 100) / 200
Experience_Bonus = Merc's_Effective_Experience_Level * 3

Base_Chance = ( Mechanical_Bonus * Wisdom_Bonus * Dexterity_Bonus ) + Experience_Bonus

If Mechanical_Bonus = 0, then
No way. Automatic Failure. Stop here.

If this is an ATTACH_SPECIAL_ELECTRONIC_ITEM_CHECK, then
If the merc doesn't have the ELECTRONICS trait, then
Base_Chance is reduced by 50%!

Calculate Fatigue_Penalty
Base_Chance is reduced by Fatigue_Penalty

Base_Chance is increased by External_Modifier, if there is one.

If Base_Chance < 30, then
Base_Chance = 0!!

Calculate Morale_Modifier
Base_Chance is modified by Morale_Modifier

If Base_Chance > 99, then
Base_Chance = 99

Random_Number = anywhere between 0 and 99
Result = Base_Chance - Random_Number

Lots of skills go into the calculation, although the Mechanical skill is the most important. If we're running an electronic skill check,
you'd better have the ELECTRONICS trait or you lose 50% of your base_chance!

Also note that if you fail to reach a Base_Chance of 30, after all modifiers have been accounted for, then you have no chance of success.

----------------------------------------------

Before we move on to merges, I decided to give yet another insight that may help shed some light on this.

Here is a list of attachment items that require a special check in the unmodded 1.13 campaign. Every time you try to attach one of these items to something else, you will have to go through the listed skill check! All other attachments that aren't listed here are exempt from skill checks.

• Detonator
• Skill Check: ATTACH_DETONATOR
• External Modifier: none
• Remote Detonator
• Skill Check: ATTACH_REMOTE_DETONATOR
• External Modifier: -10
• Rod & Spring
• Skill Check: ATTACH_SPECIAL_ITEM
• External Modifier: none
• Gun Barrel Extender
• Skill Check: ATTACH_SPECIAL_ITEM
• External Modifier: none
• X-Ray Tube
• Skill Check: ATTACH_SPECIAL_ELECTRONIC_ITEM
• External Modifier: -15
• Copper Wires
• Skill Check: ATTACH_SPECIAL_ELECTRONIC_ITEM
• External Modifier: +20 (easier!)

---------------------------------

ITEM MERGES

Similarly to attachments, some items can be combined together to give some sort of effect. Usually this means that one or both of the items is changed in some way.

Every possible merge between any two items will have an entry in the file "Merges.XML". This entry will tell the game that the merge is possible, but will also tell the game what sort of result we want to get. Do we want to create a new item? Do we want to create TWO new items? Maybe we just want to change one item but keep the other intact? Merging stuff like ammo magazines or Medikits is also an option here. Not all types of merges will require a skill check, though.

The structure of the entry is as such:


54
291
1022
0
6
5



I don't care about the AP costs at the moment, nor do I care about resulting items. The interesting values right now are:

firstItemIndex : 54
secondItemIndex : 296
mergeType : 6


The "first item" is the one we're holding in our cursor (or, the "giver"). In this case, it's a Machete.
The "Second item" is the one we're acting upon (or, the "receiver"). In this case, it's a T-shirt.
A mergeType of 6 is also called a "USE_ITEM" merge, which doesn't require any skill check. It'll change the t-shirt into a rag, but will keep the machete untouched.

As I mentioned, some merge types require no skill check. These are:

• 0 = DESTRUCTION merge.
• Both items are destroyed automatically. I think this happens when you try to apply Compound 18 to a piece of armor that's already coated with Queen's Jelly, or vice versa.
• 1 = COMBINE merge.
• This is when we transfer the contents of one item to the other, like with ammo, medikits, canteens, toolkits, etcetera. The "Giver" item passes as much of its condition to the "receiver" item, until the receiver item is at 100% and/or the Giver item reached 0%. I don't need to tell you this sort of stuff, do I?
• 2 = TREAT_ARMOUR merge.
• Although our mercs make an encouraging sound when we do this, they don't actually have to succeed any skill check. It's always a success. The "receiver" will always change into a new item (in this case, the treated version of the armor...). The "giver" item may or may not disappear (usually does), or change into a new item.
• 4 = EASY merge.
• This type of merge is also an automatic success. Again, our mercs will say a "Cool!" but there's really no skill check involved. Some EASY merges are really silly, like wiping the blood off a Bloody Knife (do you REALLY have to say "COOL!" after you do that?? my god). Others are more complicated but still require absolutely no check, like attaching a rail kit to a G36. Is it that easy? With EASY merges, the "Receiver" item will always change to a new type. The "giver" item may also change, or disappear. Also, both items' statuses will also change, to the average of their original status.
• 6 = USE_ITEM merge.
• This is the same as an EASY merge, except it will never change or destroy the "Giver" item, only the "Receiver". There's also no alteration to the status of either of them.

That leaves us with three types of merges that do require a skill check. Since we've covered all of the different Skill Checks by now, I won't repeat the calculations here anymore. They are all similar to the ATTACHMENT skill checks, so just look at the previous section for those calculations.

EXPLOSIVE Merge (Type 3)

This type of merge is used for combining explosives with unstable matter, like RDX+TNT, to create even stronger explosives.

Result = ATTACH_DETONATOR Skill Check, with an External_Modifier of -30

If Result >= 0, then
Success!
Else
Damage_To_Items = 0 - Result
Damage the "Giver" item by Damage_To_Items
Damage the "Reciver" item by Damage_To_Items


Note that with EXPLOSIVE merges, one or both items could be changed, and just like EASY merges their condition will change to the average of their original conditions.

ELECTRONIC Merge (Type 5)

This merge type is currently used only for combining the Display Unit to the X-Ray Device to create an X-Ray Detector.

Result = ATTACH_SPECIAL_ELECTRONIC_ITEM Skill Check, with an External_Modifier of -30

If Result >= 0, then
Success!
Else
Damage_To_Items = 0 - Result
Damage the "Giver" item by Damage_To_Items
Damage the "Reciver" item by Damage_To_Items


Nice, same thing as an EXPLOSIVE merge, but with a different skill check. Again, both items can change (with the x-ray detector merge, obviously one disappears...), and their final condition will equal the average of their original conditions.

Finally, USE_ITEM_HARD Merge (Type 7)

This type of merge is NOT USED by any of the merges in the unmodded 1.13. But I figure, for any mods out there, there's always the chance of that happening, so here's the algorithm:

Result = ATTACH_ELECTRONIC_ITEM Skill Check, with an External_Modifier of -30

If Result >= 0, then
Success!
Else
Damage_To_Items = 0 - Result
Damage the "Giver" item by Damage_To_Items
Damage the "Reciver" item by Damage_To_Items


What a surprise, once again the same formula with a different Skill Check. However, USE_ITEM_HARD, much like USE_ITEM, can only change the "Receiver" item. The "Giver" item is untouched, as are both items' conditions.

-------------------------------------

Phew, well, I'd hate to leave without some pomp and circumstance, but this has really tired me out. So, I hope you enjoyed this one (no, correction, I hope you understood this one!), and I'll see you again in the next part of "How does it work"!

 Re: "How does it work?" Part 8: Skill Checks Wed, 08 October 2008 16:40
 Panpiper Messages:45 Registered:February 2007 Location: Montreal, Canada
Where do you find the motivation Headrock? I for one appreciate all your hard work. Major cred goes your way.
 Re: "How does it work?" Part 8: Skill Checks Wed, 08 October 2008 16:50
 Marlboro Man Messages:1259 Registered:October 2005 Location: USA
Quote:
Phew, well, I'd hate to leave without some pomp and circumstance, but this has really tired me out. So, I hope you enjoyed this one (no, correction, I hope you understood this one!), and I'll see you again in the next part of "How does it work"!

Of course we do.

Now all you need to do is make demonstration video's or better yet, a "how to" tv program on PBS. :biglaugh:

 Re: "How does it work?" Part 8: Skill Checks Wed, 08 October 2008 16:56
 Headrock Messages:1781 Registered:March 2006 Location: Jerusalem
Quote:
Where do you find the motivation Headrock?

Hmmmm let's see. Too much spare time, too much spare money, too little interest in a social life, too much interest in the subject matter, and finally, the utter satisfaction of achieving something which is completely irrelevant to the universe and yet seems to make people happy

Quote:
Now all you need to do is make demonstration video's or better yet, a "how to" tv program on PBS.

I wish there was a way to demonstrate these things visually. It worked with parts of the Autoresolve article, but most of this stuff... a flow chart might work, but, no.

 Re: "How does it work?" Part 8: Skill Checks Wed, 08 October 2008 17:31
 cdunigan Messages:135 Registered:September 2007 Location: Madison, Wisconsin, USA
Y'know, if you keep documenting the code this way, you may even get this C-phobic programmer to give it a try ....
 Re: "How does it work?" Part 8: Skill Checks Wed, 08 October 2008 19:13
 Headrock Messages:1781 Registered:March 2006 Location: Jerusalem
The more practical parts of the code are usually very simple - all the game mechanics stuff is pretty straightforward - stuff gets read in from external parameters, math goes flying about, result comes out the other side. I didn't know _ANY_ C language when I first looked at the code, but it explains itself, especially for people who have experience with the game itself. That way, reading the code becomes like watching your favourite DVD movie with audio commentary.

 Re: "How does it work?" Part 8: Skill Checks Thu, 09 October 2008 10:30
 FelixDrake Messages:33 Registered:September 2008
Fantastic stuff. I DO have a small piece of additional information.
I went to the middle SAM site. In the building with the alarm, there were people in said room. The doors come pre-locked and pre-trapped. In coming after me, one of the soldiers left one of the doors open. When I went to close it, it alerted me of the trap, but did not let me disarm it, only close the door. When I closed the door, it locked, AND the trap was there.

You said you were not certain how a door could be both trapped and open, that is how. You may be able to produce the same result by using a key to open a trapped door, but I am not certain on this. Point is, enemy soldiers do not actually unlock the doors or concern themselves in any way with traps when they open doors.
This was of particular concern because someone was hiding behind the opened door in question, and closing it (thus locking it and trapping it) if done from the inside would leave me trapped in the room with them.
 Re: "How does it work?" Part 8: Skill Checks Wed, 24 December 2008 07:04
 incognito253 Messages:53 Registered:December 2008 Location: Ohio, USA
I noticed something about the bomb-planting formula in this how-to. When I first read it, I didn't read too far into it but it left a niggling feeling in the back of my head and after I had a good sit on the john, I took another look at it.
Quote:
Base_Chance = (Base_Chance + 100 * (Base_Chance / 25) ) / (Base_Chance / 25 + 1)

Write this algebraically and it'd be f(x)= (x+(100*(x/25))) / ((x/25)+1) where x is the original base_chance and f(x)=resultant base chance.
It's a fimiliar kind of formula with an elegant concept, where a character with a skill level of 50 (proficient but not mastered) will have a chance of success closer to that of someone with a skill of like 90 (masterful) because the gain above 50 would decline, since anyone can make a mistake. Meanwhile the gulf below 50 (proficient) grows becuase non-proficiency with this skill (bombs) tends to lead to costly errors...it's a smart concept, but unless I'm somehow missing something here the formula is not even close to what their comment states (no bonus at a base chance of 22.
I plugged in 22 to this formula, which would be as follows:

f(22)=(22+(100*(22/25)) / ((22/25)+1). So we have 22+(100*.88 / (.88 + 1) or 110/1.88 ~= 58.51, which is a 36.5% increase to the base chance. If you change the numerator section from (x+(100*(x/25))) to (x+100)*(x/25), which I thought might be the case, it decreases the result by approximately 1.5 to about 57 instead of 58.5. Either way, it doesn't seem to work out as intended.

So then I applied 1 for x. and got f(1) = 1+(100*(1/25)) / ((1/25)+1). We derive 1+4 / 1.25 = 5/1.25 = 4, which is a 3% bonus. To make this suscinct:
f(1) = 4% (3% bonus)
f(5) = 20.83333...(15.8% bonus)
f(10)= 35.*** (25% bonus)
f(20)= 55.5555555.....(35.55...%)
f(25)= 62.5% (37.5%)
f(50)= 83.333...%(33.333...%)
f(75)= 93.75% (18.75%)
f(99)= ~99.8% (.8%)

Assessment: the formula is highly elegant, except for one minor flaw: the optimum bonus is gained at approximately 22......not around 50.

Comments? Part of the formula I'm processing wrong or misinterpreting? Another function I'm missing?
 Re: "How does it work?" Part 8: Skill Checks Wed, 24 December 2008 07:32
 Headrock Messages:1781 Registered:March 2006 Location: Jerusalem
Due to the obscurity of the formula (even the code comments are cryptic about its nature), it's quite possible that it doesn't work the way it's supposed to.

In fact, here's the code:

// Ok, this is really damn easy, so skew the values...
// e.g. if calculated skill is 84, skewed up to 96
// 51 to 84
// 22 stays as is
iSkill = (iSkill + 100 * (iSkill / 25) ) / (iSkill / 25 + 1);

Looks like you read it correctly, but I couldn't tell you why it gives the results that you say it does

EDIT: Oh, please note that due to the way C++ works, there are several automatic conversions to integer within that function, of course.

[Updated on: Wed, 24 December 2008 07:34] by Moderator

 Re: "How does it work?" Part 8: Skill Checks Wed, 24 December 2008 08:09
 Kaerar Messages:2067 Registered:January 2003 Location: Australia :D
Hey Buzzsaw why not help out with the SMP as you pick up on mathematical things the rest of us generally ignore

 Re: "How does it work?" Part 8: Skill Checks Thu, 25 December 2008 11:52
 incognito253 Messages:53 Registered:December 2008 Location: Ohio, USA
Quote:
EDIT: Oh, please note that due to the way C++ works, there are several automatic conversions to integer within that function, of course.

Automatic conversions to integer? I don't remember that from my C++ programming classes in high school. Must have missed that while I was busy writing papers for my PSEOP college English class while the C++ teacher wasn't looking. Can you tell me when integral conversions would occur? Would it just round decimals to the nearest integer? I can come up with an accurate idea of whether that system is working as intended or giving an absurdly big bonus to unskilled players.

Quote:
Hey Buzzsaw why not help out with the SMP as you pick up on mathematical things the rest of us generally ignore

Where do I sign up? What does SMP stand for? My C++ skills are antiquated but they -do- exist, and while my skills are antiquated and rudimentary, my understanding of a computer's 'thought pattern' is not, I'm pretty good at understanding code if I've got a source book handy.

As for the maths, I'm good with the maths. I also enjoy the maths. The source code is not just something you dump something on, it's a series of tubes, and if the maths get clogged, the series of .... nevermind. I'm trying to be witty about something that sourced from some severe idiocy.

That's what I get for cruising around on The Internets. It rots your brain, what you find on The Google.

Anyway, I think that with JA2 in general, basic C++, and my absurdly dorky love of MATH, I'd really enjoy helping with any stuff. Even if it's just updating things in various databases that let more skilled coders focus on codey stuff that a layman couldn't handle.

So, where's the enlistment office?
 Re: "How does it work?" Part 8: Skill Checks Thu, 25 December 2008 12:33
 Kaerar Messages:2067 Registered:January 2003 Location: Australia :D
In the SMP forum in the JA2 1.13 section:

Or you could just PM Spaceviking/ChrisL/Marlboro Man/Starwalker/Headrock/Kaiden and ask any of them if you can help and give an overview of what you can do

I just do gfx (not a coder at all! XML is closest I get to coding). So its pretty easy for me to see something I don't like and change it

 Re: "How does it work?" Part 8: Skill Checks Thu, 25 December 2008 15:05
 Headrock Messages:1781 Registered:March 2006 Location: Jerusalem
Quote:
Automatic conversions to integer? I don't remember that from my C++ programming classes in high school. Must have missed that while I was busy writing papers for my PSEOP college English class while the C++ teacher wasn't looking. Can you tell me when integral conversions would occur? Would it just round decimals to the nearest integer? I can come up with an accurate idea of whether that system is working as intended or giving an absurdly big bonus to unskilled players.

It doesn't only round decimals to the nearest integer, it also converts integers into one another, if I remember correctly. I think the conversion always tries to end up with an integer of the type of the variable into which the result of the formula is going, so I would assume that a target float would not cause automatic conversions to integer. But I'm not a coder per-se, so this is just a wild guess.

In any case, bad construction of a formula usually ends up with lopsided results, in cases where you've got division somewhere that's supposed to end up with significant fractions. To avoid this you either find some way to put the division last in the formula, or set up "store as" commands like "(float)" or "(double)" to make sure the value doesn't get truncated.

Example:

Result = (Base_Value / 100) * Percentage_Value // INCORRECT!
Result = (Base_Value * Percentage_Value) / 100 // CORRECT!

In the above example, the mathematics are exactly the same, but the results aren't.

Assuming that Result is an INT variable, and Base_Value<=100, the first syntax will usually return 0. That's because the first part ("Base_Value/100") would be a fractional number between 0 and 1, and thus would be automatically converted to 0.
By putting the division last, as in the second syntax, you make sure that fractions are irrelevant. Of course, that only applies when working with Integers, I don't think the auto conversion would occur when the result is expected to be a float or double.

 Re: "How does it work?" Part 8: Skill Checks Thu, 25 December 2008 15:48
 incognito253 Messages:53 Registered:December 2008 Location: Ohio, USA
Some of this I remember hazily in my head. So since Base_Chance is a variable of INT format, the program may actually force subsets of the formula (i.e., base chance/25) to provide an integer result before it's calculated in with the rest? If that's the case, then the heathen witchcraft I espouse, such as "mathematics" are completely irrelevent here.

If I got a c++ compiler and plugged this formula in as it's written in the code, might that be the best way to figure out how the hell it actually ends up working?

EDIT: Actually, I now remember the first time my C++ instructor had me use an INT and try to divide out a complex number, like 1.3 or something. And here I thought I'd forgotten this stuff.

[Updated on: Thu, 25 December 2008 15:50] by Moderator

 Re: "How does it work?" Part 8: Skill Checks Thu, 25 December 2008 16:59
 Headrock Messages:1781 Registered:March 2006 Location: Jerusalem
In the above example I gave, one of the following will give the correct result, but I'm not sure which:

Result = ((float)Base_Chance / 100.00) * Percentage_Value
Result = (float)(Base_Chance / 100) * Percentage_Value
Result = (float)((float)Base_Chance / 100.00) * Percentage_Value

The last line works for sure, but again I haven't thoroughly tested which one is the most correct formula, so whenever my code absolutely needs floats, I end up using a LOT of (float) conversion commands... So I'd love to find the answer too, but too busy ATM.

 Re: "How does it work?" Part 8: Skill Checks Thu, 25 December 2008 20:26
 BirdFlu Messages:445 Registered:September 2007 Location: Lampukistan
the formula
iSkill = (iSkill + 100 * (iSkill / 25) ) / (iSkill / 25 + 1);

can be transformed into this
 iSkill = (125 * iSkill) / (25 + iSkill);

And this version doesn't have any serious type conversion errors, because (125 * iSkill) is way larger than (25 + iSkill), for iSkill \in {0,100}.

Basically the function is "y = x * f(x)", with f(x) = 125/(25+x) and it looks like this.

So you take the original value X and modify it with a value M that depends on X. For small X that modifying value M is large ( M = 5.0 for X = 0)
and for large X that value M is small ( M = 1.0 for X = 100). So, for X = 100 the modifier leaves X unchanged.
For X = 50 you still have a modifier of around +60 Percent.

 Re: "How does it work?" Part 8: Skill Checks Fri, 26 December 2008 01:53
 Headrock Messages:1781 Registered:March 2006 Location: Jerusalem
In that case, the comments preceding the formula (in the source code) are mistaken, which would also make more sense than a "bell curve" type where median scores get the biggest bonus. I wonder what the original programmer thought when he wrote it, but I don't even know who that would be. I'll be glad to modify my text as necessary to reflect this (and someone should change the comments in the original code), of course I would rather test the formula several times in debug mode and see what comes out - just to be sure.

 Re: "How does it work?" Part 8: Skill Checks Fri, 26 December 2008 02:54
 BirdFlu Messages:445 Registered:September 2007 Location: Lampukistan

 Re: "How does it work?" Part 8: Skill Checks Fri, 26 December 2008 05:01
 incognito253 Messages:53 Registered:December 2008 Location: Ohio, USA
Well the formula may work but the graph indicates 125/(iskill+25), not (125*iskill)/(iskill+25). Anyway, that formula may suffice - at a base chance of 100 it provides a bonus of 0. I'll run the numbers. But I think the skew value formula is supposed to IDEALLY reach its zero modifier around ~25 (I personally don't think people with a less than 25% chance to successfully set an explosive device correctly should be touching explosives, EVER, and it's not a business with a lot of margin for error).

125*100 / (25+100) = 12,500 / 125 = 100.
It increases a base value of 1 to approximately 4.8

The problem with this formula is that it only skews the bonus positively, and quickly provides a substantial (if not huge) bonus to your success at lower base chances.

I'll toy around with some parabolic arcs tomorrow. Til that time, Headrock, all I can tell you is that the comments in the original code may be correct and the formula might work exactly as intended if the derivative equations in that formula are being skewed to integers. Personally, I don't set explosives with low explosive skill because I tend to die; so I'm inclined to believe that, despite the fact that the formula produces a completely different bell curve apex than the one the comments suggest, it's actually likely that it works as intended.

If you get a chance to test that sucker out as is, no adjustments, you might find that it does just fine.
 Re: "How does it work?" Part 8: Skill Checks Fri, 26 December 2008 12:12
 BirdFlu Messages:445 Registered:September 2007 Location: Lampukistan
Ok, I should not talk about the whole formula and plot only a part of it. Here is the full plot.

 Re: "How does it work?" Part 8: Skill Checks Fri, 26 December 2008 12:21
 BirdFlu Messages:445 Registered:September 2007 Location: Lampukistan
And here is the difference between the original and the modified value. This might be curve you have expected in the first place. The maximum of this curve is approximately for x=30 -> y=38.

 Previous Topic: "How does it work?" Part 1: Bullet Impact Next Topic: "How does it work?" Part 5: Melee Combat Chance-to-Hit
Goto Forum:

Current Time: Sat Sep 22 10:42:51 EEST 2018

Total time taken to generate the page: 0.01320 seconds