Realistic Enemy Attacks with Trails

Show off your mod creations or just a work in progress.
Post Reply
l3lessed
Posts: 1440
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Realistic Enemy Attacks with Trails

Post by l3lessed »

As part of modernizing combat, and to make my ambidexterity mod even more engaging, I have begun the basic work on providing enemies with realistic attack arcs that simulate some form of a actual attack moving through the game space.



Traditional daggerfall only does a range check and then a roll dice check to see if an enemy can possibly hit you; if they are close enough, and the roll check succeeds, you take damage. This creates very disengaging combat in my opinion that comes down to merely maxing the right stats and spamming attacks. On the player side, this is remedied with my ambidexterity mod, which provides modern looking animations with actual arc casting through the world space to detect hits.

On the enemy side, there needed to be some remedy to this also, so it makes timing blocking with shields or weapon parries in ambidexterity mode more engaging and rewarding, and move the combat closer to modern standards. In order to do this I create a basic framework to start this process.

Enemy Wall Checks and Arced Raycast Attacks

*Keep in Mind this is just a framework test and example thrown together in about a week or less. I plan to improve it further as I work on it more.

New Enemy Combat Scripts
The first step to this was to build a NPC script manager that adds a new combat script to every npc in the area. This combat script would be used for overriding the old attack formulas and methods, so they don't activate, and adding in the new attack formulas and methods and managing the hit ray casting as the enemy attacks.

Added Arc Casting to Enemies
With old combat methods removed, I then went and added code so that when the enemy attack state is engaged, it will activate code to start a Arc hitray cast, in which the enemy, from the direction and location they are sensing/looking, a number of hitrays will shoot out from them. These basic hitrays would be the basis of running the rest of the combat execution.

Added Enemy Wall/Object Hit Detection
However, how is the enemy going to handle knowing what attack direction to be attacking in, when they need to know if walls or objects are in the way of their attack? This was done by running a preliminary Arc hitray cast that only checks for physical objects. If anything is detected other than an enemy to damage, the raycast system will start over and try a different attack direction. It will repeat this process until it finds a proper way to attack the enemy that won't hit an object or wall.

Added Enemy Attack Arc Cast
Now that the enemy knows where and how to attack their perceived threat, the wall detection code will start an actual attack using the known attack direction that was verified as successful, and will shut down the wall detection checking. At this point, the attack will begin, starting at a point, sweeping through the world space, and ending when it hits something or finishes. Once hit, it will run the normal damage check and code, as I merely replicated the base code for now.

Added Rudimentary Attack Trails
The last issue is how will the player know where the enemy is attacking, seeing as default daggerfall plays only a two or three animation frames to indicate a attack roll check. This is where I messed with both a particle system and a quad with a trail render to try and find a good way to create a nice looking attack trail, like in modern games.

I ended up using a quad with a trail renderer added to it. The trail will attach itself directly to the location of the hitray cast, and then will begin moving with the hitray cast as it completes its arc, drawing a trail behind it that fades away quickly. This trail provides a clear visual indication of the enemy attacking and where they are attacking in the world space.

Future Thoughts and Plans

With the framework in place and basic tests completed, I can down begin improving the code, mechanics, and visuals of this system.

Individual Attack Types Per Enemy
I want to code specific type of attack arcs for the differing types of enemies. As an example, rats should largely only shoot out attacks in a largely straight forward motion from their face to mimic the reliance largely on biting as a way to attack. Same with bats. However, creatures with claws would have more variety of attack directions and types. And Humanoids that wield weapons or fists would have the most variety of attack types at their disposal.

Improve Visual Trait;
Make the Visual trail more pleasing to see, and possibly add mod options to customize its color and look for players.

Add Trail Sprites For Attack Types
I would like to attack sprites to the front of the trail to mimic the weapon being used in the attack. As an example, biting animals like rats and bats would have some form of fangs/mouth sprite that comes out and is the front of the trail. Clawed attacked would have some form of claws. And humanoids with weapons would have their wielded weapon checked and a sprite for that type of weapon would be used.

Any other thoughts or suggestions are welcome.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

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

Re: Realistic Enemy Attacks with Trails

Post by King of Worms »

Its a good idea, making it look good might be quite a challenge tho :geek:

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

Re: Realistic Enemy Attacks with Trails

Post by l3lessed »



Here is my solution so far. I created a basic transparent cutout mesh, dropped a particle emitter behind it with a mesh particle generator that fades out over a set time frame, and then had those attach to/follow the raycast of the attack. What you think as of now? This is first pass at this attempt after messing with the particle system and Mesh system. If I had some nice 3d models in place of these basic mesh and png textures I whipped together, it might look better.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

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

Re: Realistic Enemy Attacks with Trails

Post by King of Worms »

The 1st attack of a bat was a perfection. I think this can be good, just needs a bit of cleaning up, as it got a bit messy later in the video. But as a proof of concept, this is actually surprisingly good!

If the attack were shown only when mobs are attacking player, and not when the mobs are infighting, it would be maybe better and help cleaning it up. I think it might be doable.

Maybe keeping it more simple. Like the 1st attack of the bat, that worked extremely good.
So maybe if the mob attacks a player, and you use that hand attack, just make it play a more simple animation, like the last hit which killed you. Basically a hand attacking a player either from left or right. It doesnt have to be the precise attack arch, as you do it now. It can be just a representation of the attack. Aka less simulation and more focus on how it looks.

The idea is great, It really surprised me, that this is possible and that it actually can produce a results which can be beneficial to the game. Later, when u decide on how to make it, I can improve the graphics of the final assets for you.

Just some ideas and feedback.

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

Re: Realistic Enemy Attacks with Trails

Post by l3lessed »

Thanks for the input. I planned on making claw attacks only sideways type arcs. Biting creatures can only do forward attacks, like seen from the bat.

I'm unsure about removing the affect on mob on mob fighting. When in the midst of multiple mob fight, enemies can accidently hit you, so its important to see the enemy attack arc.

All I need now is to make an affect for each weapon type, scan the enemy for the weapon type they have equipped, and then assign the proper affect, and enemies with weapons will have actual swingable weapons that interact with you and the world.

I cleaned up the trail a little more. I added a shorter time frame, so the trail fades a little faster but shows more trailing affect without as many gaps.

I also fixed the affect getting stuck when the enemy dies in a mid-attack. Also, I cleaned up the trigger code a little, so now it triggers properly and pretty close to the attack animation playing.

I also added a attack selection code, so now it will cycle through each attack once to check wall hits. It won't repeat any of the same ones.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

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

Re: Realistic Enemy Attacks with Trails

Post by King of Worms »

Cool! Im really interested in how this will turn out :)

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

Re: Realistic Enemy Attacks with Trails

Post by l3lessed »

I'm close to a first release for testing. I'll throw up a video and put up the test files on git some time this week.

It's working as intended for now. Can use more passes on the mechanical feel of it and the visuals, but it is working.

All enemies have a attack trail that tries its best to match the weapon shown on their base sprite. As of now, I think only two maybe three enemies default to a basic melee attack trail, as I need to make the assets for their weapons.

As of now, I've completely removed chance based hitting and made all hits do at least 1 damage. It was feeling and looking add having actual weapons swinging around and yet so many of them either missing or causing 0 damage. My personal goal is to create combat system revolving around complete removal of roll based hit chance and 0 damage hits.

Maybe in the future, 0 damage and missed hits can create some form of a visual particle effect (Like large sparks or scales or tuffs of fur) can appear.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

Cassandra-IX
Posts: 6
Joined: Wed May 10, 2023 9:27 am

Re: Realistic Enemy Attacks with Trails

Post by Cassandra-IX »

Maybe in the future, 0 damage and missed hits can create some form of a visual particle effect (Like large sparks or scales or tuffs of fur) can appear.
Already available in Weapon Widget

weapon widget.jpg
weapon widget.jpg (48.09 KiB) Viewed 331 times

Post Reply