Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO 2.0] NPC Speech Box with NPC Face.


Broojo02
 Share

Recommended Posts

Massive credit to Murdoc, as this is pretty much an edit of the quest system he submitted.

NOTE: To be able to talk to a friendly NPC, give it some stats in every available area (like HP and strength). Don't ask me why, just do it :D

If you don't have access to Visual Basic 6 (what they don't sell it in shops anymore??? Well I never). Then you can grab a copy of the engine with this tutorial already installed at: http://www.2shared.com/file/fYZEcCDa/Eclipse_Origns_with_NPC_speech.html

This tutorial will add a speech box for any talking an NPC has to do. It will appear over the normal text box and shows the face of the NPC you are talking to.

Download the small picture below and add it to the location: client > data files > graphics > gui > main, this is the button you click to close the window.
![](http://img231.imageshack.us/img231/2014/speechbutton.jpg)

Copy one of the faces inside the faces folder and rename it to "default", this will act as the face for an NPC that doesn't have one defined for it.

==Client Side==

Open up frmMain and add a picture box in the top right of the screen (make sure its on top of everything), name it picSpeech, this will be the main speech box. Inside that add a picture box called picSpeechClose (clicking it closes the box), next add a picture box called picSpeechFace, finally add a label called lblSpeech (where the text is displayed). Set their Appearance as flat and their BorderStyle as 0 - none. Set the ForeColor of lblSpeech to white and the BackColor to a new colour with RGB values 15, 14, 12 (to create a new colour, on the "Palette" tab of the BackColor property, right click on one of the white block at the bottom of the palette, edit the RGB values on the right), set the same background for picSpeech. Set the property of picSpeechClose's AutoSize to True. Set all of the components visibility to false.

Set the following properties for the relevant components:

picSpeech
-Left: 12
-Top: 442
-Width: 476
-Height: 138

picSpeechClose
-Left: 6840
-Top: 0
-Width: 300
-Height: 300

picSpeechFace
-Left: 300
-Top: 300
-Width: 1500
-Height: 1500

lblSpeech
-Left: 2100
-Top: 300
-Width: 4750
-Height: 1500

This will make the Speech box appear in the correct position for a vanilla copy of Eclipse Origins 2.0, if you have changed your GUI around, increased the size of your picScreen etc then you should use different values.

Double click on picSpeechClose and add the following code to the new sub:
```
frmMain.picSpeech.Visible = False
frmMain.picSpeechClose.Visible = False
frmMain.lblSpeech.Visible = False
frmMain.picSpeechFace.Visible = False

```
Search for: "frmMain.picHotbar.Picture = LoadPicture(App.Path & "\data files\graphics\gui\main\hotbar.jpg")"
Under that add:
```
frmMain.picSpeechClose.Picture = LoadPicture(App.Path & "\data files\graphics\gui\main\speechbutton.jpg")
```
Search for "Public Enum ServerPackets", under "SAlertMsg = 1" add:
```
SSpeechWindow
```
Under "Public Sub InitMessages()" add:
```
HandleDataSub(SSpeechWindow) = GetAddress(AddressOf HandleSpeechWindow)
```
At the bottom of modHandleData add the following sub:
```
Private Sub HandleSpeechWindow(ByVal Index As Long, ByRef Data() As Byte, ByVal EditorIndex As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)

Dim Buffer As clsBuffer
Dim msg As String
Dim npcNum As Long
Set Buffer = New clsBuffer
Buffer.WriteBytes Data()

msg = Buffer.ReadString
npcNum = Buffer.ReadLong

    If Not FileExist(App.Path & "\data files\graphics\faces\" & (Npc(npcNum).Sprite) & ".bmp", True) Then
        frmMain.picSpeechFace.Picture = LoadPicture(App.Path & "\data files\graphics\faces\" & "default.bmp")
    Else
        frmMain.picSpeechFace.Picture = LoadPicture(App.Path & "\data files\graphics\faces\" & (Npc(npcNum).Sprite) & ".bmp")
    End If

frmMain.picSpeech.Visible = True
frmMain.lblSpeech.Caption = "" & msg & ""
frmMain.lblSpeech.Visible = True
frmMain.picSpeechClose.Visible = True
frmMain.picSpeechFace.Visible = True

End Sub
```
==Server Side==

Search for "PlayerMsg attacker, Trim$(Npc(npcNum).Name) & ": " & Trim$(Npc(npcNum).AttackSay), White"
You can either comment it out or leave it, this is the text that is normally shown in the text box, but underneath it add:
```
Call SpeechWindow(attacker, Trim$(Npc(npcNum).AttackSay), npcNum)
```
Search for "Public Enum ServerPackets", under "SAlertMsg = 1" add the following:
```
SSpeechWindow
```
In modGameLogic add the following sub:
```
Sub SpeechWindow(ByVal index As Long, ByVal msg As String, ByVal npcNum As Long)
Dim Buffer As clsBuffer
Set Buffer = New clsBuffer
Buffer.WriteLong SSpeechWindow
Buffer.WriteString msg
Buffer.WriteLong npcNum
SendDataTo index, Buffer.ToArray()
Set Buffer = Nothing
End Sub
```
Right, how the face works is by getting the number of the sprite your NPC is using, if you are using sprite 2 for your NPC (named 2.bmp) then the game will try and load the face "2.bmp" in the faces folder, if it does not exist then it will load the "default.bmp" file instead.

==ScreenShot==
![](http://img269.imageshack.us/img269/9429/npcspeechtest.png)

==Optional==

1\. At the moment you can only have 100 characters as an NPC's speech so to change it find:
```
AttackSay As String * 100
```and change the 100 to a higher value like 300\. **You will need to do this in both the client and server**, you also may need to delete your NPCs which is why I didn't include it in the tutorial.

2\. You can add a sound effect to your picSpeechClose by adding the statement:
```
PlaySound Sound_ButtonClick
```in "Private Sub picNPCSpeechClose_Click()"
Link to comment
Share on other sites

  • Replies 121
  • Created
  • Last Reply

Top Posters In This Topic

LOL, this was the wrong place
```
HandleDataSub(SSpeechWindow) = GetAddress(AddressOf HandleSpeechWindow)
```
I tryed to change here xD  Sub HandleSpeechWindow to Sub HandleQuestWindow
```
Private Sub HandleSpeechWindow(ByVal Index As Long, ByRef Data() As Byte, ByVal EditorIndex As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)

Dim Buffer As clsBuffer
Dim msg As String
Set Buffer = New clsBuffer
Buffer.WriteBytes Data()

msg = Buffer.ReadString

frmMain.picSpeech.Visible = True
frmMain.lblSpeech.Caption = "" & msg & ""
frmMain.lblSpeech.Visible = True
frmMain.picSpeechClose.Visible = True

End Sub
```
But that's ok. Great code.  :star: :star: :star:
Link to comment
Share on other sites

"Method or data member not found." In (Client side)
```
Private Sub HandleSpeechWindow(ByVal Index As Long, ByRef Data() As Byte, ByVal EditorIndex As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)

```
This is when I want to speak with someone…
And npc's was deleted before server start.
---

@thezeus:

> Could I trouble you for a screenshot of this in-game?  I'm not certain if I want to implement this or not without viewing such a graphic.  If not, thank you for your contribution!  It looks great.

![](http://www.freemmorpgmaker.com/files/imagehost/pics/d7e27304258002d22c67caa4b6490bb9.PNG)
Only need to fix that it shows when you start to speak with someone not when you enter in game. :)
Link to comment
Share on other sites

Ok, Ive changed the tut so it asks you to set the 3 components visibility to false at the start, silly me :P I'm not quite sure what to do about your error, maybe you still have a "quest" bit of text hanging around somewhere. I just did the tutorial on a fresh source and it worked ok (albeit with the textbox already being there at the start.

Heres another screen of the game:
![](http://img98.imageshack.us/img98/4259/screeniy.png)
Link to comment
Share on other sites

@Dami:

> may I suggest some things?
>
> make the image appear OVER the chatbox, not on the map, its disturbing there.
>
> also, add a extra field in the npc rec, to store a face graphic, so you can show the face on the dialog of the npc your talking too.
>
> just some suggestions ^^
>
> Dami

Thats an awesome idea, to have it appear over the chatbox :D I'm just used to all the other mmorpgs having them appear as a pop up.

And yeah I intend to add face graphic support some time soon, but Robin will probably add it in too, I think he did it in Silverdale.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×
×
  • Create New...