[DX8] Item RGBA Settings

FireBlade97 requested this via PM and since it’s been a long time since I wrote a tutorial, I thought why not?

After you add this you’ll have control over how items in game look by tweaking the colour of the texture. So let’s get started.

Note: I’ve used Eclipse Worlds for writing this source but this should work on any DX8 engine. 
Note2: This tutorial is not noob friendly at the end. I suggest you have basic understanding of VB6 and certain terminologies like what methods are.

EDITORS

Open up the item editor form a make something like this: 

Properties:

Leave the Frame properties as it is. Change the frame caption to Colour if you want.

Label 1

Name: lblRed

Caption: Red: 255

Label 2

Name: lblBlue

Caption: Blue: 255

Label 3

Name: lblGreen

Caption: Green: 255

Label 4

Name: lblAlpha

Caption: Alpha: 255

HScroll 1

Name: scrlRed

HScroll 2

Name: scrlBlue

HScroll 3

Name: scrlGreen

HScroll 4

Name: scrlAlpha

Now open up the source code of the Editors and paste the following at the end

Private Sub scrlRed_Change()
    If EditorIndex < 1 Or EditorIndex > MAX_ITEMS Then Exit Sub

    Item(EditorIndex).Red = scrlRed.Value
    lblRed.Caption = "Red: " & scrlRed.Value
End Sub

Private Sub scrlBlue_Change()
    If EditorIndex < 1 Or EditorIndex > MAX_ITEMS Then Exit Sub

    Item(EditorIndex).Blue = scrlBlue.Value
    lblBlue.Caption = "Blue: " & scrlBlue.Value
End Sub

Private Sub scrlGreen_Change()
    If EditorIndex < 1 Or EditorIndex > MAX_ITEMS Then Exit Sub

    Item(EditorIndex).Green = scrlGreen.Value
    lblGreen.Caption = "Green: " & scrlGreen.Value

End Sub

Private Sub scrlAlpha_Change()
    If EditorIndex < 1 Or EditorIndex > MAX_ITEMS Then Exit Sub

    Item(EditorIndex).Alpha = scrlAlpha.Value
    lblAlpha.Caption = "Alpha: " & scrlAlpha.Value

End Sub

modGameEditor:

Find **ItemEditorInit **and before the end with add in this:

        frmEditor_Item.scrlRed = .Red
        frmEditor_Item.scrlBlue = .Blue
        frmEditor_Item.scrlGreen = .Green
        frmEditor_Item.scrlAlpha = .Alpha

modTypes:

This part is common for both client and server. Open up modTypes and find ItemRec. Before End Type add the following:

    Red As Byte
    Blue As Byte
    Green As Byte
    Alpha As Byte

modRendering:

Find RenderTextureByRects method in modRendering

Add this to the end of the method declaration

Optional ByVal Red As Long = 255, Optional ByVal Green As Long = 255, Optional ByVal Blue = 255, Optional ByVal Alpha As Long = 255

Add this to the end of the RenderTexture call

D3DColorRGBA(Red, Green, Blue, Alpha) 

Find the **EditorItem_DrawItem **method in modRendering

Find the RenderTextureByRects call in this method

Add this to the end:

frmEditor_Item.scrlRed.Value, frmEditor_Item.scrlBlue.Value, frmEditor_Item.scrlGreen.Value, frmEditor_Item.scrlAlpha.Value

Now this part changes per change so I’ll provide you with the code and help you figure out. You’ll have to add in the code yourself.

Wherever there items are being drawn in game, declare the following variables.

Dim R As Long, G As Long, B As Long, A As Long

After this check

ItemNum = GetPlayerInvItemNum(MyIndex, i)

If ItemNum > 0 And ItemNum <= MAX_ITEMS Then

Add the following

R = Item(ItemNum).Red
G = Item(ItemNum).Green
B = Item(ItemNum).Blue
A = Item(ItemNum).Alpha

Now find the call to the RenderTexture method (It can be just RenderTexture for rendering dropped items or RenderTextureByRects for inventory or it may all just be RenderTexture)

Add this to the end of the call:

R, G, B, A

And it should work. Depending upon how stupid your request of help is I’ll help you. If it’s very stupid then I won’t. Ask someone else.

Here are a few methods that render items. I’m not sure if there are more but search for them. (Search for Tex_Item and in modRendering and you’ll find the methods)

DrawMapItem

DrawHotbar

DrawInventory

DrawAnimatedItem

DrawDraggedItem

DrawBank

DrawBankItem

NOTE: For DrawMapItem use this code to set the r,g,b,a rather than using the above mentioned code:

R = Item(MapItem(ItemNum).num).Red
G = Item(MapItem(ItemNum).num).Green
B = Item(MapItem(ItemNum).num).Blue
A = Item(MapItem(ItemNum).num).Alpha

if the color and alpha are only 0 to 255 why don’t you use a byte for that ?

,…,<>" data-cid=“929736” data-time=“1413631600”>

if the color and alpha are only 0 to 255 why don’t you use a byte for that ?

Because that makes too much sense, and sense in eclipse is something we don’t do.

,…,<>" data-cid=“929736” data-time=“1413631600”>

if the color and alpha are only 0 to 255 why don’t you use a byte for that ?

Nice observation. I normally use a long without much thinking so yea… Editing the OP

Wherever there items are being drawn in game, declare the following variables.

Dim R As Long, G As Long, B As Long, A As Long

might want to change these to Byte too  😛

,…,<>" data-cid=“929746” data-time=“1413655184”>

might want to change these to Byte too  😛

meh. It won’t cause any memory problems. They’ll eventually be disposed.

Sorry for the double post. Had to do it

Updated the tutorial. I missed code in ItemEditorInit in modGameEditors. Scroll to the top and find the section called modGameEditors and add in that code.

Log in to reply