Try / OpenGothic

Reimplementation of Gothic 2 Notr
MIT License
1.07k stars 78 forks source link

Friendly fire in both ranged (bow/crossbow) and magic projectiles #611

Open Abendlied opened 2 weeks ago

Abendlied commented 2 weeks ago

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.

Try commented 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.

Abendlied commented 2 weeks ago

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:

  1. 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.

  2. 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.

  3. 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.

Try commented 2 weeks ago

@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.

Abendlied commented 1 week ago

Thank you very much, Try! I will test it during the week on my end.

Abendlied commented 4 days ago

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.

save_slot_12.sav.tar.gz

Abendlied commented 3 days ago

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.

Try commented 21 hours ago

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