Broojo02 Posted January 25, 2011 Author Share Posted January 25, 2011 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 :DIf 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.htmlThis 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: 138picSpeechClose-Left: 6840-Top: 0-Width: 300-Height: 300picSpeechFace-Left: 300-Top: 300-Width: 1500-Height: 1500lblSpeech-Left: 2100-Top: 300-Width: 4750-Height: 1500This 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 = FalsefrmMain.picSpeechClose.Visible = FalsefrmMain.lblSpeech.Visible = FalsefrmMain.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 clsBufferDim msg As StringDim npcNum As LongSet Buffer = New clsBufferBuffer.WriteBytes Data()msg = Buffer.ReadStringnpcNum = 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 IffrmMain.picSpeech.Visible = TruefrmMain.lblSpeech.Caption = "" & msg & ""frmMain.lblSpeech.Visible = TruefrmMain.picSpeechClose.Visible = TruefrmMain.picSpeechFace.Visible = TrueEnd 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 clsBufferSet Buffer = New clsBufferBuffer.WriteLong SSpeechWindowBuffer.WriteString msgBuffer.WriteLong npcNumSendDataTo index, Buffer.ToArray()Set Buffer = NothingEnd 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 More sharing options...
Domino_ Posted January 25, 2011 Share Posted January 25, 2011 Maybe I'm doing something wrong but I have this problem."Variable not defined." In``` Public Sub InitMessages()Â Â HandleDataSub(SQuestWindow) = GetAddress(AddressOf HandleQuestWindow)``` Link to comment Share on other sites More sharing options...
Robin Posted January 25, 2011 Share Posted January 25, 2011 Did you add the header to the enumeration? Link to comment Share on other sites More sharing options...
Domino_ Posted January 25, 2011 Share Posted January 25, 2011 ```' Packets sent by server to clientPublic Enum ServerPackets  SSpeechWindow```I did'n add header, where to add?P.s.Or I added? :confused: xD Link to comment Share on other sites More sharing options...
Broojo02 Posted January 25, 2011 Author Share Posted January 25, 2011 Ahh, the code was wrong there, Ive changed it now. My apologies. Link to comment Share on other sites More sharing options...
Domino_ Posted January 25, 2011 Share Posted January 25, 2011 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 clsBufferDim msg As StringSet Buffer = New clsBufferBuffer.WriteBytes Data()msg = Buffer.ReadStringfrmMain.picSpeech.Visible = TruefrmMain.lblSpeech.Caption = "" & msg & ""frmMain.lblSpeech.Visible = TruefrmMain.picSpeechClose.Visible = TrueEnd Sub```But that's ok. Great code. :star: :star: :star: Link to comment Share on other sites More sharing options...
Broojo02 Posted January 25, 2011 Author Share Posted January 25, 2011 Cool, does it work for you now? I typed it out as I went along, thats why its a bit crap :P Link to comment Share on other sites More sharing options...
thezeus Posted January 25, 2011 Share Posted January 25, 2011 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. Link to comment Share on other sites More sharing options...
Domino_ Posted January 25, 2011 Share Posted January 25, 2011 "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 More sharing options...
Broojo02 Posted January 25, 2011 Author Share Posted January 25, 2011 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 More sharing options...
Domino_ Posted January 25, 2011 Share Posted January 25, 2011 @Broojo02:> Heres another screen of the game:> ```> http://img98.imageshack.us/img98/4259/screeniy.png> ```"Pe*is has joined Eclipse Origins!" xDDDDDDDDDDDDDDDDDDDDDD Link to comment Share on other sites More sharing options...
Broojo02 Posted January 25, 2011 Author Share Posted January 25, 2011 @Domino_:> "Pe*is has joined Eclipse Origins!" xDDDDDDDDDDDDDDDDDDDDDDXD, it has become the default name for my characters whenever I start a new game :P Link to comment Share on other sites More sharing options...
Dzastin Posted January 26, 2011 Share Posted January 26, 2011 Work, thanks :) Link to comment Share on other sites More sharing options...
Toranos Posted January 26, 2011 Share Posted January 26, 2011 Looks great, i'm going to test/play around with this later. Thanks Pe*is! :) Link to comment Share on other sites More sharing options...
thezeus Posted January 27, 2011 Share Posted January 27, 2011 I'm going to implement this in a bit, but I have a question. Does this box pop up when you click on an npc or is it when you log in? I haven't heard of what effect causes it to come up. Link to comment Share on other sites More sharing options...
Broojo02 Posted January 27, 2011 Author Share Posted January 27, 2011 It pops up when you attack the NPC with control. It shouldn't pop up when you log in unless you left the visibility to true in the object properties. Link to comment Share on other sites More sharing options...
Murdoc Posted January 27, 2011 Share Posted January 27, 2011 Nice work Broojo02\. ;-) Link to comment Share on other sites More sharing options...
Guest Posted January 27, 2011 Share Posted January 27, 2011 Hey, this is really cool. Once I have time I am going to try to add this.Thanks Link to comment Share on other sites More sharing options...
Guest Posted January 28, 2011 Share Posted January 28, 2011 I tested it and after i talk to a friendly npc nothing actely happens is the same thing. Link to comment Share on other sites More sharing options...
Skillzalot Posted January 28, 2011 Share Posted January 28, 2011 This works amazingly well and I thank you for releasing it. I know understand how packets work and I can now do much more Thanks Man :D Link to comment Share on other sites More sharing options...
damian666 Posted January 28, 2011 Share Posted January 28, 2011 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 Link to comment Share on other sites More sharing options...
Broojo02 Posted January 28, 2011 Author Share Posted January 28, 2011 @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 ^^> > DamiThats 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 More sharing options...
Broojo02 Posted January 28, 2011 Author Share Posted January 28, 2011 @Raiko:> I tested it and after I talk to a friendly npc nothing actely happens is the same thing.For some reason you have to add stats and stuff to an NPC before you can talk to it. Try adding a bit of everything (HP, MP, STR etc). Link to comment Share on other sites More sharing options...
Massurik Posted January 28, 2011 Share Posted January 28, 2011 Hello, I'm having a problem, the tutorial did all right, but when I attack the compiled npc my client closes but does not give any error. Link to comment Share on other sites More sharing options...
McCull96 Posted January 29, 2011 Share Posted January 29, 2011 Nice tut, maybe you could add a different sub that is similar to attacksay, except it only runs in the speech box Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now