Acquiring the Enemy Target Causing Damage

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

Acquiring the Enemy Target Causing Damage

Post by l3lessed »

So, I'm trying to get the enemy entity that last caused damage to the player assigned to an enemy entity object for manipulation.

I can't find an easy way to retrieve this. Is there one? Can I rework the formula helper some way to pump this out?

If not, this should be added the playerEntity script as a public get object, so it continually updates the object to the last hit enemy. This will be critical for future combat mods. If there isn't one, can I add it to the main branch?

This is the next step to getting the shield to actually block damage and do other effects.
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
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Acquiring the Enemy Target Causing Damage

Post by Ralzar »

Can’t you do this via a formulahelper override? Just have the damage formula pass the attacking entiry onto another value or method?

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

Re: Acquiring the Enemy Target Causing Damage

Post by l3lessed »

I was thinking that. So assign the enetitybehavior object to the formula helper and it will pick up the enemy entity the formula helper is applying too?
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.

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

Re: Acquiring the Enemy Target Causing Damage

Post by l3lessed »

Sorry, but I'm not seeing how to pull that from formula helper. I'm trying get component, but the object is being passed through the calculateattackdamage return sub-routine. I can't access the calculate damage routine to pull the assigned target value. I know I'm just being dumb with object language again. It would seem crazy I couldn't setup the formulahelper.calculateattackdamage as an object, and then get the target component from it. Any direction coding wise would be thanked.

The large issue is that target object is not part of the formulahelper main class. It is embedded in the calculatedamage sub-routine, and I do not know how to setup the code to pull it from the sub-routine if its possible.

I'm going to take a short break from this, as I feel like I'm running in circles. I have no issue accessing the main class formula helper. I just can't find any information on pulling the calculateattackdamage subclass embedded target var. Come back when I feel charged for coding again or find some helpful information on this area.
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.

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

Re: Acquiring the Enemy Target Causing Damage

Post by l3lessed »

Maybe I'm a nub at object coding, but I can't see a way to do this. The formula helper is a static, so I can't declare it as an object to manipulate, and as a result, I don't think you can grab the target from the CalculateAttackDamage sub routine.

All I can do is declare the object and subroutine by itself like so, "FormulaHelper.CalculateAttackDamage()."

What am I missing, or can you not grab a var from a return sub-routine when it is ran through a static class?

One last thing I can try, I'll try overrideing the formula, and changing the target to an out var and then tie that to my class var.
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
Magicono43
Posts: 1141
Joined: Tue Nov 06, 2018 7:06 am

Re: Acquiring the Enemy Target Causing Damage

Post by Magicono43 »

Maybe my overhaul mod code can give you an idea?

https://github.com/magicono43/DFU-Mod_P ... r-Overhaul

I could be misunderstanding, but something like "EnemyEntity AIAttacker = attacker as EnemyEntity;" and an if-statement checking if the player is a target, then returning the EnemyEntity could suffice?

I figure this has to be what you could need, since I was normally able to get all the attributes if I needed about an attacking/targeted entity such as the enemy, only thing I needed to specify was when to do said check.

Edit: Be warned, this was my first real mod and it's really messy.

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

Re: Acquiring the Enemy Target Causing Damage

Post by l3lessed »

Yep, that makes perfect sense. Thanks. Like I thought, just not setting up the right objects and object code. Seemed like I was over complicating it.
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.

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

Re: Acquiring the Enemy Target Causing Damage

Post by l3lessed »

Looking at your script, you rebuilt the whole CalculateAttackDamage and used an override for it. And that is how you pull the enemy entity target value.

The target value is acquired in the enemyattack script, passed through the formula helper, which is overridden by your script, and then you are retrieving it in that overridden pass through.

if I have to, I can.

Is there anyway of doing it, without rebuilding the whole calculateattackdamage to get the target value?
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
Magicono43
Posts: 1141
Joined: Tue Nov 06, 2018 7:06 am

Re: Acquiring the Enemy Target Causing Damage

Post by Magicono43 »

l3lessed wrote: Fri May 22, 2020 1:21 am Looking at your script, you rebuilt the whole CalculateAttackDamage and used an override for it. And that is how you pull the enemy entity target value.

The target value is acquired in the enemyattack script, passed through the formula helper, which is overridden by your script, and then you are retrieving it in that overridden pass through.

if I have to, I can.

Is there anyway of doing it, without rebuilding the whole calculateattackdamage to get the target value?
I'm sure there is a way to do it, I really was just using all the objects and such that were provided already by the FormulaHelper methods and such. If those attack calculation methods got the enemy entity as a parameter, then there must be some way of calling that outside of those methods.

There is a script, "EnemyAttack.cs" which gives most of the stuff that happens when enemies attack and how their attacks are detected as hits or misses and such, that one may also help you find what you are looking for, hopefully that helps. Like I said, my mod really has no logical "planning" besides what was done at the moment to try and get the results I wanted, so it's not a great example.

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

Re: Acquiring the Enemy Target Causing Damage

Post by l3lessed »

Yeah, dug around enemy attack. That is part of the enemyentity class, which is a class of daggerfallentity. This is part of my issue. Each enemy is its own assigned object in an enemy serialized table. Each one has its own script objects attached. The way it figures out, which to apply it to, is through the hit transforms in the attack scripts. That passes through the formula helpers.

What I need, from a logic perspective, is a way to intercept enemy damage before it is applied, and assign that value to a variable.

Right now, I'm about to give up, steal your setup, and then just do what I need to the rebuilt formula helper.

I'll keep at it on and off.
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.

Post Reply