gdquest-demos/godot-open-rpg

Attacking one monster attacks them all

NathanLovato opened this issue · 4 comments

Refactoring how stats work I broke monsters on 9f66b76
They might all be referencing the same CharacterStats object. May be due to changes to CharacterStats.copy.

I think you're correct. I followed target all the way down to Attack.gd and it's still only attacking one target. I'm looking into it now, but since CharacterStats.copy is new since I last looked at the project I'm not confident I'll be able to fix it.

I've confirmed a few more things. All the enemies have their own unique name, but the stats are a shared resource.

Here, you can see that each enemy is a unique position2d node.

https://gfycat.com/ShrillUnnaturalGrebe

But here you can see that the stats resource is the same.

https://gfycat.com/ForcefulPlumpCatbird

Okay so with @nhydock's help, I got it figured out.

You removed stats = (stats as CharacterStats).copy() from Battler.gd because you were moving everything to PartyMember.gd.

Problem is that Porcupine doesn't have an equivalent to PartyMember.gd so instead it relies on Battler.gd fully.

Which means that everything that touches stats directly updates Porcupine.tres which they all use.

I'm not going to have time today to try and create a new script for enemies so feel free to do it today if you want.

That was an easy fix actually