I am currently working on a MUD made in python, using the miniboa telnet framework. I can communicate between my clients, and I am currently working on a finite state machine to define what actions the players can do, when.
My big question mark is: NPC's. How would I go about implementing them?
Since this server is not threaded, I will assume some sort of timer will be sweeping across all the rooms, updating npc's as they go.
However; what I do not understand is how the NPC's actually "enter" rooms in a MUD.
My room file looks like:
[ROOMID] = 1
[DESC] = "An example room."
[NPCS] = 1
my npc file:
[NPCID] = 1
[NAME] = "Cairn"
[DESC] = "test"
[STARTROOM] = "1"
and so on and so forth. So my room loading script will look for npc's in their room. But in pseudocode, how do I actually make them part of the game aside from notifying the player that they are there? In an asynchronous environment, how does one make an NPC respond to commands to one player only?
here is my current "statemachine" so far, as some code is required.
""" Game States: (We cannot have loops, as this will tie up the server, so we use a Finite State Machine held by: client.GAME_STATE = int 0: Login State 1: New State 2: Non-New Authentication 3: Gameplay, entry into chat server 4: 5: 6: 7: 8: 9: Dead 10: Jailed, stuck in a lifeless room (perhaps with duties to do, or submit to a penalty that will subtract a few levels.) """ from fadedmud import * def statemachine(client): msg = client.get_command() if client.GAME_STATE == 0: client.send("> ") if msg == "hello": client.GAME_STATE = 1 client.send("YOU ARE IN STATE 1\n") if client.GAME_STATE == 1: client.send("100/100> ")
NOTE: I am not looking for someone to code my game for me, I just need some inspiration in the right direction. Thank you.