henpemaz / Rain-Meadow

Rain World multiplayer engine and custom game mode
110 stars 14 forks source link

Arena: Violence #155

Closed 6fears7 closed 2 months ago

6fears7 commented 3 months ago

To document my findings so I don't lose my mind trying to solve this.

Most notably, in CreatureOnViolence


                        // Notify entity owner of violence
                        (onlineVictim as OnlineCreature).RPCCreatureViolence(onlineTrueVillain, hitchunk?.index, hitappendage, directionandmomentum, type, damage, stunbonus);
                        return;

When using onlineVictim, an RPC error of "Target for RPC not found" is thrown. If I change this to the onlineTrueVillain, I noticed that the RPC has no issues.

This is a little interesting because OnViolence is initiated from an attacker first, so it would make sense that onlinevictim as the invoker is null reffing because the onlinevictim hasn't been notified of being attacked yet.

However, where things get weird is the RPC. We first do a little math on the chunk locally then perform the RPC: creature.Violence(onlineVillain?.apo.realizedObject.firstChunk, directionAndMomentum, hitChunk, victimAppendage, damageType, damage, stunBonus);

Now what's weird about this is that when I debugged the data (after making the invocator the vililain), I could see all of the data being sent and received. Damage, attacker, victim, type of attack, etc... and the RPC'd result was GenericResult.OK.

However, if I try to take the realized creature Victim and call .Die() on it, nothing happens.

Yet if I say, creature.State.alive = false, I do get an entity death, but it's the villain who dies.

I'm willing to concede a revisit on the vars to ensure the correct entity is going to die since I did mess with the RPC locally, but it's very strange and a little concerning that .Die() cannot kill where a forced state switch does. I'd normally believe that it's the result of a hook prevention, but there did not seem to be anything causing a prevention.

The only theory I had was PlayerOnDie:

if (!onlineEntity.isMine) return;

but that did not seem to be it.

TODO: Revert RPC behavior back to how it is in main but swap victim with villain for RPC target resulting in OK. I also think testing the attacker as the caller for .Violence() in the RPC should be tested because if the attacker is initiating the Violence call originally then that should be mirrored in the RPC.

6fears7 commented 3 months ago

Did some more testing today:

Uploaded my current work to arena-violence branch. Did some logic stuff with spear so that if players are dead with spears stuck in them switching between levels the game doesn't freak out. Need to build it out / clean it up.

I may have also added in some funkiness to Story spear behavior. They just float.

Need to test:

Gonna be awhile though since my free time to work on this is unfortunately thin as summer approaches. But if one were to build the arena branch, you could at least hop into an arena session.

6fears7 commented 2 months ago

Resolved from henpe's push to main recently. Development can continue.