Author: GodSentDeath & Tristan
Difficulty: 1/5
:: SERVER SIDE ::Find:(it's in the social packet)
Code:
Call MapMsg(GetPlayerMap(Index), GetPlayerName(Index) & " says, '" & Msg & "'", SayColor)
Beneath it, add:
Code:
Call MapMsg2(GetPlayerMap(Index), Msg, Index)
In modServerTcp, at the bottom, add:
Code:
Sub MapMsg2(ByVal MapNum As Long, ByVal Msg As String, ByVal Index As Long)
Dim Packet As String
Packet = "MAPMSG2" & SEP_CHAR & Msg & SEP_CHAR & Index & SEP_CHAR & END_CHAR
Call SendDataToMap(MapNum, Packet)
End Sub
:: CLIENT SIDE ::At the top of modTypes, add:
Code:
Type ChatBubble
Text As String
Created As Long
End Type
Public Const DISPLAY_BUBBLE_TIME = 4500 ' In milliseconds.
Public DISPLAY_BUBBLE_WIDTH As Byte
Public Const MAX_BUBBLE_WIDTH = 6 ' In tiles. Includes corners.
Public Const MAX_LINE_LENGTH = 16 ' In characters.
Public Const MAX_LINES = 4
Public Bubble(1 To MAX_PLAYERS) As ChatBubble
In modHandleData, find:
Code:
' ::::::::::::::::::::
' :: Social packets ::
' ::::::::::::::::::::
If (LCase(Parse(0)) = "saymsg") Or (LCase(Parse(0)) = "broadcastmsg") Or (LCase(Parse(0)) = "globalmsg") Or (LCase(Parse(0)) = "playermsg") Or (LCase(Parse(0)) = "mapmsg") Or (LCase(Parse(0)) = "adminmsg") Then
Call AddText(Parse(1), Val(Parse(2)))
Exit Sub
End If
Beneath it, add:
Code:
' ::::::::::::::
' :: Messages ::
' ::::::::::::::
If (LCase(Parse(0)) = "mapmsg2") Then
Bubble(Val(Parse(2))).Text = Parse(1)
Bubble(Val(Parse(2))).Created = GetTickCount()
Exit Sub
End If
In modGameLogic, in the game loop, find:
Code:
' Lock the backbuffer so we can draw text and names
TexthDC = DD_BackBuffer.GetDC
For i = 1 To MAX_PLAYERS
If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
Call BltPlayerName(i)
End If
Next i
Beneath it, add:
Code:
' Blit text and bubble
For i = 1 To MAX_PLAYERS
If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
If Bubble(i).Text <> "" Then
Call BltPlayerText(i)
End If
If GetTickCount() > Bubble(i).Created + DISPLAY_BUBBLE_TIME Then
Bubble(i).Text = ""
End If
End If
Next i
At the bottom of the module (modGameLogic), add:
Code:
Sub BltPlayerText(ByVal Index As Long)
Dim TextX As Long
Dim TextY As Long
Dim intLoop As Integer
Dim intLoop2 As Integer
Dim bytLineCount As Byte
Dim bytLineLength As Byte
Dim strLine(0 To MAX_LINES - 1) As String
Dim strWords() As String
strWords() = Split(Bubble(Index).Text, " ")
TextX = GetPlayerX(Index) * PIC_X + Player(Index).XOffset + Int(PIC_X) - ((DISPLAY_BUBBLE_WIDTH * 32) / 2) - 6
TextY = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset - Int(PIC_Y) + 75
Call DD_BackBuffer.ReleaseDC(TexthDC)
TexthDC = DD_BackBuffer.GetDC
For intLoop = 0 To UBound(strWords)
bytLineLength = bytLineLength + Len(strWords(intLoop)) + 1
If bytLineLength < MAX_LINE_LENGTH Then
strLine(bytLineCount) = strLine(bytLineCount) & strWords(intLoop) & " "
Else
bytLineCount = bytLineCount + 1
If bytLineCount = MAX_LINES Then
bytLineCount = bytLineCount - 1
Exit For
End If
strLine(bytLineCount) = Trim(strWords(intLoop)) & " "
bytLineLength = 0
End If
Next intLoop
Call DD_BackBuffer.ReleaseDC(TexthDC)
TexthDC = DD_BackBuffer.GetDC
For intLoop = 0 To (MAX_LINES - 1)
If strLine(intLoop) <> "" Then
Call DrawText(TexthDC, TextX + (((DISPLAY_BUBBLE_WIDTH) * PIC_X) / 2) - ((Len(strLine(intLoop)) * 8) \ 2) - 7, TextY - 70, strLine(intLoop), QBColor(White))
TextY = TextY + 16
End If
Next intLoop
End Sub
That's all!