Mirage Source

Free ORPG making software.
It is currently Wed May 01, 2024 5:04 am

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Player Messages
PostPosted: Tue Mar 31, 2009 8:58 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
http://web.miragesource.com/forums/viewtopic.php?f=120&t=3719&start=500#p60658

Rian mentioned a different way to do the messages that are sent to players, such as "This is a safe zone!" and so on. Instead of doing different modules for each of those, it would be better to load in an external file with the messages. Each message would have an ID associated with it so you know what message is which. For messages like player damage and npc damage, I've come up with a way to send just what you need to fill in the message.

Pseudo
Code:
SendClientMessage(MessageID as long, Optional args as string)

MessageID would be the corresponding ID client side. The optional args would be for what that message needs.

This would be client side
Code:
Private StringConst() As String

' Load our strings - Would be a text file for the real thing
Private Sub LoadStrings()
    ReDim StringConst(0 To 4)
    StringConst(0) = "Just a test message."
    StringConst(1) = "A test message with a replace %1%."
    StringConst(2) = "%1% test messages %2%"
    StringConst(3) = "%1% Test is a mother %2% that will %3% you."
    StringConst(4) = "%1% hits you for %2% damage."
End Sub


Code:
' our function to replace strings
Private Function ReplaceStr(ByRef MessageID As Long, Optional ByRef nString As String) As String
Dim i As Long
Dim args() As String

    ReplaceStr = "Error!"
   
    ' First check if it's a valid id
    If MessageID < 0 Then Exit Function
    If MessageID > UBound(StringConst) Then Exit Function
   
    ' Set our return string
    ReplaceStr = StringConst(MessageID)
   
    ' Split the nString
    If LenB(nString) > 0 Then
        args() = Split(nString, ",")
        For i = 0 To UBound(args)
            ReplaceStr = Replace(ReplaceStr, "%" & i + 1 & "%", args(i))
        Next
    End If
End Function


Example of use:
Code:
    Debug.Print ReplaceStr(2, "fucking,rock")
    Debug.Print ReplaceStr(3, "this,fucker,kill")
    Debug.Print ReplaceStr(4, "Dugor,1337")


Thoughts?


Top
 Profile  
 
 Post subject: Re: Player Messages
PostPosted: Tue Mar 31, 2009 10:12 pm 
Offline
Knowledgeable
User avatar

Joined: Sat Jun 09, 2007 3:16 am
Posts: 276
This is how most "big" game companies do things with messages, menus and errors.

_________________
Image
Island of Lost Souls wrote:
Dr. Moreau: Mr. Parker, do you know what it means to feel like God?


Top
 Profile  
 
 Post subject: Re: Player Messages
PostPosted: Wed Apr 01, 2009 5:36 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
Any other thoughts?

Think I should add it to MS4 so you guys know what I mean?


Top
 Profile  
 
 Post subject: Re: Player Messages
PostPosted: Wed Apr 01, 2009 5:39 pm 
Offline
Persistant Poster
User avatar

Joined: Wed Nov 29, 2006 11:25 pm
Posts: 860
Location: Ayer
Sure, I'd like to see it.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Player Messages
PostPosted: Wed Apr 01, 2009 6:48 pm 
Dugor would never do 1337 damage. Sorry. >.>


Top
  
 
 Post subject: Re: Player Messages
PostPosted: Wed Apr 01, 2009 8:45 pm 
Offline
Pro

Joined: Mon May 29, 2006 2:58 pm
Posts: 370
This is common practice and probably a good feature to have. It is actually called string tables to be formal, usually loaded from a file with a corresponding name or number to each so that once loaded into the table they can be easily referenced.

You could implement bloom filters for visual basic as well and name them by strings like "AttackMessage1" or however felt necessary, bloom filters can filter thousands of hits a second.

I have also been playing with bloom filters in Visual basic to use archives for large file sets. You can have over a thousand archives with thousands of files each in my C tests and still find if an archive has it and which one has it in under a few seconds. So it should handle a small group of strings very well, though hash tables may be more effective.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Player Messages
PostPosted: Thu Apr 02, 2009 1:01 am 
Offline
Persistant Poster
User avatar

Joined: Wed Nov 29, 2006 11:25 pm
Posts: 860
Location: Ayer
grimsk8ter11 wrote:
This is common practice and probably a good feature to have. It is actually called string tables to be formal, usually loaded from a file with a corresponding name or number to each so that once loaded into the table they can be easily referenced.

You could implement bloom filters for visual basic as well and name them by strings like "AttackMessage1" or however felt necessary, bloom filters can filter thousands of hits a second.

I have also been playing with bloom filters in Visual basic to use archives for large file sets. You can have over a thousand archives with thousands of files each in my C tests and still find if an archive has it and which one has it in under a few seconds. So it should handle a small group of strings very well, though hash tables may be more effective.


What's bloom filters?

_________________
Image


Top
 Profile  
 
 Post subject: Re: Player Messages
PostPosted: Thu Apr 02, 2009 11:56 am 
Offline
Pro
User avatar

Joined: Mon May 29, 2006 3:26 pm
Posts: 493
Location: São Paulo, Brasil
Google Talk: blackagesbr@gmail.com
Very good idea. I WILL implement them asap.

_________________
http://www.blackages.com.br
Image
Dave wrote:
GameBoy wrote:
www.FreeMoney.com
I admit I clicked. I immediately closed upon realizing there was, in fact, no free money.
Robin wrote:
I love you and your computer.Marry me.


Top
 Profile  
 
 Post subject: Re: Player Messages
PostPosted: Thu Apr 02, 2009 11:58 am 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
I'll probably add it to MS4 next week. Going on a vacation this weekend.


Top
 Profile  
 
 Post subject: Re: Player Messages
PostPosted: Thu Apr 02, 2009 1:35 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
Dugor wrote:
I'll probably add it to MS4 next week. Going on a vacation this weekend.


Awesome. You don't know how glad I am to hear, that MS4 will be making progress again.

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group