SFS2X Remote NPC

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Void*
Posts: 75
Joined: 15 Feb 2021, 13:49

SFS2X Remote NPC

Postby Void* » 24 Oct 2022, 11:03

Is it possible for SFS to set a remote connection as an NPC in our MMO Server?

We are just theory-crafting at the moment, so there is no code to show. What we would like to do is something along the lines of;

  • Player needs to interact with map NPC
  • Player is given a personal persistant instance of that NPC that follows them
  • NPC is disposed after fulfilling requirements

At a flow level it would be something like;

  • Client -> SFS2X Extenstion Handler -> RequestNPC
  • SFS2X -> External Svc. -> Generate NPC Instance
  • External Svc. -> Login to SFS2X with Generated Credentials
  • SFS2X (Custom Login Handler) -> Login and mark as NPC
  • SFS2X (OnJoinZone) -> Allocate NPC to Player
  • Proceed as normal

Why do we want to do this? We want to be able to treat the NPCs and Players equally when it comes to things like AOI, Server to Client Events, and AI "Client" Extension requests and processing (Cloud level scaling for AI processing). From what we saw we weren't able to allocate a session to an NPC, nor can we manually mark a user as an NPC.

We could just use the UserVars to mark the allocated User as an NPC, but we wanted to stay within the SFS2X system in case it became important to ensure that SFS2X knows this is an NPC user.

Is there an accepted method of doing this?
Is it actually important to let SFS know this user is an NPC?

Thanks in advance
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS2X Remote NPC

Postby Lapo » 24 Oct 2022, 13:44

Hi,
have read these articles?
https://smartfoxserver.com/blog/ways-of ... -game-p-1/
https://smartfoxserver.com/blog/ways-of ... -game-p-2/

They go in depth on how to implement a couple of different strategies for NPCs.
We want to be able to treat the NPCs and Players equally when it comes to things like AOI, Server to Client Events,

Then you should probably use the client API to create a number of local clients acting as NPCs
The 2nd article linked here should help.

...nor can we manually mark a user as an NPC.

Depends what you mean by "marking".
You can assign any number of custom properties to a User, via the set/getProperty() methods. I think this should do the trick.

Is there an accepted method of doing this?

Yes
Is it actually important to let SFS know this user is an NPC?

I am not sure what you mean by this. If the NPC is an actual client (rather than a simulated User in the server) SFS2X will consider it just a normal User.
However, if you need to be able to recognize real Users from NPCs you could simply check the IP address of the player and if it's a local one flag the User as NPC.

Makes sense?
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 74 guests