Page 1 of 13

Cracking Open Combat

Posted: Mon Aug 12, 2019 5:01 pm
by l3lessed
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.

Re: Cracking Open Combat

Posted: Mon Aug 12, 2019 8:56 pm
by l3lessed
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.

Re: Cracking Open Combat

Posted: Mon Aug 12, 2019 9:37 pm
by l3lessed
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.

Re: Cracking Open Combat

Posted: Mon Aug 12, 2019 10:25 pm
by l3lessed
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.

Re: Cracking Open Combat

Posted: Tue Aug 13, 2019 6:04 pm
by l3lessed
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.

Re: Cracking Open Combat

Posted: Tue Aug 13, 2019 6:18 pm
by Jay_H
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!

Re: Cracking Open Combat

Posted: Tue Aug 13, 2019 6:53 pm
by Ommamar

Re: Cracking Open Combat

Posted: Tue Aug 13, 2019 8:46 pm
by King of Worms
Ill be watching as well :)

Re: Cracking Open Combat

Posted: Tue Aug 13, 2019 10:39 pm
by l3lessed
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.

Re: Cracking Open Combat

Posted: Tue Aug 13, 2019 11:13 pm
by Ommamar