My Mud Project: As Is

Community Forums/Showcase/My Mud Project: As Is

Gauge(Posted 2004) [#1]
Nowhere near finished, and with the baby, the fiancee and the two step kids now i haven't had much time to work on it. but heres my latest code. I have a few functions to add in, but oh well. Theres a few semi-big changes i have to make, and its a little sloppy, what do you think so far??

Lots more work to do: Currently 1047 lines!

AppTitle "MDB MUD DEMO-1"
Graphics 400,300,16,3
Color 0,0,255
Global server
Global ckn
Global dir
Dim pl.player(1000);maxplayers from config.dat
Global ucount#
Ucount#=0
Global x
Const north=1
Const south=2
Const east=3
Const west=4
Const ne=5
Const mw=6
Const se=7
Const sw=8
Const up=9
Const down=10

Dim gColor$(19)
 gColor$ (0)="" ;set to default w/black background
 gColor$ (1)="" ;bright
 gColor$ (2)="" ;Underline
 gColor$(3)="" ;Blinkies
 gColor$ (4)=""   ;reverse
 gColor$ (5)="";	Dark Red
 gColor$ (6)="";	Default Green Necc??
 gColor$ (7)="";	Brown
 gColor$ (8)="";	Dark blue
 gColor$ (9)="";	Dark Purple
 gColor$ (10)="";	Dark Cyan(teal)
 gColor$ (11)="";	 light grey/light white
 gColor$(12)="" ;Grey
 gColor$(13)="";Bright Red
 gColor$(14)="";Bright green
 gColor$(15)="";Bright Yellow
 gcolor$(16)=""; Bright Blue
 gcolor$(17)=""; Bright Purple
 gcolor$(18)="";Bright cyan
 gcolor$(19)="";Bright White
Const Menu=1
Const NewChar1=2
Const NewChar2=3
Const Newchar3=4
Const Newchar4=5
Const PlayChar1=6
Const PlayChar2=7
Const Playing=8
Const Logoff=9
Const VwHelp=10
Const SelSex=11
Const SelRace=12
Const SelClass=13

Print "MDB-MUD Demo Version 1**************
Print "Programmed in Blitz Basic! ************"
Print "Written by Michael D. Boruta II*******"
Print "*******************************"

server=CreateTCPServer(4000)
If Not server Then
Print "Server Failed to start on port 4000!"
Print "terminating Program!...sorry!"
Delay 1000
End
Else
Print "Server started! Telnet to port 4000 to play!"
Print "*Now Listening for *Connections**"
Print "Hit the ESCAPE KEY to Shutdown MDB-MUD!"
EndIf

;eLoadAreas

a=0
areafile=OpenFile("c:\mdbmud\areas.dat")

If areafile Then
While Not Eof(areafile)
b$=ReadLine(areafile)
;Print b$+"file found"
a=a+1
Wend
CloseFile(areafile)
Else
Print "Areas.dat not found, terminating program"
Delay 5000
End
EndIf
Print a
Dim area.area(a)
If a=>1 Then
c=1

areafile=OpenFile("c:\mdbmud\areas.dat")
;get Each areas name

While Not Eof(areafile)
b$=ReadLine(areafile)
Print "File name found: "+b$
area(c)=New area
area(c)\areaname$=b$
area(c)\areanumber=c
c=c+1
Wend

CloseFile(areafile)
d=c-1
For x=1 To d Step 1 
Print x
c=1
afile$=area(x)\areaname$+".dat"
curr_file=OpenFile("c:\mdbmud\"+afile$)
If curr_file Then
While Not Eof(curr_file)
b$=ReadLine(curr_file)
;Print x
area(x)\ro[c]=New room
area(x)\ro[c]\roomarea=x
area(x)\ro[c]\roomname$=b$
area(x)\ro[c]\roomnumber=c
area(x)\ro[c]\also$="Nobody";remove/replace when add in alsoheres!!!
b$=ReadLine(curr_file)
;Print "Rcolor="+b$
area(x)\ro[c]\rcolor=b$
For y=1 To 10
b$=ReadLine(curr_file)
;Print "Exit# "+y+" is "+b$
;if b$<>0 then
area(x)\ro[c]\roo[y]=New RExit
area(x)\ro[c]\roo[y]\ExitTo=b$
area(x)\ro[c]\roo[y]\ExitArea=1 ;change to allow for cross area exits
;EndIf
Next 
b$=ReadLine(curr_file)
;Print "exits$="+b$
area(x)\ro[c]\Exits$=b$
b$=ReadLine(curr_file)
c=c+1
Wend
EndIf
CloseFile(curr_file)
;Print "Loaded Area #"+x+" named: "+area(x)\areaname$
Next 
EndIf


Delay 200
;For ak.area=Each area
;Print ak\areaname$+"  -#"+ak\areanumber
;Next
;For rkx.room=Each room
;Print rkx\roomname$+"room number# "+rkx\roomnumber
;Next
;For rex.rexit=Each rexit
;Print rex\exitto +"<exitto - exitarea>"+rex\exitarea
;Next
;WaitKey()


;add loadrace
;add loadclass
;add loadmob
;add loadobjects

ckn=0
While Not KeyHit(1)
ckn=ckn+1
If ckn>200 Then
checknew
ckn=0
EndIf

readstream
;add tickcounter
;add regen/repop/hunger-thirst modifiier
;add weather
;Delay 100
Wend

Function checknew()
stream=AcceptTCPStream(server)
If stream Then
Print "*CONNECTION RECIEVED!*"
ucount#=ucount+1
x=ucount#
pl (x)=New Player
pl (x)\name$="Logon........................................................................................."
pl (x)\stream=stream
pl (x)\status=Menu
pl (x)\prace$="None"
pl (x)\pclass$="None"
pl(x)\sex$="None"
pl (x)\comm1$=""
pl (x)\comm2$=""
pl (x)\comm3$=""
pl (x)\comm4$=""
pl (x)\msg$=""
pl (x)\comm=1
pl (x)\PlayerId=x
For abc=0 To 19 Step 1
pl(x)\pc$[abc]=gcolor$(abc)
Next

;WriteLine pl (x)\stream, "X="+x+"Ucount="+ucount#+"name$="
;p.player=New Player
;p\name$="Logon........................................................................................."
;p\stream=stream
;p\status=Menu
;p\prace$="None"
;p\pclass$="None"
;p\comm1$=""
;p\comm2$=""
;p\comm3$=""
;p\comm4$=""
;p\msg$=""
;p\comm=1
WriteLine pl(x)\stream, Chr$(27)+"Welcome To MDB MUD!!!!"
WriteLine pl(x)\stream, "Initiating Color Test!"
For jk=0 To 18 Step 1
WriteLine pl(x)\stream, gColor$(jk)+"This is what color$("+jk+") does!"+""
Next

WriteLine pl(x)\stream, ""
DisplayMenu pl(x)
EndIf
End Function

Function readstream()
;Print "Case ReadStream  "+ucount#
For p.player=Each player
;Print p\name$+p\playerId
If Eof(p\stream) Then
p\status=Logoff
Else
If ReadAvail(p\stream) commandreader p
EndIf
If p\status=Logoff Logoff p
Next
End Function

Type player
Field pc$[20]
Field stream
Field PlayerId
Field status
Field level
Field name$
Field password$
Field curr_area
Field curr_room
Field recallArea
Field recallRoom
Field title$
Field pclass$
Field prace$
Field pracenumber ;?
Field pclassnumber;?
Field sex$
Field comm
Field comm1$
Field comm2$
Field comm3$
Field comm4$
Field msg$
Field experience#
Field baseexp#
Field exptnl#
End Type


Type area
Field areaname$
Field areanumber
Field ro.room[1000]
Field weather
End Type

Type room
Field roomname$
Field roomnumber
Field roomarea
Field Rcolor
Field roo.Rexit[11]
Field Exits$
Field Also$
Field ro2.alsohere[100]
Field ro3.lyinghere[100]
Field RoomLight
End Type

Type Rexit
Field Exitto
Field Exitarea
End Type

Type alsohere
Field Alsoname$
Field AlsoType
End Type

Type lyinghere
Field lyingname$
Field LyingType
End Type


Function commandreader(p.player)
x=p\comm
While ReadAvail(p\stream)
b=ReadByte(p\stream)
If b=32 Then 
If x=5 p\msg$=p\msg$+Chr$(32)
Select True
Case p\comm=1
	If p\comm1$<>"" Then
	p\comm=2 
	 x=x+1
	EndIf
Case p\comm=2
	If p\comm2$<>"" Then
	p\comm=3 
	 x=x+1
	EndIf
Case p\comm=3
	 If p\comm3$<>"" Then
	 p\comm=4 
	 x=x+1
	EndIf
Case p\comm=4
	If p\comm4$<>"" Then
	p\comm=5
	 x=x+1
	EndIf
End Select
EndIf

;if b=34  " And comm=2  And p\comm2$=""Then skip add quotes
;if chr$=" and comm=2 and p\comm2$<>"" then comm=3, next comm$
If x>5 x=5
If b>32 Then
If x=1 p\comm1$=p\comm1$+Chr$(b)
If x=2 p\comm2$=p\comm2$+Chr$(b)
If x=3 p\comm3$=p\comm3$+Chr$(b)
If x=4 p\comm4$=p\comm4$+Chr$(b)
If x=5 p\msg$=p\msg$+Chr$(b)
EndIf
If b=13 selectstatus p
Wend

End Function
Function Gossip(p.player)
	For a.player=Each player
	If a\name$=p\name$ Then
	WriteLine p\stream, "You gossip: "+p\comm2$+" "+p\comm3$+" "+p\comm4$+Chr$(32)+p\msg$
	Else
	WriteLine a\stream, p\name$+" gossips: "+p\comm2$+" "+p\comm3$+" "+p\comm4$+Chr$(32)+p\msg$
	EndIf
	Next
End Function

Function DisplayMenu(p.player)
 	WriteLine p\stream, ""
	WriteLine p\stream, ""
	WriteLine p\stream, ""
	WriteLine p\stream, "             Main Menu:"
	WriteLine p\stream, "             *********************"
	WriteLine p\stream, "             *                   *"
	WriteLine p\stream, "             * (P)lay Character  *"
	WriteLine p\stream, "             *                   *"
	WriteLine p\stream, "             * (N)ew Character   *"
	WriteLine p\stream, "             *                   *"
	WriteLine p\stream, "             * (W)hos Online     *"
	WriteLine p\stream, "             *                   *"
	WriteLine p\stream, "             * (V)iew Helpfiles  *"
	WriteLine p\stream, "             *                   *"
	WriteLine p\stream, "             *********************"
	WriteLine p\stream, "             *                   *"
	WriteLine p\stream, "             * Your Command:___  *"
	WriteLine p\stream, "             *                   *"
	WriteLine p\stream, "             *********************"
	WriteLine p\stream, "  "
	WriteLine p\stream, "Only New Char works right now...btw"
End Function

Function SelectStatus(p.player)
	Select True
	Case p\status=Playing
	playing p
	Case p\status=Menu 
	Menu p
	Case p\status=NewChar1
	 SelectName p
	Case p\status=NewChar2
	 SelectPassword p
	Case p\status=NewChar3 
	VerifyPassword p
	Case p\status=PlayChar1
	 ValidateName p
	Case p\status=Playchar2 
	Validatepassword p
	Case p\status=Selsex
	SelectSex p
	Case p\status=SelRace
	SelectRace p
	Case p\status=SelClass
	selectclass2 p
	End Select
	If p\stream Then
	p\msg$=""
	p\comm=1
	p\comm1$=""
	p\comm2$=""
	p\comm3$=""
	p\comm4$=""
	p\msg$=""
	EndIf
End Function

Function SelectSex(p.player)
;j=Len(p\comm1$)
;Print j+j+j
;If j>1 Then
;command$=Left$(p\comm1$,2)
;EndIf
comx$=p\comm1$
comx$=Lower(comx$)
j=Len(comx$)
If j>1 Then comx$=Left$(comx$,1)
;Print comx$
;Print comx$+":"+command$+"p\comm$="+p\comm1$
;WriteLine p\stream, "command:  "+comx$
If comx$="m" Then 
WriteLine p\stream, "Male Selected!"
p\sex$="Male"
p\status=SelRace
DisplayRace p
EndIf
If comx$="f" Then
WriteLine p\stream, "Female Selected"
p\sex$="Female"
p\status=SelRace
DisplayRace p
EndIf
If p\sex$="None" Then
WriteLine p\stream, "You can only be female, or male, please select again"
EndIf
End Function

Function Playing(p.player)
x=0
command$=p\comm1$
command$=Lower$(command$)

n#=Len(command$)

Select True

Case command$=""
;replace area annd ro and roo
	WriteLine p\stream, area(p\curr_area)\ro[p\curr_room]\roomname$
	WriteLine p\stream, area(p\curr_area)\ro[p\curr_room]\exits$
	;WriteLine p\stream, area(p\curr_area)\ro[p\curr_room]\Ralso$
	x=1
Case command$="save"
	saveplayer p
	x=1
Case command$=Left$("title",n#) And n#>2
	ntitle$=""
	If p\comm2$<>"" ntitle$=ntitle$+p\comm2$
	If p\comm3$<>"" ntitle$=ntitle$+" "+p\comm3$
	If p\comm4$<>"" ntitle$=ntitle$+" "+p\comm4$
	If p\msg$<>"" ntitle$=ntitle$+" "+p\msg$
	;ntitle$=p\comm2$+" "+p\comm3$+" "+p\comm4$+" "+p\msg$
	;Print "ntitle$: "+ntitle$
	n#=Len(ntitle$)
	If n#>36 Then 
	ntitle$=Left$(ntitle$,36)
	EndIf
	p\title$=ntitle$
	;Print "p\title$"+p\title$
	If p\title$<>"" Then
	WriteLine p\stream, "You will be known as "+p\name$+" "+p\title$
	Else
	p\title$=""
	WriteLine p\stream, "You will be known as "+p\name$+" the nameless one!"
	EndIf
	x=1
	Case command$="area"
		;WriteLine p\stream, "You are in: "+area(p\curr_area)\areaname$+"  Area#"+p\curr_area
		;WriteLine p\stream, "Room number "+p\curr_room+"  "+area(x)\ro[p\curr_room]\roomname$
		x=1

Case command$="quit"
	p\status=Logoff
	x=1
Case command$="who"
	wholist p
	x=1
Case command$=Left$("recall",n#)
	p\curr_room=1
	WriteLine p\stream, "You recall back to Town Sqaure"
	x=1
	;add default to home recall/town sqaure
Case command$=Left$("help",n#)
	WriteLine p\stream, "Sorry, no Helpfiles have been added yet *sniff*"
	x=1
Case command$=Left$("gossip",n#) 
	gossip p
	x=1
Case command$=Left$("look",n#) 
	Case command$=Left$("look",n#) 
	WriteLine p\stream, "You look around...."
	x=1
	WriteLine p\stream, area(p\curr_area)\ro[p\curr_room]\roomname$
	WriteLine p\stream, "Exits: "+area(p\curr_area)\ro[p\curr_room]\exits$
	;WriteLine p\stream, areas(p\curr_area)\ro[p\curr_room]\Ralso$
Case command$=Left$("whois", n#) And n#>3
	commx2$=Lower(p\comm2$)
	Print commx2$
	k#=Len(commx2$)
	Print k#
	If k#>2 Then
	WriteLine p\stream, "Players found:"
	abc=0
	For plk.player=Each player
	namex$=Left$(plk\name$,k#)
	namex$=Lower(namex$)
	If commx2$=namex$ Then
	WriteLine p\stream, plk\name$+" "+plk\prace$+" "+plk\pclass$
	abc=abc+1
	EndIf
	Next
	WriteLine p\stream, "Players Found= "+abc
	Else
	WriteLine p\stream, "You must enter the first three letters of their name!"
	EndIf
	x=1
Case command$=Left$("tell",n#) And n#>1
	If p\comm3$<>"" Then
	sentmsg$=p\comm3$+" "+p\comm4$+" "+p\msg$
	Print sentmsg$
	commx2$=Lower(p\comm2$)
	Print commx2$
	K#=Len(commx2$)
	Print K#
	ck=0
	If K#>2 Then
	For plk.player=Each player
	namex$=Left$(plk\name$,k#)
	namex$=Lower(namex$)
	If commx2$=namex$ Then
	ck=1
	WriteLine p\stream, "You tell "+plk\name$+" "+Chr$(34)+sentmsg$+Chr$(34)
	WriteLine plk\stream, p\name$+" telepaths you "+plk\pc[11]+Chr$(34)+sentmsg$+Chr$(34)+" "+p\pc$[0];+add color/reset color at end
	EndIf
	Next
	If ck=0 WriteLine p\stream, commx2$+" could not be reached!"
	Else
	WriteLine p\stream, "You must include 3 or more letters of their name!"
	EndIf
	Else
	WriteLine p\stream, "You can't send them a blank line!"
	EndIf
	x=1
;end all commands******************************************

Case command$=Left$("color",n#) And n#>1
	x=1
	If p\pc$[0]="" Then
	For gc=0 To 19 Step 1
	p\pc$[gc]=gcolor$(gc)
	Next
	WriteLine p\stream, "COLORS ACTIVATED"
	Else
	For gc=0 To 19 Step 1
	p\pc$[gc]=""
	Next
	WriteLine p\stream, "COLORS DISABLED"
	EndIf

Case command$=Left$("cast",n#)
	x=1
	a=0
	o=Len(p\comm2$) 
	If o=0 Then 
	o=1
	WriteLine p\stream, "Cast What? You need to speak words silly!"
	a=1:x=1
	EndIf
	If p\comm2$=Left$("fireball",o) Then
	WriteLine p\stream, "Your fireball "+gcolor$(13)+"***DEVESTATES***"+gcolor$(0)+" someone!!!"
	a=1:x=1
	EndIf
	If  p\comm2$=Left$("gate",o) Then 
	WriteLine p\stream, "You attempt to gate out but fail!"
	a=1:x=1
	EndIf
	If p\comm2$="" Then
	WriteLine p\stream, "Cast what silly? You must specify a spell...."
	EndIf
	If a=0 Then WriteLine p\stream, "You don't know the spell "+p\comm2$
	Case command$=Left$("north",n#)
	DIR=1
	moveplayer p
	Case command$=Left$("south",n#)
	DIR=2
	moveplayer p
	Case command$=Left$("west",n#)
	DIR=3
	moveplayer p
	Case command$=Left$("east",n#)
	DIR=4
	moveplayer p
	Case command$=Left$("northeast",n#) And n#>5
	DIR=5
	moveplayer p
	Case command$=Left$("northwest",n#) And n#>5
	DIR=6
	moveplayer p
	Case command$="ne"
	DIR=5
	moveplayer p
	Case command$="nw"
	DIR=6
	moveplayer p
	Case command$=Left$("southeast",n#) And n#>5
	DIR=7
	moveplayer p
	Case command$=Left$("southwest",n#) And n#>5
	DIR=8
	moveplayer p
	Case command$="se"
	DIR=7
	moveplayer p
	Case command$="sw"
	DIR=8
	moveplayer p
	Case command$=Left$("up",n#)
	DIR=9
	moveplayer p
	Case command$=Left$("down",n#)
	DIR=10
	moveplayer p
	
	End Select
	If x<>1 Then WriteLine p\stream, "Sorry, that command does not exist"	
End Function

Function Menu(p.player)
If p\comm1$<>"" Then
command$=Left(p\comm1$,1)
EndIf
If command$="n" Then
WriteLine p\stream, "Please choose your name:  "
p\status=NewChar1
EndIf
If command$="w" wholist p
If command$="v" Then
WriteLine p\stream,  "Sorry no helpfiles have been added yet!"
EndIf
If command$="p" Then
WriteLine p\stream,  "What is your characters name?  "
p\status=Playchar1
EndIf
End Function

Function SelectName(p.player)
x=1
name$=p\comm1$
name$=Lower(name$)
j#=Len(name$)
j#=j#-1
temp$=Right$(name$,j#)
ka$=Left$(name$,1)
ka$=Upper(ka$)
p\name$=ka$+temp$
n=Len(p\name$)
;RemCheck Pfile Already Exists
cfile$=p\name$+".dat"
curr_file=OpenFile("c:\mdbmud\"+cfile$)
If curr_file
WriteLine p\stream, "Sorry That Name Is Already Taken...Try again"
x=0
Else
If n<3 Then
x=0
WriteLine p\stream, "Sorry, your name must be at least 3 characters long...please try again"
EndIf
If n>15 Then
x=0
WriteLine p\stream, "Sorry, your name must be 15 or less characters in length...please try again"
EndIf
If curr_file<>0  CloseFile(curr_file)
EndIf

If x=1 Then
WriteLine p\stream, "Welcome  to MDB MUD!!!"+p\name$
Print p\name$+" has logged on!!!"
WriteLine p\stream, "What password would you like?  "
p\status=NewChar2

EndIf
End Function

Function SelectPassword(p.player)
n=Len(p\comm1$)
If n<3 Then 
WriteLine p\stream, "sorry your password must have at least 3 letters, please reenter"
WriteLine p\stream, "Password?:  "
p\comm1$=""
EndIf
If n>15 Then
p\comm1$=""
WriteLine p\stream, "sorry, you4r password must be less then 15 characters, please reenter"
WriteLine p\stream, "Password?:  "
EndIf
If p\comm1$<>"" Then
p\password$=p\comm1$
WriteLine p\stream,  "Please Verifty that your password is:  "+p\password$+"!"
p\status=NewChar3
EndIf
End Function

Function VerifyPassword(p.player)
;add min 3 chars, max 12 characters and no spaces
If p\comm1$=p\password$ Then
WriteLine p\stream,"Password Verified...."
WriteLine p\stream, ""
WriteLine p\stream, "Are you male or female? "
p\status=SelSex
Else
WriteLine p\stream, "Sorry the passwords did not match, please try again!"
p\password$=""
p\status=NewChar2
WriteLine p\stream, "Please try another password:"
EndIf
End Function

Function Validatename(p.player)
k=1
xcomm1$=Lower(p\comm1$)
For pk.player=Each player
name$=Lower(pk\name$)
If name$=xcomm1$ Then
k=2
Exit
EndIf
Next
name$=xcomm1$

Print name$+"  k="+K
If k=2 Then
WriteLine p\stream, "Sorry, "+xcomm1$+" is already playing"
displaymenu p
p\status=MENU
Else 
cfile$=xcomm1$+".dat"
;cfile$=Lower(cfile$)
curr_file=OpenFile("c:\mdbmud\"+cfile$)
If curr_file Then
d$=ReadLine(curr_file)
p\password$=d$
Print d$+"xx"
WriteLine p\stream, "Password? "
p\status=PLAYCHAR2
tname$=p\comm1$
j#=Len(tname$)
j#=j#-1
temp$=Right$(tname$,j#)
ka$=Left$(tname$,1)
ka$=Upper(ka$)
p\name$=ka$+temp$
Else
WriteLine p\stream, p\comm1$+" was not found as a player, please try again"
displayMenu p
p\status=MENU
EndIf
EndIf
If curr_file CloseFile(curr_file)
End Function

Function Validatepassword(p.player)
If p\comm1$=p\password$ Then
WriteLine p\stream, "Password Verified"
WriteLine p\stream, "Welcome Back "+p\name$
Print p\name$+" has Logged! on"
p\status=PLAYING
startup p
Else
WriteLine p\stream, "Password Incorrect, please try again!"
WriteLine p\stream, "    "
p\status=MENU
p\name$="LOGON...................................................."
p\password$=""
displaymenu p
EndIf
End Function

Function Startup(p.player)
	p\curr_room=1
	p\curr_area=1
	WriteLine p\stream, "This is a test server, Races,Classes, Areas, etc are not in yet"
	WriteLine p\stream, "The following commands are in:"
	WriteLine p\stream, "quit recall who gossip title look* help* cast* (fireball/gate try)" 
	WriteLine p\stream, "Look,Help, and cast are not complete either"
	WriteLine p\stream, "Please enjoy the game, hopefully will soon be completed"
	WriteLine p\stream, "New areas, etc etc will always be added...Thank you for playing!"
	;WriteLine p\stream, "You Are in: "+areas(p\curr_area)\areaname$
	;WriteLine p\stream, "You are standing in: "+areas(p\curr_area)\ar [p\curr_room]\roomname$
	;WriteLine p\stream, areas(p\curr_area)\ar [p\curr_room]\Rexits$
	;WriteLine p\stream, areas(p\curr_area)\ar [p\curr_room]\RAlso$
End Function

Function logoff(p.player)
	;If not Eof(p\stream)
	;Print p\name$+" has logged off!"
	;WriteLine p\stream, "GOODBYE!...come back soon!"
	;EndIf
	;CloseTCPStream(p\stream)
	;Delete p
	;rem end first start
	If Not Eof(p\stream)
	Print p\name$+" has logged off!"
	WriteLine p\stream, "GOODBYE!...come back soon!"
	CloseTCPStream(p\stream)
	EndIf
	jhk=p\playerID
	;Print "player id deleteing: "+jhk
	For x=1 To ucount# Step 1
	If pl(x)\playerid>jhk Then
	k=x-1
	stream=pl(x)\stream
	pl (k)\stream=stream
	;Print "player_id"+pl(x)\playerID+" larger Then A!="+a
	pl(k)\playerid=pl(x)\PlayerId-1
	pl(k)\status=pl(x)\status
	pl(k)\level=pl(x)\level
	pl(k)\name$=pl(x)\name$
	pl(k)\password$=pl(x)\password$
	pl(k)\password$=pl(x)\Curr_Area
	pl(k)\curr_room=pl(x)\curr_room
	pl(k)\title$=pl(x)\title$
	pl(k)\pclass$=pl(x)\pclass$
	pl(k)\prace$=pl(x)\prace$
	pl(k)\pracenumber=pl(x)\pracenumber ;?
	pl(k)\pclassnumber=pl(x)\pclassnumber;?
	pl(k)\sex$=pl(x)\sex$
	pl(k)\comm=pl(x)\comm
	pl(k)\experience#=pl(x)\experience#
	pl(k)\baseexp#=pl(x)\baseexp#
	pl(k)\exptnl#=pl(x)\exptnl#
	EndIf
	Next
	;Print "Deleting player# "+ucount#
	Delete pl(ucount#)
	ucount#=ucount#-1
	;Print "End Logoff"
End Function

Function Wholist(p.player)
	WriteLine p\stream, "Players found:"
	c#=0
	For a.player=Each player
	c#=c#+1
	WriteLine p\stream, "Level: "+p\level+"   "+a\name$+"   "+a\title$+"    "+a\playerID
	Next
	WriteLine p\stream, "Total players found:  "+c#
	WriteLine p\stream, "Total players online:  "+ucount#
End Function


Function SelectRace(p.player)
x=0
If p\comm1$="1" Then 
WriteLine p\stream, "You are now Human"
x=1
p\prace$="Human"
p\status=SelClass
EndIf
If p\comm1$="2" Then
 WriteLine p\stream, "You are now an Ogre"
x=1
p\status=SelClass
p\prace$="Ogre"
EndIf
If p\comm1$="3" Then 
WriteLine p\stream, "You are now an Elf"
x=1
p\status=Selclass
p\prace$="Elf"
EndIf
If p\comm1$="4" Then
WriteLine p\stream, "You are now a Halfling"
x=1
p\status=Selclass
p\prace$="Halfling"
EndIf
If p\comm1$="5" Then
WriteLine p\stream, "you are now a Minotaur"
x=1
p\status=SelClass
p\prace$="Minotaur"
EndIf
WriteLine p\stream, " "
If x<>1 Then
WriteLine p\stream, "That is not a valid race, please try again..."
Else
DisplayClass p
EndIf
;WriteLine p\stream, "You are now a "+p\prace$
End Function

Function DisplayRace(p.player)
	WriteLine p\stream, " "
	WriteLine p\stream, "        1. Human"
	WriteLine p\stream, "        2. Ogre"
	WriteLine p\stream, "        3. ELf"
	WriteLine p\stream, "        4. Halfling"
	WriteLine p\stream, "        5. Minotaur"
	WriteLine p\stream, " "
End Function

Function SelectClass2(p.player)
	command$=p\comm1$
	x=0
	If command$="1" Then
	p\pclass$="Druid"
	x=1
	EndIf
	If command$="2" Then
	p\pclass$="Mystic"
	x=1
	EndIf
	If command$="3" Then
	p\pclass$="Mage"
	x=1
	EndIf
	If command$="4" Then
	p\pclass$="Bard"
	x=1
	EndIf
	If command$="5" Then
	p\pclass$="Rogue"
	x=1
	EndIf
	If x<>1 Then 
	p\baseexp#=1000
	p\exptnl#=p\baseexp#
	p\level=0
	WriteLine p\stream, "Sorry that is not a valid class, please choose again...."
	Else
	WriteLine p\stream, ""
	WriteLine p\stream, "You are now a "+p\pclass$
	p\curr_room=1
	p\curr_area=1
	WriteLine p\stream, "You are now playing
	p\status=playing
	p\experience#=0
	p\RecallArea=1
	p\RecallRoom=0
	p\curr_area=1
	p\curr_room=1
	startup p
	EndIf
End Function

Function DisplayClass(p.player)
	WriteLine p\stream, "The Following Classes are Available..."
	WriteLine p\stream, " "
	WriteLine p\stream, "          1. Druid"
	WriteLine p\stream, "          2. Mystic"
	WriteLine p\stream, "          3. Mage"
	WriteLine p\stream, "          4. Bard"
	WriteLine p\stream, "          5. Rogue"
	WriteLine p\stream, " "
	p\status=SelClass
End Function

Function SavePlayer(p.player)
	file$=p\name$+".dat"
	curr_file=OpenFile("c:\mdbmud\"+file$)
	If Not curr_file Then
	DeleteFile("c:\mdbmud\"+file$)
	Else
	CloseFile(curr_file)
	EndIf
	curr_file=WriteFile("c:\mdbmud\"+file$)
	WriteLine curr_file,p\password$
	WriteLine curr_file,p\prace$
	WriteLine curr_file,p\pclass$
	CloseFile(curr_file)
	WriteLine p\stream, "Your Character has been Saved!"
	Print p\name$+" pfile has been saved!"
End Function

Function MovePlayer(p.player)
	abc=1 ;check for if room/area exist
	old_area=p\curr_area
	old_room=p\curr_room
	new_area=old_area
	;new_area=area(p\curr_area)\ro[p\curr_room]\roo[dir]\ExitArea
	;Print area(p\curr_area)\ro[p\curr_room]\roo[dir]\Exitto

	;new_room=area(p\curr_area)\ro[p\curr_room]\roo[dir]\Exitto
	;If area(new_area)=Null Then abc=2
	;If area(p\curr_area)\ro[p\curr_room]=Null Then abc=2
	;If abc=1 Then
	
	;print "area: "+p\curr_area+" room: "+p\curr_room+" direction:  "+dir
	If area(p\curr_area)\ro[p\curr_room]\roo[dir]\ExitArea<>0 Then
	p\curr_area=area(p\curr_area)\ro[p\curr_room]\roo[dir]\ExitArea
	Else
	abc=2
	EndIf
	If area(p\curr_area)\ro[p\curr_room]\roo[dir]\Exitto<>0 Then
	p\curr_room=area(p\curr_area)\ro[p\curr_room]\roo[dir]\Exitto
	Else
	abc=2
	EndIf
	;Print abc
	
	;check stance
	;check if in combat
	;check if enough mvs
	;write to old room
	;delete old alsohere
	;write to new room
	;add new alsohere
	;check for aggy mobs
	If abc=1 Then
	WriteLine p\stream, "walking......"
	WriteLine p\stream, area(p\curr_area)\ro[p\curr_room]\roomname$
	
	;WriteLine all.alsohere
	WriteLine p\stream, area(p\curr_area)\ro[p\curr_room]\exits$
	;WriteLine p\prompt$?
	x=1
	Else
	WriteLine p\stream, "there is no exit in that direction!"
	WriteLine p\stream, area(p\curr_area)\ro[p\curr_room]\exits$
	abc=1
	x=1
	EndIf
End Function


;selskill
;selspell
;loadpfile
;savepfile



Damien Sturdy(Posted 2004) [#2]
What is it? :D


Sunteam Software(Posted 2004) [#3]
MUD = Multi User Dungeon.

I would take a look myself but I have my own projects to look after, but good luck in getting further with it :)


Dirk Krause(Posted 2004) [#4]
For what type of mud is this server?


Midnight(Posted 2004) [#5]
For what type of mud is this server?


The brown stuff.


Ok, so it's late and I'm tired.


Gauge(Posted 2004) [#6]
Its a text based mud server, like rom, diku, or merc. Never heard of them?


Dirk Krause(Posted 2004) [#7]
I have heard of them. But these usually have .are files. Yours is trying to load a .dat file, and I can't find any example for these.


Eikon(Posted 2004) [#8]
[codebox][/codebox]


Tracer(Posted 2004) [#9]
hehe, i wrote some code to load .are files a long time ago in Blitz2D, it does a semi mud server as well :) .. 1600 lines or so :)

This is REALLY old tho.



I have no idea how far this works.. i think you can walk through the areas after you connect to the MUD.

I haven't ran this in years, so i have no idea how complete anything is.. it does load ARE files and check all the exits on the rooms. Oh, i think the ARE files needed are the original MERC mud ones.

[EDIT]
I ran it quick, yeah, it allows you to run around the loaded area files.

Tracer


Gauge(Posted 2004) [#10]
My apologies...i didn't know about the codebox thing, thanks.

Tracer, I got an error with every .are file i tried, but it looks nice, do you have an .are file it works with? i think theres a few different formats.

Heres a few small .dat files that will get my code to work, well as much as it does:

make areas.dat with 1 line of text, blank lines btw
newhaven

then make newhaven.dat with the following text:
Town Sqaure
1
2
3
0
0
0
0
0
0
0
0
North,South

North Market
5
0
1
0
0
0
0
0
0
0
0
South

South Market
3
1
0
0
0
0
0
0
0
0
0
North

*again no blank, lines, etc

areas.dat needs to only include the area name, the default loadares is this:

roomname$
roomcolor
exitnorth
exitsouth
exiteast
exitwest
exitne
exitnw
exitse
exitsw
exitup
exitdown
exits$

with a blank line between them,o means no exit, a numbe will refer to the room# the exits to. I need alot of work on this.

loadraces and loadclasses isn't really supported yet. But those files should get the program to work. saving is disabled and doesn't save everything. so thats it for now, am still working on it though. Already added alsohere so you can see the people in the room, and when they leave and exit. And a few other things.


Tracer(Posted 2004) [#11]
Sure, here's two areas, i think they are the standard Merc files.

Midgaard and School area files

Copy them into a directory called "Areas" by the MUD thing source, also create a "Players" directory by the source, as that's where new players are stored.

Tracer