Events confusion

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Events confusion

      Hello all,

      I have some confusion about events and I have come up with an idea but I don't know if this is correct. On actor creation and destruction, there are several events.
      1. RequestCreateActor
      2. RequestDestroyActor
      3. CreateActor
      4. DestroyActor
      Also, scripts using #2 under a collision to destroy actor makes me more confused.

      What I come up with
      #1 and #2 should only be sent from server to client when an actor is created/destroyed, and requesting the proxy logic to do so.
      #3 and #4 should be trigger when an actor is created/destroyed, on both server and client sides internally for human view to play some sound and animation.
      Since scripts create actors directly without using event, they should also destroy actors without using event.

      Is this a correct way to interpret these events?

      Cheers,
      Chi
    • Hello!

      Perhaps a concrete example will help - let's assume your game is a client-server multiplayer game, where the server is authoritative on all game states, and the player is throwing a grenade. Granted there are more ways than one to do this, and I'm typing this example off the cuff.

      Controller: Player taps the 'toss grenade button"
      Client: Sends a "RequestThrowGrenade" message to the server.
      Server: Checks the players inventory and sees plenty of grenades left. Sends to all clients in range, "CreateActor" with the "grenade" type.
      Client: Receives the "CreateActor" message and informs the renderer to add a new object to the screen.
      Server: Sends to just the player, "DestroyAcor" message that removes the grenade from the players inventory.
      Client: Receives the "DestroyActor" message and decrements a grenade counter.
      Server: Tracks the grenade movement and at some regular frequency (we use about 10Hz on Crowfall) sends "MoveActor" messages to all clients in range of the grenade.
      Client: Receives the "MoveActor" message and informs the renderer that the visible grenade has changed world position.
      Server:

      The Server in this example receives client inputs such as moving their character and throwing grenades, and the server responds by sending changes in the game state through actor creation, removal, and movement messages to all clients in range of the actors.

      Scripts and compiled code (both on the client and the server) execute in response to events, and they can in turn create events and send them.

      Collisions in most games are handled by the client - but in the game I'm working on now are handled by the server. This is considered somewhat crazy, since it is difficult to do in practice while also making the client very responsive to player inputs. Crowfall has a physics simulation on the client as well, and the client does its best to estimate what the server will do based on all the information it currently has. When the client gets it wrong, and discovers that information coming from the server has diverged from currently displayed positions and orientations of objects on the client, their positions and orientations are quickly corrected to the server's authoritative ones.

      As you might expect, this is tricky to accomplish.

      For a simpler system, I would just have server side code trigger all object destructions. Instead of a client sending a "CriticalDamage" message, I would send a "Attack" message, and the server would perform all the calculations of whether the hit landed, how much damage was applied, and whether the damaged object should be destroyed.
      Mr.Mike
      Author, Programmer, Brewer, Patriot