Ranged Enemies Throw Their Weapons At You
- Magicono43
- Posts: 1141
- Joined: Tue Nov 06, 2018 7:06 am
Ranged Enemies Throw Their Weapons At You
Just an interesting thing I found while testing some things with the combat formulas. Since enemies that are carrying weapons will automatically use the most damaging weapon in their inventory, if said weapon exceeds the damage that their base unarmed attacks would normally do.
This also means that whatever weapon is best in their inventory, is the weapon that will be used by them for ALL attacks, funny enough this includes ranged attacks such that warrior humanoids enemies use, like the archer and warrior. So the damage roll that those arrows flying at you are doing is determined by whatever weapon in the inventory has the highest attack. So that archer is likely throwing elven flails at you, or the warrior is actually throwing dwarven katanas at you.
Just thought someone might find that interesting/funny. Also of actual useful note, said weapon being used also effects their chances of landing hits, meaning the weapon they are using also benefits from whatever material hit modifier it has. So that thief using an iron long-sword has a -1 modifier to hit you, while that orcish mace wielding knight has a +5 modifier to hit you, in both melee AND ranged combat.
This also means that whatever weapon is best in their inventory, is the weapon that will be used by them for ALL attacks, funny enough this includes ranged attacks such that warrior humanoids enemies use, like the archer and warrior. So the damage roll that those arrows flying at you are doing is determined by whatever weapon in the inventory has the highest attack. So that archer is likely throwing elven flails at you, or the warrior is actually throwing dwarven katanas at you.
Just thought someone might find that interesting/funny. Also of actual useful note, said weapon being used also effects their chances of landing hits, meaning the weapon they are using also benefits from whatever material hit modifier it has. So that thief using an iron long-sword has a -1 modifier to hit you, while that orcish mace wielding knight has a +5 modifier to hit you, in both melee AND ranged combat.
- BadLuckBurt
- Posts: 948
- Joined: Sun Nov 05, 2017 8:30 pm
Re: Ranged Enemies Throw Their Weapons At You
There is a BowDamage function and a MeleeDamage function in EnemyAttack.cs so it does seem to be handled separately?
So can you support that with a code example? I'm not saying you're wrong but I do have a hard time believing that until I see proof
So can you support that with a code example? I'm not saying you're wrong but I do have a hard time believing that until I see proof
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.
- Hazelnut
- Posts: 3016
- Joined: Sat Aug 26, 2017 2:46 pm
- Contact:
Re: Ranged Enemies Throw Their Weapons At You
I think this is correct Burt, it always uses the weapon held in right (primary) hand of the enemy. Unless I also missed something.
Just a note to say that if you use the enemy equipment module of Loot Realism then archers use their bow damage ranges. Although when you get close and they melee it will use the bow damage still.
Just a note to say that if you use the enemy equipment module of Loot Realism then archers use their bow damage ranges. Although when you get close and they melee it will use the bow damage still.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods
- Magicono43
- Posts: 1141
- Joined: Tue Nov 06, 2018 7:06 am
Re: Ranged Enemies Throw Their Weapons At You
I was mostly going by the fact (at least without mods like Loot Realism) that when I had the debug log output what skillID the enemy was currently using whenever it performed an attack, that I saw it did not change from say 29 being for long-sword to 33 for archery when they used their ranged attacks. Neither did their hit-chance mod, which would be based on the material of the weapon they were using.BadLuckBurt wrote: ↑Fri Mar 06, 2020 5:28 pm There is a BowDamage function and a MeleeDamage function in EnemyAttack.cs so it does seem to be handled separately?
So can you support that with a code example? I'm not saying you're wrong but I do have a hard time believing that until I see proof
- BadLuckBurt
- Posts: 948
- Joined: Sun Nov 05, 2017 8:30 pm
Re: Ranged Enemies Throw Their Weapons At You
Alright but then this code doesn't work as intended? If they always use their 'best' weapon, that seems like a big bug to me
EnemyAttack.cs:
EnemyAttack.cs:
Code: Select all
void Update()
{
// Unable to attack if paralyzed
if (entityBehaviour.Entity.IsParalyzed)
return;
// If a melee attack has reached the damage frame we can run a melee attempt
if (mobile.DoMeleeDamage)
{
MeleeDamage();
mobile.DoMeleeDamage = false;
}
// If a bow attack has reached the shoot frame we can shoot an arrow
else if (mobile.ShootArrow)
{
ShootBow();
mobile.ShootArrow = false;
DaggerfallAudioSource dfAudioSource = GetComponent<DaggerfallAudioSource>();
if (dfAudioSource)
dfAudioSource.PlayOneShot((int)SoundClips.ArrowShoot, 1, 1.0f);
}
}
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.
- Magicono43
- Posts: 1141
- Joined: Tue Nov 06, 2018 7:06 am
Re: Ranged Enemies Throw Their Weapons At You
Hmm, I have not tested what I just did as a werewolf, so i'll probably have to give that a shot and see what the AI does, like see if they change to using HtH like the "MeleeDamage" method says they should do in that case.BadLuckBurt wrote: ↑Fri Mar 06, 2020 6:11 pm Alright but then this code doesn't work as intended? If they always use their 'best' weapon, that seems like a big bug to me
EnemyAttack.cs:
Code: Select all
void Update() { // Unable to attack if paralyzed if (entityBehaviour.Entity.IsParalyzed) return; // If a melee attack has reached the damage frame we can run a melee attempt if (mobile.DoMeleeDamage) { MeleeDamage(); mobile.DoMeleeDamage = false; } // If a bow attack has reached the shoot frame we can shoot an arrow else if (mobile.ShootArrow) { ShootBow(); mobile.ShootArrow = false; DaggerfallAudioSource dfAudioSource = GetComponent<DaggerfallAudioSource>(); if (dfAudioSource) dfAudioSource.PlayOneShot((int)SoundClips.ArrowShoot, 1, 1.0f); } }
The code that seems to determine whether an enemy uses a weapon or not seems to be this from
FormulaHelper.cs:
Code: Select all
// Choose whether weapon-wielding enemies use their weapons or weaponless attacks.
// In classic, weapon-wielding enemies use the damage values of their weapons
// instead of their weaponless values.
// For some enemies this gives lower damage than similar-tier monsters
// and the weaponless values seems more appropriate, so here
// enemies will choose to use their weaponless attack if it is more damaging.
EnemyEntity AIAttacker = attacker as EnemyEntity;
if (AIAttacker != null && weapon != null)
{
int weaponAverage = (weapon.GetBaseDamageMin() + weapon.GetBaseDamageMax()) / 2;
int noWeaponAverage = (AIAttacker.MobileEnemy.MinDamage + AIAttacker.MobileEnemy.MaxDamage) / 2;
if (noWeaponAverage > weaponAverage)
{
// Use hand-to-hand
weapon = null;
}
}
- BadLuckBurt
- Posts: 948
- Joined: Sun Nov 05, 2017 8:30 pm
Re: Ranged Enemies Throw Their Weapons At You
The comment there seems to imply it's intentional. Feels weird to me, they should just hit you with whatever they're using, not whatever's the most damaging imo. But consider me convinced that your observation is correct, it just confuses the hell out of me
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.
- Magicono43
- Posts: 1141
- Joined: Tue Nov 06, 2018 7:06 am
Re: Ranged Enemies Throw Their Weapons At You
Yeah, I personally have no clue how the inventory of enemies work, so I don't really know what tells them which weapon they happen to be holding is the one they should be using or not. In fact, I had no idea that enemies even had a system or "right-hand" "left-hand" like the player does with their inventory.
One definite bug that I may have found when trying to become a vampire/werewolf or even give myself any disease through the console command. I gave myself yellow-fever, and waited 8 hours like five times and my health and stats were all still perfect, so not sure if that command is known to be non-functional, or maybe I just did something wrong.
One definite bug that I may have found when trying to become a vampire/werewolf or even give myself any disease through the console command. I gave myself yellow-fever, and waited 8 hours like five times and my health and stats were all still perfect, so not sure if that command is known to be non-functional, or maybe I just did something wrong.
- BadLuckBurt
- Posts: 948
- Joined: Sun Nov 05, 2017 8:30 pm
Re: Ranged Enemies Throw Their Weapons At You
If you're fresh out of Privateer's Hold, that might cause you to not be infected. There's some protection in place to save new characters. I've used the console before to give myself lycanthropy so that definitely works.Magicono43 wrote: ↑Fri Mar 06, 2020 6:46 pm Yeah, I personally have no clue how the inventory of enemies work, so I don't really know what tells them which weapon they happen to be holding is the one they should be using or not. In fact, I had no idea that enemies even had a system or "right-hand" "left-hand" like the player does with their inventory.
One definite bug that I may have found when trying to become a vampire/werewolf or even give myself any disease through the console command. I gave myself yellow-fever, and waited 8 hours like five times and my health and stats were all still perfect, so not sure if that command is known to be non-functional, or maybe I just did something wrong.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt
.
- Magicono43
- Posts: 1141
- Joined: Tue Nov 06, 2018 7:06 am
Re: Ranged Enemies Throw Their Weapons At You
I was thinking there was something like that, never really thought Privateer's Hold would pull some punches like that. Might even be some protection for level 1 characters since I left the hold and got infected by an actual wereboar, but still not seeing any changes. Will now have to try on a higher level character and see if it works.BadLuckBurt wrote: ↑Fri Mar 06, 2020 6:55 pmIf you're fresh out of Privateer's Hold, that might cause you to not be infected. There's some protection in place to save new characters. I've used the console before to give myself lycanthropy so that definitely works.Magicono43 wrote: ↑Fri Mar 06, 2020 6:46 pm Yeah, I personally have no clue how the inventory of enemies work, so I don't really know what tells them which weapon they happen to be holding is the one they should be using or not. In fact, I had no idea that enemies even had a system or "right-hand" "left-hand" like the player does with their inventory.
One definite bug that I may have found when trying to become a vampire/werewolf or even give myself any disease through the console command. I gave myself yellow-fever, and waited 8 hours like five times and my health and stats were all still perfect, so not sure if that command is known to be non-functional, or maybe I just did something wrong.