Cracking Open Combat

Discuss modding questions and implementation details.
l3lessed
Posts: 33
Joined: Mon Aug 12, 2019 4:32 pm

Cracking Open Combat

Post by l3lessed » Mon Aug 12, 2019 5:01 pm

One of my earliest and best memories with RPG style games goes back to a handful of games. I remember reading walls of text in Gemstone III, typing out endless actions in Quest for Glory, or spending countless hours on Ultimate Online to rule the server with a handful of friends. Daggerfall still made the largest impact for me because it showed me the future potential of the genre, the massive scales and depths possible, and the ability to allow the player to truly make the game theirs (like traditional D&D did). It started my life long addiction to action based RPGs that goes to this day with my modding of Skyrim.

I really want to get into this Daggerfall build and try my hands at modding for it. The first system I personally want to see remade, if possible, is combat. Currently combat is 100% chance based, using a large list of factors to figure out damage and hit percentages. I would like to move to a more modern Skyrim-lite system, but I'm unsure if this could be possible at all with the engine. So, before I invest a ton of time, can some people answer this for me and point me in the right direction.

First, can we modify the based combat system at all? Is there a way to access the hit detection data? I would like to have hits based on if you swing within hit distance of the enemy and nothing else. If there in range, you swing, you hit. Possible including/programming in weapon ranges and speed, as all documentation currently shows only difference between weapons in combat is their damage and material modifiers. Not sure about attack speed being an option though, since I have no documentation on how attack and attack animations work.

Second, can we modify the shield to create an actual blocking mechanism? When player holds the right mouse button, all damage coming at the front of the player is blocked. Let go, player is open to damage again. I don't imagine any real hitbox detection being possible in the older engine?

As an extension of blocking, if it can be put in, weapon parries could be added to, right? Create a timed trigger that blocks all damage coming at the player from the front for set parry duration with a small cooldown window.

Three, turn dodge skill into an actual ability. Currently dodge is a boring passive trait that just ups your chance of being missed by an enemy on a hit register. Could a trigger be coded in to make the player invulnerable for a second or less and move the player a short distance quickly to mimic a real life dodge at the cost of some stamina. The better the ability, the cheaper it costs, lower the CD/recovery time for you, and a small distance increase on space traveled.

Forth, maybe even a parry/collision system? Not even sure if this would be possible, but wanted to ask. Can you pull data from enemy combat states? Can we tell when an enemy swings? If so, would I be able to create a trigger of some sort that detects the enemy combat state when you swing, and if they are in a swing state and so is your enemy on hitting, cause your attack to cancel/parry costing both you and the enemy stamina but damaging no one?

Lastly, if luck is kept as a state for the core game, it could be changed to mitigate or increase critical strike chances. the enemy critical strikes you, luck has a chance to mitigate it into a normal hit. You hit someone, the higher the luck, the higher the chance of a lucky, random critical hit. This way, the player still has high control and risk/reward to combat, but still has a purpose/use for the luck skill in combat.

I love daggerfall, but the combat system takes all the power from the player and gives it over to passive systems and luck, which is horrid design in modern gaming theory and systems.

Now, this doesn't address the issue of being able to easily see when the enemy is attacking, as currently sprites don't clearly show attacking because of the lack of any attack animations or stages for the enemy sprites. However, this could be remedied for testing by some other easy, quick visual trick to indicate attacks and combat states; it could be the sprite blinking real quick when they initiate an attack or something like that.

I don't see any mods or discussions about this area of the engine and modding tools. Any information on how unity and the engine communicate and handle the actual combat system would be greatly appreciated.

https://en.uesp.net/wiki/Daggerfall:Combat
https://en.uesp.net/wiki/Daggerfall:Weapons

l3lessed
Posts: 33
Joined: Mon Aug 12, 2019 4:32 pm

Re: Cracking Open Combat

Post by l3lessed » Mon Aug 12, 2019 8:56 pm

Just got unity setup and cracked about some of the script files.

It looks like Weaponmanager is what the top layer handling the players weapons and attack data, which pulls more core game data from other script/game files.

EnemyAttack is of course the top layer managing how the enemies attack and do combat.

Heres some important data I pulled from Weaponmanager script for possible use in developing a combat modifying tool and mod.

Routine MouseDirections TrackMouseAttack(); (routine for figuring our mouse movement direction and assigning a direction to the output of the routine in the form of MouseDirections.output. Don't need the routine code, but can reuse routine and output vars for assigning movement based attack direction. May save some lines of code and processing repurposing the routine output for movement based attacks, or maybe not.)

bool isClickAttack = false; (Tells engine if user has clickattack mode enabled. Can help me in creating a direction attack mode by seeing how it uses the mouse direction to select the attack type.)

bool isAttacking = false; (Tells the engine the player is in attack state to stop further attack input data. Can use this for a parry system and to limit player movement during combat and swings.)

var attackDirection; (Child variable that is used to assign and store attack direction based on mouse movement; Think can be hijacked for use in movement based system to minimize repeat code and variables and increase efficiency)

bool isDamageFinished = false; (Tells engine when damage is done. Can be used for triggering differing combat events, maybe useful for blocking mechanics in the future).

bool isBowSoundFinished = false; (trigger to keep track of bow and when it is firing. May be useful looking into bow hold for implementing power attacks by replicating hold system melee weapons, shortening the hold period down for a second or less, and apply a slight swing speedup to simulate putting more force into an attack).

Hand lastAttackHand = Hand.None; (I imagine keeps track of current hand being used for attacking. May be useful in blocking mechanics, if they can be implemented. Guess we'll find out).

float cooldownTime = 0.0f; // Wait for weapon cooldown. (Want to repurpose to make cooldowntime vary between weapon types and weights so players have to consider weapon trade offs, like range, speed, and stamina cost).

int swingWeaponFatigueLoss = 11; // According to DF Chronicles and verified in classic (Want to repurpose to make stamina cost vary between weapon types and weights so players have to consider weapon trade offs, like range, speed, and stamina cost).

It seems the basic code and components are in place for some basic experimentation starting with only creating movement based attacks. I need to sit down and sketch out a coding/development flow to ensure an effective development cycle though. I also need to get a handle on how injection would work with these script files, so as to be modder friendly and friendly to future engine updates.

Quick question for anyone who may know, can we read multiple key inputs at the same time? Be easy to try and implement direction based attacks by merely tying it to the strafe key+attack. I'm unsure though, as I just cracked open all the asset stuff a few hours ago.
Last edited by l3lessed on Mon Aug 12, 2019 9:40 pm, edited 1 time in total.

l3lessed
Posts: 33
Joined: Mon Aug 12, 2019 4:32 pm

Re: Cracking Open Combat

Post by l3lessed » Mon Aug 12, 2019 9:37 pm

Okay more progress in tracking down the needed code and data. When I tried to figure out how the attacks were being animated, I was directed towards the FPSWeapon.cs script. Well, it seems like a good find so far.

Within here, we find all the data on how attacks are actually being done on your screen once triggered by the main script.

The good news, it seems like with the simplicity of the animations, speed can easily be changed on the fly, unlike skyrim where you have to decompile the whole animation file, open up its hkx file, manually modify each one, and then recompile and import. This should allow weapons to have assigned speeds based on their weight and other attributes, like two-handed or not (of course this would have to be coded into the mod using available weapons data, and any needed weapon attributes lacking will need to be added).

This is also where work will need to take place if a blocking/parry/recoil system is ever to be implemented, as this actually executes the attack animation using IEnumerator AnimateWeapon() code block. It calculates the screen space and via code, forces the weapon sprite to move across the screen to simulate an attack. Question is, can we stop it mid-operation to simulate a weapon impact on anything? There is a built in error catcher for animations playing when a weapon breaks. Not sure what this will mean for messing with this in the future. Once the animation code begins running, can it not be stopped without breaking something? If so, this would really mess with a block/parry/recoil system.

l3lessed
Posts: 33
Joined: Mon Aug 12, 2019 4:32 pm

Re: Cracking Open Combat

Post by l3lessed » Mon Aug 12, 2019 10:25 pm

Another important component found.

The actual attack formulas to figure out damage based on material types and all other attributes is located under the FormulaHelper file, under the CalculateAttackDamage routine.

This gives me some ideas. I never liked how certain enemies were just completely unkillable, unless you have specific weapons or magic. Just a personal taste, as I do not like feeling completely helpless in any situation in games if I play well enough to my strengths and build. I understand the other side, but for someone like me, it would be nice to make materials buff or reduce damage verses completely nullify it. Anyways, a possible future option for individuals like me.

l3lessed
Posts: 33
Joined: Mon Aug 12, 2019 4:32 pm

Re: Cracking Open Combat

Post by l3lessed » Tue Aug 13, 2019 6:04 pm

Alpha .1 has just been built.

As of now, the only feature working is a simple menu option to enable two differing combat modes. Neither are even setup yet, just the UI enabled Booleans for triggering it once coded in. Now that the UI is setup, I plan on starting on the simple changes that require very little reprogramming of the current system. This will mostly be adding weapon ranges and speed differences to reward smarter combat and load out choices. No more will a small dagger have the same reach and speed of a massive two hander, if my understanding of animation system is correct and I don't break it.

However, I have found the weapon data. It is, of course, stored under resources and the file Item Templates.

My next goal is to add range stats to every single item and have the combat code pull it from the item template file. This way, weapon choice will matter more for you and the enemy your fighting.

After that, I will then add variable speeds based on weight and one handed vs two handed. Current thought is sword will tend to be fastest being lightest weight when compared to their blunt and axe counterparts, then axes as they are in the middle on weight, and lastly blunt objects that rely on nothing but their weight for damage are slowest. If weights are set properly for one handed vs two handed weapons, then that alone should deal with the speed difference between the two styles of weapons without having to create some coding gimmick or trick. THe simpler the code, the better.

User avatar
Jay_H
Posts: 2487
Joined: Tue Aug 25, 2015 1:54 am

Re: Cracking Open Combat

Post by Jay_H » Tue Aug 13, 2019 6:18 pm

I know it looks like you've only been talking to yourself, but I've been very hopeful for a combat overhaul mod since I joined! I originally envisioned a "block" button but now you're adding a "dodge" button as well. I'll be watching!
Come join the Unofficial Daggerfall Unity Discord.
Try the first Daggerfall Unity Quest Pack with many all-new quests.
Progress on fixing classic quests here.

Ommamar
Posts: 266
Joined: Thu Jul 18, 2019 3:08 am

Re: Cracking Open Combat

Post by Ommamar » Tue Aug 13, 2019 6:53 pm

I can see a block being implemented in a first person perspective but not sure how well a dodge is going to work as you need spatial awareness between you and your opponent. Even if you implement a button to try and trigger a dodge I think it would still have to use the current system to decide success. So while it might appear you are doing something it would still be based of a roll using the skills already in place.

There is an old game called Wizardry VII that had a hide button you could click during combat, while you could actively select it the success was all based on skill rolls and modifiers depending on how good of a build you had. I am not saying it was a bad system and it did add some active participation as you had to click the button to initiate everything. I am just not sure you can pull of graphically what I perceive you want the dodge to look like.

I would love to be surprised though, I wish you luck. I too am watching to see how you can develop things.

User avatar
King of Worms
Posts: 2025
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

Re: Cracking Open Combat

Post by King of Worms » Tue Aug 13, 2019 8:46 pm

Ill be watching as well :)

l3lessed
Posts: 33
Joined: Mon Aug 12, 2019 4:32 pm

Re: Cracking Open Combat

Post by l3lessed » Tue Aug 13, 2019 10:39 pm

Thanks for the replies. It gives some extra energy to the work.

I made further progress. I have officially coded in and compiled range float variable into the engine. However, I will have to test it next day or two to see if it is being injected into the code properly when running the game. However, the engine is reading it in the template and processing it into the memory, so it should function like all the other template stats. Right now, all items range was batch created and set to 0 for ease. Now I just need to modify the core code slightly so it injects the range number from the templates into the combat code/engine properly. Long term, I need to see if this variable can be stored once when an weapon is equipped, so it doesn't draw unneeded cpu grabbing the number from memory every swing.

I also decided to use the same calculation method weight stats use. The weight stat is setup in a special way to allow for easier access and overriding because of how many differing things can affect weight or not. Point being, my thought is this should allow more complicated combat mechanics in the future if wanted. If not, I can go back and remove the extra coding. Thoughts though are momentum bonuses. So running and doing a full swing could possibly increase range slightly to mimic the extra reach a full, prepped melee swing tends to provide versus an unprepared attack.

As for dodge, I think you're thinking about it in overly complicated ways. Nothing has to be chance/skill based. That is designed into the engine, just like hitting enemies successfully. It could easily be turned into an unlockable ability or a default ability that can scale to a degree with another skill. The hard part, I imagine, will be stopping players from clipping through the world or objects and causing bugs and stuck players. However, dodging will come last.

Right now, working on only core combat features. The two main features needed now, in my opinion, is weapon range and speed variables so we have to think a little more about our builds and how we fight enemies.

As for arrows,, I'll figure this out after melee is done. My main concern is archery will become super OP if it is aim based only, like melee. Quick thoughts on how to address this, blocking enabled with shields for player and enemies would help this a ton. However, could also use armor ratings to mitigate arrows further, if they are op. As, in real life, a fully decked out armored fighter, if he had the proper layers and a layer of plate, could take and deflect multiple arrows. Archers had to hit fighters who couldn't afford good armor or hope to land one in a open/weak spot.

I also want to work on the bow and arrow a little more to try and give it more realistic feel and look. Meaning, thinner arrows that travel faster. Finally, actual arrow drop would be cool to have one day, so the set distance of 50ft could be dynamic and reward actual aiming skills. Right now, all combat feels like a lottery system at times, which a responsive system never should.

Ommamar
Posts: 266
Joined: Thu Jul 18, 2019 3:08 am

Re: Cracking Open Combat

Post by Ommamar » Tue Aug 13, 2019 11:13 pm

So you would set dodge to a Boolean state, either you do or you don't? At what point would you be able to use dodge? I like how you have to raise a skill by use, this would seem to powerful to be able to use dodge right away. You can of course get around it by using a range of skill numbers to decide the success of the dodge but that is not the feel I get that you want. I know you said it would be last so you might not have fully thought it out, you are also right I could making it more complicated then it needs to be.

I would actually deal with arrows last as they might be tweaked in future builds here is a thread about it: viewtopic.php?f=4&t=2492

So by that thread arrows are aimed in that a full on frontal or full on back shot has a better chance to do damage. The problem I have seen sometimes particularly if shooting from height or at something on a platform is they start doing this funky switch back and forth between front/back when the AI realizes it can't path to you. So this causes a lot of the 3/4 angle shots that don't seem to do damage although I think you would actually need a environment where you could step through frame by frame as I find it very hard to tell what was considered a hit and what was considered a miss.

There where of course arrows designed to punch through armor developed which you could use the different material types to simulate, in general of course the standard hunting arrows where easily defeated by plate armor. The thing with using that system is an arrows material is tied to a bow so a Dwarven bow automatically shoots Dwarven arrows so might consider an adjustment to put material on arrows instead of bows.

Here is a discussion thread about the armor mechanic: viewtopic.php?f=4&t=2478, if armor rating does have to do with if you are hit instead of if the damage is negated then might be hard to implement a mitigation system. So far after digging through the code I could find references but not the actual code showing how armor was utilized, maybe you will have more luck then I did. I am not the best with Unity so still learning how to fully utilize it, you seem to be good with it so maybe you can find the answer to that question.

Any way keep up the effort! I think Daggerfall has a lot of potential to improve on the current combat system.

Post Reply