Community Project for Networking RPG

Blitz3D Forums/Blitz3D Beginners Area/Community Project for Networking RPG

chrisnorris007(Posted 2009) [#1]
I am proposing a concept to produce a networked RPG (in order to learn fundamentals of what everyone has been asking such as chasecams, sound, network code) etc ... this project will allow everyone to contribute as well as learn concerning physics and all

just an idea..what does everything else think?

I am willing to post my project as the shared project..not a problem..also learning to model in blender


Ross C(Posted 2009) [#2]
I think it's doomed to failure. I'm not trying to be negative, but i've been around here a while and i've seen community projects come and go, largely unfinished. In fact, "Bounce Around" was the only one i can remember being sucessful.

You need for a start, a good experienced coder to take the helm and command the project and carry it when no-one else can, so it doesn't get stuck. You also need to assign people specific tasks to individuals, coding wise and art too, else you get all sorts of different styles.

I can't stress enough though, you need people who are decent coders for this to work, else you'll get someone doing physics and making a complete arse of it, not designing code so other people can read it and not making the code "plugable" so it can be removed without too much hassle.

You should try, something very simple, for a community project, just to get the feel for it and get it finished, than move up from there. RPG's generally take years to develop, with teams of people.


GfK(Posted 2009) [#3]
I'd be fairly confident its doomed from the start.

Seen it happen a hundred times before. These things end up being no more than a big waste of everyone's time.


boomboom(Posted 2009) [#4]
Agree with the two above. Plus a lot of people use the guise of 'Community Project' to really mean 'Make my game for me', which is totally doomed.

If you really want to work in a team, the absolute best way to do so is teaming up with someone at your school, college, work, club...or just a friend and working together to make something, rather than forum people.


Nike(Posted 2009) [#5]
Im sorta new in programming but i think its a great idea. I tried to do a game with 5 friends at school and they all quit before i got to type the first line of code. As long as you work, ill help, and i learn how to program better!


Ross C(Posted 2009) [#6]
Ok. Maybe you should learn something a little easier. It will advance your knowledge more, than doing a task your probably not going to be able to complete. There is nothing better for your learning and confidence, than starting a project and actually finishing it. It teaches you the patience and estimation it takes, even for a simple game. You have stuff like front end graphics, GUI, high score tables, computer AI (even if it's very simple)

It might seem like a good idea to do an RPG, because that's your favourite game, but RPG's are incredibly time consuming and difficult games to program. There's a good chance all you'll learn is, "that was too hard"

I'm not trying to belittle you in any way, just give you the benefit of hindsight, and give you something you can achieve and enjoy when it's finished.


Mahan(Posted 2009) [#7]
Very similar toughs has been discussed in this forum thread:

http://blitzmax.com/Community/posts.php?topic=41442

To shorten up my consensus from the previous thread, do one if these options:

1.) Make your own simple MMORPG engine complete with a server, client, small working starter area, two professions etc to PoC-the code. Then start a public project and invite people to join in.

2) Join someone else that has done just that for example: http://www.planeshift.it/

If you still got lots of basic questions like how to get GUI, Billboarding or collisions etc. (looking at other threads) I'd strongly recommend you to take Ross Cs advise:


Maybe you should learn something a little easier.




_PJ_(Posted 2009) [#8]
(in order to learn fundamentals of what everyone has been asking such as chasecams, sound, network code)



Personally, I would advise looking at these separately first, in smaller sample exercises rather than a full-blown (and VERY complex) environment like a Network RPG.

Check out the snippets of various code archive threads that deal with these particular points and play around with putting them into simple working routines from which you can LATER incorporate into a game framework.

Not only will this allow you to learn as you go without getting bogged down with various other parts of the game-writing (for example, just making a front-end/menu system is a real pain for me when I'm eager to get stuck into the game itself :) )
but also, it allows you the possiblitiy of re-using and modifying the individual parts of the code for other projects or more suited to specific requirements.


GIB3D(Posted 2009) [#9]
You could do like me and instead of working on just one big project and sticking with it, you try to code something that you can see how it works in your head. If you get stuck on that project, think of something else you can code and start on it. If you're like me, you'll end up learning enough from all the other projects that you'll be able to work on the one(s) you were stuck on.

You just need to build up your coding "vocabulary" heh heh.


Ginger Tea(Posted 2009) [#10]
i agree with most of the above, especially the "make my game for me" school of thought

i knew this 'moron' who was a project butterfly when it came to writing and the first hint of constructive critisism normally ened with him ripping up what he had done and throwing it away instead of taking on the advice i gave
one project was a script which he had no plot outline for, so in the end it would just be nothing but people talking aimlessly
i told him
get a story idea, block it out then work out what they are going to say
but in the end all he had was
"the opening credits of family packing luggage into car and driving to the chunnel and coming out the other end play out to the duration of this specific song"

so 'block it' do mini bits of code that work which can work anywhere

i used to paraphrase from pong to quake the evolution of video games
it starts with pong
flips the bat into break out
"wouldnt it be cool if the bricks moved and shot back" voila space invaders
3 games with similar traits

then guantlet and clones one spectrum ww2 themed one, with the aid of 2.5D (not my prefered choice of term) it became wolfenstein
the game was still a 2d game at heart

chess chequers and reversi all use an 8*8 grid and an array would be ideal for working out each game
a larger aray and you could do shogi (japanese chess)
go although played on the lines is still the same concept

learn how to do little things
learn how to make a chace cam?
you dont need a game to do that, just a simple cube would do and keys to move said cube and others to move the camrea around if you so wish, hell id even map them to a 360 joypad too just to know that i could add it to a game should a player wish to use a game pad over wsad etc


Blitzplotter(Posted 2009) [#11]
I agree with Malice and GIA_Green_Fire - once you get some way down the road you might want to consider some of the physics engines available to remove some of the awkward math you may have heartache with.

Wings posted some pretty good networking code a while back that I developed a 'little', however my interest went off the boil, I'll get back to it some day... maybe.

The code was in Blitz 3D to boot.


AJ00200(Posted 2009) [#12]
Ill help.
If the origonal poster could post back.
Weel need an easy way to share the code because it will get really long.


AJ00200(Posted 2009) [#13]
For file sharing, we could use Live Mesh
www.mesh.com
Live Mesh syncs files across computers, and stores them on a server.

Is anyone in?


chrisnorris007(Posted 2009) [#14]
sounds good to me...tell me a little about your background and strengths.
I am a software architect with major casinos.

chris


AJ00200(Posted 2009) [#15]
Don't do professional programming, its more of a hobby.
I also can make websites if we want one.
I'm best at coding, and OK with graphics (as far as using Window's paint goes.)
I like programming AIs, and I'm OK with networking.

I have some plans already drawn out for levels.
Midevil based.
Intense action w/ a sword/bow.
Short <15min levels.
For networking,
2 player co-op, and extra online level installs.


AJ00200(Posted 2009) [#16]
Ill send you the mesh.com invite soon, so have it installed.


AJ00200(Posted 2009) [#17]
If anyone else wants to join, post your email here, and make sure you have Microsoft Live Mesh (www.mesh.com) installed.


j-man(Posted 2009) [#18]
I'm in
scotty42 at gmail.com


AJ00200(Posted 2009) [#19]
OK, j-man, I sent you the invite email.
Share the updates in the news sidebar, and notes folder.


Nike(Posted 2009) [#20]
Im going to download mesh right now. my email is --------------------


AJ00200(Posted 2009) [#21]
Sorry I didn't get that last night. (Can other people send the invite? I don't know, because they didn't make the folder, but I did give them Owner permissions.)


I'll get it to you in 2 hours if you dont already have it.


AJ00200(Posted 2009) [#22]
I can do some of the music.
Im not a pro composer, so don't complain.
I wrote some good songs over the years, so I use them here


AJ00200(Posted 2009) [#23]
Is it just me, or are other people going to join in with the development?
I don't want to do this by myself


Nike(Posted 2009) [#24]
I just took my e-mail off because i just got 340 spam.


AJ00200(Posted 2009) [#25]
That's fine.
I already sent you the invite.


AJ00200(Posted 2009) [#26]
Are we doing this or what?


Nike(Posted 2009) [#27]
I will start working on this in about two and a half weeks when I go home because im on vacation. I can barley get internet so im lucky I can post this.


Guy Fawkes(Posted 2009) [#28]
Yes, and make it so u can create whatever magic abilities (particles), and attach them to any joint or bone in mesh :)


Blitzplotter(Posted 2009) [#29]
Has there been any consideration to using a physics lib ? There is some excellent tutorials in B3D which code 'from the ground up', i.e. projectiles in B3D, but physics libs make life so much easier.


Guy Fawkes(Posted 2009) [#30]
Use Physx, dude.


AJ00200(Posted 2009) [#31]
Do you 2 want in?
I can send the invites.


AJ00200(Posted 2009) [#32]
Is anyone still in?


Guy Fawkes(Posted 2009) [#33]
i think u should join ckob's community project :)

i think u would do excellent with it :)


WildCat(Posted 2009) [#34]
Why I do not see any code here, guyz? :) You want to build a kind of networked RPG framework - well, give us at least declarations. Of course, it has a value in way if it's going to be in a fully modular (pluggable?) style. It can be very simple, even naive, why not? Just a set of objects that work together and tell 'put your meshes here, maps there and all of other stuff right in that directory'... Like this:

Type TPlayer
	Field name$
	Field pivot
	Field mesh
End Type

Function TPlayerNew.TPlayer (name$, meshFile$, parent)
	pl.TPlayer = New TPlayer
	pl\name$ = name$
	pl\pivot = CreatePivot (parent)
	pl\mesh = LoadAnimMesh (meshFile, pl\pivot)
	Return pl
End Function

Who's next? :)


AJ00200(Posted 2009) [#35]
EDIT: There's no code because we're using Microsofft Live Mesh to share files (hard to keep files up ti date with only form/email.


Wings(Posted 2009) [#36]
what shold we use udp or tcp ?


RGF(Posted 2009) [#37]
I've been playing around with b3d since 2001. I had previous programming and art skills, since old amiga days. I recently managed to finish coding a generic RPG program (without any graphic work, all there is: moving cubes, a 3rd person smart camera system, sprites, enemys with some AI, rectangles instead of grids in inventory, etc...) that could be a solid base for further development, fully tested and with no errors...

Now I'm plugging in the network parts, which is, by far, the most difficult task, trying to make it work in my local network...

Just here to post some advice:

1) b3d is the most open language for programming games. If you ever feel tempted by other engines (let's say torqxx, gamestudxx...), keep up with b3d.

2) learn about each aspect of the project separatedly. As Ross said, make it pluggable.

3) maintain a logic structure in the program -Otherwise you'll end up messing with 32.000 lines of code- From a main code, call functions. Modify these functions. Fully understand TYPES, POINTERS, and ARRAYS

4) code the game first without graphics. Just moving cubes and sprites. Dont be seduced too soon for particle-systems and realtime shadows. First make it work with cubes.

5) learn maths. Avoid b3d collision system. Code your own pseudo-Physics routines, as 3rd. party physics are not always what you need for yor game. Remember:

dx#=(x-EntityX())
dy#=(y-EntityY())
dz#=(z-EntityZ())
l#=Sqr(dx*dx+dy*dy+dz*dz)
dx=dx/l
dy=dy/l
dz=dz/l
TranslateEntity e\mesh,dx,dy,dz

will be always faster!

If you don't know what this is for, draw a triangle and remember trigonometry.

5) the first thing you need to set-up is a decent gui, inventory system, and character abilities: strength, dexterity, intelligence, health, mana, xp points, how to level-up etc... Decide how it is going to work!, Interface and movement and point and click routines

6) MAKE USE OF THIS FORUMS, LEARN FROM THE COMMUNITY. SOME PEOPLE HERE ARE AWESOME MINDS! I've learned everything from people posting here, and sharing code archives. Here, there will be always an answer to your questions! This community is what makes blitz one of the best programming languages.

7) b3d rocks!

My RPG code isn't public domain. So I cannot offer you the original code, but if you want to contact me via this forum


WildCat(Posted 2009) [#38]
By the way, what's wrong with Blitz3D's collision system? Why to avoid it? What do you offer instead?


Ross C(Posted 2009) [#39]
I prefer to use linepicks, when working with character collisions, along with the blitz collision system. It lets you know more about what your hitting. It's especially useful for jumping code, because you can direct the pick downwards, to detect land beneath the feet, before you collide.


RGF(Posted 2009) [#40]
@ WildCat: Nothing wrong, if you want to check collisions only between moving and stationary objects. But when you have lots of moving objects colliding, they'll finally slide into each other.

Check out Jeppe Nielsen's method posted somewhere in code archives. Uses basic trigonometry, and never fails


AJ00200(Posted 2009) [#41]
UDP for position updates,
TCP for messages/enemy deaths... everything else


chrisnorris007(Posted 2009) [#42]
ok been a little occupied ill post everything i have...
i wrote an entire client in blitz and the server in perl

here they are: let me know what you think....the assets arent included send me an email to destinedforthethrone@... and ill send the entire zip.

Graphics3D 1024,768,32,2
SetBuffer BackBuffer ()
Type CSys
Field cx#, cy#, cz#
Field mx#, my#, sps%
End Type
Global CHATENABLED=0
Dim splitdata$(10)
; collision determinators

Dim actors(50)

Global water=CreatePlane()
Global seabottom=CreatePlane()
sbtex=LoadTexture("media\seabottom.jpg")
EntityTexture seabottom,sbtex
EntityColor seabottom,10,10,10
MoveEntity seabottom,0,1,0

Global centerpivot=CreatePivot()
Global nogravity=0
Global noserver=0
Global txt$
Global fps = 30
Global send_freq=2 ;send every fifth update
Global networked=0
Global playedoutsplash

Dim splitdata$(1)
SeedRnd MilliSecs()

; INCLUDE SPRITE CANDY (FIRST)
Include "sprite candy.bb"

; INCLUDE GUI EXTENSION (SECOND)
Include "sprite candy gui.bb"

Global my_status$
Global play.player
Global enem.enemy
Global message$
Global msg$
Global client_id$
Global me_net

Type ChaseCam
Field entity,camera,target,heading,sky
End Type

Type Player
Field psa
Field inwater
Field sprite
Field nameabove
Field aniseq#
Field animframe#
Field stream
Field model
Field Entity%
Field Name$
Field netid
Field pX#
Field pY#
Field pZ#
Field RX#
Field RY#
Field RZ#
Field yvel#
Field update,ready
Field anim_speed#, player_y#, roll#
Field tex
End Type

Type enemy
Field psa
Field inwater
Field sprite
Field nameabove
Field aniseq#
Field animframe#
Field stream
Field model
Field Entity%
Field Name$
Field netid
Field pX#
Field pY#
Field pZ#
Field RX#
Field RY#
Field RZ#
Field yvel#
Field update,ready
Field anim_speed#, player_y#, roll#
Field tex
End Type

send_ct=1

Global player_model
Global enemy_model
Global water_level=0

Global light,castle,land,ground,sky

Global playercount
light=CreateLight()

setupworld()
name$=Input("what is your name?")
AppTitle "Alternate Realities client Test: " + name$

ip$="ar.game-host.org"
port=9000
Global stream=OpenTCPStream(ip$,port)
If stream=0
Print "could not connect to server...ending now"
Print "press a key to continue"
WaitKey()
End
Else

split(ReadLine(stream))

play.player=createplayer(-445.416,30.0973,290.456)
EntityType play\entity,C_Hero
enem.enemy=createenemy(55,8,5)

playercount=Int(splitdata$(1))
play\netid=Int(splitdata$(2))
play\name$=name$

networked=1

Print "You are playerid:"+play\netid+" and there are currently " + playercount + " players connected"
WaitKey()

EndIf

;ExtractAnimSeq(play\model,2,82)
;ExtractAnimSeq(play\model,84,265)
Global attack=ExtractAnimSeq(play\model,162,181)
Global walk=ExtractAnimSeq(play\model,3,15)
DebugLog walk
DebugLog swim
play\stream=stream

If networked=1 And playercount>1
WriteLine(play\stream,88+","+play\netid+","+EntityX(play\entity)+","+EntityY(play\entity)+","+EntityZ(play\entity)+","+EntityPitch(play\entity)+","+EntityYaw(play\entity)+","+EntityRoll(play\entity)+",1,1,"+name$) ; notify new player of all existing player
If ReadAvail(stream)
For ct=1 To playercount-1
p.player=createplayer(-445.416,30.0973,290.456)

Line$=ReadLine(stream)
split(Line$)
p\netid=Int(splitdata$(2))
p\px=Float(splitdata$(3)):p\py=Float(splitdata$(4)):p\pz=Float(splitdata$(5)):p\rx=Float(splitdata$(6)):p\ry=Float(splitdata$(7)):p\rz=Float(splitdata$(8))
p\Aniseq=Int(splitdata$(9)):p\animframe=Int(splitdata$(10)):p\name$=splitdata$(11)
p\stream=stream
PositionEntity p\entity,p\px,p\py,p\pz,1
RotateEntity p\entity,p\rx,p\ry,p\rz

p\Sprite = CreateSprite()
ScaleSprite p\Sprite,1,.5

p\Tex = CreateNameTexture(p\name$,1+16+32)
EntityTexture p\Sprite,p\Tex

EntityParent p\Sprite,P\model
PositionEntity p\Sprite,1,MeshHeight(P\model)+25,0

Next
End If
End If
camera1.ChaseCam=CreateChaseCam( play\entity )

listener=CreateListener( play\entity,.1,1,.2 )
Global directory_of_project$ = "Medieval\"
Global project_filename$ = "Medieval.udp"
Udp_Load(directory_of_project$, project_filename$)
ScaleEntity centerpivot,300,300,300
b1=LoadMesh("medieval\dwarfoutpost_6.b3d")
; b2=LoadMesh("medieval\dwarfoutpost_2.b3d")
; b3=LoadMesh("medieval\dwarfoutpost_3.b3d")
; b4=LoadMesh("medieval\dwarfoutpost_4.b3d")
; b5=LoadMesh("medieval\dwarfoutpost_5.b3d")
; b6=LoadMesh("medieval\dwarfoutpost_6.b3d")
ScaleEntity b1,.2,.2,.2
; ScaleEntity b2,.2,.2,.2
; ScaleEntity b3,.2,.2,.2
; ScaleEntity b4,.2,.2,.2
; ScaleEntity b5,.2,.2,.2
; ScaleEntity b6,.2,.2,.2
EntityType b1,C_Scene
EntityFX b1,16
FlipMesh b1
; EntityType b2,C_Scene
; EntityType b3,C_Scene
; EntityType b4,C_Scene
; EntityType b5,C_Scene
; EntityType b6,C_Scene
; FlipMesh b1



;CREATE A HUD For THE GUI
MyHUD% = HUD_Create (Camera1\camera)

Font1% = HUD_LoadFont ("media\arfont.bmp","media\arfont.dat", 4)
Layer1% = HUD_CreateLayer (myHUD%, Font1)
Snd_Click% = LoadSound("Media/button.mp3")
Snd_Hover% = LoadSound("Media/hover.mp3")
Snd_Release% = LoadSound("Media/release.mp3")
snd_typing% = LoadSound("media/type.mp3")
splash% = LoadSound("media/watersplash.mp3")
underwater% = LoadSound("media/underwater.mp3")
LoopSound underwater
PauseChannel underwaterchannel

; CREATE AS MANY TEXTS ON IT AS YOU LIKE:
Global numoflines% = 8 ; <- HOW MANY LINES TO DISPLAY
txt$ = ""
Global Text1% = HUD_CreateText (Layer1, 10,600, txt$, "LEFT", 2000, "","")
HUD_SetScrollText Text1, txt$, 1, numoflines

TextHEAD% = HUD_CreateText (Layer1, 5,500, "ACTIVE CHAT: DISABLED (F1 TO ENABLE)", "LEFT", 0, "","")

TextBG = HUD_CreateShape (Layer1,"RECTANGLE" , 1,0, 130, 700, 550,400, "","" )
HUD_SetObjectAlpha TextBG, .5
HUD_SetObjectGradient TextBG,0,0,0, 255,200,255, 1
HUD_SwapObjectOrder TextBG,Text1

; CREATE THE SCROLL BAR
Bar = HUD_CreateShape (Layer1,"RECTANGLE" , 1,0, 400, 0, 10,400 ) ; SIMPLE RECT
HUD_EnableVertexColor Bar,True
HUD_SetVertexColor Bar,0, 25,25,50
HUD_SetVertexColor Bar,2, 25,25,50

; CREATE THE SCROLL BAR SLIDER
Slider = HUD_CreateShape (Layer1,"RECTANGLE" , 1,0, 0, 0, 10,10 ) ; SIMPLE RECT
HUD_EnableVertexColor Slider,True
HUD_SetVertexColor Slider,1, 75,75,75
HUD_SetVertexColor Slider,3, 75,75,75

; ENABLE SCROLL BAR FUNCTIONALITY
HUD_AttachScrollBar Text1, Slider, 270, Bar

Dim InputTexts%(2)

InputTexts(1) = HUD_CreateText (Layer1,10,700, "", "LEFT",2000,"","")

Resource1% = HUD_LoadImageResource ("Media/uwtexture.jpg",4) ; <-- BLACK BECOMES TRANSPARENT
; CREATE LAYERS
Global Layer2% = HUD_CreateLayer(myHUD%, Resource1,0)
; CREATED TILED (REPEATED) IMAGE PLANE
Global Plane% = HUD_CreateShape (layer2, "Rectangle" , 1,0,0,0,1024,768,"CENTER","CENTER")
HUD_SetObjectColor Plane, 167,186,220,.6

HUD_SetLayerVisibility (Layer2, False )

HUD_SetWrapWidth ( inputtexts(1), 400 )

Const C_hero=1
Const C_monster=2
Const C_Scene=3

Collisions C_hero,C_Scene,2,3
Collisions C_hero,C_monster,1,2

EntityType seabottom, C_Scene

period=1000/fps
time=MilliSecs()-period
piv=CreatePivot()
PositionEntity piv,0,10,40
While Not KeyHit(1)

If EntityY(play\entity)>=water_level-3 And play\inwater=1

If playedoutsplash=0
PlaySound splash
playedoutsplash=1
EndIf

EndIf
If EntityY(play\entity)<water_level-3
If play\psa=0
playedoutsplash=0
PlaySound splash
play\psa=1
underwaterchannel=PlaySound(underwater)
EndIf
HUD_SetLayerVisibility (Layer2, True )
RotateEntity water,0,0,180
play\inwater=1
; If Not AnimSeq(p\model) = walk
; necro_anim(p,walk)
; EndIf
Else
play\psa=0
HUD_SetLayerVisibility (Layer2, False )
play\inwater=0
RotateEntity water,0,0,0
PauseChannel underwaterchannel
EndIf
Repeat
elapsed=MilliSecs()-time
Until elapsed

;how many 'frames' have elapsed
ticks=elapsed/period

;fractional remainder
tween#=Float(elapsed Mod period)/Float(period)

For k=1 To ticks
time=time+period
If k=ticks Then CaptureWorld

TurnEntity piv,0,5,0
PositionEntity piv,0,7,40;47+Sin(time*.1)*40,40

For c.ChaseCam=Each ChaseCam;
UpdateChaseCam( c )
Next

UpdateGame()
top_line% = HUD_GetmaxScroll(Text1)

If KeyHit(60)
If nogravity=0
nogravity=1
txt$ = txt$ + "No Gravity Mode Activated|"
HUD_SetScrollText Text1, txt$, HUD_GetMaxScroll(Text1), numoflines

Else
nogravity=0
txt$ = txt$ + "Gravity returned to world|"
HUD_SetScrollText Text1, txt$, HUD_GetMaxScroll(Text1), numoflines

EndIf
EndIf

If KeyHit(59)
If CHATENABLED=True Then
CHATENABLED=False
HUD_DisableTextInput()
HUD_SetText ( Texthead%, "ACTIVE CHAT: DISABLED (F1 TO ENABLE)" )

Else
HUD_SetText ( Texthead%, "ACTIVE CHAT: ENABLED (F1 TO DISABLE)" )
CHATENABLED=True
HUD_EnableTextInput inputtexts(1), 65, "@", "!#$%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ[|]_abcdefghijklmnopqrstuvwxyz{}~§©® ", False, Snd_Click
EndIf
EndIf

Temp% = HUD_InputTextClosed()
If Temp <> 0 And CHATENABLED=True Then
; RESET TEXT BORDER ETC.
HUD_SetObjectBorder Temp, False
HUD_SetObjectBG Temp, False
txt$ = txt$ + name$+":"+HUD_GetText(inputtexts(1))+"|"
HUD_SetScrollText Text1, txt$, HUD_GetMaxScroll(Text1), numoflines

WriteLine(stream,3+","+name$+","+HUD_GetText(inputtexts(1))) ; send message to server

; VERIFY INPUT FIELD TEXTS
HUD_SetText InputTexts(1),""
HUD_EnableTextInput inputtexts(1), 65, "@", "!#$%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ[|]_abcdefghijklmnopqrstuvwxyz{}~§©® ", False, Snd_Click
End If
PositionEntity water,Sin(time*.01)*10,water_level+Sin(time*.05)*.5,Cos(time*.02)*10

UpdateWorld


HUD_Update : GUI_Update : RenderWorld ;: Flip 0

RenderWorld tween
play\px = EntityX(play\entity) : play\py = EntityY(play\entity) : play\pz = EntityZ(play\entity)

Flip

Next
Wend
; CLEAN UP & EXIT

GUI_Remove : HUD_RemoveAll True : End
End

Function UpdateGame()


UpdatePlayer(play )
; updateenemy(enem)
updatenetwork()


End Function

Function setupworld()

player_model=LoadAnimMesh("medieval\dwarf1.b3d")
ScaleEntity player_model,3,3,3
; RotateEntity player_model,0,180,0;
TranslateEntity player_model,0,-1.25,0
HideEntity player_model

enemy_model=LoadAnimMesh( "enemy\fatboy.x" )
et=LoadTexture("enemy\Fatboy_d2.dds")
EntityTexture enemy_model,et
ScaleEntity enemy_model,.3,.3,.3
RotateEntity enemy_model,0,180,0;
TranslateEntity enemy_model,0,-1.25,0
HideEntity enemy_model

water_tex=LoadTexture( "media\water-2_mip.bmp",3 )
ScaleTexture water_tex,20,20

EntityTexture water,water_tex
PositionEntity water,0,water_level,0


End Function


Function UpdateNetwork()

While ReadAvail(stream)

split(ReadLine(stream))
DebugLog "msg type:"+splitdata$(1)
Select splitdata$(1)

Case 3
txt$ = txt$ + splitdata$(2)+":"+splitdata$(3)+"|"
HUD_SetScrollText Text1, txt$, HUD_GetMaxScroll(Text1), numoflines


Case 1
For p.player=Each player
If Int(splitdata$(2))=p\netid
If p\nameabove<>1
p\Sprite = CreateSprite()
ScaleSprite p\Sprite,1,.5

p\Tex = CreateNameTexture(splitdata$(11),1+16+32)
EntityTexture p\Sprite,p\Tex

EntityParent p\Sprite,P\model
PositionEntity p\Sprite,1,MeshHeight(P\model)+25,0

If p\anim_speed<=0
p\anim_speed=1.75
If Not AnimSeq(p\model) = walk
necro_anim(p,walk,1)
EndIf
EndIf


p\nameabove=1
EndIf

p\px=Float(splitdata$(3)):p\py=Float(splitdata$(4)):p\pz=Float(splitdata$(5)):p\rx=Float(splitdata$(6)):p\ry=Float(splitdata$(7)):p\rz=Float(splitdata$(8))
p\Aniseq=Int(splitdata$(9)):p\animframe=Int(splitdata$(10)):p\name$=splitdata$(11)
PositionEntity p\entity,p\px,p\py,p\pz,1
RotateEntity p\entity,p\rx,p\ry,p\rz
p\anim_speed=1.75
If Not AnimSeq(p\model) = walk
necro_anim(p,walk,1)
EndIf


EndIf

Next

Case 2
p.player=createplayer(-445.416,30.0973,290.456)
p\netid=splitdata$(2)
Case 7
For p.player=Each player
If Int(splitdata$(2))=p\netid
txt$ = txt$ + p\name$ + " has left|"
FreeEntity p\entity
HUD_SetScrollText Text1, txt$, HUD_GetMaxScroll(Text1), numoflines
Delete p
EndIf
Next

Case 88
txt$ = txt$ + splitdata$(11)+" has Joined|"
HUD_SetScrollText Text1, txt$, HUD_GetMaxScroll(Text1), numoflines

End Select

Wend

For p.player=Each player
If p\inwater=0
If Animating(p\model)=False
Animate p\model,0
EndIf
EndIf
Next

For p.player=Each player
If p\entity<>play\entity
MoveEntity p\entity,0,-5,0
EndIf
Next

End Function

Function UpdateChaseCam( c.chasecam )

If KeyDown(200)
TranslateEntity c\heading,0,-3,0
Else If KeyDown(208)
TranslateEntity c\heading,0,+3,0
EndIf

dx#=EntityX(c\target,True)-EntityX(c\camera,True)
dy#=EntityY(c\target,True)-EntityY(c\camera,True)
dz#=EntityZ(c\target,True)-EntityZ(c\camera,True)

TranslateEntity c\camera,dx*.1,dy*.1,dz*.1

PointEntity c\camera,c\heading

PositionEntity c\target,0,0,0
ResetEntity c\target
PositionEntity c\target,0,3,-10

End Function

Function CreatePlayer.Player( x#,y#,z#)

p.Player=New Player
p\px=x
p\py=y
p\pz=z
p\entity=CreatePivot()
p\model=CopyEntity( player_model,p\entity )
PositionEntity p\entity,x,y,z,0
EntityType p\entity,C_Hero
ResetEntity p\entity

HideEntity player_model

Return p

End Function

Function CreateChaseCam.ChaseCam( entity )

c.ChaseCam=New ChaseCam
c\entity=entity
c\camera=CreateCamera()
c\target=CreatePivot( entity )
PositionEntity c\target,0,3,-10
EntityType c\target,TYPE_TARGET

c\heading=CreatePivot( entity )
PositionEntity c\heading,0,0,20

CameraRange c\camera, 0.05, 10000
Return c

End Function

Function UpdatePlayer( p.Player )


If KeyDown(63)
water_level=water_level+1
;WireFrame True
EndIf
If KeyDown(64)
water_level=water_level-1
;WireFrame True
EndIf


walkingspeed=1
If play\inwater=1 walkingspeed=.8


If chatenabled=False


move$=""
If KeyDown(203) ;left/right
move$="L"
TurnEntity p\entity,0,6,0 ;turn player left/right
ElseIf KeyDown(205)
move$=move$+"R"
TurnEntity p\entity,0,-6,0
EndIf

If KeyDown(30) ;forward
move$=move$+"F"
If p\anim_speed<=0
p\anim_speed=1.75
If Not AnimSeq(p\model) = walk
necro_anim(p,walk,1)
EndIf

EndIf
MoveEntity p\entity,0,0,walkingspeed

ElseIf KeyDown(44) ;back
move$=move$+"B"

If p\anim_speed>=0
p\anim_speed=-1.75
If Not AnimSeq(p\model) = walk
necro_anim(p,walk,1)
EndIf

EndIf
MoveEntity p\entity,0,0,-(walkingspeed)
ElseIf p\anim_speed
p\anim_speed=0
; If p\inwater=0
Animate p\model,0
; EndIf
EndIf


ty#=EntityY(p\entity)
y_vel#=(ty-p\player_y)
p\player_y=ty
DebugLog y_vel#
If KeyDown(57) ;jump?
y_vel=5 ;2.4
move$="L"
Else
y_vel=y_vel-.5 ;2
EndIf

If KeyDown(87) And nogravity=1
TranslateEntity p\entity,0,1,0
move$="L"
EndIf
If KeyDown(88) And nogravity=1
TranslateEntity p\entity,0,-1,0
move$="L"
EndIf

If KeyDown(28)
If AnimSeq(p\model) <> attack
necro_anim p,attack,3
EndIf
EndIf

If nogravity=0
TranslateEntity p\entity,0,y_vel,0
move$="L"
EndIf


If networked=1 And move$<>""
If AnimSeq(p\model) <> walk And p\anim_speed<>0 And AnimSeq(p\model) <> attack
necro_anim p,walk,1
EndIf

If Instr(move$,"L") Or Instr(move$,"R") Then WriteLine(stream,1+","+p\netid+","+p\px+","+p\py+","+p\pz+","+p\rx+","+p\ry+","+p\rz+","+7+","+p\animframe+","+p\name$)

If Instr(move$,"F") Or Instr(move$,"B") Then WriteLine(stream,1+","+p\netid+","+p\px+","+p\py+","+p\pz+","+p\rx+","+p\ry+","+p\rz+","+8+","+p\animframe+","+p\name$)

EndIf

p\px=EntityX(p\entity)
p\py=EntityY(p\entity)
p\pz=EntityZ(p\entity)

p\rx=EntityPitch(p\entity)
p\ry=EntityYaw(p\entity)
p\rz=EntityRoll(p\entity)
my_status$="A"
.totallyskip


EndIf
End Function

Function Split(DataToSplit$)

Local splitcounter = 0, pntr = -1,chris=1, pntr2 = 0, counter = 0

Local a=0
While pntr <> 0

pntr = Instr(datatosplit$, ",", chris)
If pntr > 0 Then splitcounter = splitcounter + 1
chris=pntr+1
a=a+1
Wend

Dim SplitData$(splitcounter + 1)

pntr = 0:pntr2 = Instr(DataToSplit$, ",", 1)
SplitData$(1) = Left$(DataToSplit$, pntr2 - 1)

For counter = 2 To splitcounter

pntr = pntr2 + 1
pntr2 = Instr(DataToSplit$, ",", pntr)

SplitData$(counter) = Mid$(DataToSplit$, pntr, (pntr2 - pntr))
Next

SplitData$(counter) = Right$(DataToSplit$, Len(DataToSplit$) - pntr2)

Return (splitcounter + 1)

End Function

Function necro_anim(p.player,seq,style)

Animate p\model,style,1,seq,10
End Function


Function ShadowText(value$,x#,y#,red%=255,green%=255,blue%=255,shadow_red=20,shadow_green=20,shadow_blue=20,center_x=1,center_y=1)

Color shadow_red,shadow_green,shadow_blue
Text x+1,y,value,center_x,center_y
Text x,y+1,value,center_x,center_y
Text x+1,y+1,value,center_x,center_y

Color red,green,blue
Text x,y,value,center_x,center_y

End Function

Function CreateNameTexture(name$,flags)

Local Width% = StringWidth(name)*2
Local Height% = StringHeight(name)*2
Local texture = CreateTexture(Width,Height,flags)

SetBuffer TextureBuffer(texture)
Color 0,0,255
Rect 0,0,TextureWidth(texture),TextureHeight(texture)*.1
Rect 0,TextureHeight(texture)*.9,TextureWidth(texture),TextureHeight(texture)*.1

Color 255,255,255
ShadowText(name,TextureWidth(texture)*.5,TextureHeight(texture)*.5,254)
SetBuffer BackBuffer()

Return texture

End Function

Function CreateQuad(width#,height#,order%=-1,parent%=False)

Local v0,v1,v2,v3
Local Point,Surface

If Not parent = False
Point = CreateMesh(parent)
Else
Point = CreateMesh()
EndIf

If order <> 0
EntityOrder Point,order
EndIf

EntityFX Point,1

Surface = CreateSurface(Point)

v0=AddVertex(Surface,-(width*.5),(height*.5),0 ,0,0)
v1=AddVertex(Surface,(width*.5),(height*.5),0 ,1,0)
v2=AddVertex(Surface,-(width*.5),-(height*.5),0 ,0,1)
v3=AddVertex(Surface,(width*.5),-(height*.5),0 ,1,1)

AddTriangle(Surface,v0,v1,v2)
AddTriangle(Surface,v1,v3,v2)

Return Point

End Function

Function Udp_Load(directory$, project$)

light_ID = 0

; check if the filename exist
If Udp_OpenFile(directory+project)<>0 Then Return

; enumerate all actors, INCLUDING lights.
; In Udp files, lights are considered as Actors
actorcount = Udp_ActorCount()

For actor_ID=0 To actorcount-1

actor_type = Udp_ActorACTypeID(actor_ID)
modelfilename$ = directory$+Udp_ActorTypeModelFilename(actor_type)
x# = Udp_ActorX(actor_ID)
y# = Udp_ActorY(actor_ID)
z# = Udp_ActorZ(actor_ID)
pitch# = Udp_ActorPitch(actor_ID)
yaw# = Udp_ActorYaw(actor_ID)
roll# = Udp_ActorRoll(actor_ID)
x_scale# = Udp_ActorXScl(actor_ID)
y_scale# = Udp_ActorYScl(actor_ID)
z_scale# = Udp_ActorZScl(actor_ID)
; Here you can add commands (please read the documentation)
; in order to access more properties of an actor.
If Udp_ActorIsLight(actor_ID)
Load_Light(light_ID)
light_ID = light_ID + 1
Else
actor = LoadMesh(modelfilename$,centerpivot)
ScaleEntity actor, x_scale#, y_scale#, z_scale#
EntityType actor,C_Scene
EndIf
If Instr(Udp_ActorTypeModelFilename(actor_type),"Terrain")=True Then y=y+.006
PositionEntity actor, x#, y#, z#
RotateEntity actor, pitch, yaw, roll
Next

End Function

Function Load_Light(lightid)

; enumerate all lights
; IMPORTAND: Enumerate always, before try to access anything
lightcount = Udp_LightCount()

light_type = Udp_LightType(lightid)
light_range = Udp_LightRange(lightid)
light_inner_angle = Udp_LightInnerAngle(lightid)
light_outer_angle = Udp_LightOuterAngle(lightid)
light_color_red = Udp_LightRed(lightid)
light_color_green = Udp_LightGreen(lightid)
light_color_blue = Udp_LightBlue(lightid)
light = CreateLight(light_type)
LightRange light, light_range
LightConeAngles light, light_inner_angle, light_outer_angle
LightColor light, light_color_red, light_color_green, light_color_blue

End Function

Function CreateEnemy.Enemy( x#,y#,z#)
p.enemy=New enemy
p\px=x
p\py=y
p\pz=z
p\entity=CreatePivot()
p\model=CopyEntity( enemy_model,p\entity )
PositionEntity p\entity,x,y,z,0
EntityType p\entity,C_Hero

Return p
End Function

Function updateenemy(e.enemy)

TranslateEntity e\entity,0,-1,0

End Function


Ross C(Posted 2009) [#43]
codebox is your friend :) Thanks for posting all that though.


AJ00200(Posted 2009) [#44]
Ill test it, and put it in
When are you posting the link for the file?


Blitzplotter(Posted 2009) [#45]
@Wings, with your XP in network coding in B3D what would you advocate - udp or B3D ?

@Sagitario: You have an impressive history of coding - I was sorting through some paperwork today and stumbled across some code I developed in BBasic 2.1. Thankyou for sharing your points. 1) yep, I agree 2) Yes, this can also be very helpful 3) Yeah, I agree until your bit about types, pointers & arrays - arrays are certainly useful, however pointers & types can wait a while 4) yep 5)Hmm, not so sure I concur here, I have extensively coded in B3D without physics engines to the extent of plotting projectiles arcs from a bloke running around in a 3D world and whilst that can be gratifying you cannot dismiss the physics engines out there - if anything JV-ODE invigorated my interest in B3D 6)Ohhh yes, and some 7)yep. Thanks for your points on code dev Sagitario - I agree with your point about a structured approach - I'd just like to add that when developing your code you may find it useful to do incremental saves with a versioning number suffix within your filenames if you are not using a versioning tool - that way you can revert to a working version of your code without to much bother.

@Ross C, interesting point on the use of linepicks.

@ChrisNorris007: Very very generous of you to share your code, like Russ said codebox with [] surrounding the 1st codebox & [/] surropunding the last codebox will make the thread more readable and still allow folks to see your code.

How is your modelling going in blender? There is some very good online tutorials available.


Wings(Posted 2009) [#46]
Sens introduction of personal firewalls i am starting to maby think udp is nice....

UDP = Fast easy, but no security, player have to alter firewall to direct trafic.

TCP = Fast easy, but can stall server/client if inproper coded. blitz3d is verry hard to not lagg.


Iam starting slowly thinking udp is better choice..


Guy Fawkes(Posted 2009) [#47]
chris. can u send me the zip?

or can someone please send me the zip?


Nike(Posted 2009) [#48]
Yeah, and you never sent it to me eather. You almost sent me your zip code, but no .zip file


AJ00200(Posted 2009) [#49]
Last I heard from him (via email this morning), he (at my request) is going to use that fancy Live Mesh Program I have sent you the invites to. So just check the Network RPG folder when he updates.

DSW, Ill send an invite to you.


Guy Fawkes(Posted 2009) [#50]
thanks, aj


AJ00200(Posted 2009) [#51]
I never explained how to use it.
Just put/change a file in the Folder, and we all get the changes (every minute)

@DSW -Your Welcome


AJ00200(Posted 2009) [#52]
Chris is putting 50megs of files in soon, so be ready.
PS - Do you think my new signature is to big?


Guy Fawkes(Posted 2009) [#53]
Hey Aj, did u send the files yet?


AJ00200(Posted 2009) [#54]
Chris is, you have to ask him.
I sent you the invite, or didn't you get it.


Guy Fawkes(Posted 2009) [#55]
nope. i didnt get it.


BLaBZ(Posted 2009) [#56]
Do you guys have documentation for this project?
Task assignments and or a team roster?
How's this organized and what's insuring its completion?


Mahan(Posted 2009) [#57]
@chrisnorris007: I found this inside you code:

; INCLUDE SPRITE CANDY (FIRST)
Include "sprite candy.bb"

; INCLUDE GUI EXTENSION (SECOND)
Include "sprite candy gui.bb"




I also saw that you use Sprite Candy GUI in your code meaning that your program will not work without it.

Note that you are not allowed to redistribute the sprite-candy source. The header of the Sprite Candy libs are very clear about this! (and yes I've bought sprite candy so thats how i know)

Implications of this:

1.) You are not allowed to redistribute any .ZIP-file containing these libs, via mail or otherwise.
2.) People who do not own Sprite Candy will not be able to compile the program.


chrisnorris007(Posted 2012) [#58]
yes but if I make it a requirement to have sprite candy, it should be ok, correct?


Adam Novagen(Posted 2012) [#59]
That would be perfectly okay. What is slightly less okay is that you're replying to a thread about a project that has obviously been dead for over two years.

Please, posters, LOOK AT THE DATES IN ANY THREAD BEFORE RESPONDING TO IT.