Friendly fire in both ranged (bow/crossbow) and magic projectiles
I have just completed a complete play through as a fire mage, it was very smooth. Thank you for all the effort your already put in, it gave me some seriously happy hours with my all time favourite game!
During the play through, multiple occasions I had trouble with friendly fire in both ranged (bow/crossbow) and magic projectiles. Friendly fire seems to happen for companion->player, companion->companion, enemy->enemy.
bow; companion-companion / companion->player:
Jharkendar Canyon clearing. I chose multiple companions, one of them had a bow. In fights, the arrows would all the time land in either my back or hit another companions, leading to a fight between the companions with one dead.
crossbow; companion->player:
Swamp Dragon fight with a dragon hunter companion
magic; enemy->enemy:
escorting Diego to the pass in the valley of mines, I was constantly shot by Diegos arrows once again. This lead to testing with orc shamans if the same would work with magic - which is the case. If the shaman's magic attack hit another orc, the orc would immediately lose agro on me, turn towards the shaman and they would fight. Works with creatures as well.
magic; bystander->player:
fire mage isgaroth fighting a seeker. I stand in the way, Isgaroths spell hits me.
dragon fire (magic); enemy->enemy:
if undead dragon's dragon fire hits an undead orc, the undead orc will fight the undead dragon.
Hi, @Abendlied !
In opengothic projectiles, such as arrows/bolts/fire-balls do not track ownership and do damage regardless. In theory your arrow may bounce back at your character and also do damage :)
For now, solution, for npc, is to trace a ray, before firing arrow and assert, that there is no friendly npc's on the path. However, if npc will move into arrow, after it been shoot, - that will cause friendly fire.
thanks for the explanation @Try.
I am not trying to push for this, just trying to contribute with brainstorming. Plus friendly fire does exist in the original game, just not to the same extend. So eliminating it entirely might not be fair.
Projectile ray tracing is not ideal in my opinion as it would cause weird attack behaviour if the game would prevent the NPC from ranged attacks, which alters the game experience to some extend. So I was thinking about the following three approaches:
-
We could forbid hostility towards or damage against enemies of the same class such as Shaman->Orc or Dragon->Lizard Men. It would not help for human NPCs of course, so would only be half a solution plus potential side effects.
-
At the time the projectile is spawned, we could include ownership reference to that projectile. Instead of checking ownership against individuals, we could check
guildValmaybe. Though doing this for every projectile is kind of heavy and I can see why you did not want to go that path. Same approach but different way could be adding conditions torangeDamagein theDamageCalculator. -
Avoid friendly fire for companions only, e.g. checking for companion status (
ai_gotonpc?) before calculating damage to player or to other following NPCs like in the canyon, swamp dragon or diego mile valley examples. Together with approach (1) it would cover most cases I experienced.
@Abendlied
I've added friendly fire between 2 npc's with friendly altitude. And also fixed a bug with ray-test logic. It was any-hit by mistake instead of closest hit.
Thank you very much, Try! I will test it during the week on my end.
I will need a bit more time to verify as I have trouble with making the file on my end, currently preventing me from including your fix.
I have created a savegame for the canyon scenario with Skip in the group, who fights with a bow. This was especially painful with the friendly fire.
Fixed the make trouble on my end.
@Try I was now able to test your improved friendly fire commit with the attached savegame (with ranged). I am afraid I do not feel an improvement for friendly fire behaviour. Skip will still hit other pirates all the time causing damage on them and leads to the attacked pirate turning agressive towards Skip.
I can't quite reproduce pirate-to-pirate case with Skip, as well as other pirates on attached save-game file.
however can notice that Skip may damage the player - fixed in 86a1bbae4563cef9ad8d56b3a3224138a4e17024
@Try Skip applying damage to the player is solved thanks to your fix. I also now noticed that the pirate-to-pirate damage does now no longer occur, indicating the ray-test logic works as intended. Not 100% sure why I could not feel this when you initially fixed it, it definitely is fixed now. I cleaned the canyon 2 times now without Skip causing ranged damage to other pirates or to me.
I notice that Skip changes to melee significantly faster now, would this be related to the ray-test failing and Skip then switching to melee due to reduced distance?
Either way, big thanks for this fix, large improvement! Solved from my point of view.