[REL] Attack Failure Chance

Post » Sat May 28, 2011 1:43 pm

Woot woot! I made a new mod! And it features a Morrowind-style Chance of Failure Attacking System!
And I've been counting -- this is the tenth "Morrowind-style" mod I've released! :celebration:

http://tesnexus.com/downloads/file.php?id=31120

This is the first version that works flawlessly and just like it's supposed to. Even though I didn't experience any effect on FPS, I'll try to optimize the script for the next version, but maybe that's not possible. At least for me, this script was annoying enough as it is.

Readme:

Attack Failure Chance v2.0
=============================

by Fearabbit

requires OBSE 0017 or higher.



Installation:

Extract archive to Oblivion/Data folder and active the plugin.



Description:

This mod introduces a Morrowind-style Chance-to-hit calculation when you attack someone to Oblivion. It is based on the assumption that you don't always deal the same amount of damage when you hit someone repeatedly; if you are not skilled with your weapon, you might fully hit your opponent maybe one out of ten times, the other times you might not put enough strength into the blow, or you hit an area where he's better protected, or something like that. Hence, we need a system to represent these inaccuracies of yours!
This is what this mod does by calculating whether your attack fails, or succeeds.

Now, Morrowind's Chance-to-hit calculation had one severe flaw: If you failed in hitting your opponent with all your force, then you *didn't* hit him at all. Your sword would go right through his body, which was pretty ridiculous and is to this day the number one flaw any Morrowind player will mention about the game.
This doesn't happen in this mod. Even when the calculation says that you failed to hit your opponent with all your force, you will still hurt him a little bit. The Chance-to-hit calculation also takes this into account, which means that if you, say, wrote down how much damage your last 100 attacks made, and then created an average, this average will be exactly like the damage you do in Oblivion with one hit.
(Well, apart from the fact that your Agility and your Luck have a bit of an influence in the calculation - see below.)



Inner workings:

Your Chance to hit your opponent is calculated for every strike you make. The formula is:

ChanceToHit = WeaponSkill + ( Agility - 50 ) * 0,25 + ( Luck - 50 ) * 0,125

The mod takes a random number between 0 and 100 and compares it to that value. If it is lower, you succeed, if it is higher, you fail.
If you succeed, your Weapon skill (HandToHand, Blade, Blunt or Marksman) is increased to 100. If you fail, it is decreased to 0. That means that your damage will be calculated as if you had either a skill of 100, or a skill of 0. The remaining three skills will be increased or decreased by the same value for the sake of simplicity in the script; it won't have any side-effects.

The calculation only applies if you are NOT sneak attacking - if you are sneaking and undetected, your damage will be the same as in vanilla Oblivion. There are two reasons for this: First, if you're undetected it's more likely that you take your time to look where to hit your opponent hardest. It wouldn't make much sense to fail in such a situation. Second, the successful sneak attack is already represented by the sneak attack multiplier.

The skills will revert to their normal value if you don't keep attacking.

Every time a random number is calculated, the script will print a message to the console that tells you what your chance to hit was, and the value of the random number. That way you can check if a strike was successful or not. However, the script does not make the calculation only once for each strike - it will make a calculation every .3 seconds that you hold your attack button. The last message will usually show the final calculation.
You can also simply check if your skills are increased or decreased.

If your skill is bigger than 100, the calculation will not be done. This is because you'll succeed anyway, and because the script would always decrease your skill to 100 before every strike, which doesn't make a lot of sense.
Also, this way it's compatible with Elys Uncapper.



Credits:

Thanks to all those people who helped me getting the last flaws out of my script, especially Low Post, TheNiceOne and showler.
Thanks to the authors of all those excellent entries in the CS Wiki.
Thanks to the OBSE team.
Without all of you, I wouldn't have been able to finish this.


Changelog:
v2.0 - Instead of simply raising/lowering the skills by 100, the script now calculates the difference to 100 or 0 and modifies them by that value. This means the mod should now be fully compatible with mods like Elys Uncapper. Additionally, the script has been improved greatly in other aspects as well.

User avatar
Bee Baby
 
Posts: 3450
Joined: Sun Jun 18, 2006 4:47 am

Post » Sat May 28, 2011 10:48 am

Now all we need is Cliff Racers.
User avatar
Guinevere Wood
 
Posts: 3368
Joined: Mon Dec 04, 2006 3:06 pm

Post » Sat May 28, 2011 9:32 am

Will it work for the NPCs too? Or just for the player?
User avatar
renee Duhamel
 
Posts: 3371
Joined: Thu Dec 14, 2006 9:12 am

Post » Sat May 28, 2011 11:29 am

It works only for the player.

By the way, I don't know how compatible this is with other combat mods. If they calculate their features from your base skill level, it will be fine; however if they use the modified skill level (i.e. the one influenced by Fortify Skill and other such spells), there will be problems.
For example, if Deadly Reflex has a special move you get with a modified skill level of 100, then you'll always get this special move if your attack succeeds. But since these are kind of like perks, they should usually be calculated from the base skill level... I hope.
User avatar
Jeffrey Lawson
 
Posts: 3485
Joined: Tue Oct 16, 2007 5:36 pm

Post » Sat May 28, 2011 9:54 am

Small bump.

In case you didn't notice, the new version is up, which has a much better script and is compatible with mods like Elys Uncapper that make skill values higher than 100 useful.
User avatar
Floor Punch
 
Posts: 3568
Joined: Tue May 29, 2007 7:18 am

Post » Sat May 28, 2011 6:20 am

Woah... this looks really neat. Well done :)
User avatar
Phoenix Draven
 
Posts: 3443
Joined: Thu Jun 29, 2006 3:50 am

Post » Sat May 28, 2011 10:40 am

This looks great, I was hoping for something to make agility more useful. It was disappointing how little perks us graceful warriors get....wow we can balance :o. Accuracy is a perfect addition :).

The only thing I don't understand is why weapon skill increases to 100 on a success. Wouldn't it be more balanced to use your original weapon skill on a success, showing that you struck to your full ability? Then on a failure it could be set to zero, or some fraction of your weapon skill.
User avatar
Scotties Hottie
 
Posts: 3406
Joined: Thu Jun 08, 2006 1:40 am

Post » Sat May 28, 2011 7:48 am

...
The only thing I don't understand is why weapon skill increases to 100 on a success. Wouldn't it be more balanced to use your original weapon skill on a success, showing that you struck to your full ability? Then on a failure it could be set to zero, or some fraction of your weapon skill.


Weapon skill is increased to 100 on a success to balance out the 0 on a failure. It keeps the average damage output roughly the same as in vanilla. The mod doesn't change the end result* so much as how the end result is arrived at. That said, I am a fan of this idea, because I like the feeling that I can do more damage on a strike as my skill gets higher. I don't really have a proper solution, but maybe someone else does. If Fearrabit likes it enough, maybe he'll implement it :)

[EDIT] *end result being defined as average damage dealt per strike, not damage on a specific strike.
User avatar
Kieren Thomson
 
Posts: 3454
Joined: Sat Jul 21, 2007 3:28 am

Post » Sat May 28, 2011 7:39 am

Weapon skill is increased to 100 on a success to balance out the 0 on a failure. It keeps the average damage output roughly the same as in vanilla. The mod doesn't change the end result* so much as how the end result is arrived at. That said, I am a fan of this idea, because I like the feeling that I can do more damage on a strike as my skill gets higher. I don't really have a proper solution, but maybe someone else does. If Fearrabit likes it enough, maybe he'll implement it :)

[EDIT] *end result being defined as average damage dealt per strike, not damage on a specific strike.


Ahh, I see what you mean. To keep the average damage output similar you have to balance the extreme of 0 with the extreme of 100. But there is another way to preserve the average without making your weapon skill inconsequential to damage.

Fearrabit could make it so that a success could increase your weapon skill by up to 50%, depending on how well you succeeded. On the other hand a failure could conversely decrease your weapon skill by as much as 50%, depending on how badly you failed. This creates an average centered around your actual weapon skill instead of an average centered around a weapon skill of 50. When your weapon skill and agility reach high values, you will eventually hit strongly more than you miss, making you a deadly accurate fighter. Sort of a critical vs miss system.

{Edit}: But honestly, I wouldn't mind making the gameplay more difficult with my first suggestion, as long as the miss system could be applied to NPCs somehow.
User avatar
~Amy~
 
Posts: 3478
Joined: Sat Aug 12, 2006 5:38 am

Post » Sat May 28, 2011 11:45 am

It works only for the player.

By the way, I don't know how compatible this is with other combat mods. If they calculate their features from your base skill level, it will be fine; however if they use the modified skill level (i.e. the one influenced by Fortify Skill and other such spells), there will be problems.
For example, if Deadly Reflex has a special move you get with a modified skill level of 100, then you'll always get this special move if your attack succeeds. But since these are kind of like perks, they should usually be calculated from the base skill level... I hope.


This does actually conflict with every weaponskill-related chance calculation - naturally I do use the actual skill in such calculations, so that for example NPC′s dodge chance takes all modifiers into account. Usually using the actual skill means BETTER compatibility - or actually better interoperability. :)

DR reads the skills into variables as soon as the attack is detected. In more detail:


1. Melee attacks: as soon as player is attacking and attack key is not pressed, or player is powerattacking. So the max delay before the skill is stored is around the value of "fpowerattackdelay" gamesetting.

2. Marksman: as soon as player is attacking and attack key is not pressed. This defines the moment when the arrow shoots out (isattacking == 1 already when player aims)



So if you WANT to, you could just wait a bit before you apply the changes. For example, with melee, see if the player is attacking, wait for fpowerattackdelay seconds, skip a frame to play it safe, see if the player is powerattacking, if so, you could wait, say, 0.1s more just incase, cause you have time.

If the player is not powerattacking, it means DR most likely already stored the skill value and you can proceed.

With ranged, you could wait for the "player.isattacking && iscontrolpressed 4 == 0" moment, skip two frames or so to give DR time to forward the processing to another script (that calls the chance function which stores the skill value) and then proceed.


But this is just info, I′m not saying what you should or should not do, not everything has to be compatible. Though I like the idea of the mod myself, and would probably like to use it. :)
User avatar
Blaine
 
Posts: 3456
Joined: Wed May 16, 2007 4:24 pm

Post » Sat May 28, 2011 1:21 pm

I haven't done scripting in a (very long) while so I guess it's probably not possible but why didn't you just modify the damage done (IE a perfect hit is normal damage for your skill, and misses subtract damage) instead of bouncing player skill around? Average damage will be the same yes, but it still makes damage spiky and this can cause balance issues (and mod issues like you said).

Either way sounds interesting, I'll be trying it out.
User avatar
JLG
 
Posts: 3364
Joined: Fri Oct 19, 2007 7:42 pm

Post » Sat May 28, 2011 5:11 am

I haven't done scripting in a (very long) while so I guess it's probably not possible but why didn't you just modify the damage done (IE a perfect hit is normal damage for your skill, and misses subtract damage) instead of bouncing player skill around? Average damage will be the same yes, but it still makes damage spiky and this can cause balance issues (and mod issues like you said).

Either way sounds interesting, I'll be trying it out.


The problem is that if you look at the damage formula, the damage is calculated by skill, weapon, strength and game settings.

Now since HtH doesn′t have a weapon included, and gamesettings would also affect damage done to YOU globally during the effect, the only individual, common-to-all-attacks modifier is the respective attack skill.
User avatar
Kortknee Bell
 
Posts: 3345
Joined: Tue Jan 30, 2007 5:05 pm


Return to IV - Oblivion