Author Topic: Server side game logic & AI  (Read 2272 times)

Ulnari

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Server side game logic & AI
« on: April 22, 2015, 04:48:26 AM »
Hi Michael, hi tnet users,

I understand that TNET server is not supposed to handle game logic, but it is possible in theory? Can I extend the code to instantiate a gameworld (with gameobjects) on the server (instead of the hosting client) and replicate to the clients?

AI: When having the game logic on the client, how do you handle AI players (aka bots) in multiplayer? I guess the idea is to let the hosting client (first client to join) handle all AI players. How was it done in Starlink?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Server side game logic & AI
« Reply #1 on: April 22, 2015, 02:37:36 PM »
While anything is possible, it wouldn't be recommended.

TNet's server executable is ~60 kb. It doesn't require Unity.

If you add level loading / instantiation logic, you will need to include Unity's DLL at the very least, which means your 60 kb executable will now have a 10 MB DLL to go with it.

In Starlink the AI is just done by the host player: if (TNManager.isHosting) [do AI Logic].

The host does the AI logic and sends the result to other clients via tno.Send("SomeFunction", Target.OthersSaved, ResultOfTheAILogic);

Naturally there can be many such calls, and it may not need to be OthersSaved. In Windward when ships shoot each other, the RFCs are sent as Target.Others instead. This way I am not allocating RFC IDs by using TNManager.Create, as all cannonballs are local to each client and have a very short lifespan, so it doesn't make sense to go through TNManager.Create.