Open Abendlied opened 2 weeks ago
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 guildVal
maybe. 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 to rangeDamage
in the DamageCalculator
.
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
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:
crossbow; companion->player:
magic; enemy->enemy:
magic; bystander->player:
dragon fire (magic); enemy->enemy: