Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developer needs help on RE - Trigger entity spawning #67

Open
Ismoh opened this issue Jul 12, 2022 · 21 comments
Open

Developer needs help on RE - Trigger entity spawning #67

Ismoh opened this issue Jul 12, 2022 · 21 comments
Assignees
Labels
dependencies Pull requests that update a dependency file help_wanted Extra attention is needed question Further information is requested rework Predicts breaking changes. This will increase MAJOR version number, when merged into develop.

Comments

@Ismoh
Copy link
Owner

Ismoh commented Jul 12, 2022

Might be that I could use some RE help. I never was depening on RE help so much.

The problem I have is:
My concept is that the server holds the truth. Spawning, moving entities, everything. Thats why I remove all entities on client side.
BUT... There is no Noita API function (or I dont know a specific one), which triggers spawning entities, therefore the client wont see any entitites spawning, when not following the servers player. I have no idea where to look in ghidra or even how to use it or if there is any Noita API function or a specific combination of components, which are needed.

I think I am going to create a 'wanted help' issue on github, because if this isnt fixed, multiplayer would mean to follow the servers player all the time and this sycks.

If I wont remove entities on client side, everything would be multiplied by amount of clients, which is even more sycking!

Anyone out there you can help me?

I still want to have a look on RegisterSpawnFunction, because I dont know it or used it before.

I really hope there will be a solution, because it's a big game changer!

@Ismoh Ismoh added help_wanted Extra attention is needed question Further information is requested rework Predicts breaking changes. This will increase MAJOR version number, when merged into develop. dependencies Pull requests that update a dependency file labels Jul 12, 2022
@Ismoh Ismoh added this to the Synchronisation milestone Sep 2, 2022
@Ismoh
Copy link
Owner Author

Ismoh commented Oct 29, 2022

Based on the default player_base.xml I created in the past a client_player_base.xml to see a copy of clients minä.
I commented out everything not need by best guess. As @GrandpaGameHacker mentioned, after RE Noita, it might be enough to add a CameraBoundComponent (double check wording) to make the clients minä copy trigger spawning entities on server instance to be synced on all clients.
This is needed, because entities on client will be removed by default, otherwise everything would be duplicated and not in sync.

@ofoxsmith
Copy link
Collaborator

PlatformShooterPlayerComponent controls which entity the camera follows and where it is positioned, and the GameGetCameraPos, GameSetCameraPos, GameSetCameraFree allow for the camera to be moved with lua, but I don't think they will be useful for what we need to do.

@ofoxsmith
Copy link
Collaborator

I assume there can only be one entity with a PlatformShooterPlayerComponent in the world, as the camera can't be centred on two entities.

@Ismoh
Copy link
Owner Author

Ismoh commented Oct 30, 2022

How about adding the component and setting center_camera_on_this_entity and move_camera_with_aim to 0?
I think, when the local minä dies, the camera might move to the other players, when setting those values to 1 after minä died. Would be a nice feature?!

@Ismoh
Copy link
Owner Author

Ismoh commented Feb 18, 2023

As discussed with @ofoxsmith we decided to implement a different approach.
We're going to have a serialisation and compression of a whole entity within his children and all components, which then is shot over network to server. Clients eentity will be destroyed. Server then sends this chunk of squeezed entity to all other clients, which then spawns the entity, if it is in range (camera bounds)
There will be pitfalls like:

  • Do not reuse the entityId from clients.
  • Are there any other properties of the entity or components, which are only peer related, i.e. minäs inventory.
  • Performance issues?
  • Entities will be respawned, but I don't care atm: client1 is on x 567, y -647. Kills all entities. Client2 go to the same position after 30mins. Entities of Client2 will be spawned.

@Ismoh
Copy link
Owner Author

Ismoh commented Feb 18, 2023

@ofoxsmith I created a branch based on develop!

@Ismoh
Copy link
Owner Author

Ismoh commented Feb 20, 2023

@Ismoh
Copy link
Owner Author

Ismoh commented Feb 22, 2023

I thought about, how to implement syncing rootEntities and all below, like children and components. This is my result:
Pseudo code:

local entitiesInRadius = EntityGetInRadius(pos_x, pos_y, radius) or {}
for entitiesInRadius do
 if entityInRadius[i] == EntityGetRootEntity(entity_id) then
-- get all attributes of root entity
-- todo
-- get all components of root 
local rootComponents = EntityGetAllComponents(entityInRadius[i]) or {}
for rootComponents do
-- store comp type, name and value into a string, table or json
-- I am pretty sure we need a lookup table like: if component type == VariableStorageComponent then field_name = "name" etc pp
end
-- get all child entities
local children = EntityGetAllChildren(entityInRadius[i]) or {}
for children do
-- recursive getAllComponents and store in string, table or json
end
else
--skip children
end

So we need to get the root entity, but ignore children. If entity == root, (1)then get all attributes and store those, then iter all components and store type, field_name and value, then get all children and repeat (1).

@Ismoh
Copy link
Owner Author

Ismoh commented Feb 23, 2023

[17:08]stefnotch: If we want to clearly communicate that to the players:
Would it make sense to have an indicator that appears when you're further away from the host. As if to say "you're on your own, things that happen here are closer to singleplayer than multiplayer"?

@Ismoh
Copy link
Owner Author

Ismoh commented Feb 24, 2023

If server is in range ask for spawn, if server isn't in range ask only for nuid.
Check for entityData if other minäs are in range, if so send otherwise not. If anything comes in range, make sure to spawn the entity: think of an projectile flying millions of pixels!

@Ismoh
Copy link
Owner Author

Ismoh commented Feb 25, 2023

Make sure all sendToPeer are put into functions. In addition do checks that parameters aren't empty.
Global function in MinaUtils for distance between minas.

if any mina in range then
  send serialized enitity to server
  Server send to all clients
end
Every peer checks, if entity is in range
then spawn, if not ack only
Else if no mina in range, do nothing

Ismoh added a commit that referenced this issue Feb 25, 2023
…erialisation of entities. Small clean up. Need to add deserialisation and tests!
@Ismoh
Copy link
Owner Author

Ismoh commented Mar 4, 2023

Make sure entities are send immediatly, when spawned, no matter what tick is set, otherwise it's getting out of sync.
Send entity data only on tick!

Ismoh added a commit that referenced this issue Mar 5, 2023
…ntities. Renamed functions for better understanding. Tweaked CustomProfiler a bit. Changed EntityUtils.processAndSyncEntityNetworking slightly. Would like to rework this again, because it's ugly as shhh. Excluded particles from being synced (FPS nom nom nom)!
@Ismoh
Copy link
Owner Author

Ismoh commented Mar 6, 2023

Ismoh added a commit that referenced this issue Mar 6, 2023
…rialize. Added EntityCacheUtils.lua for some checks before using EntityCache. Fixed game crashes, when pointing to components or entities which don't exist anymore.
@Ismoh
Copy link
Owner Author

Ismoh commented Mar 11, 2023

Add a list of entity names, which only be loaded once, like bosses. Can be modified by modders.

Ismoh added a commit that referenced this issue Mar 12, 2023
…rkCache. Formatted md5 hex hash to string without converting as tostring do.
Ismoh added a commit that referenced this issue Mar 14, 2023
Ismoh added a commit that referenced this issue Mar 14, 2023
…ua. Fixed MinaUtils.getLocalMinaEntityId(). Slightly clean up. NetworkVscUtils throwing error?
Ismoh added a commit that referenced this issue Mar 15, 2023
Ismoh added a commit that referenced this issue Apr 25, 2023
Ismoh added a commit that referenced this issue Apr 25, 2023
Ismoh added a commit that referenced this issue Apr 25, 2023
Ismoh added a commit that referenced this issue Apr 25, 2023
Ismoh added a commit that referenced this issue Apr 25, 2023
Ismoh added a commit that referenced this issue May 8, 2023
Ismoh added a commit that referenced this issue May 14, 2023
Ismoh added a commit that referenced this issue May 14, 2023
Ismoh added a commit that referenced this issue May 20, 2023
Ismoh added a commit that referenced this issue May 20, 2023
Ismoh added a commit that referenced this issue May 20, 2023
@Ismoh
Copy link
Owner Author

Ismoh commented May 29, 2023

Dextercd
np.SetGameModeDeterministic(true). This basically makes the game think it's a daily run. It makes it so all spells are available during the run and using spells does not count towards spell progress.

Ismoh added a commit that referenced this issue Jun 14, 2023
@Ismoh Ismoh assigned Ismoh and unassigned ofoxsmith Jun 30, 2023
@Ismoh
Copy link
Owner Author

Ismoh commented Jul 11, 2023

When needNuid is sent, serialise the entity and send it to the server. Remove then on client. Server will add nuid and sent spawned entity to the client.

@Ismoh
Copy link
Owner Author

Ismoh commented Jul 13, 2023

  • Make sure only root entities are serialised!

@Ismoh
Copy link
Owner Author

Ismoh commented Jul 25, 2023

  • before adding NoitaMP vscs serialise entities
  • when recieving serialised string compare and check, if it's the same entity, if not create a new one
  • if entity already have a nuid, reuse and don't create a new one

@Ismoh
Copy link
Owner Author

Ismoh commented Jul 25, 2023

  • can I get rid off GlobalsUtils?
  • maintain existing code. Some function aren't in specific utils file. GlobalsUtils.getNuid(entityId) for instance

@Ismoh
Copy link
Owner Author

Ismoh commented Aug 3, 2023

  • Change initialSerializedEntityString to md5 hash to store less in VariableStorageComponent
  • change check funtion to md5 hash
  • add server password
  • add two player lists: one simplified, one detailed
  • change tooltips of existing NoitaMPSettings
  • change external profiler to use a different port, maybe processId?
  • fix bug for default port when joining Server
  • fix unreliable player.xml when player entity is synced
  • remove old SendNewNuid and SendNeedNuid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file help_wanted Extra attention is needed question Further information is requested rework Predicts breaking changes. This will increase MAJOR version number, when merged into develop.
Projects
Status: 🏗 In progress
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants