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

Alpha Blending Npcs in 2.0 or 2.3


Guest
 Share

Recommended Posts

download link

[http://www.freemmorpgmaker.com/files/imagehost/pics/e7af871755961eafa51c68ceea14fb42.rar](http://www.freemmorpgmaker.com/files/imagehost/pics/e7af871755961eafa51c68ceea14fb42.rar)

if any credit is due anywhere it goes to robin.

In this tut you will be able to make your npcs alpha blend and turn it on and off. you can just as easily change it to work with players, or anything else for that matter. even alphaed paperdolls. i will cover a few of the things you can easily change to make this work for you.

**ALL Client Side.**

add the attached **alphablend.dll** to your **client directory**

add the attached **alphablend module** to your **client**

at the bottom of **frmmain** add

```

Private Sub optAlphaff_Click()

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

Options.alpha = 0

' save to config.ini

SaveOptions

' Error handler

Exit Sub

errorhandler:

HandleError "optMOff_Click", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Private Sub optAlphaOn_Click()

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

Options.alpha = 1

' save to config.ini

SaveOptions

' Error handler

Exit Sub

errorhandler:

HandleError "optMOff_Click", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

```

in **frmmain** add a lablel and set its caption to **Alpha Blending**

in **frmmain** add a option box to the option window named **optAlphaOn**

in **frmmain** add a option box to the option window named optAlphaff

open your **config.ini** file and add **alpha= 1** to the list

search for **Private Type OptionsRec**

below

```

Sound As Byte

```
add

```

alpha as byte

```

search for **Call PutVar(fileName, "Options", "Sound", str(Options.Sound))**

below it add

```

Call PutVar(fileName, "Options", "Alpha", str(Options.alpha))

```

search for **Options.Sound = GetVar(fileName, "Options", "Sound")**

below it add

```

Options.alpha = GetVar(fileName, "Options", "Alpha")

```

at the bottom of **Public Sub LoadOptions()**

add

```

If Options.alpha = 0 Then

frmMain.optAlphaff.Value = True

Else

frmMain.optAlphaOn.Value = True

End If

```

search for **Public Sub BltNpc(ByVal MapNpcNum As Long)**

and change it to

```

Public Sub BltNpc(ByVal MapNpcNum As Long, alpha As Boolean)

```

then directly below the other dims in **sub bltnpc** add

```

Dim aDC, bDC As Long

```

now find this bit further down the same sub….**sub bltnpc**

```

' Proceed as normal

y = MapNpc(MapNpcNum).y * PIC_Y + MapNpc(MapNpcNum).YOffset

End If

```

directly below that code add this

```

' render the actual sprite in alpha blend

If alpha = True Then

If Sprite = 146 Then

aDC = DDS_BackBuffer.GetDC

bDC = DDS_Character(Sprite).GetDC

If Options.alpha = 1 Then

FoxAlphaBlend aDC, ConvertMapX(x), ConvertMapY(y), 32, 32, bDC, rec.Left, rec.top, 100, RGB(255, 0, 255), 1

Else

Options.alpha = 0

FoxAlphaBlend aDC, ConvertMapX(x), ConvertMapY(y), 32, 32, bDC, rec.Left, rec.top, 255, RGB(255, 0, 255), 1

End If

DDS_BackBuffer.ReleaseDC aDC

DDS_Character(Sprite).ReleaseDC bDC

Else

Call BltSprite(Sprite, x, y, rec)

End If

End If

```
at the bottom comment out or delete this line

```

Call BltSprite(Sprite, x, y, rec)

```

next find this bit of code in **moddirectdraw7**

```

' Npcs

For i = 1 To Npc_HighIndex

If MapNpc(i).y = y Then

Call BltNpc(i)

End If

Next

```

change to this

```

' Npcs

For i = 1 To Npc_HighIndex

If MapNpc(i).y = y Then

Call BltNpc(i, True)

End If

Next

```

ok thats it. now on to the explaining bits.

```

'render the actual sprite in alpha blend

If alpha = True Then

'this here can be replaced by a case select if you wanted, in this case i set my ghost to sprite number 146 via the npc editor. so if its that sprite, it will be alpha blended.

If Sprite = 146 Then

aDC = DDS_BackBuffer.GetDC

bDC = DDS_Character(Sprite).GetDC

If Options.alpha = 1 Then

'these 32, 32 numbers are the sprites frame size, set it to your sprites frames size, a player sprite is 32, 48 standard i belive.

' the 100 in this line is the level of alpha being applied. in the latter its 255\. 255 = max

FoxAlphaBlend aDC, ConvertMapX(x), ConvertMapY(y), 32, 32, bDC, rec.Left, rec.top, 100, RGB(255, 0, 255), 1

Else

Options.alpha = 0

' the rgb stuff is the color used for the alpha blending, its set to the stock purple magenta color that eo sprites are backed against.

FoxAlphaBlend aDC, ConvertMapX(x), ConvertMapY(y), 32, 32, bDC, rec.Left, rec.top, 255, RGB(255, 0, 255), 1

End If

DDS_BackBuffer.ReleaseDC aDC

DDS_Character(Sprite).ReleaseDC bDC

Else

'down here we do the normal calling of the sprite.

Call BltSprite(Sprite, x, y, rec)

End If

End If

```
Link to comment
Share on other sites

> Why you maked it as ON/OFF value, why you do not saved it as value from 0 to 255 and then make scrollbar for setting it in NPC editor and then read from it and not just check if its highter than 0 then alphablend it at specific value

im sure you could. why dont you post your edit?
Link to comment
Share on other sites

I made a quick edit that only requires one check box.

Delete the label, **optAlphaOn**, and **optAlphaff**.

Add one check box, name it chkAlpha.

Replace the frmMain code with:

```
Private Sub chkAlpha_Click()

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

Options.alpha = 0

' save to config.ini

SaveOptions

' Error handler

Exit Sub

errorhandler:

HandleError "optMOff_Click", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub
```

At the bottom of **Public Sub LoadOptions()**, replace

```
If Options.alpha = 0 Then

frmMain.optAlphaff.Value = True

Else

frmMain.optAlphaOn.Value = True

End If
```
with

```
frmMain.optAlphaff.Value = Options.alpha = 0
```

Done.
Link to comment
Share on other sites

  • 2 years later...

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...