praydog / REFramework

Scripting platform, modding framework and VR support for all RE Engine games
https://cursey.github.io/reframework-book/
MIT License
2.78k stars 343 forks source link

Question: N:A Video #45

Closed WoefulWolf closed 4 years ago

WoefulWolf commented 4 years ago

Terribly sorry I have to bother you here, but I couldn't find any other method of communication. A YouTube account with videos of your RE2 first person mod also posted a video of NieR:Automata a while ago. https://www.youtube.com/watch?v=PrNIzWubFsc Is this your YouTube account with your "proof of concept" project video posted? It looks quite suspicious and was just curious if you have any info on this. Thanks!

praydog commented 4 years ago

Yes. I had this video sitting around for a while from since I was working on that project. I haven't touched the code for it in a really long time, and yes it's real.

WoefulWolf commented 4 years ago

That's really interesting! Is it possible to release this code even if it's unfinished? I'd like to take a look at it if you don't mind. Syncing entities in N:A is a bit tricky and your approach appeared flawless? Amazing!

praydog commented 4 years ago

Unfortunately no. At least, not in its entirety. There's a private library it's using that I'm not willing to make public. I wasn't developing it with other people in mind at the time. If it was developed with all open source libraries, I'd have open sourced it a long time ago. If I end up coming back to the project, I'd probably end up remaking it with all open source libraries.

To answer a few questions:

  1. It uses enet for packets.
  2. Player syncing involves keeping track of key state variables for the player (buttons, position, facing, etc...), as well as any animations. This is easy if you know where to find all this stuff, but since this is a mod, there's hooks all over the place to keep track of this data. Just a whole lot of reverse engineering on this part.
  3. The last thing I was working on was syncing of NPCs. I managed to get them to spawn, and sync their position and health, but that's about it. I didn't know how to control their AI routines and whatnot. This part was also kind of unstable and would crash sometimes.

Here's a little snippet of what exactly is synced:

namespace nier_client_and_server {
    struct PlayerData : public PacketT<ID_PLAYER_DATA> {
        bool flashlight;
        float speed;
        float facing;
        float facing2;
        uint32_t weaponIndex;
        uint32_t podIndex;
        uint32_t heldButtonFlags;
        Vector3f position;
    };

    struct AnimationStart : public PacketT<ID_ANIMATION_START> {
        uint32_t anim;
        uint32_t variant;
        uint32_t a3;
        uint32_t a4;
    };

    struct ChangePlayer : public PacketT<ID_CHANGE_PLAYER> { };

    struct Buttons : public PacketT<ID_BUTTONS> {
        uint32_t buttons[Entity::CharacterController::INDEX_MAX];
    };
}

namespace nier_client {

}

namespace nier_server {
    template<uint32_t idT>
    struct EntityPacket : public PacketT<idT> {
        uint32_t guid;
    };

    struct EntitySpawn : public EntityPacket<ID_SPAWN_ENTITY> {
        char name[0x20];
        uint32_t model;
        uint32_t model2;
        EntitySpawnParams::PositionalData matrix;
    };

    struct EntityData : public EntityPacket<ID_ENTITY_DATA> {
        float facing;
        float facing2;
        uint32_t health;
        Vector3f position;
    };
}