20-05-2009, 01:32 AM
Difficulty: 1/5 - Copypasta mmm
Introduction: This tutorial will add some random blood splatters to your game when you attack NPCs / players.
Now, lets get started...
SERVER-SIDE
[spoiler]First thing, add this to the bottom of the "Public Enum ServerPackets":
Now add this in modTypes:
Now under:
Add this:
Find this:
Add this under it:
Add this Random function to modGameLogic or whatever:
Now add this Sub in modGameLogic or wherever:
Now find this in Sub AttackNpc:
Under add this:
Find this in Sub AttackPlayer:
Under add:
Find:
Under add:
[/spoiler]
And now ~.............
CLIENT-SIDE
[spoiler]First thing, add this to the bottom of the "Public Enum ServerPackets":
Now add this in modTypes:
At the top of modDirectDraw7 add this:
Then in Sub InitSurfaces add this:
Now add this sub to modDirectDraw or wherever:
Now find:
Under add:
Now at the bottom of modHandleData add:
Now find:
Under add:
Finally in modGlobals add this to the top:
[/spoiler]
And that SHOULD be it...I might have left something out...
-----------------------------------
Oh yeah, and in your gfx folder add this:
CREDITS GO TO BLODYAVENGER IF YOU USE.
STYLE IS FOR 16-BIT GAMES, LIKE FF1.
http://mayhem.auburnflame.com/blood.bmp
Customizing and explanations:
With that blood.bmp, there are 6 different bloods able to be selected. If you want to change that, simply change this line in server-side:
That randomly selects between 6 blood pictures.
If you want to control if blood disappears faster, change this in the server in Sub SendBlood:
That tells the server to get rid of the blood in 30 seconds.
If you want to make a chance the blood appears, get rid of the comment on the second line here in Sub SendBlood:
THAT SHOULD BE ALL! I might have missed something. This was made on my engine made from MS4...so make sure you test with MS4 and post here, please.
Introduction: This tutorial will add some random blood splatters to your game when you attack NPCs / players.
Now, lets get started...
SERVER-SIDE
[spoiler]First thing, add this to the bottom of the "Public Enum ServerPackets":
Code:
SBloodSplatter
Now add this in modTypes:
Code:
Public TempTile() As TempTileRec
Type BloodRec
Active As Boolean
x As Long
y As Long
Pic As Long
Timer As Currency
End Type
Type TempMapRec
Blood(1 To 50) As BloodRec
End Type
Now under:
Code:
ReDim MapCache(1 To MAX_MAPS) As String
Add this:
Code:
ReDim TempTile(1 To MAX_MAPS) As TempTileRec
Find this:
Code:
Public Sub PlayerWarp(ByVal Index As Long, ByVal MapNum As Long, ByVal x As Long, ByVal y As Long)
Dim OldMap As Long
Dim LoopI As Long
' Check for subscript out of range
If Not IsPlaying(Index) Or MapNum MAX_MAPS Then Exit Sub
Add this under it:
Code:
'sending the blood splatter packet without any data will tell the client to clear
SendDataTo Index, SBloodSplatter & END_CHAR
For LoopI = 1 To UBound(TempMap(MapNum).Blood)
If TempMap(MapNum).Blood(LoopI).Active Then
With TempMap(MapNum).Blood(LoopI)
SendDataTo Index, SBloodSplatter & SEP_CHAR & LoopI & SEP_CHAR & .Active & SEP_CHAR & .x & SEP_CHAR & .y & SEP_CHAR & .Pic & END_CHAR
End With
End If
Next
Add this Random function to modGameLogic or whatever:
Code:
Function Random(Lowerbound As Integer, Upperbound As Integer) As Integer
Random = Int((Upperbound - Lowerbound + 1) * Rnd) + Lowerbound
End Function
Now add this Sub in modGameLogic or wherever:
Code:
Public Sub SendBlood(ByVal Map As Long, ByVal Target As Long, ByVal TargetType As Long)
Dim LoopI As Long
' 50% chance blood spawns
'If Random(1, 2) = 2 Then
For LoopI = 1 To UBound(TempMap(Map).Blood)
If Not TempMap(Map).Blood(LoopI).Active Then
With TempMap(Map).Blood(LoopI)
.Pic = Random(0, 5)
If TargetType = TARGET_TYPE_NPC Then
If Random(1, 2) = 1 Then
.x = (MapNpc(Map, Target).x * 32) + Random(0, 20)
Else
.x = (MapNpc(Map, Target).x * 32) - Random(0, 20)
End If
If Random(1, 2) = 2 Then
.y = (MapNpc(Map, Target).y * 32) + Random(0, 20)
Else
.y = (MapNpc(Map, Target).y * 32) - Random(0, 20)
End If
ElseIf TargetType = TARGET_TYPE_PLAYER Then
If IsPlaying(Target) Then
If Random(1, 2) = 1 Then
.x = (GetPlayerX(Target) * 32) + Random(0, 20)
Else
.x = (GetPlayerX(Target) * 32) - Random(0, 20)
End If
If Random(1, 2) = 2 Then
.y = (GetPlayerY(Target) * 32) + Random(0, 20)
Else
.y = (GetPlayerY(Target) * 32) - Random(0, 20)
End If
End If
End If
.Timer = GetTickCountNew + 30000
.Active = True
SendDataToMap Map, SBloodSplatter & SEP_CHAR & LoopI & SEP_CHAR & .Active & SEP_CHAR & .x & SEP_CHAR & .y & SEP_CHAR & .Pic & END_CHAR
End With
Exit For
End If
Next
'End If
End Sub
Now find this in Sub AttackNpc:
Code:
' Check for weapon
n = 0
If GetPlayerEquipmentSlot(Attacker, Weapon) > 0 Then
n = GetPlayerInvItemNum(Attacker, GetPlayerEquipmentSlot(Attacker, Weapon))
End If
Under add this:
Code:
SendBlood GetPlayerMap(Attacker), MapNpcNum, TARGET_TYPE_NPC
Find this in Sub AttackPlayer:
Code:
' reduce dur. on victims equipment
Call DamageEquipment(Victim, Armor)
Call DamageEquipment(Victim, Helmet)
Under add:
Code:
SendBlood GetPlayerMap(Victim), Victim, TARGET_TYPE_PLAYER
Find:
Code:
Do While ServerOnline
Tick = GetTickCountNew
Under add:
Code:
For x = 1 To MAX_MAPS
For y = 1 To UBound(TempMap(x).Blood)
If TempMap(x).Blood(y).Active Then
With TempMap(x).Blood(y)
If .Timer < GetTickCountNew Then
.Pic = 0
.x = 0
.y = 0
.Active = False
SendDataToMap x, SBloodSplatter & SEP_CHAR & y & SEP_CHAR & .Active & SEP_CHAR & .x & SEP_CHAR & .y & SEP_CHAR & .Pic & END_CHAR
End If
End With
End If
Next
Next
And now ~.............
CLIENT-SIDE
[spoiler]First thing, add this to the bottom of the "Public Enum ServerPackets":
Code:
SBloodSplatter
Now add this in modTypes:
Code:
Public Blood(1 To 50) As BloodRec
Type BloodRec
Active As Boolean
X As Long
Y As Long
Pic As Long
End Type
At the top of modDirectDraw7 add this:
Code:
Public DDS_Blood As DirectDrawSurface7
Public DDSD_Blood As DDSURFACEDESC2
Then in Sub InitSurfaces add this:
Code:
InitDDSurf "blood", DDSD_Blood, DDS_Blood
Now add this sub to modDirectDraw or wherever:
Code:
Public Sub DrawBloods()
Dim LoopI As Long
Dim rec As DxVBLib.RECT
For LoopI = 1 To UBound(Blood)
If Blood(LoopI).Active Then
With Blood(LoopI)
rec = Get_RECT(.Pic * PIC_Y)
DDS_BackBuffer.BltFast .X, .Y, DDS_Blood, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY
End With
End If
Next
End Sub
Now find:
Code:
BltMapTiles
Under add:
Code:
If BloodHighIndex > 0 Then DrawBloods
Now at the bottom of modHandleData add:
Code:
Private Sub HandleBloodSplatter(ByRef Parse() As String)
If UBound(Parse) < 1 Then
Dim LoopI As Long
For LoopI = 1 To UBound(Blood)
ZeroMemory ByVal VarPtr(Blood(LoopI)), LenB(Blood(LoopI))
Next
Exit Sub
End If
If CBool(Parse(2)) = True Then
BloodHighIndex = BloodHighIndex + 1
If BloodHighIndex >= UBound(Blood) Then BloodHighIndex = UBound(Blood)
Else
BloodHighIndex = BloodHighIndex - 1
If BloodHighIndex < 1 Then BloodHighIndex = 0
End If
With Blood(Val(Parse(1)))
.Active = CBool(Parse(2))
.X = Val(Parse(3))
.Y = Val(Parse(4))
.Pic = Val(Parse(5))
End With
End Sub
Now find:
Code:
Select Case Parse(0)
Under add:
Code:
Case SBloodSplatter
HandleBloodSplatter Parse
Finally in modGlobals add this to the top:
Code:
Public BloodHighIndex As Long
And that SHOULD be it...I might have left something out...
-----------------------------------
Oh yeah, and in your gfx folder add this:
CREDITS GO TO BLODYAVENGER IF YOU USE.
STYLE IS FOR 16-BIT GAMES, LIKE FF1.
http://mayhem.auburnflame.com/blood.bmp
Customizing and explanations:
With that blood.bmp, there are 6 different bloods able to be selected. If you want to change that, simply change this line in server-side:
Code:
.Pic = Random(0, 5)
That randomly selects between 6 blood pictures.
If you want to control if blood disappears faster, change this in the server in Sub SendBlood:
Code:
.Timer = GetTickCountNew + 30000
That tells the server to get rid of the blood in 30 seconds.
If you want to make a chance the blood appears, get rid of the comment on the second line here in Sub SendBlood:
Code:
' 50% chance blood spawns
'If Random(1, 2) = 2 Then
THAT SHOULD BE ALL! I might have missed something. This was made on my engine made from MS4...so make sure you test with MS4 and post here, please.