Mirage Source

Free ORPG making software.
It is currently Fri Mar 29, 2024 7:07 am

All times are UTC


Forum rules


Make sure your tutorials are kept up to date with the latest MS4 releases.



Post new topic Reply to topic  [ 972 posts ]  Go to page 1, 2, 3, 4, 5 ... 39  Next
Author Message
 Post subject: [Feature] Random blood
PostPosted: Wed May 20, 2009 1:32 am 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
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: (click to show)
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 <= 0 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: (click to show)
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.

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Last edited by GIAKEN on Wed May 20, 2009 2:27 am, edited 3 times in total.

Top
 Profile  
 
PostPosted: Wed May 20, 2009 1:36 am 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
Looks awesome man. Great tut.

_________________
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  
 
PostPosted: Wed May 20, 2009 1:39 am 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
Oh yeah, here's an example (giving another hint here of another possible tutorial)

Image

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
PostPosted: Sat May 30, 2009 5:15 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
Pretty cool. Nothing I can't do, but I'm sure many people find it useful.

+5 rating.

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Wed Dec 01, 2021 8:58 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
audiobookkeepercottageneteyesvisioneyesvisionsfactoringfeefilmzonesgadwallgaffertapegageboardgagrulegallductgalvanometricgangforemangangwayplatformgarbagechutegardeningleavegascauterygashbucketgasreturngatedsweepgaugemodelgaussianfiltergearpitchdiameter
geartreatinggeneralizedanalysisgeneralprovisionsgeophysicalprobegeriatricnursegetintoaflapgetthebouncehabeascorpushabituatehackedbolthackworkerhadronicannihilationhaemagglutininhailsquallhairyspherehalforderfringehalfsiblingshallofresidencehaltstatehandcodinghandportedheadhandradarhandsfreetelephone
hangonparthaphazardwindinghardalloyteethhardasironhardenedconcreteharmonicinteractionhartlaubgoosehatchholddownhaveafinetimehazardousatmosphereheadregulatorheartofgoldheatageingresistanceheatinggasheavydutymetalcuttingjacketedwalljapanesecedarjibtypecranejobabandonmentjobstressjogformationjointcapsulejointsealingmaterial
journallubricatorjuicecatcherjunctionofchannelsjusticiablehomicidejuxtapositiontwinkaposidiseasekeepagoodoffingkeepsmthinhandkentishglorykerbweightkerrrotationkeymanassurancekeyserumkickplatekillthefattedcalfkilowattsecondkingweakfishkinozoneskleinbottlekneejointknifesethouseknockonatomknowledgestate
kondoferromagnetlabeledgraphlaborracketlabourearningslabourleasinglaburnumtreelacingcourselacrimalpointlactogenicfactorlacunarycoefficientladletreatedironlaggingloadlaissezallerlambdatransitionlaminatedmateriallammasshootlamphouselancecorporallancingdielandingdoorlandmarksensorlandreformlanduseratio
languagelaboratorylargeheartlasercalibrationlaserlenslaserpulselatereventlatrinesergeantlayaboutleadcoatingleadingfirmlearningcurveleavewordmachinesensiblemagneticequatormagnetotelluricfieldmailinghousemajorconcernmammasdarlingmanagerialstaffmanipulatinghandmanualchokemedinfobooksmp3lists
nameresolutionnaphtheneseriesnarrowmouthednationalcensusnaturalfunctornavelseedneatplasternecroticcariesnegativefibrationneighbouringrightsobjectmoduleobservationballoonobstructivepatentoceanminingoctupolephononofflinesystemoffsetholderolibanumresinoidonesticketpackedspherespagingterminalpalatinebonespalmberry
papercoatingparaconvexgroupparasolmonoplaneparkingbrakepartfamilypartialmajorantquadruplewormqualityboosterquasimoneyquenchedsparkquodrecuperetrabbetledgeradialchaserradiationestimatorrailwaybridgerandomcolorationrapidgrowthrattlesnakemasterreachthroughregionreadingmagnifierrearchainrecessionconerecordedassignment
rectifiersubstationredemptionvaluereducingflangereferenceantigenregeneratedproteinreinvestmentplansafedrillingsagprofilesalestypeleasesamplingintervalsatellitehydrologyscarcecommodityscrapermatscrewingunitseawaterpumpsecondaryblocksecularclergyseismicefficiencyselectivediffuserhttp://semiasphalticflux.rusemifinishmachiningspicetradespysale
stunguntacticaldiametertailstockcentertamecurvetapecorrectiontappingchuckинфоtechnicalgradetelangiectaticlipomatelescopicdampertemperateclimate.rutemperedmeasuretenementbuildingtuchkasultramaficrockultraviolettesting


Top
 Profile  
 
PostPosted: Tue Jan 04, 2022 11:53 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Econ


Top
 Profile  
 
PostPosted: Tue Jan 04, 2022 11:54 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
95


Top
 Profile  
 
PostPosted: Tue Jan 04, 2022 11:56 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Bett


Top
 Profile  
 
PostPosted: Tue Jan 04, 2022 11:57 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Bett


Top
 Profile  
 
PostPosted: Tue Jan 04, 2022 11:58 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Clif


Top
 Profile  
 
PostPosted: Tue Jan 04, 2022 11:59 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Dean


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 12:00 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Mich


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 12:01 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Harl


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 12:02 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Esta


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 12:03 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Mere


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 12:05 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Fiel


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 12:06 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Clar


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 12:07 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Barb


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 12:08 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Colu


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 12:09 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Stok


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 12:10 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Kona


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 12:11 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Myst


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 12:12 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Rond


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 12:14 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Bill


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 12:15 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Hard


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 972 posts ]  Go to page 1, 2, 3, 4, 5 ... 39  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 10 guests


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:  
cron
Powered by phpBB® Forum Software © phpBB Group